@tanstack/router-generator 1.18.1 → 1.19.2
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/cjs/config.cjs +2 -1
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/config.d.cts +3 -0
- package/dist/cjs/generator.cjs +112 -49
- package/dist/cjs/generator.cjs.map +1 -1
- package/dist/cjs/generator.d.cts +12 -0
- package/dist/cjs/utils.cjs +25 -0
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +9 -0
- package/dist/esm/config.d.ts +3 -0
- package/dist/esm/config.js +2 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/generator.d.ts +12 -0
- package/dist/esm/generator.js +113 -50
- package/dist/esm/generator.js.map +1 -1
- package/dist/esm/utils.d.ts +9 -0
- package/dist/esm/utils.js +25 -0
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +1 -0
- package/src/generator.ts +162 -60
- package/src/utils.ts +20 -0
package/dist/cjs/config.cjs
CHANGED
|
@@ -10,7 +10,8 @@ const configSchema = zod.z.object({
|
|
|
10
10
|
generatedRouteTree: zod.z.string().optional().default("./src/routeTree.gen.ts"),
|
|
11
11
|
quoteStyle: zod.z.enum(["single", "double"]).optional().default("single"),
|
|
12
12
|
disableTypes: zod.z.boolean().optional().default(false),
|
|
13
|
-
addExtensions: zod.z.boolean().optional().default(false)
|
|
13
|
+
addExtensions: zod.z.boolean().optional().default(false),
|
|
14
|
+
disableLogging: zod.z.boolean().optional().default(false)
|
|
14
15
|
});
|
|
15
16
|
async function getConfig(inlineConfig = {}, configDirectory) {
|
|
16
17
|
if (configDirectory === void 0) {
|
package/dist/cjs/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","sources":["../../src/config.ts"],"sourcesContent":["import path from 'path'\nimport { readFileSync, existsSync } from 'fs'\nimport { z } from 'zod'\n\nexport const configSchema = z.object({\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routesDirectory: z.string().optional().default('./src/routes'),\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n disableTypes: z.boolean().optional().default(false),\n addExtensions: z.boolean().optional().default(false),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nexport async function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Promise<Config> {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = path.resolve(configDirectory, 'tsr.config.json')\n const exists = existsSync(configFilePathJson)\n\n let config: Config\n\n if (exists) {\n config = configSchema.parse({\n ...JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n ...inlineConfig,\n })\n } else {\n config = configSchema.parse(inlineConfig)\n }\n\n // If typescript is disabled, make sure the generated route tree is a .js file\n if (config.disableTypes) {\n config.generatedRouteTree = config.generatedRouteTree.replace(\n /\\.(ts|tsx)$/,\n '.js',\n )\n }\n\n return config\n}\n"],"names":["z","existsSync","readFileSync"],"mappings":";;;;;AAIa,MAAA,eAAeA,MAAE,OAAO;AAAA,EACnC,iBAAiBA,IAAA,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,uBAAuBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,GAAG;AAAA,EACxD,iBAAiBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,cAAc;AAAA,EAC7D,oBAAoBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,wBAAwB;AAAA,EAC1E,YAAYA,IAAAA,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC,EAAE,SAAA,EAAW,QAAQ,QAAQ;AAAA,EACpE,cAAcA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EAClD,eAAeA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"config.cjs","sources":["../../src/config.ts"],"sourcesContent":["import path from 'path'\nimport { readFileSync, existsSync } from 'fs'\nimport { z } from 'zod'\n\nexport const configSchema = z.object({\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routesDirectory: z.string().optional().default('./src/routes'),\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n disableTypes: z.boolean().optional().default(false),\n addExtensions: z.boolean().optional().default(false),\n disableLogging: z.boolean().optional().default(false),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nexport async function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Promise<Config> {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = path.resolve(configDirectory, 'tsr.config.json')\n const exists = existsSync(configFilePathJson)\n\n let config: Config\n\n if (exists) {\n config = configSchema.parse({\n ...JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n ...inlineConfig,\n })\n } else {\n config = configSchema.parse(inlineConfig)\n }\n\n // If typescript is disabled, make sure the generated route tree is a .js file\n if (config.disableTypes) {\n config.generatedRouteTree = config.generatedRouteTree.replace(\n /\\.(ts|tsx)$/,\n '.js',\n )\n }\n\n return config\n}\n"],"names":["z","existsSync","readFileSync"],"mappings":";;;;;AAIa,MAAA,eAAeA,MAAE,OAAO;AAAA,EACnC,iBAAiBA,IAAA,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,uBAAuBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,GAAG;AAAA,EACxD,iBAAiBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,cAAc;AAAA,EAC7D,oBAAoBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,wBAAwB;AAAA,EAC1E,YAAYA,IAAAA,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC,EAAE,SAAA,EAAW,QAAQ,QAAQ;AAAA,EACpE,cAAcA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EAClD,eAAeA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EACnD,gBAAgBA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AACtD,CAAC;AAID,eAAsB,UACpB,eAAgC,CAAC,GACjC,iBACiB;AACjB,MAAI,oBAAoB,QAAW;AACjC,sBAAkB,QAAQ;EAC5B;AACA,QAAM,qBAAqB,KAAK,QAAQ,iBAAiB,iBAAiB;AACpE,QAAA,SAASC,cAAW,kBAAkB;AAExC,MAAA;AAEJ,MAAI,QAAQ;AACV,aAAS,aAAa,MAAM;AAAA,MAC1B,GAAG,KAAK,MAAMC,GAAa,aAAA,oBAAoB,OAAO,CAAC;AAAA,MACvD,GAAG;AAAA,IAAA,CACJ;AAAA,EAAA,OACI;AACI,aAAA,aAAa,MAAM,YAAY;AAAA,EAC1C;AAGA,MAAI,OAAO,cAAc;AAChB,WAAA,qBAAqB,OAAO,mBAAmB;AAAA,MACpD;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AACT;;;"}
|
package/dist/cjs/config.d.cts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
7
7
|
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<["single", "double"]>>>;
|
|
8
8
|
disableTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
9
9
|
addExtensions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
10
|
+
disableLogging: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
10
11
|
}, "strip", z.ZodTypeAny, {
|
|
11
12
|
routeFileIgnorePrefix: string;
|
|
12
13
|
routesDirectory: string;
|
|
@@ -14,6 +15,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
14
15
|
quoteStyle: "single" | "double";
|
|
15
16
|
disableTypes: boolean;
|
|
16
17
|
addExtensions: boolean;
|
|
18
|
+
disableLogging: boolean;
|
|
17
19
|
routeFilePrefix?: string | undefined;
|
|
18
20
|
}, {
|
|
19
21
|
routeFilePrefix?: string | undefined;
|
|
@@ -23,6 +25,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
23
25
|
quoteStyle?: "single" | "double" | undefined;
|
|
24
26
|
disableTypes?: boolean | undefined;
|
|
25
27
|
addExtensions?: boolean | undefined;
|
|
28
|
+
disableLogging?: boolean | undefined;
|
|
26
29
|
}>;
|
|
27
30
|
export type Config = z.infer<typeof configSchema>;
|
|
28
31
|
export declare function getConfig(inlineConfig?: Partial<Config>, configDirectory?: string): Promise<Config>;
|
package/dist/cjs/generator.cjs
CHANGED
|
@@ -29,6 +29,7 @@ const rootPathId = "__root";
|
|
|
29
29
|
const routeGroupPatternRegex = /\(.+\)/g;
|
|
30
30
|
async function getRouteNodes(config) {
|
|
31
31
|
const { routeFilePrefix, routeFileIgnorePrefix } = config;
|
|
32
|
+
const logger = utils.logging({ disabled: config.disableLogging });
|
|
32
33
|
let routeNodes = [];
|
|
33
34
|
async function recurse(dir) {
|
|
34
35
|
const fullDir = path.resolve(config.routesDirectory, dir);
|
|
@@ -44,6 +45,7 @@ async function getRouteNodes(config) {
|
|
|
44
45
|
});
|
|
45
46
|
await Promise.all(
|
|
46
47
|
dirList.map(async (dirent) => {
|
|
48
|
+
var _a;
|
|
47
49
|
const fullPath = path.join(fullDir, dirent.name);
|
|
48
50
|
const relativePath = path.join(dir, dirent.name);
|
|
49
51
|
if (dirent.isDirectory()) {
|
|
@@ -65,6 +67,8 @@ async function getRouteNodes(config) {
|
|
|
65
67
|
let isErrorComponent = routePath == null ? void 0 : routePath.endsWith("/errorComponent");
|
|
66
68
|
let isPendingComponent = routePath == null ? void 0 : routePath.endsWith("/pendingComponent");
|
|
67
69
|
let isLoader = routePath == null ? void 0 : routePath.endsWith("/loader");
|
|
70
|
+
const segments = (routePath ?? "").split("/");
|
|
71
|
+
let isLayout = ((_a = segments[segments.length - 1]) == null ? void 0 : _a.startsWith("_")) || false;
|
|
68
72
|
[
|
|
69
73
|
[isComponent, "component"],
|
|
70
74
|
[isErrorComponent, "errorComponent"],
|
|
@@ -72,7 +76,7 @@ async function getRouteNodes(config) {
|
|
|
72
76
|
[isLoader, "loader"]
|
|
73
77
|
].forEach(([isType, type]) => {
|
|
74
78
|
if (isType) {
|
|
75
|
-
|
|
79
|
+
logger.warn(
|
|
76
80
|
`WARNING: The \`.${type}.tsx\` suffix used for the ${filePath} file is deprecated. Use the new \`.lazy.tsx\` suffix instead.`
|
|
77
81
|
);
|
|
78
82
|
}
|
|
@@ -95,7 +99,8 @@ async function getRouteNodes(config) {
|
|
|
95
99
|
isErrorComponent,
|
|
96
100
|
isPendingComponent,
|
|
97
101
|
isLoader,
|
|
98
|
-
isLazy
|
|
102
|
+
isLazy,
|
|
103
|
+
isLayout
|
|
99
104
|
});
|
|
100
105
|
}
|
|
101
106
|
})
|
|
@@ -108,14 +113,15 @@ async function getRouteNodes(config) {
|
|
|
108
113
|
let first = false;
|
|
109
114
|
let skipMessage = false;
|
|
110
115
|
async function generator(config) {
|
|
111
|
-
|
|
116
|
+
const logger = utils.logging({ disabled: config.disableLogging });
|
|
117
|
+
logger.log("");
|
|
112
118
|
if (!first) {
|
|
113
|
-
|
|
119
|
+
logger.log("♻️ Generating routes...");
|
|
114
120
|
first = true;
|
|
115
121
|
} else if (skipMessage) {
|
|
116
122
|
skipMessage = false;
|
|
117
123
|
} else {
|
|
118
|
-
|
|
124
|
+
logger.log("♻️ Regenerating routes...");
|
|
119
125
|
}
|
|
120
126
|
const taskId = latestTask + 1;
|
|
121
127
|
latestTask = taskId;
|
|
@@ -162,53 +168,67 @@ async function generator(config) {
|
|
|
162
168
|
const routePiecesByPath = {};
|
|
163
169
|
let routeNodes = [];
|
|
164
170
|
const handleNode = async (node) => {
|
|
165
|
-
var _a, _b;
|
|
166
|
-
|
|
171
|
+
var _a, _b, _c;
|
|
172
|
+
let parentRoute = hasParentRoute(routeNodes, node.routePath);
|
|
173
|
+
if ((parentRoute == null ? void 0 : parentRoute.isVirtualParentRoute) && ((_a = parentRoute.children) == null ? void 0 : _a.length)) {
|
|
174
|
+
const possibleParentRoute = hasParentRoute(
|
|
175
|
+
parentRoute.children,
|
|
176
|
+
node.routePath
|
|
177
|
+
);
|
|
178
|
+
if (possibleParentRoute) {
|
|
179
|
+
parentRoute = possibleParentRoute;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
167
182
|
if (parentRoute)
|
|
168
183
|
node.parent = parentRoute;
|
|
169
|
-
node.path = node.parent ? ((
|
|
184
|
+
node.path = node.parent ? ((_b = node.routePath) == null ? void 0 : _b.replace(node.parent.routePath, "")) || "/" : node.routePath;
|
|
170
185
|
const trimmedPath = utils.trimPathLeft(node.path ?? "");
|
|
171
186
|
const split = (trimmedPath == null ? void 0 : trimmedPath.split("/")) ?? [];
|
|
172
187
|
let first2 = split[0] ?? trimmedPath ?? "";
|
|
173
|
-
|
|
188
|
+
const lastRouteSegment = split[split.length - 1] ?? trimmedPath ?? "";
|
|
189
|
+
node.isNonPath = lastRouteSegment.startsWith("_");
|
|
174
190
|
node.isNonLayout = first2.endsWith("_");
|
|
175
|
-
node.cleanedPath = removeGroups(
|
|
176
|
-
|
|
177
|
-
const escapedRoutePath = removeTrailingUnderscores(
|
|
178
|
-
((_b = node.routePath) == null ? void 0 : _b.replaceAll("$", "$$")) ?? ""
|
|
191
|
+
node.cleanedPath = removeGroups(
|
|
192
|
+
removeUnderscores(removeLayoutSegments(node.path)) ?? ""
|
|
179
193
|
);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
`import { createLazyFileRoute } from '@tanstack/react-router'`,
|
|
185
|
-
`export const Route = createLazyFileRoute('${escapedRoutePath}')({
|
|
186
|
-
component: () => <div>Hello ${escapedRoutePath}!</div>
|
|
187
|
-
})`
|
|
188
|
-
].join("\n\n");
|
|
189
|
-
} else if (node.isRoute || !node.isComponent && !node.isErrorComponent && !node.isPendingComponent && !node.isLoader) {
|
|
190
|
-
replaced = [
|
|
191
|
-
`import { createFileRoute } from '@tanstack/react-router'`,
|
|
192
|
-
`export const Route = createFileRoute('${escapedRoutePath}')({
|
|
193
|
-
component: () => <div>Hello ${escapedRoutePath}!</div>
|
|
194
|
-
})`
|
|
195
|
-
].join("\n\n");
|
|
196
|
-
}
|
|
197
|
-
} else {
|
|
198
|
-
replaced = routeCode.replace(
|
|
199
|
-
/(FileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
|
|
200
|
-
(match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`
|
|
201
|
-
).replace(
|
|
202
|
-
/(createFileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
|
|
203
|
-
(match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`
|
|
204
|
-
).replace(
|
|
205
|
-
/(createLazyFileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
|
|
206
|
-
(match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`
|
|
194
|
+
if (!node.isVirtualParentRoute) {
|
|
195
|
+
const routeCode = fs__namespace.readFileSync(node.fullPath, "utf-8");
|
|
196
|
+
const escapedRoutePath = removeTrailingUnderscores(
|
|
197
|
+
((_c = node.routePath) == null ? void 0 : _c.replaceAll("$", "$$")) ?? ""
|
|
207
198
|
);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
199
|
+
let replaced = routeCode;
|
|
200
|
+
if (!routeCode) {
|
|
201
|
+
if (node.isLazy) {
|
|
202
|
+
replaced = [
|
|
203
|
+
`import { createLazyFileRoute } from '@tanstack/react-router'`,
|
|
204
|
+
`export const Route = createLazyFileRoute('${escapedRoutePath}')({
|
|
205
|
+
component: () => <div>Hello ${escapedRoutePath}!</div>
|
|
206
|
+
})`
|
|
207
|
+
].join("\n\n");
|
|
208
|
+
} else if (node.isRoute || !node.isComponent && !node.isErrorComponent && !node.isPendingComponent && !node.isLoader) {
|
|
209
|
+
replaced = [
|
|
210
|
+
`import { createFileRoute } from '@tanstack/react-router'`,
|
|
211
|
+
`export const Route = createFileRoute('${escapedRoutePath}')({
|
|
212
|
+
component: () => <div>Hello ${escapedRoutePath}!</div>
|
|
213
|
+
})`
|
|
214
|
+
].join("\n\n");
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
replaced = routeCode.replace(
|
|
218
|
+
/(FileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
|
|
219
|
+
(match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`
|
|
220
|
+
).replace(
|
|
221
|
+
/(createFileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
|
|
222
|
+
(match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`
|
|
223
|
+
).replace(
|
|
224
|
+
/(createLazyFileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
|
|
225
|
+
(match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
if (replaced !== routeCode) {
|
|
229
|
+
logger.log(`🟡 Updating ${node.fullPath}`);
|
|
230
|
+
await fsp__namespace.writeFile(node.fullPath, replaced);
|
|
231
|
+
}
|
|
212
232
|
}
|
|
213
233
|
if (!node.isVirtual && (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent || node.isLazy)) {
|
|
214
234
|
routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
|
|
@@ -227,9 +247,41 @@ async function generator(config) {
|
|
|
227
247
|
}
|
|
228
248
|
return;
|
|
229
249
|
}
|
|
250
|
+
node.isVirtualParentRequired = removeGroups(node.path ?? "").split("").filter((char) => char === "/").length >= 2 && // check that the parent route wouldn't be the root route
|
|
251
|
+
!node.parent && node.isLayout;
|
|
252
|
+
if (!node.isVirtual && node.isVirtualParentRequired) {
|
|
253
|
+
const parentRoutePath = removeLastSegmentFromPath(node.routePath) || "/";
|
|
254
|
+
const anchorRoute = routeNodes.find(
|
|
255
|
+
(d) => d.routePath === parentRoutePath
|
|
256
|
+
);
|
|
257
|
+
if (!anchorRoute) {
|
|
258
|
+
const parentNode = {
|
|
259
|
+
...node,
|
|
260
|
+
path: removeLastSegmentFromPath(node.path) || "/",
|
|
261
|
+
filePath: removeLastSegmentFromPath(node.filePath) || "/",
|
|
262
|
+
fullPath: removeLastSegmentFromPath(node.fullPath) || "/",
|
|
263
|
+
routePath: parentRoutePath,
|
|
264
|
+
variableName: routePathToVariable(parentRoutePath),
|
|
265
|
+
isVirtual: true,
|
|
266
|
+
isLayout: false,
|
|
267
|
+
isVirtualParentRoute: true,
|
|
268
|
+
isVirtualParentRequired: false
|
|
269
|
+
};
|
|
270
|
+
parentNode.children = parentNode.children ?? [];
|
|
271
|
+
parentNode.children.push(node);
|
|
272
|
+
node.parent = parentNode;
|
|
273
|
+
await handleNode(parentNode);
|
|
274
|
+
} else {
|
|
275
|
+
anchorRoute.children = anchorRoute.children ?? [];
|
|
276
|
+
anchorRoute.children.push(node);
|
|
277
|
+
node.parent = anchorRoute;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
230
280
|
if (node.parent) {
|
|
231
|
-
|
|
232
|
-
|
|
281
|
+
if (!node.isVirtualParentRequired) {
|
|
282
|
+
node.parent.children = node.parent.children ?? [];
|
|
283
|
+
node.parent.children.push(node);
|
|
284
|
+
}
|
|
233
285
|
} else {
|
|
234
286
|
routeTree.push(node);
|
|
235
287
|
}
|
|
@@ -381,10 +433,10 @@ async function generator(config) {
|
|
|
381
433
|
`declare module '@tanstack/react-router' {
|
|
382
434
|
interface FileRoutesByPath {
|
|
383
435
|
${routeNodes.map((routeNode) => {
|
|
384
|
-
var _a, _b;
|
|
436
|
+
var _a, _b, _c;
|
|
385
437
|
return `'${removeTrailingUnderscores(routeNode.routePath)}': {
|
|
386
438
|
preLoaderRoute: typeof ${routeNode.variableName}Import
|
|
387
|
-
parentRoute: typeof ${(
|
|
439
|
+
parentRoute: typeof ${routeNode.isVirtualParentRequired ? `${(_a = routeNode.parent) == null ? void 0 : _a.variableName}Route` : ((_b = routeNode.parent) == null ? void 0 : _b.variableName) ? `${(_c = routeNode.parent) == null ? void 0 : _c.variableName}Import` : "rootRoute"}
|
|
388
440
|
}`;
|
|
389
441
|
}).join("\n")}
|
|
390
442
|
}
|
|
@@ -418,7 +470,7 @@ async function generator(config) {
|
|
|
418
470
|
routeConfigFileContent
|
|
419
471
|
);
|
|
420
472
|
}
|
|
421
|
-
|
|
473
|
+
logger.log(
|
|
422
474
|
`✅ Processed ${routeNodes.length === 1 ? "route" : "routes"} in ${Date.now() - start}ms`
|
|
423
475
|
);
|
|
424
476
|
}
|
|
@@ -468,6 +520,16 @@ function replaceBackslash(s) {
|
|
|
468
520
|
function removeGroups(s) {
|
|
469
521
|
return s.replaceAll(routeGroupPatternRegex, "").replaceAll("//", "/");
|
|
470
522
|
}
|
|
523
|
+
function removeLastSegmentFromPath(path2 = "/") {
|
|
524
|
+
const segments = path2.split("/");
|
|
525
|
+
segments.pop();
|
|
526
|
+
return segments.join("/");
|
|
527
|
+
}
|
|
528
|
+
function removeLayoutSegments(path2 = "/") {
|
|
529
|
+
const segments = path2.split("/");
|
|
530
|
+
const newSegments = segments.filter((segment) => !segment.startsWith("_"));
|
|
531
|
+
return newSegments.join("/");
|
|
532
|
+
}
|
|
471
533
|
function hasParentRoute(routes, routePathToCheck) {
|
|
472
534
|
if (!routePathToCheck || routePathToCheck === "/") {
|
|
473
535
|
return null;
|
|
@@ -492,5 +554,6 @@ exports.generator = generator;
|
|
|
492
554
|
exports.hasParentRoute = hasParentRoute;
|
|
493
555
|
exports.multiSortBy = multiSortBy;
|
|
494
556
|
exports.removeExt = removeExt;
|
|
557
|
+
exports.removeLastSegmentFromPath = removeLastSegmentFromPath;
|
|
495
558
|
exports.rootPathId = rootPathId;
|
|
496
559
|
//# sourceMappingURL=generator.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.cjs","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'path'\nimport * as fs from 'fs'\nimport * as fsp from 'fs/promises'\nimport * as prettier from 'prettier'\nimport { Config } from './config'\nimport { cleanPath, trimPathLeft } from './utils'\n\nlet latestTask = 0\nexport const rootPathId = '__root'\nconst routeGroupPatternRegex = /\\(.+\\)/g\n\nexport type RouteNode = {\n filePath: string\n fullPath: string\n variableName: string\n routePath?: string\n cleanedPath?: string\n path?: string\n isNonPath?: boolean\n isNonLayout?: boolean\n isRoute?: boolean\n isLoader?: boolean\n isComponent?: boolean\n isErrorComponent?: boolean\n isPendingComponent?: boolean\n isVirtual?: boolean\n isLazy?: boolean\n isRoot?: boolean\n children?: RouteNode[]\n parent?: RouteNode\n}\n\nasync function getRouteNodes(config: Config) {\n const { routeFilePrefix, routeFileIgnorePrefix } = config\n\n let routeNodes: RouteNode[] = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fsp.readdir(fullDir, { withFileTypes: true })\n\n dirList = dirList.filter((d) => {\n if (\n d.name.startsWith('.') ||\n (routeFileIgnorePrefix && d.name.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.name.startsWith(routeFilePrefix)\n }\n\n return true\n })\n\n await Promise.all(\n dirList.map(async (dirent) => {\n const fullPath = path.join(fullDir, dirent.name)\n const relativePath = path.join(dir, dirent.name)\n\n if (dirent.isDirectory()) {\n await recurse(relativePath)\n } else if (fullPath.match(/\\.(tsx|ts|jsx|js)$/)) {\n const filePath = replaceBackslash(path.join(dir, dirent.name))\n const filePathNoExt = removeExt(filePath)\n let routePath =\n cleanPath(`/${filePathNoExt.split('.').join('/')}`) || ''\n\n if (routeFilePrefix) {\n routePath = routePath.replaceAll(routeFilePrefix, '')\n }\n\n const variableName = routePathToVariable(routePath)\n\n // Remove the index from the route path and\n // if the route path is empty, use `/'\n\n let isLazy = routePath?.endsWith('/lazy')\n\n if (isLazy) {\n routePath = routePath?.replace(/\\/lazy$/, '')\n }\n\n let isRoute = routePath?.endsWith('/route')\n let isComponent = routePath?.endsWith('/component')\n let isErrorComponent = routePath?.endsWith('/errorComponent')\n let isPendingComponent = routePath?.endsWith('/pendingComponent')\n let isLoader = routePath?.endsWith('/loader')\n\n ;(\n [\n [isComponent, 'component'],\n [isErrorComponent, 'errorComponent'],\n [isPendingComponent, 'pendingComponent'],\n [isLoader, 'loader'],\n ] as const\n ).forEach(([isType, type]) => {\n if (isType) {\n console.warn(\n `WARNING: The \\`.${type}.tsx\\` suffix used for the ${filePath} file is deprecated. Use the new \\`.lazy.tsx\\` suffix instead.`,\n )\n }\n })\n\n routePath = routePath?.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route|lazy)$/,\n '',\n )\n\n if (routePath === 'index') {\n routePath = '/'\n }\n\n routePath = routePath.replace(/\\/index$/, '/') || '/'\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n isRoute,\n isComponent,\n isErrorComponent,\n isPendingComponent,\n isLoader,\n isLazy,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n return routeNodes\n}\n\nlet first = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n lazy?: RouteNode\n}\n\nexport async function generator(config: Config) {\n console.log('')\n\n if (!first) {\n console.log('♻️ Generating routes...')\n first = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n console.log('♻️ Regenerating routes...')\n }\n\n const taskId = latestTask + 1\n latestTask = taskId\n\n const checkLatest = () => {\n if (latestTask !== taskId) {\n skipMessage = true\n return false\n }\n\n return true\n }\n\n const start = Date.now()\n const routePathIdPrefix = config.routeFilePrefix ?? ''\n const beforeRouteNodes = await getRouteNodes(config)\n const rootRouteNode = beforeRouteNodes.find(\n (d) => d.routePath === `/${rootPathId}`,\n )\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.filePath?.match(/[./]index[.]/) ? 1 : -1),\n (d) =>\n d.filePath?.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) => (d.filePath?.match(/[./]route[.]/) ? -1 : 1),\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: RouteNode[] = []\n const routePiecesByPath: Record<string, RouteSubNode> = {}\n\n // Loop over the flat list of routeNodes and\n // build up a tree based on the routeNodes' routePath\n let routeNodes: RouteNode[] = []\n\n const handleNode = async (node: RouteNode) => {\n const parentRoute = hasParentRoute(routeNodes, node.routePath)\n if (parentRoute) node.parent = parentRoute\n\n node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath!, '') || '/'\n : node.routePath\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath?.split('/') ?? []\n let first = split[0] ?? trimmedPath ?? ''\n\n node.isNonPath = first.startsWith('_')\n node.isNonLayout = first.endsWith('_')\n node.cleanedPath = removeGroups(removeUnderscores(node.path) ?? '')\n\n // Ensure the boilerplate for the route exists\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$') ?? '',\n )\n\n let replaced = routeCode\n\n if (!routeCode) {\n if (node.isLazy) {\n replaced = [\n `import { createLazyFileRoute } from '@tanstack/react-router'`,\n `export const Route = createLazyFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n})`,\n ].join('\\n\\n')\n } else if (\n node.isRoute ||\n (!node.isComponent &&\n !node.isErrorComponent &&\n !node.isPendingComponent &&\n !node.isLoader)\n ) {\n replaced = [\n `import { createFileRoute } from '@tanstack/react-router'`,\n `export const Route = createFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n})`,\n ].join('\\n\\n')\n }\n } else {\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createLazyFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n }\n\n if (replaced !== routeCode) {\n console.log(`🟡 Updating ${node.fullPath}`)\n await fsp.writeFile(node.fullPath, replaced)\n }\n\n if (\n !node.isVirtual &&\n (node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent ||\n node.isLazy)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLazy\n ? 'lazy'\n : node.isLoader\n ? 'loader'\n : node.isErrorComponent\n ? 'errorComponent'\n : node.isPendingComponent\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find((d) => d.routePath === node.routePath)\n\n if (!anchorRoute) {\n await handleNode({\n ...node,\n isVirtual: true,\n isLazy: false,\n isLoader: false,\n isComponent: false,\n isErrorComponent: false,\n isPendingComponent: false,\n })\n }\n return\n }\n\n if (node.parent) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n await Promise.all(preRouteNodes.map((node) => handleNode(node)))\n\n async function buildRouteConfig(\n nodes: RouteNode[],\n depth = 1,\n ): Promise<string> {\n const children = nodes.map(async (node) => {\n if (node.isRoot) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = await buildRouteConfig(node.children, depth + 1)\n return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`\n }\n\n return route\n })\n\n return (await Promise.all(children)).filter(Boolean).join(`,`)\n }\n\n const routeConfigChildrenText = await buildRouteConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(\"index'\") ? -1 : 1),\n (d) => d,\n ])\n\n const imports = Object.entries({\n createFileRoute: sortedRouteNodes.some((d) => d.isVirtual),\n lazyFn: sortedRouteNodes.some(\n (node) => routePiecesByPath[node.routePath!]?.loader,\n ),\n lazyRouteComponent: sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.component ||\n routePiecesByPath[node.routePath!]?.errorComponent ||\n routePiecesByPath[node.routePath!]?.pendingComponent,\n ),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n\n const virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual)\n\n const rootPathIdExtension =\n config.addExtensions && rootRouteNode\n ? path.extname(rootRouteNode.filePath)\n : ''\n\n const routeImports = [\n '/* prettier-ignore-start */',\n '/* eslint-disable */',\n '// @ts-nocheck',\n '// noinspection JSUnusedGlobalSymbols',\n '// This file is auto-generated by TanStack Router',\n imports.length\n ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\\n`\n : '',\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${replaceBackslash(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n `${routePathIdPrefix}${rootPathId}${rootPathIdExtension}`,\n ),\n ),\n )}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }Import } from './${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n config.addExtensions,\n ),\n )}'`\n }),\n ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }Import = createFileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}')()`\n })\n .join('\\n'),\n '// Create/Update Routes',\n sortedRouteNodes\n .map((node) => {\n const loaderNode = routePiecesByPath[node.routePath!]?.loader\n const componentNode = routePiecesByPath[node.routePath!]?.component\n const errorComponentNode =\n routePiecesByPath[node.routePath!]?.errorComponent\n const pendingComponentNode =\n routePiecesByPath[node.routePath!]?.pendingComponent\n const lazyComponentNode = routePiecesByPath[node.routePath!]?.lazy\n\n return [\n `const ${node.variableName}Route = ${node.variableName}Import.update({\n ${[\n node.isNonPath\n ? `id: '${node.path}'`\n : `path: '${node.cleanedPath}'`,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${config.disableTypes ? '' : 'as any'})`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n config.addExtensions,\n ),\n )}'), 'loader') })`\n : '',\n componentNode || errorComponentNode || pendingComponentNode\n ? `.update({\n ${(\n [\n ['component', componentNode],\n ['errorComponent', errorComponentNode],\n ['pendingComponent', pendingComponentNode],\n ] as const\n )\n .filter((d) => d[1])\n .map((d) => {\n return `${\n d[0]\n }: lazyRouteComponent(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n config.addExtensions,\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n lazyComponentNode\n ? `.lazy(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n lazyComponentNode!.filePath,\n ),\n ),\n config.addExtensions,\n ),\n )}').then((d) => d.Route))`\n : '',\n ].join('')\n })\n .join('\\n\\n'),\n ...(config.disableTypes\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${removeTrailingUnderscores(routeNode.routePath)}': {\n preLoaderRoute: typeof ${routeNode.variableName}Import\n parentRoute: typeof ${\n routeNode.parent?.variableName\n ? `${routeNode.parent?.variableName}Import`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n '// Create and export the route tree',\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\n '/* prettier-ignore-end */',\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const routeConfigFileContent = await prettier.format(routeImports, {\n semi: false,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n })\n\n const routeTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err: any) => {\n if (err.code === 'ENOENT') {\n return undefined\n }\n throw err\n })\n\n if (!checkLatest()) return\n\n if (routeTreeContent !== routeConfigFileContent) {\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fsp.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n console.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\nfunction routePathToVariable(d: string): string {\n return (\n removeUnderscores(d)\n ?.replace(/\\/\\$\\//g, '/splat/')\n ?.replace(/\\$$/g, 'splat')\n ?.replace(/\\$/g, '')\n ?.split(/[/-]/g)\n .map((d, i) => (i > 0 ? capitalize(d) : d))\n .join('')\n .replace(/([^a-zA-Z0-9]|[\\.])/gm, '')\n .replace(/^(\\d)/g, 'R$1') ?? ''\n )\n}\n\nexport function removeExt(d: string, keepExtension: boolean = false) {\n return keepExtension ? d : d.substring(0, d.lastIndexOf('.')) || d\n}\n\nfunction spaces(d: number): string {\n return Array.from({ length: d })\n .map(() => ' ')\n .join('')\n}\n\nexport function multiSortBy<T>(\n arr: T[],\n accessors: ((item: T) => any)[] = [(d) => d],\n): T[] {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n\nfunction capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nfunction removeUnderscores(s?: string) {\n return s?.replaceAll(/(^_|_$)/gi, '').replaceAll(/(\\/_|_\\/)/gi, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n}\n\nfunction replaceBackslash(s: string) {\n return s.replaceAll(/\\\\/gi, '/')\n}\n\nfunction removeGroups(s: string) {\n return s.replaceAll(routeGroupPatternRegex, '').replaceAll('//', '/')\n}\n\nexport function hasParentRoute(\n routes: RouteNode[],\n routePathToCheck: string | undefined,\n): RouteNode | null {\n if (!routePathToCheck || routePathToCheck === '/') {\n return null\n }\n\n const sortedNodes = multiSortBy(routes, [\n (d) => d.routePath!.length * -1,\n (d) => d.variableName,\n ]).filter((d) => d.routePath !== `/${rootPathId}`)\n\n for (const route of sortedNodes) {\n if (route.routePath === '/') continue\n\n if (\n routePathToCheck.startsWith(`${route.routePath}/`) &&\n route.routePath !== routePathToCheck\n ) {\n return route\n }\n }\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\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EAAE,EAAE,WAAW,MAAM,GAAG;AACtE;AAEgB,SAAA,eACd,QACA,kBACkB;AACd,MAAA,CAAC,oBAAoB,qBAAqB,KAAK;AAC1C,WAAA;AAAA,EACT;AAEM,QAAA,cAAc,YAAY,QAAQ;AAAA,IACtC,CAAC,MAAM,EAAE,UAAW,SAAS;AAAA,IAC7B,CAAC,MAAM,EAAE;AAAA,EAAA,CACV,EAAE,OAAO,CAAC,MAAM,EAAE,cAAc,IAAI,UAAU,EAAE;AAEjD,aAAW,SAAS,aAAa;AAC/B,QAAI,MAAM,cAAc;AAAK;AAG3B,QAAA,iBAAiB,WAAW,GAAG,MAAM,SAAS,GAAG,KACjD,MAAM,cAAc,kBACpB;AACO,aAAA;AAAA,IACT;AAAA,EACF;AACM,QAAA,WAAW,iBAAiB,MAAM,GAAG;AAC3C,WAAS,IAAI;AACP,QAAA,kBAAkB,SAAS,KAAK,GAAG;AAElC,SAAA,eAAe,QAAQ,eAAe;AAC/C;;;;;;"}
|
|
1
|
+
{"version":3,"file":"generator.cjs","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'path'\nimport * as fs from 'fs'\nimport * as fsp from 'fs/promises'\nimport * as prettier from 'prettier'\nimport { Config } from './config'\nimport { cleanPath, logging, trimPathLeft } from './utils'\n\nlet latestTask = 0\nexport const rootPathId = '__root'\nconst routeGroupPatternRegex = /\\(.+\\)/g\n\nexport type RouteNode = {\n filePath: string\n fullPath: string\n variableName: string\n routePath?: string\n cleanedPath?: string\n path?: string\n isNonPath?: boolean\n isNonLayout?: boolean\n isLayout?: boolean\n isVirtualParentRequired?: boolean\n isVirtualParentRoute?: boolean\n isRoute?: boolean\n isLoader?: boolean\n isComponent?: boolean\n isErrorComponent?: boolean\n isPendingComponent?: boolean\n isVirtual?: boolean\n isLazy?: boolean\n isRoot?: boolean\n children?: RouteNode[]\n parent?: RouteNode\n}\n\nasync function getRouteNodes(config: Config) {\n const { routeFilePrefix, routeFileIgnorePrefix } = config\n const logger = logging({ disabled: config.disableLogging })\n\n let routeNodes: RouteNode[] = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fsp.readdir(fullDir, { withFileTypes: true })\n\n dirList = dirList.filter((d) => {\n if (\n d.name.startsWith('.') ||\n (routeFileIgnorePrefix && d.name.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.name.startsWith(routeFilePrefix)\n }\n\n return true\n })\n\n await Promise.all(\n dirList.map(async (dirent) => {\n const fullPath = path.join(fullDir, dirent.name)\n const relativePath = path.join(dir, dirent.name)\n\n if (dirent.isDirectory()) {\n await recurse(relativePath)\n } else if (fullPath.match(/\\.(tsx|ts|jsx|js)$/)) {\n const filePath = replaceBackslash(path.join(dir, dirent.name))\n const filePathNoExt = removeExt(filePath)\n let routePath =\n cleanPath(`/${filePathNoExt.split('.').join('/')}`) || ''\n\n if (routeFilePrefix) {\n routePath = routePath.replaceAll(routeFilePrefix, '')\n }\n\n const variableName = routePathToVariable(routePath)\n\n // Remove the index from the route path and\n // if the route path is empty, use `/'\n\n let isLazy = routePath?.endsWith('/lazy')\n\n if (isLazy) {\n routePath = routePath?.replace(/\\/lazy$/, '')\n }\n\n let isRoute = routePath?.endsWith('/route')\n let isComponent = routePath?.endsWith('/component')\n let isErrorComponent = routePath?.endsWith('/errorComponent')\n let isPendingComponent = routePath?.endsWith('/pendingComponent')\n let isLoader = routePath?.endsWith('/loader')\n\n const segments = (routePath ?? '').split('/')\n let isLayout = segments[segments.length - 1]?.startsWith('_') || false\n\n ;(\n [\n [isComponent, 'component'],\n [isErrorComponent, 'errorComponent'],\n [isPendingComponent, 'pendingComponent'],\n [isLoader, 'loader'],\n ] as const\n ).forEach(([isType, type]) => {\n if (isType) {\n logger.warn(\n `WARNING: The \\`.${type}.tsx\\` suffix used for the ${filePath} file is deprecated. Use the new \\`.lazy.tsx\\` suffix instead.`,\n )\n }\n })\n\n routePath = routePath?.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route|lazy)$/,\n '',\n )\n\n if (routePath === 'index') {\n routePath = '/'\n }\n\n routePath = routePath.replace(/\\/index$/, '/') || '/'\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n isRoute,\n isComponent,\n isErrorComponent,\n isPendingComponent,\n isLoader,\n isLazy,\n isLayout,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n return routeNodes\n}\n\nlet first = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n lazy?: RouteNode\n}\n\nexport async function generator(config: Config) {\n const logger = logging({ disabled: config.disableLogging })\n logger.log('')\n\n if (!first) {\n logger.log('♻️ Generating routes...')\n first = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n logger.log('♻️ Regenerating routes...')\n }\n\n const taskId = latestTask + 1\n latestTask = taskId\n\n const checkLatest = () => {\n if (latestTask !== taskId) {\n skipMessage = true\n return false\n }\n\n return true\n }\n\n const start = Date.now()\n const routePathIdPrefix = config.routeFilePrefix ?? ''\n const beforeRouteNodes = await getRouteNodes(config)\n const rootRouteNode = beforeRouteNodes.find(\n (d) => d.routePath === `/${rootPathId}`,\n )\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.filePath?.match(/[./]index[.]/) ? 1 : -1),\n (d) =>\n d.filePath?.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) => (d.filePath?.match(/[./]route[.]/) ? -1 : 1),\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: RouteNode[] = []\n const routePiecesByPath: Record<string, RouteSubNode> = {}\n\n // Loop over the flat list of routeNodes and\n // build up a tree based on the routeNodes' routePath\n let routeNodes: RouteNode[] = []\n\n const handleNode = async (node: RouteNode) => {\n let parentRoute = hasParentRoute(routeNodes, node.routePath)\n\n // if the parent route is a virtual parent route, we need to find the real parent route\n if (parentRoute?.isVirtualParentRoute && parentRoute.children?.length) {\n // only if this sub-parent route returns a valid parent route, we use it, if not leave it as it\n const possibleParentRoute = hasParentRoute(\n parentRoute.children,\n node.routePath,\n )\n if (possibleParentRoute) {\n parentRoute = possibleParentRoute\n }\n }\n\n if (parentRoute) node.parent = parentRoute\n\n node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath!, '') || '/'\n : node.routePath\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath?.split('/') ?? []\n let first = split[0] ?? trimmedPath ?? ''\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath ?? ''\n\n node.isNonPath = lastRouteSegment.startsWith('_')\n node.isNonLayout = first.endsWith('_')\n\n node.cleanedPath = removeGroups(\n removeUnderscores(removeLayoutSegments(node.path)) ?? '',\n )\n\n // Ensure the boilerplate for the route exists, which can be skipped for virtual parent routes\n if (!node.isVirtualParentRoute) {\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$') ?? '',\n )\n\n let replaced = routeCode\n\n if (!routeCode) {\n if (node.isLazy) {\n replaced = [\n `import { createLazyFileRoute } from '@tanstack/react-router'`,\n `export const Route = createLazyFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n })`,\n ].join('\\n\\n')\n } else if (\n node.isRoute ||\n (!node.isComponent &&\n !node.isErrorComponent &&\n !node.isPendingComponent &&\n !node.isLoader)\n ) {\n replaced = [\n `import { createFileRoute } from '@tanstack/react-router'`,\n `export const Route = createFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n })`,\n ].join('\\n\\n')\n }\n } else {\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createLazyFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n }\n\n if (replaced !== routeCode) {\n logger.log(`🟡 Updating ${node.fullPath}`)\n await fsp.writeFile(node.fullPath, replaced)\n }\n }\n\n if (\n !node.isVirtual &&\n (node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent ||\n node.isLazy)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLazy\n ? 'lazy'\n : node.isLoader\n ? 'loader'\n : node.isErrorComponent\n ? 'errorComponent'\n : node.isPendingComponent\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find((d) => d.routePath === node.routePath)\n\n if (!anchorRoute) {\n await handleNode({\n ...node,\n isVirtual: true,\n isLazy: false,\n isLoader: false,\n isComponent: false,\n isErrorComponent: false,\n isPendingComponent: false,\n })\n }\n return\n }\n\n node.isVirtualParentRequired =\n removeGroups(node.path ?? '')\n .split('')\n .filter((char) => char === '/').length >= 2 && // check that the parent route wouldn't be the root route\n !node.parent &&\n node.isLayout\n\n if (!node.isVirtual && node.isVirtualParentRequired) {\n const parentRoutePath = removeLastSegmentFromPath(node.routePath) || '/'\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === parentRoutePath,\n )\n\n if (!anchorRoute) {\n const parentNode = {\n ...node,\n path: removeLastSegmentFromPath(node.path) || '/',\n filePath: removeLastSegmentFromPath(node.filePath) || '/',\n fullPath: removeLastSegmentFromPath(node.fullPath) || '/',\n routePath: parentRoutePath,\n variableName: routePathToVariable(parentRoutePath),\n isVirtual: true,\n isLayout: false,\n isVirtualParentRoute: true,\n isVirtualParentRequired: false,\n }\n\n parentNode.children = parentNode.children ?? []\n parentNode.children.push(node)\n\n node.parent = parentNode\n\n await handleNode(parentNode)\n } else {\n anchorRoute.children = anchorRoute.children ?? []\n anchorRoute.children.push(node)\n\n node.parent = anchorRoute\n }\n }\n\n if (node.parent) {\n if (!node.isVirtualParentRequired) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n }\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n await Promise.all(preRouteNodes.map((node) => handleNode(node)))\n\n async function buildRouteConfig(\n nodes: RouteNode[],\n depth = 1,\n ): Promise<string> {\n const children = nodes.map(async (node) => {\n if (node.isRoot) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = await buildRouteConfig(node.children, depth + 1)\n return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`\n }\n\n return route\n })\n\n return (await Promise.all(children)).filter(Boolean).join(`,`)\n }\n\n const routeConfigChildrenText = await buildRouteConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(\"index'\") ? -1 : 1),\n (d) => d,\n ])\n\n const imports = Object.entries({\n createFileRoute: sortedRouteNodes.some((d) => d.isVirtual),\n lazyFn: sortedRouteNodes.some(\n (node) => routePiecesByPath[node.routePath!]?.loader,\n ),\n lazyRouteComponent: sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.component ||\n routePiecesByPath[node.routePath!]?.errorComponent ||\n routePiecesByPath[node.routePath!]?.pendingComponent,\n ),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n\n const virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual)\n\n const rootPathIdExtension =\n config.addExtensions && rootRouteNode\n ? path.extname(rootRouteNode.filePath)\n : ''\n\n const routeImports = [\n '/* prettier-ignore-start */',\n '/* eslint-disable */',\n '// @ts-nocheck',\n '// noinspection JSUnusedGlobalSymbols',\n '// This file is auto-generated by TanStack Router',\n imports.length\n ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\\n`\n : '',\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${replaceBackslash(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n `${routePathIdPrefix}${rootPathId}${rootPathIdExtension}`,\n ),\n ),\n )}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }Import } from './${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n config.addExtensions,\n ),\n )}'`\n }),\n ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }Import = createFileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}')()`\n })\n .join('\\n'),\n '// Create/Update Routes',\n sortedRouteNodes\n .map((node) => {\n const loaderNode = routePiecesByPath[node.routePath!]?.loader\n const componentNode = routePiecesByPath[node.routePath!]?.component\n const errorComponentNode =\n routePiecesByPath[node.routePath!]?.errorComponent\n const pendingComponentNode =\n routePiecesByPath[node.routePath!]?.pendingComponent\n const lazyComponentNode = routePiecesByPath[node.routePath!]?.lazy\n\n return [\n `const ${node.variableName}Route = ${node.variableName}Import.update({\n ${[\n node.isNonPath\n ? `id: '${node.path}'`\n : `path: '${node.cleanedPath}'`,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${config.disableTypes ? '' : 'as any'})`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n config.addExtensions,\n ),\n )}'), 'loader') })`\n : '',\n componentNode || errorComponentNode || pendingComponentNode\n ? `.update({\n ${(\n [\n ['component', componentNode],\n ['errorComponent', errorComponentNode],\n ['pendingComponent', pendingComponentNode],\n ] as const\n )\n .filter((d) => d[1])\n .map((d) => {\n return `${\n d[0]\n }: lazyRouteComponent(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n config.addExtensions,\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n lazyComponentNode\n ? `.lazy(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n lazyComponentNode!.filePath,\n ),\n ),\n config.addExtensions,\n ),\n )}').then((d) => d.Route))`\n : '',\n ].join('')\n })\n .join('\\n\\n'),\n ...(config.disableTypes\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${removeTrailingUnderscores(routeNode.routePath)}': {\n preLoaderRoute: typeof ${routeNode.variableName}Import\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent?.variableName}Import`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n '// Create and export the route tree',\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\n '/* prettier-ignore-end */',\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const routeConfigFileContent = await prettier.format(routeImports, {\n semi: false,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n })\n\n const routeTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err: any) => {\n if (err.code === 'ENOENT') {\n return undefined\n }\n throw err\n })\n\n if (!checkLatest()) return\n\n if (routeTreeContent !== routeConfigFileContent) {\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fsp.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n logger.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\nfunction routePathToVariable(d: string): string {\n return (\n removeUnderscores(d)\n ?.replace(/\\/\\$\\//g, '/splat/')\n ?.replace(/\\$$/g, 'splat')\n ?.replace(/\\$/g, '')\n ?.split(/[/-]/g)\n .map((d, i) => (i > 0 ? capitalize(d) : d))\n .join('')\n .replace(/([^a-zA-Z0-9]|[\\.])/gm, '')\n .replace(/^(\\d)/g, 'R$1') ?? ''\n )\n}\n\nexport function removeExt(d: string, keepExtension: boolean = false) {\n return keepExtension ? d : d.substring(0, d.lastIndexOf('.')) || d\n}\n\nfunction spaces(d: number): string {\n return Array.from({ length: d })\n .map(() => ' ')\n .join('')\n}\n\nexport function multiSortBy<T>(\n arr: T[],\n accessors: ((item: T) => any)[] = [(d) => d],\n): T[] {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n\nfunction capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nfunction removeUnderscores(s?: string) {\n return s?.replaceAll(/(^_|_$)/gi, '').replaceAll(/(\\/_|_\\/)/gi, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n}\n\nfunction replaceBackslash(s: string) {\n return s.replaceAll(/\\\\/gi, '/')\n}\n\nfunction removeGroups(s: string) {\n return s.replaceAll(routeGroupPatternRegex, '').replaceAll('//', '/')\n}\n\n/**\n * Removes the last segment from a given path. Segments are considered to be separated by a '/'.\n *\n * @param {string} path - The path from which to remove the last segment. Defaults to '/'.\n * @returns {string} The path with the last segment removed.\n * @example\n * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'\n */\nexport function removeLastSegmentFromPath(path: string = '/'): string {\n const segments = path.split('/')\n segments.pop() // Remove the last segment\n return segments.join('/')\n}\n\n/**\n * Removes all segments from a given path that start with an underscore ('_').\n *\n * @param {string} path - The path from which to remove segments. Defaults to '/'.\n * @returns {string} The path with all underscore-prefixed segments removed.\n * @example\n * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'\n */\nfunction removeLayoutSegments(path: string = '/'): string {\n const segments = path.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\n}\n\nexport function hasParentRoute(\n routes: RouteNode[],\n routePathToCheck: string | undefined,\n): RouteNode | null {\n if (!routePathToCheck || routePathToCheck === '/') {\n return null\n }\n\n const sortedNodes = multiSortBy(routes, [\n (d) => d.routePath!.length * -1,\n (d) => d.variableName,\n ]).filter((d) => d.routePath !== `/${rootPathId}`)\n\n for (const route of sortedNodes) {\n if (route.routePath === '/') continue\n\n if (\n routePathToCheck.startsWith(`${route.routePath}/`) &&\n route.routePath !== routePathToCheck\n ) {\n return route\n }\n }\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, parentRoutePath)\n}\n"],"names":["logging","fsp","cleanPath","trimPathLeft","first","fs","prettier","d","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAI,aAAa;AACV,MAAM,aAAa;AAC1B,MAAM,yBAAyB;AA0B/B,eAA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iBAAiB,GAAW;AAC5B,SAAA,EAAE,WAAW,QAAQ,GAAG;AACjC;AAEA,SAAS,aAAa,GAAW;AAC/B,SAAO,EAAE,WAAW,wBAAwB,EAAE,EAAE,WAAW,MAAM,GAAG;AACtE;AAUgB,SAAA,0BAA0BC,QAAe,KAAa;AAC9D,QAAA,WAAWA,MAAK,MAAM,GAAG;AAC/B,WAAS,IAAI;AACN,SAAA,SAAS,KAAK,GAAG;AAC1B;AAUA,SAAS,qBAAqBA,QAAe,KAAa;AAClD,QAAA,WAAWA,MAAK,MAAM,GAAG;AACzB,QAAA,cAAc,SAAS,OAAO,CAAC,YAAY,CAAC,QAAQ,WAAW,GAAG,CAAC;AAClE,SAAA,YAAY,KAAK,GAAG;AAC7B;AAEgB,SAAA,eACd,QACA,kBACkB;AACd,MAAA,CAAC,oBAAoB,qBAAqB,KAAK;AAC1C,WAAA;AAAA,EACT;AAEM,QAAA,cAAc,YAAY,QAAQ;AAAA,IACtC,CAAC,MAAM,EAAE,UAAW,SAAS;AAAA,IAC7B,CAAC,MAAM,EAAE;AAAA,EAAA,CACV,EAAE,OAAO,CAAC,MAAM,EAAE,cAAc,IAAI,UAAU,EAAE;AAEjD,aAAW,SAAS,aAAa;AAC/B,QAAI,MAAM,cAAc;AAAK;AAG3B,QAAA,iBAAiB,WAAW,GAAG,MAAM,SAAS,GAAG,KACjD,MAAM,cAAc,kBACpB;AACO,aAAA;AAAA,IACT;AAAA,EACF;AACM,QAAA,WAAW,iBAAiB,MAAM,GAAG;AAC3C,WAAS,IAAI;AACP,QAAA,kBAAkB,SAAS,KAAK,GAAG;AAElC,SAAA,eAAe,QAAQ,eAAe;AAC/C;;;;;;;"}
|
package/dist/cjs/generator.d.cts
CHANGED
|
@@ -9,6 +9,9 @@ export type RouteNode = {
|
|
|
9
9
|
path?: string;
|
|
10
10
|
isNonPath?: boolean;
|
|
11
11
|
isNonLayout?: boolean;
|
|
12
|
+
isLayout?: boolean;
|
|
13
|
+
isVirtualParentRequired?: boolean;
|
|
14
|
+
isVirtualParentRoute?: boolean;
|
|
12
15
|
isRoute?: boolean;
|
|
13
16
|
isLoader?: boolean;
|
|
14
17
|
isComponent?: boolean;
|
|
@@ -23,4 +26,13 @@ export type RouteNode = {
|
|
|
23
26
|
export declare function generator(config: Config): Promise<void>;
|
|
24
27
|
export declare function removeExt(d: string, keepExtension?: boolean): string;
|
|
25
28
|
export declare function multiSortBy<T>(arr: T[], accessors?: ((item: T) => any)[]): T[];
|
|
29
|
+
/**
|
|
30
|
+
* Removes the last segment from a given path. Segments are considered to be separated by a '/'.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} path - The path from which to remove the last segment. Defaults to '/'.
|
|
33
|
+
* @returns {string} The path with the last segment removed.
|
|
34
|
+
* @example
|
|
35
|
+
* removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'
|
|
36
|
+
*/
|
|
37
|
+
export declare function removeLastSegmentFromPath(path?: string): string;
|
|
26
38
|
export declare function hasParentRoute(routes: RouteNode[], routePathToCheck: string | undefined): RouteNode | null;
|
package/dist/cjs/utils.cjs
CHANGED
|
@@ -6,6 +6,31 @@ function cleanPath(path) {
|
|
|
6
6
|
function trimPathLeft(path) {
|
|
7
7
|
return path === "/" ? path : path.replace(/^\/{1,}/, "");
|
|
8
8
|
}
|
|
9
|
+
function logging(config) {
|
|
10
|
+
return {
|
|
11
|
+
log: (...args) => {
|
|
12
|
+
if (!config.disabled)
|
|
13
|
+
console.log(...args);
|
|
14
|
+
},
|
|
15
|
+
debug: (...args) => {
|
|
16
|
+
if (!config.disabled)
|
|
17
|
+
console.debug(...args);
|
|
18
|
+
},
|
|
19
|
+
info: (...args) => {
|
|
20
|
+
if (!config.disabled)
|
|
21
|
+
console.info(...args);
|
|
22
|
+
},
|
|
23
|
+
warn: (...args) => {
|
|
24
|
+
if (!config.disabled)
|
|
25
|
+
console.warn(...args);
|
|
26
|
+
},
|
|
27
|
+
error: (...args) => {
|
|
28
|
+
if (!config.disabled)
|
|
29
|
+
console.error(...args);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
9
33
|
exports.cleanPath = cleanPath;
|
|
34
|
+
exports.logging = logging;
|
|
10
35
|
exports.trimPathLeft = trimPathLeft;
|
|
11
36
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/cjs/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["export function cleanPath(path: string) {\n // remove double slashes\n return path.replace(/\\/{2,}/g, '/')\n}\n\nexport function trimPathLeft(path: string) {\n return path === '/' ? path : path.replace(/^\\/{1,}/, '')\n}\n"],"names":[],"mappings":";;AAAO,SAAS,UAAU,MAAc;AAE/B,SAAA,KAAK,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,aAAa,MAAc;AACzC,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EAAE;AACzD
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["export function cleanPath(path: string) {\n // remove double slashes\n return path.replace(/\\/{2,}/g, '/')\n}\n\nexport function trimPathLeft(path: string) {\n return path === '/' ? path : path.replace(/^\\/{1,}/, '')\n}\n\nexport function logging(config: { disabled: boolean }) {\n return {\n log: (...args: any[]) => {\n if (!config.disabled) console.log(...args)\n },\n debug: (...args: any[]) => {\n if (!config.disabled) console.debug(...args)\n },\n info: (...args: any[]) => {\n if (!config.disabled) console.info(...args)\n },\n warn: (...args: any[]) => {\n if (!config.disabled) console.warn(...args)\n },\n error: (...args: any[]) => {\n if (!config.disabled) console.error(...args)\n },\n }\n}\n"],"names":[],"mappings":";;AAAO,SAAS,UAAU,MAAc;AAE/B,SAAA,KAAK,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,aAAa,MAAc;AACzC,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EAAE;AACzD;AAEO,SAAS,QAAQ,QAA+B;AAC9C,SAAA;AAAA,IACL,KAAK,IAAI,SAAgB;AACvB,UAAI,CAAC,OAAO;AAAkB,gBAAA,IAAI,GAAG,IAAI;AAAA,IAC3C;AAAA,IACA,OAAO,IAAI,SAAgB;AACzB,UAAI,CAAC,OAAO;AAAkB,gBAAA,MAAM,GAAG,IAAI;AAAA,IAC7C;AAAA,IACA,MAAM,IAAI,SAAgB;AACxB,UAAI,CAAC,OAAO;AAAkB,gBAAA,KAAK,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA,MAAM,IAAI,SAAgB;AACxB,UAAI,CAAC,OAAO;AAAkB,gBAAA,KAAK,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA,OAAO,IAAI,SAAgB;AACzB,UAAI,CAAC,OAAO;AAAkB,gBAAA,MAAM,GAAG,IAAI;AAAA,IAC7C;AAAA,EAAA;AAEJ;;;;"}
|
package/dist/cjs/utils.d.cts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
export declare function cleanPath(path: string): string;
|
|
2
2
|
export declare function trimPathLeft(path: string): string;
|
|
3
|
+
export declare function logging(config: {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
}): {
|
|
6
|
+
log: (...args: any[]) => void;
|
|
7
|
+
debug: (...args: any[]) => void;
|
|
8
|
+
info: (...args: any[]) => void;
|
|
9
|
+
warn: (...args: any[]) => void;
|
|
10
|
+
error: (...args: any[]) => void;
|
|
11
|
+
};
|
package/dist/esm/config.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
7
7
|
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<["single", "double"]>>>;
|
|
8
8
|
disableTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
9
9
|
addExtensions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
10
|
+
disableLogging: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
10
11
|
}, "strip", z.ZodTypeAny, {
|
|
11
12
|
routeFileIgnorePrefix: string;
|
|
12
13
|
routesDirectory: string;
|
|
@@ -14,6 +15,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
14
15
|
quoteStyle: "single" | "double";
|
|
15
16
|
disableTypes: boolean;
|
|
16
17
|
addExtensions: boolean;
|
|
18
|
+
disableLogging: boolean;
|
|
17
19
|
routeFilePrefix?: string | undefined;
|
|
18
20
|
}, {
|
|
19
21
|
routeFilePrefix?: string | undefined;
|
|
@@ -23,6 +25,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
23
25
|
quoteStyle?: "single" | "double" | undefined;
|
|
24
26
|
disableTypes?: boolean | undefined;
|
|
25
27
|
addExtensions?: boolean | undefined;
|
|
28
|
+
disableLogging?: boolean | undefined;
|
|
26
29
|
}>;
|
|
27
30
|
export type Config = z.infer<typeof configSchema>;
|
|
28
31
|
export declare function getConfig(inlineConfig?: Partial<Config>, configDirectory?: string): Promise<Config>;
|
package/dist/esm/config.js
CHANGED
|
@@ -8,7 +8,8 @@ const configSchema = z.object({
|
|
|
8
8
|
generatedRouteTree: z.string().optional().default("./src/routeTree.gen.ts"),
|
|
9
9
|
quoteStyle: z.enum(["single", "double"]).optional().default("single"),
|
|
10
10
|
disableTypes: z.boolean().optional().default(false),
|
|
11
|
-
addExtensions: z.boolean().optional().default(false)
|
|
11
|
+
addExtensions: z.boolean().optional().default(false),
|
|
12
|
+
disableLogging: z.boolean().optional().default(false)
|
|
12
13
|
});
|
|
13
14
|
async function getConfig(inlineConfig = {}, configDirectory) {
|
|
14
15
|
if (configDirectory === void 0) {
|
package/dist/esm/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import path from 'path'\nimport { readFileSync, existsSync } from 'fs'\nimport { z } from 'zod'\n\nexport const configSchema = z.object({\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routesDirectory: z.string().optional().default('./src/routes'),\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n disableTypes: z.boolean().optional().default(false),\n addExtensions: z.boolean().optional().default(false),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nexport async function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Promise<Config> {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = path.resolve(configDirectory, 'tsr.config.json')\n const exists = existsSync(configFilePathJson)\n\n let config: Config\n\n if (exists) {\n config = configSchema.parse({\n ...JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n ...inlineConfig,\n })\n } else {\n config = configSchema.parse(inlineConfig)\n }\n\n // If typescript is disabled, make sure the generated route tree is a .js file\n if (config.disableTypes) {\n config.generatedRouteTree = config.generatedRouteTree.replace(\n /\\.(ts|tsx)$/,\n '.js',\n )\n }\n\n return config\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,eAAe,EAAE,OAAO;AAAA,EACnC,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,uBAAuB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,GAAG;AAAA,EACxD,iBAAiB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,cAAc;AAAA,EAC7D,oBAAoB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,wBAAwB;AAAA,EAC1E,YAAY,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC,EAAE,SAAA,EAAW,QAAQ,QAAQ;AAAA,EACpE,cAAc,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EAClD,eAAe,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import path from 'path'\nimport { readFileSync, existsSync } from 'fs'\nimport { z } from 'zod'\n\nexport const configSchema = z.object({\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routesDirectory: z.string().optional().default('./src/routes'),\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n disableTypes: z.boolean().optional().default(false),\n addExtensions: z.boolean().optional().default(false),\n disableLogging: z.boolean().optional().default(false),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nexport async function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Promise<Config> {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = path.resolve(configDirectory, 'tsr.config.json')\n const exists = existsSync(configFilePathJson)\n\n let config: Config\n\n if (exists) {\n config = configSchema.parse({\n ...JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n ...inlineConfig,\n })\n } else {\n config = configSchema.parse(inlineConfig)\n }\n\n // If typescript is disabled, make sure the generated route tree is a .js file\n if (config.disableTypes) {\n config.generatedRouteTree = config.generatedRouteTree.replace(\n /\\.(ts|tsx)$/,\n '.js',\n )\n }\n\n return config\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,eAAe,EAAE,OAAO;AAAA,EACnC,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,uBAAuB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,GAAG;AAAA,EACxD,iBAAiB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,cAAc;AAAA,EAC7D,oBAAoB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,wBAAwB;AAAA,EAC1E,YAAY,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC,EAAE,SAAA,EAAW,QAAQ,QAAQ;AAAA,EACpE,cAAc,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EAClD,eAAe,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EACnD,gBAAgB,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AACtD,CAAC;AAID,eAAsB,UACpB,eAAgC,CAAC,GACjC,iBACiB;AACjB,MAAI,oBAAoB,QAAW;AACjC,sBAAkB,QAAQ;EAC5B;AACA,QAAM,qBAAqB,KAAK,QAAQ,iBAAiB,iBAAiB;AACpE,QAAA,SAAS,WAAW,kBAAkB;AAExC,MAAA;AAEJ,MAAI,QAAQ;AACV,aAAS,aAAa,MAAM;AAAA,MAC1B,GAAG,KAAK,MAAM,aAAa,oBAAoB,OAAO,CAAC;AAAA,MACvD,GAAG;AAAA,IAAA,CACJ;AAAA,EAAA,OACI;AACI,aAAA,aAAa,MAAM,YAAY;AAAA,EAC1C;AAGA,MAAI,OAAO,cAAc;AAChB,WAAA,qBAAqB,OAAO,mBAAmB;AAAA,MACpD;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AACT;"}
|
package/dist/esm/generator.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export type RouteNode = {
|
|
|
9
9
|
path?: string;
|
|
10
10
|
isNonPath?: boolean;
|
|
11
11
|
isNonLayout?: boolean;
|
|
12
|
+
isLayout?: boolean;
|
|
13
|
+
isVirtualParentRequired?: boolean;
|
|
14
|
+
isVirtualParentRoute?: boolean;
|
|
12
15
|
isRoute?: boolean;
|
|
13
16
|
isLoader?: boolean;
|
|
14
17
|
isComponent?: boolean;
|
|
@@ -23,4 +26,13 @@ export type RouteNode = {
|
|
|
23
26
|
export declare function generator(config: Config): Promise<void>;
|
|
24
27
|
export declare function removeExt(d: string, keepExtension?: boolean): string;
|
|
25
28
|
export declare function multiSortBy<T>(arr: T[], accessors?: ((item: T) => any)[]): T[];
|
|
29
|
+
/**
|
|
30
|
+
* Removes the last segment from a given path. Segments are considered to be separated by a '/'.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} path - The path from which to remove the last segment. Defaults to '/'.
|
|
33
|
+
* @returns {string} The path with the last segment removed.
|
|
34
|
+
* @example
|
|
35
|
+
* removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'
|
|
36
|
+
*/
|
|
37
|
+
export declare function removeLastSegmentFromPath(path?: string): string;
|
|
26
38
|
export declare function hasParentRoute(routes: RouteNode[], routePathToCheck: string | undefined): RouteNode | null;
|