rman 2.41.1 → 2.41.2

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.2';
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.2",
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) {