@smoothbricks/nx-plugin 0.3.3 → 0.3.5

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.
Files changed (35) hide show
  1. package/README.md +40 -8
  2. package/dist/bounded-test-policy.d.ts +4 -2
  3. package/dist/bounded-test-policy.d.ts.map +1 -1
  4. package/dist/bounded-test-policy.js +93 -15
  5. package/dist/executors/typescript-emit/executor.d.ts +17 -0
  6. package/dist/executors/typescript-emit/executor.d.ts.map +1 -0
  7. package/dist/executors/typescript-emit/executor.js +61 -0
  8. package/dist/executors/typescript-emit/schema.d.ts +5 -0
  9. package/dist/executors/typescript-emit/schema.d.ts.map +1 -0
  10. package/dist/executors/typescript-emit/schema.js +1 -0
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +278 -28
  14. package/dist/package-target-policy.d.ts +2 -0
  15. package/dist/package-target-policy.d.ts.map +1 -1
  16. package/dist/package-target-policy.js +5 -1
  17. package/dist/version-actions.cjs +13 -39
  18. package/dist/version-actions.d.cts.map +1 -1
  19. package/dist/workspace-config-policy.d.ts.map +1 -1
  20. package/dist/workspace-config-policy.js +11 -3
  21. package/executors.json +5 -0
  22. package/package.json +4 -3
  23. package/src/bounded-test-policy.test.ts +102 -2
  24. package/src/bounded-test-policy.ts +110 -17
  25. package/src/executors/typescript-emit/executor.test.ts +98 -0
  26. package/src/executors/typescript-emit/executor.ts +94 -0
  27. package/src/executors/typescript-emit/schema.json +19 -0
  28. package/src/executors/typescript-emit/schema.ts +4 -0
  29. package/src/index.test.ts +157 -17
  30. package/src/index.ts +356 -30
  31. package/src/package-target-policy.test.ts +17 -0
  32. package/src/package-target-policy.ts +5 -1
  33. package/src/version-actions.cts +13 -39
  34. package/src/workspace-config-policy.test.ts +41 -1
  35. package/src/workspace-config-policy.ts +12 -3
@@ -114,6 +114,23 @@ describe('pure core: checkWorkspaceConfig', () => {
114
114
  expect(issues.some((i) => i.message.includes('must not use colon target names'))).toBe(true);
115
115
  });
116
116
 
117
+ it('rejects static test typecheck defaults that override per-project inference', () => {
118
+ const issues = checkWorkspaceConfig({
119
+ ...validNxJson(),
120
+ targetDefaults: {
121
+ ...validTargetDefaults(),
122
+ 'typecheck-tests': {
123
+ dependsOn: ['typecheck'],
124
+ options: { command: 'ttsc -p tsconfig.test.json --noEmit' },
125
+ },
126
+ },
127
+ });
128
+
129
+ expect(
130
+ issues.some((issue) => issue.message.includes('targetDefaults.typecheck-tests must not be configured')),
131
+ ).toBe(true);
132
+ });
133
+
117
134
  it('detects native TypeScript inference', () => {
118
135
  const issues = checkWorkspaceConfig({
119
136
  plugins: ['@nx/js/typescript', '@smoothbricks/nx-plugin'],
@@ -191,6 +208,22 @@ describe('pure core: applyWorkspaceConfig', () => {
191
208
  expect(expectRecord(nxJson.targetDefaults)['build:wasm']).toBeUndefined();
192
209
  });
193
210
 
211
+ it('removes static test typecheck defaults so inference owns clean-output prerequisites', () => {
212
+ const nxJson = {
213
+ ...validNxJson(),
214
+ targetDefaults: {
215
+ ...validTargetDefaults(),
216
+ 'typecheck-tests': {
217
+ dependsOn: ['typecheck'],
218
+ options: { command: 'ttsc -p tsconfig.test.json --noEmit' },
219
+ },
220
+ },
221
+ };
222
+
223
+ expect(applyWorkspaceConfig(nxJson)).toBe(true);
224
+ expect(expectRecord(nxJson.targetDefaults)['typecheck-tests']).toBeUndefined();
225
+ });
226
+
194
227
  it('fixes imprecise production inputs', () => {
195
228
  const nxJson: Record<string, unknown> = {
196
229
  plugins: validPlugins(),
@@ -324,7 +357,13 @@ describe('filesystem: checkWorkspaceConfigPolicy / applyWorkspaceConfigPolicy',
324
357
  try {
325
358
  await writeJsonFile(join(root, 'nx.json'), {
326
359
  plugins: [],
327
- targetDefaults: { build: { cache: false } },
360
+ targetDefaults: {
361
+ build: { cache: false },
362
+ 'typecheck-tests': {
363
+ dependsOn: ['typecheck'],
364
+ options: { command: 'ttsc -p tsconfig.test.json --noEmit' },
365
+ },
366
+ },
328
367
  namedInputs: validNamedInputs(),
329
368
  });
330
369
 
@@ -339,6 +378,7 @@ describe('filesystem: checkWorkspaceConfigPolicy / applyWorkspaceConfigPolicy',
339
378
  const pluginNames = readPluginNames(nxJson.plugins);
340
379
  expect(pluginNames).not.toContain('@nx/js/typescript');
341
380
  expect(pluginNames).toContain('@smoothbricks/nx-plugin');
381
+ expect(expectRecord(nxJson.targetDefaults)['typecheck-tests']).toBeUndefined();
342
382
 
343
383
  // No issues after fix
344
384
  expect(checkWorkspaceConfigPolicy(root)).toEqual([]);
@@ -28,6 +28,7 @@ const nxJsTypescriptPlugin = '@nx/js/typescript';
28
28
  const smoothBricksNxPlugin = '@smoothbricks/nx-plugin';
29
29
  const cleanOutputsExecutor = '@smoothbricks/nx-plugin:clean-outputs';
30
30
  const expectedSharedGlobalsNamedInput = ['{workspaceRoot}/.github/workflows/ci.yml'];
31
+ const inferredTestTypecheckTarget = 'typecheck-tests';
31
32
  const defaultProductionNamedInput = [
32
33
  '{projectRoot}/src/**/*',
33
34
  '{projectRoot}/package.json',
@@ -55,6 +56,14 @@ export function checkWorkspaceConfig(nxJson: Record<string, unknown>): NxPolicyI
55
56
  'Nx CLI syntax already uses project:target:configuration, so smoo Nx target names must be unambiguous tool-output names.',
56
57
  });
57
58
  }
59
+ if (targetName === inferredTestTypecheckTarget) {
60
+ issues.push({
61
+ path: 'nx.json',
62
+ message:
63
+ `targetDefaults.${inferredTestTypecheckTarget} must not be configured. ` +
64
+ 'Per-project inference selects current library or build outputs before test typechecking.',
65
+ });
66
+ }
58
67
  }
59
68
  }
60
69
 
@@ -94,7 +103,7 @@ export function checkWorkspaceConfig(nxJson: Record<string, unknown>): NxPolicyI
94
103
  * Mutates in place, returns whether anything changed.
95
104
  */
96
105
  export function applyWorkspaceConfig(nxJson: Record<string, unknown>): boolean {
97
- let changed = removeColonTargetDefaults(nxJson);
106
+ let changed = removeDisallowedTargetDefaults(nxJson);
98
107
  changed = applyBuildTargetDefault(nxJson) || changed;
99
108
  changed = applyCleanTargetDefault(nxJson) || changed;
100
109
  changed = applyNamedInputDefaults(nxJson) || changed;
@@ -272,14 +281,14 @@ function applyNamedInputDefaults(nxJson: Record<string, unknown>): boolean {
272
281
  return changed;
273
282
  }
274
283
 
275
- function removeColonTargetDefaults(nxJson: Record<string, unknown>): boolean {
284
+ function removeDisallowedTargetDefaults(nxJson: Record<string, unknown>): boolean {
276
285
  const targetDefaults = recordProperty(nxJson, 'targetDefaults');
277
286
  if (!targetDefaults) {
278
287
  return false;
279
288
  }
280
289
  let changed = false;
281
290
  for (const targetName of Object.keys(targetDefaults)) {
282
- if (targetName.includes(':')) {
291
+ if (targetName.includes(':') || targetName === inferredTestTypecheckTarget) {
283
292
  delete targetDefaults[targetName];
284
293
  changed = true;
285
294
  }