@marktiderman/genesis-cli 1.13.1 → 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 +541 -107
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +1 -1
- package/dist/doctor.js +364 -2
- package/dist/doctor.js.map +1 -1
- package/dist/genesis-catalog.json +29 -286
- package/dist/index.js +372 -10
- package/dist/index.js.map +1 -1
- package/dist/vite.js +364 -2
- package/dist/vite.js.map +1 -1
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -2084,7 +2084,7 @@ function globToRegExp(glob) {
|
|
|
2084
2084
|
}
|
|
2085
2085
|
function globMatcher(globs) {
|
|
2086
2086
|
const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
|
|
2087
|
-
return (
|
|
2087
|
+
return (path37) => res.some((re) => re.test(path37));
|
|
2088
2088
|
}
|
|
2089
2089
|
var init_glob = __esm({
|
|
2090
2090
|
"src/doctor/glob.ts"() {
|
|
@@ -2641,6 +2641,11 @@ var init_rules = __esm({
|
|
|
2641
2641
|
"page-layout",
|
|
2642
2642
|
// dates
|
|
2643
2643
|
"iso-date-slice",
|
|
2644
|
+
// Genesis API usage (api-usage.ts)
|
|
2645
|
+
"resource-view-tree",
|
|
2646
|
+
"studio-server-auth-import",
|
|
2647
|
+
"removed-scope-name",
|
|
2648
|
+
"scope-practice-id",
|
|
2644
2649
|
// native pack
|
|
2645
2650
|
"native-raw-primitive",
|
|
2646
2651
|
"native-literal-color",
|
|
@@ -3895,7 +3900,9 @@ function checkChanges(ctx, pkg, json, base, mergeBase) {
|
|
|
3895
3900
|
}
|
|
3896
3901
|
const raw = json;
|
|
3897
3902
|
if (jsonBefore && (JSON.stringify(jsonBefore.genesis) !== JSON.stringify(raw.genesis) || JSON.stringify(jsonBefore.exports) !== JSON.stringify(raw.exports))) {
|
|
3898
|
-
const
|
|
3903
|
+
const appInRepo = path23.relative(top, realpathSync(ctx.root)).split(path23.sep).join("/");
|
|
3904
|
+
const candidates = [.../* @__PURE__ */ new Set(["features.ts", "src/features.ts", ...appInRepo ? [`${appInRepo}/features.ts`, `${appInRepo}/src/features.ts`] : []])];
|
|
3905
|
+
const registry = (git(top, ["diff", "--name-only", mergeBase, "--", ...candidates]) ?? "").trim();
|
|
3899
3906
|
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` });
|
|
3900
3907
|
}
|
|
3901
3908
|
if (bumped && !named && before !== null) {
|
|
@@ -4878,6 +4885,510 @@ var init_dates = __esm({
|
|
|
4878
4885
|
}
|
|
4879
4886
|
});
|
|
4880
4887
|
|
|
4888
|
+
// src/upgrade/bump-core.mjs
|
|
4889
|
+
function compareVersions2(a, b) {
|
|
4890
|
+
const [ca, pa = ""] = a.split(/-(.*)/s);
|
|
4891
|
+
const [cb, pb = ""] = b.split(/-(.*)/s);
|
|
4892
|
+
const x = ca.split(".").map(Number), y = cb.split(".").map(Number);
|
|
4893
|
+
for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] - y[i];
|
|
4894
|
+
if (!pa || !pb) return (pa ? 0 : 1) - (pb ? 0 : 1);
|
|
4895
|
+
const fa = pa.split("."), fb = pb.split(".");
|
|
4896
|
+
for (let i = 0; i < Math.max(fa.length, fb.length); i++) {
|
|
4897
|
+
if (fa[i] === void 0) return -1;
|
|
4898
|
+
if (fb[i] === void 0) return 1;
|
|
4899
|
+
const na = /^\d+$/.test(fa[i]), nb = /^\d+$/.test(fb[i]);
|
|
4900
|
+
if (na && nb && Number(fa[i]) !== Number(fb[i])) return Number(fa[i]) - Number(fb[i]);
|
|
4901
|
+
if (na !== nb) return na ? -1 : 1;
|
|
4902
|
+
if (fa[i] !== fb[i]) return fa[i] < fb[i] ? -1 : 1;
|
|
4903
|
+
}
|
|
4904
|
+
return 0;
|
|
4905
|
+
}
|
|
4906
|
+
function bumpPackageJson(file, text, wanted) {
|
|
4907
|
+
const pkg = JSON.parse(text);
|
|
4908
|
+
const changes = [], skipped = [];
|
|
4909
|
+
for (const section of SECTIONS) {
|
|
4910
|
+
for (const [name, spec] of Object.entries(pkg[section] ?? {})) {
|
|
4911
|
+
if (!GENESIS2.test(name)) continue;
|
|
4912
|
+
const m = EXACT.exec(spec);
|
|
4913
|
+
if (!m) {
|
|
4914
|
+
skipped.push({ file, name, spec, why: "not a plain version" });
|
|
4915
|
+
continue;
|
|
4916
|
+
}
|
|
4917
|
+
const want = wanted(name);
|
|
4918
|
+
if (!want) {
|
|
4919
|
+
skipped.push({ file, name, spec, why: "no latest version on npm" });
|
|
4920
|
+
continue;
|
|
4921
|
+
}
|
|
4922
|
+
if (!PLAIN.test(want)) {
|
|
4923
|
+
skipped.push({ file, name, spec, why: `the release names ${JSON.stringify(want)}, not a version` });
|
|
4924
|
+
continue;
|
|
4925
|
+
}
|
|
4926
|
+
const cmp = compareVersions2(want, m[2]);
|
|
4927
|
+
if (cmp === 0) continue;
|
|
4928
|
+
if (cmp < 0) {
|
|
4929
|
+
skipped.push({ file, name, spec, why: `newer than ${want}` });
|
|
4930
|
+
continue;
|
|
4931
|
+
}
|
|
4932
|
+
pkg[section][name] = `${m[1] ?? ""}${want}`;
|
|
4933
|
+
changes.push({ file, name, from: spec, to: pkg[section][name] });
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
if (!changes.length) return { text: null, changes, skipped };
|
|
4937
|
+
const indent = /^[ \t]+(?=")/m.exec(text)?.[0] ?? " ";
|
|
4938
|
+
return { text: JSON.stringify(pkg, null, indent) + (text.endsWith("\n") ? "\n" : ""), changes, skipped };
|
|
4939
|
+
}
|
|
4940
|
+
function bumpSummary(version, changes, skipped) {
|
|
4941
|
+
const row = (c) => `| \`${c.name}\` | ${c.from} | ${c.to} | ${c.file} |`;
|
|
4942
|
+
return [
|
|
4943
|
+
`Moves every Genesis package to the **${UMBRELLA}@${version}** release: the versions in its \`versions.json\`, and npm \`latest\` for packages it doesn't list.`,
|
|
4944
|
+
"",
|
|
4945
|
+
changes.length ? ["| Package | From | To | File |", "| --- | --- | --- | --- |", ...changes.map(row)].join("\n") : "Nothing to change.",
|
|
4946
|
+
...skipped.length ? ["", "Left alone:", "", ...skipped.map((s) => `- \`${s.name}\` ${s.spec} in ${s.file}: ${s.why}`)] : []
|
|
4947
|
+
].join("\n");
|
|
4948
|
+
}
|
|
4949
|
+
var UMBRELLA, GENESIS2, EXACT, PLAIN, SECTIONS;
|
|
4950
|
+
var init_bump_core = __esm({
|
|
4951
|
+
"src/upgrade/bump-core.mjs"() {
|
|
4952
|
+
UMBRELLA = "@marktiderman/genesis";
|
|
4953
|
+
GENESIS2 = /^@marktiderman\/genesis(-[a-z0-9-]+)?$/;
|
|
4954
|
+
EXACT = /^(\^|~|=)?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
4955
|
+
PLAIN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
4956
|
+
SECTIONS = ["dependencies", "devDependencies", "optionalDependencies"];
|
|
4957
|
+
}
|
|
4958
|
+
});
|
|
4959
|
+
|
|
4960
|
+
// src/upgrade/scope-names.ts
|
|
4961
|
+
function maskComments(text) {
|
|
4962
|
+
const out = text.split("");
|
|
4963
|
+
let quote2 = null;
|
|
4964
|
+
for (let i = 0; i < text.length; i++) {
|
|
4965
|
+
const ch = text[i];
|
|
4966
|
+
if (quote2) {
|
|
4967
|
+
if (ch === "\\") i++;
|
|
4968
|
+
else if (ch === quote2) quote2 = null;
|
|
4969
|
+
continue;
|
|
4970
|
+
}
|
|
4971
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
4972
|
+
quote2 = ch;
|
|
4973
|
+
continue;
|
|
4974
|
+
}
|
|
4975
|
+
if (ch === "/" && (text[i + 1] === "/" || text[i + 1] === "*")) {
|
|
4976
|
+
const line = text[i + 1] === "/";
|
|
4977
|
+
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;
|
|
4978
|
+
for (let k = i; k < end; k++) if (out[k] !== "\n") out[k] = " ";
|
|
4979
|
+
i = end - 1;
|
|
4980
|
+
}
|
|
4981
|
+
}
|
|
4982
|
+
return out.join("");
|
|
4983
|
+
}
|
|
4984
|
+
function importedFromGenesis(text, name) {
|
|
4985
|
+
for (const m of text.matchAll(/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']@marktiderman\/genesis[\w/-]*["']/g)) {
|
|
4986
|
+
for (const part of m[1].split(",")) {
|
|
4987
|
+
const local = part.trim().replace(/^type\s+/, "").split(/\s+as\s+/).pop()?.trim();
|
|
4988
|
+
if (local === name) return true;
|
|
4989
|
+
}
|
|
4990
|
+
}
|
|
4991
|
+
return false;
|
|
4992
|
+
}
|
|
4993
|
+
function matching(text, open) {
|
|
4994
|
+
const stack = [];
|
|
4995
|
+
let quote2 = null;
|
|
4996
|
+
for (let i = open; i < text.length; i++) {
|
|
4997
|
+
const ch = text[i];
|
|
4998
|
+
if (quote2) {
|
|
4999
|
+
if (ch === "\\") i++;
|
|
5000
|
+
else if (ch === quote2) quote2 = null;
|
|
5001
|
+
continue;
|
|
5002
|
+
}
|
|
5003
|
+
if (ch === '"' || ch === "'" || ch === "`") quote2 = ch;
|
|
5004
|
+
else if (OPEN[ch]) stack.push(OPEN[ch]);
|
|
5005
|
+
else if (ch === ")" || ch === "}" || ch === "]") {
|
|
5006
|
+
stack.pop();
|
|
5007
|
+
if (stack.length === 0) return i + 1;
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
return text.length;
|
|
5011
|
+
}
|
|
5012
|
+
function matchingBack(text, close) {
|
|
5013
|
+
let depth = 0;
|
|
5014
|
+
for (let i = close; i >= 0; i--) {
|
|
5015
|
+
const ch = text[i];
|
|
5016
|
+
if (ch === "}") depth++;
|
|
5017
|
+
else if (ch === "{") {
|
|
5018
|
+
depth--;
|
|
5019
|
+
if (depth === 0) return i;
|
|
5020
|
+
}
|
|
5021
|
+
}
|
|
5022
|
+
return 0;
|
|
5023
|
+
}
|
|
5024
|
+
function callSpans(text, name) {
|
|
5025
|
+
const out = [];
|
|
5026
|
+
for (const m of text.matchAll(new RegExp(`\\b${name}\\s*(?:<[^()]*?>)?\\s*\\(`, "g"))) {
|
|
5027
|
+
const open = m.index + m[0].length - 1;
|
|
5028
|
+
out.push([open, matching(text, open)]);
|
|
5029
|
+
}
|
|
5030
|
+
return out;
|
|
5031
|
+
}
|
|
5032
|
+
function typedObjectSpans(text, types) {
|
|
5033
|
+
const out = [];
|
|
5034
|
+
if (types.length === 0) return out;
|
|
5035
|
+
const names = `(?:(?:Partial|Readonly|Required|Pick|Omit)\\s*<\\s*)?(?:${types.join("|")})`;
|
|
5036
|
+
for (const m of text.matchAll(new RegExp(`:\\s*${names}\\b(?:<[^=]*?>)?[^=;{]*?=\\s*\\{`, "g"))) {
|
|
5037
|
+
const open = m.index + m[0].length - 1;
|
|
5038
|
+
out.push([open, matching(text, open)]);
|
|
5039
|
+
}
|
|
5040
|
+
for (const m of text.matchAll(new RegExp(`\\}\\s*(?:satisfies|as)\\s+${names}\\b`, "g"))) {
|
|
5041
|
+
const close = m.index;
|
|
5042
|
+
out.push([matchingBack(text, close), close + 1]);
|
|
5043
|
+
}
|
|
5044
|
+
return out;
|
|
5045
|
+
}
|
|
5046
|
+
function tagSpans(text, tag) {
|
|
5047
|
+
const out = [];
|
|
5048
|
+
for (const m of text.matchAll(new RegExp(`<${tag}\\b`, "g"))) {
|
|
5049
|
+
let depth = 0;
|
|
5050
|
+
let quote2 = null;
|
|
5051
|
+
let end = text.length;
|
|
5052
|
+
for (let i = m.index + 1; i < text.length; i++) {
|
|
5053
|
+
const ch = text[i];
|
|
5054
|
+
if (quote2) {
|
|
5055
|
+
if (ch === "\\") i++;
|
|
5056
|
+
else if (ch === quote2) quote2 = null;
|
|
5057
|
+
continue;
|
|
5058
|
+
}
|
|
5059
|
+
if (ch === '"' || ch === "'" || ch === "`") quote2 = ch;
|
|
5060
|
+
else if (ch === "{") depth++;
|
|
5061
|
+
else if (ch === "}") depth--;
|
|
5062
|
+
else if (ch === ">" && depth === 0) {
|
|
5063
|
+
end = i + 1;
|
|
5064
|
+
break;
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5067
|
+
out.push([m.index, end]);
|
|
5068
|
+
}
|
|
5069
|
+
return out;
|
|
5070
|
+
}
|
|
5071
|
+
function attributeObjectSpans(text, tag, attr) {
|
|
5072
|
+
const out = [];
|
|
5073
|
+
for (const [a, b] of tagSpans(text, tag)) {
|
|
5074
|
+
const inTag = text.slice(a, b);
|
|
5075
|
+
for (const m of inTag.matchAll(new RegExp(`\\s${attr}\\s*=\\s*\\{\\s*\\{`, "g"))) {
|
|
5076
|
+
const open = a + m.index + m[0].length - 1;
|
|
5077
|
+
out.push([open, matching(text, open)]);
|
|
5078
|
+
}
|
|
5079
|
+
}
|
|
5080
|
+
return out;
|
|
5081
|
+
}
|
|
5082
|
+
function zoneBindings(text, hook, type) {
|
|
5083
|
+
const names = /* @__PURE__ */ new Set();
|
|
5084
|
+
if (hook) {
|
|
5085
|
+
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]);
|
|
5086
|
+
}
|
|
5087
|
+
if (type) for (const m of text.matchAll(/\b([A-Za-z_$][\w$]*)\s*\??\s*:\s*DisplayTimeZones\b/g)) names.add(m[1]);
|
|
5088
|
+
return [...names];
|
|
5089
|
+
}
|
|
5090
|
+
function findRemovedScopeNames(source) {
|
|
5091
|
+
const text = maskComments(source);
|
|
5092
|
+
if (!IMPORTS_GENESIS.test(text)) return [];
|
|
5093
|
+
const out = [];
|
|
5094
|
+
const has2 = (name) => importedFromGenesis(text, name);
|
|
5095
|
+
const viewSpans = [
|
|
5096
|
+
...has2("defineView") ? callSpans(text, "defineView") : [],
|
|
5097
|
+
...typedObjectSpans(text, ["ViewDefinition", "ViewField"].filter(has2))
|
|
5098
|
+
];
|
|
5099
|
+
for (const m of text.matchAll(/(\btimeZone\s*:\s*)(["'`])practice\2/g)) {
|
|
5100
|
+
const at = m.index + m[1].length;
|
|
5101
|
+
if (!within(viewSpans, at)) continue;
|
|
5102
|
+
out.push({ index: m.index, what: "timeZone-practice", instead: 'timeZone: "scope"', start: at + 1, end: at + 1 + "practice".length, replacement: "scope" });
|
|
5103
|
+
}
|
|
5104
|
+
if (has2("resolveZone")) {
|
|
5105
|
+
for (const m of text.matchAll(/(\bresolveZone\(\s*)(["'`])practice\2/g)) {
|
|
5106
|
+
const at = m.index + m[1].length + 1;
|
|
5107
|
+
out.push({ index: m.index, what: "resolveZone-practice", instead: 'resolveZone("scope", \u2026)', start: at, end: at + "practice".length, replacement: "scope" });
|
|
5108
|
+
}
|
|
5109
|
+
}
|
|
5110
|
+
const propSpans = [
|
|
5111
|
+
...has2("NativeResourceView") ? tagSpans(text, "NativeResourceView") : [],
|
|
5112
|
+
...typedObjectSpans(text, ["NativeResourceViewProps"].filter(has2))
|
|
5113
|
+
];
|
|
5114
|
+
for (const m of text.matchAll(/(^|[\s{,(])practiceTimeZone(\s*[=:])/gm)) {
|
|
5115
|
+
const at = m.index + m[1].length;
|
|
5116
|
+
if (!within(propSpans, at)) continue;
|
|
5117
|
+
out.push({ index: at, what: "practiceTimeZone", instead: "scopeTimeZone", start: at, end: at + "practiceTimeZone".length, replacement: "scopeTimeZone" });
|
|
5118
|
+
}
|
|
5119
|
+
const zoneSpans = [
|
|
5120
|
+
...has2("DisplayTimeZonesProvider") ? attributeObjectSpans(text, "DisplayTimeZonesProvider", "value") : [],
|
|
5121
|
+
...typedObjectSpans(text, ["DisplayTimeZones"].filter(has2))
|
|
5122
|
+
];
|
|
5123
|
+
for (const m of text.matchAll(/(^|[\s{,])practice(\s*:)/gm)) {
|
|
5124
|
+
const at = m.index + m[1].length;
|
|
5125
|
+
if (!within(zoneSpans, at)) continue;
|
|
5126
|
+
out.push({ index: at, what: "DisplayTimeZones.practice", instead: "scope", start: at, end: at + "practice".length, replacement: "scope" });
|
|
5127
|
+
}
|
|
5128
|
+
for (const name of zoneBindings(text, has2("useDisplayTimeZones"), has2("DisplayTimeZones"))) {
|
|
5129
|
+
for (const m of text.matchAll(new RegExp(`(?<![\\w$])${escape(name)}\\s*\\??\\.\\s*(practice)(?![\\w$])`, "g"))) {
|
|
5130
|
+
const at = m.index + m[0].length - "practice".length;
|
|
5131
|
+
out.push({ index: m.index, what: "DisplayTimeZones.practice", instead: `${name}.scope`, start: at, end: at + "practice".length, replacement: "scope" });
|
|
5132
|
+
}
|
|
5133
|
+
}
|
|
5134
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5135
|
+
return out.filter((f) => seen.has(f.start) ? false : (seen.add(f.start), true)).sort((a, b) => a.start - b.start);
|
|
5136
|
+
}
|
|
5137
|
+
function rewriteScopeNames(text) {
|
|
5138
|
+
let next = text;
|
|
5139
|
+
for (const f of findRemovedScopeNames(text).sort((a, b) => b.start - a.start)) {
|
|
5140
|
+
next = next.slice(0, f.start) + f.replacement + next.slice(f.end);
|
|
5141
|
+
}
|
|
5142
|
+
return next;
|
|
5143
|
+
}
|
|
5144
|
+
function readsPracticeId(text) {
|
|
5145
|
+
if (!IMPORTS_GENESIS.test(text)) return [];
|
|
5146
|
+
return [...text.matchAll(/\bscope\s*\??\.\s*practiceId\b/g)].map((m) => m.index);
|
|
5147
|
+
}
|
|
5148
|
+
var IMPORTS_GENESIS, within, OPEN, escape, augmentsResourceScope, PRACTICE_ID_AUGMENTATION;
|
|
5149
|
+
var init_scope_names = __esm({
|
|
5150
|
+
"src/upgrade/scope-names.ts"() {
|
|
5151
|
+
IMPORTS_GENESIS = /\bfrom\s*["']@marktiderman\/genesis[\w/-]*["']/;
|
|
5152
|
+
within = (spans, at) => spans.some(([a, b]) => at >= a && at < b);
|
|
5153
|
+
OPEN = { "(": ")", "{": "}", "[": "]" };
|
|
5154
|
+
escape = (name) => name.replace(/\$/g, "\\$");
|
|
5155
|
+
augmentsResourceScope = (text) => /\binterface\s+ResourceScope\b/.test(text);
|
|
5156
|
+
PRACTICE_ID_AUGMENTATION = 'declare module "@marktiderman/genesis-core" { interface ResourceScope { practiceId?: string } }';
|
|
5157
|
+
}
|
|
5158
|
+
});
|
|
5159
|
+
|
|
5160
|
+
// src/upgrade/codemods.ts
|
|
5161
|
+
var codemods_exports = {};
|
|
5162
|
+
__export(codemods_exports, {
|
|
5163
|
+
CODEMODS: () => CODEMODS,
|
|
5164
|
+
appScripts: () => appScripts,
|
|
5165
|
+
codemodById: () => codemodById,
|
|
5166
|
+
codemodsFor: () => codemodsFor,
|
|
5167
|
+
scopeNeutralNames: () => scopeNeutralNames,
|
|
5168
|
+
uncoveredBreaks: () => uncoveredBreaks
|
|
5169
|
+
});
|
|
5170
|
+
function appScripts(root) {
|
|
5171
|
+
const out = [];
|
|
5172
|
+
const walk2 = (dir) => {
|
|
5173
|
+
for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
5174
|
+
const abs = path23.join(dir, entry.name);
|
|
5175
|
+
if (entry.isDirectory()) {
|
|
5176
|
+
if (!SKIP_DIRS3.has(entry.name)) walk2(abs);
|
|
5177
|
+
} else if (entry.isFile() && SCRIPT.test(entry.name) && statSync(abs).size <= MAX_BYTES) {
|
|
5178
|
+
out.push(path23.relative(root, abs).split(path23.sep).join("/"));
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
};
|
|
5182
|
+
walk2(root);
|
|
5183
|
+
return out;
|
|
5184
|
+
}
|
|
5185
|
+
function codemodById(id, registry = CODEMODS) {
|
|
5186
|
+
return registry.find((mod) => mod.id === id);
|
|
5187
|
+
}
|
|
5188
|
+
function codemodsFor(changes, registry = CODEMODS) {
|
|
5189
|
+
return registry.filter(
|
|
5190
|
+
(mod) => changes.some((c) => c.name === mod.package && compareVersions2(bare(c.from), mod.version) < 0 && compareVersions2(bare(c.to), mod.version) >= 0)
|
|
5191
|
+
);
|
|
5192
|
+
}
|
|
5193
|
+
function uncoveredBreaks(changes, registry = CODEMODS) {
|
|
5194
|
+
const major = (v) => {
|
|
5195
|
+
const [a, b] = bare(v).split(".").map(Number);
|
|
5196
|
+
return a === 0 ? `0.${b}` : String(a);
|
|
5197
|
+
};
|
|
5198
|
+
return changes.filter((c) => major(c.from) !== major(c.to) && codemodsFor([c], registry).length === 0);
|
|
5199
|
+
}
|
|
5200
|
+
var SKIP_DIRS3, SCRIPT, MAX_BYTES, scopeNeutralNames, CODEMODS, bare;
|
|
5201
|
+
var init_codemods = __esm({
|
|
5202
|
+
"src/upgrade/codemods.ts"() {
|
|
5203
|
+
init_bump_core();
|
|
5204
|
+
init_scope_names();
|
|
5205
|
+
SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", "dist", "build", ".git", ".next", ".output", ".turbo", ".expo", "coverage", "ios", "android"]);
|
|
5206
|
+
SCRIPT = /\.(?:[cm]?[jt]sx?)$/;
|
|
5207
|
+
MAX_BYTES = 2 * 1024 * 1024;
|
|
5208
|
+
scopeNeutralNames = {
|
|
5209
|
+
id: "genesis-core-2-scope-names",
|
|
5210
|
+
package: "@marktiderman/genesis-core",
|
|
5211
|
+
version: "2.0.0",
|
|
5212
|
+
description: 'Renames the "practice" scope names: timeZone "practice" \u2192 "scope", practiceTimeZone \u2192 scopeTimeZone, DisplayTimeZones.practice \u2192 .scope.',
|
|
5213
|
+
run({ root, dryRun, log }) {
|
|
5214
|
+
const changed = [];
|
|
5215
|
+
let readsId = false;
|
|
5216
|
+
let augmented = false;
|
|
5217
|
+
for (const rel of appScripts(root)) {
|
|
5218
|
+
const abs = path23.join(root, rel);
|
|
5219
|
+
const text = readFileSync(abs, "utf8");
|
|
5220
|
+
if (augmentsResourceScope(text)) augmented = true;
|
|
5221
|
+
if (!IMPORTS_GENESIS.test(text)) continue;
|
|
5222
|
+
if (readsPracticeId(text).length) readsId = true;
|
|
5223
|
+
const next = rewriteScopeNames(text);
|
|
5224
|
+
if (next === text) continue;
|
|
5225
|
+
changed.push(rel);
|
|
5226
|
+
if (!dryRun) writeFileSync(abs, next);
|
|
5227
|
+
}
|
|
5228
|
+
if (readsId && !augmented) {
|
|
5229
|
+
log(` practiceId is no longer a named ResourceScope key. Passing it still works; to read it typed, add once:
|
|
5230
|
+
${PRACTICE_ID_AUGMENTATION}`);
|
|
5231
|
+
}
|
|
5232
|
+
return changed;
|
|
5233
|
+
}
|
|
5234
|
+
};
|
|
5235
|
+
CODEMODS = [scopeNeutralNames];
|
|
5236
|
+
bare = (spec) => spec.replace(/^[\^~=]/, "");
|
|
5237
|
+
}
|
|
5238
|
+
});
|
|
5239
|
+
function openingTag(code, start) {
|
|
5240
|
+
let depth = 0;
|
|
5241
|
+
let quote2 = null;
|
|
5242
|
+
for (let i = start + 1; i < code.length; i++) {
|
|
5243
|
+
const ch = code[i];
|
|
5244
|
+
if (quote2) {
|
|
5245
|
+
if (ch === "\\") i++;
|
|
5246
|
+
else if (ch === quote2) quote2 = null;
|
|
5247
|
+
continue;
|
|
5248
|
+
}
|
|
5249
|
+
if (ch === '"' || ch === "'" || ch === "`") quote2 = ch;
|
|
5250
|
+
else if (ch === "{") depth++;
|
|
5251
|
+
else if (ch === "}") depth--;
|
|
5252
|
+
else if (ch === ">" && depth === 0) return code.slice(start, i + 1);
|
|
5253
|
+
}
|
|
5254
|
+
return code.slice(start);
|
|
5255
|
+
}
|
|
5256
|
+
function ownAttributes(tag) {
|
|
5257
|
+
let depth = 0;
|
|
5258
|
+
let quote2 = null;
|
|
5259
|
+
let out = "";
|
|
5260
|
+
let inner = "";
|
|
5261
|
+
for (let i = 0; i < tag.length; i++) {
|
|
5262
|
+
const ch = tag[i];
|
|
5263
|
+
if (depth > 0) inner += ch;
|
|
5264
|
+
if (quote2) {
|
|
5265
|
+
if (ch === "\\") {
|
|
5266
|
+
i++;
|
|
5267
|
+
if (depth > 0) inner += tag[i] ?? "";
|
|
5268
|
+
else out += ch + (tag[i] ?? "");
|
|
5269
|
+
continue;
|
|
5270
|
+
}
|
|
5271
|
+
if (ch === quote2) quote2 = null;
|
|
5272
|
+
if (depth === 0) out += ch;
|
|
5273
|
+
continue;
|
|
5274
|
+
}
|
|
5275
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
5276
|
+
quote2 = ch;
|
|
5277
|
+
if (depth === 0) out += ch;
|
|
5278
|
+
} else if (ch === "{") {
|
|
5279
|
+
if (depth === 0) inner = "";
|
|
5280
|
+
depth++;
|
|
5281
|
+
} else if (ch === "}") {
|
|
5282
|
+
depth--;
|
|
5283
|
+
if (depth === 0) {
|
|
5284
|
+
const body = inner.slice(0, -1).trim();
|
|
5285
|
+
out += /^(["'`])[^"'`]*\1$/.test(body) ? `{${body}}` : "{}";
|
|
5286
|
+
}
|
|
5287
|
+
} else if (depth === 0) out += ch;
|
|
5288
|
+
}
|
|
5289
|
+
return out;
|
|
5290
|
+
}
|
|
5291
|
+
function checkTreeViews(ctx) {
|
|
5292
|
+
for (const file of ctx.files) {
|
|
5293
|
+
if (!SCRIPT_EXTS5.has(file.ext) || !/\btree\s*=/.test(file.code)) continue;
|
|
5294
|
+
for (const m of file.code.matchAll(/<(ResourceView|ResourcePage)\b(?:\s*<[^<>]*>)?/g)) {
|
|
5295
|
+
const tag = openingTag(file.code, (m.index ?? 0) + m[0].length - 1);
|
|
5296
|
+
const attrs = ownAttributes(tag);
|
|
5297
|
+
if (!/\stree\s*=/.test(attrs) || !/\spagination\s*=/.test(attrs)) continue;
|
|
5298
|
+
const paging = attrs.match(/\spagination\s*=\s*(?:\{\s*)?["'`](server|cursor)["'`]/);
|
|
5299
|
+
if (!paging) continue;
|
|
5300
|
+
ctx.report({
|
|
5301
|
+
rule: "resource-view-tree",
|
|
5302
|
+
level: "error",
|
|
5303
|
+
file: file.path,
|
|
5304
|
+
line: lineAt(file.code, m.index ?? 0),
|
|
5305
|
+
subject: m[1],
|
|
5306
|
+
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")`
|
|
5307
|
+
});
|
|
5308
|
+
}
|
|
5309
|
+
}
|
|
5310
|
+
}
|
|
5311
|
+
function moduleFiles(ctx) {
|
|
5312
|
+
const scanned = new Set(ctx.files.map((f) => f.path));
|
|
5313
|
+
const ignored = globMatcher([...DEFAULT_IGNORE, ...ctx.config.ignore ?? []]);
|
|
5314
|
+
const extra = appScripts(ctx.root).filter((rel) => /\.(c|m)js$/.test(rel) && !scanned.has(rel) && !ignored(rel)).map((rel) => ({ path: rel, code: stripBlockComments(readFileSync(path23.join(ctx.root, rel), "utf8"), true) }));
|
|
5315
|
+
return [...ctx.files.filter((f) => SCRIPT_EXTS5.has(f.ext)), ...extra];
|
|
5316
|
+
}
|
|
5317
|
+
function checkStudioServerImports(ctx) {
|
|
5318
|
+
for (const file of moduleFiles(ctx)) {
|
|
5319
|
+
if (!file.code.includes(STUDIO_SERVER)) continue;
|
|
5320
|
+
for (const m of file.code.matchAll(DEEP)) {
|
|
5321
|
+
ctx.report({
|
|
5322
|
+
rule: "studio-server-auth-import",
|
|
5323
|
+
level: "warn",
|
|
5324
|
+
file: file.path,
|
|
5325
|
+
line: lineAt(file.code, m.index ?? 0),
|
|
5326
|
+
subject: `${STUDIO_SERVER}/${m[1]}`,
|
|
5327
|
+
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)`
|
|
5328
|
+
});
|
|
5329
|
+
}
|
|
5330
|
+
for (const m of file.code.matchAll(ROOT_REQUIRE)) {
|
|
5331
|
+
ctx.report({
|
|
5332
|
+
rule: "studio-server-auth-import",
|
|
5333
|
+
level: "warn",
|
|
5334
|
+
file: file.path,
|
|
5335
|
+
line: lineAt(file.code, m.index ?? 0),
|
|
5336
|
+
subject: STUDIO_SERVER,
|
|
5337
|
+
message: `requires ${STUDIO_SERVER}, which is ESM-only and fails under require(); ${STUDIO_SERVER}/auth (the token checks and switchToUser) ships for require too`
|
|
5338
|
+
});
|
|
5339
|
+
}
|
|
5340
|
+
}
|
|
5341
|
+
}
|
|
5342
|
+
function checkRemovedScopeNames(ctx) {
|
|
5343
|
+
let augmentedMemo;
|
|
5344
|
+
const augmented = () => augmentedMemo ??= ctx.files.some((f) => augmentsResourceScope(f.code)) || appScripts(ctx.root).filter((rel) => rel.endsWith(".d.ts")).some((rel) => augmentsResourceScope(readFileSync(path23.join(ctx.root, rel), "utf8")));
|
|
5345
|
+
for (const file of ctx.files) {
|
|
5346
|
+
if (!SCRIPT_EXTS5.has(file.ext)) continue;
|
|
5347
|
+
for (const hit of findRemovedScopeNames(file.code)) {
|
|
5348
|
+
ctx.report({
|
|
5349
|
+
rule: "removed-scope-name",
|
|
5350
|
+
level: "error",
|
|
5351
|
+
file: file.path,
|
|
5352
|
+
line: lineAt(file.code, hit.index),
|
|
5353
|
+
subject: REMOVED_WORDS[hit.what] ?? hit.what,
|
|
5354
|
+
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`
|
|
5355
|
+
});
|
|
5356
|
+
}
|
|
5357
|
+
const reads = readsPracticeId(file.code);
|
|
5358
|
+
if (!reads.length || augmented()) continue;
|
|
5359
|
+
for (const index of reads) {
|
|
5360
|
+
ctx.report({
|
|
5361
|
+
rule: "scope-practice-id",
|
|
5362
|
+
level: "info",
|
|
5363
|
+
file: file.path,
|
|
5364
|
+
line: lineAt(file.code, index),
|
|
5365
|
+
subject: "practiceId",
|
|
5366
|
+
message: `scope.practiceId is the app's own scope key now, read as unknown; type it once: ${PRACTICE_ID_AUGMENTATION}`
|
|
5367
|
+
});
|
|
5368
|
+
}
|
|
5369
|
+
}
|
|
5370
|
+
}
|
|
5371
|
+
var SCRIPT_EXTS5, STUDIO_SERVER, DEEP, ROOT_REQUIRE, REMOVED_WORDS;
|
|
5372
|
+
var init_api_usage = __esm({
|
|
5373
|
+
"src/doctor/api-usage.ts"() {
|
|
5374
|
+
init_scan();
|
|
5375
|
+
init_glob();
|
|
5376
|
+
init_color_literals();
|
|
5377
|
+
init_codemods();
|
|
5378
|
+
init_scope_names();
|
|
5379
|
+
SCRIPT_EXTS5 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
|
|
5380
|
+
STUDIO_SERVER = "@marktiderman/genesis-studio-server";
|
|
5381
|
+
DEEP = /\b(?:from|import|require)\s*\(?\s*["']@marktiderman\/genesis-studio-server\/(dist|src|lib)\/[^"']*["']/g;
|
|
5382
|
+
ROOT_REQUIRE = /\brequire\s*\(\s*["']@marktiderman\/genesis-studio-server["']\s*\)/g;
|
|
5383
|
+
REMOVED_WORDS = {
|
|
5384
|
+
"timeZone-practice": 'timeZone "practice"',
|
|
5385
|
+
"resolveZone-practice": 'resolveZone("practice")',
|
|
5386
|
+
practiceTimeZone: "practiceTimeZone",
|
|
5387
|
+
"DisplayTimeZones.practice": "DisplayTimeZones.practice"
|
|
5388
|
+
};
|
|
5389
|
+
}
|
|
5390
|
+
});
|
|
5391
|
+
|
|
4881
5392
|
// src/doctor/index.ts
|
|
4882
5393
|
var doctor_exports = {};
|
|
4883
5394
|
__export(doctor_exports, {
|
|
@@ -4971,6 +5482,9 @@ function builtinChecks(config) {
|
|
|
4971
5482
|
{ name: "resource-workspaces", check: checkResourceWorkspaces },
|
|
4972
5483
|
{ name: "page-layouts", check: checkPageLayouts },
|
|
4973
5484
|
{ name: "iso-date-slices", check: checkIsoDateSlices },
|
|
5485
|
+
{ name: "resource-view-trees", check: checkTreeViews },
|
|
5486
|
+
{ name: "studio-server-imports", check: checkStudioServerImports },
|
|
5487
|
+
{ name: "removed-scope-names", check: checkRemovedScopeNames },
|
|
4974
5488
|
...(config.packs ?? []).map((p) => packs[p])
|
|
4975
5489
|
];
|
|
4976
5490
|
}
|
|
@@ -5062,6 +5576,7 @@ var init_doctor = __esm({
|
|
|
5062
5576
|
init_installs();
|
|
5063
5577
|
init_structure();
|
|
5064
5578
|
init_dates();
|
|
5579
|
+
init_api_usage();
|
|
5065
5580
|
init_config();
|
|
5066
5581
|
init_genesis();
|
|
5067
5582
|
init_patterns();
|
|
@@ -5234,8 +5749,8 @@ function routeTags(source) {
|
|
|
5234
5749
|
}
|
|
5235
5750
|
function wireStudioRoute(source, route, pageImportPath) {
|
|
5236
5751
|
const tags = routeTags(source);
|
|
5237
|
-
const
|
|
5238
|
-
const existing = tags.find((t) => new RegExp(`path=["'](/?${
|
|
5752
|
+
const relative9 = route.replace(/^\//, "");
|
|
5753
|
+
const existing = tags.find((t) => new RegExp(`path=["'](/?${relative9.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})["']`).test(t.text));
|
|
5239
5754
|
if (existing) {
|
|
5240
5755
|
return { skipped: `Your router already has a page at ${route}. Replace its element with <DataStudioPage /> to use the studio there.` };
|
|
5241
5756
|
}
|
|
@@ -5243,17 +5758,17 @@ function wireStudioRoute(source, route, pageImportPath) {
|
|
|
5243
5758
|
const roots = layouts.length ? layouts : tags.filter((t) => !t.selfClosing && t.close !== void 0 && /path=["']\/["']/.test(t.text));
|
|
5244
5759
|
if (roots.length !== 1) {
|
|
5245
5760
|
return {
|
|
5246
|
-
skipped: roots.length === 0 ? `No layout route found to put the page under. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.` : `More than one layout route; add <Route path="${
|
|
5761
|
+
skipped: roots.length === 0 ? `No layout route found to put the page under. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.` : `More than one layout route; add <Route path="${relative9}" element={<DataStudioPage />} /> inside the one your other admin pages use.`
|
|
5247
5762
|
};
|
|
5248
5763
|
}
|
|
5249
5764
|
const layout = roots[0];
|
|
5250
5765
|
const base = (/\bpath=["']([^"']*)["']/.exec(layout.text)?.[1] ?? "").replace(/^\/+|\/+$/g, "");
|
|
5251
|
-
if (base && !
|
|
5766
|
+
if (base && !relative9.startsWith(`${base}/`)) {
|
|
5252
5767
|
return {
|
|
5253
5768
|
skipped: `Your layout route lives at /${base}, outside ${route}. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.`
|
|
5254
5769
|
};
|
|
5255
5770
|
}
|
|
5256
|
-
const childPath = base ?
|
|
5771
|
+
const childPath = base ? relative9.slice(base.length + 1) : relative9;
|
|
5257
5772
|
const guard = GUARD.exec(source)?.[1];
|
|
5258
5773
|
const element = guard ? `<${guard}><DataStudioPage /></${guard}>` : "<DataStudioPage />";
|
|
5259
5774
|
const before = source.slice(0, layout.close);
|
|
@@ -6213,100 +6728,6 @@ var init_migrate = __esm({
|
|
|
6213
6728
|
}
|
|
6214
6729
|
});
|
|
6215
6730
|
|
|
6216
|
-
// src/upgrade/bump-core.mjs
|
|
6217
|
-
function compareVersions2(a, b) {
|
|
6218
|
-
const [ca, pa = ""] = a.split(/-(.*)/s);
|
|
6219
|
-
const [cb, pb = ""] = b.split(/-(.*)/s);
|
|
6220
|
-
const x = ca.split(".").map(Number), y = cb.split(".").map(Number);
|
|
6221
|
-
for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] - y[i];
|
|
6222
|
-
if (!pa || !pb) return (pa ? 0 : 1) - (pb ? 0 : 1);
|
|
6223
|
-
const fa = pa.split("."), fb = pb.split(".");
|
|
6224
|
-
for (let i = 0; i < Math.max(fa.length, fb.length); i++) {
|
|
6225
|
-
if (fa[i] === void 0) return -1;
|
|
6226
|
-
if (fb[i] === void 0) return 1;
|
|
6227
|
-
const na = /^\d+$/.test(fa[i]), nb = /^\d+$/.test(fb[i]);
|
|
6228
|
-
if (na && nb && Number(fa[i]) !== Number(fb[i])) return Number(fa[i]) - Number(fb[i]);
|
|
6229
|
-
if (na !== nb) return na ? -1 : 1;
|
|
6230
|
-
if (fa[i] !== fb[i]) return fa[i] < fb[i] ? -1 : 1;
|
|
6231
|
-
}
|
|
6232
|
-
return 0;
|
|
6233
|
-
}
|
|
6234
|
-
function bumpPackageJson(file, text, wanted) {
|
|
6235
|
-
const pkg = JSON.parse(text);
|
|
6236
|
-
const changes = [], skipped = [];
|
|
6237
|
-
for (const section of SECTIONS) {
|
|
6238
|
-
for (const [name, spec] of Object.entries(pkg[section] ?? {})) {
|
|
6239
|
-
if (!GENESIS2.test(name)) continue;
|
|
6240
|
-
const m = EXACT.exec(spec);
|
|
6241
|
-
if (!m) {
|
|
6242
|
-
skipped.push({ file, name, spec, why: "not a plain version" });
|
|
6243
|
-
continue;
|
|
6244
|
-
}
|
|
6245
|
-
const want = wanted(name);
|
|
6246
|
-
if (!want) {
|
|
6247
|
-
skipped.push({ file, name, spec, why: "no latest version on npm" });
|
|
6248
|
-
continue;
|
|
6249
|
-
}
|
|
6250
|
-
if (!PLAIN.test(want)) {
|
|
6251
|
-
skipped.push({ file, name, spec, why: `the release names ${JSON.stringify(want)}, not a version` });
|
|
6252
|
-
continue;
|
|
6253
|
-
}
|
|
6254
|
-
const cmp = compareVersions2(want, m[2]);
|
|
6255
|
-
if (cmp === 0) continue;
|
|
6256
|
-
if (cmp < 0) {
|
|
6257
|
-
skipped.push({ file, name, spec, why: `newer than ${want}` });
|
|
6258
|
-
continue;
|
|
6259
|
-
}
|
|
6260
|
-
pkg[section][name] = `${m[1] ?? ""}${want}`;
|
|
6261
|
-
changes.push({ file, name, from: spec, to: pkg[section][name] });
|
|
6262
|
-
}
|
|
6263
|
-
}
|
|
6264
|
-
if (!changes.length) return { text: null, changes, skipped };
|
|
6265
|
-
const indent = /^[ \t]+(?=")/m.exec(text)?.[0] ?? " ";
|
|
6266
|
-
return { text: JSON.stringify(pkg, null, indent) + (text.endsWith("\n") ? "\n" : ""), changes, skipped };
|
|
6267
|
-
}
|
|
6268
|
-
function bumpSummary(version, changes, skipped) {
|
|
6269
|
-
const row = (c) => `| \`${c.name}\` | ${c.from} | ${c.to} | ${c.file} |`;
|
|
6270
|
-
return [
|
|
6271
|
-
`Moves every Genesis package to the **${UMBRELLA}@${version}** release: the versions in its \`versions.json\`, and npm \`latest\` for packages it doesn't list.`,
|
|
6272
|
-
"",
|
|
6273
|
-
changes.length ? ["| Package | From | To | File |", "| --- | --- | --- | --- |", ...changes.map(row)].join("\n") : "Nothing to change.",
|
|
6274
|
-
...skipped.length ? ["", "Left alone:", "", ...skipped.map((s) => `- \`${s.name}\` ${s.spec} in ${s.file}: ${s.why}`)] : []
|
|
6275
|
-
].join("\n");
|
|
6276
|
-
}
|
|
6277
|
-
var UMBRELLA, GENESIS2, EXACT, PLAIN, SECTIONS;
|
|
6278
|
-
var init_bump_core = __esm({
|
|
6279
|
-
"src/upgrade/bump-core.mjs"() {
|
|
6280
|
-
UMBRELLA = "@marktiderman/genesis";
|
|
6281
|
-
GENESIS2 = /^@marktiderman\/genesis(-[a-z0-9-]+)?$/;
|
|
6282
|
-
EXACT = /^(\^|~|=)?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
6283
|
-
PLAIN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
6284
|
-
SECTIONS = ["dependencies", "devDependencies", "optionalDependencies"];
|
|
6285
|
-
}
|
|
6286
|
-
});
|
|
6287
|
-
|
|
6288
|
-
// src/upgrade/codemods.ts
|
|
6289
|
-
function codemodsFor(changes, registry = CODEMODS) {
|
|
6290
|
-
return registry.filter(
|
|
6291
|
-
(mod) => changes.some((c) => c.name === mod.package && compareVersions2(bare(c.from), mod.version) < 0 && compareVersions2(bare(c.to), mod.version) >= 0)
|
|
6292
|
-
);
|
|
6293
|
-
}
|
|
6294
|
-
function uncoveredBreaks(changes, registry = CODEMODS) {
|
|
6295
|
-
const major = (v) => {
|
|
6296
|
-
const [a, b] = bare(v).split(".").map(Number);
|
|
6297
|
-
return a === 0 ? `0.${b}` : String(a);
|
|
6298
|
-
};
|
|
6299
|
-
return changes.filter((c) => major(c.from) !== major(c.to) && codemodsFor([c], registry).length === 0);
|
|
6300
|
-
}
|
|
6301
|
-
var CODEMODS, bare;
|
|
6302
|
-
var init_codemods = __esm({
|
|
6303
|
-
"src/upgrade/codemods.ts"() {
|
|
6304
|
-
init_bump_core();
|
|
6305
|
-
CODEMODS = [];
|
|
6306
|
-
bare = (spec) => spec.replace(/^[\^~=]/, "");
|
|
6307
|
-
}
|
|
6308
|
-
});
|
|
6309
|
-
|
|
6310
6731
|
// src/upgrade/index.ts
|
|
6311
6732
|
var upgrade_exports = {};
|
|
6312
6733
|
__export(upgrade_exports, {
|
|
@@ -6678,9 +7099,9 @@ async function runScaffold(opts, fs2) {
|
|
|
6678
7099
|
function joinPath(...parts) {
|
|
6679
7100
|
return parts.filter(Boolean).join("/").replace(/\/+/g, "/");
|
|
6680
7101
|
}
|
|
6681
|
-
function dirname(
|
|
6682
|
-
const idx =
|
|
6683
|
-
return idx === -1 ? "." :
|
|
7102
|
+
function dirname(path37) {
|
|
7103
|
+
const idx = path37.lastIndexOf("/");
|
|
7104
|
+
return idx === -1 ? "." : path37.slice(0, idx);
|
|
6684
7105
|
}
|
|
6685
7106
|
function brandPackageJson(consumer, genesisVersion) {
|
|
6686
7107
|
return JSON.stringify(
|
|
@@ -7079,7 +7500,7 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
|
|
|
7079
7500
|
const packageJson = JSON.parse(await fs.readFile(path23.join(root, "package.json"), "utf-8").catch(() => "{}"));
|
|
7080
7501
|
const existsSync28 = (await import('fs')).existsSync;
|
|
7081
7502
|
const readSync = (await import('fs')).readFileSync;
|
|
7082
|
-
const
|
|
7503
|
+
const readdirSync13 = (await import('fs')).readdirSync;
|
|
7083
7504
|
if (opts.host && !["next", "tanstack-start", "supabase-function"].includes(opts.host)) {
|
|
7084
7505
|
throw new Error("--host must be next, tanstack-start or supabase-function.");
|
|
7085
7506
|
}
|
|
@@ -7092,7 +7513,7 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
|
|
|
7092
7513
|
listDeep: (p) => {
|
|
7093
7514
|
const out = [];
|
|
7094
7515
|
const walk2 = (rel) => {
|
|
7095
|
-
for (const entry of
|
|
7516
|
+
for (const entry of readdirSync13(path23.join(root, rel), { withFileTypes: true })) {
|
|
7096
7517
|
const child = `${rel}/${entry.name}`;
|
|
7097
7518
|
if (entry.isDirectory()) walk2(child);
|
|
7098
7519
|
else out.push(child);
|
|
@@ -7106,7 +7527,7 @@ studio.command("init").description("Turn the Data Studio on in this app: a serve
|
|
|
7106
7527
|
},
|
|
7107
7528
|
list: (p) => {
|
|
7108
7529
|
try {
|
|
7109
|
-
return
|
|
7530
|
+
return readdirSync13(path23.join(root, p));
|
|
7110
7531
|
} catch {
|
|
7111
7532
|
return [];
|
|
7112
7533
|
}
|
|
@@ -7213,6 +7634,19 @@ program.command("upgrade").description("Move every @marktiderman/genesis* depend
|
|
|
7213
7634
|
\u2714 ${report.pr}`);
|
|
7214
7635
|
if (report.doctor === "failed") process.exitCode = 1;
|
|
7215
7636
|
});
|
|
7637
|
+
program.command("codemod [id]").description("Run one of Genesis's codemods by hand (genesis upgrade runs them for you); without an id, list them").option("-d, --dir <dir>", "The app's folder", process.cwd()).option("--dry-run", "List the files it would change; change nothing", false).action(async (id, opts) => {
|
|
7638
|
+
const { CODEMODS: CODEMODS2, codemodById: codemodById2 } = await Promise.resolve().then(() => (init_codemods(), codemods_exports));
|
|
7639
|
+
if (!id) {
|
|
7640
|
+
for (const mod2 of CODEMODS2) console.log(`${mod2.id} (${mod2.package} ${mod2.version})
|
|
7641
|
+
${mod2.description}`);
|
|
7642
|
+
return;
|
|
7643
|
+
}
|
|
7644
|
+
const mod = codemodById2(id);
|
|
7645
|
+
if (!mod) throw new Error(`No codemod "${id}". Run genesis codemod to list them.`);
|
|
7646
|
+
const changed = await mod.run({ root: path23.resolve(opts.dir), dryRun: opts.dryRun, log: (m) => console.log(m) });
|
|
7647
|
+
console.log(changed.length ? `${opts.dryRun ? "Would change" : "\u2714 Changed"} ${changed.length} file${changed.length === 1 ? "" : "s"}:
|
|
7648
|
+
${changed.map((f) => ` ${f}`).join("\n")}` : "Nothing to change.");
|
|
7649
|
+
});
|
|
7216
7650
|
program.parseAsync(process.argv).catch((err) => {
|
|
7217
7651
|
const message = err instanceof Error ? err.message : String(err);
|
|
7218
7652
|
console.error(`\u2717 ${message}`);
|