analyze-codebase 1.3.1 → 1.3.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.
@@ -10,7 +10,8 @@
10
10
  "Bash(git add:*)",
11
11
  "Bash(git commit:*)",
12
12
  "Bash(git push:*)",
13
- "Bash(npm publish:*)"
13
+ "Bash(npm publish:*)",
14
+ "Bash(npx ts-node:*)"
14
15
  ]
15
16
  }
16
17
  }
package/dist/index.js CHANGED
@@ -77,7 +77,7 @@ exports.mergeOptions = mergeOptions;
77
77
  commander_1.program
78
78
  .name("analyze-codebase")
79
79
  .description("šŸ“Š A powerful CLI tool for analyzing codebase structure, naming conventions, and code quality")
80
- .version("1.3.1")
80
+ .version("1.3.2")
81
81
  .arguments("[directory]")
82
82
  .option("-f, --framework <framework>", "Specify the framework")
83
83
  .option("-e, --extensions <extensions...>", "Specify the extensions", (value, previous) => previous.concat(value), [])
@@ -152,6 +152,40 @@ commander_1.program
152
152
  process.exit(1);
153
153
  }
154
154
  });
155
+ // Dedicated i18n command - clearly visible in --help
156
+ commander_1.program
157
+ .command("i18n [directory]")
158
+ .description("šŸ” Find and remove unused i18n translation keys\n" +
159
+ " Example: analyze-codebase i18n ./src --file locales/en.json")
160
+ .option("--file <path>", "Path to i18n JSON file (e.g., locales/en.json, messages/tr.json)")
161
+ .option("-e, --extensions <ext...>", "File extensions to scan (default: ts tsx js jsx vue)", (value, previous) => previous.concat(value), [])
162
+ .option("-exc, --exclude <dirs...>", "Additional directories to exclude", (value, previous) => previous.concat(value), [])
163
+ .option("--max-concurrency <number>", "Max concurrent file processing (default: auto)", parseInt)
164
+ .action(async (directory = ".", options) => {
165
+ var _a, _b;
166
+ if (!options.file) {
167
+ console.error(chalk_1.default.red("\nāŒ Missing required option: --file <path>\n\n" +
168
+ chalk_1.default.yellow("Usage:\n") +
169
+ ` analyze-codebase i18n ${directory} --file locales/en.json\n\n` +
170
+ chalk_1.default.gray("Example:\n") +
171
+ ` analyze-codebase i18n ./src --file public/locales/en.json\n` +
172
+ ` analyze-codebase i18n . --file messages/en.json --extensions ts tsx vue\n`));
173
+ process.exit(1);
174
+ }
175
+ try {
176
+ await (0, i18n_1.analyzeAndRemoveUnusedKeys)({
177
+ directory,
178
+ i18nFile: options.file,
179
+ extensions: ((_a = options.extensions) === null || _a === void 0 ? void 0 : _a.length) ? options.extensions : undefined,
180
+ exclude: ((_b = options.exclude) === null || _b === void 0 ? void 0 : _b.length) ? options.exclude : undefined,
181
+ maxConcurrency: options.maxConcurrency,
182
+ });
183
+ }
184
+ catch (error) {
185
+ console.error(chalk_1.default.red(`\nError during i18n analysis: ${error}\n`));
186
+ process.exit(1);
187
+ }
188
+ });
155
189
  // Add init command for creating config file
156
190
  commander_1.program
157
191
  .command("init")
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/mtahagocer/analyze-codebase"
12
12
  },
13
- "version": "1.3.1",
13
+ "version": "1.3.2",
14
14
  "main": "dist/index.js",
15
15
  "license": "MIT",
16
16
  "bin": {
package/readme.md CHANGED
@@ -41,6 +41,24 @@ npm install -g analyze-codebase
41
41
  npx analyze-codebase .
42
42
  ```
43
43
 
44
+ ### Find unused i18n translation keys
45
+
46
+ ```bash
47
+ # With npx (no install needed)
48
+ npx analyze-codebase i18n ./src --file locales/en.json
49
+
50
+ # If installed globally
51
+ analyze-codebase i18n ./src --file locales/en.json
52
+
53
+ # Vue project example
54
+ analyze-codebase i18n ./src --file public/locales/en.json --extensions ts tsx vue
55
+
56
+ # With exclusions
57
+ analyze-codebase i18n . --file messages/en.json --exclude dist public
58
+ ```
59
+
60
+ The tool will show all unused keys, then ask **y/n** before removing them. Safe to run — nothing is deleted without confirmation.
61
+
44
62
  ### Setup a config file (optional)
45
63
 
46
64
  ```bash