@multiplatform.one/cli 7.90.4 → 7.90.6

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/lib/source.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "cliVersion": "7.90.4",
2
+ "cliVersion": "7.90.6",
3
3
  "url": "https://git.corp.bitspur.com/multiplatform.one/mpo.git",
4
- "sha": "a484db92ebdad1956d8047203d42f224e57f0d71"
4
+ "sha": "5be8b3d5567335c111c400a58bdc37114ab02f01"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/cli",
3
- "version": "7.90.4",
3
+ "version": "7.90.6",
4
4
  "description": "multiplatform.one cli — mpo init clones and prunes the monorepo, mpo update merges it back",
5
5
  "keywords": [
6
6
  "create-multiplatform-app",
@@ -57,7 +57,7 @@
57
57
  "access": "public"
58
58
  },
59
59
  "dependencies": {
60
- "@multiplatform.one/utils": "^7.90.4",
60
+ "@multiplatform.one/utils": "^7.90.6",
61
61
  "commander": "^15.0.0",
62
62
  "dotenv": "^17.4.2",
63
63
  "inquirer": "^14.2.3",
@@ -442,6 +442,62 @@ if [ -f "$TREE/Makefile" ]; then
442
442
  ' "$TREE/Makefile" >"$TREE/Makefile.scaffold.tmp" && mv "$TREE/Makefile.scaffold.tmp" "$TREE/Makefile"
443
443
  fi
444
444
 
445
+ # Procfile.localnet runs one dev chain per line: a line naming a pruned app
446
+ # goes, and the file goes with its last line. A root rule that drives a tree
447
+ # the project lacks goes with the comment block above it: publish runs the
448
+ # release train over public/, localnet supervises Procfile.localnet.
449
+ if [ -f "$TREE/Procfile.localnet" ]; then
450
+ awk -v removed=" $REMOVED_APPS " '
451
+ {
452
+ rest = $0
453
+ while (match(rest, /apps\/[a-z0-9-]+/)) {
454
+ if (index(removed, " " substr(rest, RSTART + 5, RLENGTH - 5) " ")) next
455
+ rest = substr(rest, RSTART + RLENGTH)
456
+ }
457
+ print
458
+ }
459
+ ' "$TREE/Procfile.localnet" >"$TREE/Procfile.localnet.scaffold.tmp" &&
460
+ mv "$TREE/Procfile.localnet.scaffold.tmp" "$TREE/Procfile.localnet"
461
+ if ! grep -q '^[^#[:space:]]' "$TREE/Procfile.localnet"; then
462
+ rm -f "$TREE/Procfile.localnet"
463
+ REMOVED="$REMOVED Procfile.localnet"
464
+ printf 'removed: %s\n' Procfile.localnet
465
+ fi
466
+ fi
467
+ DROP_RULES=""
468
+ case " $REMOVED " in
469
+ *" public "*) DROP_RULES="$DROP_RULES publish" ;;
470
+ esac
471
+ case " $REMOVED " in
472
+ *" Procfile.localnet "*) DROP_RULES="$DROP_RULES localnet" ;;
473
+ esac
474
+ if [ -n "$DROP_RULES" ] && [ -f "$TREE/Makefile" ]; then
475
+ awk -v rules="$DROP_RULES " '
476
+ /^#/ {
477
+ held = held $0 "\n"
478
+ skipping = ""
479
+ next
480
+ }
481
+ /^\.PHONY: [^ ]+$/ && index(rules, " " $2 " ") {
482
+ held = ""
483
+ skipping = $2
484
+ next
485
+ }
486
+ skipping != "" && (index($0, skipping ":") == 1 || /^\t/) { next }
487
+ skipping != "" && /^$/ {
488
+ skipping = ""
489
+ next
490
+ }
491
+ {
492
+ skipping = ""
493
+ printf "%s", held
494
+ held = ""
495
+ print
496
+ }
497
+ END { printf "%s", held }
498
+ ' "$TREE/Makefile" >"$TREE/Makefile.scaffold.tmp" && mv "$TREE/Makefile.scaffold.tmp" "$TREE/Makefile"
499
+ fi
500
+
445
501
  if [ -f "$TREE/.gitignore" ]; then
446
502
  awk -v apps="$APPS" '
447
503
  BEGIN { napps = split(apps, app, " ") }
@@ -777,6 +833,13 @@ const cleanSegment = (segment) =>
777
833
  segment.replace(/\s--ignore-pattern\s+'([^']*)'/g, (whole, pattern) =>
778
834
  namesPruned(pattern) ? "" : whole,
779
835
  );
836
+ // A file operand under a removed tree (a spec node --test runs) leaves the
837
+ // segment that names it.
838
+ const dropPrunedOperands = (segment) =>
839
+ segment
840
+ .split(" ")
841
+ .filter((word) => !pruned.some((tree) => word.replace(/^\.\//, "").startsWith(`${tree}/`)))
842
+ .join(" ");
780
843
  // Each product app carries apps/one's design baseline; a pruned tree's
781
844
  // baseline is gone, and a lint naming a missing baseline fails.
782
845
  // A kept baseline can still record only pruned trees (packages' public and
@@ -811,7 +874,10 @@ for (const [name, script] of Object.entries(pkg.scripts ?? {})) {
811
874
  if (name === "lint:design" && !/\s--baseline\s/.test(value)) continue;
812
875
  // verify:lc audits the catalog in public/ against the rulebook in docs/.
813
876
  if (name === "verify:lc" && (pruned.includes("public") || pruned.includes("docs"))) continue;
814
- const kept = value.split(" && ").filter((segment) => !dropSegment(segment)).map(cleanSegment);
877
+ const kept = value
878
+ .split(" && ")
879
+ .filter((segment) => !dropSegment(segment))
880
+ .map((segment) => dropPrunedOperands(cleanSegment(segment)));
815
881
  if (!kept.length) continue;
816
882
  scripts[name] = kept.join(" && ");
817
883
  }
@@ -854,6 +920,113 @@ if (pruned.includes("public") && pkg.pnpm?.patchedDependencies) {
854
920
  fs.writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\n`);
855
921
  NODE
856
922
 
923
+ # turbo names packages as well as paths. A task keyed on a package the project
924
+ # has no workspace for (@multiplatform.one/theme#test once public/ is pruned)
925
+ # goes, and so does a script's --filter='!<package>' for one, which turbo
926
+ # refuses with "No package found". A globalDependencies, inputs or outputs
927
+ # entry under a pruned tree goes too. turbo.json is edited as text, so the rest
928
+ # of it keeps the monorepo's formatting.
929
+ if [ -f "$TREE/pnpm-workspace.yaml" ]; then
930
+ node - "$TREE" "$(printf '%s' "$REMOVED" | tr ' ' ',')" <<'NODE'
931
+ const fs = require("node:fs");
932
+ const path = require("node:path");
933
+ const [root, prunedCsv] = process.argv.slice(2);
934
+ const pruned = prunedCsv ? prunedCsv.split(",") : [];
935
+ const globs = [];
936
+ let inPackages = false;
937
+ for (const line of fs.readFileSync(path.join(root, "pnpm-workspace.yaml"), "utf8").split("\n")) {
938
+ if (/^packages:\s*$/.test(line)) inPackages = true;
939
+ else if (inPackages && /^\s+-\s/.test(line)) globs.push(line.replace(/^\s+-\s*["']?|["']?\s*$/g, ""));
940
+ else if (/^\S/.test(line)) inPackages = false;
941
+ }
942
+ if (!globs.length) process.exit(0);
943
+ const names = new Set(["//"]);
944
+ const addPackage = (dir) => {
945
+ const pkg = path.join(root, dir, "package.json");
946
+ if (fs.existsSync(pkg)) names.add(JSON.parse(fs.readFileSync(pkg, "utf8")).name);
947
+ };
948
+ for (const glob of globs) {
949
+ if (!glob.endsWith("/*")) {
950
+ addPackage(glob);
951
+ continue;
952
+ }
953
+ const dir = path.join(root, glob.slice(0, -2));
954
+ if (!fs.existsSync(dir)) continue;
955
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
956
+ if (entry.isDirectory()) addPackage(path.join(glob.slice(0, -2), entry.name));
957
+ }
958
+ }
959
+
960
+ const pkgFile = path.join(root, "package.json");
961
+ const pkg = JSON.parse(fs.readFileSync(pkgFile, "utf8"));
962
+ const exclusion = /\s--filter[= ](['"]?)!(?:\^?\.\.\.)?([@a-z][^'"\s]*?)(?:\.\.\.)?\1(?=\s|$)/g;
963
+ let pkgChanged = false;
964
+ for (const [name, script] of Object.entries(pkg.scripts ?? {})) {
965
+ const kept = script.replace(exclusion, (whole, _quote, filtered) => (names.has(filtered) ? whole : ""));
966
+ if (kept !== script) {
967
+ pkg.scripts[name] = kept;
968
+ pkgChanged = true;
969
+ }
970
+ }
971
+ if (pkgChanged) fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
972
+
973
+ const turboFile = path.join(root, "turbo.json");
974
+ if (!fs.existsSync(turboFile)) process.exit(0);
975
+ const raw = fs.readFileSync(turboFile, "utf8");
976
+ const turbo = JSON.parse(raw);
977
+ const gone = Object.keys(turbo.tasks ?? {}).filter(
978
+ (key) => key.includes("#") && !names.has(key.slice(0, key.lastIndexOf("#"))),
979
+ );
980
+ for (const key of gone) delete turbo.tasks[key];
981
+ const underPruned = (entry) => {
982
+ const target = entry.replace(/^!/, "").replace(/^\$TURBO_ROOT\$\//, "").replace(/^\.\//, "");
983
+ return pruned.some((tree) => target === tree || target.startsWith(`${tree}/`));
984
+ };
985
+ const dead = new Set();
986
+ const keepPaths = (owner, field) => {
987
+ if (!Array.isArray(owner[field])) return;
988
+ for (const entry of owner[field]) if (underPruned(entry)) dead.add(entry);
989
+ owner[field] = owner[field].filter((entry) => !underPruned(entry));
990
+ };
991
+ keepPaths(turbo, "globalDependencies");
992
+ for (const task of Object.values(turbo.tasks ?? {})) {
993
+ keepPaths(task, "inputs");
994
+ keepPaths(task, "outputs");
995
+ }
996
+ if (!gone.length && !dead.size) process.exit(0);
997
+ const cut = (lines) => {
998
+ for (const key of gone) {
999
+ const start = lines.findIndex((line) => line.trimStart().startsWith(`${JSON.stringify(key)}:`));
1000
+ if (start < 1) return null;
1001
+ const close = new RegExp(`^${lines[start].match(/^\s*/)[0]}[}\\]],?\\s*$`);
1002
+ let end = start;
1003
+ if (/[{[]\s*$/.test(lines[start])) while (end < lines.length - 1 && !close.test(lines[end])) end++;
1004
+ if (!/,\s*$/.test(lines[end])) lines[start - 1] = lines[start - 1].replace(/,(\s*)$/, "$1");
1005
+ lines.splice(start, end - start + 1);
1006
+ }
1007
+ for (let i = lines.length - 1; i > 0; i--) {
1008
+ const entry = lines[i].match(/^\s*("(?:[^"\\]|\\.)*"),?\s*$/);
1009
+ if (!entry || !dead.has(JSON.parse(entry[1]))) continue;
1010
+ if (!/,\s*$/.test(lines[i])) lines[i - 1] = lines[i - 1].replace(/,(\s*)$/, "$1");
1011
+ lines.splice(i, 1);
1012
+ }
1013
+ let text = lines.join("\n");
1014
+ for (const entry of dead) {
1015
+ const quoted = JSON.stringify(entry);
1016
+ text = text.split(`${quoted}, `).join("").split(`, ${quoted}`).join("").split(`[${quoted}]`).join("[]");
1017
+ }
1018
+ return text;
1019
+ };
1020
+ let text = cut(raw.split("\n"));
1021
+ try {
1022
+ if (text !== null && JSON.stringify(JSON.parse(text)) !== JSON.stringify(turbo)) text = null;
1023
+ } catch {
1024
+ text = null;
1025
+ }
1026
+ fs.writeFileSync(turboFile, text ?? `${JSON.stringify(turbo, null, 2)}\n`);
1027
+ NODE
1028
+ fi
1029
+
857
1030
  # The monorepo tags its images for its own private registry. A project's local
858
1031
  # `make docker/build/<target>` tags them under the project's name instead, so
859
1032
  # `docker run <project>/app` works with no registry at all (FZ-8862).
@@ -49,6 +49,18 @@ async function initRepo(dir: string): Promise<string> {
49
49
  return commitAll(dir, "chore: fixture");
50
50
  }
51
51
 
52
+ /**
53
+ * A clone of this checkout at `head` whose worktree holds only the paths the
54
+ * specs edit. Scaffolds read the source through git objects (scaffold.sh runs
55
+ * git archive), so the rest of the tree would only cost a checkout and a delete.
56
+ */
57
+ async function cloneSource(dir: string, head: string): Promise<void> {
58
+ await spawn("git", ["clone", "--quiet", "--shared", "--no-checkout", monorepo, dir]);
59
+ await spawn("git", ["sparse-checkout", "set", "apps/one", "public/cli/templates"], { cwd: dir });
60
+ await spawn("git", ["checkout", "--quiet", head], { cwd: dir });
61
+ await identity(dir);
62
+ }
63
+
52
64
  function writeFiles(dir: string, files: Record<string, string>): void {
53
65
  mkdirSync(dir, { recursive: true });
54
66
  for (const [file, content] of Object.entries(files)) {
@@ -84,10 +96,7 @@ describe("clone-derived project: init → update → add-app", () => {
84
96
  await initRepo(project);
85
97
 
86
98
  source = join(sandbox, "source");
87
- const head = await gitOut(monorepo, ["rev-parse", "HEAD"]);
88
- await spawn("git", ["clone", "--quiet", "--shared", "--no-checkout", monorepo, source]);
89
- await spawn("git", ["checkout", "--quiet", head], { cwd: source });
90
- await identity(source);
99
+ await cloneSource(source, await gitOut(monorepo, ["rev-parse", "HEAD"]));
91
100
  }, heavy);
92
101
 
93
102
  afterEach(() => {
@@ -97,7 +106,7 @@ describe("clone-derived project: init → update → add-app", () => {
97
106
  afterAll(() => {
98
107
  process.chdir(previousCwd);
99
108
  rmSync(sandbox, { recursive: true, force: true });
100
- });
109
+ }, heavy);
101
110
 
102
111
  it(
103
112
  "merges a One-app change into every product app, commits nothing, then goes quiet",
@@ -248,7 +257,7 @@ describe("template-era project", () => {
248
257
 
249
258
  afterAll(() => {
250
259
  rmSync(sandbox, { recursive: true, force: true });
251
- });
260
+ }, heavy);
252
261
 
253
262
  it(
254
263
  "reconciles from an empty base and becomes clone-derived",
@@ -319,16 +328,14 @@ module.exports = {
319
328
  afterAll(() => {
320
329
  process.chdir(previousCwd);
321
330
  rmSync(sandbox, { recursive: true, force: true });
322
- });
331
+ }, heavy);
323
332
 
324
333
  it(
325
334
  "loses .pnpmfile.cjs and its lockfile checksum on update to this checkout, both staged",
326
335
  async () => {
327
336
  const source = join(sandbox, "source");
328
337
  const head = await gitOut(monorepo, ["rev-parse", "HEAD"]);
329
- await spawn("git", ["clone", "--quiet", "--shared", "--no-checkout", monorepo, source]);
330
- await spawn("git", ["checkout", "--quiet", head], { cwd: source });
331
- await identity(source);
338
+ await cloneSource(source, head);
332
339
  writeFileSync(join(source, "public/cli/templates/pnpmfile.cjs"), pulpPnpmfile);
333
340
  await spawn("git", ["add", "-A"], { cwd: source });
334
341
  await spawn("git", ["commit", "--quiet", "--allow-empty", "-m", "chore: the Pulp pnpmfile"], {
@@ -390,7 +397,7 @@ describe("adopted project (pieces)", () => {
390
397
 
391
398
  afterAll(() => {
392
399
  rmSync(sandbox, { recursive: true, force: true });
393
- });
400
+ }, heavy);
394
401
 
395
402
  it(
396
403
  "first update reconciles from an empty base without committing; the next run is a no-op",
@@ -19,7 +19,7 @@ one of them is made upstream, in the monorepo, and arrives with the next
19
19
 
20
20
  MPO improves through shared rules, never app-specific patches.
21
21
 
22
- - App lanes only consume MPO. Never vendor or patch MPO internals or style MPO components locally. Published `@multiplatform.one/*` packages change upstream. MPO findings belong in a separate platform lane (LC-107).
22
+ - App lanes only consume MPO. Never vendor or patch MPO internals or style MPO components locally. Published `@multiplatform.one/*` packages change upstream. MPO findings belong in a separate platform lane ([LC-107](https://git.corp.bitspur.com/multiplatform.one/mpo/-/blob/main/docs/theme-propagation-spec.md)).
23
23
  - Triage each design gap: wrong scale → change the global token/preset; missing primitive → add a general component/variant; merely different design → snap to the nearest MPO token, leaving MPO unchanged (LC-108).
24
24
  - An MPO change needs at least two consumers or a stock Tamagui, iOS or macOS precedent. It must work under every preset, state a numbered LC rule, and receive a cross-app before/after review card (LC-109).
25
25
  - Every style Clay approves applies to every MPO app (LC-110).
@@ -78,6 +78,10 @@ frappe config, scheme adapter).
78
78
  theme tokens (`$color10`, semantic ramps, knob recipes). A file no token
79
79
  reaches (GTK widget CSS, a content script, Expo build config) opts out with
80
80
  a `// hex-escape: <reason>` comment that says why.
81
+ 4. **Nothing under `packages/` reaches `features/`**: no `@package/features`
82
+ import or dependency and no relative path into `features/`. Move the code
83
+ into a package and import it from features
84
+ (`scripts/verify-packages-direction.mjs`).
81
85
 
82
86
  Run: `pnpm lint` (oxlint + `scripts/lint-conventions.mjs`).
83
87