rman 2.41.1 → 2.41.3

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/constants.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.41.1';
1
+ export const version = '2.41.3';
@@ -15,7 +15,7 @@ import type { Repository } from './repository.js';
15
15
  * why a warning printed for one repository was suppressed for the next one in the same process.
16
16
  * - **A namespace cannot be extended.** The two seams a plugin has to specialize
17
17
  * (`NodeVersionPlanService extends VersionPlanService`) are precisely the two that are classes.
18
- * - **A namespace has to be stubbed by mutating the module**, and CLAUDE.md records that failing:
18
+ * - **A namespace has to be stubbed by mutating the module**, and docs/decisions/testing.md records that failing:
19
19
  * a spec that captured a core function at module scope and restored it put the *un-augmented*
20
20
  * version back for the rest of the process and broke a spec two files away. An instance is
21
21
  * rebuilt per application, so a stub dies with it.
@@ -12,7 +12,7 @@
12
12
  * why a warning printed for one repository was suppressed for the next one in the same process.
13
13
  * - **A namespace cannot be extended.** The two seams a plugin has to specialize
14
14
  * (`NodeVersionPlanService extends VersionPlanService`) are precisely the two that are classes.
15
- * - **A namespace has to be stubbed by mutating the module**, and CLAUDE.md records that failing:
15
+ * - **A namespace has to be stubbed by mutating the module**, and docs/decisions/testing.md records that failing:
16
16
  * a spec that captured a core function at module scope and restored it put the *un-augmented*
17
17
  * version back for the rest of the process and broke a spec two files away. An instance is
18
18
  * rebuilt per application, so a stub dies with it.
@@ -159,7 +159,7 @@ export declare function isPlugin(value: unknown): value is Plugin;
159
159
  *
160
160
  * It exists so `Package.platform` need not be optional. `Package.provider` was an empty string for
161
161
  * exactly this case, and every reader had to know that; an object with an empty `name` says the
162
- * same thing without a guard, and `pkg.provider === 'node'` - the check CLAUDE.md prescribes -
162
+ * same thing without a guard, and `pkg.provider === 'node'` - the check docs/decisions/platforms.md prescribes -
163
163
  * reads the same either way.
164
164
  *
165
165
  * **Every documented behaviour of "no plugin" survives unchanged**, because the absences are the
@@ -60,7 +60,7 @@ export function isPlugin(value) {
60
60
  *
61
61
  * It exists so `Package.platform` need not be optional. `Package.provider` was an empty string for
62
62
  * exactly this case, and every reader had to know that; an object with an empty `name` says the
63
- * same thing without a guard, and `pkg.provider === 'node'` - the check CLAUDE.md prescribes -
63
+ * same thing without a guard, and `pkg.provider === 'node'` - the check docs/decisions/platforms.md prescribes -
64
64
  * reads the same either way.
65
65
  *
66
66
  * **Every documented behaviour of "no plugin" survives unchanged**, because the absences are the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rman",
3
3
  "description": "Repository manager",
4
- "version": "2.41.1",
4
+ "version": "2.41.3",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
@@ -1,5 +1,6 @@
1
1
  import { AsyncLocalStorage } from 'node:async_hooks';
2
2
  import os from 'node:os';
3
+ import path from 'node:path';
3
4
  import { inspect } from 'node:util';
4
5
  import colors from 'ansi-colors';
5
6
  import { tokenize } from 'fast-tokenizer';
@@ -8,6 +9,7 @@ import { LOG_LEVELS, Logger, resolveRootLogLevel } from '../core/classes/logger.
8
9
  import { ProgressPanel } from '../core/classes/progress-panel.js';
9
10
  import { PanelReporter, PlainReporter } from '../core/classes/run-reporters.js';
10
11
  import { Service } from '../core/classes/service.js';
12
+ import { ORIGINS } from '../core/config/merge-config.js';
11
13
  import { exec } from '../utils/exec.js';
12
14
  import { filterPackages } from '../utils/package-filter.js';
13
15
  import { runBin } from '../utils/run-bin.js';
@@ -1022,8 +1024,10 @@ async function passesIf(repository, pkg, raw, cwd, statusCache, scopedTo, at = [
1022
1024
  *
1023
1025
  * 1. `run.<script>.override: true` -> the config, always. The escape hatch for "ignore what the
1024
1026
  * package says it does".
1025
- * 2. for `exec`, a **contributed** source - `package.json#scripts` via `rman-node` - wins over the
1026
- * config, because the two are one answer to one question and the more specific statement wins.
1027
+ * 2. for `exec`, a **contributed** source - `package.json#scripts` via `rman-node` - wins over a
1028
+ * config the package inherited, because the two are one answer to one question and the more
1029
+ * specific statement wins. An `exec` written in **the package's own config file** wins over the
1030
+ * contributed one instead, with a warning - see `ownsConfiguredExec`.
1027
1031
  * 3. for `before`/`after`, the two **compose**: they are hooks at a point rather than answers, so
1028
1032
  * the config's bracket the package's own (`config.before -> prebuild -> build -> postbuild ->
1029
1033
  * config.after`). See `slotValues` for the measurement behind that.
@@ -1040,9 +1044,15 @@ function getScriptSteps(pkg, script) {
1040
1044
  exec: RunService.normalizeScriptValue(cfg.exec, `run.${script}.exec`),
1041
1045
  after: RunService.normalizeScriptValue(cfg.after, `run.${script}.after`),
1042
1046
  };
1047
+ /** The package said this in its own config file, beside its own `package.json`: both are the
1048
+ * package's, and the rman one is the deliberate statement about how rman runs it. */
1049
+ const ownExec = !override && !!fromConfig.exec?.length && !!contributed?.exec?.length && ownsConfiguredExec(pkg, script);
1050
+ if (ownExec)
1051
+ warnReplacedScript(pkg, script);
1043
1052
  const steps = [];
1044
1053
  for (const slot of SCRIPT_SLOTS) {
1045
- for (const value of slotValues(slot, contributed?.[slot] ?? [], fromConfig[slot] ?? [], override)) {
1054
+ const slotOverride = override || (ownExec && slot === 'exec');
1055
+ for (const value of slotValues(slot, contributed?.[slot] ?? [], fromConfig[slot] ?? [], slotOverride)) {
1046
1056
  steps.push(toStep(slot, value));
1047
1057
  }
1048
1058
  }
@@ -1129,6 +1139,41 @@ const SCRIPT_SLOTS = ['before', 'exec', 'after'];
1129
1139
  function tokenizeIf(raw) {
1130
1140
  return tokenize(raw, { delimiters: /\s+/, brackets: true, keepBrackets: false }).all();
1131
1141
  }
1142
+ /**
1143
+ * Whether `run.<script>.exec` was written in the package's own config file - a `.rmanrc*` in its
1144
+ * directory, or its manifest's `rman` key - rather than inherited from a directory above, a
1145
+ * `"[selector]"` block there, or an `extends` base.
1146
+ */
1147
+ /* **Reported from `syncbridge-io/syncbridge`**: web-ui's own `.rmanrc.yml` said
1148
+ * `exec: npm run type-check && npm run build` and its `package.json` said `"build": "vite build"`.
1149
+ * The package script won, silently: the type check never ran and a TypeScript error went unnoticed
1150
+ * for two days, while `rman build --config` showed the configured exec as though it would. Both
1151
+ * statements were the package's own, and the one written for rman is the deliberate one - the user's
1152
+ * call, with a warning so the replaced script is not a surprise either way.
1153
+ *
1154
+ * Read off `rawConfig`'s `ORIGINS`, which records the file each key came from (absolute). An inherited
1155
+ * exec keeps losing to the package's script, which is what a shared preset's `"[*]" run.build.exec`
1156
+ * relies on (opra's angular package and its own `ng build`). */
1157
+ function ownsConfiguredExec(pkg, script) {
1158
+ const run = pkg.rawConfig?.run;
1159
+ if (!run || typeof run !== 'object')
1160
+ return false;
1161
+ const block = run[script];
1162
+ const origin = block && typeof block === 'object' && !Array.isArray(block)
1163
+ ? block[ORIGINS]?.exec
1164
+ : run[ORIGINS]?.[script];
1165
+ return !!origin && path.resolve(path.dirname(origin)) === path.resolve(pkg.dirname);
1166
+ }
1167
+ const warnedReplacedScript = new Set();
1168
+ /** Says once per package and script that its own `exec` replaced its `package.json` script. */
1169
+ function warnReplacedScript(pkg, script) {
1170
+ const key = `${pkg.dirname}:${script}`;
1171
+ if (warnedReplacedScript.has(key))
1172
+ return;
1173
+ warnedReplacedScript.add(key);
1174
+ console.warn(colors.yellow(`[${pkg.name}] run.${script}.exec in its own config is used instead of the "${script}" ` +
1175
+ `script in its package.json.`));
1176
+ }
1132
1177
  const warnedUnknownIf = new Set();
1133
1178
  const warnedEmptyIfValue = new Set();
1134
1179
  async function evaluateIfAtom(repository, pkg, name, value, statusCache) {