pruny 1.42.1 → 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 +49 -1
- package/package.json +1 -1
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) => {
|
|
@@ -15964,11 +15993,30 @@ async function scanBrokenLinks(config) {
|
|
|
15964
15993
|
const ignore = [...config.ignore.folders, ...config.ignore.files, "**/node_modules/**"];
|
|
15965
15994
|
const extensions = config.extensions;
|
|
15966
15995
|
const globPattern = `**/*{${extensions.join(",")}}`;
|
|
15967
|
-
|
|
15996
|
+
let sourceFiles = await import_fast_glob9.default(globPattern, {
|
|
15968
15997
|
cwd: refDir,
|
|
15969
15998
|
ignore,
|
|
15970
15999
|
absolute: true
|
|
15971
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
|
+
}
|
|
15972
16020
|
const brokenMap = new Map;
|
|
15973
16021
|
const allLinkPaths = new Set;
|
|
15974
16022
|
for (const file of sourceFiles) {
|