From 076495a59504064f505d9d44593dc488098e0fdc Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Wed, 22 Nov 2023 00:55:22 +0100 Subject: [PATCH] feat: add --no-wasm option to build command --- CHANGELOG.md | 6 ++++++ packages/cli/README.md | 4 ++++ packages/cli/lang/en.json | 1 + packages/cli/lang/es.json | 1 + .../cli/src/__tests__/e2e/p2/build.wasm.spec.ts | 3 ++- packages/cli/src/commands/build.ts | 6 +++++- .../wasm/assemblyscript/017-no-wasm/cmd.json | 3 +++ .../017-no-wasm/expected/output.json | 3 +++ .../017-no-wasm/expected/stdout.json | 6 ++++++ .../wasm/assemblyscript/017-no-wasm/package.json | 15 +++++++++++++++ .../017-no-wasm/polywrap.build.yaml | 9 +++++++++ .../wasm/assemblyscript/017-no-wasm/polywrap.yaml | 9 +++++++++ .../wasm/assemblyscript/017-no-wasm/src/index.ts | 7 +++++++ .../assemblyscript/017-no-wasm/src/schema.graphql | 5 +++++ 14 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/cmd.json create mode 100644 packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/expected/output.json create mode 100644 packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/expected/stdout.json create mode 100644 packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/package.json create mode 100644 packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/polywrap.build.yaml create mode 100644 packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/polywrap.yaml create mode 100644 packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/src/index.ts create mode 100644 packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/src/schema.graphql diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bf8465be5..3336dc3349 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Polywrap Origin (0.12.2) +## Features +**`polywrap` CLI:** +* [PR-...](https://github.com/polywrap/cli/pull/...) **Add `--no-wasm` Option To `polywrap build`** + * `build` command now supports the `--no-wasm` option, which disables the wasm compilation step when compiling projects. + # Polywrap Origin (0.12.1) ## Features **`polywrap` CLI:** diff --git a/packages/cli/README.md b/packages/cli/README.md index b1fbb16d80..c59bd5dfd8 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -104,6 +104,10 @@ Currently, `build` can be run for Wasm, Plugin and Interface projects. Skip codegen before building. By default, `build` performs a `codegen` step before building your Project. This option skips this step. +- `--no-wasm` + Skip wasm compilation. + By default, `build` performs wasm compilation. This option skips this step. + - `-s, --strategy ` Specify which build strategy to use. By default, the `vm` build strategy is used. Available strategies: diff --git a/packages/cli/lang/en.json b/packages/cli/lang/en.json index ad9f18c82a..e9324f7da7 100644 --- a/packages/cli/lang/en.json +++ b/packages/cli/lang/en.json @@ -21,6 +21,7 @@ "commands_build_options_options": "options", "commands_build_options_t": "Use the development server's ENS instance", "commands_build_options_codegen": "Skip code generation before build", + "commands_build_options_no_wasm": "Skip wasm compilation", "commands_build_options_codegen_dir": "Codegen output directory (default: {default})", "commands_build_options_s": "Strategy to use for building the wrapper (default: {default})", "commands_build_options_s_strategy": "strategy", diff --git a/packages/cli/lang/es.json b/packages/cli/lang/es.json index ad9f18c82a..e9324f7da7 100644 --- a/packages/cli/lang/es.json +++ b/packages/cli/lang/es.json @@ -21,6 +21,7 @@ "commands_build_options_options": "options", "commands_build_options_t": "Use the development server's ENS instance", "commands_build_options_codegen": "Skip code generation before build", + "commands_build_options_no_wasm": "Skip wasm compilation", "commands_build_options_codegen_dir": "Codegen output directory (default: {default})", "commands_build_options_s": "Strategy to use for building the wrapper (default: {default})", "commands_build_options_s_strategy": "strategy", diff --git a/packages/cli/src/__tests__/e2e/p2/build.wasm.spec.ts b/packages/cli/src/__tests__/e2e/p2/build.wasm.spec.ts index 43d64f6526..8bd08c8281 100644 --- a/packages/cli/src/__tests__/e2e/p2/build.wasm.spec.ts +++ b/packages/cli/src/__tests__/e2e/p2/build.wasm.spec.ts @@ -24,6 +24,7 @@ Options: -c, --client-config Add custom configuration to the PolywrapClient -n, --no-codegen Skip code generation before build + --no-wasm Skip wasm compilation --codegen-dir Codegen output directory (default: ./src/wrap) --wrapper-envs Path to a JSON file containing wrapper @@ -265,7 +266,7 @@ describe("e2e tests for build command", () => { expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`); }); }) - + describe("test-cases", () => { for (let i = 0; i < testCases.length; i++) { const testCaseName = testCases[i]; diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts index d303991a02..907b7010ee 100644 --- a/packages/cli/src/commands/build.ts +++ b/packages/cli/src/commands/build.ts @@ -51,6 +51,7 @@ export interface BuildCommandOptions extends BaseCommandOptions { clientConfig: string | false; wrapperEnvs: string | false; noCodegen: boolean; + noWasm: boolean; codegenDir: string | false; watch: boolean; strategy: `${SupportedStrategies}`; @@ -80,6 +81,7 @@ export const build: Command = { `${intlMsg.commands_common_options_config()}` ) .option(`-n, --no-codegen`, `${intlMsg.commands_build_options_codegen()}`) + .option(`--no-wasm`, `${intlMsg.commands_build_options_no_wasm()}`) .option( `--codegen-dir`, `${intlMsg.commands_build_options_codegen_dir({ @@ -117,6 +119,7 @@ export const build: Command = { outputDir: parseDirOption(options.outputDir, defaultOutputDir), bindgen: options.bindgen || false, noCodegen: !options.codegen || false, + noWasm: !options.wasm || false, codegenDir: parseDirOptionNoDefault(options.codegenDir), strategy: options.strategy || defaultStrategy, watch: options.watch || false, @@ -174,6 +177,7 @@ async function run(options: Required) { bindgen, strategy, noCodegen, + noWasm, codegenDir, verbose, quiet, @@ -220,7 +224,7 @@ async function run(options: Required) { const isInterface = language === "interface"; - if (isInterface) { + if (isInterface || noWasm) { buildStrategy = new NoopBuildStrategy({ project: project as PolywrapProject, outputDir, diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/cmd.json b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/cmd.json new file mode 100644 index 0000000000..ea713fc43f --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/cmd.json @@ -0,0 +1,3 @@ +{ + "noWasm": true +} diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/expected/output.json b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/expected/output.json new file mode 100644 index 0000000000..8dc0b28594 --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/expected/output.json @@ -0,0 +1,3 @@ +[ + "wrap.info" +] \ No newline at end of file diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/expected/stdout.json b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/expected/stdout.json new file mode 100644 index 0000000000..22bc83fb95 --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/expected/stdout.json @@ -0,0 +1,6 @@ +{ + "stdout": [ + "WRAP manifest written in ./build" + ], + "exitCode": 0 +} diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/package.json b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/package.json new file mode 100644 index 0000000000..b42812c813 --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/package.json @@ -0,0 +1,15 @@ +{ + "name": "@polywrap/test-project", + "version": "0.1.0", + "license": "MIT", + "private": true, + "scripts": { + "build": "polywrap build" + }, + "dependencies": { + "@polywrap/wasm-as": "../../../../../../../wasm/as" + }, + "devDependencies": { + "assemblyscript": "0.19.23" + } +} diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/polywrap.build.yaml b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/polywrap.build.yaml new file mode 100644 index 0000000000..de1e44ebac --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/polywrap.build.yaml @@ -0,0 +1,9 @@ +format: 0.2.0 +strategies: + image: + node_version: "14.16.0" + include: + - ./package.json +linked_packages: + - name: "@polywrap/wasm-as" + path: ../../../../../../../wasm/as \ No newline at end of file diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/polywrap.yaml b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/polywrap.yaml new file mode 100644 index 0000000000..4461b4fad2 --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/polywrap.yaml @@ -0,0 +1,9 @@ +format: 0.5.0 +project: + name: test-project + type: wasm/assemblyscript +source: + module: ./src/index.ts + schema: ./src/schema.graphql +extensions: + build: ./polywrap.build.yaml \ No newline at end of file diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/src/index.ts b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/src/index.ts new file mode 100644 index 0000000000..96ded11d66 --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/src/index.ts @@ -0,0 +1,7 @@ +import { Args_method, ModuleBase } from "./wrap"; + +export class Module extends ModuleBase { + method(args: Args_method): string { + this fails to compile + } +} diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/src/schema.graphql b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/src/schema.graphql new file mode 100644 index 0000000000..325e224971 --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/017-no-wasm/src/schema.graphql @@ -0,0 +1,5 @@ +type Module { + method( + arg: String! + ): String! +}