Skip to content

Commit a84d7b7

Browse files
committed
init: ucloud sandbox cli sdk
1 parent bf9033d commit a84d7b7

258 files changed

Lines changed: 38079 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.envrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source_up
2+
3+
dotenv ../../../.env.local

.eslintrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '../../.eslintrc.cjs',
4+
}

.github/workflows/publish.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish to NPM
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "发布版本号 (例如: 1.0.0)"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
id-token: write
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
environment: ucloud-sandbox-cli
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Setup pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: 9
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: "20"
36+
registry-url: "https://registry.npmjs.org"
37+
cache: "pnpm"
38+
39+
- name: Install dependencies
40+
run: pnpm install
41+
42+
- name: Build js-sdk
43+
run: cd packages/js-sdk && pnpm install && npx tsup
44+
45+
- name: Build CLI
46+
run: pnpm build
47+
48+
- name: Update version
49+
run: npm version ${{ github.event.inputs.version }} --no-git-tag-version --allow-same-version
50+
51+
- name: Publish to npm
52+
env:
53+
NODE_AUTH_TOKEN: ${{ secrets.NPM_JS_AUTH }}
54+
run: npm publish
55+
56+
- name: Commit and push version update
57+
run: |
58+
git config user.name "github-actions[bot]"
59+
git config user.email "github-actions[bot]@users.noreply.github.com"
60+
git add package.json
61+
git diff --staged --quiet || git commit -m "chore: bump version to ${{ github.event.inputs.version }}"
62+
git push origin HEAD:main

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
tests/temp
6+
coverage
7+
/.pnp
8+
.pnp.js
9+
10+
# testing
11+
/coverage
12+
13+
# misc
14+
.DS_Store
15+
.env.local
16+
.env.development.local
17+
.env.test.local
18+
.env.production.local
19+
20+
npm-debug.log*
21+
yarn-debug.log*
22+
yarn-error.log*
23+
24+
# Optional npm cache directory
25+
.npm
26+
27+
# Optional eslint cache
28+
.eslintcache
29+
30+
# Output of 'npm pack'
31+
*.tgz
32+
33+
# Yarn Integrity file
34+
.yarn-integrity
35+
36+
# generate output
37+
dist
38+
39+
# compiled binary addons (https://nodejs.org/api/addons.html)
40+
build/Release
41+
42+
/test.md
43+
logs.txt
44+
/dist
45+
/files

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.hbs
2+
tests/**/fixtures/**/*

LICENSE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
MIT License
2+
3+
Copyright (c) 2025 UCloud Technology Co., Ltd.
4+
5+
This project is based on E2B (https://github.com/e2b-dev/e2b), originally developed by FoundryLabs, Inc.
6+
Original E2B License: MIT License, Copyright (c) 2025 FOUNDRYLABS, INC.
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11+
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
.PHONY: install build dev link test clean help publish patch minor major
2+
3+
# Install dependencies
4+
install:
5+
pnpm install
6+
7+
# Build the CLI
8+
build:
9+
pnpm build
10+
11+
# Development mode with watch
12+
dev:
13+
pnpm dev
14+
15+
# Link CLI globally
16+
link: build
17+
pnpm link --global
18+
19+
# Run tests
20+
test:
21+
pnpm test
22+
23+
# Clean build artifacts
24+
clean:
25+
rm -rf dist
26+
27+
# Full rebuild
28+
rebuild: clean build
29+
30+
# Quick build and test
31+
quick: build
32+
./dist/index.js --help
33+
34+
# Login
35+
login:
36+
./dist/index.js auth login
37+
38+
# List templates
39+
tpl-list:
40+
./dist/index.js tpl list
41+
42+
# Version bump (patch: 0.1.0 -> 0.1.1)
43+
patch:
44+
npm version patch --no-git-tag-version
45+
46+
# Version bump (minor: 0.1.0 -> 0.2.0)
47+
minor:
48+
npm version minor --no-git-tag-version
49+
50+
# Version bump (major: 0.1.0 -> 1.0.0)
51+
major:
52+
npm version major --no-git-tag-version
53+
54+
# Publish to npm (auto bump patch version)
55+
publish: patch build
56+
npm publish --access public
57+
58+
# Publish without version bump
59+
publish-only: build
60+
npm publish --access public
61+
62+
# Help
63+
help:
64+
@echo "Available targets:"
65+
@echo " install - Install dependencies"
66+
@echo " build - Build the CLI"
67+
@echo " dev - Start development mode with watch"
68+
@echo " link - Build and link CLI globally"
69+
@echo " test - Run tests"
70+
@echo " clean - Remove build artifacts"
71+
@echo " rebuild - Clean and rebuild"
72+
@echo " quick - Build and show help"
73+
@echo " login - Run auth login"
74+
@echo " tpl-list - List templates"
75+
@echo " patch - Bump patch version (0.1.0 -> 0.1.1)"
76+
@echo " minor - Bump minor version (0.1.0 -> 0.2.0)"
77+
@echo " major - Bump major version (0.1.0 -> 1.0.0)"
78+
@echo " publish - Bump patch version and publish to npm"
79+
@echo " publish-only - Publish to npm without version bump"
80+
@echo " help - Show this help"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ucloud_sandbox CLI

package.json

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"name": "ucloud-sandbox-cli",
3+
"version": "0.1.0",
4+
"description": "CLI for managing UCloud sandbox templates",
5+
"homepage": "https://sandbox.ucloudai.com",
6+
"license": "MIT",
7+
"author": {
8+
"name": "jason.mei"
9+
},
10+
"bugs": "https://github.com/ucloud/ucloud-sandbox-cli/issues",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/ucloud/ucloud-sandbox-cli.git",
14+
"directory": "packages/cli"
15+
},
16+
"publishConfig": {
17+
"access": "public"
18+
},
19+
"keywords": [
20+
"ucloud",
21+
"ai-agents",
22+
"agents",
23+
"ai",
24+
"code-interpreter",
25+
"sandbox",
26+
"code",
27+
"cli",
28+
"runtime",
29+
"vm",
30+
"nodejs",
31+
"javascript",
32+
"typescript"
33+
],
34+
"sideEffects": false,
35+
"scripts": {
36+
"prepublishOnly": "pnpm build",
37+
"build": "tsc --noEmit --skipLibCheck && tsup --minify",
38+
"dev": "tsup --watch",
39+
"lint": "eslint src",
40+
"format": "prettier --write src",
41+
"test:interactive": "pnpm build && ./dist/index.js",
42+
"test": "vitest run",
43+
"test:watch": "vitest watch",
44+
"test:coverage": "vitest run --coverage",
45+
"check-deps": "knip",
46+
"update-deps": "ncu -u && pnpm i",
47+
"generate-ref": "./scripts/generate_sdk_ref.sh"
48+
},
49+
"devDependencies": {
50+
"e2b": "file:./packages/js-sdk",
51+
"@types/command-exists": "^1.2.3",
52+
"@types/handlebars": "^4.1.0",
53+
"@types/inquirer": "^9.0.7",
54+
"@types/json2md": "^1.5.4",
55+
"@types/node": "^20.19.19",
56+
"@types/npmcli__package-json": "^4.0.4",
57+
"@types/statuses": "^2.0.5",
58+
"@types/update-notifier": "6.0.5",
59+
"@vitest/coverage-v8": "^3.2.4",
60+
"json2md": "^2.0.1",
61+
"knip": "^5.43.6",
62+
"npm-check-updates": "^16.14.6",
63+
"tsup": "^8.4.0",
64+
"typescript": "^5.2.2",
65+
"vitest": "^3.2.4"
66+
},
67+
"files": [
68+
"dist",
69+
"LICENSE",
70+
"README.md",
71+
"package.json"
72+
],
73+
"bin": {
74+
"ucloud-sandbox-cli": "dist/index.js"
75+
},
76+
"dependencies": {
77+
"@iarna/toml": "^2.2.5",
78+
"@inquirer/prompts": "^7.9.0",
79+
"@npmcli/package-json": "^5.2.1",
80+
"async-listen": "^3.0.1",
81+
"boxen": "^7.1.1",
82+
"chalk": "^5.3.0",
83+
"cli-highlight": "^2.1.11",
84+
"command-exists": "^1.2.9",
85+
"commander": "^11.1.0",
86+
"console-table-printer": "^2.11.2",
87+
"dockerfile-ast": "^0.6.1",
88+
"handlebars": "^4.7.8",
89+
"inquirer": "^12.10.0",
90+
"open": "^9.1.0",
91+
"statuses": "^2.0.1",
92+
"strip-ansi": "^7.1.0",
93+
"update-notifier": "^6.0.2",
94+
"yup": "^1.3.2"
95+
},
96+
"engines": {
97+
"node": ">=20"
98+
}
99+
}

packages/js-sdk/.eslintrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '../../.eslintrc.cjs',
4+
}

0 commit comments

Comments
 (0)