@multiplatform.one/cli 7.10.0 → 7.15.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 +121 -111
- package/bin/createMultiplatformApp.mjs +39 -37
- package/lib/bin/multiplatformOne.mjs +65 -75
- package/lib/commands/addApp.mjs +78 -0
- package/lib/commands/adoptApp.mjs +11 -7
- package/lib/commands/doctypeTypes.mjs +148 -0
- package/lib/commands/e2e.mjs +2 -2
- package/lib/commands/init.mjs +142 -459
- package/lib/commands/merge.mjs +359 -0
- package/lib/commands/pieces.mjs +236 -0
- package/lib/commands/provenance.mjs +108 -0
- package/lib/commands/scaffold.mjs +105 -0
- package/lib/commands/updateApp.mjs +211 -528
- package/lib/source.json +5 -0
- package/lib/source.mjs +63 -0
- package/package.json +7 -7
- package/scripts/frappe-bootstrap.sh +29 -3
- package/scripts/frappe-dev.sh +1 -2
- package/scripts/frappe-helpers.sh +50 -2
- package/scripts/frappe.sh +5 -0
- package/scripts/scaffold.sh +937 -0
- package/scripts/stamp-source.mjs +51 -0
- package/scripts/stamp-source.spec.ts +86 -0
- package/src/bin/multiplatformOne.ts +116 -226
- package/src/commands/addApp.ts +102 -0
- package/src/commands/adoptApp.spec.ts +5 -1
- package/src/commands/adoptApp.ts +15 -10
- package/src/commands/doctypeTypes.spec.ts +155 -0
- package/src/commands/doctypeTypes.ts +214 -0
- package/src/commands/init.spec.ts +66 -0
- package/src/commands/init.ts +201 -643
- package/src/commands/merge.spec.ts +81 -0
- package/src/commands/merge.ts +411 -0
- package/src/commands/pieces.spec.ts +62 -0
- package/src/commands/pieces.ts +340 -0
- package/src/commands/provenance.spec.ts +92 -0
- package/src/commands/provenance.ts +169 -0
- package/src/commands/scaffold.ts +131 -0
- package/src/commands/updateApp.spec.ts +540 -331
- package/src/commands/updateApp.ts +255 -668
- package/src/source.spec.ts +45 -0
- package/src/source.ts +88 -0
- package/templates/AGENTS.md +161 -0
- package/templates/README.md +62 -0
- package/templates/pieces/frappe/universal/README.md.partial +7 -32
- package/templates/pieces/frappe/universal/env.example.partial +3 -3
- package/templates/pieces/frappe-bench/universal/README.md.partial +28 -0
- package/templates/pieces/{frappe → frappe-bench}/universal/docker/compose.frappe.yaml +2 -2
- package/templates/pieces/tauri/universal/README.md.partial +7 -5
- package/templates/pieces/tauri/universal/apps/__NAME__/src-tauri/src/dev.rs +463 -0
- package/templates/pieces/tauri/universal/apps/__NAME__/src-tauri/src/lib.rs +6 -0
- package/templates/pieces/tauri/universal/apps/__NAME__/src-tauri/tauri.conf.json +2 -1
- package/templates/pieces/webext/universal/apps/__NAME__/package.json.partial +1 -0
- package/templates/pieces/webext/universal/apps/__NAME__/vite.config.webext.ts +6 -2
- package/types/bin/multiplatformOne.d.ts.map +1 -1
- package/types/commands/addApp.d.ts +20 -0
- package/types/commands/addApp.d.ts.map +1 -0
- package/types/commands/adoptApp.d.ts +4 -3
- package/types/commands/adoptApp.d.ts.map +1 -1
- package/types/commands/doctypeTypes.d.ts +40 -0
- package/types/commands/doctypeTypes.d.ts.map +1 -0
- package/types/commands/init.d.ts +30 -13
- package/types/commands/init.d.ts.map +1 -1
- package/types/commands/merge.d.ts +54 -0
- package/types/commands/merge.d.ts.map +1 -0
- package/types/commands/pieces.d.ts +54 -0
- package/types/commands/pieces.d.ts.map +1 -0
- package/types/commands/provenance.d.ts +52 -0
- package/types/commands/provenance.d.ts.map +1 -0
- package/types/commands/scaffold.d.ts +43 -0
- package/types/commands/scaffold.d.ts.map +1 -0
- package/types/commands/updateApp.d.ts +19 -27
- package/types/commands/updateApp.d.ts.map +1 -1
- package/types/source.d.ts +35 -0
- package/types/source.d.ts.map +1 -0
- package/lib/commands/initApp.mjs +0 -431
- package/lib/generateVscode.mjs +0 -184
- package/scripts/clone.sh +0 -17
- package/scripts/update.sh +0 -46
- package/src/commands/initApp.spec.ts +0 -720
- package/src/commands/initApp.ts +0 -706
- package/src/generateVscode.ts +0 -238
- package/templates/app/AGENTS.md +0 -142
- package/templates/app/README.md +0 -62
- package/templates/app/apps/__NAME__/index.html +0 -36
- package/templates/app/apps/__NAME__/package.json +0 -31
- package/templates/app/apps/__NAME__/public/fonts/inter-400.woff2 +0 -0
- package/templates/app/apps/__NAME__/public/fonts/inter-700.woff2 +0 -0
- package/templates/app/apps/__NAME__/src/App.tsx +0 -9
- package/templates/app/apps/__NAME__/src/main.tsx +0 -14
- package/templates/app/apps/__NAME__/tsconfig.json +0 -8
- package/templates/app/apps/__NAME__/vite.config.ts +0 -17
- package/templates/app/features/__NAME__/package.json +0 -34
- package/templates/app/features/__NAME__/src/HomeScreen.tsx +0 -70
- package/templates/app/features/__NAME__/src/index.ts +0 -1
- package/templates/app/features/__NAME__/tsconfig.json +0 -5
- package/templates/app/gitignore +0 -9
- package/templates/app/npmrc +0 -2
- package/templates/app/oxlintrc.json +0 -39
- package/templates/app/package.json +0 -38
- package/templates/app/packages/config/config.json +0 -4
- package/templates/app/packages/config/index.ts +0 -5
- package/templates/app/packages/config/package.json +0 -17
- package/templates/app/packages/config/tsconfig.json +0 -5
- package/templates/app/pnpm-workspace.yaml +0 -4
- package/templates/app/tsconfig.base.json +0 -16
- package/templates/universal/AGENTS.md +0 -142
- package/templates/universal/README.md +0 -97
- package/templates/universal/apps/__NAME__/app.config.js +0 -31
- package/templates/universal/apps/__NAME__/config/tamagui.config.ts +0 -4
- package/templates/universal/apps/__NAME__/package.json +0 -62
- package/templates/universal/apps/__NAME__/polyfills.native.ts +0 -23
- package/templates/universal/apps/__NAME__/polyfills.ts +0 -3
- package/templates/universal/apps/__NAME__/public/fonts/inter-400.woff2 +0 -0
- package/templates/universal/apps/__NAME__/public/fonts/inter-700.woff2 +0 -0
- package/templates/universal/apps/__NAME__/routes/_layout.tsx +0 -22
- package/templates/universal/apps/__NAME__/routes/_layout.web.tsx +0 -21
- package/templates/universal/apps/__NAME__/routes/about.tsx +0 -3
- package/templates/universal/apps/__NAME__/routes/index.tsx +0 -3
- package/templates/universal/apps/__NAME__/src/app.ts +0 -10
- package/templates/universal/apps/__NAME__/tamagui.css +0 -3
- package/templates/universal/apps/__NAME__/tsconfig.json +0 -8
- package/templates/universal/apps/__NAME__/types.d.ts +0 -9
- package/templates/universal/apps/__NAME__/vite.config.ts +0 -20
- package/templates/universal/features/__NAME__/package.json +0 -35
- package/templates/universal/features/__NAME__/src/AboutScreen.tsx +0 -27
- package/templates/universal/features/__NAME__/src/AppLayout.tsx +0 -50
- package/templates/universal/features/__NAME__/src/ContactForm.spec.tsx +0 -22
- package/templates/universal/features/__NAME__/src/ContactForm.tsx +0 -55
- package/templates/universal/features/__NAME__/src/HomeScreen.tsx +0 -40
- package/templates/universal/features/__NAME__/src/index.ts +0 -4
- package/templates/universal/features/__NAME__/src/screens.spec.ts +0 -12
- package/templates/universal/features/__NAME__/tsconfig.json +0 -5
- package/templates/universal/features/__NAME__/vitest.config.mjs +0 -7
- package/templates/universal/gitignore +0 -14
- package/templates/universal/npmrc +0 -3
- package/templates/universal/oxlintrc.json +0 -39
- package/templates/universal/package.json +0 -51
- package/templates/universal/packages/config/config.json +0 -4
- package/templates/universal/packages/config/index.ts +0 -5
- package/templates/universal/packages/config/package.json +0 -17
- package/templates/universal/packages/config/tsconfig.json +0 -5
- package/templates/universal/packages/i18n/en/common.json +0 -30
- package/templates/universal/packages/i18n/es/common.json +0 -30
- package/templates/universal/packages/i18n/i18n.d.ts +0 -16
- package/templates/universal/packages/i18n/index.ts +0 -26
- package/templates/universal/packages/i18n/package.json +0 -20
- package/templates/universal/packages/i18n/resources.ts +0 -13
- package/templates/universal/packages/i18n/tsconfig.json +0 -5
- package/templates/universal/packages/themes/accent.ts +0 -32
- package/templates/universal/packages/themes/base.ts +0 -50
- package/templates/universal/packages/themes/fonts.ts +0 -8
- package/templates/universal/packages/themes/index.ts +0 -33
- package/templates/universal/packages/themes/package.json +0 -23
- package/templates/universal/packages/themes/tamagui.config.ts +0 -14
- package/templates/universal/packages/themes/tsconfig.json +0 -5
- package/templates/universal/pnpm-workspace.yaml +0 -4
- package/templates/universal/tsconfig.base.json +0 -21
- package/templates/universal/types/env.d.ts +0 -9
- package/types/commands/initApp.d.ts +0 -114
- package/types/commands/initApp.d.ts.map +0 -1
- package/types/generateVscode.d.ts +0 -7
- package/types/generateVscode.d.ts.map +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import spawn from "nano-spawn";
|
|
5
|
+
import { cliRoot, readProvenance, type MpoProvenance } from "./provenance";
|
|
6
|
+
|
|
7
|
+
/** The scaffold itself: POSIX sh, runs standalone. The TS commands only call it. */
|
|
8
|
+
export function scaffoldScript(): string {
|
|
9
|
+
return join(cliRoot(), "scripts/scaffold.sh");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ScaffoldRequest {
|
|
13
|
+
/** Path to a local clone or a git URL. */
|
|
14
|
+
source: string;
|
|
15
|
+
/** Commit, tag or branch. */
|
|
16
|
+
ref: string;
|
|
17
|
+
target: string;
|
|
18
|
+
/** Product apps derived from apps/one. */
|
|
19
|
+
apps: string[];
|
|
20
|
+
/** Singleton apps kept under apps/. */
|
|
21
|
+
services: string[];
|
|
22
|
+
/** Range written for @multiplatform.one/* (default: ^<cli version at the ref>). */
|
|
23
|
+
mpoVersion?: string;
|
|
24
|
+
/** Scaffold into a non-empty directory; existing paths are skipped and pinned. */
|
|
25
|
+
into?: boolean;
|
|
26
|
+
/** Url recorded in .mpo.json instead of the source path. */
|
|
27
|
+
sourceUrl?: string;
|
|
28
|
+
/** Root package.json name (default: the target's basename). */
|
|
29
|
+
name?: string;
|
|
30
|
+
/** Show the script's progress (removed: ... lines). */
|
|
31
|
+
verbose?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class ScaffoldError extends Error {
|
|
35
|
+
constructor(
|
|
36
|
+
message: string,
|
|
37
|
+
readonly request: ScaffoldRequest,
|
|
38
|
+
) {
|
|
39
|
+
super(message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** --into keeps every path the target already had; name them, since mpo update will not touch them. */
|
|
44
|
+
function reportKept(stdout: string): void {
|
|
45
|
+
const prefix = "skipped (exists): ";
|
|
46
|
+
const kept = stdout
|
|
47
|
+
.split("\n")
|
|
48
|
+
.filter((line) => line.startsWith(prefix))
|
|
49
|
+
.map((line) => line.slice(prefix.length));
|
|
50
|
+
if (!kept.length) return;
|
|
51
|
+
console.log(`\nKept ${kept.length} path(s) already here, pinned in .updateignore:`);
|
|
52
|
+
for (const path of kept) console.log(` ${path}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Run scaffold.sh and return the provenance it wrote. */
|
|
56
|
+
export async function runScaffold(request: ScaffoldRequest): Promise<MpoProvenance> {
|
|
57
|
+
const args = [scaffoldScript()];
|
|
58
|
+
for (const app of request.apps) args.push("--app", app);
|
|
59
|
+
for (const service of request.services) args.push("--service", service);
|
|
60
|
+
if (request.mpoVersion) args.push("--mpo-version", request.mpoVersion);
|
|
61
|
+
if (request.into) args.push("--into");
|
|
62
|
+
if (request.sourceUrl) args.push("--source-url", request.sourceUrl);
|
|
63
|
+
if (request.name) args.push("--name", request.name);
|
|
64
|
+
args.push("--", request.source, request.ref, request.target);
|
|
65
|
+
let stdout = "";
|
|
66
|
+
try {
|
|
67
|
+
const result = await spawn("sh", args, {
|
|
68
|
+
stdio: request.verbose ? "inherit" : ["ignore", "pipe", "pipe"],
|
|
69
|
+
});
|
|
70
|
+
stdout = result.stdout;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
const stderr = ((err as { stderr?: string }).stderr ?? "").trim();
|
|
73
|
+
const detail = stderr.split("\n").filter(Boolean).pop() ?? (err as Error).message;
|
|
74
|
+
throw new ScaffoldError(detail.replace(/^scaffold: /, ""), request);
|
|
75
|
+
}
|
|
76
|
+
if (request.into && !request.verbose) reportKept(stdout);
|
|
77
|
+
const provenance = readProvenance(request.target);
|
|
78
|
+
if (!provenance?.source) {
|
|
79
|
+
throw new ScaffoldError(`scaffold.sh wrote no provenance into ${request.target}`, request);
|
|
80
|
+
}
|
|
81
|
+
return provenance;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface TempScaffold {
|
|
85
|
+
dir: string;
|
|
86
|
+
provenance: MpoProvenance;
|
|
87
|
+
cleanup: () => void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** A scaffold in a temp dir (merge baselines). */
|
|
91
|
+
export async function scaffoldToTemp(
|
|
92
|
+
request: Omit<ScaffoldRequest, "target" | "into">,
|
|
93
|
+
): Promise<TempScaffold> {
|
|
94
|
+
const parent = mkdtempSync(join(tmpdir(), "mpo-scaffold-"));
|
|
95
|
+
const dir = join(parent, "project");
|
|
96
|
+
const cleanup = () => rmSync(parent, { recursive: true, force: true });
|
|
97
|
+
try {
|
|
98
|
+
const provenance = await runScaffold({ ...request, target: dir });
|
|
99
|
+
return { dir, provenance, cleanup };
|
|
100
|
+
} catch (err) {
|
|
101
|
+
cleanup();
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* One subtree of the monorepo at a ref, extracted into `dest` (the piece
|
|
108
|
+
* templates of an older CLI version, for adopted-project merge bases).
|
|
109
|
+
*/
|
|
110
|
+
export async function archiveSubtree(
|
|
111
|
+
source: string,
|
|
112
|
+
ref: string,
|
|
113
|
+
subtree: string,
|
|
114
|
+
dest: string,
|
|
115
|
+
): Promise<void> {
|
|
116
|
+
const script = [
|
|
117
|
+
"set -eu",
|
|
118
|
+
'SOURCE="$1"; REF="$2"; SUBTREE="$3"; DEST="$4"',
|
|
119
|
+
'if [ -d "$SOURCE" ]; then REPO="$SOURCE"; else',
|
|
120
|
+
' REPO="$(mktemp -d "${TMPDIR:-/tmp}/mpo-archive.XXXXXX")"',
|
|
121
|
+
" trap 'rm -rf \"$REPO\"' EXIT",
|
|
122
|
+
' git clone -q --depth 1 --no-checkout --branch "$REF" "$SOURCE" "$REPO"',
|
|
123
|
+
" REF=HEAD",
|
|
124
|
+
"fi",
|
|
125
|
+
'mkdir -p "$DEST"',
|
|
126
|
+
'git -C "$REPO" archive --format=tar "$REF" "$SUBTREE" | tar -xf - -C "$DEST"',
|
|
127
|
+
].join("\n");
|
|
128
|
+
await spawn("sh", ["-c", script, "sh", source, ref, subtree, dest], {
|
|
129
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
130
|
+
});
|
|
131
|
+
}
|