Skip to content

Commit

Permalink
Use .js file in aqua command by default (#278)
Browse files Browse the repository at this point in the history
* move to `aqua` and `aqua-j`

* more updates

* update readme

* aqua-cli -> aqua

* don't publish aqua as aqua-cli

* update scala

Co-authored-by: Dmitry Kurinskiy <[email protected]>
  • Loading branch information
DieMyst and alari authored Sep 8, 2021
1 parent 3e1618c commit 7556db0
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 45 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val dottyVersion = "3.0.1"
val dottyVersion = "3.0.2"

scalaVersion := dottyVersion

Expand Down Expand Up @@ -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(
)
)
Expand Down
5 changes: 5 additions & 0 deletions npm/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

"use strict";

console.error("ERROR: use 'aqua' command!")
11 changes: 6 additions & 5 deletions npm/index-experimental.js → npm/index-java.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 5 additions & 6 deletions npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 8 additions & 6 deletions npm/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
10 changes: 4 additions & 6 deletions npm/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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`
Expand Down

0 comments on commit 7556db0

Please sign in to comment.