rman 1.0.12 → 1.2.1
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 +90 -70
- package/cli.js +226 -14
- package/commands/build.command.js +1 -0
- package/commands/changed.command.js +2 -2
- package/commands/changelog.command.js +13 -15
- package/commands/config.command.js +61 -0
- package/commands/diff.command.js +9 -4
- package/commands/exec.command.js +2 -8
- package/commands/github-release.command.js +1 -0
- package/commands/info.command.d.ts +9 -0
- package/commands/info.command.js +12 -2
- package/commands/run.command.js +5 -8
- package/commands/test.command.js +1 -0
- package/commands/version.command.js +53 -14
- package/constants.js +1 -1
- package/core/config.d.ts +265 -17
- package/core/config.js +651 -76
- package/core/custom-command.d.ts +133 -0
- package/core/custom-command.js +99 -0
- package/core/extends-config.d.ts +27 -0
- package/core/extends-config.js +89 -0
- package/core/manifest.d.ts +222 -0
- package/core/manifest.js +150 -0
- package/core/merge-config.d.ts +70 -0
- package/core/merge-config.js +193 -0
- package/core/package.d.ts +73 -7
- package/core/package.js +86 -24
- package/core/plugin.d.ts +112 -0
- package/core/plugin.js +189 -0
- package/core/repository.d.ts +91 -1
- package/core/repository.js +277 -132
- package/core/resolve-target.d.ts +12 -0
- package/core/resolve-target.js +33 -0
- package/core/run-step.d.ts +75 -0
- package/core/run-step.js +1 -0
- package/core/version-scheme.d.ts +134 -0
- package/core/version-scheme.js +148 -0
- package/core/workspace.d.ts +68 -0
- package/core/workspace.js +83 -0
- package/index.d.ts +55 -8
- package/index.js +42 -7
- package/interfaces/rman-config.interface.d.ts +222 -46
- package/package.json +16 -7
- package/services/change-hash.service.d.ts +88 -0
- package/services/change-hash.service.js +112 -0
- package/services/changelog.service.d.ts +8 -13
- package/services/changelog.service.js +12 -11
- package/services/conventional-commits.service.d.ts +73 -0
- package/services/conventional-commits.service.js +116 -0
- package/services/docker-publish.service.js +1 -1
- package/services/exec.service.js +1 -1
- package/services/github-release.service.d.ts +2 -2
- package/services/github-release.service.js +10 -5
- package/services/list.service.js +5 -2
- package/services/run.service.d.ts +112 -6
- package/services/run.service.js +265 -89
- package/services/system-info.d.ts +22 -7
- package/services/system-info.js +8 -23
- package/services/version-plan.service.d.ts +244 -0
- package/services/version-plan.service.js +414 -0
- package/services/version.service.d.ts +102 -82
- package/services/version.service.js +226 -434
- package/services.d.ts +5 -3
- package/services.js +5 -3
- package/utils/bin-path.d.ts +59 -0
- package/utils/bin-path.js +82 -0
- package/utils/child-tracker.d.ts +16 -0
- package/utils/child-tracker.js +30 -0
- package/utils/exec.d.ts +13 -2
- package/utils/exec.js +17 -17
- package/utils/git.d.ts +9 -3
- package/utils/git.js +10 -2
- package/utils/package-filter.d.ts +33 -2
- package/utils/package-filter.js +47 -7
- package/utils/printable-config.d.ts +15 -0
- package/utils/printable-config.js +42 -0
- package/utils/release-version.js +3 -3
- package/utils/run-bin.d.ts +46 -0
- package/utils/run-bin.js +63 -0
- package/utils/version-stamp.d.ts +14 -6
- package/utils/version-stamp.js +25 -13
- package/commands/ci.command.js +0 -30
- package/commands/clean.command.d.ts +0 -3
- package/commands/clean.command.js +0 -36
- package/commands/publish.command.d.ts +0 -3
- package/commands/publish.command.js +0 -225
- package/rmanrc.schema.json +0 -392
- package/services/ci.service.d.ts +0 -40
- package/services/ci.service.js +0 -204
- package/services/clean.service.d.ts +0 -42
- package/services/clean.service.js +0 -226
- package/services/publish.service.d.ts +0 -79
- package/services/publish.service.js +0 -273
- package/utils/change-hash.d.ts +0 -68
- package/utils/change-hash.js +0 -98
- package/utils/conventional-commits.d.ts +0 -52
- package/utils/conventional-commits.js +0 -90
- package/utils/npm-run-path.d.ts +0 -67
- package/utils/npm-run-path.js +0 -63
- package/utils/workspace-range.d.ts +0 -17
- package/utils/workspace-range.js +0 -28
- /package/commands/{ci.command.d.ts → config.command.d.ts} +0 -0
|
@@ -1,129 +1,31 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { hasBreakingChangeFooter, isReleaseCommit, parseConventionalCommit, parseReleaseAs, } from '../utils/conventional-commits.js';
|
|
6
|
-
import { exec } from '../utils/exec.js';
|
|
3
|
+
import { interpolateConfig } from '../core/config.js';
|
|
4
|
+
import { Manifest } from '../core/manifest.js';
|
|
7
5
|
import { GitHelper } from '../utils/git.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { parseWorkspaceRange } from '../utils/workspace-range.js';
|
|
6
|
+
import { expandReleaseTag, isCalendarVersion } from '../utils/release-version.js';
|
|
7
|
+
import { stampVersionLabel } from '../utils/version-stamp.js';
|
|
8
|
+
import { ChangeHashService } from './change-hash.service.js';
|
|
12
9
|
import { ChangelogService } from './changelog.service.js';
|
|
10
|
+
import { RunService } from './run.service.js';
|
|
11
|
+
import { VersionPlanService } from './version-plan.service.js';
|
|
12
|
+
/**
|
|
13
|
+
* Applying a version plan: the writes. Every manifest edit, dependency-range refresh, stamp,
|
|
14
|
+
* commit and tag lives here; **what** to write is `VersionPlanService`'s answer.
|
|
15
|
+
*
|
|
16
|
+
* Nothing here knows what a `package.json` is, names an npm script, or runs a command: the version
|
|
17
|
+
* goes through `Manifest`/`ManifestProvider`, refreshing a sibling's dependency range goes through
|
|
18
|
+
* the same provider, and the lifecycle hooks around the write go through
|
|
19
|
+
* `RunService.runLifecycleSlot` - this module only supplies the `.rmanrc version.<slot>` fallback,
|
|
20
|
+
* which is its own config. What is left is git, that config, and the version stamps.
|
|
21
|
+
*/
|
|
13
22
|
export var VersionService;
|
|
14
23
|
(function (VersionService) {
|
|
15
|
-
function isBumpKeyword(value) {
|
|
16
|
-
return value === 'patch' || value === 'minor' || value === 'major';
|
|
17
|
-
}
|
|
18
|
-
VersionService.isBumpKeyword = isBumpKeyword;
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* Packages are partitioned into groups by their resolved `group` value (cascaded): `true`
|
|
25
|
-
* (the default) puts every such package into one implicit repo-wide group; a string joins
|
|
26
|
-
* exactly the other packages sharing that same string, regardless of the repo's default; `false`
|
|
27
|
-
* makes a package its own solo group. Each group's "current version" is always the highest
|
|
28
|
-
* version currently found among its own members (never persisted anywhere) - see
|
|
29
|
-
* `resolveGroupKey`.
|
|
30
|
-
*
|
|
31
|
-
* Within a group, a member with real commits since its own last release (or an explicit `bump`)
|
|
32
|
-
* sets the group's severity to the highest found among changed members; the new version
|
|
33
|
-
* is that current version bumped by that severity. Which members actually receive it depends on
|
|
34
|
-
* the severity: **patch** only the changed member(s) (a caret dependency range already tolerates
|
|
35
|
-
* a patch bump, no republish needed downstream); **minor** also every transitive in-group
|
|
36
|
-
* dependent; **major** the entire group, changed or not - see `computeGroupPlan`.
|
|
37
|
-
*
|
|
38
|
-
* Across groups: a package depending on another group's bumped package always gets exactly a
|
|
39
|
-
* **patch** bump of its own (never inheriting the source's severity) - the dependency reference
|
|
40
|
-
* itself is the only thing that changed for it. This never re-triggers *its own* group's
|
|
41
|
-
* minor/major cascade (a patch never cascades), but can itself ripple into a third group, and so
|
|
42
|
-
* on, until nothing new is affected - see `rippleCrossGroup`.
|
|
43
|
-
*
|
|
44
|
-
* A monorepo's root package is never a real member of any group (it's never published on its
|
|
45
|
-
* own) - it gets one trailing entry instead, carrying the repository's own release identity: the
|
|
46
|
-
* single group's version when there is one, a calendar version once there are several - see
|
|
47
|
-
* `buildRootEntry`.
|
|
48
|
-
*
|
|
49
|
-
* "Since its own last release" is resolved by the shared `detectChangeHash` - the same boundary
|
|
50
|
-
* `changelog` measures from, so the two never disagree about which commits are unreleased.
|
|
51
|
-
*/
|
|
52
|
-
async function getPlan(repository, options = {}) {
|
|
53
|
-
const bump = options.bump?.trim();
|
|
54
|
-
const explicitSeverity = bump && isBumpKeyword(bump) ? bump : undefined;
|
|
55
|
-
const explicitVersion = bump && !explicitSeverity ? (semver.valid(bump) ?? undefined) : undefined;
|
|
56
|
-
if (bump && !explicitSeverity && !explicitVersion) {
|
|
57
|
-
throw new Error(`Invalid "bump": "${bump}" (expected "patch", "minor", "major", or a valid semver version)`);
|
|
58
|
-
}
|
|
59
|
-
const git = new GitHelper({ cwd: repository.dirname });
|
|
60
|
-
const packages = filterPackages(repository.getPackages(), options);
|
|
61
|
-
const dirtyFiles = await git.listDirtyFiles({ absolute: true });
|
|
62
|
-
const isDirty = (pkg) => dirtyFiles.some(f => !path.relative(pkg.dirname, f).startsWith('..'));
|
|
63
|
-
const entries = new Map();
|
|
64
|
-
const eligible = [];
|
|
65
|
-
for (const pkg of packages) {
|
|
66
|
-
if (isDirty(pkg)) {
|
|
67
|
-
entries.set(pkg.name, {
|
|
68
|
-
package: pkg,
|
|
69
|
-
groupKey: resolveGroupKey(pkg),
|
|
70
|
-
group: groupLabel(resolveGroupKey(pkg)),
|
|
71
|
-
status: options.ignoreDirty ? 'skip' : 'error',
|
|
72
|
-
from: pkg.version,
|
|
73
|
-
reason: 'uncommitted local changes',
|
|
74
|
-
});
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
eligible.push(pkg);
|
|
78
|
-
}
|
|
79
|
-
const commitMessage = repository.rootPackage.config?.version?.commitMessage;
|
|
80
|
-
const changeByPackage = new Map();
|
|
81
|
-
await Promise.all(eligible.map(async (pkg) => {
|
|
82
|
-
if (explicitVersion) {
|
|
83
|
-
changeByPackage.set(pkg.name, { severity: undefined, reason: `explicit version ${explicitVersion}` });
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const since = await detectChangeHash(git, pkg, { npmViewVersion: options.npmViewVersion });
|
|
87
|
-
const commits = since ? await git.listCommits({ hash: since }) : await git.listAllCommits();
|
|
88
|
-
const belongsToPkg = (c) => c.files.some(f => !path.relative(pkg.dirname, f).startsWith('..'));
|
|
89
|
-
const real = commits.filter(c => belongsToPkg(c) && !isReleaseCommit(c.subject, commitMessage));
|
|
90
|
-
if (!real.length)
|
|
91
|
-
return;
|
|
92
|
-
changeByPackage.set(pkg.name, {
|
|
93
|
-
severity: explicitSeverity ?? detectSeverity(real),
|
|
94
|
-
reason: since ? `changed since ${since}` : 'unreleased commits',
|
|
95
|
-
});
|
|
96
|
-
}));
|
|
97
|
-
const groups = new Map();
|
|
98
|
-
for (const pkg of eligible) {
|
|
99
|
-
const key = resolveGroupKey(pkg);
|
|
100
|
-
const list = groups.get(key);
|
|
101
|
-
if (list)
|
|
102
|
-
list.push(pkg);
|
|
103
|
-
else
|
|
104
|
-
groups.set(key, [pkg]);
|
|
105
|
-
}
|
|
106
|
-
for (const [key, members] of groups) {
|
|
107
|
-
computeGroupPlan(key, members, changeByPackage, explicitVersion, options.preid, entries);
|
|
108
|
-
}
|
|
109
|
-
rippleCrossGroup(packages, entries, options.preid);
|
|
110
|
-
const result = packages.map(pkg => entries.get(pkg.name));
|
|
111
|
-
if (repository.monorepo) {
|
|
112
|
-
result.push(buildRootEntry(repository, result, {
|
|
113
|
-
groupCount: groups.size,
|
|
114
|
-
lastReleaseVersion: await findLastReleaseVersion(git, repository.rootPackage),
|
|
115
|
-
now: options.now ?? (() => new Date()),
|
|
116
|
-
}));
|
|
117
|
-
}
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
VersionService.getPlan = getPlan;
|
|
121
|
-
/**
|
|
122
|
-
* Same as `getPlan`, and additionally writes every `'bump'` entry's new version into its own
|
|
123
|
-
* `package.json` (and refreshes any other bumped package's dependency range on it), runs that
|
|
124
|
-
* package's `version.preScript`/`.script`/`.postScript` (or its own real `preversion`/`version`/
|
|
125
|
-
* `postversion` npm scripts) around the write, then commits and tags **once per group** - so
|
|
126
|
-
* independently-versioned groups each get their own clean commit/tag rather than one entangled
|
|
25
|
+
* Writes every `'bump'` entry's new version into its own manifest (and refreshes any other bumped
|
|
26
|
+
* package's dependency range on it), runs that package's own version-lifecycle hooks or its
|
|
27
|
+
* `.rmanrc version.before`/`.exec`/`.after` around the write - see the `hook` closure below -
|
|
28
|
+
* then commits and tags **once per group** - so independently-versioned groups each get their own clean commit/tag rather than one entangled
|
|
127
29
|
* commit spanning unrelated version lines. Pushes only when `options.push` is set - same as a
|
|
128
30
|
* plain `npm version`, this never reaches the network on its own otherwise.
|
|
129
31
|
*/
|
|
@@ -134,48 +36,61 @@ export var VersionService;
|
|
|
134
36
|
// entry handled below instead, since it's never published on its own.
|
|
135
37
|
const isRealEntry = (e) => !(repository.monorepo && e.package === repository.rootPackage);
|
|
136
38
|
const bumped = plan.filter(e => e.status === 'bump' && isRealEntry(e));
|
|
137
|
-
|
|
39
|
+
/** Keyed by package, not by name: what a manifest calls a sibling is the ecosystem's business,
|
|
40
|
+
* and the provider doing the rewrite is the thing that knows. */
|
|
41
|
+
const bumpedVersions = new Map(bumped.map(e => [e.package, e.to]));
|
|
138
42
|
/** Repo-relative paths of every file stamped with the new version below (a Dockerfile label, a
|
|
139
43
|
* source constant), so each lands in the same commit as the bump that made it stale - keyed by
|
|
140
44
|
* package, the way `changelogFileByPackage` is. */
|
|
141
45
|
const stampedByPackage = new Map();
|
|
46
|
+
/**
|
|
47
|
+
* Every `version.stamp` entry is checked **before the first write**.
|
|
48
|
+
*
|
|
49
|
+
* "This file names no version I can rewrite" is a *configuration* mistake, knowable without
|
|
50
|
+
* touching anything - and finding it mid-loop left the tree torn: the manifest already bumped
|
|
51
|
+
* on disk, no commit, no tag (measured, exit 1 with `package.json` at the new version). A
|
|
52
|
+
* pre-flight costs one extra read per listed file and turns that into a clean refusal.
|
|
53
|
+
*/
|
|
54
|
+
for (const entry of bumped)
|
|
55
|
+
assertStampable(entry.package, entry.to);
|
|
142
56
|
for (const entry of bumped) {
|
|
143
57
|
const pkg = entry.package;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
58
|
+
/** The scope these hooks are evaluated against - the only place `${{ pkg.targetVersion }}`
|
|
59
|
+
* can mean anything, and the reason `DEFERRED_PATHS` left them raw until now. */
|
|
60
|
+
const scope = repository.configScope(pkg, { targetVersion: entry.to });
|
|
61
|
+
/**
|
|
62
|
+
* One slot of the version lifecycle. This module contributes only the *fallback* - its own
|
|
63
|
+
* `.rmanrc version.<slot>`, evaluated here because these three paths are in `DEFERRED_PATHS`
|
|
64
|
+
* and `${{ pkg.targetVersion }}` exists nowhere else. Whether the package's own declaration
|
|
65
|
+
* pre-empts it, and running the thing, are `RunService`'s (`runLifecycleSlot`), so nothing
|
|
66
|
+
* here names a script, a file, or a shell.
|
|
67
|
+
*/
|
|
68
|
+
const hook = (slot) => RunService.runLifecycleSlot(pkg, VERSION_LIFECYCLE, slot, RunService.normalizeScriptValue(
|
|
69
|
+
/** `at`: the path is what tells a step function from a value one, and this is a fragment -
|
|
70
|
+
* without it a function here was called while the hook was being prepared. */
|
|
71
|
+
interpolateConfig(pkg.config?.version?.[slot], scope, { at: ['version', slot] }), `version.${slot}`));
|
|
72
|
+
await hook('before');
|
|
73
|
+
/** Through the manifest, not through a `package.json` field: where a version is written is
|
|
74
|
+
* the provider's business (see `ManifestProvider`), and this is the one place rman changes
|
|
75
|
+
* it. */
|
|
76
|
+
pkg.manifest.version = entry.to;
|
|
77
|
+
/** Which fields hold a sibling reference, and what a reference even looks like, is the
|
|
78
|
+
* ecosystem's - npm's four fields and its `"workspace:"` protocol used to be spelled out
|
|
79
|
+
* here. See `ManifestProvider.updateDependencyVersions`. */
|
|
80
|
+
Manifest.updateDependencyVersions(pkg, bumpedVersions);
|
|
81
|
+
await hook('exec');
|
|
82
|
+
pkg.writeManifest();
|
|
83
|
+
// Before the `after` hook, so a script reacting to the bump sees the whole new state.
|
|
169
84
|
const stamped = [stampDockerfile(pkg, entry.to), ...stampSourceFiles(pkg, entry.to)].filter((f) => !!f);
|
|
170
85
|
if (stamped.length) {
|
|
171
86
|
stampedByPackage.set(pkg.name, stamped.map(f => path.relative(repository.dirname, f)));
|
|
172
87
|
}
|
|
173
|
-
await
|
|
88
|
+
await hook('after');
|
|
174
89
|
}
|
|
175
90
|
const rootEntry = repository.monorepo ? plan.find(e => e.package === repository.rootPackage) : undefined;
|
|
176
91
|
if (rootEntry?.status === 'bump') {
|
|
177
|
-
repository.rootPackage.
|
|
178
|
-
repository.rootPackage.
|
|
92
|
+
repository.rootPackage.manifest.version = rootEntry.to;
|
|
93
|
+
repository.rootPackage.writeManifest();
|
|
179
94
|
}
|
|
180
95
|
/** Written before the per-group commits below so each group's changelog file lands in the
|
|
181
96
|
* *same* commit as its version bump, rather than needing a separate `changelog --write` run.
|
|
@@ -188,7 +103,7 @@ export var VersionService;
|
|
|
188
103
|
const changelogFileByPackage = new Map();
|
|
189
104
|
if (options.changelog) {
|
|
190
105
|
for (const entry of bumped) {
|
|
191
|
-
const fromTag = expandTag(entry.package, entry.from);
|
|
106
|
+
const fromTag = ChangeHashService.expandTag(entry.package, entry.from);
|
|
192
107
|
const from = (await git.tagExists(fromTag)) ? fromTag : undefined;
|
|
193
108
|
const changelogEntries = await ChangelogService.generateToFile(repository, {
|
|
194
109
|
scope: entry.package.name,
|
|
@@ -212,8 +127,14 @@ export var VersionService;
|
|
|
212
127
|
* *before* the group commits, so the last commit this makes is always a tagged release commit -
|
|
213
128
|
* otherwise the tag sits one commit behind HEAD and every `git tag --points-at HEAD` consumer
|
|
214
129
|
* (CI capturing the tag it just released, say) comes up empty in a monorepo. */
|
|
130
|
+
const commits = [];
|
|
131
|
+
const tagged = [];
|
|
215
132
|
if (rootEntry?.status === 'bump') {
|
|
216
|
-
|
|
133
|
+
const message = `chore: sync root version to ${rootEntry.to}`;
|
|
134
|
+
const sha = await git.commit([path.relative(repository.dirname, repository.rootPackage.manifestFileName)], message);
|
|
135
|
+
/** No packages: this commit carries the root's informational version and nothing releasable,
|
|
136
|
+
* which is why `updated` does not count it either. */
|
|
137
|
+
commits.push({ sha, message, packages: [] });
|
|
217
138
|
}
|
|
218
139
|
const byGroup = new Map();
|
|
219
140
|
for (const entry of bumped) {
|
|
@@ -224,18 +145,23 @@ export var VersionService;
|
|
|
224
145
|
byGroup.set(entry.groupKey, [entry]);
|
|
225
146
|
}
|
|
226
147
|
for (const [, groupEntries] of byGroup) {
|
|
227
|
-
const files = groupEntries.map(e => path.relative(repository.dirname, e.package.
|
|
148
|
+
const files = groupEntries.map(e => path.relative(repository.dirname, e.package.manifestFileName));
|
|
228
149
|
for (const e of groupEntries) {
|
|
229
150
|
const changelogFile = changelogFileByPackage.get(e.package.name);
|
|
230
151
|
if (changelogFile)
|
|
231
152
|
files.push(changelogFile);
|
|
232
153
|
files.push(...(stampedByPackage.get(e.package.name) ?? []));
|
|
233
154
|
}
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
155
|
+
const message = buildCommitMessage(repository, groupEntries, options.message);
|
|
156
|
+
const sha = await git.commit(files, message);
|
|
157
|
+
commits.push({ sha, message, packages: groupEntries.map(e => e.package.name) });
|
|
158
|
+
const tags = new Set(groupEntries.map(e => ChangeHashService.expandTag(e.package, e.to)));
|
|
159
|
+
for (const tag of tags) {
|
|
160
|
+
const exists = await git.tagExists(tag);
|
|
161
|
+
if (!exists)
|
|
238
162
|
await git.createTag(tag);
|
|
163
|
+
tagged.push({ name: tag, created: !exists });
|
|
164
|
+
}
|
|
239
165
|
}
|
|
240
166
|
/** A repository release tag, on top of the per-group ones - but only once the root is on a
|
|
241
167
|
* calendar version. With a single version line the group's own tag already *is* the release
|
|
@@ -249,308 +175,174 @@ export var VersionService;
|
|
|
249
175
|
'Wait a moment and run again.');
|
|
250
176
|
}
|
|
251
177
|
await git.createTag(releaseTag);
|
|
178
|
+
tagged.push({ name: releaseTag, created: true, release: true });
|
|
252
179
|
}
|
|
253
|
-
|
|
180
|
+
const pushed = !!options.push && bumped.length > 0;
|
|
181
|
+
if (pushed)
|
|
254
182
|
await git.push();
|
|
255
|
-
return plan;
|
|
183
|
+
return { entries: plan, updated: bumped, commits, tags: tagged, pushed };
|
|
256
184
|
}
|
|
257
185
|
VersionService.applyPlan = applyPlan;
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
return `solo:${pkg.name}`;
|
|
271
|
-
if (typeof g === 'string' && g)
|
|
272
|
-
return `named:${g}`;
|
|
273
|
-
return 'default';
|
|
274
|
-
}
|
|
275
|
-
function groupLabel(key) {
|
|
276
|
-
if (key.startsWith('named:'))
|
|
277
|
-
return key.slice('named:'.length);
|
|
278
|
-
if (key.startsWith('solo:'))
|
|
279
|
-
return key.slice('solo:'.length);
|
|
280
|
-
return key;
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Highest bump type implied by `commits`: a `Release-As: patch|minor|major` footer (see
|
|
284
|
-
* `parseReleaseAs`) replaces what that one commit's own subject/footers would otherwise imply,
|
|
285
|
-
* entirely - the escape hatch for e.g. a `feat:` that needs to ship as a patch right now, without
|
|
286
|
-
* waiting for the rest of a minor's worth of work. Absent that, a `!` marker or a `BREAKING
|
|
287
|
-
* CHANGE:` footer wins outright; otherwise `feat` implies minor; anything else (a `fix`, an
|
|
288
|
-
* unrecognized type, a non-conventional message) defaults to patch - something changed, so at
|
|
289
|
-
* least a patch release is warranted.
|
|
290
|
-
*/
|
|
291
|
-
function detectSeverity(commits) {
|
|
292
|
-
let severity = 'patch';
|
|
293
|
-
for (const c of commits) {
|
|
294
|
-
const override = parseReleaseAs(c.body);
|
|
295
|
-
if (override === 'major')
|
|
296
|
-
return 'major';
|
|
297
|
-
if (override) {
|
|
298
|
-
if (SEVERITY_RANK[override] > SEVERITY_RANK[severity])
|
|
299
|
-
severity = override;
|
|
300
|
-
continue;
|
|
186
|
+
/** `.rmanrc version.commitMessage` (root-level; `{version}` is replaced when every bumped package
|
|
187
|
+
* in this commit shares one version) - defaults to `"chore(release): v{version}"`, or a plain
|
|
188
|
+
* listing of `name@version` pairs when this particular commit spans different versions (a
|
|
189
|
+
* cross-group ripple can land a lone forced patch in a group that otherwise didn't move). */
|
|
190
|
+
function buildCommitMessage(repository, entries, messageOverride) {
|
|
191
|
+
const versions = new Set(entries.map(e => e.to));
|
|
192
|
+
if (versions.size === 1) {
|
|
193
|
+
const template = messageOverride ?? repository.rootPackage.config?.version?.commitMessage;
|
|
194
|
+
const version = entries[0].to;
|
|
195
|
+
if (typeof template === 'string' && template)
|
|
196
|
+
return template.replace(/\{version\}/g, version);
|
|
197
|
+
return `chore(release): v${version}`;
|
|
301
198
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if (parsed?.type === 'feat')
|
|
306
|
-
severity = 'minor';
|
|
307
|
-
}
|
|
308
|
-
return severity;
|
|
309
|
-
}
|
|
310
|
-
function maxVersion(versions) {
|
|
311
|
-
return versions.reduce((m, v) => (semver.gt(v, m) ? v : m), versions[0]);
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* `semver.inc`, "pre-ified" when `preid` is given: `current` already sitting on a prerelease with
|
|
315
|
-
* that *same* identifier just has its prerelease counter incremented (`'prerelease'`, e.g.
|
|
316
|
-
* `1.2.3-beta.0` -> `1.2.3-beta.1`) rather than jumping to a new base version every time this
|
|
317
|
-
* runs again during the same beta/rc cycle; anything else (a plain release, or a prerelease under
|
|
318
|
-
* a *different* identifier - switching from `beta` to `rc`, say) starts a fresh prerelease of
|
|
319
|
-
* `severity`'s own type (`'prepatch'`/`'preminor'`/`'premajor'`, e.g. `1.2.3` -> `1.3.0-beta.0`
|
|
320
|
-
* for a `minor`). Without `preid`, this is just `semver.inc(current, severity)`.
|
|
321
|
-
*/
|
|
322
|
-
function incVersion(current, severity, preid) {
|
|
323
|
-
if (!preid)
|
|
324
|
-
return semver.inc(current, severity) ?? current;
|
|
325
|
-
const existing = semver.prerelease(current);
|
|
326
|
-
const releaseType = existing && String(existing[0]) === preid ? 'prerelease' : `pre${severity}`;
|
|
327
|
-
return semver.inc(current, releaseType, preid) ?? current;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Decides one group's new version and which of its members actually receive it, writing an
|
|
331
|
-
* `Entry` per member into `entries`. `changeByPackage` holds each eligible package's own detected
|
|
332
|
-
* severity (or `undefined` for one with no real commits since its last tag) - `undefined` here
|
|
333
|
-
* always means "unchanged", never "explicit version" (that path is handled separately below).
|
|
334
|
-
*/
|
|
335
|
-
function computeGroupPlan(key, members, changeByPackage, explicitVersion, preid, entries) {
|
|
336
|
-
const label = groupLabel(key);
|
|
337
|
-
const changed = members.filter(m => changeByPackage.has(m.name));
|
|
338
|
-
if (!changed.length) {
|
|
339
|
-
for (const m of members) {
|
|
340
|
-
entries.set(m.name, { package: m, groupKey: key, group: label, status: 'no-change', from: m.version });
|
|
341
|
-
}
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
const current = maxVersion(members.map(m => m.version));
|
|
345
|
-
let to;
|
|
346
|
-
let severity;
|
|
347
|
-
if (explicitVersion) {
|
|
348
|
-
to = explicitVersion;
|
|
199
|
+
if (messageOverride)
|
|
200
|
+
return messageOverride;
|
|
201
|
+
return `chore(release): ${entries.map(e => `${e.package.name}@${e.to}`).join(', ')}`;
|
|
349
202
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
while (worklist.length) {
|
|
365
|
-
const cur = worklist.pop();
|
|
366
|
-
for (const m of members) {
|
|
367
|
-
if (bumping.has(m))
|
|
368
|
-
continue;
|
|
369
|
-
if (m.dependencies.includes(cur.name)) {
|
|
370
|
-
bumping.add(m);
|
|
371
|
-
worklist.push(m);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
203
|
+
VersionService.buildCommitMessage = buildCommitMessage;
|
|
204
|
+
/**
|
|
205
|
+
* A `version.<slot>` value: one step, or several to run in sequence - the same shape, and now the
|
|
206
|
+
* same function, as `run.<script>.before`/`.exec`/`.after`.
|
|
207
|
+
*
|
|
208
|
+
* It used to be a second implementation living here, and it differed in two ways that both had to
|
|
209
|
+
* go. It **joined an array with `' && '`** into one shell line, which a function step cannot be
|
|
210
|
+
* part of and which was not even right for shell steps - `cd x && y` in one process is not two
|
|
211
|
+
* processes. And it **dropped anything it did not recognize**, so a function here was silently
|
|
212
|
+
* never run. (The doc comment also still named `.script`/`.preScript`/`.postScript`, three keys
|
|
213
|
+
* that have been `before`/`exec`/`after` for a long time.)
|
|
214
|
+
*/
|
|
215
|
+
function normalizeScriptValue(value, at) {
|
|
216
|
+
return RunService.normalizeScriptValue(value, at);
|
|
375
217
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
218
|
+
VersionService.normalizeScriptValue = normalizeScriptValue;
|
|
219
|
+
/**
|
|
220
|
+
* Keeps a package's Dockerfile `org.opencontainers.image.version` label in step with the version
|
|
221
|
+
* just written, returning the absolute path when it actually changed (so the caller can fold it
|
|
222
|
+
* into the same commit) and `undefined` otherwise.
|
|
223
|
+
*
|
|
224
|
+
* Here rather than in a build script: the label is a *statement of the package's version*, so it
|
|
225
|
+
* belongs to whatever writes that version - which keeps it in the bump commit, leaves the tree
|
|
226
|
+
* clean, and makes it right for anyone building the Dockerfile by hand. A build-time rewrite is
|
|
227
|
+
* both later than it needs to be and invisible to git.
|
|
228
|
+
*
|
|
229
|
+
* The same path `publish --target docker` builds from (`publish.docker.dockerfile`, default
|
|
230
|
+
* `Dockerfile`), so the two can never disagree about which file this is. Opt out with `.rmanrc
|
|
231
|
+
* "version": { "stampDockerfile": false }`; a package with no Dockerfile, or one that doesn't
|
|
232
|
+
* declare the label, is a no-op either way.
|
|
233
|
+
*/
|
|
234
|
+
function stampDockerfile(pkg, version) {
|
|
235
|
+
if (pkg.config?.version?.stampDockerfile === false)
|
|
236
|
+
return undefined;
|
|
237
|
+
const file = path.resolve(pkg.dirname, pkg.config?.publish?.docker?.dockerfile || 'Dockerfile');
|
|
238
|
+
if (!fs.existsSync(file))
|
|
239
|
+
return undefined;
|
|
240
|
+
const stamped = stampVersionLabel(fs.readFileSync(file, 'utf-8'), version);
|
|
241
|
+
if (stamped === undefined)
|
|
242
|
+
return undefined;
|
|
243
|
+
fs.writeFileSync(file, stamped, 'utf-8');
|
|
244
|
+
return file;
|
|
392
245
|
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
246
|
+
VersionService.stampDockerfile = stampDockerfile;
|
|
247
|
+
/**
|
|
248
|
+
* Keeps every `.rmanrc "version.stamp"` file's hard-coded version in step with the one just
|
|
249
|
+
* written, returning the absolute paths of the ones that actually changed.
|
|
250
|
+
*
|
|
251
|
+
* Explicitly listed rather than discovered: unlike the OCI Dockerfile label there is no standard
|
|
252
|
+
* saying "this file holds the version". **A listed file a package does not have stays a silent
|
|
253
|
+
* no-op** - that is what lets one `"[*]"` declaration cover a repo where only some packages carry
|
|
254
|
+
* one.
|
|
255
|
+
*
|
|
256
|
+
* **A listed file that exists and cannot be stamped throws.** It used to be the same silent
|
|
257
|
+
* no-op as a missing file, and the two are not the same thing at all: the second means "not this
|
|
258
|
+
* package", the first means the repository asked for something and did not get it. Measured, and
|
|
259
|
+
* it is the bad kind of quiet - a package listing a file holding `const VERSION` (capital, so the
|
|
260
|
+
* pattern missed it) released a tagged commit with a stale constant and said nothing. The error
|
|
261
|
+
* names the file and, when the package's ecosystem declared none, says so.
|
|
262
|
+
*
|
|
263
|
+
* *How* a version is declared is the provider's (`ManifestProvider.stampVersion`); *which* files
|
|
264
|
+
* hold one is the repository's, which is why the list is config and the rewrite is a seam.
|
|
265
|
+
*/
|
|
266
|
+
function stampSourceFiles(pkg, version) {
|
|
267
|
+
const stamped = [];
|
|
268
|
+
for (const entry of readStampEntries(pkg)) {
|
|
269
|
+
const file = path.resolve(pkg.dirname, entry.file);
|
|
270
|
+
if (!fs.existsSync(file))
|
|
409
271
|
continue;
|
|
410
|
-
|
|
272
|
+
const before = fs.readFileSync(file, 'utf-8');
|
|
273
|
+
const next = Manifest.stampVersion(pkg, file, before, version, { constant: entry.constant });
|
|
274
|
+
if (next === undefined) {
|
|
275
|
+
const relative = path.relative(pkg.dirname, file);
|
|
276
|
+
throw new Error(`"version.stamp" lists "${relative}" for "${pkg.name}", but nothing in it could be ` +
|
|
277
|
+
`rewritten to ${version}.\n` +
|
|
278
|
+
(pkg.provider
|
|
279
|
+
? ` The "${pkg.provider}" provider looked and found no version to change. Name the ` +
|
|
280
|
+
`identifier with { file, constant } if it is not "version", or drop the entry.`
|
|
281
|
+
: ` This package belongs to no ecosystem (no plugin claimed it), so nothing knows how ` +
|
|
282
|
+
`a version is declared in it. Name a plugin in .rmanrc "plugins".`));
|
|
283
|
+
}
|
|
284
|
+
/** Matched, but already reads the target - nothing to write and nothing to report. Distinct
|
|
285
|
+
* from the `undefined` above, which is "nothing here to rewrite at all". */
|
|
286
|
+
if (next === before)
|
|
411
287
|
continue;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
.map(p => entries.get(p.name).to ?? p.version));
|
|
415
|
-
const next = {
|
|
416
|
-
...entry,
|
|
417
|
-
status: 'bump',
|
|
418
|
-
to: incVersion(groupCeiling, 'patch', preid),
|
|
419
|
-
reason: `depends on ${source.package.name}@${source.to}`,
|
|
420
|
-
};
|
|
421
|
-
entries.set(pkg.name, next);
|
|
422
|
-
worklist.push(next);
|
|
288
|
+
fs.writeFileSync(file, next, 'utf-8');
|
|
289
|
+
stamped.push(file);
|
|
423
290
|
}
|
|
291
|
+
return stamped;
|
|
424
292
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
* A monorepo root is never published on its own, but its version is still the repository's release
|
|
428
|
-
* identity - what a GitHub Release is named after. How it's computed depends on how many version
|
|
429
|
-
* lines the repo has, derived rather than configured (see `usesCalendarVersion`):
|
|
430
|
-
*
|
|
431
|
-
* - **One group**: the root simply follows it, so the repo and its packages share one number.
|
|
432
|
-
* - **Several groups** (or a repo already on calendar): a calendar version (`2026.9.15-1430`).
|
|
433
|
-
* There is no meaningful shared number to report - the old "highest version among the groups"
|
|
434
|
-
* rule would leave the root standing still whenever a *lower* line released, so a release could
|
|
435
|
-
* happen with no identity of its own, and a semver-looking identity would anyway claim something
|
|
436
|
-
* untrue about packages sitting on entirely different lines.
|
|
437
|
-
*
|
|
438
|
-
* Reports `'no-change'` (not `'bump'`) when nothing in the repository changed at all.
|
|
439
|
-
*/
|
|
440
|
-
function buildRootEntry(repository, memberEntries, context) {
|
|
441
|
-
const root = repository.rootPackage;
|
|
442
|
-
const anyBumped = memberEntries.some(e => e.status === 'bump');
|
|
443
|
-
if (!anyBumped) {
|
|
444
|
-
return { package: root, groupKey: '__root__', group: 'root', status: 'no-change', from: root.version };
|
|
445
|
-
}
|
|
446
|
-
const calendar = usesCalendarVersion({
|
|
447
|
-
groupCount: context.groupCount,
|
|
448
|
-
rootVersion: root.version,
|
|
449
|
-
lastReleaseVersion: context.lastReleaseVersion,
|
|
450
|
-
});
|
|
451
|
-
const finalVersions = memberEntries.map(e => e.to ?? e.from);
|
|
452
|
-
const to = calendar ? formatCalendarVersion(context.now()) : maxVersion(finalVersions);
|
|
453
|
-
return {
|
|
454
|
-
package: root,
|
|
455
|
-
groupKey: '__root__',
|
|
456
|
-
group: 'root',
|
|
457
|
-
status: 'bump',
|
|
458
|
-
from: root.version,
|
|
459
|
-
to,
|
|
460
|
-
reason: calendar
|
|
461
|
-
? 'repository release identity - several version lines, so no shared number to report'
|
|
462
|
-
: 'informational - monorepo root is never published on its own',
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
/** `.rmanrc version.commitMessage` (root-level; `{version}` is replaced when every bumped package
|
|
466
|
-
* in this commit shares one version) - defaults to `"chore(release): v{version}"`, or a plain
|
|
467
|
-
* listing of `name@version` pairs when this particular commit spans different versions (a
|
|
468
|
-
* cross-group ripple can land a lone forced patch in a group that otherwise didn't move). */
|
|
469
|
-
function buildCommitMessage(repository, entries, messageOverride) {
|
|
470
|
-
const versions = new Set(entries.map(e => e.to));
|
|
471
|
-
if (versions.size === 1) {
|
|
472
|
-
const template = messageOverride ?? repository.rootPackage.config?.version?.commitMessage;
|
|
473
|
-
const version = entries[0].to;
|
|
474
|
-
if (typeof template === 'string' && template)
|
|
475
|
-
return template.replace(/\{version\}/g, version);
|
|
476
|
-
return `chore(release): v${version}`;
|
|
477
|
-
}
|
|
478
|
-
if (messageOverride)
|
|
479
|
-
return messageOverride;
|
|
480
|
-
return `chore(release): ${entries.map(e => `${e.package.name}@${e.to}`).join(', ')}`;
|
|
481
|
-
}
|
|
482
|
-
/** A `version.<key>` value: one command, or several to run in sequence - same shape as
|
|
483
|
-
* `run.<script>.script`/`.preScript`/`.postScript`. */
|
|
484
|
-
function normalizeScriptValue(value) {
|
|
485
|
-
if (typeof value === 'string')
|
|
486
|
-
return value || undefined;
|
|
487
|
-
if (Array.isArray(value)) {
|
|
488
|
-
const parts = value.filter((v) => typeof v === 'string' && !!v);
|
|
489
|
-
return parts.length ? parts.join(' && ') : undefined;
|
|
490
|
-
}
|
|
491
|
-
return undefined;
|
|
492
|
-
}
|
|
293
|
+
VersionService.stampSourceFiles = stampSourceFiles;
|
|
294
|
+
})(VersionService || (VersionService = {}));
|
|
493
295
|
/**
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
296
|
+
* The lifecycle name `runVersionScript` asks the contributed step sources about. `'version'` because
|
|
297
|
+
* that is what the operation is called - which npm then spells `preversion`/`version`/`postversion`
|
|
298
|
+
* on its own, since `pre`/`post` is its convention and its source knows it. Another ecosystem's
|
|
299
|
+
* source is free to answer this name however it spells the same idea.
|
|
498
300
|
*/
|
|
499
|
-
|
|
500
|
-
const own = pkg.json.scripts?.[npmScriptName];
|
|
501
|
-
const command = typeof own === 'string' && own ? own : normalizeScriptValue(pkg.config?.version?.[cfgKey]);
|
|
502
|
-
if (command)
|
|
503
|
-
await exec(command, { cwd: pkg.dirname, stdio: 'inherit' });
|
|
504
|
-
}
|
|
301
|
+
const VERSION_LIFECYCLE = 'version';
|
|
505
302
|
/**
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* into the same commit) and `undefined` otherwise.
|
|
303
|
+
* `.rmanrc "version.stamp"`, normalized: a bare string is the file, an object may also name the
|
|
304
|
+
* identifier that holds the version (`{ file: 'src/version.go', constant: 'Version' }`).
|
|
509
305
|
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
* both later than it needs to be and invisible to git.
|
|
514
|
-
*
|
|
515
|
-
* The same path `publish --target docker` builds from (`publish.docker.dockerfile`, default
|
|
516
|
-
* `Dockerfile`), so the two can never disagree about which file this is. Opt out with `.rmanrc
|
|
517
|
-
* "version": { "stampDockerfile": false }`; a package with no Dockerfile, or one that doesn't
|
|
518
|
-
* declare the label, is a no-op either way.
|
|
306
|
+
* The object form exists because the identifier was unnameable: `stampVersionConstant` took a
|
|
307
|
+
* `name` and nothing ever passed it, so only the exact lowercase word `version` was ever matched -
|
|
308
|
+
* `VERSION`, `Version` and `appVersion` were all silently skipped.
|
|
519
309
|
*/
|
|
520
|
-
function
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
310
|
+
function readStampEntries(pkg) {
|
|
311
|
+
const configured = pkg.config?.version?.stamp;
|
|
312
|
+
const list = Array.isArray(configured) ? configured : configured ? [configured] : [];
|
|
313
|
+
const entries = [];
|
|
314
|
+
for (const item of list) {
|
|
315
|
+
if (typeof item === 'string')
|
|
316
|
+
entries.push({ file: item });
|
|
317
|
+
else if (item && typeof item === 'object' && typeof item.file === 'string') {
|
|
318
|
+
entries.push({ file: item.file, constant: item.constant });
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return entries;
|
|
531
322
|
}
|
|
532
323
|
/**
|
|
533
|
-
*
|
|
534
|
-
*
|
|
324
|
+
* Throws unless every `.rmanrc "version.stamp"` file that exists for `pkg` holds a version its own
|
|
325
|
+
* ecosystem can rewrite - the dry half of `stampSourceFiles`, run before anything is written.
|
|
535
326
|
*
|
|
536
|
-
*
|
|
537
|
-
* saying "this file holds the version", and the assignment this matches is deliberately broad. A
|
|
538
|
-
* listed file a package doesn't have is a silent no-op, which is what lets one `"[*]"` declaration
|
|
539
|
-
* cover a repo where only some packages carry one.
|
|
327
|
+
* A file that is already at `version` passes: it matched, which is the question being asked here.
|
|
540
328
|
*/
|
|
541
|
-
function
|
|
542
|
-
const
|
|
543
|
-
|
|
544
|
-
const stamped = [];
|
|
545
|
-
for (const rel of patterns) {
|
|
546
|
-
const file = path.resolve(pkg.dirname, rel);
|
|
329
|
+
function assertStampable(pkg, version) {
|
|
330
|
+
for (const entry of readStampEntries(pkg)) {
|
|
331
|
+
const file = path.resolve(pkg.dirname, entry.file);
|
|
547
332
|
if (!fs.existsSync(file))
|
|
548
333
|
continue;
|
|
549
|
-
const next =
|
|
550
|
-
|
|
334
|
+
const next = Manifest.stampVersion(pkg, file, fs.readFileSync(file, 'utf-8'), version, {
|
|
335
|
+
constant: entry.constant,
|
|
336
|
+
});
|
|
337
|
+
if (next !== undefined)
|
|
551
338
|
continue;
|
|
552
|
-
|
|
553
|
-
|
|
339
|
+
const relative = path.relative(pkg.dirname, file);
|
|
340
|
+
throw new Error(`"version.stamp" lists "${relative}" for "${pkg.name}", but nothing in it could be ` +
|
|
341
|
+
`rewritten to ${version}.\n` +
|
|
342
|
+
(pkg.provider
|
|
343
|
+
? ` The "${pkg.provider}" provider looked and found no version to change. Name the ` +
|
|
344
|
+
`identifier with { file, constant } if it is not "version", or drop the entry.`
|
|
345
|
+
: ` This package belongs to no ecosystem (no plugin claimed it), so nothing knows how a ` +
|
|
346
|
+
`version is declared in it. Name a plugin in .rmanrc "plugins".`));
|
|
554
347
|
}
|
|
555
|
-
return stamped;
|
|
556
348
|
}
|