@@ -208,18 +208,18 @@ gen_enforced_field(WorkspaceCwd, 'module', './dist/index.mjs') :-
208
208
\+ workspace_field(WorkspaceCwd , 'private' , true ).
209
209
% Non-published packages must not specify an entrypoint.
210
210
gen_enforced_field (WorkspaceCwd , 'main' , null ) :-
211
- WorkspaceCwd \= 'packages/shims' ,
211
+ WorkspaceCwd \= 'packages/shims' .
212
212
workspace_field (WorkspaceCwd , 'private' , true ).
213
213
gen_enforced_field (WorkspaceCwd , 'module' , null ) :-
214
- WorkspaceCwd \= 'packages/shims' ,
214
+ WorkspaceCwd \= 'packages/shims' .
215
215
workspace_field (WorkspaceCwd , 'private' , true ).
216
216
217
217
% The type definitions entrypoint for all publishable packages must be the same.
218
218
gen_enforced_field (WorkspaceCwd , 'types' , './dist/index.d.cts' ) :-
219
219
\+ workspace_field(WorkspaceCwd , 'private' , true ).
220
220
% Non-published packages must not specify a type definitions entrypoint.
221
221
gen_enforced_field (WorkspaceCwd , 'types' , null ) :-
222
- WorkspaceCwd \= 'packages/shims' ,
222
+ WorkspaceCwd \= 'packages/shims' .
223
223
workspace_field (WorkspaceCwd , 'private' , true ).
224
224
225
225
% The exports for all published packages must be the same.
@@ -235,18 +235,18 @@ gen_enforced_field(WorkspaceCwd, 'exports["."].import.types', './dist/index.d.mt
235
235
\+ workspace_field(WorkspaceCwd , 'private' , true ).
236
236
% package.json
237
237
gen_enforced_field (WorkspaceCwd , 'exports["./package.json"]' , './package.json' ) :-
238
- \+ workspace_field(WorkspaceCwd , 'private' , true ).
239
- % Non-published packages must not specify exports.
238
+ WorkspaceCwd \= 'packages/extension' ,
239
+ WorkspaceCwd \= '.' .
240
+ % The root package must not specify exports.
240
241
gen_enforced_field (WorkspaceCwd , 'exports' , null ) :-
241
- WorkspaceCwd \= 'packages/shims' ,
242
- workspace_field(WorkspaceCwd , 'private' , true ).
242
+ WorkspaceCwd = '.' .
243
243
244
244
% Published packages must not have side effects.
245
245
gen_enforced_field (WorkspaceCwd , 'sideEffects' , false ) :-
246
246
\+ workspace_field(WorkspaceCwd , 'private' , true ).
247
247
% Non-published packages must not specify side effects.
248
248
gen_enforced_field (WorkspaceCwd , 'sideEffects' , null ) :-
249
- WorkspaceCwd \= 'packages/shims' ,
249
+ WorkspaceCwd \= 'packages/shims' .
250
250
workspace_field (WorkspaceCwd , 'private' , true ).
251
251
252
252
% The list of files included in published packages must only include files
@@ -265,9 +265,14 @@ gen_enforced_field(WorkspaceCwd, 'files', []) :-
265
265
% gen_enforced_field(WorkspaceCwd, 'scripts.build', '') :-
266
266
% WorkspaceCwd \= '.'.
267
267
268
- % All packages except the root and extension must have the same "build:docs" script.
268
+ % All packages except the root and other exceptions must have the same "build:docs" script.
269
269
gen_enforced_field(WorkspaceCwd , 'scripts.build:docs' , 'typedoc' ) :-
270
270
WorkspaceCwd \= 'packages/extension' ,
271
+ WorkspaceCwd \= 'packages/test-utils' ,
272
+ WorkspaceCwd \= '.' .
273
+
274
+ % All packages except the root must have the same "clean" script.
275
+ gen_enforced_field (WorkspaceCwd , 'scripts.clean' , 'rimraf ./dist \' ./*.tsbuildinfo \'' ) :-
271
276
WorkspaceCwd \= '.' .
272
277
273
278
% All published packages must have the same "publish:preview" script.
@@ -301,53 +306,56 @@ gen_enforced_field(WorkspaceCwd, 'scripts.changelog:update', CorrectChangelogUpd
301
306
% All non-root packages must have the same "test" script.
302
307
gen_enforced_field (WorkspaceCwd , 'scripts.test' , 'vitest run --config vitest.config.mts' ) :-
303
308
WorkspaceCwd \= 'packages/shims' ,
309
+ WorkspaceCwd \= 'packages/test-utils' ,
304
310
WorkspaceCwd \= '.' .
305
311
306
312
% All non-root packages must have the same "test:clean" script.
307
313
gen_enforced_field (WorkspaceCwd , 'scripts.test:clean' , 'yarn test --no-cache --coverage.clean' ) :-
314
+ WorkspaceCwd \= 'packages/test-utils' ,
308
315
WorkspaceCwd \= '.' .
309
316
310
317
% All non-root packages must have the same "test:dev" script.
311
318
gen_enforced_field (WorkspaceCwd , 'scripts.test:dev' , 'yarn test --coverage false' ) :-
319
+ WorkspaceCwd \= 'packages/test-utils' ,
312
320
WorkspaceCwd \= '.' .
313
321
314
322
% All non-root packages must have the same "test:verbose" script.
315
323
gen_enforced_field (WorkspaceCwd , 'scripts.test:verbose' , 'yarn test --reporter verbose' ) :-
324
+ WorkspaceCwd \= 'packages/test-utils' ,
316
325
WorkspaceCwd \= '.' .
317
326
318
327
% All non-root packages must have the same "test:watch" script.
319
328
gen_enforced_field (WorkspaceCwd , 'scripts.test:watch' , 'vitest --config vitest.config.mts' ) :-
329
+ WorkspaceCwd \= 'packages/test-utils' ,
320
330
WorkspaceCwd \= '.' .
321
331
322
332
% All dependency ranges must be recognizable (this makes it possible to apply
323
333
% the next two rules effectively).
324
334
gen_enforced_dependency (WorkspaceCwd , DependencyIdent , 'a range optionally starting with ^ or ~' , DependencyType ) :-
325
335
workspace_has_dependency(WorkspaceCwd , DependencyIdent , DependencyRange , DependencyType ),
326
- \+ is_valid_version_range(DependencyRange ).
327
-
328
- % All version ranges used to reference one workspace package in another
329
- % workspace package's `dependencies` or `devDependencies` must be the same.
330
- % Among all references to the same dependency across the monorepo, the one with
331
- % the smallest version range will win. (We handle `peerDependencies` in another
332
- % constraint, as it has slightly different logic.)
336
+ \+ (
337
+ DependencyRange = '^1.0.0-rc.12' ; % is_valid_version_range does not handle rc suffixes
338
+ is_valid_version_range(DependencyRange )
339
+ ).
340
+
341
+ % All dependency ranges for a package must be synchronized across the monorepo
342
+ % (the least version range wins), regardless of which "*dependencies" field
343
+ % where the package appears.
333
344
gen_enforced_dependency (WorkspaceCwd , DependencyIdent , OtherDependencyRange , DependencyType ) :-
334
345
workspace_has_dependency(WorkspaceCwd , DependencyIdent , DependencyRange , DependencyType ),
335
346
workspace_has_dependency(OtherWorkspaceCwd , DependencyIdent , OtherDependencyRange , OtherDependencyType ),
336
347
WorkspaceCwd \= OtherWorkspaceCwd ,
337
348
DependencyRange \= OtherDependencyRange ,
338
- npm_version_range_out_of_sync(DependencyRange , OtherDependencyRange ),
339
- DependencyType \= 'peerDependencies' ,
340
- OtherDependencyType \= 'peerDependencies' .
341
-
342
- % All version ranges used to reference one workspace package in another
343
- % workspace package's `dependencies` or `devDependencies` must match the current
344
- % version of that package. (We handle `peerDependencies` in another rule.)
345
- gen_enforced_dependency (WorkspaceCwd , DependencyIdent , CorrectDependencyRange , DependencyType ) :-
346
- DependencyType \= 'peerDependencies' ,
349
+ npm_version_range_out_of_sync(DependencyRange , OtherDependencyRange ).
350
+
351
+ % If a dependency is listed under "dependencies", it should not be listed under
352
+ % "devDependencies". We match on the same dependency range so that if a
353
+ % dependency is listed under both lists, their versions are synchronized and
354
+ % then this constraint will apply and remove the "right" duplicate.
355
+ gen_enforced_dependency (WorkspaceCwd , DependencyIdent , null , DependencyType ) :-
356
+ workspace_has_dependency(WorkspaceCwd , DependencyIdent , DependencyRange , 'dependencies' ),
347
357
workspace_has_dependency(WorkspaceCwd , DependencyIdent , DependencyRange , DependencyType ),
348
- workspace_ident(OtherWorkspaceCwd , DependencyIdent ),
349
- workspace_version(OtherWorkspaceCwd , OtherWorkspaceVersion ),
350
- atomic_list_concat(['^' , OtherWorkspaceVersion ], CorrectDependencyRange ).
358
+ DependencyType == 'devDependencies' .
351
359
352
360
% If a workspace package is listed under another workspace package's
353
361
% `dependencies`, it should not also be listed under its `devDependencies`.
0 commit comments