@ng-shangjc/cli 1.0.6-beta → 1.0.7-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.
@@ -170,13 +170,13 @@ async function setupTailwind() {
170
170
  if (fs.existsSync(stylesPath)) {
171
171
  existingContent = await fs.readFile(stylesPath, 'utf8');
172
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
- }
173
+ // Remove existing Tailwind import and clean up extra blank lines
174
+ const cleanedContent = existingContent
175
+ .replace(/@import\s+['"]tailwindcss['"];?\s*\n?/gi, '')
176
+ .replace(/\n\s*\n\s*\n/g, '\n\n')
177
+ .trim();
178
+ // Always start with Tailwind import
179
+ let newContent = "@import 'tailwindcss';\n";
180
180
  // Add dark mode custom variant if user wants dark mode
181
181
  const config = await fs.readJson('shangjc.config.json');
182
182
  if (config.theme === 'dark' || config.theme === 'both') {
@@ -278,18 +278,10 @@ async function setupTailwind() {
278
278
  }
279
279
  `;
280
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;
286
- }
287
- }
288
- else if (existingContent && hasTailwindImport) {
289
- // If file had tailwind import, preserve everything and just add/update the theme
290
- const lines = existingContent.split('\n');
281
+ if (cleanedContent) {
282
+ // Remove any existing theme blocks from the preserved content
283
+ const lines = cleanedContent.split('\n');
291
284
  const preservedLines = [];
292
- let skipNextClosingBrace = false;
293
285
  let inThemeSection = false;
294
286
  for (let i = 0; i < lines.length; i++) {
295
287
  const line = lines[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-shangjc/cli",
3
- "version": "1.0.6-beta",
3
+ "version": "1.0.7-beta",
4
4
  "bin": {
5
5
  "ng-shangjc": "./dist/index.js"
6
6
  },
@@ -143,15 +143,14 @@ async function setupTailwind() {
143
143
  existingContent = await fs.readFile(stylesPath, 'utf8');
144
144
  }
145
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
- }
146
+ // Remove existing Tailwind import and clean up extra blank lines
147
+ const cleanedContent = existingContent
148
+ .replace(/@import\s+['"]tailwindcss['"];?\s*\n?/gi, '')
149
+ .replace(/\n\s*\n\s*\n/g, '\n\n')
150
+ .trim();
151
+
152
+ // Always start with Tailwind import
153
+ let newContent = "@import 'tailwindcss';\n";
155
154
 
156
155
  // Add dark mode custom variant if user wants dark mode
157
156
  const config = await fs.readJson('shangjc.config.json');
@@ -256,17 +255,10 @@ async function setupTailwind() {
256
255
  `;
257
256
 
258
257
  // 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, preserve everything and just add/update the theme
267
- const lines = existingContent.split('\n');
258
+ if (cleanedContent) {
259
+ // Remove any existing theme blocks from the preserved content
260
+ const lines = cleanedContent.split('\n');
268
261
  const preservedLines = [];
269
- let skipNextClosingBrace = false;
270
262
  let inThemeSection = false;
271
263
 
272
264
  for (let i = 0; i < lines.length; i++) {