Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/origin-dev' into pileks/feat/js-…
Browse files Browse the repository at this point in the history
…client-config-unique-maps
  • Loading branch information
pileks committed Mar 14, 2023
2 parents 8d77dae + 7f433da commit b5dc785
Show file tree
Hide file tree
Showing 50 changed files with 330 additions and 314 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Polywrap Origin (0.10.0-pre.11)
# Polywrap Origin (0.10.0-pre.12)
## Breaking Changes
### Toolchain
**`polywrap` CLI:**
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.0-pre.11
0.10.0-pre.12
34 changes: 17 additions & 17 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "polywrap",
"description": "Polywrap CLI",
"version": "0.10.0-pre.11",
"version": "0.10.0-pre.12",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -43,22 +43,22 @@
"@ethersproject/providers": "5.6.8",
"@ethersproject/wallet": "5.6.2",
"@formatjs/intl": "1.8.2",
"@polywrap/asyncify-js": "0.10.0-pre.11",
"@polywrap/client-config-builder-js": "0.10.0-pre.11",
"@polywrap/client-js": "0.10.0-pre.11",
"@polywrap/core-js": "0.10.0-pre.11",
"@polywrap/asyncify-js": "0.10.0-pre.12",
"@polywrap/client-config-builder-js": "0.10.0-pre.12",
"@polywrap/client-js": "0.10.0-pre.12",
"@polywrap/core-js": "0.10.0-pre.12",
"@polywrap/ethereum-provider-js": "~0.2.3",
"@polywrap/logging-js": "0.10.0-pre.11",
"@polywrap/os-js": "0.10.0-pre.11",
"@polywrap/polywrap-manifest-types-js": "0.10.0-pre.11",
"@polywrap/result": "0.10.0-pre.11",
"@polywrap/schema-bind": "0.10.0-pre.11",
"@polywrap/schema-compose": "0.10.0-pre.11",
"@polywrap/schema-parse": "0.10.0-pre.11",
"@polywrap/uri-resolver-extensions-js": "0.10.0-pre.11",
"@polywrap/uri-resolvers-js": "0.10.0-pre.11",
"@polywrap/wasm-js": "0.10.0-pre.11",
"@polywrap/wrap-manifest-types-js": "0.10.0-pre.11",
"@polywrap/logging-js": "0.10.0-pre.12",
"@polywrap/os-js": "0.10.0-pre.12",
"@polywrap/polywrap-manifest-types-js": "0.10.0-pre.12",
"@polywrap/result": "0.10.0-pre.12",
"@polywrap/schema-bind": "0.10.0-pre.12",
"@polywrap/schema-compose": "0.10.0-pre.12",
"@polywrap/schema-parse": "0.10.0-pre.12",
"@polywrap/uri-resolver-extensions-js": "0.10.0-pre.12",
"@polywrap/uri-resolvers-js": "0.10.0-pre.12",
"@polywrap/wasm-js": "0.10.0-pre.12",
"@polywrap/wrap-manifest-types-js": "0.10.0-pre.12",
"axios": "0.21.2",
"chalk": "4.1.0",
"chokidar": "3.5.1",
Expand All @@ -82,7 +82,7 @@
"yesno": "0.4.0"
},
"devDependencies": {
"@polywrap/cli-js": "0.10.0-pre.11",
"@polywrap/cli-js": "0.10.0-pre.12",
"@types/copyfiles": "2.4.0",
"@types/fs-extra": "9.0.12",
"@types/jest": "26.0.8",
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/__tests__/e2e/build.plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe("e2e tests for build command - plugin project", () => {
test(testCaseName, async () => {
const { exitCode: code, stdout: output, stderr: error } = await Commands.build({
...args,
codegen: true,
}, {
cwd: testCaseDir,
});
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/__tests__/e2e/build.wasm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ describe("e2e tests for build command", () => {
const logFileAbsPath = path.join(testCaseDir, logFilePath);
const { exitCode: code } = await Commands.build({
logFile: logFilePath,
codegen: true
}, {
cwd: testCaseDir,
cli: polywrapCli,
Expand All @@ -209,7 +208,6 @@ describe("e2e tests for build command", () => {
it("Builds for assemblyscript", async () => {
const { exitCode: code, stdout: output } = await Commands.build({
strategy: "image",
codegen: true
}, {
cwd: getTestCaseDir(0),
cli: polywrapCli,
Expand Down
146 changes: 85 additions & 61 deletions packages/cli/src/__tests__/e2e/create.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { clearStyle, polywrapCli } from "./utils";
import { ProjectType, supportedLangs } from "../../commands";
import { UrlFormat } from "../../lib";

import { runCli } from "@polywrap/cli-js";
import rimraf from "rimraf";
import { ProjectType, supportedLangs } from "../../commands";
import { UrlFormat } from "../../lib";
import path from "path";
import fs from "fs";

const HELP = `Usage: polywrap create|c [options] [command]
Expand All @@ -24,6 +26,14 @@ Commands:
help [command] display help for command
`;

const VERSION =
fs.readFileSync(
path.join(__dirname, "../../../../../VERSION"),
"utf-8"
)
.replace(/\n/g, "")
.replace(/\r/g, "");

const urlExamples = (format: UrlFormat): string => {
if (format === UrlFormat.git) {
return "https://github.com/polywrap/logging.git";
Expand Down Expand Up @@ -146,6 +156,10 @@ describe("e2e tests for create command", () => {
config: {
cwd: __dirname,
cli: polywrapCli,
env: {
...process.env,
OVERRIDE_CREATE_TEMPLATES_NPM: `@polywrap/templates@${VERSION}`
}
}
});

Expand All @@ -161,81 +175,91 @@ describe("e2e tests for create command", () => {
});
}

describe("template", () => {
it("Should throw error for missing required argument - url", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["create", "template"],
describe("template", () => {
it("Should throw error for missing required argument - url", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCli({
args: ["create", "template"],
config: {
cli: polywrapCli,
});

expect(code).toEqual(1);
expect(error).toContain("error: missing required argument 'url'");
expect(output).toBe("");
}
});

it("Should throw error for missing required argument - name", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["create", "template", "lang"],
cli: polywrapCli,
});
expect(code).toEqual(1);
expect(error).toContain("error: missing required argument 'url'");
expect(output).toBe("");
});

expect(code).toEqual(1);
expect(error).toContain("error: missing required argument 'name'");
expect(output).toBe("");
it("Should throw error for missing required argument - name", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCli({
args: ["create", "template", "lang"],
config: {
cli: polywrapCli,
}
});

it("Should throw error for invalid url parameter", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["create", "template", "lang", "demo"],
cli: polywrapCli,
});
expect(code).toEqual(1);
expect(error).toContain("error: missing required argument 'name'");
expect(output).toBe("");
});

expect(code).toEqual(1);
expect(error).toContain(`URL 'lang' uses an invalid format. Valid URL formats: ${Object.values(UrlFormat).join(", ")}`);
expect(output).toBe("");
it("Should throw error for invalid url parameter", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCli({
args: ["create", "template", "lang", "demo"],
config: {
cli: polywrapCli,
}
});

for (const format of Object.values(UrlFormat)) {
const url = urlExamples(format);
expect(code).toEqual(1);
expect(error).toContain(`URL 'lang' uses an invalid format. Valid URL formats: ${Object.values(UrlFormat).join(", ")}`);
expect(output).toBe("");
});

describe(format, () => {
it("Should throw error for missing path argument for --output-dir option", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["create", "template", url, "name", "-o"],
cli: polywrapCli,
});
for (const format of Object.values(UrlFormat)) {
const url = urlExamples(format);

expect(code).toEqual(1);
expect(error).toContain(
"error: option '-o, --output-dir <path>' argument missing"
);
expect(output).toBe("");
describe(format, () => {
it("Should throw error for missing path argument for --output-dir option", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCli({
args: ["create", "template", url, "name", "-o"],
config: {
cli: polywrapCli,
}
});

it("Should successfully generate project", async () => {
rimraf.sync(`${__dirname}/test`);
expect(code).toEqual(1);
expect(error).toContain(
"error: option '-o, --output-dir <path>' argument missing"
);
expect(output).toBe("");
});

const { exitCode: code, stdout: output } = await runCLI({
args: [
"create",
"template",
url,
"test",
"-o",
`${__dirname}/test`,
],
it("Should successfully generate project", async () => {
rimraf.sync(`${__dirname}/test`);

const { exitCode: code, stdout: output } = await runCli({
args: [
"create",
"template",
url,
"test",
"-o",
`${__dirname}/test`,
],
config: {
cwd: __dirname,
cli: polywrapCli,
});
}
});

expect(code).toEqual(0);
expect(clearStyle(output)).toContain(
"🔥 You are ready "
);
expect(code).toEqual(0);
expect(clearStyle(output)).toContain(
"🔥 You are ready "
);

rimraf.sync(`${__dirname}/test`);
}, 60000);
})
}
});
rimraf.sync(`${__dirname}/test`);
}, 60000);
})
}
});
});
2 changes: 1 addition & 1 deletion packages/cli/src/__tests__/e2e/deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const setup = async () => {
modules: ["eth-ens-ipfs"],
})
// Wait a little longer just in case
await new Promise((resolve) => setTimeout(resolve, 3000));
await new Promise((resolve) => setTimeout(resolve, 10000));

// Setup environment variables
process.env = {
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 @@ -8,7 +8,7 @@ import { GetPathToCliTestFiles } from "@polywrap/test-cases";
import { Commands } from "@polywrap/cli-js";
import { TestCommandOptions } from "../../commands";

jest.setTimeout(200000);
jest.setTimeout(100000);

const HELP = `Usage: polywrap test|t [options]
Expand Down
42 changes: 23 additions & 19 deletions packages/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,28 @@ export const build: Command = {
`-l, --log-file [${pathStr}]`,
`${intlMsg.commands_build_options_l()}`
)
.action(async (options: Partial<BuildCommandOptions>) => {
await run({
manifestFile: parseManifestFileOption(
options.manifestFile,
defaultPolywrapManifest
),
clientConfig: options.clientConfig || false,
wrapperEnvs: options.wrapperEnvs || false,
outputDir: parseDirOption(options.outputDir, defaultOutputDir),
noCodegen: options.noCodegen || false,
codegenDir: parseDirOption(options.codegenDir, DEFAULT_CODEGEN_DIR),
strategy: options.strategy || defaultStrategy,
watch: options.watch || false,
verbose: options.verbose || false,
quiet: options.quiet || false,
logFile: parseLogFileOption(options.logFile),
});
});
.action(
async (
options: Partial<BuildCommandOptions> & { codegen: boolean }
) => {
await run({
manifestFile: parseManifestFileOption(
options.manifestFile,
defaultPolywrapManifest
),
clientConfig: options.clientConfig || false,
wrapperEnvs: options.wrapperEnvs || false,
outputDir: parseDirOption(options.outputDir, defaultOutputDir),
noCodegen: !options.codegen || false,
codegenDir: parseDirOption(options.codegenDir, DEFAULT_CODEGEN_DIR),
strategy: options.strategy || defaultStrategy,
watch: options.watch || false,
verbose: options.verbose || false,
quiet: options.quiet || false,
logFile: parseLogFileOption(options.logFile),
});
}
);
},
};

Expand Down Expand Up @@ -213,7 +217,7 @@ async function run(options: Required<BuildCommandOptions>) {
project as PolywrapProject
);

canRunCodegen = language != "interface";
canRunCodegen = language !== "interface";
}

const execute = async (): Promise<boolean> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export const generateProjectTemplate = async (
const isOnline = checkIfOnline(useYarn);

const root = path.resolve(projectDir);
const dependencies: string[] = ["@polywrap/templates"];
const packageNameOverride = process.env.OVERRIDE_CREATE_TEMPLATES_NPM;
const dependencies: string[] = [packageNameOverride || "@polywrap/templates"];

fs.writeFileSync(
path.join(root, "package.json"),
Expand Down
4 changes: 2 additions & 2 deletions packages/interfaces/uri-resolver/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@polywrap/uri-resolver-interface",
"description": "URI Resolver Interface",
"version": "0.10.0-pre.11",
"version": "0.10.0-pre.12",
"scripts": {
"build": "node ../../../dependencies/node_modules/polywrap/bin/polywrap build",
"lint": "eslint --color -c ../../../.eslintrc.js .",
Expand All @@ -10,7 +10,7 @@
"deploy": "npx polywrap deploy"
},
"devDependencies": {
"polywrap": "0.10.0-pre.11"
"polywrap": "0.10.0-pre.12"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/js/asyncify/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@polywrap/asyncify-js",
"description": "Async Wasm Imports Support Using Asyncify",
"version": "0.10.0-pre.11",
"version": "0.10.0-pre.12",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit b5dc785

Please sign in to comment.