Skip to content

Commit 2257183

Browse files
authored
Merge pull request #1003 from polywrap/prealpha-dev
Prep 0.0.1-prealpha.91
2 parents 0f9caa7 + b588ba2 commit 2257183

257 files changed

Lines changed: 6261 additions & 1318 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# Polywrap 0.0.1-prealpha.91
2+
## Features
3+
* [PR-989](https://github.com/polywrap/monorepo/pull/989/files) `@polywrap/core-js`: Add job status in workflow job's result object.
4+
* [PR-992](https://github.com/polywrap/monorepo/pull/992) `polywrap` CLI: Allow configuring the client using the `--client-config` on all applicable commands.
5+
* [PR-1000](https://github.com/polywrap/monorepo/pull/1000) `@polywrap/core-js`: Added the `encodeResult` property to `InvokeOptions`.
6+
* [PR-1000](https://github.com/polywrap/monorepo/pull/1000) `@polywrap/core-js`: Introduced the concept of `Invoker` and `Invocable`.
7+
* [PR-988](https://github.com/polywrap/monorepo/pull/988) `polywrap` CLI, `wasm/rust`: Updates to the default build-image (`Dockerfile`):
8+
* Added the system dependencies `clang`, `llvm` and `build-essentials`.
9+
* Added steps to remove any `wasm-bindgen` imports that may have been injected.
10+
11+
## Bugs
12+
* [PR-1000](https://github.com/polywrap/monorepo/pull/1000) Fixed inconsistencies around `ArrayBuffer` and `Uint8Array`.
13+
* [PR-1000](https://github.com/polywrap/monorepo/pull/1000) `@polywrap/client-js`: The `noDecode` flag (renamed to `encodeResult`) now enfoces the decoding properly, where before it could get confused with returning `Bytes` from a wrapper.
14+
* [PR-981](https://github.com/polywrap/monorepo/pull/981) `polywrap-wasm-rs`: Remove the `wrap-invoke` feature because it is not being used at the moment.
15+
16+
## Breaking Changes
17+
* [PR-980](https://github.com/polywrap/monorepo/pull/980) `@polywrap/schema-parse`: Rename `TypeInfo` from `Abi`.
18+
119
# Polywrap 0.0.1-prealpha.90
220
## Features
321
* [PR-912](https://github.com/polywrap/monorepo/pull/912) [PR-930](https://github.com/polywrap/monorepo/pull/930) [PR-958](https://github.com/polywrap/monorepo/pull/958) All URI resolver extensions have been decoupled and moved into their own plugin packages:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.1-prealpha.90
1+
0.0.1-prealpha.91

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
"reset": "yarn clean && yarn && yarn build",
2525
"clean": "npx rimraf ./**/node_modules ./**/yarn.lock ./**/build ./**/coverage ./**/.polywrap",
2626
"dependencies:install": "cd dependencies && yarn",
27-
"dependencies:link": "yarn link:schema:parse && yarn link:schema:bind",
27+
"dependencies:link": "yarn link:schema:parse && yarn link:schema:compose && yarn link:schema:bind",
2828
"link:schema:parse": "cd packages/schema/parse && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-parse && cd ../",
29+
"link:schema:compose": "cd packages/schema/compose && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-compose && cd ../",
2930
"link:schema:bind": "cd packages/schema/bind && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-bind && cd ../",
3031
"preinstall": "yarn dependencies:install",
3132
"build": "yarn build:core && yarn dependencies:link && yarn build:interfaces && yarn build:plugins && yarn build:client && yarn build:test-env && yarn build:cli",

packages/cli/lang/en.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"commands_common_options_configPath": "config-path",
3+
"commands_common_options_config": "Add custom configuration to the PolywrapClient",
24
"commands_build_description": "Builds a wrapper",
35
"commands_build_error_manifestPathMissing": "{option} option missing {argument} argument",
46
"commands_build_error_manifestNotFound": "Manifest not found. Search paths used: {paths}",
@@ -141,9 +143,7 @@
141143
"commands_plugin_options_codegen": "Output directory for the generated types (default: {default})",
142144
"commands_run_options_workflow": "workflow",
143145
"commands_run_options_workflowScript": "Path to workflow script",
144-
"commands_run_options_configPath": "config-path",
145146
"commands_run_options_outputFilePath": "output-file-path",
146-
"commands_run_options_config": "Add custom configuration to the PolywrapClient",
147147
"commands_run_options_validateScript": "Validate the output of the workflow jobs",
148148
"commands_run_options_validate": "cue-file",
149149
"commands_run_options_outputFile": "Output file path for the workflow result",
@@ -182,6 +182,7 @@
182182
"commands_run_error_noApi": "API needs to be initialized",
183183
"commands_run_error_readFail": "Failed to read query {query}",
184184
"commands_run_error_unsupportedOutputFileExt": "Unsupported outputFile extention: ${outputFileExt}",
185+
"commands_run_error_cueDoesNotExist": "Require cue to run validator, checkout https://cuelang.org/ for more information",
185186
"commands_run_error_noWorkflowScriptFound": "Workflow script not found at path: {path}",
186187
"commands_run_error_noTestEnvFound": "polywrap test-env not found, please run 'polywrap infra up --modules=eth-ens-ipfs'",
187188
"commands_testEnv_description": "Manage a test environment for Polywrap",
@@ -207,7 +208,7 @@
207208
"lib_codeGenerator_templateNoModify": "NOTE: This is generated by 'polywrap codegen', DO NOT MODIFY",
208209
"lib_codeGenerator_nogenerateBindingMethod": "The generation file provided doesn't have the 'generateBinding' method.",
209210
"lib_codeGenerator_noComposedSchema": "The schema does not exist, please define one.",
210-
"lib_codeGenerator_typeInfoMissing": "The TypeInfo is missing from the composer output.",
211+
"lib_codeGenerator_abiMissing": "The ABI is missing from the composer output.",
211212
"lib_compiler_compileError": "Failed to compile Polywrap",
212213
"lib_compiler_compileText": "Compile Polywrap",
213214
"lib_compiler_compileWarning": "Warnings while compiling Polywrap",

packages/cli/lang/es.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"commands_common_options_configPath": "config-path",
3+
"commands_common_options_config": "Add custom configuration to the PolywrapClient",
24
"commands_build_description": "Builds a wrapper",
35
"commands_build_error_manifestPathMissing": "{option} option missing {argument} argument",
46
"commands_build_error_manifestNotFound": "Manifest not found. Search paths used: {paths}",
@@ -141,9 +143,7 @@
141143
"commands_plugin_options_codegen": "Output directory for the generated types (default: {default})",
142144
"commands_run_options_workflow": "workflow",
143145
"commands_run_options_workflowScript": "Path to workflow script",
144-
"commands_run_options_configPath": "config-path",
145146
"commands_run_options_outputFilePath": "output-file-path",
146-
"commands_run_options_config": "Add custom configuration to the PolywrapClient",
147147
"commands_run_options_validateScript": "Validate the output of the workflow jobs",
148148
"commands_run_options_validate": "cue-file",
149149
"commands_run_options_outputFile": "Output file path for the workflow result",
@@ -182,6 +182,7 @@
182182
"commands_run_error_noApi": "API needs to be initialized",
183183
"commands_run_error_readFail": "Failed to read query {query}",
184184
"commands_run_error_unsupportedOutputFileExt": "Unsupported outputFile extention: ${outputFileExt}",
185+
"commands_run_error_cueDoesNotExist": "Require cue to run validator, checkout https://cuelang.org/ for more information",
185186
"commands_run_error_noWorkflowScriptFound": "Workflow script not found at path: {path}",
186187
"commands_run_error_noTestEnvFound": "polywrap test-env not found, please run 'polywrap infra up --modules=eth-ens-ipfs'",
187188
"commands_testEnv_description": "Manage a test environment for Polywrap",
@@ -207,7 +208,7 @@
207208
"lib_codeGenerator_templateNoModify": "NOTE: This is generated by 'polywrap codegen', DO NOT MODIFY",
208209
"lib_codeGenerator_nogenerateBindingMethod": "The generation file provided doesn't have the 'generateBinding' method.",
209210
"lib_codeGenerator_noComposedSchema": "The schema does not exist, please define one.",
210-
"lib_codeGenerator_typeInfoMissing": "The TypeInfo is missing from the composer output.",
211+
"lib_codeGenerator_abiMissing": "The ABI is missing from the composer output.",
211212
"lib_compiler_compileError": "Failed to compile Polywrap",
212213
"lib_compiler_compileText": "Compile Polywrap",
213214
"lib_compiler_compileWarning": "Warnings while compiling Polywrap",

packages/cli/src/__tests__/e2e/app.spec.ts

Lines changed: 156 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { runCLI } from "@polywrap/test-env-js";
44
import { GetPathToCliTestFiles } from "@polywrap/test-cases";
55
import path from "path";
66
import fs from "fs";
7-
7+
import rimraf from "rimraf";
8+
import { compareSync } from "dir-compare";
89

910
const HELP = `Usage: polywrap app|a [options] [command]
1011
@@ -16,7 +17,7 @@ Options:
1617
Commands:
1718
codegen [options] Generate code for the app
1819
help [command] display help for command
19-
`
20+
`;
2021

2122
const CODEGEN_SUCCESS = `- Manifest loaded from ./polywrap.app.yaml
2223
✔ Manifest loaded from ./polywrap.app.yaml
@@ -26,88 +27,190 @@ const CODEGEN_SUCCESS = `- Manifest loaded from ./polywrap.app.yaml
2627
`;
2728

2829
describe("e2e tests for app command", () => {
29-
const testCaseRoot = path.join(GetPathToCliTestFiles(), "app/codegen");
30-
const testCases =
31-
fs.readdirSync(testCaseRoot, { withFileTypes: true })
32-
.filter((dirent) => dirent.isDirectory())
33-
.map((dirent) => dirent.name);
30+
const testCaseRoot = path.join(GetPathToCliTestFiles(), "app", "codegen");
31+
const testCases = fs
32+
.readdirSync(testCaseRoot, { withFileTypes: true })
33+
.filter((dirent) => dirent.isDirectory())
34+
.map((dirent) => dirent.name);
3435
const getTestCaseDir = (index: number) =>
3536
path.join(testCaseRoot, testCases[index]);
3637

37-
test("Should show help text", async () => {
38-
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
39-
{
40-
args: ["app", "--help"],
41-
cwd: getTestCaseDir(0),
42-
cli: polywrapCli,
43-
},
38+
const testCliOutput = (
39+
testCaseDir: string,
40+
exitCode: number,
41+
stdout: string,
42+
stder: string
43+
) => {
44+
const output = clearStyle(stdout);
45+
const error = clearStyle(stder);
46+
47+
const expected = JSON.parse(
48+
fs.readFileSync(
49+
path.join(testCaseDir, "expected", "stdout.json"),
50+
"utf-8"
51+
)
4452
);
4553

54+
if (expected.stdout) {
55+
if (Array.isArray(expected.stdout)) {
56+
for (const line of expected.stdout) {
57+
expect(output).toContain(line);
58+
}
59+
} else {
60+
expect(output).toContain(expected.stdout);
61+
}
62+
}
63+
64+
if (expected.stderr) {
65+
if (Array.isArray(expected.stderr)) {
66+
for (const line of expected.stderr) {
67+
expect(error).toContain(line);
68+
}
69+
} else {
70+
expect(error).toContain(expected.stderr);
71+
}
72+
}
73+
74+
if (expected.exitCode) {
75+
expect(exitCode).toEqual(expected.exitCode);
76+
}
77+
78+
if (expected.files) {
79+
for (const file of expected.files) {
80+
expect(fs.existsSync(path.join(testCaseDir, file))).toBeTruthy();
81+
}
82+
}
83+
};
84+
85+
const testCodegenOutput = (testCaseDir: string, codegenDir: string) => {
86+
if (fs.existsSync(path.join(testCaseDir, "expected", "wrap"))) {
87+
const expectedTypesResult = compareSync(
88+
codegenDir,
89+
path.join(testCaseDir, "expected", "wrap"),
90+
{ compareContent: true }
91+
);
92+
expect(expectedTypesResult.differences).toBe(0);
93+
}
94+
};
95+
96+
it("Should show help text", async () => {
97+
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
98+
args: ["app", "--help"],
99+
cwd: getTestCaseDir(0),
100+
cli: polywrapCli,
101+
});
102+
46103
expect(code).toEqual(0);
47104
expect(error).toBe("");
48105
expect(clearStyle(output)).toEqual(HELP);
49106
});
50107

51-
test("Should throw error for invalid params - no command", async () => {
52-
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
53-
{
54-
args: ["app", "--output-dir"],
55-
cwd: getTestCaseDir(0),
56-
cli: polywrapCli,
57-
},
58-
);
108+
it("Should show help for no command", async () => {
109+
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
110+
args: ["app"],
111+
cwd: getTestCaseDir(0),
112+
cli: polywrapCli,
113+
});
59114

60115
expect(code).toEqual(1);
61-
expect(error).toBe("error: unknown option '--output-dir'\n");
116+
expect(error).toBe(HELP);
117+
expect(output).toBe("");
118+
});
119+
120+
it("Should throw error for invalid command", async () => {
121+
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
122+
args: ["app", "invalid"],
123+
cwd: getTestCaseDir(0),
124+
cli: polywrapCli,
125+
});
126+
127+
expect(code).toEqual(1);
128+
expect(error).toBe("error: unknown command 'invalid'\n");
62129
expect(output).toEqual(``);
63130
});
64131

65-
test("Should throw error for invalid params - codegen-dir", async () => {
66-
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
67-
{
68-
args: ["app", "codegen", "--codegen-dir"],
69-
cwd: getTestCaseDir(0),
70-
cli: polywrapCli,
71-
},
72-
);
132+
it("Should throw error for unknown option --output-dir", async () => {
133+
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
134+
args: ["app", "--output-dir"],
135+
cwd: getTestCaseDir(0),
136+
cli: polywrapCli,
137+
});
73138

74139
expect(code).toEqual(1);
75-
expect(error).toBe(`error: option '-c, --codegen-dir <path>' argument missing\n`);
140+
expect(error).toBe("error: unknown option '--output-dir'\n");
76141
expect(output).toEqual(``);
77142
});
78143

79-
test("Should throw error for invalid params - ens", async () => {
80-
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
81-
{
82-
args: ["app", "codegen", "--ens"],
83-
cwd: getTestCaseDir(0),
84-
cli: polywrapCli,
85-
},
144+
describe("missing option arguments", () => {
145+
const missingOptionArgs = {
146+
"--manifest-file": "-m, --manifest-file <path>",
147+
"--codegen-dir": "-g, --codegen-dir <path>",
148+
"--client-config": "-c, --client-config <config-path>"
149+
}
150+
151+
for (const [option, errorMessage] of Object.entries(missingOptionArgs)) {
152+
it(`Should throw error if params not specified for ${option} option`, async () => {
153+
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
154+
args: ["app", "codegen", option],
155+
cwd: getTestCaseDir(0),
156+
cli: polywrapCli,
157+
});
158+
159+
expect(code).toEqual(1);
160+
expect(error).toBe(
161+
`error: option '${errorMessage}' argument missing\n`
162+
);
163+
expect(output).toEqual(``);
164+
});
165+
}
166+
});
167+
168+
it("Should store generated files to specified codegen dir", async () => {
169+
const testCaseDir = getTestCaseDir(0);
170+
const codegenDir = path.resolve(
171+
process.env.TMPDIR || "/tmp",
172+
`codegen-${Date.now()}`
86173
);
174+
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
175+
args: ["app", "codegen", "--codegen-dir", codegenDir],
176+
cwd: getTestCaseDir(0),
177+
cli: polywrapCli,
178+
});
87179

88-
expect(code).toEqual(1);
89-
expect(error).toBe("error: option '-e, --ens [<address>]' argument missing\n");
90-
expect(output)
91-
.toEqual(``);
180+
expect(error).toBe("");
181+
expect(code).toEqual(0);
182+
expect(clearStyle(output)).toEqual(CODEGEN_SUCCESS);
183+
184+
testCodegenOutput(testCaseDir, codegenDir);
185+
186+
rimraf.sync(codegenDir);
92187
});
93188

94189
describe("test-cases", () => {
95190
for (let i = 0; i < testCases.length; ++i) {
96191
const testCaseName = testCases[i];
97192
const testCaseDir = getTestCaseDir(i);
193+
194+
let cmdArgs: string[] = [];
195+
let cmdFile = path.join(testCaseDir, "cmd.json");
196+
if (fs.existsSync(cmdFile)) {
197+
const cmdConfig = JSON.parse(fs.readFileSync(cmdFile, "utf-8"));
198+
if (cmdConfig.args) {
199+
cmdArgs.push(...cmdConfig.args);
200+
}
201+
}
98202

99203
test(testCaseName, async () => {
100-
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
101-
{
102-
args: ["app", "codegen"],
103-
cwd: testCaseDir,
104-
cli: polywrapCli,
105-
},
106-
);
204+
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
205+
args: ["app", "codegen", ...cmdArgs],
206+
cwd: testCaseDir,
207+
cli: polywrapCli,
208+
});
209+
210+
const codegenDir = path.resolve(testCaseDir, "src", "wrap");
107211

108-
expect(error).toBe("");
109-
expect(code).toEqual(0);
110-
expect(clearStyle(output)).toEqual(CODEGEN_SUCCESS);
212+
testCliOutput(testCaseDir, code, output, error);
213+
testCodegenOutput(testCaseDir, codegenDir);
111214
});
112215
}
113216
});

0 commit comments

Comments
 (0)