create-pubinfo 2.0.3 → 2.0.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/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { bootstrop, readPackageJSON, run, validateInput } from "./helper-CZfznJGY.js";
2
+ import { bootstrop, readPackageJSON, run, validateInput } from "./helper-CgK5iPAH.js";
3
3
  import { checkbox, confirm, input, select } from "@inquirer/prompts";
4
4
  import { Command } from "commander";
5
5
  import consola from "consola";
@@ -1,4 +1,4 @@
1
- import { confirm, input, select } from "@inquirer/prompts";
1
+ import { checkbox, confirm, input, select } from "@inquirer/prompts";
2
2
  import consola from "consola";
3
3
  import { dirname, relative, resolve } from "node:path";
4
4
  import process, { cwd } from "node:process";
@@ -29,8 +29,14 @@ async function generate(options) {
29
29
  const { templateName, templateDir, targetDir } = {
30
30
  templateDir: resolve(__dirname, "../templates"),
31
31
  targetDir: options.dir ? resolve(root, options.dir) : void 0,
32
+ openapi: false,
33
+ modules: [],
32
34
  ...options
33
35
  };
36
+ const plopOptions = {
37
+ ...options,
38
+ rbac: options.modules.includes("rbac")
39
+ };
34
40
  plop.setGenerator("generate", { actions: () => {
35
41
  return [{
36
42
  type: "addMany",
@@ -50,6 +56,7 @@ async function generate(options) {
50
56
  continue;
51
57
  }
52
58
  if (e.name.endsWith(".hbs")) continue;
59
+ if (!plopOptions.rbac && rel === "src/modules/rbac.ts") continue;
53
60
  const targetPath = resolve(targetDir, rel);
54
61
  await fs.promises.mkdir(resolve(targetPath, ".."), { recursive: true });
55
62
  await fs.promises.copyFile(srcPath, targetPath);
@@ -59,7 +66,7 @@ async function generate(options) {
59
66
  return `Copied raw files from ${templateName}`;
60
67
  }];
61
68
  } });
62
- await plop.getGenerator("generate").runActions(options);
69
+ await plop.getGenerator("generate").runActions(plopOptions);
63
70
  for (const [oldName, newName] of Object.entries({
64
71
  _gitignore: ".gitignore",
65
72
  _npmrc: ".npmrc"
@@ -107,6 +114,14 @@ async function interaction() {
107
114
  value: "pubinfo-module"
108
115
  }]
109
116
  });
117
+ answer.modules = await checkbox({
118
+ message: "选择需要的模块",
119
+ choices: [{
120
+ name: "用户权限管理(RBAC)",
121
+ value: "rbac",
122
+ checked: true
123
+ }]
124
+ });
110
125
  answer.openapi = await confirm({
111
126
  message: "运行时自动生成接口对接文件,若关闭可通过指令生成(openapi)",
112
127
  default: false
@@ -132,7 +147,7 @@ async function run(version$1) {
132
147
  //#region package.json
133
148
  var name = "create-pubinfo";
134
149
  var type = "module";
135
- var version = "2.0.3";
150
+ var version = "2.0.4";
136
151
  var description = "初始化项目框架";
137
152
  var author = "Werheng <werheng.zhang@gmail.com>";
138
153
  var license = "MIT";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  //#region src/interface.d.ts
2
2
  type TemplateName = 'pubinfo-app' | 'pubinfo-module';
3
+ type Module = 'rbac';
3
4
  interface Options {
4
5
  /**
5
6
  * 目录名称
@@ -17,6 +18,10 @@ interface Options {
17
18
  * 模板名称
18
19
  */
19
20
  templateName: TemplateName;
21
+ /**
22
+ * 模块插件列表
23
+ */
24
+ modules: Module[];
20
25
  }
21
26
  interface GenerateOptions extends Options {
22
27
  /**
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { copyTemplate, generate, interaction, readPackageJSON, run } from "./helper-CZfznJGY.js";
1
+ import { copyTemplate, generate, interaction, readPackageJSON, run } from "./helper-CgK5iPAH.js";
2
2
 
3
3
  export { copyTemplate, generate, interaction, readPackageJSON, run };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-pubinfo",
3
3
  "type": "module",
4
- "version": "2.0.3",
4
+ "version": "2.0.4",
5
5
  "description": "初始化项目框架",
6
6
  "author": "Werheng <werheng.zhang@gmail.com>",
7
7
  "license": "MIT",
@@ -23,7 +23,9 @@
23
23
  "dependencies": {
24
24
  "@ant-design/icons-vue": "^7.0.1",
25
25
  "@pubinfo/module-auth": "{{version}}",
26
+ {{#if rbac}}
26
27
  "@pubinfo/module-rbac": "{{version}}",
28
+ {{/if}}
27
29
  "@pubinfo/pro-components": "^1.7.1",
28
30
  "@vueuse/core": "^13.7.0",
29
31
  "alova": "^3.3.4",
@@ -2,7 +2,9 @@ import { createPubinfo } from 'pubinfo';
2
2
  import { auth, basic } from './api/request';
3
3
  import App from './App.vue';
4
4
  import { setupAuth } from './modules/auth';
5
+ {{#if rbac}}
5
6
  import { setupRbac } from './modules/rbac';
7
+ {{/if}}
6
8
  import { constantRoutes } from './routes';
7
9
  import './settings';
8
10
  import 'uno.css';
@@ -17,6 +19,8 @@ createPubinfo({
17
19
  },
18
20
  modules: [
19
21
  setupAuth(),
22
+ {{#if rbac}}
20
23
  setupRbac(),
24
+ {{/if}}
21
25
  ],
22
26
  });