dsh-git-push 2.18.2 → 2.20.17
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/.gitignore +4 -0
- package/README.md +12 -5
- package/cli-audit.mjs +141 -0
- package/cli-tool.mjs +86 -0
- package/cli.mjs +116 -324
- package/lib/ARCHITECTURE.md +3 -0
- package/lib/app/audit-api.js +1 -1
- package/lib/app/command-registry.js +16 -3
- package/lib/app/constants.js +9 -0
- package/lib/app/handlers/clone.js +12 -3
- package/lib/app/handlers/http-constants.js +11 -2
- package/lib/app/handlers/npm.js +4 -2
- package/lib/app/handlers/repos.js +10 -1
- package/lib/app/handlers/settings.js +9 -1
- package/lib/app/http-handlers.js +24 -3
- package/lib/app/inject-text.js +1 -0
- package/lib/app/schema-audit.js +42 -0
- package/lib/app/schema.js +19 -19
- package/lib/app/scope-check.js +69 -0
- package/lib/app/settings-bridge.js +51 -0
- package/lib/app/tool-call.js +56 -7
- package/lib/ast/credential.js +130 -14
- package/lib/ast/dataflow.js +127 -10
- package/lib/ast/index.js +2 -0
- package/lib/ast/naming.js +9 -1
- package/lib/ast/scope-collisions.js +228 -0
- package/lib/ast/treesitter.js +142 -1
- package/lib/audit/history.js +1 -1
- package/lib/audit/orchestrate.js +93 -6
- package/lib/audit/scope-policy.js +110 -0
- package/lib/audit-rules/audit-rules-dsh.yml +16 -1
- package/lib/audit-rules/audit-rules-nodejs.yml +21 -6
- package/lib/audit-rules/audit-rules-paths.yml +7 -1
- package/lib/audit-ui-sdk/contract.js +117 -0
- package/lib/audit-ui-sdk/index.js +17 -0
- package/lib/checks/common.js +4 -4
- package/lib/checks/dispatch.js +5 -0
- package/lib/checks/index.js +2 -0
- package/lib/checks/regex.js +8 -3
- package/lib/checks/scope-collision.js +68 -0
- package/lib/cli/commands-audit.mjs +13 -18
- package/lib/cli/commands-tool.mjs +93 -0
- package/lib/cli/commands-vcs.mjs +2 -1
- package/lib/cli/shared.mjs +448 -0
- package/lib/client-parts/{account.js → git/account.js} +1 -1
- package/lib/client-parts/{actions.js → git/actions.js} +26 -11
- package/lib/client-parts/{apply.js → git/apply.js} +1 -1
- package/lib/client-parts/{browser.js → git/browser.js} +1 -1
- package/lib/client-parts/{const.js → git/const.js} +6 -1
- package/lib/client-parts/{controller.js → git/controller.js} +23 -11
- package/lib/client-parts/{icons.js → git/icons.js} +1 -1
- package/lib/client-parts/{loader.js → git/loader.js} +1 -1
- package/lib/client-parts/{npm.js → git/npm.js} +1 -1
- package/lib/client-parts/{page.js → git/page.js} +11 -21
- package/lib/client-parts/{repo.js → git/repo.js} +1 -1
- package/lib/client-parts/{settings.js → git/settings.js} +1 -1
- package/lib/client-parts/{utils.js → git/utils.js} +1 -1
- package/lib/client.js +75 -354
- package/lib/commit-push/pre-commit-engine.js +388 -0
- package/lib/commit-push.js +44 -17
- package/lib/exempt/index.js +5 -2
- package/lib/git/ignore.js +6 -4
- package/lib/git/init-compat.js +83 -4
- package/lib/git/push.js +25 -2
- package/lib/git/sensitive.js +30 -1
- package/lib/git/transport.js +31 -10
- package/lib/http/index.js +82 -10
- package/lib/lint-adapter/detect.js +161 -0
- package/lib/lint-adapter/index.js +50 -0
- package/lib/lint-adapter/runner.js +133 -0
- package/lib/npm/npmrc.js +22 -5
- package/lib/rule/compilers/structure.js +24 -0
- package/lib/score/index.js +36 -4
- package/lib/self/index.js +1 -1
- package/package.json +25 -2
- package/scripts/audit-gate.mjs +235 -0
- package/scripts/build-client.mjs +15 -8
- package/scripts/bump-version.mjs +20 -5
- package/scripts/check-js-scope.mjs +87 -0
- package/scripts/check.mjs +51 -4
- package/scripts/scan-file-io.mjs +5 -1
- package/scripts/scan-version.mjs +10 -7
- package/skills/dev/dsh-git-push.md +70 -2
- package/skills/guide/guide-audit.md +11 -11
- package/skills/guide/guide-cli-scripts.md +3 -3
- package/skills/guide/guide-commit-push.md +2 -2
- package/skills/guide/guide-inject-ui.md +0 -16
- package/assets/start.sh +0 -396
- package/scripts/scan-hardcoded-paths.mjs +0 -125
- /package/lib/client-parts/{audit.js → audit/audit.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ─── 第
|
|
1
|
+
/* ─── 第 11/13 片 · Controller(状态机 + 数据加载 + 动作注入) ─────────────────── */
|
|
2
2
|
class dshgp_Controller {
|
|
3
3
|
constructor(scope) {
|
|
4
4
|
this.scope = scope;
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
if (this.repoBusy) return; // 已有交互在进行(含本页面自己发起的 clone),不抢
|
|
290
290
|
let st;
|
|
291
291
|
try {
|
|
292
|
-
st = await
|
|
292
|
+
st = await dshgp_getJson('/api/git-push/clone-progress');
|
|
293
293
|
} catch { return; /* 探测失败静默:下次刷新再试 */ }
|
|
294
294
|
if (!st || st.state !== 'running' || !st.progress) return;
|
|
295
295
|
const p = st.progress;
|
|
@@ -301,14 +301,14 @@
|
|
|
301
301
|
if (this._cloneResumeTimer) clearInterval(this._cloneResumeTimer);
|
|
302
302
|
this._cloneResumeTimer = setInterval(async () => {
|
|
303
303
|
try {
|
|
304
|
-
const s2 = await
|
|
304
|
+
const s2 = await dshgp_getJson('/api/git-push/clone-progress');
|
|
305
305
|
if (s2 && s2.state === 'running' && s2.progress) {
|
|
306
306
|
this.cloneProgress = s2.progress;
|
|
307
307
|
this.publish();
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
310
|
if (s2 && s2.state === 'done') {
|
|
311
|
-
const fin = await
|
|
311
|
+
const fin = await dshgp_getJson('/api/git-push/clone-progress?consume=1');
|
|
312
312
|
const res = (fin && fin.result) || (s2 && s2.result) || null;
|
|
313
313
|
this.cloudMsg = res && res.ok
|
|
314
314
|
? '✅ 已克隆 ' + (p.target || '') + ' → ' + (res.dest || p.dest || '')
|
|
@@ -713,15 +713,18 @@
|
|
|
713
713
|
this.localMsg = '⏳ 扫描中…(后台独立进程,扫到一个追加一个)';
|
|
714
714
|
this.publish();
|
|
715
715
|
let seen = this.localRepos.length;
|
|
716
|
+
let scanFinished = false; // 是否**真的收到**结束事件(轮次耗尽不算)
|
|
716
717
|
try {
|
|
717
718
|
const started = await dshgp_postJson('/api/git-push/repos-local-scan', { path: p });
|
|
718
719
|
if (started && started.running && started.ok === false) {
|
|
719
720
|
this.localMsg = '⚠️ ' + (started.error || '扫描进行中,不能重复扫描');
|
|
720
721
|
return;
|
|
721
722
|
}
|
|
722
|
-
// 循环等待新增:每次 wait
|
|
723
|
+
// 循环等待新增:每次 wait 挂起直到独立进程写了新进度(非轮询)。
|
|
724
|
+
// 单请求超时显式给 dshgp_SCAN_WAIT_FETCH_MS(> 服务端挂起上限、≤ 默认超时),
|
|
725
|
+
// 否则服务端还在挂起、前端先 abort,长轮询就成了假失败。
|
|
723
726
|
for (let i = 0; i < dshgp_SCAN_WAIT_MAX_ROUNDS; i += 1) {
|
|
724
|
-
const waitRes = await dshgp_postJson('/api/git-push/repos-local-scan-wait', { from: seen });
|
|
727
|
+
const waitRes = await dshgp_postJson('/api/git-push/repos-local-scan-wait', { from: seen }, dshgp_SCAN_WAIT_FETCH_MS);
|
|
725
728
|
const newest = (waitRes && waitRes.newest) || [];
|
|
726
729
|
if (newest.length) {
|
|
727
730
|
// 只追加新增:从索引取这几条详情(不全量重读列表)
|
|
@@ -730,16 +733,25 @@
|
|
|
730
733
|
this.localMsg = '⏳ 扫描中… 已发现 ' + seen + ' 个仓库';
|
|
731
734
|
this.publish();
|
|
732
735
|
}
|
|
733
|
-
|
|
734
|
-
if (
|
|
736
|
+
// 推进只由「结束」这件事驱动:done 事件,或独立进程已退出(running=false)
|
|
737
|
+
if (waitRes && waitRes.done) { scanFinished = true; break; }
|
|
738
|
+
if (!waitRes || waitRes.running === false) { scanFinished = true; break; }
|
|
739
|
+
// waitRes.timeout && running → 服务端到点返回,属于正常「还没结束」,继续下一轮
|
|
735
740
|
}
|
|
736
741
|
} catch (e) {
|
|
737
742
|
this.localMsg = '❌ 扫描失败: ' + (e && e.message || e);
|
|
743
|
+
this.localScanning = false;
|
|
744
|
+
this.publish();
|
|
745
|
+
return;
|
|
738
746
|
}
|
|
739
747
|
this.localScanning = false;
|
|
740
748
|
// 收尾:按索引读一次对齐(保证领先/落后等字段完整)
|
|
741
749
|
await this.scanLocalRepos(p, false);
|
|
742
|
-
|
|
750
|
+
// **轮次耗尽 != 扫描完成**:只等到循环上限却没收到 done/退出事件,必须如实报「未结束」
|
|
751
|
+
// 而不是报「✅ 完成」(那是把超时当成功,等于把「事件永远不来」这个 bug 藏起来)。
|
|
752
|
+
this.localMsg = scanFinished
|
|
753
|
+
? '✅ 扫描完成,读取到 ' + this.localRepos.length + ' 个仓库'
|
|
754
|
+
: '⚠️ 扫描未收到结束事件(已等 ' + dshgp_SCAN_WAIT_MAX_ROUNDS + ' 轮),进度见 scan-live.json;可稍后刷新查看';
|
|
743
755
|
this.publish();
|
|
744
756
|
}
|
|
745
757
|
|
|
@@ -1006,13 +1018,13 @@
|
|
|
1006
1018
|
// consume=true 让后端取走终态,避免下次打开面板读到上次结果。
|
|
1007
1019
|
const poll = async () => {
|
|
1008
1020
|
try {
|
|
1009
|
-
const st = await
|
|
1021
|
+
const st = await dshgp_getJson('/api/git-push/clone-progress');
|
|
1010
1022
|
if (st && st.state === 'running' && st.progress) {
|
|
1011
1023
|
this.cloneProgress = st.progress;
|
|
1012
1024
|
this.publish();
|
|
1013
1025
|
} else if (st && st.state === 'done') {
|
|
1014
1026
|
// 任务已结束:先取终态再 consume 清掉(顺序反了会读到空)
|
|
1015
|
-
const fin = await
|
|
1027
|
+
const fin = await dshgp_getJson('/api/git-push/clone-progress?consume=1');
|
|
1016
1028
|
stopPoll();
|
|
1017
1029
|
renderResult(fin && fin.result ? fin.result : (st.result || null));
|
|
1018
1030
|
this.cloneProgress = null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ─── 第 4/
|
|
1
|
+
/* ─── 第 4/13 片 · 图标区(ghIcon/refreshIcon) ─────────────────── */
|
|
2
2
|
/* ═══════════════════ 选项卡一:账号信息(美化版:渐变卡片 + GitHub 图标 + 状态徽标) ═══════════════════ */
|
|
3
3
|
const dshgp_ghIcon = jsx.jsx('svg', {
|
|
4
4
|
width: '22', height: '22', viewBox: '0 0 24 24', fill: 'none',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dsh-git-push v2 设置侧边栏(settings.section 独立页)
|
|
3
|
-
* 分片顺序锚点:第 1/
|
|
3
|
+
* 分片顺序锚点:第 1/13 片(顺序唯一权威 = scripts/build-client.mjs 的 PART_ORDER)
|
|
4
4
|
* ============================================================================
|
|
5
5
|
* 重写(三选项卡版):
|
|
6
6
|
* - 纯中文:删 zh/en 键值对字典,用户可见文案直接硬编码中文(产品设计)。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// dsh-skip-func-length: NPM 子页为自包含组件(自有 useState/useEffect,不依赖 controller),拆分会改动 hook 顺序与状态归属,风险高于收益
|
|
2
|
-
/* ─── 第 8/
|
|
2
|
+
/* ─── 第 8/13 片 · NPM 面板(账号卡 + 装包表单 + 已装列表 + npm 凭据字段) ───────────────────
|
|
3
3
|
* 设计取舍:完全自包含(自己 useState/useEffect + 直接走 HTTP),不碰 40-controller(884 行)与 41-actions,
|
|
4
4
|
* 把 Step 4 的改动面压到最小;数据源:/npm-account、/npm-packages、/npm-install、/settings-set、/status。
|
|
5
5
|
* 安全默认与后端一致:`ignore-scripts` 默认勾选(不执行 postinstall)、默认非全局、**安装需二次确认**。
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/* ─── 第
|
|
1
|
+
/* ─── 第 10/13 片 · 页面装配(GitPushPage:两选项卡聚合;审计 Tab 已移出构建) ─── */
|
|
2
2
|
function dshgp_GitPushPage(props) {
|
|
3
3
|
dshgp_ensureCss();
|
|
4
4
|
const [tab, setTab] = react.useState('account');
|
|
5
|
+
// 两选项卡:审计 Tab 随审计侧解耦一起移出构建(分片在 lib/client-parts/audit/,
|
|
6
|
+
// 不进产物 ⇒ UI 上不出现)。后端审计能力不受影响,提交门禁照常。
|
|
5
7
|
const tabs = [
|
|
6
8
|
{ id: 'account', label: '账号信息' },
|
|
7
|
-
{ id: 'audit', label: '审计' },
|
|
8
9
|
{ id: 'settings', label: '设置' },
|
|
9
10
|
];
|
|
10
11
|
const tabBar = jsx.jsxs('div', {
|
|
@@ -23,27 +24,16 @@
|
|
|
23
24
|
// pushLocalRepo/cloneFlow),只传 state+refreshAccount 会导致卡片按钮 onClick 报
|
|
24
25
|
// 「props.xxx is not a function」——整包传 props(state + 全部注入动作)。
|
|
25
26
|
const panel = tab === 'account' ? jsx.jsx(dshgp_AccountTab, props)
|
|
26
|
-
:
|
|
27
|
+
: jsx.jsx(dshgp_SettingsTab, {
|
|
27
28
|
state: props.state,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
edit: props.edit,
|
|
30
|
+
editSsh: props.editSsh,
|
|
31
|
+
editEmail: props.editEmail,
|
|
32
|
+
save: props.save,
|
|
33
|
+
discard: props.discard,
|
|
34
|
+
genKey: props.genKey,
|
|
33
35
|
setAdvanced: props.setAdvanced,
|
|
34
|
-
|
|
35
|
-
toggleDisabled: props.toggleDisabled,
|
|
36
|
-
})
|
|
37
|
-
: jsx.jsx(dshgp_SettingsTab, {
|
|
38
|
-
state: props.state,
|
|
39
|
-
edit: props.edit,
|
|
40
|
-
editSsh: props.editSsh,
|
|
41
|
-
editEmail: props.editEmail,
|
|
42
|
-
save: props.save,
|
|
43
|
-
discard: props.discard,
|
|
44
|
-
genKey: props.genKey,
|
|
45
|
-
setAdvanced: props.setAdvanced,
|
|
46
|
-
});
|
|
36
|
+
});
|
|
47
37
|
return jsx.jsxs('div', {
|
|
48
38
|
style: { padding: '0 4px' },
|
|
49
39
|
children: [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ─── 第 7/
|
|
1
|
+
/* ─── 第 7/13 片 · 仓库管理卡(RepoManagerCard/RepoLocalPane/RepoCloudPane) ─────────────────── */
|
|
2
2
|
function dshgp_RepoManagerCard(props) {
|
|
3
3
|
const s = props.state;
|
|
4
4
|
const [view, setView] = react.useState('local');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ─── 第 3/
|
|
1
|
+
/* ─── 第 3/13 片 · 工具区(ensureCss/getJson/postJson/tokenConfigured/copyText) ─────────────────── */
|
|
2
2
|
function dshgp_ensureCss() {
|
|
3
3
|
if (typeof document === 'undefined') return;
|
|
4
4
|
if (document.querySelector('style[data-plugin-css="dsh-git-push"]')) return;
|