@smoothbricks/nx-plugin 0.4.17 → 0.4.19
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 +12 -11
- package/dist/ensure-built.d.ts +7 -4
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +77 -17
- package/dist/executors/typescript-emit/executor.d.ts +1 -1
- package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
- package/dist/executors/typescript-emit/executor.js +3 -8
- package/dist/index.js +10 -8
- package/dist/managed-files/files.d.ts +6 -0
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +11 -0
- package/dist/managed-files/managed-content.d.ts +2 -0
- package/dist/managed-files/managed-content.d.ts.map +1 -1
- package/dist/managed-files/managed-content.js +19 -5
- package/dist/typecheck-test-policy.d.ts +2 -0
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +57 -12
- package/executors.json +1 -1
- package/managed/raw/patches/ttsc@0.30.4.patch +2255 -0
- package/managed/raw/tooling/direnv/devenv.smoo.nix +14 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +3 -4
- package/package.json +5 -5
- package/src/ensure-built.test.ts +41 -5
- package/src/ensure-built.ts +127 -43
- package/src/executors/typescript-emit/executor.test.ts +64 -115
- package/src/executors/typescript-emit/executor.ts +4 -9
- package/src/executors/typescript-emit/schema.json +1 -1
- package/src/index.test.ts +4 -4
- package/src/index.ts +9 -8
- package/src/managed-files/files.ts +12 -0
- package/src/managed-files/managed-content.test.ts +19 -0
- package/src/managed-files/managed-content.ts +23 -6
- package/src/typecheck-test-policy.test.ts +56 -5
- package/src/typecheck-test-policy.ts +56 -12
package/README.md
CHANGED
|
@@ -270,6 +270,10 @@ through the inferred `typecheck-tests` target, not through `tsc --build`.
|
|
|
270
270
|
hashes. A full hit returns without running tasks or printing output. A miss runs the task graph through Nx's in-process
|
|
271
271
|
runner with streaming output; only a workspace with the daemon disabled falls back to its checkout-local `nx` CLI.
|
|
272
272
|
|
|
273
|
+
Before hashing, it compares a native snapshot of the workspace with the daemon's file table. A write the daemon's
|
|
274
|
+
watcher has not delivered yet counts as a miss unless every changed path is a declared output of a task in the graph, so
|
|
275
|
+
a build's own artifacts never turn the next call noisy, and an edit made moments before the call never hits stale.
|
|
276
|
+
|
|
273
277
|
```typescript
|
|
274
278
|
import { ensureBuilt } from '@smoothbricks/nx-plugin/ensure-built';
|
|
275
279
|
|
|
@@ -342,17 +346,14 @@ The generator rewrites `package.json` so `nx.targets.test` uses:
|
|
|
342
346
|
|
|
343
347
|
## Managed workspace files
|
|
344
348
|
|
|
345
|
-
`nx generate @smoothbricks/nx-plugin:managed-files` stages the same managed files as
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
for `nx sync` and `nx sync:check`.
|
|
349
|
+
`nx generate @smoothbricks/nx-plugin:managed-files` stages the same managed files as `smoo monorepo update`, without
|
|
350
|
+
installing packages or resolving secrets. Use Nx `--dry-run` to inspect the changes. The workspace defaults register
|
|
351
|
+
this generator for `nx sync` and `nx sync:check`.
|
|
349
352
|
|
|
350
|
-
The plugin owns the packaged templates, pure rendering and content-preservation
|
|
351
|
-
|
|
352
|
-
resolved project graph for inferred targets. The CLI only supplies the filesystem
|
|
353
|
+
The plugin owns the packaged templates, pure rendering and content-preservation functions. The generator reads workspace
|
|
354
|
+
files through Nx `Tree` and uses Nx's resolved project graph for inferred targets. The CLI only supplies the filesystem
|
|
353
355
|
and process boundary. There is no separate serialized change plan.
|
|
354
356
|
|
|
355
|
-
Files with a `# smoo-local` tail or `# smoo-local-begin` / `# smoo-local-end` blocks
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
generator does not remove a repository-owned file when a capability is disabled.
|
|
357
|
+
Files with a `# smoo-local` tail or `# smoo-local-begin` / `# smoo-local-end` blocks retain those sections. Matching
|
|
358
|
+
source symlinks are preserved; conflicting local blocks and broken or external links are reported instead of
|
|
359
|
+
overwritten. The generator does not remove a repository-owned file when a capability is disabled.
|
package/dist/ensure-built.d.ts
CHANGED
|
@@ -34,6 +34,9 @@ export type MissReason = {
|
|
|
34
34
|
} | {
|
|
35
35
|
readonly kind: 'stale-outputs';
|
|
36
36
|
readonly taskId: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: 'stale-inputs';
|
|
39
|
+
readonly taskId: string;
|
|
37
40
|
} | {
|
|
38
41
|
readonly kind: 'cache-disabled';
|
|
39
42
|
readonly taskId: string;
|
|
@@ -108,10 +111,10 @@ export declare function firstStaleOutputs(tasks: readonly Task[], matches: reado
|
|
|
108
111
|
* when they already are.
|
|
109
112
|
*
|
|
110
113
|
* "Already built" is the hot path, because a checkout-local CLI wrapper pays it
|
|
111
|
-
* on every invocation. So it never spawns the `nx` CLI:
|
|
112
|
-
* task hashes and
|
|
113
|
-
*
|
|
114
|
-
*
|
|
114
|
+
* on every invocation. So it never spawns the `nx` CLI: a native filesystem
|
|
115
|
+
* snapshot refreshes the daemon's inputs, the task hashes and on-disk output
|
|
116
|
+
* verification are daemon round-trips, and the cache lookup is a local SQLite
|
|
117
|
+
* read. Nx's task runner is only invoked once something needs running.
|
|
115
118
|
*
|
|
116
119
|
* With the daemon disabled there is no probe to make — hashing would have to
|
|
117
120
|
* build the project graph in this process, and no service holds the recorded
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-built.d.ts","sourceRoot":"","sources":["../src/ensure-built.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ensure-built.d.ts","sourceRoot":"","sources":["../src/ensure-built.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,IAAI,EAAa,MAAM,0BAA0B,CAAC;AAmDhE;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,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ure-built.js
CHANGED
|
@@ -36,6 +36,8 @@ export function describeMiss(reason) {
|
|
|
36
36
|
return `${reason.taskId} last failed with exit code ${reason.code}`;
|
|
37
37
|
case 'stale-outputs':
|
|
38
38
|
return `${reason.taskId} outputs are missing or modified on disk`;
|
|
39
|
+
case 'stale-inputs':
|
|
40
|
+
return `${reason.taskId} inputs changed since the Nx daemon last looked`;
|
|
39
41
|
case 'cache-disabled':
|
|
40
42
|
return `the Nx cache is disabled, so ${reason.taskId} must run`;
|
|
41
43
|
case 'no-daemon':
|
|
@@ -91,10 +93,10 @@ export function firstStaleOutputs(tasks, matches) {
|
|
|
91
93
|
* when they already are.
|
|
92
94
|
*
|
|
93
95
|
* "Already built" is the hot path, because a checkout-local CLI wrapper pays it
|
|
94
|
-
* on every invocation. So it never spawns the `nx` CLI:
|
|
95
|
-
* task hashes and
|
|
96
|
-
*
|
|
97
|
-
*
|
|
96
|
+
* on every invocation. So it never spawns the `nx` CLI: a native filesystem
|
|
97
|
+
* snapshot refreshes the daemon's inputs, the task hashes and on-disk output
|
|
98
|
+
* verification are daemon round-trips, and the cache lookup is a local SQLite
|
|
99
|
+
* read. Nx's task runner is only invoked once something needs running.
|
|
98
100
|
*
|
|
99
101
|
* With the daemon disabled there is no probe to make — hashing would have to
|
|
100
102
|
* build the project graph in this process, and no service holds the recorded
|
|
@@ -167,6 +169,7 @@ async function ensureBuiltInWorkspace(workspaceRoot, selector, onMiss) {
|
|
|
167
169
|
const { readNxJson } = requireNx('nx/src/config/nx-json');
|
|
168
170
|
const { splitArgsIntoNxArgsAndOverrides } = requireNx('nx/src/utils/command-line-utils');
|
|
169
171
|
const { setEnvVarsBasedOnArgs } = requireNx('nx/src/tasks-runner/run-command');
|
|
172
|
+
const { createTaskGraph } = requireNx('nx/src/tasks-runner/create-task-graph');
|
|
170
173
|
const hooks = requireNx('nx/src/project-graph/plugins/tasks-execution-hooks');
|
|
171
174
|
const nxJson = readNxJson();
|
|
172
175
|
// Reproduce `nx run <selector> --outputStyle=<style>` exactly. Task hashes
|
|
@@ -179,6 +182,13 @@ async function ensureBuiltInWorkspace(workspaceRoot, selector, onMiss) {
|
|
|
179
182
|
// reads through each task's environment. It has to happen before hashing or
|
|
180
183
|
// the probe keys differently from the CLI.
|
|
181
184
|
setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles);
|
|
185
|
+
performance.mark('ensureBuilt:graph:start');
|
|
186
|
+
const { projectGraph } = await daemonClient.getProjectGraphAndSourceMaps();
|
|
187
|
+
requireProject(projectGraph, selector.project);
|
|
188
|
+
const taskGraph = createTaskGraph(projectGraph, {}, [selector.project], [selector.target], selector.configuration, overrides, false);
|
|
189
|
+
const tasks = Object.values(taskGraph.tasks);
|
|
190
|
+
performance.measure('ensureBuilt:graph', 'ensureBuilt:graph:start');
|
|
191
|
+
const inputsChanged = await refreshWorkspaceContext(workspaceRoot, tasks, requireNx);
|
|
182
192
|
const runId = randomUUID();
|
|
183
193
|
const startTime = Date.now();
|
|
184
194
|
// Plugin `preTasksExecution` hooks inject environment variables, and declared
|
|
@@ -193,14 +203,17 @@ async function ensureBuiltInWorkspace(workspaceRoot, selector, onMiss) {
|
|
|
193
203
|
});
|
|
194
204
|
performance.mark('ensureBuilt:probe:start');
|
|
195
205
|
let reason;
|
|
206
|
+
const selectorTaskId = selector.configuration === undefined
|
|
207
|
+
? `${selector.project}:${selector.target}`
|
|
208
|
+
: `${selector.project}:${selector.target}:${selector.configuration}`;
|
|
196
209
|
if (process.env.NX_SKIP_NX_CACHE === 'true' || process.env.NX_DISABLE_NX_CACHE === 'true') {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
reason = { kind: '
|
|
210
|
+
reason = { kind: 'cache-disabled', taskId: selectorTaskId };
|
|
211
|
+
}
|
|
212
|
+
else if (inputsChanged) {
|
|
213
|
+
reason = { kind: 'stale-inputs', taskId: selectorTaskId };
|
|
201
214
|
}
|
|
202
215
|
else {
|
|
203
|
-
reason = await probe(nxJson, nxArgs,
|
|
216
|
+
reason = await probe(nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx);
|
|
204
217
|
}
|
|
205
218
|
performance.measure('ensureBuilt:probe', 'ensureBuilt:probe:start');
|
|
206
219
|
const outcome = reason === null
|
|
@@ -241,21 +254,68 @@ function bindWorkspaceRoot(workspaceRoot, requireNx) {
|
|
|
241
254
|
throw new Error(`ensureBuilt: Nx is already bound to workspace root ${boundRoot}, cannot switch to ${workspaceRoot}`);
|
|
242
255
|
}
|
|
243
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* The daemon drains delivered watcher events before serving its graph, but an
|
|
259
|
+
* OS event can still be in flight after a write has completed. Its graph and
|
|
260
|
+
* hashes can then agree with each other while both describe yesterday's files.
|
|
261
|
+
* Take Nx's native, ignore-aware disk snapshot and compare it with the
|
|
262
|
+
* daemon's file table; its metadata cache reuses unchanged file hashes.
|
|
263
|
+
*
|
|
264
|
+
* Any difference is handed to the daemon so its next graph is current, but
|
|
265
|
+
* that only schedules a recomputation, and a probe meanwhile would hash
|
|
266
|
+
* against the file map it already has. So the caller does not probe: if any
|
|
267
|
+
* differing path is not a declared output of a task in the graph, this
|
|
268
|
+
* returns true and the target is run, which lets Nx's own runner wait for the
|
|
269
|
+
* recomputation. Output paths are exempt because a build's own writes are the
|
|
270
|
+
* commonest thing to reach here before the watcher does, and treating them as
|
|
271
|
+
* a miss would make every hit after a build replay the cached log.
|
|
272
|
+
*/
|
|
273
|
+
async function refreshWorkspaceContext(workspaceRoot, tasks, requireNx) {
|
|
274
|
+
const { daemonClient } = requireNx('nx/src/daemon/client/client');
|
|
275
|
+
const { WorkspaceContext, matchOutputPaths } = requireNx('nx/src/native');
|
|
276
|
+
const { workspaceDataDirectoryForWorkspace } = requireNx('nx/src/utils/cache-directory');
|
|
277
|
+
performance.mark('ensureBuilt:inputs:start');
|
|
278
|
+
const previousFiles = await daemonClient.getWorkspaceContextFileData();
|
|
279
|
+
const previousHashes = new Map();
|
|
280
|
+
for (const { file, hash } of previousFiles) {
|
|
281
|
+
previousHashes.set(file, hash);
|
|
282
|
+
}
|
|
283
|
+
// A context is a snapshot, not a watcher. Do not reuse one across calls.
|
|
284
|
+
const context = new WorkspaceContext(workspaceRoot, workspaceDataDirectoryForWorkspace(workspaceRoot));
|
|
285
|
+
const createdFiles = [];
|
|
286
|
+
const updatedFiles = [];
|
|
287
|
+
for (const { file, hash } of context.allFileData()) {
|
|
288
|
+
const previousHash = previousHashes.get(file);
|
|
289
|
+
if (previousHash === undefined) {
|
|
290
|
+
createdFiles.push(file);
|
|
291
|
+
}
|
|
292
|
+
else if (previousHash !== hash) {
|
|
293
|
+
updatedFiles.push(file);
|
|
294
|
+
}
|
|
295
|
+
previousHashes.delete(file);
|
|
296
|
+
}
|
|
297
|
+
const deletedFiles = [...previousHashes.keys()];
|
|
298
|
+
const changed = [...createdFiles, ...updatedFiles, ...deletedFiles];
|
|
299
|
+
let inputsChanged = false;
|
|
300
|
+
if (changed.length > 0) {
|
|
301
|
+
await daemonClient.updateWorkspaceContext(createdFiles, updatedFiles, deletedFiles);
|
|
302
|
+
// The same matcher the task runner uses to collect outputs, over the union
|
|
303
|
+
// of every task's declared outputs. A negation declared by one task then
|
|
304
|
+
// also excludes another task's output, which errs toward a miss.
|
|
305
|
+
const outputs = tasks.flatMap((task) => task.outputs);
|
|
306
|
+
inputsChanged = matchOutputPaths(outputs, changed).includes(false);
|
|
307
|
+
}
|
|
308
|
+
performance.measure('ensureBuilt:inputs', 'ensureBuilt:inputs:start');
|
|
309
|
+
return inputsChanged;
|
|
310
|
+
}
|
|
244
311
|
/** `null` when the target is already built; otherwise the first reason it is not. */
|
|
245
|
-
async function probe(nxJson, nxArgs,
|
|
312
|
+
async function probe(nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx) {
|
|
246
313
|
const { daemonClient } = requireNx('nx/src/daemon/client/client');
|
|
247
|
-
const { createTaskGraph } = requireNx('nx/src/tasks-runner/create-task-graph');
|
|
248
314
|
const { DaemonBasedTaskHasher } = requireNx('nx/src/hasher/task-hasher');
|
|
249
315
|
const { getTaskDetails, hashTasks } = requireNx('nx/src/hasher/hash-task');
|
|
250
316
|
const { getTaskSpecificEnv } = requireNx('nx/src/tasks-runner/task-env');
|
|
251
317
|
const { getCache } = requireNx('nx/src/tasks-runner/cache');
|
|
252
318
|
const { getRunnerOptions } = requireNx('nx/src/tasks-runner/run-command');
|
|
253
|
-
performance.mark('ensureBuilt:graph:start');
|
|
254
|
-
const { projectGraph } = await daemonClient.getProjectGraphAndSourceMaps();
|
|
255
|
-
requireProject(projectGraph, selector.project);
|
|
256
|
-
const taskGraph = createTaskGraph(projectGraph, {}, [selector.project], [selector.target], selector.configuration, overrides, false);
|
|
257
|
-
const tasks = Object.values(taskGraph.tasks);
|
|
258
|
-
performance.measure('ensureBuilt:graph', 'ensureBuilt:graph:start');
|
|
259
319
|
// `isCloudDefault: false` because these options are only read here by the
|
|
260
320
|
// hasher, which looks at `selectivelyHashTsConfig`; the cloud credentials the
|
|
261
321
|
// flag would add belong to the cloud runner, and the run path calls Nx's own
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/typescript-emit/executor.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,oBAAoB;IAC5B,OAAO,EAAE,OAAO,CAAC;CAClB;AAMD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/typescript-emit/executor.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,oBAAoB;IAC5B,OAAO,EAAE,OAAO,CAAC;CAClB;AAMD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,kBAAkB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAElF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,oBAAoB,CAAC,CAkC/B"}
|
|
@@ -16,8 +16,8 @@ export async function runTypeScriptEmit(options, context, runner) {
|
|
|
16
16
|
extends: `./${basename(tsConfigPath)}`,
|
|
17
17
|
compilerOptions: {
|
|
18
18
|
composite: false,
|
|
19
|
-
declaration:
|
|
20
|
-
declarationMap:
|
|
19
|
+
declaration: true,
|
|
20
|
+
declarationMap: true,
|
|
21
21
|
emitDeclarationOnly: false,
|
|
22
22
|
incremental: false,
|
|
23
23
|
},
|
|
@@ -34,12 +34,7 @@ export async function runTypeScriptEmit(options, context, runner) {
|
|
|
34
34
|
return { success: false };
|
|
35
35
|
}
|
|
36
36
|
await makePackageBinsExecutable(cwd, options.executableOutputs ?? []);
|
|
37
|
-
|
|
38
|
-
command: 'tsc',
|
|
39
|
-
args: ['-p', overlayPath, '--emitDeclarationOnly', '--declaration', '--declarationMap'],
|
|
40
|
-
cwd,
|
|
41
|
-
});
|
|
42
|
-
return { success: declarationsSucceeded };
|
|
37
|
+
return { success: true };
|
|
43
38
|
}
|
|
44
39
|
finally {
|
|
45
40
|
await rm(overlayPath, { force: true });
|
package/dist/index.js
CHANGED
|
@@ -835,10 +835,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
835
835
|
// Build every JavaScript output lane before resolving package exports, without pulling
|
|
836
836
|
// unrelated Wasm, N-API, native, or web outputs onto the compiler critical path.
|
|
837
837
|
//
|
|
838
|
-
//
|
|
839
|
-
// generated implementation identifiers are not valid declaration inputs.
|
|
840
|
-
// The executor gives ttsc a JS-only overlay and emits declarations from the
|
|
841
|
-
// original project with native tsc.
|
|
838
|
+
// One transformer-aware compiler emits JavaScript and declarations.
|
|
842
839
|
targets['tsc-js'] = {
|
|
843
840
|
executor: '@smoothbricks/nx-plugin:typescript-emit',
|
|
844
841
|
cache: true,
|
|
@@ -858,7 +855,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
858
855
|
outputs: [],
|
|
859
856
|
dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
|
|
860
857
|
options: {
|
|
861
|
-
command: '
|
|
858
|
+
command: 'ttsc -p tsconfig.lib.json --noEmit',
|
|
862
859
|
cwd: projectRoot,
|
|
863
860
|
},
|
|
864
861
|
};
|
|
@@ -870,7 +867,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
870
867
|
inputs: [selfDefault, dependencyProduction, ...checkInputs, '{projectRoot}/tsconfig.test.json'],
|
|
871
868
|
dependsOn: ['typecheck'],
|
|
872
869
|
options: {
|
|
873
|
-
command: '
|
|
870
|
+
command: 'ttsc -p tsconfig.test.json --noEmit',
|
|
874
871
|
cwd: projectRoot,
|
|
875
872
|
},
|
|
876
873
|
};
|
|
@@ -878,7 +875,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
878
875
|
executor: 'nx:run-commands',
|
|
879
876
|
continuous: true,
|
|
880
877
|
options: {
|
|
881
|
-
command: '
|
|
878
|
+
command: 'ttsc -p tsconfig.test.json --noEmit --watch',
|
|
882
879
|
cwd: projectRoot,
|
|
883
880
|
},
|
|
884
881
|
};
|
|
@@ -1127,11 +1124,16 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1127
1124
|
}
|
|
1128
1125
|
}
|
|
1129
1126
|
}
|
|
1130
|
-
if ('test' in declaredTargets && targets.test === undefined) {
|
|
1127
|
+
if (('test' in declaredTargets || typeof packageJson.scripts?.test === 'string') && targets.test === undefined) {
|
|
1131
1128
|
targets.test = {
|
|
1132
1129
|
dependsOn: ['^build', 'build'],
|
|
1133
1130
|
};
|
|
1134
1131
|
}
|
|
1132
|
+
for (const name of Object.keys(declaredTargets)) {
|
|
1133
|
+
if (name === 'test' || !isTestRunnerTargetName(name) || targets[name] !== undefined)
|
|
1134
|
+
continue;
|
|
1135
|
+
targets[name] = { dependsOn: ['^build', 'build'] };
|
|
1136
|
+
}
|
|
1135
1137
|
// Every `cargoFrozen` command needs a registry cache holding the whole locked
|
|
1136
1138
|
// graph, and offline cargo checks that at RESOLUTION — so a dev-dependency no
|
|
1137
1139
|
// build ever downloaded takes down `cargo --frozen build` just as surely as
|
|
@@ -40,6 +40,12 @@ export interface ManagedFileContext {
|
|
|
40
40
|
*/
|
|
41
41
|
crossTestArchives: CiCrossTestArchive[];
|
|
42
42
|
}
|
|
43
|
+
/** Temporary upstream compiler repairs distributed to smoo-managed Bun workspaces. */
|
|
44
|
+
export declare const managedTtscPatch: {
|
|
45
|
+
readonly version: '0.30.4';
|
|
46
|
+
readonly key: 'ttsc@0.30.4';
|
|
47
|
+
readonly path: 'patches/ttsc@0.30.4.patch';
|
|
48
|
+
};
|
|
43
49
|
export declare const managedFileTargetsForTest: {
|
|
44
50
|
target: string;
|
|
45
51
|
executable: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/managed-files/files.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2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mB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,qFAAqF;IACrF,0BAA0B,EAAE,MAAM,EAAE,CAAC;IACrC,0BAA0B,EAAE,MAAM,EAAE,CAAC;IACrC,wFAAwF;IACxF,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,sFAAsF;IACtF,eAAe,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAChD,kGAAkG;IAClG,gBAAgB,CAAC,EAAE,6BAA6B,CAAC;IACjD,uGAAuG;IACvG,WAAW,CAAC,EAAE,wBAAwB,CAAC;IACvC;;;;OAIG;IACH,iBAAiB,EAAE,kBAAkB,EAAE,CAAC;CACzC;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB;aAC3B,OAAO,EAAE,QAAQ;aACjB,GAAG,EAAE,aAAa;aAClB,IAAI,EAAE,2BAA2B;CACzB,CAAC;AAmJX,eAAO,MAAM,yBAAyB;;;GAAyE,CAAC;AAchH,qFAAqF;AACrF,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAElF;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,EAAE,CAM7E;AAED,+GAA+G;AAC/G,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,aAAa,GAAG,kBAAkB,EAC1C,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CAMR"}
|
|
@@ -5,7 +5,18 @@ import { privateNpmReadTokenJobEnv, renderCiWorkflowYaml } from './ci-workflow.j
|
|
|
5
5
|
import { renderRunsOnLine } from './github-runs-on.js';
|
|
6
6
|
import { renderPrPreviewCleanupWorkflowYaml } from './pr-preview-cleanup-workflow.js';
|
|
7
7
|
import { renderPublishWorkflowYaml } from './publish-workflow.js';
|
|
8
|
+
/** Temporary upstream compiler repairs distributed to smoo-managed Bun workspaces. */
|
|
9
|
+
export const managedTtscPatch = {
|
|
10
|
+
version: '0.30.4',
|
|
11
|
+
key: 'ttsc@0.30.4',
|
|
12
|
+
path: 'patches/ttsc@0.30.4.patch',
|
|
13
|
+
};
|
|
8
14
|
const managedFiles = [
|
|
15
|
+
{
|
|
16
|
+
kind: 'raw',
|
|
17
|
+
source: managedTtscPatch.path,
|
|
18
|
+
target: managedTtscPatch.path,
|
|
19
|
+
},
|
|
9
20
|
{
|
|
10
21
|
kind: 'raw',
|
|
11
22
|
source: 'envrc',
|
|
@@ -29,6 +29,8 @@ export interface InlineLocalBlock {
|
|
|
29
29
|
anchor: string;
|
|
30
30
|
lines: string;
|
|
31
31
|
markerIndent?: string;
|
|
32
|
+
/** The comment prefix the markers were written with; `#` unless stated. */
|
|
33
|
+
markerPrefix?: string;
|
|
32
34
|
/** Distinguishes no lines from one deliberately blank line. */
|
|
33
35
|
empty?: true;
|
|
34
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managed-content.d.ts","sourceRoot":"","sources":["../../src/managed-files/managed-content.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,qBAAa,sBAAuB,SAAQ,KAAK;CAAG;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,yEAAyE,CAAC;AAE3G,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAUzF;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"managed-content.d.ts","sourceRoot":"","sources":["../../src/managed-files/managed-content.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,qBAAa,sBAAuB,SAAQ,KAAK;CAAG;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,yEAAyE,CAAC;AAE3G,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAUzF;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAcnD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,IAAI,CAAC;CACd;AAED;;8BAE8B;AAC9B,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,EAAE,CAAA;CAAE,CA8C/G;AAED;+EAC+E;AAC/E,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAyB7F"}
|
|
@@ -32,6 +32,17 @@ export function splitLocalSection(current) {
|
|
|
32
32
|
*/
|
|
33
33
|
export const INLINE_LOCAL_BEGIN = '# smoo-local-begin';
|
|
34
34
|
export const INLINE_LOCAL_END = '# smoo-local-end';
|
|
35
|
+
/**
|
|
36
|
+
* The markers are line comments, so a managed file whose language does not
|
|
37
|
+
* comment with `#` (a TypeScript setup script) fences its repo-owned block
|
|
38
|
+
* with `//` instead: `// smoo-local-begin`. The prefix a block was written
|
|
39
|
+
* with is the prefix it is re-emitted with.
|
|
40
|
+
*/
|
|
41
|
+
const INLINE_MARKER = /^\s*(#|\/\/) smoo-local-(begin|end)$/;
|
|
42
|
+
function inlineMarker(line) {
|
|
43
|
+
const match = line === undefined ? null : INLINE_MARKER.exec(line);
|
|
44
|
+
return match === null ? undefined : { kind: match[2] === 'begin' ? 'begin' : 'end', prefix: match[1] };
|
|
45
|
+
}
|
|
35
46
|
/** Pull inline local blocks out of a managed section, returning the section
|
|
36
47
|
* with each block (and its markers) removed, plus the extracted blocks in
|
|
37
48
|
* the order they appeared. */
|
|
@@ -42,16 +53,17 @@ export function extractInlineLocalBlocks(managed) {
|
|
|
42
53
|
let i = 0;
|
|
43
54
|
while (i < lines.length) {
|
|
44
55
|
const line = lines[i];
|
|
45
|
-
|
|
56
|
+
const marker = inlineMarker(line);
|
|
57
|
+
if (line !== undefined && marker?.kind === 'begin') {
|
|
46
58
|
const anchor = kept.at(-1);
|
|
47
59
|
if (anchor === undefined) {
|
|
48
60
|
throw new ManagedContentConflict(`${INLINE_LOCAL_BEGIN} on line ${i + 1} has no preceding anchor line`);
|
|
49
61
|
}
|
|
50
62
|
const blockLines = [];
|
|
51
63
|
i += 1;
|
|
52
|
-
while (i < lines.length && lines[i]?.
|
|
64
|
+
while (i < lines.length && inlineMarker(lines[i])?.kind !== 'end') {
|
|
53
65
|
const blockLine = lines[i];
|
|
54
|
-
if (blockLine
|
|
66
|
+
if (inlineMarker(blockLine)?.kind === 'begin') {
|
|
55
67
|
throw new ManagedContentConflict(`${INLINE_LOCAL_BEGIN} on line ${i + 1} is nested`);
|
|
56
68
|
}
|
|
57
69
|
blockLines.push(blockLine);
|
|
@@ -66,11 +78,12 @@ export function extractInlineLocalBlocks(managed) {
|
|
|
66
78
|
lines: blockLines.join('\n'),
|
|
67
79
|
...(blockLines.length === 0 ? { empty: true } : {}),
|
|
68
80
|
...(markerIndent === '' ? {} : { markerIndent }),
|
|
81
|
+
...(marker.prefix === '#' ? {} : { markerPrefix: marker.prefix }),
|
|
69
82
|
});
|
|
70
83
|
i += 1; // skip the END marker line itself
|
|
71
84
|
continue;
|
|
72
85
|
}
|
|
73
|
-
if (line
|
|
86
|
+
if (inlineMarker(line)?.kind === 'end') {
|
|
74
87
|
throw new ManagedContentConflict(`${INLINE_LOCAL_END} on line ${i + 1} has no matching ${INLINE_LOCAL_BEGIN}`);
|
|
75
88
|
}
|
|
76
89
|
kept.push(line);
|
|
@@ -94,8 +107,9 @@ export function reinsertInlineLocalBlocks(content, blocks) {
|
|
|
94
107
|
}
|
|
95
108
|
const index = matches[0];
|
|
96
109
|
const markerIndent = block.markerIndent ?? '';
|
|
110
|
+
const prefix = block.markerPrefix ?? '#';
|
|
97
111
|
const inserted = additions.get(index) ?? [];
|
|
98
|
-
inserted.push(`${markerIndent}${
|
|
112
|
+
inserted.push(`${markerIndent}${prefix} smoo-local-begin`, ...(block.empty ? [] : block.lines.split('\n')), `${markerIndent}${prefix} smoo-local-end`);
|
|
99
113
|
additions.set(index, inserted);
|
|
100
114
|
}
|
|
101
115
|
return lines.flatMap((line, index) => [line, ...(additions.get(index) ?? [])]).join('\n');
|
|
@@ -25,6 +25,8 @@ export declare function applyTypecheckTestDefaults(tsconfigTest: Record<string,
|
|
|
25
25
|
tsconfigLibExtends?: string | string[];
|
|
26
26
|
libCompilerOptions?: Record<string, unknown>;
|
|
27
27
|
referencePaths: string[];
|
|
28
|
+
/** The file did not exist: a fresh program gets the src-test globs. */
|
|
29
|
+
isNew?: boolean;
|
|
28
30
|
}): boolean;
|
|
29
31
|
/**
|
|
30
32
|
* Remove the ./tsconfig.test.json reference from a tsconfig.json object.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typecheck-test-policy.d.ts","sourceRoot":"","sources":["../src/typecheck-test-policy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,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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AW,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,GAAG,MAAM,EAAE,CAAC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACA,OAAO,CAkET;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,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,EAAE,CAgDlE;AAeD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAiEtE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _assertGuard_1 from "typia/lib/internal/_assertGuard";
|
|
2
2
|
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
3
|
-
import { join, relative } from 'node:path';
|
|
3
|
+
import { dirname, join, relative } from 'node:path';
|
|
4
4
|
import { getProjects, readJson, readProjectConfiguration } from 'nx/src/devkit-exports.js';
|
|
5
5
|
import typia from 'typia';
|
|
6
6
|
import { ManagedContentConflict } from './managed-files/managed-content.js';
|
|
@@ -152,7 +152,11 @@ export function applyTypecheckTestDefaults(tsconfigTest, options) {
|
|
|
152
152
|
changed = setBooleanProperty(compilerOptions, 'declarationMap', false) || changed;
|
|
153
153
|
changed = setBooleanProperty(compilerOptions, 'emitDeclarationOnly', false) || changed;
|
|
154
154
|
changed = setBooleanProperty(compilerOptions, 'noEmit', true) || changed;
|
|
155
|
-
|
|
155
|
+
// `types`, like `include` below, replaces what `extends` provides the
|
|
156
|
+
// moment it is declared: a program inheriting workers + bun types from its
|
|
157
|
+
// tsconfig.json would be left with `["bun"]` alone. Merge only into a
|
|
158
|
+
// declared list or a new file.
|
|
159
|
+
if (options.testRunners.has('bun') && (options.isNew || Object.hasOwn(compilerOptions, 'types'))) {
|
|
156
160
|
changed = mergeStringListProperty(compilerOptions, 'types', ['bun']) || changed;
|
|
157
161
|
}
|
|
158
162
|
if ('outDir' in compilerOptions) {
|
|
@@ -163,14 +167,22 @@ export function applyTypecheckTestDefaults(tsconfigTest, options) {
|
|
|
163
167
|
delete compilerOptions.tsBuildInfoFile;
|
|
164
168
|
changed = true;
|
|
165
169
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
// A test program that declares no `include` inherits one from `extends`
|
|
171
|
+
// (a package keeping its suites in `test/` alongside src, tooling and
|
|
172
|
+
// scripts as one program). Minting `include` there REPLACES the inherited
|
|
173
|
+
// set with globs that match nothing, and a program of zero files passes the
|
|
174
|
+
// gate by compiling nothing. Only a program that already declares `include`,
|
|
175
|
+
// or a new file, gets the src-test globs merged in.
|
|
176
|
+
if (options.isNew || Object.hasOwn(tsconfigTest, 'include')) {
|
|
177
|
+
changed =
|
|
178
|
+
mergeStringListProperty(tsconfigTest, 'include', [
|
|
179
|
+
'src/**/*.test.ts',
|
|
180
|
+
'src/**/*.spec.ts',
|
|
181
|
+
'src/**/__tests__/**/*.ts',
|
|
182
|
+
'src/**/__tests__/**/*.tsx',
|
|
183
|
+
'src/test-suite-tracer.ts',
|
|
184
|
+
]) || changed;
|
|
185
|
+
}
|
|
174
186
|
for (const referencePath of options.referencePaths) {
|
|
175
187
|
changed = addTsconfigReference(tsconfigTest, referencePath) || changed;
|
|
176
188
|
}
|
|
@@ -262,6 +274,7 @@ export function renderTypecheckTestFiles(tree) {
|
|
|
262
274
|
tsconfigLibExtends,
|
|
263
275
|
libCompilerOptions: libCompilerOptions ?? undefined,
|
|
264
276
|
referencePaths,
|
|
277
|
+
isNew,
|
|
265
278
|
});
|
|
266
279
|
files.push(renderTsconfig(tree, tsconfigTestPath, tsconfigTest, changed || isNew));
|
|
267
280
|
// Remove test reference from tsconfig.json
|
|
@@ -425,8 +438,14 @@ function collectWorkspacePackagesTree(tree) {
|
|
|
425
438
|
}
|
|
426
439
|
function collectReferencePathsTree(tree, packageRoot, pkg, workspacePackages) {
|
|
427
440
|
const paths = [];
|
|
441
|
+
// A project reference is only legal to a `composite` program (TS6306); a
|
|
442
|
+
// lib tsconfig that is not composite — an application target's emit
|
|
443
|
+
// program — is included by the test program's own globs instead.
|
|
444
|
+
// `composite` is usually inherited from tsconfig.base.json, so the option is
|
|
445
|
+
// resolved through the `extends` chain, not read off the one file.
|
|
446
|
+
const isComposite = (path) => resolveTsconfigOption(tree, path, 'composite') === true;
|
|
428
447
|
const libTsconfigPath = `${packageRoot}/tsconfig.lib.json`;
|
|
429
|
-
if (
|
|
448
|
+
if (isComposite(libTsconfigPath)) {
|
|
430
449
|
paths.push('./tsconfig.lib.json');
|
|
431
450
|
}
|
|
432
451
|
const packagesByName = new Map(workspacePackages.map((p) => [p.name, p]));
|
|
@@ -439,7 +458,7 @@ function collectReferencePathsTree(tree, packageRoot, pkg, workspacePackages) {
|
|
|
439
458
|
if (!depPkg)
|
|
440
459
|
continue;
|
|
441
460
|
const depTsconfig = `${depPkg.path}/tsconfig.lib.json`;
|
|
442
|
-
if (!
|
|
461
|
+
if (!isComposite(depTsconfig))
|
|
443
462
|
continue;
|
|
444
463
|
const refPath = relative(packageRoot, depTsconfig).replaceAll('\\', '/');
|
|
445
464
|
if (!paths.includes(refPath))
|
|
@@ -662,6 +681,32 @@ function recordProperty(record, key) {
|
|
|
662
681
|
const value = record[key];
|
|
663
682
|
return isRecord(value) ? value : null;
|
|
664
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* A tsconfig compiler option as TypeScript would see it: the file's own value,
|
|
686
|
+
* else the nearest base in its `extends` chain (an array extends applies
|
|
687
|
+
* left-to-right, so the last base naming the option wins). Bases that are not
|
|
688
|
+
* relative paths (package configs) are outside the tree and contribute nothing.
|
|
689
|
+
*/
|
|
690
|
+
function resolveTsconfigOption(tree, path, option) {
|
|
691
|
+
if (!tree.exists(path))
|
|
692
|
+
return undefined;
|
|
693
|
+
const config = readJson(tree, path);
|
|
694
|
+
const own = recordProperty(config, 'compilerOptions')?.[option];
|
|
695
|
+
if (own !== undefined)
|
|
696
|
+
return own;
|
|
697
|
+
const bases = config.extends;
|
|
698
|
+
const baseList = typeof bases === 'string' ? [bases] : Array.isArray(bases) ? bases : [];
|
|
699
|
+
for (let i = baseList.length - 1; i >= 0; i--) {
|
|
700
|
+
const base = baseList[i];
|
|
701
|
+
if (typeof base !== 'string' || !base.startsWith('.'))
|
|
702
|
+
continue;
|
|
703
|
+
const basePath = join(dirname(path), base.endsWith('.json') ? base : `${base}.json`);
|
|
704
|
+
const inherited = resolveTsconfigOption(tree, basePath, option);
|
|
705
|
+
if (inherited !== undefined)
|
|
706
|
+
return inherited;
|
|
707
|
+
}
|
|
708
|
+
return undefined;
|
|
709
|
+
}
|
|
665
710
|
function getOrCreateRecord(record, key) {
|
|
666
711
|
const value = record[key];
|
|
667
712
|
if (isRecord(value)) {
|
package/executors.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"typescript-emit": {
|
|
9
9
|
"implementation": "./dist/executors/typescript-emit/executor.js",
|
|
10
10
|
"schema": "./src/executors/typescript-emit/schema.json",
|
|
11
|
-
"description": "Emit transformed JavaScript
|
|
11
|
+
"description": "Emit transformed JavaScript and declarations together with ttsc"
|
|
12
12
|
},
|
|
13
13
|
"clean-outputs": {
|
|
14
14
|
"implementation": "./dist/executors/clean-outputs/executor.js",
|