Add JS build to package and to integration tests (#256)

This commit is contained in:
Dima 2021-08-31 12:20:22 +03:00 committed by GitHub
parent 5fd54b5656
commit bc461457da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 4 deletions

View File

@ -26,6 +26,11 @@ jobs:
env:
BUILD_NUMBER: ${{ github.run_number }}
- name: JS build
run: sbt cliJS/fullLinkJS
env:
BUILD_NUMBER: ${{ github.run_number }}
- name: Get project version
# In CI sbt appends a new line after its output, so we need `tail -n3 | head -n2` to get last two non-empty lines
run: |
@ -54,13 +59,21 @@ jobs:
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"
stat "$JS"
echo "JS=$JS" >> $GITHUB_ENV
### Publish to NPM registry
- uses: actions/setup-node@v1
with:
node-version: "14"
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: npm version ${{ env.VERSION }}
working-directory: ./npm
@ -121,6 +134,8 @@ jobs:
body: ${{ steps.github_release.outputs.changelog }}
draft: false
prerelease: false
files: ${{ env.JAR }}
files: |
${{ env.JAR }}
${{ env.JS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -56,3 +56,9 @@ jobs:
sbt "cli/run -i aqua-playground/aqua/examples -o aqua-playground/src/compiled/examples -m aqua-playground/node_modules -c \"uniqueConst = 1\" -c \"anotherConst = \\\"ab\\\"\""
cd aqua-playground
npm run examples
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 "uniqueConst = 1" -c "anotherConst = \"ab\""
cd aqua-playground
npm run examples

33
npm/index-experimental.js Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env node
"use strict";
const { exec } = require("child_process");
const path = require("path");
const fs = require('fs');
let importArgs = []
const nm = path.join("./", "node_modules")
if (fs.existsSync(nm) && fs.lstatSync(nm).isDirectory()) {
importArgs = ["-m", "node_modules"]
}
const args = [
"node",
path.join(__dirname, "aqua-cli-experimental.js"),
...importArgs,
...process.argv.slice(2),
];
const argsString = args.join(" ");
console.log("Aqua JS: " + argsString);
exec(argsString, (err, stdout, stderr) => {
console.error("Aqua JS: " + stderr);
console.log("Aqua JS: " + stdout);
if (err) {
process.exit(err.code);
}
});

View File

@ -3,9 +3,14 @@
"version": "0.0.0",
"description": "Aqua compiler",
"files": [
"aqua-cli.jar"
"aqua-cli.jar",
"aqua-cli-experimental.js",
"index-experimental.js"
],
"bin": "index.js",
"bin": {
"aqua": "index.js",
"aqua-js": "index-experimental.js"
},
"scripts": {},
"repository": {
"type": "git",