cardbuddy 0.21.1 → 0.23.0
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 +11 -11
- package/dist/cli.js +4 -3
- package/dist/config.js +3 -3
- package/dist/init.js +13 -13
- package/dist/mcp.js +1 -1
- package/dist/preview-editor/assets/index-7RzNd7tf.css +1 -0
- package/dist/preview-editor/assets/{index-CqRhiLWo.js → index-C7N5n_qW.js} +124 -102
- package/dist/preview-editor/index.html +2 -2
- package/dist/skills-upgrade.js +1 -1
- package/dist/standalone.js +2 -2
- package/dist/vendored/card-editor/runtime/adapter.js +10 -11
- package/dist/vendored/mcp/client.mjs +50 -13
- package/dist/vendored/mcp/tools.mjs +13 -7
- package/dist/vendored/server/core/ai-chat.js +540 -183
- package/dist/vendored/server/core/assetProxy.js +1 -1
- package/dist/vendored/server/core/browser.js +1 -1
- package/dist/vendored/server/core/cardDigest.js +324 -0
- package/dist/vendored/server/core/cardExport.js +128 -55
- package/dist/vendored/server/core/cardFiles.js +1 -1
- package/dist/vendored/server/core/cardGitCommit.js +190 -0
- package/dist/vendored/server/core/cardHistoryRemote.js +1 -1
- package/dist/vendored/server/core/cardImportMeta.js +1 -1
- package/dist/vendored/server/core/cardListCache.js +92 -10
- package/dist/vendored/server/core/cardPublish.js +47 -8
- package/dist/vendored/server/core/cardPublishVersions.js +302 -5
- package/dist/vendored/server/core/cardSave.js +14 -10
- package/dist/vendored/server/core/cardSidecar.js +3 -3
- package/dist/vendored/server/core/cardSync.js +35 -23
- package/dist/vendored/server/core/cardVersion.js +1 -1
- package/dist/vendored/server/core/index.js +11 -5
- package/dist/vendored/server/core/logger.js +1 -1
- package/dist/vendored/server/core/remoteCard.js +207 -0
- package/dist/vendored/server/core/skillPaths.js +1 -1
- package/dist/vendored/server/core/sliceUpload.js +4 -4
- package/dist/vendored/skills/README.md +13 -13
- package/dist/vendored/skills/card-doctor/SKILL.md +2 -2
- package/dist/vendored/skills/dsl-card-ai/SKILL.md +4 -4
- package/dist/vendored/skills/dsl-card-generator/SKILL.md +2 -2
- package/dist/vendored/skills/dsl-card-generator/references/amount_formatting.md +1 -1
- package/dist/vendored/skills/dsl-card-generator/references/build_protocol.md +54 -0
- package/dist/vendored/skills/dsl-card-generator/references/component_rules.md +2 -2
- package/dist/vendored/skills/dsl-card-generator/references/converge_protocol.md +36 -0
- package/dist/vendored/skills/dsl-card-generator/references/event_patterns.md +1 -1
- package/dist/vendored/skills/dsl-card-generator/references/generation_pitfalls.md +1 -1
- package/dist/vendored/skills/dsl-card-generator/references/image_to_card.md +1 -1
- package/dist/vendored/skills/dsl-card-generator/references/quickref.md +1 -1
- package/dist/vendored/skills/dsl-card-generator/references/recipes.md +4 -4
- package/dist/vendored/skills/dsl-card-generator/references/rules.md +1 -1
- package/dist/vendored/skills/dsl-card-generator/references/slices_convention.md +6 -6
- package/dist/vendored/skills/dsl-card-generator/scripts/inventory_schemas.py +1 -1
- package/dist/vendored/skills/dsl-card-generator/scripts/lib/scaffold.mjs +1 -1
- package/dist/vendored/skills/dsl-card-generator/scripts/lib/slice_dedupe.mjs +2 -2
- package/dist/vendored/skills/dsl-card-generator/vendor/preview/assets/standalone-CeVX_y-M.js +137 -0
- package/dist/vendored/skills/dsl-card-generator/vendor/preview/assets/standalone-DiEiY59H.css +1 -0
- package/dist/vendored/skills/dsl-card-generator/vendor/preview/standalone.html +2 -2
- package/dist/vendored/skills/{finmall-card-sync → platform-card-sync}/SKILL.md +26 -26
- package/dist/vendored/skills/{finmall-card-sync → platform-card-sync}/scripts/api_batch_sync.mjs +564 -124
- package/dist/vendored/skills/{finmall-card-sync → platform-card-sync}/scripts/slice_upload.mjs +80 -22
- package/dist/vendored/skills/{finmall-session-navigator → platform-session-navigator}/SKILL.md +13 -13
- package/dist/vendored/skills/platform-session-navigator/scripts/package-lock.json +42 -0
- package/dist/vendored/skills/{finmall-session-navigator → platform-session-navigator}/scripts/package.json +2 -2
- package/dist/vendored/skills/{finmall-session-navigator/scripts/finmall_login.mjs → platform-session-navigator/scripts/platform_login.mjs} +41 -31
- package/dist/vendored/skills/{finmall-session-navigator → platform-session-navigator}/scripts/session-manager.mjs +17 -17
- package/dist/vendored/skills/shared/README.md +21 -21
- package/dist/vendored/skills/shared/auth-model.md +8 -10
- package/dist/vendored/skills/shared/{finmall-config.mjs → platform-config.mjs} +10 -10
- package/dist/vendored/tools/{finmall-env.mjs → platform-env.mjs} +13 -13
- package/package.json +6 -6
- package/dist/preview-editor/assets/index-C8VLzU18.css +0 -1
- package/dist/vendored/skills/dsl-card-generator/vendor/preview/assets/standalone-BCLshIzC.css +0 -1
- package/dist/vendored/skills/dsl-card-generator/vendor/preview/assets/standalone-pP5kTKiI.js +0 -88
- package/dist/vendored/skills/finmall-session-navigator/scripts/package-lock.json +0 -59
|
@@ -1,26 +1,61 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 远端卡片列表缓存(dev server 进程内单例)。
|
|
3
3
|
*
|
|
4
|
-
* 用途:推送(保存 /
|
|
4
|
+
* 用途:推送(保存 / 预览 / 发布)前确认目标卡片确实存在于远端卡片列表中,
|
|
5
5
|
* 拦截「推到已删除 / pageId 错位的卡片」这类风险。
|
|
6
6
|
*
|
|
7
7
|
* 数据来源:IDC10001 卡片列表(与同步同一份数据)。刷新时机由同步逻辑触发——
|
|
8
8
|
* 全量同步(无 cardCode 过滤)时整体替换;单卡同步时增量合并,避免清空其他卡片。
|
|
9
9
|
* 列表条目字段:cardId(数字型,等于 schema.pageId)、code(英文卡 id)、cardName。
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* app 上下文:列表内容随 appId / workspaceId 而异(同一 baseUrl 下多个应用各有
|
|
12
|
+
* 独立卡片列表)。开发中途切换 .env.cb 的 appId 后,旧 app 的缓存对当前环境
|
|
13
|
+
* 完全无意义——若不失效,存在性闸门会拿旧 app 的列表误判新 app 的卡片
|
|
14
|
+
* 「不在远端列表中」。因此:
|
|
15
|
+
* - refreshCardList 写入时盖 appId 戳;发现 appId 变化即清空旧缓存(无论 full 与否);
|
|
16
|
+
* - checkPushAllowed 带上当前 appId 比对,缓存属于另一 app 时视为「未同步」放行。
|
|
17
|
+
*
|
|
18
|
+
* 单例性:本模块被 server/* 与 skills/platform-card-sync 以相同绝对路径 import,
|
|
12
19
|
* 在同一 dev server 进程内共享同一份内存,故同步写入、推送读取天然一致。
|
|
13
20
|
*/
|
|
14
21
|
|
|
22
|
+
import fs from 'node:fs'
|
|
23
|
+
import path from 'node:path'
|
|
24
|
+
import { pathToFileURL } from 'node:url'
|
|
25
|
+
import { skillsCandidates } from './skillPaths.js'
|
|
26
|
+
|
|
15
27
|
const cardIndex = new Map(); // cardId(String) -> { cardId, code, cardName }
|
|
16
28
|
|
|
29
|
+
/** 缓存当前所属的远端环境(由最近一次 refreshCardList 盖戳)。 */
|
|
30
|
+
const cacheCtx = { appId: null, workspaceId: null };
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 最近一次「全量同步」所属的 appId。存在性闸门只在「当前 appId == 最近全量同步的
|
|
34
|
+
* appId」时才有判离权:增量合并(单卡同步)只会让列表更片面,片面列表永远不能
|
|
35
|
+
* 证明「卡片不在远端」——拿它做存在性判断就是刻舟求剑。
|
|
36
|
+
*/
|
|
37
|
+
let fullSyncedAppId = null;
|
|
38
|
+
|
|
17
39
|
/**
|
|
18
40
|
* 写入/合并卡片列表。
|
|
19
41
|
* @param {Array<{cardId:string|number, code?:string, cardName?:string}>} cards
|
|
20
|
-
* @param {{ full?: boolean }} [opts]
|
|
42
|
+
* @param {{ full?: boolean, appId?: string|number, workspaceId?: string|number }} [opts]
|
|
43
|
+
* full=true 时整体替换(先清空),否则增量合并;
|
|
44
|
+
* appId 与缓存戳不一致(环境切换)时无条件清空——旧 app 的列表条目不可复用;
|
|
45
|
+
* 仅 full=true 才更新 fullSyncedAppId(增量合并不赋予闸门判离权)。
|
|
21
46
|
*/
|
|
22
|
-
export function refreshCardList(cards, { full = false } = {}) {
|
|
23
|
-
|
|
47
|
+
export function refreshCardList(cards, { full = false, appId = null, workspaceId = null } = {}) {
|
|
48
|
+
const ctxChanged =
|
|
49
|
+
appId != null && cacheCtx.appId != null && String(cacheCtx.appId) !== String(appId);
|
|
50
|
+
if (full || ctxChanged) {
|
|
51
|
+
cardIndex.clear();
|
|
52
|
+
if (ctxChanged) fullSyncedAppId = null; // 换了环境,旧的全量结论作废
|
|
53
|
+
}
|
|
54
|
+
if (appId != null) {
|
|
55
|
+
cacheCtx.appId = String(appId);
|
|
56
|
+
cacheCtx.workspaceId = workspaceId == null ? null : String(workspaceId);
|
|
57
|
+
}
|
|
58
|
+
if (full && appId != null) fullSyncedAppId = String(appId);
|
|
24
59
|
for (const c of cards || []) {
|
|
25
60
|
if (c == null || c.cardId == null) continue;
|
|
26
61
|
const id = String(c.cardId);
|
|
@@ -35,17 +70,64 @@ export function hasCardId(cardId) {
|
|
|
35
70
|
|
|
36
71
|
/**
|
|
37
72
|
* 推送前存在性校验:目标卡片是否确实在远端卡片列表中(按 cardId/pageId 查)。
|
|
38
|
-
* - 缓存为空(本次 dev server
|
|
39
|
-
* -
|
|
40
|
-
*
|
|
73
|
+
* - 缓存为空(本次 dev server 尚未同步过):放行,避免误拦截首推。
|
|
74
|
+
* - 当前 appId 从未做过全量同步(或中途切换过环境):缓存片面 / 不可判,放行并标记
|
|
75
|
+
* notFullSynced / staleContext=true(调用方可据此记日志提示)。
|
|
76
|
+
* - 命中:放行。
|
|
77
|
+
* - 未命中(且当前 appId 有全量列表背书):拒绝,reason 给出拦截说明。
|
|
41
78
|
* @param {string|number} pageId
|
|
42
|
-
* @
|
|
79
|
+
* @param {{ appId?: string|number }} [ctx] 当前生效的远端环境(来自 platform-config)
|
|
80
|
+
* @returns {{ allowed: boolean, reason: string, staleContext?: boolean, notFullSynced?: boolean }}
|
|
43
81
|
*/
|
|
44
|
-
export function checkPushAllowed(pageId) {
|
|
82
|
+
export function checkPushAllowed(pageId, { appId = null } = {}) {
|
|
45
83
|
if (cardIndex.size === 0) return { allowed: true, reason: '' };
|
|
84
|
+
if (appId != null && String(appId) !== fullSyncedAppId) {
|
|
85
|
+
const staleContext =
|
|
86
|
+
cacheCtx.appId != null && String(cacheCtx.appId) !== String(appId);
|
|
87
|
+
return {
|
|
88
|
+
allowed: true,
|
|
89
|
+
reason: '',
|
|
90
|
+
staleContext: staleContext || undefined,
|
|
91
|
+
notFullSynced: !staleContext || undefined,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
46
94
|
if (hasCardId(pageId)) return { allowed: true, reason: '' };
|
|
47
95
|
return {
|
|
48
96
|
allowed: false,
|
|
49
97
|
reason: `卡片 pageId=${pageId} 不在远端卡片列表中,疑似已删除或 pageId 错位,请先「远程同步」刷新列表后再推送`,
|
|
50
98
|
};
|
|
51
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 读取当前工程生效的远端环境(appId / workspaceId),供推送闸门做上下文比对。
|
|
103
|
+
* 从项目 skills/shared/platform-config.mjs 动态加载(三态解析,优先项目根下的
|
|
104
|
+
* skills/——其内部按自身位置向上找 .env.cb,读到的正是当前工程生效值)。
|
|
105
|
+
* 进程内按 root 记忆化:配置在 dev server 生命周期内视为不变(改 .env 需重启服务)。
|
|
106
|
+
* @param {string} root 项目根
|
|
107
|
+
* @returns {Promise<{ appId: string|null, workspaceId: string|null }>}
|
|
108
|
+
*/
|
|
109
|
+
const _ctxPromises = new Map();
|
|
110
|
+
export function currentAppContext(root) {
|
|
111
|
+
const key = String(root || '');
|
|
112
|
+
if (!_ctxPromises.has(key)) {
|
|
113
|
+
_ctxPromises.set(
|
|
114
|
+
key,
|
|
115
|
+
(async () => {
|
|
116
|
+
for (const dir of skillsCandidates(root)) {
|
|
117
|
+
const p = path.join(dir, 'shared', 'platform-config.mjs');
|
|
118
|
+
if (!fs.existsSync(p)) continue;
|
|
119
|
+
try {
|
|
120
|
+
const m = await import(pathToFileURL(p).href);
|
|
121
|
+
const c = m.platformConfig || {};
|
|
122
|
+
return {
|
|
123
|
+
appId: c.appId != null ? String(c.appId) : null,
|
|
124
|
+
workspaceId: c.workspaceId != null ? String(c.workspaceId) : null,
|
|
125
|
+
};
|
|
126
|
+
} catch { /* 读下一个候选 */ }
|
|
127
|
+
}
|
|
128
|
+
return { appId: null, workspaceId: null };
|
|
129
|
+
})(),
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return _ctxPromises.get(key);
|
|
133
|
+
}
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import { pathToFileURL } from 'node:url'
|
|
3
|
-
import { assertRemoteSource } from './cardSidecar.js'
|
|
4
|
-
import {
|
|
3
|
+
import { assertRemoteSource, findCardDir } from './cardSidecar.js'
|
|
4
|
+
import { commitCardChanges } from './cardGitCommit.js'
|
|
5
|
+
import { checkPushAllowed, currentAppContext } from './cardListCache.js'
|
|
5
6
|
import { log } from './logger.js'
|
|
6
7
|
import { resolveSkillPathOrProject } from './skillPaths.js'
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* platform-card-sync 的批量同步脚本(发布复用),相对 skills/
|
|
10
11
|
* 与 cardSync.js 同款定位:发布只用到其中的 publishCard。
|
|
11
12
|
*/
|
|
12
|
-
const SYNC_SCRIPT_REL = '
|
|
13
|
+
const SYNC_SCRIPT_REL = 'platform-card-sync/scripts/api_batch_sync.mjs'
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* 顶栏「远端 → 卡片发布」的服务端处理:取远端最大版本号 +1 后发布上线(IDC10004 → IDC10016)。
|
|
16
|
-
* 复用
|
|
17
|
+
* 复用 platform-card-sync 的 publishCard(与「同步」「保存远端」「预览」共用同一后台远端会话)。
|
|
17
18
|
*
|
|
18
19
|
* 安全闸(与 /__preview 一致):
|
|
19
20
|
* - assertRemoteSource:本地自建、无 .import-meta.json 侧车的卡一律禁止发布,
|
|
20
|
-
*
|
|
21
|
+
* 避免把测试数据误发布到远端服务器。
|
|
21
22
|
* - checkPushAllowed:卡片须存在于远端列表缓存(全量同步时刷新);缓存为空(尚未同步)则放行。
|
|
22
23
|
*
|
|
24
|
+
* 发布成功后的收尾:把该卡目录(src/cards/<code>/)的未提交变更提交为一条
|
|
25
|
+
* `chore(cards)` 提交(见 cardGitCommit.js),只落本地、不 push。提交结果随响应
|
|
26
|
+
* 以 commit 字段回传,前端据此提示;提交失败不回滚发布,也不影响接口成功态。
|
|
27
|
+
*
|
|
23
28
|
* @param {{ root: string }} opts
|
|
24
29
|
* @returns {(req: import('http').IncomingMessage, res: import('http').ServerResponse, next: Function) => void}
|
|
25
30
|
*/
|
|
@@ -59,8 +64,13 @@ export function createPublishMiddleware({ root }) {
|
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
// 存在性闸门:发布前确认目标卡片在远端卡片列表缓存中(为空说明尚未同步,放行)。
|
|
67
|
+
// 缓存带 appId 戳:环境切换后旧 app 的缓存自动失效放行,不再误判「不在远端列表」。
|
|
62
68
|
{
|
|
63
|
-
const
|
|
69
|
+
const ctx = await currentAppContext(root)
|
|
70
|
+
const allow = checkPushAllowed(payload.schema.pageId, ctx)
|
|
71
|
+
if (allow.staleContext || allow.notFullSynced) {
|
|
72
|
+
log.warn('远端列表缓存对当前 appId 不可判(环境已切换或未全量同步),存在性闸门放行;建议先「远程同步」刷新当前环境列表', { ...ctx, staleContext: !!allow.staleContext })
|
|
73
|
+
}
|
|
64
74
|
if (!allow.allowed) {
|
|
65
75
|
res.statusCode = 409
|
|
66
76
|
res.setHeader('Content-Type', 'application/json')
|
|
@@ -72,9 +82,38 @@ export function createPublishMiddleware({ root }) {
|
|
|
72
82
|
const { publishCard } = await import(pathToFileURL(skillPath).href)
|
|
73
83
|
const result = await publishCard(payload.schema)
|
|
74
84
|
log.ok('卡片发布完成', { cardId: payload.schema.pageId, nextVersion: result.nextVersion })
|
|
85
|
+
|
|
86
|
+
// 发布成功后的本地快照:该卡目录若有未提交变更,只提交这一个目录(不 push)。
|
|
87
|
+
// 提交的是磁盘现状——编辑器未保存的改动不在其中,故失败/跳过都不影响发布结果。
|
|
88
|
+
// 整段独立 try/catch:工程不是 git 工程、git 未安装、定位目录异常等一律静默降级,
|
|
89
|
+
// 绝不能让附加的本地提交把已经成功的发布改成 500。
|
|
90
|
+
let commit = { committed: false, reason: 'skipped', message: '本地提交环节已跳过' }
|
|
91
|
+
try {
|
|
92
|
+
const cardDir = findCardDir(root, { pageId: payload.schema.pageId })
|
|
93
|
+
const cardCode = cardDir ? path.basename(cardDir) : String(payload.schema.pageId)
|
|
94
|
+
commit = await commitCardChanges({ root, cardDir, cardCode, version: result.nextVersion })
|
|
95
|
+
if (commit.committed) {
|
|
96
|
+
log.ok('发布后已提交卡片本地变更', { cardCode, hash: commit.hash, files: commit.files })
|
|
97
|
+
} else if (commit.reason === 'failed') {
|
|
98
|
+
log.warn('发布后提交卡片本地变更失败', { cardCode, message: commit.message })
|
|
99
|
+
}
|
|
100
|
+
// 其余 reason(not_a_git_repo / git_unavailable / no_changes / card_dir_not_found)
|
|
101
|
+
// 都是正常的「无需提交」,不写日志、不提示用户。
|
|
102
|
+
} catch (e) {
|
|
103
|
+
commit = { committed: false, reason: 'skipped', message: String((e && e.message) || e) }
|
|
104
|
+
log.warn('本地提交环节异常(已忽略,不影响发布)', { message: String((e && e.message) || e) })
|
|
105
|
+
}
|
|
106
|
+
|
|
75
107
|
res.statusCode = 200
|
|
76
108
|
res.setHeader('Content-Type', 'application/json')
|
|
77
|
-
return res.end(
|
|
109
|
+
return res.end(
|
|
110
|
+
JSON.stringify({
|
|
111
|
+
ok: true,
|
|
112
|
+
maxVersion: result.maxVersion,
|
|
113
|
+
nextVersion: result.nextVersion,
|
|
114
|
+
commit,
|
|
115
|
+
}),
|
|
116
|
+
)
|
|
78
117
|
} catch (e) {
|
|
79
118
|
log.error('卡片发布失败', e)
|
|
80
119
|
// 区分「凭据缺失」与「真正的发布错误」:前者让前端弹登录表单,而非裸抛 ENOENT。
|
|
@@ -4,29 +4,54 @@ import { readImportMeta } from './cardImportMeta.js'
|
|
|
4
4
|
import { log } from './logger.js'
|
|
5
5
|
import { resolveSkillPathOrProject } from './skillPaths.js'
|
|
6
6
|
|
|
7
|
-
const SYNC_SCRIPT_REL = '
|
|
7
|
+
const SYNC_SCRIPT_REL = 'platform-card-sync/scripts/api_batch_sync.mjs'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* 调试面板「导入信息」tab
|
|
11
|
-
*
|
|
10
|
+
* 调试面板「导入信息」tab「发布版本记录」弹框的远端数据源:
|
|
11
|
+
* GET /__card-publish-versions/:cardCode?pageNo=&pageSize= → 版本记录分页(IDC10004)
|
|
12
|
+
* POST /__card-publish-versions/:cardCode/stop → 停止发布(IDC20003)
|
|
13
|
+
* POST /__card-publish-versions/:cardCode/publish → 创建发布任务(IDC20004)
|
|
12
14
|
*
|
|
13
15
|
* 语义:经 .import-meta.json 侧车里的 cardId 调 IDC10004,取该卡发布版本记录分页(新→旧),
|
|
14
|
-
* 每条含版本号 / 平台(iOS·Android·HarmonyOS 子集)/ 发布状态 /
|
|
16
|
+
* 每条含版本号 / 平台(iOS·Android·HarmonyOS 子集)/ 发布状态 / 发布时间,
|
|
17
|
+
* 以及该版本仍在进行中的「发布任务」(task,含取消发布所需的 taskId)。
|
|
15
18
|
* 触发时机由前端控制(打开弹框 / 滚动到底懒加载下一页),不自动轮询——与「编辑记录」tab
|
|
16
19
|
* 的懒加载策略一致,避免每次加载卡片都拉起后台 Chrome。
|
|
17
20
|
*
|
|
18
21
|
* 安全闸(与 /__card-history / /__card-version 同源):仅「已同步导入卡」(有
|
|
19
22
|
* .import-meta.json 侧车且含 cardId)可查;本地自建卡 / 未同步卡返回 409 local_card_no_source。
|
|
20
23
|
*
|
|
24
|
+
* 停止发布(IDC20003)作用在「发布任务」而非版本记录上,taskId 与 cardId 之间没有直接约束,
|
|
25
|
+
* 因此这里做两道归属校验再下发:
|
|
26
|
+
* 1) versionId 必须出现在该卡的发布版本记录里(防止拿别人的 versionId 越权);
|
|
27
|
+
* 2) taskId 必须属于该 versionId 的任务列表(防止伪造 taskId 停掉无关任务)。
|
|
28
|
+
* 校验不过一律 404,不把远端错误直接抛给前端。
|
|
29
|
+
*
|
|
21
30
|
* @param {{ root: string }} opts
|
|
22
31
|
* @returns {(req: import('http').IncomingMessage, res: import('http').ServerResponse, next: Function) => void}
|
|
23
32
|
*/
|
|
24
33
|
export function createCardPublishVersionsMiddleware({ root }) {
|
|
25
34
|
return function cardPublishVersionsMiddleware(req, res, next) {
|
|
26
35
|
const pathname = decodeURIComponent((req.url || '').split('?')[0])
|
|
36
|
+
const method = (req.method || 'GET').toUpperCase()
|
|
37
|
+
|
|
38
|
+
// ---- 停止发布:POST /__card-publish-versions/:cardCode/stop ----
|
|
39
|
+
const stopMatch = pathname.match(/^\/__card-publish-versions\/([^/]+)\/stop$/)
|
|
40
|
+
if (stopMatch) {
|
|
41
|
+
if (method !== 'POST') return next()
|
|
42
|
+
return handleStopPublish({ root, cardCode: decodeURIComponent(stopMatch[1]), req, res })
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ---- 创建发布:POST /__card-publish-versions/:cardCode/publish ----
|
|
46
|
+
const publishMatch = pathname.match(/^\/__card-publish-versions\/([^/]+)\/publish$/)
|
|
47
|
+
if (publishMatch) {
|
|
48
|
+
if (method !== 'POST') return next()
|
|
49
|
+
return handlePublishVersion({ root, cardCode: decodeURIComponent(publishMatch[1]), req, res })
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (method !== 'GET') return next()
|
|
27
53
|
const m = pathname.match(/^\/__card-publish-versions\/([^/]+)$/)
|
|
28
54
|
if (!m) return next()
|
|
29
|
-
if ((req.method || 'GET').toUpperCase() !== 'GET') return next()
|
|
30
55
|
|
|
31
56
|
const id = decodeURIComponent(m[1])
|
|
32
57
|
const dir = findCardDir(root, { code: id })
|
|
@@ -89,3 +114,275 @@ export function createCardPublishVersionsMiddleware({ root }) {
|
|
|
89
114
|
})()
|
|
90
115
|
}
|
|
91
116
|
}
|
|
117
|
+
|
|
118
|
+
/** 统一 JSON 响应(与 cardExport / remoteCard 同风格) */
|
|
119
|
+
function sendJson(res, status, obj) {
|
|
120
|
+
res.statusCode = status
|
|
121
|
+
res.setHeader('Content-Type', 'application/json')
|
|
122
|
+
res.setHeader('Cache-Control', 'no-store')
|
|
123
|
+
res.end(JSON.stringify(obj))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** 读 JSON 请求体;上限 64KB(停止发布只传三个 id 字段,无需大 body) */
|
|
127
|
+
function readJsonBody(req, res, cb) {
|
|
128
|
+
let body = ''
|
|
129
|
+
let done = false
|
|
130
|
+
req.setEncoding('utf8')
|
|
131
|
+
req.on('data', (c) => {
|
|
132
|
+
if (done) return
|
|
133
|
+
body += c
|
|
134
|
+
if (body.length > 64 * 1024) {
|
|
135
|
+
done = true
|
|
136
|
+
req.destroy()
|
|
137
|
+
sendJson(res, 413, { ok: false, error: 'body too large', message: '请求体超过 64KB。' })
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
req.on('end', () => {
|
|
141
|
+
if (done) return
|
|
142
|
+
done = true
|
|
143
|
+
let parsed
|
|
144
|
+
try {
|
|
145
|
+
parsed = JSON.parse(body || '{}')
|
|
146
|
+
} catch (e) {
|
|
147
|
+
return sendJson(res, 400, { ok: false, error: 'invalid_json', message: String(e.message) })
|
|
148
|
+
}
|
|
149
|
+
cb(parsed && typeof parsed === 'object' ? parsed : {})
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 停止发布:POST /__card-publish-versions/:cardCode/stop,body { taskId, versionId, version? }
|
|
155
|
+
*
|
|
156
|
+
* 两道归属校验见上方中间件注释。校验通过后调 IDC20003(taskStatus:'0')。
|
|
157
|
+
* 已处于停止状态的任务返回 409(幂等语义上不算错,但对前端是一次无效点击,给明确反馈更好)。
|
|
158
|
+
*/
|
|
159
|
+
function handleStopPublish({ root, cardCode, req, res }) {
|
|
160
|
+
const dir = findCardDir(root, { code: cardCode })
|
|
161
|
+
const meta = dir ? readImportMeta(dir) : null
|
|
162
|
+
if (!meta || !meta.cardId) {
|
|
163
|
+
return sendJson(res, 409, {
|
|
164
|
+
ok: false,
|
|
165
|
+
error: 'local_card_no_source',
|
|
166
|
+
message: '该卡片为本地自建、无远端同步来源(缺少 .import-meta.json 侧车),无法停止远端发布。',
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
readJsonBody(req, res, (body) => {
|
|
171
|
+
const taskId = String(body.taskId == null ? '' : body.taskId).trim()
|
|
172
|
+
const versionId = String(body.versionId == null ? '' : body.versionId).trim()
|
|
173
|
+
const version = String(body.version == null ? '' : body.version).trim()
|
|
174
|
+
if (!/^\d+$/.test(taskId) || !/^\d+$/.test(versionId)) {
|
|
175
|
+
return sendJson(res, 400, {
|
|
176
|
+
ok: false,
|
|
177
|
+
error: 'bad_request',
|
|
178
|
+
message: '停止发布需要数字型 taskId 与 versionId(均来自 IDC20002 的发布任务)。',
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
;(async () => {
|
|
183
|
+
try {
|
|
184
|
+
const skillPath = resolveSkillPathOrProject(root, SYNC_SCRIPT_REL)
|
|
185
|
+
const { fetchCardPublishVersions, fetchCardVersionTasks, updateCardTaskStatus } = await import(
|
|
186
|
+
pathToFileURL(skillPath).href
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
// 校验 1:versionId 必须是该卡发布记录中的一条。
|
|
190
|
+
// 带 version 时按版本号精确筛选(一条即可),否则取前 100 条兜底扫描。
|
|
191
|
+
const page = await fetchCardPublishVersions(meta.cardId, {
|
|
192
|
+
pageNo: 1,
|
|
193
|
+
pageSize: version ? 10 : 100,
|
|
194
|
+
version,
|
|
195
|
+
withTasks: false,
|
|
196
|
+
})
|
|
197
|
+
const row = (page.list || []).find((x) => x.versionId === versionId)
|
|
198
|
+
if (!row) {
|
|
199
|
+
return sendJson(res, 404, {
|
|
200
|
+
ok: false,
|
|
201
|
+
error: 'version_not_found',
|
|
202
|
+
message: `版本记录 ${versionId} 不属于卡片 ${cardCode}(cardId=${meta.cardId}),已拒绝。`,
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// 校验 2:taskId 必须挂在该版本下。
|
|
207
|
+
const tasks = await fetchCardVersionTasks(versionId)
|
|
208
|
+
const target = tasks.find((t) => t.taskId === taskId)
|
|
209
|
+
if (!target) {
|
|
210
|
+
return sendJson(res, 404, {
|
|
211
|
+
ok: false,
|
|
212
|
+
error: 'task_not_found',
|
|
213
|
+
message: `发布任务 ${taskId} 不属于版本 ${row.version},已拒绝。`,
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
if (target.taskStatus === '0') {
|
|
217
|
+
return sendJson(res, 409, {
|
|
218
|
+
ok: false,
|
|
219
|
+
error: 'task_already_stopped',
|
|
220
|
+
message: `版本 ${row.version} 的发布任务已处于停止状态,无需重复操作。`,
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
await updateCardTaskStatus({ taskId, taskStatus: '0' })
|
|
225
|
+
log.ok('停止远端发布任务', {
|
|
226
|
+
cardCode,
|
|
227
|
+
cardId: String(meta.cardId),
|
|
228
|
+
version: row.version,
|
|
229
|
+
versionId,
|
|
230
|
+
taskId,
|
|
231
|
+
})
|
|
232
|
+
sendJson(res, 200, {
|
|
233
|
+
ok: true,
|
|
234
|
+
cardCode,
|
|
235
|
+
cardId: String(meta.cardId),
|
|
236
|
+
version: row.version,
|
|
237
|
+
versionId,
|
|
238
|
+
taskId,
|
|
239
|
+
})
|
|
240
|
+
} catch (e) {
|
|
241
|
+
const raw = String((e && e.message) || '停止发布失败')
|
|
242
|
+
const isNoCred = /credentials\.json|credentials 不存在|NO_CREDENTIALS/.test(raw)
|
|
243
|
+
if (isNoCred) {
|
|
244
|
+
return sendJson(res, 200, {
|
|
245
|
+
ok: false,
|
|
246
|
+
error: 'need_credentials',
|
|
247
|
+
needCredentials: true,
|
|
248
|
+
message: raw,
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
// platformPost 抛出的是「远端交易失败 [errorCode=IMVM0005] 状态修改失败 | {整包 JSON}」,
|
|
252
|
+
// 整包塞进 toast 读不过来:这里只取 errorMsg + code,其余留日志。
|
|
253
|
+
log.error('停止远端发布失败', { cardCode, versionId, taskId, error: raw.slice(0, 300) })
|
|
254
|
+
sendJson(res, 500, {
|
|
255
|
+
ok: false,
|
|
256
|
+
error: 'stop_publish_failed',
|
|
257
|
+
message: platformErrorMessage(raw, '远端拒绝了本次停止操作'),
|
|
258
|
+
})
|
|
259
|
+
}
|
|
260
|
+
})()
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* 创建发布任务:POST /__card-publish-versions/:cardCode/publish,body { versionId, version?, memo? }
|
|
266
|
+
*
|
|
267
|
+
* 对应线上详情页版本行的「创建发布」(tooltip:创建发布)→ 发布任务抽屉 → IDC20004.do。
|
|
268
|
+
* 线上抽屉有「发布类型(正式 / 灰度)」等表单,这里只走正式发布(publishType='2'),
|
|
269
|
+
* 灰度白名单 / 时间窗 / 高级规则等有真实需求再补。
|
|
270
|
+
*
|
|
271
|
+
* 归属校验与停止发布同源:versionId 必须出现在该卡的发布版本记录里(不接受外来 versionId)。
|
|
272
|
+
* 这道闸是必需的——实测 IDC20004 对不存在的 versionId 也返回「交易成功」并真的建出任务,
|
|
273
|
+
* 远端本身不校验归属。
|
|
274
|
+
*
|
|
275
|
+
* 唯一的拒绝条件是「该版本已有进行中的发布任务」(409):同一版本重复下发会生成两条并行的
|
|
276
|
+
* 发布任务,线上页面虽然不拦,但对我们这个批量工具属于误操作,409 比默默任务重复更好排查。
|
|
277
|
+
* 特意**不**拿 publishStatus 当拒绝理由:publishStatus='1' 只表示该版本已上线,与「有没有
|
|
278
|
+
* 任务在跑」无因果关系(实测存在发布中但 versionTaskList 为空的行),拿它拒绝会把
|
|
279
|
+
* 「已上线、无任务」这种正常行堵成死路——那种行既停不了也发不了。线上页面同样只看任务:
|
|
280
|
+
* 版本行的「创建发布」按钮没有任何 disabled 条件。
|
|
281
|
+
*/
|
|
282
|
+
function handlePublishVersion({ root, cardCode, req, res }) {
|
|
283
|
+
const dir = findCardDir(root, { code: cardCode })
|
|
284
|
+
const meta = dir ? readImportMeta(dir) : null
|
|
285
|
+
if (!meta || !meta.cardId) {
|
|
286
|
+
return sendJson(res, 409, {
|
|
287
|
+
ok: false,
|
|
288
|
+
error: 'local_card_no_source',
|
|
289
|
+
message: '该卡片为本地自建、无远端同步来源(缺少 .import-meta.json 侧车),无法创建远端发布。',
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
readJsonBody(req, res, (body) => {
|
|
294
|
+
const versionId = String(body.versionId == null ? '' : body.versionId).trim()
|
|
295
|
+
const version = String(body.version == null ? '' : body.version).trim()
|
|
296
|
+
const memo = String(body.memo == null ? '' : body.memo).trim().slice(0, 200)
|
|
297
|
+
if (!/^\d+$/.test(versionId)) {
|
|
298
|
+
return sendJson(res, 400, {
|
|
299
|
+
ok: false,
|
|
300
|
+
error: 'bad_request',
|
|
301
|
+
message: '创建发布需要数字型 versionId(来自 IDC10004 的版本记录)。',
|
|
302
|
+
})
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
;(async () => {
|
|
306
|
+
try {
|
|
307
|
+
const skillPath = resolveSkillPathOrProject(root, SYNC_SCRIPT_REL)
|
|
308
|
+
const { fetchCardPublishVersions, createCardPublishTask } = await import(
|
|
309
|
+
pathToFileURL(skillPath).href
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
// 归属校验 + 顺便拿到该行是否已有进行中的任务(带 version 时只查这一条,代价很小)。
|
|
313
|
+
// withTasks 恒开:409 判定依赖真实任务列表,不能因调用方没传 version 就跳过查询。
|
|
314
|
+
const page = await fetchCardPublishVersions(meta.cardId, {
|
|
315
|
+
pageNo: 1,
|
|
316
|
+
pageSize: version ? 10 : 100,
|
|
317
|
+
version,
|
|
318
|
+
withTasks: true,
|
|
319
|
+
})
|
|
320
|
+
const row = (page.list || []).find((x) => x.versionId === versionId)
|
|
321
|
+
if (!row) {
|
|
322
|
+
return sendJson(res, 404, {
|
|
323
|
+
ok: false,
|
|
324
|
+
error: 'version_not_found',
|
|
325
|
+
message: `版本记录 ${versionId} 不属于卡片 ${cardCode}(cardId=${meta.cardId}),已拒绝。`,
|
|
326
|
+
})
|
|
327
|
+
}
|
|
328
|
+
if (row.task && row.task.taskStatus !== '0') {
|
|
329
|
+
return sendJson(res, 409, {
|
|
330
|
+
ok: false,
|
|
331
|
+
error: 'task_already_running',
|
|
332
|
+
message: `版本 ${row.version} 已有进行中的发布任务,如需重新发布请先停止。`,
|
|
333
|
+
})
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
await createCardPublishTask({
|
|
337
|
+
cardId: meta.cardId,
|
|
338
|
+
versionId,
|
|
339
|
+
version: row.version,
|
|
340
|
+
memo,
|
|
341
|
+
})
|
|
342
|
+
log.ok('创建远端发布任务', {
|
|
343
|
+
cardCode,
|
|
344
|
+
cardId: String(meta.cardId),
|
|
345
|
+
version: row.version,
|
|
346
|
+
versionId,
|
|
347
|
+
})
|
|
348
|
+
sendJson(res, 200, {
|
|
349
|
+
ok: true,
|
|
350
|
+
cardCode,
|
|
351
|
+
cardId: String(meta.cardId),
|
|
352
|
+
version: row.version,
|
|
353
|
+
versionId,
|
|
354
|
+
publishType: '2',
|
|
355
|
+
})
|
|
356
|
+
} catch (e) {
|
|
357
|
+
const raw = String((e && e.message) || '创建发布失败')
|
|
358
|
+
const isNoCred = /credentials\.json|credentials 不存在|NO_CREDENTIALS/.test(raw)
|
|
359
|
+
if (isNoCred) {
|
|
360
|
+
return sendJson(res, 200, {
|
|
361
|
+
ok: false,
|
|
362
|
+
error: 'need_credentials',
|
|
363
|
+
needCredentials: true,
|
|
364
|
+
message: raw,
|
|
365
|
+
})
|
|
366
|
+
}
|
|
367
|
+
log.error('创建远端发布失败', { cardCode, versionId, error: raw.slice(0, 300) })
|
|
368
|
+
sendJson(res, 500, {
|
|
369
|
+
ok: false,
|
|
370
|
+
error: 'publish_failed',
|
|
371
|
+
message: platformErrorMessage(raw, '远端拒绝了本次发布'),
|
|
372
|
+
})
|
|
373
|
+
}
|
|
374
|
+
})()
|
|
375
|
+
})
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* 把 platformPost 抛出的原始错误压成一句可读文案。
|
|
380
|
+
* 原始形态:「远端交易失败 [errorCode=IMVM0005] 状态修改失败 | {整包 JSON}」——
|
|
381
|
+
* 整包 JSON 塞进 toast 读不过来,只取 errorMsg + code,其余由调用方写日志。
|
|
382
|
+
*/
|
|
383
|
+
function platformErrorMessage(raw, fallback) {
|
|
384
|
+
const m = String(raw || '').match(/远端交易失败 \[errorCode=([^\]]+)\]\s*([^|]*)/)
|
|
385
|
+
if (!m) return raw
|
|
386
|
+
return `${(m[2] || '').trim() || fallback}(${m[1]})`
|
|
387
|
+
}
|
|
388
|
+
|
|
@@ -5,15 +5,15 @@ import { fileURLToPath } from 'node:url'
|
|
|
5
5
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
6
6
|
|
|
7
7
|
import { recordExport, markDirty } from './cardImportMeta.js'
|
|
8
|
-
import { checkPushAllowed } from './cardListCache.js'
|
|
8
|
+
import { checkPushAllowed, currentAppContext } from './cardListCache.js'
|
|
9
9
|
import { assertRemoteSource, findCardDir } from './cardSidecar.js'
|
|
10
10
|
import { log } from './logger.js'
|
|
11
11
|
import { resolveSkillPathOrProject } from './skillPaths.js'
|
|
12
12
|
import { generateCardCover } from './screenshot.js'
|
|
13
13
|
import { serialize } from './browser.js'
|
|
14
14
|
|
|
15
|
-
/** 远端保存脚本相对 skills/ 的路径(与「同步」共用
|
|
16
|
-
const SYNC_SCRIPT_REL = '
|
|
15
|
+
/** 远端保存脚本相对 skills/ 的路径(与「同步」共用 platform-card-sync) */
|
|
16
|
+
const SYNC_SCRIPT_REL = 'platform-card-sync/scripts/api_batch_sync.mjs'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* 推送成功后「截图 + 上传为远端预览图」的整段预算。
|
|
@@ -47,7 +47,7 @@ function withDeadline(promise, ms, label) {
|
|
|
47
47
|
*
|
|
48
48
|
* 为什么放在服务端而不是前端:①截图走本地无头渲染(screenshot.js 单例 Chrome),
|
|
49
49
|
* 与「预览图」按钮同一条链路,产出透明底、与卡片实际渲染尺寸 1:1 的 PNG;
|
|
50
|
-
*
|
|
50
|
+
* ②上传必须带远端 token,只有已登录的后台会话拿得到,前端不接触凭据。
|
|
51
51
|
*
|
|
52
52
|
* 三条纪律:
|
|
53
53
|
* - **best-effort**:任何失败都返回结构化结果,绝不向上抛——预览图是推送的附加产物,
|
|
@@ -108,14 +108,14 @@ export async function uploadPreviewAfterPush({
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
111
|
+
* 远端保存(写回远端)服务端处理。
|
|
112
112
|
* 前端「保存」按钮把当前预览的 schema(含实时数据绑定)POST 过来,
|
|
113
113
|
* 本中间件校验 pageId 后,经已登录浏览器中转调用 IDC10010.do 写回远端,
|
|
114
|
-
* 与「同步」共用
|
|
114
|
+
* 与「同步」共用 platform-card-sync 的 saveCardToRemote(带会话自愈)。
|
|
115
115
|
*
|
|
116
116
|
* @param {{ root: string, previewAfterPush?: typeof uploadPreviewAfterPush }} opts
|
|
117
117
|
* - previewAfterPush:推送成功后的「截图 + 上传预览图」实现,默认即上面的
|
|
118
|
-
* uploadPreviewAfterPush;单测注入替身以便在无 Chrome /
|
|
118
|
+
* uploadPreviewAfterPush;单测注入替身以便在无 Chrome / 无远端会话的环境断言接线。
|
|
119
119
|
*/
|
|
120
120
|
export function createSaveMiddleware({ root, previewAfterPush = uploadPreviewAfterPush }) {
|
|
121
121
|
return async function saveMiddleware(req, res, next) {
|
|
@@ -150,7 +150,7 @@ export function createSaveMiddleware({ root, previewAfterPush = uploadPreviewAft
|
|
|
150
150
|
return res.end(JSON.stringify({ ok: false, error: 'schema.pageId 缺失,无法确定要保存的卡片' }))
|
|
151
151
|
}
|
|
152
152
|
// 远端来源硬闸:本地自建、无 .import-meta.json 侧车的卡一律禁止推送,
|
|
153
|
-
//
|
|
153
|
+
// 避免把测试数据误提交到远端服务器(比「是否在远端列表」更根本)。
|
|
154
154
|
{
|
|
155
155
|
const src = assertRemoteSource(root, { code, pageId: schema.pageId })
|
|
156
156
|
if (!src.ok) {
|
|
@@ -183,9 +183,13 @@ export function createSaveMiddleware({ root, previewAfterPush = uploadPreviewAft
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
// 存在性闸门:推送前确认目标卡片在远端卡片列表缓存中(全量同步时刷新)。
|
|
186
|
-
//
|
|
186
|
+
// 缓存非空才校验(为空说明尚未同步,放行);缓存属于其他 appId(环境切换)也放行。
|
|
187
187
|
{
|
|
188
|
-
const
|
|
188
|
+
const ctx = await currentAppContext(root)
|
|
189
|
+
const allow = checkPushAllowed(schema.pageId, ctx)
|
|
190
|
+
if (allow.staleContext || allow.notFullSynced) {
|
|
191
|
+
log.warn('远端列表缓存对当前 appId 不可判(环境已切换或未全量同步),存在性闸门放行;建议先「远程同步」刷新当前环境列表', { ...ctx, staleContext: !!allow.staleContext })
|
|
192
|
+
}
|
|
189
193
|
if (!allow.allowed) {
|
|
190
194
|
res.statusCode = 409
|
|
191
195
|
res.setHeader('Content-Type', 'application/json')
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* 卡片「远端来源侧车」判定。
|
|
3
3
|
*
|
|
4
4
|
* 本地卡片目录 src/cards/<code>/ 下的 .import-meta.json 由「远程同步」写入,
|
|
5
|
-
*
|
|
5
|
+
* 记录该卡来自远端的 cardId 等来源信息。只有存在侧车的卡才被视为
|
|
6
6
|
* 「有合法远端来源」,允许推送(保存 / 预览)到服务器;本地自建、从未同步过的
|
|
7
|
-
*
|
|
7
|
+
* 测试卡没有侧车,一律禁止推送,避免把测试数据误提交到远端。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import fs from 'node:fs'
|
|
@@ -66,7 +66,7 @@ export function assertRemoteSource(root, { code, pageId } = {}) {
|
|
|
66
66
|
ok: false,
|
|
67
67
|
reason:
|
|
68
68
|
'该卡片为本地自建、无远端同步来源(缺少 .import-meta.json 侧车)。' +
|
|
69
|
-
'
|
|
69
|
+
'为防止将测试数据误提交到远端服务器,已禁止保存 / 推送。' +
|
|
70
70
|
'请先通过「远程同步」把卡片来源刷新到本地后再操作。',
|
|
71
71
|
}
|
|
72
72
|
}
|