@ng-shangjc/cli 1.0.5-beta → 1.0.6-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 +27 -17
- package/package.json +1 -1
- package/src/commands/init.ts +33 -17
package/dist/commands/init.js
CHANGED
|
@@ -286,34 +286,44 @@ async function setupTailwind() {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
else if (existingContent && hasTailwindImport) {
|
|
289
|
-
// If file had tailwind import,
|
|
289
|
+
// If file had tailwind import, preserve everything and just add/update the theme
|
|
290
290
|
const lines = existingContent.split('\n');
|
|
291
|
-
const
|
|
292
|
-
let
|
|
293
|
-
let
|
|
294
|
-
for (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
291
|
+
const preservedLines = [];
|
|
292
|
+
let skipNextClosingBrace = false;
|
|
293
|
+
let inThemeSection = false;
|
|
294
|
+
for (let i = 0; i < lines.length; i++) {
|
|
295
|
+
const line = lines[i];
|
|
296
|
+
const trimmedLine = line.trim();
|
|
297
|
+
// Skip theme-related blocks but preserve everything else
|
|
298
|
+
if (trimmedLine.startsWith('@theme {') ||
|
|
299
|
+
trimmedLine.startsWith(':root {') ||
|
|
300
|
+
trimmedLine.startsWith('.dark {') ||
|
|
301
|
+
trimmedLine.startsWith('@custom-variant dark')) {
|
|
302
|
+
inThemeSection = true;
|
|
298
303
|
continue;
|
|
299
304
|
}
|
|
300
|
-
if (
|
|
301
|
-
|
|
305
|
+
if (inThemeSection && trimmedLine === '}' &&
|
|
306
|
+
!lines[i + 1]?.trim().startsWith('@layer')) {
|
|
307
|
+
inThemeSection = false;
|
|
302
308
|
continue;
|
|
303
309
|
}
|
|
304
|
-
if (
|
|
305
|
-
|
|
310
|
+
if (trimmedLine.startsWith('@layer base {')) {
|
|
311
|
+
inThemeSection = true;
|
|
306
312
|
continue;
|
|
307
313
|
}
|
|
308
|
-
if (
|
|
314
|
+
if (inThemeSection && trimmedLine === '}' &&
|
|
315
|
+
lines[i - 1]?.trim().startsWith('@layer base')) {
|
|
316
|
+
inThemeSection = false;
|
|
309
317
|
continue;
|
|
310
318
|
}
|
|
311
|
-
if (
|
|
312
|
-
|
|
319
|
+
if (inThemeSection) {
|
|
320
|
+
continue;
|
|
313
321
|
}
|
|
322
|
+
// Preserve this line
|
|
323
|
+
preservedLines.push(line);
|
|
314
324
|
}
|
|
315
|
-
if (
|
|
316
|
-
newContent += '\n\n' +
|
|
325
|
+
if (preservedLines.length > 0) {
|
|
326
|
+
newContent += '\n\n' + preservedLines.join('\n');
|
|
317
327
|
}
|
|
318
328
|
}
|
|
319
329
|
// Write the updated content
|
package/package.json
CHANGED
package/src/commands/init.ts
CHANGED
|
@@ -263,36 +263,52 @@ async function setupTailwind() {
|
|
|
263
263
|
newContent += '\n\n' + existingWithoutTailwind;
|
|
264
264
|
}
|
|
265
265
|
} else if (existingContent && hasTailwindImport) {
|
|
266
|
-
// If file had tailwind import,
|
|
266
|
+
// If file had tailwind import, preserve everything and just add/update the theme
|
|
267
267
|
const lines = existingContent.split('\n');
|
|
268
|
-
const
|
|
269
|
-
let
|
|
270
|
-
let
|
|
268
|
+
const preservedLines = [];
|
|
269
|
+
let skipNextClosingBrace = false;
|
|
270
|
+
let inThemeSection = false;
|
|
271
271
|
|
|
272
|
-
for (
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
272
|
+
for (let i = 0; i < lines.length; i++) {
|
|
273
|
+
const line = lines[i];
|
|
274
|
+
const trimmedLine = line.trim();
|
|
275
|
+
|
|
276
|
+
// Skip theme-related blocks but preserve everything else
|
|
277
|
+
if (trimmedLine.startsWith('@theme {') ||
|
|
278
|
+
trimmedLine.startsWith(':root {') ||
|
|
279
|
+
trimmedLine.startsWith('.dark {') ||
|
|
280
|
+
trimmedLine.startsWith('@custom-variant dark')) {
|
|
281
|
+
inThemeSection = true;
|
|
276
282
|
continue;
|
|
277
283
|
}
|
|
278
|
-
|
|
279
|
-
|
|
284
|
+
|
|
285
|
+
if (inThemeSection && trimmedLine === '}' &&
|
|
286
|
+
!lines[i + 1]?.trim().startsWith('@layer')) {
|
|
287
|
+
inThemeSection = false;
|
|
280
288
|
continue;
|
|
281
289
|
}
|
|
282
|
-
|
|
283
|
-
|
|
290
|
+
|
|
291
|
+
if (trimmedLine.startsWith('@layer base {')) {
|
|
292
|
+
inThemeSection = true;
|
|
284
293
|
continue;
|
|
285
294
|
}
|
|
286
|
-
|
|
295
|
+
|
|
296
|
+
if (inThemeSection && trimmedLine === '}' &&
|
|
297
|
+
lines[i - 1]?.trim().startsWith('@layer base')) {
|
|
298
|
+
inThemeSection = false;
|
|
287
299
|
continue;
|
|
288
300
|
}
|
|
289
|
-
|
|
290
|
-
|
|
301
|
+
|
|
302
|
+
if (inThemeSection) {
|
|
303
|
+
continue;
|
|
291
304
|
}
|
|
305
|
+
|
|
306
|
+
// Preserve this line
|
|
307
|
+
preservedLines.push(line);
|
|
292
308
|
}
|
|
293
309
|
|
|
294
|
-
if (
|
|
295
|
-
newContent += '\n\n' +
|
|
310
|
+
if (preservedLines.length > 0) {
|
|
311
|
+
newContent += '\n\n' + preservedLines.join('\n');
|
|
296
312
|
}
|
|
297
313
|
}
|
|
298
314
|
|