@multiplatform.one/cli 8.0.0 → 8.2.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 +14 -8
- package/lib/bin/multiplatformOne.mjs +17 -11
- package/lib/commands/e2e.mjs +6 -15
- package/lib/commands/pythonTools.mjs +81 -0
- package/lib/commands/scaffold.mjs +62 -3
- package/lib/commands/verbs.mjs +55 -33
- package/lib/source.json +2 -2
- package/package.json +2 -2
- package/scripts/scaffold.sh +12 -0
- package/src/bin/multiplatformOne.ts +19 -13
- package/src/commands/e2e.ts +16 -21
- package/src/commands/pythonTools.spec.ts +134 -0
- package/src/commands/pythonTools.ts +106 -0
- package/src/commands/scaffold.ts +60 -3
- package/src/commands/updateCleanups.spec.ts +282 -0
- package/src/commands/verbs.spec.ts +94 -5
- package/src/commands/verbs.ts +57 -33
- package/types/commands/e2e.d.ts +1 -1
- package/types/commands/e2e.d.ts.map +1 -1
- package/types/commands/pythonTools.d.ts +22 -0
- package/types/commands/pythonTools.d.ts.map +1 -0
- package/types/commands/scaffold.d.ts +1 -1
- package/types/commands/scaffold.d.ts.map +1 -1
- package/types/commands/verbs.d.ts +2 -2
- package/types/commands/verbs.d.ts.map +1 -1
- package/lib/commands/ruff.mjs +0 -52
- package/src/commands/ruff.spec.ts +0 -46
- package/src/commands/ruff.ts +0 -74
- package/types/commands/ruff.d.ts +0 -15
- package/types/commands/ruff.d.ts.map +0 -1
|
@@ -4,6 +4,7 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { waitForMariaDB, waitServices } from "@multiplatform.one/utils/dev";
|
|
5
5
|
import nanoSpawn from "nano-spawn";
|
|
6
6
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
|
+
import { discoverE2EApp } from "./e2e";
|
|
7
8
|
import {
|
|
8
9
|
availableServices,
|
|
9
10
|
parseTestTiers,
|
|
@@ -49,6 +50,9 @@ const isTurboTest = (call: Call) =>
|
|
|
49
50
|
|
|
50
51
|
const benchCalls = (calls: Call[]) => calls.filter((call) => call.file === "bench");
|
|
51
52
|
|
|
53
|
+
const isTurboIntegration = (call: Call) =>
|
|
54
|
+
call.file === "pnpm" && call.args.slice(0, 3).join(" ") === "turbo run test:integration";
|
|
55
|
+
|
|
52
56
|
describe("mpo test tiers (FZ-10496)", () => {
|
|
53
57
|
let root: string;
|
|
54
58
|
|
|
@@ -86,17 +90,38 @@ describe("mpo test tiers (FZ-10496)", () => {
|
|
|
86
90
|
expect(benchCalls(calls)[0].cwd).toBe(join(root, "apps/frappe"));
|
|
87
91
|
});
|
|
88
92
|
|
|
89
|
-
it("
|
|
93
|
+
it("unit runs every app's turbo test, the e2e app's too (FZ-10556)", async () => {
|
|
94
|
+
write(
|
|
95
|
+
root,
|
|
96
|
+
"apps/one/package.json",
|
|
97
|
+
JSON.stringify({ name: "@platform/one", mpo: { e2e: true } }),
|
|
98
|
+
);
|
|
99
|
+
write(root, "apps/one/playwright.config.ts", "");
|
|
100
|
+
const { calls, spawn } = recorder();
|
|
101
|
+
await runUnitTests(root, spawn);
|
|
102
|
+
expect(calls).toEqual([{ file: "pnpm", args: ["turbo", "run", "test"], cwd: root }]);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("integration runs the turbo test:integration task, then the bench's integration tests (FZ-10556)", async () => {
|
|
90
106
|
plantBench(root, { bootstrapped: true });
|
|
91
107
|
const { calls, spawn } = recorder();
|
|
92
108
|
await runIntegrationTests(root, spawn);
|
|
93
109
|
expect(calls.filter(isTurboTest)).toEqual([]);
|
|
94
110
|
expect(calls.map((call) => [call.file, ...call.args])).toEqual([
|
|
111
|
+
["pnpm", "turbo", "run", "test:integration", "--continue"],
|
|
95
112
|
["bench", "run-tests", "--app", "core", "--", "-m", "integration"],
|
|
96
113
|
["bench", "run-tests", "--app", "live", "--", "-m", "integration"],
|
|
97
114
|
]);
|
|
98
115
|
});
|
|
99
116
|
|
|
117
|
+
it("a failed test:integration still runs the bench before integration fails (FZ-10556)", async () => {
|
|
118
|
+
plantBench(root, { bootstrapped: true });
|
|
119
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
120
|
+
const { calls, spawn } = recorder(isTurboIntegration);
|
|
121
|
+
await expect(runIntegrationTests(root, spawn)).rejects.toThrow(/exit code 1/);
|
|
122
|
+
expect(benchCalls(calls)).toHaveLength(2);
|
|
123
|
+
});
|
|
124
|
+
|
|
100
125
|
it("a bootstrapped bench that fails fails integration, after every app ran", async () => {
|
|
101
126
|
plantBench(root, { bootstrapped: true });
|
|
102
127
|
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
@@ -116,14 +141,78 @@ describe("mpo test tiers (FZ-10496)", () => {
|
|
|
116
141
|
);
|
|
117
142
|
});
|
|
118
143
|
|
|
119
|
-
it("a bench that is not bootstrapped
|
|
144
|
+
it("unit skips a bench that is not bootstrapped, with a note", async () => {
|
|
120
145
|
plantBench(root, { bootstrapped: false });
|
|
121
146
|
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
122
147
|
const { calls, spawn } = recorder();
|
|
123
|
-
await
|
|
124
|
-
expect(calls).toEqual([]);
|
|
148
|
+
await runUnitTests(root, spawn);
|
|
149
|
+
expect(benchCalls(calls)).toEqual([]);
|
|
125
150
|
expect(warn).toHaveBeenCalledWith(
|
|
126
|
-
'no frappe bench (apps/frappe/sites): skipped bench tests -m "integration"',
|
|
151
|
+
'no frappe bench (apps/frappe/sites): skipped bench tests -m "not integration"',
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("integration fails on a bench that is not bootstrapped, naming it (FZ-10556)", async () => {
|
|
156
|
+
plantBench(root, { bootstrapped: false });
|
|
157
|
+
const { calls, spawn } = recorder();
|
|
158
|
+
await expect(runIntegrationTests(root, spawn)).rejects.toThrow(
|
|
159
|
+
'no frappe bench (apps/frappe/sites): bench tests -m "integration" need one',
|
|
160
|
+
);
|
|
161
|
+
expect(benchCalls(calls)).toEqual([]);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("integration with no frappe apps runs only test:integration", async () => {
|
|
165
|
+
const { calls, spawn } = recorder();
|
|
166
|
+
await runIntegrationTests(root, spawn);
|
|
167
|
+
expect(calls.map((call) => [call.file, ...call.args])).toEqual([
|
|
168
|
+
["pnpm", "turbo", "run", "test:integration", "--continue"],
|
|
169
|
+
]);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe("the e2e app (FZ-10556)", () => {
|
|
174
|
+
let root: string;
|
|
175
|
+
|
|
176
|
+
beforeEach(() => {
|
|
177
|
+
root = mkdtempSync(join(tmpdir(), "mpo-e2e-app-spec-"));
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
afterEach(() => {
|
|
181
|
+
rmSync(root, { recursive: true, force: true });
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("is the app whose package.json names it, not the first with a playwright config", async () => {
|
|
185
|
+
write(root, "apps/frappe/package.json", JSON.stringify({ name: "@service/frappe" }));
|
|
186
|
+
write(root, "apps/frappe/playwright.config.ts", "");
|
|
187
|
+
write(
|
|
188
|
+
root,
|
|
189
|
+
"apps/one/package.json",
|
|
190
|
+
JSON.stringify({ name: "@platform/one", mpo: { e2e: true } }),
|
|
191
|
+
);
|
|
192
|
+
write(root, "apps/one/playwright.config.ts", "");
|
|
193
|
+
expect(await discoverE2EApp(root)).toBe("one");
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("is none when no app names itself", async () => {
|
|
197
|
+
write(root, "apps/one/package.json", JSON.stringify({ name: "@platform/one" }));
|
|
198
|
+
write(root, "apps/one/playwright.config.ts", "");
|
|
199
|
+
expect(await discoverE2EApp(root)).toBeNull();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("refuses two apps that both name themselves", async () => {
|
|
203
|
+
write(
|
|
204
|
+
root,
|
|
205
|
+
"apps/one/package.json",
|
|
206
|
+
JSON.stringify({ name: "@platform/one", mpo: { e2e: true } }),
|
|
207
|
+
);
|
|
208
|
+
write(
|
|
209
|
+
root,
|
|
210
|
+
"apps/two/package.json",
|
|
211
|
+
JSON.stringify({ name: "@platform/two", mpo: { e2e: true } }),
|
|
212
|
+
);
|
|
213
|
+
await expect(discoverE2EApp(root)).rejects.toThrow(
|
|
214
|
+
'more than one app sets "mpo": { "e2e": true } in its package.json: one, two. ' +
|
|
215
|
+
"Keep it on the one app mpo test e2e should run and delete it from the others.",
|
|
127
216
|
);
|
|
128
217
|
});
|
|
129
218
|
});
|
package/src/commands/verbs.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
} from "@multiplatform.one/utils/dev";
|
|
11
11
|
import nanoSpawn from "nano-spawn";
|
|
12
12
|
import YAML from "yaml";
|
|
13
|
-
import { discoverE2EApp } from "./e2e";
|
|
14
13
|
|
|
15
14
|
type Spawn = typeof nanoSpawn;
|
|
16
15
|
|
|
@@ -79,33 +78,36 @@ async function getTurboExcludeFiltersForMissing(root: string): Promise<string[]>
|
|
|
79
78
|
return filters;
|
|
80
79
|
}
|
|
81
80
|
|
|
81
|
+
type FrappeEntry = string | { name?: string; source?: string };
|
|
82
|
+
type FrappeApp = { name: string; absolutePath: string };
|
|
83
|
+
|
|
84
|
+
function frappeEntryName(entry: FrappeEntry): { src: string; name: string } | undefined {
|
|
85
|
+
if (typeof entry === "string") return { src: entry, name: path.basename(entry) };
|
|
86
|
+
if (!entry.source || !entry.name) return undefined;
|
|
87
|
+
return { src: entry.source, name: entry.name };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function resolveFrappeApp(frappeDir: string, entry: FrappeEntry): FrappeApp | undefined {
|
|
91
|
+
const named = frappeEntryName(entry);
|
|
92
|
+
if (!named) return undefined;
|
|
93
|
+
const src = named.src.startsWith("file://") ? named.src.slice(7) : named.src;
|
|
94
|
+
if (!src.startsWith("./") && !src.startsWith("../") && !src.startsWith("/")) return undefined;
|
|
95
|
+
const absolutePath = path.isAbsolute(src) ? src : path.resolve(frappeDir, src);
|
|
96
|
+
if (!fsSync.existsSync(absolutePath)) return undefined;
|
|
97
|
+
return { name: named.name, absolutePath };
|
|
98
|
+
}
|
|
99
|
+
|
|
82
100
|
/** Discover frappe apps from frappe.yaml that have local source paths.
|
|
83
101
|
* Supports both string entries (`- ./apps/core`) and object entries (`- name: core\n source: ./apps/core`). */
|
|
84
|
-
async function getFrappeApps(root: string): Promise<
|
|
102
|
+
async function getFrappeApps(root: string): Promise<FrappeApp[]> {
|
|
85
103
|
const frappeDir = path.join(root, "apps", "frappe");
|
|
86
104
|
const frappeYamlPath = path.join(frappeDir, "frappe.yaml");
|
|
87
105
|
if (!fsSync.existsSync(frappeYamlPath)) return [];
|
|
88
106
|
const raw = await fs.readFile(frappeYamlPath, "utf8");
|
|
89
|
-
const config = YAML.parse(raw) as { apps?:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
let name: string;
|
|
94
|
-
if (typeof app === "string") {
|
|
95
|
-
src = app;
|
|
96
|
-
name = path.basename(app);
|
|
97
|
-
} else {
|
|
98
|
-
if (!app.source || !app.name) continue;
|
|
99
|
-
src = app.source;
|
|
100
|
-
name = app.name;
|
|
101
|
-
}
|
|
102
|
-
src = src.startsWith("file://") ? src.slice(7) : src;
|
|
103
|
-
if (!src.startsWith("./") && !src.startsWith("../") && !src.startsWith("/")) continue;
|
|
104
|
-
const absPath = path.isAbsolute(src) ? src : path.resolve(frappeDir, src);
|
|
105
|
-
if (!fsSync.existsSync(absPath)) continue;
|
|
106
|
-
out.push({ name, absolutePath: absPath });
|
|
107
|
-
}
|
|
108
|
-
return out;
|
|
107
|
+
const config = YAML.parse(raw) as { apps?: FrappeEntry[] };
|
|
108
|
+
return (config?.apps ?? [])
|
|
109
|
+
.map((entry) => resolveFrappeApp(frappeDir, entry))
|
|
110
|
+
.filter((app): app is FrappeApp => app !== undefined);
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
export const testTiers = ["unit", "integration", "e2e", "visual"] as const;
|
|
@@ -126,15 +128,24 @@ export function parseTestTiers(args: string[]): TestTier[] {
|
|
|
126
128
|
/**
|
|
127
129
|
* `bench run-tests` for every frappe app with a pyproject.toml, limited to the
|
|
128
130
|
* pytest marker expression. Skipped when the bench is not bootstrapped
|
|
129
|
-
* (no apps/frappe/sites)
|
|
131
|
+
* (no apps/frappe/sites), or failed when `required`; once it is, any app
|
|
132
|
+
* whose run fails fails the tier.
|
|
130
133
|
*/
|
|
131
|
-
async function runBenchTests(
|
|
134
|
+
async function runBenchTests(
|
|
135
|
+
projectRoot: string,
|
|
136
|
+
marker: string,
|
|
137
|
+
spawn: Spawn,
|
|
138
|
+
required: boolean,
|
|
139
|
+
): Promise<void> {
|
|
132
140
|
const benchDir = path.join(projectRoot, "apps", "frappe");
|
|
133
141
|
const apps = (await getFrappeApps(projectRoot)).filter((app) =>
|
|
134
142
|
fsSync.existsSync(path.join(app.absolutePath, "pyproject.toml")),
|
|
135
143
|
);
|
|
136
144
|
if (!apps.length) return;
|
|
137
145
|
if (!fsSync.existsSync(path.join(benchDir, "sites"))) {
|
|
146
|
+
if (required) {
|
|
147
|
+
throw new Error(`no frappe bench (apps/frappe/sites): bench tests -m "${marker}" need one`);
|
|
148
|
+
}
|
|
138
149
|
console.warn(`no frappe bench (apps/frappe/sites): skipped bench tests -m "${marker}"`);
|
|
139
150
|
return;
|
|
140
151
|
}
|
|
@@ -155,28 +166,41 @@ async function runBenchTests(projectRoot: string, marker: string, spawn: Spawn):
|
|
|
155
166
|
}
|
|
156
167
|
}
|
|
157
168
|
|
|
158
|
-
/** The unit tier: turbo test minus missing services
|
|
169
|
+
/** The unit tier: turbo test minus missing services, then the bench's non-integration tests. */
|
|
159
170
|
export async function runUnitTests(projectRoot: string, spawn: Spawn = nanoSpawn): Promise<void> {
|
|
160
171
|
const excludeFilters = await getTurboExcludeFiltersForMissing(projectRoot);
|
|
161
|
-
const
|
|
162
|
-
const filters = [
|
|
163
|
-
...excludeFilters.flatMap((f) => ["--filter", f]),
|
|
164
|
-
...(e2eApp ? ["--filter", `'!./apps/${e2eApp}'`] : []),
|
|
165
|
-
];
|
|
172
|
+
const filters = excludeFilters.flatMap((f) => ["--filter", f]);
|
|
166
173
|
await spawn("pnpm", ["turbo", "run", "test", ...filters], {
|
|
167
174
|
stdio: "inherit",
|
|
168
175
|
shell: true,
|
|
169
176
|
cwd: projectRoot,
|
|
170
177
|
});
|
|
171
|
-
await runBenchTests(projectRoot, "not integration", spawn);
|
|
178
|
+
await runBenchTests(projectRoot, "not integration", spawn, false);
|
|
172
179
|
}
|
|
173
180
|
|
|
174
|
-
/** The integration tier: the bench's integration-marked tests
|
|
181
|
+
/** The integration tier: turbo test:integration, then the bench's integration-marked tests; a missing service fails it. */
|
|
175
182
|
export async function runIntegrationTests(
|
|
176
183
|
projectRoot: string,
|
|
177
184
|
spawn: Spawn = nanoSpawn,
|
|
178
185
|
): Promise<void> {
|
|
179
|
-
await
|
|
186
|
+
const excludeFilters = await getTurboExcludeFiltersForMissing(projectRoot);
|
|
187
|
+
const filters = excludeFilters.flatMap((f) => ["--filter", f]);
|
|
188
|
+
const failures: string[] = [];
|
|
189
|
+
try {
|
|
190
|
+
await spawn("pnpm", ["turbo", "run", "test:integration", "--continue", ...filters], {
|
|
191
|
+
stdio: "inherit",
|
|
192
|
+
shell: true,
|
|
193
|
+
cwd: projectRoot,
|
|
194
|
+
});
|
|
195
|
+
} catch (error) {
|
|
196
|
+
failures.push((error as Error).message);
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
await runBenchTests(projectRoot, "integration", spawn, true);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
failures.push((error as Error).message);
|
|
202
|
+
}
|
|
203
|
+
if (failures.length) throw new Error(failures.join("\n"));
|
|
180
204
|
}
|
|
181
205
|
|
|
182
206
|
/** `mpo build`: the packages, then every present app with a build script, each once. */
|
package/types/commands/e2e.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface E2EOptions {
|
|
|
6
6
|
noBuild?: boolean;
|
|
7
7
|
filter?: string;
|
|
8
8
|
}
|
|
9
|
-
/** Discover app
|
|
9
|
+
/** Discover the app whose package.json names it the e2e app (`"mpo": { "e2e": true }`), for E2E test cwd. Returns app name (e.g. "one") or null. */
|
|
10
10
|
export declare function discoverE2EApp(projectRoot: string): Promise<string | null>;
|
|
11
11
|
export declare function detectServices(projectRoot: string): Promise<string[]>;
|
|
12
12
|
export declare function generateCompose(services: string[], portOffset: number, projectRoot: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e2e.d.ts","sourceRoot":"","sources":["../../src/commands/e2e.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAmDD,
|
|
1
|
+
{"version":3,"file":"e2e.d.ts","sourceRoot":"","sources":["../../src/commands/e2e.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAmDD,oJAAoJ;AACpJ,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAehF;AAED,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAkB3E;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAAE,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAsBR;AAiHD,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA+G3F"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import nanoSpawn from "nano-spawn";
|
|
2
|
+
export type PythonMode = "format" | "check";
|
|
3
|
+
type Spawn = typeof nanoSpawn;
|
|
4
|
+
type Tool = "black" | "black --check" | "basedpyright";
|
|
5
|
+
/** Why `uv --version` did not answer, as one line for the lint output. */
|
|
6
|
+
export declare function uvStartFailure(error: unknown): string;
|
|
7
|
+
/** Why a tool failed once uv had started it, as one line for the lint output. */
|
|
8
|
+
export declare function toolFailure(tool: Tool, error: unknown): string;
|
|
9
|
+
/**
|
|
10
|
+
* The Python files git knows under `cwd`, tracked or untracked and not
|
|
11
|
+
* ignored, that are still on disk: the set CI's frappe/lint job checks.
|
|
12
|
+
*/
|
|
13
|
+
export declare function pythonFiles(cwd: string, spawn?: Spawn): Promise<string[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Run black, or black --check then basedpyright, on `files` through the uv
|
|
16
|
+
* project at `cwd`, first proving uv starts and the lock is there, so a missing
|
|
17
|
+
* install or project is reported as that instead of as a lint failure. Returns
|
|
18
|
+
* the reasons it failed, one per line, or undefined when it passed.
|
|
19
|
+
*/
|
|
20
|
+
export declare function runPythonTools(mode: PythonMode, files: readonly string[], cwd: string, spawn?: Spawn): Promise<string | undefined>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=pythonTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pythonTools.d.ts","sourceRoot":"","sources":["../../src/commands/pythonTools.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE5C,KAAK,KAAK,GAAG,OAAO,SAAS,CAAC;AAE9B,KAAK,IAAI,GAAG,OAAO,GAAG,eAAe,GAAG,cAAc,CAAC;AA2BvD,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKrD;AAED,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAU9D;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,KAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQ1F;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,KAAiB,GACvB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAwB7B"}
|
|
@@ -27,7 +27,7 @@ export declare class ScaffoldError extends Error {
|
|
|
27
27
|
constructor(message: string, request: ScaffoldRequest);
|
|
28
28
|
}
|
|
29
29
|
/** Run scaffold.sh and return the provenance it wrote. */
|
|
30
|
-
export declare function runScaffold(request: ScaffoldRequest): Promise<MpoProvenance>;
|
|
30
|
+
export declare function runScaffold(request: ScaffoldRequest, script?: string): Promise<MpoProvenance>;
|
|
31
31
|
export interface TempScaffold {
|
|
32
32
|
dir: string;
|
|
33
33
|
provenance: MpoProvenance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/commands/scaffold.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3E,oFAAoF;AACpF,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,uCAAuC;IACvC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe;CAItD;AAcD,0DAA0D;AAC1D,wBAAsB,WAAW,
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/commands/scaffold.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3E,oFAAoF;AACpF,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,uCAAuC;IACvC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe;CAItD;AAcD,0DAA0D;AAC1D,wBAAsB,WAAW,CAC/B,OAAO,EAAE,eAAe,EACxB,MAAM,SAAmB,GACxB,OAAO,CAAC,aAAa,CAAC,CA2BxB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,aAAa,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAmDD,kDAAkD;AAClD,wBAAsB,cAAc,CAClC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,MAAM,CAAC,GAChD,OAAO,CAAC,YAAY,CAAC,CAgBvB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -6,9 +6,9 @@ export declare const testTiers: readonly ["unit", "integration", "e2e", "visual"
|
|
|
6
6
|
export type TestTier = (typeof testTiers)[number];
|
|
7
7
|
/** The tiers `mpo test` was asked for (comma or space separated); unit when none is named. */
|
|
8
8
|
export declare function parseTestTiers(args: string[]): TestTier[];
|
|
9
|
-
/** The unit tier: turbo test minus missing services
|
|
9
|
+
/** The unit tier: turbo test minus missing services, then the bench's non-integration tests. */
|
|
10
10
|
export declare function runUnitTests(projectRoot: string, spawn?: Spawn): Promise<void>;
|
|
11
|
-
/** The integration tier: the bench's integration-marked tests
|
|
11
|
+
/** The integration tier: turbo test:integration, then the bench's integration-marked tests; a missing service fails it. */
|
|
12
12
|
export declare function runIntegrationTests(projectRoot: string, spawn?: Spawn): Promise<void>;
|
|
13
13
|
/** `mpo build`: the packages, then every present app with a build script, each once. */
|
|
14
14
|
export declare function runBuild(args: string[], projectRoot: string, spawn?: Spawn): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verbs.d.ts","sourceRoot":"","sources":["../../src/commands/verbs.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,WAAW,EAKjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,SAAS,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"verbs.d.ts","sourceRoot":"","sources":["../../src/commands/verbs.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,WAAW,EAKjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,SAAS,MAAM,YAAY,CAAC;AAGnC,KAAK,KAAK,GAAG,OAAO,SAAS,CAAC;AAE9B,eAAO,MAAM,iBAAiB,UAA0C,CAAC;AAiGzE,eAAO,MAAM,SAAS,mDAAoD,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD,8FAA8F;AAC9F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAQzD;AA2CD,gGAAgG;AAChG,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,GAAE,KAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAS/F;AAED,2HAA2H;AAC3H,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,KAAiB,GACvB,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED,wFAAwF;AACxF,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EAAE,EACd,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,KAAiB,GACvB,OAAO,CAAC,IAAI,CAAC,CA4Cf;AAED,sFAAsF;AACtF,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,KAAiB,GACvB,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,0GAA0G;AAC1G,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EAAE,EACd,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,KAAiB,GACvB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,0DAA0D;AAC1D,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAKlF,CAAC"}
|
package/lib/commands/ruff.mjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import spawn from "nano-spawn";
|
|
2
|
-
|
|
3
|
-
//#region src/commands/ruff.ts
|
|
4
|
-
const pinHint = "ruff is pinned in .tool-versions; `make configure` installs it through mise or asdf";
|
|
5
|
-
function errorDetail(error) {
|
|
6
|
-
const e = error ?? {};
|
|
7
|
-
return {
|
|
8
|
-
code: e.cause?.code,
|
|
9
|
-
exitCode: e.exitCode,
|
|
10
|
-
signalName: e.signalName,
|
|
11
|
-
stderr: e.stderr?.trim() || void 0,
|
|
12
|
-
message: e.cause?.message ?? e.message ?? String(error)
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/** Why `ruff --version` did not answer, as one line for the lint output. */
|
|
16
|
-
function ruffStartFailure(error) {
|
|
17
|
-
const d = errorDetail(error);
|
|
18
|
-
if (d.code === "ENOENT") return `ruff is not on PATH. ${pinHint}.`;
|
|
19
|
-
return `ruff did not start: ${d.stderr ?? d.message}. ${pinHint}.`;
|
|
20
|
-
}
|
|
21
|
-
/** Why `ruff <mode>` failed once it had started, as one line for the lint output. */
|
|
22
|
-
function ruffRunFailure(mode, target, error) {
|
|
23
|
-
const d = errorDetail(error);
|
|
24
|
-
if (d.signalName) return `ruff ${mode} was killed by ${d.signalName}.`;
|
|
25
|
-
if (d.exitCode === 1 && mode === "check") return `ruff check found problems in ${target} (listed above).`;
|
|
26
|
-
if (d.exitCode !== void 0) return `ruff ${mode} exited ${d.exitCode}, a configuration or usage error (see above).`;
|
|
27
|
-
return `ruff ${mode} failed: ${d.message}.`;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Run ruff format or check on `target`, first proving ruff starts so a missing
|
|
31
|
-
* or broken install is reported as that instead of as a lint failure. Returns
|
|
32
|
-
* the reason it failed, or undefined when it passed.
|
|
33
|
-
*/
|
|
34
|
-
async function runRuff(mode, target, cwd, spawn$1 = spawn) {
|
|
35
|
-
try {
|
|
36
|
-
await spawn$1("ruff", ["--version"], { cwd });
|
|
37
|
-
} catch (error) {
|
|
38
|
-
return ruffStartFailure(error);
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
await spawn$1("ruff", [mode, target], {
|
|
42
|
-
stdio: "inherit",
|
|
43
|
-
cwd
|
|
44
|
-
});
|
|
45
|
-
return;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
return ruffRunFailure(mode, target, error);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
export { ruffRunFailure, ruffStartFailure, runRuff };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import nanoSpawn from "nano-spawn";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { runRuff } from "./ruff";
|
|
4
|
-
|
|
5
|
-
type Spawn = typeof nanoSpawn;
|
|
6
|
-
|
|
7
|
-
// Runs a real subprocess in place of ruff, so the errors are nano-spawn's own.
|
|
8
|
-
function standIn(script: (args: readonly string[]) => string): Spawn {
|
|
9
|
-
return ((_file: string, args: readonly string[] = [], options = {}) =>
|
|
10
|
-
nanoSpawn("sh", ["-c", script(args)], options)) as Spawn;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
describe("runRuff (MPO-497)", () => {
|
|
14
|
-
it("names a missing ruff and the pin that provides it", async () => {
|
|
15
|
-
const missing = ((_file: string, args: readonly string[] = [], options = {}) =>
|
|
16
|
-
nanoSpawn("mpo-497-no-such-ruff", [...args], options)) as Spawn;
|
|
17
|
-
const reason = await runRuff("check", "apps/frappe/apps", process.cwd(), missing);
|
|
18
|
-
expect(reason).toMatch(/^ruff is not on PATH\./);
|
|
19
|
-
expect(reason).toContain(".tool-versions");
|
|
20
|
-
expect(reason).toContain("make configure");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("reports a ruff that will not start with what it printed", async () => {
|
|
24
|
-
const shim = standIn(() => "echo 'mise ERROR No version is set for shim: ruff' >&2; exit 1");
|
|
25
|
-
const reason = await runRuff("check", "apps/frappe/apps", process.cwd(), shim);
|
|
26
|
-
expect(reason).toBe(
|
|
27
|
-
"ruff did not start: mise ERROR No version is set for shim: ruff. ruff is pinned in .tool-versions; `make configure` installs it through mise or asdf.",
|
|
28
|
-
);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("separates findings from a configuration error", async () => {
|
|
32
|
-
const findings = standIn((args) => (args[0] === "--version" ? "true" : "exit 1"));
|
|
33
|
-
expect(await runRuff("check", "apps/frappe/apps", process.cwd(), findings)).toBe(
|
|
34
|
-
"ruff check found problems in apps/frappe/apps (listed above).",
|
|
35
|
-
);
|
|
36
|
-
const broken = standIn((args) => (args[0] === "--version" ? "true" : "exit 2"));
|
|
37
|
-
expect(await runRuff("check", "apps/frappe/apps", process.cwd(), broken)).toBe(
|
|
38
|
-
"ruff check exited 2, a configuration or usage error (see above).",
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("passes when ruff starts and exits 0", async () => {
|
|
43
|
-
const clean = standIn(() => "true");
|
|
44
|
-
expect(await runRuff("check", "apps/frappe/apps", process.cwd(), clean)).toBeUndefined();
|
|
45
|
-
});
|
|
46
|
-
});
|
package/src/commands/ruff.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import nanoSpawn from "nano-spawn";
|
|
2
|
-
|
|
3
|
-
export type RuffMode = "format" | "check";
|
|
4
|
-
|
|
5
|
-
type Spawn = typeof nanoSpawn;
|
|
6
|
-
|
|
7
|
-
const pinHint =
|
|
8
|
-
"ruff is pinned in .tool-versions; `make configure` installs it through mise or asdf";
|
|
9
|
-
|
|
10
|
-
function errorDetail(error: unknown): {
|
|
11
|
-
code?: string;
|
|
12
|
-
exitCode?: number;
|
|
13
|
-
signalName?: string;
|
|
14
|
-
stderr?: string;
|
|
15
|
-
message: string;
|
|
16
|
-
} {
|
|
17
|
-
const e = (error ?? {}) as {
|
|
18
|
-
cause?: { code?: string; message?: string };
|
|
19
|
-
exitCode?: number;
|
|
20
|
-
signalName?: string;
|
|
21
|
-
stderr?: string;
|
|
22
|
-
message?: string;
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
code: e.cause?.code,
|
|
26
|
-
exitCode: e.exitCode,
|
|
27
|
-
signalName: e.signalName,
|
|
28
|
-
stderr: e.stderr?.trim() || undefined,
|
|
29
|
-
message: e.cause?.message ?? e.message ?? String(error),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** Why `ruff --version` did not answer, as one line for the lint output. */
|
|
34
|
-
export function ruffStartFailure(error: unknown): string {
|
|
35
|
-
const d = errorDetail(error);
|
|
36
|
-
if (d.code === "ENOENT") return `ruff is not on PATH. ${pinHint}.`;
|
|
37
|
-
const why = d.stderr ?? d.message;
|
|
38
|
-
return `ruff did not start: ${why}. ${pinHint}.`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Why `ruff <mode>` failed once it had started, as one line for the lint output. */
|
|
42
|
-
export function ruffRunFailure(mode: RuffMode, target: string, error: unknown): string {
|
|
43
|
-
const d = errorDetail(error);
|
|
44
|
-
if (d.signalName) return `ruff ${mode} was killed by ${d.signalName}.`;
|
|
45
|
-
if (d.exitCode === 1 && mode === "check")
|
|
46
|
-
return `ruff check found problems in ${target} (listed above).`;
|
|
47
|
-
if (d.exitCode !== undefined)
|
|
48
|
-
return `ruff ${mode} exited ${d.exitCode}, a configuration or usage error (see above).`;
|
|
49
|
-
return `ruff ${mode} failed: ${d.message}.`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Run ruff format or check on `target`, first proving ruff starts so a missing
|
|
54
|
-
* or broken install is reported as that instead of as a lint failure. Returns
|
|
55
|
-
* the reason it failed, or undefined when it passed.
|
|
56
|
-
*/
|
|
57
|
-
export async function runRuff(
|
|
58
|
-
mode: RuffMode,
|
|
59
|
-
target: string,
|
|
60
|
-
cwd: string,
|
|
61
|
-
spawn: Spawn = nanoSpawn,
|
|
62
|
-
): Promise<string | undefined> {
|
|
63
|
-
try {
|
|
64
|
-
await spawn("ruff", ["--version"], { cwd });
|
|
65
|
-
} catch (error) {
|
|
66
|
-
return ruffStartFailure(error);
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
await spawn("ruff", [mode, target], { stdio: "inherit", cwd });
|
|
70
|
-
return undefined;
|
|
71
|
-
} catch (error) {
|
|
72
|
-
return ruffRunFailure(mode, target, error);
|
|
73
|
-
}
|
|
74
|
-
}
|
package/types/commands/ruff.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import nanoSpawn from "nano-spawn";
|
|
2
|
-
export type RuffMode = "format" | "check";
|
|
3
|
-
type Spawn = typeof nanoSpawn;
|
|
4
|
-
/** Why `ruff --version` did not answer, as one line for the lint output. */
|
|
5
|
-
export declare function ruffStartFailure(error: unknown): string;
|
|
6
|
-
/** Why `ruff <mode>` failed once it had started, as one line for the lint output. */
|
|
7
|
-
export declare function ruffRunFailure(mode: RuffMode, target: string, error: unknown): string;
|
|
8
|
-
/**
|
|
9
|
-
* Run ruff format or check on `target`, first proving ruff starts so a missing
|
|
10
|
-
* or broken install is reported as that instead of as a lint failure. Returns
|
|
11
|
-
* the reason it failed, or undefined when it passed.
|
|
12
|
-
*/
|
|
13
|
-
export declare function runRuff(mode: RuffMode, target: string, cwd: string, spawn?: Spawn): Promise<string | undefined>;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=ruff.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ruff.d.ts","sourceRoot":"","sources":["../../src/commands/ruff.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1C,KAAK,KAAK,GAAG,OAAO,SAAS,CAAC;AA4B9B,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKvD;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAQrF;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,KAAiB,GACvB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAY7B"}
|