@anolilab/multi-semantic-release 1.0.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 ADDED
@@ -0,0 +1,410 @@
1
+ <div align="center">
2
+
3
+ <img src=".github/logo.svg" alt="Logo" width="200">
4
+
5
+ <h1>Multi Semantic Release</h1>
6
+
7
+ hacky [semantic-release](https://github.com/semantic-release/semantic-release) for monorepos based on [qiwi/multi-semantic-release](https://github.com/qiwi/multi-semantic-release)
8
+
9
+ [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
10
+
11
+ </div>
12
+
13
+ ---
14
+
15
+ <div align="center">
16
+ <p>
17
+ <sup>
18
+ Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
19
+ </sup>
20
+ </p>
21
+ </div>
22
+
23
+ ---
24
+
25
+ This fork of [dhoub/multi-semantic-release](https://github.com/dhoulb/multi-semantic-release) replaces [`setImmediate` loops](https://github.com/dhoulb/multi-semantic-release/blob/561a8e66133d422d88008c32c479d1148876aba4/lib/wait.js#L13)
26
+ and [`execa.sync` hooks](https://github.com/dhoulb/multi-semantic-release/blob/561a8e66133d422d88008c32c479d1148876aba4/lib/execaHook.js#L5) with event-driven flow and finally makes possible to run the most release operations in parallel.
27
+ ๐ŸŽ‰ ๐ŸŽ‰ ๐ŸŽ‰
28
+
29
+ This package should work well, but **may not be fundamentally stable enough** for important production use as
30
+ it's pretty dependent on how semantic-release works (so it may break or get out-of-date in future versions
31
+ of semantic-release).
32
+
33
+ One of the best things about semantic-release is forgetting about version numbers. In a monorepo though there's still
34
+ a lot of version number management required for local deps (packages in the same monorepo referenced in `dependencies`
35
+ or `devDependencies` or `peerDependencies`). However in multi-semantic-release the version numbers of local deps are
36
+ written into `package.json` at release time. This means there's no need to hard-code versions any more
37
+ (we recommend just using `*` asterisk instead in your repo code).
38
+
39
+ ### Key features
40
+
41
+ - CLI & JS API
42
+ - Automated & configurable cross-pkg version bumping
43
+ - Provides alpha & beta-branched release flow
44
+ - Supports npm (v7+), yarn, pnpm, bolt-based monorepos
45
+ - Optional packages ignoring
46
+ - Linux/MacOs/Windows support
47
+
48
+ ## Install
49
+
50
+ ```bash
51
+ npm install --save-dev @anolilab/multi-semantic-release@latest semantic-release@latest
52
+ ```
53
+
54
+ ```sh
55
+ pnpm add -D @anolilab/multi-semantic-release@latest semantic-release@latest
56
+ ```
57
+
58
+ ```sh
59
+ yarn add -D @anolilab/multi-semantic-release@latest semantic-release@latest
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ```sh
65
+ multi-semantic-release
66
+ ```
67
+
68
+ ## Requirements
69
+
70
+ - Node.js >= 20.6.1
71
+ - [git-notes enabled](https://github.com/semantic-release/semantic-release/blob/2e4b901c4f412980a425469fae49cfaef500d47a/docs/support/troubleshooting.md#release-not-found-release-branch-after-git-push---force)
72
+
73
+ ### yarn / npm (v7+)
74
+
75
+ Make sure to have a `workspaces` attribute inside your `package.json` project file. In there, you can set a list of packages that you might want to process in the msr process, as well as ignore others. For example, let's say your project has 4 packages (i.e. a, b, c and d) and you want to process only a and d (ignore b and c). You can set the following structure in your `package.json` file:
76
+
77
+ ```json
78
+ {
79
+ "name": "msr-test-yarn",
80
+ "author": "Dave Houlbrooke <dave@shax.com",
81
+ "version": "0.0.0-semantically-released",
82
+ "private": true,
83
+ "license": "0BSD",
84
+ "engines": {
85
+ "node": ">=8.3"
86
+ },
87
+ "workspaces": ["packages/*", "!packages/b/**", "!packages/c/**"],
88
+ "release": {
89
+ "plugins": ["@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator"],
90
+ "noCi": true
91
+ }
92
+ }
93
+ ```
94
+
95
+ ### pnpm
96
+
97
+ Make sure to have a `packages` attribute inside your `pnpm-workspace.yaml` in the root of your project.
98
+
99
+ > Note: You need to have the `"workspaces": ["packages/*"]` attribute inside your `package.json` project file as well, need from semantic-release.
100
+
101
+ In there, you can set a list of packages that you might want to process in the msr process, as well as ignore others.
102
+ For example, let's say your project has 4 packages (i.e. a, b, c and d) and you want to process only a and d (ignore b and c). You can set the following structure in your `pnpm-workspace.yaml` file:
103
+
104
+ ```yaml
105
+ packages:
106
+ - "packages/**"
107
+ - "!packages/b/**"
108
+ - "!packages/c/**"
109
+ ```
110
+
111
+ ### bolt
112
+
113
+ Make sure to have a `bolt.workspaces` attribute inside your `package.json` project file.
114
+ In there, you can set a list of packages that you might want to process in the msr process, as well as ignore others.
115
+ For example, let's say your project has 4 packages (i.e. a, b, c and d) and you want to process only a and d (ignore b and c). You can set the following structure in your `package.json` file:
116
+
117
+ ```json
118
+ {
119
+ "name": "msr-test-bolt",
120
+ "author": "Dave Houlbrooke <dave@shax.com",
121
+ "version": "0.0.0-semantically-released",
122
+ "private": true,
123
+ "license": "0BSD",
124
+ "engines": {
125
+ "node": ">=8.3"
126
+ },
127
+ "bolt": {
128
+ "workspaces": ["packages/*", "!packages/b/**", "!packages/c/**"]
129
+ },
130
+ "release": {
131
+ "plugins": ["@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator"],
132
+ "noCi": true
133
+ }
134
+ }
135
+ ```
136
+
137
+ ## Configuring Multi-Semantic-Release
138
+
139
+ multi-semantic-release can be configured a number of ways:
140
+
141
+ - A `.multi-releaserc` file, written in YAML or JSON, with optional extensions: `.yaml`/ `.yml`/ `.json`/ `.js`
142
+ - A `multi-release.config.js` file that exports an object
143
+ - A `multi-release` key in the workspace root package.json
144
+
145
+ Alternatively some options may be set via CLI flags.
146
+
147
+ **Note:** CLI arguments take precedence over options configured in the configuration file.
148
+
149
+ ### Options
150
+
151
+ | Option | Type | CLI Flag | Description |
152
+ | ----------------- | ----------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
153
+ | dryRun | `boolean` | `--dry-run` | Dry run mode. |
154
+ | logLevel | `String` | `--log-level` | Sets the internal logger verbosity level: `error, warn, info, debug, trace`. Defaults to `info`. |
155
+ | debug | `boolean` | `--debug` | Output debugging information. Shortcut for `--logLevel=debug`. |
156
+ | silent | `boolean` | `--silent` | Turns off any log outputs. |
157
+ | extends | `String \| Array` | N/A | List of modules or file paths containing a shareable configuration. If multiple shareable configurations are set, they will be imported in the order defined with each configuration option taking precedence over the options defined in the previous. |
158
+ | sequentialInit | `boolean` | `--sequential-init` | Avoid hypothetical concurrent initialization collisions. |
159
+ | sequentialPrepare | `boolean` | `--sequential-prepare` | Avoid hypothetical concurrent preparation collisions. **True by default.** |
160
+ | firstParent | `boolean` | `--first-parent` | Apply commit filtering to current branch only. |
161
+ | ignorePrivate | `boolean` | `--ignore-private` | Exclude private packages. **True by default.** |
162
+ | ignorePackages | `String \| Array` | `--ignore-packages` | Packages list to be ignored on bumping process (appended to the ones that already exist at package.json workspaces). If using the CLI flag, supply a comma seperated list of strings. |
163
+ | tagFormat | `String` | `--tag-format` | Format to use when creating tag names. Should include "name" and "version" vars. Default: `"${name}@${version}"` which generates "package-name@1.0.0" |
164
+ | deps | `Object` | N/A | Dependency handling, see below for possible values. |
165
+
166
+ ### `deps` Options
167
+
168
+ | Option | Type | CLI Flag | Description |
169
+ | ------- | ------------------------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
170
+ | bump | `override \| satisfy \| inherit` | `--deps.bump` | Define deps version update rule. <ul><li>`override` โ€” replace any prev version with the next one</li><li>`satisfy` โ€” check the next pkg version against its current references. If it matches (`*` matches to any, `1.1.0` matches `1.1.x`, `1.5.0` matches to `^1.0.0` and so on) release will not be triggered, if not `override` strategy will be applied instead; `inherit` will try to follow the current declaration version/range. `~1.0.0` + `minor` turns into `~1.1.0`, `1.x` + `major` gives `2.x`, but `1.x` + `minor` gives `1.x` so there will be no release, etc. +;</li><li>`ignore` prevent dependencies from being bumped by MSR</li></ul> |
171
+ | release | `patch \| minor \| major \| inherit` | `--deps.release` | Define release type for dependent package if any of its deps changes. <ul><li>`patch`, `minor`, `major` โ€” strictly declare the release type that occurs when any dependency is updated;</li><li> `inherit` โ€” applies the "highest" release of updated deps to the package. <br/> _For example, if any dep has a breaking change, `major` release will be applied to the all dependants up the chain._</li></ul> |
172
+ | prefix | `'^' \| '~' \| ''` | `--deps.prefix` | Optional prefix to be attached to the next version if `bump` is set to `override`. Supported values: `^` \| `~` \| `''` (empty string) ; **`''` by default**. |
173
+
174
+ ### Examples
175
+
176
+ - Via multi-release key in the project's package.json file:
177
+
178
+ ```json
179
+ {
180
+ "multi-release": {
181
+ "ignorePackages": ["!packages/b/**", "!packages/c/**"],
182
+ "deps": {
183
+ "bump": "inherit"
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ - Via `.multi-releaserc` file:
190
+
191
+ ```json
192
+ {
193
+ "ignorePackages": ["!packages/b/**", "!packages/c/**"],
194
+ "deps": {
195
+ "bump": "inherit"
196
+ }
197
+ }
198
+ ```
199
+
200
+ - Via CLI:
201
+
202
+ ```sh
203
+ $ multi-semantic-release --ignore-packages=packages/a/**,packages/b/** --deps.bump=inherit
204
+ ```
205
+
206
+ ## Configuring Semantic-Release
207
+
208
+ **MSR** requires **semrel** config to be added [in any supported format](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration) for each package or/and declared in repo root (`globalConfig` is extremely useful if all the modules have the same strategy of release).
209
+ NOTE config resolver joins `globalConfig` and `packageConfig` during execution.
210
+
211
+ ```javascript
212
+ // Load the package-specific options.
213
+ const { options: pkgOptions } = await getConfig(dir);
214
+
215
+ // The 'final options' are the global options merged with package-specific options.
216
+ // We merge this ourselves because package-specific options can override global options.
217
+ const finalOptions = Object.assign({}, globalOptions, pkgOptions);
218
+ ```
219
+
220
+ Make sure to have a `workspaces` attribute inside your `package.json` project file. In there, you can set a list of packages that you might want to process in the msr process, as well as ignore others. For example, let's say your project has 4 packages (i.e. a, b, c and d) and you want to process only a and d (ignore b and c). You can set the following structure in your `package.json` file:
221
+
222
+ ```json
223
+ {
224
+ "name": "msr-__tests__-yarn",
225
+ "author": "Dave Houlbrooke <dave@shax.com",
226
+ "version": "0.0.0-semantically-released",
227
+ "private": true,
228
+ "license": "0BSD",
229
+ "engines": {
230
+ "node": ">=8.3"
231
+ },
232
+ "workspaces": ["packages/*", "!packages/b/**", "!packages/c/**"],
233
+ "release": {
234
+ "plugins": ["@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator"],
235
+ "noCi": true
236
+ }
237
+ }
238
+ ```
239
+
240
+ You can also ignore it with the CLI:
241
+
242
+ ```bash
243
+ $ multi-semantic-release --ignore-packages=packages/b/**,packages/c/**
244
+ ```
245
+
246
+ You can also combine the CLI ignore options with the `!` operator at each package inside `workspaces` attribute. Even though you can use the CLI to ignore options, you can't use it to set which packages to be released โ€“ i.e. you still need to set the `workspaces` attribute inside the `package.json`.
247
+
248
+ ## Verified usage examples
249
+
250
+ We use this tool to release our JS platform code inhouse (GitHub Enterprise + JB TeamCity) and for our OSS (GitHub + Travis CI). Guaranteed working configurations available in projects.
251
+
252
+ - [qiwi/substrate](https://github.com/qiwi/substrate)
253
+ - [qiwi/json-rpc](https://github.com/qiwi/json-rpc)
254
+ - [qiwi/lint-config-qiwi](https://github.com/qiwi/lint-config-qiwi)
255
+
256
+ ## Troubleshooting
257
+
258
+ ### npm v8.5+: npm ERR! notarget No matching version found for...
259
+
260
+ When releasing a monorepo you may get a `npm ERR! code ETARGET` error. This is caused by `npm version` creating a reify update on packages with future dependency versions MSR has not updated yet.
261
+
262
+ The simplest work around is to set [workspaces-update](https://docs.npmjs.com/cli/v8/commands/npm-version#workspaces-update) to false either in your .npmrc or manually by running `npm config set workspaces-update false`
263
+
264
+ ### npm: invalid npm token
265
+
266
+ When releasing a monorepos you may get `EINVALIDNPMTOKEN` error. The more packages, the more chance of error, unfortunately.
267
+
268
+ ```shell
269
+ INVALIDNPMTOKEN Invalid npm token.
270
+ The npm token (https://github.com/semantic-release/npm/blob/master/README.md#npm-registry-authentication) configured in the NPM_TOKEN environment variable must be a valid token (https://docs.npmjs.com/getting-started/working_with_tokens) allowing to publish to the registry https://registry.npmjs.org/.
271
+ ```
272
+
273
+ Do not rush to change your token. _Perhaps_ this is related to [`npm whoami` request](https://github.com/semantic-release/npm/blob/master/lib/verify-auth.js#L21) throttling on your registry (just a hypothesis: https://github.com/semantic-release/npm/pull/416). At this point you can:
274
+
275
+ - Rerun your build as many times as necessary. You may get lucky in a new attempt.
276
+ - Use [semrel-extra/npm plugin](https://github.com/semrel-extra/npm) for npm publishing (recommended).
277
+
278
+ ### git: connection reset by peer
279
+
280
+ This error seems to be related to concurrent git invocations ([issues/24](https://github.com/dhoulb/multi-semantic-release/issues/24)). Or maybe not.
281
+ Anyway we've added a special [`--sequental-init`](#cli) flag to queue up these calls.
282
+
283
+ ## Implementation notes (and other thoughts)
284
+
285
+ ### Support for monorepos
286
+
287
+ Automatically finds packages as long as workspaces are configured as-per the workspace-feature of one of the support package managers.
288
+
289
+ - [Yarn workspaces](https://yarnpkg.com/lang/en/docs/workspaces/).
290
+ - [Npm workspaces (Version 7.x)](https://docs.npmjs.com/cli/v7/using-npm/workspaces)
291
+ - [pnpm workspace](https://pnpm.js.org/workspaces/)
292
+ - [bolt workspaces](https://github.com/boltpkg/bolt#configuration)
293
+
294
+ I'm aware Lerna is the best-known tool right now, but in future it seems clear it will be replaced by functionality in Yarn and NPM directly. If you use Yarn workspaces today (January 2019), then publishing is the only remaining feature Lerna is _really_ required for (though it'd be lovely if Yarn added parallel script execution). Thus using multi-semantic-release means you can probably remove Lerna entirely from your project.
295
+
296
+ ### Iteration vs coordination
297
+
298
+ Other packages that enable semantic-release for monorepos work by iterating into each package and running the `semantic-release` command. This is conceptually simple but unfortunately not viable because:
299
+
300
+ - If a package is published that depends on minor changes that have been made in a sibling package it could cause extremely subtle errors (the worst kind!) โ€” if the project follows semver religiously this should never happen, but it's better to eliminate the _potential_ for errors
301
+ - Dependency version numbers need to reflect the _next_ release at time of publishing, so a package needs to know the state of _all other packages_ before it can publish correctly โ€” this central state needs to be coordinated by something
302
+
303
+ ### Local dependencies and version numbers
304
+
305
+ A key requirement is handling local dep version numbers elegantly. multi-semantic-release does the following:
306
+
307
+ - The next version number of all packages is established first
308
+ - If a release has not changed but has local deps that _have_ changed... do a `patch` bump on that package too
309
+ - Before packages are released (in semantic-release's prepare step), the correct current/next version number of _all_ local dependencies is written into the `package.json` file (overwriting any existing value)
310
+ - This ensures the package at the time of publishing will be atomically correct with all other packages in the monorepo.
311
+
312
+ The above means that, possibly, if someone upgrades dependencies and pulls down a package from NPM _during the multirelease_ (before all its deps have been published at their next versions), then their `npm install` will fail (it will work if they try again in a few minutes). On balance I thought it was more important to be atomically correct (this situation should be fairly rare assuming projects commit their lockfiles).
313
+
314
+ ### Integration with semantic-release
315
+
316
+ This is the jankiest part of multi-semantic-release and most likely part to break relies. I expect this to cause maintenance issues down the line. In an ideal world semantic-release will bake-in support for monorepos (making this package unnecessary).
317
+
318
+ The way I ended up integrating is to create a custom "inline plugin" for semantic-release, and passing that in to `semanticRelease()` as the only plugin. This then calls any other configured plugins to retrieve and potentially modify the response.
319
+
320
+ The plugin starts all release at once, then pauses them (using Promises) at various points to allow other packages in the multirelease to catch up. This is mainly needed so the version number of all packages can be established _before_ any package is released. This allows us to do a `patch` bump on releases whose local deps have bumped, and to accurately write in the version of local deps in each `package.json`
321
+
322
+ The inline plugin does the following:
323
+
324
+ - **verifyConditions:** _not used_
325
+ - **analyzeCommits:**
326
+ - Replaces `context.commits` with a list of commits filtered to the folder only
327
+ - Calls `plugins.analyzeCommits()` to get the next release type (e.g. from @semantic-release/commit-analyzer)
328
+ - Waits for _all_ packages to catch up to this point.
329
+ - For packages that haven't bumped, checks if it has local deps (or deps of deps) that have bumped and returns `patch` if that's true
330
+ - **verifyRelease:** _not used_
331
+ - **generateNotes:**
332
+ - Calls `plugins.generateNotes()` to get the notes (e.g. from @semantic-release/release-notes-generator)
333
+ - Appends a section listing any local deps bumps (e.g. "my-pkg-2: upgraded to 1.2.1")
334
+ - **prepare:**
335
+ - Writes in the correct version for local deps in `dependencies`, `devDependencies`, `peerDependencies` in `package.json`
336
+ - Serialize the releases so they happen one-at-a-time (because semantic-release calls `git push` asynchronously, multiple releases at once fail because Git refs aren't locked โ€” semantic-release should use `execa.sync()` so Git operations are atomic)
337
+ - **publish:** _not used_
338
+ - **success:** _not used_
339
+ - **fail:** _not used_
340
+
341
+ ### Jank
342
+
343
+ The integration with semantic release is pretty janky โ€” this is a quick summary of the reasons this package will be hard to maintain:
344
+
345
+ 1. Had to filter `context.commits` object before it was used by `@semantic-release/commit-analyzer` (so it only lists commits for the corresponding directory).
346
+
347
+ - The actual Git filtering is easy peasy: see [getCommitsFiltered.js](https://github.com/dhoulb/multi-semantic-release/blob/master/lib/getCommitsFiltered.js)
348
+ - But overriding `context.commits` was very difficult! I did it eventually creating an _inline plugin_ and passing it into `semanticRelease()` via `options.plugins`
349
+ - The inline plugin proxies between semantic release and other configured plugins. It does what it needs to then calls e.g. `plugins.analyzeCommits()` with an overridden `context.commits` โ€” see [createInlinePluginCreator.js](https://github.com/dhoulb/multi-semantic-release/blob/master/lib/createInlinePluginCreator.js)
350
+ - I think this is messy โ€” inline plugins aren't even documented :(
351
+
352
+ 2. Need to run the analyze commit step on _all_ plugins before any proceed to the publish step
353
+
354
+ - The inline plugin returns a Promise for every package then waits for all packages to analyze their commits before resolving them one at a time
355
+ - If packages have local deps (e.g. `dependencies` in package.json points to an internal package) this step also does a `patch` bump if any of them did a bump.
356
+ - This has to work recursively! See [hasChangedDeep.js](https://github.com/dhoulb/multi-semantic-release/blob/master/lib/hasChangedDeep.js)
357
+
358
+ 3. The configuration can be layered (i.e. global `.releaserc` and then per-directory overrides for individual packages).
359
+
360
+ - Had to duplicate the internal cosmiconfig setup from semantic release to get this working :(
361
+
362
+ 4. I found Git getting itself into weird states because e.g. `git tag` is done asynchronously
363
+
364
+ - To get around this I had to stagger package publishing so they were done one at a time (which slows things down)
365
+ - I think calls to `execa()` in semantic release should be replaced with `execa.sync()` to ensure Git's internal state is atomic.
366
+ - Fortunately, another workaround has been implemented. `Synchronizer` is the neat part. It is critical to make the tag and commit publishing phases strictly sequential. [Event emitter allows](https://github.com/dhoulb/multi-semantic-release/blob/master/lib/getSynchronizer.js):
367
+ - To synchronize release stages for all packages.
368
+ - To ensure the completeness of checks and the sufficiency of conditions for a conflict-free process.
369
+
370
+ ### Git tags
371
+
372
+ Releases always use a `tagFormat` of `my-pkg-1@1.0.1` for Git tags, and always overrides any `gitTag` set in semantic-release configuration.
373
+
374
+ I can personally see the potential for this option in coordinating a semantic-release (e.g. so two packages with the same tag always bump and release simultaneously). Unfortunately with the points of integration available in semantic-release, it was effectively impossible when releasing to stop a second package creating a duplicate tag (causing an error).
375
+
376
+ To make the `tagFormat` option work as intended the following would need to happen:
377
+
378
+ - semantic-release needs to check if a given tag already exists at a given commit, and not create it / push it if that's true
379
+ - Release notes for multiple package releases need to be merged BUT the Github release only done once (by having the notes merged at the semantic-release level but only published once, or having the Github plugin merge them)
380
+ - Make it clear in documentation that the default tag `v1.0.0` will have the same effect as Lerna's fixed mode (all changed monorepo packages released at same time)
381
+
382
+ ## Supported Node.js Versions
383
+
384
+ Libraries in this ecosystem make the best effort to track
385
+ [Node.jsโ€™ release schedule](https://nodejs.org/en/about/releases/). Hereโ€™s [a
386
+ post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
387
+
388
+ ## Contributing
389
+
390
+ If you would like to help take a look at the [list of issues](https://github.com/anolilab/multi-semantic-release/issues) and check our [Contributing](.github/CONTRIBUTING.md) guild.
391
+
392
+ > **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
393
+
394
+ ## Credits
395
+
396
+ - [Daniel Bannert](https://github.com/prisis)
397
+ - [All Contributors](https://github.com/anolilab/multi-semantic-release/graphs/contributors)
398
+ - [dhoub/multi-semantic-release](https://github.com/dhoulb/multi-semantic-release)
399
+ - [qiwi/multi-semantic-release](https://github.com/qiwi/multi-semantic-release)
400
+
401
+ ## License
402
+
403
+ [0BSD](./LICENSE.md)
404
+
405
+ [typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
406
+ [typescript-url]: "typescript"
407
+ [license-image]: https://img.shields.io/npm/l/@anolilab/eslint-config?color=blueviolet&style=for-the-badge
408
+ [license-url]: LICENSE.md "license"
409
+ [npm-image]: https://img.shields.io/npm/v/@anolilab/eslint-config/latest.svg?style=for-the-badge&logo=npm
410
+ [npm-url]: https://www.npmjs.com/package/@anolilab/eslint-config/v/latest "npm"
package/bin/cli.js ADDED
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env node
2
+
3
+ // eslint-disable-next-line import/no-unused-modules
4
+ import { exit } from "node:process";
5
+
6
+ import yargs from "yargs";
7
+ import { hideBin } from "yargs/helpers";
8
+
9
+ import logger from "../lib/logger.js";
10
+
11
+ const stringList = {
12
+ array: true,
13
+ coerce: function coerce(values) {
14
+ // eslint-disable-next-line unicorn/no-array-reduce,unicorn/prefer-spread
15
+ return values.length === 1 && values[0].trim() === "false" ? [] : values.reduce((v, value) => v.concat(value.split(",").map((x) => x.trim())), []);
16
+ },
17
+ type: "string",
18
+ };
19
+
20
+ // eslint-disable-next-line consistent-return
21
+ await (async () => {
22
+ const cli = yargs(hideBin(process.argv))
23
+ .usage("$0 [args]")
24
+ .scriptName("multi-semantic-release")
25
+ .option("d", { alias: "dry-run", describe: "Skip publishing", group: "Options", type: "boolean" })
26
+ .option("h", { alias: "help", group: "Options" })
27
+ .option("debug", {
28
+ describe: "Output debugging information.",
29
+ type: "boolean",
30
+ })
31
+ .option("silent", {
32
+ describe: "Do not print configuration information.",
33
+ type: "boolean",
34
+ })
35
+ .option("sequential-init", {
36
+ describe: "Avoid hypothetical concurrent initialization collisions.",
37
+ type: "boolean",
38
+ })
39
+ .option("sequential-prepare", {
40
+ describe: "Avoid hypothetical concurrent preparation collisions. Do not use if your project have cyclic dependencies.",
41
+ type: "boolean",
42
+ })
43
+ .option("first-parent", {
44
+ describe: "Apply commit filtering to current branch only.",
45
+ type: "boolean",
46
+ })
47
+ .option("deps.bump", {
48
+ describe: "Define deps version updating rule. Allowed: override, satisfy, inherit.",
49
+ type: "string",
50
+ })
51
+ .option("deps.release", {
52
+ describe: "Define release type for dependent package if any of its deps changes. Supported values: patch, minor, major, inherit.",
53
+ type: "string",
54
+ })
55
+ .option("deps.prefix", {
56
+ describe:
57
+ "Optional prefix to be attached to the next dep version if '--deps.bump' set to 'override'. Supported values: '^' | '~' | '' (empty string as default).",
58
+ type: "string",
59
+ })
60
+ .option("b", { alias: "branches", describe: "Git branches to release from", ...stringList, group: "Options" })
61
+ .option("ci", { describe: "Toggle CI verifications", group: "Options", type: "boolean" })
62
+ .option("ignore-packages", {
63
+ ...stringList,
64
+ describe: "Packages list to be ignored on bumping process",
65
+ })
66
+ .option("ignore-private", {
67
+ describe: "Exclude private packages. Enabled by default, pass 'no-ignore-private' to disable.",
68
+ type: "boolean",
69
+ })
70
+ .option("tag-format", {
71
+ describe:
72
+ // eslint-disable-next-line no-template-curly-in-string
73
+ 'Format to use for creating tag names. Should include "name" and "version" vars. Default: "${name}@${version}" generates "package-name@1.0.0"',
74
+ type: "string",
75
+ })
76
+ .strict(false)
77
+ .exitProcess(false);
78
+
79
+ try {
80
+ const { _, help, version, ...options } = cli.parse(process.argv.slice(2));
81
+
82
+ if (Boolean(help) || Boolean(version)) {
83
+ return 0;
84
+ }
85
+
86
+ // Imports.
87
+ // eslint-disable-next-line unicorn/no-await-expression-member
88
+ const multiSemanticRelease = (await import("../lib/multi-semantic-release.js")).default;
89
+
90
+ // Do multirelease (log out any errors).
91
+ // eslint-disable-next-line promise/catch-or-return
92
+ multiSemanticRelease(null, {}, {}, options).then(
93
+ // eslint-disable-next-line promise/always-return
94
+ () => {
95
+ // Success.
96
+ exit(0);
97
+ },
98
+ (error) => {
99
+ // Log out errors.
100
+ logger.error(`[multi-semantic-release]:`, error);
101
+ exit(1);
102
+ },
103
+ );
104
+ } catch (error) {
105
+ // Log out errors.
106
+ logger.error(`[multi-semantic-release]:`, error);
107
+ exit(1);
108
+ }
109
+ })();