@nx-devkit/prepare-for-release 0.1.23 → 0.1.25

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 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` `^22 || ^23` — installed automatically.
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
- { "plugins": [{ "plugin": "@nx-devkit/prepare-for-release", "options": { "exclude": ["fixtures"] } }] }
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 | Default | Effect |
73
- |---|---|---|
74
- | `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. |
75
- | `scope` | every package in `packages/*` | Package scope prefixes to check. |
76
- | `placeholderTag` | `placeholder` | npm dist-tag applied to the placeholder publish. |
77
- | `placeholderVersion` | `0.0.0` | Version written into the temporary placeholder manifest. |
78
- | `registry` | `https://registry.npmjs.org/` | npm registry URL. |
79
- | `dryRun` | `false` | Report what would happen — no `npm pack`, no publish. |
80
- | `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. |
81
- | `trustRepo` | `NPM_TRUST_REPO` or `GITHUB_REPOSITORY` env, else `nx-devkit/nx.ts` | `owner/repo` slug for the `npm trust github` command. |
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
- //#region src/executors/publish-placeholder/executor.d.ts
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
- //#endregion
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
- //#region src/executors/publish-placeholder/executor.ts
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 = 5 * 6e4;
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) if (resolved.trust && !resolved.dryRun) {
361
- const trustTargets = [...acc.published, ...acc.skipped];
362
- console.log(`\nConfiguring GitHub OIDC trusted publishing for ${trustTargets.length} package(s) (requires MFA)...\n`);
363
- for (const pkgName of trustTargets) try {
364
- await runTrustFor(pkgName, resolved.trustRepo, resolved.registry);
365
- } catch (error) {
366
- if (error instanceof Error && /already.*trust|conflict|exists/i.test(error.message)) {
367
- console.log(` ⊙ ${pkgName} (trust already configured)`);
368
- continue;
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
- throw error;
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
- //#endregion
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
- //#region src/generators/init/generator.ts
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
- //#endregion
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
- //#region src/plugin.ts
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 projectJsonPath = join(isAbsolute(configDir) ? configDir : join(workspaceRoot, configDir), "project.json");
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx-devkit/prepare-for-release",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "license": "MIT",
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": [
@@ -50,13 +50,13 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "tinyglobby": "^0.2.0",
53
- "@nx/devkit": "^22.0.0 || ^23.0.0"
53
+ "@nx/devkit": "^24.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@types/node": "^20.19.0",
57
- "tsdown": "^0.22.3",
56
+ "@types/node": "^26.6.6",
57
+ "tsdown": "^0.23.7",
58
58
  "typescript": "^6.0.3",
59
- "vitest": "^4.1.11"
59
+ "vitest": "^5.1.0"
60
60
  },
61
61
  "repository": {
62
62
  "type": "git",