rman 2.37.0 → 2.39.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
@@ -41,8 +41,9 @@ npx rman list
41
41
  ## Quick start
42
42
 
43
43
  `rman` auto-detects your repository layout - point it at a directory containing a `package.json`
44
- with a `workspaces` array (npm/yarn/pnpm-style) and every matched package becomes available to
45
- every command:
44
+ with a `workspaces` array (npm/yarn), or a `pnpm-workspace.yaml` with a `packages` list beside it
45
+ (pnpm, which wins when both are there), and every matched package becomes available to every
46
+ command:
46
47
 
47
48
  ```json
48
49
  // package.json (repository root)
@@ -267,13 +268,13 @@ they still install.
267
268
  ```bash
268
269
  rman deps # what could move, and what holds it back
269
270
  rman deps -u # write the new ranges, then check that they install
270
- rman deps --target major # across a major too
271
+ rman deps --target minor # stay inside each major
271
272
  rman deps '@types/*' # only the dependencies matching this glob
272
273
  ```
273
274
 
274
- **A dependency stays inside its major by default** (`deps.target: minor`). Taking a major is a
275
- decision a person makes: `--target major` for one run, `.rmanrc "deps.target"` for a standing
276
- answer, or `deps.targets` for one dependency. Only a caret or tilde range is rewritten; a version is
275
+ **A dependency may cross a major by default** (`deps.target: major`), as long as every other rule
276
+ allows it. To keep majors a decision: `--target minor` for one run, `.rmanrc "deps.target": minor`
277
+ for a standing answer, or `deps.targets` for one dependency. Only a caret or tilde range is rewritten; a version is
277
278
  offered only when every rule rman can see allows it. See
278
279
  [docs/cli/deps.md](https://github.com/panates/rman/blob/main/docs/cli/deps.md).
279
280
 
@@ -11,15 +11,12 @@ export declare class NodePlatform implements Platform {
11
11
  manifestProvider: NodeManifestProvider;
12
12
  versionPlanner: NodeVersionPlanService;
13
13
  dependencyUpdater: NodeDependencyUpdater;
14
+ /** The file pnpm keeps a workspace's member list in - see `getWorkspace`. */
15
+ protected readonly pnpmWorkspaceFile: string;
14
16
  /**
15
- * npm's `workspaces` globs, resolved against `dir` - the directories directly below it that hold
16
- * a `package.json`.
17
- *
18
- * **Asked of every directory the walk reaches, not only of the repository root**, which is what
19
- * the seam changing from a layout to a per-directory question bought: a `package.json` naming
20
- * `workspaces` is a workspace root wherever it sits, so a Node sub-workspace inside a larger
21
- * repository is now found by the same code that finds the top one. `deep: 0` already made the
22
- * globs one level, so nothing here had to change to make that true.
17
+ * The workspace members of `dir`: the directories its `pnpm-workspace.yaml` `packages` globs
18
+ * match when it has that list, else its `package.json` `workspaces` globs - each one holding a
19
+ * `package.json`. Throws for a `pnpm-workspace.yaml` that is not valid YAML.
23
20
  */
24
21
  getWorkspace(dir: string): string[] | undefined;
25
22
  /**
@@ -52,4 +49,9 @@ export declare class NodePlatform implements Platform {
52
49
  * `<root>/node_modules/.bin` when that has to be overridden - the walk above reaches there first.
53
50
  */
54
51
  getBinPaths(cwd: string): string[];
52
+ /** The `packages` globs of `dir`'s `pnpm-workspace.yaml`, or `undefined` when there is no such
53
+ * file or it lists none. Throws when the file is not valid YAML. */
54
+ protected pnpmWorkspacePackages(dir: string): string[] | undefined;
55
+ /** The directories of `dirs` that hold a `package.json`, each once. */
56
+ protected packageDirs(dirs: readonly string[]): string[];
55
57
  }
@@ -2,6 +2,7 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import parseNpmScript from '@netlify/parse-npm-script';
4
4
  import glob from 'fast-glob';
5
+ import * as yaml from 'js-yaml';
5
6
  import { NodeDependencyUpdater } from './node-dependency-updater.js';
6
7
  import { NodeManifestProvider } from './node-manifest.provider.js';
7
8
  import { NodeVersionPlanService } from './services/version-plan.service.js';
@@ -15,20 +16,40 @@ export class NodePlatform {
15
16
  manifestProvider = new NodeManifestProvider();
16
17
  versionPlanner = new NodeVersionPlanService();
17
18
  dependencyUpdater = new NodeDependencyUpdater();
19
+ /** The file pnpm keeps a workspace's member list in - see `getWorkspace`. */
20
+ pnpmWorkspaceFile = 'pnpm-workspace.yaml';
18
21
  /**
19
- * npm's `workspaces` globs, resolved against `dir` - the directories directly below it that hold
20
- * a `package.json`.
22
+ * The workspace members of `dir`: the directories its `pnpm-workspace.yaml` `packages` globs
23
+ * match when it has that list, else its `package.json` `workspaces` globs - each one holding a
24
+ * `package.json`. Throws for a `pnpm-workspace.yaml` that is not valid YAML.
25
+ */
26
+ /* **pnpm's list first, when there is one** - pnpm reads `pnpm-workspace.yaml` and ignores
27
+ * `package.json#workspaces`, so in a pnpm repository that file is the one the installed tree
28
+ * follows. Reported from `syncbridge-io/public-modules`: with only `pnpm-workspace.yaml`, rman
29
+ * found no packages at all, and the repository had to keep both lists in step.
30
+ *
31
+ * **A `pnpm-workspace.yaml` with no `packages` falls back to `workspaces`**, which is not what pnpm
32
+ * does: measured on pnpm 12.10.1, a settings-only file (`publicHoistPattern` alone) leaves pnpm
33
+ * with the root and no members. pnpm 9 moved its settings into this file, so a settings-only one
34
+ * is ordinary, and a file that says nothing about packages is read as saying nothing.
35
+ *
36
+ * **pnpm's globbing, as measured on the same pnpm**: `packages/**` takes members at any depth and
37
+ * none under `node_modules`; `!packages/test-*` leaves those out. npm's `workspaces` keep the
38
+ * one-level reading (`deep: 0`), which nothing has asked to change.
21
39
  *
22
40
  * **Asked of every directory the walk reaches, not only of the repository root**, which is what
23
41
  * the seam changing from a layout to a per-directory question bought: a `package.json` naming
24
42
  * `workspaces` is a workspace root wherever it sits, so a Node sub-workspace inside a larger
25
- * repository is now found by the same code that finds the top one. `deep: 0` already made the
26
- * globs one level, so nothing here had to change to make that true.
27
- */
43
+ * repository is found by the same code that finds the top one. */
28
44
  getWorkspace(dir) {
29
45
  const manifest = path.join(dir, 'package.json');
30
46
  if (!fs.existsSync(manifest))
31
47
  return undefined;
48
+ const pnpm = this.pnpmWorkspacePackages(dir);
49
+ if (pnpm) {
50
+ const dirs = glob.sync([...pnpm, '!**/node_modules/**'], { cwd: dir, absolute: true, onlyDirectories: true });
51
+ return this.packageDirs(dirs);
52
+ }
32
53
  let patterns;
33
54
  try {
34
55
  patterns = JSON.parse(fs.readFileSync(manifest, 'utf-8'))?.workspaces;
@@ -40,17 +61,13 @@ export class NodePlatform {
40
61
  }
41
62
  if (!Array.isArray(patterns))
42
63
  return undefined;
43
- const packageDirs = [];
64
+ const dirs = [];
44
65
  for (const pattern of patterns) {
45
66
  if (typeof pattern !== 'string')
46
67
  continue;
47
- const dirs = glob.sync(pattern, { cwd: dir, absolute: true, deep: 0, onlyDirectories: true });
48
- for (const d of dirs) {
49
- if (fs.existsSync(path.join(d, 'package.json')))
50
- packageDirs.push(d);
51
- }
68
+ dirs.push(...glob.sync(pattern, { cwd: dir, absolute: true, deep: 0, onlyDirectories: true }));
52
69
  }
53
- return packageDirs;
70
+ return this.packageDirs(dirs);
54
71
  }
55
72
  /**
56
73
  * Teaches `run` about `package.json#scripts`.
@@ -123,6 +140,30 @@ export class NodePlatform {
123
140
  result.push(path.resolve(cwd, process.execPath, '..'));
124
141
  return result;
125
142
  }
143
+ /** The `packages` globs of `dir`'s `pnpm-workspace.yaml`, or `undefined` when there is no such
144
+ * file or it lists none. Throws when the file is not valid YAML. */
145
+ /* Thrown rather than swallowed, unlike a malformed `package.json` above: nothing else in rman
146
+ * reads this file, so a parse error left here would surface as a repository with no packages. */
147
+ pnpmWorkspacePackages(dir) {
148
+ const file = path.join(dir, this.pnpmWorkspaceFile);
149
+ if (!fs.existsSync(file))
150
+ return undefined;
151
+ let parsed;
152
+ try {
153
+ parsed = yaml.load(fs.readFileSync(file, 'utf-8'));
154
+ }
155
+ catch (e) {
156
+ throw new Error(`Cannot read ${file}: ${e.message}`, { cause: e });
157
+ }
158
+ const packages = parsed?.packages;
159
+ if (!Array.isArray(packages))
160
+ return undefined;
161
+ return packages.filter((p) => typeof p === 'string');
162
+ }
163
+ /** The directories of `dirs` that hold a `package.json`, each once. */
164
+ packageDirs(dirs) {
165
+ return [...new Set(dirs)].filter(d => fs.existsSync(path.join(d, 'package.json')));
166
+ }
126
167
  }
127
168
  /** npm's lifecycle names, mapped onto rman's three slots. */
128
169
  function slotOf(stepName, script) {
@@ -84,7 +84,7 @@ const depsCommand = registerCommand(app => {
84
84
  examples: [
85
85
  { command: '$0 deps', description: '# What could move, and what holds it back' },
86
86
  { command: '$0 deps -u', description: '# Write the new ranges, then check that they install' },
87
- { command: '$0 deps --target major', description: '# Across a major too' },
87
+ { command: '$0 deps --target minor', description: '# Stay inside each major' },
88
88
  { command: '$0 deps "@types/*"', description: '# Only the dependencies matching this glob' },
89
89
  ],
90
90
  handler: async (args) => {
@@ -193,7 +193,7 @@ function defaultConcurrency() {
193
193
  return 16;
194
194
  }
195
195
  /**
196
- * `--target`: one of the version schemes' sizes, and by default every size but the largest.
196
+ * `--target`: one of the version schemes' sizes, and by default the largest.
197
197
  *
198
198
  * Read off the technologies this repository loaded rather than written down, because the sizes are
199
199
  * a scheme's - semver's three are the only ones today.
package/constants.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.37.0';
1
+ export const version = '2.39.0';
@@ -116,8 +116,7 @@ export declare namespace DependencyUpdater {
116
116
  restore(): void;
117
117
  }
118
118
  /**
119
- * Every move but the largest - `minor` under semver. The largest is the one a scheme reserves for a
120
- * break, and taking a break is a decision a person makes, not a default.
119
+ * The largest move the scheme has - `major` under semver. `deps.target` or `--target` narrows it.
121
120
  */
122
121
  function defaultTarget(bumps: readonly string[]): string;
123
122
  /**
@@ -2,15 +2,22 @@ import micromatch from 'micromatch';
2
2
  export var DependencyUpdater;
3
3
  (function (DependencyUpdater) {
4
4
  /**
5
- * Every move but the largest - `minor` under semver. The largest is the one a scheme reserves for a
6
- * break, and taking a break is a decision a person makes, not a default.
5
+ * The largest move the scheme has - `major` under semver. `deps.target` or `--target` narrows it.
7
6
  */
8
- /* **It was `latest` - every move - and that was the wrong default**, measured the moment it ran:
9
- * a `^5.3.0` came back as `^7.0.2`. The values are the scheme's own `bumpNames` rather than a list
10
- * written here, for the reason `version` gives: `patch`/`minor`/`major` are semver's words, and a
11
- * four-part scheme would offer four. */
7
+ /* **It has been both, and this is the user's call.** It was every move from the start, then every
8
+ * move but the largest after a `^5.3.0` came back as `^7.0.2` the first time it ran - "taking a
9
+ * break is a decision a person makes". It is the largest again on the user's request, after
10
+ * `--target major` had to be typed to get one (`panates/peacox-ui`'s jsdom 30). What made the old
11
+ * reasoning weaker than it was: the rules that matter for a major are checked whatever the target
12
+ * - a dependency's peer ranges, the running Node and the package's `engines.node`, and under `-u`
13
+ * the package manager's own resolver. A repository that wants majors as a decision writes
14
+ * `deps.target: minor`.
15
+ *
16
+ * The values are the scheme's own `bumpNames` rather than a list written here, for the reason
17
+ * `version` gives: `patch`/`minor`/`major` are semver's words, and a four-part scheme would offer
18
+ * four. */
12
19
  function defaultTarget(bumps) {
13
- return bumps[Math.max(0, bumps.length - 2)];
20
+ return bumps[bumps.length - 1];
14
21
  }
15
22
  DependencyUpdater.defaultTarget = defaultTarget;
16
23
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rman",
3
3
  "description": "Repository manager",
4
- "version": "2.37.0",
4
+ "version": "2.39.0",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {