npmapps 1.0.26 → 1.0.28

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/PUBLISH.md ADDED
@@ -0,0 +1,268 @@
1
+ # npmapps 发布流程
2
+
3
+ > 本机作为「内网文件分发 / 跨设备搬运」工具的 npm 发布会话。包名 `npmapps`,基于公网 npmjs.org。每次发布照本流程做,5-10 分钟跑完。
4
+
5
+ ---
6
+
7
+ ## 0. 前置检查(30 秒)
8
+
9
+ ```bash
10
+ cd /Users/wk/Documents/npmapps
11
+ cat package.json | grep -E '"(name|version)"'
12
+ npm config get registry
13
+ ```
14
+
15
+ 期望:
16
+ - `name: "npmapps"`
17
+ - `version: "1.0.<上次版本号>"`
18
+ - `registry: https://registry.npmjs.org/`
19
+
20
+ 如果 `registry` 是内网,后面所有命令一致,只是发布目标不同。
21
+
22
+ ---
23
+
24
+ ## 1. 阶段 1:搬运源文件到 `app/`(2-5 分钟)
25
+
26
+ ### 1.1 搬整个文件夹(过滤 `node_modules`)
27
+
28
+ ```bash
29
+ # 源
30
+ SRC=/Users/wk/Documents/wk/web/wujie-wk/wujie-vue2-child
31
+
32
+ # 目标
33
+ DST=/Users/wk/Documents/npmapps/app
34
+
35
+ # 同步(过滤 node_modules)
36
+ rsync -a --exclude='node_modules' "$SRC/" "$DST/"
37
+
38
+ # 删除原目录(完成"移动"语义)
39
+ rm -rf "$SRC"
40
+
41
+ # 验证:确认没漏
42
+ du -sh "$DST"
43
+ find "$DST" -type d -name node_modules # 应该无输出
44
+ ```
45
+
46
+ ### 1.2 搬单个文件(zip / 压缩包 / 二进制)
47
+
48
+ ```bash
49
+ mv /path/to/some.zip /Users/wk/Documents/npmapps/app/
50
+
51
+ # 验证
52
+ ls -la /Users/wk/Documents/npmapps/app/some.zip
53
+ ```
54
+
55
+ ### 1.3 验证 `app/` 状态
56
+
57
+ ```bash
58
+ ls -la /Users/wk/Documents/npmapps/app
59
+ ```
60
+
61
+ 确认:
62
+ - ✅ `wujie-vue2-child/` 子目录在(整个 Vue2 子应用)
63
+ - ✅ `*.zip` 文件在
64
+ - ✅ 没有 `node_modules`
65
+
66
+ ---
67
+
68
+ ## 2. 阶段 2:更新版本号(10 秒)
69
+
70
+ ```bash
71
+ # 推荐用 npm 内置命令(自动修改 package.json)
72
+ npm version patch # 1.0.25 → 1.0.26
73
+ # 其它选项:minor → 1.1.0,major → 2.0.0,具体版本号 → 1.0.27
74
+
75
+ # 或者手动改 package.json
76
+ # "version": "1.0.25" → "1.0.26"
77
+
78
+ # 验证
79
+ grep '"version"' package.json
80
+ ```
81
+
82
+ > ⚠️ 注意:`npm version` 默认会 `git commit` + `git tag`。这个项目不是 git 仓库所以没事。如果以后初始化了 git,加 `--no-git-tag-version` 防止自动 commit。
83
+
84
+ ---
85
+
86
+ ## 3. 阶段 3:预览(20 秒,发布前最后一道检查)
87
+
88
+ ```bash
89
+ npm pack --dry-run
90
+ ```
91
+
92
+ 期望输出:
93
+ ```
94
+ npm notice name: npmapps
95
+ npm notice version: 1.0.26
96
+ npm notice total files: 109 (大概)
97
+ ```
98
+
99
+ **重点检查**:
100
+ - ⚠️ 警告 `No .npmignore file found, using .gitignore` —— 这个项目外层没 `.gitignore`,npm 会读 `app/wujie-vue2-child/.gitignore`(嵌套目录的 gitignore npm 不读),所以 .codegraph、.DS_Store 之类的不会被自动排除
101
+ - ⚠️ 出现 `app/.codegraph/daemon.pid` —— 这是本地 codegraph 索引 daemon 运行时残留文件,会进包。按需决定:
102
+ - 想干净:加 `.npmignore`(见附录 A)
103
+ - 无所谓:照发,166B 不影响
104
+
105
+ ---
106
+
107
+ ## 4. 阶段 4:处理 2FA / token(最容易卡住的环节)
108
+
109
+ ### 4.1 现状诊断
110
+
111
+ ```bash
112
+ npm whoami # 应该返回 npm 用户名
113
+ npm profile get | grep "two-factor"
114
+ ```
115
+
116
+ - `npm whoami` 返回用户名 ✅ token 有效
117
+ - `two-factor auth: auth-and-writes` ❌ publish 会被 2FA 拦
118
+
119
+ ### 4.2 如果 `npm whoami` 401(token 失效)
120
+
121
+ 在终端跑(交互式):
122
+
123
+ ```
124
+ ! npm login
125
+ ```
126
+
127
+ 走 web flow:浏览器打开,登录授权,完成后 npm 自动把 token 写到 `~/.npmrc`。
128
+
129
+ ### 4.3 如果 publish 报 EOTP(2FA 拦下)
130
+
131
+ **最快路径 —— 生成 bypass 2FA 的 token**:
132
+
133
+ 1. 浏览器打开 https://www.npmjs.com/settings/<用户名>/tokens
134
+ 2. **Generate New Token** → 名字随便(例如 `local-publish`)
135
+ 3. 类型选 **"Publish"**
136
+ 4. **关键:勾上 "Bypass two-factor authentication"** ⚠️ 这步必须勾,否则 publish 仍要 OTP
137
+ 5. 复制 token(`npm_xxxxxx...`)
138
+ 6. 替换 `~/.npmrc`:
139
+
140
+ ```bash
141
+ # 备份 + 替换
142
+ cp ~/.npmrc ~/.npmrc.bak
143
+ # 编辑 ~/.npmrc,把 _authToken 那行的 token 换成新复制的
144
+ ```
145
+
146
+ 或者直接跑(把新 token 替换成你拿到的):
147
+
148
+ ```bash
149
+ TOKEN=npm_xxxxxxxx
150
+ sed -i '' "s|//registry.npmjs.org/:_authToken=.*|//registry.npmjs.org/:_authToken=$TOKEN|" ~/.npmrc
151
+
152
+ # 验证
153
+ npm whoami
154
+ ```
155
+
156
+ ### 4.4 替代方案:从账号层改 2FA 模式
157
+
158
+ 如果不想用 bypass token:
159
+ 1. 浏览器打开 https://www.npmjs.com/settings/<用户名>/security
160
+ 2. Two-Factor Authentication 改成 **"Authorization only"** 或 **Disabled**
161
+ 3. 保存(可能需要再输一次 OTP 或点邮件 magic link)
162
+ 4. 回来重试 publish
163
+
164
+ ---
165
+
166
+ ## 5. 阶段 5:真正发布(10 秒)
167
+
168
+ ```bash
169
+ cd /Users/wk/Documents/npmapps
170
+ npm publish
171
+ ```
172
+
173
+ 成功标志:
174
+
175
+ ```
176
+ + npmapps@1.0.26
177
+ ```
178
+
179
+ 失败标志:
180
+ - `EOTP`:回到阶段 4.3 换 bypass token
181
+ - `E404: PUT ... npmapps`:token 失效,回到阶段 4.2
182
+ - `ENEEDAUTH`:同上
183
+ - `You do not have permission`:包名在公网被占,需要换名
184
+
185
+ ---
186
+
187
+ ## 6. 阶段 6:验证(10 秒)
188
+
189
+ ```bash
190
+ # 1. 查公网版本列表
191
+ npm view npmapps versions --json | tail -5
192
+ # 期望看到刚发的版本
193
+
194
+ # 2. 查发布时间戳
195
+ npm view npmapps time --json | grep "<新版本号>"
196
+ # 期望: "<新版本号>": "2026-..."
197
+
198
+ # 3. 查 tarball 信息
199
+ npm view npmapps dist
200
+ # 期望:tarball URL 指向新版本
201
+ ```
202
+
203
+ ---
204
+
205
+ ## 7. 收尾(可选,2 分钟)
206
+
207
+ ```bash
208
+ # 1. 清理 .npmrc 备份
209
+ rm -f ~/.npmrc.bak
210
+
211
+ # 2. 在 npm 网站 revoke 失效/过期的 token
212
+ # https://www.npmjs.com/settings/<用户名>/tokens
213
+ # 只保留当前 .npmrc 里的那个,其余全 revoke
214
+
215
+ # 3. 检查发布的 tarball 内容
216
+ npm pack
217
+ tar -tzf npmapps-<新版本号>.tgz | head -20
218
+ # 看到不应该出现的文件就清理后再发新版本
219
+ ```
220
+
221
+ ---
222
+
223
+ ## 附录 A:加 `.npmignore` 让发布更干净(可选)
224
+
225
+ 如果想排除 `.codegraph`、`.DS_Store`、`package-lock.json`、`dist/` 等:
226
+
227
+ ```bash
228
+ cat > /Users/wk/Documents/npmapps/.npmignore <<'EOF'
229
+ .DS_Store
230
+ .codegraph
231
+ *.pid
232
+ node_modules
233
+ package-lock.json
234
+ dist
235
+ EOF
236
+ ```
237
+
238
+ 之后 `npm pack --dry-run` 会用这个文件,不再读 `.gitignore`。
239
+
240
+ ---
241
+
242
+ ## 附录 B:常用命令速查
243
+
244
+ | 目的 | 命令 |
245
+ |---|---|
246
+ | 查包是否被占 | `npm view <name> name version` |
247
+ | 查包全部元信息 | `npm view <name> --json` |
248
+ | 查自己是谁 | `npm whoami` |
249
+ | 查账号 2FA 模式 | `npm profile get` |
250
+ | 生成 tarball(不发布) | `npm pack` |
251
+ | 预览 tarball 内容 | `npm pack --dry-run` |
252
+ | 登录 | `npm login`(交互) |
253
+ | 登出 | `npm logout` |
254
+ | 撤销发布(24 小时内) | `npm unpublish <pkg>@<version>` ⚠️ 慎用 |
255
+ | deprecate 版本 | `npm deprecate <pkg>@<version> "msg"` |
256
+
257
+ ---
258
+
259
+ ## 附录 C:本次踩过的坑(避坑指南)
260
+
261
+ | 坑 | 原因 | 解法 |
262
+ |---|---|---|
263
+ | `npm whoami` 401 | `~/.npmrc` 里 token 失效 | `npm login` 重新登录 |
264
+ | publish E404 | 包名被占,token 无权覆盖 | 确认包归属 / 换名 / 用有 publish 权限的 token |
265
+ | publish EOTP | 账号 `auth-and-writes` 2FA 模式 | 生成 **bypass 2FA** 的 token,或网站改 2FA 模式 |
266
+ | tarball 里有 `.codegraph/` | 外层没 `.gitignore`/`.npmignore` | 加 `.npmignore`(附录 A),或接受 166B 的 daemon.pid 跟着发 |
267
+ | `npm version` 自动 commit | 项目变成 git 仓库后 | 加 `--no-git-tag-version` 标志 |
268
+ | `npmrc` 改了没生效 | 缓存 / 文件权限 | `cat ~/.npmrc` 确认;`chmod 600 ~/.npmrc` |
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npmapps",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {