rman 2.29.0 → 2.31.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/builtins/platforms/node/node-manifest.provider.d.ts +3 -0
- package/builtins/platforms/node/node-manifest.provider.js +20 -0
- package/builtins/platforms/node/services/publish.service.js +5 -4
- package/builtins/publish-targets/cloudflare/cloudflare-publish.service.js +4 -3
- package/builtins/publish-targets/docker/docker-publish.service.js +34 -9
- package/commands/publish.command.js +55 -12
- package/constants.js +1 -1
- package/core/interfaces/manifest.d.ts +11 -0
- package/core/interfaces/manifest.js +7 -0
- package/core/interfaces/publish-target.d.ts +9 -0
- package/package.json +1 -1
- package/services/changelog.service.js +6 -1
- package/services/version-plan.service.d.ts +3 -3
- package/services/version-plan.service.js +20 -41
- package/utils/bundled-packages.d.ts +22 -0
- package/utils/bundled-packages.js +91 -0
- package/utils/exec.d.ts +4 -2
- package/utils/exec.js +1 -1
|
@@ -18,6 +18,9 @@ export declare class NodeManifestProvider implements ManifestProvider {
|
|
|
18
18
|
* that does not hold resolves its own way, which is why this is the provider's job.
|
|
19
19
|
*/
|
|
20
20
|
dependencies(manifest: Manifest, candidates: readonly Package[]): Package[];
|
|
21
|
+
/** `dependencies`, `optionalDependencies` and the peers that are not optional - everything but
|
|
22
|
+
* what only a developer of the package installs. */
|
|
23
|
+
runtimeDependencies(manifest: Manifest, candidates: readonly Package[]): Package[];
|
|
21
24
|
/** npm's `@scope/name`. A name with no `/` has no scope and is its own unscoped form; the
|
|
22
25
|
* *last* `/` splits it, so `@scope/a/b` keeps `@scope/a` as the scope the registry would. */
|
|
23
26
|
splitName(name: string): {
|
|
@@ -58,6 +58,26 @@ export class NodeManifestProvider {
|
|
|
58
58
|
}
|
|
59
59
|
return result;
|
|
60
60
|
}
|
|
61
|
+
/** `dependencies`, `optionalDependencies` and the peers that are not optional - everything but
|
|
62
|
+
* what only a developer of the package installs. */
|
|
63
|
+
runtimeDependencies(manifest, candidates) {
|
|
64
|
+
const optionalPeers = this.optionalPeerNames(manifest);
|
|
65
|
+
const byName = new Map(candidates.map(p => [p.name, p]));
|
|
66
|
+
const result = [];
|
|
67
|
+
for (const key of ['dependencies', 'optionalDependencies', 'peerDependencies']) {
|
|
68
|
+
const declared = manifest.raw[key];
|
|
69
|
+
if (!declared || typeof declared !== 'object')
|
|
70
|
+
continue;
|
|
71
|
+
for (const name of Object.keys(declared)) {
|
|
72
|
+
if (key === 'peerDependencies' && optionalPeers.has(name))
|
|
73
|
+
continue;
|
|
74
|
+
const pkg = byName.get(name);
|
|
75
|
+
if (pkg && !result.includes(pkg))
|
|
76
|
+
result.push(pkg);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
61
81
|
/** npm's `@scope/name`. A name with no `/` has no scope and is its own unscoped form; the
|
|
62
82
|
* *last* `/` splits it, so `@scope/a/b` keeps `@scope/a` as the scope the registry would. */
|
|
63
83
|
splitName(name) {
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import fs from 'node:fs';
|
|
18
18
|
import path from 'node:path';
|
|
19
|
+
import { filesOwnedBy } from '../../../../utils/bundled-packages.js';
|
|
19
20
|
import { exec } from '../../../../utils/exec.js';
|
|
20
|
-
import { dirtyReason,
|
|
21
|
+
import { dirtyReason, GitHelper } from '../../../../utils/git.js';
|
|
21
22
|
import { filterPackages } from '../../../../utils/package-filter.js';
|
|
22
23
|
import { isCalendarVersion } from '../../../../utils/release-version.js';
|
|
23
24
|
import { npmViewPackage } from '../../../publish-targets/npm/npm-view.js';
|
|
@@ -197,7 +198,7 @@ export var PublishService;
|
|
|
197
198
|
const git = new GitHelper({ cwd: repository.dirname });
|
|
198
199
|
const packages = filterPackages(repository.getPackages({ toposort: true }), options).filter(pkg => options.shipsHere?.(pkg) ?? true);
|
|
199
200
|
const dirtyFiles = await git.listDirtyFiles({ absolute: true });
|
|
200
|
-
const isDirty = (pkg) =>
|
|
201
|
+
const isDirty = (pkg) => filesOwnedBy(dirtyFiles, pkg).length > 0;
|
|
201
202
|
/** Per package, not per run: `resolveRegistry` reads the package's own `publishConfig.registry`
|
|
202
203
|
* when `--registry` was not given, so the question is asked where the answer lives. The test
|
|
203
204
|
* seam keeps its `(name, cwd)` shape - a stub answers from a map and has no registry to
|
|
@@ -250,7 +251,7 @@ export var PublishService;
|
|
|
250
251
|
package: pkg,
|
|
251
252
|
version: pkg.version,
|
|
252
253
|
status: options.ignoreDirty ? 'skip' : 'error',
|
|
253
|
-
reason: dirtyReason(
|
|
254
|
+
reason: dirtyReason(filesOwnedBy(dirtyFiles, pkg), repository.dirname),
|
|
254
255
|
});
|
|
255
256
|
}
|
|
256
257
|
else {
|
|
@@ -371,7 +372,7 @@ export var PublishService;
|
|
|
371
372
|
}), {
|
|
372
373
|
cwd: publishDir,
|
|
373
374
|
app: pkg.repository.app,
|
|
374
|
-
stdio: '
|
|
375
|
+
stdio: 'stderr',
|
|
375
376
|
});
|
|
376
377
|
result.push(entry);
|
|
377
378
|
}
|
|
@@ -2,7 +2,8 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { Service } from '../../../core/classes/service.js';
|
|
4
4
|
import { targetsOf } from '../../../core/interfaces/publish-target.js';
|
|
5
|
-
import {
|
|
5
|
+
import { filesOwnedBy } from '../../../utils/bundled-packages.js';
|
|
6
|
+
import { dirtyReason, GitHelper } from '../../../utils/git.js';
|
|
6
7
|
import { filterPackages } from '../../../utils/package-filter.js';
|
|
7
8
|
import { runBin } from '../../../utils/run-bin.js';
|
|
8
9
|
/** The name this target answers to in `publish.target` and `--target`. */
|
|
@@ -34,7 +35,7 @@ export class CloudflarePublishService extends Service {
|
|
|
34
35
|
const git = new GitHelper({ cwd: repository.dirname });
|
|
35
36
|
const packages = filterPackages(repository.getPackages({ toposort: true }), options).filter(pkg => targetsOf(this.app, pkg).some(t => t.name === CLOUDFLARE_TARGET) && !pkg.config.publish?.skip);
|
|
36
37
|
const dirtyFiles = await git.listDirtyFiles({ absolute: true });
|
|
37
|
-
const isDirty = (pkg) =>
|
|
38
|
+
const isDirty = (pkg) => filesOwnedBy(dirtyFiles, pkg).length > 0;
|
|
38
39
|
const credentials = this.credentials();
|
|
39
40
|
const isDeployed = deps.isDeployed ?? ((deploy) => this.isDeployed(deploy));
|
|
40
41
|
return Promise.all(packages.map(async (pkg) => {
|
|
@@ -51,7 +52,7 @@ export class CloudflarePublishService extends Service {
|
|
|
51
52
|
return {
|
|
52
53
|
...located,
|
|
53
54
|
status: options.ignoreDirty ? 'skip' : 'error',
|
|
54
|
-
reason: dirtyReason(
|
|
55
|
+
reason: dirtyReason(filesOwnedBy(dirtyFiles, pkg), repository.dirname),
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
if (!credentials) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { promisify } from 'node:util';
|
|
5
6
|
import { Service } from '../../../core/classes/service.js';
|
|
6
7
|
import { targetsOf } from '../../../core/interfaces/publish-target.js';
|
|
8
|
+
import { filesOwnedBy } from '../../../utils/bundled-packages.js';
|
|
7
9
|
import { exec } from '../../../utils/exec.js';
|
|
8
|
-
import { dirtyReason,
|
|
10
|
+
import { dirtyReason, GitHelper } from '../../../utils/git.js';
|
|
9
11
|
import { filterPackages } from '../../../utils/package-filter.js';
|
|
10
12
|
import { isCalendarVersion } from '../../../utils/release-version.js';
|
|
11
13
|
/**
|
|
@@ -43,7 +45,7 @@ export class DockerPublishService extends Service {
|
|
|
43
45
|
* where a package ships. */
|
|
44
46
|
const packages = filterPackages(repository.getPackages({ toposort: true }), options).filter(pkg => targetsOf(this.app, pkg).some(t => t.name === DOCKER_TARGET) && !pkg.config.publish?.skip);
|
|
45
47
|
const dirtyFiles = await git.listDirtyFiles({ absolute: true });
|
|
46
|
-
const isDirty = (pkg) =>
|
|
48
|
+
const isDirty = (pkg) => filesOwnedBy(dirtyFiles, pkg).length > 0;
|
|
47
49
|
const imageExists = deps.imageExists ?? defaultImageExists;
|
|
48
50
|
const entries = new Map();
|
|
49
51
|
const toCheck = [];
|
|
@@ -73,7 +75,7 @@ export class DockerPublishService extends Service {
|
|
|
73
75
|
image,
|
|
74
76
|
detail: image,
|
|
75
77
|
status: options.ignoreDirty ? 'skip' : 'error',
|
|
76
|
-
reason: dirtyReason(
|
|
78
|
+
reason: dirtyReason(filesOwnedBy(dirtyFiles, pkg), repository.dirname),
|
|
77
79
|
});
|
|
78
80
|
continue;
|
|
79
81
|
}
|
|
@@ -112,7 +114,7 @@ export class DockerPublishService extends Service {
|
|
|
112
114
|
await exec('docker buildx create --use', {
|
|
113
115
|
cwd: repository.dirname,
|
|
114
116
|
app: repository.app,
|
|
115
|
-
stdio: '
|
|
117
|
+
stdio: 'stderr',
|
|
116
118
|
throwOnError: false,
|
|
117
119
|
});
|
|
118
120
|
const result = [];
|
|
@@ -122,9 +124,9 @@ export class DockerPublishService extends Service {
|
|
|
122
124
|
continue;
|
|
123
125
|
}
|
|
124
126
|
try {
|
|
125
|
-
await buildAndPush(repository, entry);
|
|
127
|
+
const digest = await buildAndPush(repository, entry);
|
|
126
128
|
await updateDescription(entry);
|
|
127
|
-
result.push(entry);
|
|
129
|
+
result.push(digest ? { ...entry, artifact: { ref: entry.image, digest } } : entry);
|
|
128
130
|
}
|
|
129
131
|
catch (e) {
|
|
130
132
|
result.push({ ...entry, status: 'error', reason: e.message });
|
|
@@ -204,7 +206,7 @@ async function dockerLogin(app, cwd) {
|
|
|
204
206
|
await exec(`echo "${password}" | docker login --username "${username}" --password-stdin`, {
|
|
205
207
|
cwd,
|
|
206
208
|
app,
|
|
207
|
-
stdio: '
|
|
209
|
+
stdio: 'stderr',
|
|
208
210
|
});
|
|
209
211
|
}
|
|
210
212
|
async function buildAndPush(repository, entry) {
|
|
@@ -233,6 +235,11 @@ async function buildAndPush(repository, entry) {
|
|
|
233
235
|
args.push('-f', `"${dockerfile}"`);
|
|
234
236
|
for (const tag of imageTags(pkg))
|
|
235
237
|
args.push('-t', `"${entry.image}:${tag}"`);
|
|
238
|
+
/** buildx writes what it pushed here - `containerimage.digest` is the pushed index's own, the
|
|
239
|
+
* address `docker buildx imagetools inspect` reports for the tag right after. */
|
|
240
|
+
const metadataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rman-buildx-'));
|
|
241
|
+
const metadataFile = path.join(metadataDir, 'metadata.json');
|
|
242
|
+
args.push('--metadata-file', `"${metadataFile}"`);
|
|
236
243
|
args.push('--push', '.');
|
|
237
244
|
/** **Shown as it runs and kept**, so a failure can say why. It ran with `stdio: 'inherit'`, and the
|
|
238
245
|
* one thing left to report was the exit code - measured on `panates/syncbridge`, the line that
|
|
@@ -248,8 +255,26 @@ async function buildAndPush(repository, entry) {
|
|
|
248
255
|
process.stderr.write(line + '\n');
|
|
249
256
|
},
|
|
250
257
|
});
|
|
251
|
-
|
|
252
|
-
|
|
258
|
+
try {
|
|
259
|
+
if (result.code)
|
|
260
|
+
throw new Error(`docker build exited with code ${result.code}${failureLines(lines)}`);
|
|
261
|
+
return readPushedDigest(metadataFile);
|
|
262
|
+
}
|
|
263
|
+
finally {
|
|
264
|
+
fs.rmSync(metadataDir, { recursive: true, force: true });
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/** The digest buildx recorded for what it pushed, or `undefined` when its metadata says none. */
|
|
268
|
+
/* Unreadable metadata is not a failed publish - the image is on the registry either way - so it
|
|
269
|
+
* reads as "no digest", which leaves the entry without an `artifact` rather than failing it. */
|
|
270
|
+
function readPushedDigest(file) {
|
|
271
|
+
try {
|
|
272
|
+
const digest = JSON.parse(fs.readFileSync(file, 'utf-8'))['containerimage.digest'];
|
|
273
|
+
return typeof digest === 'string' && /^sha256:[0-9a-f]{64}$/.test(digest) ? digest : undefined;
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
253
278
|
}
|
|
254
279
|
/**
|
|
255
280
|
* The lines of a failed build worth putting in a one-paragraph reason: those saying "error", with
|
|
@@ -36,8 +36,10 @@ const config = {
|
|
|
36
36
|
json: {
|
|
37
37
|
target: 'cli',
|
|
38
38
|
alias: 'j',
|
|
39
|
-
describe: 'Print
|
|
40
|
-
'
|
|
39
|
+
describe: 'Print JSON instead of text - one entry per package and target. With --dry-run it is the plan ' +
|
|
40
|
+
'("is there anything to publish?", e.g. a CI release gate); otherwise it is printed once the ' +
|
|
41
|
+
'run is over and says what happened: "published" entries, with the digest a registry returned ' +
|
|
42
|
+
'under "artifact".',
|
|
41
43
|
type: 'boolean',
|
|
42
44
|
},
|
|
43
45
|
ignoreDirty: {
|
|
@@ -151,10 +153,18 @@ const publishCommand = registerCommand(app => {
|
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
/** One document per run, whichever way it ends: the plan under `--dry-run` or on any exit
|
|
157
|
+
* before publishing, what happened once it has. */
|
|
158
|
+
let printed = false;
|
|
159
|
+
const printJson = (doc) => {
|
|
160
|
+
if (!args.json || printed)
|
|
161
|
+
return;
|
|
162
|
+
printed = true;
|
|
163
|
+
console.log(JSON.stringify(doc, undefined, 2));
|
|
164
|
+
};
|
|
165
|
+
if (args.dryRun)
|
|
166
|
+
printJson(jsonPlan(plans));
|
|
167
|
+
if (!args.json) {
|
|
158
168
|
for (const [target, plan] of plans) {
|
|
159
169
|
printPlan(plan, target.name);
|
|
160
170
|
printFiles(plan, target);
|
|
@@ -165,12 +175,14 @@ const publishCommand = registerCommand(app => {
|
|
|
165
175
|
if (requested?.length) {
|
|
166
176
|
const empty = [...plans].filter(([, plan]) => !plan.length).map(([target]) => target.name);
|
|
167
177
|
if (empty.length) {
|
|
178
|
+
printJson(jsonPlan(plans));
|
|
168
179
|
throw logged(`--target ${empty.join(', ')} was given, but no package ships there ` + '(see .rmanrc "publish.target").');
|
|
169
180
|
}
|
|
170
181
|
}
|
|
171
182
|
const all = [...plans.values()].flat();
|
|
172
183
|
const errors = all.filter(e => e.status === 'error');
|
|
173
184
|
if (errors.length) {
|
|
185
|
+
printJson(jsonPlan(plans));
|
|
174
186
|
const allDirty = errors.every(e => e.reason?.startsWith(UNCOMMITTED));
|
|
175
187
|
throw logged(allDirty
|
|
176
188
|
? `${errors.length} package(s) have uncommitted local changes ` +
|
|
@@ -178,6 +190,7 @@ const publishCommand = registerCommand(app => {
|
|
|
178
190
|
: `${errors.length} package(s) failed to prepare for publish - see the errors above`);
|
|
179
191
|
}
|
|
180
192
|
if (!all.some(e => e.status === 'publish')) {
|
|
193
|
+
printJson(jsonPlan(plans));
|
|
181
194
|
if (!args.json)
|
|
182
195
|
console.log(colors.gray('Nothing to publish.'));
|
|
183
196
|
return;
|
|
@@ -187,14 +200,18 @@ const publishCommand = registerCommand(app => {
|
|
|
187
200
|
let proceed = !!args.yes;
|
|
188
201
|
if (!proceed) {
|
|
189
202
|
if (!process.stdout.isTTY) {
|
|
190
|
-
|
|
203
|
+
printJson(jsonPlan(plans));
|
|
204
|
+
console.error(colors.gray('Not a TTY - refusing to prompt. Pass --yes to publish non-interactively.'));
|
|
191
205
|
return;
|
|
192
206
|
}
|
|
193
207
|
proceed = await confirm('Publish these packages?');
|
|
194
208
|
}
|
|
195
|
-
if (!proceed)
|
|
209
|
+
if (!proceed) {
|
|
210
|
+
printJson(jsonPlan(plans));
|
|
196
211
|
return;
|
|
212
|
+
}
|
|
197
213
|
const outcomes = [];
|
|
214
|
+
const results = new Map();
|
|
198
215
|
const publishedBy = new Map();
|
|
199
216
|
let waited = false;
|
|
200
217
|
for (const [target, plan] of plans) {
|
|
@@ -213,10 +230,12 @@ const publishCommand = registerCommand(app => {
|
|
|
213
230
|
finally {
|
|
214
231
|
staged?.restore();
|
|
215
232
|
}
|
|
216
|
-
|
|
233
|
+
results.set(target, applied);
|
|
234
|
+
const done = printApplied(applied, plan, target.name, args.json ? console.error : console.log);
|
|
217
235
|
outcomes.push(...done);
|
|
218
236
|
publishedBy.set(target, done.filter(o => o.entry.status === 'publish').map(o => o.entry));
|
|
219
237
|
}
|
|
238
|
+
printJson(jsonResult(plans, results));
|
|
220
239
|
if (!args.json)
|
|
221
240
|
printRecap(outcomes);
|
|
222
241
|
writeStepSummary(outcomes);
|
|
@@ -339,6 +358,30 @@ function jsonPlan(plans) {
|
|
|
339
358
|
reason: entry.reason,
|
|
340
359
|
})));
|
|
341
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* `--json` once the run has published: the plan's rows, each as it ended - `published` for one that
|
|
363
|
+
* went up (with the registry's `artifact`, where the target reports one), `error` for one that did
|
|
364
|
+
* not, and a row nothing was asked of as it was planned.
|
|
365
|
+
*/
|
|
366
|
+
/* **`published`, not the plan's `publish`**, so a document read after the run cannot be mistaken
|
|
367
|
+
* for a plan that has yet to happen. The release workflow counts these and takes the digests from
|
|
368
|
+
* `artifact` - `syncbridge-io/syncbridge` deploys by them. */
|
|
369
|
+
function jsonResult(plans, results) {
|
|
370
|
+
return [...plans].flatMap(([target, plan]) => plan.map(planned => {
|
|
371
|
+
const entry = planned.status === 'publish'
|
|
372
|
+
? (results.get(target)?.find(e => e.package === planned.package) ?? planned)
|
|
373
|
+
: planned;
|
|
374
|
+
return {
|
|
375
|
+
name: entry.package.name,
|
|
376
|
+
target: target.name,
|
|
377
|
+
status: planned.status === 'publish' && entry.status === 'publish' ? 'published' : entry.status,
|
|
378
|
+
version: entry.version,
|
|
379
|
+
detail: entry.detail,
|
|
380
|
+
reason: entry.reason,
|
|
381
|
+
...(entry.artifact && { artifact: entry.artifact }),
|
|
382
|
+
};
|
|
383
|
+
}));
|
|
384
|
+
}
|
|
342
385
|
function printPlan(entries, label) {
|
|
343
386
|
const prefix = colors.gray(`[${label}] `);
|
|
344
387
|
for (const e of entries) {
|
|
@@ -392,17 +435,17 @@ async function waitForPublished(ctx, publishedBy) {
|
|
|
392
435
|
* was already an error before anything ran has been printed once by `printPlan`, and printing it
|
|
393
436
|
* again under "failed" would read as a push that was attempted and did not work.
|
|
394
437
|
*/
|
|
395
|
-
function printApplied(applied, plan, label) {
|
|
438
|
+
function printApplied(applied, plan, label, log) {
|
|
396
439
|
const prefix = colors.gray(`[${label}] `);
|
|
397
440
|
const outcomes = [];
|
|
398
441
|
for (const entry of applied) {
|
|
399
442
|
if (plan.find(e => e.package === entry.package)?.status !== 'publish')
|
|
400
443
|
continue;
|
|
401
444
|
if (entry.status === 'publish') {
|
|
402
|
-
|
|
445
|
+
log(colors.green('published'), prefix + colors.cyan(entry.package.name), entry.detail ?? entry.version);
|
|
403
446
|
}
|
|
404
447
|
else if (entry.status === 'error') {
|
|
405
|
-
|
|
448
|
+
log(colors.red('failed'), prefix + colors.cyan(entry.package.name), colors.red(entry.reason ?? ''));
|
|
406
449
|
}
|
|
407
450
|
else
|
|
408
451
|
continue;
|
package/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.31.0';
|
|
@@ -113,6 +113,14 @@ export interface ManifestProvider {
|
|
|
113
113
|
* Omit it and a package has no declared dependencies beyond `.rmanrc "dependencies"`.
|
|
114
114
|
*/
|
|
115
115
|
dependencies?(manifest: Manifest, candidates: readonly Package[]): Package[];
|
|
116
|
+
/**
|
|
117
|
+
* Which of `candidates` this package's artifact needs where it runs - what a consumer installs
|
|
118
|
+
* with it, or what an image built from it carries. A subset of `dependencies`: npm leaves out
|
|
119
|
+
* `devDependencies` and optional peers.
|
|
120
|
+
*
|
|
121
|
+
* Omit it and every dependency counts.
|
|
122
|
+
*/
|
|
123
|
+
runtimeDependencies?(manifest: Manifest, candidates: readonly Package[]): Package[];
|
|
116
124
|
/**
|
|
117
125
|
* Splits a package name into the parts a config expression can ask for - `${{ pkg.scope }}` and
|
|
118
126
|
* `${{ pkg.unscopedName }}`.
|
|
@@ -245,6 +253,9 @@ export declare namespace Manifest {
|
|
|
245
253
|
* of can still describe its own graph by hand.
|
|
246
254
|
*/
|
|
247
255
|
function dependenciesOf(pkg: Package, candidates: readonly Package[]): Package[];
|
|
256
|
+
/** The packages `pkg`'s artifact needs at run time - see `ManifestProvider.runtimeDependencies`.
|
|
257
|
+
* Every declared dependency when the provider has no opinion. */
|
|
258
|
+
function runtimeDependenciesOf(pkg: Package, candidates: readonly Package[]): Package[];
|
|
248
259
|
/** `${{ pkg.scope }}`/`${{ pkg.unscopedName }}`, by whichever provider recognizes `dir` - and
|
|
249
260
|
* "no scope, the name is its own unscoped form" when none has an opinion. */
|
|
250
261
|
function splitName(app: RmanApplication, dir: string, name: string): {
|
|
@@ -67,6 +67,13 @@ export var Manifest;
|
|
|
67
67
|
return platformOf(pkg)?.manifestProvider.dependencies?.(pkg.manifest, candidates) ?? [];
|
|
68
68
|
}
|
|
69
69
|
Manifest.dependenciesOf = dependenciesOf;
|
|
70
|
+
/** The packages `pkg`'s artifact needs at run time - see `ManifestProvider.runtimeDependencies`.
|
|
71
|
+
* Every declared dependency when the provider has no opinion. */
|
|
72
|
+
function runtimeDependenciesOf(pkg, candidates) {
|
|
73
|
+
const provider = platformOf(pkg)?.manifestProvider;
|
|
74
|
+
return (provider?.runtimeDependencies ?? provider?.dependencies)?.call(provider, pkg.manifest, candidates) ?? [];
|
|
75
|
+
}
|
|
76
|
+
Manifest.runtimeDependenciesOf = runtimeDependenciesOf;
|
|
70
77
|
/** `${{ pkg.scope }}`/`${{ pkg.unscopedName }}`, by whichever provider recognizes `dir` - and
|
|
71
78
|
* "no scope, the name is its own unscoped form" when none has an opinion. */
|
|
72
79
|
function splitName(app, dir, name) {
|
|
@@ -129,6 +129,15 @@ export declare namespace PublishTarget {
|
|
|
129
129
|
/** Printed after the package name - docker's resolved `<namespace>/<image>`, for instance. */
|
|
130
130
|
detail?: string;
|
|
131
131
|
reason?: string;
|
|
132
|
+
/**
|
|
133
|
+
* What `applyPlan` actually pushed, when the registry names it by content: `ref` is where it went
|
|
134
|
+
* and `digest` the content address the registry returned. Set by a target on a published entry,
|
|
135
|
+
* never in a plan - nothing has been pushed yet there.
|
|
136
|
+
*/
|
|
137
|
+
artifact?: {
|
|
138
|
+
ref: string;
|
|
139
|
+
digest: string;
|
|
140
|
+
};
|
|
132
141
|
}
|
|
133
142
|
}
|
|
134
143
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { Service } from '../core/classes/service.js';
|
|
4
|
+
import { bundledPackages } from '../utils/bundled-packages.js';
|
|
4
5
|
import { GitHelper } from '../utils/git.js';
|
|
5
6
|
import { filterPackages } from '../utils/package-filter.js';
|
|
6
7
|
import { groupKeyOf } from '../utils/version-group.js';
|
|
@@ -181,6 +182,10 @@ export class ChangelogService extends Service {
|
|
|
181
182
|
* --changelog` and `github-release` see too, since both pass an explicit boundary.
|
|
182
183
|
*/
|
|
183
184
|
const dirsAt = homesAt(homes, commitsByTarget[i]);
|
|
185
|
+
/** A member's commits include those of the unversioned packages it carries - the same rule
|
|
186
|
+
* `version` bumps by (`bundledPackages`), or a release would be cut for a change its notes
|
|
187
|
+
* never mention. */
|
|
188
|
+
const owns = new Set([...group.members].flatMap(m => [m, ...bundledPackages(m)]));
|
|
184
189
|
const floor = await resolveStartingPoint(git, pkg, options);
|
|
185
190
|
const floorIndex = floor?.sha ? commitsByTarget[i].findIndex(c => c.sha === floor.sha) : -1;
|
|
186
191
|
const withUnreleased = resolveUnreleased(pkg, options);
|
|
@@ -193,7 +198,7 @@ export class ChangelogService extends Service {
|
|
|
193
198
|
continue;
|
|
194
199
|
/** A commit belongs to a group when it belongs to **any** of its members - one line for a
|
|
195
200
|
* commit touching two of them, which is the whole reason a group shares a file. */
|
|
196
|
-
const ownCommits = dropVersionBumps(segment.commits).filter(c => [...ownersOf(repository, c, dirsAt(c))].some(owner =>
|
|
201
|
+
const ownCommits = dropVersionBumps(segment.commits).filter(c => [...ownersOf(repository, c, dirsAt(c))].some(owner => owns.has(owner)));
|
|
197
202
|
if (!ownCommits.length)
|
|
198
203
|
continue;
|
|
199
204
|
const sections = groupCommits(ownCommits, ignoreTypesConfig(pkg), titles, order, withCommitHash(pkg, options));
|
|
@@ -72,9 +72,9 @@ export declare abstract class VersionPlanService {
|
|
|
72
72
|
*/
|
|
73
73
|
getPlan(repository: Repository, options?: VersionPlanService.Options): Promise<VersionPlanService.Entry[]>;
|
|
74
74
|
/**
|
|
75
|
-
* Why `pkg` takes no version at all, or `undefined` when it does
|
|
76
|
-
*
|
|
77
|
-
*
|
|
75
|
+
* Why `pkg` takes no version at all, or `undefined` when it does - `unversionedReason`'s answer,
|
|
76
|
+
* kept `protected` so a planner can override it. A package this answers for is also one whose
|
|
77
|
+
* commits count toward the published packages that carry it (`bundledPackages`).
|
|
78
78
|
*/
|
|
79
79
|
protected notVersionedReason(pkg: Package): string | undefined;
|
|
80
80
|
/**
|
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { RmanApplication } from '../core/application.js';
|
|
3
3
|
import { assertOneScheme, semverScheme, VersionScheme } from '../core/classes/version-scheme.js';
|
|
4
4
|
import { Manifest } from '../core/interfaces/manifest.js';
|
|
5
|
-
import {
|
|
5
|
+
import { bundledPackages, unversionedReason } from '../utils/bundled-packages.js';
|
|
6
6
|
import { dirtyReason, filesUnder, GitHelper } from '../utils/git.js';
|
|
7
7
|
import { filterPackages } from '../utils/package-filter.js';
|
|
8
8
|
import { findLastReleaseVersion, formatCalendarVersion, usesCalendarVersion } from '../utils/release-version.js';
|
|
@@ -98,9 +98,14 @@ export class VersionPlanService {
|
|
|
98
98
|
}
|
|
99
99
|
const git = new GitHelper({ cwd: repository.dirname });
|
|
100
100
|
const packages = filterPackages(repository.getPackages(), options);
|
|
101
|
+
/** Each package with the unversioned packages it carries - see `bundledPackages`. Their files
|
|
102
|
+
* are the package's own for every question below: commits, and a dirty tree. */
|
|
103
|
+
const carried = new Map(packages.map(pkg => [pkg, bundledPackages(pkg, p => !!this.notVersionedReason(p))]));
|
|
104
|
+
const homesOf = (pkg) => [pkg, ...(carried.get(pkg) ?? [])].map(p => p.dirname);
|
|
101
105
|
const dirtyFiles = await git.listDirtyFiles({ absolute: true });
|
|
102
|
-
const
|
|
103
|
-
const
|
|
106
|
+
const dirtyOf = (pkg) => [...new Set(homesOf(pkg).flatMap(dir => filesUnder(dirtyFiles, dir)))];
|
|
107
|
+
const isDirty = (pkg) => dirtyOf(pkg).length > 0;
|
|
108
|
+
const dirtyReasonOf = (pkg) => dirtyReason(dirtyOf(pkg), repository.dirname);
|
|
104
109
|
const dirty = packages.filter(isDirty);
|
|
105
110
|
const entries = new Map();
|
|
106
111
|
/**
|
|
@@ -163,13 +168,19 @@ export class VersionPlanService {
|
|
|
163
168
|
}
|
|
164
169
|
const since = await this.plannerFor(pkg).detectBoundary(git, pkg, options);
|
|
165
170
|
const commits = since ? await git.listCommits({ hash: since }) : await git.listAllCommits();
|
|
166
|
-
const
|
|
171
|
+
const homes = homesOf(pkg);
|
|
172
|
+
const under = (dir, f) => !path.relative(dir, f).startsWith('..');
|
|
173
|
+
const belongsToPkg = (c) => c.files.some(f => homes.some(dir => under(dir, f)));
|
|
167
174
|
const real = commits.filter(c => belongsToPkg(c) && !ConventionalCommitsService.isReleaseCommit(c.subject, commitMessage));
|
|
168
175
|
if (!real.length)
|
|
169
176
|
return;
|
|
177
|
+
/** Named when a carried package is all that changed, or part of it - the one thing that
|
|
178
|
+
* explains a bump with no commit under the package's own directory. */
|
|
179
|
+
const via = (carried.get(pkg) ?? []).filter(dep => real.some(c => c.files.some(f => under(dep.dirname, f))));
|
|
180
|
+
const base = since ? `changed since ${since}` : 'unreleased commits';
|
|
170
181
|
changeByPackage.set(pkg.name, {
|
|
171
182
|
bump: explicitBump ?? this.detectBump(real, pkg.versionScheme),
|
|
172
|
-
reason:
|
|
183
|
+
reason: via.length ? `${base} (via ${via.map(d => d.name).join(', ')})` : base,
|
|
173
184
|
});
|
|
174
185
|
}));
|
|
175
186
|
const groups = new Map();
|
|
@@ -218,44 +229,12 @@ export class VersionPlanService {
|
|
|
218
229
|
return result;
|
|
219
230
|
}
|
|
220
231
|
/**
|
|
221
|
-
* Why `pkg` takes no version at all, or `undefined` when it does
|
|
222
|
-
*
|
|
223
|
-
*
|
|
232
|
+
* Why `pkg` takes no version at all, or `undefined` when it does - `unversionedReason`'s answer,
|
|
233
|
+
* kept `protected` so a planner can override it. A package this answers for is also one whose
|
|
234
|
+
* commits count toward the published packages that carry it (`bundledPackages`).
|
|
224
235
|
*/
|
|
225
|
-
/* **A version nothing publishes is a number nobody can install**, and that is the user's reason
|
|
226
|
-
* for reversing the old rule that `version` never reads `publish.skip`. Measured on
|
|
227
|
-
* `panates/syncbridge`: fourteen packages kept out of publishing were still bumped, tagged and
|
|
228
|
-
* written into changelogs on every release - tags with nothing on the registry behind them, and a
|
|
229
|
-
* version line that had jumped by the time publishing was switched back on.
|
|
230
|
-
*
|
|
231
|
-
* `version.skip` decides first, both ways: `true` holds back a package that does publish, `false`
|
|
232
|
-
* versions one that does not - an application deployed by other means, whose number still
|
|
233
|
-
* matters. A monorepo's root never reaches here; its version is the repository's release
|
|
234
|
-
* identity, decided by `buildRootEntry`.
|
|
235
|
-
*
|
|
236
|
-
* **A package no target ships to is still versioned**, deliberately. Tried the other way first,
|
|
237
|
-
* and it stopped versioning every package of a repository that has no publish target at all - one
|
|
238
|
-
* that versions with rman and publishes by other means, or a technology rman has no target for -
|
|
239
|
-
* which is most of the core's own spec fixtures. Only a package kept out *on purpose* is left
|
|
240
|
-
* out. */
|
|
241
236
|
notVersionedReason(pkg) {
|
|
242
|
-
|
|
243
|
-
if (declared === true)
|
|
244
|
-
return 'excluded via .rmanrc "version.skip"';
|
|
245
|
-
if (declared === false)
|
|
246
|
-
return undefined;
|
|
247
|
-
if (pkg.config.publish?.skip)
|
|
248
|
-
return 'not published - .rmanrc "publish.skip"';
|
|
249
|
-
const app = pkg.repository?.app;
|
|
250
|
-
if (!app)
|
|
251
|
-
return undefined;
|
|
252
|
-
const targets = targetsOf(app, pkg);
|
|
253
|
-
if (!targets.length)
|
|
254
|
-
return undefined;
|
|
255
|
-
const reasons = targets.map(target => skipReasonFor(pkg, target));
|
|
256
|
-
if (reasons.every(Boolean))
|
|
257
|
-
return `not published - ${reasons[0]}`;
|
|
258
|
-
return undefined;
|
|
237
|
+
return unversionedReason(pkg);
|
|
259
238
|
}
|
|
260
239
|
/**
|
|
261
240
|
* **Which planner answers for one package: its own technology's.**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Package } from '../core/classes/package.js';
|
|
2
|
+
/**
|
|
3
|
+
* Why `pkg` takes no version at all, or `undefined` when it does: `.rmanrc "version.skip"` when it
|
|
4
|
+
* says so, and otherwise whether it has been kept out of publishing - `publish.skip`, or every
|
|
5
|
+
* target that ships it leaving it out (npm's `private`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function unversionedReason(pkg: Package): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* The in-repo packages whose commits count as `pkg`'s own: those it needs at run time that take no
|
|
10
|
+
* version themselves, and theirs in turn - a versioned one stops the walk, since it releases on its
|
|
11
|
+
* own and reaches `pkg` through the ordinary cascade. Empty for a package that is itself not
|
|
12
|
+
* versioned.
|
|
13
|
+
*
|
|
14
|
+
* `isUnversioned` is the planner's answer when one is asking; `unversionedReason` otherwise.
|
|
15
|
+
*/
|
|
16
|
+
export declare function bundledPackages(pkg: Package, isUnversioned?: (p: Package) => boolean): Package[];
|
|
17
|
+
/**
|
|
18
|
+
* The files of `files` that are `pkg`'s - under its own directory or under one of the packages it
|
|
19
|
+
* carries (`bundledPackages`). What every "is this package dirty" check asks, so an artifact is
|
|
20
|
+
* never built from a carried package's uncommitted changes.
|
|
21
|
+
*/
|
|
22
|
+
export declare function filesOwnedBy(files: readonly string[], pkg: Package): string[];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Manifest } from '../core/interfaces/manifest.js';
|
|
2
|
+
import { skipReasonFor, targetsOf } from '../core/interfaces/publish-target.js';
|
|
3
|
+
import { filesUnder } from './git.js';
|
|
4
|
+
/**
|
|
5
|
+
* Why `pkg` takes no version at all, or `undefined` when it does: `.rmanrc "version.skip"` when it
|
|
6
|
+
* says so, and otherwise whether it has been kept out of publishing - `publish.skip`, or every
|
|
7
|
+
* target that ships it leaving it out (npm's `private`).
|
|
8
|
+
*/
|
|
9
|
+
/* **A version nothing publishes is a number nobody can install**, and that is the user's reason
|
|
10
|
+
* for reversing the old rule that `version` never reads `publish.skip`. Measured on
|
|
11
|
+
* `panates/syncbridge`: fourteen packages kept out of publishing were still bumped, tagged and
|
|
12
|
+
* written into changelogs on every release - tags with nothing on the registry behind them, and a
|
|
13
|
+
* version line that had jumped by the time publishing was switched back on.
|
|
14
|
+
*
|
|
15
|
+
* `version.skip` decides first, both ways: `true` holds back a package that does publish, `false`
|
|
16
|
+
* versions one that does not - an application deployed by other means, whose number still
|
|
17
|
+
* matters. A monorepo's root never reaches here; its version is the repository's release
|
|
18
|
+
* identity, decided by `buildRootEntry`.
|
|
19
|
+
*
|
|
20
|
+
* **A package no target ships to is still versioned**, deliberately. Tried the other way first,
|
|
21
|
+
* and it stopped versioning every package of a repository that has no publish target at all - one
|
|
22
|
+
* that versions with rman and publishes by other means, or a technology rman has no target for -
|
|
23
|
+
* which is most of the core's own spec fixtures. Only a package kept out *on purpose* is left
|
|
24
|
+
* out.
|
|
25
|
+
*
|
|
26
|
+
* **Here rather than on `VersionPlanService`**, which delegates to it, because `ChangelogService`
|
|
27
|
+
* asks the same question through `bundledPackages` and must work in a repository with no planner -
|
|
28
|
+
* the `groupKeyOf` arrangement. */
|
|
29
|
+
export function unversionedReason(pkg) {
|
|
30
|
+
const declared = pkg.config.version?.skip;
|
|
31
|
+
if (declared === true)
|
|
32
|
+
return 'excluded via .rmanrc "version.skip"';
|
|
33
|
+
if (declared === false)
|
|
34
|
+
return undefined;
|
|
35
|
+
if (pkg.config.publish?.skip)
|
|
36
|
+
return 'not published - .rmanrc "publish.skip"';
|
|
37
|
+
const app = pkg.repository?.app;
|
|
38
|
+
if (!app)
|
|
39
|
+
return undefined;
|
|
40
|
+
const targets = targetsOf(app, pkg);
|
|
41
|
+
if (!targets.length)
|
|
42
|
+
return undefined;
|
|
43
|
+
const reasons = targets.map(target => skipReasonFor(pkg, target));
|
|
44
|
+
if (reasons.every(Boolean))
|
|
45
|
+
return `not published - ${reasons[0]}`;
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The in-repo packages whose commits count as `pkg`'s own: those it needs at run time that take no
|
|
50
|
+
* version themselves, and theirs in turn - a versioned one stops the walk, since it releases on its
|
|
51
|
+
* own and reaches `pkg` through the ordinary cascade. Empty for a package that is itself not
|
|
52
|
+
* versioned.
|
|
53
|
+
*
|
|
54
|
+
* `isUnversioned` is the planner's answer when one is asking; `unversionedReason` otherwise.
|
|
55
|
+
*/
|
|
56
|
+
/* **Asked for on `panates/syncbridge-cloud`**: the server ships as a Docker image built from four
|
|
57
|
+
* workspace packages that are `publish.skip`, so take no version. A fix to one of them changed the
|
|
58
|
+
* image and left the server `no-change` - the four were out of the plan before any commit was read,
|
|
59
|
+
* and a commit counted only for the package whose directory held its files. A package kept out of
|
|
60
|
+
* publishing that a published one needs at run time can reach anyone only inside that published
|
|
61
|
+
* package's artifact, so a change to it *is* a change to the artifact.
|
|
62
|
+
*
|
|
63
|
+
* **Run-time edges only** (`Manifest.runtimeDependenciesOf`): a test helper kept out of publishing
|
|
64
|
+
* that a library lists under `devDependencies` would otherwise release the library on every change
|
|
65
|
+
* to it. */
|
|
66
|
+
export function bundledPackages(pkg, isUnversioned = p => !!unversionedReason(p)) {
|
|
67
|
+
const repository = pkg.repository;
|
|
68
|
+
if (!repository || isUnversioned(pkg))
|
|
69
|
+
return [];
|
|
70
|
+
const candidates = repository.packages;
|
|
71
|
+
const result = [];
|
|
72
|
+
const visit = (from) => {
|
|
73
|
+
for (const dep of Manifest.runtimeDependenciesOf(from, candidates)) {
|
|
74
|
+
if (dep === pkg || result.includes(dep) || !isUnversioned(dep))
|
|
75
|
+
continue;
|
|
76
|
+
result.push(dep);
|
|
77
|
+
visit(dep);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
visit(pkg);
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The files of `files` that are `pkg`'s - under its own directory or under one of the packages it
|
|
85
|
+
* carries (`bundledPackages`). What every "is this package dirty" check asks, so an artifact is
|
|
86
|
+
* never built from a carried package's uncommitted changes.
|
|
87
|
+
*/
|
|
88
|
+
export function filesOwnedBy(files, pkg) {
|
|
89
|
+
const dirs = [pkg, ...bundledPackages(pkg)].map(p => p.dirname);
|
|
90
|
+
return [...new Set(dirs.flatMap(dir => filesUnder(files, dir)))];
|
|
91
|
+
}
|
package/utils/exec.d.ts
CHANGED
|
@@ -10,8 +10,10 @@ export interface ExecOptions {
|
|
|
10
10
|
*/
|
|
11
11
|
app?: RmanApplication;
|
|
12
12
|
/** 'inherit' streams the child directly to our stdio (used for non-TTY/CI passthrough).
|
|
13
|
-
* '
|
|
14
|
-
|
|
13
|
+
* 'stderr' does the same with the child's stdout sent to our stderr, for a command whose own
|
|
14
|
+
* stdout is a document. 'pipe' (default) captures output so the caller can drive a live view
|
|
15
|
+
* via onLine. */
|
|
16
|
+
stdio?: 'inherit' | 'stderr' | 'pipe';
|
|
15
17
|
cwd?: string;
|
|
16
18
|
env?: Record<string, string | undefined>;
|
|
17
19
|
onLine?: (line: string, stdio: 'stderr' | 'stdout') => void;
|
package/utils/exec.js
CHANGED
|
@@ -22,7 +22,7 @@ export async function exec(command, options) {
|
|
|
22
22
|
};
|
|
23
23
|
opts.cwd = opts.cwd || process.cwd();
|
|
24
24
|
const spawnOptions = {
|
|
25
|
-
stdio: opts.stdio === 'inherit' ? 'inherit' : 'pipe',
|
|
25
|
+
stdio: opts.stdio === 'inherit' ? 'inherit' : opts.stdio === 'stderr' ? ['inherit', 2, 2] : 'pipe',
|
|
26
26
|
env: opts.env,
|
|
27
27
|
cwd: opts.cwd,
|
|
28
28
|
shell: true,
|