@smoothbricks/nx-plugin 0.1.0 → 0.2.0

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 (74) hide show
  1. package/README.md +35 -8
  2. package/dist/bounded-test-policy.d.ts +32 -0
  3. package/dist/bounded-test-policy.d.ts.map +1 -0
  4. package/dist/bounded-test-policy.js +184 -0
  5. package/dist/executors/bounded-exec/executor.d.ts +15 -0
  6. package/dist/executors/bounded-exec/executor.d.ts.map +1 -0
  7. package/dist/executors/bounded-exec/executor.js +179 -0
  8. package/dist/executors/bounded-exec/schema.d.ts +11 -0
  9. package/dist/executors/bounded-exec/schema.d.ts.map +1 -0
  10. package/dist/executors/bounded-exec/schema.js +1 -0
  11. package/dist/generators/bounded-test-targets/generator.d.ts +7 -0
  12. package/dist/generators/bounded-test-targets/generator.d.ts.map +1 -0
  13. package/dist/generators/bounded-test-targets/generator.js +40 -0
  14. package/dist/generators/bun-test-tracing/generator.d.ts.map +1 -1
  15. package/dist/generators/bun-test-tracing/generator.js +5 -4
  16. package/dist/generators/create-package/generator.d.ts +4 -0
  17. package/dist/generators/create-package/generator.d.ts.map +1 -0
  18. package/dist/generators/create-package/generator.js +204 -0
  19. package/dist/generators/make-public/generator.d.ts +4 -0
  20. package/dist/generators/make-public/generator.d.ts.map +1 -0
  21. package/dist/generators/make-public/generator.js +55 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +78 -7
  24. package/dist/package-target-policy.d.ts +31 -0
  25. package/dist/package-target-policy.d.ts.map +1 -0
  26. package/dist/package-target-policy.js +930 -0
  27. package/dist/release-config-policy.d.ts +32 -0
  28. package/dist/release-config-policy.d.ts.map +1 -0
  29. package/dist/release-config-policy.js +225 -0
  30. package/dist/typecheck-test-policy.d.ts +56 -0
  31. package/dist/typecheck-test-policy.d.ts.map +1 -0
  32. package/dist/typecheck-test-policy.js +640 -0
  33. package/dist/version-actions.cjs +78 -0
  34. package/dist/version-actions.d.cts +6 -0
  35. package/dist/version-actions.d.cts.map +1 -0
  36. package/dist/workspace-config-policy.d.ts +33 -0
  37. package/dist/workspace-config-policy.d.ts.map +1 -0
  38. package/dist/workspace-config-policy.js +334 -0
  39. package/executors.json +9 -0
  40. package/generators.json +15 -0
  41. package/package.json +45 -11
  42. package/src/bounded-test-policy.test.ts +257 -0
  43. package/src/bounded-test-policy.ts +257 -0
  44. package/src/bun-bootstrap.test.ts +52 -0
  45. package/src/executors/bounded-exec/executor.test.ts +258 -0
  46. package/src/executors/bounded-exec/executor.ts +228 -0
  47. package/src/executors/bounded-exec/schema.json +68 -0
  48. package/src/executors/bounded-exec/schema.ts +10 -0
  49. package/src/generators/bounded-test-targets/generator.test.ts +136 -0
  50. package/src/generators/bounded-test-targets/generator.ts +67 -0
  51. package/src/generators/bounded-test-targets/schema.d.ts +3 -0
  52. package/src/generators/bounded-test-targets/schema.json +14 -0
  53. package/src/generators/bun-test-tracing/generator.test.ts +25 -1
  54. package/src/generators/bun-test-tracing/generator.ts +6 -5
  55. package/src/generators/create-package/generator.test.ts +206 -0
  56. package/src/generators/create-package/generator.ts +251 -0
  57. package/src/generators/create-package/schema.d.ts +5 -0
  58. package/src/generators/create-package/schema.json +24 -0
  59. package/src/generators/make-public/generator.test.ts +137 -0
  60. package/src/generators/make-public/generator.ts +83 -0
  61. package/src/generators/make-public/schema.d.ts +3 -0
  62. package/src/generators/make-public/schema.json +13 -0
  63. package/src/index.test.ts +85 -18
  64. package/src/index.ts +99 -8
  65. package/src/package-target-policy.test.ts +778 -0
  66. package/src/package-target-policy.ts +1127 -0
  67. package/src/release-config-policy.test.ts +280 -0
  68. package/src/release-config-policy.ts +258 -0
  69. package/src/typecheck-test-policy.test.ts +797 -0
  70. package/src/typecheck-test-policy.ts +752 -0
  71. package/src/version-actions.cts +94 -0
  72. package/src/workspace-config-policy.test.ts +376 -0
  73. package/src/workspace-config-policy.ts +390 -0
  74. package/src/test-suite-tracer.ts +0 -0
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ const node_fs_1 = require("node:fs");
3
+ const node_path_1 = require("node:path");
4
+ const nxJsVersionActions = require('@nx/js/src/release/version-actions');
5
+ const baseVersionActions = nxJsVersionActions.default ?? nxJsVersionActions;
6
+ const afterAllProjectsVersioned = async (cwd, options) => {
7
+ const result = await nxJsVersionActions.afterAllProjectsVersioned(cwd, options);
8
+ // Temporary Bun workaround. Delete this hook together with the CLI lockfile
9
+ // sync/validation code once supported Bun versions fix all three issues:
10
+ // - https://github.com/oven-sh/bun/issues/18906
11
+ // - https://github.com/oven-sh/bun/issues/20477
12
+ // - https://github.com/oven-sh/bun/issues/20829
13
+ // Nx runs `bun install --lockfile-only`, but Bun currently leaves workspace
14
+ // versions stale in bun.lock. `bun pm pack` then rewrites `workspace:*` using
15
+ // those stale lockfile versions instead of the current package.json versions.
16
+ const updated = syncBunLockfileVersions(cwd);
17
+ if (updated === 0) {
18
+ return result;
19
+ }
20
+ return {
21
+ changedFiles: Array.from(new Set([...result.changedFiles, 'bun.lock'])),
22
+ deletedFiles: result.deletedFiles,
23
+ };
24
+ };
25
+ baseVersionActions.afterAllProjectsVersioned = afterAllProjectsVersioned;
26
+ function syncBunLockfileVersions(root) {
27
+ const lockfilePath = (0, node_path_1.join)(root, 'bun.lock');
28
+ if (!(0, node_fs_1.existsSync)(lockfilePath)) {
29
+ throw new Error('bun.lock not found');
30
+ }
31
+ const packages = workspacePackages(root);
32
+ let lockfile = (0, node_fs_1.readFileSync)(lockfilePath, 'utf8');
33
+ let updated = 0;
34
+ for (const pkg of packages) {
35
+ const relativePath = pkg.path.replaceAll('\\', '/');
36
+ const escaped = escapeRegex(relativePath);
37
+ const pattern = new RegExp(`("${escaped}":\\s*\\{[^}]*"version":\\s*")([^"]+)(")`);
38
+ const match = lockfile.match(pattern);
39
+ if (!match) {
40
+ console.log(`skip: ${relativePath} (not found in lockfile)`);
41
+ continue;
42
+ }
43
+ const lockVersion = match[2];
44
+ if (lockVersion === pkg.version) {
45
+ console.log(`ok: ${relativePath} = ${pkg.version}`);
46
+ continue;
47
+ }
48
+ lockfile = lockfile.replace(pattern, `$1${pkg.version}$3`);
49
+ console.log(`fix: ${relativePath}: ${lockVersion} -> ${pkg.version}`);
50
+ updated++;
51
+ }
52
+ if (updated > 0) {
53
+ (0, node_fs_1.writeFileSync)(lockfilePath, lockfile);
54
+ }
55
+ console.log(updated > 0 ? `Updated ${updated} workspace version(s) in bun.lock` : 'All workspace versions already in sync.');
56
+ return updated;
57
+ }
58
+ function workspacePackages(root) {
59
+ const packagesRoot = (0, node_path_1.join)(root, 'packages');
60
+ return (0, node_fs_1.readdirSync)(packagesRoot, { withFileTypes: true })
61
+ .filter((entry) => entry.isDirectory())
62
+ .map((entry) => {
63
+ const path = `packages/${entry.name}`;
64
+ const packageJsonPath = (0, node_path_1.join)(root, path, 'package.json');
65
+ if (!(0, node_fs_1.existsSync)(packageJsonPath)) {
66
+ return null;
67
+ }
68
+ const json = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, 'utf8'));
69
+ return typeof json.name === 'string' && typeof json.version === 'string'
70
+ ? { path, name: json.name, version: json.version }
71
+ : null;
72
+ })
73
+ .filter((pkg) => pkg !== null);
74
+ }
75
+ function escapeRegex(value) {
76
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
77
+ }
78
+ module.exports = baseVersionActions;
@@ -0,0 +1,6 @@
1
+ import type { AfterAllProjectsVersioned, VersionActions } from 'nx/release';
2
+ declare const baseVersionActions: typeof VersionActions & {
3
+ afterAllProjectsVersioned: AfterAllProjectsVersioned;
4
+ };
5
+ export = baseVersionActions;
6
+ //# sourceMappingURL=version-actions.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-actions.d.cts","sourceRoot":"","sources":["../src/version-actions.cts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAQ5E,QAAA,MAAM,kBAAkB;+BALyC,yBAAyB;CAKf,CAAC;AA0B5E,SAAS,kBAAkB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { Tree } from 'nx/src/devkit-exports.js';
2
+ export interface NxPolicyIssue {
3
+ path: string;
4
+ message: string;
5
+ }
6
+ export declare const BUILD_OUTPUT_DEPENDENCIES: string[];
7
+ /**
8
+ * Check workspace config policy on an in-memory nx.json object.
9
+ */
10
+ export declare function checkWorkspaceConfig(nxJson: Record<string, unknown>): NxPolicyIssue[];
11
+ /**
12
+ * Apply workspace config policy to an in-memory nx.json object.
13
+ * Mutates in place, returns whether anything changed.
14
+ */
15
+ export declare function applyWorkspaceConfig(nxJson: Record<string, unknown>): boolean;
16
+ /**
17
+ * Check workspace config policy using an Nx Tree.
18
+ */
19
+ export declare function checkWorkspaceConfigTree(tree: Tree): NxPolicyIssue[];
20
+ /**
21
+ * Apply workspace config policy using an Nx Tree.
22
+ * Returns whether anything changed.
23
+ */
24
+ export declare function applyWorkspaceConfigTree(tree: Tree): boolean;
25
+ /**
26
+ * Check nx.json workspace config policy, returns issues found.
27
+ */
28
+ export declare function checkWorkspaceConfigPolicy(root: string): NxPolicyIssue[];
29
+ /**
30
+ * Fix nx.json workspace config policy. Returns whether anything changed.
31
+ */
32
+ export declare function applyWorkspaceConfigPolicy(root: string): boolean;
33
+ //# sourceMappingURL=workspace-config-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-config-policy.d.ts","sourceRoot":"","sources":["../src/workspace-config-policy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,yBAAyB,UAWrC,CAAC;AAcF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,EAAE,CAoDrF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAc7E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAKpE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAU5D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAYxE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAWhE"}
@@ -0,0 +1,334 @@
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { readJson, updateJson } from 'nx/src/devkit-exports.js';
4
+ export const BUILD_OUTPUT_DEPENDENCIES = [
5
+ '*-js',
6
+ '*-web',
7
+ '*-html',
8
+ '*-css',
9
+ '*-ios',
10
+ '*-android',
11
+ '*-native',
12
+ '*-napi',
13
+ '*-bun',
14
+ '*-wasm',
15
+ ];
16
+ const nxJsTypescriptPlugin = '@nx/js/typescript';
17
+ const smoothBricksNxPlugin = '@smoothbricks/nx-plugin';
18
+ const expectedSharedGlobalsNamedInput = ['{workspaceRoot}/.github/workflows/ci.yml'];
19
+ const defaultProductionNamedInput = [
20
+ '{projectRoot}/src/**/*',
21
+ '{projectRoot}/package.json',
22
+ '!{projectRoot}/**/__tests__/**',
23
+ '!{projectRoot}/**/*.test.*',
24
+ '!{projectRoot}/**/*.spec.*',
25
+ ];
26
+ const impreciseProductionInputs = new Set(['default', '{projectRoot}/**/*', '{projectRoot}/**']);
27
+ /**
28
+ * Check workspace config policy on an in-memory nx.json object.
29
+ */
30
+ export function checkWorkspaceConfig(nxJson) {
31
+ const issues = [];
32
+ // Colon target defaults
33
+ const targetDefaults = recordProperty(nxJson, 'targetDefaults');
34
+ if (targetDefaults) {
35
+ for (const targetName of Object.keys(targetDefaults)) {
36
+ if (targetName.includes(':')) {
37
+ issues.push({
38
+ path: 'nx.json',
39
+ message: `targetDefaults.${targetName} must not use colon target names. ` +
40
+ 'Nx CLI syntax already uses project:target:configuration, so smoo Nx target names must be unambiguous tool-output names.',
41
+ });
42
+ }
43
+ }
44
+ }
45
+ // Build target default
46
+ validateBuildTargetDefault(nxJson, 'nx.json', issues);
47
+ // Named input defaults
48
+ validateNamedInputDefaults(nxJson, 'nx.json', issues);
49
+ // Plugin configuration
50
+ const plugins = Array.isArray(nxJson.plugins) ? nxJson.plugins : [];
51
+ const nxJsPlugin = plugins.find(isNxJsTypescriptPlugin);
52
+ if (!nxJsPlugin) {
53
+ issues.push({
54
+ path: 'nx.json',
55
+ message: `plugins must configure ${nxJsTypescriptPlugin}. ` +
56
+ 'Official Nx owns TypeScript library inference; smoo configures it so tsconfig.lib.json produces tsc-js and leaves build available as an aggregate target.',
57
+ });
58
+ }
59
+ else if (nxJsBuildTargetName(nxJsPlugin) !== 'tsc-js') {
60
+ issues.push({
61
+ path: 'nx.json',
62
+ message: `${nxJsTypescriptPlugin} build.targetName must be tsc-js. ` +
63
+ 'TypeScript library output is a concrete tool-output target; build is reserved for aggregate targets that depend on concrete build work.',
64
+ });
65
+ }
66
+ if (!plugins.includes(smoothBricksNxPlugin) && !plugins.some(isSmoothBricksNxPluginRecord)) {
67
+ issues.push({
68
+ path: 'nx.json',
69
+ message: `plugins must include ${smoothBricksNxPlugin}. ` +
70
+ 'Smoo relies on this plugin to infer convention targets that official Nx does not provide, including typecheck-tests, non-TypeScript build-tool targets, and aggregate build/lint targets.',
71
+ });
72
+ }
73
+ return issues;
74
+ }
75
+ /**
76
+ * Apply workspace config policy to an in-memory nx.json object.
77
+ * Mutates in place, returns whether anything changed.
78
+ */
79
+ export function applyWorkspaceConfig(nxJson) {
80
+ let changed = removeColonTargetDefaults(nxJson);
81
+ changed = applyBuildTargetDefault(nxJson) || changed;
82
+ changed = applyNamedInputDefaults(nxJson) || changed;
83
+ const currentPlugins = Array.isArray(nxJson.plugins) ? nxJson.plugins : [];
84
+ const nextPlugins = upsertNxPlugin(upsertNxPlugin(currentPlugins, expectedNxJsTypescriptPlugin()), smoothBricksNxPlugin);
85
+ if (JSON.stringify(currentPlugins) !== JSON.stringify(nextPlugins)) {
86
+ nxJson.plugins = nextPlugins;
87
+ changed = true;
88
+ }
89
+ return changed;
90
+ }
91
+ /**
92
+ * Check workspace config policy using an Nx Tree.
93
+ */
94
+ export function checkWorkspaceConfigTree(tree) {
95
+ if (!tree.exists('nx.json')) {
96
+ return [{ path: 'nx.json', message: 'nx.json not found' }];
97
+ }
98
+ return checkWorkspaceConfig(readJson(tree, 'nx.json'));
99
+ }
100
+ /**
101
+ * Apply workspace config policy using an Nx Tree.
102
+ * Returns whether anything changed.
103
+ */
104
+ export function applyWorkspaceConfigTree(tree) {
105
+ if (!tree.exists('nx.json')) {
106
+ return false;
107
+ }
108
+ let changed = false;
109
+ updateJson(tree, 'nx.json', (nxJson) => {
110
+ changed = applyWorkspaceConfig(nxJson);
111
+ return nxJson;
112
+ });
113
+ return changed;
114
+ }
115
+ /**
116
+ * Check nx.json workspace config policy, returns issues found.
117
+ */
118
+ export function checkWorkspaceConfigPolicy(root) {
119
+ const nxJsonPath = join(root, 'nx.json');
120
+ const nxJson = readJsonObject(nxJsonPath);
121
+ if (!nxJson) {
122
+ return [{ path: nxJsonPath, message: 'nx.json not found or invalid' }];
123
+ }
124
+ const coreIssues = checkWorkspaceConfig(nxJson);
125
+ // Remap 'nx.json' paths to absolute paths for filesystem callers
126
+ return coreIssues.map((issue) => ({
127
+ ...issue,
128
+ path: issue.path === 'nx.json' ? nxJsonPath : issue.path,
129
+ }));
130
+ }
131
+ /**
132
+ * Fix nx.json workspace config policy. Returns whether anything changed.
133
+ */
134
+ export function applyWorkspaceConfigPolicy(root) {
135
+ const nxJsonPath = join(root, 'nx.json');
136
+ const nxJson = readJsonObject(nxJsonPath);
137
+ if (!nxJson) {
138
+ return false;
139
+ }
140
+ const changed = applyWorkspaceConfig(nxJson);
141
+ if (changed) {
142
+ writeJsonObject(nxJsonPath, nxJson);
143
+ }
144
+ return changed;
145
+ }
146
+ function validateBuildTargetDefault(nxJson, nxJsonPath, issues) {
147
+ const targetDefaults = recordProperty(nxJson, 'targetDefaults');
148
+ const build = targetDefaults ? recordProperty(targetDefaults, 'build') : null;
149
+ if (!build || build.cache !== true) {
150
+ issues.push({ path: nxJsonPath, message: 'targetDefaults.build.cache must be true' });
151
+ }
152
+ const outputs = build?.outputs;
153
+ if (!Array.isArray(outputs) || outputs.length !== 1 || outputs[0] !== '{projectRoot}/dist') {
154
+ issues.push({ path: nxJsonPath, message: 'targetDefaults.build.outputs must be ["{projectRoot}/dist"]' });
155
+ }
156
+ }
157
+ function validateNamedInputDefaults(nxJson, nxJsonPath, issues) {
158
+ const namedInputs = recordProperty(nxJson, 'namedInputs');
159
+ if (!namedInputs) {
160
+ issues.push({
161
+ path: nxJsonPath,
162
+ message: 'namedInputs must be configured so production builds have precise cache inputs.',
163
+ });
164
+ return;
165
+ }
166
+ if (!Array.isArray(namedInputs.default)) {
167
+ issues.push({
168
+ path: nxJsonPath,
169
+ message: 'namedInputs.default must be an array; smoo allows it to remain broad for non-production tasks.',
170
+ });
171
+ }
172
+ if (!stringArrayEquals(namedInputs.sharedGlobals, expectedSharedGlobalsNamedInput)) {
173
+ issues.push({
174
+ path: nxJsonPath,
175
+ message: 'namedInputs.sharedGlobals must include only {workspaceRoot}/.github/workflows/ci.yml',
176
+ });
177
+ }
178
+ const production = namedInputs.production;
179
+ if (!Array.isArray(production)) {
180
+ issues.push({
181
+ path: nxJsonPath,
182
+ message: 'namedInputs.production must be an array of precise production inputs.',
183
+ });
184
+ return;
185
+ }
186
+ if (!isPreciseProductionNamedInput(production)) {
187
+ issues.push({
188
+ path: nxJsonPath,
189
+ message: 'namedInputs.production must enumerate precise production inputs. Do not include default or broad {projectRoot}/** globs; use language/tool-specific paths such as {projectRoot}/src/**/*, {projectRoot}/Cargo.toml, or {projectRoot}/pyproject.toml.',
190
+ });
191
+ }
192
+ }
193
+ function applyBuildTargetDefault(nxJson) {
194
+ const targetDefaults = getOrCreateRecord(nxJson, 'targetDefaults');
195
+ const build = getOrCreateRecord(targetDefaults, 'build');
196
+ let changed = setBooleanProperty(build, 'cache', true);
197
+ changed = setStringArrayProperty(build, 'outputs', ['{projectRoot}/dist']) || changed;
198
+ return changed;
199
+ }
200
+ function applyNamedInputDefaults(nxJson) {
201
+ const namedInputs = getOrCreateRecord(nxJson, 'namedInputs');
202
+ let changed = false;
203
+ if (!Array.isArray(namedInputs.default)) {
204
+ namedInputs.default = ['{projectRoot}/**/*', 'sharedGlobals'];
205
+ changed = true;
206
+ }
207
+ changed = setStringArrayProperty(namedInputs, 'sharedGlobals', expectedSharedGlobalsNamedInput) || changed;
208
+ const production = namedInputs.production;
209
+ if (!Array.isArray(production) || !isPreciseProductionNamedInput(production)) {
210
+ namedInputs.production = defaultProductionNamedInput;
211
+ changed = true;
212
+ }
213
+ return changed;
214
+ }
215
+ function removeColonTargetDefaults(nxJson) {
216
+ const targetDefaults = recordProperty(nxJson, 'targetDefaults');
217
+ if (!targetDefaults) {
218
+ return false;
219
+ }
220
+ let changed = false;
221
+ for (const targetName of Object.keys(targetDefaults)) {
222
+ if (targetName.includes(':')) {
223
+ delete targetDefaults[targetName];
224
+ changed = true;
225
+ }
226
+ }
227
+ return changed;
228
+ }
229
+ function isPreciseProductionNamedInput(production) {
230
+ let hasPositiveProjectInput = false;
231
+ for (const input of production) {
232
+ if (typeof input !== 'string') {
233
+ return false;
234
+ }
235
+ const normalized = input.startsWith('!') ? input.slice(1) : input;
236
+ if (impreciseProductionInputs.has(input) || impreciseProductionInputs.has(normalized)) {
237
+ return false;
238
+ }
239
+ if (!input.startsWith('!') && normalized.startsWith('{projectRoot}/')) {
240
+ hasPositiveProjectInput = true;
241
+ }
242
+ }
243
+ return hasPositiveProjectInput;
244
+ }
245
+ function expectedNxJsTypescriptPlugin() {
246
+ return {
247
+ plugin: nxJsTypescriptPlugin,
248
+ options: {
249
+ typecheck: { targetName: 'typecheck' },
250
+ build: {
251
+ targetName: 'tsc-js',
252
+ configName: 'tsconfig.lib.json',
253
+ buildDepsName: 'build-deps',
254
+ watchDepsName: 'watch-deps',
255
+ },
256
+ },
257
+ };
258
+ }
259
+ function upsertNxPlugin(plugins, plugin) {
260
+ const pluginName = typeof plugin === 'string' ? plugin : stringProperty(plugin, 'plugin');
261
+ const next = plugins.filter((entry) => nxPluginName(entry) !== pluginName);
262
+ next.push(plugin);
263
+ return next;
264
+ }
265
+ function nxPluginName(value) {
266
+ if (typeof value === 'string') {
267
+ return value;
268
+ }
269
+ return isRecord(value) ? stringProperty(value, 'plugin') : null;
270
+ }
271
+ function isNxJsTypescriptPlugin(value) {
272
+ return isRecord(value) && stringProperty(value, 'plugin') === nxJsTypescriptPlugin;
273
+ }
274
+ function isSmoothBricksNxPluginRecord(value) {
275
+ return isRecord(value) && stringProperty(value, 'plugin') === smoothBricksNxPlugin;
276
+ }
277
+ function nxJsBuildTargetName(plugin) {
278
+ const options = recordProperty(plugin, 'options');
279
+ const build = options ? recordProperty(options, 'build') : null;
280
+ return build ? stringProperty(build, 'targetName') : null;
281
+ }
282
+ function readJsonObject(path) {
283
+ if (!existsSync(path)) {
284
+ return null;
285
+ }
286
+ try {
287
+ const parsed = JSON.parse(readFileSync(path, 'utf8'));
288
+ return isRecord(parsed) ? parsed : null;
289
+ }
290
+ catch {
291
+ return null;
292
+ }
293
+ }
294
+ function writeJsonObject(path, value) {
295
+ writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
296
+ }
297
+ function isRecord(value) {
298
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
299
+ }
300
+ function stringProperty(record, key) {
301
+ const value = record[key];
302
+ return typeof value === 'string' && value.length > 0 ? value : null;
303
+ }
304
+ function recordProperty(record, key) {
305
+ const value = record[key];
306
+ return isRecord(value) ? value : null;
307
+ }
308
+ function getOrCreateRecord(record, key) {
309
+ const value = record[key];
310
+ if (isRecord(value)) {
311
+ return value;
312
+ }
313
+ const next = {};
314
+ record[key] = next;
315
+ return next;
316
+ }
317
+ function setBooleanProperty(record, key, value) {
318
+ if (record[key] === value) {
319
+ return false;
320
+ }
321
+ record[key] = value;
322
+ return true;
323
+ }
324
+ function setStringArrayProperty(record, key, value) {
325
+ const current = record[key];
326
+ if (stringArrayEquals(current, value)) {
327
+ return false;
328
+ }
329
+ record[key] = value;
330
+ return true;
331
+ }
332
+ function stringArrayEquals(value, expected) {
333
+ return (Array.isArray(value) && value.length === expected.length && value.every((entry, index) => entry === expected[index]));
334
+ }
package/executors.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "executors": {
3
+ "bounded-exec": {
4
+ "implementation": "./dist/executors/bounded-exec/executor.js",
5
+ "schema": "./src/executors/bounded-exec/schema.json",
6
+ "description": "Run a command with bounded timeout and force-kill behavior"
7
+ }
8
+ }
9
+ }
package/generators.json CHANGED
@@ -4,6 +4,21 @@
4
4
  "factory": "./dist/generators/bun-test-tracing/generator.js",
5
5
  "schema": "./src/generators/bun-test-tracing/schema.json",
6
6
  "description": "Configure a package for the workspace Bun test tracing pattern"
7
+ },
8
+ "bounded-test-targets": {
9
+ "factory": "./dist/generators/bounded-test-targets/generator.js",
10
+ "schema": "./src/generators/bounded-test-targets/schema.json",
11
+ "description": "Normalize package test targets to the bounded command executor"
12
+ },
13
+ "create-package": {
14
+ "factory": "./dist/generators/create-package/generator.js",
15
+ "schema": "./src/generators/create-package/schema.json",
16
+ "description": "Scaffold a new workspace package (ts-lib or ts-zig)"
17
+ },
18
+ "make-public": {
19
+ "factory": "./dist/generators/make-public/generator.js",
20
+ "schema": "./src/generators/make-public/schema.json",
21
+ "description": "Promote a private package to public npm publication"
7
22
  }
8
23
  }
9
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smoothbricks/nx-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./loader.js",
@@ -13,23 +13,58 @@
13
13
  "development": "./src/index.ts",
14
14
  "import": "./loader.js",
15
15
  "default": "./loader.js"
16
+ },
17
+ "./version-actions": {
18
+ "types": "./dist/version-actions.d.cts",
19
+ "require": "./dist/version-actions.cjs",
20
+ "default": "./dist/version-actions.cjs"
21
+ },
22
+ "./bounded-test-policy": {
23
+ "types": "./dist/bounded-test-policy.d.ts",
24
+ "development": "./src/bounded-test-policy.ts",
25
+ "import": "./dist/bounded-test-policy.js",
26
+ "default": "./dist/bounded-test-policy.js"
27
+ },
28
+ "./workspace-config-policy": {
29
+ "types": "./dist/workspace-config-policy.d.ts",
30
+ "development": "./src/workspace-config-policy.ts",
31
+ "import": "./dist/workspace-config-policy.js",
32
+ "default": "./dist/workspace-config-policy.js"
33
+ },
34
+ "./release-config-policy": {
35
+ "types": "./dist/release-config-policy.d.ts",
36
+ "development": "./src/release-config-policy.ts",
37
+ "import": "./dist/release-config-policy.js",
38
+ "default": "./dist/release-config-policy.js"
39
+ },
40
+ "./package-target-policy": {
41
+ "types": "./dist/package-target-policy.d.ts",
42
+ "development": "./src/package-target-policy.ts",
43
+ "import": "./dist/package-target-policy.js",
44
+ "default": "./dist/package-target-policy.js"
45
+ },
46
+ "./typecheck-test-policy": {
47
+ "types": "./dist/typecheck-test-policy.d.ts",
48
+ "development": "./src/typecheck-test-policy.ts",
49
+ "import": "./dist/typecheck-test-policy.js",
50
+ "default": "./dist/typecheck-test-policy.js"
16
51
  }
17
52
  },
18
53
  "generators": "./generators.json",
54
+ "executors": "./executors.json",
19
55
  "scripts": {
20
- "test": "nx run nx-plugin:test"
56
+ "test": "nx run nx-plugin:test --tui=false --outputStyle=stream"
21
57
  },
22
58
  "nx": {
23
59
  "targets": {
24
60
  "lint": {},
25
61
  "test": {
26
- "executor": "nx:run-commands",
27
- "dependsOn": [
28
- "^build"
29
- ],
62
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
30
63
  "options": {
31
64
  "command": "bun test",
32
- "cwd": "{projectRoot}"
65
+ "cwd": "{projectRoot}",
66
+ "timeoutMs": 120000,
67
+ "killAfterMs": 1e4
33
68
  }
34
69
  }
35
70
  },
@@ -44,6 +79,7 @@
44
79
  "README.md",
45
80
  "loader.js",
46
81
  "generators.json",
82
+ "executors.json",
47
83
  "!**/*.tsbuildinfo"
48
84
  ],
49
85
  "license": "MIT",
@@ -56,10 +92,8 @@
56
92
  "directory": "packages/nx-plugin"
57
93
  },
58
94
  "dependencies": {
59
- "nx": "22.5.4",
95
+ "@nx/js": "22.7.1",
96
+ "nx": "22.7.1",
60
97
  "tslib": "^2.8.1"
61
- },
62
- "devDependencies": {
63
- "@smoothbricks/lmao": "0.1.2"
64
98
  }
65
99
  }