fix(deploy): set default version to 1.0.0 and generate key using nanoid; remove confirmation prompt

This commit is contained in:
2026-03-08 14:07:18 +08:00
parent 8867951893
commit cb8e709c5d
4 changed files with 771 additions and 925 deletions

View File

@@ -10,7 +10,7 @@
], ],
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)", "author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
"license": "MIT", "license": "MIT",
"packageManager": "pnpm@10.30.2", "packageManager": "pnpm@10.31.0",
"type": "module", "type": "module",
"files": [ "files": [
"dist", "dist",
@@ -43,18 +43,18 @@
}, },
"devDependencies": { "devDependencies": {
"@inquirer/prompts": "^8.3.0", "@inquirer/prompts": "^8.3.0",
"@kevisual/ai": "^0.0.24", "@kevisual/ai": "^0.0.26",
"@kevisual/api": "^0.0.60", "@kevisual/api": "^0.0.62",
"@kevisual/load": "^0.0.6", "@kevisual/load": "^0.0.6",
"@kevisual/local-app-manager": "^0.1.32", "@kevisual/local-app-manager": "^0.1.32",
"@kevisual/logger": "^0.0.4", "@kevisual/logger": "^0.0.4",
"@kevisual/query": "0.0.52", "@kevisual/query": "0.0.53",
"@kevisual/router": "^0.0.84", "@kevisual/router": "^0.0.88",
"@kevisual/types": "^0.0.12", "@kevisual/types": "^0.0.12",
"@kevisual/use-config": "^1.0.30", "@kevisual/use-config": "^1.0.30",
"@opencode-ai/plugin": "^1.2.14", "@opencode-ai/plugin": "^1.2.21",
"@types/bun": "^1.3.9", "@types/bun": "^1.3.10",
"@types/node": "^25.3.0", "@types/node": "^25.3.5",
"@types/send": "^1.2.1", "@types/send": "^1.2.1",
"@types/ws": "^8.18.1", "@types/ws": "^8.18.1",
"chalk": "^5.6.2", "chalk": "^5.6.2",
@@ -76,12 +76,12 @@
"access": "public" "access": "public"
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "^3.997.0", "@aws-sdk/client-s3": "^3.1004.0",
"@kevisual/js-filter": "^0.0.5", "@kevisual/js-filter": "^0.0.5",
"@kevisual/oss": "^0.0.19", "@kevisual/oss": "^0.0.20",
"@kevisual/video-tools": "^0.0.13", "@kevisual/video-tools": "^0.0.13",
"@opencode-ai/sdk": "^1.2.14", "@opencode-ai/sdk": "^1.2.21",
"es-toolkit": "^1.44.0", "es-toolkit": "^1.45.1",
"eventemitter3": "^5.0.4", "eventemitter3": "^5.0.4",
"lowdb": "^7.0.1", "lowdb": "^7.0.1",
"lru-cache": "^11.2.6", "lru-cache": "^11.2.6",

View File

@@ -46,7 +46,7 @@
"@kevisual/auth": "^2.0.3", "@kevisual/auth": "^2.0.3",
"@kevisual/context": "^0.0.8", "@kevisual/context": "^0.0.8",
"@kevisual/use-config": "^1.0.30", "@kevisual/use-config": "^1.0.30",
"@opencode-ai/sdk": "^1.2.17", "@opencode-ai/sdk": "^1.2.21",
"@types/busboy": "^1.5.4", "@types/busboy": "^1.5.4",
"busboy": "^1.6.0", "busboy": "^1.6.0",
"eventemitter3": "^5.0.4", "eventemitter3": "^5.0.4",
@@ -54,22 +54,23 @@
"lowdb": "^7.0.1", "lowdb": "^7.0.1",
"lru-cache": "^11.2.6", "lru-cache": "^11.2.6",
"micromatch": "^4.0.8", "micromatch": "^4.0.8",
"nanoid": "^5.1.6",
"pm2": "latest", "pm2": "latest",
"semver": "^7.7.4", "semver": "^7.7.4",
"unstorage": "^1.17.4" "unstorage": "^1.17.4"
}, },
"devDependencies": { "devDependencies": {
"@kevisual/api": "^0.0.62", "@kevisual/api": "^0.0.62",
"@kevisual/cnb": "^0.0.33", "@kevisual/cnb": "^0.0.37",
"@kevisual/dts": "^0.0.4", "@kevisual/dts": "^0.0.4",
"@kevisual/load": "^0.0.6", "@kevisual/load": "^0.0.6",
"@kevisual/logger": "^0.0.4", "@kevisual/logger": "^0.0.4",
"@kevisual/query": "0.0.52", "@kevisual/query": "0.0.53",
"@types/bun": "^1.3.10", "@types/bun": "^1.3.10",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"@types/jsonwebtoken": "^9.0.10", "@types/jsonwebtoken": "^9.0.10",
"@types/micromatch": "^4.0.10", "@types/micromatch": "^4.0.10",
"@types/node": "^25.3.3", "@types/node": "^25.3.5",
"@types/semver": "^7.7.1", "@types/semver": "^7.7.1",
"chalk": "^5.6.2", "chalk": "^5.6.2",
"commander": "^14.0.3", "commander": "^14.0.3",

1632
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,13 +4,15 @@ import path from 'path';
import fs from 'fs'; import fs from 'fs';
import FormData from 'form-data'; import FormData from 'form-data';
import { getBaseURL, query, storage } from '@/module/query.ts'; import { getBaseURL, query, storage } from '@/module/query.ts';
import { input, confirm } from '@inquirer/prompts'; import { confirm } from '@inquirer/prompts';
import chalk from 'chalk'; import chalk from 'chalk';
import { upload } from '@/module/download/upload.ts'; import { upload } from '@/module/download/upload.ts';
import { getBufferHash, getHash } from '@/uitls/hash.ts'; import { getHash } from '@/uitls/hash.ts';
import { queryAppVersion } from '@/query/app-manager/query-app.ts'; import { queryAppVersion } from '@/query/app-manager/query-app.ts';
import { logger } from '@/module/logger.ts'; import { logger } from '@/module/logger.ts';
import { getUsername } from './login.ts'; import { getUsername } from './login.ts';
import { customAlphabet } from 'nanoid';
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz', 8);
/** /**
* 获取package.json 中的 basename, version, user, appKey * 获取package.json 中的 basename, version, user, appKey
* @returns * @returns
@@ -23,7 +25,7 @@ export const getPackageJson = (opts?: { version?: string; appKey?: string }) =>
try { try {
const packageJson = JSON.parse(fs.readFileSync(filePath, 'utf-8')); const packageJson = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
const basename = packageJson.basename || ''; const basename = packageJson.basename || '';
const version = packageJson.version || ''; const version = packageJson.version || '1.0.0';
const app = packageJson.app; const app = packageJson.app;
const userAppArry = basename.split('/'); const userAppArry = basename.split('/');
if (userAppArry.length <= 2 && !opts?.appKey) { if (userAppArry.length <= 2 && !opts?.appKey) {
@@ -41,7 +43,7 @@ const command = new Command('deploy')
.argument('<filePath>', 'Path to the file to be uploaded, filepath or directory') // 定义文件路径参数 .argument('<filePath>', 'Path to the file to be uploaded, filepath or directory') // 定义文件路径参数
.option('-v, --version <version>', 'verbose') .option('-v, --version <version>', 'verbose')
.option('-k, --key <key>', 'key') .option('-k, --key <key>', 'key')
.option('-y, --yes <yes>', 'yes') .option('-y, --yes <yes>', 'yes 已经去除')
.option('-o, --org <org>', 'org') .option('-o, --org <org>', 'org')
.option('-u, --update', 'load current app. set current version in product。 redis 缓存更新') .option('-u, --update', 'load current app. set current version in product。 redis 缓存更新')
.option('-s, --showBackend', 'show backend url, 部署的后端应用显示执行的cli命令') .option('-s, --showBackend', 'show backend url, 部署的后端应用显示执行的cli命令')
@@ -49,25 +51,21 @@ const command = new Command('deploy')
.option('--dir, --directory <directory>', '上传的prefix路径默认为空例如设置为static则会上传到/${username}/resources/${key}/${version}/static/路径下') .option('--dir, --directory <directory>', '上传的prefix路径默认为空例如设置为static则会上传到/${username}/resources/${key}/${version}/static/路径下')
.action(async (filePath, options) => { .action(async (filePath, options) => {
try { try {
let { version, key, yes, update, org, showBackend } = options; let { version, key, update, org, showBackend } = options;
const dot = !!options.dot; const dot = !!options.dot;
const pkgInfo = getPackageJson({ version, appKey: key }); const pkgInfo = getPackageJson({ version, appKey: key });
if (!version && pkgInfo?.version) { if (!version && pkgInfo?.version) {
version = pkgInfo?.version || ''; version = pkgInfo?.version || '1.0.0';
} }
if (!key && pkgInfo?.appKey) { if (!key && pkgInfo?.appKey) {
key = pkgInfo?.appKey || ''; key = pkgInfo?.appKey || '';
} }
logger.debug('start deploy'); logger.debug('start deploy');
if (!version) { if (!version) {
version = await input({ version = '1.0.0';
message: 'Enter your version:',
});
} }
if (!key) { if (!key) {
key = await input({ key = nanoid(8);
message: 'Enter your key:',
});
} }
const pwd = process.cwd(); const pwd = process.cwd();
const directory = path.join(pwd, filePath); const directory = path.join(pwd, filePath);
@@ -99,15 +97,6 @@ const command = new Command('deploy')
} }
logger.debug('upload Files', _relativeFiles); logger.debug('upload Files', _relativeFiles);
logger.debug('upload Files Key', key, version); logger.debug('upload Files Key', key, version);
if (!yes) {
// 确认是否上传
const confirmed = await confirm({
message: 'Do you want to upload these files?',
});
if (!confirmed) {
return;
}
}
let username = ''; let username = '';
if (pkgInfo?.user) { if (pkgInfo?.user) {
username = pkgInfo.user; username = pkgInfo.user;