pruny 1.2.9 → 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.
- package/dist/index.js +31 -4
- 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
|
|
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);
|
|
@@ -9318,6 +9318,11 @@ var IGNORED_EXPORT_NAMES = new Set([
|
|
|
9318
9318
|
"dynamicParams",
|
|
9319
9319
|
"maxDuration",
|
|
9320
9320
|
"generateViewport",
|
|
9321
|
+
"generateSitemaps",
|
|
9322
|
+
"generateImageMetadata",
|
|
9323
|
+
"alt",
|
|
9324
|
+
"size",
|
|
9325
|
+
"contentType",
|
|
9321
9326
|
"GET",
|
|
9322
9327
|
"POST",
|
|
9323
9328
|
"PUT",
|
|
@@ -9662,15 +9667,37 @@ function removeExportFromLine(rootDir, exp) {
|
|
|
9662
9667
|
}
|
|
9663
9668
|
}
|
|
9664
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
|
+
|
|
9665
9688
|
// src/index.ts
|
|
9666
9689
|
var program2 = new Command;
|
|
9667
|
-
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")
|
|
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) => {
|
|
9668
9695
|
const config = loadConfig({
|
|
9669
9696
|
dir: options.dir,
|
|
9670
9697
|
config: options.config,
|
|
9671
9698
|
excludePublic: !options.public
|
|
9672
9699
|
});
|
|
9673
|
-
const absoluteDir = config.dir.startsWith("/") ? config.dir :
|
|
9700
|
+
const absoluteDir = config.dir.startsWith("/") ? config.dir : join8(process.cwd(), config.dir);
|
|
9674
9701
|
config.dir = absoluteDir;
|
|
9675
9702
|
if (options.verbose) {
|
|
9676
9703
|
console.log(source_default.dim(`
|
|
@@ -9798,7 +9825,7 @@ Config:`));
|
|
|
9798
9825
|
console.log(source_default.yellow.bold(`\uD83D\uDDD1️ Deleting unused routes...
|
|
9799
9826
|
`));
|
|
9800
9827
|
for (const route of unusedRoutes) {
|
|
9801
|
-
const routeDir = dirname2(
|
|
9828
|
+
const routeDir = dirname2(join8(config.dir, route.filePath));
|
|
9802
9829
|
try {
|
|
9803
9830
|
rmSync(routeDir, { recursive: true, force: true });
|
|
9804
9831
|
console.log(source_default.red(` Deleted: ${route.filePath}`));
|