@git.zone/cli 8.9.1 → 8.10.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/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/helpers.workflow.d.ts +2 -1
- package/dist_ts/helpers.workflow.js +3 -2
- package/dist_ts/mod_config/index.js +7 -4
- package/dist_ts/mod_release/classes.releasejournal.js +6 -4
- package/dist_ts/mod_release/helpers.npmartifact.d.ts +10 -6
- package/dist_ts/mod_release/helpers.npmartifact.js +10 -7
- package/dist_ts/mod_release/helpers.releaseline.d.ts +14 -5
- package/dist_ts/mod_release/helpers.releaseline.js +63 -6
- package/dist_ts/mod_release/helpers.releasepreparation.d.ts +1 -1
- package/dist_ts/mod_release/helpers.releasepreparation.js +11 -6
- package/dist_ts/mod_release/helpers.releasepublication.js +4 -3
- package/dist_ts/mod_release/index.js +11 -2
- package/package.json +2 -2
- package/readme.md +99 -14
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/helpers.workflow.ts +4 -2
- package/ts/mod_config/index.ts +7 -2
- package/ts/mod_release/classes.releasejournal.ts +5 -2
- package/ts/mod_release/helpers.npmartifact.ts +11 -6
- package/ts/mod_release/helpers.releaseline.ts +90 -7
- package/ts/mod_release/helpers.releasepreparation.ts +9 -5
- package/ts/mod_release/helpers.releasepublication.ts +3 -2
- package/ts/mod_release/index.ts +12 -1
package/readme.md
CHANGED
|
@@ -186,7 +186,7 @@ Before interactive confirmation or source mutation, a Docker release verifies th
|
|
|
186
186
|
|
|
187
187
|
The release core is not configurable plumbing. It always follows the same professional release transaction:
|
|
188
188
|
|
|
189
|
-
1. Verify the release branch, clean state, and worktree ownership of `main` (or of the maintenance branch a release line names). A project that configures `packageFiles` must carry exactly the `files` list it generates (step `preflight.packageFiles`, see [Package contents](#package-contents)). A release that builds or packs a commit with a `package.json` also proves here that the source commit carries a `pnpm-lock.yaml` its checkout can install with `--frozen-lockfile`. An npm release then reads every registry's dist-tags for every package it publishes: `latest` never moves downwards, and a line
|
|
189
|
+
1. Verify the release branch, clean state, and worktree ownership of `main` (or of the maintenance branch a release line names). A project that configures `packageFiles` must carry exactly the `files` list it generates (step `preflight.packageFiles`, see [Package contents](#package-contents)). A release that builds or packs a commit with a `package.json` also proves here that the source commit carries a `pnpm-lock.yaml` its checkout can install with `--frozen-lockfile`. An npm release then reads every registry's dist-tags for every package it publishes: `latest` never moves downwards, and a line takes `latest` only while every higher major is a prerelease (step `preflight.npmDistTags`, see [A line that keeps `latest`](#a-line-that-keeps-latest)).
|
|
190
190
|
2. Read `changelog.md` `## Pending` entries and infer or accept a semver bump, raised to `release.versionFloor` when that is higher.
|
|
191
191
|
3. Run configured tests.
|
|
192
192
|
4. With `--merge`, fast-forward and lease-push `main` before release metadata is created.
|
|
@@ -237,11 +237,15 @@ Consequences worth knowing before upgrading:
|
|
|
237
237
|
- Pnpm commands use the scope carried by the release commit. A repository that
|
|
238
238
|
tracks its own root `pnpm-workspace.yaml` retains that workspace's settings
|
|
239
239
|
and member validation. Otherwise, lockfile verification and checkout
|
|
240
|
-
installation use `--ignore-workspace`.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
240
|
+
installation use `--ignore-workspace`. For a committed root workspace,
|
|
241
|
+
configured test and build commands clear inherited workspace overrides and
|
|
242
|
+
let each pnpm process discover the workspace from its own working directory.
|
|
243
|
+
Independent fixture projects can therefore install their own dependencies,
|
|
244
|
+
including their own workspace members. Without a committed root workspace,
|
|
245
|
+
configured commands retain the repository directory as a forced pnpm scope;
|
|
246
|
+
independent fixture installs are not supported in that mode. Both modes
|
|
247
|
+
exclude an unrelated enclosing workspace from release lockfile validation
|
|
248
|
+
and installation.
|
|
245
249
|
- A Deno-only project — a commit with a `deno.json` and no `package.json` —
|
|
246
250
|
neither needs a pnpm lockfile nor installs anything: its checkout runs the
|
|
247
251
|
configured build and test commands against the committed tree, and pinning
|
|
@@ -449,10 +453,12 @@ produces another prerelease.
|
|
|
449
453
|
### Maintenance lines
|
|
450
454
|
|
|
451
455
|
A maintenance line releases an older major from its own branch under its own
|
|
452
|
-
npm dist-tag, so that `latest` never moves.
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
`
|
|
456
|
+
npm dist-tag, so that `latest` never moves. While `main` has published the
|
|
457
|
+
next major only as a prerelease, a line may instead keep `latest` (see
|
|
458
|
+
[A line that keeps `latest`](#a-line-that-keeps-latest)). It is opted into
|
|
459
|
+
per branch: the maintenance branch commits a `release.line` block in its
|
|
460
|
+
`.smartconfig.json`, and that block makes that branch, and only that branch,
|
|
461
|
+
a release source. `main` never carries the block.
|
|
456
462
|
|
|
457
463
|
Worked example: `@push.rocks/smartserve` publishes 8.x as `latest`, and its 4.x
|
|
458
464
|
line lives on the branch `v4-maintenance` under the dist-tag `v4-lts`
|
|
@@ -498,9 +504,11 @@ The release commits `v4.4.1` on `v4-maintenance`, tags it, pushes exactly
|
|
|
498
504
|
The rules:
|
|
499
505
|
|
|
500
506
|
- `release.line` takes exactly `branch` and `distTag`. The branch is a
|
|
501
|
-
canonical branch name other than `main`. The dist-tag is
|
|
502
|
-
|
|
503
|
-
|
|
507
|
+
canonical branch name other than `main`. The dist-tag is `latest` (see
|
|
508
|
+
[A line that keeps `latest`](#a-line-that-keeps-latest)) or a tag of the
|
|
509
|
+
line's own: lowercase letters and digits joined by hyphens that start with
|
|
510
|
+
a letter and are never a semver range such as `v4` or `x`, which npm
|
|
511
|
+
refuses as a tag.
|
|
504
512
|
- The release must run on the branch the line names. On any other branch,
|
|
505
513
|
`main` included, the release stops before anything is created. A branch
|
|
506
514
|
without `release.line` still releases only `main`.
|
|
@@ -530,12 +538,68 @@ The rules:
|
|
|
530
538
|
major, verify without an upload under `success` and stop under `error`.
|
|
531
539
|
Identical bytes without the line's tag stay unverified; gitzone does not add
|
|
532
540
|
the tag.
|
|
541
|
+
- A line whose `distTag` is `latest` replaces the three dist-tag rules above
|
|
542
|
+
with its own, described in the next section.
|
|
533
543
|
- Private packages follow the same rules. Their dist-tags are read with the
|
|
534
544
|
registry's authentication through `pnpm view <package> dist-tags --json`,
|
|
535
545
|
which every release path (fresh, `resume` and `recover`) qualifies from
|
|
536
546
|
`pnpm view --help` in both pnpm command dialects before it authenticates,
|
|
537
547
|
reads or publishes anything.
|
|
538
548
|
|
|
549
|
+
#### A line that keeps `latest`
|
|
550
|
+
|
|
551
|
+
While `main` publishes the next major only as a prerelease (see
|
|
552
|
+
[Prerelease channels on main](#prerelease-channels-on-main)), `latest` still
|
|
553
|
+
belongs to the current major, and fixes for it come from its maintenance
|
|
554
|
+
branch. Such a line names `latest` as its dist-tag. Continuing the prerelease
|
|
555
|
+
example: `main` has released `6.0.0-beta.0` under `beta`, `latest` is
|
|
556
|
+
`5.1.2`, and `release/5.x` branched from `v5.1.2` carries:
|
|
557
|
+
|
|
558
|
+
```json
|
|
559
|
+
{
|
|
560
|
+
"@git.zone/cli": {
|
|
561
|
+
"release": {
|
|
562
|
+
"line": { "branch": "release/5.x", "distTag": "latest" }
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
The version comes from the branch's own `changelog.md` Pending section, as
|
|
569
|
+
on every line; a `### Features` entry releases `5.2.0`:
|
|
570
|
+
|
|
571
|
+
```bash
|
|
572
|
+
gitzone release --plan
|
|
573
|
+
# source branch: release/5.x
|
|
574
|
+
# release line: release/5.x -> npm dist-tag latest (major 5; latest moves only while every higher major is a prerelease)
|
|
575
|
+
# npm dist-tag: latest
|
|
576
|
+
# npm dist-tags of @example/package at https://registry.npmjs.org: latest 5.1.2 -> 5.2.0, beta 6.0.0-beta.0 unchanged
|
|
577
|
+
gitzone release -y
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
Before anything is created, and again right before each upload, every
|
|
581
|
+
package must, at every registry, show exactly that state:
|
|
582
|
+
|
|
583
|
+
- no dist-tag carries a stable version of a higher major;
|
|
584
|
+
- `latest` is a canonical version of the line's major, not above the release;
|
|
585
|
+
- some dist-tag carries a prerelease of a higher major.
|
|
586
|
+
|
|
587
|
+
Otherwise the release stops like any line: before anything is committed or
|
|
588
|
+
tagged, or right before an upload with the terminal `dist-tag-conflict` and
|
|
589
|
+
nothing published. Publication passes `--tag=latest`, and verification
|
|
590
|
+
treats `latest` as it does for `main`: it names the version or a later one.
|
|
591
|
+
The same holds for `release.targets.npm.alreadyPublished`: identical bytes
|
|
592
|
+
already published with `latest` on them verify without an upload.
|
|
593
|
+
The line records no `previousLatest`, because it moves `latest` itself. Every
|
|
594
|
+
other line rule applies unchanged: the branch, the major, Docker images only
|
|
595
|
+
under version-bound tags (the Docker `latest` tag never moves), no Gitea
|
|
596
|
+
assets, no `--merge` and no `recover`.
|
|
597
|
+
|
|
598
|
+
Once `main` promotes the higher major, for example to `6.0.0`, the line
|
|
599
|
+
stops in preflight because `latest` carries `6.0.0`. Commit a dist-tag of its
|
|
600
|
+
own on the branch, such as `"distTag": "v5-lts"`, and the line continues
|
|
601
|
+
under the [usual rules](#maintenance-lines).
|
|
602
|
+
|
|
539
603
|
#### Docker images on a line
|
|
540
604
|
|
|
541
605
|
A line may enable the `docker` target, but its images never move a tag that
|
|
@@ -603,7 +667,10 @@ line release onto `main` nor publish it under `latest`. A line release with
|
|
|
603
667
|
Docker writes a schema 2 journal whose Docker request carries
|
|
604
668
|
`options.aliasPolicy: "release-version"`; a schema 2 journal is accepted only
|
|
605
669
|
when that policy is present exactly for a line. GitZone 8.7.x and earlier
|
|
606
|
-
refuse to read such a journal or its intent.
|
|
670
|
+
refuse to read such a journal or its intent. A line that keeps `latest`
|
|
671
|
+
journals `distTag: "latest"` and `npm.tag: "latest"` and never records
|
|
672
|
+
`previousLatest`. GitZone 8.9.x and earlier refuse to read its journal or
|
|
673
|
+
intent, and GitZone 8.4.0 to 8.9.x refuse its configuration as well.
|
|
607
674
|
|
|
608
675
|
### Exact artifacts and release journals
|
|
609
676
|
|
|
@@ -2381,6 +2448,24 @@ stops before the next registry and says that rerunning is safe. A rerun skips an
|
|
|
2381
2448
|
registry where every version already has the exact requested message, so accepted
|
|
2382
2449
|
deprecations are not submitted again. `--json` prints the plan without changing it.
|
|
2383
2450
|
|
|
2451
|
+
## Developing GitZone
|
|
2452
|
+
|
|
2453
|
+
From this repository, `cli.ts.js` runs the TypeScript sources through the
|
|
2454
|
+
project's `@git.zone/tsrun`. `cli.js` runs the built `dist_ts` output. Child
|
|
2455
|
+
GitZone processes retain the same entry point as their parent.
|
|
2456
|
+
|
|
2457
|
+
After committing and verifying a CLI correction on clean, integrated `main`,
|
|
2458
|
+
maintainers can use the source entry point to release that correction when the
|
|
2459
|
+
globally installed CLI is affected by the defect:
|
|
2460
|
+
|
|
2461
|
+
```bash
|
|
2462
|
+
node cli.ts.js release --plan
|
|
2463
|
+
node cli.ts.js release -y
|
|
2464
|
+
```
|
|
2465
|
+
|
|
2466
|
+
This runs the configured release transaction, including its preflight and
|
|
2467
|
+
publication targets. The usual release authorization and checks still apply.
|
|
2468
|
+
|
|
2384
2469
|
## Troubleshooting
|
|
2385
2470
|
|
|
2386
2471
|
Format only previews changes:
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@git.zone/cli',
|
|
6
|
-
version: '8.
|
|
6
|
+
version: '8.10.0',
|
|
7
7
|
description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
|
|
8
8
|
}
|
package/ts/helpers.workflow.ts
CHANGED
|
@@ -280,7 +280,8 @@ export interface IReleaseWorkflowConfig {
|
|
|
280
280
|
prerelease?: IReleasePrerelease;
|
|
281
281
|
/**
|
|
282
282
|
* A maintenance line, committed on its branch: that branch becomes the
|
|
283
|
-
* release source, and npm publishes under `distTag
|
|
283
|
+
* release source, and npm publishes under `distTag`. A `latest` dist-tag is
|
|
284
|
+
* admitted only while every higher major is a prerelease.
|
|
284
285
|
*/
|
|
285
286
|
line?: {
|
|
286
287
|
branch?: string;
|
|
@@ -823,7 +824,8 @@ const buildReleasePlan = (options: {
|
|
|
823
824
|
)
|
|
824
825
|
plan.push("preflight.lockfile");
|
|
825
826
|
// Every npm release reads the registries' dist-tags before it creates
|
|
826
|
-
// anything: `latest` never moves downwards, and a line
|
|
827
|
+
// anything: `latest` never moves downwards, and a line takes it only when
|
|
828
|
+
// its dist-tag is `latest` and every higher major is a prerelease.
|
|
827
829
|
if (options.targets.includes("npm")) plan.push("preflight.npmDistTags");
|
|
828
830
|
if (options.runTests) plan.push("preflight.test");
|
|
829
831
|
if (options.mergeRequested) {
|
package/ts/mod_config/index.ts
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
import { getSealedReleaseConfigError } from "../helpers.sealedrelease.js";
|
|
47
47
|
import {
|
|
48
48
|
getReleaseDockerAliasPolicy,
|
|
49
|
+
latestDistTag,
|
|
49
50
|
parseReleaseLine,
|
|
50
51
|
type IReleaseLine,
|
|
51
52
|
} from "../mod_release/helpers.releaseline.js";
|
|
@@ -2162,11 +2163,15 @@ function validateReleaseLine(
|
|
|
2162
2163
|
});
|
|
2163
2164
|
return line;
|
|
2164
2165
|
}
|
|
2166
|
+
const npmDistTag =
|
|
2167
|
+
line.distTag === latestDistTag
|
|
2168
|
+
? "npm dist-tag latest while every higher major is a prerelease"
|
|
2169
|
+
: `npm dist-tag ${line.distTag}`;
|
|
2165
2170
|
findings.push({
|
|
2166
2171
|
level: "ok",
|
|
2167
2172
|
message: isEnabled("docker")
|
|
2168
|
-
? `Release line ${line.branch} publishes under
|
|
2169
|
-
: `Release line ${line.branch} publishes under
|
|
2173
|
+
? `Release line ${line.branch} publishes under ${npmDistTag}, and Docker images only under tags bound to the release version (tSDocker alias policy ${getReleaseDockerAliasPolicy(line)})`
|
|
2174
|
+
: `Release line ${line.branch} publishes under ${npmDistTag}`,
|
|
2170
2175
|
});
|
|
2171
2176
|
return line;
|
|
2172
2177
|
}
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
import {
|
|
42
42
|
getReleaseDistTag,
|
|
43
43
|
getReleaseDockerAliasPolicy,
|
|
44
|
+
latestDistTag,
|
|
44
45
|
parseReleaseLine,
|
|
45
46
|
type IReleaseLine,
|
|
46
47
|
} from "./helpers.releaseline.js";
|
|
@@ -655,8 +656,9 @@ const assertReleaseLineRecord = (valueArg: unknown): IReleaseLine => {
|
|
|
655
656
|
|
|
656
657
|
/**
|
|
657
658
|
* Only a line release claims a publication with the `latest` version it found,
|
|
658
|
-
* and the guard admitted it only with a higher major than the release.
|
|
659
|
-
* record exists once the
|
|
659
|
+
* and the guard admitted it only with a higher major than the release. A line
|
|
660
|
+
* that takes `latest` itself records none. The record exists once the
|
|
661
|
+
* publication was claimed.
|
|
660
662
|
*/
|
|
661
663
|
const assertPreviousLatest = (
|
|
662
664
|
registryArg: Record<string, unknown>,
|
|
@@ -667,6 +669,7 @@ const assertPreviousLatest = (
|
|
|
667
669
|
const prerelease = parsePrereleaseVersion(releaseArg.version);
|
|
668
670
|
if (
|
|
669
671
|
(!releaseArg.line && !releaseArg.prerelease) ||
|
|
672
|
+
releaseArg.line?.distTag === latestDistTag ||
|
|
670
673
|
typeof previousLatest !== "string" ||
|
|
671
674
|
!isCanonicalReleaseVersion(previousLatest) ||
|
|
672
675
|
(prerelease
|
|
@@ -1259,11 +1259,11 @@ const tagSupersedesVersion = (
|
|
|
1259
1259
|
/**
|
|
1260
1260
|
* Reads the dist-tags of a published version. A prerelease needs stable latest
|
|
1261
1261
|
* below its core and an exact or later sequence of its own channel and core.
|
|
1262
|
-
* `latest` follows the rule
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1265
|
-
*
|
|
1266
|
-
*
|
|
1262
|
+
* `latest`, of `main` or of a line that takes it, follows the rule above. A
|
|
1263
|
+
* maintenance line's own tag is superseded only by a later version of its
|
|
1264
|
+
* own major, and such a line additionally requires `latest` to still carry a
|
|
1265
|
+
* higher major: a line whose version took `latest` is a terminal conflict,
|
|
1266
|
+
* because the registry now serves it as the newest release.
|
|
1267
1267
|
*/
|
|
1268
1268
|
export const assessPublishedDistTags = (
|
|
1269
1269
|
distTagsArg: Record<string, unknown> | undefined,
|
|
@@ -1834,6 +1834,8 @@ export interface INpmDistTagPreflightOptions {
|
|
|
1834
1834
|
packageNames: readonly string[];
|
|
1835
1835
|
version: string;
|
|
1836
1836
|
distTag: string;
|
|
1837
|
+
/** The release publishes from a release line. */
|
|
1838
|
+
line: boolean;
|
|
1837
1839
|
/** What the operator runs once an authentication failure is fixed. */
|
|
1838
1840
|
nextStep: string;
|
|
1839
1841
|
probeOptions?: INpmArtifactProbeOptions;
|
|
@@ -1842,7 +1844,9 @@ export interface INpmDistTagPreflightOptions {
|
|
|
1842
1844
|
/**
|
|
1843
1845
|
* Before anything is committed or tagged, every package at every registry
|
|
1844
1846
|
* must allow `version` under `distTag`: a `main` release never moves `latest`
|
|
1845
|
-
* downwards,
|
|
1847
|
+
* downwards, a line under its own tag never takes `latest` or moves its tag
|
|
1848
|
+
* backwards, and a line under `latest` takes it only while every higher major
|
|
1849
|
+
* is a prerelease.
|
|
1846
1850
|
* A registry that cannot be read stops the release as well, because nothing
|
|
1847
1851
|
* else proves the dist-tags it would change. A private read needs the
|
|
1848
1852
|
* capability the release qualified with {@link assertPnpmDistTagReadCapability}.
|
|
@@ -1880,6 +1884,7 @@ export const assertNpmDistTagsAllowPublication = async (
|
|
|
1880
1884
|
registry,
|
|
1881
1885
|
version: optionsArg.version,
|
|
1882
1886
|
distTag: optionsArg.distTag,
|
|
1887
|
+
line: optionsArg.line,
|
|
1883
1888
|
},
|
|
1884
1889
|
);
|
|
1885
1890
|
if (refusal) refusals.push(refusal);
|
|
@@ -14,8 +14,10 @@ export const latestDistTag = "latest";
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* A maintenance line: an older major released from its own branch under its
|
|
17
|
-
* own npm dist-tag, so that `latest` never moves.
|
|
18
|
-
*
|
|
17
|
+
* own npm dist-tag, so that `latest` never moves. A line whose dist-tag is
|
|
18
|
+
* `latest` takes it only while every higher major is a prerelease, see
|
|
19
|
+
* {@link findDistTagPublicationRefusal}. Its Docker images carry only tags
|
|
20
|
+
* bound to the release version, so no floating image tag moves either.
|
|
19
21
|
* The block is committed on the maintenance branch itself, which makes that
|
|
20
22
|
* branch, and only that branch, a release source.
|
|
21
23
|
*/
|
|
@@ -60,7 +62,10 @@ export const isReleaseLineDistTag = (valueArg: unknown): boolean =>
|
|
|
60
62
|
!/^v*(?:\d+|x)$/.test(valueArg) &&
|
|
61
63
|
valueArg !== latestDistTag;
|
|
62
64
|
|
|
63
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Validates `release.line`; absent means the release runs from `main`. The
|
|
67
|
+
* dist-tag is a {@link isReleaseLineDistTag} tag of its own, or `latest`.
|
|
68
|
+
*/
|
|
64
69
|
export const parseReleaseLine = (
|
|
65
70
|
valueArg: unknown,
|
|
66
71
|
contextArg = "release.line",
|
|
@@ -86,9 +91,12 @@ export const parseReleaseLine = (
|
|
|
86
91
|
`${contextArg}.branch must be a canonical Git branch name other than main, found ${JSON.stringify(valueArg.branch)}.`,
|
|
87
92
|
);
|
|
88
93
|
}
|
|
89
|
-
if (
|
|
94
|
+
if (
|
|
95
|
+
valueArg.distTag !== latestDistTag &&
|
|
96
|
+
!isReleaseLineDistTag(valueArg.distTag)
|
|
97
|
+
) {
|
|
90
98
|
throw new Error(
|
|
91
|
-
`${contextArg}.distTag must be lowercase letters and digits joined by hyphens
|
|
99
|
+
`${contextArg}.distTag must be "latest" or lowercase letters and digits joined by hyphens that start with a letter and are not a semver range such as "v4", found ${JSON.stringify(valueArg.distTag)}.`,
|
|
92
100
|
);
|
|
93
101
|
}
|
|
94
102
|
return {
|
|
@@ -158,6 +166,8 @@ export interface IDistTagSubject {
|
|
|
158
166
|
registry: string;
|
|
159
167
|
version: string;
|
|
160
168
|
distTag: string;
|
|
169
|
+
/** The release publishes from a release line; required for a line that takes `latest`. */
|
|
170
|
+
line?: boolean;
|
|
161
171
|
}
|
|
162
172
|
|
|
163
173
|
const describeDistTagValue = (valueArg: unknown): string =>
|
|
@@ -170,8 +180,10 @@ const describeDistTagValue = (valueArg: unknown): string =>
|
|
|
170
180
|
*
|
|
171
181
|
* - `main` (`latest`): a canonical `latest` above the version would move
|
|
172
182
|
* `latest` downwards, so it refuses.
|
|
173
|
-
* - A line: `latest` must already carry a higher major, so
|
|
174
|
-
*
|
|
183
|
+
* - A line under its own tag: `latest` must already carry a higher major, so
|
|
184
|
+
* the line never takes `latest`, and the line's own tag must not be ahead
|
|
185
|
+
* of the version.
|
|
186
|
+
* - A line under `latest`: see {@link findLatestLineRefusal}.
|
|
175
187
|
*/
|
|
176
188
|
export const findDistTagPublicationRefusal = (
|
|
177
189
|
distTagsArg: Record<string, unknown> | undefined,
|
|
@@ -202,6 +214,7 @@ export const findDistTagPublicationRefusal = (
|
|
|
202
214
|
return `${packageName} at ${registry}: prerelease dist-tag ${distTag} points at ${describeDistTagValue(tagged)}, which is not a prior release of the configured identifier; publishing would overwrite a different channel or move it backwards.`;
|
|
203
215
|
}
|
|
204
216
|
if (distTag === latestDistTag) {
|
|
217
|
+
if (subjectArg.line) return findLatestLineRefusal(distTagsArg, subjectArg);
|
|
205
218
|
if (
|
|
206
219
|
typeof latest === "string" &&
|
|
207
220
|
isCanonicalReleaseVersion(latest) &&
|
|
@@ -239,6 +252,76 @@ export const findDistTagPublicationRefusal = (
|
|
|
239
252
|
);
|
|
240
253
|
};
|
|
241
254
|
|
|
255
|
+
/** The major of an npm version and whether it is a prerelease; `undefined` for anything else. */
|
|
256
|
+
const parseNpmVersion = (
|
|
257
|
+
valueArg: unknown,
|
|
258
|
+
): { major: bigint; prerelease: boolean } | undefined => {
|
|
259
|
+
const match =
|
|
260
|
+
typeof valueArg === "string"
|
|
261
|
+
? /^(0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.exec(
|
|
262
|
+
valueArg,
|
|
263
|
+
)
|
|
264
|
+
: null;
|
|
265
|
+
return match
|
|
266
|
+
? { major: BigInt(match[1]), prerelease: match[2] !== undefined }
|
|
267
|
+
: undefined;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* A line whose dist-tag is `latest` releases the stable major while `main`
|
|
272
|
+
* has published the next major only as a prerelease. It may move `latest`
|
|
273
|
+
* only upwards within its own major, and only while the dist-tags show that
|
|
274
|
+
* the higher major is a prerelease: `latest` is a canonical version of the
|
|
275
|
+
* line's major not above the release, some dist-tag carries a prerelease of a
|
|
276
|
+
* higher major, and no dist-tag carries a stable version of a higher major.
|
|
277
|
+
* Once the higher major is stable the line needs a dist-tag of its own.
|
|
278
|
+
*/
|
|
279
|
+
const findLatestLineRefusal = (
|
|
280
|
+
distTagsArg: Record<string, unknown> | undefined,
|
|
281
|
+
subjectArg: IDistTagSubject,
|
|
282
|
+
): string | undefined => {
|
|
283
|
+
const { packageName, registry, version } = subjectArg;
|
|
284
|
+
const major = releaseVersionMajor(version);
|
|
285
|
+
const latest = distTagsArg?.[latestDistTag];
|
|
286
|
+
const ownTag = `Give the line a dist-tag of its own in release.line.distTag (see "Maintenance lines" in the gitzone readme).`;
|
|
287
|
+
const higherMajor = (prereleaseArg: boolean) =>
|
|
288
|
+
Object.entries(distTagsArg ?? {}).filter(([, valueArg]) => {
|
|
289
|
+
const parsed = parseNpmVersion(valueArg);
|
|
290
|
+
return (
|
|
291
|
+
parsed !== undefined &&
|
|
292
|
+
parsed.prerelease === prereleaseArg &&
|
|
293
|
+
parsed.major > major
|
|
294
|
+
);
|
|
295
|
+
});
|
|
296
|
+
const higherStable = higherMajor(false);
|
|
297
|
+
if (higherStable.length > 0) {
|
|
298
|
+
return (
|
|
299
|
+
`${packageName} at ${registry}: release line latest takes latest only while every higher major is a prerelease, but ${higherStable.map(([tagArg, valueArg]) => `${tagArg} carries ${describeDistTagValue(valueArg)}`).join(", ")}. ` +
|
|
300
|
+
ownTag
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
if (
|
|
304
|
+
typeof latest !== "string" ||
|
|
305
|
+
!isCanonicalReleaseVersion(latest) ||
|
|
306
|
+
releaseVersionMajor(latest) !== major
|
|
307
|
+
) {
|
|
308
|
+
return (
|
|
309
|
+
`${packageName} at ${registry}: release line latest requires the latest dist-tag to carry a stable version of major ${major}, but latest is ${describeDistTagValue(latest)}. ` +
|
|
310
|
+
ownTag
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
if (compareReleaseVersions(latest, version) > 0) {
|
|
314
|
+
return `${packageName} at ${registry}: the latest dist-tag points at ${latest}, above ${version}. A release line never moves latest downwards.`;
|
|
315
|
+
}
|
|
316
|
+
if (higherMajor(true).length === 0) {
|
|
317
|
+
return (
|
|
318
|
+
`${packageName} at ${registry}: release line latest takes latest only while a higher major is published as a prerelease, but no dist-tag carries a prerelease above major ${major}. ` +
|
|
319
|
+
"Release this major from main instead."
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
return undefined;
|
|
323
|
+
};
|
|
324
|
+
|
|
242
325
|
/**
|
|
243
326
|
* gitzone never writes dist-tags. When a line release finds `latest` on its
|
|
244
327
|
* own version, it names the command that restores the version `latest`
|
|
@@ -311,7 +311,7 @@ const commitCarriesBlob = async (
|
|
|
311
311
|
return result.exitCode === 0 && result.stdout.trim() === "blob";
|
|
312
312
|
};
|
|
313
313
|
|
|
314
|
-
/**
|
|
314
|
+
/** Use committed workspace discovery, or the standalone release boundary. */
|
|
315
315
|
export const getReleaseCommandEnvironment = async (
|
|
316
316
|
options: IReleaseSourceCommit,
|
|
317
317
|
): Promise<NodeJS.ProcessEnv> => {
|
|
@@ -321,19 +321,23 @@ export const getReleaseCommandEnvironment = async (
|
|
|
321
321
|
([key]) =>
|
|
322
322
|
![
|
|
323
323
|
"pnpm_config_ignore_workspace",
|
|
324
|
+
"npm_config_ignore_workspace",
|
|
324
325
|
"pnpm_config_workspace_dir",
|
|
325
326
|
"npm_config_workspace_dir",
|
|
326
327
|
].includes(key.toLowerCase()),
|
|
327
328
|
),
|
|
328
329
|
);
|
|
329
|
-
//
|
|
330
|
-
// environment
|
|
331
|
-
//
|
|
330
|
+
// A committed root manifest already stops pnpm's ancestor discovery. An
|
|
331
|
+
// environment override would also redirect independent fixture installs
|
|
332
|
+
// started by configured commands, regardless of their working directory.
|
|
333
|
+
if (ownsWorkspace) return env;
|
|
334
|
+
// Without that manifest, preserve standalone isolation from an enclosing
|
|
335
|
+
// workspace for configured commands and their nested pnpm processes.
|
|
332
336
|
return {
|
|
333
337
|
...env,
|
|
334
338
|
PNPM_CONFIG_WORKSPACE_DIR: options.cwd,
|
|
335
339
|
NPM_CONFIG_WORKSPACE_DIR: options.cwd,
|
|
336
|
-
PNPM_CONFIG_IGNORE_WORKSPACE:
|
|
340
|
+
PNPM_CONFIG_IGNORE_WORKSPACE: "true",
|
|
337
341
|
};
|
|
338
342
|
};
|
|
339
343
|
|
|
@@ -780,8 +780,8 @@ const markNpmProbeFailure = async (
|
|
|
780
780
|
* Right before a version is published, the registry's dist-tags must still
|
|
781
781
|
* allow it: the guard the release ran in preflight, repeated per package and
|
|
782
782
|
* registry, because a registry can change between the two. A refusal is a
|
|
783
|
-
* terminal dist-tag conflict and nothing is published. A line
|
|
784
|
-
* `latest` version it found, which its claim records.
|
|
783
|
+
* terminal dist-tag conflict and nothing is published. A line under its own
|
|
784
|
+
* tag returns the `latest` version it found, which its claim records.
|
|
785
785
|
*/
|
|
786
786
|
const assertNpmDistTagsBeforePublication = async (
|
|
787
787
|
optionsArg: IReleasePublicationOptions,
|
|
@@ -821,6 +821,7 @@ const assertNpmDistTagsBeforePublication = async (
|
|
|
821
821
|
registry: selectorArg.registry,
|
|
822
822
|
version: journalArg.release.version,
|
|
823
823
|
distTag: journalArg.npm.tag,
|
|
824
|
+
line: journalArg.release.line !== undefined,
|
|
824
825
|
});
|
|
825
826
|
if (refusal) {
|
|
826
827
|
await markUnclaimedTarget(
|
package/ts/mod_release/index.ts
CHANGED
|
@@ -296,6 +296,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
296
296
|
packageNames: getReleaseNpmPublicationOrder(workflow.npmPackages),
|
|
297
297
|
version: newVersion,
|
|
298
298
|
distTag: workflow.npmDistTag,
|
|
299
|
+
line: workflow.line !== undefined,
|
|
299
300
|
nextStep: "release again",
|
|
300
301
|
});
|
|
301
302
|
}
|
|
@@ -2443,11 +2444,21 @@ const describeReleaseLineDistTags = async (
|
|
|
2443
2444
|
registry,
|
|
2444
2445
|
version: versionArg,
|
|
2445
2446
|
distTag: workflowArg.npmDistTag,
|
|
2447
|
+
line: workflowArg.line !== undefined,
|
|
2446
2448
|
});
|
|
2447
2449
|
if (refusal) {
|
|
2448
2450
|
lines.push(`${prefix} refused: ${refusal}`);
|
|
2449
2451
|
continue;
|
|
2450
2452
|
}
|
|
2453
|
+
if (workflowArg.npmDistTag === latestDistTag) {
|
|
2454
|
+
const otherTags = Object.entries(distTags ?? {})
|
|
2455
|
+
.filter(([tagArg]) => tagArg !== latestDistTag)
|
|
2456
|
+
.map(([tagArg, valueArg]) => `${tagArg} ${String(valueArg)}`);
|
|
2457
|
+
lines.push(
|
|
2458
|
+
`${prefix} ${latestDistTag} ${String(distTags?.[latestDistTag])} -> ${versionArg}, ${otherTags.join(", ")} unchanged`,
|
|
2459
|
+
);
|
|
2460
|
+
continue;
|
|
2461
|
+
}
|
|
2451
2462
|
const lineVersion = distTags?.[workflowArg.npmDistTag];
|
|
2452
2463
|
lines.push(
|
|
2453
2464
|
`${prefix} ${workflowArg.npmDistTag} ${typeof lineVersion === "string" ? lineVersion : "(new)"} -> ${versionArg}, ${latestDistTag} ${String(distTags?.[latestDistTag])} unchanged`,
|
|
@@ -2527,7 +2538,7 @@ async function printReleasePlan(
|
|
|
2527
2538
|
);
|
|
2528
2539
|
if (workflow.line) {
|
|
2529
2540
|
console.log(
|
|
2530
|
-
`release line: ${workflow.line.branch} -> npm dist-tag ${workflow.line.distTag} (major ${releaseVersionMajor(versionResolutionArg.currentVersion)}; latest is never moved)`,
|
|
2541
|
+
`release line: ${workflow.line.branch} -> npm dist-tag ${workflow.line.distTag} (major ${releaseVersionMajor(versionResolutionArg.currentVersion)}; ${workflow.line.distTag === latestDistTag ? "latest moves only while every higher major is a prerelease" : "latest is never moved"})`,
|
|
2531
2542
|
);
|
|
2532
2543
|
}
|
|
2533
2544
|
if (branchContextArg.sourceBranch !== branchContextArg.releaseBranch) {
|