vite-plugin-generoutes 0.0.9 → 0.0.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.
Files changed (2) hide show
  1. package/dist/index.js +4 -3
  2. package/package.json +3 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/index.ts
2
- import fs from "node:fs";
3
2
  import path from "node:path";
4
3
  import { exec } from "node:child_process";
4
+ import fs from "fs-extra";
5
5
  import { globSync } from "glob";
6
6
  import { parse } from "@vue/compiler-sfc";
7
7
  import { debounce, slash } from "@antfu/utils";
@@ -10,7 +10,7 @@ var defineOptionsCache = /* @__PURE__ */ new Map();
10
10
  function VitePluginGeneroutes() {
11
11
  let rootDir;
12
12
  let routesFolder;
13
- const writerRoutesFile = debounce(500, () => {
13
+ const writerRoutesFile = debounce(500, async () => {
14
14
  const { routes } = generateMenusAndRoutes();
15
15
  let routesStr = `
16
16
  // ! \u6B64\u6587\u4EF6\u6709plugin\u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u4FEE\u6539\uFF0C\u8BF7\u52FF\u4FEE\u6539\uFF0C\u8BF7\u52FF\u4FEE\u6539!!!
@@ -18,6 +18,7 @@ function VitePluginGeneroutes() {
18
18
  export const routes = ${JSON.stringify(routes, null, 2)}
19
19
  `;
20
20
  routesStr = routesStr.replace(/"##(.*)##"/g, (_, p1) => `() => import('${p1}')`);
21
+ await fs.ensureDir(routesFolder);
21
22
  fs.writeFileSync(routesFolder, routesStr);
22
23
  try {
23
24
  exec(`npx eslint --fix ${routesFolder}`);
@@ -28,7 +29,7 @@ function VitePluginGeneroutes() {
28
29
  name: "vite-plugin-generoutes",
29
30
  async configResolved(config) {
30
31
  rootDir = config.root;
31
- routesFolder = slash(path.resolve(rootDir, "src/router/routes.js"));
32
+ routesFolder = slash(path.resolve(rootDir, "src/router/generoutes.js"));
32
33
  chokidar.watch("src/pages/**/index.vue", { ignoreInitial: true }).on("all", (event, path2) => {
33
34
  if (event === "change")
34
35
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-plugin-generoutes",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
5
5
  "packageManager": "pnpm@9.1.1",
6
6
  "description": "_description_",
7
7
  "author": "Ronnie Zhang <zclzone@outlook.com>",
@@ -51,11 +51,13 @@
51
51
  "@antfu/utils": "^0.7.8",
52
52
  "@vue/compiler-sfc": "^3.4.27",
53
53
  "chokidar": "^3.6.0",
54
+ "fs-extra": "^11.2.0",
54
55
  "glob": "^10.4.1"
55
56
  },
56
57
  "devDependencies": {
57
58
  "@antfu/eslint-config": "^2.18.1",
58
59
  "@antfu/ni": "^0.21.12",
60
+ "@types/fs-extra": "^11.0.4",
59
61
  "@types/node": "^20.12.12",
60
62
  "bumpp": "^9.4.1",
61
63
  "eslint": "^9.3.0",