Skip to content

Commit

Permalink
Merge branch 'release/0.14.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
pmlopes committed Feb 5, 2021
2 parents eeadd05 + 12c1637 commit 0af64fc
Show file tree
Hide file tree
Showing 96 changed files with 336 additions and 237 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.14.1] - 2021-02-05
* Bumped vert.x to 4.0.2
* Bumped vert.x to 4.0.1
* Avoided deprecated API
* Bumped graalvm to 20.3.1 (LTS)
* Several TSC fixes for missing (non annotated API)
* Error messages updated to be easier to follow
* Silent install should not take other commands arguments
* Fix wrong guard on install command

## [0.14.0] - 2020-12-09
* Started paving the way for the `install` command to allow other target than `node_modules`
* Implemented the official `import-map` spec to map url based modules
Expand Down
4 changes: 2 additions & 2 deletions codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<parent>
<groupId>io.reactiverse</groupId>
<artifactId>es4x-parent</artifactId>
<version>0.14.0</version>
<version>0.14.1</version>
<relativePath>..</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<artifactId>es4x-codegen</artifactId>
<version>0.14.0</version>
<version>0.14.1</version>

<properties>
<tools.jar>${java.home}/../lib/tools.jar</tools.jar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.vertx.codegen.*;
import io.vertx.codegen.type.*;
import io.vertx.core.json.JsonObject;

import java.io.PrintWriter;
import java.io.StringWriter;
Expand Down Expand Up @@ -75,6 +76,12 @@ public String render(ClassModel model, int index, int size, Map<String, Object>

boolean imports = false;

JsonObject includes = getIncludes(type.getSimpleName());

if (includes.containsKey("import<d.ts>")) {
writer.printf("%s\n", includes.getString("import<d.ts>"));
}

@SuppressWarnings("unchecked")
Map<String, String> aliasMap = (Map<String, String>) session.computeIfAbsent("aliasMap", (a) -> new HashMap<String, String>());
for (ApiTypeInfo referencedType : model.getReferencedTypes()) {
Expand Down Expand Up @@ -186,6 +193,11 @@ public String render(ClassModel model, int index, int size, Map<String, Object>
boolean moreMethods = false;
boolean hasStaticMethodsInInterface = false;

// need to redeclare the parent static methods or else TSC will complain that the extension is not correct
if (includes.containsKey("d.ts")) {
writer.printf("%s\n", includes.getString("d.ts"));
}

for (MethodInfo method : model.getMethods()) {
if (isExcluded(type.getSimpleName(), method.getName(), method.getParams())) {
continue;
Expand Down Expand Up @@ -242,6 +254,12 @@ public String render(ClassModel model, int index, int size, Map<String, Object>
}

moreMethods = false;

// need to redeclare the parent static methods or else TSC will complain that the extension is not correct
if (includes.containsKey("d.ts")) {
writer.printf("%s\n", includes.getString("d.ts"));
}

for (MethodInfo method : model.getMethods()) {
if (isExcluded(type.getSimpleName(), method.getName(), method.getParams())) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void generateJS(PrintWriter writer, String fqcn) {
return;
}

writer.printf(" %s: Java.type('%s')", getSimpleName(clazz), clazz.getName());
writer.printf(" %s: Java.type('%s'),\n", getSimpleName(clazz), clazz.getName());
}

public static void generateMJS(PrintWriter writer, String fqcn) {
Expand All @@ -40,7 +40,7 @@ public static void generateMJS(PrintWriter writer, String fqcn) {
return;
}

writer.printf("export const %s = Java.type('%s');", getSimpleName(clazz), clazz.getName());
writer.printf("export const %s = Java.type('%s');\n", getSimpleName(clazz), clazz.getName());
}

public static void generateDTS(PrintWriter writer, String fqcn) {
Expand All @@ -54,7 +54,26 @@ public static void generateDTS(PrintWriter writer, String fqcn) {
return;
}

writer.printf("/** Auto-generated from %s %s extends %s\n", Modifier.toString(clazz.getModifiers()), clazz.getName(), clazz.getSuperclass() != null ? clazz.getSuperclass().getName() : "");
boolean isInterface = clazz.isInterface();
boolean isAbstract = !clazz.isInterface() && Modifier.isAbstract(clazz.getModifiers());

// verify if we need to "change" from interface to abstract class, this is needed when "static" methods exist
// on interfaces
if (isInterface) {
// Get the metadata or information of all the methods of the class using getDeclaredMethods()
for (Method method : clazz.getMethods()) {
if (isExcluded(getSimpleName(clazz), method.getName(), Arrays.asList(method.getParameterTypes()))) {
continue;
}
if (Modifier.isPublic(method.getModifiers()) && Modifier.isStatic(method.getModifiers())) {
isInterface = false;
isAbstract = true;
break;
}
}
}

writer.printf("/** Auto-generated from %s %s %s %s\n", Modifier.toString(clazz.getModifiers()), clazz.getName(), clazz.isInterface() ? "" : "extends", clazz.getSuperclass() != null ? clazz.getSuperclass().getName() : "");
// Get the list of implemented interfaces in the form of Class array using getInterface() method
Class<?>[] clazzInterfaces = clazz.getInterfaces();
for (Class<?> c : clazzInterfaces) {
Expand All @@ -64,7 +83,7 @@ public static void generateDTS(PrintWriter writer, String fqcn) {
writer.println(" * @deprecated");
}
writer.println(" */");
writer.printf("export %s%s %s {\n", !clazz.isInterface() && Modifier.isAbstract(clazz.getModifiers()) ? "abstract " : "", clazz.isInterface() ? "interface" : "class", getSimpleName(clazz));
writer.printf("export %s%s %s {\n", isAbstract ? "abstract " : "", isInterface ? "interface" : "class", getSimpleName(clazz));
writer.println();

// Get the metadata of all the fields of the class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ public String render(DataObjectModel model, int index, int size, Map<String, Obj

if (index == 0) {
Util.generateLicense(writer);
registerJvmClasses();
for (Object fqcn : jvmClasses("dataObject")) {
JVMClass.generateJS(writer, fqcn.toString());
}

writer.printf("/// <reference types=\"%s/options\" />\n\n", getNPMScope(model.getType().getRaw().getModule()));
writer.printf(
"/**\n" +
" * @typedef { import(\"@vertx/core\") } Java\n" +
" */\n");
writer.print("module.exports = {\n");
registerJvmClasses();
for (Object fqcn : jvmClasses("dataObject")) {
JVMClass.generateJS(writer, fqcn.toString());
}
}

writer.printf(" %s: Java.type('%s')", model.getType().getRaw().getSimpleName(), model.getType().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ public String render(DataObjectModel model, int index, int size, Map<String, Obj

if (index == 0) {
Util.generateLicense(writer);
registerJvmClasses();
for (Object fqcn : jvmClasses("dataObject")) {
JVMClass.generateMJS(writer, fqcn.toString());
}

writer.printf("/// <reference types=\"%s/options\" />\n\n", getNPMScope(model.getType().getRaw().getModule()));
writer.printf(
"/**\n" +
" * @typedef { import(\"@vertx/core\") } Java\n" +
" */\n");

registerJvmClasses();
for (Object fqcn : jvmClasses("dataObject")) {
JVMClass.generateMJS(writer, fqcn.toString());
}
}

writer.printf("export const %s = Java.type('%s');\n", model.getType().getRaw().getSimpleName(), model.getType().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private Util() {

private final static Map<String, JsonObject> OVERRIDES = new HashMap<>();
private final static Map<String, JsonObject> EXCLUDES = new HashMap<>();
private final static Map<String, JsonObject> INCLUDES = new HashMap<>();

private final static JsonArray OPTIONAL_DEPENDENCIES;
private final static JsonArray CLASS_EXCLUSIONS;
Expand Down Expand Up @@ -531,6 +532,22 @@ private static JsonObject getExclude(String type) {
return excludes;
}

public static JsonObject getIncludes(String type) {
JsonObject includes = INCLUDES.get(type);

if (includes == null) {
String raw = includeFileIfPresent(type + ".includes.json");
if (raw.equals("")) {
includes = new JsonObject();
} else {
includes = new JsonObject(raw);
}
INCLUDES.put(type, includes);
}

return includes;
}

public static String getOverrideArgs(String type, String method) {
JsonObject overrides = getOverride(type);

Expand Down
4 changes: 2 additions & 2 deletions es4x/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<parent>
<groupId>io.reactiverse</groupId>
<artifactId>es4x-parent</artifactId>
<version>0.14.0</version>
<version>0.14.1</version>
<relativePath>..</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<artifactId>es4x</artifactId>
<version>0.14.0</version>
<version>0.14.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
14 changes: 12 additions & 2 deletions es4x/src/main/java/io/reactiverse/es4x/ES4X.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,23 @@ public static void main(String... args) {

if (isFileOrDir) {
// we will assume a js command
launcher.execute("run", args);
try {
launcher.execute("run", args);
} catch (NoClassDefFoundError e) {
System.err.println("'node_modules' jars missing and/or wrong versions. Removing 'node_modules' may solve the problem.");
System.exit(1);
}
return;
}
}

// default behavior
launcher.dispatch(args);
try {
launcher.dispatch(args);
} catch (NoClassDefFoundError e) {
System.err.println("'node_modules' jars missing and/or wrong versions. Removing 'node_modules' may solve the problem.");
System.exit(1);
}
}

private static void processProperty(String name, String defaultEmpty, Consumer<String> consumer) {
Expand Down
3 changes: 3 additions & 0 deletions es4x/src/main/java/io/reactiverse/es4x/ESVerticleFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import io.vertx.core.Promise;
import io.vertx.core.Verticle;
import io.vertx.core.Vertx;
import io.vertx.core.impl.logging.Logger;
import io.vertx.core.impl.logging.LoggerFactory;
import io.vertx.core.spi.VerticleFactory;
import org.graalvm.polyglot.Source;
import org.graalvm.polyglot.Value;
Expand All @@ -38,6 +40,7 @@
*/
public abstract class ESVerticleFactory implements VerticleFactory {

protected static final Logger LOGGER = LoggerFactory.getLogger(ESVerticleFactory.class);
protected ECMAEngine engine;

@Override
Expand Down
4 changes: 2 additions & 2 deletions es4x/src/main/java/io/reactiverse/es4x/impl/ESModuleIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.file.FileSystem;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.core.impl.logging.Logger;
import io.vertx.core.impl.logging.LoggerFactory;

import java.io.IOException;
import java.net.URI;
Expand Down
7 changes: 3 additions & 4 deletions examples/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@es4x/create": "latest",
"@vertx/unit": "latest"
"@es4x/create": "0.14.0",
"@vertx/unit": "4.0.0"
},
"dependencies": {
"@vertx/core": "latest"
"@vertx/core": "4.0.0"
},
"scripts": {
"postinstall": "es4x install",
"start": "es4x",
"test": "es4x test index.test.js"
}
Expand Down
4 changes: 2 additions & 2 deletions generator/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ set -e
# build
if [ "$1" = "publish-local" ]; then
REGISTRY="http://localhost:4873"
TAG=${2:-release}
TAG=${2:-latest}
npm adduser --registry "$REGISTRY"
mvn -fae -Pio.vertx,io.reactiverse -Dnpm-registry="$REGISTRY" -Dnpm-tag=${TAG} clean generate-sources install exec:exec@npm-publish | tee build-$1.log
elif [ "$1" = "publish" ]; then
REGISTRY="https://registry.npmjs.org"
TAG=${2:-release}
TAG=${2:-latest}

echo "login as vertx"
npm adduser --registry "$REGISTRY"
Expand Down
6 changes: 3 additions & 3 deletions generator/io.reactiverse/elasticsearch-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
<parent>
<groupId>io.reactiverse.es4x</groupId>
<artifactId>es4x-generator</artifactId>
<version>0.14.0</version>
<version>0.14.1</version>
<relativePath>../..</relativePath>
</parent>

<artifactId>elasticsearch-client</artifactId>
<version>0.14.0</version>
<version>0.14.1</version>

<packaging>jar</packaging>

<properties>
<maven.groupId>io.reactiverse</maven.groupId>
<npm-name>@reactiverse/elasticsearch-client</npm-name>
<npm-version>0.8.3-ec7.8.0</npm-version>
<npm-version>0.8.4-ec7.10.1</npm-version>
<npm-skip>false</npm-skip>
<!-- language=json -->
<npm-dependencies>
Expand Down
Loading

0 comments on commit 0af64fc

Please sign in to comment.