@smoothbricks/nx-plugin 0.3.0 → 0.3.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/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +44 -3
- package/dist/generators/create-package/generator.js +29 -2
- package/dist/generators/make-public/generator.js +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -4
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +4 -2
- package/dist/version-actions.cjs +8 -3
- package/dist/version-actions.d.cts.map +1 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +8 -34
- package/package.json +3 -3
- package/src/bounded-test-policy.ts +46 -3
- package/src/generators/create-package/generator.ts +37 -9
- package/src/generators/make-public/generator.ts +5 -1
- package/src/index.test.ts +36 -5
- package/src/index.ts +57 -4
- package/src/package-target-policy.test.ts +9 -1
- package/src/release-config-policy.test.ts +22 -11
- package/src/typecheck-test-policy.test.ts +85 -38
- package/src/typecheck-test-policy.ts +6 -2
- package/src/version-actions.cts +12 -5
- package/src/workspace-config-policy.test.ts +37 -57
- package/src/workspace-config-policy.ts +11 -40
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-test-policy.d.ts","sourceRoot":"","sources":["../src/bounded-test-policy.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,yCAAyC,CAAC;AAC5E,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAC/C,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAKjD,eAAO,MAAM,gCAAgC,QAAS,CAAC;AAEvD,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,EAAE,CAAC,EAAE;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACnD,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mCAAmC;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,4BAA4B,CAAC;CAC5C;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,4BAA4B,EACzC,OAAO,EAAE,mCAAmC,GAC3C,IAAI,
|
|
1
|
+
{"version":3,"file":"bounded-test-policy.d.ts","sourceRoot":"","sources":["../src/bounded-test-policy.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,yCAAyC,CAAC;AAC5E,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAC/C,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAKjD,eAAO,MAAM,gCAAgC,QAAS,CAAC;AAEvD,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,EAAE,CAAC,EAAE;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACnD,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mCAAmC;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,4BAA4B,CAAC;CAC5C;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,4BAA4B,EACzC,OAAO,EAAE,mCAAmC,GAC3C,IAAI,CAuBN;AAED,wBAAgB,qCAAqC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA0B3E;AAED,wBAAgB,qCAAqC,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,EAAE,CAyB5F;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,4BAA4B,EACzC,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAmBT;AAED,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,4BAA4B,EACzC,cAAc,SAAa,EAC3B,WAAW,CAAC,EAAE,4BAA4B,GACzC,MAAM,CAER;AA+CD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,SAAmC,GAAG,MAAM,CAa9G"}
|
|
@@ -10,7 +10,11 @@ export const BOUNDED_TEST_KILL_AFTER_MS = 10_000;
|
|
|
10
10
|
export const BOUNDED_TEST_PER_TEST_TIMEOUT_MS = 30_000;
|
|
11
11
|
export function applyBoundedTestTargetPolicy(packageJson, options) {
|
|
12
12
|
const command = resolveTestCommand(packageJson, options.defaultCommand ?? 'bun test', options.projectJson);
|
|
13
|
-
|
|
13
|
+
let targetOwner = options.projectJson;
|
|
14
|
+
if (!targetOwner) {
|
|
15
|
+
packageJson.nx ??= {};
|
|
16
|
+
targetOwner = packageJson.nx;
|
|
17
|
+
}
|
|
14
18
|
targetOwner.targets ??= {};
|
|
15
19
|
const existingTestTarget = targetOwner.targets.test;
|
|
16
20
|
const nextTestTarget = isRecord(existingTestTarget) ? { ...existingTestTarget } : {};
|
|
@@ -186,13 +190,50 @@ function listWorkspacePackageJsonPaths(root) {
|
|
|
186
190
|
return paths.sort((a, b) => a.localeCompare(b));
|
|
187
191
|
}
|
|
188
192
|
function readPackageJson(path) {
|
|
189
|
-
|
|
193
|
+
const parsed = readJsonObject(path);
|
|
194
|
+
const nx = isRecord(parsed.nx) ? parsed.nx : undefined;
|
|
195
|
+
const normalizedNx = nx
|
|
196
|
+
? {
|
|
197
|
+
...nx,
|
|
198
|
+
name: typeof nx.name === 'string' ? nx.name : undefined,
|
|
199
|
+
targets: readTargets(nx.targets),
|
|
200
|
+
}
|
|
201
|
+
: undefined;
|
|
202
|
+
return {
|
|
203
|
+
...parsed,
|
|
204
|
+
name: typeof parsed.name === 'string' ? parsed.name : undefined,
|
|
205
|
+
workspaces: parsed.workspaces,
|
|
206
|
+
scripts: isRecord(parsed.scripts) ? parsed.scripts : undefined,
|
|
207
|
+
nx: normalizedNx,
|
|
208
|
+
};
|
|
190
209
|
}
|
|
191
210
|
function writePackageJson(path, packageJson) {
|
|
192
211
|
writeFileSync(path, `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
193
212
|
}
|
|
194
213
|
function readProjectJson(path) {
|
|
195
|
-
|
|
214
|
+
const parsed = readJsonObject(path);
|
|
215
|
+
return {
|
|
216
|
+
...parsed,
|
|
217
|
+
name: typeof parsed.name === 'string' ? parsed.name : undefined,
|
|
218
|
+
targets: readTargets(parsed.targets),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function readJsonObject(path) {
|
|
222
|
+
const parsed = JSON.parse(readFileSync(path, 'utf8'));
|
|
223
|
+
if (!isRecord(parsed)) {
|
|
224
|
+
throw new Error(`${path} must contain a JSON object`);
|
|
225
|
+
}
|
|
226
|
+
return parsed;
|
|
227
|
+
}
|
|
228
|
+
function readTargets(value) {
|
|
229
|
+
if (!isRecord(value)) {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
const targets = {};
|
|
233
|
+
for (const [name, target] of Object.entries(value)) {
|
|
234
|
+
targets[name] = isRecord(target) ? target : {};
|
|
235
|
+
}
|
|
236
|
+
return targets;
|
|
196
237
|
}
|
|
197
238
|
function writeProjectJson(path, projectJson) {
|
|
198
239
|
writeFileSync(path, `${JSON.stringify(projectJson, null, 2)}\n`);
|
|
@@ -112,14 +112,18 @@ function buildPackageJson(schema, packageName, projectRoot, rootPkg) {
|
|
|
112
112
|
packageJson.license = 'MIT';
|
|
113
113
|
packageJson.publishConfig = { access: 'public' };
|
|
114
114
|
const rootRepository = rootPkg.repository;
|
|
115
|
-
if (rootRepository
|
|
115
|
+
if (isRecord(rootRepository)) {
|
|
116
116
|
packageJson.repository = {
|
|
117
117
|
type: rootRepository.type ?? 'git',
|
|
118
118
|
url: rootRepository.url,
|
|
119
119
|
directory: projectRoot,
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
const nx = packageJson.nx;
|
|
123
|
+
if (!isRecord(nx)) {
|
|
124
|
+
throw new Error('generated package.json nx configuration must be an object');
|
|
125
|
+
}
|
|
126
|
+
nx.tags = ['npm:public'];
|
|
123
127
|
}
|
|
124
128
|
else {
|
|
125
129
|
packageJson.private = true;
|
|
@@ -131,11 +135,23 @@ function writeZigFiles(tree, schema, projectRoot) {
|
|
|
131
135
|
const packageJson = readJson(tree, `${projectRoot}/package.json`);
|
|
132
136
|
// Add wasm export and remove development condition
|
|
133
137
|
const exports = packageJson.exports;
|
|
138
|
+
if (!isRecord(exports)) {
|
|
139
|
+
// invariant throw: writeCommonFiles always emits an object-valued exports map.
|
|
140
|
+
throw new Error('generated package.json exports must be an object');
|
|
141
|
+
}
|
|
134
142
|
exports['./wasm'] = `./dist/${schema.name}.wasm`;
|
|
135
143
|
const dotExport = exports['.'];
|
|
144
|
+
if (!isRecord(dotExport)) {
|
|
145
|
+
// invariant throw: writeCommonFiles always emits an object-valued "." export.
|
|
146
|
+
throw new Error('generated package.json "." export must be an object');
|
|
147
|
+
}
|
|
136
148
|
delete dotExport.development;
|
|
137
149
|
// Add build scripts
|
|
138
150
|
const scripts = packageJson.scripts;
|
|
151
|
+
if (!isRecord(scripts)) {
|
|
152
|
+
// invariant throw: writeCommonFiles always emits an object-valued scripts map.
|
|
153
|
+
throw new Error('generated package.json scripts must be an object');
|
|
154
|
+
}
|
|
139
155
|
scripts['build:zig'] = `nx run ${schema.name}:zig-wasm`;
|
|
140
156
|
scripts['build:ts'] = `nx run ${schema.name}:tsc-js`;
|
|
141
157
|
scripts.build = 'bun run build:ts && bun run build:zig';
|
|
@@ -145,6 +161,10 @@ function writeZigFiles(tree, schema, projectRoot) {
|
|
|
145
161
|
// Modify tsconfig.lib.json for ts-zig
|
|
146
162
|
const tsconfigLib = readJson(tree, `${projectRoot}/tsconfig.lib.json`);
|
|
147
163
|
const libCompilerOptions = tsconfigLib.compilerOptions;
|
|
164
|
+
if (!isRecord(libCompilerOptions)) {
|
|
165
|
+
// invariant throw: writeCommonFiles always emits compilerOptions for library builds.
|
|
166
|
+
throw new Error('generated tsconfig.lib.json compilerOptions must be an object');
|
|
167
|
+
}
|
|
148
168
|
libCompilerOptions.lib = ['es2022', 'webworker'];
|
|
149
169
|
libCompilerOptions.declaration = true;
|
|
150
170
|
libCompilerOptions.sourceMap = true;
|
|
@@ -153,6 +173,10 @@ function writeZigFiles(tree, schema, projectRoot) {
|
|
|
153
173
|
// Modify tsconfig.test.json for ts-zig
|
|
154
174
|
const tsconfigTest = readJson(tree, `${projectRoot}/tsconfig.test.json`);
|
|
155
175
|
const testCompilerOptions = tsconfigTest.compilerOptions;
|
|
176
|
+
if (!isRecord(testCompilerOptions)) {
|
|
177
|
+
// invariant throw: writeCommonFiles always emits compilerOptions for test builds.
|
|
178
|
+
throw new Error('generated tsconfig.test.json compilerOptions must be an object');
|
|
179
|
+
}
|
|
156
180
|
testCompilerOptions.lib = ['es2022', 'webworker'];
|
|
157
181
|
writeJson(tree, `${projectRoot}/tsconfig.test.json`, tsconfigTest);
|
|
158
182
|
// Write build.zig
|
|
@@ -202,3 +226,6 @@ pub fn build(b: *std.Build) void {
|
|
|
202
226
|
}
|
|
203
227
|
`);
|
|
204
228
|
}
|
|
229
|
+
function isRecord(value) {
|
|
230
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
231
|
+
}
|
|
@@ -20,7 +20,7 @@ export default async function generator(tree, schema) {
|
|
|
20
20
|
directory: resolved.root,
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
const nx = (pkg.nx
|
|
23
|
+
const nx = isRecord(pkg.nx) ? pkg.nx : {};
|
|
24
24
|
const tags = Array.isArray(nx.tags) ? [...nx.tags] : [];
|
|
25
25
|
if (!tags.includes('npm:public')) {
|
|
26
26
|
tags.push('npm:public');
|
|
@@ -33,6 +33,9 @@ export default async function generator(tree, schema) {
|
|
|
33
33
|
return pkg;
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
+
function isRecord(value) {
|
|
37
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
38
|
+
}
|
|
36
39
|
function resolveProject(tree, projectInput) {
|
|
37
40
|
const normalizedInput = normalizeLookupValue(projectInput);
|
|
38
41
|
for (const [name, config] of getProjects(tree)) {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAuB,aAAa,EAAuB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAuB,aAAa,EAAuB,MAAM,0BAA0B,CAAC;AAsDxG,eAAO,MAAM,aAAa,EAAE,aAsB3B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,12 @@ const RESERVED_ZIG_STEPS = new Set(['all', 'clean', 'install', 'test']);
|
|
|
7
7
|
const ZIG_STEP_PATTERN = /\bb\.step\(\s*["']([^"']+)["']\s*,/g;
|
|
8
8
|
const VALID_ZIG_STEP_NAME = /^[A-Za-z0-9_-]+$/;
|
|
9
9
|
const BUILD_OUTPUT_TARGET_PATTERN = /-(?:js|web|html|css|ios|android|native|napi|bun|wasm)$/;
|
|
10
|
+
const TYPESCRIPT_TOOLCHAIN_INPUTS = [
|
|
11
|
+
'{workspaceRoot}/package.json',
|
|
12
|
+
'{workspaceRoot}/bun.lock',
|
|
13
|
+
'{workspaceRoot}/patches/**/*',
|
|
14
|
+
'{workspaceRoot}/tsconfig.base.json',
|
|
15
|
+
];
|
|
10
16
|
// Cargo workspace inference: a package.json sitting next to a Cargo.toml that
|
|
11
17
|
// declares [workspace] gets direct cargo-test/test targets, cargo-lint feeding
|
|
12
18
|
// the lint aggregate, mutation (cargo-mutants), bench, and — per cdylib member
|
|
@@ -71,13 +77,44 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
71
77
|
const validationTargets = [];
|
|
72
78
|
const hasLibTsconfig = existsSync(join(absoluteProjectRoot, 'tsconfig.lib.json'));
|
|
73
79
|
let hasBuildOutputTarget = hasLibTsconfig || hasPackageLocalBuildOutputTarget(packageJson);
|
|
80
|
+
if (hasLibTsconfig) {
|
|
81
|
+
// Official Nx target inference is disabled because its compiler surface only
|
|
82
|
+
// supports tsc/tsgo. Smoo owns the complete transformer-aware ttsc targets.
|
|
83
|
+
targets['tsc-js'] = {
|
|
84
|
+
executor: 'nx:run-commands',
|
|
85
|
+
cache: true,
|
|
86
|
+
inputs: ['production', '^production', ...TYPESCRIPT_TOOLCHAIN_INPUTS, '{projectRoot}/tsconfig.lib.json'],
|
|
87
|
+
outputs: [
|
|
88
|
+
'{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}',
|
|
89
|
+
'{projectRoot}/dist/.build.tsbuildinfo',
|
|
90
|
+
],
|
|
91
|
+
dependsOn: ['^tsc-js'],
|
|
92
|
+
options: {
|
|
93
|
+
command: 'ttsc -p tsconfig.lib.json --emit',
|
|
94
|
+
cwd: projectRoot,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
targets.typecheck = {
|
|
98
|
+
executor: 'nx:run-commands',
|
|
99
|
+
cache: true,
|
|
100
|
+
inputs: ['production', '^production', ...TYPESCRIPT_TOOLCHAIN_INPUTS, '{projectRoot}/tsconfig.lib.json'],
|
|
101
|
+
outputs: [],
|
|
102
|
+
dependsOn: ['^tsc-js'],
|
|
103
|
+
options: {
|
|
104
|
+
command: 'ttsc -p tsconfig.lib.json --noEmit',
|
|
105
|
+
cwd: projectRoot,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
74
109
|
const hasTestTsconfig = existsSync(join(absoluteProjectRoot, 'tsconfig.test.json'));
|
|
75
110
|
if (hasTestTsconfig) {
|
|
76
111
|
targets['typecheck-tests'] = {
|
|
77
112
|
executor: 'nx:run-commands',
|
|
78
113
|
cache: true,
|
|
114
|
+
inputs: ['default', '^production', ...TYPESCRIPT_TOOLCHAIN_INPUTS, '{projectRoot}/tsconfig.test.json'],
|
|
115
|
+
dependsOn: ['typecheck'],
|
|
79
116
|
options: {
|
|
80
|
-
command: '
|
|
117
|
+
command: 'ttsc -p tsconfig.test.json --noEmit',
|
|
81
118
|
cwd: projectRoot,
|
|
82
119
|
},
|
|
83
120
|
};
|
|
@@ -85,7 +122,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
85
122
|
executor: 'nx:run-commands',
|
|
86
123
|
continuous: true,
|
|
87
124
|
options: {
|
|
88
|
-
command: '
|
|
125
|
+
command: 'ttsc -p tsconfig.test.json --noEmit --watch',
|
|
89
126
|
cwd: projectRoot,
|
|
90
127
|
},
|
|
91
128
|
};
|
|
@@ -215,7 +252,6 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
215
252
|
}
|
|
216
253
|
if (validationTargets.length > 0) {
|
|
217
254
|
targets.lint = {
|
|
218
|
-
executor: 'nx:noop',
|
|
219
255
|
cache: true,
|
|
220
256
|
dependsOn: validationTargets,
|
|
221
257
|
};
|
|
@@ -231,7 +267,23 @@ async function createProjectTargets(packageJsonPath, workspaceRoot) {
|
|
|
231
267
|
};
|
|
232
268
|
}
|
|
233
269
|
async function readPackageJson(packageJsonPath) {
|
|
234
|
-
|
|
270
|
+
const parsed = JSON.parse(await readFile(packageJsonPath, 'utf-8'));
|
|
271
|
+
if (!isRecord(parsed)) {
|
|
272
|
+
throw new Error(`${packageJsonPath} must contain a JSON object`);
|
|
273
|
+
}
|
|
274
|
+
const rawNx = isRecord(parsed.nx) ? parsed.nx : undefined;
|
|
275
|
+
return {
|
|
276
|
+
...(typeof parsed.name === 'string' ? { name: parsed.name } : {}),
|
|
277
|
+
...(isRecord(parsed.scripts) ? { scripts: parsed.scripts } : {}),
|
|
278
|
+
...(rawNx
|
|
279
|
+
? {
|
|
280
|
+
nx: {
|
|
281
|
+
...(typeof rawNx.name === 'string' ? { name: rawNx.name } : {}),
|
|
282
|
+
...(isRecord(rawNx.targets) ? { targets: rawNx.targets } : {}),
|
|
283
|
+
},
|
|
284
|
+
}
|
|
285
|
+
: {}),
|
|
286
|
+
};
|
|
235
287
|
}
|
|
236
288
|
function inferTestWatchCommand(packageJson) {
|
|
237
289
|
const scriptCommand = packageJson.scripts?.test;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typecheck-test-policy.d.ts","sourceRoot":"","sources":["../src/typecheck-test-policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typecheck-test-policy.d.ts","sourceRoot":"","sources":["../src/typecheck-test-policy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;AAI1C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,WAAW,CAAC,UAAU,CAAC,CAqDzB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC5C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAgDjB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC/C,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAYjB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,OAAO,EAAE;IACP,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,GACA,OAAO,CAoDT;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAO7F;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAwCxE;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAyDhE;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CA2CtE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAyD9D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join, relative } from 'node:path';
|
|
3
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
3
4
|
import { getProjects, readJson, readProjectConfiguration, updateJson, writeJson } from 'nx/src/devkit-exports.js';
|
|
4
5
|
const workspaceDependencyFields = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
|
|
5
6
|
/**
|
|
@@ -67,7 +68,7 @@ export function checkTypecheckTestConfig(tsconfigTest, packagePath) {
|
|
|
67
68
|
const issues = [];
|
|
68
69
|
const tsconfigTestPath = join(packagePath, 'tsconfig.test.json');
|
|
69
70
|
const compilerOptions = recordProperty(tsconfigTest, 'compilerOptions');
|
|
70
|
-
if (
|
|
71
|
+
if (compilerOptions?.noEmit !== true) {
|
|
71
72
|
issues.push({
|
|
72
73
|
path: tsconfigTestPath,
|
|
73
74
|
message: 'compilerOptions.noEmit must be true',
|
|
@@ -132,7 +133,8 @@ export function applyTypecheckTestDefaults(tsconfigTest, options) {
|
|
|
132
133
|
// Copy relevant compiler options from lib tsconfig
|
|
133
134
|
if (options.libCompilerOptions) {
|
|
134
135
|
for (const key of ['baseUrl', 'module', 'moduleResolution', 'jsx', 'lib']) {
|
|
135
|
-
if (Object.hasOwn(options.libCompilerOptions, key) &&
|
|
136
|
+
if (Object.hasOwn(options.libCompilerOptions, key) &&
|
|
137
|
+
!isDeepStrictEqual(compilerOptions[key], options.libCompilerOptions[key])) {
|
|
136
138
|
compilerOptions[key] = options.libCompilerOptions[key];
|
|
137
139
|
changed = true;
|
|
138
140
|
}
|
package/dist/version-actions.cjs
CHANGED
|
@@ -72,15 +72,20 @@ function workspacePackages(root) {
|
|
|
72
72
|
if (!(0, node_fs_1.existsSync)(packageJsonPath)) {
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
|
-
const
|
|
76
|
-
if (typeof
|
|
75
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, 'utf8'));
|
|
76
|
+
if (!isRecord(parsed) || typeof parsed.name !== 'string' || typeof parsed.version !== 'string') {
|
|
77
77
|
return null;
|
|
78
|
-
|
|
78
|
+
}
|
|
79
|
+
const json = parsed;
|
|
80
|
+
const nx = isRecord(json.nx) ? json.nx : null;
|
|
79
81
|
const projectName = (nx ? (typeof nx.name === 'string' ? nx.name : null) : null) ?? json.name;
|
|
80
82
|
return { path, name: json.name, projectName, version: json.version };
|
|
81
83
|
})
|
|
82
84
|
.filter((pkg) => pkg !== null);
|
|
83
85
|
}
|
|
86
|
+
function isRecord(value) {
|
|
87
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
88
|
+
}
|
|
84
89
|
function escapeRegex(value) {
|
|
85
90
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
86
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-actions.d.cts","sourceRoot":"","sources":["../src/version-actions.cts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAQ5E,QAAA,MAAM,kBAAkB;+BALyC,yBAAyB;CAKf,CAAC;
|
|
1
|
+
{"version":3,"file":"version-actions.d.cts","sourceRoot":"","sources":["../src/version-actions.cts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAQ5E,QAAA,MAAM,kBAAkB;+BALyC,yBAAyB;CAKf,CAAC;SA0BnE,kBAAkB"}
|
|
@@ -1 +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;AAeF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,EAAE,
|
|
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;AAeF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,EAAE,CA+CrF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAa7E;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"}
|
|
@@ -51,19 +51,11 @@ export function checkWorkspaceConfig(nxJson) {
|
|
|
51
51
|
validateNamedInputDefaults(nxJson, 'nx.json', issues);
|
|
52
52
|
// Plugin configuration
|
|
53
53
|
const plugins = Array.isArray(nxJson.plugins) ? nxJson.plugins : [];
|
|
54
|
-
|
|
55
|
-
if (!nxJsPlugin) {
|
|
54
|
+
if (plugins.some(isNxJsTypescriptPlugin)) {
|
|
56
55
|
issues.push({
|
|
57
56
|
path: 'nx.json',
|
|
58
|
-
message: `plugins must configure ${nxJsTypescriptPlugin}. ` +
|
|
59
|
-
'
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
else if (nxJsBuildTargetName(nxJsPlugin) !== 'tsc-js') {
|
|
63
|
-
issues.push({
|
|
64
|
-
path: 'nx.json',
|
|
65
|
-
message: `${nxJsTypescriptPlugin} build.targetName must be tsc-js. ` +
|
|
66
|
-
'TypeScript library output is a concrete tool-output target; build is reserved for aggregate targets that depend on concrete build work.',
|
|
57
|
+
message: `plugins must not configure ${nxJsTypescriptPlugin}. ` +
|
|
58
|
+
'Smoo owns transformer-aware TypeScript targets; Nx native inference only supports tsc/tsgo.',
|
|
67
59
|
});
|
|
68
60
|
}
|
|
69
61
|
if (!plugins.includes(smoothBricksNxPlugin) && !plugins.some(isSmoothBricksNxPluginRecord)) {
|
|
@@ -85,7 +77,8 @@ export function applyWorkspaceConfig(nxJson) {
|
|
|
85
77
|
changed = applyCleanTargetDefault(nxJson) || changed;
|
|
86
78
|
changed = applyNamedInputDefaults(nxJson) || changed;
|
|
87
79
|
const currentPlugins = Array.isArray(nxJson.plugins) ? nxJson.plugins : [];
|
|
88
|
-
const
|
|
80
|
+
const pluginsWithoutNxTypeScript = currentPlugins.filter((plugin) => !isNxJsTypescriptPlugin(plugin));
|
|
81
|
+
const nextPlugins = upsertNxPlugin(pluginsWithoutNxTypeScript, smoothBricksNxPlugin);
|
|
89
82
|
if (JSON.stringify(currentPlugins) !== JSON.stringify(nextPlugins)) {
|
|
90
83
|
nxJson.plugins = nextPlugins;
|
|
91
84
|
changed = true;
|
|
@@ -150,7 +143,7 @@ export function applyWorkspaceConfigPolicy(root) {
|
|
|
150
143
|
function validateBuildTargetDefault(nxJson, nxJsonPath, issues) {
|
|
151
144
|
const targetDefaults = recordProperty(nxJson, 'targetDefaults');
|
|
152
145
|
const build = targetDefaults ? recordProperty(targetDefaults, 'build') : null;
|
|
153
|
-
if (
|
|
146
|
+
if (build?.cache !== true) {
|
|
154
147
|
issues.push({ path: nxJsonPath, message: 'targetDefaults.build.cache must be true' });
|
|
155
148
|
}
|
|
156
149
|
const outputs = build?.outputs;
|
|
@@ -164,7 +157,7 @@ function validateCleanTargetDefault(nxJson, nxJsonPath, issues) {
|
|
|
164
157
|
if (!clean || clean.executor !== cleanOutputsExecutor) {
|
|
165
158
|
issues.push({ path: nxJsonPath, message: `targetDefaults.clean.executor must be ${cleanOutputsExecutor}` });
|
|
166
159
|
}
|
|
167
|
-
if (
|
|
160
|
+
if (clean?.cache !== false) {
|
|
168
161
|
issues.push({ path: nxJsonPath, message: 'targetDefaults.clean.cache must be false' });
|
|
169
162
|
}
|
|
170
163
|
}
|
|
@@ -263,20 +256,6 @@ function isPreciseProductionNamedInput(production) {
|
|
|
263
256
|
}
|
|
264
257
|
return hasPositiveProjectInput;
|
|
265
258
|
}
|
|
266
|
-
function expectedNxJsTypescriptPlugin() {
|
|
267
|
-
return {
|
|
268
|
-
plugin: nxJsTypescriptPlugin,
|
|
269
|
-
options: {
|
|
270
|
-
typecheck: { targetName: 'typecheck' },
|
|
271
|
-
build: {
|
|
272
|
-
targetName: 'tsc-js',
|
|
273
|
-
configName: 'tsconfig.lib.json',
|
|
274
|
-
buildDepsName: 'build-deps',
|
|
275
|
-
watchDepsName: 'watch-deps',
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
259
|
function upsertNxPlugin(plugins, plugin) {
|
|
281
260
|
const pluginName = typeof plugin === 'string' ? plugin : stringProperty(plugin, 'plugin');
|
|
282
261
|
const next = plugins.filter((entry) => nxPluginName(entry) !== pluginName);
|
|
@@ -290,16 +269,11 @@ function nxPluginName(value) {
|
|
|
290
269
|
return isRecord(value) ? stringProperty(value, 'plugin') : null;
|
|
291
270
|
}
|
|
292
271
|
function isNxJsTypescriptPlugin(value) {
|
|
293
|
-
return isRecord(value) && stringProperty(value, 'plugin') === nxJsTypescriptPlugin;
|
|
272
|
+
return (value === nxJsTypescriptPlugin || (isRecord(value) && stringProperty(value, 'plugin') === nxJsTypescriptPlugin));
|
|
294
273
|
}
|
|
295
274
|
function isSmoothBricksNxPluginRecord(value) {
|
|
296
275
|
return isRecord(value) && stringProperty(value, 'plugin') === smoothBricksNxPlugin;
|
|
297
276
|
}
|
|
298
|
-
function nxJsBuildTargetName(plugin) {
|
|
299
|
-
const options = recordProperty(plugin, 'options');
|
|
300
|
-
const build = options ? recordProperty(options, 'build') : null;
|
|
301
|
-
return build ? stringProperty(build, 'targetName') : null;
|
|
302
|
-
}
|
|
303
277
|
function readJsonObject(path) {
|
|
304
278
|
if (!existsSync(path)) {
|
|
305
279
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothbricks/nx-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./loader.js",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"directory": "packages/nx-plugin"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@nx/js": "
|
|
96
|
-
"nx": "
|
|
95
|
+
"@nx/js": "23.1.0",
|
|
96
|
+
"nx": "23.1.0",
|
|
97
97
|
"tslib": "^2.8.1"
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -41,7 +41,11 @@ export function applyBoundedTestTargetPolicy(
|
|
|
41
41
|
options: ApplyBoundedTestTargetPolicyOptions,
|
|
42
42
|
): void {
|
|
43
43
|
const command = resolveTestCommand(packageJson, options.defaultCommand ?? 'bun test', options.projectJson);
|
|
44
|
-
|
|
44
|
+
let targetOwner = options.projectJson;
|
|
45
|
+
if (!targetOwner) {
|
|
46
|
+
packageJson.nx ??= {};
|
|
47
|
+
targetOwner = packageJson.nx;
|
|
48
|
+
}
|
|
45
49
|
|
|
46
50
|
targetOwner.targets ??= {};
|
|
47
51
|
|
|
@@ -251,7 +255,22 @@ function listWorkspacePackageJsonPaths(root: string): string[] {
|
|
|
251
255
|
}
|
|
252
256
|
|
|
253
257
|
function readPackageJson(path: string): BoundedTestPolicyPackageJson {
|
|
254
|
-
|
|
258
|
+
const parsed = readJsonObject(path);
|
|
259
|
+
const nx = isRecord(parsed.nx) ? parsed.nx : undefined;
|
|
260
|
+
const normalizedNx = nx
|
|
261
|
+
? {
|
|
262
|
+
...nx,
|
|
263
|
+
name: typeof nx.name === 'string' ? nx.name : undefined,
|
|
264
|
+
targets: readTargets(nx.targets),
|
|
265
|
+
}
|
|
266
|
+
: undefined;
|
|
267
|
+
return {
|
|
268
|
+
...parsed,
|
|
269
|
+
name: typeof parsed.name === 'string' ? parsed.name : undefined,
|
|
270
|
+
workspaces: parsed.workspaces,
|
|
271
|
+
scripts: isRecord(parsed.scripts) ? parsed.scripts : undefined,
|
|
272
|
+
nx: normalizedNx,
|
|
273
|
+
};
|
|
255
274
|
}
|
|
256
275
|
|
|
257
276
|
function writePackageJson(path: string, packageJson: BoundedTestPolicyPackageJson): void {
|
|
@@ -259,7 +278,31 @@ function writePackageJson(path: string, packageJson: BoundedTestPolicyPackageJso
|
|
|
259
278
|
}
|
|
260
279
|
|
|
261
280
|
function readProjectJson(path: string): BoundedTestPolicyProjectJson {
|
|
262
|
-
|
|
281
|
+
const parsed = readJsonObject(path);
|
|
282
|
+
return {
|
|
283
|
+
...parsed,
|
|
284
|
+
name: typeof parsed.name === 'string' ? parsed.name : undefined,
|
|
285
|
+
targets: readTargets(parsed.targets),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function readJsonObject(path: string): Record<string, unknown> {
|
|
290
|
+
const parsed: unknown = JSON.parse(readFileSync(path, 'utf8'));
|
|
291
|
+
if (!isRecord(parsed)) {
|
|
292
|
+
throw new Error(`${path} must contain a JSON object`);
|
|
293
|
+
}
|
|
294
|
+
return parsed;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function readTargets(value: unknown): Record<string, Record<string, unknown>> | undefined {
|
|
298
|
+
if (!isRecord(value)) {
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
301
|
+
const targets: Record<string, Record<string, unknown>> = {};
|
|
302
|
+
for (const [name, target] of Object.entries(value)) {
|
|
303
|
+
targets[name] = isRecord(target) ? target : {};
|
|
304
|
+
}
|
|
305
|
+
return targets;
|
|
263
306
|
}
|
|
264
307
|
|
|
265
308
|
function writeProjectJson(path: string, projectJson: BoundedTestPolicyProjectJson): void {
|
|
@@ -140,14 +140,18 @@ function buildPackageJson(
|
|
|
140
140
|
packageJson.license = 'MIT';
|
|
141
141
|
packageJson.publishConfig = { access: 'public' };
|
|
142
142
|
const rootRepository = rootPkg.repository;
|
|
143
|
-
if (rootRepository
|
|
143
|
+
if (isRecord(rootRepository)) {
|
|
144
144
|
packageJson.repository = {
|
|
145
|
-
type:
|
|
146
|
-
url:
|
|
145
|
+
type: rootRepository.type ?? 'git',
|
|
146
|
+
url: rootRepository.url,
|
|
147
147
|
directory: projectRoot,
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
const nx = packageJson.nx;
|
|
151
|
+
if (!isRecord(nx)) {
|
|
152
|
+
throw new Error('generated package.json nx configuration must be an object');
|
|
153
|
+
}
|
|
154
|
+
nx.tags = ['npm:public'];
|
|
151
155
|
} else {
|
|
152
156
|
packageJson.private = true;
|
|
153
157
|
}
|
|
@@ -160,13 +164,25 @@ function writeZigFiles(tree: Tree, schema: CreatePackageGeneratorSchema, project
|
|
|
160
164
|
const packageJson = readJson<Record<string, unknown>>(tree, `${projectRoot}/package.json`);
|
|
161
165
|
|
|
162
166
|
// Add wasm export and remove development condition
|
|
163
|
-
const exports = packageJson.exports
|
|
167
|
+
const exports = packageJson.exports;
|
|
168
|
+
if (!isRecord(exports)) {
|
|
169
|
+
// invariant throw: writeCommonFiles always emits an object-valued exports map.
|
|
170
|
+
throw new Error('generated package.json exports must be an object');
|
|
171
|
+
}
|
|
164
172
|
exports['./wasm'] = `./dist/${schema.name}.wasm`;
|
|
165
|
-
const dotExport = exports['.']
|
|
173
|
+
const dotExport = exports['.'];
|
|
174
|
+
if (!isRecord(dotExport)) {
|
|
175
|
+
// invariant throw: writeCommonFiles always emits an object-valued "." export.
|
|
176
|
+
throw new Error('generated package.json "." export must be an object');
|
|
177
|
+
}
|
|
166
178
|
delete dotExport.development;
|
|
167
179
|
|
|
168
180
|
// Add build scripts
|
|
169
|
-
const scripts = packageJson.scripts
|
|
181
|
+
const scripts = packageJson.scripts;
|
|
182
|
+
if (!isRecord(scripts)) {
|
|
183
|
+
// invariant throw: writeCommonFiles always emits an object-valued scripts map.
|
|
184
|
+
throw new Error('generated package.json scripts must be an object');
|
|
185
|
+
}
|
|
170
186
|
scripts['build:zig'] = `nx run ${schema.name}:zig-wasm`;
|
|
171
187
|
scripts['build:ts'] = `nx run ${schema.name}:tsc-js`;
|
|
172
188
|
scripts.build = 'bun run build:ts && bun run build:zig';
|
|
@@ -178,7 +194,11 @@ function writeZigFiles(tree: Tree, schema: CreatePackageGeneratorSchema, project
|
|
|
178
194
|
|
|
179
195
|
// Modify tsconfig.lib.json for ts-zig
|
|
180
196
|
const tsconfigLib = readJson<Record<string, unknown>>(tree, `${projectRoot}/tsconfig.lib.json`);
|
|
181
|
-
const libCompilerOptions = tsconfigLib.compilerOptions
|
|
197
|
+
const libCompilerOptions = tsconfigLib.compilerOptions;
|
|
198
|
+
if (!isRecord(libCompilerOptions)) {
|
|
199
|
+
// invariant throw: writeCommonFiles always emits compilerOptions for library builds.
|
|
200
|
+
throw new Error('generated tsconfig.lib.json compilerOptions must be an object');
|
|
201
|
+
}
|
|
182
202
|
libCompilerOptions.lib = ['es2022', 'webworker'];
|
|
183
203
|
libCompilerOptions.declaration = true;
|
|
184
204
|
libCompilerOptions.sourceMap = true;
|
|
@@ -187,7 +207,11 @@ function writeZigFiles(tree: Tree, schema: CreatePackageGeneratorSchema, project
|
|
|
187
207
|
|
|
188
208
|
// Modify tsconfig.test.json for ts-zig
|
|
189
209
|
const tsconfigTest = readJson<Record<string, unknown>>(tree, `${projectRoot}/tsconfig.test.json`);
|
|
190
|
-
const testCompilerOptions = tsconfigTest.compilerOptions
|
|
210
|
+
const testCompilerOptions = tsconfigTest.compilerOptions;
|
|
211
|
+
if (!isRecord(testCompilerOptions)) {
|
|
212
|
+
// invariant throw: writeCommonFiles always emits compilerOptions for test builds.
|
|
213
|
+
throw new Error('generated tsconfig.test.json compilerOptions must be an object');
|
|
214
|
+
}
|
|
191
215
|
testCompilerOptions.lib = ['es2022', 'webworker'];
|
|
192
216
|
writeJson(tree, `${projectRoot}/tsconfig.test.json`, tsconfigTest);
|
|
193
217
|
|
|
@@ -249,3 +273,7 @@ pub fn build(b: *std.Build) void {
|
|
|
249
273
|
`,
|
|
250
274
|
);
|
|
251
275
|
}
|
|
276
|
+
|
|
277
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
278
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
279
|
+
}
|
|
@@ -40,7 +40,7 @@ export default async function generator(tree: Tree, schema: MakePublicGeneratorS
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const nx = (pkg.nx
|
|
43
|
+
const nx = isRecord(pkg.nx) ? pkg.nx : {};
|
|
44
44
|
const tags = Array.isArray(nx.tags) ? [...nx.tags] : [];
|
|
45
45
|
if (!tags.includes('npm:public')) {
|
|
46
46
|
tags.push('npm:public');
|
|
@@ -56,6 +56,10 @@ export default async function generator(tree: Tree, schema: MakePublicGeneratorS
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
60
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
function resolveProject(tree: Tree, projectInput: string): { name: string; root: string } {
|
|
60
64
|
const normalizedInput = normalizeLookupValue(projectInput);
|
|
61
65
|
|