apex-auditor 0.2.5 → 0.2.7
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/route-detectors.js +53 -1
- package/dist/wizard-cli.js +3 -0
- package/package.json +1 -1
package/dist/route-detectors.js
CHANGED
|
@@ -2,15 +2,17 @@ import { readdir } from "node:fs/promises";
|
|
|
2
2
|
import { join, relative, sep } from "node:path";
|
|
3
3
|
import { pathExists, readTextFile } from "./fs-utils.js";
|
|
4
4
|
const PAGE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
|
|
5
|
-
const DEFAULT_LIMIT =
|
|
5
|
+
const DEFAULT_LIMIT = 200;
|
|
6
6
|
const SOURCE_NEXT_APP = "next-app";
|
|
7
7
|
const SOURCE_NEXT_PAGES = "next-pages";
|
|
8
8
|
const SOURCE_REMIX = "remix-routes";
|
|
9
|
+
const SOURCE_SVELTEKIT = "sveltekit-routes";
|
|
9
10
|
const SOURCE_SPA = "spa-html";
|
|
10
11
|
const ROUTE_DETECTORS = [
|
|
11
12
|
createNextAppDetector(),
|
|
12
13
|
createNextPagesDetector(),
|
|
13
14
|
createRemixRoutesDetector(),
|
|
15
|
+
createSvelteKitRoutesDetector(),
|
|
14
16
|
createSpaHtmlDetector(),
|
|
15
17
|
];
|
|
16
18
|
export async function detectRoutes(options) {
|
|
@@ -60,6 +62,19 @@ function createNextAppDetector() {
|
|
|
60
62
|
},
|
|
61
63
|
};
|
|
62
64
|
}
|
|
65
|
+
function createSvelteKitRoutesDetector() {
|
|
66
|
+
return {
|
|
67
|
+
id: SOURCE_SVELTEKIT,
|
|
68
|
+
canDetect: async (options) => {
|
|
69
|
+
const routesRoot = join(options.projectRoot, "src", "routes");
|
|
70
|
+
return pathExists(routesRoot);
|
|
71
|
+
},
|
|
72
|
+
detect: async (options) => {
|
|
73
|
+
const routesRoot = join(options.projectRoot, "src", "routes");
|
|
74
|
+
return detectSvelteKitRoutes(routesRoot, options.limit);
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
63
78
|
function createNextPagesDetector() {
|
|
64
79
|
return {
|
|
65
80
|
id: SOURCE_NEXT_PAGES,
|
|
@@ -191,6 +206,10 @@ async function detectRemixRoutes(routesRoot, limit) {
|
|
|
191
206
|
const files = await collectRouteFiles(routesRoot, limit, isRemixRouteFile);
|
|
192
207
|
return files.map((file) => buildRoute(file, routesRoot, formatRemixRoutePath, SOURCE_REMIX));
|
|
193
208
|
}
|
|
209
|
+
async function detectSvelteKitRoutes(routesRoot, limit) {
|
|
210
|
+
const files = await collectRouteFiles(routesRoot, limit, isSvelteKitPageFile);
|
|
211
|
+
return files.map((file) => buildRoute(file, routesRoot, formatSvelteKitRoutePath, SOURCE_SVELTEKIT));
|
|
212
|
+
}
|
|
194
213
|
async function detectSpaRoutes(projectRoot, limit) {
|
|
195
214
|
const htmlPath = await findSpaHtml(projectRoot);
|
|
196
215
|
if (!htmlPath) {
|
|
@@ -270,6 +289,17 @@ function isRemixRouteFile(entry, relativePath) {
|
|
|
270
289
|
}
|
|
271
290
|
return !posixPath.split("/").some((segment) => segment.startsWith("__"));
|
|
272
291
|
}
|
|
292
|
+
function isSvelteKitPageFile(entry, relativePath) {
|
|
293
|
+
if (!entry.isFile()) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
const posixPath = normalisePath(relativePath);
|
|
297
|
+
return (posixPath.endsWith("+page.svelte") ||
|
|
298
|
+
posixPath.endsWith("+page.ts") ||
|
|
299
|
+
posixPath.endsWith("+page.js") ||
|
|
300
|
+
posixPath.endsWith("+page.tsx") ||
|
|
301
|
+
posixPath.endsWith("+page.jsx"));
|
|
302
|
+
}
|
|
273
303
|
function hasAllowedExtension(path) {
|
|
274
304
|
return PAGE_EXTENSIONS.some((extension) => path.endsWith(extension));
|
|
275
305
|
}
|
|
@@ -329,6 +359,28 @@ function formatRemixRoutePath(relativePath) {
|
|
|
329
359
|
.filter((segment) => segment.length > 0);
|
|
330
360
|
return parts.length === 0 ? "/" : normaliseRoute(parts.join("/"));
|
|
331
361
|
}
|
|
362
|
+
function formatSvelteKitRoutePath(relativePath) {
|
|
363
|
+
const cleanPath = relativePath.replace(/\\/g, "/");
|
|
364
|
+
const withoutFile = cleanPath.replace(/\/?\+page\.[^/]+$/, "");
|
|
365
|
+
const segments = withoutFile.split("/").filter((segment) => segment.length > 0);
|
|
366
|
+
const parts = segments
|
|
367
|
+
.filter((segment) => !(segment.startsWith("(") && segment.endsWith(")")))
|
|
368
|
+
.map((segment) => {
|
|
369
|
+
if (segment.startsWith("[") && segment.endsWith("]")) {
|
|
370
|
+
const inner = segment.slice(1, -1);
|
|
371
|
+
const name = inner.replace(/^\.\.\./, "");
|
|
372
|
+
if (name.length === 0) {
|
|
373
|
+
return ":param";
|
|
374
|
+
}
|
|
375
|
+
return `:${name}`;
|
|
376
|
+
}
|
|
377
|
+
return segment;
|
|
378
|
+
});
|
|
379
|
+
if (parts.length === 0) {
|
|
380
|
+
return "/";
|
|
381
|
+
}
|
|
382
|
+
return normaliseRoute(parts.join("/"));
|
|
383
|
+
}
|
|
332
384
|
function normaliseRoute(path) {
|
|
333
385
|
const trimmed = path.replace(/^\/+/, "");
|
|
334
386
|
if (trimmed.length === 0) {
|
package/dist/wizard-cli.js
CHANGED
|
@@ -9,6 +9,7 @@ const PROFILE_TO_DETECTOR = {
|
|
|
9
9
|
"next-pages": "next-pages",
|
|
10
10
|
spa: "spa-html",
|
|
11
11
|
remix: "remix-routes",
|
|
12
|
+
sveltekit: "sveltekit-routes",
|
|
12
13
|
custom: undefined,
|
|
13
14
|
};
|
|
14
15
|
const DEFAULT_BASE_URL = "http://localhost:3000";
|
|
@@ -25,6 +26,7 @@ const profileQuestion = {
|
|
|
25
26
|
{ title: "Next.js (App Router)", value: "next-app" },
|
|
26
27
|
{ title: "Next.js (Pages Router)", value: "next-pages" },
|
|
27
28
|
{ title: "Remix", value: "remix" },
|
|
29
|
+
{ title: "SvelteKit", value: "sveltekit" },
|
|
28
30
|
{ title: "Single Page App (Vite/CRA/etc.)", value: "spa" },
|
|
29
31
|
{ title: "Custom/manual", value: "custom" },
|
|
30
32
|
],
|
|
@@ -113,6 +115,7 @@ const detectorChoiceQuestion = {
|
|
|
113
115
|
{ title: "Next.js (App Router)", value: "next-app" },
|
|
114
116
|
{ title: "Next.js (Pages Router)", value: "next-pages" },
|
|
115
117
|
{ title: "Remix", value: "remix-routes" },
|
|
118
|
+
{ title: "SvelteKit", value: "sveltekit-routes" },
|
|
116
119
|
{ title: "SPA Crawl", value: "spa-html" },
|
|
117
120
|
],
|
|
118
121
|
};
|