@marktiderman/genesis-cli 1.13.2 → 1.14.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 +12 -3
- package/dist/cli.js +538 -106
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +1 -1
- package/dist/doctor.js +361 -1
- package/dist/doctor.js.map +1 -1
- package/dist/genesis-catalog.json +16 -288
- package/dist/index.js +369 -9
- package/dist/index.js.map +1 -1
- package/dist/vite.js +361 -1
- package/dist/vite.js.map +1 -1
- package/package.json +4 -4
package/dist/vite.js
CHANGED
|
@@ -366,7 +366,7 @@ function globToRegExp(glob) {
|
|
|
366
366
|
}
|
|
367
367
|
function globMatcher(globs) {
|
|
368
368
|
const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
|
|
369
|
-
return (
|
|
369
|
+
return (path23) => res.some((re) => re.test(path23));
|
|
370
370
|
}
|
|
371
371
|
var DEFAULT_UI_PACKAGE = "@marktiderman/genesis-ui";
|
|
372
372
|
var NATIVE_UI_PACKAGE = "@marktiderman/genesis-ui-native";
|
|
@@ -1233,6 +1233,11 @@ var BUILTIN_RULES = [
|
|
|
1233
1233
|
"page-layout",
|
|
1234
1234
|
// dates
|
|
1235
1235
|
"iso-date-slice",
|
|
1236
|
+
// Genesis API usage (api-usage.ts)
|
|
1237
|
+
"resource-view-tree",
|
|
1238
|
+
"studio-server-auth-import",
|
|
1239
|
+
"removed-scope-name",
|
|
1240
|
+
"scope-practice-id",
|
|
1236
1241
|
// native pack
|
|
1237
1242
|
"native-raw-primitive",
|
|
1238
1243
|
"native-literal-color",
|
|
@@ -3560,6 +3565,358 @@ function checkIsoDateSlices(ctx) {
|
|
|
3560
3565
|
}
|
|
3561
3566
|
}
|
|
3562
3567
|
|
|
3568
|
+
// src/upgrade/scope-names.ts
|
|
3569
|
+
var IMPORTS_GENESIS = /\bfrom\s*["']@marktiderman\/genesis[\w/-]*["']/;
|
|
3570
|
+
function maskComments(text) {
|
|
3571
|
+
const out = text.split("");
|
|
3572
|
+
let quote = null;
|
|
3573
|
+
for (let i = 0; i < text.length; i++) {
|
|
3574
|
+
const ch = text[i];
|
|
3575
|
+
if (quote) {
|
|
3576
|
+
if (ch === "\\") i++;
|
|
3577
|
+
else if (ch === quote) quote = null;
|
|
3578
|
+
continue;
|
|
3579
|
+
}
|
|
3580
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
3581
|
+
quote = ch;
|
|
3582
|
+
continue;
|
|
3583
|
+
}
|
|
3584
|
+
if (ch === "/" && (text[i + 1] === "/" || text[i + 1] === "*")) {
|
|
3585
|
+
const line = text[i + 1] === "/";
|
|
3586
|
+
const end = line ? text.indexOf("\n", i) === -1 ? text.length : text.indexOf("\n", i) : text.indexOf("*/", i + 2) === -1 ? text.length : text.indexOf("*/", i + 2) + 2;
|
|
3587
|
+
for (let k = i; k < end; k++) if (out[k] !== "\n") out[k] = " ";
|
|
3588
|
+
i = end - 1;
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
return out.join("");
|
|
3592
|
+
}
|
|
3593
|
+
var within = (spans, at) => spans.some(([a, b]) => at >= a && at < b);
|
|
3594
|
+
function importedFromGenesis(text, name) {
|
|
3595
|
+
for (const m of text.matchAll(/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']@marktiderman\/genesis[\w/-]*["']/g)) {
|
|
3596
|
+
for (const part of m[1].split(",")) {
|
|
3597
|
+
const local = part.trim().replace(/^type\s+/, "").split(/\s+as\s+/).pop()?.trim();
|
|
3598
|
+
if (local === name) return true;
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
return false;
|
|
3602
|
+
}
|
|
3603
|
+
var OPEN = { "(": ")", "{": "}", "[": "]" };
|
|
3604
|
+
function matching(text, open) {
|
|
3605
|
+
const stack = [];
|
|
3606
|
+
let quote = null;
|
|
3607
|
+
for (let i = open; i < text.length; i++) {
|
|
3608
|
+
const ch = text[i];
|
|
3609
|
+
if (quote) {
|
|
3610
|
+
if (ch === "\\") i++;
|
|
3611
|
+
else if (ch === quote) quote = null;
|
|
3612
|
+
continue;
|
|
3613
|
+
}
|
|
3614
|
+
if (ch === '"' || ch === "'" || ch === "`") quote = ch;
|
|
3615
|
+
else if (OPEN[ch]) stack.push(OPEN[ch]);
|
|
3616
|
+
else if (ch === ")" || ch === "}" || ch === "]") {
|
|
3617
|
+
stack.pop();
|
|
3618
|
+
if (stack.length === 0) return i + 1;
|
|
3619
|
+
}
|
|
3620
|
+
}
|
|
3621
|
+
return text.length;
|
|
3622
|
+
}
|
|
3623
|
+
function matchingBack(text, close) {
|
|
3624
|
+
let depth = 0;
|
|
3625
|
+
for (let i = close; i >= 0; i--) {
|
|
3626
|
+
const ch = text[i];
|
|
3627
|
+
if (ch === "}") depth++;
|
|
3628
|
+
else if (ch === "{") {
|
|
3629
|
+
depth--;
|
|
3630
|
+
if (depth === 0) return i;
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
return 0;
|
|
3634
|
+
}
|
|
3635
|
+
function callSpans(text, name) {
|
|
3636
|
+
const out = [];
|
|
3637
|
+
for (const m of text.matchAll(new RegExp(`\\b${name}\\s*(?:<[^()]*?>)?\\s*\\(`, "g"))) {
|
|
3638
|
+
const open = m.index + m[0].length - 1;
|
|
3639
|
+
out.push([open, matching(text, open)]);
|
|
3640
|
+
}
|
|
3641
|
+
return out;
|
|
3642
|
+
}
|
|
3643
|
+
function typedObjectSpans(text, types) {
|
|
3644
|
+
const out = [];
|
|
3645
|
+
if (types.length === 0) return out;
|
|
3646
|
+
const names = `(?:(?:Partial|Readonly|Required|Pick|Omit)\\s*<\\s*)?(?:${types.join("|")})`;
|
|
3647
|
+
for (const m of text.matchAll(new RegExp(`:\\s*${names}\\b(?:<[^=]*?>)?[^=;{]*?=\\s*\\{`, "g"))) {
|
|
3648
|
+
const open = m.index + m[0].length - 1;
|
|
3649
|
+
out.push([open, matching(text, open)]);
|
|
3650
|
+
}
|
|
3651
|
+
for (const m of text.matchAll(new RegExp(`\\}\\s*(?:satisfies|as)\\s+${names}\\b`, "g"))) {
|
|
3652
|
+
const close = m.index;
|
|
3653
|
+
out.push([matchingBack(text, close), close + 1]);
|
|
3654
|
+
}
|
|
3655
|
+
return out;
|
|
3656
|
+
}
|
|
3657
|
+
function tagSpans(text, tag) {
|
|
3658
|
+
const out = [];
|
|
3659
|
+
for (const m of text.matchAll(new RegExp(`<${tag}\\b`, "g"))) {
|
|
3660
|
+
let depth = 0;
|
|
3661
|
+
let quote = null;
|
|
3662
|
+
let end = text.length;
|
|
3663
|
+
for (let i = m.index + 1; i < text.length; i++) {
|
|
3664
|
+
const ch = text[i];
|
|
3665
|
+
if (quote) {
|
|
3666
|
+
if (ch === "\\") i++;
|
|
3667
|
+
else if (ch === quote) quote = null;
|
|
3668
|
+
continue;
|
|
3669
|
+
}
|
|
3670
|
+
if (ch === '"' || ch === "'" || ch === "`") quote = ch;
|
|
3671
|
+
else if (ch === "{") depth++;
|
|
3672
|
+
else if (ch === "}") depth--;
|
|
3673
|
+
else if (ch === ">" && depth === 0) {
|
|
3674
|
+
end = i + 1;
|
|
3675
|
+
break;
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
out.push([m.index, end]);
|
|
3679
|
+
}
|
|
3680
|
+
return out;
|
|
3681
|
+
}
|
|
3682
|
+
function attributeObjectSpans(text, tag, attr) {
|
|
3683
|
+
const out = [];
|
|
3684
|
+
for (const [a, b] of tagSpans(text, tag)) {
|
|
3685
|
+
const inTag = text.slice(a, b);
|
|
3686
|
+
for (const m of inTag.matchAll(new RegExp(`\\s${attr}\\s*=\\s*\\{\\s*\\{`, "g"))) {
|
|
3687
|
+
const open = a + m.index + m[0].length - 1;
|
|
3688
|
+
out.push([open, matching(text, open)]);
|
|
3689
|
+
}
|
|
3690
|
+
}
|
|
3691
|
+
return out;
|
|
3692
|
+
}
|
|
3693
|
+
function zoneBindings(text, hook, type) {
|
|
3694
|
+
const names = /* @__PURE__ */ new Set();
|
|
3695
|
+
if (hook) {
|
|
3696
|
+
for (const m of text.matchAll(/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::\s*DisplayTimeZones\s*)?=\s*useDisplayTimeZones\(\)/g)) names.add(m[1]);
|
|
3697
|
+
}
|
|
3698
|
+
if (type) for (const m of text.matchAll(/\b([A-Za-z_$][\w$]*)\s*\??\s*:\s*DisplayTimeZones\b/g)) names.add(m[1]);
|
|
3699
|
+
return [...names];
|
|
3700
|
+
}
|
|
3701
|
+
var escape = (name) => name.replace(/\$/g, "\\$");
|
|
3702
|
+
function findRemovedScopeNames(source) {
|
|
3703
|
+
const text = maskComments(source);
|
|
3704
|
+
if (!IMPORTS_GENESIS.test(text)) return [];
|
|
3705
|
+
const out = [];
|
|
3706
|
+
const has = (name) => importedFromGenesis(text, name);
|
|
3707
|
+
const viewSpans = [
|
|
3708
|
+
...has("defineView") ? callSpans(text, "defineView") : [],
|
|
3709
|
+
...typedObjectSpans(text, ["ViewDefinition", "ViewField"].filter(has))
|
|
3710
|
+
];
|
|
3711
|
+
for (const m of text.matchAll(/(\btimeZone\s*:\s*)(["'`])practice\2/g)) {
|
|
3712
|
+
const at = m.index + m[1].length;
|
|
3713
|
+
if (!within(viewSpans, at)) continue;
|
|
3714
|
+
out.push({ index: m.index, what: "timeZone-practice", instead: 'timeZone: "scope"', start: at + 1, end: at + 1 + "practice".length, replacement: "scope" });
|
|
3715
|
+
}
|
|
3716
|
+
if (has("resolveZone")) {
|
|
3717
|
+
for (const m of text.matchAll(/(\bresolveZone\(\s*)(["'`])practice\2/g)) {
|
|
3718
|
+
const at = m.index + m[1].length + 1;
|
|
3719
|
+
out.push({ index: m.index, what: "resolveZone-practice", instead: 'resolveZone("scope", \u2026)', start: at, end: at + "practice".length, replacement: "scope" });
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
const propSpans = [
|
|
3723
|
+
...has("NativeResourceView") ? tagSpans(text, "NativeResourceView") : [],
|
|
3724
|
+
...typedObjectSpans(text, ["NativeResourceViewProps"].filter(has))
|
|
3725
|
+
];
|
|
3726
|
+
for (const m of text.matchAll(/(^|[\s{,(])practiceTimeZone(\s*[=:])/gm)) {
|
|
3727
|
+
const at = m.index + m[1].length;
|
|
3728
|
+
if (!within(propSpans, at)) continue;
|
|
3729
|
+
out.push({ index: at, what: "practiceTimeZone", instead: "scopeTimeZone", start: at, end: at + "practiceTimeZone".length, replacement: "scopeTimeZone" });
|
|
3730
|
+
}
|
|
3731
|
+
const zoneSpans = [
|
|
3732
|
+
...has("DisplayTimeZonesProvider") ? attributeObjectSpans(text, "DisplayTimeZonesProvider", "value") : [],
|
|
3733
|
+
...typedObjectSpans(text, ["DisplayTimeZones"].filter(has))
|
|
3734
|
+
];
|
|
3735
|
+
for (const m of text.matchAll(/(^|[\s{,])practice(\s*:)/gm)) {
|
|
3736
|
+
const at = m.index + m[1].length;
|
|
3737
|
+
if (!within(zoneSpans, at)) continue;
|
|
3738
|
+
out.push({ index: at, what: "DisplayTimeZones.practice", instead: "scope", start: at, end: at + "practice".length, replacement: "scope" });
|
|
3739
|
+
}
|
|
3740
|
+
for (const name of zoneBindings(text, has("useDisplayTimeZones"), has("DisplayTimeZones"))) {
|
|
3741
|
+
for (const m of text.matchAll(new RegExp(`(?<![\\w$])${escape(name)}\\s*\\??\\.\\s*(practice)(?![\\w$])`, "g"))) {
|
|
3742
|
+
const at = m.index + m[0].length - "practice".length;
|
|
3743
|
+
out.push({ index: m.index, what: "DisplayTimeZones.practice", instead: `${name}.scope`, start: at, end: at + "practice".length, replacement: "scope" });
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3747
|
+
return out.filter((f) => seen.has(f.start) ? false : (seen.add(f.start), true)).sort((a, b) => a.start - b.start);
|
|
3748
|
+
}
|
|
3749
|
+
function readsPracticeId(text) {
|
|
3750
|
+
if (!IMPORTS_GENESIS.test(text)) return [];
|
|
3751
|
+
return [...text.matchAll(/\bscope\s*\??\.\s*practiceId\b/g)].map((m) => m.index);
|
|
3752
|
+
}
|
|
3753
|
+
var augmentsResourceScope = (text) => /\binterface\s+ResourceScope\b/.test(text);
|
|
3754
|
+
var PRACTICE_ID_AUGMENTATION = 'declare module "@marktiderman/genesis-core" { interface ResourceScope { practiceId?: string } }';
|
|
3755
|
+
|
|
3756
|
+
// src/upgrade/codemods.ts
|
|
3757
|
+
var SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", "dist", "build", ".git", ".next", ".output", ".turbo", ".expo", "coverage", "ios", "android"]);
|
|
3758
|
+
var SCRIPT = /\.(?:[cm]?[jt]sx?)$/;
|
|
3759
|
+
var MAX_BYTES = 2 * 1024 * 1024;
|
|
3760
|
+
function appScripts(root) {
|
|
3761
|
+
const out = [];
|
|
3762
|
+
const walk = (dir) => {
|
|
3763
|
+
for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
3764
|
+
const abs = path14.join(dir, entry.name);
|
|
3765
|
+
if (entry.isDirectory()) {
|
|
3766
|
+
if (!SKIP_DIRS3.has(entry.name)) walk(abs);
|
|
3767
|
+
} else if (entry.isFile() && SCRIPT.test(entry.name) && statSync(abs).size <= MAX_BYTES) {
|
|
3768
|
+
out.push(path14.relative(root, abs).split(path14.sep).join("/"));
|
|
3769
|
+
}
|
|
3770
|
+
}
|
|
3771
|
+
};
|
|
3772
|
+
walk(root);
|
|
3773
|
+
return out;
|
|
3774
|
+
}
|
|
3775
|
+
|
|
3776
|
+
// src/doctor/api-usage.ts
|
|
3777
|
+
var SCRIPT_EXTS5 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
|
|
3778
|
+
function openingTag(code, start) {
|
|
3779
|
+
let depth = 0;
|
|
3780
|
+
let quote = null;
|
|
3781
|
+
for (let i = start + 1; i < code.length; i++) {
|
|
3782
|
+
const ch = code[i];
|
|
3783
|
+
if (quote) {
|
|
3784
|
+
if (ch === "\\") i++;
|
|
3785
|
+
else if (ch === quote) quote = null;
|
|
3786
|
+
continue;
|
|
3787
|
+
}
|
|
3788
|
+
if (ch === '"' || ch === "'" || ch === "`") quote = ch;
|
|
3789
|
+
else if (ch === "{") depth++;
|
|
3790
|
+
else if (ch === "}") depth--;
|
|
3791
|
+
else if (ch === ">" && depth === 0) return code.slice(start, i + 1);
|
|
3792
|
+
}
|
|
3793
|
+
return code.slice(start);
|
|
3794
|
+
}
|
|
3795
|
+
function ownAttributes(tag) {
|
|
3796
|
+
let depth = 0;
|
|
3797
|
+
let quote = null;
|
|
3798
|
+
let out = "";
|
|
3799
|
+
let inner = "";
|
|
3800
|
+
for (let i = 0; i < tag.length; i++) {
|
|
3801
|
+
const ch = tag[i];
|
|
3802
|
+
if (depth > 0) inner += ch;
|
|
3803
|
+
if (quote) {
|
|
3804
|
+
if (ch === "\\") {
|
|
3805
|
+
i++;
|
|
3806
|
+
if (depth > 0) inner += tag[i] ?? "";
|
|
3807
|
+
else out += ch + (tag[i] ?? "");
|
|
3808
|
+
continue;
|
|
3809
|
+
}
|
|
3810
|
+
if (ch === quote) quote = null;
|
|
3811
|
+
if (depth === 0) out += ch;
|
|
3812
|
+
continue;
|
|
3813
|
+
}
|
|
3814
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
3815
|
+
quote = ch;
|
|
3816
|
+
if (depth === 0) out += ch;
|
|
3817
|
+
} else if (ch === "{") {
|
|
3818
|
+
if (depth === 0) inner = "";
|
|
3819
|
+
depth++;
|
|
3820
|
+
} else if (ch === "}") {
|
|
3821
|
+
depth--;
|
|
3822
|
+
if (depth === 0) {
|
|
3823
|
+
const body = inner.slice(0, -1).trim();
|
|
3824
|
+
out += /^(["'`])[^"'`]*\1$/.test(body) ? `{${body}}` : "{}";
|
|
3825
|
+
}
|
|
3826
|
+
} else if (depth === 0) out += ch;
|
|
3827
|
+
}
|
|
3828
|
+
return out;
|
|
3829
|
+
}
|
|
3830
|
+
function checkTreeViews(ctx) {
|
|
3831
|
+
for (const file of ctx.files) {
|
|
3832
|
+
if (!SCRIPT_EXTS5.has(file.ext) || !/\btree\s*=/.test(file.code)) continue;
|
|
3833
|
+
for (const m of file.code.matchAll(/<(ResourceView|ResourcePage)\b(?:\s*<[^<>]*>)?/g)) {
|
|
3834
|
+
const tag = openingTag(file.code, (m.index ?? 0) + m[0].length - 1);
|
|
3835
|
+
const attrs = ownAttributes(tag);
|
|
3836
|
+
if (!/\stree\s*=/.test(attrs) || !/\spagination\s*=/.test(attrs)) continue;
|
|
3837
|
+
const paging = attrs.match(/\spagination\s*=\s*(?:\{\s*)?["'`](server|cursor)["'`]/);
|
|
3838
|
+
if (!paging) continue;
|
|
3839
|
+
ctx.report({
|
|
3840
|
+
rule: "resource-view-tree",
|
|
3841
|
+
level: "error",
|
|
3842
|
+
file: file.path,
|
|
3843
|
+
line: lineAt(file.code, m.index ?? 0),
|
|
3844
|
+
subject: m[1],
|
|
3845
|
+
message: `${m[1]} has \`tree\` with pagination="${paging[1]}", which throws when it renders: a tree is built from every row on the client. Leave pagination unset (docs/RESOURCE-VIEW.md, "Tree mode")`
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
var STUDIO_SERVER = "@marktiderman/genesis-studio-server";
|
|
3851
|
+
var DEEP = /\b(?:from|import|require)\s*\(?\s*["']@marktiderman\/genesis-studio-server\/(dist|src|lib)\/[^"']*["']/g;
|
|
3852
|
+
var ROOT_REQUIRE = /\brequire\s*\(\s*["']@marktiderman\/genesis-studio-server["']\s*\)/g;
|
|
3853
|
+
function moduleFiles(ctx) {
|
|
3854
|
+
const scanned = new Set(ctx.files.map((f) => f.path));
|
|
3855
|
+
const ignored = globMatcher([...DEFAULT_IGNORE, ...ctx.config.ignore ?? []]);
|
|
3856
|
+
const extra = appScripts(ctx.root).filter((rel) => /\.(c|m)js$/.test(rel) && !scanned.has(rel) && !ignored(rel)).map((rel) => ({ path: rel, code: stripBlockComments(readFileSync(path14.join(ctx.root, rel), "utf8"), true) }));
|
|
3857
|
+
return [...ctx.files.filter((f) => SCRIPT_EXTS5.has(f.ext)), ...extra];
|
|
3858
|
+
}
|
|
3859
|
+
function checkStudioServerImports(ctx) {
|
|
3860
|
+
for (const file of moduleFiles(ctx)) {
|
|
3861
|
+
if (!file.code.includes(STUDIO_SERVER)) continue;
|
|
3862
|
+
for (const m of file.code.matchAll(DEEP)) {
|
|
3863
|
+
ctx.report({
|
|
3864
|
+
rule: "studio-server-auth-import",
|
|
3865
|
+
level: "warn",
|
|
3866
|
+
file: file.path,
|
|
3867
|
+
line: lineAt(file.code, m.index ?? 0),
|
|
3868
|
+
subject: `${STUDIO_SERVER}/${m[1]}`,
|
|
3869
|
+
message: `imports a studio-server file the package doesn't export, which fails at run time; the token checks and switchToUser are in ${STUDIO_SERVER}/auth (import or require)`
|
|
3870
|
+
});
|
|
3871
|
+
}
|
|
3872
|
+
for (const m of file.code.matchAll(ROOT_REQUIRE)) {
|
|
3873
|
+
ctx.report({
|
|
3874
|
+
rule: "studio-server-auth-import",
|
|
3875
|
+
level: "warn",
|
|
3876
|
+
file: file.path,
|
|
3877
|
+
line: lineAt(file.code, m.index ?? 0),
|
|
3878
|
+
subject: STUDIO_SERVER,
|
|
3879
|
+
message: `requires ${STUDIO_SERVER}, which is ESM-only and fails under require(); ${STUDIO_SERVER}/auth (the token checks and switchToUser) ships for require too`
|
|
3880
|
+
});
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
}
|
|
3884
|
+
var REMOVED_WORDS = {
|
|
3885
|
+
"timeZone-practice": 'timeZone "practice"',
|
|
3886
|
+
"resolveZone-practice": 'resolveZone("practice")',
|
|
3887
|
+
practiceTimeZone: "practiceTimeZone",
|
|
3888
|
+
"DisplayTimeZones.practice": "DisplayTimeZones.practice"
|
|
3889
|
+
};
|
|
3890
|
+
function checkRemovedScopeNames(ctx) {
|
|
3891
|
+
let augmentedMemo;
|
|
3892
|
+
const augmented = () => augmentedMemo ??= ctx.files.some((f) => augmentsResourceScope(f.code)) || appScripts(ctx.root).filter((rel) => rel.endsWith(".d.ts")).some((rel) => augmentsResourceScope(readFileSync(path14.join(ctx.root, rel), "utf8")));
|
|
3893
|
+
for (const file of ctx.files) {
|
|
3894
|
+
if (!SCRIPT_EXTS5.has(file.ext)) continue;
|
|
3895
|
+
for (const hit of findRemovedScopeNames(file.code)) {
|
|
3896
|
+
ctx.report({
|
|
3897
|
+
rule: "removed-scope-name",
|
|
3898
|
+
level: "error",
|
|
3899
|
+
file: file.path,
|
|
3900
|
+
line: lineAt(file.code, hit.index),
|
|
3901
|
+
subject: REMOVED_WORDS[hit.what] ?? hit.what,
|
|
3902
|
+
message: `${REMOVED_WORDS[hit.what] ?? hit.what} was removed in genesis-core 2; use ${hit.instead}. \`genesis codemod genesis-core-2-scope-names\` rewrites every one`
|
|
3903
|
+
});
|
|
3904
|
+
}
|
|
3905
|
+
const reads = readsPracticeId(file.code);
|
|
3906
|
+
if (!reads.length || augmented()) continue;
|
|
3907
|
+
for (const index of reads) {
|
|
3908
|
+
ctx.report({
|
|
3909
|
+
rule: "scope-practice-id",
|
|
3910
|
+
level: "info",
|
|
3911
|
+
file: file.path,
|
|
3912
|
+
line: lineAt(file.code, index),
|
|
3913
|
+
subject: "practiceId",
|
|
3914
|
+
message: `scope.practiceId is the app's own scope key now, read as unknown; type it once: ${PRACTICE_ID_AUGMENTATION}`
|
|
3915
|
+
});
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3563
3920
|
// src/doctor/index.ts
|
|
3564
3921
|
async function runDoctor(options = {}) {
|
|
3565
3922
|
const root = path14.resolve(options.root ?? process.cwd());
|
|
@@ -3624,6 +3981,9 @@ function builtinChecks(config) {
|
|
|
3624
3981
|
{ name: "resource-workspaces", check: checkResourceWorkspaces },
|
|
3625
3982
|
{ name: "page-layouts", check: checkPageLayouts },
|
|
3626
3983
|
{ name: "iso-date-slices", check: checkIsoDateSlices },
|
|
3984
|
+
{ name: "resource-view-trees", check: checkTreeViews },
|
|
3985
|
+
{ name: "studio-server-imports", check: checkStudioServerImports },
|
|
3986
|
+
{ name: "removed-scope-names", check: checkRemovedScopeNames },
|
|
3627
3987
|
...(config.packs ?? []).map((p) => packs[p])
|
|
3628
3988
|
];
|
|
3629
3989
|
}
|