create-pubinfo 2.0.2 → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 PUBINFO 腾龙框架
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { bootstrop, readPackageJSON, run, validateInput } from "./helper-D73z-FZU.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,6 +1,6 @@
1
- import { confirm, input, select } from "@inquirer/prompts";
1
+ import { checkbox, confirm, input, select } from "@inquirer/prompts";
2
2
  import consola from "consola";
3
- import { dirname, resolve } from "node:path";
3
+ import { dirname, relative, resolve } from "node:path";
4
4
  import process, { cwd } from "node:process";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { copy } from "fs-extra";
@@ -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",
@@ -44,12 +50,13 @@ async function generate(options) {
44
50
  const entries = await fs.promises.readdir(dir, { withFileTypes: true });
45
51
  for (const e of entries) {
46
52
  const srcPath = resolve(dir, e.name);
47
- const rel = srcPath.replace(`${baseDir}/`, "");
53
+ const rel = relative(baseDir, srcPath);
48
54
  if (e.isDirectory()) {
49
55
  await walk(srcPath);
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.2";
150
+ var version = "2.0.4";
136
151
  var description = "初始化项目框架";
137
152
  var author = "Werheng <werheng.zhang@gmail.com>";
138
153
  var license = "MIT";
@@ -160,7 +175,7 @@ var dependencies = {
160
175
  "commander": "catalog:node",
161
176
  "confbox": "catalog:node",
162
177
  "consola": "catalog:browser",
163
- "fs-extra": "^11.3.2",
178
+ "fs-extra": "catalog:node",
164
179
  "giget": "catalog:node",
165
180
  "node-plop": "catalog:node",
166
181
  "ofetch": "catalog:http",
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-D73z-FZU.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.2",
4
+ "version": "2.0.4",
5
5
  "description": "初始化项目框架",
6
6
  "author": "Werheng <werheng.zhang@gmail.com>",
7
7
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "commander": "^14.0.0",
32
32
  "confbox": "^0.2.2",
33
33
  "consola": "^3.4.2",
34
- "fs-extra": "^11.3.2",
34
+ "fs-extra": "^11.3.0",
35
35
  "giget": "^2.0.0",
36
36
  "node-plop": "0.32.1",
37
37
  "ofetch": "^1.4.1",
@@ -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
  });