pruny 1.2.10 → 1.2.11

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/index.js +26 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7632,7 +7632,7 @@ var source_default = chalk;
7632
7632
 
7633
7633
  // src/index.ts
7634
7634
  import { rmSync } from "node:fs";
7635
- import { dirname as dirname2, join as join7 } from "node:path";
7635
+ import { dirname as dirname2, join as join8 } from "node:path";
7636
7636
 
7637
7637
  // src/scanner.ts
7638
7638
  var import_fast_glob4 = __toESM(require_out4(), 1);
@@ -9667,15 +9667,37 @@ function removeExportFromLine(rootDir, exp) {
9667
9667
  }
9668
9668
  }
9669
9669
 
9670
+ // src/init.ts
9671
+ import { writeFileSync as writeFileSync2, existsSync as existsSync5 } from "node:fs";
9672
+ import { join as join7 } from "node:path";
9673
+ function init(cwd = process.cwd()) {
9674
+ const configPath = join7(cwd, "pruny.config.json");
9675
+ if (existsSync5(configPath)) {
9676
+ console.log(source_default.yellow("⚠️ pruny.config.json already exists. Skipping."));
9677
+ return;
9678
+ }
9679
+ try {
9680
+ const configContent = JSON.stringify(DEFAULT_CONFIG, null, 2);
9681
+ writeFileSync2(configPath, configContent, "utf-8");
9682
+ console.log(source_default.green("✅ Created pruny.config.json"));
9683
+ } catch (err) {
9684
+ console.error(source_default.red("Error creating config file:"), err);
9685
+ }
9686
+ }
9687
+
9670
9688
  // src/index.ts
9671
9689
  var program2 = new Command;
9672
- program2.name("pruny").description("Find and remove unused Next.js API routes").version("1.0.0").option("-d, --dir <path>", "Target directory to scan", "./").option("--fix", "Delete unused API routes").option("-c, --config <path>", "Path to config file").option("--json", "Output as JSON").option("--no-public", "Disable public assets scanning").option("-v, --verbose", "Show detailed info").action(async (options) => {
9690
+ program2.name("pruny").description("Find and remove unused Next.js API routes").version("1.0.0").option("-d, --dir <path>", "Target directory to scan", "./").option("--fix", "Delete unused API routes").option("-c, --config <path>", "Path to config file").option("--json", "Output as JSON").option("--no-public", "Disable public assets scanning").option("-v, --verbose", "Show detailed info");
9691
+ program2.command("init").description("Create a default pruny.config.json file").action(() => {
9692
+ init();
9693
+ });
9694
+ program2.action(async (options) => {
9673
9695
  const config = loadConfig({
9674
9696
  dir: options.dir,
9675
9697
  config: options.config,
9676
9698
  excludePublic: !options.public
9677
9699
  });
9678
- const absoluteDir = config.dir.startsWith("/") ? config.dir : join7(process.cwd(), config.dir);
9700
+ const absoluteDir = config.dir.startsWith("/") ? config.dir : join8(process.cwd(), config.dir);
9679
9701
  config.dir = absoluteDir;
9680
9702
  if (options.verbose) {
9681
9703
  console.log(source_default.dim(`
@@ -9803,7 +9825,7 @@ Config:`));
9803
9825
  console.log(source_default.yellow.bold(`\uD83D\uDDD1️ Deleting unused routes...
9804
9826
  `));
9805
9827
  for (const route of unusedRoutes) {
9806
- const routeDir = dirname2(join7(config.dir, route.filePath));
9828
+ const routeDir = dirname2(join8(config.dir, route.filePath));
9807
9829
  try {
9808
9830
  rmSync(routeDir, { recursive: true, force: true });
9809
9831
  console.log(source_default.red(` Deleted: ${route.filePath}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pruny",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "description": "Find and remove unused Next.js API routes & Nest.js Controllers",
5
5
  "type": "module",
6
6
  "files": [