pruny 1.31.0 → 1.33.0

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 CHANGED
@@ -14990,7 +14990,14 @@ var import_fast_glob5 = __toESM(require_out4(), 1);
14990
14990
  // src/scanners/missing-assets.ts
14991
14991
  var import_fast_glob6 = __toESM(require_out4(), 1);
14992
14992
  import { readFileSync as readFileSync5, existsSync as existsSync4 } from "node:fs";
14993
- import { join as join5 } from "node:path";
14993
+ import { basename, join as join5 } from "node:path";
14994
+ var NEXTJS_METADATA_PREFIXES = [
14995
+ "icon",
14996
+ "apple-icon",
14997
+ "favicon",
14998
+ "opengraph-image",
14999
+ "twitter-image"
15000
+ ];
14994
15001
  async function scanMissingAssets(config) {
14995
15002
  const cwd = config.appSpecificScan ? config.appSpecificScan.appDir : config.dir;
14996
15003
  const publicDir = join5(cwd, "public");
@@ -15020,6 +15027,13 @@ async function scanMissingAssets(config) {
15020
15027
  const lineNumber = linesUpToMatch.length;
15021
15028
  const fullPath = join5(publicDir, assetPath.substring(1));
15022
15029
  if (!existsSync4(fullPath)) {
15030
+ const fileName = basename(assetPath);
15031
+ const isNextjsMetadata = NEXTJS_METADATA_PREFIXES.some((prefix) => fileName === prefix || fileName.startsWith(`${prefix}.`) || fileName.match(new RegExp(`^${prefix}\\d+\\.`)));
15032
+ if (isNextjsMetadata) {
15033
+ const appPath = join5(cwd, "app", fileName);
15034
+ if (existsSync4(appPath))
15035
+ continue;
15036
+ }
15023
15037
  const assetKey = assetPath;
15024
15038
  if (!missingMap.has(assetKey)) {
15025
15039
  missingMap.set(assetKey, new Set);
@@ -16196,6 +16210,7 @@ program2.command("init").description("Create a default pruny.config.json file").
16196
16210
  });
16197
16211
  program2.action(async (options) => {
16198
16212
  const startTime = Date.now();
16213
+ const isNonInteractive = !process.stdin.isTTY || !!process.env.CI;
16199
16214
  try {
16200
16215
  const baseConfig = loadConfig({
16201
16216
  dir: options.dir,
@@ -16256,7 +16271,7 @@ program2.action(async (options) => {
16256
16271
  appsToScan.push(...availableApps.filter((app) => !ignoredApps.includes(app)));
16257
16272
  } else if (options.folder) {
16258
16273
  appsToScan.push(...availableApps);
16259
- } else if (!options.ignoreApps && !options.filter && !options.json) {
16274
+ } else if (!isNonInteractive && !options.ignoreApps && !options.filter && !options.json) {
16260
16275
  const response = await import_prompts.default({
16261
16276
  type: "select",
16262
16277
  name: "selected",
@@ -16349,6 +16364,10 @@ program2.action(async (options) => {
16349
16364
  if (issues > 0) {
16350
16365
  process.exit(1);
16351
16366
  }
16367
+ } else if (isNonInteractive) {
16368
+ if (hasUnusedItems(result)) {
16369
+ printDetailedReport(result);
16370
+ }
16352
16371
  } else if (hasUnusedItems(result)) {
16353
16372
  if (options.verbose) {
16354
16373
  printDetailedReport(result);
@@ -16384,7 +16403,7 @@ program2.action(async (options) => {
16384
16403
  }
16385
16404
  }
16386
16405
  }
16387
- if (!isMonorepo || !requestedBack && appsToScan.length > 0 || options.json || options.filter || options.all) {
16406
+ if (!isMonorepo || !requestedBack && appsToScan.length > 0 || options.json || options.filter || options.all || isNonInteractive) {
16388
16407
  break;
16389
16408
  }
16390
16409
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pruny",
3
- "version": "1.31.0",
3
+ "version": "1.33.0",
4
4
  "description": "Find and remove unused Next.js API routes & Nest.js Controllers",
5
5
  "type": "module",
6
6
  "files": [
package/bin/pruny.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import('../dist/index.js');