Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
## Breaking Changes
### Toolchain
**`polywrap` CLI:**
* [PR-1385](https://github.com/polywrap/toolchain/pull/1385) **Separate Build & Codegen Functionality**
* Running `polywrap build` no longer automatically generates code bindings (`codegen`). You need to either run `polywrap codegen` before running `polywrap build`, or run `polywrap build` with the `--codegen` flag.
* Running `polywrap codegen` in Plugin Projects will no longer output the WRAP ABI (`wrap.info`) file into a build folder. To output the WRAP ABI, you need to run `polywrap build` within your Plugin Project.
* [PR-1432](https://github.com/polywrap/toolchain/pull/1432) **Remove Legacy Polywrap Project Metadata**
* Remove the `polywrap.meta.yaml` manifest.
* [PR-1367](https://github.com/polywrap/toolchain/pull/1367) **Client Configuration Refactor**
Expand Down Expand Up @@ -1097,4 +1094,4 @@ generateBinding = (
* Fix typescript plugin template's package.json

# Web3API 0.0.1-prealpha.1
Pre-Alpha Initial Release
Pre-Alpha Initial Release
6 changes: 3 additions & 3 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ Currently, `build` can be run for Wasm, Plugin and Interface projects.
- `--wrapper-envs <envs-path>`
Configure wrapper environment values using the provided file.

- `--codegen`
Perform codegen before building.
By default, `build` doesn't perform a `codegen` step before building your Project. This option includes this step. This is especially useful when used in conjunction with the `--watch` option.
- `-n, --no-codegen`
Skip codegen before building.
By default, `build` performs a `codegen` step before building your Project. This option skips this step.

- `-s, --strategy <strategy>`
Specify which build strategy to use. By default, the `vm` build strategy is used.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"commands_build_options_o_path": "path",
"commands_build_options_options": "options",
"commands_build_options_t": "Use the development server's ENS instance",
"commands_build_options_codegen": "Perform code generation before build",
"commands_build_options_codegen": "Skip code generation before build",
"commands_build_options_codegen_dir": "Codegen output directory (default: {default})",
"commands_build_options_w": "Automatically rebuild when changes are made (default: false)",
"commands_build_options_s": "Strategy to use for building the wrapper (default: {default})",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"commands_build_options_o_path": "path",
"commands_build_options_options": "options",
"commands_build_options_t": "Use the development server's ENS instance",
"commands_build_options_codegen": "Perform code generation before build",
"commands_build_options_codegen": "Skip code generation before build",
"commands_build_options_codegen_dir": "Codegen output directory (default: {default})",
"commands_build_options_w": "Automatically rebuild when changes are made (default: false)",
"commands_build_options_s": "Strategy to use for building the wrapper (default: {default})",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/__tests__/e2e/build-rs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("e2e tests for build command", () => {
describe("Image strategy", () => {
it("Builds for rust", async () => {
const { exitCode: code, stdout: output } = await runCLI({
args: ["build", "-v", "--codegen", "-s", "image"],
args: ["build", "-v", "-s", "image"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
});
Expand All @@ -37,7 +37,7 @@ describe("e2e tests for build command", () => {
describe.skip("Local strategy", () => {
it("Builds for rust", async () => {
const { exitCode: code, stdout: output } = await runCLI({
args: ["build", "-v", "--codegen", "-s", "local"],
args: ["build", "-v", "-s", "local"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
});
Expand All @@ -53,7 +53,7 @@ describe("e2e tests for build command", () => {
describe("VM strategy", () => {
it("Builds for rust", async () => {
const { exitCode: code, stdout: output } = await runCLI({
args: ["build", "-v", "--codegen", "-s", "vm"],
args: ["build", "-v", "-s", "vm"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/__tests__/e2e/build.wasm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Options:
(default: ./build)
-c, --client-config <config-path> Add custom configuration to the
PolywrapClient
--codegen Perform code generation before build
-n, --no-codegen Skip code generation before build
--codegen-dir Codegen output directory (default:
./src/wrap)
--wrapper-envs <envs-path> Path to a JSON file containing wrapper
Expand Down Expand Up @@ -160,7 +160,7 @@ describe("e2e tests for build command", () => {
);
const testCaseDir = getTestCaseDir(0);
const { exitCode: code, stdout: output } = await runCLI({
args: ["build", "-v", "--output-dir", outputDir, "--codegen"],
args: ["build", "-v", "--output-dir", outputDir],
cwd: testCaseDir,
cli: polywrapCli,
});
Expand Down Expand Up @@ -235,7 +235,7 @@ describe("e2e tests for build command", () => {

it("Builds for assemblyscript", async () => {
const { exitCode: code, stdout: output } = await runCLI({
args: ["build", "-v", "-s", "local", "--codegen"],
args: ["build", "-v", "-s", "local"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
});
Expand Down Expand Up @@ -264,7 +264,7 @@ describe("e2e tests for build command", () => {

test(testCaseName, async () => {
let { exitCode, stdout, stderr } = await runCLI({
args: ["build", "-v", "--codegen", ...cmdArgs],
args: ["build", "-v", ...cmdArgs],
cwd: testCaseDir,
cli: polywrapCli,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/__tests__/e2e/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("e2e tests for test command", () => {

beforeAll(async () => {
const wrapperPath = path.join(testCaseRoot, "run-test-wrapper");
await buildWrapper(wrapperPath, undefined, true);
await buildWrapper(wrapperPath);
});

it("Should show help text", async () => {
Expand Down
9 changes: 5 additions & 4 deletions packages/cli/src/__tests__/unit/jobrunner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { buildWrapper } from "@polywrap/test-env-js";
import { testCases } from "./jobrunner-test-cases";
import { JobRunner } from "../../lib";
import path from "path";
import { ClientConfigBuilder, IClientConfigBuilder } from "@polywrap/client-config-builder-js";
import {
ClientConfigBuilder,
IClientConfigBuilder,
} from "@polywrap/client-config-builder-js";

jest.setTimeout(200000);

Expand All @@ -12,9 +15,7 @@ describe("workflow JobRunner", () => {

beforeAll(async () => {
await buildWrapper(
path.join(GetPathToTestWrappers(), "wasm-as", "simple-calculator"),
undefined,
true
path.join(GetPathToTestWrappers(), "wasm-as", "simple-calculator")
);
configBuilder = new ClientConfigBuilder().addDefaults();
});
Expand Down
14 changes: 9 additions & 5 deletions packages/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface BuildCommandOptions extends BaseCommandOptions {
outputDir: string;
clientConfig: string | false;
wrapperEnvs: string | false;
codegen: boolean; // defaults to false
noCodegen: boolean;
codegenDir: string;
watch: boolean;
strategy: `${SupportedStrategies}`;
Expand Down Expand Up @@ -77,7 +77,7 @@ export const build: Command = {
`-c, --client-config <${intlMsg.commands_common_options_configPath()}>`,
`${intlMsg.commands_common_options_config()}`
)
.option(`--codegen`, `${intlMsg.commands_build_options_codegen()}`)
.option(`-n, --no-codegen`, `${intlMsg.commands_build_options_codegen()}`)
.option(
`--codegen-dir`,
`${intlMsg.commands_build_options_codegen_dir({
Expand Down Expand Up @@ -110,7 +110,7 @@ export const build: Command = {
clientConfig: options.clientConfig || false,
wrapperEnvs: options.wrapperEnvs || false,
outputDir: parseDirOption(options.outputDir, defaultOutputDir),
codegen: options.codegen || false,
noCodegen: options.noCodegen || false,
codegenDir: parseDirOption(options.codegenDir, defaultCodegenDir),
strategy: options.strategy || defaultStrategy,
watch: options.watch || false,
Expand Down Expand Up @@ -165,12 +165,13 @@ async function run(options: Required<BuildCommandOptions>) {
wrapperEnvs,
outputDir,
strategy,
codegen,
noCodegen,
codegenDir,
verbose,
quiet,
logFile,
} = options;

const logger = createLogger({ verbose, quiet, logFile });

const envs = await parseWrapperEnvsOption(wrapperEnvs);
Expand Down Expand Up @@ -206,6 +207,7 @@ async function run(options: Required<BuildCommandOptions>) {
}

let buildStrategy: BuildStrategy<unknown>;
let canRunCodegen = true;

if (isPolywrapManifestLanguage(language)) {
await validateManifestModules(manifest as PolywrapManifest);
Expand All @@ -215,6 +217,8 @@ async function run(options: Required<BuildCommandOptions>) {
outputDir,
project as PolywrapProject
);

canRunCodegen = language != "interface";
}

const execute = async (): Promise<boolean> => {
Expand All @@ -224,7 +228,7 @@ async function run(options: Required<BuildCommandOptions>) {
client,
});

if (codegen) {
if (canRunCodegen && !noCodegen) {
const codeGenerator = new CodeGenerator({
project,
schemaComposer,
Expand Down
4 changes: 2 additions & 2 deletions packages/js/cli/src/__tests__/commands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const clearDir = (dir: string) => {

const testData: CommandTestCaseData<CommandTypings> = {
build: [{
options: { strategy: "vm", codegen: true },
options: { strategy: "vm" },
cwd: path.join(GetPathToCliTestFiles(), "wasm/build-cmd/assemblyscript/001-sanity"),
before: async (test) => {
// clear build dir
Expand Down Expand Up @@ -208,7 +208,7 @@ const testData: CommandTestCaseData<CommandTypings> = {
if (!test.cwd)
throw Error("This shouldn't happen");
const wrapperPath = path.join(test.cwd, "../run-test-wrapper");
await Commands.build({ codegen: true }, { cwd: wrapperPath });
await Commands.build({}, { cwd: wrapperPath });
},
after: (_, stdout, __, exitCode) => {
expect(stdout).toContain("Data: ");
Expand Down
10 changes: 5 additions & 5 deletions packages/js/client/src/__tests__/core/error-structure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ describe("Error structure", () => {
let client: PolywrapClient;

beforeAll(async () => {
await buildWrapper(simpleWrapperPath, undefined, true);
await buildWrapper(badUtilWrapperPath, undefined, true);
await buildWrapper(badMathWrapperPath, undefined, true);
await buildWrapper(subinvokeErrorWrapperPath, undefined, true);
await buildWrapper(invalidTypesWrapperPath, undefined, true);
await buildWrapper(simpleWrapperPath);
await buildWrapper(badUtilWrapperPath);
await buildWrapper(badMathWrapperPath);
await buildWrapper(subinvokeErrorWrapperPath);
await buildWrapper(invalidTypesWrapperPath);

client = new PolywrapClient({
packages: [mockPluginRegistration("plugin/mock")],
Expand Down
6 changes: 3 additions & 3 deletions packages/js/client/src/__tests__/core/sanity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("sanity", () => {
envs: undefined
}

await buildWrapper(fooPath, undefined, true);
await buildWrapper(fooPath);
let client = new PolywrapClient(config as PolywrapCoreClientConfig, { noDefaults: true });
let result = await client.validate(fooUri, {});
expect(result.ok).toBeFalsy();
Expand Down Expand Up @@ -115,7 +115,7 @@ describe("sanity", () => {
expect(resultError).toBeTruthy();
expect(resultError.message).toContain("Unable to find URI");

await buildWrapper(greetingPath, undefined, true);
await buildWrapper(greetingPath);

let modifiedFooWrapper: IUriPackage = {
uri: Uri.from(greetingUri),
Expand All @@ -133,7 +133,7 @@ describe("sanity", () => {

expect(result.ok).toBeTruthy()

await buildWrapper(modifiedFooPath, undefined, true);
await buildWrapper(modifiedFooPath);
let redirectUri: IUriRedirect = {
from: Uri.from(fooUri),
to: Uri.from(modifiedFooUri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ function replaceAll(str: string, strToReplace: string, replaceStr: string) {
describe("URI resolution", () => {
beforeAll(async () => {
await Promise.all([
buildWrapper(wrapperPath, undefined, true),
buildWrapper(simpleFsResolverWrapperPath, undefined, true),
buildWrapper(simpleRedirectResolverWrapperPath, undefined, true)
buildWrapper(wrapperPath),
buildWrapper(simpleFsResolverWrapperPath),
buildWrapper(simpleRedirectResolverWrapperPath)
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const simpleWrapperUri = new Uri(`fs/${simpleWrapperPath}/build`);

describe("wasm-wrapper", () => {
beforeAll(async () => {
await buildWrapper(simpleWrapperPath, undefined, true);
await buildWrapper(simpleWrapperPath);
});

const mockPlugin = (): IWrapPackage => {
Expand Down
Loading