rman 2.41.0 → 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.
@@ -23,6 +23,7 @@ import { filterPackages } from '../../../../utils/package-filter.js';
23
23
  import { isCalendarVersion } from '../../../../utils/release-version.js';
24
24
  import { npmViewPackage } from '../../../publish-targets/npm/npm-view.js';
25
25
  import { DEPENDENCY_KEYS } from '../node-manifest.provider.js';
26
+ import { consumerNeeds } from '../utils/consumer-needs.js';
26
27
  import { parseWorkspaceRange, resolveWorkspaceRange } from '../utils/workspace-range.js';
27
28
  import { CiService } from './ci.service.js';
28
29
  function preparePublishManifest(pkg, publishDir, packagesByName) {
@@ -460,24 +461,6 @@ function resolvePublishDir(pkg, contentsOverride) {
460
461
  function privateBySource(pkg) {
461
462
  return !!pkg.manifest.raw.private && !pkg.manifest.raw.publishConfig;
462
463
  }
463
- /** Whether a consumer installing `pkg` needs `name` to resolve: a `dependencies` entry, or a peer
464
- * not marked optional. */
465
- /* **Not every edge blocks a publish**, and blocking on all of them cost a release. A failed publish
466
- * stops its dependents because their published range would point at a version that is not there -
467
- * which is only true of what reaches the consumer:
468
- * - `devDependencies` are removed from the published manifest (`derivePublishManifest`);
469
- * - an optional peer that cannot be satisfied does not fail an install;
470
- * - `optionalDependencies` are the ones npm proceeds without "if it cannot be found or fails to
471
- * install" (npm's own documentation; not measured here).
472
- * Measured on opra's 1.31.0 release: `@opra/api-ui` failed its first publish, and `@opra/http` -
473
- * which lists it as an optional peer and a devDependency only - was blocked, taking elastic, mongodb
474
- * and sqb with it, though none of their installs would have needed api-ui. */
475
- function consumerNeeds(pkg, name) {
476
- const raw = pkg.manifest.raw;
477
- if (raw.dependencies?.[name] !== undefined)
478
- return true;
479
- return raw.peerDependencies?.[name] !== undefined && !raw.peerDependenciesMeta?.[name]?.optional;
480
- }
481
464
  /** Whether `pkg` is published from its own directory, whose `package.json` is then the manifest. */
482
465
  /* In place, `private` is the source's whatever `publishConfig` says - npm refuses to publish it. */
483
466
  function publishesInPlace(pkg, contentsOverride) {
@@ -528,8 +511,15 @@ function resolveRegistry(pkg, override) {
528
511
  const native = pkg.manifest.raw.publishConfig?.registry;
529
512
  return override || (typeof native === 'string' && native ? native : undefined);
530
513
  }
531
- /** Why a failed publish is worth trying again, read off npm's output - `undefined` when it is not. */
532
- /* The pattern names are npm's own error codes. `TLOG_CREATE_ENTRY_ERROR` is the Sigstore conflict
514
+ /** Why a failed publish is worth trying again, read off the package manager's output - `undefined`
515
+ * when it is not. */
516
+ /* **npm's and pnpm's spellings both.** npm says `code E503`; pnpm 12 says `Failed to publish package
517
+ * x@1.0.0 (status 503 Service Unavailable)` (`FailedToPublishError`, pnpm/crates/publish), with the
518
+ * status text empty when the registry sent none - hence `(status 5xx` alone. pnpm retries the sigstore
519
+ * signing exchange itself (`sign_with_retry`, two retries), so a transparency-log conflict rarely
520
+ * reaches rman from pnpm; its network errors are not recognized here, not having been seen.
521
+ *
522
+ * The pattern names are npm's own error codes. `TLOG_CREATE_ENTRY_ERROR` is the Sigstore conflict
533
523
  * opra's release hit; the rest are a registry or a network that did not answer this time. A 4xx
534
524
  * other than 429 is left out on purpose: the registry has decided, and asking again changes nothing. */
535
525
  function transientPublishError(output) {
@@ -542,10 +532,10 @@ function transientPublishError(output) {
542
532
  const TRANSIENT_PUBLISH_ERRORS = [
543
533
  [/TLOG_CREATE_ENTRY_ERROR/, 'transparency-log conflict'],
544
534
  [
545
- /\bcode E(5\d\d)\b|\b5\d\d (Internal Server Error|Bad Gateway|Service Unavailable|Gateway Time-?out)\b/i,
535
+ /\bcode E(5\d\d)\b|\(status 5\d\d\b|\b5\d\d (Internal Server Error|Bad Gateway|Service Unavailable|Gateway Time-?out)\b/i,
546
536
  'registry server error',
547
537
  ],
548
- [/\bcode E429\b|\b429 Too Many Requests\b/i, 'registry rate limit'],
538
+ [/\bcode E429\b|\(status 429\b|\b429 Too Many Requests\b/i, 'registry rate limit'],
549
539
  [/\b(ETIMEDOUT|ECONNRESET|ECONNREFUSED|EAI_AGAIN|ESOCKETTIMEDOUT|EPIPE)\b|socket hang up/, 'network error'],
550
540
  ];
551
541
  /** Whether the registry already serves `version` of `pkg` - asked past npm's cache. */
@@ -636,7 +626,13 @@ function distTagFor(pkg, tag) {
636
626
  * The publish flags are passed through unchanged. `--otp` is the one that reads oddly beside it,
637
627
  * since staging is what *defers* the 2FA challenge to approval time - it is passed anyway rather
638
628
  * than refused, because whether npm accepts it there is npm's to answer and a guess here would be a
639
- * rule rman invented. */
629
+ * rule rman invented.
630
+ *
631
+ * **`--no-git-checks` for pnpm**, which otherwise refuses to publish from any branch but
632
+ * `main`/`master` and from a tree with changes. Both are rman's to decide, and both disagree with how
633
+ * rman publishes: a repository releasing prereleases from `alpha`/`beta` (`--allow-branch`) would be
634
+ * refused, and a package published in place has its derived manifest written over `package.json`
635
+ * first, which pnpm reads as a dirty tree. npm makes neither check. */
640
636
  function buildPublishCommand(packageManager, options) {
641
637
  const args = options.staged ? ['stage', 'publish'] : ['publish'];
642
638
  if (options.access)
@@ -649,6 +645,10 @@ function buildPublishCommand(packageManager, options) {
649
645
  args.push('--registry', options.registry);
650
646
  if (options.userconfig)
651
647
  args.push('--userconfig', options.userconfig);
648
+ /** rman has already decided the tree is clean and the branch is allowed (`dirtyReason`,
649
+ * `allowBranch`); pnpm's own checks would decide again, by a rule of its own. */
650
+ if (packageManager === 'pnpm')
651
+ args.push('--no-git-checks');
652
652
  return `${packageManager} ${args.join(' ')}`;
653
653
  }
654
654
  /** Whether this package stages: `--staged`/`--no-staged` when given, else its own
@@ -0,0 +1,4 @@
1
+ import type { Package } from '../../../../core/classes/package.js';
2
+ /** Whether a consumer installing `pkg` needs `name` to resolve: a `dependencies` entry, or a peer
3
+ * not marked optional. */
4
+ export declare function consumerNeeds(pkg: Package, name: string): boolean;
@@ -0,0 +1,18 @@
1
+ /** Whether a consumer installing `pkg` needs `name` to resolve: a `dependencies` entry, or a peer
2
+ * not marked optional. */
3
+ /* **Not every edge blocks a publish**, and blocking on all of them cost a release. A failed publish
4
+ * stops its dependents because their published range would point at a version that is not there -
5
+ * which is only true of what reaches the consumer:
6
+ * - `devDependencies` are removed from the published manifest (`derivePublishManifest`);
7
+ * - an optional peer that cannot be satisfied does not fail an install;
8
+ * - `optionalDependencies` are the ones npm proceeds without "if it cannot be found or fails to
9
+ * install" (npm's own documentation; not measured here).
10
+ * Measured on opra's 1.31.0 release: `@opra/api-ui` failed its first publish, and `@opra/http` -
11
+ * which lists it as an optional peer and a devDependency only - was blocked, taking elastic, mongodb
12
+ * and sqb with it, though none of their installs would have needed api-ui. */
13
+ export function consumerNeeds(pkg, name) {
14
+ const raw = pkg.manifest.raw;
15
+ if (raw.dependencies?.[name] !== undefined)
16
+ return true;
17
+ return raw.peerDependencies?.[name] !== undefined && !raw.peerDependenciesMeta?.[name]?.optional;
18
+ }
@@ -24,7 +24,9 @@ export declare class SpmPublishService extends Service {
24
24
  getPlan(options?: SpmPublishService.Options, deps?: SpmPublishService.Deps): Promise<SpmPublishService.Entry[]>;
25
25
  /**
26
26
  * Publishes every `'publish'` entry with `spm publish --skip-existing`, one package after another,
27
- * in the package's own directory. A failure is that package's alone and is reported on its entry.
27
+ * in the package's own directory. A failure is reported on its entry, and every later entry whose
28
+ * consumers need the failed package - a dependency, or a peer not marked optional - is marked
29
+ * `'error'` without being tried.
28
30
  */
29
31
  applyPlan(plan: SpmPublishService.Entry[]): Promise<SpmPublishService.Entry[]>;
30
32
  /** The access and registry `pkg` publishes with: the flag, else its `.rmanrc "publish.spm"`. */
@@ -4,6 +4,7 @@ import { filesOwnedBy } from '../../../utils/bundled-packages.js';
4
4
  import { dirtyReason, GitHelper } from '../../../utils/git.js';
5
5
  import { filterPackages } from '../../../utils/package-filter.js';
6
6
  import { runBin } from '../../../utils/run-bin.js';
7
+ import { consumerNeeds } from '../../platforms/node/utils/consumer-needs.js';
7
8
  /** The name this target answers to in `publish.target` and `--target`. */
8
9
  export const SPM_TARGET = 'spm';
9
10
  /**
@@ -61,15 +62,30 @@ export class SpmPublishService extends Service {
61
62
  }
62
63
  /**
63
64
  * Publishes every `'publish'` entry with `spm publish --skip-existing`, one package after another,
64
- * in the package's own directory. A failure is that package's alone and is reported on its entry.
65
+ * in the package's own directory. A failure is reported on its entry, and every later entry whose
66
+ * consumers need the failed package - a dependency, or a peer not marked optional - is marked
67
+ * `'error'` without being tried.
65
68
  */
69
+ /* **A failure stops what a consumer's install needs it for**, as the npm target does: the plan is in
70
+ * dependency order, so a module whose dependency or required peer failed would be refused by the
71
+ * registry anyway - its range points at a version that is not there - and trying it only adds a
72
+ * second error further from the cause. The same `consumerNeeds` rule, so an optional peer or a
73
+ * devDependency does not block. */
66
74
  async applyPlan(plan) {
67
75
  const result = [];
76
+ const failed = new Set();
68
77
  for (const entry of plan) {
69
78
  if (entry.status !== 'publish') {
70
79
  result.push(entry);
71
80
  continue;
72
81
  }
82
+ const pkg = entry.package;
83
+ const blocker = pkg.dependencies.find(d => failed.has(d.name) && consumerNeeds(pkg, d.name));
84
+ if (blocker) {
85
+ failed.add(pkg.name);
86
+ result.push({ ...entry, status: 'error', reason: `dependency "${blocker.name}" failed to publish` });
87
+ continue;
88
+ }
73
89
  try {
74
90
  const skipped = await this.publish(entry);
75
91
  result.push(skipped
@@ -81,6 +97,7 @@ export class SpmPublishService extends Service {
81
97
  : entry);
82
98
  }
83
99
  catch (e) {
100
+ failed.add(pkg.name);
84
101
  result.push({ ...entry, status: 'error', reason: e.message });
85
102
  }
86
103
  }
package/constants.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.41.0';
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.0",
4
+ "version": "2.41.2",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
@@ -63,4 +63,4 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  }
66
- }
66
+ }
@@ -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) {