rman 2.11.0 → 2.11.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.
|
@@ -43,6 +43,11 @@ export declare namespace PublishService {
|
|
|
43
43
|
* goes green" is the most important sentence in the plan when it applies.
|
|
44
44
|
*/
|
|
45
45
|
staged?: boolean;
|
|
46
|
+
/** Subdirectory to publish from, relative to the package's own directory - only consulted when
|
|
47
|
+
* the package doesn't already declare its own `package.json` `publishConfig.directory` (npm's
|
|
48
|
+
* native mechanism for this, which always wins when present). A plan option, because the
|
|
49
|
+
* manifest in that directory is what the plan decides from. */
|
|
50
|
+
contents?: string;
|
|
46
51
|
}
|
|
47
52
|
interface ApplyOptions extends Options {
|
|
48
53
|
packageManager?: CiService.PackageManager;
|
|
@@ -50,10 +55,6 @@ export declare namespace PublishService {
|
|
|
50
55
|
access?: 'public' | 'restricted';
|
|
51
56
|
/** `npm publish --otp <otp>` - a 2FA one-time password, for registries that require it. */
|
|
52
57
|
otp?: string;
|
|
53
|
-
/** Subdirectory to publish from, relative to the package's own directory - only consulted when
|
|
54
|
-
* the package doesn't already declare its own `package.json` `publishConfig.directory` (npm's
|
|
55
|
-
* native mechanism for this, which always wins when present). */
|
|
56
|
-
contents?: string;
|
|
57
58
|
}
|
|
58
59
|
/** One package's outcome in a publish plan - see `getPlan`. */
|
|
59
60
|
interface Entry {
|
|
@@ -101,7 +102,11 @@ export declare namespace PublishService {
|
|
|
101
102
|
* queries it to decide, so it's safe to call any time, including as the plan a bare `rman
|
|
102
103
|
* publish` shows before asking for confirmation.
|
|
103
104
|
*
|
|
104
|
-
*
|
|
105
|
+
* **Whether a package is private is decided from the manifest that would be published.** From a
|
|
106
|
+
* build directory that is the one `publish` derives (see `derivePublishManifest`): `private` there
|
|
107
|
+
* only when the source has it and no `publishConfig`. In place it is the source's own. A build
|
|
108
|
+
* directory that is missing or holds nothing but a `package.json` is an `'error'`: nothing has been
|
|
109
|
+
* built to publish. Each remaining package's **dist-tag**
|
|
105
110
|
* is settled next (`distTagFor`): usually derived from the version itself, `'error'` in the two
|
|
106
111
|
* cases with nothing to derive - that one is about the invocation rather than the package, so it
|
|
107
112
|
* is answered before anything touches the network. A package with uncommitted local changes is
|
|
@@ -72,21 +72,19 @@ function preparePublishManifest(pkg, publishDir, packagesByName) {
|
|
|
72
72
|
* builds a native module on install. The rest (`build`, `test`, `prepare`, ...) never reach the
|
|
73
73
|
* consumer - `prepare` runs for a git dependency, which builds from the repository, not from this
|
|
74
74
|
* tarball.
|
|
75
|
-
* - `private` -
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* `rman publish` became its own release path and the gate started refusing the thing it ships.
|
|
81
|
-
* A narrower guard (`prepublishOnly`, which never reaches a consumer either) says the same thing
|
|
82
|
-
* without claiming the artifact is unpublishable.
|
|
75
|
+
* - `private` - **only when the package declares a `publishConfig`**. A package configured to be
|
|
76
|
+
* published that is also `private` is guarding its source tree against a stray `npm publish`,
|
|
77
|
+
* not refusing to ship; one with no `publishConfig` means it, and keeps the flag. `getPlan`
|
|
78
|
+
* decides from the manifest this produces, so the rule here *is* the publish rule - a preset
|
|
79
|
+
* writing the build directory's manifest must apply the same one.
|
|
83
80
|
* - `publishConfig.directory` - it pointed *here*; kept, it would point one level deeper again.
|
|
84
81
|
*/
|
|
85
82
|
function derivePublishManifest(pkg, packagesByName) {
|
|
86
83
|
const json = structuredClone(pkg.manifest.raw);
|
|
87
84
|
resolveWorkspaceRanges(json, packagesByName);
|
|
88
85
|
delete json.devDependencies;
|
|
89
|
-
|
|
86
|
+
if (json.publishConfig)
|
|
87
|
+
delete json.private;
|
|
90
88
|
if (json.scripts) {
|
|
91
89
|
const kept = Object.fromEntries(Object.entries(json.scripts).filter(([name]) => CONSUMER_SCRIPTS.has(name)));
|
|
92
90
|
if (Object.keys(kept).length)
|
|
@@ -129,7 +127,11 @@ export var PublishService;
|
|
|
129
127
|
* queries it to decide, so it's safe to call any time, including as the plan a bare `rman
|
|
130
128
|
* publish` shows before asking for confirmation.
|
|
131
129
|
*
|
|
132
|
-
*
|
|
130
|
+
* **Whether a package is private is decided from the manifest that would be published.** From a
|
|
131
|
+
* build directory that is the one `publish` derives (see `derivePublishManifest`): `private` there
|
|
132
|
+
* only when the source has it and no `publishConfig`. In place it is the source's own. A build
|
|
133
|
+
* directory that is missing or holds nothing but a `package.json` is an `'error'`: nothing has been
|
|
134
|
+
* built to publish. Each remaining package's **dist-tag**
|
|
133
135
|
* is settled next (`distTagFor`): usually derived from the version itself, `'error'` in the two
|
|
134
136
|
* cases with nothing to derive - that one is about the invocation rather than the package, so it
|
|
135
137
|
* is answered before anything touches the network. A package with uncommitted local changes is
|
|
@@ -187,7 +189,19 @@ export var PublishService;
|
|
|
187
189
|
reason: 'excluded via .rmanrc "publish.skip"',
|
|
188
190
|
});
|
|
189
191
|
}
|
|
190
|
-
else if (pkg
|
|
192
|
+
else if (privateBySource(pkg)) {
|
|
193
|
+
entries.set(pkg.name, { package: pkg, version: pkg.version, status: 'skip', reason: 'private package' });
|
|
194
|
+
}
|
|
195
|
+
else if (!hasBuildOutput(pkg, options.contents)) {
|
|
196
|
+
const dir = path.relative(pkg.dirname, resolvePublishDir(pkg, options.contents)) || '.';
|
|
197
|
+
entries.set(pkg.name, {
|
|
198
|
+
package: pkg,
|
|
199
|
+
version: pkg.version,
|
|
200
|
+
status: 'error',
|
|
201
|
+
reason: `nothing to publish in "${dir}" - it is missing or empty; build the package first`,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
else if (publishesInPlace(pkg, options.contents) && pkg.manifest.raw.private) {
|
|
191
205
|
entries.set(pkg.name, { package: pkg, version: pkg.version, status: 'skip', reason: 'private package' });
|
|
192
206
|
}
|
|
193
207
|
else if (distTag.error) {
|
|
@@ -310,6 +324,41 @@ function resolvePublishDir(pkg, contentsOverride) {
|
|
|
310
324
|
const rel = (typeof native === 'string' && native) || configured || contentsOverride;
|
|
311
325
|
return rel ? path.resolve(pkg.dirname, rel) : pkg.dirname;
|
|
312
326
|
}
|
|
327
|
+
/** `private` in the source with no `publishConfig` - private in every manifest derived from it too. */
|
|
328
|
+
/* **Decided from the manifest `npm publish` reads, which rman writes.** Publishing from a build
|
|
329
|
+
* directory, that is `derivePublishManifest`'s output - written over whatever is there at publish time
|
|
330
|
+
* - so `private` is the source's, kept only without a `publishConfig`. Reported from
|
|
331
|
+
* `postgrejs-kysely`: its source carried `private: true` as a guard against a stray `npm publish`,
|
|
332
|
+
* the plan answered `skip - private package`, and version, tag and GitHub release went through with
|
|
333
|
+
* nothing on the registry.
|
|
334
|
+
*
|
|
335
|
+
* **2.11.1 read `build/package.json` instead, and that file is not what is published.** It is
|
|
336
|
+
* whatever the build left there - the shared preset writes one, but only from the build `after` step
|
|
337
|
+
* a package can replace, and `@opra/common`/`@opra/client` replace it with their own esbuild step. Both
|
|
338
|
+
* had 625 and 52 built files and no `package.json`, the plan answered `error` for both, and opra's
|
|
339
|
+
* release stopped after the version had been pushed.
|
|
340
|
+
*
|
|
341
|
+
* Asked before the build is looked for, so an unbuilt private package is skipped rather than
|
|
342
|
+
* reported as unbuilt: opra's examples inherit `publish.npm.directory` and skip their build. */
|
|
343
|
+
function privateBySource(pkg) {
|
|
344
|
+
return !!pkg.manifest.raw.private && !pkg.manifest.raw.publishConfig;
|
|
345
|
+
}
|
|
346
|
+
/** Whether `pkg` is published from its own directory, whose `package.json` is then the manifest. */
|
|
347
|
+
/* In place, `private` is the source's whatever `publishConfig` says - npm refuses to publish it. */
|
|
348
|
+
function publishesInPlace(pkg, contentsOverride) {
|
|
349
|
+
return path.resolve(resolvePublishDir(pkg, contentsOverride)) === path.resolve(pkg.dirname);
|
|
350
|
+
}
|
|
351
|
+
/** Whether the directory `pkg` is published from holds something to publish - anything besides a
|
|
352
|
+
* `package.json`, which `publish` writes itself. Always true in place. */
|
|
353
|
+
/* Without it `applyPlan` creates the directory, writes the derived manifest and publishes a tarball
|
|
354
|
+
* holding nothing else. Not "has a package.json": that is the build's to write or not (see
|
|
355
|
+
* `privateBySource`). */
|
|
356
|
+
function hasBuildOutput(pkg, contentsOverride) {
|
|
357
|
+
if (publishesInPlace(pkg, contentsOverride))
|
|
358
|
+
return true;
|
|
359
|
+
const dir = resolvePublishDir(pkg, contentsOverride);
|
|
360
|
+
return fs.existsSync(dir) && fs.readdirSync(dir).some(name => name !== 'package.json');
|
|
361
|
+
}
|
|
313
362
|
/**
|
|
314
363
|
* Which registry a package's own version is asked about, and published to.
|
|
315
364
|
*
|
|
@@ -84,7 +84,6 @@ export class NpmPublishTarget {
|
|
|
84
84
|
packageManager: ctx.args.packageManager,
|
|
85
85
|
access: ctx.args.access,
|
|
86
86
|
otp: ctx.args.otp,
|
|
87
|
-
contents: ctx.args.contents,
|
|
88
87
|
});
|
|
89
88
|
}
|
|
90
89
|
/** The shared filters plus the two flags both halves need - read here rather than in the
|
|
@@ -103,6 +102,9 @@ export class NpmPublishTarget {
|
|
|
103
102
|
* flag was not given, so each package's own `publish.npm.staged` still decides - `false`
|
|
104
103
|
* here would mean `--no-staged` and silently overrule the config. */
|
|
105
104
|
staged: ctx.args.staged,
|
|
105
|
+
/** The plan decides from the manifest in the directory being published, so it has to know
|
|
106
|
+
* which directory that is. */
|
|
107
|
+
contents: ctx.args.contents,
|
|
106
108
|
};
|
|
107
109
|
}
|
|
108
110
|
}
|
|
@@ -286,8 +286,11 @@ function printApplied(applied, plan, label) {
|
|
|
286
286
|
return failed;
|
|
287
287
|
}
|
|
288
288
|
/** The `logged` convention: printed here, so `runCli`'s catch does not print it a second time. */
|
|
289
|
+
/* On stderr, because under `--json` stdout is one JSON document: measured on opra's release, the
|
|
290
|
+
* failure line printed below the plan and a reader parsing it got `Unexpected non-whitespace
|
|
291
|
+
* character after JSON`. */
|
|
289
292
|
function logged(message) {
|
|
290
|
-
console.
|
|
293
|
+
console.error(colors.red(message));
|
|
291
294
|
const err = new Error(message);
|
|
292
295
|
err.logged = true;
|
|
293
296
|
return err;
|
package/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.11.
|
|
1
|
+
export const version = '2.11.2';
|