Commit 4da7ad1
committed
feat(nx-npm-access): add npm-fix target — auto-remediation, not just checks
Previously the plugin only registered the read-only `npm-check` target.
Add a sibling `npm-fix` target that runs the same script with `--fix` and
applies safe, idempotent remediations:
1. package.json patch — sets `publishConfig.access = "public"` in place
when it is missing or wrong. Offline, no auth required.
2. `npm access set status=public <pkg>` — only for packages already on
npm whose remote visibility drifted to private.
3. `npm access set mfa=<target> <pkg>` — only when `--mfa=<target>` is
explicitly passed (e.g. `--mfa=none` before moving a package to
OIDC trusted publishing).
Trusted publisher (OIDC) registration is deliberately NOT automated — npm
v11 still ships no CLI for it. The script keeps printing the settings
URL for manual UI work, which is the same behaviour as `npm-check`.
Every mutation is recorded in a new `fixes: string[]` field on the
structured JSON report, so a CI step can diff "what changed".
Usage:
bunx nx run-many -t npm-fix # fix everywhere
bunx nx run adt-cli:npm-fix --args="--mfa=none" # per package
The targets now pass `forwardAllArgs: true` so ad-hoc flags (e.g.
`--mfa=...`, `--quiet`) reach the script via nx `--args=...`.
Plugin options renamed: `targetName` → `checkTargetName`, plus a new
`fixTargetName` (defaults preserve backwards-compatible target names).
Locally verified end-to-end on `@abapify/adt-locks` (the only package
still missing `publishConfig.access`): `--fix` successfully patched the
manifest; the local change was reverted from the commit since applying
the actual fix to adt-locks is a separate, intentional action the user
should run via `nx run adt-locks:npm-fix`.1 parent ba33e9a commit 4da7ad1
3 files changed
Lines changed: 151 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
10 | | - | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
14 | 21 | | |
| 22 | + | |
15 | 23 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 24 | + | |
| 25 | + | |
19 | 26 | | |
20 | 27 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
25 | 46 | | |
26 | 47 | | |
27 | 48 | | |
| |||
62 | 83 | | |
63 | 84 | | |
64 | 85 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
68 | 89 | | |
69 | 90 | | |
70 | 91 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
18 | 29 | | |
19 | 30 | | |
20 | 31 | | |
| |||
23 | 34 | | |
24 | 35 | | |
25 | 36 | | |
26 | | - | |
| 37 | + | |
27 | 38 | | |
28 | 39 | | |
29 | 40 | | |
| |||
49 | 60 | | |
50 | 61 | | |
51 | 62 | | |
| 63 | + | |
52 | 64 | | |
| 65 | + | |
53 | 66 | | |
54 | 67 | | |
55 | 68 | | |
| |||
59 | 72 | | |
60 | 73 | | |
61 | 74 | | |
| 75 | + | |
| 76 | + | |
62 | 77 | | |
63 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
64 | 83 | | |
65 | 84 | | |
66 | 85 | | |
| |||
126 | 145 | | |
127 | 146 | | |
128 | 147 | | |
| 148 | + | |
129 | 149 | | |
| 150 | + | |
130 | 151 | | |
131 | 152 | | |
132 | 153 | | |
133 | 154 | | |
134 | | - | |
| 155 | + | |
135 | 156 | | |
136 | 157 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
141 | 177 | | |
142 | 178 | | |
| 179 | + | |
143 | 180 | | |
144 | 181 | | |
145 | 182 | | |
| |||
188 | 225 | | |
189 | 226 | | |
190 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
191 | 263 | | |
192 | 264 | | |
193 | 265 | | |
| |||
215 | 287 | | |
216 | 288 | | |
217 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
218 | 294 | | |
219 | 295 | | |
220 | 296 | | |
221 | 297 | | |
222 | 298 | | |
| 299 | + | |
223 | 300 | | |
224 | | - | |
| 301 | + | |
225 | 302 | | |
226 | 303 | | |
227 | 304 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
11 | 19 | | |
12 | 20 | | |
13 | 21 | | |
| |||
47 | 55 | | |
48 | 56 | | |
49 | 57 | | |
50 | | - | |
| 58 | + | |
| 59 | + | |
51 | 60 | | |
52 | 61 | | |
53 | 62 | | |
| 63 | + | |
| 64 | + | |
54 | 65 | | |
55 | 66 | | |
56 | 67 | | |
| |||
83 | 94 | | |
84 | 95 | | |
85 | 96 | | |
86 | | - | |
| 97 | + | |
87 | 98 | | |
88 | | - | |
| 99 | + | |
| 100 | + | |
89 | 101 | | |
90 | 102 | | |
91 | | - | |
| 103 | + | |
92 | 104 | | |
93 | | - | |
94 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
95 | 108 | | |
96 | 109 | | |
97 | 110 | | |
98 | | - | |
| 111 | + | |
99 | 112 | | |
100 | 113 | | |
101 | 114 | | |
102 | 115 | | |
103 | 116 | | |
104 | 117 | | |
105 | 118 | | |
106 | | - | |
| 119 | + | |
| 120 | + | |
107 | 121 | | |
108 | 122 | | |
109 | 123 | | |
| |||
0 commit comments