@ng-shangjc/cli 1.0.4-beta → 1.0.5-beta
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/commands/init.js +137 -95
- package/package.json +1 -1
- package/src/commands/init.ts +144 -96
package/dist/commands/init.js
CHANGED
|
@@ -153,56 +153,6 @@ async function initProject() {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
async function setupTailwind() {
|
|
156
|
-
// Check if tailwind.config.js exists
|
|
157
|
-
const tailwindConfigPath = 'tailwind.config.js';
|
|
158
|
-
if (!fs.existsSync(tailwindConfigPath)) {
|
|
159
|
-
const tailwindConfig = `/** @type {import('tailwindcss').Config} */
|
|
160
|
-
module.exports = {
|
|
161
|
-
content: [
|
|
162
|
-
"./src/**/*.{html,ts}",
|
|
163
|
-
],
|
|
164
|
-
darkMode: 'class',
|
|
165
|
-
theme: {
|
|
166
|
-
extend: {
|
|
167
|
-
colors: {
|
|
168
|
-
primary: {
|
|
169
|
-
DEFAULT: 'hsl(var(--primary))',
|
|
170
|
-
foreground: 'hsl(var(--primary-foreground))',
|
|
171
|
-
},
|
|
172
|
-
secondary: {
|
|
173
|
-
DEFAULT: 'hsl(var(--secondary))',
|
|
174
|
-
foreground: 'hsl(var(--secondary-foreground))',
|
|
175
|
-
},
|
|
176
|
-
muted: {
|
|
177
|
-
DEFAULT: 'hsl(var(--muted))',
|
|
178
|
-
foreground: 'hsl(var(--muted-foreground))',
|
|
179
|
-
},
|
|
180
|
-
accent: {
|
|
181
|
-
DEFAULT: 'hsl(var(--accent))',
|
|
182
|
-
foreground: 'hsl(var(--accent-foreground))',
|
|
183
|
-
},
|
|
184
|
-
destructive: {
|
|
185
|
-
DEFAULT: 'hsl(var(--destructive))',
|
|
186
|
-
foreground: 'hsl(var(--destructive-foreground))',
|
|
187
|
-
},
|
|
188
|
-
border: 'hsl(var(--border))',
|
|
189
|
-
input: 'hsl(var(--input))',
|
|
190
|
-
ring: 'hsl(var(--ring))',
|
|
191
|
-
background: 'hsl(var(--background))',
|
|
192
|
-
foreground: 'hsl(var(--foreground))',
|
|
193
|
-
},
|
|
194
|
-
borderRadius: {
|
|
195
|
-
lg: 'var(--radius)',
|
|
196
|
-
md: 'calc(var(--radius) - 2px)',
|
|
197
|
-
sm: 'calc(var(--radius) - 4px)',
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
plugins: [],
|
|
202
|
-
};`;
|
|
203
|
-
await fs.writeFile(tailwindConfigPath, tailwindConfig);
|
|
204
|
-
console.log('✅ Created tailwind.config.js');
|
|
205
|
-
}
|
|
206
156
|
// Update global styles with Tailwind 4 @theme directive
|
|
207
157
|
const globalStylesPath = 'src/styles.css';
|
|
208
158
|
// Check if styles.css exists, if not try other common locations
|
|
@@ -215,43 +165,106 @@ module.exports = {
|
|
|
215
165
|
stylesPath = 'src/app.css';
|
|
216
166
|
}
|
|
217
167
|
}
|
|
218
|
-
|
|
219
|
-
|
|
168
|
+
// Read existing content or create empty string for new file
|
|
169
|
+
let existingContent = '';
|
|
170
|
+
if (fs.existsSync(stylesPath)) {
|
|
171
|
+
existingContent = await fs.readFile(stylesPath, 'utf8');
|
|
172
|
+
}
|
|
173
|
+
// Check if Tailwind import already exists
|
|
174
|
+
const hasTailwindImport = existingContent.includes("@import 'tailwindcss';");
|
|
175
|
+
let newContent = '';
|
|
176
|
+
// Add Tailwind import if not present
|
|
177
|
+
if (!hasTailwindImport) {
|
|
178
|
+
newContent += "@import 'tailwindcss';\n";
|
|
179
|
+
}
|
|
180
|
+
// Add dark mode custom variant if user wants dark mode
|
|
181
|
+
const config = await fs.readJson('shangjc.config.json');
|
|
182
|
+
if (config.theme === 'dark' || config.theme === 'both') {
|
|
183
|
+
newContent += "@custom-variant dark (&:where(.dark, .dark *));\n";
|
|
184
|
+
}
|
|
185
|
+
// Add the default theme
|
|
186
|
+
newContent += `
|
|
220
187
|
@theme {
|
|
221
|
-
--color-
|
|
222
|
-
--color-
|
|
223
|
-
--color-
|
|
224
|
-
--color-
|
|
225
|
-
--color-
|
|
226
|
-
|
|
227
|
-
--color-
|
|
228
|
-
--color-
|
|
229
|
-
|
|
230
|
-
--color-
|
|
231
|
-
--color-
|
|
232
|
-
|
|
233
|
-
--color-
|
|
234
|
-
--color-
|
|
235
|
-
|
|
188
|
+
--color-border: hsl(var(--border));
|
|
189
|
+
--color-input: hsl(var(--input));
|
|
190
|
+
--color-ring: hsl(var(--ring));
|
|
191
|
+
--color-background: hsl(var(--background));
|
|
192
|
+
--color-foreground: hsl(var(--foreground));
|
|
193
|
+
|
|
194
|
+
--color-primary: hsl(var(--primary));
|
|
195
|
+
--color-primary-foreground: hsl(var(--primary-foreground));
|
|
196
|
+
|
|
197
|
+
--color-secondary: hsl(var(--secondary));
|
|
198
|
+
--color-secondary-foreground: hsl(var(--secondary-foreground));
|
|
199
|
+
|
|
200
|
+
--color-destructive: hsl(var(--destructive));
|
|
201
|
+
--color-destructive-foreground: hsl(var(--destructive-foreground));
|
|
202
|
+
|
|
203
|
+
--color-muted: hsl(var(--muted));
|
|
204
|
+
--color-muted-foreground: hsl(var(--muted-foreground));
|
|
205
|
+
|
|
206
|
+
--color-accent: hsl(var(--accent));
|
|
207
|
+
--color-accent-foreground: hsl(var(--accent-foreground));
|
|
208
|
+
|
|
209
|
+
--color-popover: hsl(var(--popover));
|
|
210
|
+
--color-popover-foreground: hsl(var(--popover-foreground));
|
|
211
|
+
|
|
212
|
+
--color-card: hsl(var(--card));
|
|
213
|
+
--color-card-foreground: hsl(var(--card-foreground));
|
|
236
214
|
--radius: 0.5rem;
|
|
215
|
+
--radius-sm: calc(var(--radius) - 0.25rem);
|
|
216
|
+
--radius-md: calc(var(--radius) - 0.125rem);
|
|
217
|
+
--radius-lg: var(--radius);
|
|
218
|
+
--radius-xl: calc(var(--radius) * 1.5);
|
|
219
|
+
--radius-2xl: calc(var(--radius) * 2);
|
|
220
|
+
--radius-3xl: calc(var(--radius) * 3);
|
|
221
|
+
--radius-full: 9999px;
|
|
237
222
|
}
|
|
238
223
|
|
|
224
|
+
:root {
|
|
225
|
+
@apply [color-scheme:light];
|
|
226
|
+
--background: 0 0% 100%;
|
|
227
|
+
--foreground: 222.2 84% 4.9%;
|
|
228
|
+
--card: 0 0% 100%;
|
|
229
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
230
|
+
--popover: 0 0% 100%;
|
|
231
|
+
--popover-foreground: 222.2 84% 4.9%;
|
|
232
|
+
--primary: 222.2 47.4% 11.2%;
|
|
233
|
+
--primary-foreground: 210 40% 98%;
|
|
234
|
+
--secondary: 210 40% 96.1%;
|
|
235
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
236
|
+
--muted: 210 40% 96.1%;
|
|
237
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
238
|
+
--accent: 210 40% 96.1%;
|
|
239
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
240
|
+
--destructive: 0 84.2% 60.2%;
|
|
241
|
+
--destructive-foreground: 210 40% 98%;
|
|
242
|
+
--border: 214.3 31.8% 91.4%;
|
|
243
|
+
--input: 214.3 31.8% 91.4%;
|
|
244
|
+
--ring: 222.2 84% 4.9%;
|
|
245
|
+
--radius: 0.5rem;
|
|
246
|
+
}
|
|
239
247
|
.dark {
|
|
240
|
-
|
|
241
|
-
--
|
|
242
|
-
--
|
|
243
|
-
--
|
|
244
|
-
--
|
|
245
|
-
--
|
|
246
|
-
--
|
|
247
|
-
--
|
|
248
|
-
--
|
|
249
|
-
--
|
|
250
|
-
--
|
|
251
|
-
--
|
|
252
|
-
--
|
|
253
|
-
--
|
|
254
|
-
--
|
|
248
|
+
@apply [color-scheme:dark];
|
|
249
|
+
--background: 222.2 84% 4.9%;
|
|
250
|
+
--foreground: 210 40% 98%;
|
|
251
|
+
--card: 222.2 84% 4.9%;
|
|
252
|
+
--card-foreground: 210 40% 98%;
|
|
253
|
+
--popover: 222.2 84% 4.9%;
|
|
254
|
+
--popover-foreground: 210 40% 98%;
|
|
255
|
+
--primary: 210 40% 98%;
|
|
256
|
+
--primary-foreground: 222.2 47.4% 11.2%;
|
|
257
|
+
--secondary: 217.2 32.6% 17.5%;
|
|
258
|
+
--secondary-foreground: 210 40% 98%;
|
|
259
|
+
--muted: 217.2 32.6% 17.5%;
|
|
260
|
+
--muted-foreground: 215 20.2% 65.1%;
|
|
261
|
+
--accent: 217.2 32.6% 17.5%;
|
|
262
|
+
--accent-foreground: 210 40% 98%;
|
|
263
|
+
--destructive: 0 62.8% 30.6%;
|
|
264
|
+
--destructive-foreground: 210 40% 98%;
|
|
265
|
+
--border: 217.2 32.6% 17.5%;
|
|
266
|
+
--input: 217.2 32.6% 17.5%;
|
|
267
|
+
--ring: 212.7 26.8% 83.9%;
|
|
255
268
|
}
|
|
256
269
|
|
|
257
270
|
@layer base {
|
|
@@ -260,21 +273,50 @@ module.exports = {
|
|
|
260
273
|
}
|
|
261
274
|
body {
|
|
262
275
|
@apply bg-background text-foreground;
|
|
276
|
+
font-feature-settings: "rlig" 1, "calt" 1;
|
|
263
277
|
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
else {
|
|
273
|
-
console.log(`⚠️ ${stylesPath} already contains Tailwind imports`);
|
|
278
|
+
}
|
|
279
|
+
`;
|
|
280
|
+
// Preserve existing styles after the theme
|
|
281
|
+
if (existingContent && !hasTailwindImport) {
|
|
282
|
+
// If file existed but didn't have tailwind import, keep existing content
|
|
283
|
+
const existingWithoutTailwind = existingContent;
|
|
284
|
+
if (existingWithoutTailwind.trim()) {
|
|
285
|
+
newContent += '\n\n' + existingWithoutTailwind;
|
|
274
286
|
}
|
|
275
287
|
}
|
|
276
|
-
else {
|
|
277
|
-
|
|
278
|
-
|
|
288
|
+
else if (existingContent && hasTailwindImport) {
|
|
289
|
+
// If file had tailwind import, remove the old theme and keep other styles
|
|
290
|
+
const lines = existingContent.split('\n');
|
|
291
|
+
const afterThemeLines = [];
|
|
292
|
+
let inThemeBlock = false;
|
|
293
|
+
let foundTheme = false;
|
|
294
|
+
for (const line of lines) {
|
|
295
|
+
if (line.includes('@theme {') || line.includes(':root {') || line.includes('.dark {') || line.includes('@layer base {')) {
|
|
296
|
+
inThemeBlock = true;
|
|
297
|
+
foundTheme = true;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (inThemeBlock && line.includes('}') && !line.includes('@layer')) {
|
|
301
|
+
inThemeBlock = false;
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (inThemeBlock && line.includes('@layer base {')) {
|
|
305
|
+
// Skip the old @layer base content
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (inThemeBlock) {
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (foundTheme && line.trim()) {
|
|
312
|
+
afterThemeLines.push(line);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (afterThemeLines.length > 0) {
|
|
316
|
+
newContent += '\n\n' + afterThemeLines.join('\n');
|
|
317
|
+
}
|
|
279
318
|
}
|
|
319
|
+
// Write the updated content
|
|
320
|
+
await fs.writeFile(stylesPath, newContent);
|
|
321
|
+
console.log(`✅ Updated ${stylesPath} with Tailwind 4 theme`);
|
|
280
322
|
}
|
package/package.json
CHANGED
package/src/commands/init.ts
CHANGED
|
@@ -124,59 +124,6 @@ export async function initProject() {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
async function setupTailwind() {
|
|
127
|
-
// Check if tailwind.config.js exists
|
|
128
|
-
const tailwindConfigPath = 'tailwind.config.js';
|
|
129
|
-
|
|
130
|
-
if (!fs.existsSync(tailwindConfigPath)) {
|
|
131
|
-
const tailwindConfig = `/** @type {import('tailwindcss').Config} */
|
|
132
|
-
module.exports = {
|
|
133
|
-
content: [
|
|
134
|
-
"./src/**/*.{html,ts}",
|
|
135
|
-
],
|
|
136
|
-
darkMode: 'class',
|
|
137
|
-
theme: {
|
|
138
|
-
extend: {
|
|
139
|
-
colors: {
|
|
140
|
-
primary: {
|
|
141
|
-
DEFAULT: 'hsl(var(--primary))',
|
|
142
|
-
foreground: 'hsl(var(--primary-foreground))',
|
|
143
|
-
},
|
|
144
|
-
secondary: {
|
|
145
|
-
DEFAULT: 'hsl(var(--secondary))',
|
|
146
|
-
foreground: 'hsl(var(--secondary-foreground))',
|
|
147
|
-
},
|
|
148
|
-
muted: {
|
|
149
|
-
DEFAULT: 'hsl(var(--muted))',
|
|
150
|
-
foreground: 'hsl(var(--muted-foreground))',
|
|
151
|
-
},
|
|
152
|
-
accent: {
|
|
153
|
-
DEFAULT: 'hsl(var(--accent))',
|
|
154
|
-
foreground: 'hsl(var(--accent-foreground))',
|
|
155
|
-
},
|
|
156
|
-
destructive: {
|
|
157
|
-
DEFAULT: 'hsl(var(--destructive))',
|
|
158
|
-
foreground: 'hsl(var(--destructive-foreground))',
|
|
159
|
-
},
|
|
160
|
-
border: 'hsl(var(--border))',
|
|
161
|
-
input: 'hsl(var(--input))',
|
|
162
|
-
ring: 'hsl(var(--ring))',
|
|
163
|
-
background: 'hsl(var(--background))',
|
|
164
|
-
foreground: 'hsl(var(--foreground))',
|
|
165
|
-
},
|
|
166
|
-
borderRadius: {
|
|
167
|
-
lg: 'var(--radius)',
|
|
168
|
-
md: 'calc(var(--radius) - 2px)',
|
|
169
|
-
sm: 'calc(var(--radius) - 4px)',
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
plugins: [],
|
|
174
|
-
};`;
|
|
175
|
-
|
|
176
|
-
await fs.writeFile(tailwindConfigPath, tailwindConfig);
|
|
177
|
-
console.log('✅ Created tailwind.config.js');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
127
|
// Update global styles with Tailwind 4 @theme directive
|
|
181
128
|
const globalStylesPath = 'src/styles.css';
|
|
182
129
|
|
|
@@ -190,43 +137,111 @@ module.exports = {
|
|
|
190
137
|
}
|
|
191
138
|
}
|
|
192
139
|
|
|
193
|
-
|
|
140
|
+
// Read existing content or create empty string for new file
|
|
141
|
+
let existingContent = '';
|
|
142
|
+
if (fs.existsSync(stylesPath)) {
|
|
143
|
+
existingContent = await fs.readFile(stylesPath, 'utf8');
|
|
144
|
+
}
|
|
194
145
|
|
|
146
|
+
// Check if Tailwind import already exists
|
|
147
|
+
const hasTailwindImport = existingContent.includes("@import 'tailwindcss';");
|
|
148
|
+
|
|
149
|
+
let newContent = '';
|
|
150
|
+
|
|
151
|
+
// Add Tailwind import if not present
|
|
152
|
+
if (!hasTailwindImport) {
|
|
153
|
+
newContent += "@import 'tailwindcss';\n";
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Add dark mode custom variant if user wants dark mode
|
|
157
|
+
const config = await fs.readJson('shangjc.config.json');
|
|
158
|
+
if (config.theme === 'dark' || config.theme === 'both') {
|
|
159
|
+
newContent += "@custom-variant dark (&:where(.dark, .dark *));\n";
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Add the default theme
|
|
163
|
+
newContent += `
|
|
195
164
|
@theme {
|
|
196
|
-
--color-
|
|
197
|
-
--color-
|
|
198
|
-
--color-
|
|
199
|
-
--color-
|
|
200
|
-
--color-
|
|
201
|
-
|
|
202
|
-
--color-
|
|
203
|
-
--color-
|
|
204
|
-
|
|
205
|
-
--color-
|
|
206
|
-
--color-
|
|
207
|
-
|
|
208
|
-
--color-
|
|
209
|
-
--color-
|
|
210
|
-
|
|
165
|
+
--color-border: hsl(var(--border));
|
|
166
|
+
--color-input: hsl(var(--input));
|
|
167
|
+
--color-ring: hsl(var(--ring));
|
|
168
|
+
--color-background: hsl(var(--background));
|
|
169
|
+
--color-foreground: hsl(var(--foreground));
|
|
170
|
+
|
|
171
|
+
--color-primary: hsl(var(--primary));
|
|
172
|
+
--color-primary-foreground: hsl(var(--primary-foreground));
|
|
173
|
+
|
|
174
|
+
--color-secondary: hsl(var(--secondary));
|
|
175
|
+
--color-secondary-foreground: hsl(var(--secondary-foreground));
|
|
176
|
+
|
|
177
|
+
--color-destructive: hsl(var(--destructive));
|
|
178
|
+
--color-destructive-foreground: hsl(var(--destructive-foreground));
|
|
179
|
+
|
|
180
|
+
--color-muted: hsl(var(--muted));
|
|
181
|
+
--color-muted-foreground: hsl(var(--muted-foreground));
|
|
182
|
+
|
|
183
|
+
--color-accent: hsl(var(--accent));
|
|
184
|
+
--color-accent-foreground: hsl(var(--accent-foreground));
|
|
185
|
+
|
|
186
|
+
--color-popover: hsl(var(--popover));
|
|
187
|
+
--color-popover-foreground: hsl(var(--popover-foreground));
|
|
188
|
+
|
|
189
|
+
--color-card: hsl(var(--card));
|
|
190
|
+
--color-card-foreground: hsl(var(--card-foreground));
|
|
211
191
|
--radius: 0.5rem;
|
|
192
|
+
--radius-sm: calc(var(--radius) - 0.25rem);
|
|
193
|
+
--radius-md: calc(var(--radius) - 0.125rem);
|
|
194
|
+
--radius-lg: var(--radius);
|
|
195
|
+
--radius-xl: calc(var(--radius) * 1.5);
|
|
196
|
+
--radius-2xl: calc(var(--radius) * 2);
|
|
197
|
+
--radius-3xl: calc(var(--radius) * 3);
|
|
198
|
+
--radius-full: 9999px;
|
|
212
199
|
}
|
|
213
200
|
|
|
201
|
+
:root {
|
|
202
|
+
@apply [color-scheme:light];
|
|
203
|
+
--background: 0 0% 100%;
|
|
204
|
+
--foreground: 222.2 84% 4.9%;
|
|
205
|
+
--card: 0 0% 100%;
|
|
206
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
207
|
+
--popover: 0 0% 100%;
|
|
208
|
+
--popover-foreground: 222.2 84% 4.9%;
|
|
209
|
+
--primary: 222.2 47.4% 11.2%;
|
|
210
|
+
--primary-foreground: 210 40% 98%;
|
|
211
|
+
--secondary: 210 40% 96.1%;
|
|
212
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
213
|
+
--muted: 210 40% 96.1%;
|
|
214
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
215
|
+
--accent: 210 40% 96.1%;
|
|
216
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
217
|
+
--destructive: 0 84.2% 60.2%;
|
|
218
|
+
--destructive-foreground: 210 40% 98%;
|
|
219
|
+
--border: 214.3 31.8% 91.4%;
|
|
220
|
+
--input: 214.3 31.8% 91.4%;
|
|
221
|
+
--ring: 222.2 84% 4.9%;
|
|
222
|
+
--radius: 0.5rem;
|
|
223
|
+
}
|
|
214
224
|
.dark {
|
|
215
|
-
|
|
216
|
-
--
|
|
217
|
-
--
|
|
218
|
-
--
|
|
219
|
-
--
|
|
220
|
-
--
|
|
221
|
-
--
|
|
222
|
-
--
|
|
223
|
-
--
|
|
224
|
-
--
|
|
225
|
-
--
|
|
226
|
-
--
|
|
227
|
-
--
|
|
228
|
-
--
|
|
229
|
-
--
|
|
225
|
+
@apply [color-scheme:dark];
|
|
226
|
+
--background: 222.2 84% 4.9%;
|
|
227
|
+
--foreground: 210 40% 98%;
|
|
228
|
+
--card: 222.2 84% 4.9%;
|
|
229
|
+
--card-foreground: 210 40% 98%;
|
|
230
|
+
--popover: 222.2 84% 4.9%;
|
|
231
|
+
--popover-foreground: 210 40% 98%;
|
|
232
|
+
--primary: 210 40% 98%;
|
|
233
|
+
--primary-foreground: 222.2 47.4% 11.2%;
|
|
234
|
+
--secondary: 217.2 32.6% 17.5%;
|
|
235
|
+
--secondary-foreground: 210 40% 98%;
|
|
236
|
+
--muted: 217.2 32.6% 17.5%;
|
|
237
|
+
--muted-foreground: 215 20.2% 65.1%;
|
|
238
|
+
--accent: 217.2 32.6% 17.5%;
|
|
239
|
+
--accent-foreground: 210 40% 98%;
|
|
240
|
+
--destructive: 0 62.8% 30.6%;
|
|
241
|
+
--destructive-foreground: 210 40% 98%;
|
|
242
|
+
--border: 217.2 32.6% 17.5%;
|
|
243
|
+
--input: 217.2 32.6% 17.5%;
|
|
244
|
+
--ring: 212.7 26.8% 83.9%;
|
|
230
245
|
}
|
|
231
246
|
|
|
232
247
|
@layer base {
|
|
@@ -235,20 +250,53 @@ module.exports = {
|
|
|
235
250
|
}
|
|
236
251
|
body {
|
|
237
252
|
@apply bg-background text-foreground;
|
|
253
|
+
font-feature-settings: "rlig" 1, "calt" 1;
|
|
238
254
|
}
|
|
239
|
-
}
|
|
255
|
+
}
|
|
256
|
+
`;
|
|
240
257
|
|
|
241
|
-
//
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
258
|
+
// Preserve existing styles after the theme
|
|
259
|
+
if (existingContent && !hasTailwindImport) {
|
|
260
|
+
// If file existed but didn't have tailwind import, keep existing content
|
|
261
|
+
const existingWithoutTailwind = existingContent;
|
|
262
|
+
if (existingWithoutTailwind.trim()) {
|
|
263
|
+
newContent += '\n\n' + existingWithoutTailwind;
|
|
264
|
+
}
|
|
265
|
+
} else if (existingContent && hasTailwindImport) {
|
|
266
|
+
// If file had tailwind import, remove the old theme and keep other styles
|
|
267
|
+
const lines = existingContent.split('\n');
|
|
268
|
+
const afterThemeLines = [];
|
|
269
|
+
let inThemeBlock = false;
|
|
270
|
+
let foundTheme = false;
|
|
271
|
+
|
|
272
|
+
for (const line of lines) {
|
|
273
|
+
if (line.includes('@theme {') || line.includes(':root {') || line.includes('.dark {') || line.includes('@layer base {')) {
|
|
274
|
+
inThemeBlock = true;
|
|
275
|
+
foundTheme = true;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (inThemeBlock && line.includes('}') && !line.includes('@layer')) {
|
|
279
|
+
inThemeBlock = false;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (inThemeBlock && line.includes('@layer base {')) {
|
|
283
|
+
// Skip the old @layer base content
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
if (inThemeBlock) {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (foundTheme && line.trim()) {
|
|
290
|
+
afterThemeLines.push(line);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (afterThemeLines.length > 0) {
|
|
295
|
+
newContent += '\n\n' + afterThemeLines.join('\n');
|
|
249
296
|
}
|
|
250
|
-
} else {
|
|
251
|
-
await fs.writeFile(stylesPath, globalStyles);
|
|
252
|
-
console.log(`✅ Created ${stylesPath} with Tailwind 4 theme`);
|
|
253
297
|
}
|
|
298
|
+
|
|
299
|
+
// Write the updated content
|
|
300
|
+
await fs.writeFile(stylesPath, newContent);
|
|
301
|
+
console.log(`✅ Updated ${stylesPath} with Tailwind 4 theme`);
|
|
254
302
|
}
|