diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index efc417a4..8bb306e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,14 +55,14 @@ jobs: - name: Check .jar exists run: | - JAR="cli/.jvm/target/scala-3.0.1/aqua-cli-${{ env.VERSION }}.jar" + JAR="cli/.jvm/target/scala-3.0.2/aqua-${{ env.VERSION }}.jar" stat "$JAR" echo "JAR=$JAR" >> $GITHUB_ENV - name: Check .js exists run: | - JS="cli/.js/target/scala-3.0.1/cli-opt/aqua-cli-experimental-${{ env.VERSION }}.js" - mv cli/.js/target/scala-3.0.1/cli-opt/main.js "$JS" + JS="cli/.js/target/scala-3.0.2/cli-opt/aqua-${{ env.VERSION }}.js" + mv cli/.js/target/scala-3.0.2/cli-opt/main.js "$JS" stat "$JS" echo "JS=$JS" >> $GITHUB_ENV @@ -72,23 +72,14 @@ jobs: node-version: "15" registry-url: "https://registry.npmjs.org" - - run: cp ${{ env.JAR }} ./npm/aqua-cli.jar - - run: cp ${{ env.JS }} ./npm/aqua-cli-experimental.js + - run: cp ${{ env.JAR }} ./npm/aqua.jar + - run: cp ${{ env.JS }} ./npm/aqua.js - run: npm version ${{ env.VERSION }} working-directory: ./npm - - name: Publish to NPM as aqua-cli - run: npm publish --access public - working-directory: ./npm - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Publish to NPM as aqua - run: | - CONTENTS="$(jq '.name = "@fluencelabs/aqua"' package.json)" - echo "$CONTENTS" > package.json - npm publish --access public + run: npm publish --access public working-directory: ./npm env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test_branch.yml b/.github/workflows/test_branch.yml index 23a299e7..0777267a 100644 --- a/.github/workflows/test_branch.yml +++ b/.github/workflows/test_branch.yml @@ -60,6 +60,6 @@ jobs: cd .. sbt "cliJS/fastOptJS" rm -rf aqua-playground/src/compiled/examples/* - node cli/.js/target/scala-3.0.1/cli-fastopt.js -i aqua-playground/aqua/examples -o aqua-playground/src/compiled/examples -m aqua-playground/node_modules -c "UNIQUE_CONST = 1" -c "ANOTHER_CONST = \"ab\"" + node cli/.js/target/scala-3.0.2/cli-fastopt.js -i aqua-playground/aqua/examples -o aqua-playground/src/compiled/examples -m aqua-playground/node_modules -c "UNIQUE_CONST = 1" -c "ANOTHER_CONST = \"ab\"" cd aqua-playground npm run examples diff --git a/README.md b/README.md index 17cb757d..04544f38 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,20 @@ Please refer to [Aqua Book](https://doc.fluence.dev/aqua-book/) to learn how to ## Compiler CLI -To build the Aqua compiler, clone the repo & run `sbt cli/assembly`, -or simply download the latest JAR file from the [releases](https://github.com/fluencelabs/aqua/releases) page. +To build the Aqua compiler, clone the repo & run `sbt cliJS/fullLinkOpt` to build JavaScript file. File location: `cli/.js/target/scala-%scala-version%/cli-opt`. +Or `sbt cli/assembly` to build JAR file. File location: `cli/.jvm/target/scala-%scala-version%/` +Or simply download the latest JS or JAR file from the [releases](https://github.com/fluencelabs/aqua/releases) page. -It requires `java` to run Aqua compiler from the command line: +It requires `node` to run Aqua compiler in `.js` file from the command line: ```commandline -java -jar aqua-cli-%version_number%.jar -i path/to/input/dir -o path/to/output/dir +node aqua-%version_number%.js -i path/to/input/dir -o path/to/output/dir +``` + +It requires `java` to run Aqua compiler in `.jar` file from the command line: + +```commandline +java -jar aqua-%version_number%.jar -i path/to/input/dir -o path/to/output/dir ``` Input directory should contain files with `aqua` scripts. diff --git a/build.sbt b/build.sbt index 29c27c89..c9a1b680 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -val dottyVersion = "3.0.1" +val dottyVersion = "3.0.2" scalaVersion := dottyVersion @@ -64,7 +64,7 @@ lazy val cliJVM = cli.jvm .settings( Compile / run / mainClass := Some("aqua.AquaCli"), assembly / mainClass := Some("aqua.AquaCli"), - assembly / assemblyJarName := "aqua-cli-" + version.value + ".jar", + assembly / assemblyJarName := "aqua-" + version.value + ".jar", libraryDependencies ++= Seq( ) ) diff --git a/npm/error.js b/npm/error.js new file mode 100644 index 00000000..e46877a7 --- /dev/null +++ b/npm/error.js @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +"use strict"; + +console.error("ERROR: use 'aqua' command!") diff --git a/npm/index-experimental.js b/npm/index-java.js similarity index 73% rename from npm/index-experimental.js rename to npm/index-java.js index bfdef597..3b89e843 100644 --- a/npm/index-experimental.js +++ b/npm/index-java.js @@ -14,18 +14,19 @@ if (fs.existsSync(nm) && fs.lstatSync(nm).isDirectory()) { } const args = [ - "node", - path.join(__dirname, "aqua-cli-experimental.js"), + "java", + "-jar", + path.join(__dirname, "aqua.jar"), ...importArgs, ...process.argv.slice(2), ]; const argsString = args.join(" "); -console.log("Aqua JS: " + argsString); +console.log("Aqua Java " + argsString); exec(argsString, (err, stdout, stderr) => { - console.error("Aqua JS: " + stderr); - console.log("Aqua JS: " + stdout); + console.error("Aqua Java: " + stderr); + console.log("Aqua Java: " + stdout); if (err) { process.exit(err.code); diff --git a/npm/index.js b/npm/index.js index e87b9d10..30838559 100644 --- a/npm/index.js +++ b/npm/index.js @@ -14,19 +14,18 @@ if (fs.existsSync(nm) && fs.lstatSync(nm).isDirectory()) { } const args = [ - "java", - "-jar", - path.join(__dirname, "aqua-cli.jar"), + "node", + path.join(__dirname, "aqua.js"), ...importArgs, ...process.argv.slice(2), ]; const argsString = args.join(" "); -console.log(argsString); +console.log("Aqua JS: " + argsString); exec(argsString, (err, stdout, stderr) => { - console.error(stderr); - console.log(stdout); + console.error("Aqua JS: " + stderr); + console.log("Aqua JS: " + stdout); if (err) { process.exit(err.code); diff --git a/npm/package.json b/npm/package.json index af2734ee..f9f70a08 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,16 +1,18 @@ { - "name": "@fluencelabs/aqua-cli", + "name": "@fluencelabs/aqua", "version": "0.0.0", "description": "Aqua compiler", "files": [ - "aqua-cli.jar", - "aqua-cli-experimental.js", - "index-experimental.js" + "aqua.jar", + "aqua.js", + "index.js", + "index-java.js", + "error.js" ], "bin": { "aqua": "index.js", - "aqua-cli": "index.js", - "aqua-js": "index-experimental.js" + "aqua-cli": "error.js", + "aqua-j": "index-java.js" }, "scripts": {}, "repository": { diff --git a/npm/readme.md b/npm/readme.md index 56a8f38e..6c59cc04 100644 --- a/npm/readme.md +++ b/npm/readme.md @@ -8,18 +8,16 @@ or in parallel, forming a single-use coordination network. Aqua's runtime is heterogeneous: it includes browsers, servers, devices, all involved in solving a single task. Therefore, Aqua scripts are compiled into several targets at once, with AIR and Typescript as a default. -## aqua-cli +## aqua -The package contains a convenience `aqua-cli` wrapper for usage in npm-based projects. +The package contains a convenience `aqua` wrapper for usage in npm-based projects. ### usage -**Warning: the package requires java to be installed (it will call "java -jar ... ") ** - Get the latest package ```bash -npm i --save-dev @fluencelabs/aqua-cli +npm i --save-dev @fluencelabs/aqua ``` Create a directory for the source files: `.aqua` and for compiled files: `.ts` @@ -31,7 +29,7 @@ mkdir aqua compiled To compile files run: ```bash -npx aqua -i ./src/aqua/ -o ./src/compiled +aqua -i ./src/aqua/ -o ./src/compiled ``` Alternatively the compilation script can be put into scripts section of `package.json`