@storytype/cli 0.2.3 → 0.2.4

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 (2) hide show
  1. package/dist/cli.js +43 -19
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -6,9 +6,10 @@ import {
6
6
 
7
7
  // src/cli.ts
8
8
  import { Command } from "commander";
9
+ import path3 from "path";
9
10
 
10
11
  // package.json
11
- var version = "0.2.3";
12
+ var version = "0.2.4";
12
13
 
13
14
  // src/generate/Generate.ts
14
15
  import fs from "fs-extra";
@@ -204,7 +205,7 @@ async function analyzeDirectory(dirPath, components, options) {
204
205
  const componentName = getComponentBaseName(componentFile.name);
205
206
  const pascalComponentName = toPascalCase2(componentName);
206
207
  const dirName = path2.basename(dirPath);
207
- const expectedDirName = toKebabCase2(componentName);
208
+ const expectedDirName = toKebabCase2(dirName);
208
209
  const needsRename = dirName !== expectedDirName;
209
210
  const files = [];
210
211
  const existingFileNames = /* @__PURE__ */ new Set();
@@ -438,33 +439,56 @@ Componentes encontrados: ${result.components.length}`));
438
439
  console.log(chalk.gray(`Diret\xF3rios a renomear: ${result.directoriesToRename}`));
439
440
  console.log(chalk.gray(`Arquivos a renomear: ${result.filesToRename}`));
440
441
  console.log(chalk.gray(`Arquivos a criar: ${result.filesToCreate}`));
441
- if (options?.dryRun) {
442
- console.log(chalk.yellow("\n\u26A0 Modo dry-run: nenhuma mudan\xE7a foi feita"));
443
- console.log(chalk.gray("Execute sem --dry-run para aplicar as mudan\xE7as"));
444
- } else if (result.directoriesToRename + result.filesToRename + result.filesToCreate > 0) {
445
- console.log(chalk.green("\n\u2713 Normaliza\xE7\xE3o conclu\xEDda com sucesso!"));
446
- } else {
447
- console.log(
448
- chalk.green("\n\u2713 Todos os componentes j\xE1 est\xE3o estruturados corretamente!")
449
- );
450
- }
451
- if (options?.verbose) {
452
- console.log(chalk.gray("\nMudan\xE7as detalhadas:"));
442
+ if ((options?.dryRun || options?.verbose) && result.directoriesToRename + result.filesToRename + result.filesToCreate > 0) {
443
+ console.log(chalk.cyan("\n\u{1F4CB} Mudan\xE7as detalhadas:\n"));
444
+ const cwd = process.cwd();
445
+ const relativePath = (absolutePath) => {
446
+ const rel = path3.relative(cwd, absolutePath);
447
+ return rel.startsWith("..") ? absolutePath : rel;
448
+ };
453
449
  result.components.forEach((comp) => {
454
- if (comp.needsRename || comp.missingFiles.length > 0) {
455
- console.log(chalk.gray(`
456
- ${comp.componentName}:`));
450
+ const hasChanges = comp.needsRename || comp.missingFiles.length > 0 || comp.files.some((f) => f.currentPath !== f.targetPath);
451
+ if (hasChanges) {
452
+ console.log(chalk.bold(`
453
+ Componente: ${comp.componentName}`));
457
454
  if (comp.needsRename) {
455
+ console.log(chalk.yellow(` \u{1F4C1} Renomear diret\xF3rio:`));
456
+ console.log(chalk.gray(` ${relativePath(comp.currentPath)}`));
457
+ console.log(chalk.gray(` \u2192 ${relativePath(comp.targetPath)}`));
458
+ }
459
+ const filesToRename = comp.files.filter((f) => f.currentPath !== f.targetPath);
460
+ if (filesToRename.length > 0) {
458
461
  console.log(
459
- chalk.yellow(` Renomear: ${comp.currentPath} \u2192 ${comp.targetPath}`)
462
+ chalk.yellow(` \u{1F4C4} Renomear arquivo${filesToRename.length > 1 ? "s" : ""}:`)
460
463
  );
464
+ filesToRename.forEach((file) => {
465
+ console.log(chalk.gray(` ${relativePath(file.currentPath)}`));
466
+ console.log(chalk.gray(` \u2192 ${relativePath(file.targetPath)}`));
467
+ });
461
468
  }
462
469
  if (comp.missingFiles.length > 0) {
463
- console.log(chalk.yellow(` Criar: ${comp.missingFiles.join(", ")}`));
470
+ console.log(
471
+ chalk.green(` \u2728 Criar arquivo${comp.missingFiles.length > 1 ? "s" : ""}:`)
472
+ );
473
+ comp.missingFiles.forEach((fileName) => {
474
+ const targetDir = comp.needsRename ? comp.targetPath : comp.currentPath;
475
+ const fullPath = `${targetDir}/${fileName}`;
476
+ console.log(chalk.gray(` ${relativePath(fullPath)}`));
477
+ });
464
478
  }
465
479
  }
466
480
  });
467
481
  }
482
+ if (options?.dryRun) {
483
+ console.log(chalk.yellow("\n\u26A0\uFE0F Modo dry-run: nenhuma mudan\xE7a foi feita"));
484
+ console.log(chalk.gray("Execute sem --dry-run para aplicar as mudan\xE7as\n"));
485
+ } else if (result.directoriesToRename + result.filesToRename + result.filesToCreate > 0) {
486
+ console.log(chalk.green("\n\u2713 Normaliza\xE7\xE3o conclu\xEDda com sucesso!"));
487
+ } else {
488
+ console.log(
489
+ chalk.green("\n\u2713 Todos os componentes j\xE1 est\xE3o estruturados corretamente!")
490
+ );
491
+ }
468
492
  } else {
469
493
  console.error(chalk.red(`
470
494
  \u2717 Erro: ${result.error}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storytype/cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "CLI tool for scaffolding Storytype components and analyzing project structure",
5
5
  "keywords": [
6
6
  "cli",