@marktiderman/genesis-cli 1.12.0 → 1.13.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 +10 -4
- package/dist/cli.js +83 -36
- package/dist/cli.js.map +1 -1
- package/dist/doctor.js +23 -11
- package/dist/doctor.js.map +1 -1
- package/dist/genesis-catalog.json +54 -15
- package/dist/index.d.ts +11 -1
- package/dist/index.js +81 -35
- package/dist/index.js.map +1 -1
- package/dist/vite.js +23 -11
- package/dist/vite.js.map +1 -1
- package/package.json +3 -3
package/dist/vite.js
CHANGED
|
@@ -843,7 +843,9 @@ ${globs.join("\n")}`;
|
|
|
843
843
|
for (const dir of [...dirs].sort()) {
|
|
844
844
|
const manifest = path14.join(dir, "package.json");
|
|
845
845
|
if (!existsSync(manifest)) continue;
|
|
846
|
-
if (!inside(real2, realpathSync(dir)))
|
|
846
|
+
if (!inside(real2, realpathSync(dir))) {
|
|
847
|
+
throw new LocalPackagesError(`${path14.relative(appRoot, dir) || dir} is outside the repository; localPackages may only list folders inside it`);
|
|
848
|
+
}
|
|
847
849
|
let pkg;
|
|
848
850
|
try {
|
|
849
851
|
pkg = JSON.parse(readFileSync(manifest, "utf8"));
|
|
@@ -1561,7 +1563,7 @@ function namedImportsFrom(code, pkg) {
|
|
|
1561
1563
|
// src/doctor/native.ts
|
|
1562
1564
|
var SCRIPT_EXTS3 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
|
|
1563
1565
|
var JSX_EXTS3 = /* @__PURE__ */ new Set([".tsx", ".jsx"]);
|
|
1564
|
-
var LAYOUT_NAME = /(?:Page|Screen|ScreenContainer)$/;
|
|
1566
|
+
var LAYOUT_NAME = /(?:Page|Screen|ScreenContainer)$|^NativeResourceView$/;
|
|
1565
1567
|
var NON_SCREEN_ROUTE = /(?:^|\/)(?:_layout|\+html|\+native-intent|\+middleware)\.[jt]sx?$|\+api\.[jt]sx?$/;
|
|
1566
1568
|
var PART_HEADER = /(?:Section|List|Card|Dialog|Table|Group|Column|Row|Cell|Accordion|Sheet|Drawer|Modal|Popover|Menu|Panel|Form)Header$/;
|
|
1567
1569
|
var HIDES_HEADER = /\bheaderShown\s*(?::|=\s*\{)\s*false\b/;
|
|
@@ -2358,7 +2360,7 @@ var SOURCE = /\.(?:[cm]?[jt]sx?)$/;
|
|
|
2358
2360
|
var SKIP_DIRS2 = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage", ".turbo"]);
|
|
2359
2361
|
var BUILTINS = new Set(builtinModules.flatMap((m) => [m, `node:${m}`]));
|
|
2360
2362
|
var IMPORT = /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*)["']([^"']+)["']/g;
|
|
2361
|
-
var TYPE_ONLY = /\b(?:import|export)\s+type\
|
|
2363
|
+
var TYPE_ONLY = /\b(?:import|export)\s+type\s+(?:\{[^}]*\}|\*\s+as\s+[\w$]+|\*|[\w$]+)\s*from\s*["'][^"']+["']/g;
|
|
2362
2364
|
function sourceFiles(dir, rel = "") {
|
|
2363
2365
|
const out = [];
|
|
2364
2366
|
for (const entry of readdirSync(path14.join(dir, rel)).sort()) {
|
|
@@ -2497,7 +2499,7 @@ function checkExports(ctx, pkg, json) {
|
|
|
2497
2499
|
};
|
|
2498
2500
|
walk(json.exports);
|
|
2499
2501
|
for (const t of targets) {
|
|
2500
|
-
if (!t.startsWith("./") || t.includes("*") ||
|
|
2502
|
+
if (!t.startsWith("./") || t.includes("*") || !/\.(?:[cm]?tsx?|json)$/.test(t) || /\.d\.[cm]?ts$/.test(t)) continue;
|
|
2501
2503
|
if (!existsSync(path14.join(pkg.dir, t))) {
|
|
2502
2504
|
ctx.report({ rule: "package-export-missing", file: `${pkg.rel}/package.json`, subject: t, message: `${pkg.name} exports ${t}, which doesn't exist` });
|
|
2503
2505
|
}
|
|
@@ -2528,10 +2530,13 @@ function checkRegistered(ctx, pkg) {
|
|
|
2528
2530
|
} catch {
|
|
2529
2531
|
return;
|
|
2530
2532
|
}
|
|
2533
|
+
const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
|
|
2534
|
+
const forms = /* @__PURE__ */ new Set([pkg.rel]);
|
|
2535
|
+
if (top) forms.add(path14.relative(top, realpathSync(pkg.dir)).split(path14.sep).join("/"));
|
|
2531
2536
|
const covered = (doc.features ?? []).some(
|
|
2532
2537
|
(f) => (f.links?.code ?? []).some((c) => {
|
|
2533
2538
|
const norm = c.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
2534
|
-
return norm ===
|
|
2539
|
+
return [...forms].some((rel) => norm === rel || norm.startsWith(`${rel}/`) || rel.startsWith(`${norm}/`));
|
|
2535
2540
|
})
|
|
2536
2541
|
);
|
|
2537
2542
|
if (!covered) {
|
|
@@ -2555,8 +2560,12 @@ function mergeBaseOf(root, base) {
|
|
|
2555
2560
|
return sha ? { sha } : { reason: `HEAD has no merge base with ${base} (fetch with depth 0)` };
|
|
2556
2561
|
}
|
|
2557
2562
|
function checkChanges(ctx, pkg, json, base, mergeBase) {
|
|
2558
|
-
const
|
|
2559
|
-
|
|
2563
|
+
const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
|
|
2564
|
+
if (!top) return;
|
|
2565
|
+
const appRelative = (fromTop) => path14.relative(realpathSync(ctx.root), path14.join(top, fromTop)).split(path14.sep).join("/");
|
|
2566
|
+
const inRepo = path14.relative(top, realpathSync(pkg.dir)).split(path14.sep).join("/");
|
|
2567
|
+
const diff = (git(top, ["diff", "--name-status", "-M", mergeBase, "--", inRepo]) ?? "").split("\n").filter(Boolean).map((row) => row.split(" ").map((cell, i) => i === 0 ? cell : appRelative(cell)).join(" ")).join("\n");
|
|
2568
|
+
const untracked = (git(top, ["ls-files", "--others", "--exclude-standard", "--", inRepo]) ?? "").split("\n").filter(Boolean).map(appRelative);
|
|
2560
2569
|
const changed = [...diff.split("\n").filter(Boolean).map((row) => row.split(" ").at(-1)), ...untracked].filter(
|
|
2561
2570
|
(f) => !/(^|\/)(CHANGELOG\.md|node_modules\/)/.test(f)
|
|
2562
2571
|
);
|
|
@@ -2577,7 +2586,6 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
|
|
|
2577
2586
|
const now = typeof json.version === "string" ? parseVersion(json.version) : null;
|
|
2578
2587
|
const was = typeof versionBefore === "string" ? parseVersion(versionBefore) : null;
|
|
2579
2588
|
const bumped = before === null || now !== null && was !== null && compareVersions(now, was) > 0;
|
|
2580
|
-
const top = git(ctx.root, ["rev-parse", "--show-toplevel"])?.trim();
|
|
2581
2589
|
const changesets = top ? (git(top, ["diff", "--name-only", "--diff-filter=A", mergeBase, "--", ".changeset"]) ?? "").split("\n").concat((git(top, ["ls-files", "--others", "--exclude-standard", "--", ".changeset"]) ?? "").split("\n")).filter((f) => f.endsWith(".md")).map((f) => path14.join(top, f)) : [];
|
|
2582
2590
|
const naming = changesets.filter((p) => existsSync(p) && changesetNames(readFileSync(p, "utf8")).has(json.name));
|
|
2583
2591
|
const named = naming.length > 0;
|
|
@@ -2595,6 +2603,9 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
|
|
|
2595
2603
|
const registry = (git(ctx.root, ["diff", "--relative", "--name-only", mergeBase, "--", "features.ts", "src/features.ts"]) ?? "").trim();
|
|
2596
2604
|
if (!registry) ctx.report({ rule: "package-unversioned-change", level: "warn", file: `${pkg.rel}/package.json`, message: `${pkg.name}'s blocks or exports changed but features.ts didn't; update the features they belong to` });
|
|
2597
2605
|
}
|
|
2606
|
+
if (bumped && !named && before !== null) {
|
|
2607
|
+
ctx.report({ rule: "package-unversioned-change", level: "warn", file: `${pkg.rel}/package.json`, message: `${pkg.name}'s version went up without a changeset; add one with a "Features:" line so the change is recorded` });
|
|
2608
|
+
}
|
|
2598
2609
|
if (!bumped && !named) {
|
|
2599
2610
|
ctx.report({
|
|
2600
2611
|
rule: "package-unversioned-change",
|
|
@@ -3391,8 +3402,9 @@ var CONTAINER = /(?:Card|CardContent|Dialog|DialogContent|Sheet|SheetContent|Dra
|
|
|
3391
3402
|
var SWITCHER = /<(TabsList|SubNavTabs)(?=[\s>/])/g;
|
|
3392
3403
|
var SHELL = /<AppShell(?=[\s>/])/;
|
|
3393
3404
|
var GENESIS_PACKAGE2 = /^@marktiderman\/genesis(?:-[\w-]+)?(?:\/|$)/;
|
|
3394
|
-
var PAGE_LAYOUT = /^(?!Breadcrumb)[A-Z]\w*(?:Page|PageShell)$/;
|
|
3395
|
-
var
|
|
3405
|
+
var PAGE_LAYOUT = /^(?:(?!Breadcrumb)[A-Z]\w*(?:Page|PageShell)|ResourceView)$/;
|
|
3406
|
+
var EMBEDDED_RESOURCE_VIEW = /<ResourceView\b[^>]*?\blayout\s*=\s*(?:(["'`]) {8}\1|\{\s*(["'`]) {8}\2\s*\})[^>]*>/g;
|
|
3407
|
+
var PACKAGE_SCREEN = /^(?:(?!Breadcrumb)[A-Z]\w*(?:Page|PageShell|Screen|Workspace)|ResourceView)$/;
|
|
3396
3408
|
var isNative = (ctx) => ctx.config.packs?.includes("native") ?? false;
|
|
3397
3409
|
var rendersRe = (names) => {
|
|
3398
3410
|
const list = [...names];
|
|
@@ -3506,7 +3518,7 @@ function checkPageLayouts(ctx) {
|
|
|
3506
3518
|
const rendersLayout = (code) => {
|
|
3507
3519
|
const names = new Set(layouts);
|
|
3508
3520
|
for (const n of namedImportsFrom(code, GENESIS_PACKAGE2)) if (PACKAGE_SCREEN.test(n)) names.add(n);
|
|
3509
|
-
return rendersRe(names)?.test(code) ?? false;
|
|
3521
|
+
return rendersRe(names)?.test(code.replace(EMBEDDED_RESOURCE_VIEW, "")) ?? false;
|
|
3510
3522
|
};
|
|
3511
3523
|
const cache2 = /* @__PURE__ */ new Map();
|
|
3512
3524
|
const provides = (r) => {
|