rman 2.34.0 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -94,7 +94,7 @@ worked examples of every single command, see **[docs/cli-rman.md](https://github
94
94
  | [`github-release`](#rman-github-release) | Creates the repository's GitHub Release for its release tag. |
95
95
  | [`import <path>`](#rman-import-path) | Imports an external git repository as a new package, with history. |
96
96
 
97
- **`ci` and `clean` come from the `node` built-in**, which ships inside this package - each is about
97
+ **`ci`, `install` and `clean` come from the `node` built-in**, which ships inside this package - each is about
98
98
  npm or TypeScript rather than about repositories. It needs no declaration: rman lays its own `node`
99
99
  preset under every repository, so a clone with no `.rmanrc` at all already has them, plus the `node`
100
100
  technology itself and the npm publish target. It used to take a second package (`rman-node`) and a
@@ -47,7 +47,10 @@ export function augmentSystemInfo() {
47
47
  const configured = options?.repository?.config?.packageManager;
48
48
  if (typeof configured === 'string')
49
49
  CiService.resolvePackageManager(options.repository);
50
- const packageManager = options?.packageManager ?? asPackageManager(configured?.node) ?? 'npm';
50
+ const packageManager = options?.packageManager ??
51
+ asPackageManager(configured?.node) ??
52
+ detected(options?.repository) ??
53
+ 'npm';
51
54
  return base({
52
55
  ...options,
53
56
  envinfo: {
@@ -80,6 +83,19 @@ function asPackageManager(value) {
80
83
  ? value
81
84
  : undefined;
82
85
  }
86
+ /** The package manager the repository's lockfile names, as `ci` and `publish` would read it. */
87
+ /* **A lockfile pair `ci` would refuse reads as no answer here**: `info` is what someone runs to find
88
+ * out what is wrong, so it must not be the command that stops on it - `ci` names the files. */
89
+ function detected(repository) {
90
+ if (!repository)
91
+ return undefined;
92
+ try {
93
+ return CiService.detectPackageManager(repository);
94
+ }
95
+ catch {
96
+ return undefined;
97
+ }
98
+ }
83
99
  /** Marks an implementation as already wrapped. A symbol rather than a property name so it cannot
84
100
  * collide with anything `envinfo` or a future core option carries. */
85
101
  const AUGMENTED = Symbol.for('rman.node.systemInfo.augmented');
@@ -12,7 +12,7 @@ const config = {
12
12
  packageManager: {
13
13
  target: 'cli',
14
14
  cliName: 'package-manager',
15
- describe: 'Package manager to install with (default: npm, or .rmanrc "packageManager")',
15
+ describe: 'Package manager to install with (default: .rmanrc "packageManager.node", else the lockfile\'s, else npm)',
16
16
  choices: CiService.PACKAGE_MANAGERS,
17
17
  },
18
18
  progress: {
@@ -0,0 +1,130 @@
1
+ import type { ArgsOf } from '../../../../index.js';
2
+ /** Hoisted for `ArgsOf`, as in `ci.command.ts`. */
3
+ declare const COMMAND: "install";
4
+ declare const config: {
5
+ packageManager: {
6
+ target: "cli";
7
+ cliName: string;
8
+ describe: string;
9
+ choices: readonly ["npm", "yarn", "pnpm", "bun"];
10
+ };
11
+ frozenLockfile: {
12
+ target: "cli";
13
+ cliName: string;
14
+ describe: string;
15
+ type: "boolean";
16
+ };
17
+ prod: {
18
+ target: "cli";
19
+ describe: string;
20
+ type: "boolean";
21
+ };
22
+ ignoreScripts: {
23
+ target: "cli";
24
+ cliName: string;
25
+ describe: string;
26
+ type: "boolean";
27
+ };
28
+ lockfileOnly: {
29
+ target: "cli";
30
+ cliName: string;
31
+ describe: string;
32
+ type: "boolean";
33
+ };
34
+ offline: {
35
+ target: "cli";
36
+ describe: string;
37
+ type: "boolean";
38
+ };
39
+ preferOffline: {
40
+ target: "cli";
41
+ cliName: string;
42
+ describe: string;
43
+ type: "boolean";
44
+ };
45
+ dryRun: {
46
+ target: "cli";
47
+ cliName: string;
48
+ describe: string;
49
+ type: "boolean";
50
+ };
51
+ registry: {
52
+ target: "cli";
53
+ describe: string;
54
+ type: "string";
55
+ };
56
+ };
57
+ type Args = ArgsOf<typeof config, typeof COMMAND>;
58
+ /**
59
+ * `rman install` / `rman i` - one install at the repository root with whichever package manager the
60
+ * repository uses, so nobody has to know which one to type.
61
+ */
62
+ export declare const installCommand: (app: import("../../../../index.js").RmanApplication) => {
63
+ command: "install";
64
+ aliases: string[];
65
+ platforms: string[];
66
+ describe: string;
67
+ configKeys: string[];
68
+ parserConfiguration: {
69
+ 'populate--': true;
70
+ };
71
+ config: {
72
+ packageManager: {
73
+ target: "cli";
74
+ cliName: string;
75
+ describe: string;
76
+ choices: readonly ["npm", "yarn", "pnpm", "bun"];
77
+ };
78
+ frozenLockfile: {
79
+ target: "cli";
80
+ cliName: string;
81
+ describe: string;
82
+ type: "boolean";
83
+ };
84
+ prod: {
85
+ target: "cli";
86
+ describe: string;
87
+ type: "boolean";
88
+ };
89
+ ignoreScripts: {
90
+ target: "cli";
91
+ cliName: string;
92
+ describe: string;
93
+ type: "boolean";
94
+ };
95
+ lockfileOnly: {
96
+ target: "cli";
97
+ cliName: string;
98
+ describe: string;
99
+ type: "boolean";
100
+ };
101
+ offline: {
102
+ target: "cli";
103
+ describe: string;
104
+ type: "boolean";
105
+ };
106
+ preferOffline: {
107
+ target: "cli";
108
+ cliName: string;
109
+ describe: string;
110
+ type: "boolean";
111
+ };
112
+ dryRun: {
113
+ target: "cli";
114
+ cliName: string;
115
+ describe: string;
116
+ type: "boolean";
117
+ };
118
+ registry: {
119
+ target: "cli";
120
+ describe: string;
121
+ type: "string";
122
+ };
123
+ };
124
+ examples: {
125
+ command: string;
126
+ description: string;
127
+ }[];
128
+ handler: (args: Args) => Promise<void>;
129
+ };
130
+ export {};
@@ -0,0 +1,104 @@
1
+ import { declareCommand } from '../../../../interfaces/rman-config.interface.js';
2
+ import { CiService } from '../services/ci.service.js';
3
+ /** Hoisted for `ArgsOf`, as in `ci.command.ts`. */
4
+ const COMMAND = 'install';
5
+ const config = {
6
+ packageManager: {
7
+ target: 'cli',
8
+ cliName: 'package-manager',
9
+ describe: 'Package manager to install with (default: .rmanrc "packageManager.node", else the lockfile\'s, else npm)',
10
+ choices: CiService.PACKAGE_MANAGERS,
11
+ },
12
+ frozenLockfile: {
13
+ target: 'cli',
14
+ cliName: 'frozen-lockfile',
15
+ describe: 'Install exactly what the lockfile says, failing rather than changing it. Under npm this is npm ci, which removes node_modules first',
16
+ type: 'boolean',
17
+ },
18
+ prod: {
19
+ target: 'cli',
20
+ describe: 'Production dependencies only - no devDependencies',
21
+ type: 'boolean',
22
+ },
23
+ ignoreScripts: {
24
+ target: 'cli',
25
+ cliName: 'ignore-scripts',
26
+ describe: 'Run no lifecycle scripts',
27
+ type: 'boolean',
28
+ },
29
+ lockfileOnly: {
30
+ target: 'cli',
31
+ cliName: 'lockfile-only',
32
+ describe: 'Bring the lockfile up to date with the manifests, installing nothing',
33
+ type: 'boolean',
34
+ },
35
+ offline: {
36
+ target: 'cli',
37
+ describe: 'Use only what is in the local cache, never the network',
38
+ type: 'boolean',
39
+ },
40
+ preferOffline: {
41
+ target: 'cli',
42
+ cliName: 'prefer-offline',
43
+ describe: 'Use the local cache where it has the answer, the network only for what is missing',
44
+ type: 'boolean',
45
+ },
46
+ dryRun: {
47
+ target: 'cli',
48
+ cliName: 'dry-run',
49
+ describe: 'Report what an install would change, writing nothing (pnpm 11.8+)',
50
+ type: 'boolean',
51
+ },
52
+ registry: {
53
+ target: 'cli',
54
+ describe: 'Registry to install from, for this run',
55
+ type: 'string',
56
+ },
57
+ };
58
+ /**
59
+ * `rman install` / `rman i` - one install at the repository root with whichever package manager the
60
+ * repository uses, so nobody has to know which one to type.
61
+ */
62
+ /* **`ci` without the wipe**, which is the whole difference: `ci` deletes every `node_modules` and
63
+ * lockfile and then installs, this installs into what is there. The package manager comes from the
64
+ * same `resolvePackageManager` `ci` and `publish` use - flag, `packageManager.node`, the lockfile,
65
+ * npm - so the two commands cannot disagree about whose install runs.
66
+ *
67
+ * **The options are the ones npm and pnpm share**, spelled once here and translated per tool by
68
+ * `CiService.installArgv`; anything else goes after `--` (`populate--`, as `exec` and the preset's
69
+ * `lint` do). A positional package (`rman i lodash`) is deliberately not taken: adding a dependency
70
+ * is `npm install <pkg>` but `pnpm add <pkg>`, a second verb with its own flags, and a command that
71
+ * half-supports it is worse than one that does not pretend to. */
72
+ export const installCommand = declareCommand(app => {
73
+ const repository = app.repository;
74
+ return {
75
+ command: COMMAND,
76
+ aliases: ['i'],
77
+ platforms: ['node'],
78
+ describe: "Installs the repository's dependencies with its own package manager, deleting nothing first",
79
+ configKeys: ['packageManager'],
80
+ parserConfiguration: { 'populate--': true },
81
+ config,
82
+ examples: [
83
+ { command: '$0 install', description: "# The repository's package manager, whichever it is" },
84
+ { command: '$0 i --frozen-lockfile', description: '# Exactly the lockfile - for CI' },
85
+ { command: '$0 i --prod --ignore-scripts', description: '# Production dependencies, no lifecycle scripts' },
86
+ { command: '$0 i -- --legacy-peer-deps', description: '# Anything else goes to the package manager after --' },
87
+ ],
88
+ handler: async (args) => {
89
+ await CiService.install(repository, {
90
+ packageManager: args.packageManager,
91
+ frozenLockfile: args.frozenLockfile,
92
+ prod: args.prod,
93
+ ignoreScripts: args.ignoreScripts,
94
+ lockfileOnly: args.lockfileOnly,
95
+ offline: args.offline,
96
+ preferOffline: args.preferOffline,
97
+ dryRun: args.dryRun,
98
+ registry: args.registry,
99
+ extra: (args['--'] ?? []).map(String),
100
+ logLevel: args.logLevel,
101
+ });
102
+ },
103
+ };
104
+ });
@@ -2,6 +2,7 @@ export * from './augmentation/rmanrc.augmentation.js';
2
2
  export * from './augmentation/system-info.augmentation.js';
3
3
  export * from './commands/ci.command.js';
4
4
  export * from './commands/clean.command.js';
5
+ export * from './commands/install.command.js';
5
6
  export * from './node.platform.js';
6
7
  export * from './node-config.interface.js';
7
8
  export * from './node-manifest.provider.js';
@@ -2,6 +2,7 @@ export * from './augmentation/rmanrc.augmentation.js';
2
2
  export * from './augmentation/system-info.augmentation.js';
3
3
  export * from './commands/ci.command.js';
4
4
  export * from './commands/clean.command.js';
5
+ export * from './commands/install.command.js';
5
6
  export * from './node.platform.js';
6
7
  export * from './node-config.interface.js';
7
8
  export * from './node-manifest.provider.js';
@@ -1,5 +1,6 @@
1
1
  import type { Package } from '../../../core/classes/package.js';
2
2
  import { DependencyUpdater } from '../../../core/interfaces/dependency-updater.js';
3
+ import { type ExecResult } from '../../../utils/exec.js';
3
4
  import { type NpmRelease, type NpmReleases } from '../../publish-targets/npm/npm-view.js';
4
5
  /**
5
6
  * npm's answer to `rman deps`: which of a `package.json`'s dependencies have a newer version on the
@@ -18,20 +19,54 @@ export declare class NodeDependencyUpdater implements DependencyUpdater {
18
19
  protected readonly movablePattern: RegExp;
19
20
  /** The plan each `'update'` entry was made from, for `applyPlan`. */
20
21
  protected readonly planned: WeakMap<DependencyUpdater.Entry, NodeDependencyUpdater.Decision>;
22
+ /** The first pnpm whose `install` takes `--dry-run`; an older one is not asked. */
23
+ protected readonly pnpmDryRunSince: string;
24
+ /** `name@version` for each move the last `applyPlan` wrote - what a pnpm peer issue is matched
25
+ * against, to tell the upgrade's issues from the repository's own. */
26
+ protected written: Set<string>;
21
27
  getPlan(ctx: DependencyUpdater.Context, packages: readonly Package[]): Promise<DependencyUpdater.Entry[]>;
22
28
  applyPlan(ctx: DependencyUpdater.Context, plan: readonly DependencyUpdater.Entry[]): Promise<DependencyUpdater.Applied>;
29
+ /**
30
+ * The repository's own package manager, asked whether the manifests install, writing nothing:
31
+ * `npm install --dry-run` (`verifyWithNpm`) or `pnpm install --dry-run --strict-peer-dependencies`
32
+ * (`verifyWithPnpm`). yarn and bun are not asked, and a note says so.
33
+ */
34
+ verify(ctx: DependencyUpdater.Context): Promise<string | undefined>;
35
+ /**
36
+ * The upgrades a refusal names at the version they move to - see `blameNpm` and `blamePnpm`,
37
+ * which read the two package managers' own words.
38
+ */
39
+ blame(refusal: string, plan: readonly DependencyUpdater.Entry[]): DependencyUpdater.Blame[];
23
40
  /**
24
41
  * `npm install --dry-run` at the repository root: npm's own resolver, which refuses a peer
25
42
  * conflict anywhere in the tree with `ERESOLVE`, and writes nothing.
26
- *
27
- * Another package manager is not asked - its dry run is not the same question - and a note says so.
28
43
  */
29
- verify(ctx: DependencyUpdater.Context): Promise<string | undefined>;
44
+ protected verifyWithNpm(ctx: DependencyUpdater.Context): Promise<string | undefined>;
45
+ /**
46
+ * `pnpm install --dry-run --strict-peer-dependencies` at the repository root - pnpm's resolver,
47
+ * which writes nothing - counting only the peer issues one of this run's moves is part of. A pnpm
48
+ * older than `pnpmDryRunSince` is not asked.
49
+ */
50
+ protected verifyWithPnpm(ctx: DependencyUpdater.Context): Promise<string | undefined>;
30
51
  /**
31
52
  * The upgrades an `ERESOLVE` names at the version they move to - the one under `Could not resolve
32
53
  * dependency:` when it is one of them, else every one the output mentions.
33
54
  */
34
- blame(refusal: string, plan: readonly DependencyUpdater.Entry[]): DependencyUpdater.Blame[];
55
+ protected blameNpm(refusal: string, plan: readonly DependencyUpdater.Entry[]): DependencyUpdater.Blame[];
56
+ /** Runs `pnpm <args>` at the repository root, never throwing - the one place this class spawns
57
+ * pnpm, so a spec answers for it instead of whichever pnpm is on the machine. */
58
+ protected pnpm(ctx: DependencyUpdater.Context, args: string): Promise<ExecResult>;
59
+ /**
60
+ * The moves a pnpm peer issue is about: the peer at the version pnpm found, when this run moved it
61
+ * there, else the packages wanting it that this run moved.
62
+ */
63
+ protected blamePnpm(refusal: string, plan: readonly DependencyUpdater.Entry[]): DependencyUpdater.Blame[];
64
+ /** Every `name@version` a pnpm peer issue names - the peer as found, and each package wanting it. */
65
+ protected pnpmIssueMoves(issue: NodeDependencyUpdater.PnpmPeerIssue): string[];
66
+ /**
67
+ * The peer issues in pnpm's `ERR_PNPM_PEER_DEP_ISSUES` report, each with its own lines.
68
+ */
69
+ protected pnpmPeerIssues(output: string): NodeDependencyUpdater.PnpmPeerIssue[];
35
70
  /** One decision per dependency name `pkg` declares, whether or not it may move - one that may not
36
71
  * still states rules the others have to keep. */
37
72
  protected collect(pkg: Package, settings: DependencyUpdater.Settings, options: DependencyUpdater.Options, inRepo: ReadonlySet<string>): NodeDependencyUpdater.Decision[];
@@ -60,14 +95,18 @@ export declare class NodeDependencyUpdater implements DependencyUpdater {
60
95
  * would not accept is a `major`, so `0.1.0 -> 0.2.0` is one.
61
96
  */
62
97
  protected sizeOf(from: string, to: string): string;
63
- /** Steps 2 and 3: the package's own other declarations of this name, and the runtime it supports.
64
- * The rule `release` breaks, or `undefined`. */
98
+ /** Steps 2 and 3: the package's own other declarations of this name, and Node - the one rman runs
99
+ * on, and the ones the package supports. The rule `release` breaks, or `undefined`. */
65
100
  protected staticRefusal(d: NodeDependencyUpdater.Decision, release: NpmRelease): string | undefined;
66
- /**
67
- * The Node versions a newer release has to keep covering: those the package supports **and** the
68
- * lowest release its declaration allows now (`current`) already runs on.
69
- */
70
- protected nodeCoverage(pkg: Package, current: NpmRelease | undefined): string | undefined;
101
+ /** The Node a release is checked against first - the one running rman, which is the one that
102
+ * installs. */
103
+ protected runningNode(): string;
104
+ /** Whether `release` declares that it runs on `node`. No `engines.node`, or one semver cannot
105
+ * read, is no objection. */
106
+ protected runsOn(release: NpmRelease | undefined, node: string): boolean;
107
+ /** Whether `release`'s `engines.node` and `supported` have at least one Node in common. No
108
+ * `engines.node`, or one semver cannot read, is no objection. */
109
+ protected sharesNode(release: NpmRelease | undefined, supported: string): boolean;
71
110
  /** The Node versions `pkg` supports - its own `engines.node`, else the repository root's. */
72
111
  protected supportedNode(pkg: Package): string | undefined;
73
112
  /**
@@ -165,9 +204,20 @@ export declare namespace NodeDependencyUpdater {
165
204
  index: number;
166
205
  releases?: Map<string, NpmRelease>;
167
206
  latestTag?: string;
168
- /** The Node versions a newer release has to keep covering - see `nodeCoverage`. */
169
- baselineNode?: string;
170
207
  reason?: string;
171
208
  error?: string;
172
209
  }
210
+ /** One unmet or missing peer in pnpm's report - see `pnpmPeerIssues`. */
211
+ interface PnpmPeerIssue {
212
+ peer: string;
213
+ /** The version pnpm found, absent for a missing peer. */
214
+ installed?: string;
215
+ /** Each range asked for, quoted as pnpm prints it, with the `name@version`s asking. */
216
+ wanted: {
217
+ range: string;
218
+ by: string[];
219
+ }[];
220
+ /** The issue as pnpm printed it, trimmed. */
221
+ lines: string[];
222
+ }
173
223
  }
@@ -36,7 +36,8 @@ import { parseWorkspaceRange } from './utils/workspace-range.js';
36
36
  * above the `latest` dist-tag, or a prerelease when the range is not on one;
37
37
  * 2. the package's own other declarations of the same name - a `devDependencies` caret cannot move
38
38
  * outside the package's own `peerDependencies` range for that name;
39
- * 3. the runtime: a version whose `engines.node` does not cover every Node the package supports;
39
+ * 3. the runtime: a version whose `engines.node` leaves out the Node rman is running on, or shares
40
+ * no Node at all with the package's own `engines.node`;
40
41
  * 4. the peer ranges of the other dependencies the package names, at the versions *they* move to;
41
42
  * 5. a sibling package's peer range, for a package naming that sibling.
42
43
  *
@@ -63,6 +64,14 @@ export class NodeDependencyUpdater {
63
64
  movablePattern = /^([\^~])(\d+(?:\.\d+){0,2}(?:-[0-9A-Za-z.-]+)?)$/;
64
65
  /** The plan each `'update'` entry was made from, for `applyPlan`. */
65
66
  planned = new WeakMap();
67
+ /** The first pnpm whose `install` takes `--dry-run`; an older one is not asked. */
68
+ /* pnpm 11.8 (2026-06-18) is where the release notes put it. Below it there is nothing to ask, and
69
+ * no older pnpm was measured - what one makes of a flag it does not know is a guess, and the bad
70
+ * guess is a real install. */
71
+ pnpmDryRunSince = '11.8.0';
72
+ /** `name@version` for each move the last `applyPlan` wrote - what a pnpm peer issue is matched
73
+ * against, to tell the upgrade's issues from the repository's own. */
74
+ written = new Set();
66
75
  async getPlan(ctx, packages) {
67
76
  const inRepo = new Set([ctx.repository.rootPackage, ...ctx.repository.packages].map(p => p.name));
68
77
  const decisions = packages.flatMap(pkg => this.collect(pkg, DependencyUpdater.settingsFor(pkg, ctx.options), ctx.options, inRepo));
@@ -86,11 +95,13 @@ export class NodeDependencyUpdater {
86
95
  }
87
96
  async applyPlan(ctx, plan) {
88
97
  const originals = new Map();
98
+ this.written = new Set();
89
99
  for (const entry of plan) {
90
100
  const d = this.planned.get(entry);
91
101
  if (entry.status !== 'update' || !d)
92
102
  continue;
93
103
  const version = d.candidates[d.index];
104
+ this.written.add(`${d.name}@${version}`);
94
105
  if (!originals.has(d.pkg))
95
106
  originals.set(d.pkg, fs.readFileSync(this.manifestFile(d.pkg), 'utf-8'));
96
107
  for (const field of d.movable) {
@@ -110,22 +121,36 @@ export class NodeDependencyUpdater {
110
121
  },
111
122
  };
112
123
  }
124
+ /**
125
+ * The repository's own package manager, asked whether the manifests install, writing nothing:
126
+ * `npm install --dry-run` (`verifyWithNpm`) or `pnpm install --dry-run --strict-peer-dependencies`
127
+ * (`verifyWithPnpm`). yarn and bun are not asked, and a note says so.
128
+ */
129
+ async verify(ctx) {
130
+ const manager = CiService.resolvePackageManager(ctx.repository);
131
+ if (manager === 'npm')
132
+ return this.verifyWithNpm(ctx);
133
+ if (manager === 'pnpm')
134
+ return this.verifyWithPnpm(ctx);
135
+ console.error(colors.yellow(`Not verified: "${manager}" has no dry-run install to ask.`));
136
+ return undefined;
137
+ }
138
+ /**
139
+ * The upgrades a refusal names at the version they move to - see `blameNpm` and `blamePnpm`,
140
+ * which read the two package managers' own words.
141
+ */
142
+ blame(refusal, plan) {
143
+ return this.pnpmPeerIssues(refusal).length ? this.blamePnpm(refusal, plan) : this.blameNpm(refusal, plan);
144
+ }
113
145
  /**
114
146
  * `npm install --dry-run` at the repository root: npm's own resolver, which refuses a peer
115
147
  * conflict anywhere in the tree with `ERESOLVE`, and writes nothing.
116
- *
117
- * Another package manager is not asked - its dry run is not the same question - and a note says so.
118
148
  */
119
149
  /* Measured on a manifest pairing `typescript@^7` with `@typescript-eslint/parser@8.40.0`, whose
120
150
  * peer range stops below 6: `--dry-run` exits 1 with `ERESOLVE unable to resolve dependency tree`
121
151
  * and the offending `peer typescript@">=4.8.4 <6.0.0"` line, as `--package-lock-only` does, but
122
152
  * without touching the lockfile. */
123
- async verify(ctx) {
124
- const manager = CiService.resolvePackageManager(ctx.repository);
125
- if (manager !== 'npm') {
126
- console.error(colors.yellow(`Not verified: "${manager}" has no dry-run install to ask.`));
127
- return undefined;
128
- }
153
+ async verifyWithNpm(ctx) {
129
154
  const result = await exec('npm install --dry-run --ignore-scripts --no-audit --no-fund', {
130
155
  cwd: ctx.repository.dirname,
131
156
  app: ctx.app,
@@ -140,6 +165,49 @@ export class NodeDependencyUpdater {
140
165
  .filter(line => line.trim());
141
166
  return lines.join('\n') || ` npm install --dry-run exited ${result.code}`;
142
167
  }
168
+ /**
169
+ * `pnpm install --dry-run --strict-peer-dependencies` at the repository root - pnpm's resolver,
170
+ * which writes nothing - counting only the peer issues one of this run's moves is part of. A pnpm
171
+ * older than `pnpmDryRunSince` is not asked.
172
+ */
173
+ /* **`--strict-peer-dependencies`, or there is nothing to refuse.** pnpm treats an unmet peer as a
174
+ * warning by default - measured on pnpm 12.10.1 with the npm case above: plain `--dry-run` exits 0
175
+ * with `Issues with peer dependencies found`, the strict form exits 1 with
176
+ * `ERR_PNPM_PEER_DEP_ISSUES`, and neither writes a lockfile or `node_modules`. A pnpm workspace is
177
+ * covered from the root: the same conflict in `packages/a` came back under a `packages/a` heading.
178
+ *
179
+ * **Strict is also stricter than the repository**, which has lived with its peer warnings, so an
180
+ * issue none of this run's moves is part of is the repository's own and is let through - otherwise
181
+ * a repository carrying one could never upgrade anything. The cost, stated: a conflict a move
182
+ * brings in only through a dependency of its own names that dependency, not the move, and passes
183
+ * as well - which is what pnpm itself does with it by default.
184
+ *
185
+ * **Any other failure is a refusal, as with npm**: the manifests did not resolve, whatever the
186
+ * reason, and with nothing to blame the command puts every write back and shows pnpm's lines. */
187
+ async verifyWithPnpm(ctx) {
188
+ const version = (await this.pnpm(ctx, '--version')).stdout?.trim();
189
+ if (!version || !semver.valid(version) || semver.lt(version, this.pnpmDryRunSince)) {
190
+ console.error(colors.yellow(`Not verified: pnpm ${version || '(not found)'} has no dry-run install - it needs pnpm ${this.pnpmDryRunSince}.`));
191
+ return undefined;
192
+ }
193
+ const result = await this.pnpm(ctx, 'install --dry-run --strict-peer-dependencies --ignore-scripts');
194
+ if (!result.code)
195
+ return undefined;
196
+ const output = result.stdout ?? '';
197
+ const issues = this.pnpmPeerIssues(output);
198
+ if (issues.length) {
199
+ const ours = issues.filter(issue => this.pnpmIssueMoves(issue).some(token => this.written.has(token)));
200
+ if (!ours.length)
201
+ return undefined;
202
+ return ours.map(issue => issue.lines.map(line => ` ${line}`).join('\n')).join('\n');
203
+ }
204
+ /** Not a peer issue: pnpm's own error lines, without the dry run's list of what it would add. */
205
+ const lines = output
206
+ .split('\n')
207
+ .filter(line => /ERR_PNPM_|^\s*error\b|^\s*✕/i.test(line))
208
+ .map(line => ` ${line.trim()}`);
209
+ return lines.join('\n') || ` pnpm install --dry-run exited ${result.code}`;
210
+ }
143
211
  /**
144
212
  * The upgrades an `ERESOLVE` names at the version they move to - the one under `Could not resolve
145
213
  * dependency:` when it is one of them, else every one the output mentions.
@@ -155,7 +223,7 @@ export class NodeDependencyUpdater {
155
223
  * `abisena/syncbridge-iomt`, the verdict read `dev @syncbridge/syncbuild@"^2.2.0" from the root
156
224
  * project`, matched nothing, and every move the output mentioned anywhere was held under that one
157
225
  * line - `@syncbridge/testing` included, with syncbuild's reason. */
158
- blame(refusal, plan) {
226
+ blameNpm(refusal, plan) {
159
227
  const moves = plan.flatMap(entry => {
160
228
  const d = this.planned.get(entry);
161
229
  if (entry.status !== 'update' || !d)
@@ -184,6 +252,88 @@ export class NodeDependencyUpdater {
184
252
  return line ? [{ entry: m.entry, reason: `npm cannot install it: ${line}` }] : [];
185
253
  });
186
254
  }
255
+ /** Runs `pnpm <args>` at the repository root, never throwing - the one place this class spawns
256
+ * pnpm, so a spec answers for it instead of whichever pnpm is on the machine. */
257
+ pnpm(ctx, args) {
258
+ return exec(`pnpm ${args}`, { cwd: ctx.repository.dirname, app: ctx.app, throwOnError: false });
259
+ }
260
+ /**
261
+ * The moves a pnpm peer issue is about: the peer at the version pnpm found, when this run moved it
262
+ * there, else the packages wanting it that this run moved.
263
+ */
264
+ /* **The peer first.** `typescript` moved to 7.0.2 and `@typescript-eslint/parser` wanting `<6` is
265
+ * the peer outgrowing its requirers, and holding the peer is the one move that answers it; only
266
+ * when the peer did not move is a requirer the one that changed. Each round holds at least one, so
267
+ * a run with both moved holds the peer, asks again, and ends. */
268
+ blamePnpm(refusal, plan) {
269
+ const byToken = new Map();
270
+ for (const entry of plan) {
271
+ const d = this.planned.get(entry);
272
+ if (entry.status === 'update' && d)
273
+ byToken.set(`${d.name}@${d.candidates[d.index]}`, entry);
274
+ }
275
+ const blamed = new Map();
276
+ for (const issue of this.pnpmPeerIssues(refusal)) {
277
+ const peer = issue.installed && byToken.get(`${issue.peer}@${issue.installed}`);
278
+ const entries = peer ? [peer] : issue.wanted.flatMap(w => w.by.flatMap(by => byToken.get(by) ?? []));
279
+ for (const entry of entries) {
280
+ if (blamed.has(entry))
281
+ continue;
282
+ const wants = issue.wanted.map(w => `${w.range} by ${w.by[0]}`).join(', ');
283
+ const found = issue.installed ? ` (found ${issue.installed})` : '';
284
+ blamed.set(entry, `pnpm cannot install it: unmet peer ${issue.peer}${found}, wanted ${wants}`);
285
+ }
286
+ }
287
+ return [...blamed].map(([entry, reason]) => ({ entry, reason }));
288
+ }
289
+ /** Every `name@version` a pnpm peer issue names - the peer as found, and each package wanting it. */
290
+ pnpmIssueMoves(issue) {
291
+ return [...(issue.installed ? [`${issue.peer}@${issue.installed}`] : []), ...issue.wanted.flatMap(w => w.by)];
292
+ }
293
+ /**
294
+ * The peer issues in pnpm's `ERR_PNPM_PEER_DEP_ISSUES` report, each with its own lines.
295
+ */
296
+ /* The shape, measured on pnpm 12.10.1 - a workspace adds a project heading above and indents the
297
+ * rest, so lines are read trimmed:
298
+ *
299
+ * ✕ unmet peer typescript
300
+ * Installed: 7.0.2
301
+ * Wanted:
302
+ * ">=4.8.4 <6.0.0":
303
+ * @typescript-eslint/parser@8.40.0
304
+ * @typescript-eslint/typescript-estree@8.40.0
305
+ *
306
+ * `missing peer` is read the same way, with no `Installed`. */
307
+ pnpmPeerIssues(output) {
308
+ const issues = [];
309
+ let issue;
310
+ for (const raw of output.split('\n')) {
311
+ const line = raw.trim();
312
+ const head = /^✕ (?:unmet|missing) peer (\S+)$/.exec(line);
313
+ if (head) {
314
+ issue = { peer: head[1], wanted: [], lines: [line] };
315
+ issues.push(issue);
316
+ continue;
317
+ }
318
+ if (!issue)
319
+ continue;
320
+ const installed = /^Installed: (\S+)$/.exec(line);
321
+ const range = /^(".*"):$/.exec(line);
322
+ const by = /^((?:@[^/@\s]+\/)?[^@\s]+@\S+)$/.exec(line);
323
+ if (installed)
324
+ issue.installed = installed[1];
325
+ else if (range)
326
+ issue.wanted.push({ range: range[1], by: [] });
327
+ else if (by && issue.wanted.length)
328
+ issue.wanted.at(-1).by.push(by[1]);
329
+ else if (line !== 'Wanted:') {
330
+ issue = undefined;
331
+ continue;
332
+ }
333
+ issue.lines.push(line);
334
+ }
335
+ return issues;
336
+ }
187
337
  /** One decision per dependency name `pkg` declares, whether or not it may move - one that may not
188
338
  * still states rules the others have to keep. */
189
339
  collect(pkg, settings, options, inRepo) {
@@ -293,7 +443,6 @@ export class NodeDependencyUpdater {
293
443
  if (d.available && d.available !== d.allowed[0]) {
294
444
  d.skipReason = this.settingRefusal(d, newer[0], info.time);
295
445
  }
296
- d.baselineNode = this.nodeCoverage(d.pkg, d.releases.get(d.floor));
297
446
  for (const version of d.allowed) {
298
447
  const refusal = this.staticRefusal(d, d.releases.get(version));
299
448
  if (!refusal)
@@ -369,8 +518,8 @@ export class NodeDependencyUpdater {
369
518
  const diff = semver.diff(from, to) ?? 'patch';
370
519
  return diff.replace(/^pre(?!release)/, '') === 'prerelease' ? 'patch' : diff.replace(/^pre(?!release)/, '');
371
520
  }
372
- /** Steps 2 and 3: the package's own other declarations of this name, and the runtime it supports.
373
- * The rule `release` breaks, or `undefined`. */
521
+ /** Steps 2 and 3: the package's own other declarations of this name, and Node - the one rman runs
522
+ * on, and the ones the package supports. The rule `release` breaks, or `undefined`. */
374
523
  staticRefusal(d, release) {
375
524
  for (const [field, range] of d.fields) {
376
525
  if (d.movable.includes(field) || !semver.validRange(range))
@@ -379,33 +528,47 @@ export class NodeDependencyUpdater {
379
528
  return `${d.pkg.name} declares ${d.name} ${range} in ${field}`;
380
529
  }
381
530
  }
382
- const covered = d.baselineNode;
383
- const needed = release.engines?.node;
384
- if (covered && needed && semver.validRange(needed) && !semver.subset(covered, needed)) {
385
- return `${d.name}@${release.version} needs node ${needed}, ${d.pkg.name} supports ${this.supportedNode(d.pkg)}`;
531
+ const floor = d.floor ? d.releases?.get(d.floor) : undefined;
532
+ const node = this.runningNode();
533
+ if (!this.runsOn(release, node) && this.runsOn(floor, node)) {
534
+ return `${d.name}@${release.version} needs node ${release.engines.node}, this is node ${node}`;
535
+ }
536
+ const supported = this.supportedNode(d.pkg);
537
+ if (supported && !this.sharesNode(release, supported) && this.sharesNode(floor, supported)) {
538
+ return `${d.name}@${release.version} needs node ${release.engines.node}, none of which ${d.pkg.name} supports (${supported})`;
386
539
  }
387
540
  return undefined;
388
541
  }
389
- /**
390
- * The Node versions a newer release has to keep covering: those the package supports **and** the
391
- * lowest release its declaration allows now (`current`) already runs on.
392
- */
393
- /* **Not the package's whole range**, and that was measured wrong first. A package declaring
394
- * `node >=18` with `eslint ^9` was offered no 9.x at all, because every one of them needs
395
- * `^18.18.0` - but so does the 9.x it already installs. A rule the current version breaks is not
396
- * one a newer version can be held to; only taking away a Node that works today is a refusal.
542
+ /** The Node a release is checked against first - the one running rman, which is the one that
543
+ * installs. */
544
+ /* **Two questions, and both are the user's.** Does it install on the Node running now, and does it
545
+ * share *any* Node with the package's own `engines.node` (`sharesNode`). The second was
546
+ * `semver.subset(supported, needed)` - every Node the package supports - until it was reported on
547
+ * `panates/peacox-ui`: jsdom 30.1.3 needs `^22.22.2 || ^24.15.0 || >=26.0.0`, Node 25 left out,
548
+ * and the package says `>=24.15`, so `deps --target major` held it on a machine running 24.15.0
549
+ * where it installs. A range is "I accept these"; a gap in a dependency's range is not a reason to
550
+ * refuse it, a range with nothing in common is. What that gives up, stated: a library whose runtime
551
+ * dependency drops *one* Node its own `engines` still names is no longer told so here.
397
552
  *
398
- * **The floor, not the newest release the range allows.** `^1.0.0` installs 1.2.0 today, so
399
- * measuring against that would wave 1.2.0 through - but raising the floor to it is exactly what
400
- * stops a Node that 1.0.0 still served. */
401
- nodeCoverage(pkg, current) {
402
- const supported = this.supportedNode(pkg);
403
- const runs = current?.engines?.node;
404
- if (!supported || !runs || !semver.validRange(runs))
405
- return supported;
406
- const sets = new semver.Range(supported).set.flatMap(a => new semver.Range(runs).set.map(b => [...a, ...b].map(c => c.value).join(' ')));
407
- const both = sets.filter(set => semver.validRange(set) && semver.minVersion(set)).join(' || ');
408
- return both || supported;
553
+ * **A Node the declared version already leaves out is no objection either** - the floor, measured
554
+ * the hard way under the old rule: `eslint ^9` needs `^18.18.0`, so a package on an older 18 was
555
+ * offered no 9.x at all, though the 9.x it installs today has the same requirement. Only a release
556
+ * that stops working where the current one works is refused. The floor rather than the newest the
557
+ * range allows, because raising the floor is what can stop it. */
558
+ runningNode() {
559
+ return process.versions.node;
560
+ }
561
+ /** Whether `release` declares that it runs on `node`. No `engines.node`, or one semver cannot
562
+ * read, is no objection. */
563
+ runsOn(release, node) {
564
+ const needed = release?.engines?.node;
565
+ return !needed || !semver.validRange(needed) || semver.satisfies(node, needed, { includePrerelease: true });
566
+ }
567
+ /** Whether `release`'s `engines.node` and `supported` have at least one Node in common. No
568
+ * `engines.node`, or one semver cannot read, is no objection. */
569
+ sharesNode(release, supported) {
570
+ const needed = release?.engines?.node;
571
+ return !needed || !semver.validRange(needed) || semver.intersects(supported, needed, { includePrerelease: true });
409
572
  }
410
573
  /** The Node versions `pkg` supports - its own `engines.node`, else the repository root's. */
411
574
  supportedNode(pkg) {
@@ -24,9 +24,47 @@ export declare namespace CiService {
24
24
  }
25
25
  /**
26
26
  * The package manager `pkg` uses: `cliValue` when given, else its `.rmanrc "packageManager.node"`,
27
- * else `npm`. Pass the repository for the one the repository installs with.
27
+ * else the one its lockfile belongs to (`detectPackageManager`), else `npm`. Pass the repository
28
+ * for the one the repository installs with.
28
29
  */
29
30
  function resolvePackageManager(pkg: Package, cliValue?: PackageManager): PackageManager;
31
+ /**
32
+ * The package manager whose lockfile sits nearest `pkg` - its own directory, then each one above
33
+ * it up to the repository root - or `undefined` when there is none. Throws when the nearest
34
+ * directory holding a lockfile holds two package managers' lockfiles, naming them.
35
+ */
36
+ function detectPackageManager(pkg: Package): PackageManager | undefined;
37
+ /** What `rman install` hands on, in rman's own words - `installArgv` spells each one for the
38
+ * package manager that runs. */
39
+ interface InstallOptions {
40
+ packageManager?: PackageManager;
41
+ /** Install exactly what the lockfile says, failing rather than changing it. */
42
+ frozenLockfile?: boolean;
43
+ /** Production dependencies only - no `devDependencies`. */
44
+ prod?: boolean;
45
+ ignoreScripts?: boolean;
46
+ /** Bring the lockfile up to date with the manifests, installing nothing. */
47
+ lockfileOnly?: boolean;
48
+ offline?: boolean;
49
+ preferOffline?: boolean;
50
+ /** Report what an install would change, writing nothing. */
51
+ dryRun?: boolean;
52
+ registry?: string;
53
+ /** Handed on last, as written - whatever a package manager has and these do not say. */
54
+ extra?: string[];
55
+ logLevel?: LogLevel;
56
+ }
57
+ /**
58
+ * `rman install`: one install at the repository root, with the repository's own package manager
59
+ * (`resolvePackageManager`) - nothing is deleted first, which is what sets it apart from
60
+ * `reinstall`.
61
+ */
62
+ function install(repository: Repository, options?: InstallOptions): Promise<void>;
63
+ /**
64
+ * The argv `manager` is run with for `options`. Throws, before anything runs, for an option
65
+ * `manager` has no spelling of, naming it and the way round it.
66
+ */
67
+ function installArgv(manager: PackageManager, options: InstallOptions): string[];
30
68
  /** Deletes `node_modules` and any known lockfile directly under `dirname`. Returns the names
31
69
  * that actually existed (and were removed), so the caller can log only those. */
32
70
  function wipe(dirname: string): Promise<string[]>;
@@ -1,3 +1,4 @@
1
+ import { existsSync } from 'node:fs';
1
2
  import fs from 'node:fs/promises';
2
3
  import path from 'node:path';
3
4
  import colors from 'ansi-colors';
@@ -5,6 +6,7 @@ import { Logger, resolveRootLogLevel } from '../../../../core/classes/logger.js'
5
6
  import { formatDuration, ProgressPanel } from '../../../../core/classes/progress-panel.js';
6
7
  import { exec } from '../../../../utils/exec.js';
7
8
  import { filterPackages } from '../../../../utils/package-filter.js';
9
+ import { runBin } from '../../../../utils/run-bin.js';
8
10
  export var CiService;
9
11
  (function (CiService) {
10
12
  /**
@@ -18,7 +20,8 @@ export var CiService;
18
20
  CiService.PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm', 'bun'];
19
21
  /**
20
22
  * The package manager `pkg` uses: `cliValue` when given, else its `.rmanrc "packageManager.node"`,
21
- * else `npm`. Pass the repository for the one the repository installs with.
23
+ * else the one its lockfile belongs to (`detectPackageManager`), else `npm`. Pass the repository
24
+ * for the one the repository installs with.
22
25
  */
23
26
  /* **The bare string is refused rather than read.** `packageManager: pnpm` was the old spelling,
24
27
  * and rman validates no config keys, so read as an object it would simply have no `node` entry -
@@ -34,12 +37,101 @@ export var CiService;
34
37
  }
35
38
  const node = configured?.node;
36
39
  if (node === undefined)
37
- return 'npm';
40
+ return detectPackageManager(pkg) ?? 'npm';
38
41
  if (typeof node === 'string' && CiService.PACKAGE_MANAGERS.includes(node))
39
42
  return node;
40
43
  throw new Error(`Invalid "packageManager.node" in .rmanrc: "${String(node)}" (expected one of: ${CiService.PACKAGE_MANAGERS.join(', ')})`);
41
44
  }
42
45
  CiService.resolvePackageManager = resolvePackageManager;
46
+ /**
47
+ * The package manager whose lockfile sits nearest `pkg` - its own directory, then each one above
48
+ * it up to the repository root - or `undefined` when there is none. Throws when the nearest
49
+ * directory holding a lockfile holds two package managers' lockfiles, naming them.
50
+ */
51
+ /* **The lockfile, not `package.json#packageManager`.** The lockfile is what the last install
52
+ * actually wrote; the field is a declaration nothing checks, and it goes stale. Measured on this
53
+ * repository: its root `package.json` says `yarn@3.4.1` and it has only ever installed with npm
54
+ * (`package-lock.json`, no `yarn.lock`) - read first, the field would have sent `rman ci` to yarn.
55
+ *
56
+ * **Two managers in one directory is refused, not ranked.** Any order picks a tool on the
57
+ * repository's behalf, and the wrong pick is silent: `ci` wipes every lockfile before it installs,
58
+ * so the one it guessed against is gone and the next run sees only what it wrote. The fix is one
59
+ * line of config, and the message says which.
60
+ *
61
+ * **Nearest, not root-only**: a package installing on its own keeps its lockfile beside its own
62
+ * `package.json`, and the walk stops at the repository root so a checkout nested inside another
63
+ * project never answers with the outer one's tool. */
64
+ function detectPackageManager(pkg) {
65
+ if (!pkg.dirname)
66
+ return undefined;
67
+ for (const dir of lockfileDirs(pkg)) {
68
+ const found = Object.keys(LOCKFILE_MANAGERS).filter(name => existsSync(path.join(dir, name)));
69
+ if (!found.length)
70
+ continue;
71
+ const managers = [...new Set(found.map(name => LOCKFILE_MANAGERS[name]))];
72
+ if (managers.length === 1)
73
+ return managers[0];
74
+ throw new Error(`Cannot tell which package manager ${dir} uses: it holds lockfiles of ${managers.join(' and ')} ` +
75
+ `(${found.join(', ')}). Delete the stale one, or say which in .rmanrc: ` +
76
+ `packageManager: { node: ${managers.join(' | ')} }.`);
77
+ }
78
+ return undefined;
79
+ }
80
+ CiService.detectPackageManager = detectPackageManager;
81
+ /**
82
+ * `rman install`: one install at the repository root, with the repository's own package manager
83
+ * (`resolvePackageManager`) - nothing is deleted first, which is what sets it apart from
84
+ * `reinstall`.
85
+ */
86
+ async function install(repository, options = {}) {
87
+ const manager = resolvePackageManager(repository, options.packageManager);
88
+ await runBin(manager, installArgv(manager, options), {
89
+ cwd: repository.dirname,
90
+ app: repository.app,
91
+ logLevel: options.logLevel ?? resolveRootLogLevel(repository),
92
+ });
93
+ }
94
+ CiService.install = install;
95
+ /**
96
+ * The argv `manager` is run with for `options`. Throws, before anything runs, for an option
97
+ * `manager` has no spelling of, naming it and the way round it.
98
+ */
99
+ /* **One table, read flag by flag** (`INSTALL_FLAGS`, below), each spelling taken from that tool's
100
+ * own `install --help`: npm 11.12.1, pnpm 12.10.1, bun 1.4.2, yarn 3.4.1. A spelling nobody
101
+ * checked is left out rather than guessed - a flag that means something else, or nothing, to the
102
+ * tool that receives it is the silent version of this refusal.
103
+ *
104
+ * **`--frozen-lockfile` is `npm ci` under npm**, and that is the one place this command deletes
105
+ * anything: npm has no frozen install that keeps `node_modules`, and `ci` is npm's own answer to
106
+ * "exactly the lockfile". Refusing it would leave the one flag a CI script needs most unable to be
107
+ * written without knowing the tool, which is the whole point of the command.
108
+ *
109
+ * **yarn takes `--frozen-lockfile` and nothing else here.** Berry's `install` has no production,
110
+ * offline, dry-run or registry flag at all, and spells the rest as `--mode` values that cannot be
111
+ * combined; classic spells them differently again. Both accept `--frozen-lockfile` - berry as an
112
+ * alias of `--immutable`. */
113
+ function installArgv(manager, options) {
114
+ if (options.frozenLockfile && options.lockfileOnly) {
115
+ throw new Error('--frozen-lockfile and --lockfile-only contradict each other: one refuses to change the lockfile, the other only changes it.');
116
+ }
117
+ const argv = manager === 'npm' && options.frozenLockfile ? ['ci'] : ['install'];
118
+ for (const flag of INSTALL_FLAGS) {
119
+ const value = options[flag.option];
120
+ if (value === undefined || value === false || value === '')
121
+ continue;
122
+ const spelled = flag.spellings[manager];
123
+ if (spelled === undefined) {
124
+ throw new Error(`${manager} install has no equivalent of --${flag.cliName}. Pass ${manager}'s own flag after --, ` +
125
+ `e.g. rman install -- <flag>.`);
126
+ }
127
+ if (!spelled)
128
+ continue;
129
+ argv.push(typeof value === 'string' ? `${spelled}=${value}` : spelled);
130
+ }
131
+ argv.push(...(options.extra ?? []));
132
+ return argv;
133
+ }
134
+ CiService.installArgv = installArgv;
43
135
  /** Deletes `node_modules` and any known lockfile directly under `dirname`. Returns the names
44
136
  * that actually existed (and were removed), so the caller can log only those. */
45
137
  async function wipe(dirname) {
@@ -129,6 +221,62 @@ export var CiService;
129
221
  CiService.reinstall = reinstall;
130
222
  })(CiService || (CiService = {}));
131
223
  const LOCK_FILES = ['package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lock', 'bun.lockb'];
224
+ /** Each `rman install` option, as each package manager spells it: `''` when the subcommand already
225
+ * says it (`npm ci`), missing when that tool has none. See `installArgv`. */
226
+ const INSTALL_FLAGS = [
227
+ {
228
+ option: 'frozenLockfile',
229
+ cliName: 'frozen-lockfile',
230
+ spellings: { npm: '', pnpm: '--frozen-lockfile', bun: '--frozen-lockfile', yarn: '--frozen-lockfile' },
231
+ },
232
+ { option: 'prod', cliName: 'prod', spellings: { npm: '--omit=dev', pnpm: '--prod', bun: '--production' } },
233
+ {
234
+ option: 'ignoreScripts',
235
+ cliName: 'ignore-scripts',
236
+ spellings: { npm: '--ignore-scripts', pnpm: '--ignore-scripts', bun: '--ignore-scripts' },
237
+ },
238
+ {
239
+ option: 'lockfileOnly',
240
+ cliName: 'lockfile-only',
241
+ spellings: { npm: '--package-lock-only', pnpm: '--lockfile-only', bun: '--lockfile-only' },
242
+ },
243
+ { option: 'offline', cliName: 'offline', spellings: { npm: '--offline', pnpm: '--offline', bun: '--offline' } },
244
+ {
245
+ option: 'preferOffline',
246
+ cliName: 'prefer-offline',
247
+ spellings: { npm: '--prefer-offline', pnpm: '--prefer-offline', bun: '--prefer-offline' },
248
+ },
249
+ { option: 'dryRun', cliName: 'dry-run', spellings: { npm: '--dry-run', pnpm: '--dry-run', bun: '--dry-run' } },
250
+ { option: 'registry', cliName: 'registry', spellings: { npm: '--registry', pnpm: '--registry', bun: '--registry' } },
251
+ ];
252
+ /** Which package manager each lockfile belongs to, for `detectPackageManager`. */
253
+ /* `npm-shrinkwrap.json` is here and not in `LOCK_FILES`: it says npm as surely as a
254
+ * `package-lock.json` does, but it is published with the package, so `ci` has no business deleting
255
+ * it. */
256
+ const LOCKFILE_MANAGERS = {
257
+ 'package-lock.json': 'npm',
258
+ 'npm-shrinkwrap.json': 'npm',
259
+ 'yarn.lock': 'yarn',
260
+ 'pnpm-lock.yaml': 'pnpm',
261
+ 'bun.lock': 'bun',
262
+ 'bun.lockb': 'bun',
263
+ };
264
+ /** `pkg`'s own directory, then each one above it, ending at the repository root - only `pkg`'s own
265
+ * when it has no repository or does not sit inside it. */
266
+ function lockfileDirs(pkg) {
267
+ const root = pkg.repository?.dirname;
268
+ const dirs = [pkg.dirname];
269
+ if (!root || path.relative(root, pkg.dirname).startsWith('..'))
270
+ return dirs;
271
+ let dir = pkg.dirname;
272
+ while (dir !== root) {
273
+ const parent = path.dirname(dir);
274
+ if (parent === dir)
275
+ break;
276
+ dirs.push((dir = parent));
277
+ }
278
+ return dirs;
279
+ }
132
280
  /** Runs a shell `command` in `cwd`, driving `item` for the live panel when it's on, or falling
133
281
  * back to the plain "classic" log line `logLine` prints first - the same split `run`'s classic
134
282
  * log uses. `logLine` is expected to go through a `Logger` (so it respects `--log-level`), not a
@@ -8,7 +8,7 @@ import type { RmanConfig } from '../../interfaces/rman-config.interface.js';
8
8
  * ```
9
9
  *
10
10
  * It contributes the technology (how a `package.json` is read, where `workspaces` point, how
11
- * versions are planned), the two commands that are npm's alone (`clean`, `ci`), and the `npm`
11
+ * versions are planned), the commands that are npm's alone (`clean`, `ci`, `install`), and the `npm`
12
12
  * publish target. A polyglot repository names several: `extends: ['node', 'cargo']` holds both,
13
13
  * because every key here appends.
14
14
  */
@@ -1,6 +1,6 @@
1
1
  import { definePlatform } from '../../core/interfaces/plugin.js';
2
2
  import { defineConfig } from '../../interfaces/rman-config.interface.js';
3
- import { augmentSystemInfo, ciCommand, cleanCommand, NodePlatform } from '../platforms/node/index.js';
3
+ import { augmentSystemInfo, ciCommand, cleanCommand, installCommand, NodePlatform } from '../platforms/node/index.js';
4
4
  import { NpmPublishTarget } from '../publish-targets/npm/index.js';
5
5
  /**
6
6
  * **The `node` preset** - everything rman knows about the npm ecosystem, as a config.
@@ -11,7 +11,7 @@ import { NpmPublishTarget } from '../publish-targets/npm/index.js';
11
11
  * ```
12
12
  *
13
13
  * It contributes the technology (how a `package.json` is read, where `workspaces` point, how
14
- * versions are planned), the two commands that are npm's alone (`clean`, `ci`), and the `npm`
14
+ * versions are planned), the commands that are npm's alone (`clean`, `ci`, `install`), and the `npm`
15
15
  * publish target. A polyglot repository names several: `extends: ['node', 'cargo']` holds both,
16
16
  * because every key here appends.
17
17
  */
@@ -28,7 +28,7 @@ export function nodePreset() {
28
28
  augmentSystemInfo();
29
29
  return defineConfig({
30
30
  platforms: [(nodePlatform ??= definePlatform(new NodePlatform()))],
31
- commands: [ciCommand, cleanCommand],
31
+ commands: [ciCommand, cleanCommand, installCommand],
32
32
  publishTargets: [(npmTarget ??= new NpmPublishTarget())],
33
33
  });
34
34
  }
@@ -32,7 +32,7 @@ export class NpmPublishTarget {
32
32
  packageManager: {
33
33
  target: 'cli',
34
34
  cliName: 'package-manager',
35
- describe: 'Package manager to publish with (default: .rmanrc "packageManager.node", else npm)',
35
+ describe: 'Package manager to publish with (default: .rmanrc "packageManager.node", else the lockfile\'s, else npm)',
36
36
  choices: CiService.PACKAGE_MANAGERS,
37
37
  },
38
38
  access: {
package/constants.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.34.0';
1
+ export const version = '2.36.0';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rman",
3
3
  "description": "Repository manager",
4
- "version": "2.34.0",
4
+ "version": "2.36.0",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {