pruny 1.42.0 → 1.43.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
@@ -14146,6 +14146,30 @@ import { join as join3, dirname as dirname2, resolve as resolve2, relative } fro
14146
14146
  // src/utils.ts
14147
14147
  import { isAbsolute, join as join2, resolve, dirname } from "node:path";
14148
14148
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
14149
+ function detectAppFramework(appDir) {
14150
+ const pkgPath = join2(appDir, "package.json");
14151
+ if (!existsSync2(pkgPath))
14152
+ return ["unknown"];
14153
+ try {
14154
+ const pkg = JSON.parse(readFileSync2(pkgPath, "utf-8"));
14155
+ const allDeps = {
14156
+ ...pkg.dependencies,
14157
+ ...pkg.devDependencies
14158
+ };
14159
+ const frameworks = [];
14160
+ if (allDeps["next"])
14161
+ frameworks.push("nextjs");
14162
+ if (allDeps["@nestjs/core"] || allDeps["@nestjs/common"])
14163
+ frameworks.push("nestjs");
14164
+ if (allDeps["expo"])
14165
+ frameworks.push("expo");
14166
+ else if (allDeps["react-native"])
14167
+ frameworks.push("react-native");
14168
+ return frameworks.length > 0 ? frameworks : ["unknown"];
14169
+ } catch {
14170
+ return ["unknown"];
14171
+ }
14172
+ }
14149
14173
  function sanitizeLine(line) {
14150
14174
  return line.replace(/\\./g, "__").replace(/'[^']*'/g, "''").replace(/"[^"]*"/g, '""').replace(/`[^`]*`/g, "``").replace(/\/\/.*/, "").replace(/\/\*.*?\*\//g, "");
14151
14175
  }
@@ -14320,6 +14344,11 @@ async function scanUnusedFiles(config) {
14320
14344
  if (searchDirName.includes("lambda") || searchDirName.includes("function") || searchDirName.includes("serverless")) {
14321
14345
  entryPatterns.push("{index,handler}.{ts,js}");
14322
14346
  }
14347
+ const frameworks = detectAppFramework(searchDir);
14348
+ const isExpoOrRN = frameworks.includes("expo") || frameworks.includes("react-native");
14349
+ if (isExpoOrRN) {
14350
+ entryPatterns.push("**/_layout.{ts,tsx,js,jsx}", "app/**/*.{ts,tsx,js,jsx}", "App.{ts,tsx,js,jsx}", "index.{ts,tsx,js,jsx}", "app.{json,config.js,config.ts}", "metro.config.{js,ts,cjs}", "babel.config.{js,cjs}", "expo-env.d.ts", "eas.json");
14351
+ }
14323
14352
  for (const file of allFiles) {
14324
14353
  const relPath = relative(searchDir, file);
14325
14354
  const isEntry = entryPatterns.some((pattern) => {
@@ -14449,7 +14478,9 @@ var IGNORED_EXPORT_NAMES = new Set([
14449
14478
  "default",
14450
14479
  "handler",
14451
14480
  "main",
14452
- "lambdaHandler"
14481
+ "lambdaHandler",
14482
+ "middleware",
14483
+ "proxy"
14453
14484
  ]);
14454
14485
  var FRAMEWORK_METHOD_DECORATORS = new Set([
14455
14486
  "@Cron",
@@ -15962,11 +15993,30 @@ async function scanBrokenLinks(config) {
15962
15993
  const ignore = [...config.ignore.folders, ...config.ignore.files, "**/node_modules/**"];
15963
15994
  const extensions = config.extensions;
15964
15995
  const globPattern = `**/*{${extensions.join(",")}}`;
15965
- const sourceFiles = await import_fast_glob9.default(globPattern, {
15996
+ let sourceFiles = await import_fast_glob9.default(globPattern, {
15966
15997
  cwd: refDir,
15967
15998
  ignore,
15968
15999
  absolute: true
15969
16000
  });
16001
+ if (config.appSpecificScan) {
16002
+ const { readdirSync, lstatSync } = await import("node:fs");
16003
+ const { join: join7 } = await import("node:path");
16004
+ const appsDir = join7(config.appSpecificScan.rootDir, "apps");
16005
+ try {
16006
+ const apps = readdirSync(appsDir).filter((a) => lstatSync(join7(appsDir, a)).isDirectory());
16007
+ const expoAppDirs = [];
16008
+ for (const app of apps) {
16009
+ const appPath = join7(appsDir, app);
16010
+ const frameworks = detectAppFramework(appPath);
16011
+ if (frameworks.includes("expo") || frameworks.includes("react-native")) {
16012
+ expoAppDirs.push(appPath);
16013
+ }
16014
+ }
16015
+ if (expoAppDirs.length > 0) {
16016
+ sourceFiles = sourceFiles.filter((f) => !expoAppDirs.some((d) => f.startsWith(d)));
16017
+ }
16018
+ } catch {}
16019
+ }
15970
16020
  const brokenMap = new Map;
15971
16021
  const allLinkPaths = new Set;
15972
16022
  for (const file of sourceFiles) {
@@ -33,7 +33,9 @@ var IGNORED_EXPORT_NAMES = new Set([
33
33
  "default",
34
34
  "handler",
35
35
  "main",
36
- "lambdaHandler"
36
+ "lambdaHandler",
37
+ "middleware",
38
+ "proxy"
37
39
  ]);
38
40
  var FRAMEWORK_METHOD_DECORATORS = new Set([
39
41
  "@Cron",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pruny",
3
- "version": "1.42.0",
3
+ "version": "1.43.0",
4
4
  "description": "Find and remove unused Next.js API routes & Nest.js Controllers",
5
5
  "type": "module",
6
6
  "files": [