@ng-shangjc/cli 1.0.5-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 +35 -33
- package/package.json +1 -1
- package/src/commands/init.ts +42 -34
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,42 +278,44 @@ async function setupTailwind() {
|
|
|
278
278
|
}
|
|
279
279
|
`;
|
|
280
280
|
// Preserve existing styles after the theme
|
|
281
|
-
if (
|
|
282
|
-
//
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (line.includes('@theme {') || line.includes(':root {') || line.includes('.dark {') || line.includes('@layer base {')) {
|
|
296
|
-
inThemeBlock = true;
|
|
297
|
-
foundTheme = true;
|
|
281
|
+
if (cleanedContent) {
|
|
282
|
+
// Remove any existing theme blocks from the preserved content
|
|
283
|
+
const lines = cleanedContent.split('\n');
|
|
284
|
+
const preservedLines = [];
|
|
285
|
+
let inThemeSection = false;
|
|
286
|
+
for (let i = 0; i < lines.length; i++) {
|
|
287
|
+
const line = lines[i];
|
|
288
|
+
const trimmedLine = line.trim();
|
|
289
|
+
// Skip theme-related blocks but preserve everything else
|
|
290
|
+
if (trimmedLine.startsWith('@theme {') ||
|
|
291
|
+
trimmedLine.startsWith(':root {') ||
|
|
292
|
+
trimmedLine.startsWith('.dark {') ||
|
|
293
|
+
trimmedLine.startsWith('@custom-variant dark')) {
|
|
294
|
+
inThemeSection = true;
|
|
298
295
|
continue;
|
|
299
296
|
}
|
|
300
|
-
if (
|
|
301
|
-
|
|
297
|
+
if (inThemeSection && trimmedLine === '}' &&
|
|
298
|
+
!lines[i + 1]?.trim().startsWith('@layer')) {
|
|
299
|
+
inThemeSection = false;
|
|
302
300
|
continue;
|
|
303
301
|
}
|
|
304
|
-
if (
|
|
305
|
-
|
|
302
|
+
if (trimmedLine.startsWith('@layer base {')) {
|
|
303
|
+
inThemeSection = true;
|
|
306
304
|
continue;
|
|
307
305
|
}
|
|
308
|
-
if (
|
|
306
|
+
if (inThemeSection && trimmedLine === '}' &&
|
|
307
|
+
lines[i - 1]?.trim().startsWith('@layer base')) {
|
|
308
|
+
inThemeSection = false;
|
|
309
309
|
continue;
|
|
310
310
|
}
|
|
311
|
-
if (
|
|
312
|
-
|
|
311
|
+
if (inThemeSection) {
|
|
312
|
+
continue;
|
|
313
313
|
}
|
|
314
|
+
// Preserve this line
|
|
315
|
+
preservedLines.push(line);
|
|
314
316
|
}
|
|
315
|
-
if (
|
|
316
|
-
newContent += '\n\n' +
|
|
317
|
+
if (preservedLines.length > 0) {
|
|
318
|
+
newContent += '\n\n' + preservedLines.join('\n');
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
321
|
// Write the updated content
|
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,43 +255,52 @@ async function setupTailwind() {
|
|
|
256
255
|
`;
|
|
257
256
|
|
|
258
257
|
// Preserve existing styles after the theme
|
|
259
|
-
if (
|
|
260
|
-
//
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
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;
|
|
258
|
+
if (cleanedContent) {
|
|
259
|
+
// Remove any existing theme blocks from the preserved content
|
|
260
|
+
const lines = cleanedContent.split('\n');
|
|
261
|
+
const preservedLines = [];
|
|
262
|
+
let inThemeSection = false;
|
|
271
263
|
|
|
272
|
-
for (
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
264
|
+
for (let i = 0; i < lines.length; i++) {
|
|
265
|
+
const line = lines[i];
|
|
266
|
+
const trimmedLine = line.trim();
|
|
267
|
+
|
|
268
|
+
// Skip theme-related blocks but preserve everything else
|
|
269
|
+
if (trimmedLine.startsWith('@theme {') ||
|
|
270
|
+
trimmedLine.startsWith(':root {') ||
|
|
271
|
+
trimmedLine.startsWith('.dark {') ||
|
|
272
|
+
trimmedLine.startsWith('@custom-variant dark')) {
|
|
273
|
+
inThemeSection = true;
|
|
276
274
|
continue;
|
|
277
275
|
}
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
|
|
277
|
+
if (inThemeSection && trimmedLine === '}' &&
|
|
278
|
+
!lines[i + 1]?.trim().startsWith('@layer')) {
|
|
279
|
+
inThemeSection = false;
|
|
280
280
|
continue;
|
|
281
281
|
}
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
|
|
283
|
+
if (trimmedLine.startsWith('@layer base {')) {
|
|
284
|
+
inThemeSection = true;
|
|
284
285
|
continue;
|
|
285
286
|
}
|
|
286
|
-
|
|
287
|
+
|
|
288
|
+
if (inThemeSection && trimmedLine === '}' &&
|
|
289
|
+
lines[i - 1]?.trim().startsWith('@layer base')) {
|
|
290
|
+
inThemeSection = false;
|
|
287
291
|
continue;
|
|
288
292
|
}
|
|
289
|
-
|
|
290
|
-
|
|
293
|
+
|
|
294
|
+
if (inThemeSection) {
|
|
295
|
+
continue;
|
|
291
296
|
}
|
|
297
|
+
|
|
298
|
+
// Preserve this line
|
|
299
|
+
preservedLines.push(line);
|
|
292
300
|
}
|
|
293
301
|
|
|
294
|
-
if (
|
|
295
|
-
newContent += '\n\n' +
|
|
302
|
+
if (preservedLines.length > 0) {
|
|
303
|
+
newContent += '\n\n' + preservedLines.join('\n');
|
|
296
304
|
}
|
|
297
305
|
}
|
|
298
306
|
|