@anizoptera/publish-clean 0.4.0 → 0.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/README.md +147 -212
- package/dist/cli.js +443 -305
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
# @anizoptera/publish-clean
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Pre-publish npm package cleaner that strips common useless noise and crap from
|
|
4
|
+
`package.json`; prevents accidental publication of unwanted things and unresolved
|
|
5
|
+
dependencies. No deps, one JS file.
|
|
5
6
|
|
|
6
7
|
[](https://www.npmjs.com/package/@anizoptera/publish-clean)
|
|
7
8
|
[](https://www.npmjs.com/package/@anizoptera/publish-clean#provenance)
|
|
8
9
|
[](https://github.com/Anizoptera/publish-clean/actions/workflows/check.yml)
|
|
9
|
-
[](package.json)
|
|
11
11
|
[](package.json)
|
|
12
|
-
[](https://pnpm.io/cli/pack)
|
|
14
|
-
[](https://bun.sh/docs/cli/test)
|
|
12
|
+
[](LICENSE)
|
|
15
13
|
|
|
16
14
|
When you run `npm publish`, two things ship that you probably did not mean to ship.
|
|
17
15
|
|
|
18
|
-
The first is your `package.json`. It is a development manifest
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
The first is your `package.json`. It is a development manifest: devDependencies, config
|
|
17
|
+
blocks for your test runner, linter and formatter, `packageManager`, `workspaces`, `pnpm`
|
|
18
|
+
settings, release-tool settings, and every script you run locally.
|
|
21
19
|
npm sends all of it, unchanged, to everyone who installs your package. In a pnpm
|
|
22
20
|
workspace it can also send `workspace:*` and `catalog:` specs that were never resolved,
|
|
23
21
|
and those break the install for every consumer.
|
|
@@ -27,50 +25,53 @@ tests, `.github/`, a lockfile. You do not see the tarball before it goes out, an
|
|
|
27
25
|
version is published you cannot edit it. Unpublishing only works for a short window and
|
|
28
26
|
under conditions npm decides.
|
|
29
27
|
|
|
30
|
-
`publish-clean` packs the package, rewrites the
|
|
31
|
-
what consumers actually use,
|
|
32
|
-
never modified. If the artifact still has something in it that should
|
|
33
|
-
declares a `main`, `exports`, or `bin` path that is not in the tarball, it
|
|
34
|
-
of publishing.
|
|
28
|
+
`publish-clean` packs the package once, rewrites the `package.json` inside that tarball
|
|
29
|
+
down to what consumers actually use, checks the result, and publishes those exact bytes.
|
|
30
|
+
Your working tree is never modified. If the artifact still has something in it that should
|
|
31
|
+
not ship, or declares a `main`, `exports`, or `bin` path that is not in the tarball, it
|
|
32
|
+
fails instead of publishing.
|
|
35
33
|
|
|
36
|
-
It
|
|
37
|
-
|
|
34
|
+
It packs with pnpm and publishes with npm, and cleans the manifest in between. Both
|
|
35
|
+
choices are argued, with measurements, in
|
|
36
|
+
[why pnpm packs and npm publishes](docs/why-pnpm-and-npm.md).
|
|
38
37
|
|
|
39
38
|
## Install
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
| Project | Install | Run |
|
|
41
|
+
| ------- | --------------------------------------- | ------------------------- |
|
|
42
|
+
| pnpm | `pnpm add -D @anizoptera/publish-clean` | `pnpm exec publish-clean` |
|
|
43
|
+
| Bun | `bun add -d @anizoptera/publish-clean` | `bunx publish-clean` |
|
|
44
|
+
| npm | `npm i -D @anizoptera/publish-clean` | `npm exec publish-clean` |
|
|
45
|
+
| Yarn | `yarn add -D @anizoptera/publish-clean` | `yarn publish-clean` |
|
|
46
|
+
|
|
47
|
+
**Whatever you start it with, `pnpm` prepares the package and `npm` uploads it, so both
|
|
48
|
+
must be on `PATH`.** A Bun, npm or Yarn project needs pnpm installed too, including in CI.
|
|
49
|
+
|
|
50
|
+
Node.js 22+ runs it. npm provenance additionally needs 22.14+, because below that npm
|
|
51
|
+
cannot mint it.
|
|
44
52
|
|
|
45
53
|
That installs one package and nothing else. `publish-clean` has zero runtime
|
|
46
|
-
dependencies: it is a single file that talks to `pnpm
|
|
47
|
-
|
|
54
|
+
dependencies: it is a single file that talks to `pnpm` and `npm`, and reads and rewrites
|
|
55
|
+
the tarball itself, so there is nothing else to have on the machine.
|
|
56
|
+
|
|
57
|
+
For something that sits on your publish path and handles your
|
|
48
58
|
registry credentials, that matters. A publishing tool with a dependency tree is a
|
|
49
59
|
supply-chain risk of its own, and this one has no transitive code to audit.
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
`--provenance` also needs Node.js 22.14+, npm 11.5.1+, and a cloud CI runner. npm will
|
|
54
|
-
not sign a publish that came from your laptop.
|
|
61
|
+
`--provenance` additionally needs npm 11.5.1+ and a cloud CI runner. npm will not sign a
|
|
62
|
+
publish that came from your laptop.
|
|
55
63
|
|
|
56
64
|
## Package managers
|
|
57
65
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
Why pnpm packs and npm publishes: pnpm is the only packer that resolves every workspace
|
|
67
|
+
layout correctly, and npm is the only client that can sign a release. The measurements are
|
|
68
|
+
in [why pnpm packs and npm publishes](docs/why-pnpm-and-npm.md).
|
|
61
69
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
| npm | `npm exec publish-clean` | Works. Prints an advisory that packing goes through pnpm. |
|
|
66
|
-
| Yarn | `yarn publish-clean` | Same as npm. |
|
|
67
|
-
| Bun | `bunx publish-clean` | Same as npm. |
|
|
70
|
+
Started with anything other than pnpm, it prints an advisory on stderr saying so. That is
|
|
71
|
+
a warning, not an error. Nothing behaves differently because of it, and there is no flag
|
|
72
|
+
to silence it.
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
it and there's no flag to silence it. Worth seeing once if the rest of your pipeline runs
|
|
71
|
-
on something other than pnpm.
|
|
72
|
-
|
|
73
|
-
For a single package all four behave the same, since nothing in the manifest needs
|
|
74
|
+
For a single package every manager behaves the same, since nothing in the manifest needs
|
|
74
75
|
resolving before it ships.
|
|
75
76
|
|
|
76
77
|
Monorepos are where it matters. `pnpm pack` resolves `workspace:` and `catalog:` specs by
|
|
@@ -159,8 +160,8 @@ publishes its own tarball, so you get the checks and not the cleaned manifest.
|
|
|
159
160
|
pnpm exec publish-clean --dry-run
|
|
160
161
|
```
|
|
161
162
|
|
|
162
|
-
Prints
|
|
163
|
-
|
|
163
|
+
Prints every file that would ship and the cleaned `package.json`, then deletes its temp
|
|
164
|
+
tree. Add `--tarball-out DIR` to keep the tarball itself.
|
|
164
165
|
|
|
165
166
|
### Publishing a restricted package
|
|
166
167
|
|
|
@@ -181,98 +182,43 @@ publish-clean packages/my-lib -- --access public --tag next
|
|
|
181
182
|
|
|
182
183
|
```mermaid
|
|
183
184
|
flowchart TD
|
|
184
|
-
A[Your package directory] -->|pnpm pack| B[Tarball
|
|
185
|
-
B --> C[
|
|
186
|
-
C --> D
|
|
187
|
-
D --> E
|
|
188
|
-
E
|
|
189
|
-
|
|
190
|
-
G --> H{Same files, expected manifest, still no leaks?}
|
|
191
|
-
H --> I[npm publish that tarball]
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
Any gate that fails exits non-zero and nothing is published. `--dry-run` and
|
|
195
|
-
`--guard-only` run the whole pipeline and stop before the publish.
|
|
196
|
-
|
|
197
|
-
## Why it works this way
|
|
198
|
-
|
|
199
|
-
### Why pnpm does the packing
|
|
200
|
-
|
|
201
|
-
Not for file selection. pnpm, npm and Bun pick the same files: same `files` field, same
|
|
202
|
-
`.npmignore`, same packlist defaults. There are no file rules of this tool's own either,
|
|
203
|
-
so that part behaves however your package manager already behaves.
|
|
204
|
-
|
|
205
|
-
Workspaces are the reason. A dependency written as `"@acme/utils": "workspace:*"` means
|
|
206
|
-
"whatever version of that package is in this repo right now". It has to become a real
|
|
207
|
-
version range before it ships, because to a stranger installing from the registry
|
|
208
|
-
`workspace:*` means nothing.
|
|
209
|
-
|
|
210
|
-
npm never adopted the protocol. It won't even install it:
|
|
211
|
-
|
|
212
|
-
```
|
|
213
|
-
npm error code EUNSUPPORTEDPROTOCOL
|
|
214
|
-
npm error Unsupported URL Type "workspace:": workspace:*
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
`npm pack` on that same package exits 0 and writes `workspace:*` straight into the
|
|
218
|
-
tarball. It neither resolves it nor refuses it, and silently publishing something you
|
|
219
|
-
can't install is the one behaviour a release tool can't be built on.
|
|
220
|
-
|
|
221
|
-
pnpm and Bun both resolve it, and both stop loudly when they can't. Their output matches
|
|
222
|
-
down to `workspace:^` and `workspace:~` in `peerDependencies` and `optionalDependencies`,
|
|
223
|
-
and `catalog:` entries too. On correctness there is nothing to choose between them.
|
|
224
|
-
|
|
225
|
-
### Why pnpm rather than Bun
|
|
226
|
-
|
|
227
|
-
They resolve from different places, and that decides it.
|
|
228
|
-
|
|
229
|
-
pnpm looks for the dependency in the packing package's own `node_modules` and resolves it
|
|
230
|
-
from there. It never asks who put it there, so a Bun workspace, which gives every package
|
|
231
|
-
its own `node_modules`, packs as readily as pnpm's own. Yarn hoists to the root instead
|
|
232
|
-
and needs the one-time setup above.
|
|
233
|
-
|
|
234
|
-
Bun reads `bun.lock`. It resolves the workspaces Bun installed and refuses the others:
|
|
235
|
-
|
|
236
|
-
```
|
|
237
|
-
error: Failed to resolve workspace version for "@acme/utils" in `dependencies`.
|
|
238
|
-
Run `bun install` and try again.
|
|
185
|
+
A[Your package directory] -->|pnpm pack| B[Tarball, file set chosen by pnpm]
|
|
186
|
+
B --> C[Copy it, rewriting only the package.json inside]
|
|
187
|
+
C --> D[Final tarball]
|
|
188
|
+
D --> E{Checks, all reading this tarball}
|
|
189
|
+
E -->|any fails| F[Exit non-zero, publish nothing]
|
|
190
|
+
E -->|all pass| G[npm publish this same tarball]
|
|
239
191
|
```
|
|
240
192
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
reads all of them.
|
|
193
|
+
The checks are listed under [What it checks](#what-it-checks). The point of the shape is
|
|
194
|
+
that they all read the tarball that gets uploaded, so what passed the checks and what
|
|
195
|
+
reached the registry are the same bytes, not two things that ought to match.
|
|
245
196
|
|
|
246
|
-
|
|
247
|
-
`"utils": "workspace:@acme/utils@*"`, has to come out the other side as an npm alias.
|
|
248
|
-
pnpm writes `"npm:@acme/utils@1.2.3"`. Bun 1.3.14 writes `"@acme/utils@*"`: the `npm:`
|
|
249
|
-
prefix is dropped and the range was never resolved. npm won't take it.
|
|
197
|
+
`--dry-run` and `--guard-only` run the whole pipeline and stop before the publish.
|
|
250
198
|
|
|
251
|
-
|
|
252
|
-
npm error code EINVALIDTAGNAME
|
|
253
|
-
npm error Invalid tag name "is-odd@3.0.1" of package "aliased@is-odd@3.0.1"
|
|
254
|
-
```
|
|
199
|
+
## Why it works this way
|
|
255
200
|
|
|
256
|
-
|
|
257
|
-
release.
|
|
201
|
+
### Why pnpm packs, and npm publishes
|
|
258
202
|
|
|
259
|
-
|
|
260
|
-
|
|
203
|
+
pnpm because of workspaces. A dependency written `"@acme/utils": "workspace:*"` has to
|
|
204
|
+
become a real version range before it ships, and pnpm is the only packer that does that
|
|
205
|
+
for every layout it might find, including a Bun one. npm writes `workspace:*` into the
|
|
206
|
+
tarball unchanged and exits 0, publishing a package nobody can install. Bun resolves only
|
|
207
|
+
what Bun installed, and quietly mangles an aliased workspace dependency.
|
|
261
208
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
209
|
+
npm because of provenance. The signed attestation behind the "Built and signed on GitHub
|
|
210
|
+
Actions" badge is minted by the npm CLI talking to Sigstore, and trusted publishing, which
|
|
211
|
+
removes the long-lived token entirely, is npm's own exchange with the registry. No other
|
|
212
|
+
client does either one. `npm publish` also takes a tarball directly, which is what the
|
|
213
|
+
packing step already produced.
|
|
267
214
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
`workspace:1.2.3` ranges, named catalogs, and refusing a catalog entry that doesn't exist.
|
|
215
|
+
The measurements behind both choices, and the one thing packing with pnpm costs you, are
|
|
216
|
+
in [why pnpm packs and npm publishes](docs/why-pnpm-and-npm.md).
|
|
271
217
|
|
|
272
218
|
### Why the manifest is cleaned on a copy
|
|
273
219
|
|
|
274
|
-
The
|
|
275
|
-
is never touched.
|
|
220
|
+
The manifest is read out of the packed tarball and written back into a copy of it, in a
|
|
221
|
+
temp directory. Your working tree is never touched.
|
|
276
222
|
|
|
277
223
|
The obvious alternative is what a lot of hand-rolled release scripts do: edit
|
|
278
224
|
`package.json`, publish, edit it back. That's fine until something dies in the middle,
|
|
@@ -294,63 +240,54 @@ then has nothing left to select with, falls back to your `.gitignore`/`.npmignor
|
|
|
294
240
|
exclusion, and quietly drops files the first pack included. A package shipping a
|
|
295
241
|
`.gitignore` that excludes any other shipped file loses it.
|
|
296
242
|
|
|
297
|
-
Editing avoids the
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
machine
|
|
243
|
+
Editing avoids the question. Only the `package/package.json` member is replaced. Every
|
|
244
|
+
other entry is copied without being decoded, so the file set stays exactly what pnpm chose,
|
|
245
|
+
and entry shapes this tool does not model (pax headers for long paths, prefix splitting)
|
|
246
|
+
pass through untouched. It also keeps pnpm's normalised metadata: owner `0:0`, a fixed
|
|
247
|
+
timestamp, mode 644. A plain `tar` invocation would replace those with whatever the build
|
|
248
|
+
machine happens to have.
|
|
303
249
|
|
|
304
250
|
Lifecycle scripts run once, at the first pack. `pnpm pack` runs your `prepare` and
|
|
305
251
|
`prepack`, which is how build output reaches the package at all. Nothing runs afterwards:
|
|
306
252
|
npm skips `prepack`/`postpack` when it is handed a tarball rather than a directory, so
|
|
307
253
|
nothing can alter the artifact after it was checked.
|
|
308
254
|
|
|
309
|
-
### Why npm does the publishing
|
|
310
|
-
|
|
311
|
-
Provenance is an npm feature. The signed attestation behind the "Built and signed on
|
|
312
|
-
GitHub Actions" badge is minted by the npm CLI talking to Sigstore, and trusted
|
|
313
|
-
publishing, which removes the long-lived token entirely, is npm's own OIDC exchange with
|
|
314
|
-
the registry.
|
|
315
|
-
|
|
316
|
-
No other client mints it. `bun publish` offers `--access`, `--tag`, `--otp` and
|
|
317
|
-
`--auth-type`, and nothing at all for provenance or attestation, so publishing through it
|
|
318
|
-
would cost both the badge and the tokenless path. That trade isn't on the table here:
|
|
319
|
-
verifiable provenance is why this package exists.
|
|
320
|
-
|
|
321
|
-
`npm publish` also takes a tarball directly, which is exactly what the previous step
|
|
322
|
-
produced.
|
|
323
|
-
|
|
324
255
|
## What it checks
|
|
325
256
|
|
|
326
|
-
`publish-clean`
|
|
327
|
-
|
|
328
|
-
- the package is `private: true`
|
|
329
|
-
- the
|
|
330
|
-
- the package has no non-empty `files` array
|
|
331
|
-
- the tarball
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
-
|
|
335
|
-
|
|
336
|
-
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
257
|
+
`publish-clean` stops, and publishes nothing, when:
|
|
258
|
+
|
|
259
|
+
- the package is marked `private: true`
|
|
260
|
+
- the working tree has uncommitted changes (`--no-git-checks` to allow it)
|
|
261
|
+
- the package has no non-empty `files` array (`--skip-file-check` to allow it)
|
|
262
|
+
- the tarball holds tests, CI config, a lockfile or a `tsconfig` (`--allow-suspicious` to
|
|
263
|
+
allow it — a separate switch from the one above, so waiving a manifest convention never
|
|
264
|
+
silently disarms the artifact scan)
|
|
265
|
+
- the tarball holds something that should never ship: a `.env`, an `.npmrc`, `.git`,
|
|
266
|
+
`node_modules`, or a private key. This one has no off switch, by any flag or config key
|
|
267
|
+
- a dependency is still written as `catalog:`, `workspace:`, `link:` or `portal:`, which
|
|
268
|
+
nobody outside your repo can install
|
|
269
|
+
- the manifest points `exports`, `types`, `main`, `browser`, `bin` or `sideEffects` at a
|
|
270
|
+
path that is not in the tarball
|
|
271
|
+
- rewriting the manifest changed anything else in the tarball
|
|
272
|
+
- you asked for `--provenance` from GitHub Actions, but the `repository` in your manifest
|
|
273
|
+
is not the repository the workflow is running in
|
|
274
|
+
|
|
275
|
+
It warns, without stopping, when it was started by npm, Yarn or Bun rather than pnpm. The
|
|
276
|
+
packing still goes through pnpm, but the warning is there because the rest of your release
|
|
277
|
+
probably should too.
|
|
345
278
|
|
|
346
279
|
## What the cleaned manifest keeps
|
|
347
280
|
|
|
348
281
|
Everything a consumer or a registry reads survives: `name`, `version`, `license`,
|
|
349
282
|
`dependencies`, `peerDependencies` and their meta, `exports`, `main`, `module`, `types`,
|
|
350
|
-
`bin`, `
|
|
351
|
-
|
|
283
|
+
`bin`, `engines`, `os`, `cpu`, `sideEffects`, `publishConfig`, and the rest of the public
|
|
284
|
+
surface.
|
|
352
285
|
|
|
353
|
-
|
|
286
|
+
`files` goes, because it is spent: it told the packer what to include, the tarball already
|
|
287
|
+
exists, nothing re-selects afterwards, and an install extracts every entry unfiltered. npm
|
|
288
|
+
agrees — its registry drops the field from the metadata it serves.
|
|
289
|
+
|
|
290
|
+
What else goes: `devDependencies`, `workspaces`, `pnpm`, `packageManager`, `overrides`,
|
|
354
291
|
`resolutions`, and the config blocks belonging to test runners, linters, formatters,
|
|
355
292
|
coverage tools, build systems and release tools. Scripts go too, apart from the install
|
|
356
293
|
lifecycle ones a consumer actually runs: `preinstall`, `install`, `postinstall`,
|
|
@@ -374,40 +311,21 @@ hear about it from a stranger's broken build rather than from your own release.
|
|
|
374
311
|
Add your own with `devFields`. Better still, run `--dry-run` and read the manifest that
|
|
375
312
|
would ship instead of trusting this list.
|
|
376
313
|
|
|
377
|
-
## Options
|
|
314
|
+
## Options and config
|
|
378
315
|
|
|
379
316
|
```bash
|
|
380
317
|
publish-clean [options] [package-dir] [-- npm-publish-args]
|
|
381
318
|
```
|
|
382
319
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
- `--guard-only`: run the full pack, clean, and final-tarball guard without
|
|
386
|
-
publishing.
|
|
387
|
-
- `--registry URL`: set `publishConfig.registry` on the cleaned manifest.
|
|
388
|
-
- `--skip-file-check`: skip suspicious-file checks and the required `files`
|
|
389
|
-
array check. Critical leak checks still run.
|
|
390
|
-
- `--no-git-checks`: skip the source git cleanliness check.
|
|
391
|
-
- `--tarball-out DIR`: copy the final tarball into `DIR` before publishing. The bytes
|
|
392
|
-
kept are the ones that were published, so a release pipeline can attach them to a
|
|
393
|
-
GitHub Release or sign them with build-provenance attestation.
|
|
394
|
-
- `-h`, `--help`: print usage.
|
|
395
|
-
|
|
396
|
-
Arguments after `--` go to `npm publish`, which publishes the final cleaned
|
|
397
|
-
tarball.
|
|
398
|
-
|
|
399
|
-
Pass the npm dist-tag explicitly. For normal public releases, use
|
|
400
|
-
`--tag latest`.
|
|
401
|
-
|
|
402
|
-
## Package config
|
|
403
|
-
|
|
404
|
-
Stable project defaults can live in `package.json`:
|
|
320
|
+
Most settings can be a flag or a `package.json` key. Flags win, so keep per-release
|
|
321
|
+
choices like dist-tags on the command line and stable project policy in the manifest:
|
|
405
322
|
|
|
406
323
|
```json
|
|
407
324
|
{
|
|
408
325
|
"publish-clean": {
|
|
409
326
|
"registry": "https://registry.npmjs.org",
|
|
410
327
|
"skipFileCheck": false,
|
|
328
|
+
"allowSuspicious": false,
|
|
411
329
|
"noGitChecks": false,
|
|
412
330
|
"devFields": ["customBuildOnlyField"],
|
|
413
331
|
"keepFields": ["contributes"]
|
|
@@ -415,35 +333,54 @@ Stable project defaults can live in `package.json`:
|
|
|
415
333
|
}
|
|
416
334
|
```
|
|
417
335
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
336
|
+
| Flag | `package.json` | What it does |
|
|
337
|
+
| -------------------- | ----------------- | ------------------------------------------------------------------------------------------ |
|
|
338
|
+
| `--dry-run` | - | Run everything up to the publish, then print the file list and the cleaned `package.json`. |
|
|
339
|
+
| `--guard-only` | - | Run everything up to the publish and exit, printing nothing. |
|
|
340
|
+
| `--tarball-out DIR` | - | Copy the final tarball into `DIR` before publishing. |
|
|
341
|
+
| `--registry URL` | `registry` | Set `publishConfig.registry` on the cleaned manifest, and publish to it. |
|
|
342
|
+
| `--skip-file-check` | `skipFileCheck` | Allow a manifest with no `files` array. |
|
|
343
|
+
| `--allow-suspicious` | `allowSuspicious` | Allow tests, CI config, lockfiles or `tsconfig` in the artifact. |
|
|
344
|
+
| `--no-git-checks` | `noGitChecks` | Allow publishing from a dirty working tree. |
|
|
345
|
+
| - | `devFields` | Extra manifest fields to strip. |
|
|
346
|
+
| - | `keepFields` | Fields that belong in the published package, so stop reporting them. |
|
|
347
|
+
| `-h`, `--help` | - | Print usage, every flag, and the config keys. |
|
|
348
|
+
| `-v`, `--version` | - | Print the installed version. |
|
|
349
|
+
|
|
350
|
+
Arguments after `--` go to `npm publish`. Pass the dist-tag explicitly: `--tag latest` for
|
|
351
|
+
a normal public release.
|
|
421
352
|
|
|
422
|
-
|
|
423
|
-
Leak checks keep running; those cannot be turned off.
|
|
353
|
+
A few of these deserve a sentence more.
|
|
424
354
|
|
|
425
|
-
`
|
|
426
|
-
|
|
355
|
+
`--tarball-out` keeps the bytes that were published, so a release pipeline can attach them
|
|
356
|
+
to a GitHub Release or sign them with build-provenance attestation. The copy happens in
|
|
357
|
+
every mode, before the publish, so you get the validated artifact even if the upload fails.
|
|
427
358
|
|
|
428
|
-
`
|
|
429
|
-
|
|
430
|
-
the dependency maps, are rejected here, so a typo cannot quietly break your package.
|
|
359
|
+
`registry` pins where the package goes, so it cannot end up on whatever registry the
|
|
360
|
+
machine happens to be pointed at.
|
|
431
361
|
|
|
432
|
-
`
|
|
433
|
-
|
|
434
|
-
|
|
362
|
+
`skipFileCheck` and `allowSuspicious` are deliberately two switches. A missing `files`
|
|
363
|
+
array is a manifest convention some packages do not follow; tests or a lockfile in the
|
|
364
|
+
tarball is content nobody meant to ship. Neither touches the leak checks, which have no
|
|
365
|
+
off switch at all.
|
|
435
366
|
|
|
436
|
-
|
|
437
|
-
|
|
367
|
+
`noGitChecks` is what you need when you publish from a build directory, or from a checkout
|
|
368
|
+
that is not a git repository at all.
|
|
369
|
+
|
|
370
|
+
`devFields` refuses fields that npm or your consumers actually read, like `exports`, `bin`,
|
|
371
|
+
`engines` and the dependency maps, so a typo cannot quietly break your package.
|
|
372
|
+
|
|
373
|
+
`keepFields` answers the unrecognised-field report the other way: the field belongs in the
|
|
374
|
+
published package, stop mentioning it. A VS Code extension needs `contributes` and
|
|
375
|
+
`publisher` in the artifact to work, and no generic publishing tool is ever going to know
|
|
376
|
+
that.
|
|
438
377
|
|
|
439
378
|
## What it does not do
|
|
440
379
|
|
|
441
380
|
It isn't a release manager. It won't pick your version number, write a changelog, tag
|
|
442
|
-
anything, push a commit, create a GitHub release, or set up trusted publishing for you.
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
Pick a release manager and a validator to go with it. The next section covers which.
|
|
381
|
+
anything, push a commit, create a GitHub release, or set up trusted publishing for you. It
|
|
382
|
+
also doesn't check that your entry points resolve correctly for consumers. Pair it with a
|
|
383
|
+
release manager and a validator; the next section names them.
|
|
447
384
|
|
|
448
385
|
It can't publish a package that uses `bundleDependencies`. pnpm links dependencies rather
|
|
449
386
|
than copying them, so it has nothing to bundle and refuses:
|
|
@@ -454,9 +391,7 @@ Add "nodeLinker: hoisted" to pnpm-workspace.yaml or delete bundleDependencies
|
|
|
454
391
|
|
|
455
392
|
Doing what it says makes the package publishable again. This is the one thing you give up
|
|
456
393
|
by packing with pnpm, and it's a fair trade: `bundleDependencies` is rare, and the failure
|
|
457
|
-
is loud and tells you the fix.
|
|
458
|
-
neither bundles anything for a package inside a workspace, because the dependency hoists
|
|
459
|
-
to the workspace root where the package can't see it.
|
|
394
|
+
is loud and tells you the fix.
|
|
460
395
|
|
|
461
396
|
## How it compares
|
|
462
397
|
|