@lark-apaas/miaoda-cli 0.1.4 → 0.1.5-alpha.2f1e0ff
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 +6 -5
- package/dist/api/deploy/index.js +13 -1
- package/dist/api/deploy/modern-types.js +23 -0
- package/dist/api/deploy/modern.js +78 -0
- package/dist/api/deploy/plugin-instances-types.js +6 -0
- package/dist/api/deploy/plugin-instances.js +22 -0
- package/dist/api/observability/api.js +10 -0
- package/dist/api/observability/index.js +2 -1
- package/dist/cli/commands/app/index.js +144 -2
- package/dist/cli/commands/deploy/modern.js +50 -0
- package/dist/cli/commands/index.js +68 -5
- package/dist/cli/commands/observability/index.js +62 -6
- package/dist/cli/commands/shared.js +5 -0
- package/dist/cli/commands/skills/index.js +79 -0
- package/dist/cli/handlers/app/index.js +9 -1
- package/dist/cli/handlers/app/init.js +132 -0
- package/dist/cli/handlers/app/sync.js +215 -0
- package/dist/cli/handlers/deploy/modern.js +33 -0
- package/dist/cli/handlers/observability/helpers.js +4 -0
- package/dist/cli/handlers/observability/index.js +3 -1
- package/dist/cli/handlers/observability/log.js +8 -2
- package/dist/cli/handlers/observability/source-stack.js +389 -0
- package/dist/cli/handlers/observability/trace.js +7 -1
- package/dist/cli/handlers/skills/index.js +7 -0
- package/dist/cli/handlers/skills/status.js +31 -0
- package/dist/cli/handlers/skills/sync.js +49 -0
- package/dist/config/fullstack-cli-pin.js +17 -0
- package/dist/config/sync-configs/design-stack.js +98 -0
- package/dist/config/sync-configs/index.js +62 -0
- package/dist/config/sync-configs/nestjs-react-fullstack.js +177 -0
- package/dist/config/sync.js +14 -0
- package/dist/services/app/init/index.js +12 -0
- package/dist/services/app/init/install.js +123 -0
- package/dist/services/app/init/template.js +108 -0
- package/dist/services/deploy/modern/atoms/build.js +59 -0
- package/dist/services/deploy/modern/atoms/context.js +27 -0
- package/dist/services/deploy/modern/atoms/index.js +17 -0
- package/dist/services/deploy/modern/atoms/local-release.js +27 -0
- package/dist/services/deploy/modern/atoms/pre-release.js +13 -0
- package/dist/services/deploy/modern/atoms/save-plugin-instances.js +72 -0
- package/dist/services/deploy/modern/atoms/upload.js +246 -0
- package/dist/services/deploy/modern/check.js +53 -0
- package/dist/services/deploy/modern/constants.js +13 -0
- package/dist/services/deploy/modern/index.js +16 -0
- package/dist/services/deploy/modern/pipelines/index.js +5 -0
- package/dist/services/deploy/modern/pipelines/local.js +75 -0
- package/dist/services/deploy/modern/protocol.js +122 -0
- package/dist/services/deploy/modern/run-types.js +4 -0
- package/dist/services/deploy/modern/run.js +13 -0
- package/dist/services/deploy/modern/template-key-map.js +22 -0
- package/dist/services/skills/index.js +5 -0
- package/dist/services/skills/status.js +37 -0
- package/dist/utils/coding-steering.js +169 -0
- package/dist/utils/file-ops.js +45 -0
- package/dist/utils/git.js +22 -0
- package/dist/utils/githooks.js +55 -0
- package/dist/utils/http.js +21 -11
- package/dist/utils/merge-json.js +63 -0
- package/dist/utils/npm-pack.js +55 -0
- package/dist/utils/platform-sync.js +160 -0
- package/dist/utils/spark-meta.js +42 -0
- package/dist/utils/sync-rule.js +295 -0
- package/package.json +5 -3
- package/upgrade/templates/README.md +34 -0
- package/upgrade/templates/design-stack/templates/.githooks/pre-commit +4 -0
- package/upgrade/templates/design-stack/templates/scripts/dev-local.sh +53 -0
- package/upgrade/templates/design-stack/templates/scripts/dev.sh +25 -0
- package/upgrade/templates/design-stack/templates/scripts/hooks/run-precommit.js +37 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/.githooks/pre-commit +4 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/.gitignore.append +8 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/.spark_project +16 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/drizzle.config.ts +55 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/helper/gen-openapi.ts +34 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/nest-cli.json +25 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/scripts/build.sh +207 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/scripts/dev-local.sh +61 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/scripts/dev.js +295 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/scripts/dev.sh +25 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/scripts/hooks/run-precommit.js +37 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/scripts/lint.js +150 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/scripts/prune-smart.js +330 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/scripts/run.sh +8 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/server/global.d.ts +19 -0
- package/upgrade/templates/nestjs-react-fullstack/templates/tsconfig.node.json +5 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.savePluginInstances = savePluginInstances;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const index_1 = require("../../../../api/deploy/index");
|
|
10
|
+
const logger_1 = require("../../../../utils/logger");
|
|
11
|
+
const constants_1 = require("../constants");
|
|
12
|
+
function isValidCapability(o) {
|
|
13
|
+
if (typeof o !== 'object' || o === null)
|
|
14
|
+
return false;
|
|
15
|
+
const id = o.id;
|
|
16
|
+
return typeof id === 'string' && id.length > 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 扫描 dist/output_capabilities/*.json,过滤出合法 capability,批量上报到 studio_server。
|
|
20
|
+
*
|
|
21
|
+
* 合法判定:能 JSON.parse + 顶层 id 是非空字符串。其它字段后端校验。
|
|
22
|
+
* 目录不存在 / 没有合法 capability → 直接返回 0,pipeline 当作 no-op。
|
|
23
|
+
* batchSave 调用失败 → 透传抛 AppError,pipeline 兜底 finalizeLocalRelease(Failed)。
|
|
24
|
+
*/
|
|
25
|
+
async function savePluginInstances(opts) {
|
|
26
|
+
const dir = node_path_1.default.join(opts.projectDir, constants_1.DIST_DIR, constants_1.OUTPUT_CAPABILITIES_DIR);
|
|
27
|
+
if (!node_fs_1.default.existsSync(dir)) {
|
|
28
|
+
(0, logger_1.debug)(`save-plugin-instances: ${dir} not present, skipping`);
|
|
29
|
+
return { saved: 0, skipped: 0 };
|
|
30
|
+
}
|
|
31
|
+
const files = node_fs_1.default.readdirSync(dir).filter((f) => f.endsWith('.json'));
|
|
32
|
+
const instances = [];
|
|
33
|
+
let skipped = 0;
|
|
34
|
+
for (const f of files) {
|
|
35
|
+
const full = node_path_1.default.join(dir, f);
|
|
36
|
+
let raw;
|
|
37
|
+
try {
|
|
38
|
+
raw = node_fs_1.default.readFileSync(full, 'utf-8');
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
(0, logger_1.debug)(`save-plugin-instances: read ${f} failed: ${err.message}`);
|
|
42
|
+
skipped++;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = JSON.parse(raw);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
(0, logger_1.debug)(`save-plugin-instances: ${f} is not valid JSON, skipping`);
|
|
51
|
+
skipped++;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (!isValidCapability(parsed)) {
|
|
55
|
+
(0, logger_1.debug)(`save-plugin-instances: ${f} missing 'id' string, skipping`);
|
|
56
|
+
skipped++;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
instances.push({ id: parsed.id, content: JSON.stringify(parsed) });
|
|
60
|
+
}
|
|
61
|
+
if (instances.length === 0) {
|
|
62
|
+
(0, logger_1.log)('deploy', `No capability to register (${String(files.length)} files scanned, all skipped)`);
|
|
63
|
+
return { saved: 0, skipped };
|
|
64
|
+
}
|
|
65
|
+
(0, logger_1.log)('deploy', `Registering ${String(instances.length)} capability instance(s)...`);
|
|
66
|
+
await (0, index_1.batchSavePluginInstances)({
|
|
67
|
+
appID: opts.appId,
|
|
68
|
+
appVersion: opts.version,
|
|
69
|
+
pluginInstances: instances,
|
|
70
|
+
});
|
|
71
|
+
return { saved: instances.length, skipped };
|
|
72
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.uploadArtifacts = uploadArtifacts;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const node_child_process_1 = require("node:child_process");
|
|
11
|
+
const index_1 = require("../../../../api/deploy/index");
|
|
12
|
+
const error_1 = require("../../../../utils/error");
|
|
13
|
+
const logger_1 = require("../../../../utils/logger");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
15
|
+
const protocol_1 = require("../protocol");
|
|
16
|
+
const UPLOAD_PLAN = [
|
|
17
|
+
{
|
|
18
|
+
kind: 'tos',
|
|
19
|
+
dir: constants_1.OUTPUT_DIR,
|
|
20
|
+
dataKey: protocol_1.DataKey.OUTPUT_TOS_UPLOAD_CREDENTIAL,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
kind: 'tos',
|
|
25
|
+
dir: constants_1.OUTPUT_RESOURCE_DIR,
|
|
26
|
+
dataKey: protocol_1.DataKey.OUTPUT_RESOURCE_TOS_UPLOAD_CREDENTIAL,
|
|
27
|
+
required: false,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
kind: 'paas_storage',
|
|
31
|
+
dir: constants_1.OUTPUT_STATIC_DIR,
|
|
32
|
+
dataKey: protocol_1.DataKey.OUTPUT_STATIC_PAAS_STORAGE_CREDENTIAL,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
function resolveTosutilPath() {
|
|
36
|
+
try {
|
|
37
|
+
const resolved = (0, node_child_process_1.execFileSync)('which', ['tosutil'], { encoding: 'utf-8' }).trim();
|
|
38
|
+
if (resolved)
|
|
39
|
+
return resolved;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
/* fallthrough */
|
|
43
|
+
}
|
|
44
|
+
throw new error_1.AppError('DEPLOY_TOSUTIL_MISSING', 'tosutil is not installed or not in PATH. modern deploy requires sandbox preinstalled tosutil.');
|
|
45
|
+
}
|
|
46
|
+
function tosutilUploadFromTos(cred) {
|
|
47
|
+
return {
|
|
48
|
+
accessKeyID: cred.accessKeyID,
|
|
49
|
+
secretAccessKey: cred.secretAccessKey,
|
|
50
|
+
sessionToken: cred.sessionToken,
|
|
51
|
+
endpoint: cred.endpoint,
|
|
52
|
+
region: cred.region,
|
|
53
|
+
bucket: cred.bucket,
|
|
54
|
+
prefix: cred.prefix,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function tosutilUploadFromPaasStorage(cred, dataKey) {
|
|
58
|
+
const { bucket, prefix } = (0, protocol_1.parseTosUploadPrefix)(cred.uploadPrefix, dataKey);
|
|
59
|
+
return {
|
|
60
|
+
accessKeyID: cred.accessKeyID,
|
|
61
|
+
secretAccessKey: cred.secretAccessKey,
|
|
62
|
+
sessionToken: cred.sessionToken,
|
|
63
|
+
endpoint: cred.endpoint,
|
|
64
|
+
region: cred.region,
|
|
65
|
+
bucket,
|
|
66
|
+
prefix,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 写一个 tosutil 临时 config 文件,注入 STS 凭证 + endpoint + region。
|
|
71
|
+
* 返回 config 路径,调用方负责清理。
|
|
72
|
+
*/
|
|
73
|
+
function writeTosutilConfig(tosutilPath, cred, label) {
|
|
74
|
+
const confPath = node_path_1.default.join(node_os_1.default.tmpdir(), `.tosutilconfig-miaoda-${label}-${String(process.pid)}-${String(Date.now())}`);
|
|
75
|
+
node_fs_1.default.writeFileSync(confPath, '');
|
|
76
|
+
(0, node_child_process_1.execFileSync)(tosutilPath, [
|
|
77
|
+
'config',
|
|
78
|
+
'-conf',
|
|
79
|
+
confPath,
|
|
80
|
+
'-e',
|
|
81
|
+
cred.endpoint,
|
|
82
|
+
'-i',
|
|
83
|
+
cred.accessKeyID,
|
|
84
|
+
'-k',
|
|
85
|
+
cred.secretAccessKey,
|
|
86
|
+
'-t',
|
|
87
|
+
cred.sessionToken,
|
|
88
|
+
'-re',
|
|
89
|
+
cred.region,
|
|
90
|
+
], { stdio: 'pipe' });
|
|
91
|
+
return confPath;
|
|
92
|
+
}
|
|
93
|
+
/** 把 tosutil 进程的输出按行回放到 stderr,便于线上排查(沙箱里无法 attach 进程)。 */
|
|
94
|
+
function streamTosutilOutput(output) {
|
|
95
|
+
if (!output)
|
|
96
|
+
return;
|
|
97
|
+
for (const line of output.split('\n')) {
|
|
98
|
+
if (line.length === 0)
|
|
99
|
+
continue;
|
|
100
|
+
process.stderr.write(`[tosutil] ${line}\n`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function normalizeTosDest(bucket, prefix) {
|
|
104
|
+
const bucketPart = bucket.startsWith('tos://') ? bucket : `tos://${bucket}`;
|
|
105
|
+
const normalized = prefix.replace(/^\/+/, '');
|
|
106
|
+
return `${bucketPart.replace(/\/+$/, '')}/${normalized}`;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 用 tosutil 把目录批量上传到 tos://bucket/prefix(STS 凭证从 config 文件读取)。
|
|
110
|
+
*/
|
|
111
|
+
function uploadDirWithCredential(tosutilPath, sourceDir, cred, label) {
|
|
112
|
+
const entries = node_fs_1.default.readdirSync(sourceDir);
|
|
113
|
+
if (entries.length === 0) {
|
|
114
|
+
(0, logger_1.debug)(`upload: skip empty dir ${sourceDir}`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const dest = normalizeTosDest(cred.bucket, cred.prefix);
|
|
118
|
+
(0, logger_1.debug)(`upload: ${sourceDir} -> ${dest} (${String(entries.length)} entries)`);
|
|
119
|
+
const confPath = writeTosutilConfig(tosutilPath, cred, label);
|
|
120
|
+
let output;
|
|
121
|
+
try {
|
|
122
|
+
output = (0, node_child_process_1.execFileSync)(tosutilPath, [
|
|
123
|
+
'cp',
|
|
124
|
+
sourceDir,
|
|
125
|
+
dest,
|
|
126
|
+
'-r',
|
|
127
|
+
'-flat',
|
|
128
|
+
'-j',
|
|
129
|
+
'5',
|
|
130
|
+
'-p',
|
|
131
|
+
'3',
|
|
132
|
+
'-ps',
|
|
133
|
+
'10485760',
|
|
134
|
+
'-f',
|
|
135
|
+
'-conf',
|
|
136
|
+
confPath,
|
|
137
|
+
], { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
138
|
+
streamTosutilOutput(output);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
const e = err;
|
|
142
|
+
const stderr = (e.stderr ?? '').trim();
|
|
143
|
+
const stdout = (e.stdout ?? '').trim();
|
|
144
|
+
streamTosutilOutput(stdout);
|
|
145
|
+
streamTosutilOutput(stderr);
|
|
146
|
+
throw new error_1.AppError('DEPLOY_UPLOAD_FAILED', `tosutil cp exited with status ${String(e.status ?? -1)} for ${sourceDir}\n` +
|
|
147
|
+
` stderr: ${stderr || '(empty)'}\n` +
|
|
148
|
+
` stdout: ${stdout.slice(0, 500) || '(empty)'}`);
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
try {
|
|
152
|
+
node_fs_1.default.unlinkSync(confPath);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
/* ignore */
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const succeedMatch = /Succeed count is:\s*(\d+)/.exec(output);
|
|
159
|
+
const failedMatch = /Failed count is:\s*(\d+)/.exec(output);
|
|
160
|
+
const succeedCount = succeedMatch ? Number.parseInt(succeedMatch[1], 10) : 0;
|
|
161
|
+
const failedCount = failedMatch ? Number.parseInt(failedMatch[1], 10) : 0;
|
|
162
|
+
if (failedCount > 0) {
|
|
163
|
+
throw new error_1.AppError('DEPLOY_UPLOAD_FAILED', `Upload failed: ${String(failedCount)} files failed, ${String(succeedCount)} succeeded. source=${sourceDir}`);
|
|
164
|
+
}
|
|
165
|
+
if (succeedCount === 0) {
|
|
166
|
+
throw new error_1.AppError('DEPLOY_UPLOAD_EMPTY', `Upload failed: 0 files uploaded. source=${sourceDir}. Check tosutil credentials and bucket permissions.`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function uploadTosTarget(tosutilPath, target, localPath, data) {
|
|
170
|
+
const credRaw = target.required
|
|
171
|
+
? (0, protocol_1.requireDataKey)(data, target.dataKey)
|
|
172
|
+
: (0, protocol_1.optionalDataKey)(data, target.dataKey);
|
|
173
|
+
if (credRaw === undefined) {
|
|
174
|
+
(0, logger_1.debug)(`upload: ${target.dir} exists but no credential configured, skipping`);
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
const cred = (0, protocol_1.parseTosUploadCredential)(credRaw, target.dataKey);
|
|
178
|
+
(0, logger_1.log)('deploy', `Uploading ${target.dir}...`);
|
|
179
|
+
uploadDirWithCredential(tosutilPath, localPath, tosutilUploadFromTos(cred), target.dir);
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
function uploadPaasStorageTarget(tosutilPath, target, localPath, data) {
|
|
183
|
+
// 空目录:直接跳过;callbackStatic 也不能调,否则会让后端把"未发生的上传"
|
|
184
|
+
// 误以为已完成。凭证本身 build 阶段已经消费过 downloadURLPrefix,这里不重复要求。
|
|
185
|
+
if (node_fs_1.default.readdirSync(localPath).length === 0) {
|
|
186
|
+
(0, logger_1.debug)(`upload: ${target.dir} is empty, skipping`);
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
const cred = (0, protocol_1.parsePaasStorageCredential)((0, protocol_1.requireDataKey)(data, target.dataKey), target.dataKey);
|
|
190
|
+
(0, logger_1.log)('deploy', `Uploading ${target.dir}...`);
|
|
191
|
+
uploadDirWithCredential(tosutilPath, localPath, tosutilUploadFromPaasStorage(cred, target.dataKey), target.dir);
|
|
192
|
+
return cred;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* 上传三类产物。output / output_resource 走 TOS STS 凭证;output_static 走 PaaS Storage
|
|
196
|
+
* 凭证(uploadPrefix 解出 tosutil cp 目的,上传完后再调 callbackStatic 把 uploadID
|
|
197
|
+
* 提交给后端核销):
|
|
198
|
+
* - dist/output (必传) → OUTPUT_TOS_UPLOAD_CREDENTIAL
|
|
199
|
+
* - dist/output_resource (可选) → OUTPUT_RESOURCE_TOS_UPLOAD_CREDENTIAL
|
|
200
|
+
* - dist/output_static (可选) → OUTPUT_STATIC_PAAS_STORAGE_CREDENTIAL + callbackStatic
|
|
201
|
+
*
|
|
202
|
+
* 目录不存在的可选项跳过;output 不存在或凭证缺失抛错。
|
|
203
|
+
*/
|
|
204
|
+
async function uploadArtifacts(opts) {
|
|
205
|
+
const tosutilPath = resolveTosutilPath();
|
|
206
|
+
const distDir = node_path_1.default.join(opts.projectDir, constants_1.DIST_DIR);
|
|
207
|
+
const outcome = { uploaded: 0 };
|
|
208
|
+
for (const target of UPLOAD_PLAN) {
|
|
209
|
+
const localPath = node_path_1.default.join(distDir, target.dir);
|
|
210
|
+
const exists = node_fs_1.default.existsSync(localPath);
|
|
211
|
+
if (target.kind === 'tos') {
|
|
212
|
+
if (!exists) {
|
|
213
|
+
if (target.required) {
|
|
214
|
+
throw new error_1.AppError('DEPLOY_NO_BUILD_OUTPUT', `Required directory missing: ${constants_1.DIST_DIR}/${target.dir}`);
|
|
215
|
+
}
|
|
216
|
+
(0, logger_1.debug)(`upload: dir not present, skipping ${target.dir}`);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (uploadTosTarget(tosutilPath, target, localPath, opts.data)) {
|
|
220
|
+
outcome.uploaded++;
|
|
221
|
+
}
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
// PaaS Storage 分支
|
|
225
|
+
if (!exists) {
|
|
226
|
+
(0, logger_1.debug)(`upload: dir not present, skipping ${target.dir}`);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
const cred = uploadPaasStorageTarget(tosutilPath, target, localPath, opts.data);
|
|
230
|
+
if (cred) {
|
|
231
|
+
outcome.staticUploaded = cred;
|
|
232
|
+
outcome.uploaded++;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (outcome.uploaded === 0) {
|
|
236
|
+
throw new error_1.AppError('DEPLOY_UPLOAD_EMPTY', 'No artifacts uploaded — check build output.');
|
|
237
|
+
}
|
|
238
|
+
if (outcome.staticUploaded) {
|
|
239
|
+
(0, logger_1.log)('deploy', 'Callbacking static upload...');
|
|
240
|
+
await (0, index_1.callbackStatic)({
|
|
241
|
+
appID: opts.appId,
|
|
242
|
+
bucketID: outcome.staticUploaded.bucketID,
|
|
243
|
+
uploadID: outcome.staticUploaded.uploadID,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runDeployChecks = runDeployChecks;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const error_1 = require("../../../utils/error");
|
|
10
|
+
/**
|
|
11
|
+
* 项目级 deploy 前置检查:node_modules / .spark/meta.json / package.json.scripts.build。
|
|
12
|
+
* 任一 error 级别失败抛 AppError,附错误码 DEPLOY_PROJECT_CHECK_FAILED。
|
|
13
|
+
*/
|
|
14
|
+
function runDeployChecks(projectDir) {
|
|
15
|
+
const issues = [];
|
|
16
|
+
const nodeModules = node_path_1.default.join(projectDir, 'node_modules');
|
|
17
|
+
if (!node_fs_1.default.existsSync(nodeModules)) {
|
|
18
|
+
issues.push('node_modules not found. Run `npm install` (or equivalent) first.');
|
|
19
|
+
}
|
|
20
|
+
const metaPath = node_path_1.default.join(projectDir, '.spark', 'meta.json');
|
|
21
|
+
if (!node_fs_1.default.existsSync(metaPath)) {
|
|
22
|
+
issues.push('.spark/meta.json not found. Run `miaoda app init` first.');
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
try {
|
|
26
|
+
const meta = JSON.parse(node_fs_1.default.readFileSync(metaPath, 'utf-8'));
|
|
27
|
+
if (!meta.stack) {
|
|
28
|
+
issues.push('.spark/meta.json missing fields: stack');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
issues.push('.spark/meta.json is not valid JSON.');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const pkgPath = node_path_1.default.join(projectDir, 'package.json');
|
|
36
|
+
if (!node_fs_1.default.existsSync(pkgPath)) {
|
|
37
|
+
issues.push('package.json not found.');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
try {
|
|
41
|
+
const pkg = JSON.parse(node_fs_1.default.readFileSync(pkgPath, 'utf-8'));
|
|
42
|
+
if (!pkg.scripts?.build) {
|
|
43
|
+
issues.push('package.json missing "build" script.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
issues.push('package.json is not valid JSON.');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (issues.length > 0) {
|
|
51
|
+
throw new error_1.AppError('DEPLOY_PROJECT_CHECK_FAILED', `Project check failed:\n${issues.map((i) => ` - ${i}`).join('\n')}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// modern deploy 流程使用的目录常量。
|
|
3
|
+
// (旧版的 STACK_CONFIGS / archType / FaaS 相关常量在新接口契约下不再需要——
|
|
4
|
+
// 发布模板差异完全由后端 preRelease.data 下发,CLI 不维护 stack 配置。)
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OUTPUT_CAPABILITIES_DIR = exports.OUTPUT_STATIC_DIR = exports.OUTPUT_RESOURCE_DIR = exports.OUTPUT_DIR = exports.DIST_DIR = void 0;
|
|
7
|
+
/** 构建产物固定目录约定 */
|
|
8
|
+
exports.DIST_DIR = 'dist';
|
|
9
|
+
exports.OUTPUT_DIR = 'output';
|
|
10
|
+
exports.OUTPUT_RESOURCE_DIR = 'output_resource';
|
|
11
|
+
exports.OUTPUT_STATIC_DIR = 'output_static';
|
|
12
|
+
/** 发布插件能力声明目录:含若干 capability.json 文件,发布时批量注册到 plugin_instances */
|
|
13
|
+
exports.OUTPUT_CAPABILITIES_DIR = 'output_capabilities';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OUTPUT_STATIC_DIR = exports.OUTPUT_RESOURCE_DIR = exports.OUTPUT_DIR = exports.DIST_DIR = exports.optionalDataKey = exports.requireDataKey = exports.DataKey = exports.runDeployChecks = exports.runModernDeploy = void 0;
|
|
4
|
+
var run_1 = require("./run");
|
|
5
|
+
Object.defineProperty(exports, "runModernDeploy", { enumerable: true, get: function () { return run_1.runModernDeploy; } });
|
|
6
|
+
var check_1 = require("./check");
|
|
7
|
+
Object.defineProperty(exports, "runDeployChecks", { enumerable: true, get: function () { return check_1.runDeployChecks; } });
|
|
8
|
+
var protocol_1 = require("./protocol");
|
|
9
|
+
Object.defineProperty(exports, "DataKey", { enumerable: true, get: function () { return protocol_1.DataKey; } });
|
|
10
|
+
Object.defineProperty(exports, "requireDataKey", { enumerable: true, get: function () { return protocol_1.requireDataKey; } });
|
|
11
|
+
Object.defineProperty(exports, "optionalDataKey", { enumerable: true, get: function () { return protocol_1.optionalDataKey; } });
|
|
12
|
+
var constants_1 = require("./constants");
|
|
13
|
+
Object.defineProperty(exports, "DIST_DIR", { enumerable: true, get: function () { return constants_1.DIST_DIR; } });
|
|
14
|
+
Object.defineProperty(exports, "OUTPUT_DIR", { enumerable: true, get: function () { return constants_1.OUTPUT_DIR; } });
|
|
15
|
+
Object.defineProperty(exports, "OUTPUT_RESOURCE_DIR", { enumerable: true, get: function () { return constants_1.OUTPUT_RESOURCE_DIR; } });
|
|
16
|
+
Object.defineProperty(exports, "OUTPUT_STATIC_DIR", { enumerable: true, get: function () { return constants_1.OUTPUT_STATIC_DIR; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.localBuildLocalPublishPipeline = void 0;
|
|
4
|
+
var local_1 = require("./local");
|
|
5
|
+
Object.defineProperty(exports, "localBuildLocalPublishPipeline", { enumerable: true, get: function () { return local_1.localBuildLocalPublishPipeline; } });
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.localBuildLocalPublishPipeline = localBuildLocalPublishPipeline;
|
|
4
|
+
const spark_meta_1 = require("../../../../utils/spark-meta");
|
|
5
|
+
const error_1 = require("../../../../utils/error");
|
|
6
|
+
const logger_1 = require("../../../../utils/logger");
|
|
7
|
+
const index_1 = require("../atoms/index");
|
|
8
|
+
/**
|
|
9
|
+
* 本地构建 + 本地部署 pipeline。
|
|
10
|
+
*
|
|
11
|
+
* 步骤顺序:
|
|
12
|
+
* 1. prepareDeployContext — 校验项目 + 读 meta
|
|
13
|
+
* 2. preRelease — 签发 pre_release_id / version / 动态配置 data
|
|
14
|
+
* 3. runBuild — 本地 npm run build(注入 data 中的 CDN 前缀)
|
|
15
|
+
* 4. createLocalRelease — 创建发布单(加锁、拿 releaseID)
|
|
16
|
+
* 5. uploadArtifacts — 把产物推到 preRelease 下发的 pre-signed URL
|
|
17
|
+
* 6. savePluginInstances — 扫描 dist/output_capabilities/*.json,批量注册插件能力
|
|
18
|
+
* 7. finalizeLocalRelease — Finished / Failed 翻终态
|
|
19
|
+
*
|
|
20
|
+
* createLocalRelease 提前到 upload 之前:发布单先建出来,
|
|
21
|
+
* upload / savePluginInstances 在已知 releaseID 的前提下进行;
|
|
22
|
+
* 任一步失败都会精准把该发布单标记为 Failed,避免遗留挂态。
|
|
23
|
+
*/
|
|
24
|
+
async function localBuildLocalPublishPipeline(opts) {
|
|
25
|
+
const ctx = (0, index_1.prepareDeployContext)(opts.projectDir, opts.appId);
|
|
26
|
+
(0, logger_1.log)('deploy', 'Pre-releasing...');
|
|
27
|
+
const pre = await (0, index_1.preRelease)(ctx.appId, ctx.templateKey);
|
|
28
|
+
(0, logger_1.log)('deploy', `pre_release_id=${pre.preReleaseID} version=${pre.version}`);
|
|
29
|
+
// data 文档标注为选填,但本地构建链路所有 atom 都需要其中的 key;
|
|
30
|
+
// 此处早期检查,把"data 缺失"翻为明确错误码,比让 requireDataKey 在
|
|
31
|
+
// 各 atom 里散落抛错好排查。
|
|
32
|
+
if (pre.data === undefined) {
|
|
33
|
+
throw new error_1.AppError('DEPLOY_PRE_RELEASE_DATA_MISSING', 'preRelease did not return a `data` map — backend tcc may not be configured for current template_key');
|
|
34
|
+
}
|
|
35
|
+
const data = pre.data;
|
|
36
|
+
if (!opts.skipBuild) {
|
|
37
|
+
(0, index_1.runBuild)({
|
|
38
|
+
projectDir: ctx.projectDir,
|
|
39
|
+
appId: ctx.appId,
|
|
40
|
+
version: pre.version,
|
|
41
|
+
templateKey: ctx.templateKey,
|
|
42
|
+
data,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
(0, logger_1.log)('deploy', 'Creating local release...');
|
|
46
|
+
const release = await (0, index_1.createLocalRelease)(ctx.appId, pre.version);
|
|
47
|
+
try {
|
|
48
|
+
(0, logger_1.log)('deploy', 'Uploading artifacts...');
|
|
49
|
+
await (0, index_1.uploadArtifacts)({ projectDir: ctx.projectDir, appId: ctx.appId, data });
|
|
50
|
+
const saveResult = await (0, index_1.savePluginInstances)({
|
|
51
|
+
projectDir: ctx.projectDir,
|
|
52
|
+
appId: ctx.appId,
|
|
53
|
+
version: pre.version,
|
|
54
|
+
});
|
|
55
|
+
if (saveResult.saved > 0) {
|
|
56
|
+
(0, logger_1.log)('deploy', `${String(saveResult.saved)} capability instance(s) registered`);
|
|
57
|
+
}
|
|
58
|
+
await (0, index_1.finalizeLocalRelease)(ctx.appId, release.releaseID, index_1.LocalReleaseStatus.Finished);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
await (0, index_1.finalizeLocalRelease)(ctx.appId, release.releaseID, index_1.LocalReleaseStatus.Failed);
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
if (release.onlineUrl !== undefined && release.onlineUrl !== '') {
|
|
65
|
+
(0, spark_meta_1.writeSparkMeta)(ctx.projectDir, { appUrl: release.onlineUrl });
|
|
66
|
+
}
|
|
67
|
+
(0, logger_1.log)('deploy', 'Deployed successfully');
|
|
68
|
+
return {
|
|
69
|
+
appId: ctx.appId,
|
|
70
|
+
version: pre.version,
|
|
71
|
+
url: release.onlineUrl ?? '',
|
|
72
|
+
releaseID: release.releaseID,
|
|
73
|
+
preReleaseID: pre.preReleaseID,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataKey = void 0;
|
|
4
|
+
exports.requireDataKey = requireDataKey;
|
|
5
|
+
exports.optionalDataKey = optionalDataKey;
|
|
6
|
+
exports.parseTosUploadCredential = parseTosUploadCredential;
|
|
7
|
+
exports.parsePaasStorageCredential = parsePaasStorageCredential;
|
|
8
|
+
exports.parseTosUploadPrefix = parseTosUploadPrefix;
|
|
9
|
+
const error_1 = require("../../../utils/error");
|
|
10
|
+
/**
|
|
11
|
+
* modern deploy 对外协议常量集中地(SSOT)。
|
|
12
|
+
*
|
|
13
|
+
* preRelease 接口返回 `data` 动态配置 map,其 key 由后端按 template_key 在 tcc
|
|
14
|
+
* 中下发。CLI 端通过本文件枚举的 DataKey 访问 `data`,避免拼写错误散布,
|
|
15
|
+
* 同时让协议演进(新增 key / 重命名)只需要改这一个文件。
|
|
16
|
+
*/
|
|
17
|
+
exports.DataKey = {
|
|
18
|
+
// ── CDN 前缀(构建期注入到 build env,用于客户端资源访问) ──
|
|
19
|
+
/** dist/output_resource 对应的 CDN 域名前缀 */
|
|
20
|
+
RESOURCE_CDN_PREFIX: 'resource_cdn_prefix',
|
|
21
|
+
// ── TOS 上传凭证(output / output_resource 两条线,value 为 JSON.stringify 的凭证对象) ──
|
|
22
|
+
// 凭证对象形态(camelCase):
|
|
23
|
+
// { accessKeyID, secretAccessKey, sessionToken, endpoint, region, bucket, prefix }
|
|
24
|
+
// CLI 端 JSON.parse 后写 tosutil 临时 config,cp 到 tos://bucket/prefix。
|
|
25
|
+
/** dist/output 上传凭证(必传) */
|
|
26
|
+
OUTPUT_TOS_UPLOAD_CREDENTIAL: 'output_tos_upload_credential',
|
|
27
|
+
/** dist/output_resource 上传凭证(仅当目录存在时使用) */
|
|
28
|
+
OUTPUT_RESOURCE_TOS_UPLOAD_CREDENTIAL: 'output_resource_tos_upload_credential',
|
|
29
|
+
// ── PaaS Storage 静态资源凭证(dist/output_static 专用) ──
|
|
30
|
+
// 形态:JSON.stringify 后的 PaasStorageCredential(见下方 interface)。
|
|
31
|
+
// 上传走 tosutil(从 uploadPrefix 解析出 bucket/prefix);上传完成后再调
|
|
32
|
+
// callbackStatic(appID, bucketID, uploadID) 把本次上传核销给后端;
|
|
33
|
+
// downloadURLPrefix 替代原 static_cdn_prefix 注入 build env。
|
|
34
|
+
/** dist/output_static 上传凭证(仅当目录存在时使用) */
|
|
35
|
+
OUTPUT_STATIC_PAAS_STORAGE_CREDENTIAL: 'output_static_paas_storage_credential',
|
|
36
|
+
};
|
|
37
|
+
/** 取必传 key,缺失抛 AppError(带 key 名,便于后端 tcc 配置排查) */
|
|
38
|
+
function requireDataKey(data, key) {
|
|
39
|
+
const v = data[key];
|
|
40
|
+
if (v === undefined || v === '') {
|
|
41
|
+
throw new error_1.AppError('DEPLOY_DATA_KEY_MISSING', `preRelease.data missing required key "${key}" — backend tcc may not be configured for the current template_key`);
|
|
42
|
+
}
|
|
43
|
+
return v;
|
|
44
|
+
}
|
|
45
|
+
/** 取可选 key,缺失返回 undefined(不抛错) */
|
|
46
|
+
function optionalDataKey(data, key) {
|
|
47
|
+
const v = data[key];
|
|
48
|
+
return v === undefined || v === '' ? undefined : v;
|
|
49
|
+
}
|
|
50
|
+
const TOS_CREDENTIAL_REQUIRED_FIELDS = [
|
|
51
|
+
'accessKeyID',
|
|
52
|
+
'secretAccessKey',
|
|
53
|
+
'sessionToken',
|
|
54
|
+
'endpoint',
|
|
55
|
+
'region',
|
|
56
|
+
'bucket',
|
|
57
|
+
'prefix',
|
|
58
|
+
];
|
|
59
|
+
const PAAS_STORAGE_CREDENTIAL_REQUIRED_FIELDS = [
|
|
60
|
+
'accessKeyID',
|
|
61
|
+
'secretAccessKey',
|
|
62
|
+
'sessionToken',
|
|
63
|
+
'endpoint',
|
|
64
|
+
'region',
|
|
65
|
+
'uploadPrefix',
|
|
66
|
+
'downloadURLPrefix',
|
|
67
|
+
'uploadID',
|
|
68
|
+
'bucketID',
|
|
69
|
+
];
|
|
70
|
+
function parseCredentialObject(raw, dataKey) {
|
|
71
|
+
let parsed;
|
|
72
|
+
try {
|
|
73
|
+
parsed = JSON.parse(raw);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
throw new error_1.AppError('DEPLOY_CRED_INVALID_JSON', `preRelease.data["${dataKey}"] is not valid JSON: ${err.message}`);
|
|
77
|
+
}
|
|
78
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
79
|
+
throw new error_1.AppError('DEPLOY_CRED_INVALID_JSON', `preRelease.data["${dataKey}"] is not an object`);
|
|
80
|
+
}
|
|
81
|
+
return parsed;
|
|
82
|
+
}
|
|
83
|
+
function assertStringFields(obj, required, dataKey) {
|
|
84
|
+
const missing = required.filter((k) => {
|
|
85
|
+
const v = obj[k];
|
|
86
|
+
return typeof v !== 'string' || v === '';
|
|
87
|
+
});
|
|
88
|
+
if (missing.length > 0) {
|
|
89
|
+
throw new error_1.AppError('DEPLOY_CRED_INCOMPLETE', `preRelease.data["${dataKey}"] credential missing fields: ${missing.join(', ')}`);
|
|
90
|
+
}
|
|
91
|
+
return obj;
|
|
92
|
+
}
|
|
93
|
+
/** JSON.parse + 字段完整性校验:output / output_resource 凭证 */
|
|
94
|
+
function parseTosUploadCredential(raw, dataKey) {
|
|
95
|
+
const obj = parseCredentialObject(raw, dataKey);
|
|
96
|
+
return assertStringFields(obj, TOS_CREDENTIAL_REQUIRED_FIELDS, dataKey);
|
|
97
|
+
}
|
|
98
|
+
/** JSON.parse + 字段完整性校验:output_static PaaS Storage 凭证 */
|
|
99
|
+
function parsePaasStorageCredential(raw, dataKey) {
|
|
100
|
+
const obj = parseCredentialObject(raw, dataKey);
|
|
101
|
+
return assertStringFields(obj, PAAS_STORAGE_CREDENTIAL_REQUIRED_FIELDS, dataKey);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 解析 `tos://<storage-bucket>/<segments...>/` 形态的 uploadPrefix。
|
|
105
|
+
* 返回的 bucket 是 tosutil cp 视角的 TOS 物理 bucket(uploadPrefix 第一段),
|
|
106
|
+
* prefix 是其余路径(不含开头斜杠,保留可能存在的尾部斜杠以贴合 tosutil 习惯)。
|
|
107
|
+
*
|
|
108
|
+
* 注意:这里返回的 bucket 与 PaasStorageCredential.bucketID 不是同一个概念
|
|
109
|
+
* (bucketID 是 PaaS Storage 逻辑 bucket,给 callbackStatic 用)。
|
|
110
|
+
*/
|
|
111
|
+
function parseTosUploadPrefix(uploadPrefix, dataKey) {
|
|
112
|
+
const match = /^tos:\/\/([^/]+)\/(.*)$/.exec(uploadPrefix);
|
|
113
|
+
if (!match) {
|
|
114
|
+
throw new error_1.AppError('DEPLOY_CRED_INCOMPLETE', `preRelease.data["${dataKey}"].uploadPrefix must look like "tos://<bucket>/<prefix>/", got: ${uploadPrefix}`);
|
|
115
|
+
}
|
|
116
|
+
const bucket = match[1];
|
|
117
|
+
const prefix = match[2];
|
|
118
|
+
if (bucket === '' || prefix === '') {
|
|
119
|
+
throw new error_1.AppError('DEPLOY_CRED_INCOMPLETE', `preRelease.data["${dataKey}"].uploadPrefix missing bucket or prefix segment: ${uploadPrefix}`);
|
|
120
|
+
}
|
|
121
|
+
return { bucket, prefix };
|
|
122
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// modern deploy 主入口(dispatch 层)。
|
|
3
|
+
//
|
|
4
|
+
// 当前阶段(Scope A)只接入"本地构建 + 本地部署"一条 pipeline;
|
|
5
|
+
// 后续接入"本地构建 + 远端部署 / 远端构建 + 远端部署"时,在此处按 template_key
|
|
6
|
+
// 或显式 flag 选不同 pipeline。pipeline 之间彼此独立、不共享中间状态。
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.runModernDeploy = runModernDeploy;
|
|
9
|
+
const index_1 = require("./pipelines/index");
|
|
10
|
+
async function runModernDeploy(opts) {
|
|
11
|
+
// 暂只支持本地构建 + 本地部署
|
|
12
|
+
return (0, index_1.localBuildLocalPublishPipeline)(opts);
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveTemplateKey = resolveTemplateKey;
|
|
4
|
+
/**
|
|
5
|
+
* 本地 stack 短名 → 后端发布模板 key 的映射。
|
|
6
|
+
*
|
|
7
|
+
* .spark/meta.json.stack 存的是脚手架模板短名(vite-react / html ...),
|
|
8
|
+
* 而服务端 preRelease 接受的 templateKey 是"部署类别"维度,由后端 tcc 注册。
|
|
9
|
+
* 当前所有支持的 stack 都属于纯前端类别,默认映射到 client_local_deploy;
|
|
10
|
+
* 未来出现需要走别的 templateKey 的 stack,再在表里加一行覆盖默认。
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_TEMPLATE_KEY = 'client_local_deploy';
|
|
13
|
+
const TEMPLATE_KEY_MAP = {
|
|
14
|
+
'vite-react': DEFAULT_TEMPLATE_KEY,
|
|
15
|
+
html: DEFAULT_TEMPLATE_KEY,
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* 把本地 stack 短名映射到后端 templateKey;未配置的 stack 走默认 client_local_deploy。
|
|
19
|
+
*/
|
|
20
|
+
function resolveTemplateKey(template) {
|
|
21
|
+
return TEMPLATE_KEY_MAP[template] ?? DEFAULT_TEMPLATE_KEY;
|
|
22
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readSkillsStatus = void 0;
|
|
4
|
+
var status_1 = require("./status");
|
|
5
|
+
Object.defineProperty(exports, "readSkillsStatus", { enumerable: true, get: function () { return status_1.readSkillsStatus; } });
|