一、问题(本轮实测)
`draw-ui` 与 `oil-motion` 目录里**各自带一个内嵌 `.git`** ⇒ 上一次提交把它们记成了 **gitlink(子模块指针)**
⇒ 仓库里只存了一个不属于任何远端的 commit id,**别人克隆下来这两份是空的** ✗(`git status` 显示 ` m draw-ui` / ` m oil-motion` = 子模块内容有改动)。
二、处置(可回退)
· 把两处的 `.git` **挪走**(⛔ 不是删除)⇒ `归档/内嵌git-20261008/{draw-ui,oil-motion}.git`;
· `git rm --cached` 掉那两个 gitlink,再 `git add` 两个目录 ⇒ **按正常文件入库**(内容才真的进仓库)。
三、副作用(如实记)
挪走 `.git` 后,这两个技能**不能再原地 `git pull` 取上游更新**(要更新得重新拉一份覆盖);
如需恢复其本地仓库,把 `归档/内嵌git-20261008/` 里的 `.git` 挪回原处即可。
31 lines
2.0 KiB
TypeScript
31 lines
2.0 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { test } from 'node:test';
|
|
import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
import { tmpdir } from 'node:os';
|
|
import path from 'node:path';
|
|
import { execFile } from 'node:child_process';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { loadPage } from '../src/page.ts';
|
|
|
|
test('页面配置真实 CLI:相对路径、独立字段文案、更新与只读预览', async t => {
|
|
const dir = await mkdtemp(path.join(tmpdir(), 'credential-page-')); t.after(() => rm(dir, { recursive: true, force: true }));
|
|
const files = ['one', 'two'].map(name => path.join(dir, name + '.json'));
|
|
for (const [index, file] of files.entries()) await writeFile(file, JSON.stringify({ version: 1, id: 'sample-skill', label: '服务' + index,
|
|
credential: 'sample/' + index, ui: { placeholder: '请输入测试凭据' + index } }));
|
|
const page = path.join(dir, 'page.json');
|
|
const script = fileURLToPath(new URL('../src/cli.ts', import.meta.url));
|
|
const run = (args: string[]) => new Promise<number>(resolve => execFile(process.execPath,
|
|
[script, 'configure-page', '--page', page, ...args], error => resolve(error ? 1 : 0)));
|
|
const args = ['--manifest', files[0], '--manifest', files[1], '--title', '两项凭据'];
|
|
assert.equal(await run(args), 0);
|
|
assert.deepEqual(JSON.parse(await readFile(page, 'utf8')).manifests, ['one.json', 'two.json']);
|
|
const loaded = await loadPage(page); assert.equal(loaded.manifests.length, 2); assert.equal(loaded.ui.title, '两项凭据');
|
|
assert.equal(loaded.manifests[1].ui?.placeholder, '请输入测试凭据1');
|
|
assert.equal(await run(['--label', '业务配置']), 0);
|
|
const before = await readFile(page, 'utf8');
|
|
assert.equal(await run(['--title', '只读预览', '--dry-run']), 0); assert.equal(await readFile(page, 'utf8'), before);
|
|
assert.notEqual(await run(['--manifest', files[0], '--manifest', files[0]]), 0);
|
|
assert.notEqual(await run(['--api-key', 'FAKE_ONLY']), 0);
|
|
assert.equal(await readFile(page, 'utf8'), before);
|
|
});
|