rman 2.41.0 → 2.41.1
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/builtins/platforms/node/services/publish.service.js +23 -23
- package/builtins/platforms/node/utils/consumer-needs.d.ts +4 -0
- package/builtins/platforms/node/utils/consumer-needs.js +18 -0
- package/builtins/publish-targets/spm/spm-publish.service.d.ts +3 -1
- package/builtins/publish-targets/spm/spm-publish.service.js +18 -1
- package/constants.js +1 -1
- package/package.json +2 -2
|
@@ -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
|
|
532
|
-
|
|
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
|
|
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
|
|
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.
|
|
1
|
+
export const version = '2.41.1';
|
package/package.json
CHANGED