@lark-apaas/miaoda-cli 0.1.18 → 0.1.19-alpha.4bf5458
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/api/deploy/index.js +3 -1
- package/dist/api/deploy/modern-types.js +4 -1
- package/dist/api/deploy/modern.js +8 -0
- package/dist/cli/commands/app/index.js +5 -3
- package/dist/cli/commands/deploy/modern.js +30 -0
- package/dist/cli/commands/index.js +10 -0
- package/dist/cli/handlers/app/init.js +5 -4
- package/dist/cli/handlers/app/migrate.js +4 -5
- package/dist/cli/handlers/deploy/index.js +3 -1
- package/dist/cli/handlers/deploy/patch.js +16 -0
- package/dist/services/app/init/async-install.js +3 -7
- package/dist/services/app/init/index.js +1 -2
- package/dist/services/app/init/template.js +1 -0
- package/dist/services/deploy/modern/atoms/design-build.js +41 -0
- package/dist/services/deploy/modern/atoms/design-upload.js +74 -0
- package/dist/services/deploy/modern/atoms/index.js +5 -1
- package/dist/services/deploy/modern/atoms/tosutil.js +246 -0
- package/dist/services/deploy/modern/atoms/upload.js +4 -127
- package/dist/services/deploy/modern/check.js +28 -16
- package/dist/services/deploy/modern/patch/actions.js +60 -0
- package/dist/services/deploy/modern/patch/content.js +18 -0
- package/dist/services/deploy/modern/patch/index.js +41 -0
- package/dist/services/deploy/modern/patch/routes.js +28 -0
- package/dist/services/deploy/modern/patch/source-scan.js +56 -0
- package/dist/services/deploy/modern/pipelines/design-local.js +47 -0
- package/dist/services/deploy/modern/pipelines/index.js +3 -1
- package/dist/services/deploy/modern/protocol.js +7 -0
- package/dist/services/deploy/modern/run.js +10 -4
- package/dist/services/deploy/modern/template-key-map.js +4 -0
- package/dist/utils/coding-steering.js +6 -5
- package/dist/utils/env.js +19 -0
- package/dist/utils/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
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.EXCLUDES = void 0;
|
|
7
|
+
exports.listSourceFiles = listSourceFiles;
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
// 与模板 scripts/build.sh 的 rsync EXCLUDES 对齐:这些名字(任意层级 basename)不进产物/不计入路由。
|
|
11
|
+
exports.EXCLUDES = new Set([
|
|
12
|
+
'.git',
|
|
13
|
+
'node_modules',
|
|
14
|
+
'dist',
|
|
15
|
+
'scripts',
|
|
16
|
+
'package.json',
|
|
17
|
+
'package-lock.json',
|
|
18
|
+
'pnpm-lock.yaml',
|
|
19
|
+
'yarn.lock',
|
|
20
|
+
'.gitignore',
|
|
21
|
+
'.npmrc',
|
|
22
|
+
'.agent',
|
|
23
|
+
'.env',
|
|
24
|
+
'.env.local',
|
|
25
|
+
'README.md',
|
|
26
|
+
'.DS_Store',
|
|
27
|
+
'.spark',
|
|
28
|
+
]);
|
|
29
|
+
/**
|
|
30
|
+
* 递归列出 root 下所有文件的相对 posix 路径,跳过 EXCLUDES(任意层级 basename),
|
|
31
|
+
* 用 statSync 判定目录/文件以 follow 符号链接(含指向目录的软链),断链等无法 stat 的条目跳过。
|
|
32
|
+
*/
|
|
33
|
+
function listSourceFiles(root) {
|
|
34
|
+
const out = [];
|
|
35
|
+
const walk = (dir, rel) => {
|
|
36
|
+
for (const entry of node_fs_1.default.readdirSync(dir, { withFileTypes: true })) {
|
|
37
|
+
if (exports.EXCLUDES.has(entry.name))
|
|
38
|
+
continue;
|
|
39
|
+
const childRel = rel ? `${rel}/${entry.name}` : entry.name;
|
|
40
|
+
const abs = node_path_1.default.join(dir, entry.name);
|
|
41
|
+
let isDir;
|
|
42
|
+
try {
|
|
43
|
+
isDir = node_fs_1.default.statSync(abs).isDirectory();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (isDir)
|
|
49
|
+
walk(abs, childRel);
|
|
50
|
+
else
|
|
51
|
+
out.push(childRel);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
walk(root, '');
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.designLocalPublishPipeline = designLocalPublishPipeline;
|
|
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
|
+
* design(design_local_deploy)本地构建 + 本地部署 pipeline。
|
|
10
|
+
*
|
|
11
|
+
* 与 client 版差异:build 走 buildDesignOutput(CLI 闭环,不跑 npm run build)、upload 走 uploadDesignArtifacts(version+latest
|
|
12
|
+
* 双写、latest 精确镜像)、不注册插件能力(design-html 无 capability)。其余复用同一套 atom。
|
|
13
|
+
*/
|
|
14
|
+
async function designLocalPublishPipeline(opts) {
|
|
15
|
+
const ctx = (0, index_1.prepareDeployContext)(opts.projectDir, opts.appId);
|
|
16
|
+
(0, logger_1.log)('deploy', 'Pre-releasing...');
|
|
17
|
+
const pre = await (0, index_1.preRelease)(ctx.appId, ctx.templateKey);
|
|
18
|
+
(0, logger_1.log)('deploy', `pre_release_id=${pre.preReleaseID} version=${pre.version}`);
|
|
19
|
+
if (pre.data === undefined) {
|
|
20
|
+
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');
|
|
21
|
+
}
|
|
22
|
+
const data = pre.data;
|
|
23
|
+
if (!opts.skipBuild) {
|
|
24
|
+
(0, index_1.buildDesignOutput)({ projectDir: ctx.projectDir });
|
|
25
|
+
}
|
|
26
|
+
(0, logger_1.log)('deploy', 'Creating local release...');
|
|
27
|
+
const release = await (0, index_1.createLocalRelease)(ctx.appId, pre.version);
|
|
28
|
+
try {
|
|
29
|
+
await (0, index_1.uploadDesignArtifacts)({ projectDir: ctx.projectDir, data });
|
|
30
|
+
await (0, index_1.finalizeLocalRelease)(ctx.appId, release.releaseID, index_1.LocalReleaseStatus.Finished);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
await (0, index_1.finalizeLocalRelease)(ctx.appId, release.releaseID, index_1.LocalReleaseStatus.Failed);
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
if (release.onlineUrl !== undefined && release.onlineUrl !== '') {
|
|
37
|
+
(0, spark_meta_1.writeSparkMeta)(ctx.projectDir, { appUrl: release.onlineUrl });
|
|
38
|
+
}
|
|
39
|
+
(0, logger_1.log)('deploy', 'Deployed successfully');
|
|
40
|
+
return {
|
|
41
|
+
appId: ctx.appId,
|
|
42
|
+
version: pre.version,
|
|
43
|
+
url: release.onlineUrl ?? '',
|
|
44
|
+
releaseID: release.releaseID,
|
|
45
|
+
preReleaseID: pre.preReleaseID,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localBuildLocalPublishPipeline = void 0;
|
|
3
|
+
exports.designLocalPublishPipeline = exports.localBuildLocalPublishPipeline = void 0;
|
|
4
4
|
var local_1 = require("./local");
|
|
5
5
|
Object.defineProperty(exports, "localBuildLocalPublishPipeline", { enumerable: true, get: function () { return local_1.localBuildLocalPublishPipeline; } });
|
|
6
|
+
var design_local_1 = require("./design-local");
|
|
7
|
+
Object.defineProperty(exports, "designLocalPublishPipeline", { enumerable: true, get: function () { return design_local_1.designLocalPublishPipeline; } });
|
|
@@ -33,6 +33,13 @@ exports.DataKey = {
|
|
|
33
33
|
// downloadURLPrefix 替代原 static_cdn_prefix 注入 build env。
|
|
34
34
|
/** dist/output_static 上传凭证(仅当目录存在时使用) */
|
|
35
35
|
OUTPUT_STATIC_PAAS_STORAGE_CREDENTIAL: 'output_static_paas_storage_credential',
|
|
36
|
+
// ── design 部署专用(design_local_deploy) ──
|
|
37
|
+
/** 覆盖整个 {app_id} 文件夹的上传凭证(形态同 TosUploadCredential) */
|
|
38
|
+
OUTPUT_ALL_TOS_UPLOAD_CREDENTIAL: 'output_all_tos_upload_credential',
|
|
39
|
+
/** version/备份份真实路径(后端已替换 {app_id}/{version}) */
|
|
40
|
+
OUTPUT_BACKUP_PATH: 'output_backup_path',
|
|
41
|
+
/** latest 份真实路径(后端已替换 {app_id}/latest) */
|
|
42
|
+
OUTPUT_LATEST_PATH: 'output_latest_path',
|
|
36
43
|
};
|
|
37
44
|
/** 取必传 key,缺失抛 AppError(带 key 名,便于后端 tcc 配置排查) */
|
|
38
45
|
function requireDataKey(data, key) {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// modern deploy 主入口(dispatch 层)。
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// 按 templateKey 选 pipeline:design_local_deploy → design pipeline,其余 → client pipeline。
|
|
5
|
+
// 仅为路由轻量解析 templateKey(读 meta.stack + 映射),不跑前置检查——前置检查在各
|
|
6
|
+
// pipeline 内部的 prepareDeployContext 里做。client 分支与原行为完全一致。
|
|
7
|
+
// pipeline 之间彼此独立、不共享中间状态。
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
exports.runModernDeploy = runModernDeploy;
|
|
10
|
+
const spark_meta_1 = require("../../../utils/spark-meta");
|
|
11
|
+
const template_key_map_1 = require("./template-key-map");
|
|
9
12
|
const index_1 = require("./pipelines/index");
|
|
10
13
|
async function runModernDeploy(opts) {
|
|
11
|
-
|
|
14
|
+
const stack = (0, spark_meta_1.readSparkMeta)(opts.projectDir).stack ?? '';
|
|
15
|
+
if ((0, template_key_map_1.resolveTemplateKey)(stack) === template_key_map_1.DESIGN_LOCAL_DEPLOY) {
|
|
16
|
+
return (0, index_1.designLocalPublishPipeline)(opts);
|
|
17
|
+
}
|
|
12
18
|
return (0, index_1.localBuildLocalPublishPipeline)(opts);
|
|
13
19
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DESIGN_LOCAL_DEPLOY = void 0;
|
|
3
4
|
exports.resolveTemplateKey = resolveTemplateKey;
|
|
4
5
|
/**
|
|
5
6
|
* 本地 stack 短名 → 后端发布模板 key 的映射。
|
|
@@ -10,9 +11,12 @@ exports.resolveTemplateKey = resolveTemplateKey;
|
|
|
10
11
|
* 未来出现需要走别的 templateKey 的 stack,再在表里加一行覆盖默认。
|
|
11
12
|
*/
|
|
12
13
|
const DEFAULT_TEMPLATE_KEY = 'client_local_deploy';
|
|
14
|
+
/** design 部署 templateKey(run.ts 据此分流到 design pipeline) */
|
|
15
|
+
exports.DESIGN_LOCAL_DEPLOY = 'design_local_deploy';
|
|
13
16
|
const TEMPLATE_KEY_MAP = {
|
|
14
17
|
'vite-react': DEFAULT_TEMPLATE_KEY,
|
|
15
18
|
html: DEFAULT_TEMPLATE_KEY,
|
|
19
|
+
'design-html': exports.DESIGN_LOCAL_DEPLOY,
|
|
16
20
|
};
|
|
17
21
|
/**
|
|
18
22
|
* 把本地 stack 短名映射到后端 templateKey;未配置的 stack 走默认 client_local_deploy。
|
|
@@ -8,10 +8,11 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const npm_pack_1 = require("../utils/npm-pack");
|
|
10
10
|
const logger_1 = require("../utils/logger");
|
|
11
|
+
const env_1 = require("../utils/env");
|
|
11
12
|
const STEERING_PACKAGE = '@lark-apaas/coding-steering';
|
|
12
13
|
function inferMode() {
|
|
13
|
-
//
|
|
14
|
-
return
|
|
14
|
+
// 沙箱(MIAODA_DEP_CACHE_DIR 非空)→ sandbox;本地 → local
|
|
15
|
+
return (0, env_1.isSandboxEnv)() ? 'sandbox' : 'local';
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* 把 coding-steering 包内 <stack>/skills_common + 专有层(skills 或 skills_local)同步到
|
|
@@ -19,7 +20,7 @@ function inferMode() {
|
|
|
19
20
|
*
|
|
20
21
|
* 包内目录约定(每个 stack 三层):
|
|
21
22
|
* <stack>/skills_common → 沙箱 + 本地都下发的共有层
|
|
22
|
-
* <stack>/skills → 沙箱专有(沙箱端 update-skills.sh /
|
|
23
|
+
* <stack>/skills → 沙箱专有(沙箱端 update-skills.sh / mode=sandbox 时拿)
|
|
23
24
|
* <stack>/skills_local → 本地专有(本地 dev / agent 环境拿)
|
|
24
25
|
*
|
|
25
26
|
* 下发组合(mode):
|
|
@@ -31,8 +32,8 @@ function inferMode() {
|
|
|
31
32
|
* 'flat':拷到 .agents/skills/(平铺),tech.md → .agents/tech.md,并创建 .claude/skills
|
|
32
33
|
* 软链指向 ../.agents/skills 让 Claude Code 识别同一份
|
|
33
34
|
*
|
|
34
|
-
* 同名 skill 覆盖顺序:common < 专有(专有覆盖 common 同名)。mode 缺省按
|
|
35
|
-
*
|
|
35
|
+
* 同名 skill 覆盖顺序:common < 专有(专有覆盖 common 同名)。mode 缺省按 isSandboxEnv()
|
|
36
|
+
* 推断(MIAODA_DEP_CACHE_DIR 非空 → sandbox;空 / undefined → local)。
|
|
36
37
|
*
|
|
37
38
|
* 纯本地 atom(pull npm package + 拷贝文件),不属于任何 cli 域;放在 utils 让
|
|
38
39
|
* app init handler 与独立 skills sync handler 都能复用。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSandboxEnv = isSandboxEnv;
|
|
4
|
+
/**
|
|
5
|
+
* 运行环境判定:当前进程是否跑在妙搭沙箱里。
|
|
6
|
+
*
|
|
7
|
+
* 口径:`process.env.MIAODA_DEP_CACHE_DIR` 非空(既非 undefined 也非空串)即为沙箱。
|
|
8
|
+
* 沙箱平台运行时会给应用进程注入依赖缓存目录;本地 dev / agent 环境拿不到该变量。
|
|
9
|
+
*
|
|
10
|
+
* 历史上用 `SANDBOX_ID` 判断,但该变量在部分沙箱场景下并不会注入,判断不可靠,已换成
|
|
11
|
+
* `MIAODA_DEP_CACHE_DIR`。注意:下发给 user app 的 `scripts/dev.sh` 仍按 `SANDBOX_ID`
|
|
12
|
+
* 判断(独立 bash 链路,不复用本函数)。
|
|
13
|
+
*
|
|
14
|
+
* 这是 CLI 运行时沙箱判定的 SSOT —— init outputLayout 分流、migrate 重启 dev process、
|
|
15
|
+
* coding-steering 同步 mode 推断、async-install 写 marker 都走这里,别再各处内联读环境变量。
|
|
16
|
+
*/
|
|
17
|
+
function isSandboxEnv() {
|
|
18
|
+
return process.env.MIAODA_DEP_CACHE_DIR !== undefined && process.env.MIAODA_DEP_CACHE_DIR !== '';
|
|
19
|
+
}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pollUntilDone = exports.msToSec = exports.msToNs = exports.parseToSec = exports.parseToNs = exports.parseToMs = exports.parseTimeToMs = exports.getInnerApi = exports.postInnerApi = exports.setRuntimeHttpClient = exports.setHttpClient = exports.resetHttpClient = exports.getRuntimeHttpClient = exports.getHttpClient = exports.log = exports.debug = exports.fmt = exports.isJsonMode = exports.emitPaged = exports.emitOk = exports.emitError = exports.emit = exports.getLogId = exports.generateLogId = exports.initConfigFromOpts = exports.resetConfig = exports.setConfig = exports.getConfig = exports.HttpError = exports.AppError = void 0;
|
|
3
|
+
exports.pollUntilDone = exports.msToSec = exports.msToNs = exports.parseToSec = exports.parseToNs = exports.parseToMs = exports.parseTimeToMs = exports.isSandboxEnv = exports.getInnerApi = exports.postInnerApi = exports.setRuntimeHttpClient = exports.setHttpClient = exports.resetHttpClient = exports.getRuntimeHttpClient = exports.getHttpClient = exports.log = exports.debug = exports.fmt = exports.isJsonMode = exports.emitPaged = exports.emitOk = exports.emitError = exports.emit = exports.getLogId = exports.generateLogId = exports.initConfigFromOpts = exports.resetConfig = exports.setConfig = exports.getConfig = exports.HttpError = exports.AppError = void 0;
|
|
4
4
|
var error_1 = require("./error");
|
|
5
5
|
Object.defineProperty(exports, "AppError", { enumerable: true, get: function () { return error_1.AppError; } });
|
|
6
6
|
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return error_1.HttpError; } });
|
|
@@ -30,6 +30,8 @@ Object.defineProperty(exports, "setHttpClient", { enumerable: true, get: functio
|
|
|
30
30
|
Object.defineProperty(exports, "setRuntimeHttpClient", { enumerable: true, get: function () { return http_1.setRuntimeHttpClient; } });
|
|
31
31
|
Object.defineProperty(exports, "postInnerApi", { enumerable: true, get: function () { return http_1.postInnerApi; } });
|
|
32
32
|
Object.defineProperty(exports, "getInnerApi", { enumerable: true, get: function () { return http_1.getInnerApi; } });
|
|
33
|
+
var env_1 = require("./env");
|
|
34
|
+
Object.defineProperty(exports, "isSandboxEnv", { enumerable: true, get: function () { return env_1.isSandboxEnv; } });
|
|
33
35
|
var time_1 = require("./time");
|
|
34
36
|
Object.defineProperty(exports, "parseTimeToMs", { enumerable: true, get: function () { return time_1.parseTimeToMs; } });
|
|
35
37
|
Object.defineProperty(exports, "parseToMs", { enumerable: true, get: function () { return time_1.parseToMs; } });
|