-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1437 from polywrap/pileks/feat/cli-wrapper-envs-o…
…ption CLI - Add `--wrapper-envs` option to `build`, `codegen`, `docgen` and `test`
- Loading branch information
Showing
17 changed files
with
244 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
64 changes: 64 additions & 0 deletions
64
packages/cli/src/__tests__/unit/option-parsers/option-parsers.spec.ts
This file contains 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,64 @@ | ||
import { Uri } from "@polywrap/core-js"; | ||
import path from "path"; | ||
import { parseWrapperEnvsOption } from "../../../lib"; | ||
|
||
describe("unit tests for option-parsers", () => { | ||
describe("wrapper-envs", () => { | ||
const sampleFileEnvs = [ | ||
{ | ||
uri: Uri.from("wrap://ens/hello-world.polywrap.eth"), | ||
env: { | ||
foo: "bar", | ||
}, | ||
}, | ||
{ | ||
uri: Uri.from("ens/ethereum.polywrap.eth"), | ||
env: { | ||
connection: { | ||
node: "https://mainnet.infura.io/v3/some_api_key", | ||
networkNameOrChainId: "mainnet", | ||
}, | ||
}, | ||
}, | ||
]; | ||
|
||
it("Should return undefined when no filename is provided", async () => { | ||
const envs = await parseWrapperEnvsOption(undefined); | ||
|
||
expect(envs).toBeUndefined(); | ||
}); | ||
|
||
it("Should throw for a nonexistent wrapper-env file", async () => { | ||
const nonExistentFilePath = path.join( | ||
__dirname, | ||
"./samples/nonexistent.json" | ||
); | ||
|
||
await expect(async () => { | ||
await parseWrapperEnvsOption(nonExistentFilePath); | ||
}).rejects.toThrow(); | ||
}); | ||
|
||
it("Should return envs for a valid json file", async () => { | ||
const wrapperEnvsFilePath = path.join( | ||
__dirname, | ||
"./samples/wrapper-envs.json" | ||
); | ||
|
||
const envs = await parseWrapperEnvsOption(wrapperEnvsFilePath); | ||
|
||
expect(envs).toEqual(sampleFileEnvs); | ||
}); | ||
|
||
it("Should return envs for a valid yaml file", async () => { | ||
const wrapperEnvsFilePath = path.join( | ||
__dirname, | ||
"./samples/wrapper-envs.yaml" | ||
); | ||
|
||
const envs = await parseWrapperEnvsOption(wrapperEnvsFilePath); | ||
|
||
expect(envs).toEqual(sampleFileEnvs); | ||
}); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/cli/src/__tests__/unit/option-parsers/samples/wrapper-envs.json
This file contains 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,11 @@ | ||
{ | ||
"ens/hello-world.polywrap.eth": { | ||
"foo": "bar" | ||
}, | ||
"ens/ethereum.polywrap.eth": { | ||
"connection": { | ||
"node": "https://mainnet.infura.io/v3/some_api_key", | ||
"networkNameOrChainId": "mainnet" | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/cli/src/__tests__/unit/option-parsers/samples/wrapper-envs.yaml
This file contains 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,6 @@ | ||
ens/hello-world.polywrap.eth: | ||
foo: bar | ||
ens/ethereum.polywrap.eth: | ||
connection: | ||
node: https://mainnet.infura.io/v3/some_api_key | ||
networkNameOrChainId: mainnet |
This file contains 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 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 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
Oops, something went wrong.