fix(README): 安裝指令補上 git+ 前綴,否則 npm 會把它當壓縮檔
npm 只有看到 git/git+ssh/git+http/git+https/git+file 才會當成 git repo。 寫成 https://….git 會被歸類成遠端 tarball,下載回來解壓失敗,錯誤是 TAR_BAD_ARCHIVE: Unrecognized archive format——看起來完全不像「網址寫法錯了」, 使用者只會以為套件壞了。 先前那條「README 指令逐字執行得動」的測試沒抓到,因為它只跑 tea-sdlc 開頭的 行,npm 那行從來沒被執行過。補一條規則把 .git 網址必須帶 git+ 前綴釘住: 真的去跑一次 npm 全域安裝要開網路、要三秒,不適合放進這套向來密封的測試裡, 但「前綴在不在」這條規則本身就足以擋掉這個錯。 議題 #25 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,15 +27,24 @@ test('安裝以 npm 為唯一建議路徑,指令含完整可複製的 git URL'
|
||||
|
||||
assert.equal(install.length > 0, true, 'README 沒有 npm 安裝指令');
|
||||
assert.ok(
|
||||
install.some((line) => line.includes('https://gitea.jsc.idv.tw/plugins/tea-sdlc.git')),
|
||||
install.some((line) => line.includes('gitea.jsc.idv.tw/plugins/tea-sdlc.git')),
|
||||
`安裝指令少了完整 git URL:${install.join(' / ')}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('指向 .git 的安裝指令一律帶 git+ 前綴,否則 npm 會把它當壓縮檔去解', () => {
|
||||
// npm 只有看到 git/git+ssh/git+http/git+https/git+file 才會當成 git repo;
|
||||
// 純 https://….git 會被歸類成遠端 tarball,下載回來解壓失敗,錯誤訊息是
|
||||
// TAR_BAD_ARCHIVE: Unrecognized archive format——看起來完全不像「網址寫法錯了」。
|
||||
for (const line of commands(readme()).filter((l) => l.startsWith('npm i -g') && l.includes('.git'))) {
|
||||
assert.match(line, /git\+https:\/\//, `這行 npm 跑不起來:${line}`);
|
||||
}
|
||||
});
|
||||
|
||||
test('更新與移除各有完整指令表,順序講清楚先 uninstall 再 npm rm', () => {
|
||||
const text = readme();
|
||||
|
||||
assert.match(text, /npm i -g https:\/\/gitea\.jsc\.idv\.tw\/plugins\/tea-sdlc\.git/);
|
||||
assert.match(text, /npm i -g git\+https:\/\/gitea\.jsc\.idv\.tw\/plugins\/tea-sdlc\.git/);
|
||||
assert.match(text, /tea-sdlc uninstall/);
|
||||
assert.match(text, /npm rm -g tea-sdlc/);
|
||||
// 先砍套件就再也刪不掉那些孤兒轉接檔,順序本身就是內容
|
||||
|
||||
Reference in New Issue
Block a user