@marktiderman/genesis-cli 1.10.0 → 1.11.1
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 +5 -2
- package/dist/cli.js +165 -31
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +7 -7
- package/dist/doctor.js +164 -30
- package/dist/doctor.js.map +1 -1
- package/dist/genesis-catalog.json +34 -7
- package/dist/index.js +164 -30
- package/dist/index.js.map +1 -1
- package/dist/vite.js +164 -30
- package/dist/vite.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -358,7 +358,7 @@ Exit codes: `0` pass, `1` findings, `2` the doctor couldn't run (bad config, Gen
|
|
|
358
358
|
| `raw-color` | error | Hex and `rgb()/hsl()` literals in code and CSS, via the same lexer as the repo's `check:token-usage` (comments, issue refs and `hsl(var(--x))` are fine). A brand file that defines token values needs an `allow` entry. |
|
|
359
359
|
| `undefined-token` | error | `var(--x)` where the theme doesn't define `--x`. Tokens declared in the app's CSS (or only `tokenFiles`) and inline style custom properties count as defined; `--tw-*` and `--radix-*` are ignored. |
|
|
360
360
|
| `shadowed-export` | error | An exported value named like a Genesis export (`export function Button`). Reuse or extend it. |
|
|
361
|
-
| `duplicate-genesis-package` | warn | More than one copy of a `@marktiderman/genesis-*` package that the app can load, with each copy's path, version and the ranges that asked for it. Found by resolving
|
|
361
|
+
| `duplicate-genesis-package` | warn | More than one copy of a `@marktiderman/genesis-*` package that the app can load, with each copy's path, version and the ranges that asked for it. Found by resolving the app's dependency graph the way Node does, from each package's real folder (starting from the app's own `package.json`), so npm/yarn/bun hoisted and nested trees, pnpm's `.pnpm` store (in the app, or at the workspace root above a sub-app) and bun's isolated `.bun` store all count; a store entry nothing resolves to is ignored. Two copies are two module instances: a `DataProvider` from one is invisible to hooks from the other. A copy reached only through dev tooling (the app's `devDependencies`, or anything under `@marktiderman/genesis-cli`, wherever it's listed) is `[dev only]`: every path to it from the app runs through declared tooling (test runners, `@types/*`, linters and formatters, compilers and bundlers, Storybook, release tools, or the CLI). Other devDependencies count as runtime: a bundler ships what the app imports from them. When exactly one copy is reached from a declared runtime dependency and every other copy is dev-only, the finding is `info` (it can't split the app's contexts). Anything else warns, a copy reached through an undeclared hoisted package included. An app with no runtime dependencies at all (a bundled SPA listing everything in `devDependencies`) has its devDependencies taken as runtime. A copy that only walking up the folders finds is left out: in an app with its own install inside another app's folder (a lockfile of its own, like `apps/mobile`), a peer dependency the app doesn't declare or install is unmet rather than met by the parent's copy, and the parent's CLI isn't followed unless the app declares it. A regular dependency that resolves up to the parent still counts. |
|
|
362
362
|
| `peer-range-mismatch` | warn | An installed Genesis package's `peerDependencies` range on another Genesis package that the copy it resolves (looked up from its own folder, as Node does) doesn't satisfy: the package, the range and the installed version. Missing peers and non-semver ranges (`workspace:*`) are skipped. Ranges are read with npm's grammar (`^ ~ x - ||`, prereleases only when the range names one). A mismatch inside a dev-only copy (the CLI's own tree) is `info`. |
|
|
363
363
|
| `hand-rolled-sub-nav` | warn | A route under the layout that renders `AppShell` that switches its sections with its own page-level `<TabsList>` or `<SubNavTabs>`, when the installed Genesis has `useAppShellSubNav`. Tabs inside a card, dialog, sheet, popover, accordion, panel, table or another tab's content are fine, as are pages that call the hook. Use `useAppShellSubNav(items, { mode: "tabs" })`, `AppShellPageHeader` and `AppShellSubNavEnd` from `@marktiderman/genesis-ui/layout` ([sub-navigation](../ui/SKILL.md)). |
|
|
364
364
|
| `local-genesis-copy` | warn | An app component definition named like a component of `uiPackage` or of `componentPackages` (forms-studio's `ResourceHeader`, `SettingsSection`, `ResourceSettingsPage`, `HeadlineNumbers`, `SummaryCard`, `ShareDialog`, …): "Genesis already has X". A definition renders JSX, isn't in a file that imports the Genesis one, and is exported or lives outside the routes folder; a route's own non-exported functions and anything passed as `component` / `errorComponent` / `pendingComponent` / `notFoundComponent` (TanStack's `FormError`) are not copies. An exported genesis-ui value is `shadowed-export` instead; `const X = lazy(() => import("@marktiderman/genesis-…"))` is fine. |
|
|
@@ -396,7 +396,9 @@ components it renders (or names as `component:`), `lazy(() => import(…))` /
|
|
|
396
396
|
`lazyRouteComponent(…)`, re-exports and barrels, through relative paths, tsconfig/jsconfig
|
|
397
397
|
`paths` and `baseUrl` (following `extends`, to a file or a package's config), package.json
|
|
398
398
|
`imports` and the `@/`, `~/`, `#/` defaults. Imports it only calls (data helpers, hooks) aren't
|
|
399
|
-
followed, and an `import(…)` inside a string or
|
|
399
|
+
followed, and an `import(…)` inside a string, comment, template or regex literal isn't one (the
|
|
400
|
+
tokenizer reads regex literals and JSX text such as `Rock 'n roll`; a file it can't read for sure
|
|
401
|
+
is treated as unknown). An import that is neither an
|
|
400
402
|
app file nor an installed or declared package makes that route unsure, and the route rules don't
|
|
401
403
|
report it; it never makes a route a layout. Past six modules the trail stops as a one-hop check
|
|
402
404
|
would: the route is reported.
|
|
@@ -463,6 +465,7 @@ bodies blanked, so text inside a function body never matches; the one exception
|
|
|
463
465
|
| `migration-definer-search-path` | error | A `security definer` function or procedure without `set search_path`. Functions are keyed by name and argument types, so overloads are separate; `alter function … security definer` makes one definer, `alter function … set search_path` fixes it, and renames, replaces and drops are followed. |
|
|
464
466
|
| `migration-edited` | error | A `.sql` migration that already exists at the merge base with `supabase.base` (default `origin/main`) was modified, deleted or renamed. Applied migrations are never edited; add a new one. Skipped outside a git repo; a **warn** when the base ref isn't available. |
|
|
465
467
|
| `migration-testing-kit` | error | A migration that uses `genesis_testing`, genesis-supabase's pgTAP kit for test databases only (it signs in as anyone and resets roles). Keep it in `supabase/tests/database/000_genesis_testing.test.sql`. |
|
|
468
|
+
| `migration-view-rls` | error | A view in an exposed schema that runs as its owner once every migration has run: created without `with (security_invoker = true)`, replaced without it, or reset by `alter view … reset (security_invoker)`. A plain view reads past row level security on every table it selects from. `alter view … set (security_invoker = true)`, renames and drops are followed. A view that runs as its owner on purpose (it filters rows itself) takes an `allow` entry: `{ "rule": "migration-view-rls", "match": "public.profile_cards", "reason": "…" }`. |
|
|
466
469
|
|
|
467
470
|
**Which migrations are new.** In a git repo with the base ref, a migration is new when it was
|
|
468
471
|
added, modified or is untracked since the merge base. `since` (a file name or timestamp prefix)
|
package/dist/cli.js
CHANGED
|
@@ -2503,7 +2503,8 @@ var init_rules = __esm({
|
|
|
2503
2503
|
"migration-rls",
|
|
2504
2504
|
"migration-definer-search-path",
|
|
2505
2505
|
"migration-edited",
|
|
2506
|
-
"migration-testing-kit"
|
|
2506
|
+
"migration-testing-kit",
|
|
2507
|
+
"migration-view-rls"
|
|
2507
2508
|
];
|
|
2508
2509
|
DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
|
|
2509
2510
|
STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
|
|
@@ -3199,6 +3200,7 @@ function checkSupabasePack(ctx) {
|
|
|
3199
3200
|
checkGrants(ctx, migrations.filter((m) => isNew(m.file)), exposed);
|
|
3200
3201
|
}
|
|
3201
3202
|
checkRls(ctx, migrations, exposed);
|
|
3203
|
+
checkViewInvoker(ctx, migrations, exposed);
|
|
3202
3204
|
checkDefinerSearchPath(ctx, migrations);
|
|
3203
3205
|
checkTestingKit(ctx, migrations);
|
|
3204
3206
|
}
|
|
@@ -3328,6 +3330,50 @@ function checkRls(ctx, migrations, exposed) {
|
|
|
3328
3330
|
});
|
|
3329
3331
|
}
|
|
3330
3332
|
}
|
|
3333
|
+
function checkViewInvoker(ctx, migrations, exposed) {
|
|
3334
|
+
const views = /* @__PURE__ */ new Map();
|
|
3335
|
+
const name = String.raw`([\w$.]+)`;
|
|
3336
|
+
const invokerOn = /\bsecurity_invoker\s*(?:=\s*(?:true|on|yes|1|'true'|'on'))?\s*(?:,|\))/;
|
|
3337
|
+
for (const { file, statements } of migrations) {
|
|
3338
|
+
for (const { sql, line } of statements) {
|
|
3339
|
+
const create = new RegExp(String.raw`^create (?:or replace )?(?:temp |temporary )?(?:recursive )?view ${name}`).exec(sql);
|
|
3340
|
+
if (create) {
|
|
3341
|
+
if (/^create (?:or replace )?(?:temp|temporary) /.test(sql)) continue;
|
|
3342
|
+
const options = /^[^(]*?\bwith\s*(\([^)]*\))\s*as\b/.exec(sql)?.[1] ?? "";
|
|
3343
|
+
views.set(qualify(create[1]), { invoker: invokerOn.test(options), file, line });
|
|
3344
|
+
continue;
|
|
3345
|
+
}
|
|
3346
|
+
const alter = new RegExp(String.raw`^alter view (?:if exists )?${name} (set|reset) (\([^)]*\))`).exec(sql);
|
|
3347
|
+
if (alter && /\bsecurity_invoker\b/.test(alter[3])) {
|
|
3348
|
+
const state = views.get(qualify(alter[1]));
|
|
3349
|
+
if (state) state.invoker = alter[2] === "set" && invokerOn.test(alter[3]);
|
|
3350
|
+
continue;
|
|
3351
|
+
}
|
|
3352
|
+
const rename = new RegExp(String.raw`^alter view (?:if exists )?${name} rename to ([\w$]+)$`).exec(sql);
|
|
3353
|
+
if (rename) {
|
|
3354
|
+
const from = qualify(rename[1]);
|
|
3355
|
+
const state = views.get(from);
|
|
3356
|
+
if (state) {
|
|
3357
|
+
views.delete(from);
|
|
3358
|
+
views.set(`${schemaOf(from)}.${rename[2]}`, state);
|
|
3359
|
+
}
|
|
3360
|
+
continue;
|
|
3361
|
+
}
|
|
3362
|
+
const drop = /^drop view (?:if exists )?(.+?)(?: cascade| restrict)?$/.exec(sql);
|
|
3363
|
+
if (drop) for (const n of drop[1].split(",")) views.delete(qualify(n));
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
for (const [v, at] of views) {
|
|
3367
|
+
if (at.invoker || !exposed.has(schemaOf(v))) continue;
|
|
3368
|
+
ctx.report({
|
|
3369
|
+
rule: "migration-view-rls",
|
|
3370
|
+
file: at.file,
|
|
3371
|
+
line: at.line,
|
|
3372
|
+
subject: v,
|
|
3373
|
+
message: `${v} runs as its owner, so it reads past row level security; create it "with (security_invoker = true)" or add "alter view ${v} set (security_invoker = true);"`
|
|
3374
|
+
});
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3331
3377
|
function checkDefinerSearchPath(ctx, migrations) {
|
|
3332
3378
|
const fns = /* @__PURE__ */ new Map();
|
|
3333
3379
|
const keysFor = (sql, nameEnd, fnName) => {
|
|
@@ -3536,6 +3582,10 @@ var init_semver = __esm({
|
|
|
3536
3582
|
ver = (major, minor, patch, pre = []) => ({ major, minor, patch, pre });
|
|
3537
3583
|
}
|
|
3538
3584
|
});
|
|
3585
|
+
function nodeModulesOf(dir) {
|
|
3586
|
+
const parent = path32.dirname(dir);
|
|
3587
|
+
return path32.basename(parent).startsWith("@") ? path32.dirname(parent) : parent;
|
|
3588
|
+
}
|
|
3539
3589
|
function packagesIn(nodeModules) {
|
|
3540
3590
|
if (!existsSync(nodeModules)) return [];
|
|
3541
3591
|
const out = [];
|
|
@@ -3584,24 +3634,41 @@ function genesisInstalls(root) {
|
|
|
3584
3634
|
for (const r of roots) visit(r.dir, r.by, r.range);
|
|
3585
3635
|
while (queue.length) {
|
|
3586
3636
|
const { real: from, manifest, label } = queue.shift();
|
|
3587
|
-
const deps = { ...manifest.
|
|
3637
|
+
const deps = { ...manifest.optionalDependencies, ...manifest.dependencies };
|
|
3588
3638
|
for (const [name, range] of Object.entries(deps)) {
|
|
3589
3639
|
const dir = findPackageDir(from, name);
|
|
3590
3640
|
if (dir) visit(dir, label, range);
|
|
3591
3641
|
}
|
|
3642
|
+
for (const [name, range] of Object.entries(manifest.peerDependencies ?? {})) {
|
|
3643
|
+
if (name in deps) continue;
|
|
3644
|
+
const dir = peerOf(from, name);
|
|
3645
|
+
if (dir) visit(dir, label, range);
|
|
3646
|
+
}
|
|
3592
3647
|
}
|
|
3593
3648
|
};
|
|
3649
|
+
const peerOf = (from, name) => {
|
|
3650
|
+
const dir = findPackageDir(from, name);
|
|
3651
|
+
if (!dir) return null;
|
|
3652
|
+
if (!ownInstall || name in declared) return dir;
|
|
3653
|
+
const realDir = real(dir);
|
|
3654
|
+
if (realDir.startsWith(realRoot + path32.sep)) return dir;
|
|
3655
|
+
return nodeModulesOf(realDir) === nodeModulesOf(from) ? dir : null;
|
|
3656
|
+
};
|
|
3594
3657
|
const rootsOf = (deps, by) => Object.entries(deps).flatMap(([name, range]) => {
|
|
3595
3658
|
const dir = findPackageDir(root, name);
|
|
3596
3659
|
return dir ? [{ dir, by, ...range ? { range } : {} }] : [];
|
|
3597
3660
|
});
|
|
3598
3661
|
const app = readManifest(root);
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3662
|
+
const ownInstall = LOCKFILES.some((f) => existsSync(path32.join(root, f)));
|
|
3663
|
+
const declared = { ...app?.devDependencies, ...app?.peerDependencies, ...app?.optionalDependencies, ...app?.dependencies };
|
|
3664
|
+
const declaredDev = Object.entries(app?.devDependencies ?? {});
|
|
3665
|
+
const runtimeDeps = {
|
|
3666
|
+
...Object.fromEntries(declaredDev.filter(([n]) => !NON_SHIPPING.test(n))),
|
|
3667
|
+
...app?.peerDependencies,
|
|
3668
|
+
...app?.optionalDependencies,
|
|
3669
|
+
...app?.dependencies
|
|
3670
|
+
};
|
|
3671
|
+
const devDeps = Object.fromEntries(declaredDev.filter(([n]) => NON_SHIPPING.test(n) && !(n in runtimeDeps)));
|
|
3605
3672
|
walk2("runtime", rootsOf(runtimeDeps, "the app"));
|
|
3606
3673
|
const top = path32.join(root, "node_modules");
|
|
3607
3674
|
walk2(
|
|
@@ -3612,7 +3679,7 @@ function genesisInstalls(root) {
|
|
|
3612
3679
|
}).map((dir) => ({ dir, by: "hoisted, not a direct dependency" }))
|
|
3613
3680
|
);
|
|
3614
3681
|
const devRoots = { ...devDeps };
|
|
3615
|
-
for (const tool of DEV_TOOLS) if (!(tool in devRoots)) devRoots[tool] = runtimeDeps[tool];
|
|
3682
|
+
for (const tool of DEV_TOOLS) if (!(tool in devRoots) && tool in runtimeDeps) devRoots[tool] = runtimeDeps[tool];
|
|
3616
3683
|
walk2("dev", rootsOf(devRoots, "the app (dev)"));
|
|
3617
3684
|
for (const [key2, copy] of copies) {
|
|
3618
3685
|
const kinds = via.get(key2);
|
|
@@ -3672,13 +3739,14 @@ function checkPeerRanges(ctx) {
|
|
|
3672
3739
|
}
|
|
3673
3740
|
}
|
|
3674
3741
|
}
|
|
3675
|
-
var GENESIS, DEV_TOOLS, readManifest, real;
|
|
3742
|
+
var GENESIS, DEV_TOOLS, NON_SHIPPING, readManifest, real, LOCKFILES;
|
|
3676
3743
|
var init_installs = __esm({
|
|
3677
3744
|
"src/doctor/installs.ts"() {
|
|
3678
3745
|
init_genesis();
|
|
3679
3746
|
init_semver();
|
|
3680
3747
|
GENESIS = /^@marktiderman\/genesis(?:-[\w.-]+)?$/;
|
|
3681
3748
|
DEV_TOOLS = /* @__PURE__ */ new Set(["@marktiderman/genesis-cli"]);
|
|
3749
|
+
NON_SHIPPING = /^(?:@marktiderman\/genesis-cli|vitest|@vitest\/.+|jest|jest-.+|@jest\/.+|ts-jest|babel-jest|mocha|ava|c8|nyc|@playwright\/test|playwright|cypress|@testing-library\/.+|happy-dom|jsdom|msw|@types\/.+|typescript|tsx|ts-node|eslint|eslint-.+|@eslint\/.+|@typescript-eslint\/.+|typescript-eslint|prettier|prettier-.+|@biomejs\/.+|oxlint|vite|@vitejs\/.+|vite-plugin-.+|webpack|webpack-.+|rollup|@rollup\/.+|esbuild|tsup|turbo|@storybook\/.+|storybook|@changesets\/.+|husky|lint-staged|wrangler|knip|concurrently|npm-run-all2?|rimraf|cross-env|dotenv-cli)$/;
|
|
3682
3750
|
readManifest = (dir) => {
|
|
3683
3751
|
try {
|
|
3684
3752
|
return JSON.parse(readFileSync(path32.join(dir, "package.json"), "utf8"));
|
|
@@ -3693,6 +3761,7 @@ var init_installs = __esm({
|
|
|
3693
3761
|
return p;
|
|
3694
3762
|
}
|
|
3695
3763
|
};
|
|
3764
|
+
LOCKFILES = ["bun.lock", "bun.lockb", "package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "pnpm-lock.yaml"];
|
|
3696
3765
|
}
|
|
3697
3766
|
});
|
|
3698
3767
|
function stripForImports(code) {
|
|
@@ -3702,11 +3771,21 @@ function stripForImports(code) {
|
|
|
3702
3771
|
const templates = [];
|
|
3703
3772
|
let depth = 0;
|
|
3704
3773
|
let i = 0;
|
|
3774
|
+
let sure = true;
|
|
3705
3775
|
const isSpecifier = () => /(?:\bfrom|(?:^|[;{}\n])\s*import|\bimport\s*\(|\brequire\s*\()\s*$/.test(out.slice(-40).join(""));
|
|
3706
|
-
const
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3776
|
+
const before = () => out.slice(-24).join("");
|
|
3777
|
+
const KEYWORD = /(?:^|[^\w$.])(?:return|typeof|instanceof|case|do|else|in|of|new|delete|void|throw|yield|await|from|import|export|default|require)\s*$/;
|
|
3778
|
+
const startsExpression = (b) => {
|
|
3779
|
+
const t = b.replace(/\s+$/, "");
|
|
3780
|
+
if (!t) return true;
|
|
3781
|
+
if (KEYWORD.test(b)) return true;
|
|
3782
|
+
return /[([{,;:=!&|?+\-*%<>~^}]$/.test(t);
|
|
3783
|
+
};
|
|
3784
|
+
const exprStart = () => startsExpression(before());
|
|
3785
|
+
const taggedTemplate = () => {
|
|
3786
|
+
const b = out.slice(-48).join("");
|
|
3787
|
+
const m = /([A-Za-z_$][\w$.]*)$/.exec(b);
|
|
3788
|
+
return m !== null && startsExpression(b.slice(0, b.length - m[1].length));
|
|
3710
3789
|
};
|
|
3711
3790
|
const templateBody = () => {
|
|
3712
3791
|
while (i < n) {
|
|
@@ -3729,8 +3808,9 @@ function stripForImports(code) {
|
|
|
3729
3808
|
i++;
|
|
3730
3809
|
}
|
|
3731
3810
|
}
|
|
3811
|
+
sure = false;
|
|
3732
3812
|
};
|
|
3733
|
-
while (i < n) {
|
|
3813
|
+
while (i < n && sure) {
|
|
3734
3814
|
const ch = code[i];
|
|
3735
3815
|
const next = code[i + 1];
|
|
3736
3816
|
if (ch === "/" && next === "/") {
|
|
@@ -3749,7 +3829,45 @@ function stripForImports(code) {
|
|
|
3749
3829
|
out.push(" ");
|
|
3750
3830
|
i += 2;
|
|
3751
3831
|
}
|
|
3752
|
-
} else if (
|
|
3832
|
+
} else if (ch === "/" && next !== ">" && code[i - 1] !== "<" && exprStart()) {
|
|
3833
|
+
const afterBrace = /[}>]\s*$/.test(before());
|
|
3834
|
+
const start = i;
|
|
3835
|
+
const mark = out.length;
|
|
3836
|
+
out.push("/");
|
|
3837
|
+
i++;
|
|
3838
|
+
let inClass = false;
|
|
3839
|
+
for (; ; ) {
|
|
3840
|
+
const c = code[i];
|
|
3841
|
+
if (c === void 0 || c === "\n") {
|
|
3842
|
+
if (afterBrace) {
|
|
3843
|
+
out.length = mark;
|
|
3844
|
+
out.push("/");
|
|
3845
|
+
i = start + 1;
|
|
3846
|
+
} else sure = false;
|
|
3847
|
+
break;
|
|
3848
|
+
}
|
|
3849
|
+
if (c === "\\") {
|
|
3850
|
+
out.push(" ", blank(code[i + 1] ?? ""));
|
|
3851
|
+
i += 2;
|
|
3852
|
+
continue;
|
|
3853
|
+
}
|
|
3854
|
+
i++;
|
|
3855
|
+
if (c === "[") inClass = true;
|
|
3856
|
+
else if (c === "]") inClass = false;
|
|
3857
|
+
else if (c === "/" && !inClass) {
|
|
3858
|
+
if (afterBrace && /[<>]/.test(code.slice(start + 1, i - 1))) {
|
|
3859
|
+
out.length = mark;
|
|
3860
|
+
out.push("/");
|
|
3861
|
+
i = start + 1;
|
|
3862
|
+
break;
|
|
3863
|
+
}
|
|
3864
|
+
out.push("/");
|
|
3865
|
+
break;
|
|
3866
|
+
}
|
|
3867
|
+
out.push(" ");
|
|
3868
|
+
}
|
|
3869
|
+
if (out.length > mark + 1 || i > start + 1) while (i < n && /[a-z]/.test(code[i])) out.push(code[i++]);
|
|
3870
|
+
} else if ((ch === '"' || ch === "'") && exprStart()) {
|
|
3753
3871
|
const keep = isSpecifier();
|
|
3754
3872
|
out.push(ch);
|
|
3755
3873
|
i++;
|
|
@@ -3762,11 +3880,12 @@ function stripForImports(code) {
|
|
|
3762
3880
|
i++;
|
|
3763
3881
|
}
|
|
3764
3882
|
}
|
|
3765
|
-
if (i
|
|
3883
|
+
if (code[i] !== ch) sure = false;
|
|
3884
|
+
else {
|
|
3766
3885
|
out.push(code[i]);
|
|
3767
3886
|
i++;
|
|
3768
3887
|
}
|
|
3769
|
-
} else if (ch === "`") {
|
|
3888
|
+
} else if (ch === "`" && (exprStart() || taggedTemplate())) {
|
|
3770
3889
|
out.push("`");
|
|
3771
3890
|
i++;
|
|
3772
3891
|
templateBody();
|
|
@@ -3783,7 +3902,7 @@ function stripForImports(code) {
|
|
|
3783
3902
|
i++;
|
|
3784
3903
|
}
|
|
3785
3904
|
}
|
|
3786
|
-
return out.join("");
|
|
3905
|
+
return sure && templates.length === 0 ? out.join("") : null;
|
|
3787
3906
|
}
|
|
3788
3907
|
function bindings(clause) {
|
|
3789
3908
|
const out = [];
|
|
@@ -3896,6 +4015,11 @@ function createTrail(ctx) {
|
|
|
3896
4015
|
const files = [];
|
|
3897
4016
|
let lost = false;
|
|
3898
4017
|
const code = stripped(file);
|
|
4018
|
+
if (code === null) {
|
|
4019
|
+
const out2 = { files: [], lost: true };
|
|
4020
|
+
importsCache.set(file.absolutePath, out2);
|
|
4021
|
+
return out2;
|
|
4022
|
+
}
|
|
3899
4023
|
const used = new Set(renderedElements(code).map((e) => e.split(".")[0]));
|
|
3900
4024
|
for (const m of code.matchAll(/\b\w*[cC]omponent\s*:\s*([A-Za-z_$][\w$]*)/g)) used.add(m[1]);
|
|
3901
4025
|
for (const m of code.matchAll(/\bexport\s+default\s+([A-Za-z_$][\w$]*)/g)) used.add(m[1]);
|
|
@@ -3932,20 +4056,23 @@ function createTrail(ctx) {
|
|
|
3932
4056
|
};
|
|
3933
4057
|
const strippedCache = /* @__PURE__ */ new Map();
|
|
3934
4058
|
const stripped = (file) => {
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
return c;
|
|
4059
|
+
if (!strippedCache.has(file.absolutePath)) strippedCache.set(file.absolutePath, stripForImports(file.code));
|
|
4060
|
+
return strippedCache.get(file.absolutePath);
|
|
3938
4061
|
};
|
|
3939
4062
|
const memo = /* @__PURE__ */ new WeakMap();
|
|
3940
4063
|
const reach = (file, test2, depth, seen) => {
|
|
3941
4064
|
let cache = memo.get(test2);
|
|
3942
|
-
if (!cache) memo.set(test2, cache = /* @__PURE__ */ new Map());
|
|
4065
|
+
if (!cache) memo.set(test2, cache = { free: /* @__PURE__ */ new Map(), cut: /* @__PURE__ */ new Map() });
|
|
3943
4066
|
const k = `${file.absolutePath}\0${depth}`;
|
|
3944
|
-
const
|
|
3945
|
-
if (
|
|
4067
|
+
const free = cache.free.get(k);
|
|
4068
|
+
if (free) return [free, /* @__PURE__ */ new Set()];
|
|
4069
|
+
const reusable = cache.cut.get(k)?.find((e) => e.cut.every((m) => seen.has(m)));
|
|
4070
|
+
if (reusable) return [reusable.result, new Set(reusable.cut)];
|
|
3946
4071
|
let result;
|
|
3947
|
-
|
|
3948
|
-
|
|
4072
|
+
const cut = /* @__PURE__ */ new Set();
|
|
4073
|
+
const code = stripped(file);
|
|
4074
|
+
if (code === null) result = "unknown";
|
|
4075
|
+
else if (test2(code)) result = "yes";
|
|
3949
4076
|
else {
|
|
3950
4077
|
const { files, lost } = importsOf(file);
|
|
3951
4078
|
let unknown = lost && depth > 0;
|
|
@@ -3954,7 +4081,7 @@ function createTrail(ctx) {
|
|
|
3954
4081
|
seen.add(file.absolutePath);
|
|
3955
4082
|
for (const abs of files) {
|
|
3956
4083
|
if (seen.has(abs)) {
|
|
3957
|
-
cut
|
|
4084
|
+
cut.add(abs);
|
|
3958
4085
|
continue;
|
|
3959
4086
|
}
|
|
3960
4087
|
const target = read(abs);
|
|
@@ -3963,7 +4090,7 @@ function createTrail(ctx) {
|
|
|
3963
4090
|
continue;
|
|
3964
4091
|
}
|
|
3965
4092
|
const [r, c] = reach(target, test2, depth - 1, seen);
|
|
3966
|
-
|
|
4093
|
+
for (const m of c) cut.add(m);
|
|
3967
4094
|
if (r === "yes") {
|
|
3968
4095
|
result = "yes";
|
|
3969
4096
|
break;
|
|
@@ -3971,11 +4098,18 @@ function createTrail(ctx) {
|
|
|
3971
4098
|
if (r === "unknown") unknown = true;
|
|
3972
4099
|
}
|
|
3973
4100
|
seen.delete(file.absolutePath);
|
|
4101
|
+
cut.delete(file.absolutePath);
|
|
3974
4102
|
}
|
|
3975
4103
|
if (result === "no" && unknown) result = "unknown";
|
|
3976
4104
|
}
|
|
3977
|
-
if (result === "yes" ||
|
|
3978
|
-
|
|
4105
|
+
if (result === "yes" || cut.size === 0) {
|
|
4106
|
+
cache.free.set(k, result);
|
|
4107
|
+
return [result, /* @__PURE__ */ new Set()];
|
|
4108
|
+
}
|
|
4109
|
+
const entries = cache.cut.get(k) ?? [];
|
|
4110
|
+
entries.push({ cut: [...cut], result });
|
|
4111
|
+
cache.cut.set(k, entries);
|
|
4112
|
+
return [result, cut];
|
|
3979
4113
|
};
|
|
3980
4114
|
return { reach: (file, test2, depth = TRAIL_DEPTH) => reach(file, test2, depth, /* @__PURE__ */ new Set())[0] };
|
|
3981
4115
|
}
|