sealos-cli 1.0.0 → 1.1.1
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/main.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.1",
|
|
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sealos-cli",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Official CLI tool for Sealos Cloud - Manage
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Official CLI tool for Sealos Cloud - Manage auth, workspaces, devboxes, databases, and templates",
|
|
5
5
|
"types": "dist/main.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -64,10 +64,11 @@
|
|
|
64
64
|
"cli",
|
|
65
65
|
"cloud",
|
|
66
66
|
"devbox",
|
|
67
|
-
"s3",
|
|
68
67
|
"database",
|
|
69
68
|
"kubernetes",
|
|
70
|
-
"deployment"
|
|
69
|
+
"deployment",
|
|
70
|
+
"template",
|
|
71
|
+
"workspace"
|
|
71
72
|
],
|
|
72
73
|
"homepage": "https://github.com/zjy365/sealos-cli.git",
|
|
73
74
|
"bugs": {
|
|
@@ -3,16 +3,17 @@ import { handleError } from '../../lib/errors.ts'
|
|
|
3
3
|
|
|
4
4
|
export function createAppCommand (): Command {
|
|
5
5
|
const appCmd = new Command('app')
|
|
6
|
-
.description('
|
|
6
|
+
.description('Future application placeholder outside the v1 release surface')
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// Future, non-v1 placeholder. Do not register this command until application
|
|
9
|
+
// APIs are implemented and ready for release.
|
|
9
10
|
|
|
10
11
|
appCmd
|
|
11
12
|
.command('list')
|
|
12
|
-
.description('
|
|
13
|
+
.description('Future application list placeholder outside the v1 release surface')
|
|
13
14
|
.action(async () => {
|
|
14
15
|
try {
|
|
15
|
-
console.log('
|
|
16
|
+
console.log('Application commands are not part of the v1 release surface yet.')
|
|
16
17
|
} catch (error) {
|
|
17
18
|
handleError(error)
|
|
18
19
|
}
|
|
@@ -445,7 +445,7 @@ export function createDatabaseCommand (): Command {
|
|
|
445
445
|
|
|
446
446
|
ctx.spinner.succeed(`Database "${data.name}" created successfully`)
|
|
447
447
|
console.log(chalk.dim(` Provisioning status: ${data.status}`))
|
|
448
|
-
console.log(chalk.dim(` Next: sealos database get ${data.name}`))
|
|
448
|
+
console.log(chalk.dim(` Next: sealos-cli database get ${data.name}`))
|
|
449
449
|
}))
|
|
450
450
|
|
|
451
451
|
dbCmd
|
|
@@ -3,16 +3,17 @@ import { handleError } from '../../lib/errors.ts'
|
|
|
3
3
|
|
|
4
4
|
export function createQuotaCommand (): Command {
|
|
5
5
|
const quotaCmd = new Command('quota')
|
|
6
|
-
.description('
|
|
6
|
+
.description('Future quota placeholder outside the v1 release surface')
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// Future, non-v1 placeholder. Do not register this command until quota APIs
|
|
9
|
+
// are implemented and ready for release.
|
|
9
10
|
|
|
10
11
|
quotaCmd
|
|
11
12
|
.command('get')
|
|
12
13
|
.description('Get quota information')
|
|
13
14
|
.action(async () => {
|
|
14
15
|
try {
|
|
15
|
-
console.log('
|
|
16
|
+
console.log('Quota commands are not part of the v1 release surface yet.')
|
|
16
17
|
} catch (error) {
|
|
17
18
|
handleError(error)
|
|
18
19
|
}
|
package/src/commands/s3/index.ts
CHANGED
|
@@ -3,9 +3,10 @@ import { handleError } from '../../lib/errors.ts'
|
|
|
3
3
|
|
|
4
4
|
export function createS3Command (): Command {
|
|
5
5
|
const s3Cmd = new Command('s3')
|
|
6
|
-
.description('
|
|
6
|
+
.description('Future S3 placeholder outside the v1 release surface')
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// Future, non-v1 placeholder. Do not register this command until the S3 API
|
|
9
|
+
// integration is implemented and ready for release.
|
|
9
10
|
// - upload
|
|
10
11
|
// - download
|
|
11
12
|
// - list
|
|
@@ -22,14 +23,13 @@ export function createS3Command (): Command {
|
|
|
22
23
|
.option('--acl <acl>', 'Access control: private, public-read')
|
|
23
24
|
.action(async (source, destination, options) => {
|
|
24
25
|
try {
|
|
25
|
-
console.log('
|
|
26
|
+
console.log('S3 commands are not part of the v1 release surface yet.', { source, destination, options })
|
|
26
27
|
} catch (error) {
|
|
27
28
|
handleError(error)
|
|
28
29
|
}
|
|
29
30
|
})
|
|
30
31
|
|
|
31
|
-
//
|
|
32
|
-
// 为了简洁,这里只实现 upload 作为示例
|
|
32
|
+
// This file is kept as a marker for future S3 work only.
|
|
33
33
|
|
|
34
34
|
return s3Cmd
|
|
35
35
|
}
|
|
@@ -364,12 +364,12 @@ export function createTemplateCommand (): Command {
|
|
|
364
364
|
.addHelpText('after', `
|
|
365
365
|
Examples:
|
|
366
366
|
Catalog:
|
|
367
|
-
sealos template deploy perplexica --name my-app --set OPENAI_API_KEY=xxx
|
|
367
|
+
sealos-cli template deploy perplexica --name my-app --set OPENAI_API_KEY=xxx
|
|
368
368
|
|
|
369
369
|
Raw:
|
|
370
|
-
sealos template deploy --file ./template.yaml --dry-run
|
|
371
|
-
sealos template deploy --yaml 'apiVersion: app.sealos.io/v1\nkind: Template\n...'
|
|
372
|
-
cat template.yaml | sealos template deploy --dry-run
|
|
370
|
+
sealos-cli template deploy --file ./template.yaml --dry-run
|
|
371
|
+
sealos-cli template deploy --yaml 'apiVersion: app.sealos.io/v1\nkind: Template\n...'
|
|
372
|
+
cat template.yaml | sealos-cli template deploy --dry-run
|
|
373
373
|
`)
|
|
374
374
|
.action(async (template: string | undefined, options: TemplateDeployOptions) => {
|
|
375
375
|
const mode = resolveTemplateDeployMode(template, options)
|
package/src/lib/api-client.ts
CHANGED
|
@@ -15,7 +15,7 @@ function resolveHost (options?: { baseUrl?: string }): string {
|
|
|
15
15
|
|
|
16
16
|
const host = options?.baseUrl || process.env.SEALOS_REGION || authRegion || DEFAULT_SEALOS_REGION
|
|
17
17
|
if (!host) {
|
|
18
|
-
throw new ConfigError('No Sealos Cloud host configured. Run "sealos login <host>" first.')
|
|
18
|
+
throw new ConfigError('No Sealos Cloud host configured. Run "sealos-cli login <host>" first.')
|
|
19
19
|
}
|
|
20
20
|
return host.replace(/\/+$/, '')
|
|
21
21
|
}
|
package/src/lib/auth.ts
CHANGED
|
@@ -141,7 +141,7 @@ export function saveAuth (auth: SealosAuthData, deps: AuthDependencies = {}): vo
|
|
|
141
141
|
export function loadAuth (deps: AuthDependencies = {}): SealosAuthData {
|
|
142
142
|
const { paths } = withDeps(deps)
|
|
143
143
|
if (!existsSync(paths.authPath)) {
|
|
144
|
-
throw new Error('Not authenticated. Please run: sealos login')
|
|
144
|
+
throw new Error('Not authenticated. Please run: sealos-cli login')
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
return JSON.parse(readFileSync(paths.authPath, 'utf-8')) as SealosAuthData
|
|
@@ -172,7 +172,7 @@ export function getAuthHeaders (deps: AuthDependencies = {}): { Authorization: s
|
|
|
172
172
|
export function requireAuth (deps: AuthDependencies = {}): { Authorization: string } {
|
|
173
173
|
const headers = getAuthHeaders(deps)
|
|
174
174
|
if (!headers) {
|
|
175
|
-
throw new Error('Authentication required. Please run "sealos login" first.')
|
|
175
|
+
throw new Error('Authentication required. Please run "sealos-cli login" first.')
|
|
176
176
|
}
|
|
177
177
|
return headers
|
|
178
178
|
}
|
|
@@ -496,7 +496,7 @@ export async function loginWithDeviceFlow (region?: string, deps: AuthDependenci
|
|
|
496
496
|
export async function listWorkspaces (deps: AuthDependencies = {}): Promise<WorkspaceListResult> {
|
|
497
497
|
const auth = loadAuth(deps)
|
|
498
498
|
if (!auth.regional_token) {
|
|
499
|
-
throw new Error('No regional_token found. Please run: sealos login')
|
|
499
|
+
throw new Error('No regional_token found. Please run: sealos-cli login')
|
|
500
500
|
}
|
|
501
501
|
|
|
502
502
|
const workspaces = await listRemoteWorkspaces(auth.region, auth.regional_token, deps)
|
|
@@ -514,13 +514,13 @@ export async function listWorkspaces (deps: AuthDependencies = {}): Promise<Work
|
|
|
514
514
|
|
|
515
515
|
export async function switchWorkspace (target: string, deps: AuthDependencies = {}): Promise<SwitchWorkspaceResult> {
|
|
516
516
|
if (!target) {
|
|
517
|
-
throw new Error('Usage: sealos auth switch <namespace-id-or-uid>')
|
|
517
|
+
throw new Error('Usage: sealos-cli auth switch <namespace-id-or-uid>')
|
|
518
518
|
}
|
|
519
519
|
|
|
520
520
|
const fullDeps = withDeps(deps)
|
|
521
521
|
const auth = loadAuth(fullDeps)
|
|
522
522
|
if (!auth.regional_token) {
|
|
523
|
-
throw new Error('No regional_token found. Please run: sealos login')
|
|
523
|
+
throw new Error('No regional_token found. Please run: sealos-cli login')
|
|
524
524
|
}
|
|
525
525
|
|
|
526
526
|
const workspaces = await listRemoteWorkspaces(auth.region, auth.regional_token, fullDeps)
|
package/src/lib/errors.ts
CHANGED
|
@@ -14,7 +14,7 @@ export class CliError extends Error {
|
|
|
14
14
|
* Authentication error
|
|
15
15
|
*/
|
|
16
16
|
export class AuthError extends CliError {
|
|
17
|
-
constructor (message: string = 'Authentication required. Please run "sealos login" first.') {
|
|
17
|
+
constructor (message: string = 'Authentication required. Please run "sealos-cli login" first.') {
|
|
18
18
|
super(message, 1)
|
|
19
19
|
this.name = 'AuthError'
|
|
20
20
|
}
|
package/src/lib/output.ts
CHANGED
|
@@ -10,12 +10,11 @@ export function outputJson (data: any): void {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Output YAML format
|
|
13
|
+
* Output YAML format.
|
|
14
|
+
* Generic YAML output is not part of the v1 command surface.
|
|
14
15
|
*/
|
|
15
|
-
export function outputYaml (
|
|
16
|
-
|
|
17
|
-
console.log('YAML output not implemented yet')
|
|
18
|
-
console.log(data)
|
|
16
|
+
export function outputYaml (_data: any): never {
|
|
17
|
+
throw new Error('YAML output is not supported in the v1 release. Use json or table output.')
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
/**
|
|
@@ -87,7 +86,7 @@ export function spinner (text: string): Ora {
|
|
|
87
86
|
* Confirmation prompt
|
|
88
87
|
*/
|
|
89
88
|
export async function confirm (message: string): Promise<boolean> {
|
|
90
|
-
//
|
|
89
|
+
// Non-interactive default for v1. Replace with a prompt implementation when needed.
|
|
91
90
|
console.log(chalk.yellow('?'), message)
|
|
92
91
|
return true
|
|
93
92
|
}
|
package/src/main.ts
CHANGED
|
@@ -6,14 +6,15 @@ import { createDevboxCommand } from './commands/devbox/index.ts'
|
|
|
6
6
|
import { createDatabaseCommand } from './commands/database/index.ts'
|
|
7
7
|
import { createTemplateCommand } from './commands/template/index.ts'
|
|
8
8
|
import { handleError } from './lib/errors.ts'
|
|
9
|
+
import packageJson from '../package.json' with { type: 'json' }
|
|
9
10
|
|
|
10
11
|
export function createProgram (): Command {
|
|
11
12
|
const program = new Command()
|
|
12
13
|
|
|
13
14
|
program
|
|
14
|
-
.name('sealos')
|
|
15
|
+
.name('sealos-cli')
|
|
15
16
|
.description('Official CLI tool for Sealos Cloud - Manage devbox, databases, templates, auth, and workspaces')
|
|
16
|
-
.version(
|
|
17
|
+
.version(packageJson.version)
|
|
17
18
|
|
|
18
19
|
// Register all command modules
|
|
19
20
|
registerAuthCommands(program)
|