@nx-devkit/prepare-for-release 0.1.24 → 0.1.26
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/README.md +16 -12
- package/dist/executors/publish-placeholder/executor.d.mts +4 -6
- package/dist/executors/publish-placeholder/executor.mjs +18 -17
- package/dist/generators/init/generator.d.mts +3 -6
- package/dist/generators/init/generator.mjs +1 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/plugin.d.mts +6 -9
- package/dist/plugin.mjs +3 -3
- package/package.json +31 -31
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Part of [nx-devkit](https://github.com/nx-devkit/nx.ts).
|
|
|
10
10
|
bun add -D @nx-devkit/prepare-for-release
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Depends on `@nx/devkit` `^
|
|
13
|
+
Depends on `@nx/devkit` `^24` — installed automatically.
|
|
14
14
|
|
|
15
15
|
## Bootstrap
|
|
16
16
|
|
|
@@ -29,7 +29,11 @@ npx nx run-many -t prepare-for-release
|
|
|
29
29
|
Each target processes exactly one package; already-published packages skip via `npm view`. Opt a package out with `"private": true`, or exclude project-root prefixes via plugin options:
|
|
30
30
|
|
|
31
31
|
```jsonc
|
|
32
|
-
{
|
|
32
|
+
{
|
|
33
|
+
"plugins": [
|
|
34
|
+
{ "plugin": "@nx-devkit/prepare-for-release", "options": { "exclude": ["fixtures"] } }
|
|
35
|
+
]
|
|
36
|
+
}
|
|
33
37
|
```
|
|
34
38
|
|
|
35
39
|
<!-- sym:generators.json → generators.init.factory,schema -->
|
|
@@ -69,16 +73,16 @@ When npm demands a one-time password, the executor doesn't leave you guessing: i
|
|
|
69
73
|
}
|
|
70
74
|
```
|
|
71
75
|
|
|
72
|
-
| Option
|
|
73
|
-
|
|
74
|
-
| `packageJson`
|
|
75
|
-
| `scope`
|
|
76
|
-
| `placeholderTag`
|
|
77
|
-
| `placeholderVersion` | `0.0.0`
|
|
78
|
-
| `registry`
|
|
79
|
-
| `dryRun`
|
|
80
|
-
| `trust`
|
|
81
|
-
| `trustRepo`
|
|
76
|
+
| Option | Default | Effect |
|
|
77
|
+
| -------------------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
78
|
+
| `packageJson` | unset | Process only this manifest (workspace-relative or absolute path). Set automatically by the per-package inferred target; leave unset for the `packages/*` scan. |
|
|
79
|
+
| `scope` | every package in `packages/*` | Package scope prefixes to check. |
|
|
80
|
+
| `placeholderTag` | `placeholder` | npm dist-tag applied to the placeholder publish. |
|
|
81
|
+
| `placeholderVersion` | `0.0.0` | Version written into the temporary placeholder manifest. |
|
|
82
|
+
| `registry` | `https://registry.npmjs.org/` | npm registry URL. |
|
|
83
|
+
| `dryRun` | `false` | Report what would happen — no `npm pack`, no publish. |
|
|
84
|
+
| `trust` | `false` | Run `npm trust github` for every checked package — including already-published (skipped) ones — not just newly published (requires MFA). With `dryRun: true` the trust commands are printed, not run. |
|
|
85
|
+
| `trustRepo` | `NPM_TRUST_REPO` or `GITHUB_REPOSITORY` env, else `nx-devkit/nx.ts` | `owner/repo` slug for the `npm trust github` command. |
|
|
82
86
|
|
|
83
87
|
## Why placeholders
|
|
84
88
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
interface NxPrepareForReleaseOptions {
|
|
1
|
+
export interface NxPrepareForReleaseOptions {
|
|
3
2
|
/** Path to a single package.json (workspace-relative or absolute). When set, only that package is processed — used by the per-package `prepare-for-release` target. */
|
|
4
3
|
packageJson?: string;
|
|
5
4
|
/** Package scopes to check. Default: derived from packages/* names in the workspace. */
|
|
@@ -21,14 +20,13 @@ interface NxPrepareForReleaseOptions {
|
|
|
21
20
|
*/
|
|
22
21
|
trustRepo?: string;
|
|
23
22
|
}
|
|
24
|
-
interface PublishPlaceholderResult {
|
|
23
|
+
export interface PublishPlaceholderResult {
|
|
25
24
|
success: boolean;
|
|
26
25
|
published: string[];
|
|
27
26
|
skipped: string[];
|
|
28
27
|
trustCommands: string[];
|
|
29
28
|
}
|
|
30
|
-
declare function publishPlaceholderExecutor(options: NxPrepareForReleaseOptions, context: {
|
|
29
|
+
export declare function publishPlaceholderExecutor(options: NxPrepareForReleaseOptions, context: {
|
|
31
30
|
root: string;
|
|
32
31
|
}): Promise<PublishPlaceholderResult>;
|
|
33
|
-
|
|
34
|
-
export { NxPrepareForReleaseOptions, PublishPlaceholderResult, publishPlaceholderExecutor as default, publishPlaceholderExecutor };
|
|
32
|
+
export { publishPlaceholderExecutor as default };
|
|
@@ -4,14 +4,14 @@ import { homedir, tmpdir } from "node:os";
|
|
|
4
4
|
import { dirname, isAbsolute, join } from "node:path";
|
|
5
5
|
import { spawn, spawnSync } from "node:child_process";
|
|
6
6
|
import { glob } from "tinyglobby";
|
|
7
|
-
|
|
7
|
+
// src/executors/publish-placeholder/executor.ts
|
|
8
8
|
const DEFAULT_REGISTRY = "https://registry.npmjs.org/";
|
|
9
9
|
const DEFAULT_TAG = "placeholder";
|
|
10
10
|
const DEFAULT_VERSION = "0.0.0";
|
|
11
11
|
const TRUST_REPO_RE = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
|
|
12
12
|
const NPM_SUBPROCESS_TIMEOUT_MS = 12e4;
|
|
13
13
|
const EOTP_RE = /\bEOTP\b|one-time password/i;
|
|
14
|
-
const WEB_AUTH_TIMEOUT_MS =
|
|
14
|
+
const WEB_AUTH_TIMEOUT_MS = 3e5;
|
|
15
15
|
const WEB_AUTH_POLL_MS = 4e3;
|
|
16
16
|
const WEB_AUTH_FETCH_TIMEOUT_MS = 15e3;
|
|
17
17
|
function resolveOptions(options) {
|
|
@@ -357,27 +357,28 @@ async function publishPlaceholderExecutor(options, context) {
|
|
|
357
357
|
if (existsSync(join(context.root, "scripts/trust-github.sh"))) {}
|
|
358
358
|
if (acc.published.length > 0) console.log(`\nPublished: ${acc.published.join(", ")}`);
|
|
359
359
|
if (acc.skipped.length > 0) console.log(`Skipped: ${acc.skipped.join(", ")}`);
|
|
360
|
-
if (acc.trustCommands.length > 0 || resolved.trust && acc.skipped.length > 0)
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
360
|
+
if (acc.trustCommands.length > 0 || resolved.trust && acc.skipped.length > 0) {
|
|
361
|
+
if (resolved.trust && !resolved.dryRun) {
|
|
362
|
+
const trustTargets = [...acc.published, ...acc.skipped];
|
|
363
|
+
console.log(`\nConfiguring GitHub OIDC trusted publishing for ${trustTargets.length} package(s) (requires MFA)...\n`);
|
|
364
|
+
for (const pkgName of trustTargets) try {
|
|
365
|
+
await runTrustFor(pkgName, resolved.trustRepo, resolved.registry);
|
|
366
|
+
} catch (error) {
|
|
367
|
+
if (error instanceof Error && /already.*trust|conflict|exists/i.test(error.message)) {
|
|
368
|
+
console.log(` ⊙ ${pkgName} (trust already configured)`);
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
throw error;
|
|
369
372
|
}
|
|
370
|
-
|
|
373
|
+
} else {
|
|
374
|
+
console.log("\nRun these locally (requires MFA) to enable GitHub OIDC trusted publishing:\n");
|
|
375
|
+
for (const cmd of acc.trustCommands) console.log(` ${cmd}`);
|
|
376
|
+
for (const pkgName of acc.skipped) console.log(` ${trustCommandFor(pkgName, resolved.trustRepo, resolved.registry)}`);
|
|
371
377
|
}
|
|
372
|
-
} else {
|
|
373
|
-
console.log("\nRun these locally (requires MFA) to enable GitHub OIDC trusted publishing:\n");
|
|
374
|
-
for (const cmd of acc.trustCommands) console.log(` ${cmd}`);
|
|
375
|
-
for (const pkgName of acc.skipped) console.log(` ${trustCommandFor(pkgName, resolved.trustRepo, resolved.registry)}`);
|
|
376
378
|
}
|
|
377
379
|
return {
|
|
378
380
|
success: true,
|
|
379
381
|
...acc
|
|
380
382
|
};
|
|
381
383
|
}
|
|
382
|
-
//#endregion
|
|
383
384
|
export { publishPlaceholderExecutor as default, publishPlaceholderExecutor };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from "@nx/devkit";
|
|
2
|
-
|
|
3
|
-
//#region src/generators/init/generator.d.ts
|
|
4
|
-
interface NxPrepareForReleaseInitOptions {
|
|
2
|
+
export interface NxPrepareForReleaseInitOptions {
|
|
5
3
|
projectName?: string;
|
|
6
4
|
pluginPath?: string;
|
|
7
5
|
}
|
|
8
|
-
declare function initGenerator(tree: Tree, options?: NxPrepareForReleaseInitOptions): Promise<GeneratorCallback>;
|
|
9
|
-
|
|
10
|
-
export { NxPrepareForReleaseInitOptions, initGenerator as default, initGenerator };
|
|
6
|
+
export declare function initGenerator(tree: Tree, options?: NxPrepareForReleaseInitOptions): Promise<GeneratorCallback>;
|
|
7
|
+
export { initGenerator as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { joinPathFragments } from "@nx/devkit";
|
|
2
|
-
|
|
2
|
+
// src/generators/init/generator.ts
|
|
3
3
|
const DEFAULT_PROJECT_NAME = "tools";
|
|
4
4
|
const DEFAULT_PLUGIN_PATH = "@nx-devkit/prepare-for-release";
|
|
5
5
|
function readJson(tree, path) {
|
|
@@ -69,5 +69,4 @@ async function initGenerator(tree, options = {}) {
|
|
|
69
69
|
for (const line of checklist) console.log(line);
|
|
70
70
|
return () => {};
|
|
71
71
|
}
|
|
72
|
-
//#endregion
|
|
73
72
|
export { initGenerator as default, initGenerator };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import { createNodesV2, isReleaseBootstrapProject } from "./plugin.mjs";
|
|
1
2
|
import publishPlaceholderExecutor, { NxPrepareForReleaseOptions, PublishPlaceholderResult } from "./executors/publish-placeholder/executor.mjs";
|
|
2
3
|
import initGenerator, { NxPrepareForReleaseInitOptions } from "./generators/init/generator.mjs";
|
|
3
|
-
import { createNodesV2, isReleaseBootstrapProject } from "./plugin.mjs";
|
|
4
4
|
export { type NxPrepareForReleaseInitOptions, type NxPrepareForReleaseOptions, type PublishPlaceholderResult, createNodesV2, initGenerator, isReleaseBootstrapProject, publishPlaceholderExecutor };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import { createNodesV2, isReleaseBootstrapProject } from "./plugin.mjs";
|
|
1
2
|
import publishPlaceholderExecutor from "./executors/publish-placeholder/executor.mjs";
|
|
2
3
|
import initGenerator from "./generators/init/generator.mjs";
|
|
3
|
-
import { createNodesV2, isReleaseBootstrapProject } from "./plugin.mjs";
|
|
4
4
|
export { createNodesV2, initGenerator, isReleaseBootstrapProject, publishPlaceholderExecutor };
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { CreateNodesV2 } from "@nx/devkit";
|
|
2
|
-
|
|
3
|
-
//#region src/plugin.d.ts
|
|
4
|
-
interface NxPrepareForReleasePluginOptions {
|
|
2
|
+
export interface NxPrepareForReleasePluginOptions {
|
|
5
3
|
/** Path to the tools project that hosts the prepare-for-release target. */
|
|
6
4
|
toolsProject?: string;
|
|
7
5
|
/** Target name inferred on the tools project. */
|
|
@@ -22,16 +20,15 @@ interface NxPrepareForReleasePluginOptions {
|
|
|
22
20
|
* `createNodesV2` to auto-wire a `prepare-for-release` target on the
|
|
23
21
|
* `tools` project created by the init generator.
|
|
24
22
|
*/
|
|
25
|
-
declare function isReleaseBootstrapProject(configFile: string, workspaceRoot: string, executor?: string): boolean;
|
|
23
|
+
export declare function isReleaseBootstrapProject(configFile: string, workspaceRoot: string, executor?: string): boolean;
|
|
26
24
|
/**
|
|
27
25
|
* Read a package.json and return its name when it is publishable
|
|
28
26
|
* (has a `name` and is not `private: true`), otherwise null.
|
|
29
27
|
*/
|
|
30
|
-
declare function publishablePackageName(configFile: string, workspaceRoot: string): string | null;
|
|
31
|
-
declare const createNodesV2: CreateNodesV2<NxPrepareForReleasePluginOptions>;
|
|
28
|
+
export declare function publishablePackageName(configFile: string, workspaceRoot: string): string | null;
|
|
29
|
+
export declare const createNodesV2: CreateNodesV2<NxPrepareForReleasePluginOptions>;
|
|
32
30
|
declare const plugin: {
|
|
33
|
-
createNodesV2: CreateNodesV2<NxPrepareForReleasePluginOptions>;
|
|
34
31
|
name: string;
|
|
32
|
+
createNodesV2: typeof createNodesV2;
|
|
35
33
|
};
|
|
36
|
-
|
|
37
|
-
export { NxPrepareForReleasePluginOptions, createNodesV2, plugin as default, isReleaseBootstrapProject, publishablePackageName };
|
|
34
|
+
export { plugin as default };
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, isAbsolute, join } from "node:path";
|
|
3
|
-
|
|
3
|
+
// src/plugin.ts
|
|
4
4
|
const PLUGIN_NAME = "@nx-devkit/prepare-for-release";
|
|
5
5
|
/**
|
|
6
6
|
* Detect whether a directory is a release-bootstrap site: it contains a
|
|
@@ -10,7 +10,8 @@ const PLUGIN_NAME = "@nx-devkit/prepare-for-release";
|
|
|
10
10
|
*/
|
|
11
11
|
function isReleaseBootstrapProject(configFile, workspaceRoot, executor = `${PLUGIN_NAME}:publish-placeholder`) {
|
|
12
12
|
const configDir = dirname(configFile);
|
|
13
|
-
const
|
|
13
|
+
const projectRoot = isAbsolute(configDir) ? configDir : join(workspaceRoot, configDir);
|
|
14
|
+
const projectJsonPath = join(projectRoot, "project.json");
|
|
14
15
|
if (!existsSync(projectJsonPath)) return false;
|
|
15
16
|
let contents;
|
|
16
17
|
try {
|
|
@@ -84,5 +85,4 @@ const plugin = {
|
|
|
84
85
|
createNodesV2,
|
|
85
86
|
name: PLUGIN_NAME
|
|
86
87
|
};
|
|
87
|
-
//#endregion
|
|
88
88
|
export { createNodesV2, plugin as default, isReleaseBootstrapProject, publishablePackageName };
|
package/package.json
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx-devkit/prepare-for-release",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.26",
|
|
4
|
+
"private": false,
|
|
5
5
|
"description": "Nx plugin that bootstraps npm publishing: 0.0.0 placeholder releases for unpublished packages plus OIDC trusted-publishing setup.",
|
|
6
6
|
"keywords": [
|
|
7
|
-
"
|
|
8
|
-
"nx-plugin",
|
|
7
|
+
"monorepo",
|
|
9
8
|
"npm",
|
|
10
9
|
"npm-publish",
|
|
10
|
+
"nx",
|
|
11
|
+
"nx-plugin",
|
|
11
12
|
"oidc",
|
|
12
|
-
"trusted-publishing",
|
|
13
13
|
"release",
|
|
14
|
-
"
|
|
14
|
+
"trusted-publishing"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/nx-devkit/nx.ts/tree/main/packages/prepare-for-release",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/nx-devkit/nx.ts/issues"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/nx-devkit/nx.ts",
|
|
24
|
+
"directory": "packages/prepare-for-release"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"executors.json",
|
|
29
|
+
"generators.json",
|
|
30
|
+
"src/executors/publish-placeholder/schema.json",
|
|
31
|
+
"src/generators/init/schema.json",
|
|
32
|
+
"README.md"
|
|
15
33
|
],
|
|
16
|
-
"private": false,
|
|
17
34
|
"type": "module",
|
|
18
35
|
"main": "./dist/index.mjs",
|
|
19
36
|
"module": "./dist/index.mjs",
|
|
@@ -33,38 +50,21 @@
|
|
|
33
50
|
},
|
|
34
51
|
"./package.json": "./package.json"
|
|
35
52
|
},
|
|
36
|
-
"executors": "./executors.json",
|
|
37
|
-
"generators": "./generators.json",
|
|
38
|
-
"files": [
|
|
39
|
-
"dist",
|
|
40
|
-
"executors.json",
|
|
41
|
-
"generators.json",
|
|
42
|
-
"src/executors/publish-placeholder/schema.json",
|
|
43
|
-
"src/generators/init/schema.json",
|
|
44
|
-
"README.md"
|
|
45
|
-
],
|
|
46
53
|
"scripts": {
|
|
47
54
|
"build": "tsdown",
|
|
48
55
|
"prepublishOnly": "npm run build -- --clean",
|
|
49
56
|
"test": "vitest run"
|
|
50
57
|
},
|
|
51
58
|
"dependencies": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
59
|
+
"@nx/devkit": "^24.0.0",
|
|
60
|
+
"tinyglobby": "^0.2.0"
|
|
54
61
|
},
|
|
55
62
|
"devDependencies": {
|
|
56
|
-
"@types/node": "^
|
|
57
|
-
"tsdown": "^0.
|
|
63
|
+
"@types/node": "^26.6.6",
|
|
64
|
+
"tsdown": "^0.23.7",
|
|
58
65
|
"typescript": "^6.0.3",
|
|
59
|
-
"vitest": "^
|
|
60
|
-
},
|
|
61
|
-
"repository": {
|
|
62
|
-
"type": "git",
|
|
63
|
-
"url": "https://github.com/nx-devkit/nx.ts",
|
|
64
|
-
"directory": "packages/prepare-for-release"
|
|
66
|
+
"vitest": "^5.1.0"
|
|
65
67
|
},
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
"homepage": "https://github.com/nx-devkit/nx.ts/tree/main/packages/prepare-for-release"
|
|
68
|
+
"executors": "./executors.json",
|
|
69
|
+
"generators": "./generators.json"
|
|
70
70
|
}
|