-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add the ability to override the default example repository URL…
… and ref
- Loading branch information
1 parent
110f572
commit 381b81d
Showing
7 changed files
with
88 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extensions": ["ts"], | ||
"spec": ["**/*.test.*"], | ||
"loader": "ts-node/esm" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
import type { Example, PackageManager } from "@/types.js" | ||
|
||
/** | ||
* To enable example development in a custom repository | ||
* we open the repository URL field to be taken from the environment | ||
*/ | ||
const repository = process.env["LAYERZERO_EXAMPLES_REPOSITORY_URL"] || "[email protected]:LayerZero-Labs/lz-utils" | ||
|
||
/** | ||
* To enable example development in a custom branch, | ||
* we open up the ref field to be taken from the environment | ||
* | ||
* `LAYERZERO_EXAMPLES_REPOSITORY_REF` can then be set to something like `#develop` or `#my-custom-branch` | ||
* to take the examples from a tag, a branch or a commit hash | ||
*/ | ||
const ref = process.env["LAYERZERO_EXAMPLES_REPOSITORY_REF"] || "" | ||
|
||
export const EXAMPLES: Example[] = [ | ||
{ | ||
id: "oft", | ||
label: "OFT", | ||
repository: "[email protected]:LayerZero-Labs/lz-examples", | ||
directory: "packages/oft", | ||
repository, | ||
directory: "examples/oft", | ||
ref, | ||
}, | ||
{ | ||
id: "oapp", | ||
label: "OApp", | ||
repository: "[email protected]:LayerZero-Labs/lz-examples", | ||
directory: "packages/oapp", | ||
repository, | ||
directory: "examples/oapp", | ||
ref, | ||
}, | ||
] | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expect } from "chai" | ||
import { describe, it } from "mocha" | ||
import { createExampleGitURL } from "../../src/utilities/cloning.js" | ||
|
||
describe("utilities/cloning", () => { | ||
describe("createExampleGitURL", () => { | ||
const REPO_URL = "[email protected]:LayerZero-Labs/lz-utils" | ||
|
||
it("should return the repository field if directory and ref are not specified", () => { | ||
expect(createExampleGitURL({ repository: REPO_URL, id: "dummy", label: "Dummy" })).to.eql(REPO_URL) | ||
}) | ||
|
||
it("should return the repository field with directory if directory is specified", () => { | ||
expect(createExampleGitURL({ repository: REPO_URL, directory: "dir", id: "dummy", label: "Dummy" })).to.eql(`${REPO_URL}/dir`) | ||
expect(createExampleGitURL({ repository: REPO_URL, directory: "/dir", id: "dummy", label: "Dummy" })).to.eql(`${REPO_URL}/dir`) | ||
expect(createExampleGitURL({ repository: REPO_URL, directory: "dir", ref: "", id: "dummy", label: "Dummy" })).to.eql( | ||
`${REPO_URL}/dir` | ||
) | ||
}) | ||
|
||
it("should return the repository field with directory and ref if directory and ref are specified", () => { | ||
expect(createExampleGitURL({ repository: REPO_URL, directory: "dir", ref: "ref", id: "dummy", label: "Dummy" })).to.eql( | ||
`${REPO_URL}/dir#ref` | ||
) | ||
expect(createExampleGitURL({ repository: REPO_URL, directory: "dir", ref: "#ref", id: "dummy", label: "Dummy" })).to.eql( | ||
`${REPO_URL}/dir#ref` | ||
) | ||
}) | ||
|
||
it("should return the repository field with ref if only ref specified", () => { | ||
expect(createExampleGitURL({ repository: REPO_URL, ref: "ref", id: "dummy", label: "Dummy" })).to.eql(`${REPO_URL}#ref`) | ||
expect(createExampleGitURL({ repository: REPO_URL, ref: "#ref", id: "dummy", label: "Dummy" })).to.eql(`${REPO_URL}#ref`) | ||
}) | ||
}) | ||
}) |
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