vite-plugin-generoutes 0.2.9 → 0.2.11

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/index.d.ts CHANGED
@@ -12,30 +12,25 @@ interface Options {
12
12
  /**
13
13
  * pages folder
14
14
  *
15
- * default: `src/pages`
15
+ * @default src/pages
16
16
  */
17
17
  pagesFolder: string;
18
18
  /**
19
- * ignore folders
19
+ * ignore folders, ignore these folders when generating routes
20
20
  *
21
- * ignore these folders when generating routes
22
- *
23
- * default: `['components']`
21
+ * @default ['components']
24
22
  */
25
23
  ignoreFolders: string[];
26
24
  /**
27
- * routes file path
28
- *
29
- * default: `src/router/routes.js`
30
- *
31
- * It can also be a ts file,such as `src/router/routes.ts`
25
+ * routes file path, It can also be a ts file,such as `src/router/routes.ts`
32
26
  *
27
+ * @default src/router/routes.js
33
28
  */
34
29
  routesPath: string;
35
30
  /**
36
31
  * nested routes
37
32
  *
38
- * default: false
33
+ * @default false
39
34
  */
40
35
  nested: boolean;
41
36
  }
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import { parse } from "@vue/compiler-sfc";
6
6
  import { debounce, slash } from "@antfu/utils";
7
7
  import chokidar from "chokidar";
8
8
  import prettier from "prettier";
9
+ import chalk from "chalk";
9
10
 
10
11
  // src/utils.ts
11
12
  function toPascalCase(str) {
@@ -99,7 +100,7 @@ function VitePluginGeneroutes(options = {}) {
99
100
  routes: nested ? convertToTree(routes) : routes
100
101
  };
101
102
  }
102
- async function writerRoutesFile() {
103
+ async function writerRoutesFile(isInit = false) {
103
104
  const { routes } = generateMenusAndRoutes();
104
105
  let routesStr = `
105
106
  // Generated by vite-plugin-generoutes, don't modify it directly.
@@ -111,6 +112,7 @@ function VitePluginGeneroutes(options = {}) {
111
112
  const filePath = path.resolve(rootDir, routesPath);
112
113
  await fs.ensureDir(path.dirname(filePath));
113
114
  fs.writeFileSync(filePath, routesStr);
115
+ console.log(` \u2705 ${isInit ? "routes generated:" : "routes updated:"} ${chalk.cyan(routesPath)}`);
114
116
  }
115
117
  const debounceWriter = debounce(500, writerRoutesFile);
116
118
  let watcher;
@@ -132,9 +134,10 @@ function VitePluginGeneroutes(options = {}) {
132
134
  name: "vite-plugin-generoutes",
133
135
  async configResolved(config) {
134
136
  rootDir = config.root;
135
- await writerRoutesFile();
136
- if (config.command !== "build")
137
+ await writerRoutesFile(true);
138
+ if (config.command !== "build") {
137
139
  createWatcher();
140
+ }
138
141
  },
139
142
  async handleHotUpdate({ file, read }) {
140
143
  if (file.includes(pagesFolder) && !ignoreFolders.some((folder) => file.includes(`/${folder}/`)) && file.endsWith(".vue")) {
@@ -167,7 +170,7 @@ function parseDefineOptions(filePath, content) {
167
170
  }
168
171
  return {};
169
172
  }
170
- var src_default = VitePluginGeneroutes;
173
+ var index_default = VitePluginGeneroutes;
171
174
  export {
172
- src_default as default
175
+ index_default as default
173
176
  };
package/package.json CHANGED
@@ -1,83 +1,84 @@
1
- {
2
- "name": "vite-plugin-generoutes",
3
- "type": "module",
4
- "version": "0.2.9",
5
- "packageManager": "pnpm@9.9.0",
6
- "description": "A Vite plugin that generate routes based on the file structure, supports dynamic routes, and supports custom meta data for each route.",
7
- "author": "Ronnie Zhang <zclzone@outlook.com>",
8
- "license": "MIT",
9
- "homepage": "https://github.com/zclzone/vite-plugin-generoutes",
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/zclzone/vite-plugin-generoutes.git"
13
- },
14
- "bugs": "https://github.com/zclzone/vite-plugin-generoutes/issues",
15
- "keywords": [],
16
- "sideEffects": false,
17
- "exports": {
18
- ".": {
19
- "types": "./dist/index.d.ts",
20
- "import": "./dist/index.js"
21
- }
22
- },
23
- "main": "./dist/index.js",
24
- "module": "./dist/index.js",
25
- "types": "./dist/index.d.ts",
26
- "typesVersions": {
27
- "*": {
28
- "*": [
29
- "./dist/*",
30
- "./dist/index.d.ts"
31
- ]
32
- }
33
- },
34
- "files": [
35
- "dist"
36
- ],
37
- "scripts": {
38
- "start": "tsup --watch",
39
- "build": "tsup",
40
- "lint": "eslint .",
41
- "prepublishOnly": "nr build",
42
- "release": "bumpp && npm publish",
43
- "test": "vitest",
44
- "typecheck": "tsc --noEmit",
45
- "prepare": "simple-git-hooks",
46
- "up:deps": "taze major -I"
47
- },
48
- "peerDependencies": {
49
- "vite": "^5.2.11"
50
- },
51
- "dependencies": {
52
- "@antfu/utils": "^0.7.10",
53
- "@vue/compiler-sfc": "^3.4.38",
54
- "chokidar": "^3.6.0",
55
- "fs-extra": "^11.2.0",
56
- "glob": "^10.4.5",
57
- "prettier": "^3.3.3"
58
- },
59
- "devDependencies": {
60
- "@antfu/eslint-config": "^3.0.0",
61
- "@antfu/ni": "^0.23.0",
62
- "@types/fs-extra": "^11.0.4",
63
- "@types/node": "^20.16.2",
64
- "bumpp": "^9.5.2",
65
- "eslint": "^9.9.1",
66
- "esno": "^4.7.0",
67
- "lint-staged": "^15.2.9",
68
- "pnpm": "^9.9.0",
69
- "rimraf": "^5.0.10",
70
- "simple-git-hooks": "^2.11.1",
71
- "taze": "^0.16.7",
72
- "tsup": "^8.2.4",
73
- "typescript": "^5.5.4",
74
- "unbuild": "^2.0.0",
75
- "vitest": "^2.0.5"
76
- },
77
- "simple-git-hooks": {
78
- "pre-commit": "pnpm lint-staged"
79
- },
80
- "lint-staged": {
81
- "*": "eslint --fix"
82
- }
83
- }
1
+ {
2
+ "name": "vite-plugin-generoutes",
3
+ "type": "module",
4
+ "version": "0.2.11",
5
+ "packageManager": "pnpm@10.2.0",
6
+ "description": "A Vite plugin that generate routes based on the file structure, supports dynamic routes, and supports custom meta data for each route.",
7
+ "author": "Ronnie Zhang <zclzone@outlook.com>",
8
+ "license": "MIT",
9
+ "homepage": "https://github.com/zclzone/vite-plugin-generoutes",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/zclzone/vite-plugin-generoutes.git"
13
+ },
14
+ "bugs": "https://github.com/zclzone/vite-plugin-generoutes/issues",
15
+ "keywords": [],
16
+ "sideEffects": false,
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ }
22
+ },
23
+ "main": "./dist/index.js",
24
+ "module": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "typesVersions": {
27
+ "*": {
28
+ "*": [
29
+ "./dist/*",
30
+ "./dist/index.d.ts"
31
+ ]
32
+ }
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "scripts": {
38
+ "start": "tsup --watch",
39
+ "build": "tsup",
40
+ "lint": "eslint .",
41
+ "prepublishOnly": "nr build",
42
+ "release": "bumpp && npm publish",
43
+ "test": "vitest",
44
+ "typecheck": "tsc --noEmit",
45
+ "prepare": "simple-git-hooks",
46
+ "up:deps": "taze major -I"
47
+ },
48
+ "peerDependencies": {
49
+ "vite": "^6.1.0"
50
+ },
51
+ "dependencies": {
52
+ "@antfu/utils": "^8.1.0",
53
+ "@vue/compiler-sfc": "^3.5.13",
54
+ "chalk": "^5.4.1",
55
+ "chokidar": "^4.0.3",
56
+ "fs-extra": "^11.3.0",
57
+ "glob": "^11.0.1",
58
+ "prettier": "^3.4.2"
59
+ },
60
+ "devDependencies": {
61
+ "@antfu/eslint-config": "^4.1.1",
62
+ "@antfu/ni": "^23.3.1",
63
+ "@types/fs-extra": "^11.0.4",
64
+ "@types/node": "^20.17.17",
65
+ "bumpp": "^10.0.2",
66
+ "eslint": "^9.19.0",
67
+ "esno": "^4.8.0",
68
+ "lint-staged": "^15.4.3",
69
+ "pnpm": "^10.2.0",
70
+ "rimraf": "^5.0.10",
71
+ "simple-git-hooks": "^2.11.1",
72
+ "taze": "^18.4.0",
73
+ "tsup": "^8.3.6",
74
+ "typescript": "^5.7.3",
75
+ "unbuild": "^3.3.1",
76
+ "vitest": "^3.0.5"
77
+ },
78
+ "simple-git-hooks": {
79
+ "pre-commit": "pnpm lint-staged"
80
+ },
81
+ "lint-staged": {
82
+ "*": "eslint --fix"
83
+ }
84
+ }