@smoothbricks/nx-plugin 0.4.14 → 0.4.16
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 +20 -3
- package/dist/deploy-policy.d.ts +26 -0
- package/dist/deploy-policy.d.ts.map +1 -0
- package/dist/deploy-policy.js +36 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +160 -37
- package/dist/managed-assets.d.ts +3 -0
- package/dist/managed-assets.d.ts.map +1 -0
- package/dist/managed-assets.js +3 -0
- package/dist/managed-files/ci-workflow.d.ts +215 -0
- package/dist/managed-files/ci-workflow.d.ts.map +1 -0
- package/dist/managed-files/ci-workflow.js +1082 -0
- package/dist/managed-files/context.d.ts +51 -0
- package/dist/managed-files/context.d.ts.map +1 -0
- package/dist/managed-files/context.js +206 -0
- package/dist/managed-files/files.d.ts +53 -0
- package/dist/managed-files/files.d.ts.map +1 -0
- package/dist/managed-files/files.js +248 -0
- package/dist/managed-files/generator.d.ts +16 -0
- package/dist/managed-files/generator.d.ts.map +1 -0
- package/dist/managed-files/generator.js +41 -0
- package/dist/managed-files/github-runs-on.d.ts +19 -0
- package/dist/managed-files/github-runs-on.d.ts.map +1 -0
- package/dist/managed-files/github-runs-on.js +48 -0
- package/dist/managed-files/managed-content.d.ts +45 -0
- package/dist/managed-files/managed-content.d.ts.map +1 -0
- package/dist/managed-files/managed-content.js +102 -0
- package/dist/managed-files/managed-format.d.ts +37 -0
- package/dist/managed-files/managed-format.d.ts.map +1 -0
- package/dist/managed-files/managed-format.js +94 -0
- package/dist/managed-files/paths.d.ts +8 -0
- package/dist/managed-files/paths.d.ts.map +1 -0
- package/dist/managed-files/paths.js +46 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +5 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.js +38 -0
- package/dist/managed-files/private-npm-policy.d.ts +7 -0
- package/dist/managed-files/private-npm-policy.d.ts.map +1 -0
- package/dist/managed-files/private-npm-policy.js +51 -0
- package/dist/managed-files/publish-workflow.d.ts +150 -0
- package/dist/managed-files/publish-workflow.d.ts.map +1 -0
- package/dist/managed-files/publish-workflow.js +989 -0
- package/dist/managed-files/tree.d.ts +30 -0
- package/dist/managed-files/tree.d.ts.map +1 -0
- package/dist/managed-files/tree.js +91 -0
- package/dist/package-target-policy.d.ts +0 -1
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +50 -23
- package/dist/platform-targets.d.ts +5 -0
- package/dist/platform-targets.d.ts.map +1 -0
- package/dist/platform-targets.js +4 -0
- package/dist/typecheck-test-policy.d.ts +5 -9
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +69 -99
- package/dist/workspace-config-policy.d.ts +23 -3
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +35 -3
- package/dist/workspace-manifest.d.ts +291 -0
- package/dist/workspace-manifest.d.ts.map +1 -0
- package/dist/workspace-manifest.js +6 -0
- package/dist/workspace-package-policy.d.ts +13 -0
- package/dist/workspace-package-policy.d.ts.map +1 -0
- package/dist/workspace-package-policy.js +24 -0
- package/generators.json +5 -0
- package/managed/raw/envrc +20 -0
- package/managed/raw/git-format-staged.yml +82 -0
- package/managed/raw/gitattributes +8 -0
- package/managed/raw/tooling/devenv +83 -0
- package/managed/raw/tooling/direnv/devenv.smoo.nix +422 -0
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +251 -0
- package/managed/raw/tooling/direnv/merge-newer-pins.sh +48 -0
- package/managed/raw/tooling/direnv/repo-path +34 -0
- package/managed/raw/tooling/direnv/secret-references.ts +636 -0
- package/managed/raw/tooling/direnv/setup-environment.ts +585 -0
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +88 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +9 -0
- package/managed/raw/tooling/git-hooks/post-commit.sh +71 -0
- package/managed/raw/tooling/git-hooks/pre-commit.sh +18 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +48 -0
- package/managed/raw/tsconfig.lib.json +28 -0
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +45 -0
- package/managed/templates/github/actions/cache-node-modules/action.yml +17 -0
- package/managed/templates/github/actions/cache-nx/action.yml +21 -0
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +19 -0
- package/managed/templates/github/actions/save-nix-devenv/action.yml +32 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +241 -0
- package/managed/templates/github/workflows/managed-files.yml +127 -0
- package/package.json +89 -5
- package/src/bun-bootstrap.test.ts +0 -6
- package/src/deploy-policy.ts +40 -0
- package/src/index.test.ts +232 -9
- package/src/index.ts +187 -40
- package/src/managed-assets.ts +4 -0
- package/src/managed-files/ci-workflow.ts +1365 -0
- package/src/managed-files/context.ts +240 -0
- package/src/managed-files/files.ts +324 -0
- package/src/managed-files/generator.test.ts +151 -0
- package/src/managed-files/generator.ts +60 -0
- package/src/managed-files/github-runs-on.ts +51 -0
- package/src/managed-files/managed-content.test.ts +147 -0
- package/src/managed-files/managed-content.ts +121 -0
- package/src/managed-files/managed-format.ts +102 -0
- package/src/managed-files/paths.ts +44 -0
- package/src/managed-files/pr-preview-cleanup-workflow.ts +44 -0
- package/src/managed-files/private-npm-policy.ts +62 -0
- package/src/managed-files/publish-workflow.ts +1523 -0
- package/src/managed-files/schema.json +8 -0
- package/src/managed-files/tree-permissions.test.ts +109 -0
- package/src/managed-files/tree.test.ts +123 -0
- package/src/managed-files/tree.ts +118 -0
- package/src/package-target-policy.test.ts +4 -28
- package/src/package-target-policy.ts +55 -31
- package/src/platform-targets.ts +4 -0
- package/src/typecheck-test-policy.test.ts +28 -3
- package/src/typecheck-test-policy.ts +46 -121
- package/src/workspace-config-policy.test.ts +14 -2
- package/src/workspace-config-policy.ts +42 -3
- package/src/workspace-manifest.ts +327 -0
- package/src/workspace-package-policy.ts +32 -0
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
1
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
2
2
|
import { readdir, readFile } from 'node:fs/promises';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
|
-
import { dirname, join, posix, relative } from 'node:path';
|
|
4
|
+
import { dirname, isAbsolute, join, posix, relative, resolve } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
|
|
7
7
|
import {
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
} from './cross-check-policy.js';
|
|
50
50
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
51
51
|
import { isNonSourceDirectory } from './source-directories.js';
|
|
52
|
-
import { PLATFORM_TARGET_GLOBS } from './workspace-config-policy.js';
|
|
52
|
+
import { isBuildOutputTargetName, isTestRunnerTargetName, PLATFORM_TARGET_GLOBS } from './workspace-config-policy.js';
|
|
53
53
|
|
|
54
54
|
export { CARGO_TEST_COMPILE_TARGET };
|
|
55
55
|
|
|
@@ -58,17 +58,21 @@ export const DEPLOY_TARGET = 'deploy';
|
|
|
58
58
|
/** The purely file-derived half a deploy needs built first; cached. */
|
|
59
59
|
export const DEPLOY_BUILD_TARGET = 'deploy-build';
|
|
60
60
|
|
|
61
|
-
const BUILD_OUTPUT_TARGET_PATTERN = /-(?:js|web|html|css|android|native|napi|bun|wasm)$/;
|
|
62
61
|
/** The workspace-wide manifests a release rewrites: the version of every member, and the lockfile mirror of it. */
|
|
63
62
|
const RELEASE_REWRITTEN_WORKSPACE_INPUTS = ['{workspaceRoot}/package.json', '{workspaceRoot}/bun.lock'];
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
/** Installed-toolchain files a TypeScript task reads that no config can name. */
|
|
64
|
+
const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*'];
|
|
65
|
+
/**
|
|
66
|
+
* The workspace's own base config, hashed for every TypeScript task whether or
|
|
67
|
+
* not this project's chain reaches it: it is where a workspace puts the options
|
|
68
|
+
* it means to apply to everything, and a project with no TypeScript config of
|
|
69
|
+
* its own has no chain to reach it with.
|
|
70
|
+
*/
|
|
71
|
+
const WORKSPACE_TSCONFIG_BASE_INPUT = '{workspaceRoot}/tsconfig.base.json';
|
|
72
|
+
|
|
69
73
|
/**
|
|
70
|
-
* The
|
|
71
|
-
*
|
|
74
|
+
* The two release-rewritten files hashed by field instead of by byte, for a
|
|
75
|
+
* check that only reads them.
|
|
72
76
|
*
|
|
73
77
|
* A `json` input is hashed by Nx's own hasher, so this costs no process. The
|
|
74
78
|
* lockfile's `workspaces` section is the mirror of each member's manifest —
|
|
@@ -76,12 +80,161 @@ const TYPESCRIPT_TOOLCHAIN_INPUTS = [
|
|
|
76
80
|
* hashed from the member's own `package.json`. Dropping that section keeps the
|
|
77
81
|
* resolution table, which is the reason the lockfile is an input at all.
|
|
78
82
|
*/
|
|
79
|
-
const
|
|
80
|
-
...TYPESCRIPT_TOOLCHAIN_INPUTS.filter((input) => !RELEASE_REWRITTEN_WORKSPACE_INPUTS.includes(input)),
|
|
83
|
+
const VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS = [
|
|
81
84
|
{ json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
|
|
82
85
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
83
86
|
];
|
|
84
87
|
|
|
88
|
+
/** A path segment Nx's workspace file map never carries, so a fileset naming it hashes nothing. */
|
|
89
|
+
const NODE_MODULES_SEGMENT = /(?:^|\/)node_modules(?:\/|$)/;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Every config file whose compiler options decide this project's TypeScript
|
|
93
|
+
* verdicts: the workspace base, plus every file reachable by `extends` from the
|
|
94
|
+
* configs its commands hand to `tsc`.
|
|
95
|
+
*
|
|
96
|
+
* Hashing only the named config is the bug this closes. A workspace whose
|
|
97
|
+
* project configs extend an INTERMEDIATE base — `packages/tsconfig.base.json`
|
|
98
|
+
* extending the root one — hashed the root and the named file and nothing in
|
|
99
|
+
* between, so flipping `noUnusedLocals` in the intermediate left every
|
|
100
|
+
* typecheck, test typecheck and emit serving its previous answer from cache:
|
|
101
|
+
* a pass for sources the compiler would now reject.
|
|
102
|
+
*
|
|
103
|
+
* Fail-closed. An `extends` that resolves to no file throws and names both
|
|
104
|
+
* files, because the only alternative is to drop an ancestor from the hash —
|
|
105
|
+
* which is the silence above. The ancestors this cannot name as a fileset are
|
|
106
|
+
* the two kinds Nx has no fileset for; see {@link configChainInput}.
|
|
107
|
+
*/
|
|
108
|
+
function typescriptConfigChainInputs(configPaths: readonly string[], workspaceRoot: string): string[] {
|
|
109
|
+
const inputs = new Set([WORKSPACE_TSCONFIG_BASE_INPUT]);
|
|
110
|
+
const walked = new Set<string>();
|
|
111
|
+
for (const configPath of configPaths) {
|
|
112
|
+
addTypescriptConfigAncestors(configPath, workspaceRoot, inputs, walked);
|
|
113
|
+
}
|
|
114
|
+
return [...inputs];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* One config's ancestors; `walked` both dedupes shared bases and breaks an
|
|
119
|
+
* `extends` cycle.
|
|
120
|
+
*
|
|
121
|
+
* The walk stops at an ancestor Nx cannot hash, because everything reachable
|
|
122
|
+
* from an installed config is installed too: the lockfile pins that whole
|
|
123
|
+
* subtree, and parsing it could only invent failures for a dependency's own
|
|
124
|
+
* chain.
|
|
125
|
+
*/
|
|
126
|
+
function addTypescriptConfigAncestors(
|
|
127
|
+
configPath: string,
|
|
128
|
+
workspaceRoot: string,
|
|
129
|
+
inputs: Set<string>,
|
|
130
|
+
walked: Set<string>,
|
|
131
|
+
): void {
|
|
132
|
+
if (walked.has(configPath)) return;
|
|
133
|
+
walked.add(configPath);
|
|
134
|
+
for (const specifier of typescriptConfigExtends(configPath)) {
|
|
135
|
+
const ancestor = resolveTypescriptConfigExtends(specifier, configPath);
|
|
136
|
+
const input = configChainInput(ancestor, configPath, workspaceRoot);
|
|
137
|
+
if (input === null) continue;
|
|
138
|
+
inputs.add(input);
|
|
139
|
+
addTypescriptConfigAncestors(ancestor.path, workspaceRoot, inputs, walked);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** What one config extends: a single specifier, or the ordered list TypeScript 5.0 added. */
|
|
144
|
+
function typescriptConfigExtends(configPath: string): string[] {
|
|
145
|
+
const config: unknown = readJsonFile(configPath, { expectComments: true });
|
|
146
|
+
if (!isRecord(config)) throw new Error(`${configPath} is not a TypeScript configuration object`);
|
|
147
|
+
const extended = config.extends;
|
|
148
|
+
if (extended === undefined) return [];
|
|
149
|
+
const specifiers: unknown[] = Array.isArray(extended) ? extended : [extended];
|
|
150
|
+
return specifiers.map((specifier) => {
|
|
151
|
+
if (typeof specifier !== 'string' || specifier.length === 0) {
|
|
152
|
+
throw new Error(`${configPath}: "extends" must name config files, not ${JSON.stringify(extended)}`);
|
|
153
|
+
}
|
|
154
|
+
return specifier;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Where one ancestor's bytes live, which is what decides whether Nx can hash them. */
|
|
159
|
+
interface ConfigAncestor {
|
|
160
|
+
path: string;
|
|
161
|
+
/**
|
|
162
|
+
* Reached through Node module resolution rather than a path, so a lockfile
|
|
163
|
+
* decides which bytes are there — wherever the installer chose to put them.
|
|
164
|
+
* A workspace member resolved this way is still workspace source; see
|
|
165
|
+
* {@link configChainInput}.
|
|
166
|
+
*/
|
|
167
|
+
installed: boolean;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* One `extends` specifier as an absolute path, by TypeScript's own rules: a
|
|
172
|
+
* relative or rooted specifier is a path — with the `.json` extension it may
|
|
173
|
+
* omit — and anything else is a Node specifier resolved from the extending file.
|
|
174
|
+
*/
|
|
175
|
+
function resolveTypescriptConfigExtends(specifier: string, fromConfigPath: string): ConfigAncestor {
|
|
176
|
+
if (specifier.startsWith('./') || specifier.startsWith('../') || isAbsolute(specifier)) {
|
|
177
|
+
const direct = resolve(dirname(fromConfigPath), specifier);
|
|
178
|
+
const candidates = direct.endsWith('.json') ? [direct] : [direct, `${direct}.json`];
|
|
179
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
180
|
+
if (found !== undefined) return { path: found, installed: false };
|
|
181
|
+
throw new Error(
|
|
182
|
+
`${fromConfigPath}: "extends": "${specifier}" names no file (looked for ${candidates.join(', ')}). ` +
|
|
183
|
+
'Every config in the chain is hashed, so one that cannot be found cannot be left out of the hash either.',
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
// A package config may be named by file or bare; TypeScript accepts both.
|
|
187
|
+
const candidates = specifier.endsWith('.json') ? [specifier] : [specifier, `${specifier}/tsconfig.json`];
|
|
188
|
+
const nodeRequire = createRequire(fromConfigPath);
|
|
189
|
+
for (const candidate of candidates) {
|
|
190
|
+
try {
|
|
191
|
+
return { path: nodeRequire.resolve(candidate), installed: true };
|
|
192
|
+
} catch {
|
|
193
|
+
// Not this spelling of the package config; try the next, then refuse.
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
throw new Error(
|
|
197
|
+
`${fromConfigPath}: "extends": "${specifier}" resolves to no installed config (tried ${candidates.join(', ')}). ` +
|
|
198
|
+
'Every config in the chain is hashed, so one that cannot be found cannot be left out of the hash either.',
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The fileset name for one ancestor, or `null` when Nx cannot hash that file.
|
|
204
|
+
*
|
|
205
|
+
* Nx hashes workspace files that are not in node_modules, so two ancestor
|
|
206
|
+
* kinds cannot be named — and they are not the same thing:
|
|
207
|
+
*
|
|
208
|
+
* - a dependency's config: `bun.lock` and the root manifest decide which
|
|
209
|
+
* bytes are installed, and both are already inputs. Where they sit is the
|
|
210
|
+
* installer's business — bun keeps them in a global store outside the
|
|
211
|
+
* workspace entirely — so this is settled by HOW the specifier resolved,
|
|
212
|
+
* not by where it landed. A workspace member reached through its package
|
|
213
|
+
* name is workspace source, and is hashed as such.
|
|
214
|
+
* - a path above the workspace root: nothing hashes it and nothing pins it,
|
|
215
|
+
* so an edit there really can serve a stale verdict. Said out loud,
|
|
216
|
+
* because the silent version of exactly that is the bug this walk closes.
|
|
217
|
+
*/
|
|
218
|
+
function configChainInput(ancestor: ConfigAncestor, fromConfigPath: string, workspaceRoot: string): string | null {
|
|
219
|
+
let relativePath = relative(workspaceRoot, ancestor.path).replaceAll('\\', '/');
|
|
220
|
+
if (relativePath.startsWith('../')) {
|
|
221
|
+
// Node resolves a package to its REAL path, and a workspace root can itself
|
|
222
|
+
// be reached through a symlink (macOS `/var` → `/private/var`): a workspace
|
|
223
|
+
// member then looks like a file above the root. Believe the real root
|
|
224
|
+
// before concluding anything is outside.
|
|
225
|
+
relativePath = relative(realpathSync(workspaceRoot), ancestor.path).replaceAll('\\', '/');
|
|
226
|
+
}
|
|
227
|
+
const outsideWorkspace = relativePath.length === 0 || relativePath.startsWith('../') || isAbsolute(relativePath);
|
|
228
|
+
if (!outsideWorkspace && !NODE_MODULES_SEGMENT.test(relativePath)) return `{workspaceRoot}/${relativePath}`;
|
|
229
|
+
if (!ancestor.installed) {
|
|
230
|
+
process.stderr.write(
|
|
231
|
+
`@smoothbricks/nx-plugin: ${fromConfigPath} extends ${ancestor.path}, which is outside the workspace. ` +
|
|
232
|
+
'Nx hashes workspace files only, so a change to it will not invalidate this project\u2019s TypeScript tasks.\n',
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
|
|
85
238
|
/**
|
|
86
239
|
* A project's own manifest, hashed without the version a release rewrites.
|
|
87
240
|
*
|
|
@@ -204,36 +357,18 @@ function hostPlatformTargetNames(targetNames: Iterable<string>, hostPlatform: Na
|
|
|
204
357
|
* its name ends in a family: `*-js`, `*-web`, `*-html`, `*-css`, `*-android`,
|
|
205
358
|
* `*-native`, `*-napi`, `*-bun`, `*-wasm`.
|
|
206
359
|
*
|
|
207
|
-
* Two spellings of the same collision. A per-crate cargo test runner is
|
|
208
|
-
* `cargo-test-<crate>`, so any crate whose name ends in a family put its RUNNER
|
|
209
|
-
* in the aggregate; the runners are one serialized chain, so a single such
|
|
210
|
-
* crate made `build` pull an entire cargo test suite. A bun suite named
|
|
211
|
-
* `test-bun` is the collision without the prefix — a runner reading as
|
|
212
|
-
* "tool=test, output=bun", swept into `build` by suffix alone. That one forced
|
|
213
|
-
* a consumer to hand-declare `build` purely to replace the inferred list.
|
|
214
|
-
*
|
|
215
360
|
* So the rule is the CLASS, not one namespace: a target that RUNS tests is
|
|
216
361
|
* never a build output, however it is spelled. Expanding the families here
|
|
217
|
-
* rather than delegating to Nx's matcher is what makes that expressible
|
|
362
|
+
* rather than delegating to Nx's matcher is what makes that expressible, and
|
|
363
|
+
* `package-target-policy` reads the same two predicates to decide whether a
|
|
364
|
+
* hand-declared aggregate is naming an edge this list already produces.
|
|
218
365
|
*/
|
|
219
366
|
function buildOutputTargetNames(targetNames: Iterable<string>): string[] {
|
|
220
367
|
return [...new Set(targetNames)]
|
|
221
|
-
.filter((name) =>
|
|
368
|
+
.filter((name) => isBuildOutputTargetName(name) && !isTestRunnerTargetName(name))
|
|
222
369
|
.sort();
|
|
223
370
|
}
|
|
224
371
|
|
|
225
|
-
/**
|
|
226
|
-
* A target whose job is to RUN tests. `test`, anything under `test-`/`test:`,
|
|
227
|
-
* and the plugin's own `cargo-test-<crate>` namespace. Deliberately name-based:
|
|
228
|
-
* the aggregate is assembled from declared AND inferred target names, and a
|
|
229
|
-
* declaration carries no marker saying "this executes rather than emits".
|
|
230
|
-
*/
|
|
231
|
-
function isTestRunnerTargetName(name: string): boolean {
|
|
232
|
-
return (
|
|
233
|
-
name === 'test' || name.startsWith('test-') || name.startsWith('test:') || name.startsWith(`${CARGO_TEST_TARGET}-`)
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
372
|
//#region smoo!n/rust-output-target-inference
|
|
238
373
|
// Cargo workspace inference: a package.json sitting next to a Cargo.toml that
|
|
239
374
|
// declares [workspace] gets direct cargo-test/test targets, cargo-lint feeding
|
|
@@ -848,6 +983,8 @@ async function createProjectTargets(
|
|
|
848
983
|
const validationTargets: string[] = [];
|
|
849
984
|
const libTsconfigPath = join(absoluteProjectRoot, 'tsconfig.lib.json');
|
|
850
985
|
const hasLibTsconfig = existsSync(libTsconfigPath);
|
|
986
|
+
const testTsconfigPath = join(absoluteProjectRoot, 'tsconfig.test.json');
|
|
987
|
+
const hasTestTsconfig = existsSync(testTsconfigPath);
|
|
851
988
|
const cargoTomlPath = join(absoluteProjectRoot, 'Cargo.toml');
|
|
852
989
|
const isCargoWorkspace =
|
|
853
990
|
existsSync(cargoTomlPath) && CARGO_WORKSPACE_PATTERN.test(await readFile(cargoTomlPath, 'utf-8'));
|
|
@@ -868,7 +1005,18 @@ async function createProjectTargets(
|
|
|
868
1005
|
const crateInputs =
|
|
869
1006
|
versionless !== null && hasCrateManifests ? await versionlessCrateInputs(projectRoot, workspaceRoot) : [];
|
|
870
1007
|
const versionlessProjectInputs = versionless === null ? [] : [...VERSIONLESS_PACKAGE_INPUTS, ...crateInputs];
|
|
871
|
-
|
|
1008
|
+
// The options a TypeScript task's answer really depends on, which is the
|
|
1009
|
+
// whole `extends` chain of the configs its commands name and not just those
|
|
1010
|
+
// two files. Resolved once per project: every target below shares it.
|
|
1011
|
+
const typescriptConfigChain = typescriptConfigChainInputs(
|
|
1012
|
+
[...(hasLibTsconfig ? [libTsconfigPath] : []), ...(hasTestTsconfig ? [testTsconfigPath] : [])],
|
|
1013
|
+
workspaceRoot,
|
|
1014
|
+
);
|
|
1015
|
+
const toolchainInputs = [...RELEASE_REWRITTEN_WORKSPACE_INPUTS, ...TYPESCRIPT_PATCH_INPUTS, ...typescriptConfigChain];
|
|
1016
|
+
const checkInputs =
|
|
1017
|
+
versionless === null
|
|
1018
|
+
? toolchainInputs
|
|
1019
|
+
: [...TYPESCRIPT_PATCH_INPUTS, ...typescriptConfigChain, ...VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS];
|
|
872
1020
|
const selfProduction = versionless === null ? 'production' : VERSIONLESS_PRODUCTION_INPUT;
|
|
873
1021
|
const selfDefault = versionless === null ? 'default' : VERSIONLESS_DEFAULT_INPUT;
|
|
874
1022
|
const dependencyProduction =
|
|
@@ -910,7 +1058,7 @@ async function createProjectTargets(
|
|
|
910
1058
|
targets['tsc-js'] = {
|
|
911
1059
|
executor: '@smoothbricks/nx-plugin:typescript-emit',
|
|
912
1060
|
cache: true,
|
|
913
|
-
inputs: ['production', '^production', ...
|
|
1061
|
+
inputs: ['production', '^production', ...toolchainInputs, '{projectRoot}/tsconfig.lib.json'],
|
|
914
1062
|
outputs: inferTypescriptOutputs(libTsconfigPath, packageJsonPath),
|
|
915
1063
|
dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
|
|
916
1064
|
options: {
|
|
@@ -932,7 +1080,6 @@ async function createProjectTargets(
|
|
|
932
1080
|
};
|
|
933
1081
|
}
|
|
934
1082
|
|
|
935
|
-
const hasTestTsconfig = existsSync(join(absoluteProjectRoot, 'tsconfig.test.json'));
|
|
936
1083
|
if (hasTestTsconfig) {
|
|
937
1084
|
targets['typecheck-tests'] = {
|
|
938
1085
|
executor: 'nx:run-commands',
|
|
@@ -954,7 +1101,7 @@ async function createProjectTargets(
|
|
|
954
1101
|
};
|
|
955
1102
|
const inferredTestWatchCommand = inferTestWatchCommand(packageJson);
|
|
956
1103
|
if (inferredTestWatchCommand) {
|
|
957
|
-
targets['test
|
|
1104
|
+
targets['test-watch'] = {
|
|
958
1105
|
executor: 'nx:run-commands',
|
|
959
1106
|
continuous: true,
|
|
960
1107
|
dependsOn: ['typecheck-tests'],
|
|
@@ -2041,7 +2188,7 @@ function classifyPackageLocalBuildOutputs(packageJson: PackageJson): { ordinary:
|
|
|
2041
2188
|
const targets = packageJson.nx?.targets;
|
|
2042
2189
|
const targetNames = isRecord(targets) ? Object.keys(targets) : [];
|
|
2043
2190
|
return {
|
|
2044
|
-
ordinary: targetNames.some(
|
|
2191
|
+
ordinary: targetNames.some(isBuildOutputTargetName),
|
|
2045
2192
|
platform: targetNames.some((targetName) =>
|
|
2046
2193
|
PLATFORM_TARGET_GLOBS.some((glob) => targetName.endsWith(glob.slice(1))),
|
|
2047
2194
|
),
|