@lark-apaas/miaoda-cli 0.1.32 → 0.1.33-alpha.021d268
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 +23 -0
- package/dist/cli/commands/app/index.js +81 -0
- package/dist/cli/commands/deploy/modern.js +6 -5
- package/dist/cli/handlers/app/index.js +6 -1
- package/dist/cli/handlers/app/pack.js +256 -0
- package/dist/services/app/pack/archive.js +35 -0
- package/dist/services/app/pack/copy-tree.js +51 -0
- package/dist/services/app/pack/download.js +52 -0
- package/dist/services/app/pack/index.js +27 -0
- package/dist/services/app/pack/inline-babel.js +91 -0
- package/dist/services/app/pack/naming.js +65 -0
- package/dist/services/app/pack/rewrite.js +80 -0
- package/dist/services/app/pack/scan.js +72 -0
- package/dist/services/app/pack/strategies.js +264 -0
- package/dist/services/app/pack/upload.js +110 -0
- package/dist/services/deploy/modern/patch/actions.js +6 -4
- package/dist/services/deploy/modern/patch/html-title.js +75 -0
- package/dist/services/deploy/modern/patch/index.js +1 -1
- package/dist/services/deploy/modern/patch/routes.js +13 -3
- package/dist/services/deploy/modern/patch/source-scan.js +3 -40
- package/dist/utils/exclude-patterns.js +49 -0
- package/dist/utils/sandbox-skills.js +13 -1
- package/package.json +1 -1
- package/upgrade/templates/nestjs-react-fullstack/templates/scripts/lint.js +43 -7
|
@@ -0,0 +1,110 @@
|
|
|
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.redactUrl = redactUrl;
|
|
7
|
+
exports.assertValidUploadUrl = assertValidUploadUrl;
|
|
8
|
+
exports.uploadZip = uploadZip;
|
|
9
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
10
|
+
const error_1 = require("../../../utils/error");
|
|
11
|
+
const logger_1 = require("../../../utils/logger");
|
|
12
|
+
/**
|
|
13
|
+
* 从响应头取排查用的 log id。字节侧网关/对象存储统一给 `x-tt-logid`;
|
|
14
|
+
* 拿不到时退到通用的 `x-request-id`,两个都没有就不报(不编造)。
|
|
15
|
+
*/
|
|
16
|
+
function pickLogId(resp) {
|
|
17
|
+
return resp.headers.get('x-tt-logid') ?? resp.headers.get('x-request-id') ?? undefined;
|
|
18
|
+
}
|
|
19
|
+
/** 有 log id 时拼成错误信息后缀,没有就什么都不加。 */
|
|
20
|
+
function logIdSuffix(logId) {
|
|
21
|
+
return logId ? `,log_id=${logId}` : '';
|
|
22
|
+
}
|
|
23
|
+
/** 上传超时。产物可达数 MB,给足余量;沙箱到对象存储通常是内网,不会真跑满。 */
|
|
24
|
+
const UPLOAD_TIMEOUT_MS = 120_000;
|
|
25
|
+
/**
|
|
26
|
+
* 抹掉 URL 的 query 再用于日志 / 错误信息。
|
|
27
|
+
*
|
|
28
|
+
* **预签名 URL 的签名等同于一份凭证** —— 谁拿到谁就能往那个位置写。原样打进日志、
|
|
29
|
+
* 错误上报或 JSON 输出,就等于把上传能力泄漏出去。所以对外可见的地方一律走这里。
|
|
30
|
+
*/
|
|
31
|
+
function redactUrl(raw) {
|
|
32
|
+
try {
|
|
33
|
+
const u = new URL(raw);
|
|
34
|
+
return u.search ? `${u.origin}${u.pathname}?<redacted>` : `${u.origin}${u.pathname}`;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// 连解析都失败的串,更不能原样回显
|
|
38
|
+
return '<unparseable url>';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 把 zip 以 **PUT 裸 body** 传到预签名 URL(TOS / S3 的标准上传形态)。
|
|
43
|
+
*
|
|
44
|
+
* 鉴权完全由 URL 自带的签名承担,不加任何额外 header —— 多带 header 反而可能破坏
|
|
45
|
+
* 某些实现的签名校验。
|
|
46
|
+
*
|
|
47
|
+
* 失败一律抛 `PACK_UPLOAD_FAILED`:调用方传了 `--upload-url` 就说明上传
|
|
48
|
+
* 是目的,传不上去等于没完成(设计决策:整个命令失败,退出码 1)。
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* 校验 `--upload-url` 合法性。**必须在动手构建之前调用** —— 否则 URL 写错要等一整轮
|
|
52
|
+
* 构建 + 图片下载 + 打包之后才被告知参数非法,白等几十秒。
|
|
53
|
+
*/
|
|
54
|
+
function assertValidUploadUrl(url) {
|
|
55
|
+
let parsed;
|
|
56
|
+
try {
|
|
57
|
+
parsed = new URL(url);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw new error_1.AppError('ARGS_INVALID', `--upload-url 不是合法 URL:${redactUrl(url)}`);
|
|
61
|
+
}
|
|
62
|
+
// 只允许 http(s):file: 会把产物写到本地路径,其它协议 fetch 也不支持
|
|
63
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
64
|
+
throw new error_1.AppError('ARGS_INVALID', `--upload-url 只支持 http/https,收到 ${parsed.protocol}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function uploadZip(zipPath, url) {
|
|
68
|
+
assertValidUploadUrl(url);
|
|
69
|
+
if (!node_fs_1.default.existsSync(zipPath)) {
|
|
70
|
+
throw new error_1.AppError('ARGS_INVALID', `待上传的 zip 不存在:${zipPath}`);
|
|
71
|
+
}
|
|
72
|
+
const body = node_fs_1.default.readFileSync(zipPath);
|
|
73
|
+
// 默认输出**不带 URL**(连脱敏版也不带):预签名 URL 属于凭证类信息,常规日志
|
|
74
|
+
// 里没有它的位置;排查靠响应头的 log_id 就够,那才是服务端能据以定位的东西。
|
|
75
|
+
// 完整地址只在显式 --verbose 时给出。
|
|
76
|
+
(0, logger_1.log)('pack', `Uploading ${String(body.length)} bytes...`);
|
|
77
|
+
(0, logger_1.debug)(`pack: PUT ${url}`);
|
|
78
|
+
let resp;
|
|
79
|
+
try {
|
|
80
|
+
resp = await fetch(url, {
|
|
81
|
+
method: 'PUT',
|
|
82
|
+
headers: {
|
|
83
|
+
'content-type': 'application/zip',
|
|
84
|
+
'content-length': String(body.length),
|
|
85
|
+
},
|
|
86
|
+
body,
|
|
87
|
+
signal: AbortSignal.timeout(UPLOAD_TIMEOUT_MS),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
throw new error_1.AppError('PACK_UPLOAD_FAILED', `上传失败:${err instanceof Error ? err.message : String(err)}`, {
|
|
92
|
+
next_actions: [
|
|
93
|
+
'本地产物已保留,可修正 --upload-url 后重跑,或手动上传',
|
|
94
|
+
'--verbose 可打印完整请求地址',
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const logId = pickLogId(resp);
|
|
99
|
+
if (!resp.ok) {
|
|
100
|
+
throw new error_1.AppError('PACK_UPLOAD_FAILED', `上传失败:HTTP ${String(resp.status)}${logIdSuffix(logId)}`, {
|
|
101
|
+
next_actions: [
|
|
102
|
+
'预签名 URL 可能已过期或签名不匹配,确认后重试',
|
|
103
|
+
'本地产物已保留,也可手动上传',
|
|
104
|
+
'--verbose 可打印完整请求地址',
|
|
105
|
+
],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
(0, logger_1.log)('pack', `Uploaded (HTTP ${String(resp.status)}${logIdSuffix(logId)})`);
|
|
109
|
+
return { status: resp.status, ...(logId ? { logId } : {}) };
|
|
110
|
+
}
|
|
@@ -36,8 +36,10 @@ function isHtml(rel) {
|
|
|
36
36
|
/**
|
|
37
37
|
* 把 changeset 组成 TosFileAction[]:
|
|
38
38
|
* - create/update 读本地文件、自动编码;delete 仅 FilePath。
|
|
39
|
-
* - .html 被 create / delete
|
|
40
|
-
*
|
|
39
|
+
* - 任一 .html 被 create / update / delete 时,追加重算 routes.json 的 UPDATE action。
|
|
40
|
+
* update 也算:routes.json 的 name 取自 HTML 的 `<title>`,改方案名就是一次纯 update,
|
|
41
|
+
* 只按 create/delete 判定会让改名永远进不了 routes.json。
|
|
42
|
+
* - 纯非 .html 改动(js / css / 图片)不动 routes.json。
|
|
41
43
|
*/
|
|
42
44
|
function buildTosActions(projectDir, cs) {
|
|
43
45
|
const actions = [];
|
|
@@ -48,8 +50,8 @@ function buildTosActions(projectDir, cs) {
|
|
|
48
50
|
for (const rel of cs.deletes) {
|
|
49
51
|
actions.push({ actionType: index_1.TosActionType.DELETE, filePath: normalizeRel(rel) });
|
|
50
52
|
}
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
+
const routesMayChange = [...cs.creates, ...cs.updates, ...cs.deletes].some(isHtml);
|
|
54
|
+
if (routesMayChange) {
|
|
53
55
|
actions.push({
|
|
54
56
|
actionType: index_1.TosActionType.UPDATE,
|
|
55
57
|
filePath: 'routes.json',
|
|
@@ -0,0 +1,75 @@
|
|
|
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.extractTitle = extractTitle;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
/**
|
|
9
|
+
* 读 `<title>` 时的扫描窗口上限(字节)。title 规范上在 `<head>` 里、正常紧贴文档开头,
|
|
10
|
+
* 64KB 足以覆盖 head 里塞了内联 style / script 的情况,同时给大 HTML 兜住 IO 上限
|
|
11
|
+
* (generateRoutes 会遍历工程内所有 .html,不能整文件读)。
|
|
12
|
+
*/
|
|
13
|
+
const HEAD_SCAN_BYTES = 64 * 1024;
|
|
14
|
+
const TITLE_RE = /<title[^>]*>([^<]*)<\/title>/i;
|
|
15
|
+
const HEAD_CLOSE_RE = /<\/head\s*>/i;
|
|
16
|
+
const COMMENT_RE = /<!--[\s\S]*?-->/g;
|
|
17
|
+
const ENTITY_RE = /&(#x[0-9a-f]+|#[0-9]+|[a-z]+);/gi;
|
|
18
|
+
/** HTML 里可能出现在 title 文本中的命名实体。未列出的原样保留,不做全量实体表。 */
|
|
19
|
+
const NAMED_ENTITIES = {
|
|
20
|
+
amp: '&',
|
|
21
|
+
lt: '<',
|
|
22
|
+
gt: '>',
|
|
23
|
+
quot: '"',
|
|
24
|
+
apos: "'",
|
|
25
|
+
nbsp: ' ',
|
|
26
|
+
};
|
|
27
|
+
/** 把 title 文本里的实体还原成明文——name 是给前端直接当文本渲染的,不该带 `&`。 */
|
|
28
|
+
function decodeEntities(s) {
|
|
29
|
+
return s.replace(ENTITY_RE, (matched, body) => {
|
|
30
|
+
if (!body.startsWith('#')) {
|
|
31
|
+
return NAMED_ENTITIES[body.toLowerCase()] ?? matched;
|
|
32
|
+
}
|
|
33
|
+
const code = /^#x/i.test(body) ? parseInt(body.slice(2), 16) : parseInt(body.slice(1), 10);
|
|
34
|
+
if (!Number.isInteger(code) || code <= 0 || code > 0x10ffff)
|
|
35
|
+
return matched;
|
|
36
|
+
return String.fromCodePoint(code);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** 只读文件头部 HEAD_SCAN_BYTES 字节。尾部可能截断多字节字符,对 title 提取无影响。 */
|
|
40
|
+
function readHead(absPath) {
|
|
41
|
+
const fd = node_fs_1.default.openSync(absPath, 'r');
|
|
42
|
+
try {
|
|
43
|
+
const buf = Buffer.alloc(HEAD_SCAN_BYTES);
|
|
44
|
+
const bytes = node_fs_1.default.readSync(fd, buf, 0, HEAD_SCAN_BYTES, 0);
|
|
45
|
+
return buf.subarray(0, bytes).toString('utf-8');
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
node_fs_1.default.closeSync(fd);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 取 HTML 的 `<title>` 文本作为该页面的方案名。
|
|
53
|
+
*
|
|
54
|
+
* - 扫描范围截到第一个 `</head>`:body 里的 `<title>` 不算——内联 SVG 图标的 a11y
|
|
55
|
+
* `<title>` 很常见,抓到就会把图标描述当成方案名。找不到 `</head>` 时退回整个窗口。
|
|
56
|
+
* - 先剔 HTML 注释,避免抓到被注释掉的 title。
|
|
57
|
+
* - 实体还原 + 空白折叠 + trim;空 title / 无 title / 读失败一律返回 undefined,
|
|
58
|
+
* 由消费侧 fallback 到 path(旧应用没有 title 时保持显示页面地址)。
|
|
59
|
+
*/
|
|
60
|
+
function extractTitle(absPath) {
|
|
61
|
+
let head;
|
|
62
|
+
try {
|
|
63
|
+
head = readHead(absPath);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const headClose = HEAD_CLOSE_RE.exec(head)?.index ?? -1;
|
|
69
|
+
const scope = (headClose >= 0 ? head.slice(0, headClose) : head).replace(COMMENT_RE, '');
|
|
70
|
+
const raw = TITLE_RE.exec(scope)?.[1];
|
|
71
|
+
if (raw === undefined)
|
|
72
|
+
return undefined;
|
|
73
|
+
const text = decodeEntities(raw).replace(/\s+/g, ' ').trim();
|
|
74
|
+
return text === '' ? undefined : text;
|
|
75
|
+
}
|
|
@@ -11,7 +11,7 @@ const actions_1 = require("./actions");
|
|
|
11
11
|
var actions_2 = require("./actions");
|
|
12
12
|
Object.defineProperty(exports, "buildTosActions", { enumerable: true, get: function () { return actions_2.buildTosActions; } });
|
|
13
13
|
/**
|
|
14
|
-
* design-html 增量发布:读本地文件组 TosFileAction
|
|
14
|
+
* design-html 增量发布:读本地文件组 TosFileAction(改动含 .html 时带重算的
|
|
15
15
|
* routes.json),调后端 applyTosDiff 应用到 latest。scope 限 design_local_deploy。
|
|
16
16
|
*/
|
|
17
17
|
async function patchDesignDeploy(opts) {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.generateRoutes = generateRoutes;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const html_title_1 = require("./html-title");
|
|
4
9
|
const source_scan_1 = require("./source-scan");
|
|
5
10
|
/**
|
|
6
11
|
* .html → route path 推导(相对路径,不带 base 前缀)。rel 为 posix 相对路径。
|
|
@@ -16,8 +21,9 @@ function toRoute(rel) {
|
|
|
16
21
|
}
|
|
17
22
|
/**
|
|
18
23
|
* 扫描 projectDir 下所有 .html(套 source-scan 的 EXCLUDES),生成 routes.json 文本(含尾换行)。
|
|
19
|
-
* 每项为 { path, file }:path 为相对路径(不带 CLIENT_BASE_PATH 前缀,由消费侧拼接),
|
|
20
|
-
* file 为该路由对应的原始 .html
|
|
24
|
+
* 每项为 { path, file, name? }:path 为相对路径(不带 CLIENT_BASE_PATH 前缀,由消费侧拼接),
|
|
25
|
+
* file 为该路由对应的原始 .html 源文件,name 为该文件 `<title>` 解析出的方案名(可缺省)。
|
|
26
|
+
* 按 path 排序、同 path 取字典序靠前的 file 去重。
|
|
21
27
|
* 零 html 时输出空数组——不伪造解析不到文件的根路由。
|
|
22
28
|
*/
|
|
23
29
|
function generateRoutes(projectDir) {
|
|
@@ -27,7 +33,11 @@ function generateRoutes(projectDir) {
|
|
|
27
33
|
if (!byPath.has(entry.path))
|
|
28
34
|
byPath.set(entry.path, entry);
|
|
29
35
|
}
|
|
30
|
-
|
|
36
|
+
// title 只读去重后胜出的 file:同 path 多源(foo.html / foo/index.html)时不做无用 IO。
|
|
37
|
+
const routes = [...byPath.values()].map((entry) => {
|
|
38
|
+
const name = (0, html_title_1.extractTitle)(node_path_1.default.join(projectDir, entry.file));
|
|
39
|
+
return name === undefined ? entry : { ...entry, name };
|
|
40
|
+
});
|
|
31
41
|
return JSON.stringify(routes, null, 2) + '\n';
|
|
32
42
|
}
|
|
33
43
|
function byPathThenFile(a, b) {
|
|
@@ -7,45 +7,8 @@ exports.EXCLUDES = void 0;
|
|
|
7
7
|
exports.listSourceFiles = listSourceFiles;
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
|
|
11
|
-
exports
|
|
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
|
-
// 注意 .claude/skills 在 flat layout 下是指向 ../.agents/skills 的软链,而 listSourceFiles
|
|
24
|
-
// 会 follow 软链,所以必须按 basename 把 .claude 整个排掉,否则 skills 会从软链侧被带进产物。
|
|
25
|
-
'.agent',
|
|
26
|
-
'.agents',
|
|
27
|
-
'.claude',
|
|
28
|
-
'.codex',
|
|
29
|
-
'.cursor',
|
|
30
|
-
'.gemini',
|
|
31
|
-
'.trae',
|
|
32
|
-
'.windsurf',
|
|
33
|
-
'.vscode',
|
|
34
|
-
'.idea',
|
|
35
|
-
'AGENTS.md',
|
|
36
|
-
'CLAUDE.md',
|
|
37
|
-
'GEMINI.md',
|
|
38
|
-
'skills',
|
|
39
|
-
'.env',
|
|
40
|
-
'.env.local',
|
|
41
|
-
'README.md',
|
|
42
|
-
'.DS_Store',
|
|
43
|
-
'.spark',
|
|
44
|
-
// 本地开发的临时/运行时目录:tmp 里的 .html 是草稿或中间产物,logs 是本地日志,
|
|
45
|
-
// 两者既不进产物也不该出现在 routes.json。
|
|
46
|
-
'tmp',
|
|
47
|
-
'logs',
|
|
48
|
-
]);
|
|
10
|
+
const exclude_patterns_1 = require("../../../../utils/exclude-patterns");
|
|
11
|
+
Object.defineProperty(exports, "EXCLUDES", { enumerable: true, get: function () { return exclude_patterns_1.EXCLUDES; } });
|
|
49
12
|
/**
|
|
50
13
|
* 递归列出 root 下所有文件的相对 posix 路径,跳过 EXCLUDES(任意层级 basename),
|
|
51
14
|
* 用 statSync 判定目录/文件以 follow 符号链接(含指向目录的软链),断链等无法 stat 的条目跳过。
|
|
@@ -54,7 +17,7 @@ function listSourceFiles(root) {
|
|
|
54
17
|
const out = [];
|
|
55
18
|
const walk = (dir, rel) => {
|
|
56
19
|
for (const entry of node_fs_1.default.readdirSync(dir, { withFileTypes: true })) {
|
|
57
|
-
if (
|
|
20
|
+
if (exclude_patterns_1.EXCLUDES.has(entry.name))
|
|
58
21
|
continue;
|
|
59
22
|
const childRel = rel ? `${rel}/${entry.name}` : entry.name;
|
|
60
23
|
const abs = node_path_1.default.join(dir, entry.name);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EXCLUDES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 与模板 `scripts/build.sh` 的 rsync EXCLUDES 对齐:这些名字(任意层级 basename)不进产物/不计入路由。
|
|
6
|
+
*
|
|
7
|
+
* 放在 `utils/` 而非某个 domain 的 service 下,是因为它被 `deploy`(`source-scan.ts` 的
|
|
8
|
+
* `listSourceFiles`)与 `app`(`pack` 的 `copyTree`)两个 domain 共用 ——
|
|
9
|
+
* service 层跨域互调被 `boundaries/dependencies` 禁止(见 docs/dependency-rules.md F4),
|
|
10
|
+
* 共享的纯数据/纯逻辑必须下沉到 `utils/`。
|
|
11
|
+
*/
|
|
12
|
+
exports.EXCLUDES = new Set([
|
|
13
|
+
'.git',
|
|
14
|
+
'node_modules',
|
|
15
|
+
'dist',
|
|
16
|
+
'scripts',
|
|
17
|
+
'package.json',
|
|
18
|
+
'package-lock.json',
|
|
19
|
+
'pnpm-lock.yaml',
|
|
20
|
+
'yarn.lock',
|
|
21
|
+
'.gitignore',
|
|
22
|
+
'.npmrc',
|
|
23
|
+
// agent / 编辑器配置目录与指令文件:只服务本地开发,不属于应用资产。
|
|
24
|
+
// 注意 .claude/skills 在 flat layout 下是指向 ../.agents/skills 的软链,而 listSourceFiles
|
|
25
|
+
// 会 follow 软链,所以必须按 basename 把 .claude 整个排掉,否则 skills 会从软链侧被带进产物。
|
|
26
|
+
'.agent',
|
|
27
|
+
'.agents',
|
|
28
|
+
'.claude',
|
|
29
|
+
'.codex',
|
|
30
|
+
'.cursor',
|
|
31
|
+
'.gemini',
|
|
32
|
+
'.trae',
|
|
33
|
+
'.windsurf',
|
|
34
|
+
'.vscode',
|
|
35
|
+
'.idea',
|
|
36
|
+
'AGENTS.md',
|
|
37
|
+
'CLAUDE.md',
|
|
38
|
+
'GEMINI.md',
|
|
39
|
+
'skills',
|
|
40
|
+
'.env',
|
|
41
|
+
'.env.local',
|
|
42
|
+
'README.md',
|
|
43
|
+
'.DS_Store',
|
|
44
|
+
'.spark',
|
|
45
|
+
// 本地开发的临时/运行时目录:tmp 里的 .html 是草稿或中间产物,logs 是本地日志,
|
|
46
|
+
// 两者既不进产物也不该出现在 routes.json。
|
|
47
|
+
'tmp',
|
|
48
|
+
'logs',
|
|
49
|
+
]);
|
|
@@ -128,7 +128,16 @@ function syncSandboxSkills(opts) {
|
|
|
128
128
|
(0, logger_1.debug)(`sandbox-skills: no npm version matched -alpha.${lane}, fallback to @latest ` +
|
|
129
129
|
`(TCC 里的 X 可能是老 lane dist-tag 命名 / 已 unpublish / npm view 挂 / 网络断)`);
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
// 版本优先级:lane(TCC 显式定向)> BOE 默认 @dev > @latest
|
|
132
|
+
//
|
|
133
|
+
// `dev` 通道由 miaoda-coding 的 publish-sandbox-skills-dev.sh 在 develop 分支自动发布
|
|
134
|
+
// (`<base>-dev.<sha>` + dist-tag `dev`),口径与 coding-steering 完全一致 ——
|
|
135
|
+
// 后者在本仓 coding-steering 侧也是 `FORCE_FRAMEWORK_ENVIRONMENT=boe` 时默认取 `dev`。
|
|
136
|
+
//
|
|
137
|
+
// lane 必须压过 dev:TCC 里配了 tgz-key 就说明是定向灰度(钉某个 feat 分支的快照),
|
|
138
|
+
// 不能被"BOE 就跟 develop"这条默认规则覆盖掉。
|
|
139
|
+
const isBoe = process.env.FORCE_FRAMEWORK_ENVIRONMENT === 'boe';
|
|
140
|
+
const primaryVersion = laneVersion ?? (isBoe ? 'dev' : 'latest');
|
|
132
141
|
try {
|
|
133
142
|
(0, logger_1.debug)(`sandbox-skills: fetching ${packageName}@${primaryVersion}`);
|
|
134
143
|
fetched = (0, npm_pack_1.fetchNpmPackage)({
|
|
@@ -138,6 +147,9 @@ function syncSandboxSkills(opts) {
|
|
|
138
147
|
});
|
|
139
148
|
}
|
|
140
149
|
catch (err) {
|
|
150
|
+
// @latest 是最后一档,它再挂就没得降了,直接抛。
|
|
151
|
+
// lane / dev 拉失败都降到 @latest:dev 通道可能因为 develop 还没发过包而不存在
|
|
152
|
+
// (dist-tag 缺失 → npm pack 404),这时候不该让整条 sync 挂掉。
|
|
141
153
|
if (primaryVersion === 'latest') {
|
|
142
154
|
throw err;
|
|
143
155
|
}
|
package/package.json
CHANGED
|
@@ -63,13 +63,47 @@ function isStylelintTarget(filePath) {
|
|
|
63
63
|
return filePath.endsWith('.css');
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
const STYLELINT_CONFIG_FILES = [
|
|
67
|
+
'.stylelintrc',
|
|
68
|
+
'.stylelintrc.js',
|
|
69
|
+
'.stylelintrc.cjs',
|
|
70
|
+
'.stylelintrc.json',
|
|
71
|
+
'stylelint.config.js',
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 老模板(fullstack-nestjs-template 1.x 时代)的应用跑不了 stylelint,跑了就挂、把 pre-commit
|
|
76
|
+
* 卡死。两种形态都实测过:
|
|
77
|
+
*
|
|
78
|
+
* - 缺 scripts.stylelint → `npm error Missing script: "stylelint"`
|
|
79
|
+
* - 缺 .stylelintrc.* → `ConfigurationError: No configuration provided`
|
|
80
|
+
*
|
|
81
|
+
* 注意光判断 stylelint 装没装拦不住:@lark-apaas/fullstack-presets 的 dependencies 里有
|
|
82
|
+
* stylelint,只要 dep 了 presets 二进制就在。缺任一件就跳过这一步。
|
|
83
|
+
*/
|
|
84
|
+
function canRunStylelint() {
|
|
85
|
+
let pkg;
|
|
86
|
+
try {
|
|
87
|
+
pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));
|
|
88
|
+
} catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!pkg.scripts || !pkg.scripts.stylelint) return false;
|
|
93
|
+
|
|
94
|
+
return STYLELINT_CONFIG_FILES.some(file => fs.existsSync(path.join(cwd, file)));
|
|
95
|
+
}
|
|
96
|
+
|
|
66
97
|
async function runDefaultLint() {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
'npm run
|
|
71
|
-
|
|
72
|
-
|
|
98
|
+
const commands = ['npm run eslint', 'npm run type:check'];
|
|
99
|
+
|
|
100
|
+
if (canRunStylelint()) {
|
|
101
|
+
commands.push('npm run stylelint');
|
|
102
|
+
} else {
|
|
103
|
+
console.warn('[lint] Skip stylelint: missing scripts.stylelint or stylelint config');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const code = await runCommand(getBinName('npx'), ['concurrently', ...commands]);
|
|
73
107
|
process.exit(code);
|
|
74
108
|
}
|
|
75
109
|
|
|
@@ -107,7 +141,9 @@ async function runSelectiveLint(inputFiles) {
|
|
|
107
141
|
tasks.push(runCommand(getBinName('npx'), ['eslint', '--quiet', ...eslintFiles]));
|
|
108
142
|
}
|
|
109
143
|
|
|
110
|
-
if (stylelintFiles.length > 0) {
|
|
144
|
+
if (stylelintFiles.length > 0 && !canRunStylelint()) {
|
|
145
|
+
console.warn('[lint] Skip stylelint: missing scripts.stylelint or stylelint config');
|
|
146
|
+
} else if (stylelintFiles.length > 0) {
|
|
111
147
|
tasks.push(runCommand(getBinName('npx'), ['stylelint', '--quiet', ...stylelintFiles]));
|
|
112
148
|
}
|
|
113
149
|
|