@multiplatform.one/cli 7.90.6 → 8.1.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 +13 -7
- package/lib/commands/e2e.mjs +6 -15
- package/lib/commands/init.mjs +0 -2
- package/lib/commands/scaffold.mjs +62 -3
- package/lib/commands/verbs.mjs +31 -10
- package/lib/source.json +2 -2
- package/package.json +2 -2
- package/scripts/scaffold.sh +13 -1
- package/src/bin/multiplatformOne.ts +2 -2
- package/src/commands/e2e.ts +16 -21
- package/src/commands/init.ts +0 -2
- 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 +33 -12
- package/templates/AGENTS.md +3 -0
- package/templates/pieces/gnome/universal/apps/__NAME__/gnome/shims/components.ts +72 -11
- package/templates/pieces/gnome/universal/apps/__NAME__/gnome/shims/forms.ts +16 -24
- package/templates/pieces/gnome/universal/apps/__NAME__/gnome/shims/frappe-ui.ts +4 -3
- package/templates/pieces/gnome/universal/apps/__NAME__/gnome/shims/theme.ts +244 -20
- package/templates/pieces/gnome/universal/apps/__NAME__/vite.config.gnome.ts +16 -31
- package/types/commands/e2e.d.ts +1 -1
- package/types/commands/e2e.d.ts.map +1 -1
- package/types/commands/init.d.ts +1 -1
- package/types/commands/init.d.ts.map +1 -1
- 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
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import spawn from "nano-spawn";
|
|
5
|
+
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { addApp } from "./addApp";
|
|
7
|
+
import { init } from "./init";
|
|
8
|
+
import { readProvenance } from "./provenance";
|
|
9
|
+
import { scaffoldScript } from "./scaffold";
|
|
10
|
+
import { updateApp } from "./updateApp";
|
|
11
|
+
|
|
12
|
+
// A stand-in monorepo of five files, so a scaffold takes well under a second.
|
|
13
|
+
// Its scaffold.sh starts as this CLI's own, and a later commit teaches it a
|
|
14
|
+
// cleanup made up here. Nothing in update or add-app names that cleanup: it can
|
|
15
|
+
// only reach a project when each side of the merge runs the scaffold.sh its own
|
|
16
|
+
// commit carries.
|
|
17
|
+
const heavy = 300_000;
|
|
18
|
+
const json = (value: unknown) => `${JSON.stringify(value, null, 2)}\n`;
|
|
19
|
+
const ownScript = readFileSync(scaffoldScript(), "utf-8");
|
|
20
|
+
const anchor = "# ── 6. provenance";
|
|
21
|
+
|
|
22
|
+
const legacyRule = ".PHONY: legacy\nlegacy:\n\t@echo legacy\n\n";
|
|
23
|
+
const makefile = `.PHONY: build\nbuild:\n\t@echo build\n\n${legacyRule}.PHONY: test\ntest:\n\t@echo test\n`;
|
|
24
|
+
const cleaned = makefile.replace(legacyRule, "");
|
|
25
|
+
const dropLegacy = "sed_file \"$TREE/Makefile\" '/^\\.PHONY: legacy$/,/^$/d'";
|
|
26
|
+
|
|
27
|
+
/** The scaffold with `step` run just before it writes .mpo.json. */
|
|
28
|
+
function scaffoldWith(step: string): string {
|
|
29
|
+
if (!ownScript.includes(anchor)) throw new Error(`scaffold.sh has no "${anchor}" line`);
|
|
30
|
+
return ownScript.replace(anchor, `${step}\n\n${anchor}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function git(cwd: string, args: string[]): Promise<string> {
|
|
34
|
+
const result = await spawn("git", args, { cwd });
|
|
35
|
+
return result.stdout.trim();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function newRepo(dir: string): Promise<void> {
|
|
39
|
+
mkdirSync(dir, { recursive: true });
|
|
40
|
+
await git(dir, ["init", "--quiet", "--initial-branch=main"]);
|
|
41
|
+
await git(dir, ["config", "user.email", "spec@example.com"]);
|
|
42
|
+
await git(dir, ["config", "user.name", "Spec"]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function commitAll(dir: string, message: string): Promise<string> {
|
|
46
|
+
await git(dir, ["add", "-A"]);
|
|
47
|
+
await git(dir, ["commit", "--quiet", "-m", message]);
|
|
48
|
+
return git(dir, ["rev-parse", "HEAD"]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function writeFiles(dir: string, files: Record<string, string>): void {
|
|
52
|
+
for (const [file, content] of Object.entries(files)) {
|
|
53
|
+
mkdirSync(dirname(join(dir, file)), { recursive: true });
|
|
54
|
+
writeFileSync(join(dir, file), content);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A stand-in monorepo whose first commit carries `script` as its scaffold.sh. */
|
|
59
|
+
async function standIn(dir: string, script: string): Promise<string> {
|
|
60
|
+
await newRepo(dir);
|
|
61
|
+
// The url cases fetch commits by sha, as a project's base does from GitLab.
|
|
62
|
+
await git(dir, ["config", "uploadpack.allowFilter", "true"]);
|
|
63
|
+
await git(dir, ["config", "uploadpack.allowAnySHA1InWant", "true"]);
|
|
64
|
+
writeFiles(dir, {
|
|
65
|
+
"package.json": json({ name: "fixture", private: true }),
|
|
66
|
+
Makefile: makefile,
|
|
67
|
+
"apps/one/package.json": json({ name: "@platform/one", private: true }),
|
|
68
|
+
"public/cli/package.json": json({ name: "@multiplatform.one/cli", version: "1.0.0" }),
|
|
69
|
+
"public/cli/scripts/scaffold.sh": script,
|
|
70
|
+
});
|
|
71
|
+
return commitAll(dir, "chore: stand-in monorepo");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const read = (dir: string, file: string) => readFileSync(join(dir, file), "utf-8");
|
|
75
|
+
|
|
76
|
+
describe("mpo update runs the scaffold each commit carries", () => {
|
|
77
|
+
let sandbox: string;
|
|
78
|
+
let previousCwd: string;
|
|
79
|
+
let source: string;
|
|
80
|
+
let recorded: string;
|
|
81
|
+
let next: string;
|
|
82
|
+
|
|
83
|
+
beforeAll(async () => {
|
|
84
|
+
sandbox = mkdtempSync(join(tmpdir(), "mpo-update-cleanups-spec-"));
|
|
85
|
+
previousCwd = process.cwd();
|
|
86
|
+
source = join(sandbox, "source");
|
|
87
|
+
recorded = await standIn(source, ownScript);
|
|
88
|
+
writeFileSync(join(source, "public/cli/scripts/scaffold.sh"), scaffoldWith(dropLegacy));
|
|
89
|
+
next = await commitAll(source, "feat: the scaffold drops the legacy rule");
|
|
90
|
+
}, heavy);
|
|
91
|
+
|
|
92
|
+
afterEach(() => {
|
|
93
|
+
process.chdir(previousCwd);
|
|
94
|
+
vi.restoreAllMocks();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
afterAll(() => {
|
|
98
|
+
process.chdir(previousCwd);
|
|
99
|
+
rmSync(sandbox, { recursive: true, force: true });
|
|
100
|
+
}, heavy);
|
|
101
|
+
|
|
102
|
+
/** `mpo init` at the recorded commit, committed; optionally edited and committed again. */
|
|
103
|
+
async function project(
|
|
104
|
+
name: string,
|
|
105
|
+
edit?: (dir: string) => void,
|
|
106
|
+
from = { source, checkout: recorded },
|
|
107
|
+
): Promise<string> {
|
|
108
|
+
const parent = join(sandbox, name);
|
|
109
|
+
mkdirSync(parent);
|
|
110
|
+
process.chdir(parent);
|
|
111
|
+
await init("shop", {
|
|
112
|
+
...from,
|
|
113
|
+
services: [],
|
|
114
|
+
skipInstall: true,
|
|
115
|
+
skipGit: true,
|
|
116
|
+
yes: true,
|
|
117
|
+
});
|
|
118
|
+
const dir = join(parent, "shop");
|
|
119
|
+
await newRepo(dir);
|
|
120
|
+
await commitAll(dir, "feat: scaffold (mpo init)");
|
|
121
|
+
expect(read(dir, "Makefile")).toBe(makefile);
|
|
122
|
+
if (edit) {
|
|
123
|
+
edit(dir);
|
|
124
|
+
await commitAll(dir, "feat: the project's own edit");
|
|
125
|
+
}
|
|
126
|
+
process.chdir(dir);
|
|
127
|
+
return dir;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function expectQuietRerun(dir: string, from: string): Promise<void> {
|
|
131
|
+
const committed = await commitAll(dir, "chore: mpo update");
|
|
132
|
+
await updateApp({ source: from, skipInstall: true });
|
|
133
|
+
expect(await git(dir, ["rev-parse", "HEAD"])).toBe(committed);
|
|
134
|
+
expect(await git(dir, ["status", "--porcelain"])).toBe("");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
it(
|
|
138
|
+
"a cleanup added after the recorded commit leaves the project with the update",
|
|
139
|
+
async () => {
|
|
140
|
+
const dir = await project("untouched");
|
|
141
|
+
await updateApp({ source, skipInstall: true });
|
|
142
|
+
expect(read(dir, "Makefile")).toBe(cleaned);
|
|
143
|
+
expect(await git(dir, ["diff", "--cached", "--name-only"])).toBe("Makefile");
|
|
144
|
+
expect(readProvenance(dir)?.source?.sha).toBe(next);
|
|
145
|
+
await expectQuietRerun(dir, source);
|
|
146
|
+
},
|
|
147
|
+
heavy,
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
it(
|
|
151
|
+
"reads each commit's scaffold from a git url as well",
|
|
152
|
+
async () => {
|
|
153
|
+
const dir = await project("from-url");
|
|
154
|
+
const url = `file://${source}`;
|
|
155
|
+
await updateApp({ source: url, skipInstall: true });
|
|
156
|
+
expect(read(dir, "Makefile")).toBe(cleaned);
|
|
157
|
+
expect(readProvenance(dir)?.source?.sha).toBe(next);
|
|
158
|
+
await expectQuietRerun(dir, url);
|
|
159
|
+
},
|
|
160
|
+
heavy,
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
it(
|
|
164
|
+
"the project's own edit to that file survives the cleanup",
|
|
165
|
+
async () => {
|
|
166
|
+
const deploy = ".PHONY: deploy\ndeploy:\n\t@echo deploy\n";
|
|
167
|
+
const dir = await project("edited-elsewhere", (dir) => {
|
|
168
|
+
writeFileSync(join(dir, "Makefile"), `${makefile}\n${deploy}`);
|
|
169
|
+
});
|
|
170
|
+
await updateApp({ source, skipInstall: true });
|
|
171
|
+
expect(read(dir, "Makefile")).toBe(`${cleaned}\n${deploy}`);
|
|
172
|
+
await expectQuietRerun(dir, source);
|
|
173
|
+
},
|
|
174
|
+
heavy,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
it(
|
|
178
|
+
"an edit to the lines the cleanup drops is a conflict the user sees, not an overwrite",
|
|
179
|
+
async () => {
|
|
180
|
+
const dir = await project("edited-rule", (dir) => {
|
|
181
|
+
writeFileSync(
|
|
182
|
+
join(dir, "Makefile"),
|
|
183
|
+
makefile.replace("\t@echo legacy", "\t@echo legacy, kept by the project"),
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
const lines: string[] = [];
|
|
187
|
+
vi.spyOn(console, "log").mockImplementation((...args) => {
|
|
188
|
+
lines.push(args.join(" "));
|
|
189
|
+
});
|
|
190
|
+
await updateApp({ source, skipInstall: true });
|
|
191
|
+
const merged = read(dir, "Makefile");
|
|
192
|
+
expect(merged).toContain("<<<<<<<");
|
|
193
|
+
expect(merged).toContain("legacy, kept by the project");
|
|
194
|
+
expect(merged).toContain(">>>>>>>");
|
|
195
|
+
const warning = lines.findIndex((line) => line.includes("merge conflicts"));
|
|
196
|
+
expect(warning).toBeGreaterThan(-1);
|
|
197
|
+
expect(lines.slice(warning + 1)).toContain(" Makefile");
|
|
198
|
+
},
|
|
199
|
+
heavy,
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
it(
|
|
203
|
+
"a project that already dropped the rule is left as it is",
|
|
204
|
+
async () => {
|
|
205
|
+
const dir = await project("already-clean", (dir) => {
|
|
206
|
+
writeFileSync(join(dir, "Makefile"), cleaned);
|
|
207
|
+
});
|
|
208
|
+
await updateApp({ source, skipInstall: true });
|
|
209
|
+
expect(read(dir, "Makefile")).toBe(cleaned);
|
|
210
|
+
expect(await git(dir, ["diff", "--cached", "--name-only"])).toBe("");
|
|
211
|
+
expect(await git(dir, ["status", "--porcelain"])).toBe("M .mpo.json");
|
|
212
|
+
await expectQuietRerun(dir, source);
|
|
213
|
+
},
|
|
214
|
+
heavy,
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
it(
|
|
218
|
+
"a recorded commit that carries no scaffold.sh gets this CLI's, and update says so",
|
|
219
|
+
async () => {
|
|
220
|
+
const bare = join(sandbox, "bare-source");
|
|
221
|
+
await standIn(bare, ownScript);
|
|
222
|
+
rmSync(join(bare, "public/cli/scripts"), { recursive: true });
|
|
223
|
+
const old = await commitAll(bare, "chore: no scaffold.sh yet");
|
|
224
|
+
writeFiles(bare, { "public/cli/scripts/scaffold.sh": scaffoldWith(dropLegacy) });
|
|
225
|
+
await commitAll(bare, "feat: scaffold.sh, dropping the legacy rule");
|
|
226
|
+
const dir = await project("no-script", undefined, { source: bare, checkout: old });
|
|
227
|
+
const warnings: string[] = [];
|
|
228
|
+
vi.spyOn(console, "warn").mockImplementation((...args) => {
|
|
229
|
+
warnings.push(args.join(" "));
|
|
230
|
+
});
|
|
231
|
+
await updateApp({ source: bare, skipInstall: true });
|
|
232
|
+
expect(warnings).toContain(
|
|
233
|
+
`⚠️ ${old} carries no public/cli/scripts/scaffold.sh; using this CLI's for that side`,
|
|
234
|
+
);
|
|
235
|
+
expect(read(dir, "Makefile")).toBe(cleaned);
|
|
236
|
+
},
|
|
237
|
+
heavy,
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
describe("mpo add-app runs the scaffold at the recorded commit", () => {
|
|
242
|
+
let sandbox: string;
|
|
243
|
+
let previousCwd: string;
|
|
244
|
+
|
|
245
|
+
beforeAll(() => {
|
|
246
|
+
sandbox = mkdtempSync(join(tmpdir(), "mpo-add-app-scaffold-spec-"));
|
|
247
|
+
previousCwd = process.cwd();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
afterEach(() => {
|
|
251
|
+
process.chdir(previousCwd);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
afterAll(() => {
|
|
255
|
+
process.chdir(previousCwd);
|
|
256
|
+
rmSync(sandbox, { recursive: true, force: true });
|
|
257
|
+
}, heavy);
|
|
258
|
+
|
|
259
|
+
it(
|
|
260
|
+
"root wiring that scaffold writes per app follows the new app",
|
|
261
|
+
async () => {
|
|
262
|
+
// Root wiring this CLI's scaffold never writes: only the recorded
|
|
263
|
+
// commit's scaffold can add the new app to it.
|
|
264
|
+
const script = scaffoldWith(`printf 'apps:%s\\n' " $APPS" >"$TREE/apps.txt"`);
|
|
265
|
+
const source = join(sandbox, "source");
|
|
266
|
+
const recorded = await standIn(source, script);
|
|
267
|
+
const scriptFile = join(sandbox, "scaffold.sh");
|
|
268
|
+
writeFileSync(scriptFile, script);
|
|
269
|
+
const dir = join(sandbox, "shop");
|
|
270
|
+
await spawn("sh", [scriptFile, "--app", "shop", "--", source, recorded, dir]);
|
|
271
|
+
await newRepo(dir);
|
|
272
|
+
await commitAll(dir, "feat: scaffold");
|
|
273
|
+
expect(read(dir, "apps.txt")).toBe("apps: shop\n");
|
|
274
|
+
|
|
275
|
+
process.chdir(dir);
|
|
276
|
+
await addApp("kiosk", { source, skipInstall: true });
|
|
277
|
+
expect(read(dir, "apps.txt")).toBe("apps: shop kiosk\n");
|
|
278
|
+
expect(readProvenance(dir)?.apps).toEqual(["shop", "kiosk"]);
|
|
279
|
+
},
|
|
280
|
+
heavy,
|
|
281
|
+
);
|
|
282
|
+
});
|
|
@@ -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
|
|
|
@@ -126,15 +125,24 @@ export function parseTestTiers(args: string[]): TestTier[] {
|
|
|
126
125
|
/**
|
|
127
126
|
* `bench run-tests` for every frappe app with a pyproject.toml, limited to the
|
|
128
127
|
* pytest marker expression. Skipped when the bench is not bootstrapped
|
|
129
|
-
* (no apps/frappe/sites)
|
|
128
|
+
* (no apps/frappe/sites), or failed when `required`; once it is, any app
|
|
129
|
+
* whose run fails fails the tier.
|
|
130
130
|
*/
|
|
131
|
-
async function runBenchTests(
|
|
131
|
+
async function runBenchTests(
|
|
132
|
+
projectRoot: string,
|
|
133
|
+
marker: string,
|
|
134
|
+
spawn: Spawn,
|
|
135
|
+
required: boolean,
|
|
136
|
+
): Promise<void> {
|
|
132
137
|
const benchDir = path.join(projectRoot, "apps", "frappe");
|
|
133
138
|
const apps = (await getFrappeApps(projectRoot)).filter((app) =>
|
|
134
139
|
fsSync.existsSync(path.join(app.absolutePath, "pyproject.toml")),
|
|
135
140
|
);
|
|
136
141
|
if (!apps.length) return;
|
|
137
142
|
if (!fsSync.existsSync(path.join(benchDir, "sites"))) {
|
|
143
|
+
if (required) {
|
|
144
|
+
throw new Error(`no frappe bench (apps/frappe/sites): bench tests -m "${marker}" need one`);
|
|
145
|
+
}
|
|
138
146
|
console.warn(`no frappe bench (apps/frappe/sites): skipped bench tests -m "${marker}"`);
|
|
139
147
|
return;
|
|
140
148
|
}
|
|
@@ -155,28 +163,41 @@ async function runBenchTests(projectRoot: string, marker: string, spawn: Spawn):
|
|
|
155
163
|
}
|
|
156
164
|
}
|
|
157
165
|
|
|
158
|
-
/** The unit tier: turbo test minus missing services
|
|
166
|
+
/** The unit tier: turbo test minus missing services, then the bench's non-integration tests. */
|
|
159
167
|
export async function runUnitTests(projectRoot: string, spawn: Spawn = nanoSpawn): Promise<void> {
|
|
160
168
|
const excludeFilters = await getTurboExcludeFiltersForMissing(projectRoot);
|
|
161
|
-
const
|
|
162
|
-
const filters = [
|
|
163
|
-
...excludeFilters.flatMap((f) => ["--filter", f]),
|
|
164
|
-
...(e2eApp ? ["--filter", `'!./apps/${e2eApp}'`] : []),
|
|
165
|
-
];
|
|
169
|
+
const filters = excludeFilters.flatMap((f) => ["--filter", f]);
|
|
166
170
|
await spawn("pnpm", ["turbo", "run", "test", ...filters], {
|
|
167
171
|
stdio: "inherit",
|
|
168
172
|
shell: true,
|
|
169
173
|
cwd: projectRoot,
|
|
170
174
|
});
|
|
171
|
-
await runBenchTests(projectRoot, "not integration", spawn);
|
|
175
|
+
await runBenchTests(projectRoot, "not integration", spawn, false);
|
|
172
176
|
}
|
|
173
177
|
|
|
174
|
-
/** The integration tier: the bench's integration-marked tests
|
|
178
|
+
/** The integration tier: turbo test:integration, then the bench's integration-marked tests; a missing service fails it. */
|
|
175
179
|
export async function runIntegrationTests(
|
|
176
180
|
projectRoot: string,
|
|
177
181
|
spawn: Spawn = nanoSpawn,
|
|
178
182
|
): Promise<void> {
|
|
179
|
-
await
|
|
183
|
+
const excludeFilters = await getTurboExcludeFiltersForMissing(projectRoot);
|
|
184
|
+
const filters = excludeFilters.flatMap((f) => ["--filter", f]);
|
|
185
|
+
const failures: string[] = [];
|
|
186
|
+
try {
|
|
187
|
+
await spawn("pnpm", ["turbo", "run", "test:integration", "--continue", ...filters], {
|
|
188
|
+
stdio: "inherit",
|
|
189
|
+
shell: true,
|
|
190
|
+
cwd: projectRoot,
|
|
191
|
+
});
|
|
192
|
+
} catch (error) {
|
|
193
|
+
failures.push((error as Error).message);
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
await runBenchTests(projectRoot, "integration", spawn, true);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
failures.push((error as Error).message);
|
|
199
|
+
}
|
|
200
|
+
if (failures.length) throw new Error(failures.join("\n"));
|
|
180
201
|
}
|
|
181
202
|
|
|
182
203
|
/** `mpo build`: the packages, then every present app with a build script, each once. */
|
package/templates/AGENTS.md
CHANGED
|
@@ -82,6 +82,9 @@ frappe config, scheme adapter).
|
|
|
82
82
|
import or dependency and no relative path into `features/`. Move the code
|
|
83
83
|
into a package and import it from features
|
|
84
84
|
(`scripts/verify-packages-direction.mjs`).
|
|
85
|
+
5. **No `@multiplatform.one/<pkg>/src/…` imports**: a package's src/ is not
|
|
86
|
+
its API and its exports map does not resolve one. Import the package or one
|
|
87
|
+
of its named subpaths.
|
|
85
88
|
|
|
86
89
|
Run: `pnpm lint` (oxlint + `scripts/lint-conventions.mjs`).
|
|
87
90
|
|
|
@@ -11,29 +11,75 @@
|
|
|
11
11
|
// exactly that. Add modules as your screens grow; a missing export is a
|
|
12
12
|
// build error naming the symbol, which is the cheapest possible signal.
|
|
13
13
|
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
14
|
+
// The bare package name: from THIS file it reaches the package's gnome
|
|
15
|
+
// entry, not this shim, so importing it here cannot loop.
|
|
16
16
|
|
|
17
|
-
export
|
|
18
|
-
|
|
17
|
+
export {
|
|
18
|
+
CONTENT_MAX_WIDTH,
|
|
19
|
+
EmptyState,
|
|
20
|
+
GutterFrame,
|
|
21
|
+
PageActionButton,
|
|
22
|
+
PageBackButton,
|
|
23
|
+
PageBarButton,
|
|
24
|
+
PageHeader,
|
|
25
|
+
PageMenuButton,
|
|
26
|
+
PageSection,
|
|
27
|
+
PushedPage,
|
|
28
|
+
READABLE_MAX_WIDTH,
|
|
29
|
+
Screen,
|
|
30
|
+
ScreenToolbar,
|
|
31
|
+
useInlinePageTitle,
|
|
32
|
+
} from "@multiplatform.one/components";
|
|
33
|
+
export type {
|
|
34
|
+
EmptyStateProps,
|
|
35
|
+
PageActionButtonProps,
|
|
36
|
+
PageBackButtonProps,
|
|
37
|
+
PageBarButtonProps,
|
|
38
|
+
PageHeaderProps,
|
|
39
|
+
PageSectionProps,
|
|
40
|
+
ScreenProps,
|
|
41
|
+
ScreenToolbarProps,
|
|
42
|
+
} from "@multiplatform.one/components";
|
|
43
|
+
export {
|
|
44
|
+
ShellSidebarSlotProvider,
|
|
45
|
+
useHasShellSidebarSlot,
|
|
46
|
+
useShellSidebarPanel,
|
|
47
|
+
useShellSidebarSlotState,
|
|
48
|
+
} from "@multiplatform.one/components";
|
|
49
|
+
export type { ShellSidebarPanel } from "@multiplatform.one/components";
|
|
19
50
|
|
|
20
51
|
// Async list/table chrome — the wrapper real screens put around their
|
|
21
52
|
// fetches. Its skeleton + error icons stay unrendered until used; the
|
|
22
53
|
// module graph (forms Button/Skeleton via the shims, three tree-shaken
|
|
23
54
|
// phosphor icons) is GJS-inert at init.
|
|
24
|
-
export
|
|
55
|
+
export {
|
|
56
|
+
AsyncBoundary,
|
|
57
|
+
AsyncSkeleton,
|
|
58
|
+
__resetAsyncDevWarnSeen,
|
|
59
|
+
asyncLoadDelayMs,
|
|
60
|
+
resolveAsyncStatus,
|
|
61
|
+
useAsyncBoundary,
|
|
62
|
+
useAsyncCount,
|
|
63
|
+
} from "@multiplatform.one/components";
|
|
64
|
+
export type {
|
|
65
|
+
AsyncBoundaryContextValue,
|
|
66
|
+
AsyncBoundaryLayout,
|
|
67
|
+
AsyncBoundaryProps,
|
|
68
|
+
AsyncSkeletonHero,
|
|
69
|
+
AsyncStatus,
|
|
70
|
+
} from "@multiplatform.one/components";
|
|
25
71
|
|
|
26
72
|
// Chip lives in the FORMS package — the real components barrel re-exports
|
|
27
|
-
// it.
|
|
28
|
-
//
|
|
29
|
-
export { Chip, ChipFrame, ChipText, chipIconSize } from "@multiplatform.one/forms
|
|
73
|
+
// it. The bare forms name reaches the forms shim, which exports the same
|
|
74
|
+
// module instance.
|
|
75
|
+
export { Chip, ChipFrame, ChipText, chipIconSize } from "@multiplatform.one/forms";
|
|
30
76
|
export type {
|
|
31
77
|
ChipColor,
|
|
32
78
|
ChipFrameProps,
|
|
33
79
|
ChipProps,
|
|
34
80
|
ChipSize,
|
|
35
81
|
ChipVariant,
|
|
36
|
-
} from "@multiplatform.one/forms
|
|
82
|
+
} from "@multiplatform.one/forms";
|
|
37
83
|
|
|
38
84
|
export {
|
|
39
85
|
Button,
|
|
@@ -59,5 +105,20 @@ export {
|
|
|
59
105
|
// CheckIcon — Popover/Dialog resolve through the gnome tamagui-barrel
|
|
60
106
|
// with vite-plugin-gnome's portal/sheet patches, and phosphor resolves to
|
|
61
107
|
// the SvgXml glyph shim.
|
|
62
|
-
export
|
|
63
|
-
export
|
|
108
|
+
export { ConfirmDialog, confirmDialogPresentation } from "@multiplatform.one/components";
|
|
109
|
+
export type { ConfirmDialogProps } from "@multiplatform.one/components";
|
|
110
|
+
export { DropdownMenu, isIconTrigger } from "@multiplatform.one/components";
|
|
111
|
+
export type {
|
|
112
|
+
DropdownMenuCheckboxItemProps,
|
|
113
|
+
DropdownMenuCloseAutoFocusEvent,
|
|
114
|
+
DropdownMenuContentProps,
|
|
115
|
+
DropdownMenuEntry,
|
|
116
|
+
DropdownMenuItemProps,
|
|
117
|
+
DropdownMenuItemSpec,
|
|
118
|
+
DropdownMenuLabelProps,
|
|
119
|
+
DropdownMenuPlacement,
|
|
120
|
+
DropdownMenuProps,
|
|
121
|
+
DropdownMenuRowProps,
|
|
122
|
+
DropdownMenuSeparatorProps,
|
|
123
|
+
DropdownMenuTriggerProps,
|
|
124
|
+
} from "@multiplatform.one/components";
|