@lerna-lite/publish 0.3.0 → 0.3.3

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 CHANGED
@@ -1,415 +1,419 @@
1
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2
- [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)
3
- [![npm](https://img.shields.io/npm/v/@lerna-lite/publish.svg?color=forest)](https://www.npmjs.com/package/@lerna-lite/publish)
4
- [![npm](https://img.shields.io/npm/dy/@lerna-lite/publish?color=forest)](https://www.npmjs.com/package/@lerna-lite/publish)
5
- [![Actions Status](https://github.com/ghiscoding/lerna-lite/workflows/CI%20Build/badge.svg)](https://github.com/ghiscoding/lerna-lite/actions)
6
-
7
- # @lerna-lite/publish
8
- ## (`ws-roller publish`) Publish command
9
-
10
- Lerna-Lite Publish command, publish packages in the current project
11
-
12
- ### Internal Dependencies
13
- - [@lerna-lite/core](https://github.com/ghiscoding/lerna-lite/tree/main/packages/core)
14
- - [@lerna-lite/version](https://github.com/ghiscoding/lerna-lite/tree/main/packages/version)
15
-
16
- ---
17
-
18
- ## Installation
19
- ```sh
20
- # install globally
21
- npm install -g @lerna-lite/cli
22
- # then use it (see usage below)
23
- ws-roller publish
24
-
25
- # OR use npx
26
- npx ws-roller publish
27
- ```
28
-
29
- ## Usage
30
-
31
- ```sh
32
- ws-roller publish # publish packages that have changed since the last release
33
- ws-roller publish from-git # explicitly publish packages tagged in the current commit
34
- ws-roller publish from-package # explicitly publish packages where the latest version is not present in the registry
35
- ```
36
-
37
- When run, this command does one of the following things:
38
-
39
- - Publish packages updated since the last release (calling [`ws-roller version`](https://github.com/ghiscoding/lerna-lite/blob/main/packages/version/README.md) behind the scenes).
40
- - This is the legacy behavior of ws-roller 2.x
41
- - Publish packages tagged in the current commit (`from-git`).
42
- - Publish packages in the latest commit where the version is not present in the registry (`from-package`).
43
- - Publish an unversioned "canary" release of packages (and their dependents) updated in the previous commit.
44
-
45
- > ws-roller will never publish packages which are marked as private (`"private": true` in the `package.json`).
46
-
47
- During all publish operations, appropriate [lifecycle scripts](#lifecycle-scripts) are called in the root and per-package (unless disabled by [`--ignore-scripts](#--ignore-scripts)).
48
-
49
- Check out [Per-Package Configuration](#per-package-configuration) for more details about publishing scoped packages, custom registries, and custom dist-tags.
50
-
51
- ## Positionals
52
-
53
- ### bump `from-git`
54
-
55
- In addition to the semver keywords supported by [`ws-roller version`](https://github.com/ws-roller/ws-roller/tree/main/commands/version#positionals),
56
- `ws-roller publish` also supports the `from-git` keyword.
57
- This will identify packages tagged by `ws-roller version` and publish them to npm.
58
- This is useful in CI scenarios where you wish to manually increment versions,
59
- but have the package contents themselves consistently published by an automated process.
60
-
61
- ### bump `from-package`
62
-
63
- Similar to the `from-git` keyword except the list of packages to publish is determined by inspecting each `package.json`
64
- and determining if any package version is not present in the registry. Any versions not present in the registry will
65
- be published.
66
- This is useful when a previous `ws-roller publish` failed to publish all packages to the registry.
67
-
68
- ## Options
69
-
70
- `ws-roller publish` supports all of the options provided by [`ws-roller version`](https://github.com/ws-roller/ws-roller/tree/main/commands/version#options) in addition to the following:
71
-
72
- - [`--canary`](#--canary)
73
- - [`--contents <dir>`](#--contents-dir)
74
- - [`--dist-tag <tag>`](#--dist-tag-tag)
75
- - [`--force-publish`](#--force-publish)
76
- - [`--git-head <sha>`](#--git-head-sha)
77
- - [`--graph-type <all|dependencies>`](#--graph-type-alldependencies)
78
- - [`--ignore-scripts`](#--ignore-scripts)
79
- - [`--ignore-prepublish`](#--ignore-prepublish)
80
- - [`--legacy-auth`](#--legacy-auth)
81
- - [`--no-git-reset`](#--no-git-reset)
82
- - [`--no-granular-pathspec`](#--no-granular-pathspec)
83
- - [`--no-verify-access`](#--no-verify-access)
84
- - [`--otp`](#--otp)
85
- - [`--preid`](#--preid)
86
- - [`--pre-dist-tag <tag>`](#--pre-dist-tag-tag)
87
- - [`--registry <url>`](#--registry-url)
88
- - [`--tag-version-prefix`](#--tag-version-prefix)
89
- - [`--temp-tag`](#--temp-tag)
90
- - [`--yes`](#--yes)
91
-
92
- ### `--canary`
93
-
94
- ```sh
95
- ws-roller publish --canary
96
- # 1.0.0 => 1.0.1-alpha.0+${SHA} of packages changed since the previous commit
97
- # a subsequent canary publish will yield 1.0.1-alpha.1+${SHA}, etc
98
-
99
- ws-roller publish --canary --preid beta
100
- # 1.0.0 => 1.0.1-beta.0+${SHA}
101
-
102
- # The following are equivalent:
103
- ws-roller publish --canary minor
104
- ws-roller publish --canary preminor
105
- # 1.0.0 => 1.1.0-alpha.0+${SHA}
106
- ```
107
-
108
- When run with this flag, `ws-roller publish` publishes packages in a more granular way (per commit).
109
- Before publishing to npm, it creates the new `version` tag by taking the current `version`, bumping it to the next _minor_ version, adding the provided meta suffix (defaults to `alpha`) and appending the current git sha (ex: `1.0.0` becomes `1.1.0-alpha.0+81e3b443`).
110
-
111
- If you have publish canary releases from multiple active development branches in CI,
112
- it is recommended to customize the [`--preid`](#--preid) and [`--dist-tag <tag>`](#--dist-tag-tag) on a per-branch basis to avoid clashing versions.
113
-
114
- > The intended use case for this flag is a per commit level release or nightly release.
115
-
116
- ### `--contents <dir>`
117
-
118
- Subdirectory to publish. Must apply to ALL packages, and MUST contain a package.json file.
119
- Package lifecycles will still be run in the original leaf directory.
120
- You should probably use one of those lifecycles (`prepare`, `prepublishOnly`, or `prepack`) to _create_ the subdirectory and whatnot.
121
-
122
- If you're into unnecessarily complicated publishing, this will give you joy.
123
-
124
- ```sh
125
- ws-roller publish --contents dist
126
- # publish the "dist" subfolder of every ws-roller-managed leaf package
127
- ```
128
-
129
- **NOTE:** You should wait until the `postpublish` lifecycle phase (root or leaf) to clean up this generated subdirectory,
130
- as the generated package.json is used during package upload (_after_ `postpack`).
131
-
132
- ### `--dist-tag <tag>`
133
-
134
- ```sh
135
- ws-roller publish --dist-tag next
136
- ```
137
-
138
- When run with this flag, `ws-roller publish` will publish to npm with the given npm [dist-tag](https://docs.npmjs.com/cli/v8/commands/npm-dist-tag) (defaults to `latest`).
139
-
140
- This option can be used to publish a [`prerelease`](http://carrot.is/coding/npm_prerelease) or `beta` version under a non-`latest` dist-tag, helping consumers avoid automatically upgrading to prerelease-quality code.
141
-
142
- > Note: the `latest` tag is the one that is used when a user runs `npm install my-package`.
143
- > To install a different tag, a user can run `npm install my-package@prerelease`.
144
-
145
- ### `--force-publish`
146
-
147
- To be used with [`--canary`](#--canary) to publish a canary version of all packages in your monorepo. This flag can be helpful when you need to make canary releases of packages beyond what was changed in the most recent commit.
148
-
149
- ```
150
- ws-roller publish --canary --force-publish
151
-
152
- ### `--git-head <sha>`
153
-
154
- Explicit SHA to set as [`gitHead`](https://git.io/fh7np) on manifests when packing tarballs, only allowed with [`from-package`](#bump-from-package) positional.
155
-
156
- For example, when publishing from AWS CodeBuild (where `git` is not available),
157
- you could use this option to pass the appropriate [environment variable](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html) to use for this package metadata:
158
-
159
- ```sh
160
- ws-roller publish from-package --git-head ${CODEBUILD_RESOLVED_SOURCE_VERSION}
161
- ```
162
-
163
- Under all other circumstances, this value is derived from a local `git` command.
164
-
165
- ### `--graph-type <all|dependencies>`
166
-
167
- Set which kind of dependencies to use when building a package graph. The default value is `dependencies`, whereby only packages listed in the `dependencies` section of a package's `package.json` are included. Pass `all` to include both `dependencies` _and_ `devDependencies` when constructing the package graph and determining topological order.
168
-
169
- When using traditional peer + dev dependency pairs, this option should be configured to `all` so the peers are always published before their dependents.
170
-
171
- ```sh
172
- ws-roller publish --graph-type all
173
- ```
174
-
175
- Configured via `lerna.json`:
176
-
177
- ```json
178
- {
179
- "command": {
180
- "publish": {
181
- "graphType": "all"
182
- }
183
- }
184
- }
185
- ```
186
-
187
- ### `--ignore-scripts`
188
-
189
- When passed, this flag will disable running [lifecycle scripts](#lifecycle-scripts) during `ws-roller publish`.
190
-
191
- ### `--ignore-prepublish`
192
-
193
- When passed, this flag will disable running [deprecated](https://docs.npmjs.com/misc/scripts#prepublish-and-prepare) [`prepublish` scripts](#lifecycle-scripts) during `ws-roller publish`.
194
-
195
- ### `--legacy-auth`
196
-
197
- When publishing packages that require authentication but you are working with an internally hosted NPM Registry that only uses the legacy Base64 version of username:password. This is the same as the NPM publish `_auth` flag.
198
-
199
- ```sh
200
- ws-roller publish --legacy-auth aGk6bW9t
201
- ```
202
-
203
- ### `--no-git-reset`
204
-
205
- By default, `ws-roller publish` ensures any changes to the working tree have been reset.
206
-
207
- To avoid this, pass `--no-git-reset`. This can be especially useful when used as part of a CI pipeline in conjunction with the `--canary` flag. For instance, the `package.json` version numbers which have been bumped may need to be used in subsequent CI pipeline steps (such as Docker builds).
208
-
209
- ```sh
210
- ws-roller publish --no-git-reset
211
- ```
212
-
213
- ### `--no-granular-pathspec`
214
-
215
- By default, `ws-roller publish` will attempt (if enabled) to `git checkout` _only_ the leaf package manifests that are temporarily modified during the publishing process. This yields the equivalent of `git checkout -- packages/*/package.json`, but tailored to _exactly_ what changed.
216
-
217
- If you **know** you need different behavior, you'll understand: Pass `--no-granular-pathspec` to make the git command _literally_ `git checkout -- .`. By opting into this [pathspec](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec), you must have all intentionally unversioned content properly ignored.
218
-
219
- This option makes the most sense configured in `lerna.json`, as you really don't want to mess it up:
220
-
221
- ```json
222
- {
223
- "version": "independent",
224
- "granularPathspec": false
225
- }
226
- ```
227
-
228
- The root-level configuration is intentional, as this also covers the [identically-named option in `ws-roller version`](https://github.com/ws-roller/ws-roller/tree/main/commands/version#--no-granular-pathspec).
229
-
230
- ### `--no-verify-access`
231
-
232
- By default, `ws-roller` will verify the logged-in npm user's access to the packages about to be published. Passing this flag will disable that check.
233
-
234
- If you are using a third-party registry that does not support `npm access ls-packages`, you will need to pass this flag (or set `command.publish.verifyAccess` to `false` in `lerna.json`).
235
-
236
- > Please use with caution
237
-
238
- ### `--otp`
239
-
240
- When publishing packages that require two-factor authentication, you can specify a [one-time password](https://docs.npmjs.com/about-two-factor-authentication) using `--otp`:
241
-
242
- ```sh
243
- ws-roller publish --otp 123456
244
- ```
245
-
246
- > Please keep in mind that one-time passwords expire within 30 seconds of their generation. If it expires during publish operations, a prompt will request a refreshed value before continuing.
247
-
248
- ### `--preid`
249
-
250
- Unlike the `ws-roller version` option of the same name, this option only applies to [`--canary`](#--canary) version calculation.
251
-
252
- ```sh
253
- ws-roller publish --canary
254
- # uses the next semantic prerelease version, e.g.
255
- # 1.0.0 => 1.0.1-alpha.0
256
-
257
- ws-roller publish --canary --preid next
258
- # uses the next semantic prerelease version with a specific prerelease identifier, e.g.
259
- # 1.0.0 => 1.0.1-next.0
260
- ```
261
-
262
- When run with this flag, `ws-roller publish --canary` will increment `premajor`, `preminor`, `prepatch`, or `prerelease` semver
263
- bumps using the specified [prerelease identifier](http://semver.org/#spec-item-9).
264
-
265
- ### `--pre-dist-tag <tag>`
266
-
267
- ```sh
268
- ws-roller publish --pre-dist-tag next
269
- ```
270
-
271
- Works the same as [`--dist-tag`](#--dist-tag-tag), except only applies to packages being released with a prerelease version.
272
-
273
- ### `--registry <url>`
274
-
275
- When run with this flag, forwarded npm commands will use the specified registry for your package(s).
276
-
277
- This is useful if you do not want to explicitly set up your registry
278
- configuration in all of your package.json files individually when e.g. using
279
- private registries.
280
-
281
- ### `--tag-version-prefix`
282
-
283
- This option allows to provide custom prefix instead of the default one: `v`.
284
-
285
- Keep in mind, if splitting `ws-roller version` and `ws-roller publish`, you need to pass it to both commands:
286
-
287
- ```bash
288
- # locally
289
- ws-roller version --tag-version-prefix=''
290
-
291
- # on ci
292
- ws-roller publish from-git --tag-version-prefix=''
293
- ```
294
-
295
- You could also configure this at the root level of `lerna.json`, applying to both commands equally:
296
-
297
- ```json
298
- {
299
- "tagVersionPrefix": "",
300
- "packages": ["packages/*"],
301
- "version": "independent"
302
- }
303
- ```
304
-
305
- ### `--temp-tag`
306
-
307
- When passed, this flag will alter the default publish process by first publishing
308
- all changed packages to a temporary dist-tag (`ws-roller-temp`) and then moving the
309
- new version(s) to the dist-tag configured by [`--dist-tag`](#--dist-tag-tag) (default `latest`).
310
-
311
- This is not generally necessary, as ws-roller will publish packages in topological
312
- order (all dependencies before dependents) by default.
313
-
314
- ### `--yes`
315
-
316
- ```sh
317
- ws-roller publish --canary --yes
318
- # skips `Are you sure you want to publish the above changes?`
319
- ```
320
-
321
- When run with this flag, `ws-roller publish` will skip all confirmation prompts.
322
- Useful in [Continuous integration (CI)](https://en.wikipedia.org/wiki/Continuous_integration) to automatically answer the publish confirmation prompt.
323
-
324
- ## Per-Package Configuration
325
-
326
- A leaf package can be configured with special [`publishConfig`](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#publishconfig) that in _certain_ circumstances changes the behavior of `ws-roller publish`.
327
-
328
- ### `publishConfig.access`
329
-
330
- To publish packages with a scope (e.g., `@mycompany/rocks`), you must set [`access`](https://docs.npmjs.com/cli/v8/using-npm/config#access):
331
-
332
- ```json
333
- "publishConfig": {
334
- "access": "public"
335
- }
336
- ```
337
-
338
- - If this field is set for a package _without_ a scope, it **will** fail.
339
- - If you _want_ your scoped package to remain private (i.e., `"restricted"`), there is no need to set this value.
340
-
341
- Note that this is **not** the same as setting `"private": true` in a leaf package; if the `private` field is set, that package will _never_ be published under any circumstances.
342
-
343
- ### `publishConfig.registry`
344
-
345
- You can customize the registry on a per-package basis by setting [`registry`](https://docs.npmjs.com/cli/v8/using-npm/config#registry):
346
-
347
- ```json
348
- "publishConfig": {
349
- "registry": "http://my-awesome-registry.com/"
350
- }
351
- ```
352
-
353
- - Passing [`--registry`](#--registry-url) applies globally, and in some cases isn't what you want.
354
-
355
- ### `publishConfig.tag`
356
-
357
- You can customize the dist-tag on a per-package basis by setting [`tag`](https://docs.npmjs.com/cli/v8/using-npm/config#tag):
358
-
359
- ```json
360
- "publishConfig": {
361
- "tag": "flippin-sweet"
362
- }
363
- ```
364
-
365
- - Passing [`--dist-tag`](#--dist-tag-tag) will _overwrite_ this value.
366
- - This value is _always_ ignored when [`--canary`](#--canary) is passed.
367
-
368
- ### `publishConfig.directory`
369
-
370
- This _non-standard_ field allows you to customize the published subdirectory just like [`--contents`](#--contents-dir), but on a per-package basis. All other caveats of `--contents` still apply.
371
-
372
- ```json
373
- "publishConfig": {
374
- "directory": "dist"
375
- }
376
- ```
377
-
378
- <a id="lifecycle-events"><!-- back-compat with previous heading --></a>
379
-
380
- ## Lifecycle Scripts
381
-
382
- ```js
383
- // prepublish: Run BEFORE the package is packed and published.
384
- // prepare: Run BEFORE the package is packed and published, AFTER prepublish, BEFORE prepublishOnly.
385
- // prepublishOnly: Run BEFORE the package is packed and published, ONLY on npm publish.
386
- // prepack: Run BEFORE a tarball is packed.
387
- // postpack: Run AFTER the tarball has been generated and moved to its final destination.
388
- // publish: Run AFTER the package is published.
389
- // postpublish: Run AFTER the package is published.
390
- ```
391
-
392
- ws-roller will run [npm lifecycle scripts](https://docs.npmjs.com/cli/v8/using-npm/scripts#description) during `ws-roller publish` in the following order:
393
-
394
- 1. If versioning implicitly, run all [version lifecycle scripts](https://github.com/ws-roller/ws-roller/tree/main/commands/version#lifecycle-scripts)
395
- 2. Run `prepublish` lifecycle in root, if [enabled](#--ignore-prepublish)
396
- 3. Run `prepare` lifecycle in root
397
- 4. Run `prepublishOnly` lifecycle in root
398
- 5. Run `prepack` lifecycle in root
399
- 6. For each changed package, in topological order (all dependencies before dependents):
400
- 1. Run `prepublish` lifecycle, if [enabled](#--ignore-prepublish)
401
- 2. Run `prepare` lifecycle
402
- 3. Run `prepublishOnly` lifecycle
403
- 4. Run `prepack` lifecycle
404
- 5. Create package tarball in temp directory via [JS API](https://github.com/ghiscoding/lerna-lite/blob/main/packages/publish/src/lib/pack-directory.ts)
405
- 6. Run `postpack` lifecycle
406
- 7. Run `postpack` lifecycle in root
407
- 8. For each changed package, in topological order (all dependencies before dependents):
408
- 1. Publish package to configured [registry](#--registry-url) via [JS API](https://github.com/ghiscoding/lerna-lite/blob/main/packages/publish/src/lib/npm-publish.ts)
409
- 2. Run `publish` lifecycle
410
- 3. Run `postpublish` lifecycle
411
- 9. Run `publish` lifecycle in root
412
- - To avoid recursive calls, don't use this root lifecycle to run `ws-roller publish`
413
- 10. Run `postpublish` lifecycle in root
414
- 11. Update temporary dist-tag to latest, if [enabled](#--temp-tag)
415
-
1
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2
+ [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)
3
+ [![npm](https://img.shields.io/npm/v/@lerna-lite/publish.svg?color=forest)](https://www.npmjs.com/package/@lerna-lite/publish)
4
+ [![npm](https://img.shields.io/npm/dy/@lerna-lite/publish?color=forest)](https://www.npmjs.com/package/@lerna-lite/publish)
5
+ [![Actions Status](https://github.com/ghiscoding/lerna-lite/workflows/CI%20Build/badge.svg)](https://github.com/ghiscoding/lerna-lite/actions)
6
+
7
+ # @lerna-lite/publish
8
+ ## (`ws-roller publish`) Publish command 📰
9
+
10
+ Lerna-Lite Publish command, publish packages in the current project
11
+
12
+ ### Internal Dependencies
13
+ - [@lerna-lite/core](https://github.com/ghiscoding/lerna-lite/tree/main/packages/core)
14
+ - [@lerna-lite/version](https://github.com/ghiscoding/lerna-lite/tree/main/packages/version)
15
+
16
+ ---
17
+
18
+ ## Installation
19
+ ```sh
20
+ # install globally
21
+ npm install -g @lerna-lite/cli
22
+ # then use it (see usage below)
23
+ ws-roller publish
24
+
25
+ # OR use npx
26
+ npx ws-roller publish
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ```sh
32
+ ws-roller publish # publish packages that have changed since the last release
33
+ ws-roller publish from-git # explicitly publish packages tagged in the current commit
34
+ ws-roller publish from-package # explicitly publish packages where the latest version is not present in the registry
35
+ ```
36
+
37
+ When run, this command does one of the following things:
38
+
39
+ - Publish packages updated since the last release (calling [`ws-roller version`](https://github.com/ghiscoding/lerna-lite/blob/main/packages/version/README.md) behind the scenes).
40
+ - This is the legacy behavior of ws-roller 2.x
41
+ - Publish packages tagged in the current commit (`from-git`).
42
+ - Publish packages in the latest commit where the version is not present in the registry (`from-package`).
43
+ - Publish an unversioned "canary" release of packages (and their dependents) updated in the previous commit.
44
+
45
+ > ws-roller will never publish packages which are marked as private (`"private": true` in the `package.json`).
46
+
47
+ During all publish operations, appropriate [lifecycle scripts](#lifecycle-scripts) are called in the root and per-package (unless disabled by [`--ignore-scripts](#--ignore-scripts)).
48
+
49
+ Check out [Per-Package Configuration](#per-package-configuration) for more details about publishing scoped packages, custom registries, and custom dist-tags.
50
+
51
+ ## Positionals
52
+
53
+ ### semver `--bump from-git`
54
+
55
+ In addition to the semver keywords supported by [`ws-roller version`](https://github.com/ws-roller/ws-roller/tree/main/commands/version#positionals),
56
+ `ws-roller publish` also supports the `from-git` keyword.
57
+ This will identify packages tagged by `ws-roller version` and publish them to npm.
58
+ This is useful in CI scenarios where you wish to manually increment versions,
59
+ but have the package contents themselves consistently published by an automated process.
60
+
61
+ ### semver `--bump from-package`
62
+
63
+ Similar to the `from-git` keyword except the list of packages to publish is determined by inspecting each `package.json`
64
+ and determining if any package version is not present in the registry. Any versions not present in the registry will
65
+ be published.
66
+ This is useful when a previous `ws-roller publish` failed to publish all packages to the registry.
67
+
68
+ ## Options
69
+
70
+ `ws-roller publish` supports all of the options provided by [`ws-roller version`](https://github.com/ws-roller/ws-roller/tree/main/commands/version#options) in addition to the following:
71
+ - [`@ws-roller/publish`](#ws-rollerpublish)
72
+ - [Positionals](#positionals)
73
+ - [semver `--bump from-git`](#semver--bump-from-git)
74
+ - [semver `--bump from-package`](#semver--bump-from-package)
75
+ - [Options](#options)
76
+ - [`--canary`](#--canary)
77
+ - [`--contents <dir>`](#--contents-dir)
78
+ - [`--dist-tag <tag>`](#--dist-tag-tag)
79
+ - [`--force-publish`](#--force-publish)
80
+ - [`--git-head <sha>`](#--git-head-sha)
81
+ - [`--graph-type <all|dependencies>`](#--graph-type-alldependencies)
82
+ - [`--ignore-scripts`](#--ignore-scripts)
83
+ - [`--ignore-prepublish`](#--ignore-prepublish)
84
+ - [`--legacy-auth`](#--legacy-auth)
85
+ - [`--no-git-reset`](#--no-git-reset)
86
+ - [`--no-granular-pathspec`](#--no-granular-pathspec)
87
+ - [`--no-verify-access`](#--no-verify-access)
88
+ - [`--otp`](#--otp)
89
+ - [`--preid`](#--preid)
90
+ - [`--pre-dist-tag <tag>`](#--pre-dist-tag-tag)
91
+ - [`--registry <url>`](#--registry-url)
92
+ - [`--tag-version-prefix`](#--tag-version-prefix)
93
+ - [`--temp-tag`](#--temp-tag)
94
+ - [`--yes`](#--yes)
95
+
96
+ ### `--canary`
97
+
98
+ ```sh
99
+ ws-roller publish --canary
100
+ # 1.0.0 => 1.0.1-alpha.0+${SHA} of packages changed since the previous commit
101
+ # a subsequent canary publish will yield 1.0.1-alpha.1+${SHA}, etc
102
+
103
+ ws-roller publish --canary --preid beta
104
+ # 1.0.0 => 1.0.1-beta.0+${SHA}
105
+
106
+ # The following are equivalent:
107
+ ws-roller publish --canary minor
108
+ ws-roller publish --canary preminor
109
+ # 1.0.0 => 1.1.0-alpha.0+${SHA}
110
+ ```
111
+
112
+ When run with this flag, `ws-roller publish` publishes packages in a more granular way (per commit).
113
+ Before publishing to npm, it creates the new `version` tag by taking the current `version`, bumping it to the next _minor_ version, adding the provided meta suffix (defaults to `alpha`) and appending the current git sha (ex: `1.0.0` becomes `1.1.0-alpha.0+81e3b443`).
114
+
115
+ If you have publish canary releases from multiple active development branches in CI,
116
+ it is recommended to customize the [`--preid`](#--preid) and [`--dist-tag <tag>`](#--dist-tag-tag) on a per-branch basis to avoid clashing versions.
117
+
118
+ > The intended use case for this flag is a per commit level release or nightly release.
119
+
120
+ ### `--contents <dir>`
121
+
122
+ Subdirectory to publish. Must apply to ALL packages, and MUST contain a package.json file.
123
+ Package lifecycles will still be run in the original leaf directory.
124
+ You should probably use one of those lifecycles (`prepare`, `prepublishOnly`, or `prepack`) to _create_ the subdirectory and whatnot.
125
+
126
+ If you're into unnecessarily complicated publishing, this will give you joy.
127
+
128
+ ```sh
129
+ ws-roller publish --contents dist
130
+ # publish the "dist" subfolder of every ws-roller-managed leaf package
131
+ ```
132
+
133
+ **NOTE:** You should wait until the `postpublish` lifecycle phase (root or leaf) to clean up this generated subdirectory,
134
+ as the generated package.json is used during package upload (_after_ `postpack`).
135
+
136
+ ### `--dist-tag <tag>`
137
+
138
+ ```sh
139
+ ws-roller publish --dist-tag next
140
+ ```
141
+
142
+ When run with this flag, `ws-roller publish` will publish to npm with the given npm [dist-tag](https://docs.npmjs.com/cli/v8/commands/npm-dist-tag) (defaults to `latest`).
143
+
144
+ This option can be used to publish a [`prerelease`](http://carrot.is/coding/npm_prerelease) or `beta` version under a non-`latest` dist-tag, helping consumers avoid automatically upgrading to prerelease-quality code.
145
+
146
+ > Note: the `latest` tag is the one that is used when a user runs `npm install my-package`.
147
+ > To install a different tag, a user can run `npm install my-package@prerelease`.
148
+
149
+ ### `--force-publish`
150
+
151
+ To be used with [`--canary`](#--canary) to publish a canary version of all packages in your monorepo. This flag can be helpful when you need to make canary releases of packages beyond what was changed in the most recent commit.
152
+
153
+ ```
154
+ ws-roller publish --canary --force-publish
155
+
156
+ ### `--git-head <sha>`
157
+
158
+ Explicit SHA to set as [`gitHead`](https://git.io/fh7np) on manifests when packing tarballs, only allowed with [`from-package`](#bump-from-package) positional.
159
+
160
+ For example, when publishing from AWS CodeBuild (where `git` is not available),
161
+ you could use this option to pass the appropriate [environment variable](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html) to use for this package metadata:
162
+
163
+ ```sh
164
+ ws-roller publish from-package --git-head ${CODEBUILD_RESOLVED_SOURCE_VERSION}
165
+ ```
166
+
167
+ Under all other circumstances, this value is derived from a local `git` command.
168
+
169
+ ### `--graph-type <all|dependencies>`
170
+
171
+ Set which kind of dependencies to use when building a package graph. The default value is `dependencies`, whereby only packages listed in the `dependencies` section of a package's `package.json` are included. Pass `all` to include both `dependencies` _and_ `devDependencies` when constructing the package graph and determining topological order.
172
+
173
+ When using traditional peer + dev dependency pairs, this option should be configured to `all` so the peers are always published before their dependents.
174
+
175
+ ```sh
176
+ ws-roller publish --graph-type all
177
+ ```
178
+
179
+ Configured via `lerna.json`:
180
+
181
+ ```json
182
+ {
183
+ "command": {
184
+ "publish": {
185
+ "graphType": "all"
186
+ }
187
+ }
188
+ }
189
+ ```
190
+
191
+ ### `--ignore-scripts`
192
+
193
+ When passed, this flag will disable running [lifecycle scripts](#lifecycle-scripts) during `ws-roller publish`.
194
+
195
+ ### `--ignore-prepublish`
196
+
197
+ When passed, this flag will disable running [deprecated](https://docs.npmjs.com/misc/scripts#prepublish-and-prepare) [`prepublish` scripts](#lifecycle-scripts) during `ws-roller publish`.
198
+
199
+ ### `--legacy-auth`
200
+
201
+ When publishing packages that require authentication but you are working with an internally hosted NPM Registry that only uses the legacy Base64 version of username:password. This is the same as the NPM publish `_auth` flag.
202
+
203
+ ```sh
204
+ ws-roller publish --legacy-auth aGk6bW9t
205
+ ```
206
+
207
+ ### `--no-git-reset`
208
+
209
+ By default, `ws-roller publish` ensures any changes to the working tree have been reset.
210
+
211
+ To avoid this, pass `--no-git-reset`. This can be especially useful when used as part of a CI pipeline in conjunction with the `--canary` flag. For instance, the `package.json` version numbers which have been bumped may need to be used in subsequent CI pipeline steps (such as Docker builds).
212
+
213
+ ```sh
214
+ ws-roller publish --no-git-reset
215
+ ```
216
+
217
+ ### `--no-granular-pathspec`
218
+
219
+ By default, `ws-roller publish` will attempt (if enabled) to `git checkout` _only_ the leaf package manifests that are temporarily modified during the publishing process. This yields the equivalent of `git checkout -- packages/*/package.json`, but tailored to _exactly_ what changed.
220
+
221
+ If you **know** you need different behavior, you'll understand: Pass `--no-granular-pathspec` to make the git command _literally_ `git checkout -- .`. By opting into this [pathspec](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec), you must have all intentionally unversioned content properly ignored.
222
+
223
+ This option makes the most sense configured in `lerna.json`, as you really don't want to mess it up:
224
+
225
+ ```json
226
+ {
227
+ "version": "independent",
228
+ "granularPathspec": false
229
+ }
230
+ ```
231
+
232
+ The root-level configuration is intentional, as this also covers the [identically-named option in `ws-roller version`](https://github.com/ws-roller/ws-roller/tree/main/commands/version#--no-granular-pathspec).
233
+
234
+ ### `--no-verify-access`
235
+
236
+ By default, `ws-roller` will verify the logged-in npm user's access to the packages about to be published. Passing this flag will disable that check.
237
+
238
+ If you are using a third-party registry that does not support `npm access ls-packages`, you will need to pass this flag (or set `command.publish.verifyAccess` to `false` in `lerna.json`).
239
+
240
+ > Please use with caution
241
+
242
+ ### `--otp`
243
+
244
+ When publishing packages that require two-factor authentication, you can specify a [one-time password](https://docs.npmjs.com/about-two-factor-authentication) using `--otp`:
245
+
246
+ ```sh
247
+ ws-roller publish --otp 123456
248
+ ```
249
+
250
+ > Please keep in mind that one-time passwords expire within 30 seconds of their generation. If it expires during publish operations, a prompt will request a refreshed value before continuing.
251
+
252
+ ### `--preid`
253
+
254
+ Unlike the `ws-roller version` option of the same name, this option only applies to [`--canary`](#--canary) version calculation.
255
+
256
+ ```sh
257
+ ws-roller publish --canary
258
+ # uses the next semantic prerelease version, e.g.
259
+ # 1.0.0 => 1.0.1-alpha.0
260
+
261
+ ws-roller publish --canary --preid next
262
+ # uses the next semantic prerelease version with a specific prerelease identifier, e.g.
263
+ # 1.0.0 => 1.0.1-next.0
264
+ ```
265
+
266
+ When run with this flag, `ws-roller publish --canary` will increment `premajor`, `preminor`, `prepatch`, or `prerelease` semver
267
+ bumps using the specified [prerelease identifier](http://semver.org/#spec-item-9).
268
+
269
+ ### `--pre-dist-tag <tag>`
270
+
271
+ ```sh
272
+ ws-roller publish --pre-dist-tag next
273
+ ```
274
+
275
+ Works the same as [`--dist-tag`](#--dist-tag-tag), except only applies to packages being released with a prerelease version.
276
+
277
+ ### `--registry <url>`
278
+
279
+ When run with this flag, forwarded npm commands will use the specified registry for your package(s).
280
+
281
+ This is useful if you do not want to explicitly set up your registry
282
+ configuration in all of your package.json files individually when e.g. using
283
+ private registries.
284
+
285
+ ### `--tag-version-prefix`
286
+
287
+ This option allows to provide custom prefix instead of the default one: `v`.
288
+
289
+ Keep in mind, if splitting `ws-roller version` and `ws-roller publish`, you need to pass it to both commands:
290
+
291
+ ```bash
292
+ # locally
293
+ ws-roller version --tag-version-prefix=''
294
+
295
+ # on ci
296
+ ws-roller publish from-git --tag-version-prefix=''
297
+ ```
298
+
299
+ You could also configure this at the root level of `lerna.json`, applying to both commands equally:
300
+
301
+ ```json
302
+ {
303
+ "tagVersionPrefix": "",
304
+ "packages": ["packages/*"],
305
+ "version": "independent"
306
+ }
307
+ ```
308
+
309
+ ### `--temp-tag`
310
+
311
+ When passed, this flag will alter the default publish process by first publishing
312
+ all changed packages to a temporary dist-tag (`ws-roller-temp`) and then moving the
313
+ new version(s) to the dist-tag configured by [`--dist-tag`](#--dist-tag-tag) (default `latest`).
314
+
315
+ This is not generally necessary, as ws-roller will publish packages in topological
316
+ order (all dependencies before dependents) by default.
317
+
318
+ ### `--yes`
319
+
320
+ ```sh
321
+ ws-roller publish --canary --yes
322
+ # skips `Are you sure you want to publish the above changes?`
323
+ ```
324
+
325
+ When run with this flag, `ws-roller publish` will skip all confirmation prompts.
326
+ Useful in [Continuous integration (CI)](https://en.wikipedia.org/wiki/Continuous_integration) to automatically answer the publish confirmation prompt.
327
+
328
+ ## Per-Package Configuration
329
+
330
+ A leaf package can be configured with special [`publishConfig`](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#publishconfig) that in _certain_ circumstances changes the behavior of `ws-roller publish`.
331
+
332
+ ### `publishConfig.access`
333
+
334
+ To publish packages with a scope (e.g., `@mycompany/rocks`), you must set [`access`](https://docs.npmjs.com/cli/v8/using-npm/config#access):
335
+
336
+ ```json
337
+ "publishConfig": {
338
+ "access": "public"
339
+ }
340
+ ```
341
+
342
+ - If this field is set for a package _without_ a scope, it **will** fail.
343
+ - If you _want_ your scoped package to remain private (i.e., `"restricted"`), there is no need to set this value.
344
+
345
+ Note that this is **not** the same as setting `"private": true` in a leaf package; if the `private` field is set, that package will _never_ be published under any circumstances.
346
+
347
+ ### `publishConfig.registry`
348
+
349
+ You can customize the registry on a per-package basis by setting [`registry`](https://docs.npmjs.com/cli/v8/using-npm/config#registry):
350
+
351
+ ```json
352
+ "publishConfig": {
353
+ "registry": "http://my-awesome-registry.com/"
354
+ }
355
+ ```
356
+
357
+ - Passing [`--registry`](#--registry-url) applies globally, and in some cases isn't what you want.
358
+
359
+ ### `publishConfig.tag`
360
+
361
+ You can customize the dist-tag on a per-package basis by setting [`tag`](https://docs.npmjs.com/cli/v8/using-npm/config#tag):
362
+
363
+ ```json
364
+ "publishConfig": {
365
+ "tag": "flippin-sweet"
366
+ }
367
+ ```
368
+
369
+ - Passing [`--dist-tag`](#--dist-tag-tag) will _overwrite_ this value.
370
+ - This value is _always_ ignored when [`--canary`](#--canary) is passed.
371
+
372
+ ### `publishConfig.directory`
373
+
374
+ This _non-standard_ field allows you to customize the published subdirectory just like [`--contents`](#--contents-dir), but on a per-package basis. All other caveats of `--contents` still apply.
375
+
376
+ ```json
377
+ "publishConfig": {
378
+ "directory": "dist"
379
+ }
380
+ ```
381
+
382
+ <a id="lifecycle-events"><!-- back-compat with previous heading --></a>
383
+
384
+ ## Lifecycle Scripts
385
+
386
+ ```js
387
+ // prepublish: Run BEFORE the package is packed and published.
388
+ // prepare: Run BEFORE the package is packed and published, AFTER prepublish, BEFORE prepublishOnly.
389
+ // prepublishOnly: Run BEFORE the package is packed and published, ONLY on npm publish.
390
+ // prepack: Run BEFORE a tarball is packed.
391
+ // postpack: Run AFTER the tarball has been generated and moved to its final destination.
392
+ // publish: Run AFTER the package is published.
393
+ // postpublish: Run AFTER the package is published.
394
+ ```
395
+
396
+ ws-roller will run [npm lifecycle scripts](https://docs.npmjs.com/cli/v8/using-npm/scripts#description) during `ws-roller publish` in the following order:
397
+
398
+ 1. If versioning implicitly, run all [version lifecycle scripts](https://github.com/ws-roller/ws-roller/tree/main/commands/version#lifecycle-scripts)
399
+ 2. Run `prepublish` lifecycle in root, if [enabled](#--ignore-prepublish)
400
+ 3. Run `prepare` lifecycle in root
401
+ 4. Run `prepublishOnly` lifecycle in root
402
+ 5. Run `prepack` lifecycle in root
403
+ 6. For each changed package, in topological order (all dependencies before dependents):
404
+ 1. Run `prepublish` lifecycle, if [enabled](#--ignore-prepublish)
405
+ 2. Run `prepare` lifecycle
406
+ 3. Run `prepublishOnly` lifecycle
407
+ 4. Run `prepack` lifecycle
408
+ 5. Create package tarball in temp directory via [JS API](https://github.com/ghiscoding/lerna-lite/blob/main/packages/publish/src/lib/pack-directory.ts)
409
+ 6. Run `postpack` lifecycle
410
+ 7. Run `postpack` lifecycle in root
411
+ 8. For each changed package, in topological order (all dependencies before dependents):
412
+ 1. Publish package to configured [registry](#--registry-url) via [JS API](https://github.com/ghiscoding/lerna-lite/blob/main/packages/publish/src/lib/npm-publish.ts)
413
+ 2. Run `publish` lifecycle
414
+ 3. Run `postpublish` lifecycle
415
+ 9. Run `publish` lifecycle in root
416
+ - To avoid recursive calls, don't use this root lifecycle to run `ws-roller publish`
417
+ 10. Run `postpublish` lifecycle in root
418
+ 11. Update temporary dist-tag to latest, if [enabled](#--temp-tag)
419
+