x7-code-line 0.2.0 → 0.3.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 +21 -7
- package/package.json +1 -1
- package/src/install.js +8 -1
package/README.md
CHANGED
|
@@ -18,6 +18,20 @@
|
|
|
18
18
|
|
|
19
19
|
作为 npm 依赖安装时,`postinstall` 脚本使用 `INIT_CWD` 作为当前安装目录,也就是执行 `npm install` 时所在的项目目录。
|
|
20
20
|
|
|
21
|
+
如果只是全局安装:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm install -g x7-code-line
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
此时只安装 CLI,不会自动为任何项目写入 hooks。全局安装完成后,需要手动执行:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
x7-code-line install --dir <absolute-path>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
只有在 `X7_CODE_LINE_DIRS` 或 `X7_CODE_LINE_CONFIG` 明确提供目标目录时,`postinstall` 才会继续执行项目安装逻辑。
|
|
34
|
+
|
|
21
35
|
当前安装目录会创建或覆盖:
|
|
22
36
|
|
|
23
37
|
```text
|
|
@@ -175,20 +189,20 @@ x7-ai-lines: 0
|
|
|
175
189
|
默认要求传入绝对路径:
|
|
176
190
|
|
|
177
191
|
```sh
|
|
178
|
-
|
|
192
|
+
npm install -g x7-code-line --dir /abs/path/repo-a --dir /abs/path/repo-b
|
|
179
193
|
```
|
|
180
194
|
|
|
181
195
|
例如,将 `x7-code-line` 安装在 C 盘目录,但指定 D 盘的 Git 项目:
|
|
182
196
|
|
|
183
197
|
```powershell
|
|
184
198
|
cd C:\x7-tools\x7-code-line-host
|
|
185
|
-
|
|
199
|
+
npm install -g x7-code-line --dir D:\work\repo-a --dir D:\work\repo-b
|
|
186
200
|
```
|
|
187
201
|
|
|
188
202
|
如果确实需要解析相对路径,必须显式传 `--relative`:
|
|
189
203
|
|
|
190
204
|
```sh
|
|
191
|
-
|
|
205
|
+
npm install -g x7-code-line --relative --dir ../repo-a --dir ../repo-b
|
|
192
206
|
```
|
|
193
207
|
|
|
194
208
|
此时相对路径基于当前执行 `install` 命令的目录解析。
|
|
@@ -200,7 +214,7 @@ npx --no-install x7-code-line install --relative --dir ../repo-a --dir ../repo-b
|
|
|
200
214
|
macOS / Linux 示例:
|
|
201
215
|
|
|
202
216
|
```sh
|
|
203
|
-
X7_CODE_LINE_RELATIVE_PATHS=1 X7_CODE_LINE_DIRS="../repo-a:../repo-b" npm install x7-code-line
|
|
217
|
+
X7_CODE_LINE_RELATIVE_PATHS=1 X7_CODE_LINE_DIRS="../repo-a:../repo-b" npm install -g x7-code-line
|
|
204
218
|
```
|
|
205
219
|
|
|
206
220
|
Windows 使用 `;` 作为目录分隔符:
|
|
@@ -208,7 +222,7 @@ Windows 使用 `;` 作为目录分隔符:
|
|
|
208
222
|
```powershell
|
|
209
223
|
$env:X7_CODE_LINE_RELATIVE_PATHS = "1"
|
|
210
224
|
$env:X7_CODE_LINE_DIRS = "../repo-a;../repo-b"
|
|
211
|
-
npm install x7-code-line
|
|
225
|
+
npm install -g x7-code-line
|
|
212
226
|
```
|
|
213
227
|
|
|
214
228
|
## 配置文件
|
|
@@ -334,7 +348,7 @@ npm login
|
|
|
334
348
|
确认 `package.json` 中的包名和版本号正确后,执行:
|
|
335
349
|
|
|
336
350
|
```sh
|
|
337
|
-
npm publish
|
|
351
|
+
npm publish --access public
|
|
338
352
|
```
|
|
339
353
|
|
|
340
354
|
如果 npm 账号开启了 2FA,通常需要附带 OTP:
|
|
@@ -351,7 +365,7 @@ npm publish --access public --otp <6位验证码>
|
|
|
351
365
|
|
|
352
366
|
### 更新已发布版本
|
|
353
367
|
|
|
354
|
-
|
|
368
|
+
每次发布新版本前,手动修改package.json版本号或命令提升版本号:
|
|
355
369
|
|
|
356
370
|
```sh
|
|
357
371
|
npm version patch
|
package/package.json
CHANGED
package/src/install.js
CHANGED
|
@@ -27,9 +27,16 @@ function install(options = {}) {
|
|
|
27
27
|
|
|
28
28
|
function installFromPostinstall() {
|
|
29
29
|
const envDirs = splitList(process.env.X7_CODE_LINE_DIRS);
|
|
30
|
+
const configPath = process.env.X7_CODE_LINE_CONFIG;
|
|
31
|
+
const config = readConfig(configPath);
|
|
32
|
+
const configuredDirs = Array.isArray(config.dirs) ? config.dirs.map((dir) => String(dir || "").trim()).filter(Boolean) : [];
|
|
33
|
+
|
|
34
|
+
if (envDirs.length === 0 && configuredDirs.length === 0) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
30
37
|
|
|
31
38
|
return install({
|
|
32
|
-
configPath
|
|
39
|
+
configPath,
|
|
33
40
|
targetDirs: envDirs,
|
|
34
41
|
relativePaths: process.env.X7_CODE_LINE_RELATIVE_PATHS === "1"
|
|
35
42
|
});
|