nuxt-typed-router 3.2.3 → 3.2.5
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/module.json +1 -1
- package/dist/module.mjs +15 -42
- package/package.json +18 -18
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import logSymbols from 'log-symbols';
|
|
|
4
4
|
import { defu } from 'defu';
|
|
5
5
|
import { customAlphabet } from 'nanoid/non-secure';
|
|
6
6
|
import { nanoid as nanoid$1 } from 'nanoid';
|
|
7
|
-
import prettier from 'prettier';
|
|
8
7
|
import fs, { existsSync } from 'fs';
|
|
9
8
|
import { fileURLToPath } from 'url';
|
|
10
9
|
import { dirname, resolve } from 'pathe';
|
|
@@ -240,9 +239,9 @@ function createValidatePathTypes(pathElements, withLocale = false) {
|
|
|
240
239
|
function createTypeValidatePathCondition(elements) {
|
|
241
240
|
const typeName = `Validate${nanoid(7)}`;
|
|
242
241
|
const params = /* @__PURE__ */ new Map();
|
|
243
|
-
const routeName = elements.flat()[0]
|
|
242
|
+
const routeName = elements.flat()[0]?.routeName ?? "index";
|
|
244
243
|
elements.flat().every((elem) => elem.type === "name");
|
|
245
|
-
const isLocale = elements.flat()[0]
|
|
244
|
+
const isLocale = elements.flat()[0]?.isLocale ?? false;
|
|
246
245
|
const condition = `type ${typeName}<T> = T extends \`/${elements.map((elementArray, index) => {
|
|
247
246
|
return elementArray.map((elem) => {
|
|
248
247
|
const isLast = index === elements.flat().length - 1;
|
|
@@ -885,7 +884,7 @@ function createi18nRouterFile() {
|
|
|
885
884
|
);
|
|
886
885
|
}
|
|
887
886
|
|
|
888
|
-
const routeParamExtractRegxp = /(:(\w+)(\(
|
|
887
|
+
const routeParamExtractRegxp = /(:(\w+)(\(\.[^(]\)[*+]?)?(\?)?)+/g;
|
|
889
888
|
function extractParamsFromPathDecl(path) {
|
|
890
889
|
let params = [];
|
|
891
890
|
let matches;
|
|
@@ -1029,7 +1028,7 @@ function createPathsFiles({ routesPaths }) {
|
|
|
1029
1028
|
});
|
|
1030
1029
|
const pathElements = filteredRoutesPaths.filter((f) => f.path && f.path !== "/").map((route) => {
|
|
1031
1030
|
return route.path.split("/").filter((f) => f.length).map((m) => destructurePath(m, route));
|
|
1032
|
-
});
|
|
1031
|
+
}).filter((f) => f.length);
|
|
1033
1032
|
const validatePathTypes = createValidatePathTypes(pathElements);
|
|
1034
1033
|
const validateLocalePathTypes = createValidatePathTypes(pathElements, true);
|
|
1035
1034
|
return (
|
|
@@ -1233,33 +1232,6 @@ async function handleAddPlugin() {
|
|
|
1233
1232
|
});
|
|
1234
1233
|
}
|
|
1235
1234
|
|
|
1236
|
-
const { resolveConfig, format } = prettier;
|
|
1237
|
-
const defaultPrettierOptions = {
|
|
1238
|
-
printWidth: 100,
|
|
1239
|
-
tabWidth: 2,
|
|
1240
|
-
trailingComma: "es5",
|
|
1241
|
-
singleQuote: true,
|
|
1242
|
-
semi: true,
|
|
1243
|
-
bracketSpacing: true,
|
|
1244
|
-
htmlWhitespaceSensitivity: "strict"
|
|
1245
|
-
};
|
|
1246
|
-
async function formatOutputWithPrettier(template) {
|
|
1247
|
-
try {
|
|
1248
|
-
let prettierFoundOptions = await resolveConfig(process.cwd());
|
|
1249
|
-
if (!prettierFoundOptions) {
|
|
1250
|
-
prettierFoundOptions = defaultPrettierOptions;
|
|
1251
|
-
}
|
|
1252
|
-
const formatedTemplate = format(template, {
|
|
1253
|
-
...prettierFoundOptions,
|
|
1254
|
-
parser: "typescript"
|
|
1255
|
-
});
|
|
1256
|
-
return formatedTemplate;
|
|
1257
|
-
} catch (e) {
|
|
1258
|
-
console.error(logSymbols.error, chalk.red("Error while formatting the output"), "\n" + e);
|
|
1259
|
-
return Promise.reject(e);
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
1235
|
dirname(fileURLToPath(import.meta.url));
|
|
1264
1236
|
async function processPathAndWriteFile({
|
|
1265
1237
|
content,
|
|
@@ -1271,15 +1243,14 @@ async function processPathAndWriteFile({
|
|
|
1271
1243
|
const finalOutDir = outDir ?? `.nuxt/typed-router`;
|
|
1272
1244
|
const processedOutDir = resolve(rootDir, finalOutDir);
|
|
1273
1245
|
const outputFile = resolve(process.cwd(), `${processedOutDir}/${fileName}`);
|
|
1274
|
-
const formatedContent = await formatOutputWithPrettier(content);
|
|
1275
1246
|
if (fs.existsSync(outputFile)) {
|
|
1276
|
-
await writeFile(outputFile,
|
|
1247
|
+
await writeFile(outputFile, content);
|
|
1277
1248
|
} else {
|
|
1278
1249
|
let dirList = outputFile.split("/");
|
|
1279
1250
|
dirList.pop();
|
|
1280
1251
|
const dirPath = dirList.join("/");
|
|
1281
1252
|
await mkdirp(dirPath);
|
|
1282
|
-
await writeFile(outputFile,
|
|
1253
|
+
await writeFile(outputFile, content);
|
|
1283
1254
|
}
|
|
1284
1255
|
} catch (e) {
|
|
1285
1256
|
return Promise.reject(e);
|
|
@@ -1432,7 +1403,7 @@ function createKeyedName(route, parent) {
|
|
|
1432
1403
|
if (parent) {
|
|
1433
1404
|
return camelCase(parentPath || "index");
|
|
1434
1405
|
} else {
|
|
1435
|
-
return camelCase(route.path.split("/").join("-") || "index"
|
|
1406
|
+
return camelCase(route.path.split("/").join("-")) || "index";
|
|
1436
1407
|
}
|
|
1437
1408
|
}
|
|
1438
1409
|
function createNameKeyFromFullName(route, level, parentName) {
|
|
@@ -1457,12 +1428,14 @@ function walkThoughRoutes({
|
|
|
1457
1428
|
}) {
|
|
1458
1429
|
const route = modifyRoutePrefixDefaultIfI18n(_route);
|
|
1459
1430
|
const isLocaleRoute = isLocale || is18Sibling(output.routesPaths, route);
|
|
1460
|
-
const newPath = `${parent?.path ?? ""}${route.path.startsWith("/") ? route.path : `/${route.path}`}`;
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1431
|
+
const newPath = `${parent?.path ?? ""}${route.path.startsWith("/") || parent?.path === "/" ? route.path : `/${route.path}`}`;
|
|
1432
|
+
if (parent?.path !== "/") {
|
|
1433
|
+
output.routesPaths.push({
|
|
1434
|
+
name: route.name,
|
|
1435
|
+
path: newPath,
|
|
1436
|
+
isLocale: isLocaleRoute
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1466
1439
|
if (route.children?.length) {
|
|
1467
1440
|
let childrenChunks = route.children;
|
|
1468
1441
|
let nameKey = createKeyedName(route, parent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-typed-router",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.5",
|
|
4
4
|
"description": "Provide autocompletion for routes paths, names and params in Nuxt apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/module.cjs",
|
|
@@ -60,44 +60,44 @@
|
|
|
60
60
|
"url": "https://github.com/victorgarciaesgi/nuxt-typed-router/issues"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@nuxt/kit": "^3.
|
|
64
|
-
"chalk": "^5.
|
|
63
|
+
"@nuxt/kit": "^3.6.1",
|
|
64
|
+
"chalk": "^5.3.0",
|
|
65
65
|
"defu": "^6.1.2",
|
|
66
66
|
"lodash-es": "^4.17.21",
|
|
67
67
|
"log-symbols": "^5.1.0",
|
|
68
68
|
"mkdirp": "^3.0.1",
|
|
69
69
|
"nanoid": "^4.0.2",
|
|
70
|
-
"pathe": "1.1.0"
|
|
71
|
-
"prettier": "2.8.8"
|
|
70
|
+
"pathe": "1.1.0"
|
|
72
71
|
},
|
|
73
72
|
"devDependencies": {
|
|
74
73
|
"@nuxt/devtools": "^0.5.5",
|
|
75
74
|
"@nuxt/module-builder": "^0.3.1",
|
|
76
|
-
"@nuxt/test-utils": "^3.
|
|
77
|
-
"@nuxt/types": "^2.
|
|
75
|
+
"@nuxt/test-utils": "^3.6.1",
|
|
76
|
+
"@nuxt/types": "^2.17.0",
|
|
78
77
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|
|
79
78
|
"@nuxtjs/i18n": "8.0.0-beta.10",
|
|
80
79
|
"@nuxtjs/web-vitals": "^0.2.6",
|
|
81
80
|
"@types/lodash-es": "^4.17.7",
|
|
82
|
-
"@types/node": "^20.
|
|
83
|
-
"@types/prettier": "^2.7.
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
85
|
-
"@typescript-eslint/parser": "^5.
|
|
86
|
-
"@vue/test-utils": "^2.
|
|
81
|
+
"@types/node": "^20.3.3",
|
|
82
|
+
"@types/prettier": "^2.7.3",
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
|
84
|
+
"@typescript-eslint/parser": "^5.61.0",
|
|
85
|
+
"@vue/test-utils": "^2.4.0",
|
|
87
86
|
"bumpp": "9.1.0",
|
|
88
87
|
"changelogithub": "0.12.11",
|
|
89
88
|
"cross-env": "^7.0.3",
|
|
90
89
|
"eslint": "8.41.0",
|
|
91
90
|
"eslint-config-prettier": "^8.8.0",
|
|
92
|
-
"eslint-plugin-vue": "^9.
|
|
91
|
+
"eslint-plugin-vue": "^9.15.1",
|
|
93
92
|
"nuxt": "3.5.1",
|
|
94
93
|
"nuxt-seo-kit": "1.3.8",
|
|
95
94
|
"playwright": "1.34.3",
|
|
96
95
|
"tsd": "^0.28.1",
|
|
97
|
-
"typescript": "^5.
|
|
98
|
-
"vitest": "^0.31.
|
|
99
|
-
"vue-eslint-parser": "^9.3.
|
|
100
|
-
"vue-router": "^4.2.
|
|
101
|
-
"vue-tsc": "^1.
|
|
96
|
+
"typescript": "^5.1.6",
|
|
97
|
+
"vitest": "^0.31.4",
|
|
98
|
+
"vue-eslint-parser": "^9.3.1",
|
|
99
|
+
"vue-router": "^4.2.2",
|
|
100
|
+
"vue-tsc": "^1.8.4",
|
|
101
|
+
"prettier": "2.8.8"
|
|
102
102
|
}
|
|
103
103
|
}
|