@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.
@@ -286,34 +286,44 @@ async function setupTailwind() {
286
286
  }
287
287
  }
288
288
  else if (existingContent && hasTailwindImport) {
289
- // If file had tailwind import, remove the old theme and keep other styles
289
+ // If file had tailwind import, preserve everything and just add/update the theme
290
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;
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 (inThemeBlock && line.includes('}') && !line.includes('@layer')) {
301
- inThemeBlock = false;
305
+ if (inThemeSection && trimmedLine === '}' &&
306
+ !lines[i + 1]?.trim().startsWith('@layer')) {
307
+ inThemeSection = false;
302
308
  continue;
303
309
  }
304
- if (inThemeBlock && line.includes('@layer base {')) {
305
- // Skip the old @layer base content
310
+ if (trimmedLine.startsWith('@layer base {')) {
311
+ inThemeSection = true;
306
312
  continue;
307
313
  }
308
- if (inThemeBlock) {
314
+ if (inThemeSection && trimmedLine === '}' &&
315
+ lines[i - 1]?.trim().startsWith('@layer base')) {
316
+ inThemeSection = false;
309
317
  continue;
310
318
  }
311
- if (foundTheme && line.trim()) {
312
- afterThemeLines.push(line);
319
+ if (inThemeSection) {
320
+ continue;
313
321
  }
322
+ // Preserve this line
323
+ preservedLines.push(line);
314
324
  }
315
- if (afterThemeLines.length > 0) {
316
- newContent += '\n\n' + afterThemeLines.join('\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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-shangjc/cli",
3
- "version": "1.0.5-beta",
3
+ "version": "1.0.6-beta",
4
4
  "bin": {
5
5
  "ng-shangjc": "./dist/index.js"
6
6
  },
@@ -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, remove the old theme and keep other styles
266
+ // If file had tailwind import, preserve everything and just add/update the theme
267
267
  const lines = existingContent.split('\n');
268
- const afterThemeLines = [];
269
- let inThemeBlock = false;
270
- let foundTheme = false;
268
+ const preservedLines = [];
269
+ let skipNextClosingBrace = false;
270
+ let inThemeSection = false;
271
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;
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
- if (inThemeBlock && line.includes('}') && !line.includes('@layer')) {
279
- inThemeBlock = false;
284
+
285
+ if (inThemeSection && trimmedLine === '}' &&
286
+ !lines[i + 1]?.trim().startsWith('@layer')) {
287
+ inThemeSection = false;
280
288
  continue;
281
289
  }
282
- if (inThemeBlock && line.includes('@layer base {')) {
283
- // Skip the old @layer base content
290
+
291
+ if (trimmedLine.startsWith('@layer base {')) {
292
+ inThemeSection = true;
284
293
  continue;
285
294
  }
286
- if (inThemeBlock) {
295
+
296
+ if (inThemeSection && trimmedLine === '}' &&
297
+ lines[i - 1]?.trim().startsWith('@layer base')) {
298
+ inThemeSection = false;
287
299
  continue;
288
300
  }
289
- if (foundTheme && line.trim()) {
290
- afterThemeLines.push(line);
301
+
302
+ if (inThemeSection) {
303
+ continue;
291
304
  }
305
+
306
+ // Preserve this line
307
+ preservedLines.push(line);
292
308
  }
293
309
 
294
- if (afterThemeLines.length > 0) {
295
- newContent += '\n\n' + afterThemeLines.join('\n');
310
+ if (preservedLines.length > 0) {
311
+ newContent += '\n\n' + preservedLines.join('\n');
296
312
  }
297
313
  }
298
314