@smoothbricks/nx-plugin 0.6.3-0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -121
- package/dist/.build-inputs.json +25 -20
- package/dist/bin/smoo-nx-go-test-build.d.ts +3 -0
- package/dist/bin/smoo-nx-go-test-build.d.ts.map +1 -0
- package/dist/bin/smoo-nx-go-test-build.js +79 -0
- package/dist/bin/smoo-nx-go-test-run.d.ts +3 -0
- package/dist/bin/smoo-nx-go-test-run.d.ts.map +1 -0
- package/dist/bin/smoo-nx-go-test-run.js +129 -0
- package/dist/bounded-test-policy.d.ts +1 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +9 -8
- package/dist/cargo-workspace.d.ts +10 -20
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +12 -22
- package/dist/cross-check-policy.d.ts +2 -2
- package/dist/cross-check-policy.js +2 -2
- package/dist/deploy-policy.d.ts +6 -0
- package/dist/deploy-policy.d.ts.map +1 -1
- package/dist/deploy-policy.js +11 -0
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +49 -37
- package/dist/executors/bounded-exec/mbx-pool.d.ts +39 -10
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +78 -24
- package/dist/executors/bounded-exec/progress.js +5 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts +40 -2
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +55 -4
- package/dist/executors/bounded-exec/runtime-pin.js +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +6 -0
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +6 -0
- package/dist/executors/wrangler-deploy/deploy-hash.d.ts +10 -0
- package/dist/executors/wrangler-deploy/deploy-hash.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/deploy-hash.js +14 -0
- package/dist/executors/wrangler-deploy/executor.d.ts +24 -0
- package/dist/executors/wrangler-deploy/executor.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/executor.js +43 -0
- package/dist/executors/wrangler-deploy/hasher.d.ts +27 -0
- package/dist/executors/wrangler-deploy/hasher.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/hasher.js +90 -0
- package/dist/executors/wrangler-deploy/schema.d.ts +5 -0
- package/dist/executors/wrangler-deploy/schema.d.ts.map +1 -0
- package/dist/go-tests.d.ts +30 -0
- package/dist/go-tests.d.ts.map +1 -0
- package/dist/go-tests.js +43 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -230
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +5 -0
- package/dist/process-group.js +2 -2
- package/dist/runtime-input-policy.d.ts +3 -3
- package/dist/runtime-input-policy.js +3 -3
- package/dist/test-timings.d.ts +23 -4
- package/dist/test-timings.d.ts.map +1 -1
- package/dist/test-timings.js +72 -12
- package/dist/version-actions.cjs +10 -11
- package/dist/version-actions.d.cts.map +1 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +17 -22
- package/dist/workspace-manifest.js +3 -3
- package/executors.json +6 -5
- package/managed/raw/patches/nx@23.2.1.patch +118 -24
- package/managed/raw/patches/ttsc@0.34.1.patch +64 -0
- package/managed/raw/tooling/direnv/developer-links.ts +121 -51
- package/managed/raw/tooling/direnv/installed-bun-links.ts +7 -6
- package/managed/raw/tooling/direnv/setup-environment.ts +14 -4
- package/managed/raw/tooling/git-hooks/pinned-revisions-served.ts +252 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +34 -32
- package/package.json +57 -7
- package/runtime/nx-publish/.build-inputs.json +11 -0
- package/runtime-input.sh +50 -23
- package/src/bin/smoo-nx-go-test-build.ts +83 -0
- package/src/bin/smoo-nx-go-test-run.ts +140 -0
- package/src/bounded-test-policy.ts +9 -8
- package/src/cargo-workspace.ts +12 -24
- package/src/cross-check-policy.ts +2 -2
- package/src/deploy-policy.ts +11 -0
- package/src/executors/bounded-exec/executor.ts +61 -42
- package/src/executors/bounded-exec/mbx-pool.ts +97 -33
- package/src/executors/bounded-exec/progress.ts +5 -5
- package/src/executors/bounded-exec/runner-sizing.ts +73 -7
- package/src/executors/bounded-exec/runtime-pin.ts +1 -1
- package/src/executors/bounded-exec/verdict.ts +7 -0
- package/src/executors/wrangler-deploy/deploy-hash.ts +15 -0
- package/src/executors/wrangler-deploy/executor.ts +63 -0
- package/src/executors/wrangler-deploy/hasher.ts +111 -0
- package/src/executors/wrangler-deploy/schema.json +16 -0
- package/src/executors/wrangler-deploy/schema.ts +4 -0
- package/src/go-tests.ts +67 -0
- package/src/index.ts +294 -253
- package/src/managed-files/files.ts +5 -0
- package/src/process-group.ts +2 -2
- package/src/runtime-input-policy.ts +3 -3
- package/src/test-timings.ts +72 -14
- package/src/version-actions.cts +10 -11
- package/src/workspace-config-policy.ts +20 -29
- package/src/workspace-manifest.ts +3 -3
- package/test-timings.json +131 -130
- package/dist/executors/clean-outputs/executor.d.ts +0 -26
- package/dist/executors/clean-outputs/executor.d.ts.map +0 -1
- package/dist/executors/clean-outputs/executor.js +0 -83
- package/dist/executors/clean-outputs/schema.d.ts +0 -4
- package/dist/executors/clean-outputs/schema.d.ts.map +0 -1
- package/src/executors/clean-outputs/executor.ts +0 -131
- package/src/executors/clean-outputs/schema.json +0 -15
- package/src/executors/clean-outputs/schema.ts +0 -3
- /package/dist/executors/{clean-outputs → wrangler-deploy}/schema.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/clean-outputs/executor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE;QACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;KACrC,CAAC;CACH;AAED,UAAU,kBAAkB;IAC1B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CAClD;AAED,wBAA8B,oBAAoB,CAChD,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CA8B7B;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,MAAM,EAAE,CAOX"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { rm } from 'node:fs/promises';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
export default async function cleanOutputsExecutor(options, context) {
|
|
5
|
-
const projectName = context.projectName;
|
|
6
|
-
if (!projectName) {
|
|
7
|
-
throw new Error('@smoothbricks/nx-plugin:clean-outputs requires a project context.');
|
|
8
|
-
}
|
|
9
|
-
const workspaceRoot = context.root;
|
|
10
|
-
const project = context.projectsConfigurations?.projects[projectName];
|
|
11
|
-
if (!project) {
|
|
12
|
-
throw new Error(`Project ${projectName} was not found in the Nx project graph.`);
|
|
13
|
-
}
|
|
14
|
-
const outputDirs = resolveOutputDirs({
|
|
15
|
-
outputs: options.outputs ?? project.targets?.build?.outputs ?? ['{projectRoot}/dist'],
|
|
16
|
-
projectName,
|
|
17
|
-
projectRoot: project.root ?? '.',
|
|
18
|
-
workspaceRoot,
|
|
19
|
-
});
|
|
20
|
-
for (const outputDir of outputDirs) {
|
|
21
|
-
assertSafeOutputDir(outputDir, project.root ?? '.', workspaceRoot);
|
|
22
|
-
if (containsTrackedFiles(outputDir, workspaceRoot)) {
|
|
23
|
-
console.log(`skipped ${path.relative(workspaceRoot, outputDir)} (contains tracked files)`);
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
await rm(outputDir, { force: true, recursive: true });
|
|
27
|
-
console.log(`removed ${path.relative(workspaceRoot, outputDir)}`);
|
|
28
|
-
}
|
|
29
|
-
return { success: true };
|
|
30
|
-
}
|
|
31
|
-
export function resolveOutputDirs(options) {
|
|
32
|
-
const concreteOutputDirs = options.outputs.map((output) => outputDir(output, options));
|
|
33
|
-
const dedupedOutputDirs = [...new Set(concreteOutputDirs)].sort((a, b) => a.length - b.length);
|
|
34
|
-
return dedupedOutputDirs.filter((candidate, index) => !dedupedOutputDirs.some((other, otherIndex) => otherIndex < index && isWithin(candidate, other)));
|
|
35
|
-
}
|
|
36
|
-
function outputDir(output, options) {
|
|
37
|
-
const interpolated = output
|
|
38
|
-
.replaceAll('{workspaceRoot}', '.')
|
|
39
|
-
.replaceAll('{projectRoot}', options.projectRoot)
|
|
40
|
-
.replaceAll('{projectName}', options.projectName);
|
|
41
|
-
const segments = interpolated.split(/[\\/]/);
|
|
42
|
-
const globIndex = segments.findIndex((segment) => segment.includes('*'));
|
|
43
|
-
const dirSegments = globIndex === -1 ? segments : segments.slice(0, globIndex);
|
|
44
|
-
const outputPath = dirSegments.join(path.sep);
|
|
45
|
-
return path.resolve(options.workspaceRoot, outputPath);
|
|
46
|
-
}
|
|
47
|
-
function assertSafeOutputDir(outputDir, projectRoot, workspaceRoot) {
|
|
48
|
-
const absoluteWorkspaceRoot = path.resolve(workspaceRoot);
|
|
49
|
-
const absoluteProjectRoot = path.resolve(workspaceRoot, projectRoot);
|
|
50
|
-
if (!isWithin(outputDir, absoluteWorkspaceRoot)) {
|
|
51
|
-
throw new Error(`Refusing to remove output outside workspace: ${outputDir}`);
|
|
52
|
-
}
|
|
53
|
-
if (outputDir === absoluteWorkspaceRoot || outputDir === absoluteProjectRoot) {
|
|
54
|
-
throw new Error(`Refusing to remove unsafe output directory: ${path.relative(workspaceRoot, outputDir) || '.'}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function isWithin(candidate, parent) {
|
|
58
|
-
const relative = path.relative(parent, candidate);
|
|
59
|
-
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
60
|
-
}
|
|
61
|
-
function containsTrackedFiles(outputDir, workspaceRoot) {
|
|
62
|
-
const relativeOutputDir = path.relative(workspaceRoot, outputDir);
|
|
63
|
-
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a local git file listing whose length is its own read of this repository: it asks no remote, and a held index.lock fails it at once rather than waiting, so only the operator's interrupt ends a hung one
|
|
64
|
-
const result = spawnSync('git', ['ls-files', '--', relativeOutputDir], {
|
|
65
|
-
cwd: workspaceRoot,
|
|
66
|
-
encoding: 'utf8',
|
|
67
|
-
});
|
|
68
|
-
const command = `git ls-files -- ${relativeOutputDir}`;
|
|
69
|
-
if (typeof result.stdout === 'string' && result.stdout.length > 0) {
|
|
70
|
-
process.stdout.write(result.stdout);
|
|
71
|
-
}
|
|
72
|
-
if (typeof result.stderr === 'string' && result.stderr.length > 0) {
|
|
73
|
-
process.stderr.write(result.stderr);
|
|
74
|
-
}
|
|
75
|
-
if (result.error) {
|
|
76
|
-
console.error(result.error.message);
|
|
77
|
-
throw new Error(`${command} failed with exit code ${result.status ?? 1}`, { cause: result.error });
|
|
78
|
-
}
|
|
79
|
-
if (result.status !== 0) {
|
|
80
|
-
throw new Error(`${command} failed with exit code ${result.status ?? 1}`);
|
|
81
|
-
}
|
|
82
|
-
return result.stdout.trim().length > 0;
|
|
83
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/clean-outputs/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { rm } from 'node:fs/promises';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
|
|
5
|
-
import type { CleanOutputsOptions } from './schema.js';
|
|
6
|
-
|
|
7
|
-
interface CleanOutputsContext {
|
|
8
|
-
root: string;
|
|
9
|
-
projectName?: string;
|
|
10
|
-
projectsConfigurations?: {
|
|
11
|
-
projects: Record<string, NxProject>;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface CleanOutputsResult {
|
|
16
|
-
success: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface NxProject {
|
|
20
|
-
root?: string;
|
|
21
|
-
targets?: Record<string, { outputs?: string[] }>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default async function cleanOutputsExecutor(
|
|
25
|
-
options: CleanOutputsOptions,
|
|
26
|
-
context: CleanOutputsContext,
|
|
27
|
-
): Promise<CleanOutputsResult> {
|
|
28
|
-
const projectName = context.projectName;
|
|
29
|
-
if (!projectName) {
|
|
30
|
-
throw new Error('@smoothbricks/nx-plugin:clean-outputs requires a project context.');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const workspaceRoot = context.root;
|
|
34
|
-
const project = context.projectsConfigurations?.projects[projectName];
|
|
35
|
-
if (!project) {
|
|
36
|
-
throw new Error(`Project ${projectName} was not found in the Nx project graph.`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const outputDirs = resolveOutputDirs({
|
|
40
|
-
outputs: options.outputs ?? project.targets?.build?.outputs ?? ['{projectRoot}/dist'],
|
|
41
|
-
projectName,
|
|
42
|
-
projectRoot: project.root ?? '.',
|
|
43
|
-
workspaceRoot,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
for (const outputDir of outputDirs) {
|
|
47
|
-
assertSafeOutputDir(outputDir, project.root ?? '.', workspaceRoot);
|
|
48
|
-
if (containsTrackedFiles(outputDir, workspaceRoot)) {
|
|
49
|
-
console.log(`skipped ${path.relative(workspaceRoot, outputDir)} (contains tracked files)`);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
await rm(outputDir, { force: true, recursive: true });
|
|
53
|
-
console.log(`removed ${path.relative(workspaceRoot, outputDir)}`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return { success: true };
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function resolveOutputDirs(options: {
|
|
60
|
-
outputs: string[];
|
|
61
|
-
projectName: string;
|
|
62
|
-
projectRoot: string;
|
|
63
|
-
workspaceRoot: string;
|
|
64
|
-
}): string[] {
|
|
65
|
-
const concreteOutputDirs = options.outputs.map((output) => outputDir(output, options));
|
|
66
|
-
const dedupedOutputDirs = [...new Set(concreteOutputDirs)].sort((a, b) => a.length - b.length);
|
|
67
|
-
return dedupedOutputDirs.filter(
|
|
68
|
-
(candidate, index) =>
|
|
69
|
-
!dedupedOutputDirs.some((other, otherIndex) => otherIndex < index && isWithin(candidate, other)),
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function outputDir(
|
|
74
|
-
output: string,
|
|
75
|
-
options: { projectName: string; projectRoot: string; workspaceRoot: string },
|
|
76
|
-
): string {
|
|
77
|
-
const interpolated = output
|
|
78
|
-
.replaceAll('{workspaceRoot}', '.')
|
|
79
|
-
.replaceAll('{projectRoot}', options.projectRoot)
|
|
80
|
-
.replaceAll('{projectName}', options.projectName);
|
|
81
|
-
|
|
82
|
-
const segments = interpolated.split(/[\\/]/);
|
|
83
|
-
const globIndex = segments.findIndex((segment) => segment.includes('*'));
|
|
84
|
-
const dirSegments = globIndex === -1 ? segments : segments.slice(0, globIndex);
|
|
85
|
-
const outputPath = dirSegments.join(path.sep);
|
|
86
|
-
|
|
87
|
-
return path.resolve(options.workspaceRoot, outputPath);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function assertSafeOutputDir(outputDir: string, projectRoot: string, workspaceRoot: string): void {
|
|
91
|
-
const absoluteWorkspaceRoot = path.resolve(workspaceRoot);
|
|
92
|
-
const absoluteProjectRoot = path.resolve(workspaceRoot, projectRoot);
|
|
93
|
-
|
|
94
|
-
if (!isWithin(outputDir, absoluteWorkspaceRoot)) {
|
|
95
|
-
throw new Error(`Refusing to remove output outside workspace: ${outputDir}`);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (outputDir === absoluteWorkspaceRoot || outputDir === absoluteProjectRoot) {
|
|
99
|
-
throw new Error(`Refusing to remove unsafe output directory: ${path.relative(workspaceRoot, outputDir) || '.'}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function isWithin(candidate: string, parent: string): boolean {
|
|
104
|
-
const relative = path.relative(parent, candidate);
|
|
105
|
-
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function containsTrackedFiles(outputDir: string, workspaceRoot: string): boolean {
|
|
109
|
-
const relativeOutputDir = path.relative(workspaceRoot, outputDir);
|
|
110
|
-
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a local git file listing whose length is its own read of this repository: it asks no remote, and a held index.lock fails it at once rather than waiting, so only the operator's interrupt ends a hung one
|
|
111
|
-
const result = spawnSync('git', ['ls-files', '--', relativeOutputDir], {
|
|
112
|
-
cwd: workspaceRoot,
|
|
113
|
-
encoding: 'utf8',
|
|
114
|
-
});
|
|
115
|
-
const command = `git ls-files -- ${relativeOutputDir}`;
|
|
116
|
-
if (typeof result.stdout === 'string' && result.stdout.length > 0) {
|
|
117
|
-
process.stdout.write(result.stdout);
|
|
118
|
-
}
|
|
119
|
-
if (typeof result.stderr === 'string' && result.stderr.length > 0) {
|
|
120
|
-
process.stderr.write(result.stderr);
|
|
121
|
-
}
|
|
122
|
-
if (result.error) {
|
|
123
|
-
console.error(result.error.message);
|
|
124
|
-
throw new Error(`${command} failed with exit code ${result.status ?? 1}`, { cause: result.error });
|
|
125
|
-
}
|
|
126
|
-
if (result.status !== 0) {
|
|
127
|
-
throw new Error(`${command} failed with exit code ${result.status ?? 1}`);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return result.stdout.trim().length > 0;
|
|
131
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/schema",
|
|
3
|
-
"version": 2,
|
|
4
|
-
"title": "Clean Outputs Executor",
|
|
5
|
-
"description": "Remove declared build output directories unless they contain tracked files.",
|
|
6
|
-
"type": "object",
|
|
7
|
-
"properties": {
|
|
8
|
-
"outputs": {
|
|
9
|
-
"type": "array",
|
|
10
|
-
"items": { "type": "string" },
|
|
11
|
-
"description": "Optional output patterns. Defaults to the project's build outputs, then {projectRoot}/dist."
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"additionalProperties": false
|
|
15
|
-
}
|
|
File without changes
|