xertica-ui 1.2.1 → 1.2.2

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.
Files changed (3) hide show
  1. package/bin/cli.ts +56 -0
  2. package/dist/cli.js +41 -0
  3. package/package.json +1 -1
package/bin/cli.ts CHANGED
@@ -287,6 +287,62 @@ program
287
287
  componentsToUpdate = response.selected;
288
288
  }
289
289
 
290
+
291
+
292
+ // --- Theme Update Logic ---
293
+ // Ask if user wants to update theme
294
+ const themeResponse = await prompts({
295
+ type: 'confirm',
296
+ name: 'updateTheme',
297
+ message: 'Do you want to update/change the project theme?',
298
+ initial: false
299
+ });
300
+
301
+ if (themeResponse.updateTheme) {
302
+ const themeSelection = await prompts({
303
+ type: 'select',
304
+ name: 'theme',
305
+ message: 'Select the new color theme:',
306
+ choices: colorThemes.map(t => ({
307
+ title: t.name,
308
+ description: t.description,
309
+ value: t.id
310
+ })),
311
+ initial: 0
312
+ });
313
+
314
+ if (themeSelection.theme) {
315
+ const spinnerTheme = ora('Updating theme...').start();
316
+ // 1. Update React Context
317
+ const contextPath = path.join(targetDir, 'contexts', 'BrandColorsContext.tsx');
318
+ if (await fs.pathExists(contextPath)) {
319
+ let content = await fs.readFile(contextPath, 'utf8');
320
+ // Replace existing default. We can try to find any string like "return saved || '...';"
321
+ // The regex needs to be robust to catch whatever is there currently.
322
+ // It might be 'xertica-original' or previously set 'rose', etc.
323
+ // Regex: /return saved \|\| '([a-zA-Z0-9-]+)';/
324
+ content = content.replace(
325
+ /return saved \|\| '([a-zA-Z0-9-]+)';/,
326
+ `return saved || '${themeSelection.theme}';`
327
+ );
328
+ await fs.writeFile(contextPath, content);
329
+ } else {
330
+ spinnerTheme.warn('BrandColorsContext.tsx not found. Skipping context update.');
331
+ }
332
+
333
+ // 2. Update styles/xertica/tokens.css
334
+ const tokensPath = path.join(targetDir, 'styles', 'xertica', 'tokens.css');
335
+ const selectedTheme = colorThemes.find(t => t.id === themeSelection.theme);
336
+
337
+ if (selectedTheme) {
338
+ await fs.ensureDir(path.dirname(tokensPath));
339
+ const newTokensCss = generateTokensCss(selectedTheme);
340
+ await fs.writeFile(tokensPath, newTokensCss);
341
+ }
342
+ spinnerTheme.succeed('Theme updated successfully!');
343
+ }
344
+ }
345
+
290
346
  const spinner = ora('Updating components...').start();
291
347
 
292
348
  try {
package/dist/cli.js CHANGED
@@ -713,6 +713,47 @@ program.command("update").description("Update components in your project").argum
713
713
  if (!response.selected) return;
714
714
  componentsToUpdate = response.selected;
715
715
  }
716
+ const themeResponse = await prompts({
717
+ type: "confirm",
718
+ name: "updateTheme",
719
+ message: "Do you want to update/change the project theme?",
720
+ initial: false
721
+ });
722
+ if (themeResponse.updateTheme) {
723
+ const themeSelection = await prompts({
724
+ type: "select",
725
+ name: "theme",
726
+ message: "Select the new color theme:",
727
+ choices: colorThemes.map((t) => ({
728
+ title: t.name,
729
+ description: t.description,
730
+ value: t.id
731
+ })),
732
+ initial: 0
733
+ });
734
+ if (themeSelection.theme) {
735
+ const spinnerTheme = ora("Updating theme...").start();
736
+ const contextPath = path.join(targetDir, "contexts", "BrandColorsContext.tsx");
737
+ if (await fs.pathExists(contextPath)) {
738
+ let content = await fs.readFile(contextPath, "utf8");
739
+ content = content.replace(
740
+ /return saved \|\| '([a-zA-Z0-9-]+)';/,
741
+ `return saved || '${themeSelection.theme}';`
742
+ );
743
+ await fs.writeFile(contextPath, content);
744
+ } else {
745
+ spinnerTheme.warn("BrandColorsContext.tsx not found. Skipping context update.");
746
+ }
747
+ const tokensPath = path.join(targetDir, "styles", "xertica", "tokens.css");
748
+ const selectedTheme = colorThemes.find((t) => t.id === themeSelection.theme);
749
+ if (selectedTheme) {
750
+ await fs.ensureDir(path.dirname(tokensPath));
751
+ const newTokensCss = generateTokensCss(selectedTheme);
752
+ await fs.writeFile(tokensPath, newTokensCss);
753
+ }
754
+ spinnerTheme.succeed("Theme updated successfully!");
755
+ }
756
+ }
716
757
  const spinner = ora("Updating components...").start();
717
758
  try {
718
759
  let updatedCount = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xertica-ui",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Xertica UI - Design System completo com componentes React e Tailwind CSS",
5
5
  "type": "module",
6
6
  "bin": "./dist/cli.js",