-
Notifications
You must be signed in to change notification settings - Fork 49
TS Wraps support #1888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
TS Wraps support #1888
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
81722c2
Added build strategy defaults for JS
namesty 41f464f
Added wrap/js as a language
namesty 0e16386
FIxed naming and giving typescript its own language definition
namesty 0726fed
Merge remote-tracking branch 'origin/origin-dev' into namesty/wrap-js…
namesty 97f13db
Added ts to bind language outputs
namesty 367f349
Image strategy working and building fine
namesty ea10982
Added template project + create command addition
namesty 8a28933
Added build test cases
namesty 3f2dde0
Edited local strategy skip reason
namesty 7e6f22c
Enabled VM build strategy + separated bindings language from build lang
namesty 530e06e
Updated TS template to use VM strategy by default. Like the others
namesty 25e4836
Fixed create spec
namesty 1b174b6
Merge remote-tracking branch 'origin/origin-dev' into namesty/wrap-js…
namesty 5cf3694
Moved buildable language definition + added comments for build strats
namesty 08195b2
Changed bindings URI to Wrapscan URI
namesty 3e60c84
Init VM image at version 0.0.1
namesty 2661b89
Copying moduleFilePath in JS wrap strategies, instead of moduleDirs
namesty fc45feb
Lint fixes
namesty 285ad3b
Merge branch 'origin-dev' into namesty/wrap-ts-support
dOrgJelli 2ddc176
Merge branch 'origin-dev' into namesty/wrap-ts-support
dOrgJelli 702862f
chore: fix polywrap cli install
dOrgJelli 04f2071
chore: fix template tests
dOrgJelli 7419b56
chore: add tests to wrap/typescript
dOrgJelli eaaf9cb
chore: fix lint
dOrgJelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| module.exports = { | ||
| collectCoverage: true, | ||
| preset: "ts-jest", | ||
| testEnvironment: "node", | ||
| globals: { | ||
| "ts-jest": { | ||
| diagnostics: false | ||
| }, | ||
| }, | ||
| modulePathIgnorePatterns: [ | ||
| "<rootDir>/build", | ||
| "<rootDir>/src/__tests__/project/.polywrap" | ||
| ], | ||
| testPathIgnorePatterns: [ | ||
| "<rootDir>/src/__tests__/project/.polywrap" | ||
| ], | ||
| transformIgnorePatterns: [ | ||
| "<rootDir>/src/__tests__/project/.polywrap" | ||
| ], | ||
| setupFilesAfterEnv: ["./jest.setup.js"], | ||
| testMatch: ["**/build-ts.spec.ts"] | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { polywrapCli } from "./utils"; | ||
| import { Commands } from "@polywrap/cli-js"; | ||
| import { GetPathToCliTestFiles } from "@polywrap/test-cases"; | ||
| import fs from "fs"; | ||
| import path from "path"; | ||
|
|
||
| jest.setTimeout(1500000); | ||
|
|
||
| describe("e2e tests for build command", () => { | ||
| const testCaseRoot = path.join(GetPathToCliTestFiles(), "build-cmd/wasm/typescript"); | ||
| const testCases = fs | ||
| .readdirSync(testCaseRoot, { withFileTypes: true }) | ||
| .filter((dirent) => dirent.isDirectory()) | ||
| .map((dirent) => dirent.name); | ||
|
|
||
| const getTestCaseDir = (index: number) => | ||
| path.join(testCaseRoot, testCases[index]); | ||
|
|
||
| describe("Image strategy", () => { | ||
| it("Builds for typescript", async () => { | ||
| const { exitCode: code, stdout: output } = await Commands.build({ | ||
| strategy: "image", | ||
| verbose: true | ||
| }, { | ||
| cwd: getTestCaseDir(0), | ||
| cli: polywrapCli, | ||
| }); | ||
| const buildDir = `./build`; | ||
|
|
||
| expect(code).toEqual(0); | ||
| expect(output).toContain(`Artifacts written to ${buildDir}`); | ||
| expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`); | ||
| }); | ||
| }) | ||
|
|
||
| // NOTE: Skipped because CI needs system prequisites: pwr CLI | ||
| describe.skip("Local strategy", () => { | ||
| it("Builds for typescript", async () => { | ||
| const { exitCode: code, stdout: output } = await Commands.build({ | ||
| strategy: "local", | ||
| verbose: true | ||
| }, { | ||
| cwd: getTestCaseDir(0), | ||
| cli: polywrapCli, | ||
| }); | ||
|
|
||
| const buildDir = `./build`; | ||
|
|
||
| expect(code).toEqual(0); | ||
| expect(output).toContain(`Artifacts written to ${buildDir}`); | ||
| expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`); | ||
| }); | ||
| }) | ||
|
|
||
| describe("VM strategy", () => { | ||
| it("Builds for typescript", async () => { | ||
| const { exitCode: code, stdout: output } = await Commands.build({ | ||
| strategy: "vm", | ||
| verbose: true | ||
| }, { | ||
| cwd: getTestCaseDir(0), | ||
| cli: polywrapCli, | ||
| }); | ||
|
|
||
| const buildDir = `./build`; | ||
|
|
||
| expect(code).toEqual(0); | ||
| expect(output).toContain(`Artifacts written to ${buildDir}`); | ||
| expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`); | ||
| }); | ||
| }) | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/cli/src/lib/defaults/build-strategies/wasm/javascript/default.build.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| format: 0.3.0 |
14 changes: 14 additions & 0 deletions
14
packages/cli/src/lib/defaults/build-strategies/wasm/javascript/image/Dockerfile.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| FROM ubuntu:latest | ||
| # Install curl and git | ||
| RUN apt-get update && apt-get install -y curl git | ||
|
|
||
| # Download and install pwrup | ||
| RUN curl -L https://raw.githubusercontent.com/polywrap/pwr/main/pwrup/install | bash | ||
| # Source bash and use pwrup to install pwr | ||
| RUN /bin/bash -i -c "source ~/.bashrc; pwrup" | ||
|
|
||
| WORKDIR /project | ||
| # Copy the script file to build | ||
| COPY {{#polywrap_module}}{{moduleFilePath}}{{/polywrap_module}} ./wrap.js | ||
| # Use pwr to build the script | ||
| RUN /bin/bash -i -c "pwr js build -f ./wrap.js -o build" |
8 changes: 8 additions & 0 deletions
8
packages/cli/src/lib/defaults/build-strategies/wasm/javascript/local/local.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Assumes user has curl and git installed | ||
| # Install pwrup | ||
| curl -L https://raw.githubusercontent.com/polywrap/pwr/main/pwrup/install | bash | ||
|
|
||
| # Use pwrup to install pwr | ||
| $HOME/.pwr/bin/pwrup | ||
| # Use pwr to build the script | ||
| $HOME/.pwr/bin/pwr js build -f $3 -o build |
14 changes: 14 additions & 0 deletions
14
packages/cli/src/lib/defaults/build-strategies/wasm/javascript/manifest.ext.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "properties": { | ||
| "config": { | ||
| "type": "object", | ||
| "required": ["scriptFile"], | ||
| "properties": { | ||
| "scriptFile": { | ||
| "description": "Path to the JS file to build the wrap from", | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
packages/cli/src/lib/defaults/build-strategies/wasm/javascript/vm/Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| FROM ubuntu:latest | ||
| # Install curl and git | ||
| RUN apt-get update && apt-get install -y curl git | ||
|
|
||
| # Download and install pwrup and then use it to install pwr | ||
| RUN curl -L https://raw.githubusercontent.com/polywrap/pwr/main/pwrup/install | bash && /root/.pwr/bin/pwrup | ||
|
|
||
| WORKDIR /project | ||
1 change: 1 addition & 0 deletions
1
packages/cli/src/lib/defaults/build-strategies/wasm/javascript/vm/NAME
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| polywrap/vm-base-js |
1 change: 1 addition & 0 deletions
1
packages/cli/src/lib/defaults/build-strategies/wasm/javascript/vm/VERSION
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 0.0.1 |
4 changes: 4 additions & 0 deletions
4
packages/cli/src/lib/defaults/build-strategies/wasm/javascript/vm/vm-script.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| set -e | ||
|
|
||
| {{! Use pwr to build the script }} | ||
| /root/.pwr/bin/pwr js build -f {{#polywrap_module}}{{moduleFilePath}}{{/polywrap_module}} -o build |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.