@tanstack/router-generator 1.5.4
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/LICENSE +21 -0
- package/build/cjs/config.js +35 -0
- package/build/cjs/config.js.map +1 -0
- package/build/cjs/generator.js +318 -0
- package/build/cjs/generator.js.map +1 -0
- package/build/cjs/index.js +21 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/utils.js +23 -0
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +316 -0
- package/build/esm/index.js.map +1 -0
- package/build/types/index.d.ts +37 -0
- package/package.json +43 -0
- package/src/config.ts +27 -0
- package/src/generator.ts +559 -0
- package/src/index.ts +2 -0
- package/src/utils.ts +8 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tanstack/router-generator/src/index.ts
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) TanStack
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import { existsSync, readFileSync } from 'fs';
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import * as fs from 'fs/promises';
|
|
15
|
+
import * as prettier from 'prettier';
|
|
16
|
+
|
|
17
|
+
const configSchema = z.object({
|
|
18
|
+
routeFilePrefix: z.string().optional(),
|
|
19
|
+
routeFileIgnorePrefix: z.string().optional().default('-'),
|
|
20
|
+
routesDirectory: z.string().optional().default('./src/routes'),
|
|
21
|
+
generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),
|
|
22
|
+
quoteStyle: z.enum(['single', 'double']).optional().default('single')
|
|
23
|
+
});
|
|
24
|
+
const configFilePathJson = path.resolve(process.cwd(), 'tsr.config.json');
|
|
25
|
+
async function getConfig() {
|
|
26
|
+
const exists = existsSync(configFilePathJson);
|
|
27
|
+
if (exists) {
|
|
28
|
+
return configSchema.parse(JSON.parse(readFileSync(configFilePathJson, 'utf-8')));
|
|
29
|
+
}
|
|
30
|
+
return configSchema.parse({});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function cleanPath(path) {
|
|
34
|
+
// remove double slashes
|
|
35
|
+
return path.replace(/\/{2,}/g, '/');
|
|
36
|
+
}
|
|
37
|
+
function trimPathLeft(path) {
|
|
38
|
+
return path === '/' ? path : path.replace(/^\/{1,}/, '');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let latestTask = 0;
|
|
42
|
+
const rootPathId = '__root';
|
|
43
|
+
const fileRouteRegex = /new\s+FileRoute\(([^)]*)\)/g;
|
|
44
|
+
async function getRouteNodes(config) {
|
|
45
|
+
const {
|
|
46
|
+
routeFilePrefix,
|
|
47
|
+
routeFileIgnorePrefix
|
|
48
|
+
} = config;
|
|
49
|
+
let routeNodes = [];
|
|
50
|
+
async function recurse(dir) {
|
|
51
|
+
const fullDir = path.resolve(config.routesDirectory, dir);
|
|
52
|
+
let dirList = await fs.readdir(fullDir, {
|
|
53
|
+
withFileTypes: true
|
|
54
|
+
});
|
|
55
|
+
dirList = dirList.filter(d => {
|
|
56
|
+
if (d.name.startsWith('.') || routeFileIgnorePrefix && d.name.startsWith(routeFileIgnorePrefix)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (routeFilePrefix) {
|
|
60
|
+
return d.name.startsWith(routeFilePrefix);
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
});
|
|
64
|
+
await Promise.all(dirList.map(async dirent => {
|
|
65
|
+
const fullPath = path.join(fullDir, dirent.name);
|
|
66
|
+
const relativePath = path.join(dir, dirent.name);
|
|
67
|
+
if (dirent.isDirectory()) {
|
|
68
|
+
await recurse(relativePath);
|
|
69
|
+
} else if (fullPath.match(/\.(tsx|ts|jsx|js)$/)) {
|
|
70
|
+
const filePath = replaceBackslash(path.join(dir, dirent.name));
|
|
71
|
+
const filePathNoExt = removeExt(filePath);
|
|
72
|
+
let routePath = cleanPath(`/${filePathNoExt.split('.').join('/')}`) || '';
|
|
73
|
+
const variableName = routePathToVariable(routePath);
|
|
74
|
+
|
|
75
|
+
// Remove the index from the route path and
|
|
76
|
+
// if the route path is empty, use `/'
|
|
77
|
+
|
|
78
|
+
let isRoute = routePath?.endsWith('/route');
|
|
79
|
+
let isComponent = routePath?.endsWith('/component');
|
|
80
|
+
let isErrorComponent = routePath?.endsWith('/errorComponent');
|
|
81
|
+
let isPendingComponent = routePath?.endsWith('/pendingComponent');
|
|
82
|
+
let isLoader = routePath?.endsWith('/loader');
|
|
83
|
+
routePath = routePath?.replace(/\/(component|errorComponent|pendingComponent|loader|route)$/, '');
|
|
84
|
+
if (routePath === 'index') {
|
|
85
|
+
routePath = '/';
|
|
86
|
+
}
|
|
87
|
+
routePath = routePath.replace(/\/index$/, '/') || '/';
|
|
88
|
+
routeNodes.push({
|
|
89
|
+
filePath,
|
|
90
|
+
fullPath,
|
|
91
|
+
routePath,
|
|
92
|
+
variableName,
|
|
93
|
+
isRoute,
|
|
94
|
+
isComponent,
|
|
95
|
+
isErrorComponent,
|
|
96
|
+
isPendingComponent,
|
|
97
|
+
isLoader
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}));
|
|
101
|
+
return routeNodes;
|
|
102
|
+
}
|
|
103
|
+
await recurse('./');
|
|
104
|
+
return routeNodes;
|
|
105
|
+
}
|
|
106
|
+
let first = false;
|
|
107
|
+
let skipMessage = false;
|
|
108
|
+
async function generator(config) {
|
|
109
|
+
console.log();
|
|
110
|
+
if (!first) {
|
|
111
|
+
console.log('🔄 Generating routes...');
|
|
112
|
+
first = true;
|
|
113
|
+
} else if (skipMessage) {
|
|
114
|
+
skipMessage = false;
|
|
115
|
+
} else {
|
|
116
|
+
console.log('♻️ Regenerating routes...');
|
|
117
|
+
}
|
|
118
|
+
const taskId = latestTask + 1;
|
|
119
|
+
latestTask = taskId;
|
|
120
|
+
const checkLatest = () => {
|
|
121
|
+
if (latestTask !== taskId) {
|
|
122
|
+
skipMessage = true;
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
};
|
|
127
|
+
const start = Date.now();
|
|
128
|
+
const routePathIdPrefix = config.routeFilePrefix ?? '';
|
|
129
|
+
const preRouteNodes = multiSortBy(await getRouteNodes(config), [d => d.routePath === '/' ? -1 : 1, d => d.routePath?.split('/').length, d => d.filePath?.match(/[./]index[.]/) ? 1 : -1, d => d.filePath?.match(/[./](component|errorComponent|pendingComponent|loader)[.]/) ? 1 : -1, d => d.filePath?.match(/[./]route[.]/) ? -1 : 1, d => d.routePath?.endsWith('/') ? -1 : 1, d => d.routePath]).filter(d => ![`/${routePathIdPrefix + rootPathId}`].includes(d.routePath || ''));
|
|
130
|
+
const routeTree = [];
|
|
131
|
+
const routePiecesByPath = {};
|
|
132
|
+
|
|
133
|
+
// Loop over the flat list of routeNodes and
|
|
134
|
+
// build up a tree based on the routeNodes' routePath
|
|
135
|
+
let routeNodes = [];
|
|
136
|
+
const handleNode = node => {
|
|
137
|
+
const parentRoute = hasParentRoute(routeNodes, node.routePath);
|
|
138
|
+
if (parentRoute) node.parent = parentRoute;
|
|
139
|
+
node.path = node.parent ? node.routePath?.replace(node.parent.routePath, '') || '/' : node.routePath;
|
|
140
|
+
const trimmedPath = trimPathLeft(node.path ?? '');
|
|
141
|
+
const split = trimmedPath?.split('/') ?? [];
|
|
142
|
+
let first = split[0] ?? trimmedPath ?? '';
|
|
143
|
+
node.isNonPath = first.startsWith('_');
|
|
144
|
+
node.isNonLayout = first.endsWith('_');
|
|
145
|
+
node.cleanedPath = removeUnderscores(node.path) ?? '';
|
|
146
|
+
if (!node.isVirtual && (node.isLoader || node.isComponent || node.isErrorComponent || node.isPendingComponent)) {
|
|
147
|
+
routePiecesByPath[node.routePath] = routePiecesByPath[node.routePath] || {};
|
|
148
|
+
routePiecesByPath[node.routePath][node.isLoader ? 'loader' : node.isErrorComponent ? 'errorComponent' : node.isPendingComponent ? 'pendingComponent' : 'component'] = node;
|
|
149
|
+
const anchorRoute = routeNodes.find(d => d.routePath === node.routePath);
|
|
150
|
+
if (!anchorRoute) {
|
|
151
|
+
handleNode({
|
|
152
|
+
...node,
|
|
153
|
+
isVirtual: true,
|
|
154
|
+
isLoader: false,
|
|
155
|
+
isComponent: false,
|
|
156
|
+
isErrorComponent: false,
|
|
157
|
+
isPendingComponent: false
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (node.parent) {
|
|
163
|
+
node.parent.children = node.parent.children ?? [];
|
|
164
|
+
node.parent.children.push(node);
|
|
165
|
+
} else {
|
|
166
|
+
routeTree.push(node);
|
|
167
|
+
}
|
|
168
|
+
routeNodes.push(node);
|
|
169
|
+
};
|
|
170
|
+
preRouteNodes.forEach(node => handleNode(node));
|
|
171
|
+
async function buildRouteConfig(nodes, depth = 1) {
|
|
172
|
+
const children = nodes.map(async node => {
|
|
173
|
+
const routeCode = await fs.readFile(node.fullPath, 'utf-8');
|
|
174
|
+
|
|
175
|
+
// Ensure the boilerplate for the route exists
|
|
176
|
+
if (node.isRoot) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Ensure that new FileRoute(anything?) is replaced with FileRoute(${node.routePath})
|
|
181
|
+
// routePath can contain $ characters, which have special meaning when used in replace
|
|
182
|
+
// so we have to escape it by turning all $ into $$. But since we do it through a replace call
|
|
183
|
+
// we have to double escape it into $$$$. For more information, see
|
|
184
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement
|
|
185
|
+
const escapedRoutePath = removeTrailingUnderscores(node.routePath?.replaceAll('$', '$$$$') ?? '');
|
|
186
|
+
const quote = config.quoteStyle === 'single' ? `'` : `"`;
|
|
187
|
+
const replaced = routeCode.replace(fileRouteRegex, `new FileRoute(${quote}${escapedRoutePath}${quote})`);
|
|
188
|
+
if (replaced !== routeCode) {
|
|
189
|
+
await fs.writeFile(node.fullPath, replaced);
|
|
190
|
+
}
|
|
191
|
+
const route = `${node.variableName}Route`;
|
|
192
|
+
if (node.children?.length) {
|
|
193
|
+
const childConfigs = await buildRouteConfig(node.children, depth + 1);
|
|
194
|
+
return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`;
|
|
195
|
+
}
|
|
196
|
+
return route;
|
|
197
|
+
});
|
|
198
|
+
return (await Promise.all(children)).filter(Boolean).join(`,`);
|
|
199
|
+
}
|
|
200
|
+
const routeConfigChildrenText = await buildRouteConfig(routeTree);
|
|
201
|
+
const sortedRouteNodes = multiSortBy(routeNodes, [d => d.routePath?.includes(`/${routePathIdPrefix + rootPathId}`) ? -1 : 1, d => d.routePath?.split('/').length, d => d.routePath?.endsWith("index'") ? -1 : 1, d => d]);
|
|
202
|
+
const imports = Object.entries({
|
|
203
|
+
FileRoute: sortedRouteNodes.some(d => d.isVirtual),
|
|
204
|
+
lazyFn: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.loader),
|
|
205
|
+
lazyRouteComponent: sortedRouteNodes.some(node => routePiecesByPath[node.routePath]?.component || routePiecesByPath[node.routePath]?.errorComponent || routePiecesByPath[node.routePath]?.pendingComponent)
|
|
206
|
+
}).filter(d => d[1]).map(d => d[0]);
|
|
207
|
+
const virtualRouteNodes = sortedRouteNodes.filter(d => d.isVirtual);
|
|
208
|
+
const routeImports = ['// This file is auto-generated by TanStack Router', imports.length ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\n` : '', '// Import Routes', [`import { Route as rootRoute } from './${replaceBackslash(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, routePathIdPrefix + rootPathId)))}'`, ...sortedRouteNodes.filter(d => !d.isVirtual).map(node => {
|
|
209
|
+
return `import { Route as ${node.variableName}Import } from './${replaceBackslash(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, node.filePath))))}'`;
|
|
210
|
+
})].join('\n'), virtualRouteNodes.length ? '// Create Virtual Routes' : '', virtualRouteNodes.map(node => {
|
|
211
|
+
return `const ${node.variableName}Import = new FileRoute('${removeTrailingUnderscores(node.routePath)}').createRoute()`;
|
|
212
|
+
}).join('\n'), '// Create/Update Routes', sortedRouteNodes.map(node => {
|
|
213
|
+
const loaderNode = routePiecesByPath[node.routePath]?.loader;
|
|
214
|
+
const componentNode = routePiecesByPath[node.routePath]?.component;
|
|
215
|
+
const errorComponentNode = routePiecesByPath[node.routePath]?.errorComponent;
|
|
216
|
+
const pendingComponentNode = routePiecesByPath[node.routePath]?.pendingComponent;
|
|
217
|
+
return [`const ${node.variableName}Route = ${node.variableName}Import.update({
|
|
218
|
+
${[node.isNonPath ? `id: '${node.path}'` : `path: '${node.cleanedPath}'`, `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`].filter(Boolean).join(',')}
|
|
219
|
+
} as any)`, loaderNode ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, loaderNode.filePath))))}'), 'loader') })` : '', componentNode || errorComponentNode || pendingComponentNode ? `.update({
|
|
220
|
+
${[['component', componentNode], ['errorComponent', errorComponentNode], ['pendingComponent', pendingComponentNode]].filter(d => d[1]).map(d => {
|
|
221
|
+
return `${d[0]}: lazyRouteComponent(() => import('./${replaceBackslash(removeExt(path.relative(path.dirname(config.generatedRouteTree), path.resolve(config.routesDirectory, d[1].filePath))))}'), '${d[0]}')`;
|
|
222
|
+
}).join('\n,')}
|
|
223
|
+
})` : ''].join('');
|
|
224
|
+
}).join('\n\n'), '// Populate the FileRoutesByPath interface', `declare module '@tanstack/react-router' {
|
|
225
|
+
interface FileRoutesByPath {
|
|
226
|
+
${routeNodes.map(routeNode => {
|
|
227
|
+
return `'${removeTrailingUnderscores(routeNode.routePath)}': {
|
|
228
|
+
preLoaderRoute: typeof ${routeNode.variableName}Import
|
|
229
|
+
parentRoute: typeof ${routeNode.parent?.variableName ? `${routeNode.parent?.variableName}Import` : 'rootRoute'}
|
|
230
|
+
}`;
|
|
231
|
+
}).join('\n')}
|
|
232
|
+
}
|
|
233
|
+
}`, '// Create and export the route tree', `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`].filter(Boolean).join('\n\n');
|
|
234
|
+
const routeConfigFileContent = await prettier.format(routeImports, {
|
|
235
|
+
semi: false,
|
|
236
|
+
singleQuote: config.quoteStyle === 'single',
|
|
237
|
+
parser: 'typescript'
|
|
238
|
+
});
|
|
239
|
+
const routeTreeContent = await fs.readFile(path.resolve(config.generatedRouteTree), 'utf-8').catch(err => {
|
|
240
|
+
if (err.code === 'ENOENT') {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
throw err;
|
|
244
|
+
});
|
|
245
|
+
if (!checkLatest()) return;
|
|
246
|
+
if (routeTreeContent !== routeConfigFileContent) {
|
|
247
|
+
await fs.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {
|
|
248
|
+
recursive: true
|
|
249
|
+
});
|
|
250
|
+
if (!checkLatest()) return;
|
|
251
|
+
await fs.writeFile(path.resolve(config.generatedRouteTree), routeConfigFileContent);
|
|
252
|
+
}
|
|
253
|
+
console.log(`🌲 Processed ${routeNodes.length} routes in ${Date.now() - start}ms`);
|
|
254
|
+
}
|
|
255
|
+
function routePathToVariable(d) {
|
|
256
|
+
return removeUnderscores(d)?.replace(/\/\$\//g, '/splat/')?.replace(/\$$/g, 'splat')?.replace(/\$/g, '')?.split(/[/-]/g).map((d, i) => i > 0 ? capitalize(d) : d).join('').replace(/([^a-zA-Z0-9]|[\.])/gm, '') ?? '';
|
|
257
|
+
}
|
|
258
|
+
function removeExt(d) {
|
|
259
|
+
return d.substring(0, d.lastIndexOf('.')) || d;
|
|
260
|
+
}
|
|
261
|
+
function spaces(d) {
|
|
262
|
+
return Array.from({
|
|
263
|
+
length: d
|
|
264
|
+
}).map(() => ' ').join('');
|
|
265
|
+
}
|
|
266
|
+
function multiSortBy(arr, accessors = [d => d]) {
|
|
267
|
+
return arr.map((d, i) => [d, i]).sort(([a, ai], [b, bi]) => {
|
|
268
|
+
for (const accessor of accessors) {
|
|
269
|
+
const ao = accessor(a);
|
|
270
|
+
const bo = accessor(b);
|
|
271
|
+
if (typeof ao === 'undefined') {
|
|
272
|
+
if (typeof bo === 'undefined') {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
return 1;
|
|
276
|
+
}
|
|
277
|
+
if (ao === bo) {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
return ao > bo ? 1 : -1;
|
|
281
|
+
}
|
|
282
|
+
return ai - bi;
|
|
283
|
+
}).map(([d]) => d);
|
|
284
|
+
}
|
|
285
|
+
function capitalize(s) {
|
|
286
|
+
if (typeof s !== 'string') return '';
|
|
287
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
288
|
+
}
|
|
289
|
+
function removeUnderscores(s) {
|
|
290
|
+
return s?.replace(/(^_|_$)/, '').replace(/(\/_|_\/)/, '/');
|
|
291
|
+
}
|
|
292
|
+
function removeTrailingUnderscores(s) {
|
|
293
|
+
return s?.replace(/(_$)/, '').replace(/(_\/)/, '/');
|
|
294
|
+
}
|
|
295
|
+
function replaceBackslash(s) {
|
|
296
|
+
return s.replace(/\\/gi, '/');
|
|
297
|
+
}
|
|
298
|
+
function hasParentRoute(routes, routePathToCheck) {
|
|
299
|
+
if (!routePathToCheck || routePathToCheck === '/') {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
const sortedNodes = multiSortBy(routes, [d => d.routePath.length * -1, d => d.variableName]).filter(d => d.routePath !== `/${rootPathId}`);
|
|
303
|
+
for (const route of sortedNodes) {
|
|
304
|
+
if (route.routePath === '/') continue;
|
|
305
|
+
if (routePathToCheck.startsWith(`${route.routePath}/`) && route.routePath !== routePathToCheck) {
|
|
306
|
+
return route;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const segments = routePathToCheck.split('/');
|
|
310
|
+
segments.pop(); // Remove the last segment
|
|
311
|
+
const parentRoutePath = segments.join('/');
|
|
312
|
+
return hasParentRoute(routes, parentRoutePath);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export { configSchema, generator, getConfig };
|
|
316
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/config.ts","../../src/utils.ts","../../src/generator.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})\n\nexport type Config = z.infer<typeof configSchema>\n\nconst configFilePathJson = path.resolve(process.cwd(), 'tsr.config.json')\n\nexport async function getConfig(): Promise<Config> {\n const exists = existsSync(configFilePathJson)\n\n if (exists) {\n return configSchema.parse(\n JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n )\n }\n\n return configSchema.parse({})\n}\n","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","import path from 'path'\nimport * as fs 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'\nexport const fileRouteRegex = /new\\s+FileRoute\\(([^)]*)\\)/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 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 fs.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 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 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 routePath = routePath?.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route)$/,\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 })\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}\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\n const preRouteNodes = multiSortBy(await getRouteNodes(config), [\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)[.]/,\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(\n (d) => ![`/${routePathIdPrefix + rootPathId}`].includes(d.routePath || ''),\n )\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 = (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\n node.cleanedPath = removeUnderscores(node.path) ?? ''\n\n if (\n !node.isVirtual &&\n (node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\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 handleNode({\n ...node,\n isVirtual: true,\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 preRouteNodes.forEach((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 const routeCode = await fs.readFile(node.fullPath, 'utf-8')\n\n // Ensure the boilerplate for the route exists\n if (node.isRoot) {\n return\n }\n\n // Ensure that new FileRoute(anything?) is replaced with FileRoute(${node.routePath})\n // routePath can contain $ characters, which have special meaning when used in replace\n // so we have to escape it by turning all $ into $$. But since we do it through a replace call\n // we have to double escape it into $$$$. For more information, see\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$$$') ?? '',\n )\n const quote = config.quoteStyle === 'single' ? `'` : `\"`\n const replaced = routeCode.replace(\n fileRouteRegex,\n `new FileRoute(${quote}${escapedRoutePath}${quote})`,\n )\n\n if (replaced !== routeCode) {\n await fs.writeFile(node.fullPath, replaced)\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) =>\n d.routePath?.includes(`/${routePathIdPrefix + 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 FileRoute: 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 routeImports = [\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(config.routesDirectory, routePathIdPrefix + rootPathId),\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 ),\n )}'`\n }),\n ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }Import = new FileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}').createRoute()`\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\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 } 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 ),\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 ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n ].join('')\n })\n .join('\\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 '// Create and export the route tree',\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\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 fs\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 fs.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fs.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n console.log(\n `🌲 Processed ${routeNodes.length} routes in ${Date.now() - start}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 )\n}\n\nexport function removeExt(d: string) {\n return 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?.replace(/(^_|_$)/, '').replace(/(\\/_|_\\/)/, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replace(/(_$)/, '').replace(/(_\\/)/, '/')\n}\n\nfunction replaceBackslash(s: string) {\n return s.replace(/\\\\/gi, '/')\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":["configSchema","z","object","routeFilePrefix","string","optional","routeFileIgnorePrefix","default","routesDirectory","generatedRouteTree","quoteStyle","enum","configFilePathJson","path","resolve","process","cwd","getConfig","exists","existsSync","parse","JSON","readFileSync","cleanPath","replace","trimPathLeft","latestTask","rootPathId","fileRouteRegex","getRouteNodes","config","routeNodes","recurse","dir","fullDir","dirList","fs","readdir","withFileTypes","filter","d","name","startsWith","Promise","all","map","dirent","fullPath","join","relativePath","isDirectory","match","filePath","replaceBackslash","filePathNoExt","removeExt","routePath","split","variableName","routePathToVariable","isRoute","endsWith","isComponent","isErrorComponent","isPendingComponent","isLoader","push","first","skipMessage","generator","console","log","taskId","checkLatest","start","Date","now","routePathIdPrefix","preRouteNodes","multiSortBy","length","includes","routeTree","routePiecesByPath","handleNode","node","parentRoute","hasParentRoute","parent","trimmedPath","isNonPath","isNonLayout","cleanedPath","removeUnderscores","isVirtual","anchorRoute","find","children","forEach","buildRouteConfig","nodes","depth","routeCode","readFile","isRoot","escapedRoutePath","removeTrailingUnderscores","replaceAll","quote","replaced","writeFile","route","childConfigs","spaces","Boolean","routeConfigChildrenText","sortedRouteNodes","imports","Object","entries","FileRoute","some","lazyFn","loader","lazyRouteComponent","component","errorComponent","pendingComponent","virtualRouteNodes","routeImports","relative","dirname","loaderNode","componentNode","errorComponentNode","pendingComponentNode","routeNode","routeConfigFileContent","prettier","format","semi","singleQuote","parser","routeTreeContent","catch","err","code","undefined","mkdir","recursive","i","capitalize","substring","lastIndexOf","Array","from","arr","accessors","sort","a","ai","b","bi","accessor","ao","bo","s","charAt","toUpperCase","slice","routes","routePathToCheck","sortedNodes","segments","pop","parentRoutePath"],"mappings":";;;;;;;;;;;;;;;;MAIaA,YAAY,GAAGC,CAAC,CAACC,MAAM,CAAC;EACnCC,eAAe,EAAEF,CAAC,CAACG,MAAM,EAAE,CAACC,QAAQ,EAAE;AACtCC,EAAAA,qBAAqB,EAAEL,CAAC,CAACG,MAAM,EAAE,CAACC,QAAQ,EAAE,CAACE,OAAO,CAAC,GAAG,CAAC;AACzDC,EAAAA,eAAe,EAAEP,CAAC,CAACG,MAAM,EAAE,CAACC,QAAQ,EAAE,CAACE,OAAO,CAAC,cAAc,CAAC;AAC9DE,EAAAA,kBAAkB,EAAER,CAAC,CAACG,MAAM,EAAE,CAACC,QAAQ,EAAE,CAACE,OAAO,CAAC,wBAAwB,CAAC;AAC3EG,EAAAA,UAAU,EAAET,CAAC,CAACU,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAACN,QAAQ,EAAE,CAACE,OAAO,CAAC,QAAQ,CAAA;AACtE,CAAC,EAAC;AAIF,MAAMK,kBAAkB,GAAGC,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAA;AAElE,eAAeC,SAASA,GAAoB;AACjD,EAAA,MAAMC,MAAM,GAAGC,UAAU,CAACP,kBAAkB,CAAC,CAAA;AAE7C,EAAA,IAAIM,MAAM,EAAE;AACV,IAAA,OAAOlB,YAAY,CAACoB,KAAK,CACvBC,IAAI,CAACD,KAAK,CAACE,YAAY,CAACV,kBAAkB,EAAE,OAAO,CAAC,CACtD,CAAC,CAAA;AACH,GAAA;AAEA,EAAA,OAAOZ,YAAY,CAACoB,KAAK,CAAC,EAAE,CAAC,CAAA;AAC/B;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A;AACd,KAAA;AACF,GAAA;AACA,EAAA,MAAM8D,QAAQ,GAAGF,gBAAgB,CAAClH,KAAK,CAAC,GAAG,CAAC,CAAA;AAC5CoH,EAAAA,QAAQ,CAACC,GAAG,EAAE,CAAC;AACf,EAAA,MAAMC,eAAe,GAAGF,QAAQ,CAAC7H,IAAI,CAAC,GAAG,CAAC,CAAA;AAE1C,EAAA,OAAOuC,cAAc,CAACmF,MAAM,EAAEK,eAAe,CAAC,CAAA;AAChD;;;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tanstack/router-generator/src/index.ts
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) TanStack
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
|
|
13
|
+
declare const configSchema: z.ZodObject<{
|
|
14
|
+
routeFilePrefix: z.ZodOptional<z.ZodString>;
|
|
15
|
+
routeFileIgnorePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
16
|
+
routesDirectory: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
17
|
+
generatedRouteTree: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
18
|
+
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<["single", "double"]>>>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
routeFileIgnorePrefix: string;
|
|
21
|
+
routesDirectory: string;
|
|
22
|
+
generatedRouteTree: string;
|
|
23
|
+
quoteStyle: "single" | "double";
|
|
24
|
+
routeFilePrefix?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
routeFilePrefix?: string | undefined;
|
|
27
|
+
routeFileIgnorePrefix?: string | undefined;
|
|
28
|
+
routesDirectory?: string | undefined;
|
|
29
|
+
generatedRouteTree?: string | undefined;
|
|
30
|
+
quoteStyle?: "single" | "double" | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
type Config = z.infer<typeof configSchema>;
|
|
33
|
+
declare function getConfig(): Promise<Config>;
|
|
34
|
+
|
|
35
|
+
declare function generator(config: Config): Promise<void>;
|
|
36
|
+
|
|
37
|
+
export { type Config, configSchema, generator, getConfig };
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tanstack/router-generator",
|
|
3
|
+
"author": "Tanner Linsley",
|
|
4
|
+
"version": "1.5.4",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "tanstack/router",
|
|
7
|
+
"homepage": "https://tanstack.com/router",
|
|
8
|
+
"description": "",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"registry": "https://registry.npmjs.org/"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"react",
|
|
14
|
+
"location",
|
|
15
|
+
"router",
|
|
16
|
+
"routing",
|
|
17
|
+
"async",
|
|
18
|
+
"async router",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"funding": {
|
|
22
|
+
"type": "github",
|
|
23
|
+
"url": "https://github.com/sponsors/tannerlinsley"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=12"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"build/**",
|
|
30
|
+
"src"
|
|
31
|
+
],
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"module": "build/esm/index.js",
|
|
34
|
+
"main": "build/cjs/index.js",
|
|
35
|
+
"types": "build/types/index.d.ts",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"prettier": "^3.0.2",
|
|
38
|
+
"zod": "^3.19.1"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "rollup --config rollup.config.js"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { readFileSync, existsSync } from 'fs'
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
export const configSchema = z.object({
|
|
6
|
+
routeFilePrefix: z.string().optional(),
|
|
7
|
+
routeFileIgnorePrefix: z.string().optional().default('-'),
|
|
8
|
+
routesDirectory: z.string().optional().default('./src/routes'),
|
|
9
|
+
generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),
|
|
10
|
+
quoteStyle: z.enum(['single', 'double']).optional().default('single'),
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export type Config = z.infer<typeof configSchema>
|
|
14
|
+
|
|
15
|
+
const configFilePathJson = path.resolve(process.cwd(), 'tsr.config.json')
|
|
16
|
+
|
|
17
|
+
export async function getConfig(): Promise<Config> {
|
|
18
|
+
const exists = existsSync(configFilePathJson)
|
|
19
|
+
|
|
20
|
+
if (exists) {
|
|
21
|
+
return configSchema.parse(
|
|
22
|
+
JSON.parse(readFileSync(configFilePathJson, 'utf-8')),
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return configSchema.parse({})
|
|
27
|
+
}
|