Skip to content

Commit

Permalink
Merge pull request #822 from polywrap/prealpha-dev
Browse files Browse the repository at this point in the history
Prep 0.0.1-prealpha.73
  • Loading branch information
dOrgJelli authored Apr 23, 2022
2 parents 5f7c914 + 7b0205f commit e2fbd65
Show file tree
Hide file tree
Showing 248 changed files with 3,670 additions and 1,486 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/release-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ jobs:
github.event.pull_request.merged == true
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.base.ref }}

- name: Read VERSION into env.RELEASE_VERSION
run: echo RELEASE_VERSION=$(cat VERSION) >> $GITHUB_ENV

- name: Read .nvmrc into env.NVMRC
run: echo NVMRC=$(cat .nvmrc) >> $GITHUB_ENV

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '${{env.NVMRC}}'

- name: Auth into NPM
if: ${{env.TAG_EXISTS}} == 'false'
run: |
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Web3API 0.0.1-prealpha.73
## Bugs
* [PR-821](https://github.com/polywrap/monorepo/pull/821) `@web3api/cli`: Fixed a codegen issue when generating types for plugins with only one module.

# Web3API 0.0.1-prealpha.72
## Features
* [PR-620](https://github.com/polywrap/monorepo/pull/620) Plugin DevExp Improvements: The plugin developer experience has been revised to be very close to the API development experience.
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.72
0.0.1-prealpha.73
1 change: 0 additions & 1 deletion packages/cli/src/__tests__/app/web3api.app.graphql

This file was deleted.

6 changes: 0 additions & 6 deletions packages/cli/src/__tests__/app/web3api.app.multiPackage.yaml

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions packages/cli/src/__tests__/app/web3api.app.withPlugin.yaml

This file was deleted.

123 changes: 41 additions & 82 deletions packages/cli/src/__tests__/e2e/app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import path from "path";
import { clearStyle, w3Cli } from "./utils";

import { runCLI } from "@web3api/test-env-js";
import { GetPathToCliTestFiles } from "@web3api/test-cases";
import path from "path";
import fs from "fs";

const HELP = `
w3 app command [options]
Expand All @@ -17,24 +20,27 @@ Options:
`;

describe("e2e tests for app command", () => {
const projectRoot = path.resolve(__dirname, "../app/");
const simpleStorageProject = path.resolve(__dirname, "../project/");

beforeAll(async () => {
await testEnvUp(simpleStorageProject);
await buildApi(simpleStorageProject);
});
const CODEGEN_SUCCESS = `- Manifest loaded from ./web3api.app.yaml
✔ Manifest loaded from ./web3api.app.yaml
- Generate types
✔ Generate types
🔥 Code was generated successfully 🔥
`;

afterAll(async () => {
await testEnvDown(simpleStorageProject);
});
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 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", "codegen", "--help"],
cwd: projectRoot,
cwd: getTestCaseDir(0),
cli: w3Cli,
},
);
Expand All @@ -48,7 +54,7 @@ describe("e2e tests for app command", () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["app", "--output-dir"],
cwd: projectRoot,
cwd: getTestCaseDir(0),
cli: w3Cli,
},
);
Expand All @@ -63,7 +69,7 @@ ${HELP}`);
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["app", "codegen", "--codegen-dir"],
cwd: projectRoot,
cwd: getTestCaseDir(0),
cli: w3Cli,
},
);
Expand All @@ -79,7 +85,7 @@ ${HELP}`);
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["app", "codegen", "--ens"],
cwd: projectRoot,
cwd: getTestCaseDir(0),
cli: w3Cli,
},
);
Expand All @@ -91,71 +97,24 @@ ${HELP}`);
${HELP}`);
});

test("Should successfully generate types for plugins", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["app", "codegen", "-m", `${projectRoot}/web3api.app.withPlugin.yaml`],
cwd: projectRoot,
cli: w3Cli,
},
);

expect(error).toBe("");
expect(code).toEqual(0);
expect(clearStyle(output)).toEqual(`- Manifest loaded from ./web3api.app.withPlugin.yaml
✔ Manifest loaded from ./web3api.app.withPlugin.yaml
- Generate types
✔ Generate types
🔥 Code was generated successfully 🔥
`);
});

test("Should successfully generate types for multiple packages", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["app", "codegen", "-m", `${projectRoot}/web3api.app.multiPackage.yaml`],
cwd: projectRoot,
cli: w3Cli,
},
);

expect(error).toBe("");
expect(code).toEqual(0);
expect(clearStyle(output)).toEqual(`- Manifest loaded from ./web3api.app.multiPackage.yaml
✔ Manifest loaded from ./web3api.app.multiPackage.yaml
- Generate types
✔ Generate types
🔥 Code was generated successfully 🔥
`);
describe("test-cases", () => {
for (let i = 0; i < testCases.length; ++i) {
const testCaseName = testCases[i];
const testCaseDir = getTestCaseDir(i);

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

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

async function testEnvUp(cwd: string): Promise<void> {
const { exitCode: testenvCode, stderr: testEnvUpErr } = await runCLI({
args: ["test-env", "up"],
cwd: cwd,
cli: w3Cli,
});
expect(testEnvUpErr).toBe("");
expect(testenvCode).toEqual(0);
}

async function testEnvDown(cwd: string): Promise<void> {
await runCLI({
args: ["test-env", "down"],
cwd: cwd,
cli: w3Cli,
});
}

async function buildApi(cwd: string): Promise<void> {
const { exitCode: buildCode, stderr: buildErr } = await runCLI({
args: [
"build",
],
cwd: cwd,
cli: w3Cli,
});
expect(buildErr).toBe("");
expect(buildCode).toEqual(0);
}
Loading

0 comments on commit e2fbd65

Please sign in to comment.