@nx-devkit/prepare-for-release 0.1.0 → 0.1.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/README.md CHANGED
@@ -1,16 +1,8 @@
1
1
  # @nx-devkit/prepare-for-release
2
2
 
3
- Bootstraps a workspace of packages onto the npm registry by publishing minimal `0.0.0` placeholders. Built so any Nx monorepo can use it.
3
+ Nx plugin + executor for bootstrapping npm packages: publishes a `0.0.0` placeholder tarball for every workspace package that doesn't exist on the registry yet, so the package name is claimed before you wire up [OIDC trusted publishing](https://docs.npmjs.com/trusted-publishers). Idempotent — already-published packages are skipped.
4
4
 
5
- ## What it does
6
-
7
- | Surface | Kind | Purpose |
8
- |---|---|---|
9
- | `@nx-devkit/prepare-for-release:publish-placeholder` | Executor | Scans `packages/*`, publishes a `0.0.0` placeholder for any package not yet on the registry. |
10
- | `@nx-devkit/prepare-for-release:init` | Generator | Adds the plugin to `nx.json`, creates a `tools` project with a `prepare-for-release` target, prints the post-setup checklist. |
11
- | `@nx-devkit/prepare-for-release` (createNodesV2) | Plugin | Detects a `tools/project.json` referencing the executor and re-affirms the `prepare-for-release` target. |
12
-
13
- The executor is idempotent — already-published packages are skipped — and never modifies the source `package.json` (the placeholder tarball is built in a temp directory). Use `dryRun: true` to preview.
5
+ Part of [nx-devkit](https://github.com/nx-devkit/nx.ts).
14
6
 
15
7
  ## Install
16
8
 
@@ -18,73 +10,94 @@ The executor is idempotent — already-published packages are skipped — and ne
18
10
  bun add -D @nx-devkit/prepare-for-release
19
11
  ```
20
12
 
21
- ## Register in nx.json
13
+ Requires `@nx/devkit` `^22 || ^23` (peer).
22
14
 
23
- ```jsonc
24
- {
25
- "plugins": ["@nx-devkit/prepare-for-release"]
26
- }
27
- ```
15
+ ## Bootstrap
28
16
 
29
- Or run the generator:
17
+ Run the `init` generator — it registers the plugin in `nx.json` and creates a `tools` project with the `prepare-for-release` target:
30
18
 
31
19
  ```bash
32
- bunx nx g @nx-devkit/prepare-for-release:init
20
+ npx nx g @nx-devkit/prepare-for-release:init
33
21
  ```
34
22
 
35
- ## Run
23
+ <!-- sym:generators.json → generators.init.factory,schema -->
36
24
 
37
- ```bash
38
- bunx nx run tools:prepare-for-release
39
- # or with options
40
- bunx nx run tools:prepare-for-release --placeholderTag=alpha --placeholderVersion=0.0.1 --dryRun
25
+ Or do it manually:
26
+
27
+ 1. Register the plugin in `nx.json` so `createNodesV2` can detect release-bootstrap projects:
28
+
29
+ ```jsonc
30
+ { "plugins": ["@nx-devkit/prepare-for-release"] }
41
31
  ```
42
32
 
43
- ## Options
33
+ 2. Create `tools/project.json` wired to the executor:
44
34
 
45
- ```ts
46
- export interface NxPrepareForReleaseOptions {
47
- scope?: string[]; // default: derived from packages/* names
48
- placeholderTag?: string; // default: "placeholder"
49
- placeholderVersion?: string; // default: "0.0.0"
50
- registry?: string; // default: "https://registry.npmjs.org/"
51
- dryRun?: boolean; // default: false
52
- trust?: boolean; // default: false — run `npm trust github` for all packages including already-published (requires MFA)
53
- trustRepo?: string; // default: process.env.NPM_TRUST_REPO or process.env.GITHUB_REPOSITORY or "nx-devkit/nx.ts"
35
+ ```jsonc
36
+ {
37
+ "name": "tools",
38
+ "targets": {
39
+ "prepare-for-release": {
40
+ "executor": "@nx-devkit/prepare-for-release:publish-placeholder"
41
+ }
42
+ }
54
43
  }
55
44
  ```
56
45
 
57
- ## Example output
46
+ The plugin's `createNodesV2` scans `**/project.json` for projects whose targets reference its executor and surfaces them on the graph.
47
+
48
+ Then run:
58
49
 
59
- ```text
60
- > nx run tools:prepare-for-release
50
+ ```bash
51
+ npx nx run tools:prepare-for-release
52
+ ```
61
53
 
62
- [@nx-devkit/prepare-for-release] Checking 4 packages
63
- [@nx-devkit/prepare-for-release] @nx-devkit/tsdown: 404 → publishing 0.0.0 placeholder
64
- [@nx-devkit/prepare-for-release] @nx-devkit/oxlint: 404 → publishing 0.0.0 placeholder
65
- [@nx-devkit/prepare-for-release] @nx-devkit/biome: 0.5.0 already on registry, skipping
66
- [@nx-devkit/prepare-for-release] @nx-devkit/typescript: 404 → publishing 0.0.0 placeholder
54
+ ## What the executor does
67
55
 
68
- Published: @nx-devkit/tsdown, @nx-devkit/oxlint, @nx-devkit/typescript
69
- Skipped: @nx-devkit/biome
56
+ For each package under `packages/*` (or your `scope` filter):
70
57
 
71
- Run these locally (requires MFA) to enable GitHub OIDC trusted publishing:
58
+ 1. Checks the registry for an existing version of the package.
59
+ 2. If the name is unclaimed, builds a minimal placeholder tarball **in a temp dir** — your source `package.json` is never mutated.
60
+ 3. Publishes it with `npm publish --tag placeholder`.
61
+ 4. Optionally runs `npm trust github` to bind OIDC trusted publishing to your repo.
62
+
63
+ Already-published packages are skipped on every run.
64
+
65
+ ## Options
72
66
 
73
- npm trust github @nx-devkit/tsdown --file release.yml --repo your-org/your-repo --allow-publish
74
- npm trust github @nx-devkit/oxlint --file release.yml --repo your-org/your-repo --allow-publish
75
- npm trust github @nx-devkit/typescript --file release.yml --repo your-org/your-repo --allow-publish
67
+ <!-- option reference consistent with src/executors/publish-placeholder/schema.json -->
68
+
69
+ ```jsonc
70
+ // tools/project.json → targets.prepare-for-release.options
71
+ {
72
+ "scope": ["@nx-devkit"],
73
+ "placeholderTag": "placeholder",
74
+ "placeholderVersion": "0.0.0",
75
+ "registry": "https://registry.npmjs.org/",
76
+ "dryRun": false,
77
+ "trust": false,
78
+ "trustRepo": "owner/repo"
79
+ }
76
80
  ```
77
81
 
78
- ## When to use
82
+ | Option | Default | Effect |
83
+ |---|---|---|
84
+ | `scope` | every package in `packages/*` | Package scope prefixes to check. |
85
+ | `placeholderTag` | `placeholder` | npm dist-tag applied to the placeholder publish. |
86
+ | `placeholderVersion` | `0.0.0` | Version written into the temporary placeholder manifest. |
87
+ | `registry` | `https://registry.npmjs.org/` | npm registry URL. |
88
+ | `dryRun` | `false` | Report what would happen — no `npm pack`, no publish. |
89
+ | `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. |
90
+ | `trustRepo` | `NPM_TRUST_REPO` or `GITHUB_REPOSITORY` env, else `nx-devkit/nx.ts` | `owner/repo` slug for the `npm trust github` command. |
91
+
92
+ ## Why placeholders
79
93
 
80
- - Adding a brand new Nx plugin package to a workspace that hasn't shipped to npm yet.
81
- - Bootstrapping a multi-package monorepo so that downstream `nx release` + OIDC trusted publishing can take over from there.
82
- - You want the placeholder publish to be idempotent and offline-friendly (it just shells out to `npm view` and `npm publish`).
94
+ npm OIDC trusted publishing requires the package to already exist before you can configure a trust relationship — but publishing the real package first defeats the point. Placeholders claim the name with throwaway `0.0.0` content under a `placeholder` tag (not `latest`), so users never install a stub by accident. The first real release lands under your normal version.
83
95
 
84
- ## Why not `bun publish`?
96
+ ## Security notes
85
97
 
86
- `bun publish` does not yet support npm OIDC trusted publishing. The CI release workflow uses `npx nx release publish` (which uses the npm CLI). The executor also calls the npm CLI directly to keep the bootstrap flow consistent.
98
+ - The executor invokes `npm` via `spawnSync` with an argv array — no shell interpolation of package names, paths, or registry URLs.
99
+ - `npm trust github` runs only when `trust: true` and may prompt for MFA — it's a real-world side effect, not idempotent in the same sense.
87
100
 
88
101
  ## License
89
102
 
90
- MIT
103
+ MIT
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "generators": {
4
+ "init": {
5
+ "factory": "./dist/generators/init/generator.mjs",
6
+ "schema": "./src/generators/init/schema.json",
7
+ "description": "Wires @nx-devkit/prepare-for-release into an Nx workspace: adds the plugin to nx.json, creates a `tools` project with a `prepare-for-release` target, and prints the post-setup checklist."
8
+ }
9
+ }
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx-devkit/prepare-for-release",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "type": "module",
@@ -16,13 +16,20 @@
16
16
  "types": "./dist/plugin.d.mts",
17
17
  "default": "./dist/plugin.mjs"
18
18
  },
19
+ "./generators/init": {
20
+ "types": "./dist/generators/init/generator.d.mts",
21
+ "default": "./dist/generators/init/generator.mjs"
22
+ },
19
23
  "./package.json": "./package.json"
20
24
  },
21
25
  "executors": "./executors.json",
26
+ "generators": "./generators.json",
22
27
  "files": [
23
28
  "dist",
24
29
  "executors.json",
30
+ "generators.json",
25
31
  "src/executors/publish-placeholder/schema.json",
32
+ "src/generators/init/schema.json",
26
33
  "README.md"
27
34
  ],
28
35
  "scripts": {
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "version": 2,
4
+ "title": "init generator",
5
+ "description": "Wires @nx-devkit/prepare-for-release into an Nx workspace: adds the plugin to nx.json, creates a `tools` project with a `prepare-for-release` target, and prints the post-setup checklist.",
6
+ "type": "object",
7
+ "properties": {
8
+ "projectName": {
9
+ "type": "string",
10
+ "description": "Name of the workspace project that hosts the prepare-for-release target.",
11
+ "default": "tools"
12
+ },
13
+ "pluginPath": {
14
+ "type": "string",
15
+ "description": "Module specifier for the plugin in nx.json plugins[]. Use a relative path or package name.",
16
+ "default": "@nx-devkit/prepare-for-release"
17
+ }
18
+ },
19
+ "additionalProperties": false
20
+ }