Skip to content

Commit

Permalink
Merge pull request #1003 from polywrap/prealpha-dev
Browse files Browse the repository at this point in the history
Prep 0.0.1-prealpha.91
  • Loading branch information
dOrgJelli authored Jun 30, 2022
2 parents 0f9caa7 + b588ba2 commit 2257183
Show file tree
Hide file tree
Showing 257 changed files with 6,261 additions and 1,318 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Polywrap 0.0.1-prealpha.91
## Features
* [PR-989](https://github.com/polywrap/monorepo/pull/989/files) `@polywrap/core-js`: Add job status in workflow job's result object.
* [PR-992](https://github.com/polywrap/monorepo/pull/992) `polywrap` CLI: Allow configuring the client using the `--client-config` on all applicable commands.
* [PR-1000](https://github.com/polywrap/monorepo/pull/1000) `@polywrap/core-js`: Added the `encodeResult` property to `InvokeOptions`.
* [PR-1000](https://github.com/polywrap/monorepo/pull/1000) `@polywrap/core-js`: Introduced the concept of `Invoker` and `Invocable`.
* [PR-988](https://github.com/polywrap/monorepo/pull/988) `polywrap` CLI, `wasm/rust`: Updates to the default build-image (`Dockerfile`):
* Added the system dependencies `clang`, `llvm` and `build-essentials`.
* Added steps to remove any `wasm-bindgen` imports that may have been injected.

## Bugs
* [PR-1000](https://github.com/polywrap/monorepo/pull/1000) Fixed inconsistencies around `ArrayBuffer` and `Uint8Array`.
* [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.
* [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.

## Breaking Changes
* [PR-980](https://github.com/polywrap/monorepo/pull/980) `@polywrap/schema-parse`: Rename `TypeInfo` from `Abi`.

# Polywrap 0.0.1-prealpha.90
## Features
* [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:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1-prealpha.90
0.0.1-prealpha.91
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
"reset": "yarn clean && yarn && yarn build",
"clean": "npx rimraf ./**/node_modules ./**/yarn.lock ./**/build ./**/coverage ./**/.polywrap",
"dependencies:install": "cd dependencies && yarn",
"dependencies:link": "yarn link:schema:parse && yarn link:schema:bind",
"dependencies:link": "yarn link:schema:parse && yarn link:schema:compose && yarn link:schema:bind",
"link:schema:parse": "cd packages/schema/parse && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-parse && cd ../",
"link:schema:compose": "cd packages/schema/compose && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-compose && cd ../",
"link:schema:bind": "cd packages/schema/bind && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-bind && cd ../",
"preinstall": "yarn dependencies:install",
"build": "yarn build:core && yarn dependencies:link && yarn build:interfaces && yarn build:plugins && yarn build:client && yarn build:test-env && yarn build:cli",
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/lang/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"commands_common_options_configPath": "config-path",
"commands_common_options_config": "Add custom configuration to the PolywrapClient",
"commands_build_description": "Builds a wrapper",
"commands_build_error_manifestPathMissing": "{option} option missing {argument} argument",
"commands_build_error_manifestNotFound": "Manifest not found. Search paths used: {paths}",
Expand Down Expand Up @@ -141,9 +143,7 @@
"commands_plugin_options_codegen": "Output directory for the generated types (default: {default})",
"commands_run_options_workflow": "workflow",
"commands_run_options_workflowScript": "Path to workflow script",
"commands_run_options_configPath": "config-path",
"commands_run_options_outputFilePath": "output-file-path",
"commands_run_options_config": "Add custom configuration to the PolywrapClient",
"commands_run_options_validateScript": "Validate the output of the workflow jobs",
"commands_run_options_validate": "cue-file",
"commands_run_options_outputFile": "Output file path for the workflow result",
Expand Down Expand Up @@ -182,6 +182,7 @@
"commands_run_error_noApi": "API needs to be initialized",
"commands_run_error_readFail": "Failed to read query {query}",
"commands_run_error_unsupportedOutputFileExt": "Unsupported outputFile extention: ${outputFileExt}",
"commands_run_error_cueDoesNotExist": "Require cue to run validator, checkout https://cuelang.org/ for more information",
"commands_run_error_noWorkflowScriptFound": "Workflow script not found at path: {path}",
"commands_run_error_noTestEnvFound": "polywrap test-env not found, please run 'polywrap infra up --modules=eth-ens-ipfs'",
"commands_testEnv_description": "Manage a test environment for Polywrap",
Expand All @@ -207,7 +208,7 @@
"lib_codeGenerator_templateNoModify": "NOTE: This is generated by 'polywrap codegen', DO NOT MODIFY",
"lib_codeGenerator_nogenerateBindingMethod": "The generation file provided doesn't have the 'generateBinding' method.",
"lib_codeGenerator_noComposedSchema": "The schema does not exist, please define one.",
"lib_codeGenerator_typeInfoMissing": "The TypeInfo is missing from the composer output.",
"lib_codeGenerator_abiMissing": "The ABI is missing from the composer output.",
"lib_compiler_compileError": "Failed to compile Polywrap",
"lib_compiler_compileText": "Compile Polywrap",
"lib_compiler_compileWarning": "Warnings while compiling Polywrap",
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/lang/es.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"commands_common_options_configPath": "config-path",
"commands_common_options_config": "Add custom configuration to the PolywrapClient",
"commands_build_description": "Builds a wrapper",
"commands_build_error_manifestPathMissing": "{option} option missing {argument} argument",
"commands_build_error_manifestNotFound": "Manifest not found. Search paths used: {paths}",
Expand Down Expand Up @@ -141,9 +143,7 @@
"commands_plugin_options_codegen": "Output directory for the generated types (default: {default})",
"commands_run_options_workflow": "workflow",
"commands_run_options_workflowScript": "Path to workflow script",
"commands_run_options_configPath": "config-path",
"commands_run_options_outputFilePath": "output-file-path",
"commands_run_options_config": "Add custom configuration to the PolywrapClient",
"commands_run_options_validateScript": "Validate the output of the workflow jobs",
"commands_run_options_validate": "cue-file",
"commands_run_options_outputFile": "Output file path for the workflow result",
Expand Down Expand Up @@ -182,6 +182,7 @@
"commands_run_error_noApi": "API needs to be initialized",
"commands_run_error_readFail": "Failed to read query {query}",
"commands_run_error_unsupportedOutputFileExt": "Unsupported outputFile extention: ${outputFileExt}",
"commands_run_error_cueDoesNotExist": "Require cue to run validator, checkout https://cuelang.org/ for more information",
"commands_run_error_noWorkflowScriptFound": "Workflow script not found at path: {path}",
"commands_run_error_noTestEnvFound": "polywrap test-env not found, please run 'polywrap infra up --modules=eth-ens-ipfs'",
"commands_testEnv_description": "Manage a test environment for Polywrap",
Expand All @@ -207,7 +208,7 @@
"lib_codeGenerator_templateNoModify": "NOTE: This is generated by 'polywrap codegen', DO NOT MODIFY",
"lib_codeGenerator_nogenerateBindingMethod": "The generation file provided doesn't have the 'generateBinding' method.",
"lib_codeGenerator_noComposedSchema": "The schema does not exist, please define one.",
"lib_codeGenerator_typeInfoMissing": "The TypeInfo is missing from the composer output.",
"lib_codeGenerator_abiMissing": "The ABI is missing from the composer output.",
"lib_compiler_compileError": "Failed to compile Polywrap",
"lib_compiler_compileText": "Compile Polywrap",
"lib_compiler_compileWarning": "Warnings while compiling Polywrap",
Expand Down
209 changes: 156 additions & 53 deletions packages/cli/src/__tests__/e2e/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { runCLI } from "@polywrap/test-env-js";
import { GetPathToCliTestFiles } from "@polywrap/test-cases";
import path from "path";
import fs from "fs";

import rimraf from "rimraf";
import { compareSync } from "dir-compare";

const HELP = `Usage: polywrap app|a [options] [command]
Expand All @@ -16,7 +17,7 @@ Options:
Commands:
codegen [options] Generate code for the app
help [command] display help for command
`
`;

const CODEGEN_SUCCESS = `- Manifest loaded from ./polywrap.app.yaml
✔ Manifest loaded from ./polywrap.app.yaml
Expand All @@ -26,88 +27,190 @@ const CODEGEN_SUCCESS = `- Manifest loaded from ./polywrap.app.yaml
`;

describe("e2e tests for app command", () => {
const testCaseRoot = path.join(GetPathToCliTestFiles(), "app/codegen");
const testCases =
fs.readdirSync(testCaseRoot, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
const testCaseRoot = path.join(GetPathToCliTestFiles(), "app", "codegen");
const testCases = fs
.readdirSync(testCaseRoot, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
const getTestCaseDir = (index: number) =>
path.join(testCaseRoot, testCases[index]);

test("Should show help text", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["app", "--help"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
},
const testCliOutput = (
testCaseDir: string,
exitCode: number,
stdout: string,
stder: string
) => {
const output = clearStyle(stdout);
const error = clearStyle(stder);

const expected = JSON.parse(
fs.readFileSync(
path.join(testCaseDir, "expected", "stdout.json"),
"utf-8"
)
);

if (expected.stdout) {
if (Array.isArray(expected.stdout)) {
for (const line of expected.stdout) {
expect(output).toContain(line);
}
} else {
expect(output).toContain(expected.stdout);
}
}

if (expected.stderr) {
if (Array.isArray(expected.stderr)) {
for (const line of expected.stderr) {
expect(error).toContain(line);
}
} else {
expect(error).toContain(expected.stderr);
}
}

if (expected.exitCode) {
expect(exitCode).toEqual(expected.exitCode);
}

if (expected.files) {
for (const file of expected.files) {
expect(fs.existsSync(path.join(testCaseDir, file))).toBeTruthy();
}
}
};

const testCodegenOutput = (testCaseDir: string, codegenDir: string) => {
if (fs.existsSync(path.join(testCaseDir, "expected", "wrap"))) {
const expectedTypesResult = compareSync(
codegenDir,
path.join(testCaseDir, "expected", "wrap"),
{ compareContent: true }
);
expect(expectedTypesResult.differences).toBe(0);
}
};

it("Should show help text", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["app", "--help"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
});

expect(code).toEqual(0);
expect(error).toBe("");
expect(clearStyle(output)).toEqual(HELP);
});

test("Should throw error for invalid params - no command", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["app", "--output-dir"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
},
);
it("Should show help for no command", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["app"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
});

expect(code).toEqual(1);
expect(error).toBe("error: unknown option '--output-dir'\n");
expect(error).toBe(HELP);
expect(output).toBe("");
});

it("Should throw error for invalid command", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["app", "invalid"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
});

expect(code).toEqual(1);
expect(error).toBe("error: unknown command 'invalid'\n");
expect(output).toEqual(``);
});

test("Should throw error for invalid params - codegen-dir", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["app", "codegen", "--codegen-dir"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
},
);
it("Should throw error for unknown option --output-dir", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["app", "--output-dir"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
});

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

test("Should throw error for invalid params - ens", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["app", "codegen", "--ens"],
cwd: getTestCaseDir(0),
cli: polywrapCli,
},
describe("missing option arguments", () => {
const missingOptionArgs = {
"--manifest-file": "-m, --manifest-file <path>",
"--codegen-dir": "-g, --codegen-dir <path>",
"--client-config": "-c, --client-config <config-path>"
}

for (const [option, errorMessage] of Object.entries(missingOptionArgs)) {
it(`Should throw error if params not specified for ${option} option`, async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["app", "codegen", option],
cwd: getTestCaseDir(0),
cli: polywrapCli,
});

expect(code).toEqual(1);
expect(error).toBe(
`error: option '${errorMessage}' argument missing\n`
);
expect(output).toEqual(``);
});
}
});

it("Should store generated files to specified codegen dir", async () => {
const testCaseDir = getTestCaseDir(0);
const codegenDir = path.resolve(
process.env.TMPDIR || "/tmp",
`codegen-${Date.now()}`
);
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["app", "codegen", "--codegen-dir", codegenDir],
cwd: getTestCaseDir(0),
cli: polywrapCli,
});

expect(code).toEqual(1);
expect(error).toBe("error: option '-e, --ens [<address>]' argument missing\n");
expect(output)
.toEqual(``);
expect(error).toBe("");
expect(code).toEqual(0);
expect(clearStyle(output)).toEqual(CODEGEN_SUCCESS);

testCodegenOutput(testCaseDir, codegenDir);

rimraf.sync(codegenDir);
});

describe("test-cases", () => {
for (let i = 0; i < testCases.length; ++i) {
const testCaseName = testCases[i];
const testCaseDir = getTestCaseDir(i);

let cmdArgs: string[] = [];
let cmdFile = path.join(testCaseDir, "cmd.json");
if (fs.existsSync(cmdFile)) {
const cmdConfig = JSON.parse(fs.readFileSync(cmdFile, "utf-8"));
if (cmdConfig.args) {
cmdArgs.push(...cmdConfig.args);
}
}

test(testCaseName, async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["app", "codegen"],
cwd: testCaseDir,
cli: polywrapCli,
},
);
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["app", "codegen", ...cmdArgs],
cwd: testCaseDir,
cli: polywrapCli,
});

const codegenDir = path.resolve(testCaseDir, "src", "wrap");

expect(error).toBe("");
expect(code).toEqual(0);
expect(clearStyle(output)).toEqual(CODEGEN_SUCCESS);
testCliOutput(testCaseDir, code, output, error);
testCodegenOutput(testCaseDir, codegenDir);
});
}
});
Expand Down
Loading

0 comments on commit 2257183

Please sign in to comment.