sealos-cli 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -60
- package/dist/bin/cli.cjs +145 -21
- package/dist/bin/cli.mjs +145 -21
- package/dist/main.cjs +145 -21
- package/dist/main.mjs +145 -21
- package/package.json +5 -4
- package/src/commands/app/index.ts +5 -4
- package/src/commands/database/index.ts +1 -1
- package/src/commands/quota/index.ts +4 -3
- package/src/commands/s3/index.ts +5 -5
- package/src/commands/template/index.ts +4 -4
- package/src/lib/api-client.ts +1 -1
- package/src/lib/auth.ts +5 -5
- package/src/lib/errors.ts +1 -1
- package/src/lib/output.ts +5 -6
- package/src/main.ts +3 -2
package/dist/bin/cli.mjs
CHANGED
|
@@ -68,7 +68,7 @@ __name(saveAuth, "saveAuth");
|
|
|
68
68
|
function loadAuth(deps = {}) {
|
|
69
69
|
const { paths } = withDeps(deps);
|
|
70
70
|
if (!existsSync(paths.authPath)) {
|
|
71
|
-
throw new Error("Not authenticated. Please run: sealos login");
|
|
71
|
+
throw new Error("Not authenticated. Please run: sealos-cli login");
|
|
72
72
|
}
|
|
73
73
|
return JSON.parse(readFileSync(paths.authPath, "utf-8"));
|
|
74
74
|
}
|
|
@@ -90,7 +90,7 @@ __name(getAuthHeaders, "getAuthHeaders");
|
|
|
90
90
|
function requireAuth(deps = {}) {
|
|
91
91
|
const headers = getAuthHeaders(deps);
|
|
92
92
|
if (!headers) {
|
|
93
|
-
throw new Error('Authentication required. Please run "sealos login" first.');
|
|
93
|
+
throw new Error('Authentication required. Please run "sealos-cli login" first.');
|
|
94
94
|
}
|
|
95
95
|
return headers;
|
|
96
96
|
}
|
|
@@ -376,7 +376,7 @@ __name(loginWithDeviceFlow, "loginWithDeviceFlow");
|
|
|
376
376
|
async function listWorkspaces(deps = {}) {
|
|
377
377
|
const auth = loadAuth(deps);
|
|
378
378
|
if (!auth.regional_token) {
|
|
379
|
-
throw new Error("No regional_token found. Please run: sealos login");
|
|
379
|
+
throw new Error("No regional_token found. Please run: sealos-cli login");
|
|
380
380
|
}
|
|
381
381
|
const workspaces = await listRemoteWorkspaces(auth.region, auth.regional_token, deps);
|
|
382
382
|
return {
|
|
@@ -393,12 +393,12 @@ async function listWorkspaces(deps = {}) {
|
|
|
393
393
|
__name(listWorkspaces, "listWorkspaces");
|
|
394
394
|
async function switchWorkspace(target, deps = {}) {
|
|
395
395
|
if (!target) {
|
|
396
|
-
throw new Error("Usage: sealos auth switch <namespace-id-or-uid>");
|
|
396
|
+
throw new Error("Usage: sealos-cli auth switch <namespace-id-or-uid>");
|
|
397
397
|
}
|
|
398
398
|
const fullDeps = withDeps(deps);
|
|
399
399
|
const auth = loadAuth(fullDeps);
|
|
400
400
|
if (!auth.regional_token) {
|
|
401
|
-
throw new Error("No regional_token found. Please run: sealos login");
|
|
401
|
+
throw new Error("No regional_token found. Please run: sealos-cli login");
|
|
402
402
|
}
|
|
403
403
|
const workspaces = await listRemoteWorkspaces(auth.region, auth.regional_token, fullDeps);
|
|
404
404
|
if (workspaces.length === 0) {
|
|
@@ -3366,11 +3366,7 @@ var StdinDiscarder = class {
|
|
|
3366
3366
|
}
|
|
3367
3367
|
const code = typeof chunk === "string" ? chunk.codePointAt(0) : chunk[0];
|
|
3368
3368
|
if (code === ASCII_ETX_CODE) {
|
|
3369
|
-
|
|
3370
|
-
process7.emit("SIGINT");
|
|
3371
|
-
} else {
|
|
3372
|
-
process7.kill(process7.pid, "SIGINT");
|
|
3373
|
-
}
|
|
3369
|
+
process7.kill(process7.pid, "SIGINT");
|
|
3374
3370
|
}
|
|
3375
3371
|
}, "#handleInputBound");
|
|
3376
3372
|
start() {
|
|
@@ -3427,6 +3423,7 @@ var RENDER_DEFERRAL_TIMEOUT = 200;
|
|
|
3427
3423
|
var SYNCHRONIZED_OUTPUT_ENABLE = "\x1B[?2026h";
|
|
3428
3424
|
var SYNCHRONIZED_OUTPUT_DISABLE = "\x1B[?2026l";
|
|
3429
3425
|
var activeHooksPerStream = /* @__PURE__ */ new Map();
|
|
3426
|
+
var validColors = /* @__PURE__ */ new Set(["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray"]);
|
|
3430
3427
|
var Ora = class {
|
|
3431
3428
|
static {
|
|
3432
3429
|
__name(this, "Ora");
|
|
@@ -3443,7 +3440,7 @@ var Ora = class {
|
|
|
3443
3440
|
#drainHandler;
|
|
3444
3441
|
#deferRenderTimer;
|
|
3445
3442
|
#isDiscardingStdin = false;
|
|
3446
|
-
color;
|
|
3443
|
+
#color;
|
|
3447
3444
|
// Helper to execute writes while preventing hook recursion
|
|
3448
3445
|
#internalWrite(fn) {
|
|
3449
3446
|
this.#isInternalWrite = true;
|
|
@@ -3528,6 +3525,9 @@ var Ora = class {
|
|
|
3528
3525
|
if (typeof this.#options.isSilent !== "boolean") {
|
|
3529
3526
|
this.#options.isSilent = false;
|
|
3530
3527
|
}
|
|
3528
|
+
if (this.#options.interval !== void 0 && !(Number.isInteger(this.#options.interval) && this.#options.interval > 0)) {
|
|
3529
|
+
throw new Error("The `interval` option must be a positive integer");
|
|
3530
|
+
}
|
|
3531
3531
|
const userInterval = this.#options.interval;
|
|
3532
3532
|
this.spinner = this.#options.spinner;
|
|
3533
3533
|
this.#options.interval = userInterval;
|
|
@@ -3642,6 +3642,15 @@ var Ora = class {
|
|
|
3642
3642
|
}
|
|
3643
3643
|
return count;
|
|
3644
3644
|
}
|
|
3645
|
+
get color() {
|
|
3646
|
+
return this.#color;
|
|
3647
|
+
}
|
|
3648
|
+
set color(value) {
|
|
3649
|
+
if (value !== void 0 && value !== false && !validColors.has(value)) {
|
|
3650
|
+
throw new Error("The `color` option must be a valid color or `false` to disable");
|
|
3651
|
+
}
|
|
3652
|
+
this.#color = value;
|
|
3653
|
+
}
|
|
3645
3654
|
get isEnabled() {
|
|
3646
3655
|
return this.#options.isEnabled && !this.#options.isSilent;
|
|
3647
3656
|
}
|
|
@@ -3668,8 +3677,8 @@ var Ora = class {
|
|
|
3668
3677
|
}
|
|
3669
3678
|
const { frames } = this.#spinner;
|
|
3670
3679
|
let frame = frames[this.#frameIndex];
|
|
3671
|
-
if (this
|
|
3672
|
-
frame = source_default[this
|
|
3680
|
+
if (this.#color) {
|
|
3681
|
+
frame = source_default[this.#color](frame);
|
|
3673
3682
|
}
|
|
3674
3683
|
const fullPrefixText = this.#getFullPrefixText(this.#options.prefixText, " ");
|
|
3675
3684
|
const fullText = typeof this.text === "string" ? " " + this.text : "";
|
|
@@ -3916,7 +3925,7 @@ var AuthError = class extends CliError {
|
|
|
3916
3925
|
static {
|
|
3917
3926
|
__name(this, "AuthError");
|
|
3918
3927
|
}
|
|
3919
|
-
constructor(message = 'Authentication required. Please run "sealos login" first.') {
|
|
3928
|
+
constructor(message = 'Authentication required. Please run "sealos-cli login" first.') {
|
|
3920
3929
|
super(message, 1);
|
|
3921
3930
|
this.name = "AuthError";
|
|
3922
3931
|
}
|
|
@@ -4717,7 +4726,7 @@ function resolveHost(options) {
|
|
|
4717
4726
|
}
|
|
4718
4727
|
const host = options?.baseUrl || process.env.SEALOS_REGION || authRegion || DEFAULT_SEALOS_REGION;
|
|
4719
4728
|
if (!host) {
|
|
4720
|
-
throw new ConfigError('No Sealos Cloud host configured. Run "sealos login <host>" first.');
|
|
4729
|
+
throw new ConfigError('No Sealos Cloud host configured. Run "sealos-cli login <host>" first.');
|
|
4721
4730
|
}
|
|
4722
4731
|
return host.replace(/\/+$/, "");
|
|
4723
4732
|
}
|
|
@@ -5680,7 +5689,7 @@ function createDatabaseCommand() {
|
|
|
5680
5689
|
}
|
|
5681
5690
|
ctx.spinner.succeed(`Database "${data.name}" created successfully`);
|
|
5682
5691
|
console.log(source_default.dim(` Provisioning status: ${data.status}`));
|
|
5683
|
-
console.log(source_default.dim(` Next: sealos database get ${data.name}`));
|
|
5692
|
+
console.log(source_default.dim(` Next: sealos-cli database get ${data.name}`));
|
|
5684
5693
|
}));
|
|
5685
5694
|
dbCmd.command("get <name>").alias("describe").description("Get database details").option("-o, --output <format>", "Output format (json|table)", "table").action(withAuth({ spinnerText: "Loading database..." }, async (ctx, name, options) => {
|
|
5686
5695
|
const client = createDatabaseClient();
|
|
@@ -6219,14 +6228,14 @@ function createTemplateCommand() {
|
|
|
6219
6228
|
tplCmd.command("deploy [template]").description("Deploy a template (from catalog or raw YAML)").option("--name <name>", "Instance name (required when deploying from catalog)").option("--file <path>", "Path to template YAML file").option("--yaml <yaml>", "Template YAML string").option("--set <KEY=VALUE...>", "Set template arguments", (val, prev) => [...prev, val], []).option("--dry-run", "Validate raw template YAML without creating resources").addHelpText("after", `
|
|
6220
6229
|
Examples:
|
|
6221
6230
|
Catalog:
|
|
6222
|
-
sealos template deploy perplexica --name my-app --set OPENAI_API_KEY=xxx
|
|
6231
|
+
sealos-cli template deploy perplexica --name my-app --set OPENAI_API_KEY=xxx
|
|
6223
6232
|
|
|
6224
6233
|
Raw:
|
|
6225
|
-
sealos template deploy --file ./template.yaml --dry-run
|
|
6226
|
-
sealos template deploy --yaml 'apiVersion: app.sealos.io/v1
|
|
6234
|
+
sealos-cli template deploy --file ./template.yaml --dry-run
|
|
6235
|
+
sealos-cli template deploy --yaml 'apiVersion: app.sealos.io/v1
|
|
6227
6236
|
kind: Template
|
|
6228
6237
|
...'
|
|
6229
|
-
cat template.yaml | sealos template deploy --dry-run
|
|
6238
|
+
cat template.yaml | sealos-cli template deploy --dry-run
|
|
6230
6239
|
`).action(async (template, options) => {
|
|
6231
6240
|
const mode = resolveTemplateDeployMode(template, options);
|
|
6232
6241
|
await deployTemplate(template, options, mode);
|
|
@@ -6235,10 +6244,125 @@ kind: Template
|
|
|
6235
6244
|
}
|
|
6236
6245
|
__name(createTemplateCommand, "createTemplateCommand");
|
|
6237
6246
|
|
|
6247
|
+
// package.json
|
|
6248
|
+
var package_default = {
|
|
6249
|
+
name: "sealos-cli",
|
|
6250
|
+
version: "1.1.0",
|
|
6251
|
+
description: "Official CLI tool for Sealos Cloud - Manage auth, workspaces, devboxes, databases, and templates",
|
|
6252
|
+
types: "dist/main.d.ts",
|
|
6253
|
+
type: "module",
|
|
6254
|
+
bin: {
|
|
6255
|
+
"sealos-cli": "dist/bin/cli.cjs"
|
|
6256
|
+
},
|
|
6257
|
+
exports: {
|
|
6258
|
+
".": {
|
|
6259
|
+
import: {
|
|
6260
|
+
types: "./dist/main.d.ts",
|
|
6261
|
+
default: "./dist/main.mjs"
|
|
6262
|
+
},
|
|
6263
|
+
require: {
|
|
6264
|
+
types: "./dist/main.d.cts",
|
|
6265
|
+
default: "./dist/main.cjs"
|
|
6266
|
+
},
|
|
6267
|
+
default: "./dist/main.mjs"
|
|
6268
|
+
},
|
|
6269
|
+
"./dist/*": {
|
|
6270
|
+
types: "./dist/*.d.ts",
|
|
6271
|
+
import: "./dist/*.mjs",
|
|
6272
|
+
require: "./dist/*.cjs"
|
|
6273
|
+
}
|
|
6274
|
+
},
|
|
6275
|
+
engines: {
|
|
6276
|
+
node: ">=22.0.0"
|
|
6277
|
+
},
|
|
6278
|
+
packageManager: "npm@8.4.0",
|
|
6279
|
+
files: [
|
|
6280
|
+
"dist",
|
|
6281
|
+
"src",
|
|
6282
|
+
"bin"
|
|
6283
|
+
],
|
|
6284
|
+
scripts: {
|
|
6285
|
+
start: "node --import tsx src/bin/cli.ts",
|
|
6286
|
+
"generate:api": "openapi-typescript src/docs/template_openapi.json -o src/generated/template.ts && openapi-typescript src/docs/database_openapi.json -o src/generated/database.ts && openapi-typescript src/docs/devbox_openapi.json -o src/generated/devbox.ts",
|
|
6287
|
+
build: "npm run generate:api && tsc && tsup",
|
|
6288
|
+
lint: "eslint . && npm run lint:lockfile && npm run lint:markdown",
|
|
6289
|
+
"lint:markdown": "npx -y markdownlint-cli@0.45.0 -c .github/.markdownlint.yml -i '.git' -i '__tests__' -i '.github' -i '.changeset' -i 'CODE_OF_CONDUCT.md' -i 'CHANGELOG.md' -i 'docs/**' -i 'node_modules' -i 'dist' '**/**.md' --fix",
|
|
6290
|
+
"lint:fix": "eslint . --fix",
|
|
6291
|
+
"lint:lockfile": "lockfile-lint --path package-lock.json --validate-https --allowed-hosts npm yarn",
|
|
6292
|
+
test: "vitest run",
|
|
6293
|
+
"test:watch": "vitest",
|
|
6294
|
+
"test:coverage": "vitest run --coverage",
|
|
6295
|
+
"coverage:view": "open coverage/lcov-report/index.html",
|
|
6296
|
+
version: "changeset version",
|
|
6297
|
+
release: "changeset publish"
|
|
6298
|
+
},
|
|
6299
|
+
author: {
|
|
6300
|
+
name: "zjy365",
|
|
6301
|
+
email: "3161362058@qq.com",
|
|
6302
|
+
url: "https://github.com/zjy365"
|
|
6303
|
+
},
|
|
6304
|
+
publishConfig: {
|
|
6305
|
+
provenance: true,
|
|
6306
|
+
access: "public"
|
|
6307
|
+
},
|
|
6308
|
+
license: "Apache-2.0",
|
|
6309
|
+
keywords: [
|
|
6310
|
+
"sealos",
|
|
6311
|
+
"cli",
|
|
6312
|
+
"cloud",
|
|
6313
|
+
"devbox",
|
|
6314
|
+
"database",
|
|
6315
|
+
"kubernetes",
|
|
6316
|
+
"deployment",
|
|
6317
|
+
"template",
|
|
6318
|
+
"workspace"
|
|
6319
|
+
],
|
|
6320
|
+
homepage: "https://github.com/zjy365/sealos-cli.git",
|
|
6321
|
+
bugs: {
|
|
6322
|
+
url: "https://github.com/zjy365/sealos-cli.git/issues"
|
|
6323
|
+
},
|
|
6324
|
+
repository: {
|
|
6325
|
+
type: "git",
|
|
6326
|
+
url: "git+https://github.com/zjy365/sealos-cli.git"
|
|
6327
|
+
},
|
|
6328
|
+
dependencies: {
|
|
6329
|
+
axios: "^1.15.0",
|
|
6330
|
+
chalk: "^5.2.0",
|
|
6331
|
+
commander: "^14.0.3",
|
|
6332
|
+
"openapi-fetch": "^0.17.0",
|
|
6333
|
+
ora: "^9.3.0",
|
|
6334
|
+
table: "^6.8.1"
|
|
6335
|
+
},
|
|
6336
|
+
devDependencies: {
|
|
6337
|
+
"@changesets/changelog-github": "^0.5.0",
|
|
6338
|
+
"@changesets/cli": "^2.27.7",
|
|
6339
|
+
"@types/node": "^20.14.10",
|
|
6340
|
+
"@vitest/coverage-v8": "^4.1.6",
|
|
6341
|
+
eslint: "^9.6.0",
|
|
6342
|
+
"eslint-plugin-security": "^3.0.1",
|
|
6343
|
+
husky: "^9.0.11",
|
|
6344
|
+
"lint-staged": "^15.2.7",
|
|
6345
|
+
"lockfile-lint": "^4.14.0",
|
|
6346
|
+
neostandard: "^0.11.0",
|
|
6347
|
+
"openapi-typescript": "^7.13.0",
|
|
6348
|
+
"ts-node": "^10.9.2",
|
|
6349
|
+
tsup: "^8.1.0",
|
|
6350
|
+
tsx: "^4.19.4",
|
|
6351
|
+
typescript: "^5.5.3",
|
|
6352
|
+
"validate-conventional-commit": "^1.0.4",
|
|
6353
|
+
vitest: "^4.1.6"
|
|
6354
|
+
},
|
|
6355
|
+
"lint-staged": {
|
|
6356
|
+
"**/*.{js,json}": [
|
|
6357
|
+
"npm run lint:fix"
|
|
6358
|
+
]
|
|
6359
|
+
}
|
|
6360
|
+
};
|
|
6361
|
+
|
|
6238
6362
|
// src/main.ts
|
|
6239
6363
|
function createProgram() {
|
|
6240
6364
|
const program = new Command9();
|
|
6241
|
-
program.name("sealos").description("Official CLI tool for Sealos Cloud - Manage devbox, databases, templates, auth, and workspaces").version(
|
|
6365
|
+
program.name("sealos-cli").description("Official CLI tool for Sealos Cloud - Manage devbox, databases, templates, auth, and workspaces").version(package_default.version);
|
|
6242
6366
|
registerAuthCommands(program);
|
|
6243
6367
|
program.addCommand(createWorkspaceCommand());
|
|
6244
6368
|
program.addCommand(createDevboxCommand());
|
package/dist/main.cjs
CHANGED
|
@@ -97,7 +97,7 @@ __name(saveAuth, "saveAuth");
|
|
|
97
97
|
function loadAuth(deps = {}) {
|
|
98
98
|
const { paths } = withDeps(deps);
|
|
99
99
|
if (!(0, import_node_fs.existsSync)(paths.authPath)) {
|
|
100
|
-
throw new Error("Not authenticated. Please run: sealos login");
|
|
100
|
+
throw new Error("Not authenticated. Please run: sealos-cli login");
|
|
101
101
|
}
|
|
102
102
|
return JSON.parse((0, import_node_fs.readFileSync)(paths.authPath, "utf-8"));
|
|
103
103
|
}
|
|
@@ -119,7 +119,7 @@ __name(getAuthHeaders, "getAuthHeaders");
|
|
|
119
119
|
function requireAuth(deps = {}) {
|
|
120
120
|
const headers = getAuthHeaders(deps);
|
|
121
121
|
if (!headers) {
|
|
122
|
-
throw new Error('Authentication required. Please run "sealos login" first.');
|
|
122
|
+
throw new Error('Authentication required. Please run "sealos-cli login" first.');
|
|
123
123
|
}
|
|
124
124
|
return headers;
|
|
125
125
|
}
|
|
@@ -405,7 +405,7 @@ __name(loginWithDeviceFlow, "loginWithDeviceFlow");
|
|
|
405
405
|
async function listWorkspaces(deps = {}) {
|
|
406
406
|
const auth = loadAuth(deps);
|
|
407
407
|
if (!auth.regional_token) {
|
|
408
|
-
throw new Error("No regional_token found. Please run: sealos login");
|
|
408
|
+
throw new Error("No regional_token found. Please run: sealos-cli login");
|
|
409
409
|
}
|
|
410
410
|
const workspaces = await listRemoteWorkspaces(auth.region, auth.regional_token, deps);
|
|
411
411
|
return {
|
|
@@ -422,12 +422,12 @@ async function listWorkspaces(deps = {}) {
|
|
|
422
422
|
__name(listWorkspaces, "listWorkspaces");
|
|
423
423
|
async function switchWorkspace(target, deps = {}) {
|
|
424
424
|
if (!target) {
|
|
425
|
-
throw new Error("Usage: sealos auth switch <namespace-id-or-uid>");
|
|
425
|
+
throw new Error("Usage: sealos-cli auth switch <namespace-id-or-uid>");
|
|
426
426
|
}
|
|
427
427
|
const fullDeps = withDeps(deps);
|
|
428
428
|
const auth = loadAuth(fullDeps);
|
|
429
429
|
if (!auth.regional_token) {
|
|
430
|
-
throw new Error("No regional_token found. Please run: sealos login");
|
|
430
|
+
throw new Error("No regional_token found. Please run: sealos-cli login");
|
|
431
431
|
}
|
|
432
432
|
const workspaces = await listRemoteWorkspaces(auth.region, auth.regional_token, fullDeps);
|
|
433
433
|
if (workspaces.length === 0) {
|
|
@@ -3395,11 +3395,7 @@ var StdinDiscarder = class {
|
|
|
3395
3395
|
}
|
|
3396
3396
|
const code = typeof chunk === "string" ? chunk.codePointAt(0) : chunk[0];
|
|
3397
3397
|
if (code === ASCII_ETX_CODE) {
|
|
3398
|
-
|
|
3399
|
-
import_node_process5.default.emit("SIGINT");
|
|
3400
|
-
} else {
|
|
3401
|
-
import_node_process5.default.kill(import_node_process5.default.pid, "SIGINT");
|
|
3402
|
-
}
|
|
3398
|
+
import_node_process5.default.kill(import_node_process5.default.pid, "SIGINT");
|
|
3403
3399
|
}
|
|
3404
3400
|
}, "#handleInputBound");
|
|
3405
3401
|
start() {
|
|
@@ -3456,6 +3452,7 @@ var RENDER_DEFERRAL_TIMEOUT = 200;
|
|
|
3456
3452
|
var SYNCHRONIZED_OUTPUT_ENABLE = "\x1B[?2026h";
|
|
3457
3453
|
var SYNCHRONIZED_OUTPUT_DISABLE = "\x1B[?2026l";
|
|
3458
3454
|
var activeHooksPerStream = /* @__PURE__ */ new Map();
|
|
3455
|
+
var validColors = /* @__PURE__ */ new Set(["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray"]);
|
|
3459
3456
|
var Ora = class {
|
|
3460
3457
|
static {
|
|
3461
3458
|
__name(this, "Ora");
|
|
@@ -3472,7 +3469,7 @@ var Ora = class {
|
|
|
3472
3469
|
#drainHandler;
|
|
3473
3470
|
#deferRenderTimer;
|
|
3474
3471
|
#isDiscardingStdin = false;
|
|
3475
|
-
color;
|
|
3472
|
+
#color;
|
|
3476
3473
|
// Helper to execute writes while preventing hook recursion
|
|
3477
3474
|
#internalWrite(fn) {
|
|
3478
3475
|
this.#isInternalWrite = true;
|
|
@@ -3557,6 +3554,9 @@ var Ora = class {
|
|
|
3557
3554
|
if (typeof this.#options.isSilent !== "boolean") {
|
|
3558
3555
|
this.#options.isSilent = false;
|
|
3559
3556
|
}
|
|
3557
|
+
if (this.#options.interval !== void 0 && !(Number.isInteger(this.#options.interval) && this.#options.interval > 0)) {
|
|
3558
|
+
throw new Error("The `interval` option must be a positive integer");
|
|
3559
|
+
}
|
|
3560
3560
|
const userInterval = this.#options.interval;
|
|
3561
3561
|
this.spinner = this.#options.spinner;
|
|
3562
3562
|
this.#options.interval = userInterval;
|
|
@@ -3671,6 +3671,15 @@ var Ora = class {
|
|
|
3671
3671
|
}
|
|
3672
3672
|
return count;
|
|
3673
3673
|
}
|
|
3674
|
+
get color() {
|
|
3675
|
+
return this.#color;
|
|
3676
|
+
}
|
|
3677
|
+
set color(value) {
|
|
3678
|
+
if (value !== void 0 && value !== false && !validColors.has(value)) {
|
|
3679
|
+
throw new Error("The `color` option must be a valid color or `false` to disable");
|
|
3680
|
+
}
|
|
3681
|
+
this.#color = value;
|
|
3682
|
+
}
|
|
3674
3683
|
get isEnabled() {
|
|
3675
3684
|
return this.#options.isEnabled && !this.#options.isSilent;
|
|
3676
3685
|
}
|
|
@@ -3697,8 +3706,8 @@ var Ora = class {
|
|
|
3697
3706
|
}
|
|
3698
3707
|
const { frames } = this.#spinner;
|
|
3699
3708
|
let frame = frames[this.#frameIndex];
|
|
3700
|
-
if (this
|
|
3701
|
-
frame = source_default[this
|
|
3709
|
+
if (this.#color) {
|
|
3710
|
+
frame = source_default[this.#color](frame);
|
|
3702
3711
|
}
|
|
3703
3712
|
const fullPrefixText = this.#getFullPrefixText(this.#options.prefixText, " ");
|
|
3704
3713
|
const fullText = typeof this.text === "string" ? " " + this.text : "";
|
|
@@ -3945,7 +3954,7 @@ var AuthError = class extends CliError {
|
|
|
3945
3954
|
static {
|
|
3946
3955
|
__name(this, "AuthError");
|
|
3947
3956
|
}
|
|
3948
|
-
constructor(message = 'Authentication required. Please run "sealos login" first.') {
|
|
3957
|
+
constructor(message = 'Authentication required. Please run "sealos-cli login" first.') {
|
|
3949
3958
|
super(message, 1);
|
|
3950
3959
|
this.name = "AuthError";
|
|
3951
3960
|
}
|
|
@@ -4746,7 +4755,7 @@ function resolveHost(options) {
|
|
|
4746
4755
|
}
|
|
4747
4756
|
const host = options?.baseUrl || process.env.SEALOS_REGION || authRegion || DEFAULT_SEALOS_REGION;
|
|
4748
4757
|
if (!host) {
|
|
4749
|
-
throw new ConfigError('No Sealos Cloud host configured. Run "sealos login <host>" first.');
|
|
4758
|
+
throw new ConfigError('No Sealos Cloud host configured. Run "sealos-cli login <host>" first.');
|
|
4750
4759
|
}
|
|
4751
4760
|
return host.replace(/\/+$/, "");
|
|
4752
4761
|
}
|
|
@@ -5709,7 +5718,7 @@ function createDatabaseCommand() {
|
|
|
5709
5718
|
}
|
|
5710
5719
|
ctx.spinner.succeed(`Database "${data.name}" created successfully`);
|
|
5711
5720
|
console.log(source_default.dim(` Provisioning status: ${data.status}`));
|
|
5712
|
-
console.log(source_default.dim(` Next: sealos database get ${data.name}`));
|
|
5721
|
+
console.log(source_default.dim(` Next: sealos-cli database get ${data.name}`));
|
|
5713
5722
|
}));
|
|
5714
5723
|
dbCmd.command("get <name>").alias("describe").description("Get database details").option("-o, --output <format>", "Output format (json|table)", "table").action(withAuth({ spinnerText: "Loading database..." }, async (ctx, name, options) => {
|
|
5715
5724
|
const client = createDatabaseClient();
|
|
@@ -6248,14 +6257,14 @@ function createTemplateCommand() {
|
|
|
6248
6257
|
tplCmd.command("deploy [template]").description("Deploy a template (from catalog or raw YAML)").option("--name <name>", "Instance name (required when deploying from catalog)").option("--file <path>", "Path to template YAML file").option("--yaml <yaml>", "Template YAML string").option("--set <KEY=VALUE...>", "Set template arguments", (val, prev) => [...prev, val], []).option("--dry-run", "Validate raw template YAML without creating resources").addHelpText("after", `
|
|
6249
6258
|
Examples:
|
|
6250
6259
|
Catalog:
|
|
6251
|
-
sealos template deploy perplexica --name my-app --set OPENAI_API_KEY=xxx
|
|
6260
|
+
sealos-cli template deploy perplexica --name my-app --set OPENAI_API_KEY=xxx
|
|
6252
6261
|
|
|
6253
6262
|
Raw:
|
|
6254
|
-
sealos template deploy --file ./template.yaml --dry-run
|
|
6255
|
-
sealos template deploy --yaml 'apiVersion: app.sealos.io/v1
|
|
6263
|
+
sealos-cli template deploy --file ./template.yaml --dry-run
|
|
6264
|
+
sealos-cli template deploy --yaml 'apiVersion: app.sealos.io/v1
|
|
6256
6265
|
kind: Template
|
|
6257
6266
|
...'
|
|
6258
|
-
cat template.yaml | sealos template deploy --dry-run
|
|
6267
|
+
cat template.yaml | sealos-cli template deploy --dry-run
|
|
6259
6268
|
`).action(async (template, options) => {
|
|
6260
6269
|
const mode = resolveTemplateDeployMode(template, options);
|
|
6261
6270
|
await deployTemplate(template, options, mode);
|
|
@@ -6264,10 +6273,125 @@ kind: Template
|
|
|
6264
6273
|
}
|
|
6265
6274
|
__name(createTemplateCommand, "createTemplateCommand");
|
|
6266
6275
|
|
|
6276
|
+
// package.json
|
|
6277
|
+
var package_default = {
|
|
6278
|
+
name: "sealos-cli",
|
|
6279
|
+
version: "1.1.0",
|
|
6280
|
+
description: "Official CLI tool for Sealos Cloud - Manage auth, workspaces, devboxes, databases, and templates",
|
|
6281
|
+
types: "dist/main.d.ts",
|
|
6282
|
+
type: "module",
|
|
6283
|
+
bin: {
|
|
6284
|
+
"sealos-cli": "dist/bin/cli.cjs"
|
|
6285
|
+
},
|
|
6286
|
+
exports: {
|
|
6287
|
+
".": {
|
|
6288
|
+
import: {
|
|
6289
|
+
types: "./dist/main.d.ts",
|
|
6290
|
+
default: "./dist/main.mjs"
|
|
6291
|
+
},
|
|
6292
|
+
require: {
|
|
6293
|
+
types: "./dist/main.d.cts",
|
|
6294
|
+
default: "./dist/main.cjs"
|
|
6295
|
+
},
|
|
6296
|
+
default: "./dist/main.mjs"
|
|
6297
|
+
},
|
|
6298
|
+
"./dist/*": {
|
|
6299
|
+
types: "./dist/*.d.ts",
|
|
6300
|
+
import: "./dist/*.mjs",
|
|
6301
|
+
require: "./dist/*.cjs"
|
|
6302
|
+
}
|
|
6303
|
+
},
|
|
6304
|
+
engines: {
|
|
6305
|
+
node: ">=22.0.0"
|
|
6306
|
+
},
|
|
6307
|
+
packageManager: "npm@8.4.0",
|
|
6308
|
+
files: [
|
|
6309
|
+
"dist",
|
|
6310
|
+
"src",
|
|
6311
|
+
"bin"
|
|
6312
|
+
],
|
|
6313
|
+
scripts: {
|
|
6314
|
+
start: "node --import tsx src/bin/cli.ts",
|
|
6315
|
+
"generate:api": "openapi-typescript src/docs/template_openapi.json -o src/generated/template.ts && openapi-typescript src/docs/database_openapi.json -o src/generated/database.ts && openapi-typescript src/docs/devbox_openapi.json -o src/generated/devbox.ts",
|
|
6316
|
+
build: "npm run generate:api && tsc && tsup",
|
|
6317
|
+
lint: "eslint . && npm run lint:lockfile && npm run lint:markdown",
|
|
6318
|
+
"lint:markdown": "npx -y markdownlint-cli@0.45.0 -c .github/.markdownlint.yml -i '.git' -i '__tests__' -i '.github' -i '.changeset' -i 'CODE_OF_CONDUCT.md' -i 'CHANGELOG.md' -i 'docs/**' -i 'node_modules' -i 'dist' '**/**.md' --fix",
|
|
6319
|
+
"lint:fix": "eslint . --fix",
|
|
6320
|
+
"lint:lockfile": "lockfile-lint --path package-lock.json --validate-https --allowed-hosts npm yarn",
|
|
6321
|
+
test: "vitest run",
|
|
6322
|
+
"test:watch": "vitest",
|
|
6323
|
+
"test:coverage": "vitest run --coverage",
|
|
6324
|
+
"coverage:view": "open coverage/lcov-report/index.html",
|
|
6325
|
+
version: "changeset version",
|
|
6326
|
+
release: "changeset publish"
|
|
6327
|
+
},
|
|
6328
|
+
author: {
|
|
6329
|
+
name: "zjy365",
|
|
6330
|
+
email: "3161362058@qq.com",
|
|
6331
|
+
url: "https://github.com/zjy365"
|
|
6332
|
+
},
|
|
6333
|
+
publishConfig: {
|
|
6334
|
+
provenance: true,
|
|
6335
|
+
access: "public"
|
|
6336
|
+
},
|
|
6337
|
+
license: "Apache-2.0",
|
|
6338
|
+
keywords: [
|
|
6339
|
+
"sealos",
|
|
6340
|
+
"cli",
|
|
6341
|
+
"cloud",
|
|
6342
|
+
"devbox",
|
|
6343
|
+
"database",
|
|
6344
|
+
"kubernetes",
|
|
6345
|
+
"deployment",
|
|
6346
|
+
"template",
|
|
6347
|
+
"workspace"
|
|
6348
|
+
],
|
|
6349
|
+
homepage: "https://github.com/zjy365/sealos-cli.git",
|
|
6350
|
+
bugs: {
|
|
6351
|
+
url: "https://github.com/zjy365/sealos-cli.git/issues"
|
|
6352
|
+
},
|
|
6353
|
+
repository: {
|
|
6354
|
+
type: "git",
|
|
6355
|
+
url: "git+https://github.com/zjy365/sealos-cli.git"
|
|
6356
|
+
},
|
|
6357
|
+
dependencies: {
|
|
6358
|
+
axios: "^1.15.0",
|
|
6359
|
+
chalk: "^5.2.0",
|
|
6360
|
+
commander: "^14.0.3",
|
|
6361
|
+
"openapi-fetch": "^0.17.0",
|
|
6362
|
+
ora: "^9.3.0",
|
|
6363
|
+
table: "^6.8.1"
|
|
6364
|
+
},
|
|
6365
|
+
devDependencies: {
|
|
6366
|
+
"@changesets/changelog-github": "^0.5.0",
|
|
6367
|
+
"@changesets/cli": "^2.27.7",
|
|
6368
|
+
"@types/node": "^20.14.10",
|
|
6369
|
+
"@vitest/coverage-v8": "^4.1.6",
|
|
6370
|
+
eslint: "^9.6.0",
|
|
6371
|
+
"eslint-plugin-security": "^3.0.1",
|
|
6372
|
+
husky: "^9.0.11",
|
|
6373
|
+
"lint-staged": "^15.2.7",
|
|
6374
|
+
"lockfile-lint": "^4.14.0",
|
|
6375
|
+
neostandard: "^0.11.0",
|
|
6376
|
+
"openapi-typescript": "^7.13.0",
|
|
6377
|
+
"ts-node": "^10.9.2",
|
|
6378
|
+
tsup: "^8.1.0",
|
|
6379
|
+
tsx: "^4.19.4",
|
|
6380
|
+
typescript: "^5.5.3",
|
|
6381
|
+
"validate-conventional-commit": "^1.0.4",
|
|
6382
|
+
vitest: "^4.1.6"
|
|
6383
|
+
},
|
|
6384
|
+
"lint-staged": {
|
|
6385
|
+
"**/*.{js,json}": [
|
|
6386
|
+
"npm run lint:fix"
|
|
6387
|
+
]
|
|
6388
|
+
}
|
|
6389
|
+
};
|
|
6390
|
+
|
|
6267
6391
|
// src/main.ts
|
|
6268
6392
|
function createProgram() {
|
|
6269
6393
|
const program = new import_commander9.Command();
|
|
6270
|
-
program.name("sealos").description("Official CLI tool for Sealos Cloud - Manage devbox, databases, templates, auth, and workspaces").version(
|
|
6394
|
+
program.name("sealos-cli").description("Official CLI tool for Sealos Cloud - Manage devbox, databases, templates, auth, and workspaces").version(package_default.version);
|
|
6271
6395
|
registerAuthCommands(program);
|
|
6272
6396
|
program.addCommand(createWorkspaceCommand());
|
|
6273
6397
|
program.addCommand(createDevboxCommand());
|