-
Notifications
You must be signed in to change notification settings - Fork 1
Init fixes #3
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
Init fixes #3
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a707dac
cleaned up code
steven-passynkov 11b121a
fixes
steven-passynkov 40c2681
fixes
steven-passynkov 0db7899
fixes
steven-passynkov 2e3a1bb
fixes
steven-passynkov 2ab70ee
fixes
steven-passynkov 16bf181
fixes
steven-passynkov 130587b
fixes
steven-passynkov 711502f
fixes
steven-passynkov 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,40 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20.19.0 | ||
| cache: pnpm | ||
| registry-url: https://registry.npmjs.org | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Run tests | ||
| run: pnpm test | ||
|
|
||
| - name: Publish package | ||
| run: npm publish --provenance --access public | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,34 @@ | ||
| import { writeFile } from "node:fs/promises" | ||
| import { writeFile } from "node:fs/promises"; | ||
|
|
||
| import { DEFAULT_DESKTOP_TEMPLATE_NAME, Leap0Client } from "../src/index.js" | ||
|
|
||
| function decodeScreenshot(value: string): Uint8Array { | ||
| const encoded = value.startsWith("data:") ? value.slice(value.indexOf(",") + 1) : value | ||
| return Buffer.from(encoded, "base64") | ||
| } | ||
| import { DEFAULT_DESKTOP_TEMPLATE_NAME, Leap0Client } from "../src/index.js"; | ||
|
|
||
| async function main(): Promise<void> { | ||
| const client = new Leap0Client() | ||
| let sandbox: Awaited<ReturnType<Leap0Client["createSandbox"]>> | null = null | ||
| const client = new Leap0Client(); | ||
|
|
||
| try { | ||
| sandbox = await client.sandboxes.create({ templateName: DEFAULT_DESKTOP_TEMPLATE_NAME }) | ||
| await sandbox.desktop.waitUntilReady(60) | ||
| console.log("Desktop:", sandbox.desktop.browserUrl()) | ||
|
|
||
| const display = await sandbox.desktop.display() | ||
| console.log("Display:", display) | ||
|
|
||
| await sandbox.desktop.movePointer(Math.floor(display.width / 2), Math.floor(display.height / 2)) | ||
| await sandbox.desktop.click(1) | ||
|
|
||
| const screenshot = await sandbox.desktop.screenshot() | ||
| await writeFile("desktop-screenshot.png", decodeScreenshot(screenshot)) | ||
| console.log("Saved screenshot to desktop-screenshot.png") | ||
| } finally { | ||
| if (sandbox) { | ||
| await sandbox.delete() | ||
| const sandbox = await client.sandboxes.create({ templateName: DEFAULT_DESKTOP_TEMPLATE_NAME }); | ||
| try { | ||
| await sandbox.desktop.waitUntilReady(60); | ||
| console.log("Desktop:", sandbox.desktop.desktopUrl()); | ||
|
|
||
| const display = await sandbox.desktop.displayInfo(); | ||
| console.log("Display:", display); | ||
|
|
||
| await sandbox.desktop.movePointer( | ||
| Math.floor(display.width / 2), | ||
| Math.floor(display.height / 2), | ||
| ); | ||
| await sandbox.desktop.click({ button: 1 }); | ||
|
|
||
| const screenshot = await sandbox.desktop.screenshot(); | ||
| await writeFile("desktop-screenshot.png", screenshot); | ||
| console.log("Saved screenshot to desktop-screenshot.png"); | ||
| } finally { | ||
| await sandbox.delete(); | ||
| } | ||
| await client.close() | ||
| } finally { | ||
| await client.close(); | ||
| } | ||
| } | ||
|
|
||
| void main() | ||
| void main(); |
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 |
|---|---|---|
| @@ -1,34 +1,43 @@ | ||
| import { Leap0Client } from "../src/index.js" | ||
| import { Leap0Client } from "../src/index.js"; | ||
|
|
||
| async function main(): Promise<void> { | ||
| const client = new Leap0Client() | ||
| const repoPath = "/workspace/hello-world" | ||
| const client = new Leap0Client(); | ||
| const repoPath = "/workspace/hello-world"; | ||
|
|
||
| try { | ||
| const sandbox = await client.sandboxes.create() | ||
| const sandbox = await client.sandboxes.create(); | ||
|
|
||
| try { | ||
| const clone = await sandbox.git.clone("https://github.com/octocat/Hello-World.git", repoPath) | ||
| console.log("clone exit:", clone.exitCode) | ||
|
|
||
| const status = await sandbox.git.status(repoPath) | ||
| console.log("git status:\n", status.output) | ||
|
|
||
| await sandbox.filesystem.writeFile(`${repoPath}/sdk-demo.txt`, "Hello from the Leap0 JS SDK\n") | ||
| const exists = await sandbox.filesystem.exists(`${repoPath}/sdk-demo.txt`) | ||
| console.log("file exists:", exists.exists) | ||
|
|
||
| const fileInfo = await sandbox.filesystem.stat(`${repoPath}/README`) | ||
| console.log("readme size:", fileInfo.size) | ||
|
|
||
| const tree = await sandbox.filesystem.tree(repoPath, 2) | ||
| console.log("tree items:", tree.entries.map((entry) => entry.name)) | ||
| const clone = await sandbox.git.clone({ | ||
| url: "https://github.com/octocat/Hello-World.git", | ||
| path: repoPath, | ||
| }); | ||
| console.log("clone exit:", clone.exitCode); | ||
|
|
||
| const status = await sandbox.git.status(repoPath); | ||
| console.log("git status:\n", status.output); | ||
|
|
||
| await sandbox.filesystem.writeFile( | ||
| `${repoPath}/sdk-demo.txt`, | ||
| "Hello from the Leap0 JS SDK\n", | ||
| ); | ||
| const exists = await sandbox.filesystem.exists(`${repoPath}/sdk-demo.txt`); | ||
| console.log("file exists:", exists); | ||
|
|
||
| const fileInfo = await sandbox.filesystem.stat(`${repoPath}/README`); | ||
| console.log("readme size:", fileInfo.size); | ||
|
|
||
| const tree = await sandbox.filesystem.tree(repoPath, { maxDepth: 2 }); | ||
| console.log( | ||
| "tree items:", | ||
| tree.items.map((entry: { name: string }) => entry.name), | ||
| ); | ||
| } finally { | ||
| await sandbox.delete() | ||
| await sandbox.delete(); | ||
| } | ||
| } finally { | ||
| await client.close() | ||
| await client.close(); | ||
| } | ||
| } | ||
|
|
||
| void main() | ||
| void main(); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
Whennpm publishis run without--tag, what dist-tag is used by default, and how should prerelease versions be published to avoid settinglatest?💡 Result:
When npm publish is run without --tag, the default dist-tag used is latest. This is confirmed across multiple official npm documentation pages and changelogs. To publish prerelease versions (e.g., versions with a prerelease identifier like 1.0.0-alpha.1) without setting the latest tag, use the --tag flag with a different tag name, such as beta, alpha, next, or rc. For example: npm publish --tag beta. In npm 11 (current as of 2026), publishing prereleases without an explicit --tag requires specifying a tag explicitly; otherwise, it fails to prevent accidentally setting latest. For non-prerelease versions, the default latest is applied only if the version is greater than the current latest semver version (excluding prereleases).
Citations:
🏁 Script executed:
Repository: leap0-dev/leap0-js
Length of output: 1887
Publish prerelease versions with an explicit dist-tag to prevent incorrectly setting
latest.Without
--tag,npm publishdefaults to thelatestdist-tag. Prerelease versions (e.g.,v1.0.0-beta.1) trigger on thev*tag pattern but will incorrectly mark themselves aslatestfor consumers unless explicitly tagged otherwise.Proposed fix
jobs: publish: runs-on: ubuntu-latest @@ - name: Run tests run: pnpm test + - name: Resolve npm dist-tag + id: npm_tag + run: | + if [[ "${GITHUB_REF_NAME#v}" == *-* ]]; then + echo "tag=next" >> "$GITHUB_OUTPUT" + else + echo "tag=latest" >> "$GITHUB_OUTPUT" + fi + - name: Publish package - run: npm publish --provenance --access public + run: npm publish --provenance --access public --tag "${{ steps.npm_tag.outputs.tag }}" env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}🤖 Prompt for AI Agents