@getcoherent/cli 0.6.42 → 0.6.44
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/dist/chunk-4TLYDTT3.js +22 -0
- package/dist/{chunk-QT5MRW4F.js → chunk-KJRBBLXT.js} +1 -1
- package/dist/{chunk-4A4YYAGN.js → chunk-NOM47EB4.js} +41 -3
- package/dist/chunk-Q67PCGRQ.js +308 -0
- package/dist/{chunk-TD2ZYIIC.js → chunk-QE66D55S.js} +6 -9
- package/dist/{code-generator-D3ZHOO4M.js → code-generator-ASIANBH2.js} +4 -3
- package/dist/fix-globals-css-UQCGJ5NO.js +9 -0
- package/dist/index.js +422 -585
- package/dist/{plan-generator-625ZNUZF.js → plan-generator-YOPF773K.js} +2 -2
- package/dist/{quality-validator-ONJCQ325.js → quality-validator-2KIT6QKA.js} +1 -1
- package/dist/strings-BHAW5PVU.js +11 -0
- package/package.json +2 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/utils/strings.ts
|
|
2
|
+
function toKebabCase(str) {
|
|
3
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
4
|
+
}
|
|
5
|
+
function toPascalCase(str) {
|
|
6
|
+
return str.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^(.)/, (_, c) => c.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "");
|
|
7
|
+
}
|
|
8
|
+
function toTitleCase(slug) {
|
|
9
|
+
let s = slug.trim();
|
|
10
|
+
if (!s) return "My App";
|
|
11
|
+
s = s.replace(/^@[^/]+\//, "");
|
|
12
|
+
if (!s) return "My App";
|
|
13
|
+
const words = s.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[-_\s]+/).filter(Boolean);
|
|
14
|
+
if (words.length === 0) return "My App";
|
|
15
|
+
return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
toKebabCase,
|
|
20
|
+
toPascalCase,
|
|
21
|
+
toTitleCase
|
|
22
|
+
};
|
|
@@ -155,7 +155,7 @@ function applyComponentRules(code) {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
// src/utils/quality-validator.ts
|
|
158
|
-
var RAW_COLOR_RE = /(?:(?:hover|focus|active|group-hover|focus-visible|focus-within):)?(?:bg|text|border|ring|outline|from|to|via)-(gray|blue|red|green|yellow|purple|pink|indigo|orange|slate|zinc|stone|neutral|emerald|teal|cyan|sky|violet|fuchsia|rose|amber|lime)-\d+/g;
|
|
158
|
+
var RAW_COLOR_RE = /(?:(?:hover|focus|active|group-hover|focus-visible|focus-within):)?(?:bg|text|border|ring|outline|shadow|from|to|via)-(gray|blue|red|green|yellow|purple|pink|indigo|orange|slate|zinc|stone|neutral|emerald|teal|cyan|sky|violet|fuchsia|rose|amber|lime)-\d+/g;
|
|
159
159
|
var HEX_IN_CLASS_RE = /className="[^"]*#[0-9a-fA-F]{3,8}[^"]*"/g;
|
|
160
160
|
var TEXT_BASE_RE = /\btext-base\b/g;
|
|
161
161
|
var HEAVY_SHADOW_RE = /\bshadow-(md|lg|xl|2xl)\b/g;
|
|
@@ -613,7 +613,7 @@ function resolveHref(linkText, context) {
|
|
|
613
613
|
function replaceRawColors(classes, colorMap) {
|
|
614
614
|
let changed = false;
|
|
615
615
|
let result = classes;
|
|
616
|
-
const accentColorRe = /\b((?:(?:hover|focus|active|group-hover|focus-visible|focus-within):)?)(bg|text|border|ring|outline|from|to|via)-(emerald|blue|violet|indigo|purple|teal|cyan|sky|rose|amber|red|green|yellow|pink|orange|fuchsia|lime)-(\d+)(?:\/\d+)?\b/g;
|
|
616
|
+
const accentColorRe = /\b((?:(?:hover|focus|active|group-hover|focus-visible|focus-within):)?)(bg|text|border|ring|outline|shadow|from|to|via)-(emerald|blue|violet|indigo|purple|teal|cyan|sky|rose|amber|red|green|yellow|pink|orange|fuchsia|lime)-(\d+)(?:\/\d+)?\b/g;
|
|
617
617
|
result = result.replace(accentColorRe, (m, statePrefix, prefix, color, shade) => {
|
|
618
618
|
const bareNoOpacity = m.replace(statePrefix, "").replace(/\/\d+$/, "");
|
|
619
619
|
if (colorMap[bareNoOpacity]) {
|
|
@@ -622,6 +622,26 @@ function replaceRawColors(classes, colorMap) {
|
|
|
622
622
|
}
|
|
623
623
|
const n = parseInt(shade);
|
|
624
624
|
const isDestructive = color === "red";
|
|
625
|
+
const restAfterState = m.slice(statePrefix.length);
|
|
626
|
+
const tailOpacity = restAfterState.match(/(\/\d+)$/)?.[0] ?? "";
|
|
627
|
+
const applyShadowTail = (cls) => {
|
|
628
|
+
if (!tailOpacity) return statePrefix + cls;
|
|
629
|
+
const base = cls.replace(/\/\d+$/, "");
|
|
630
|
+
return statePrefix + base + tailOpacity;
|
|
631
|
+
};
|
|
632
|
+
if (prefix === "shadow") {
|
|
633
|
+
const bgKey = `bg-${color}-${shade}`;
|
|
634
|
+
if (colorMap[bgKey]) {
|
|
635
|
+
changed = true;
|
|
636
|
+
return applyShadowTail(colorMap[bgKey].replace(/^bg-/, "shadow-"));
|
|
637
|
+
}
|
|
638
|
+
changed = true;
|
|
639
|
+
if (n <= 100) return applyShadowTail(isDestructive ? "shadow-destructive/10" : "shadow-primary/10");
|
|
640
|
+
if (n <= 200) return applyShadowTail(isDestructive ? "shadow-destructive/10" : "shadow-primary/10");
|
|
641
|
+
if (n <= 400) return applyShadowTail(isDestructive ? "shadow-destructive/20" : "shadow-primary/20");
|
|
642
|
+
if (n <= 700) return applyShadowTail(isDestructive ? "shadow-destructive" : "shadow-primary");
|
|
643
|
+
return applyShadowTail("shadow-muted");
|
|
644
|
+
}
|
|
625
645
|
if (prefix === "bg") {
|
|
626
646
|
changed = true;
|
|
627
647
|
if (n <= 100) return statePrefix + (isDestructive ? "bg-destructive/10" : "bg-primary/10");
|
|
@@ -648,7 +668,7 @@ function replaceRawColors(classes, colorMap) {
|
|
|
648
668
|
}
|
|
649
669
|
return m;
|
|
650
670
|
});
|
|
651
|
-
const neutralColorRe = /\b((?:(?:hover|focus|active|group-hover|focus-visible|focus-within):)?)(bg|text|border|ring|outline)-(zinc|slate|gray|neutral|stone)-(\d+)(?:\/\d+)?\b/g;
|
|
671
|
+
const neutralColorRe = /\b((?:(?:hover|focus|active|group-hover|focus-visible|focus-within):)?)(bg|text|border|ring|outline|shadow)-(zinc|slate|gray|neutral|stone)-(\d+)(?:\/\d+)?\b/g;
|
|
652
672
|
result = result.replace(neutralColorRe, (m, statePrefix, prefix, _color, shade) => {
|
|
653
673
|
const bareNoOpacity = m.replace(statePrefix, "").replace(/\/\d+$/, "");
|
|
654
674
|
if (colorMap[bareNoOpacity]) {
|
|
@@ -656,6 +676,24 @@ function replaceRawColors(classes, colorMap) {
|
|
|
656
676
|
return statePrefix + colorMap[bareNoOpacity];
|
|
657
677
|
}
|
|
658
678
|
const n = parseInt(shade);
|
|
679
|
+
const restAfterStateNeutral = m.slice(statePrefix.length);
|
|
680
|
+
const tailOpacityNeutral = restAfterStateNeutral.match(/(\/\d+)$/)?.[0] ?? "";
|
|
681
|
+
const applyNeutralShadowTail = (cls) => {
|
|
682
|
+
if (!tailOpacityNeutral) return statePrefix + cls;
|
|
683
|
+
const base = cls.replace(/\/\d+$/, "");
|
|
684
|
+
return statePrefix + base + tailOpacityNeutral;
|
|
685
|
+
};
|
|
686
|
+
if (prefix === "shadow") {
|
|
687
|
+
const bgKey = `bg-${_color}-${shade}`;
|
|
688
|
+
if (colorMap[bgKey]) {
|
|
689
|
+
changed = true;
|
|
690
|
+
return applyNeutralShadowTail(colorMap[bgKey].replace(/^bg-/, "shadow-"));
|
|
691
|
+
}
|
|
692
|
+
changed = true;
|
|
693
|
+
if (n <= 300) return applyNeutralShadowTail("shadow-muted");
|
|
694
|
+
if (n <= 700) return applyNeutralShadowTail("shadow-muted");
|
|
695
|
+
return applyNeutralShadowTail("shadow-background");
|
|
696
|
+
}
|
|
659
697
|
if (prefix === "bg") {
|
|
660
698
|
changed = true;
|
|
661
699
|
if (n <= 300) return statePrefix + "bg-muted";
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
// src/utils/fix-globals-css.ts
|
|
2
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
3
|
+
import { resolve as resolve2 } from "path";
|
|
4
|
+
import { buildCssVariables } from "@getcoherent/core";
|
|
5
|
+
|
|
6
|
+
// src/utils/tailwind-version.ts
|
|
7
|
+
import { existsSync, readFileSync } from "fs";
|
|
8
|
+
import { resolve } from "path";
|
|
9
|
+
function isTailwindV4(projectRoot) {
|
|
10
|
+
const pkgPath = resolve(projectRoot, "package.json");
|
|
11
|
+
if (existsSync(pkgPath)) {
|
|
12
|
+
try {
|
|
13
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
14
|
+
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
15
|
+
if (allDeps["@tailwindcss/postcss"]) return true;
|
|
16
|
+
const twVersion = allDeps["tailwindcss"] || "";
|
|
17
|
+
if (twVersion.startsWith("^4") || twVersion.startsWith("~4") || twVersion.startsWith("4")) return true;
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const globalsPath = resolve(projectRoot, "app", "globals.css");
|
|
22
|
+
if (existsSync(globalsPath)) {
|
|
23
|
+
const content = readFileSync(globalsPath, "utf-8");
|
|
24
|
+
if (content.includes('@import "tailwindcss"') || content.includes("@import 'tailwindcss'")) return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
function generateV4GlobalsCss(config) {
|
|
29
|
+
const light = config.tokens.colors.light;
|
|
30
|
+
const dark = config.tokens.colors.dark;
|
|
31
|
+
const contrastFg = (hex) => {
|
|
32
|
+
const c = hex.replace("#", "");
|
|
33
|
+
const r = parseInt(c.slice(0, 2), 16);
|
|
34
|
+
const g = parseInt(c.slice(2, 4), 16);
|
|
35
|
+
const b = parseInt(c.slice(4, 6), 16);
|
|
36
|
+
const lum = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
37
|
+
return lum > 0.5 ? "#09090b" : "#fafafa";
|
|
38
|
+
};
|
|
39
|
+
const blendColors = (hex1, hex2, ratio) => {
|
|
40
|
+
const parse = (h) => {
|
|
41
|
+
const c = h.replace("#", "");
|
|
42
|
+
return [parseInt(c.slice(0, 2), 16), parseInt(c.slice(2, 4), 16), parseInt(c.slice(4, 6), 16)];
|
|
43
|
+
};
|
|
44
|
+
const [r1, g1, b1] = parse(hex1);
|
|
45
|
+
const [r2, g2, b2] = parse(hex2);
|
|
46
|
+
const blend = (a, b) => Math.round(a + (b - a) * ratio);
|
|
47
|
+
const toHex = (n) => n.toString(16).padStart(2, "0");
|
|
48
|
+
return `#${toHex(blend(r1, r2))}${toHex(blend(g1, g2))}${toHex(blend(b1, b2))}`;
|
|
49
|
+
};
|
|
50
|
+
const radius = config.tokens.radius;
|
|
51
|
+
return `@import "tailwindcss";
|
|
52
|
+
|
|
53
|
+
@theme inline {
|
|
54
|
+
--color-background: var(--background);
|
|
55
|
+
--color-foreground: var(--foreground);
|
|
56
|
+
--color-primary: var(--primary);
|
|
57
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
58
|
+
--color-secondary: var(--secondary);
|
|
59
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
60
|
+
--color-muted: var(--muted);
|
|
61
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
62
|
+
--color-accent: var(--accent);
|
|
63
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
64
|
+
--color-destructive: var(--destructive);
|
|
65
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
66
|
+
--color-transparent: transparent;
|
|
67
|
+
--color-border: var(--border);
|
|
68
|
+
--color-input: var(--input);
|
|
69
|
+
--color-ring: var(--ring);
|
|
70
|
+
--color-card: var(--card);
|
|
71
|
+
--color-card-foreground: var(--card-foreground);
|
|
72
|
+
--color-popover: var(--popover);
|
|
73
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
74
|
+
--color-success: var(--success);
|
|
75
|
+
--color-warning: var(--warning);
|
|
76
|
+
--color-error: var(--error);
|
|
77
|
+
--color-info: var(--info);
|
|
78
|
+
--color-black: #000;
|
|
79
|
+
--color-white: #fff;
|
|
80
|
+
--color-sidebar-background: var(--sidebar-background);
|
|
81
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
82
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
83
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
84
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
85
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
86
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
87
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
88
|
+
--color-sidebar-muted: var(--sidebar-muted);
|
|
89
|
+
--color-sidebar-muted-foreground: var(--sidebar-muted-foreground);
|
|
90
|
+
--color-chart-1: var(--chart-1);
|
|
91
|
+
--color-chart-2: var(--chart-2);
|
|
92
|
+
--color-chart-3: var(--chart-3);
|
|
93
|
+
--color-chart-4: var(--chart-4);
|
|
94
|
+
--color-chart-5: var(--chart-5);
|
|
95
|
+
--radius-xs: 0.125rem;
|
|
96
|
+
--radius-sm: ${radius.sm || "0.25rem"};
|
|
97
|
+
--radius-md: ${radius.md || "0.5rem"};
|
|
98
|
+
--radius-lg: ${radius.lg || "0.75rem"};
|
|
99
|
+
--radius-xl: ${radius.xl || "1rem"};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:root {
|
|
103
|
+
--background: ${light.background};
|
|
104
|
+
--foreground: ${light.foreground};
|
|
105
|
+
--primary: ${light.primary};
|
|
106
|
+
--primary-foreground: ${contrastFg(light.primary)};
|
|
107
|
+
--secondary: ${light.secondary};
|
|
108
|
+
--secondary-foreground: ${contrastFg(light.secondary)};
|
|
109
|
+
--muted: ${light.muted};
|
|
110
|
+
--muted-foreground: ${blendColors(light.foreground, light.background, 0.45)};
|
|
111
|
+
--accent: ${light.accent || light.muted};
|
|
112
|
+
--accent-foreground: ${light.foreground};
|
|
113
|
+
--destructive: ${light.error};
|
|
114
|
+
--destructive-foreground: ${contrastFg(light.error)};
|
|
115
|
+
--border: ${light.border};
|
|
116
|
+
--input: ${light.border};
|
|
117
|
+
--ring: ${light.primary};
|
|
118
|
+
--radius: ${radius.md || "0.5rem"};
|
|
119
|
+
--card: ${light.background};
|
|
120
|
+
--card-foreground: ${light.foreground};
|
|
121
|
+
--popover: ${light.background};
|
|
122
|
+
--popover-foreground: ${light.foreground};
|
|
123
|
+
--success: ${light.success};
|
|
124
|
+
--warning: ${light.warning};
|
|
125
|
+
--error: ${light.error};
|
|
126
|
+
--info: ${light.info || light.primary};
|
|
127
|
+
--sidebar-background: ${light.background};
|
|
128
|
+
--sidebar-foreground: ${light.foreground};
|
|
129
|
+
--sidebar-primary: ${light.primary};
|
|
130
|
+
--sidebar-primary-foreground: ${contrastFg(light.primary)};
|
|
131
|
+
--sidebar-accent: ${light.accent || light.muted};
|
|
132
|
+
--sidebar-accent-foreground: ${light.foreground};
|
|
133
|
+
--sidebar-border: ${light.border};
|
|
134
|
+
--sidebar-ring: ${light.primary};
|
|
135
|
+
--sidebar-muted: ${light.muted};
|
|
136
|
+
--sidebar-muted-foreground: ${blendColors(light.foreground, light.background, 0.45)};
|
|
137
|
+
--chart-1: ${light.primary};
|
|
138
|
+
--chart-2: ${light.success};
|
|
139
|
+
--chart-3: ${light.warning};
|
|
140
|
+
--chart-4: ${light.error};
|
|
141
|
+
--chart-5: ${light.info || light.primary};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.dark {
|
|
145
|
+
--background: ${dark.background};
|
|
146
|
+
--foreground: ${dark.foreground};
|
|
147
|
+
--primary: ${dark.primary};
|
|
148
|
+
--primary-foreground: ${contrastFg(dark.primary)};
|
|
149
|
+
--secondary: ${dark.secondary};
|
|
150
|
+
--secondary-foreground: ${contrastFg(dark.secondary)};
|
|
151
|
+
--muted: ${dark.muted};
|
|
152
|
+
--muted-foreground: ${blendColors(dark.foreground, dark.background, 0.45)};
|
|
153
|
+
--accent: ${dark.accent || dark.muted};
|
|
154
|
+
--accent-foreground: ${dark.foreground};
|
|
155
|
+
--destructive: ${dark.error};
|
|
156
|
+
--destructive-foreground: ${contrastFg(dark.error)};
|
|
157
|
+
--border: ${dark.border};
|
|
158
|
+
--input: ${dark.border};
|
|
159
|
+
--ring: ${dark.primary};
|
|
160
|
+
--card: ${dark.background};
|
|
161
|
+
--card-foreground: ${dark.foreground};
|
|
162
|
+
--popover: ${dark.background};
|
|
163
|
+
--popover-foreground: ${dark.foreground};
|
|
164
|
+
--success: ${dark.success};
|
|
165
|
+
--warning: ${dark.warning};
|
|
166
|
+
--error: ${dark.error};
|
|
167
|
+
--info: ${dark.info || dark.primary};
|
|
168
|
+
--sidebar-background: ${dark.background};
|
|
169
|
+
--sidebar-foreground: ${dark.foreground};
|
|
170
|
+
--sidebar-primary: ${dark.primary};
|
|
171
|
+
--sidebar-primary-foreground: ${contrastFg(dark.primary)};
|
|
172
|
+
--sidebar-accent: ${dark.accent || dark.muted};
|
|
173
|
+
--sidebar-accent-foreground: ${dark.foreground};
|
|
174
|
+
--sidebar-border: ${dark.border};
|
|
175
|
+
--sidebar-ring: ${dark.primary};
|
|
176
|
+
--sidebar-muted: ${dark.muted};
|
|
177
|
+
--sidebar-muted-foreground: ${blendColors(dark.foreground, dark.background, 0.45)};
|
|
178
|
+
--chart-1: ${dark.primary};
|
|
179
|
+
--chart-2: ${dark.success};
|
|
180
|
+
--chart-3: ${dark.warning};
|
|
181
|
+
--chart-4: ${dark.error};
|
|
182
|
+
--chart-5: ${dark.info || dark.primary};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
* {
|
|
186
|
+
border-color: var(--border);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
body {
|
|
190
|
+
background-color: var(--background);
|
|
191
|
+
color: var(--foreground);
|
|
192
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/utils/fix-globals-css.ts
|
|
198
|
+
function needsGlobalsFix(projectRoot) {
|
|
199
|
+
const globalsPath = resolve2(projectRoot, "app", "globals.css");
|
|
200
|
+
if (!existsSync2(globalsPath)) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
const content = readFileSync2(globalsPath, "utf-8");
|
|
204
|
+
if (isTailwindV4(projectRoot)) {
|
|
205
|
+
if (!content.includes("@theme inline")) return true;
|
|
206
|
+
if (content.includes("@tailwind base")) return true;
|
|
207
|
+
const REQUIRED_V4_TOKENS = [
|
|
208
|
+
"--color-transparent",
|
|
209
|
+
"--color-sidebar-background",
|
|
210
|
+
"--color-chart-1",
|
|
211
|
+
"--color-black",
|
|
212
|
+
"--color-white",
|
|
213
|
+
"--radius-xs"
|
|
214
|
+
];
|
|
215
|
+
for (const token of REQUIRED_V4_TOKENS) {
|
|
216
|
+
if (!content.includes(token)) return true;
|
|
217
|
+
}
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
if (content.includes(":root {") || content.includes(".dark {")) return true;
|
|
221
|
+
if (content.includes("@apply")) return true;
|
|
222
|
+
if (!content.includes("@tailwind base") || content.length < 100) return true;
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
function fixGlobalsCss(projectRoot, config) {
|
|
226
|
+
const globalsPath = resolve2(projectRoot, "app", "globals.css");
|
|
227
|
+
const layoutPath = resolve2(projectRoot, "app", "layout.tsx");
|
|
228
|
+
if (!existsSync2(globalsPath)) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (isTailwindV4(projectRoot)) {
|
|
232
|
+
const v4Css = generateV4GlobalsCss(config);
|
|
233
|
+
writeFileSync(globalsPath, v4Css, "utf-8");
|
|
234
|
+
if (existsSync2(layoutPath)) {
|
|
235
|
+
let layoutContent2 = readFileSync2(layoutPath, "utf-8");
|
|
236
|
+
if (layoutContent2.includes("dangerouslySetInnerHTML")) {
|
|
237
|
+
const styleStart = layoutContent2.indexOf("<style dangerouslySetInnerHTML");
|
|
238
|
+
if (styleStart !== -1) {
|
|
239
|
+
const styleEnd = layoutContent2.indexOf("/>", styleStart);
|
|
240
|
+
if (styleEnd !== -1) {
|
|
241
|
+
const before = layoutContent2.slice(0, styleStart).replace(/\s+$/, "");
|
|
242
|
+
const after = layoutContent2.slice(styleEnd + 2).replace(/^\s*\n/, "\n");
|
|
243
|
+
layoutContent2 = before + after;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
layoutContent2 = layoutContent2.replace(/\s*<head>\s*<\/head>\s*/g, "\n");
|
|
247
|
+
writeFileSync(layoutPath, layoutContent2, "utf-8");
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const minimalCss = `@tailwind base;
|
|
253
|
+
@tailwind components;
|
|
254
|
+
@tailwind utilities;
|
|
255
|
+
|
|
256
|
+
@layer base {
|
|
257
|
+
* {
|
|
258
|
+
border-color: var(--border);
|
|
259
|
+
}
|
|
260
|
+
body {
|
|
261
|
+
background-color: var(--background);
|
|
262
|
+
color: var(--foreground);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
`;
|
|
266
|
+
writeFileSync(globalsPath, minimalCss, "utf-8");
|
|
267
|
+
if (!existsSync2(layoutPath)) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
let layoutContent = readFileSync2(layoutPath, "utf-8");
|
|
271
|
+
if (layoutContent.includes("dangerouslySetInnerHTML")) {
|
|
272
|
+
const cssVars2 = buildCssVariables(config);
|
|
273
|
+
const marker = "__html: ";
|
|
274
|
+
const markerIdx = layoutContent.indexOf(marker);
|
|
275
|
+
if (markerIdx !== -1) {
|
|
276
|
+
const valueStart = markerIdx + marker.length;
|
|
277
|
+
const jsonStr = JSON.stringify(cssVars2);
|
|
278
|
+
const oldQuoteStart = layoutContent.indexOf('"', valueStart);
|
|
279
|
+
if (oldQuoteStart !== -1) {
|
|
280
|
+
let i = oldQuoteStart + 1;
|
|
281
|
+
while (i < layoutContent.length) {
|
|
282
|
+
if (layoutContent[i] === "\\") {
|
|
283
|
+
i += 2;
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
if (layoutContent[i] === '"') break;
|
|
287
|
+
i++;
|
|
288
|
+
}
|
|
289
|
+
layoutContent = layoutContent.slice(0, oldQuoteStart) + jsonStr + layoutContent.slice(i + 1);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
writeFileSync(layoutPath, layoutContent, "utf-8");
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const cssVars = buildCssVariables(config);
|
|
296
|
+
const headBlock = `<head>
|
|
297
|
+
<style dangerouslySetInnerHTML={{ __html: ${JSON.stringify(cssVars)} }} />
|
|
298
|
+
</head>`;
|
|
299
|
+
layoutContent = layoutContent.replace('<html lang="en">', '<html lang="en">\n ' + headBlock);
|
|
300
|
+
writeFileSync(layoutPath, layoutContent, "utf-8");
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export {
|
|
304
|
+
isTailwindV4,
|
|
305
|
+
generateV4GlobalsCss,
|
|
306
|
+
needsGlobalsFix,
|
|
307
|
+
fixGlobalsCss
|
|
308
|
+
};
|
|
@@ -6,7 +6,10 @@ import {
|
|
|
6
6
|
getPageGroup,
|
|
7
7
|
installPackages,
|
|
8
8
|
sanitizeMetadataStrings
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-KJRBBLXT.js";
|
|
10
|
+
import {
|
|
11
|
+
toKebabCase
|
|
12
|
+
} from "./chunk-4TLYDTT3.js";
|
|
10
13
|
|
|
11
14
|
// src/commands/chat/code-generator.ts
|
|
12
15
|
import { resolve as resolve3 } from "path";
|
|
@@ -1793,11 +1796,6 @@ function getComponentProvider(_config) {
|
|
|
1793
1796
|
return _instance;
|
|
1794
1797
|
}
|
|
1795
1798
|
|
|
1796
|
-
// src/utils/strings.ts
|
|
1797
|
-
function toKebabCase(str) {
|
|
1798
|
-
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
1799
|
// src/commands/chat/utils.ts
|
|
1802
1800
|
import { resolve as resolve2 } from "path";
|
|
1803
1801
|
import { existsSync as existsSync4, readFileSync as readFileSync2 } from "fs";
|
|
@@ -2149,7 +2147,7 @@ async function regeneratePage(pageId, config, projectRoot) {
|
|
|
2149
2147
|
const code = await generator.generate(page, appType);
|
|
2150
2148
|
const route = page.route || "/";
|
|
2151
2149
|
const isAuth = isAuthRoute(route) || isAuthRoute(page.name || page.id || "");
|
|
2152
|
-
const { loadPlan: loadPlanForPath } = await import("./plan-generator-
|
|
2150
|
+
const { loadPlan: loadPlanForPath } = await import("./plan-generator-YOPF773K.js");
|
|
2153
2151
|
const planForPath = loadPlanForPath(projectRoot);
|
|
2154
2152
|
const filePath = routeToFsPath(projectRoot, route, planForPath || isAuth);
|
|
2155
2153
|
await mkdir3(dirname3(filePath), { recursive: true });
|
|
@@ -2338,7 +2336,7 @@ export default function AppLayout({
|
|
|
2338
2336
|
{children}
|
|
2339
2337
|
</main>
|
|
2340
2338
|
<footer className="border-t px-4 py-3 text-xs text-muted-foreground">
|
|
2341
|
-
|
|
2339
|
+
\xA9 ${year} ${name}
|
|
2342
2340
|
</footer>
|
|
2343
2341
|
</SidebarInset>
|
|
2344
2342
|
</SidebarProvider>
|
|
@@ -2519,7 +2517,6 @@ export {
|
|
|
2519
2517
|
getShadcnComponent,
|
|
2520
2518
|
listShadcnComponents,
|
|
2521
2519
|
getComponentProvider,
|
|
2522
|
-
toKebabCase,
|
|
2523
2520
|
isAuthRoute,
|
|
2524
2521
|
detectPageType,
|
|
2525
2522
|
expandPageRequest,
|
|
@@ -12,10 +12,11 @@ import {
|
|
|
12
12
|
regeneratePage,
|
|
13
13
|
scanAndInstallSharedDeps,
|
|
14
14
|
validateAndFixGeneratedCode
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-QE66D55S.js";
|
|
16
|
+
import "./chunk-KJRBBLXT.js";
|
|
17
|
+
import "./chunk-4TLYDTT3.js";
|
|
17
18
|
import "./chunk-5AHG4NNX.js";
|
|
18
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-NOM47EB4.js";
|
|
19
20
|
import "./chunk-3RG5ZIWI.js";
|
|
20
21
|
export {
|
|
21
22
|
buildAppLayoutCode,
|