diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 16398f89..89a77a79 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -81,8 +81,8 @@ jobs: with: apps: sbt - - name: cli-js build - run: sbt "cliJS/fastOptJS" + - name: aqua-api build + run: sbt "aqua-apiJS/fastOptJS" - name: Setup pnpm uses: pnpm/action-setup@v2.4.0 @@ -108,10 +108,6 @@ jobs: - run: pnpm install --no-frozen-lockfile working-directory: integration-tests - - name: Build cli - run: pnpm run build - working-directory: cli/cli-npm - - name: Compile aqua run: pnpm run compile-aqua working-directory: integration-tests diff --git a/integration-tests/package.json b/integration-tests/package.json index b24e16d8..5704a2d0 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -22,14 +22,15 @@ "pubsub": "node -r ts-node/register src/pubsub.ts", "exec": "npm run compile-aqua && npm run prettify-compiled && node -r ts-node/register src/index.ts", "run": "node -r ts-node/register src/index.ts", - "compile-aqua": "aqua -i ./aqua/ -o ./src/compiled", + "compile-aqua": "ts-node ./src/compile.ts", "compile-aqua:air": "aqua -i ./aqua/ -o ./compiled-air -a", "prettify-compiled": "prettier --write src/compiled", "aqua": "aqua", "do": "aqua dist deploy --addr /dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi --config-path deploy.json --service tsOracle" }, + "prettier": {}, "devDependencies": { - "@fluencelabs/aqua": "0.12.1", + "@fluencelabs/aqua-api": "0.12.1", "@fluencelabs/aqua-dht": "0.2.5", "@fluencelabs/aqua-lib": "0.7.3", "@types/jest": "29.5.2", diff --git a/integration-tests/src/compile.ts b/integration-tests/src/compile.ts new file mode 100644 index 00000000..dab03c7a --- /dev/null +++ b/integration-tests/src/compile.ts @@ -0,0 +1,32 @@ +import { compileFromPath } from "@fluencelabs/aqua-api"; +import { mkdir, writeFile } from "node:fs/promises"; +import { resolve, parse, format, dirname } from "node:path"; + +const inputPath = resolve("./aqua"); + +const result = await compileFromPath({ + filePath: "aqua", + imports: ["node_modules"], + targetType: "ts", +}); + +const outputPath = resolve("./src/compiled"); +await mkdir(outputPath, { recursive: true }); + +if (result.errors.length > 0) { + throw new Error(result.errors.join("\n")); +} + +await Promise.all( + result.generatedSources.map(async (src) => { + const outFilePath = resolve(src.name).replace(inputPath, outputPath); + const outputTsPath = format({ + ...parse(outFilePath), + base: "", + ext: ".ts", + }); + + await mkdir(dirname(outputTsPath), { recursive: true }); + await writeFile(outputTsPath, src.tsSource); + }), +); diff --git a/integration-tests/tsconfig.json b/integration-tests/tsconfig.json index 2ac511f0..c8e8df68 100644 --- a/integration-tests/tsconfig.json +++ b/integration-tests/tsconfig.json @@ -18,5 +18,8 @@ "dist", "bundle" ], - "include": ["src/**/*"] + "include": ["src/**/*"], + "ts-node": { + "esm": true + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4504b5ed..736cb01b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,9 +64,9 @@ importers: specifier: 1.8.1 version: 1.8.1 devDependencies: - '@fluencelabs/aqua': + '@fluencelabs/aqua-api': specifier: 0.12.1 - version: link:../cli/cli-npm + version: link:../api/api-npm '@fluencelabs/aqua-dht': specifier: 0.2.5 version: 0.2.5