@produck/agent-toolkit 0.11.0 → 0.11.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
|
@@ -26,7 +26,7 @@ What it does (in order):
|
|
|
26
26
|
6. Deploys root `.c8rc.json` and root `c8` devDependency
|
|
27
27
|
**Note:** The `produck:coverage` script in subpackages is for local and AI development use only. It is NOT enforced by organization CI or `.c8rc.json`. Only the root workspace (monorepo root) is subject to org-level coverage enforcement and `.c8rc.json`.
|
|
28
28
|
7. Deploys root `.gitattributes`
|
|
29
|
-
8. Deploys the pinned `produck:coverage` script
|
|
29
|
+
8. Deploys the pinned `produck:coverage` script to each workspace package and enforces `scripts.test` (generates a default `test` script when missing). Workspace packages rely on root-level c8 devDependency (hoisted by npm workspaces).
|
|
30
30
|
9. Deploys `.husky/pre-commit` and `.husky/commit-msg`
|
|
31
31
|
|
|
32
32
|
After running, add the persistent enforcement entry to the repository
|
|
@@ -90,11 +90,14 @@ failure:
|
|
|
90
90
|
(`produck:baseline`, `produck:commit:check`) plus shared pinned root
|
|
91
91
|
devDependencies (`husky`, `lerna`, `@produck/agent-toolkit`)
|
|
92
92
|
8. `sync-coverage` — deploy root `scripts.produck:coverage`, `.c8rc.json`, and
|
|
93
|
-
root `c8` devDependency
|
|
94
|
-
|
|
95
|
-
package
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
root `c8` devDependency (root-only; does not touch workspace packages)
|
|
94
|
+
9. `sync-workspace` — deploy pinned `produck:coverage` script to each
|
|
95
|
+
workspace package and enforce `scripts.test` (auto-generate a default value
|
|
96
|
+
when missing). Workspace packages rely on root-level c8 devDependency
|
|
97
|
+
(hoisted by npm workspaces) and must not duplicate c8 in their own
|
|
98
|
+
`devDependencies`
|
|
99
|
+
10. `sync-publish` — create default `lerna.json` when missing and deploy root
|
|
100
|
+
`scripts.produck:publish:check` plus `scripts.produck:publish`
|
|
98
101
|
|
|
99
102
|
Add to downstream repository root `package.json` for one-command enforcement:
|
|
100
103
|
|
|
@@ -12,13 +12,14 @@ Behavior:
|
|
|
12
12
|
5) sync-lint
|
|
13
13
|
6) sync-install
|
|
14
14
|
7) sync-git
|
|
15
|
-
8) sync-coverage
|
|
16
|
-
9) sync-
|
|
15
|
+
8) sync-coverage (root-level only)
|
|
16
|
+
9) sync-workspace (workspace packages, scripts only)
|
|
17
|
+
10) sync-publish
|
|
17
18
|
- Stops at first failed step and exits non-zero
|
|
18
19
|
- Prints one combined JSON report for all executed steps
|
|
19
20
|
|
|
20
21
|
Rules:
|
|
21
|
-
- --check runs non-mutating validation mode for step 2
|
|
22
|
-
- --dry-run runs non-mutating preview mode for step 2
|
|
22
|
+
- --check runs non-mutating validation mode for step 2 through step 10
|
|
23
|
+
- --dry-run runs non-mutating preview mode for step 2 through step 10
|
|
23
24
|
- --check takes precedence over --dry-run
|
|
24
|
-
- --workspace filters
|
|
25
|
+
- --workspace filters workspace package targets in step 9
|
|
@@ -3,20 +3,20 @@ Usage:
|
|
|
3
3
|
[--workspace <path>] ... [--check] [--dry-run] [--json <file>]
|
|
4
4
|
|
|
5
5
|
Behavior:
|
|
6
|
-
- Adds or updates scripts.produck:coverage
|
|
7
|
-
|
|
6
|
+
- Adds or updates scripts.produck:coverage in each workspace
|
|
7
|
+
package.json.
|
|
8
8
|
- Enforces scripts.test in each workspace package.json.
|
|
9
9
|
- If scripts.test is missing, generates:
|
|
10
10
|
node -e "console.log('No tests configured')"
|
|
11
|
-
- The produck:coverage script in workspaces
|
|
12
|
-
|
|
11
|
+
- The produck:coverage script in workspaces relies on root-level
|
|
12
|
+
c8 devDependency (hoisted by npm workspaces).
|
|
13
13
|
- Organization-reserved script key is scripts.produck:coverage
|
|
14
|
-
- c8 version is resolved from organization tooling baseline file
|
|
15
14
|
|
|
16
15
|
Rules:
|
|
17
16
|
- When --workspace is omitted, root package.json workspaces are used
|
|
18
17
|
- Single-level glob patterns (e.g. packages/*) are expanded automatically
|
|
19
18
|
- Recursive glob patterns (e.g. packages/**) are rejected
|
|
20
|
-
- Workspace
|
|
19
|
+
- Workspace packages must not duplicate root devDependencies;
|
|
20
|
+
c8 belongs in root package.json only
|
|
21
21
|
- --check validates without writing and exits non-zero on mismatch
|
|
22
22
|
- --dry-run prints planned changes without writing
|
|
@@ -111,10 +111,6 @@ function buildRequiredCoverageScript(baseline) {
|
|
|
111
111
|
return coverageTemplate.replace(/\{c8\.version\}/g, c8Version);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
function buildRequiredC8DevDependency(baseline) {
|
|
115
|
-
return String(baseline.tools.c8.version);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
114
|
function expandGlobPatterns(cwd, entries) {
|
|
119
115
|
const result = [];
|
|
120
116
|
for (const entry of entries) {
|
|
@@ -182,13 +178,7 @@ function resolveWorkspacePaths(cwd, options) {
|
|
|
182
178
|
return raw;
|
|
183
179
|
}
|
|
184
180
|
|
|
185
|
-
function reconcileWorkspace(
|
|
186
|
-
cwd,
|
|
187
|
-
workspacePath,
|
|
188
|
-
mode,
|
|
189
|
-
requiredCoverageScript,
|
|
190
|
-
requiredC8Version,
|
|
191
|
-
) {
|
|
181
|
+
function reconcileWorkspace(cwd, workspacePath, mode, requiredCoverageScript) {
|
|
192
182
|
const packageDir = path.resolve(cwd, workspacePath);
|
|
193
183
|
const packageJsonPath = path.resolve(packageDir, 'package.json');
|
|
194
184
|
|
|
@@ -202,14 +192,10 @@ function reconcileWorkspace(
|
|
|
202
192
|
coverageScript: null,
|
|
203
193
|
previousTestScript: null,
|
|
204
194
|
testScript: null,
|
|
205
|
-
previousC8DevDependency: null,
|
|
206
|
-
c8DevDependency: null,
|
|
207
195
|
matchesRequiredCoverageBefore: false,
|
|
208
196
|
matchesRequiredCoverageAfter: false,
|
|
209
197
|
hasRequiredTestScriptBefore: false,
|
|
210
198
|
hasRequiredTestScriptAfter: false,
|
|
211
|
-
matchesRequiredC8DevDependencyBefore: false,
|
|
212
|
-
matchesRequiredC8DevDependencyAfter: false,
|
|
213
199
|
updated: false,
|
|
214
200
|
error: '',
|
|
215
201
|
};
|
|
@@ -235,12 +221,6 @@ function reconcileWorkspace(
|
|
|
235
221
|
!Array.isArray(pkg.scripts)
|
|
236
222
|
? { ...pkg.scripts }
|
|
237
223
|
: {};
|
|
238
|
-
const devDependencies =
|
|
239
|
-
pkg.devDependencies &&
|
|
240
|
-
typeof pkg.devDependencies === 'object' &&
|
|
241
|
-
!Array.isArray(pkg.devDependencies)
|
|
242
|
-
? { ...pkg.devDependencies }
|
|
243
|
-
: {};
|
|
244
224
|
|
|
245
225
|
const previousCoverage =
|
|
246
226
|
typeof scripts[REQUIRED_COVERAGE_SCRIPT_KEY] === 'string'
|
|
@@ -251,30 +231,22 @@ function reconcileWorkspace(
|
|
|
251
231
|
scripts[REQUIRED_TEST_SCRIPT_KEY].trim() !== ''
|
|
252
232
|
? scripts[REQUIRED_TEST_SCRIPT_KEY]
|
|
253
233
|
: null;
|
|
254
|
-
const previousC8DevDependency =
|
|
255
|
-
typeof devDependencies.c8 === 'string' ? devDependencies.c8 : null;
|
|
256
234
|
result.previousCoverage = previousCoverage;
|
|
257
235
|
result.previousTestScript = previousTestScript;
|
|
258
|
-
result.previousC8DevDependency = previousC8DevDependency;
|
|
259
236
|
result.matchesRequiredCoverageBefore =
|
|
260
237
|
previousCoverage === requiredCoverageScript;
|
|
261
238
|
result.hasRequiredTestScriptBefore = previousTestScript !== null;
|
|
262
|
-
result.matchesRequiredC8DevDependencyBefore =
|
|
263
|
-
previousC8DevDependency === requiredC8Version;
|
|
264
239
|
|
|
265
240
|
if (
|
|
266
241
|
(!result.matchesRequiredCoverageBefore ||
|
|
267
|
-
!result.hasRequiredTestScriptBefore
|
|
268
|
-
!result.matchesRequiredC8DevDependencyBefore) &&
|
|
242
|
+
!result.hasRequiredTestScriptBefore) &&
|
|
269
243
|
mode === 'sync'
|
|
270
244
|
) {
|
|
271
245
|
scripts[REQUIRED_COVERAGE_SCRIPT_KEY] = requiredCoverageScript;
|
|
272
246
|
if (!result.hasRequiredTestScriptBefore) {
|
|
273
247
|
scripts[REQUIRED_TEST_SCRIPT_KEY] = DEFAULT_TEST_SCRIPT_VALUE;
|
|
274
248
|
}
|
|
275
|
-
devDependencies.c8 = requiredC8Version;
|
|
276
249
|
pkg.scripts = scripts;
|
|
277
|
-
pkg.devDependencies = devDependencies;
|
|
278
250
|
fs.writeFileSync(
|
|
279
251
|
packageJsonPath,
|
|
280
252
|
`${JSON.stringify(pkg, null, 2)}\n`,
|
|
@@ -291,18 +263,12 @@ function reconcileWorkspace(
|
|
|
291
263
|
mode === 'sync' && !result.hasRequiredTestScriptBefore
|
|
292
264
|
? DEFAULT_TEST_SCRIPT_VALUE
|
|
293
265
|
: previousTestScript;
|
|
294
|
-
result.c8DevDependency =
|
|
295
|
-
mode === 'sync' && !result.matchesRequiredC8DevDependencyBefore
|
|
296
|
-
? requiredC8Version
|
|
297
|
-
: previousC8DevDependency;
|
|
298
266
|
|
|
299
267
|
result.matchesRequiredCoverageAfter =
|
|
300
268
|
result.updated || result.matchesRequiredCoverageBefore;
|
|
301
269
|
result.hasRequiredTestScriptAfter =
|
|
302
270
|
(mode === 'sync' && !result.hasRequiredTestScriptBefore) ||
|
|
303
271
|
result.hasRequiredTestScriptBefore;
|
|
304
|
-
result.matchesRequiredC8DevDependencyAfter =
|
|
305
|
-
result.updated || result.matchesRequiredC8DevDependencyBefore;
|
|
306
272
|
return result;
|
|
307
273
|
}
|
|
308
274
|
|
|
@@ -314,7 +280,6 @@ export function runSyncWorkspace(options) {
|
|
|
314
280
|
const { baseline: toolingBaseline, toolingBaselinePath } =
|
|
315
281
|
loadToolingBaseline();
|
|
316
282
|
const requiredCoverageScript = buildRequiredCoverageScript(toolingBaseline);
|
|
317
|
-
const requiredC8Version = buildRequiredC8DevDependency(toolingBaseline);
|
|
318
283
|
|
|
319
284
|
if (!fs.existsSync(cwd)) {
|
|
320
285
|
console.error(`CWD does not exist: ${cwd}`);
|
|
@@ -334,7 +299,6 @@ export function runSyncWorkspace(options) {
|
|
|
334
299
|
},
|
|
335
300
|
requiredCoverageScript,
|
|
336
301
|
requiredTestScript: DEFAULT_TEST_SCRIPT_VALUE,
|
|
337
|
-
requiredC8DevDependency: requiredC8Version,
|
|
338
302
|
workspaces: workspacePaths,
|
|
339
303
|
results: [],
|
|
340
304
|
ok: true,
|
|
@@ -347,7 +311,6 @@ export function runSyncWorkspace(options) {
|
|
|
347
311
|
workspacePath,
|
|
348
312
|
effectiveMode,
|
|
349
313
|
requiredCoverageScript,
|
|
350
|
-
requiredC8Version,
|
|
351
314
|
);
|
|
352
315
|
report.results.push(item);
|
|
353
316
|
|
|
@@ -358,9 +321,7 @@ export function runSyncWorkspace(options) {
|
|
|
358
321
|
|
|
359
322
|
if (
|
|
360
323
|
mode === 'check' &&
|
|
361
|
-
(!item.matchesRequiredCoverageAfter ||
|
|
362
|
-
!item.hasRequiredTestScriptAfter ||
|
|
363
|
-
!item.matchesRequiredC8DevDependencyAfter)
|
|
324
|
+
(!item.matchesRequiredCoverageAfter || !item.hasRequiredTestScriptAfter)
|
|
364
325
|
) {
|
|
365
326
|
report.ok = false;
|
|
366
327
|
}
|
package/package.json
CHANGED