@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.
- package/dist/commands/init.js +10 -18
- package/package.json +1 -1
- package/src/commands/init.ts +11 -19
package/dist/commands/init.js
CHANGED
|
@@ -170,13 +170,13 @@ async function setupTailwind() {
|
|
|
170
170
|
if (fs.existsSync(stylesPath)) {
|
|
171
171
|
existingContent = await fs.readFile(stylesPath, 'utf8');
|
|
172
172
|
}
|
|
173
|
-
//
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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 (
|
|
282
|
-
//
|
|
283
|
-
const
|
|
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
package/src/commands/init.ts
CHANGED
|
@@ -143,15 +143,14 @@ async function setupTailwind() {
|
|
|
143
143
|
existingContent = await fs.readFile(stylesPath, 'utf8');
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
//
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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 (
|
|
260
|
-
//
|
|
261
|
-
const
|
|
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++) {
|