pnpm-airgap-next 0.0.0-stage → 2.6.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BrightStarrySky
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,143 @@
1
- # Temporary Holding Version
1
+ # pnpm-airgap-next
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 把 pnpm 项目的依赖闭包在**在线环境**与**离线 / air-gapped 内网环境**之间搬运:按 `pnpm-lock.yaml` 下载离线包(tgz),再发布到私有 registry(Verdaccio / Nexus 等),并支持增量同步、覆盖重传、发布清单导出。
4
+
5
+ > 本包是 [`pnpm-airgap`](https://github.com/ReemX/pnpm-airgap) `2.5.0` 的 fork 增强版,**完全向后兼容**原版配置、命令与产物;新增能力均为可选开关,不传新参数时行为与原版一致。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ npm install -g pnpm-airgap-next
11
+ # 或作为项目依赖
12
+ npm install --save-dev pnpm-airgap-next
13
+ ```
14
+
15
+ 要求 Node.js `>= 18.0.0`。
16
+
17
+ ## 命令一览
18
+
19
+ ```bash
20
+ # 按 lockfile 下载依赖 tgz 到本地目录(不发布)
21
+ pnpm-airgap-next fetch -l ./pnpm-lock.yaml -o ./packages -r <source-registry>
22
+
23
+ # 把本地 packages 目录的 tgz 发布到私有 registry
24
+ pnpm-airgap-next publish -p ./packages -r <private-registry>
25
+
26
+ # 导出 registry 现有包版本清单(增量比对基准)
27
+ pnpm-airgap-next registry-state export -r <private-registry> -o ./registry-state.json
28
+
29
+ # 预览将要发布哪些包(dry-run,不实际上传)
30
+ pnpm-airgap-next publish -p ./packages -r <private-registry> --dry-run
31
+ ```
32
+
33
+ 程序名也可通过 `npx` 调用:`npx pnpm-airgap-next <command>`。
34
+
35
+ ## 相对原版 2.5.0 的增强
36
+
37
+ ### 1. 支持 pnpm 11 / 12 多文档 lockfile
38
+
39
+ 原版 `yaml.load()` 只能解析单文档,遇到多文档流会报 `expected a single document in the stream, but found more`。本版改用 `yaml.loadAll()` 遍历全部文档,合并各段 `packages` / `snapshots`,按 `name@version` 去重;单文档 lockfile 行为不变。
40
+
41
+ ### 2. Scope 路由与包排除
42
+
43
+ `fetch` 配置新增三个可选项(默认空,不填等价原版):
44
+
45
+ | 配置项 | 类型 | 说明 |
46
+ | ----------------- | ------------------------ | ---------------------------------------------------------- |
47
+ | `excludeScopes` | `string[]` | 按 scope 排除,如 `["@hearglobal"]`;命中包不计入下载/发布 |
48
+ | `excludePackages` | `string[]` | 按包名精确排除 |
49
+ | `scopeRegistries` | `Record<string, string>` | scope → registry 映射;命中包使用对应源解析 tarball 与鉴权 |
50
+
51
+ ### 3. 按包携带鉴权头
52
+
53
+ 多私有源场景下,下载请求按包所属 registry 匹配对应鉴权头,避免私有源包 401。
54
+
55
+ ### 4. 交互式鉴权 `--auth-prompt`
56
+
57
+ `publish` 与 `registry-state export` 支持 `--auth-prompt`:在 TTY 终端交互录入用户名 / 密码,密码静默不回显,凭据仅保留在当前进程内存、不落盘;录入结果覆盖 `.npmrc` / 环境变量中的旧凭据。
58
+
59
+ - 不传该参数:沿用原版鉴权链(`.npmrc` → userconfig → `~/.npmrc` → 环境变量 `NPM_TOKEN` 等);
60
+ - 非 TTY / CI 环境不要使用该参数。
61
+
62
+ ### 5. 结构化发布清单 `--publish-report <path>`
63
+
64
+ `publish` 支持 `--publish-report <path>`,把本轮**成功上传**的包写成结构化 JSON 清单(dry-run 同样生成):
65
+
66
+ ```json
67
+ {
68
+ "timestamp": "2026-12-05T10:34:18.228Z",
69
+ "registry": "http://registry:4873/",
70
+ "dryRun": false,
71
+ "publishedCount": 2,
72
+ "packages": [
73
+ { "name": "lodash", "version": "4.17.21" },
74
+ { "name": "@scope/utils", "version": "1.2.0" }
75
+ ]
76
+ }
77
+ ```
78
+
79
+ 控制台逐条打印 `✅ published: name@version`。
80
+
81
+ > 原版内置的 `packages/publish-report.json`(汇总统计 + 失败明细)保留不变,与本清单是两份独立文件。
82
+
83
+ ### 6. 消除 DEP0169 弃用告警
84
+
85
+ 内嵌依赖原本调用已弃用的 legacy `url.parse()`,在 Node 18+ 持续输出 `DEP0169` 告警。本版在模块加载前以 WHATWG `new URL()` 提供对齐 legacy 字段形态的兼容实现,从解析根源消除告警,不改动上层网络逻辑。
86
+
87
+ ## 配置文件
88
+
89
+ 可通过 `-c/--config <path>` 传入 JSON 配置,结构:
90
+
91
+ ```json
92
+ {
93
+ "fetch": {
94
+ "lockfilePath": "./pnpm-lock.yaml",
95
+ "outputDir": "./packages",
96
+ "concurrency": 16,
97
+ "registryUrl": "https://registry.npmjs.org",
98
+ "registryStatePath": null,
99
+ "skipOptional": false,
100
+ "excludeScopes": [],
101
+ "excludePackages": [],
102
+ "scopeRegistries": {},
103
+ "debug": false
104
+ },
105
+ "publish": {
106
+ "packagesDir": "./packages",
107
+ "registryUrl": "http://localhost:4873",
108
+ "concurrency": 8,
109
+ "skipExisting": true,
110
+ "dryRun": false,
111
+ "publishReportPath": null,
112
+ "timeout": 300,
113
+ "debug": false
114
+ },
115
+ "registryState": {
116
+ "registryUrl": "http://localhost:4873",
117
+ "outputPath": "./registry-state.json",
118
+ "scope": null,
119
+ "concurrency": 10,
120
+ "debug": false
121
+ }
122
+ }
123
+ ```
124
+
125
+ ## CLI 参数(publish / export 新增项)
126
+
127
+ | 参数 | 生效命令 | 说明 |
128
+ | ------------------------- | ---------------------------------- | ----------------------------------------------- |
129
+ | `--auth-prompt` | `publish`、`registry-state export` | 交互录入 Basic 鉴权 |
130
+ | `--publish-report <path>` | `publish` | 输出成功包结构化清单 |
131
+ | `--dry-run` | `publish` | 预览,不真实提交 |
132
+ | `--no-skip-existing` | `publish` | 强制重传已存在版本(需 registry 允许 redeploy) |
133
+ | `--registry-state <path>` | `fetch` | 对照已有清单跳过私服已存在包 |
134
+
135
+ ## 向后兼容说明
136
+
137
+ - 原版 `fetch` / `publish` / `registry-state export` / `sync` 子命令、并发、重试、完整性校验、dry-run 逻辑保持不变;
138
+ - 原有鉴权回退链、内置产物(`metadata.json`、`bundle-info.json`、`publish-report.json`)行为不变;
139
+ - 新增配置项与 CLI 参数全部可选;未使用时,行为与 `pnpm-airgap@2.5.0` 一致。
140
+
141
+ ## 许可证
142
+
143
+ MIT,继承自上游 [pnpm-airgap](https://github.com/ReemX/pnpm-airgap)。