@smoothbricks/cli 0.10.3 → 0.10.4
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 +9 -13
- package/dist/bun/preload.d.ts +13 -0
- package/dist/bun/preload.d.ts.map +1 -0
- package/dist/bun/preload.js +12 -0
- package/dist/cli.js +12 -4
- package/dist/generate/index.d.ts.map +1 -1
- package/dist/generate/index.js +0 -6
- package/dist/github-ci/index.d.ts.map +1 -1
- package/dist/github-ci/index.js +52 -16
- package/dist/github-ci/outputs.d.ts.map +1 -1
- package/dist/github-ci/outputs.js +1 -2
- package/dist/lib/cli-package.js +2 -2
- package/dist/lib/json.d.ts +118 -11
- package/dist/lib/json.d.ts.map +1 -1
- package/dist/lib/json.js +317 -29
- package/dist/lib/workspace.d.ts +7 -14
- package/dist/lib/workspace.d.ts.map +1 -1
- package/dist/lib/workspace.js +76 -82
- package/dist/monorepo/ci-workflow.d.ts +2 -0
- package/dist/monorepo/ci-workflow.d.ts.map +1 -1
- package/dist/monorepo/ci-workflow.js +27 -1
- package/dist/monorepo/git-config.js +2 -2
- package/dist/monorepo/index.d.ts +3 -1
- package/dist/monorepo/index.d.ts.map +1 -1
- package/dist/monorepo/index.js +6 -2
- package/dist/monorepo/lockfile.d.ts +13 -1
- package/dist/monorepo/lockfile.d.ts.map +1 -1
- package/dist/monorepo/lockfile.js +33 -21
- package/dist/monorepo/managed-files.d.ts +11 -0
- package/dist/monorepo/managed-files.d.ts.map +1 -1
- package/dist/monorepo/managed-files.js +52 -32
- package/dist/monorepo/package-policy.d.ts.map +1 -1
- package/dist/monorepo/package-policy.js +52 -45
- package/dist/monorepo/packed-manifest.d.ts +5 -2
- package/dist/monorepo/packed-manifest.d.ts.map +1 -1
- package/dist/monorepo/packed-manifest.js +16 -47
- package/dist/monorepo/packed-package.d.ts.map +1 -1
- package/dist/monorepo/packed-package.js +28 -16
- package/dist/monorepo/packs/index.d.ts.map +1 -1
- package/dist/monorepo/packs/index.js +13 -4
- package/dist/monorepo/publish-workflow.js +3 -1
- package/dist/monorepo/runtime.d.ts +15 -0
- package/dist/monorepo/runtime.d.ts.map +1 -1
- package/dist/monorepo/runtime.js +66 -12
- package/dist/monorepo/tool-validation.d.ts.map +1 -1
- package/dist/monorepo/tool-validation.js +32 -23
- package/dist/monorepo/wrangler.d.ts.map +1 -1
- package/dist/monorepo/wrangler.js +13 -13
- package/dist/nx/index.d.ts +9 -7
- package/dist/nx/index.d.ts.map +1 -1
- package/dist/nx/index.js +48 -31
- package/dist/pr/index.d.ts.map +1 -1
- package/dist/pr/index.js +28 -32
- package/dist/release/candidates.d.ts +3 -2
- package/dist/release/candidates.d.ts.map +1 -1
- package/dist/release/candidates.js +4 -5
- package/dist/release/index.d.ts +1 -0
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +82 -59
- package/dist/wrangler/prepare-env.d.ts +0 -1
- package/dist/wrangler/prepare-env.d.ts.map +1 -1
- package/dist/wrangler/prepare-env.js +100 -51
- package/dist/wrangler/scaffold.d.ts.map +1 -1
- package/dist/wrangler/scaffold.js +12 -12
- package/managed/raw/git-format-staged.yml +19 -1
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +2 -1
- package/managed/raw/tooling/direnv/merge-newer-pins.sh +3 -3
- package/managed/raw/tooling/direnv/setup-environment.ts +150 -19
- package/managed/raw/tooling/git-hooks/pre-commit.sh +0 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +5 -2
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +19 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +5 -0
- package/managed/templates/github/workflows/managed-files.yml +80 -0
- package/package.json +15 -4
- package/src/bun/preload.ts +12 -0
- package/src/cli.ts +19 -7
- package/src/generate/index.ts +0 -6
- package/src/github-ci/index.ts +49 -18
- package/src/github-ci/outputs.ts +1 -2
- package/src/lib/cli-package.ts +2 -2
- package/src/lib/json.ts +291 -32
- package/src/lib/workspace.ts +88 -100
- package/src/monorepo/__tests__/ci-workflow.test.ts +3 -3
- package/src/monorepo/ci-workflow.ts +27 -1
- package/src/monorepo/git-config.ts +2 -2
- package/src/monorepo/index.ts +6 -2
- package/src/monorepo/lockfile.test.ts +35 -36
- package/src/monorepo/lockfile.ts +48 -24
- package/src/monorepo/managed-files.test.ts +1 -0
- package/src/monorepo/managed-files.ts +57 -38
- package/src/monorepo/package-policy.test.ts +20 -50
- package/src/monorepo/package-policy.ts +76 -59
- package/src/monorepo/packed-manifest.ts +18 -52
- package/src/monorepo/packed-package.ts +43 -22
- package/src/monorepo/packs/index.ts +13 -4
- package/src/monorepo/publish-workflow.ts +3 -1
- package/src/monorepo/runtime.test.ts +42 -3
- package/src/monorepo/runtime.ts +90 -12
- package/src/monorepo/tool-validation.ts +35 -25
- package/src/monorepo/wrangler.test.ts +11 -15
- package/src/monorepo/wrangler.ts +15 -15
- package/src/nx/index.test.ts +9 -5
- package/src/nx/index.ts +69 -42
- package/src/pr/index.ts +42 -36
- package/src/release/__tests__/candidates.test.ts +5 -4
- package/src/release/__tests__/trust-publisher.test.ts +7 -0
- package/src/release/candidates.ts +10 -17
- package/src/release/index.ts +104 -73
- package/src/wrangler/prepare-env.ts +75 -54
- package/src/wrangler/scaffold.test.ts +9 -12
- package/src/wrangler/scaffold.ts +13 -13
|
@@ -4,7 +4,8 @@ import { dirname, join, relative } from 'node:path';
|
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
5
5
|
import { publint } from 'publint';
|
|
6
6
|
import { formatMessage } from 'publint/utils';
|
|
7
|
-
import
|
|
7
|
+
import typia from 'typia';
|
|
8
|
+
import { parsePackageJsonText } from '../lib/json.js';
|
|
8
9
|
import { printCommandOutput, runResult } from '../lib/run.js';
|
|
9
10
|
import { listPublicPackages } from '../lib/workspace.js';
|
|
10
11
|
import { readPackedPackageJson, validatePackedWorkspaceDependencies } from './packed-manifest.js';
|
|
@@ -60,7 +61,7 @@ async function validatePublint(_root, pkg, packed) {
|
|
|
60
61
|
async function validatePackedManifest(root, pkg, packed) {
|
|
61
62
|
let failures = 0;
|
|
62
63
|
const packedPackage = await readPackedPackageJson(root, packed.path, pkg.name);
|
|
63
|
-
for (const message of validatePackedWorkspaceDependencies(root, pkg, packedPackage)) {
|
|
64
|
+
for (const message of validatePackedWorkspaceDependencies(root, pkg, packedPackage, { mode: 'install' })) {
|
|
64
65
|
console.error(message);
|
|
65
66
|
failures++;
|
|
66
67
|
}
|
|
@@ -71,11 +72,10 @@ async function validateAttw(root, pkg, packed) {
|
|
|
71
72
|
const analysis = await attw.checkPackage(await createAttwPackageFromTarball(attw, root, packed.path), {
|
|
72
73
|
excludeEntrypoints: nonJsExportEntrypoints(pkg.json.exports),
|
|
73
74
|
});
|
|
74
|
-
if (!
|
|
75
|
+
if (!isAttwAnalysis(analysis) || analysis.types === false) {
|
|
75
76
|
return 0;
|
|
76
77
|
}
|
|
77
|
-
const
|
|
78
|
-
const problems = rawProblems.filter(isReportedAttwProblem);
|
|
78
|
+
const problems = (analysis.problems ?? []).filter(isReportedAttwProblem);
|
|
79
79
|
if (problems.length === 0) {
|
|
80
80
|
return 0;
|
|
81
81
|
}
|
|
@@ -85,10 +85,22 @@ async function validateAttw(root, pkg, packed) {
|
|
|
85
85
|
console.error(`${pkg.path}: are-the-types-wrong validation failed`);
|
|
86
86
|
return 1;
|
|
87
87
|
}
|
|
88
|
+
const isAttwAnalysis = (() => {
|
|
89
|
+
const _io0 = input => true && (undefined === input.problems || Array.isArray(input.problems));
|
|
90
|
+
return input => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
|
|
91
|
+
})();
|
|
92
|
+
const isAttwProblem = (() => {
|
|
93
|
+
const _io0 = input => "string" === typeof input.kind && (undefined === input.resolutionKind || "string" === typeof input.resolutionKind) && (undefined === input.entrypoint || "string" === typeof input.entrypoint);
|
|
94
|
+
return input => "object" === typeof input && null !== input && _io0(input);
|
|
95
|
+
})();
|
|
96
|
+
const isAttwCoreExport = (() => {
|
|
97
|
+
const _io0 = input => true && true;
|
|
98
|
+
return input => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
|
|
99
|
+
})();
|
|
88
100
|
async function loadAttwCore() {
|
|
89
101
|
const packageJson = fileURLToPath(import.meta.resolve('@arethetypeswrong/core/package.json'));
|
|
90
102
|
const core = await import(pathToFileURL(join(dirname(packageJson), 'dist', 'index.js')).href);
|
|
91
|
-
if (!
|
|
103
|
+
if (!isAttwCoreExport(core)) {
|
|
92
104
|
throw new Error('@arethetypeswrong/core does not expose the expected API');
|
|
93
105
|
}
|
|
94
106
|
const PackageConstructor = core.Package;
|
|
@@ -117,8 +129,8 @@ async function createAttwPackageFromTarball(attw, root, tarballPath) {
|
|
|
117
129
|
}
|
|
118
130
|
function createAttwPackageFromDirectory(attw, packageDir) {
|
|
119
131
|
const packageJson = readJsonFile(join(packageDir, 'package.json'));
|
|
120
|
-
const packageName =
|
|
121
|
-
const packageVersion =
|
|
132
|
+
const packageName = packageJson.name;
|
|
133
|
+
const packageVersion = packageJson.version;
|
|
122
134
|
if (!packageName || !packageVersion) {
|
|
123
135
|
throw new Error('packed package.json must contain name and version');
|
|
124
136
|
}
|
|
@@ -142,14 +154,14 @@ function collectAttwFiles(root, current, packageName, files) {
|
|
|
142
154
|
}
|
|
143
155
|
}
|
|
144
156
|
function readJsonFile(path) {
|
|
145
|
-
const parsed =
|
|
146
|
-
if (!
|
|
157
|
+
const parsed = parsePackageJsonText(readFileSync(path, 'utf8'));
|
|
158
|
+
if (!parsed) {
|
|
147
159
|
throw new Error(`${path} is not a JSON object`);
|
|
148
160
|
}
|
|
149
161
|
return parsed;
|
|
150
162
|
}
|
|
151
163
|
function isReportedAttwProblem(problem) {
|
|
152
|
-
if (!
|
|
164
|
+
if (!isAttwProblem(problem)) {
|
|
153
165
|
return false;
|
|
154
166
|
}
|
|
155
167
|
const flag = attwProblemFlag(problem.kind);
|
|
@@ -189,9 +201,6 @@ function attwProblemFlag(kind) {
|
|
|
189
201
|
}
|
|
190
202
|
}
|
|
191
203
|
function formatProblemLocation(problem) {
|
|
192
|
-
if (!isRecord(problem)) {
|
|
193
|
-
return '';
|
|
194
|
-
}
|
|
195
204
|
const entrypoint = typeof problem.entrypoint === 'string' ? ` ${problem.entrypoint}` : '';
|
|
196
205
|
const resolution = typeof problem.resolutionKind === 'string' ? ` ${formatResolutionKind(problem.resolutionKind)}` : '';
|
|
197
206
|
return `${entrypoint}${resolution}`;
|
|
@@ -206,7 +215,7 @@ function formatResolutionKind(kind) {
|
|
|
206
215
|
return kind;
|
|
207
216
|
}
|
|
208
217
|
function nonJsExportEntrypoints(exports) {
|
|
209
|
-
if (
|
|
218
|
+
if (exports === null || exports === undefined || typeof exports === 'string') {
|
|
210
219
|
return [];
|
|
211
220
|
}
|
|
212
221
|
return Object.entries(exports)
|
|
@@ -219,7 +228,10 @@ function exportPointsToNonJs(value) {
|
|
|
219
228
|
// Existence of the target files is still validated by publint.
|
|
220
229
|
return value.endsWith('.wasm') || value.endsWith('.css');
|
|
221
230
|
}
|
|
222
|
-
|
|
231
|
+
if (value === null || value === undefined) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
return Object.values(value).some(exportPointsToNonJs);
|
|
223
235
|
}
|
|
224
236
|
async function packPackage(root, pkg) {
|
|
225
237
|
const packageDir = join(root, pkg.path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/monorepo/packs/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAsB,MAAM,mBAAmB,CAAC;AAK5E,OAAO,EAKL,KAAK,sBAAsB,EAO5B,MAAM,sBAAsB,CAAC;AAU9B,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAA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AE,cAAc,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAaxG"}
|
|
@@ -3,12 +3,12 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { printCommandOutput, runResult, runStatus } from '../../lib/run.js';
|
|
4
4
|
import { readProjectTargets } from '../../nx/index.js';
|
|
5
5
|
import { syncBunLockfileVersions, validateBunLockfileVersions } from '../lockfile.js';
|
|
6
|
-
import {
|
|
6
|
+
import { warnOnManagedFileDrift } from '../managed-files.js';
|
|
7
7
|
import { fixNxSync, validateNxSync } from '../nx-sync.js';
|
|
8
8
|
import { fixPackageHygiene, validatePackageHygiene } from '../package-hygiene.js';
|
|
9
9
|
import { applyFixableMonorepoDefaults, applyNxReleaseDefaults, applyPublicPackageDefaults, applyWorkspaceDependencyDefaults, validateNxProjectNames, validateNxReleaseConfig, validatePublicPackageMetadata, validatePublicTags, validateRootPackagePolicy, validateWorkspaceDependencies, } from '../package-policy.js';
|
|
10
10
|
import { validatePackedPublicPackageManifest, validatePackedPublicPackagePublint, validatePackedPublicPackageTypes, } from '../packed-package.js';
|
|
11
|
-
import { syncRootRuntimeVersions } from '../runtime.js';
|
|
11
|
+
import { syncRootRuntimeVersions, validateRootRuntimeVersions } from '../runtime.js';
|
|
12
12
|
import { applyToolConfigDefaults, validateToolConfig } from '../tool-validation.js';
|
|
13
13
|
import { applyWranglerDefaults, validateWrangler } from '../wrangler.js';
|
|
14
14
|
const packs = [
|
|
@@ -27,12 +27,21 @@ const packs = [
|
|
|
27
27
|
async fixPreBuild(ctx) {
|
|
28
28
|
applyFixableMonorepoDefaults(ctx.root);
|
|
29
29
|
await applyToolConfigDefaults(ctx.root);
|
|
30
|
-
|
|
30
|
+
// Install/CI alignment only — do not rewrite -next to stable tags here.
|
|
31
|
+
syncBunLockfileVersions(ctx.root, { mode: 'install' });
|
|
31
32
|
await fixNxSync(ctx.root, ctx.verbose === true);
|
|
32
33
|
applyWorkspaceDependencyDefaults(ctx.root, { resolvedTargetsByProject: await readResolvedTargetsByProject(ctx) });
|
|
33
34
|
},
|
|
34
35
|
async validatePreBuild(ctx) {
|
|
35
|
-
|
|
36
|
+
// Runtime pins validate against the live PATH runtimes (devenv shell),
|
|
37
|
+
// never a stored template — outside devenv the PATH is not authoritative,
|
|
38
|
+
// mirroring the init-time syncRuntime gate above.
|
|
39
|
+
const runtimeFailures = ctx.syncRuntime ? await validateRootRuntimeVersions(ctx.root) : 0;
|
|
40
|
+
// Managed-file drift is derived state (CLI template x pinned version) with
|
|
41
|
+
// its own remediation flow; it warns instead of failing so validation only
|
|
42
|
+
// blocks on actual package issues. See warnOnManagedFileDrift.
|
|
43
|
+
warnOnManagedFileDrift(ctx.root);
|
|
44
|
+
return (runtimeFailures +
|
|
36
45
|
validateRootPackagePolicy(ctx.root) +
|
|
37
46
|
validateToolConfig(ctx.root) +
|
|
38
47
|
validateNxProjectNames(ctx.root) +
|
|
@@ -326,7 +326,9 @@ function yamlLinesForStep(step, options) {
|
|
|
326
326
|
' "$GITHUB_OUTPUT"',
|
|
327
327
|
];
|
|
328
328
|
case PublishWorkflowStepKind.CheckManagedMonorepoFiles:
|
|
329
|
-
|
|
329
|
+
// Drift is derived state with its own remediation PR; publishing only
|
|
330
|
+
// blocks on actual package issues (smoo monorepo validate).
|
|
331
|
+
return conditionalRunStep(step, 'smoo monorepo check --warn');
|
|
330
332
|
case PublishWorkflowStepKind.Build:
|
|
331
333
|
return conditionalRunStep(step, `smoo github-ci nx-run-many --targets build --projects "${githubExpression('steps.version.outputs.projects')}"`);
|
|
332
334
|
case PublishWorkflowStepKind.Lint:
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
+
import { type PackageJson } from '../lib/json.js';
|
|
2
|
+
export interface RuntimeVersions {
|
|
3
|
+
node: string;
|
|
4
|
+
bun: string;
|
|
5
|
+
}
|
|
6
|
+
/** Live runtime versions from the shell PATH — the single source sync AND validate derive from. */
|
|
7
|
+
export declare function runtimeVersionsFromPath(root: string): Promise<RuntimeVersions>;
|
|
1
8
|
export declare function syncRootRuntimeVersions(root: string): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Validate that package.json runtime pins agree with the LIVE PATH runtimes,
|
|
11
|
+
* never a stored template. Offline by design: structural alignment only
|
|
12
|
+
* (majors, exact bun pin, no `~major.0.0` floor) — the registry is not
|
|
13
|
+
* consulted. Repair: `smoo monorepo init --runtime-only` inside the devenv shell.
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateRootRuntimeVersions(root: string): Promise<number>;
|
|
16
|
+
export declare function validateRuntimePins(packageJson: PackageJson, runtime: RuntimeVersions): number;
|
|
2
17
|
type RuntimeTypesPinMode = 'major' | 'exact';
|
|
3
18
|
export declare function runtimeTypesRangeForPublishedVersions(packageName: string, runtimeVersion: string, pinMode: RuntimeTypesPinMode, versions: readonly string[]): string;
|
|
4
19
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/monorepo/runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/monorepo/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,WAAW,EAMjB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,mGAAmG;AACnG,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAOpF;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCzE;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO/E;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAmC9F;AAED,KAAK,mBAAmB,GAAG,OAAO,GAAG,OAAO,CAAC;AAgB7C,wBAAgB,qCAAqC,CACnD,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,MAAM,CA2BR"}
|
package/dist/monorepo/runtime.js
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { $ } from 'bun';
|
|
4
|
-
import {
|
|
4
|
+
import { ensureDependencyMap, ensureEngines, parseStringArrayText, readJsonObject, setPackageStringField, setStringProperty, writeJsonObject, } from '../lib/json.js';
|
|
5
|
+
/** Live runtime versions from the shell PATH — the single source sync AND validate derive from. */
|
|
6
|
+
export async function runtimeVersionsFromPath(root) {
|
|
7
|
+
const node = runtimeCommand(root, 'node');
|
|
8
|
+
const bun = runtimeCommand(root, 'bun');
|
|
9
|
+
return {
|
|
10
|
+
node: (await $ `${node} --version`.cwd(root).text()).trim().replace(/^v/, ''),
|
|
11
|
+
bun: (await $ `${bun} --version`.cwd(root).text()).trim(),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
5
14
|
export async function syncRootRuntimeVersions(root) {
|
|
6
15
|
const packageJsonPath = join(root, 'package.json');
|
|
7
16
|
const packageJson = readJsonObject(packageJsonPath);
|
|
8
17
|
if (!packageJson) {
|
|
9
18
|
throw new Error('package.json not found or invalid');
|
|
10
19
|
}
|
|
11
|
-
const node =
|
|
12
|
-
const bun = runtimeCommand(root, 'bun');
|
|
13
|
-
const nodeVersion = (await $ `${node} --version`.cwd(root).text()).trim().replace(/^v/, '');
|
|
14
|
-
const bunVersion = (await $ `${bun} --version`.cwd(root).text()).trim();
|
|
20
|
+
const { node: nodeVersion, bun: bunVersion } = await runtimeVersionsFromPath(root);
|
|
15
21
|
const nodeMajor = nodeVersion.split('.', 1)[0];
|
|
16
22
|
if (!nodeMajor) {
|
|
17
23
|
throw new Error(`Unable to derive Node major version from ${nodeVersion}`);
|
|
18
24
|
}
|
|
19
25
|
let changed = false;
|
|
20
|
-
const engines =
|
|
26
|
+
const engines = ensureEngines(packageJson);
|
|
21
27
|
changed = setStringProperty(engines, 'node', `>=${nodeMajor}.0.0`) || changed;
|
|
22
|
-
changed =
|
|
23
|
-
const devDependencies =
|
|
28
|
+
changed = setPackageStringField(packageJson, 'packageManager', `bun@${bunVersion}`) || changed;
|
|
29
|
+
const devDependencies = ensureDependencyMap(packageJson, 'devDependencies');
|
|
24
30
|
changed =
|
|
25
31
|
setStringProperty(devDependencies, '@types/node', await runtimeTypesRange(root, '@types/node', nodeVersion, 'major')) || changed;
|
|
26
32
|
changed =
|
|
@@ -30,10 +36,53 @@ export async function syncRootRuntimeVersions(root) {
|
|
|
30
36
|
console.log('updated package.json runtime versions');
|
|
31
37
|
}
|
|
32
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Validate that package.json runtime pins agree with the LIVE PATH runtimes,
|
|
41
|
+
* never a stored template. Offline by design: structural alignment only
|
|
42
|
+
* (majors, exact bun pin, no `~major.0.0` floor) — the registry is not
|
|
43
|
+
* consulted. Repair: `smoo monorepo init --runtime-only` inside the devenv shell.
|
|
44
|
+
*/
|
|
45
|
+
export async function validateRootRuntimeVersions(root) {
|
|
46
|
+
const packageJson = readJsonObject(join(root, 'package.json'));
|
|
47
|
+
if (!packageJson) {
|
|
48
|
+
console.error('package.json not found or invalid');
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
return validateRuntimePins(packageJson, await runtimeVersionsFromPath(root));
|
|
52
|
+
}
|
|
53
|
+
export function validateRuntimePins(packageJson, runtime) {
|
|
54
|
+
const nodeMajor = runtime.node.split('.', 1)[0];
|
|
55
|
+
if (!nodeMajor) {
|
|
56
|
+
throw new Error(`Unable to derive Node major version from ${runtime.node}`);
|
|
57
|
+
}
|
|
58
|
+
let failures = 0;
|
|
59
|
+
const repair = 'run `smoo monorepo init --runtime-only` inside the devenv shell';
|
|
60
|
+
const enginesNode = packageJson.engines?.node ?? null;
|
|
61
|
+
if (enginesNode !== `>=${nodeMajor}.0.0`) {
|
|
62
|
+
console.error(`package.json engines.node is ${enginesNode ?? 'missing'} but the PATH node is v${runtime.node} — expected >=${nodeMajor}.0.0; ${repair}`);
|
|
63
|
+
failures++;
|
|
64
|
+
}
|
|
65
|
+
const packageManager = packageJson.packageManager ?? null;
|
|
66
|
+
if (packageManager !== `bun@${runtime.bun}`) {
|
|
67
|
+
console.error(`package.json packageManager is ${packageManager ?? 'missing'} but the PATH bun is ${runtime.bun} — expected bun@${runtime.bun}; ${repair}`);
|
|
68
|
+
failures++;
|
|
69
|
+
}
|
|
70
|
+
const typesNode = packageJson.devDependencies?.['@types/node'] ?? null;
|
|
71
|
+
const typesNodeParts = typesNode ? /^~(\d+)\.(\d+)\.(\d+)$/.exec(typesNode) : null;
|
|
72
|
+
if (!typesNodeParts || typesNodeParts[1] !== nodeMajor) {
|
|
73
|
+
console.error(`package.json @types/node is ${typesNode ?? 'missing'} but the PATH node is v${runtime.node} — types track the runtime major (~${nodeMajor}.x.y, newest published minor); ${repair}`);
|
|
74
|
+
failures++;
|
|
75
|
+
}
|
|
76
|
+
else if (typesNodeParts[2] === '0' && typesNodeParts[3] === '0') {
|
|
77
|
+
console.error(`package.json @types/node is pinned to the ~${nodeMajor}.0.0 floor — tilde locks the first patch line and strands the repo on early broken releases; ${repair} to repin to the newest published ${nodeMajor}.x`);
|
|
78
|
+
failures++;
|
|
79
|
+
}
|
|
80
|
+
return failures;
|
|
81
|
+
}
|
|
33
82
|
async function runtimeTypesRange(root, packageName, runtimeVersion, pinMode) {
|
|
34
83
|
const versionsText = await $ `bun pm view ${packageName} versions --json`.cwd(root).text();
|
|
35
|
-
const versions =
|
|
36
|
-
if (!
|
|
84
|
+
const versions = parseStringArrayText(versionsText);
|
|
85
|
+
if (!versions) {
|
|
37
86
|
throw new Error(`Unable to read published ${packageName} versions`);
|
|
38
87
|
}
|
|
39
88
|
return runtimeTypesRangeForPublishedVersions(packageName, runtimeVersion, pinMode, versions);
|
|
@@ -45,8 +94,13 @@ export function runtimeTypesRangeForPublishedVersions(packageName, runtimeVersio
|
|
|
45
94
|
}
|
|
46
95
|
if (pinMode === 'major') {
|
|
47
96
|
const runtimeMajor = parsedRuntimeVersion[0].toString();
|
|
48
|
-
|
|
49
|
-
|
|
97
|
+
// Newest published types WITHIN the runtime major — never the `~major.0.0`
|
|
98
|
+
// floor: tilde locks the patch line, so the floor can strand consumers on a
|
|
99
|
+
// broken early release (e.g. @types/node 24.0.x's URLPattern/DOM TS2403
|
|
100
|
+
// conflict, fixed in 24.13) with no path to the repaired minors.
|
|
101
|
+
const latestInMajor = latestVersion(versions.filter((version) => versionMajor(version) === runtimeMajor));
|
|
102
|
+
if (latestInMajor) {
|
|
103
|
+
return `~${latestInMajor}`;
|
|
50
104
|
}
|
|
51
105
|
}
|
|
52
106
|
else if (versions.includes(runtimeVersion)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-validation.d.ts","sourceRoot":"","sources":["../../src/monorepo/tool-validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-validation.d.ts","sourceRoot":"","sources":["../../src/monorepo/tool-validation.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,qBAAqB,CAAC;AAU9E,MAAM,WAAW,UAAU;IACzB,sBAAsB,EAAE,OAAO,CAAC;IAChC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,UAAU,CAAC;CACpB;AA0CD,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKzE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQvD;AAED,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBtG;AAoCD,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAkBlF;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAY/D;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CA0B7D;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,MAAM,CAyBvG;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAoB/E;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,MAAM,CAWhF;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB3D;AA0DD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAQzD"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
+
import typia from 'typia';
|
|
3
4
|
import { cliPackageVersion, isSmoothBricksCodebasePackageName } from '../lib/cli-package.js';
|
|
4
|
-
import {
|
|
5
|
+
import { ensureDependencyMap, readJsonObject, setPackageStringField, setStringProperty, writeJsonObject, } from '../lib/json.js';
|
|
5
6
|
import { readPackageJsonObject } from '../lib/workspace.js';
|
|
7
|
+
const isRegistryPackument = (() => {
|
|
8
|
+
const _io0 = input => "object" === typeof input.versions && null !== input.versions && false === Array.isArray(input.versions) && _io1(input.versions);
|
|
9
|
+
const _io1 = input => Object.keys(input).every(key => {
|
|
10
|
+
const value = input[key];
|
|
11
|
+
if (undefined === value)
|
|
12
|
+
return true;
|
|
13
|
+
return true;
|
|
14
|
+
});
|
|
15
|
+
return input => "object" === typeof input && null !== input && _io0(input);
|
|
16
|
+
})();
|
|
6
17
|
const rootDevDependencies = [
|
|
7
18
|
{ name: '@biomejs/biome', fallbackVersion: '^2.3.5', minimumVersion: '2.3.0', prefix: '^' },
|
|
8
19
|
{ name: '@nx/js', fallbackVersion: '23.1.0', minimumVersion: '23.1.0' },
|
|
@@ -24,13 +35,17 @@ const rootDevDependencies = [
|
|
|
24
35
|
{ name: 'nx', fallbackVersion: '23.1.0', minimumVersion: '23.1.0' },
|
|
25
36
|
{ name: 'prettier', fallbackVersion: '^3.6.1', minimumVersion: '3.6.0', prefix: '^' },
|
|
26
37
|
{ name: 'ttsc', fallbackVersion: '^0.18.4', minimumVersion: '0.18.4', prefix: '^' },
|
|
27
|
-
// Nx and typescript-eslint still load the TypeScript
|
|
38
|
+
// Nx and typescript-eslint still load the TypeScript JS API (6.x).
|
|
28
39
|
// Compilation is exclusively delegated to ttsc by the Nx plugin targets.
|
|
29
40
|
{ name: 'typescript', fallbackVersion: '^5.9.3', minimumVersion: '5.9.0', prefix: '^' },
|
|
30
41
|
];
|
|
31
42
|
const cliPackageName = '@smoothbricks/cli';
|
|
32
43
|
const requiredDevenvPackages = ['bun', 'git', 'git-format-staged', 'jq', 'alejandra', 'coreutils', 'gnutar'];
|
|
33
|
-
|
|
44
|
+
// Any explicit nodejs provider is fine — the pinned major is the repo's choice
|
|
45
|
+
// (Lambda parity, org convergence, …). Whether the pins in package.json agree
|
|
46
|
+
// with the runtime is validated against the live PATH (validateRootRuntimeVersions),
|
|
47
|
+
// never against a version template here.
|
|
48
|
+
const nodePackagePattern = /(^|\s)nodejs(_\d+|_latest)?(\s|#|$)/m;
|
|
34
49
|
export async function applyToolConfigDefaults(root) {
|
|
35
50
|
const context = readToolContext(root);
|
|
36
51
|
await applyRootPackageToolDefaults(root, context);
|
|
@@ -50,7 +65,7 @@ export async function applyRootDevDependencyDefaults(root, context) {
|
|
|
50
65
|
return;
|
|
51
66
|
}
|
|
52
67
|
let changed = false;
|
|
53
|
-
const devDependencies =
|
|
68
|
+
const devDependencies = ensureDependencyMap(pkg, 'devDependencies');
|
|
54
69
|
for (const dependency of rootDevDependencies) {
|
|
55
70
|
const current = devDependencies[dependency.name];
|
|
56
71
|
if (typeof current !== 'string' || !satisfiesDependencyPolicy(context.policy, current, dependency)) {
|
|
@@ -76,7 +91,7 @@ async function applyRootPackageToolDefaults(root, context) {
|
|
|
76
91
|
}
|
|
77
92
|
let dependencyChanged = false;
|
|
78
93
|
let workspaceChanged = false;
|
|
79
|
-
const devDependencies =
|
|
94
|
+
const devDependencies = ensureDependencyMap(pkg, 'devDependencies');
|
|
80
95
|
for (const dependency of rootDevDependencies) {
|
|
81
96
|
const current = devDependencies[dependency.name];
|
|
82
97
|
if (typeof current !== 'string' || !satisfiesDependencyPolicy(context.policy, current, dependency)) {
|
|
@@ -102,12 +117,12 @@ export function applyToolingPackageDefaults(root, policy) {
|
|
|
102
117
|
const path = join(root, 'tooling', 'package.json');
|
|
103
118
|
const pkg = readJsonObject(path) ?? { name: policy.toolingPackageName, private: true, dependencies: {} };
|
|
104
119
|
let changed = false;
|
|
105
|
-
changed =
|
|
120
|
+
changed = setPackageStringField(pkg, 'name', policy.toolingPackageName) || changed;
|
|
106
121
|
if (pkg.private !== true) {
|
|
107
122
|
pkg.private = true;
|
|
108
123
|
changed = true;
|
|
109
124
|
}
|
|
110
|
-
const dependencies =
|
|
125
|
+
const dependencies = ensureDependencyMap(pkg, 'dependencies');
|
|
111
126
|
changed = setStringProperty(dependencies, cliPackageName, policy.cliDependencyRange) || changed;
|
|
112
127
|
if (changed || !existsSync(path)) {
|
|
113
128
|
mkdirSync(dirname(path), { recursive: true });
|
|
@@ -139,7 +154,7 @@ export function applyDevenvPackageDefaults(root) {
|
|
|
139
154
|
}
|
|
140
155
|
let content = readFileSync(path, 'utf8');
|
|
141
156
|
let changed = false;
|
|
142
|
-
if (!
|
|
157
|
+
if (!nodePackagePattern.test(content)) {
|
|
143
158
|
const next = addNixPackage(content, 'nodejs_latest', '# Node.js for workspace tooling');
|
|
144
159
|
changed = next !== content || changed;
|
|
145
160
|
content = next;
|
|
@@ -166,7 +181,7 @@ export function validateRootDevDependencies(policy, rootPackage) {
|
|
|
166
181
|
console.error('package.json not found or invalid');
|
|
167
182
|
return 1;
|
|
168
183
|
}
|
|
169
|
-
const devDependencies =
|
|
184
|
+
const devDependencies = pkg.devDependencies;
|
|
170
185
|
let failures = 0;
|
|
171
186
|
for (const dependency of rootDevDependencies) {
|
|
172
187
|
const version = devDependencies?.[dependency.name];
|
|
@@ -192,9 +207,9 @@ export function validateToolingPackage(root, policy) {
|
|
|
192
207
|
console.error('tooling/package.json not found or invalid');
|
|
193
208
|
return 1;
|
|
194
209
|
}
|
|
195
|
-
const dependencies =
|
|
210
|
+
const dependencies = pkg.dependencies;
|
|
196
211
|
let failures = 0;
|
|
197
|
-
const actualName =
|
|
212
|
+
const actualName = pkg.name ?? null;
|
|
198
213
|
if (actualName !== policy.toolingPackageName) {
|
|
199
214
|
console.error(`tooling/package.json name must be ${policy.toolingPackageName}`);
|
|
200
215
|
failures++;
|
|
@@ -226,8 +241,8 @@ export function validateDevenvPackages(root) {
|
|
|
226
241
|
}
|
|
227
242
|
const content = readFileSync(path, 'utf8');
|
|
228
243
|
let failures = 0;
|
|
229
|
-
if (!
|
|
230
|
-
console.error(
|
|
244
|
+
if (!nodePackagePattern.test(content)) {
|
|
245
|
+
console.error('tooling/direnv/devenv.nix packages must include a nodejs provider (nodejs_<major> or nodejs_latest)');
|
|
231
246
|
failures++;
|
|
232
247
|
}
|
|
233
248
|
for (const name of requiredDevenvPackages) {
|
|
@@ -291,14 +306,14 @@ function formatExpectedDependency(policy, dependency) {
|
|
|
291
306
|
export function readToolContext(root) {
|
|
292
307
|
const rootPackage = readPackageJsonObject(join(root, 'package.json'));
|
|
293
308
|
const toolingPackage = readJsonObject(join(root, 'tooling', 'package.json'));
|
|
294
|
-
const configuredCliRange =
|
|
309
|
+
const configuredCliRange = toolingPackage?.dependencies?.[cliPackageName];
|
|
295
310
|
return {
|
|
296
311
|
rootPackage,
|
|
297
312
|
policy: toolPolicy(rootPackage, typeof configuredCliRange === 'string' ? configuredCliRange : null),
|
|
298
313
|
};
|
|
299
314
|
}
|
|
300
315
|
function toolPolicy(rootPackage, configuredCliRange) {
|
|
301
|
-
const name =
|
|
316
|
+
const name = rootPackage?.name ?? null;
|
|
302
317
|
const isCodebase = isSmoothBricksCodebasePackageName(name ?? undefined);
|
|
303
318
|
const toolingName = toolingPackageName(name);
|
|
304
319
|
// A locally linked prerelease can be newer than every published CLI. Keep an existing
|
|
@@ -375,12 +390,6 @@ function latestVersionInSameMajorMinor(versions, minimum) {
|
|
|
375
390
|
function compareVersions(left, right) {
|
|
376
391
|
return left.major - right.major || left.minor - right.minor || left.patch - right.patch;
|
|
377
392
|
}
|
|
378
|
-
function isRegistryPackument(value) {
|
|
379
|
-
return typeof value === 'object' && value !== null && 'versions' in value && isObjectRecord(value.versions);
|
|
380
|
-
}
|
|
381
|
-
function isObjectRecord(value) {
|
|
382
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
383
|
-
}
|
|
384
393
|
function stripRangePrefix(version) {
|
|
385
394
|
return version.replace(/^[~^]/, '');
|
|
386
395
|
}
|
|
@@ -393,7 +402,7 @@ function addWorkspacePattern(pkg, pattern) {
|
|
|
393
402
|
workspaces.push(pattern);
|
|
394
403
|
return true;
|
|
395
404
|
}
|
|
396
|
-
if (
|
|
405
|
+
if (workspaces && Array.isArray(workspaces.packages)) {
|
|
397
406
|
if (workspaces.packages.includes(pattern)) {
|
|
398
407
|
return false;
|
|
399
408
|
}
|
|
@@ -408,5 +417,5 @@ function hasWorkspacePattern(pkg, pattern) {
|
|
|
408
417
|
if (Array.isArray(workspaces)) {
|
|
409
418
|
return workspaces.includes(pattern);
|
|
410
419
|
}
|
|
411
|
-
return
|
|
420
|
+
return Boolean(workspaces && Array.isArray(workspaces.packages) && workspaces.packages.includes(pattern));
|
|
412
421
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler.d.ts","sourceRoot":"","sources":["../../src/monorepo/wrangler.ts"],"names":[],"mappings":"AAaA,4HAA4H;AAC5H,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhE;
|
|
1
|
+
{"version":3,"file":"wrangler.d.ts","sourceRoot":"","sources":["../../src/monorepo/wrangler.ts"],"names":[],"mappings":"AAaA,4HAA4H;AAC5H,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhE;AAmCD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAiDxD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA+BrD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { join
|
|
3
|
-
import {
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { ensureNx, ensureNxTargets, writeJsonObject } from '../lib/json.js';
|
|
4
4
|
import { getWorkspacePackageManifests } from '../lib/workspace.js';
|
|
5
5
|
/** First `[env.<name>]` header in a wrangler.toml, or `null` when the config declares no envs (top-level bindings only). */
|
|
6
6
|
export function firstWranglerEnv(tomlText) {
|
|
@@ -10,13 +10,14 @@ export function firstWranglerEnv(tomlText) {
|
|
|
10
10
|
function wranglerProjects(root) {
|
|
11
11
|
const projects = [];
|
|
12
12
|
for (const pkg of getWorkspacePackageManifests(root)) {
|
|
13
|
-
const
|
|
13
|
+
const dir = join(root, pkg.path);
|
|
14
|
+
const tomlPath = join(dir, 'wrangler.toml');
|
|
14
15
|
if (!existsSync(tomlPath)) {
|
|
15
16
|
continue;
|
|
16
17
|
}
|
|
17
18
|
projects.push({
|
|
18
|
-
label:
|
|
19
|
-
dir
|
|
19
|
+
label: pkg.path || '.',
|
|
20
|
+
dir,
|
|
20
21
|
packageJsonPath: pkg.packageJsonPath,
|
|
21
22
|
json: pkg.json,
|
|
22
23
|
tomlPath,
|
|
@@ -44,8 +45,8 @@ export function applyWranglerDefaults(root) {
|
|
|
44
45
|
}
|
|
45
46
|
for (const project of projects) {
|
|
46
47
|
const env = firstWranglerEnv(readFileSync(project.tomlPath, 'utf8'));
|
|
47
|
-
const nx =
|
|
48
|
-
const targets =
|
|
48
|
+
const nx = ensureNx(project.json);
|
|
49
|
+
const targets = ensureNxTargets(nx);
|
|
49
50
|
const desired = {
|
|
50
51
|
executor: 'nx:run-commands',
|
|
51
52
|
cache: true,
|
|
@@ -57,14 +58,14 @@ export function applyWranglerDefaults(root) {
|
|
|
57
58
|
},
|
|
58
59
|
};
|
|
59
60
|
let changed = false;
|
|
60
|
-
const existing =
|
|
61
|
+
const existing = targets['wrangler-types'];
|
|
61
62
|
if (!existing || JSON.stringify(existing) !== JSON.stringify(desired)) {
|
|
62
63
|
targets['wrangler-types'] = desired;
|
|
63
64
|
changed = true;
|
|
64
65
|
}
|
|
65
|
-
const typecheck =
|
|
66
|
+
const typecheck = targets.typecheck;
|
|
66
67
|
if (typecheck) {
|
|
67
|
-
const dependsOn = Array.isArray(typecheck.dependsOn) ? typecheck.dependsOn : [];
|
|
68
|
+
const dependsOn = Array.isArray(typecheck.dependsOn) ? [...typecheck.dependsOn] : [];
|
|
68
69
|
if (!dependsOn.includes('wrangler-types')) {
|
|
69
70
|
dependsOn.push('wrangler-types');
|
|
70
71
|
typecheck.dependsOn = dependsOn;
|
|
@@ -103,9 +104,8 @@ export function validateWrangler(root) {
|
|
|
103
104
|
console.log(`⨯ ${project.label}: missing .dev.vars.example`);
|
|
104
105
|
projectProblems++;
|
|
105
106
|
}
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
if (!targets || !recordProperty(targets, 'wrangler-types')) {
|
|
107
|
+
const targets = project.json.nx?.targets;
|
|
108
|
+
if (!targets?.['wrangler-types']) {
|
|
109
109
|
console.log(`⨯ ${project.label}: missing wrangler-types nx target`);
|
|
110
110
|
projectProblems++;
|
|
111
111
|
}
|
package/dist/nx/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NxProjectJson, type NxTargetConfig } from '../lib/json.js';
|
|
1
2
|
export interface ProjectTargets {
|
|
2
3
|
project: string;
|
|
3
4
|
root?: string;
|
|
@@ -15,13 +16,13 @@ export interface CommandInvocation {
|
|
|
15
16
|
export declare function nxResetCommand(): CommandInvocation;
|
|
16
17
|
export declare function nxShowProjectCommand(project: string): CommandInvocation;
|
|
17
18
|
export declare function nxCacheDirectories(root: string): string[];
|
|
18
|
-
export declare function targetNamesFromNxProjectJson(value:
|
|
19
|
-
export declare function projectRootFromNxProjectJson(value:
|
|
20
|
-
export declare function buildDependsOnFromNxProjectJson(value:
|
|
21
|
-
export declare function targetDependenciesFromNxProjectJson(value:
|
|
22
|
-
export declare function targetExecutorsFromNxProjectJson(value:
|
|
23
|
-
export declare function targetOutputsFromNxProjectJson(value:
|
|
24
|
-
export declare function targetScriptsFromNxProjectJson(value:
|
|
19
|
+
export declare function targetNamesFromNxProjectJson(value: NxProjectJson | null | undefined): string[];
|
|
20
|
+
export declare function projectRootFromNxProjectJson(value: NxProjectJson | null | undefined): string | undefined;
|
|
21
|
+
export declare function buildDependsOnFromNxProjectJson(value: NxProjectJson | null | undefined): string[] | undefined;
|
|
22
|
+
export declare function targetDependenciesFromNxProjectJson(value: NxProjectJson | null | undefined): Map<string, string[]>;
|
|
23
|
+
export declare function targetExecutorsFromNxProjectJson(value: NxProjectJson | null | undefined): Map<string, string>;
|
|
24
|
+
export declare function targetOutputsFromNxProjectJson(value: NxProjectJson | null | undefined): Map<string, string[]>;
|
|
25
|
+
export declare function targetScriptsFromNxProjectJson(value: NxProjectJson | null | undefined): Map<string, string>;
|
|
25
26
|
export declare function formatProjectTargetLines(projects: ProjectTargets[]): string;
|
|
26
27
|
export declare function projectNamesWithTarget(projects: ProjectTargets[], target: string): string[];
|
|
27
28
|
export declare function projectNamesFromNxShowProjectsOutput(output: string): string[];
|
|
@@ -32,4 +33,5 @@ export declare function listProjects(root: string, options: {
|
|
|
32
33
|
export declare function resetCache(root: string): Promise<void>;
|
|
33
34
|
export declare function cleanCache(root: string): Promise<void>;
|
|
34
35
|
export declare function readProjectTargets(root: string): Promise<ProjectTargets[]>;
|
|
36
|
+
export type { NxProjectJson, NxTargetConfig };
|
|
35
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/nx/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nx/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nx/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3C,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtC,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,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