@zphhpzzph/vue-route-gen 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +349 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @signlab/vue-route-gen
|
|
2
|
+
|
|
3
|
+
Vue 3 file-based route generator for Vue Router.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Automatic route discovery from file structure
|
|
8
|
+
- Layout support (`layout.vue` or `layout/index.vue`)
|
|
9
|
+
- Dynamic route parameters (`$param` or `[param]`)
|
|
10
|
+
- Cache mechanism for fast rebuilds
|
|
11
|
+
- TypeScript support with generated types
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @signlab/vue-route-gen
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### CLI
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
vue-route-gen
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Programmatic
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { generateRoutes } from '@signlab/vue-route-gen';
|
|
31
|
+
|
|
32
|
+
// Generate routes with default options
|
|
33
|
+
generateRoutes();
|
|
34
|
+
|
|
35
|
+
// Or specify custom directories
|
|
36
|
+
generateRoutes({
|
|
37
|
+
pagesDir: './src/pages',
|
|
38
|
+
outFile: './src/router/route.gen.ts'
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## File Structure
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
src/pages/
|
|
46
|
+
├── layout.vue # Root layout
|
|
47
|
+
├── index.vue # Home page (/)
|
|
48
|
+
├── about.vue # About page (/about)
|
|
49
|
+
├── users/
|
|
50
|
+
│ ├── layout.vue # Users layout (/users)
|
|
51
|
+
│ ├── index.vue # Users list (/users)
|
|
52
|
+
│ └── [id].vue # User detail (/users/:id)
|
|
53
|
+
└── $slug.vue # Catch-all (/:slug)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Configuration
|
|
57
|
+
|
|
58
|
+
### Options
|
|
59
|
+
|
|
60
|
+
- `pagesDir`: Pages directory path (default: `src/pages`)
|
|
61
|
+
- `outFile`: Output file path (default: `src/router/route.gen.ts`)
|
|
62
|
+
|
|
63
|
+
### Excluded Directories
|
|
64
|
+
|
|
65
|
+
The following directories are automatically excluded:
|
|
66
|
+
- `components`
|
|
67
|
+
- `hooks`
|
|
68
|
+
- `service`
|
|
69
|
+
|
|
70
|
+
## Generated Output
|
|
71
|
+
|
|
72
|
+
The generator creates:
|
|
73
|
+
|
|
74
|
+
1. `ROUTE_NAME` - Route name constants
|
|
75
|
+
2. `ROUTE_PATH` - Route path constants
|
|
76
|
+
3. `ROUTE_PATH_BY_NAME` - Path lookup by name
|
|
77
|
+
4. `routes` - Vue Router route records array
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,cAAc,EAAE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface GenerateRoutesOptions {
|
|
2
|
+
pagesDir?: string;
|
|
3
|
+
outFile?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RouteEntry {
|
|
6
|
+
path: string;
|
|
7
|
+
name: string;
|
|
8
|
+
importPath: string;
|
|
9
|
+
children: RouteEntry[];
|
|
10
|
+
}
|
|
11
|
+
export interface RouteData {
|
|
12
|
+
routes: RouteEntry[];
|
|
13
|
+
routeNameList: readonly string[];
|
|
14
|
+
routePathList: readonly string[];
|
|
15
|
+
routePathByName: [string, string][];
|
|
16
|
+
}
|
|
17
|
+
export declare function generateRoutes({ pagesDir, outFile, }?: GenerateRoutesOptions): boolean;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CACrC;AAqZD,wBAAgB,cAAc,CAAC,EAC7B,QAAmD,EACnD,OAAgE,GACjE,GAAE,qBAA0B,GAAG,OAAO,CAiCtC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
const EXCLUDED_DIRS = new Set(['components', 'hooks', 'service']);
|
|
4
|
+
const CACHE_FILE = path.resolve(process.cwd(), 'node_modules/.cache/route-gen.json');
|
|
5
|
+
function normalizePath(p) {
|
|
6
|
+
return p.split(path.sep).join('/');
|
|
7
|
+
}
|
|
8
|
+
function loadCache() {
|
|
9
|
+
try {
|
|
10
|
+
if (fs.existsSync(CACHE_FILE)) {
|
|
11
|
+
const data = fs.readFileSync(CACHE_FILE, 'utf8');
|
|
12
|
+
return JSON.parse(data);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
// Ignore cache read errors
|
|
17
|
+
}
|
|
18
|
+
return { files: '{}', lastRoutesHash: null };
|
|
19
|
+
}
|
|
20
|
+
function saveCache(cache) {
|
|
21
|
+
const cacheDir = path.dirname(CACHE_FILE);
|
|
22
|
+
if (!fs.existsSync(cacheDir)) {
|
|
23
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
fs.writeFileSync(CACHE_FILE, JSON.stringify(cache, null, 2), 'utf8');
|
|
26
|
+
}
|
|
27
|
+
function getFileHash(filePath) {
|
|
28
|
+
const stats = fs.statSync(filePath);
|
|
29
|
+
return `${stats.mtimeMs}-${stats.size}`;
|
|
30
|
+
}
|
|
31
|
+
function buildFileHash(pagesDir) {
|
|
32
|
+
const files = scanVueFiles(pagesDir);
|
|
33
|
+
const hashObj = {};
|
|
34
|
+
for (const file of files) {
|
|
35
|
+
hashObj[normalizePath(path.relative(pagesDir, file))] = getFileHash(file);
|
|
36
|
+
}
|
|
37
|
+
return JSON.stringify(hashObj);
|
|
38
|
+
}
|
|
39
|
+
function scanVueFiles(rootDir) {
|
|
40
|
+
const files = [];
|
|
41
|
+
const stack = [rootDir];
|
|
42
|
+
while (stack.length > 0) {
|
|
43
|
+
const dir = stack.pop();
|
|
44
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
const fullPath = path.join(dir, entry.name);
|
|
47
|
+
if (entry.isDirectory()) {
|
|
48
|
+
if (EXCLUDED_DIRS.has(entry.name)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
stack.push(fullPath);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (entry.isFile() && entry.name.endsWith('.vue')) {
|
|
55
|
+
files.push(fullPath);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return files.sort();
|
|
60
|
+
}
|
|
61
|
+
function isLayout(segments) {
|
|
62
|
+
const last = segments[segments.length - 1];
|
|
63
|
+
const secondLast = segments[segments.length - 2];
|
|
64
|
+
return last === 'layout' || (last === 'index' && secondLast === 'layout');
|
|
65
|
+
}
|
|
66
|
+
function segmentToPath(segment) {
|
|
67
|
+
if (segment.includes('.')) {
|
|
68
|
+
return segment.split('.').join('/');
|
|
69
|
+
}
|
|
70
|
+
if (segment === 'index') {
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
if (segment.startsWith('$')) {
|
|
74
|
+
return `:${segment.slice(1)}`;
|
|
75
|
+
}
|
|
76
|
+
if (segment.startsWith('[') && segment.endsWith(']')) {
|
|
77
|
+
return `:${segment.slice(1, -1)}`;
|
|
78
|
+
}
|
|
79
|
+
return segment;
|
|
80
|
+
}
|
|
81
|
+
function segmentsToPath(segments, leadingSlash) {
|
|
82
|
+
const rawPath = segments.map(segmentToPath).join('/');
|
|
83
|
+
const cleaned = rawPath.replace(/\/+/g, '/').replace(/\/$/, '');
|
|
84
|
+
if (leadingSlash) {
|
|
85
|
+
if (!cleaned) {
|
|
86
|
+
return '/';
|
|
87
|
+
}
|
|
88
|
+
return `/${cleaned}`;
|
|
89
|
+
}
|
|
90
|
+
return cleaned;
|
|
91
|
+
}
|
|
92
|
+
function joinPaths(parent, child) {
|
|
93
|
+
if (!child) {
|
|
94
|
+
return parent || '/';
|
|
95
|
+
}
|
|
96
|
+
if (!parent || parent === '/') {
|
|
97
|
+
return `/${child}`.replace(/\/+/g, '/');
|
|
98
|
+
}
|
|
99
|
+
return `${parent.replace(/\/$/, '')}/${child}`.replace(/\/+/g, '/');
|
|
100
|
+
}
|
|
101
|
+
function renderRoute(route, indent = ' ') {
|
|
102
|
+
const nextIndent = `${indent} `;
|
|
103
|
+
const lines = [];
|
|
104
|
+
lines.push(`${indent}{`);
|
|
105
|
+
lines.push(`${nextIndent}path: ${JSON.stringify(route.path)},`);
|
|
106
|
+
lines.push(`${nextIndent}name: ${JSON.stringify(route.name)},`);
|
|
107
|
+
lines.push(`${nextIndent}component: () => import(${JSON.stringify(route.importPath)}),`);
|
|
108
|
+
if (route.children.length === 0) {
|
|
109
|
+
lines.push(`${nextIndent}children: [],`);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
lines.push(`${nextIndent}children: [`);
|
|
113
|
+
lines.push(route.children
|
|
114
|
+
.map((child) => renderRoute(child, `${nextIndent} `))
|
|
115
|
+
.join(',\n'));
|
|
116
|
+
lines.push(`${nextIndent}],`);
|
|
117
|
+
}
|
|
118
|
+
lines.push(`${indent}}`);
|
|
119
|
+
return lines.join('\n');
|
|
120
|
+
}
|
|
121
|
+
function unique(values) {
|
|
122
|
+
const seen = new Set();
|
|
123
|
+
const out = [];
|
|
124
|
+
for (const value of values) {
|
|
125
|
+
if (!seen.has(value)) {
|
|
126
|
+
seen.add(value);
|
|
127
|
+
out.push(value);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
function toConstKey(input) {
|
|
133
|
+
const withWordBreaks = input.replace(/([a-z0-9])([A-Z])/g, '$1_$2');
|
|
134
|
+
const normalized = withWordBreaks
|
|
135
|
+
.replace(/[^a-zA-Z0-9]+/g, '_')
|
|
136
|
+
.replace(/_+/g, '_')
|
|
137
|
+
.replace(/^_|_$/g, '');
|
|
138
|
+
return normalized.toUpperCase();
|
|
139
|
+
}
|
|
140
|
+
function buildRoutes({ pagesDir, outFile }) {
|
|
141
|
+
const files = scanVueFiles(pagesDir);
|
|
142
|
+
const outDir = path.dirname(outFile);
|
|
143
|
+
const entries = files.map((filePath) => {
|
|
144
|
+
const relPath = normalizePath(path.relative(pagesDir, filePath));
|
|
145
|
+
const withoutExt = relPath.replace(/\.vue$/, '');
|
|
146
|
+
const segments = withoutExt.split('/');
|
|
147
|
+
const importPath = normalizePath(path.relative(outDir, filePath));
|
|
148
|
+
const normalizedImportPath = importPath.startsWith('.') ? importPath : `./${importPath}`;
|
|
149
|
+
return {
|
|
150
|
+
filePath,
|
|
151
|
+
importPath: normalizedImportPath,
|
|
152
|
+
segments,
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
const layoutEntries = entries.filter((entry) => isLayout(entry.segments));
|
|
156
|
+
const layouts = layoutEntries
|
|
157
|
+
.map((entry) => {
|
|
158
|
+
const layoutIndex = entry.segments.indexOf('layout');
|
|
159
|
+
return {
|
|
160
|
+
importPath: entry.importPath,
|
|
161
|
+
segments: entry.segments.slice(0, layoutIndex),
|
|
162
|
+
depth: layoutIndex,
|
|
163
|
+
};
|
|
164
|
+
})
|
|
165
|
+
.sort((a, b) => a.depth - b.depth);
|
|
166
|
+
const pageEntries = entries
|
|
167
|
+
.filter((entry) => !isLayout(entry.segments))
|
|
168
|
+
.sort((a, b) => a.segments.join('/').localeCompare(b.segments.join('/')));
|
|
169
|
+
const pages = pageEntries.map((entry) => {
|
|
170
|
+
const pageLayouts = layouts.filter((layout) => {
|
|
171
|
+
if (layout.segments.length > entry.segments.length) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
return layout.segments.every((segment, index) => segment === entry.segments[index]);
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
importPath: entry.importPath,
|
|
178
|
+
segments: entry.segments,
|
|
179
|
+
layouts: pageLayouts,
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
const layoutGroups = new Map();
|
|
183
|
+
const standalonePages = [];
|
|
184
|
+
for (const page of pages) {
|
|
185
|
+
if (page.layouts.length === 0) {
|
|
186
|
+
standalonePages.push(page);
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const layoutKey = page.layouts[0].segments.join('/');
|
|
190
|
+
const group = layoutGroups.get(layoutKey) ?? [];
|
|
191
|
+
group.push(page);
|
|
192
|
+
layoutGroups.set(layoutKey, group);
|
|
193
|
+
}
|
|
194
|
+
const routeEntries = [];
|
|
195
|
+
const standaloneRoutes = standalonePages.map((page) => {
|
|
196
|
+
const name = page.segments.join('-');
|
|
197
|
+
const routePath = segmentsToPath(page.segments, true);
|
|
198
|
+
routeEntries.push({ name, path: routePath });
|
|
199
|
+
return {
|
|
200
|
+
path: routePath,
|
|
201
|
+
name,
|
|
202
|
+
importPath: page.importPath,
|
|
203
|
+
children: [],
|
|
204
|
+
};
|
|
205
|
+
});
|
|
206
|
+
const layoutRoutes = Array.from(layoutGroups.entries())
|
|
207
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
208
|
+
.map(([, pagesInLayout]) => {
|
|
209
|
+
const sortedPages = [...pagesInLayout].sort((a, b) => a.segments.join('/').localeCompare(b.segments.join('/')));
|
|
210
|
+
const layout = sortedPages[0].layouts[0];
|
|
211
|
+
const layoutNameBase = layout.segments.join('-');
|
|
212
|
+
const layoutName = layoutNameBase ? `${layoutNameBase}-layout` : 'layout';
|
|
213
|
+
const layoutPath = segmentsToPath(layout.segments, true);
|
|
214
|
+
routeEntries.push({ name: layoutName, path: layoutPath });
|
|
215
|
+
const children = sortedPages.map((page) => {
|
|
216
|
+
const name = page.segments.join('-');
|
|
217
|
+
const relativeSegments = page.segments.slice(layout.segments.length);
|
|
218
|
+
const childPath = segmentsToPath(relativeSegments, false);
|
|
219
|
+
const fullPath = joinPaths(layoutPath, childPath);
|
|
220
|
+
routeEntries.push({ name, path: fullPath });
|
|
221
|
+
return {
|
|
222
|
+
path: childPath,
|
|
223
|
+
name,
|
|
224
|
+
importPath: page.importPath,
|
|
225
|
+
children: [],
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
return {
|
|
229
|
+
path: layoutPath,
|
|
230
|
+
name: layoutName,
|
|
231
|
+
importPath: layout.importPath,
|
|
232
|
+
children,
|
|
233
|
+
};
|
|
234
|
+
});
|
|
235
|
+
const routes = [...standaloneRoutes, ...layoutRoutes];
|
|
236
|
+
const uniqueNames = unique(routeEntries.map((entry) => entry.name));
|
|
237
|
+
const uniquePaths = unique(routeEntries.map((entry) => entry.path));
|
|
238
|
+
const pathByName = new Map();
|
|
239
|
+
for (const entry of routeEntries) {
|
|
240
|
+
if (!pathByName.has(entry.name)) {
|
|
241
|
+
pathByName.set(entry.name, entry.path);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const routePathByName = uniqueNames.map((name) => [name, pathByName.get(name)]);
|
|
245
|
+
return {
|
|
246
|
+
routes,
|
|
247
|
+
routeNameList: uniqueNames,
|
|
248
|
+
routePathList: uniquePaths,
|
|
249
|
+
routePathByName,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function renderRoutesFile({ routes, routeNameList, routePathList, routePathByName }) {
|
|
253
|
+
const lines = [];
|
|
254
|
+
const pathByName = new Map(routePathByName);
|
|
255
|
+
const routeKeyEntries = [];
|
|
256
|
+
const usedKeys = new Set();
|
|
257
|
+
for (const name of routeNameList) {
|
|
258
|
+
const baseKey = toConstKey(name) || 'ROUTE';
|
|
259
|
+
let key = baseKey;
|
|
260
|
+
let suffix = 1;
|
|
261
|
+
while (usedKeys.has(key)) {
|
|
262
|
+
suffix += 1;
|
|
263
|
+
key = `${baseKey}_${suffix}`;
|
|
264
|
+
}
|
|
265
|
+
usedKeys.add(key);
|
|
266
|
+
routeKeyEntries.push({
|
|
267
|
+
key,
|
|
268
|
+
name,
|
|
269
|
+
path: pathByName.get(name),
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
lines.push('// This file is auto-generated by @signlab/vue-route-gen.');
|
|
273
|
+
lines.push('// Do not edit this file directly.');
|
|
274
|
+
lines.push("import type { RouteRecordRaw } from 'vue-router';");
|
|
275
|
+
lines.push('');
|
|
276
|
+
lines.push('export const ROUTE_NAME = {');
|
|
277
|
+
lines.push(routeKeyEntries
|
|
278
|
+
.map((entry) => ` ${entry.key}: ${JSON.stringify(entry.name)},`)
|
|
279
|
+
.join('\n'));
|
|
280
|
+
lines.push('} as const;');
|
|
281
|
+
lines.push('');
|
|
282
|
+
lines.push('export type RouteName = (typeof ROUTE_NAME)[keyof typeof ROUTE_NAME];');
|
|
283
|
+
lines.push('');
|
|
284
|
+
lines.push('export const ROUTE_PATH = {');
|
|
285
|
+
lines.push(routeKeyEntries
|
|
286
|
+
.map((entry) => ` ${entry.key}: ${JSON.stringify(entry.path)},`)
|
|
287
|
+
.join('\n'));
|
|
288
|
+
lines.push('} as const;');
|
|
289
|
+
lines.push('');
|
|
290
|
+
lines.push('export type RoutePath = (typeof ROUTE_PATH)[keyof typeof ROUTE_PATH];');
|
|
291
|
+
lines.push('');
|
|
292
|
+
lines.push('export const ROUTE_PATH_BY_NAME = {');
|
|
293
|
+
lines.push(routeKeyEntries
|
|
294
|
+
.map((entry) => ` ${JSON.stringify(entry.name)}: ROUTE_PATH.${entry.key},`)
|
|
295
|
+
.join('\n'));
|
|
296
|
+
lines.push('} as const;');
|
|
297
|
+
lines.push('');
|
|
298
|
+
lines.push('export type RoutePathByName = typeof ROUTE_PATH_BY_NAME;');
|
|
299
|
+
lines.push('');
|
|
300
|
+
lines.push('export const routeNameList = [');
|
|
301
|
+
lines.push(routeNameList.map((name) => ` ${JSON.stringify(name)},`).join('\n'));
|
|
302
|
+
lines.push('] as const;');
|
|
303
|
+
lines.push('');
|
|
304
|
+
lines.push('export const routePathList = [');
|
|
305
|
+
lines.push(routePathList.map((path) => ` ${JSON.stringify(path)},`).join('\n'));
|
|
306
|
+
lines.push('] as const;');
|
|
307
|
+
lines.push('');
|
|
308
|
+
lines.push('export const routePathByName = {');
|
|
309
|
+
lines.push(routePathByName
|
|
310
|
+
.map(([name, pathValue]) => ` ${JSON.stringify(name)}: ${JSON.stringify(pathValue)},`)
|
|
311
|
+
.join('\n'));
|
|
312
|
+
lines.push('} as const;');
|
|
313
|
+
lines.push('');
|
|
314
|
+
lines.push('export const routes = [');
|
|
315
|
+
lines.push(routes.map((route) => renderRoute(route)).join(',\n'));
|
|
316
|
+
lines.push('] satisfies RouteRecordRaw[];');
|
|
317
|
+
lines.push('');
|
|
318
|
+
lines.push('export default routes;');
|
|
319
|
+
lines.push('');
|
|
320
|
+
return `${lines.join('\n')}\n`;
|
|
321
|
+
}
|
|
322
|
+
export function generateRoutes({ pagesDir = path.resolve(process.cwd(), 'src/pages'), outFile = path.resolve(process.cwd(), 'src/router/route.gen.ts'), } = {}) {
|
|
323
|
+
if (!fs.existsSync(pagesDir)) {
|
|
324
|
+
throw new Error(`Pages directory not found: ${pagesDir}`);
|
|
325
|
+
}
|
|
326
|
+
// Load cache and check if we can skip generation
|
|
327
|
+
const cache = loadCache();
|
|
328
|
+
const currentFilesHash = buildFileHash(pagesDir);
|
|
329
|
+
// If files haven't changed and output exists, skip generation
|
|
330
|
+
if (cache.files === currentFilesHash && fs.existsSync(outFile)) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
const data = buildRoutes({ pagesDir, outFile });
|
|
334
|
+
const output = renderRoutesFile(data);
|
|
335
|
+
fs.mkdirSync(path.dirname(outFile), { recursive: true });
|
|
336
|
+
if (fs.existsSync(outFile)) {
|
|
337
|
+
const current = fs.readFileSync(outFile, 'utf8');
|
|
338
|
+
if (current === output) {
|
|
339
|
+
// Save cache even if output unchanged
|
|
340
|
+
saveCache({ files: currentFilesHash, lastRoutesHash: currentFilesHash });
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
fs.writeFileSync(outFile, output, 'utf8');
|
|
345
|
+
// Save cache after successful generation
|
|
346
|
+
saveCache({ files: currentFilesHash, lastRoutesHash: currentFilesHash });
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AAClE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,oCAAoC,CAAC,CAAC;AAgCrF,SAAS,aAAa,CAAC,CAAS;IAC9B,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,SAAS;IAChB,IAAI,CAAC;QACH,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACjD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAc,CAAC;QACvC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,2BAA2B;IAC7B,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;AAC/C,CAAC;AAED,SAAS,SAAS,CAAC,KAAgB;IACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAC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AC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzD,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjD,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;YACvB,sCAAsC;YACtC,SAAS,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC,CAAC;YACzE,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C,yCAAyC;IACzC,SAAS,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACzE,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zphhpzzph/vue-route-gen",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Vue 3 route generator for file-based routing",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"bin": {
|
|
18
|
+
"vue-route-gen": "./dist/cli.js"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"dev": "tsc --watch",
|
|
23
|
+
"prepublishOnly": "pnpm run build",
|
|
24
|
+
"publish": "npm publish --access public --registry https://registry.npmjs.org/"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"vue",
|
|
28
|
+
"vue-router",
|
|
29
|
+
"route-generator",
|
|
30
|
+
"file-based-routing"
|
|
31
|
+
],
|
|
32
|
+
"author": "z-ph",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/z-ph/signLab-front.git",
|
|
40
|
+
"directory": "packages/vue-route-gen"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/z-ph/signLab-front/tree/main/packages/vue-route-gen#readme",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/z-ph/signLab-front/issues"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.11.0",
|
|
48
|
+
"typescript": "^5.3.3"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=18.0.0"
|
|
52
|
+
}
|
|
53
|
+
}
|