@cloudbase/cli 2.12.3-beta.0 → 2.12.3-beta.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/dist/standalone/cli.js +40 -89
- package/package.json +1 -1
package/dist/standalone/cli.js
CHANGED
|
@@ -326147,7 +326147,7 @@ module.exports = function generate_pattern(it, $keyword, $ruleType) {
|
|
|
326147
326147
|
/***/ ((module) => {
|
|
326148
326148
|
|
|
326149
326149
|
"use strict";
|
|
326150
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.12.3-beta.
|
|
326150
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.12.3-beta.1","description":"cli tool for cloudbase","main":"lib/index.js","scripts":{"build":"rimraf lib types && tsc --resolveJsonModule && cpx \\"src/**/*.html\\" lib","watch":"rimraf lib types && tsc -w","dev":"rimraf lib types && cpx \\"src/**/*.html\\" lib && tsc -w","eslint":"eslint \\"./**/*.ts\\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000","tsc":"tsc","pkg":"pkg ./bin/cloudbase.js --out-path ./pkg","postinstall":"node ./post-install.js || exit 0 && patch-package","prepublishOnly":"node ./scripts/check-publish-source.js","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs && node build/scripts/copy-figlet-fonts.js","package:darwin-arm64":"OS=darwin ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:darwin-x64":"OS=darwin ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-arm64":"OS=linux ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-x64":"OS=linux ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:all":"bash build/scripts/build-all.sh","node:fetch:one":"node -e \\"require(\'child_process\').execSync(\'bash build/scripts/fetch-node.sh\',{stdio:\'inherit\'})\\"","node:fetch:all":"NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh --all","node:fetch:win-x64":"OS=windows ARCH=x64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","node:fetch:win-arm64":"OS=windows ARCH=arm64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","package:windows-x64":"OS=windows ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-arm64":"OS=windows ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-all":"npm run -s node:fetch:win-x64 && npm run -s node:fetch:win-arm64 && npm run -s package:windows-x64 && npm run -s package:windows-arm64","package:npm":"npm run build && npm run build:bundle && bash build/scripts/prepare-publish.sh","out:prune":"bash build/scripts/prune-out.sh","i18n:scan":"i18next-scanner --config locales/i18next-scanner.config.js && node locales/scripts/generate.js","i18n:sync":"node locales/scripts/sync.js sync","publish":"node ./scripts/publish.js"},"repository":{"type":"git","url":"https://github.com/TencentCloudBase/cloud-base-cli.git"},"bin":{"cloudbase":"bin/cloudbase.js","cloudbase-mcp":"bin/cloudbase-mcp.cjs","tcb":"bin/tcb.js"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^2.7.3","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.14","@cloudbase/lowcode-cli":"^0.23.0","@cloudbase/manager-node":"4.10.1","@cloudbase/toolbox":"^0.7.9","@dotenvx/dotenvx":"^1.48.3","@musistudio/claude-code-router":"1.0.36","address":"^1.1.2","camelcase-keys":"^7.0.2","chalk":"^2.4.2","cli-table3":"^0.5.1","commander":"7","del":"^5.1.0","didyoumean":"^1.2.2","enquirer":"^2.3.6","execa":"^4.0.3","figlet":"^1.7.0","fs-extra":"^8.1.0","gradient-string":"^2.0.2","https-proxy-agent":"^5.0.1","i":"^0.3.7","inquirer":"^6.5.0","json-schema-to-typescript":"^14.0.5","lodash":"^4.17.21","log-symbols":"^3.0.0","lowdb":"^1.0.0","make-dir":"^3.0.0","node-fetch":"^2.6.0","nodemon":"^3.1.4","npm":"^11.5.2","open":"^7.0.0","ora":"^4.0.2","os-locale":"5.0.0","patch-package":"^8.0.0","portfinder":"^1.0.28","progress":"^2.0.3","query-string":"^6.8.1","reflect-metadata":"^0.1.13","semver":"^7.3.7","simple-git":"^3.28.0","tar-fs":"^2.0.1","terminal-link":"^2.1.1","toml":"^3.0.0","unzipper":"^0.10.10","update-notifier":"^4.0.0","xdg-basedir":"^4.0.0","yargs":"^16.2.0","yargs-parser":"^21.0.1","zod":"^4.0.13"},"devDependencies":{"@babel/parser":"^7.28.4","@babel/traverse":"^7.28.4","@babel/types":"^7.28.4","@types/fs-extra":"^11.0.4","@types/jest":"^27","@types/koa__router":"^8.0.11","@types/lodash":"^4.14.182","@types/node":"^12.12.38","@types/node-fetch":"^2.5.4","@types/react":"^17.0.37","@types/semver":"^7.3.9","@types/unzipper":"^0.10.11","@types/webpack-dev-server":"^3.11.1","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","cpx":"^1.5.0","eslint":"^7.14.0","eslint-config-alloy":"^3.8.2","husky":"^3.0.9","i18next-scanner":"^4.6.0","jest":"^27","rimraf":"^3.0.2","ts-jest":"^27","typescript":"^4.7.2","webpack":"^5.92.0","webpack-cli":"^5.1.4"},"packageManager":"yarn@3.6.2+sha512.2c2f8b9615e6659773f65cdec7cf92ef773a98a99e611579601f61c7a91ec94c89c929aac86f1cee819421a9b0db7acfd53ec3ebb95af44f77f77634b08b9557"}');
|
|
326151
326151
|
|
|
326152
326152
|
/***/ }),
|
|
326153
326153
|
|
|
@@ -835603,18 +835603,24 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835603
835603
|
}
|
|
835604
835604
|
catch (e) {
|
|
835605
835605
|
loading.stop();
|
|
835606
|
-
|
|
835607
|
-
|
|
835608
|
-
|
|
835609
|
-
|
|
835610
|
-
|
|
835611
|
-
|
|
835612
|
-
|
|
835613
|
-
|
|
835614
|
-
|
|
835615
|
-
|
|
835616
|
-
|
|
835617
|
-
|
|
835606
|
+
try {
|
|
835607
|
+
const result = yield this.handleDeployFail(e, {
|
|
835608
|
+
func: funcWithType,
|
|
835609
|
+
envId,
|
|
835610
|
+
force,
|
|
835611
|
+
codeSecret,
|
|
835612
|
+
functionRootPath,
|
|
835613
|
+
functionPath: func.dir ? funcPath : undefined,
|
|
835614
|
+
accessPath: access,
|
|
835615
|
+
yes: yes || functionsToOverwrite.has(func.name),
|
|
835616
|
+
batchMode: true,
|
|
835617
|
+
logger: log
|
|
835618
|
+
});
|
|
835619
|
+
return { status: result || 'error', name: func.name };
|
|
835620
|
+
}
|
|
835621
|
+
catch (handleError) {
|
|
835622
|
+
return { status: 'error', name: func.name, error: handleError };
|
|
835623
|
+
}
|
|
835618
835624
|
}
|
|
835619
835625
|
}));
|
|
835620
835626
|
if (tasks.length > 5) {
|
|
@@ -835622,7 +835628,14 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835622
835628
|
}
|
|
835623
835629
|
const asyncTaskController = new utils_1.AsyncTaskParallelController(5, 50);
|
|
835624
835630
|
asyncTaskController.loadTasks(tasks);
|
|
835625
|
-
const
|
|
835631
|
+
const rawResults = yield asyncTaskController.run();
|
|
835632
|
+
const results = rawResults.map((r, index) => {
|
|
835633
|
+
var _a;
|
|
835634
|
+
if (r instanceof Error) {
|
|
835635
|
+
return { status: 'error', name: ((_a = selectedFunctions[index]) === null || _a === void 0 ? void 0 : _a.name) || 'unknown', error: r };
|
|
835636
|
+
}
|
|
835637
|
+
return r;
|
|
835638
|
+
});
|
|
835626
835639
|
const successCount = results.filter(r => (r === null || r === void 0 ? void 0 : r.status) === 'success').length;
|
|
835627
835640
|
const skippedCount = results.filter(r => (r === null || r === void 0 ? void 0 : r.status) === 'skipped').length;
|
|
835628
835641
|
const cancelledCount = results.filter(r => (r === null || r === void 0 ? void 0 : r.status) === 'cancelled').length;
|
|
@@ -835638,91 +835651,28 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835638
835651
|
}
|
|
835639
835652
|
if (errorCount > 0) {
|
|
835640
835653
|
log.error((0, i18n_1.t)('{{count}} 个云函数部署失败', { count: errorCount }));
|
|
835654
|
+
let envNotFoundError = null;
|
|
835641
835655
|
results.filter(r => (r === null || r === void 0 ? void 0 : r.status) === 'error').forEach((r) => {
|
|
835642
835656
|
var _a;
|
|
835643
835657
|
if ((_a = r === null || r === void 0 ? void 0 : r.error) === null || _a === void 0 ? void 0 : _a.message) {
|
|
835644
835658
|
log.error(` - [${r.name}] ${r.error.message}`);
|
|
835659
|
+
if (r.error.message.includes('Environment') && r.error.message.includes('not found') && !envNotFoundError) {
|
|
835660
|
+
envNotFoundError = r.error;
|
|
835661
|
+
}
|
|
835645
835662
|
}
|
|
835646
835663
|
});
|
|
835664
|
+
if (envNotFoundError) {
|
|
835665
|
+
throw envNotFoundError;
|
|
835666
|
+
}
|
|
835647
835667
|
}
|
|
835648
835668
|
if (successCount === 0 && errorCount === 0 && skippedCount === 0 && cancelledCount === 0) {
|
|
835649
835669
|
log.info((0, i18n_1.t)('没有函数被部署'));
|
|
835650
835670
|
}
|
|
835651
835671
|
});
|
|
835652
835672
|
}
|
|
835653
|
-
handleDeployFailBatch(e, options) {
|
|
835654
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
835655
|
-
const { envId, codeSecret, functionRootPath, func: originalFunc, functionPath, accessPath, force: forceOverwrite, shouldOverwrite, logger: log } = options;
|
|
835656
|
-
let func = originalFunc;
|
|
835657
|
-
const loading = (0, utils_1.loadingFactory)();
|
|
835658
|
-
const isResourceInUseError = e.code === 'ResourceInUse.FunctionName'
|
|
835659
|
-
|| e.code === 'ResourceInUse.Function'
|
|
835660
|
-
|| (e.message && e.message.includes('ResourceInUse.FunctionName'))
|
|
835661
|
-
|| (e.message && e.message.includes('ResourceInUse.Function'));
|
|
835662
|
-
if (isResourceInUseError) {
|
|
835663
|
-
const functionService = yield (0, function_2.getFunctionService)(envId);
|
|
835664
|
-
const existingFunction = yield functionService.getFunctionDetail(func.name, codeSecret);
|
|
835665
|
-
const existingType = (existingFunction === null || existingFunction === void 0 ? void 0 : existingFunction.Type) || 'Event';
|
|
835666
|
-
const newType = func.type || existingType;
|
|
835667
|
-
if (func.type && existingType !== newType) {
|
|
835668
|
-
(log || utils_1.logger).error((0, i18n_1.t)('不支持变更函数类型:云端函数 [{{name}}] 类型为 {{existingType}},无法变更为 {{newType}}', {
|
|
835669
|
-
name: func.name,
|
|
835670
|
-
existingType,
|
|
835671
|
-
newType
|
|
835672
|
-
}));
|
|
835673
|
-
return 'error';
|
|
835674
|
-
}
|
|
835675
|
-
const existingProtocolType = (existingFunction === null || existingFunction === void 0 ? void 0 : existingFunction.ProtocolType) || '';
|
|
835676
|
-
const newProtocolType = func.protocolType !== undefined ? func.protocolType : existingProtocolType;
|
|
835677
|
-
if (func.protocolType !== undefined && existingProtocolType !== newProtocolType) {
|
|
835678
|
-
(log || utils_1.logger).error((0, i18n_1.t)('不支持变更协议类型:云端函数 [{{name}}] 协议类型为 {{existingProtocolType}},本地配置为 {{newProtocolType}},协议类型仅支持在创建函数时设置', {
|
|
835679
|
-
name: func.name,
|
|
835680
|
-
existingProtocolType: existingProtocolType || '无',
|
|
835681
|
-
newProtocolType: newProtocolType || '无'
|
|
835682
|
-
}));
|
|
835683
|
-
return 'error';
|
|
835684
|
-
}
|
|
835685
|
-
func = Object.assign(Object.assign({}, func), { type: newType, protocolType: newProtocolType || undefined });
|
|
835686
|
-
const shouldForce = forceOverwrite || shouldOverwrite;
|
|
835687
|
-
if (shouldForce) {
|
|
835688
|
-
loading.start((0, i18n_1.t)('云函数 [{{name}}] 更新部署中...', { name: func.name }));
|
|
835689
|
-
try {
|
|
835690
|
-
yield (0, function_2.updateFunctionCode)({
|
|
835691
|
-
func,
|
|
835692
|
-
envId,
|
|
835693
|
-
codeSecret,
|
|
835694
|
-
functionRootPath,
|
|
835695
|
-
functionPath
|
|
835696
|
-
});
|
|
835697
|
-
const success = yield this.waitForFunctionReady(envId, func.name, loading);
|
|
835698
|
-
if (!success) {
|
|
835699
|
-
return 'error';
|
|
835700
|
-
}
|
|
835701
|
-
loading.succeed((0, i18n_1.t)('[{{name}}] 云函数配置更新中...', { name: func.name }));
|
|
835702
|
-
yield (0, function_2.updateFunctionConfig)({
|
|
835703
|
-
envId,
|
|
835704
|
-
functionName: func.name,
|
|
835705
|
-
config: func
|
|
835706
|
-
});
|
|
835707
|
-
loading.succeed((0, i18n_1.t)('[{{name}}] 云函数更新成功!', { name: func.name }));
|
|
835708
|
-
return 'success';
|
|
835709
|
-
}
|
|
835710
|
-
catch (e) {
|
|
835711
|
-
loading.stop();
|
|
835712
|
-
throw e;
|
|
835713
|
-
}
|
|
835714
|
-
}
|
|
835715
|
-
else {
|
|
835716
|
-
(log || utils_1.logger).info((0, i18n_1.t)('[{{name}}] 已跳过部署', { name: func.name }));
|
|
835717
|
-
return 'cancelled';
|
|
835718
|
-
}
|
|
835719
|
-
}
|
|
835720
|
-
throw e;
|
|
835721
|
-
});
|
|
835722
|
-
}
|
|
835723
835673
|
handleDeployFail(e, options) {
|
|
835724
835674
|
return __awaiter(this, void 0, void 0, function* () {
|
|
835725
|
-
const { envId, codeSecret, functionRootPath, func: originalFunc, functionPath, accessPath, force: forceOverwrite, yes, logger: log } = options;
|
|
835675
|
+
const { envId, codeSecret, functionRootPath, func: originalFunc, functionPath, accessPath, force: forceOverwrite, yes, batchMode, logger: log } = options;
|
|
835726
835676
|
let func = originalFunc;
|
|
835727
835677
|
const loading = (0, utils_1.loadingFactory)();
|
|
835728
835678
|
const isResourceInUseError = e.code === 'ResourceInUse.FunctionName'
|
|
@@ -835763,9 +835713,8 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835763
835713
|
});
|
|
835764
835714
|
shouldForce = answer.force;
|
|
835765
835715
|
}
|
|
835766
|
-
const { triggers } = func;
|
|
835767
835716
|
if (shouldForce) {
|
|
835768
|
-
loading.start((0, i18n_1.t)('云函数更新部署中...'));
|
|
835717
|
+
loading.start(batchMode ? (0, i18n_1.t)('云函数 [{{name}}] 更新部署中...', { name: func.name }) : (0, i18n_1.t)('云函数更新部署中...'));
|
|
835769
835718
|
try {
|
|
835770
835719
|
yield (0, function_2.updateFunctionCode)({
|
|
835771
835720
|
func,
|
|
@@ -835785,7 +835734,9 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835785
835734
|
config: func
|
|
835786
835735
|
});
|
|
835787
835736
|
loading.succeed((0, i18n_1.t)('[{{name}}] 云函数更新成功!', { name: func.name }));
|
|
835788
|
-
|
|
835737
|
+
if (!batchMode) {
|
|
835738
|
+
yield this.printSuccessTips(envId);
|
|
835739
|
+
}
|
|
835789
835740
|
return 'success';
|
|
835790
835741
|
}
|
|
835791
835742
|
catch (e) {
|
|
@@ -835794,7 +835745,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835794
835745
|
}
|
|
835795
835746
|
}
|
|
835796
835747
|
else {
|
|
835797
|
-
(log || utils_1.logger).info((0, i18n_1.t)('已取消部署'));
|
|
835748
|
+
(log || utils_1.logger).info(batchMode ? (0, i18n_1.t)('[{{name}}] 已跳过部署', { name: func.name }) : (0, i18n_1.t)('已取消部署'));
|
|
835798
835749
|
return 'cancelled';
|
|
835799
835750
|
}
|
|
835800
835751
|
}
|