@maxelms/create-plugin-cli 1.1.0

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 (274) hide show
  1. package/README.en.md +36 -0
  2. package/README.md +12 -0
  3. package/bin/build.js +29 -0
  4. package/bin/compress.js +35 -0
  5. package/bin/copy.js +39 -0
  6. package/bin/index.js +53 -0
  7. package/configuration-schema.json +829 -0
  8. package/lib/index.d.ts +21 -0
  9. package/lib/index.js +242 -0
  10. package/lib/utils.d.ts +18 -0
  11. package/lib/utils.js +114 -0
  12. package/package.json +50 -0
  13. package/templates/jQuery-micro-app/package.json.tpl +19 -0
  14. package/templates/jQuery-micro-app/src/README.md +5 -0
  15. package/templates/jQuery-micro-app/src/configuration.json +30 -0
  16. package/templates/jQuery-micro-app/src/index.html +17 -0
  17. package/templates/jQuery-micro-app/src/main.js.tpl +31 -0
  18. package/templates/jQuery-micro-app/src/manifest.json.tpl +9 -0
  19. package/templates/jQuery-micro-app/src/style.css +11 -0
  20. package/templates/maxelms-navigation/.babelrc +7 -0
  21. package/templates/maxelms-navigation/.gitignore.tpl +23 -0
  22. package/templates/maxelms-navigation/README.md +15 -0
  23. package/templates/maxelms-navigation/global.d.ts +2 -0
  24. package/templates/maxelms-navigation/index.html +16 -0
  25. package/templates/maxelms-navigation/package.json +65 -0
  26. package/templates/maxelms-navigation/patches/live2d-widget@3.1.4.patch +4534 -0
  27. package/templates/maxelms-navigation/pnpm-lock.yaml +7993 -0
  28. package/templates/maxelms-navigation/src/App.tsx +47 -0
  29. package/templates/maxelms-navigation/src/components/Actions/ColorPicker.tsx +86 -0
  30. package/templates/maxelms-navigation/src/components/Actions/SwitchApps.tsx +83 -0
  31. package/templates/maxelms-navigation/src/components/Actions/index.tsx +95 -0
  32. package/templates/maxelms-navigation/src/components/Cutie.tsx +24 -0
  33. package/templates/maxelms-navigation/src/components/Enterprises.tsx +46 -0
  34. package/templates/maxelms-navigation/src/components/Logo.tsx +29 -0
  35. package/templates/maxelms-navigation/src/components/Menus/MenuPanel.tsx +55 -0
  36. package/templates/maxelms-navigation/src/components/Menus/index.tsx +50 -0
  37. package/templates/maxelms-navigation/src/components/Search.tsx +77 -0
  38. package/templates/maxelms-navigation/src/imgs/corp-admin.svg +1 -0
  39. package/templates/maxelms-navigation/src/imgs/saas-admin.svg +1 -0
  40. package/templates/maxelms-navigation/src/imgs/skin.svg +1 -0
  41. package/templates/maxelms-navigation/src/imgs/tenant-admin.svg +1 -0
  42. package/templates/maxelms-navigation/src/imgs/user-center.svg +1 -0
  43. package/templates/maxelms-navigation/src/index.tsx +14 -0
  44. package/templates/maxelms-navigation/src/interface.ts +27 -0
  45. package/templates/maxelms-navigation/src/style.less.tpl +278 -0
  46. package/templates/maxelms-navigation/src/utils.ts.tpl +40 -0
  47. package/templates/maxelms-navigation/tsconfig.json +111 -0
  48. package/templates/maxelms-navigation/webpack.config.js +119 -0
  49. package/templates/maxelms-script/.babelrc +5 -0
  50. package/templates/maxelms-script/.gitignore.tpl +23 -0
  51. package/templates/maxelms-script/README.md +0 -0
  52. package/templates/maxelms-script/global.d.ts +2 -0
  53. package/templates/maxelms-script/index.html +10 -0
  54. package/templates/maxelms-script/package.json.tpl +55 -0
  55. package/templates/maxelms-script/pnpm-lock.yaml +7699 -0
  56. package/templates/maxelms-script/src/App.tsx +15 -0
  57. package/templates/maxelms-script/src/index.tsx +15 -0
  58. package/templates/maxelms-script/src/style.less.tpl +8 -0
  59. package/templates/maxelms-script/src/utils.ts.tpl +2 -0
  60. package/templates/maxelms-script/tsconfig.json +111 -0
  61. package/templates/maxelms-script/webpack.config.js +92 -0
  62. package/templates/maxelms-style/.gitignore.tpl +38 -0
  63. package/templates/maxelms-style/README.md +0 -0
  64. package/templates/maxelms-style/index.css +3 -0
  65. package/templates/maxelms-style/index.less +4 -0
  66. package/templates/maxelms-style/package.json.tpl +17 -0
  67. package/templates/playground/dist/main.css +2 -0
  68. package/templates/playground/dist/main.js +2 -0
  69. package/templates/playground/dist/main.js.LICENSE.txt +52 -0
  70. package/templates/playground/dist/playground.html +1 -0
  71. package/templates/playground/dist/react-dom.production.min.js +2 -0
  72. package/templates/playground/dist/react-dom.production.min.js.LICENSE.txt +8 -0
  73. package/templates/playground/dist/react.production.min.js +2 -0
  74. package/templates/playground/dist/react.production.min.js.LICENSE.txt +8 -0
  75. package/templates/playground/dist/zone.umd.min.js +2 -0
  76. package/templates/playground/dist/zone.umd.min.js.LICENSE.txt +29 -0
  77. package/templates/project/package.json +17 -0
  78. package/templates/react-micro-app/.babelrc +6 -0
  79. package/templates/react-micro-app/.gitignore.tpl +23 -0
  80. package/templates/react-micro-app/README.md +5 -0
  81. package/templates/react-micro-app/manifest.json.tpl +21 -0
  82. package/templates/react-micro-app/package.json.tpl +53 -0
  83. package/templates/react-micro-app/public/configuration.json +30 -0
  84. package/templates/react-micro-app/public/index.html +10 -0
  85. package/templates/react-micro-app/src/components/NoMatch.tsx +15 -0
  86. package/templates/react-micro-app/src/context/masterContext.ts +11 -0
  87. package/templates/react-micro-app/src/index.tsx +52 -0
  88. package/templates/react-micro-app/src/layouts/BasicLayout.less +16 -0
  89. package/templates/react-micro-app/src/layouts/BasicLayout.tsx +21 -0
  90. package/templates/react-micro-app/src/pages/Home/index.less +15 -0
  91. package/templates/react-micro-app/src/pages/Home/index.tsx +33 -0
  92. package/templates/react-micro-app/src/pages/List/index.less +12 -0
  93. package/templates/react-micro-app/src/pages/List/index.tsx +12 -0
  94. package/templates/react-micro-app/src/pages/New/index.less +12 -0
  95. package/templates/react-micro-app/src/pages/New/index.tsx +12 -0
  96. package/templates/react-micro-app/src/pages/View/index.less +12 -0
  97. package/templates/react-micro-app/src/pages/View/index.tsx +12 -0
  98. package/templates/react-micro-app/src/public-path.js +4 -0
  99. package/templates/react-micro-app/src/router.tsx +44 -0
  100. package/templates/react-micro-app/tsconfig.json +102 -0
  101. package/templates/react-micro-app/typings.d.ts +11 -0
  102. package/templates/react-micro-app/webpack.config.js.tpl +178 -0
  103. package/templates/react-micro-app-umi/.editorconfig +16 -0
  104. package/templates/react-micro-app-umi/.env +1 -0
  105. package/templates/react-micro-app-umi/.gitignore.tpl +23 -0
  106. package/templates/react-micro-app-umi/.prettierignore +8 -0
  107. package/templates/react-micro-app-umi/.prettierrc +11 -0
  108. package/templates/react-micro-app-umi/.umirc.ts.tpl +31 -0
  109. package/templates/react-micro-app-umi/README.md +5 -0
  110. package/templates/react-micro-app-umi/manifest.json.tpl +21 -0
  111. package/templates/react-micro-app-umi/package.json.tpl +42 -0
  112. package/templates/react-micro-app-umi/public/basicConfiguration.json +30 -0
  113. package/templates/react-micro-app-umi/public/configuration.json +30 -0
  114. package/templates/react-micro-app-umi/src/layout/BasicLayout.tsx +16 -0
  115. package/templates/react-micro-app-umi/src/pages/about.tsx +11 -0
  116. package/templates/react-micro-app-umi/src/pages/home.tsx +19 -0
  117. package/templates/react-micro-app-umi/tsconfig.json +36 -0
  118. package/templates/react-micro-app-umi/typings.d.ts +8 -0
  119. package/templates/react-micro-button/.gitignore.tpl +23 -0
  120. package/templates/react-micro-button/README.md +5 -0
  121. package/templates/react-micro-button/configuration/Configuration.tsx +113 -0
  122. package/templates/react-micro-button/configuration/index.css +8 -0
  123. package/templates/react-micro-button/configuration/index.tsx +6 -0
  124. package/templates/react-micro-button/manifest.json.tpl +3 -0
  125. package/templates/react-micro-button/package.json.tpl +49 -0
  126. package/templates/react-micro-button/postcss.config.js +5 -0
  127. package/templates/react-micro-button/public/basicConfiguration.json +30 -0
  128. package/templates/react-micro-button/public/configuration.html +10 -0
  129. package/templates/react-micro-button/public/configuration.json +30 -0
  130. package/templates/react-micro-button/public/index.html +10 -0
  131. package/templates/react-micro-button/src/App.tsx +41 -0
  132. package/templates/react-micro-button/src/app.less +0 -0
  133. package/templates/react-micro-button/src/index.less +0 -0
  134. package/templates/react-micro-button/src/index.tsx +30 -0
  135. package/templates/react-micro-button/tsconfig.json +11 -0
  136. package/templates/react-micro-button/webpack.config.js.tpl +150 -0
  137. package/templates/react-micro-field/.babelrc +5 -0
  138. package/templates/react-micro-field/.gitignore.tpl +23 -0
  139. package/templates/react-micro-field/README.md +5 -0
  140. package/templates/react-micro-field/configuration/Configuration.tsx +113 -0
  141. package/templates/react-micro-field/configuration/index.css +8 -0
  142. package/templates/react-micro-field/configuration/index.tsx +6 -0
  143. package/templates/react-micro-field/manifest.json.tpl +7 -0
  144. package/templates/react-micro-field/package.json.tpl +50 -0
  145. package/templates/react-micro-field/postcss.config.js +5 -0
  146. package/templates/react-micro-field/public/basicConfiguration.json +30 -0
  147. package/templates/react-micro-field/public/configuration.html +10 -0
  148. package/templates/react-micro-field/public/configuration.json +30 -0
  149. package/templates/react-micro-field/public/index.html +10 -0
  150. package/templates/react-micro-field/src/App.tsx.tpl +51 -0
  151. package/templates/react-micro-field/src/index.tsx +29 -0
  152. package/templates/react-micro-field/src/style.less.tpl +12 -0
  153. package/templates/react-micro-field/tsconfig.json +11 -0
  154. package/templates/react-micro-field/webpack.config.js.tpl +157 -0
  155. package/templates/react-micro-field-umi/.editorconfig +16 -0
  156. package/templates/react-micro-field-umi/.gitignore.tpl +24 -0
  157. package/templates/react-micro-field-umi/.prettierignore +8 -0
  158. package/templates/react-micro-field-umi/.prettierrc +11 -0
  159. package/templates/react-micro-field-umi/README.md +5 -0
  160. package/templates/react-micro-field-umi/config/config.ts.tpl +41 -0
  161. package/templates/react-micro-field-umi/config/plugin.ts +18 -0
  162. package/templates/react-micro-field-umi/manifest.json.tpl +7 -0
  163. package/templates/react-micro-field-umi/package.json.tpl +48 -0
  164. package/templates/react-micro-field-umi/public/basicConfiguration.json +30 -0
  165. package/templates/react-micro-field-umi/public/configuration.json +30 -0
  166. package/templates/react-micro-field-umi/src/app.tsx +46 -0
  167. package/templates/react-micro-field-umi/src/global.tsx +0 -0
  168. package/templates/react-micro-field-umi/src/hooks/masterProps.ts +33 -0
  169. package/templates/react-micro-field-umi/src/layouts/BasicLayout.tsx +17 -0
  170. package/templates/react-micro-field-umi/src/pages/configuration/index.tsx +90 -0
  171. package/templates/react-micro-field-umi/src/pages/index.tsx.tpl +54 -0
  172. package/templates/react-micro-field-umi/src/pages/interface.ts +12 -0
  173. package/templates/react-micro-field-umi/src/pages/style.less.tpl +15 -0
  174. package/templates/react-micro-field-umi/src/public-path.js +5 -0
  175. package/templates/react-micro-field-umi/tsconfig.json +37 -0
  176. package/templates/react-micro-field-umi/typings.d.ts +10 -0
  177. package/templates/react-micro-plugin/.babelrc +5 -0
  178. package/templates/react-micro-plugin/.gitignore.tpl +23 -0
  179. package/templates/react-micro-plugin/README.md +5 -0
  180. package/templates/react-micro-plugin/configuration/Configuration.tsx +114 -0
  181. package/templates/react-micro-plugin/configuration/index.css +8 -0
  182. package/templates/react-micro-plugin/configuration/index.tsx +6 -0
  183. package/templates/react-micro-plugin/manifest.json.tpl +3 -0
  184. package/templates/react-micro-plugin/package.json.tpl +50 -0
  185. package/templates/react-micro-plugin/postcss.config.js +5 -0
  186. package/templates/react-micro-plugin/public/configuration.html +10 -0
  187. package/templates/react-micro-plugin/public/configuration.json +30 -0
  188. package/templates/react-micro-plugin/public/index.html +10 -0
  189. package/templates/react-micro-plugin/src/App.tsx.tpl +32 -0
  190. package/templates/react-micro-plugin/src/index.tsx +29 -0
  191. package/templates/react-micro-plugin/src/style.less.tpl +12 -0
  192. package/templates/react-micro-plugin/tsconfig.json +11 -0
  193. package/templates/react-micro-plugin/webpack.config.js.tpl +156 -0
  194. package/templates/react-micro-plugin-umi/.editorconfig +16 -0
  195. package/templates/react-micro-plugin-umi/.gitignore.tpl +24 -0
  196. package/templates/react-micro-plugin-umi/.prettierignore +8 -0
  197. package/templates/react-micro-plugin-umi/.prettierrc +11 -0
  198. package/templates/react-micro-plugin-umi/README.md +5 -0
  199. package/templates/react-micro-plugin-umi/config/config.ts +29 -0
  200. package/templates/react-micro-plugin-umi/config/plugin.ts +18 -0
  201. package/templates/react-micro-plugin-umi/manifest.json.tpl +3 -0
  202. package/templates/react-micro-plugin-umi/package.json.tpl +48 -0
  203. package/templates/react-micro-plugin-umi/public/configuration.json +30 -0
  204. package/templates/react-micro-plugin-umi/src/app.tsx +46 -0
  205. package/templates/react-micro-plugin-umi/src/global.tsx +0 -0
  206. package/templates/react-micro-plugin-umi/src/hooks/masterProps.ts +34 -0
  207. package/templates/react-micro-plugin-umi/src/layouts/BasicLayout.tsx +17 -0
  208. package/templates/react-micro-plugin-umi/src/pages/configuration/index.tsx +113 -0
  209. package/templates/react-micro-plugin-umi/src/pages/index.tsx +21 -0
  210. package/templates/react-micro-plugin-umi/src/public-path.js +5 -0
  211. package/templates/react-micro-plugin-umi/tsconfig.json +37 -0
  212. package/templates/react-micro-plugin-umi/typings.d.ts +10 -0
  213. package/templates/vue-micro-app/.gitignore.tpl +23 -0
  214. package/templates/vue-micro-app/README.md +5 -0
  215. package/templates/vue-micro-app/babel.config.js +15 -0
  216. package/templates/vue-micro-app/manifest.json.tpl +21 -0
  217. package/templates/vue-micro-app/package.json.tpl +54 -0
  218. package/templates/vue-micro-app/public/configuration.json +30 -0
  219. package/templates/vue-micro-app/public/favicon.ico +0 -0
  220. package/templates/vue-micro-app/public/index.html +10 -0
  221. package/templates/vue-micro-app/src/App.vue +35 -0
  222. package/templates/vue-micro-app/src/assets/logo.png +0 -0
  223. package/templates/vue-micro-app/src/components/HelloWorld.vue +32 -0
  224. package/templates/vue-micro-app/src/main.js +80 -0
  225. package/templates/vue-micro-app/src/public-path.js +5 -0
  226. package/templates/vue-micro-app/src/routes.js +19 -0
  227. package/templates/vue-micro-app/src/views/About.vue +13 -0
  228. package/templates/vue-micro-app/src/views/Home.vue +21 -0
  229. package/templates/vue-micro-app/vue.config.js.tpl +35 -0
  230. package/templates/vue-micro-button/.gitignore.tpl +23 -0
  231. package/templates/vue-micro-button/README.md +5 -0
  232. package/templates/vue-micro-button/babel.config.js +8 -0
  233. package/templates/vue-micro-button/configuration/App.vue +78 -0
  234. package/templates/vue-micro-button/configuration/main.js +11 -0
  235. package/templates/vue-micro-button/manifest.json.tpl +3 -0
  236. package/templates/vue-micro-button/package.json.tpl +51 -0
  237. package/templates/vue-micro-button/public/basicConfiguration.json +30 -0
  238. package/templates/vue-micro-button/public/configuration.html +10 -0
  239. package/templates/vue-micro-button/public/configuration.json +30 -0
  240. package/templates/vue-micro-button/public/index.html +12 -0
  241. package/templates/vue-micro-button/src/App.vue +46 -0
  242. package/templates/vue-micro-button/src/main.js +44 -0
  243. package/templates/vue-micro-button/vue.config.js.tpl +51 -0
  244. package/templates/vue-micro-field/.gitignore.tpl +23 -0
  245. package/templates/vue-micro-field/README.md +5 -0
  246. package/templates/vue-micro-field/babel.config.js +8 -0
  247. package/templates/vue-micro-field/configuration/App.vue +78 -0
  248. package/templates/vue-micro-field/configuration/main.js +11 -0
  249. package/templates/vue-micro-field/manifest.json.tpl +7 -0
  250. package/templates/vue-micro-field/package.json.tpl +53 -0
  251. package/templates/vue-micro-field/public/basicConfiguration.json +30 -0
  252. package/templates/vue-micro-field/public/configuration.html +10 -0
  253. package/templates/vue-micro-field/public/configuration.json +30 -0
  254. package/templates/vue-micro-field/public/index.html +10 -0
  255. package/templates/vue-micro-field/scripts/compress.js +32 -0
  256. package/templates/vue-micro-field/src/App.vue.tpl +55 -0
  257. package/templates/vue-micro-field/src/main.js +38 -0
  258. package/templates/vue-micro-field/src/style.less.tpl +16 -0
  259. package/templates/vue-micro-field/vue.config.js.tpl +51 -0
  260. package/templates/vue-micro-plugin/.gitignore.tpl +23 -0
  261. package/templates/vue-micro-plugin/README.md +24 -0
  262. package/templates/vue-micro-plugin/babel.config.js +8 -0
  263. package/templates/vue-micro-plugin/configuration/App.vue +100 -0
  264. package/templates/vue-micro-plugin/configuration/main.js +11 -0
  265. package/templates/vue-micro-plugin/manifest.json.tpl +3 -0
  266. package/templates/vue-micro-plugin/package.json.tpl +56 -0
  267. package/templates/vue-micro-plugin/public/configuration.html +10 -0
  268. package/templates/vue-micro-plugin/public/configuration.json +30 -0
  269. package/templates/vue-micro-plugin/public/index.html +10 -0
  270. package/templates/vue-micro-plugin/scripts/compress.js +32 -0
  271. package/templates/vue-micro-plugin/src/App.vue.tpl +42 -0
  272. package/templates/vue-micro-plugin/src/main.js +38 -0
  273. package/templates/vue-micro-plugin/src/style.less.tpl +16 -0
  274. package/templates/vue-micro-plugin/vue.config.js.tpl +53 -0
package/lib/index.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /** 项目类型 */
2
+ declare enum ProjectTypeEnum {
3
+ MICROAPP = "micro-app",
4
+ MICROFIELD = "micro-field",
5
+ MICROPLUGIN = "micro-plugin",
6
+ MICROBUTTON = "micro-button",
7
+ NAV = "nav",
8
+ STYLE = "style",
9
+ SCRIPT = "script"
10
+ }
11
+ declare enum ConfigTypeEnum {
12
+ JSON = "json",
13
+ HTML = "html"
14
+ }
15
+ declare const create: (pluginName: string, options: {
16
+ PROJECT_TYPE: keyof typeof ProjectTypeEnum;
17
+ PROJECT_FRAME: string;
18
+ PROJECT_CONFIG_TYPE: keyof typeof ConfigTypeEnum;
19
+ TEMPLATE: string;
20
+ }) => Promise<void>;
21
+ export default create;
package/lib/index.js ADDED
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var fs_1 = __importDefault(require("fs"));
43
+ var path_1 = __importDefault(require("path"));
44
+ var chalk_1 = __importDefault(require("chalk"));
45
+ var figlet_1 = __importDefault(require("figlet"));
46
+ var inquirer_1 = __importDefault(require("inquirer"));
47
+ var uuid_1 = require("uuid");
48
+ var utils_1 = require("./utils");
49
+ var pkg = require('../package.json');
50
+ var cliVersion = pkg.version;
51
+ var frameworks = ['react', 'vue'];
52
+ var jQuery = 'jQuery';
53
+ var templates = ['umi'];
54
+ /** 项目类型 */
55
+ var ProjectTypeEnum;
56
+ (function (ProjectTypeEnum) {
57
+ ProjectTypeEnum["MICROAPP"] = "micro-app";
58
+ ProjectTypeEnum["MICROFIELD"] = "micro-field";
59
+ ProjectTypeEnum["MICROPLUGIN"] = "micro-plugin";
60
+ ProjectTypeEnum["MICROBUTTON"] = "micro-button";
61
+ ProjectTypeEnum["NAV"] = "nav";
62
+ ProjectTypeEnum["STYLE"] = "style";
63
+ ProjectTypeEnum["SCRIPT"] = "script";
64
+ })(ProjectTypeEnum || (ProjectTypeEnum = {}));
65
+ // 配置类型
66
+ var ConfigTypeEnum;
67
+ (function (ConfigTypeEnum) {
68
+ ConfigTypeEnum["JSON"] = "json";
69
+ ConfigTypeEnum["HTML"] = "html";
70
+ })(ConfigTypeEnum || (ConfigTypeEnum = {}));
71
+ var create = function (pluginName, options) { return __awaiter(void 0, void 0, void 0, function () {
72
+ var targetDir, PROJECT_TYPE, PROJECT_FRAME, PROJECT_CONFIG_TYPE, _a, TEMPLATE, type, _b, framework, configurationType, choices, _c, _d, templateName, templateDir, ignore, files, ejsData;
73
+ return __generator(this, function (_e) {
74
+ switch (_e.label) {
75
+ case 0:
76
+ console.log(figlet_1.default.textSync('maxelms cli'));
77
+ targetDir = path_1.default.resolve(process.cwd(), pluginName);
78
+ if (fs_1.default.existsSync(targetDir)) {
79
+ console.log(chalk_1.default.redBright("\n Folder (".concat(pluginName, ") already exists!\n\n \u9879\u76EE\u540D\u79F0\u51B2\u7A81\uFF0C\u8BF7\u91CD\u65B0\u547D\u540D\u3002\n ")));
80
+ return [2 /*return*/];
81
+ }
82
+ PROJECT_TYPE = options.PROJECT_TYPE, PROJECT_FRAME = options.PROJECT_FRAME, PROJECT_CONFIG_TYPE = options.PROJECT_CONFIG_TYPE, _a = options.TEMPLATE, TEMPLATE = _a === void 0 ? '' : _a;
83
+ _b = ProjectTypeEnum[PROJECT_TYPE];
84
+ if (_b) return [3 /*break*/, 2];
85
+ return [4 /*yield*/, inquirer_1.default.prompt({
86
+ name: 'type',
87
+ type: 'list',
88
+ message: '请选择项目类型:',
89
+ choices: [
90
+ {
91
+ name: '页面组件(组件将会在布局设计器中作为基础物料拖拽使用)',
92
+ value: ProjectTypeEnum.MICROPLUGIN
93
+ },
94
+ {
95
+ name: '字段组件(替换系统内置字段组件)',
96
+ value: ProjectTypeEnum.MICROFIELD
97
+ },
98
+ {
99
+ name: '微应用(可以在业务前台、业务后台)',
100
+ value: ProjectTypeEnum.MICROAPP
101
+ },
102
+ {
103
+ name: '按钮组件(自定义标准对象按钮行为、扩展业务后台)',
104
+ value: ProjectTypeEnum.MICROBUTTON
105
+ },
106
+ // {
107
+ // name: '导航组件(替换系统内置的导航组件)',
108
+ // value: ProjectTypeEnum.NAV
109
+ // },
110
+ {
111
+ name: '主题样式(通过 css 样式表覆盖系统默认样式)',
112
+ value: ProjectTypeEnum.STYLE
113
+ },
114
+ // {
115
+ // name: '扩展脚本(在系统初始化时加载并执行指定的 js 文件)',
116
+ // value: ProjectTypeEnum.SCRIPT
117
+ // },
118
+ ],
119
+ }).then(function (re) { return re.type; })];
120
+ case 1:
121
+ _b = (_e.sent());
122
+ _e.label = 2;
123
+ case 2:
124
+ type = _b;
125
+ framework = '';
126
+ configurationType = '';
127
+ if (!![
128
+ ProjectTypeEnum.NAV,
129
+ ProjectTypeEnum.STYLE,
130
+ ProjectTypeEnum.SCRIPT
131
+ ].includes(type)) return [3 /*break*/, 7];
132
+ choices = frameworks.map(function (framework) {
133
+ return {
134
+ name: framework,
135
+ value: framework,
136
+ };
137
+ });
138
+ if (type === ProjectTypeEnum.MICROAPP)
139
+ choices.push({
140
+ name: jQuery,
141
+ value: jQuery
142
+ });
143
+ _c = PROJECT_FRAME;
144
+ if (_c) return [3 /*break*/, 4];
145
+ return [4 /*yield*/, inquirer_1.default.prompt({
146
+ name: 'framework',
147
+ type: 'list',
148
+ message: '请选择前端框架:',
149
+ choices: choices,
150
+ }).then(function (re) { return re.framework; })];
151
+ case 3:
152
+ _c = (_e.sent());
153
+ _e.label = 4;
154
+ case 4:
155
+ framework = _c;
156
+ if (!(type === ProjectTypeEnum.MICROFIELD || type === ProjectTypeEnum.MICROPLUGIN || type === ProjectTypeEnum.MICROBUTTON)) return [3 /*break*/, 7];
157
+ _d = ConfigTypeEnum[PROJECT_CONFIG_TYPE];
158
+ if (_d) return [3 /*break*/, 6];
159
+ return [4 /*yield*/, inquirer_1.default.prompt({
160
+ name: 'configurationType',
161
+ type: 'list',
162
+ message: '请选择配置类型:',
163
+ choices: Object.keys(ConfigTypeEnum).map(function (key) {
164
+ return {
165
+ name: key,
166
+ value: ConfigTypeEnum[key],
167
+ };
168
+ }),
169
+ }).then(function (re) { return re.configurationType; })];
170
+ case 5:
171
+ _d = (_e.sent());
172
+ _e.label = 6;
173
+ case 6:
174
+ configurationType = _d;
175
+ _e.label = 7;
176
+ case 7:
177
+ templateName = "".concat(framework, "-").concat(type);
178
+ if (type === ProjectTypeEnum.NAV) {
179
+ templateName = 'maxelms-navigation';
180
+ }
181
+ if (type === ProjectTypeEnum.STYLE) {
182
+ templateName = 'maxelms-style';
183
+ }
184
+ if (type === ProjectTypeEnum.SCRIPT) {
185
+ templateName = 'maxelms-script';
186
+ }
187
+ // React 字段、页面组件,增加 umi 模版
188
+ if (framework === 'react') {
189
+ if (TEMPLATE && templates.includes(TEMPLATE))
190
+ templateName += "-".concat(TEMPLATE);
191
+ }
192
+ templateDir = path_1.default.resolve(__dirname, "../templates/".concat(templateName));
193
+ ignore = [];
194
+ if (configurationType === ConfigTypeEnum.JSON) {
195
+ ignore.push.apply(ignore, ['**/configuration/**', '**/configuration.html']);
196
+ }
197
+ return [4 /*yield*/, (0, utils_1.readFiles)(templateDir, ignore)];
198
+ case 8:
199
+ files = _e.sent();
200
+ ejsData = {
201
+ pluginName: pluginName,
202
+ configurationType: configurationType,
203
+ timestamp: new Date().getTime(),
204
+ uniqueIdentifier: (0, uuid_1.v4)(),
205
+ cliVersion: cliVersion,
206
+ };
207
+ (0, utils_1.replaceTplVars)(files, ejsData);
208
+ return [4 /*yield*/, (0, utils_1.writeFiles)(targetDir, files)];
209
+ case 9:
210
+ _e.sent();
211
+ if (![
212
+ ProjectTypeEnum.MICROFIELD,
213
+ ProjectTypeEnum.MICROPLUGIN,
214
+ ].includes(type)) return [3 /*break*/, 11];
215
+ return [4 /*yield*/, createPlayground(targetDir)];
216
+ case 10:
217
+ _e.sent();
218
+ _e.label = 11;
219
+ case 11:
220
+ console.log(chalk_1.default.greenBright("\n \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01\n\n cd ".concat(pluginName, "\n\n yarn && yarn start\n ")));
221
+ return [2 /*return*/];
222
+ }
223
+ });
224
+ }); };
225
+ /** 将布局设计器加入项目模板 */
226
+ var createPlayground = function (targetDir) { return __awaiter(void 0, void 0, void 0, function () {
227
+ var playgroundDir, files;
228
+ return __generator(this, function (_a) {
229
+ switch (_a.label) {
230
+ case 0:
231
+ playgroundDir = path_1.default.resolve(__dirname, "../templates/playground/dist");
232
+ return [4 /*yield*/, (0, utils_1.readFiles)(playgroundDir)];
233
+ case 1:
234
+ files = _a.sent();
235
+ return [4 /*yield*/, (0, utils_1.writeFiles)(targetDir + '/examples', files)];
236
+ case 2:
237
+ _a.sent();
238
+ return [2 /*return*/];
239
+ }
240
+ });
241
+ }); };
242
+ exports.default = create;
package/lib/utils.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ export declare function normalizeFilePaths(files: {
3
+ [prop: string]: string | Buffer;
4
+ }): {
5
+ [prop: string]: string | Buffer;
6
+ };
7
+ export declare function readFiles(context: string, ignore?: string[]): Promise<{
8
+ [prop: string]: string | Buffer;
9
+ }>;
10
+ /**
11
+ * 替换模板文件中的变量
12
+ * @param files
13
+ * @param ejsData
14
+ */
15
+ export declare const replaceTplVars: (files: Record<string, string | Buffer>, ejsData: Record<string, any>) => void;
16
+ export declare function writeFiles(dir: string, files: {
17
+ [prop: string]: string | Buffer;
18
+ }): Promise<void>;
package/lib/utils.js ADDED
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.writeFiles = exports.replaceTplVars = exports.readFiles = exports.normalizeFilePaths = void 0;
43
+ var ejs_1 = __importDefault(require("ejs"));
44
+ var fs_extra_1 = __importDefault(require("fs-extra"));
45
+ var path_1 = __importDefault(require("path"));
46
+ var slash_1 = __importDefault(require("slash"));
47
+ var globby_1 = __importDefault(require("globby"));
48
+ function normalizeFilePaths(files) {
49
+ Object.keys(files).forEach(function (file) {
50
+ var normalized = (0, slash_1.default)(file);
51
+ if (file !== normalized) {
52
+ files[normalized] = files[file];
53
+ delete files[file];
54
+ }
55
+ });
56
+ return files;
57
+ }
58
+ exports.normalizeFilePaths = normalizeFilePaths;
59
+ function readFiles(context, ignore) {
60
+ if (ignore === void 0) { ignore = []; }
61
+ return __awaiter(this, void 0, void 0, function () {
62
+ var files, res, _i, files_1, file, name_1;
63
+ return __generator(this, function (_a) {
64
+ switch (_a.label) {
65
+ case 0: return [4 /*yield*/, (0, globby_1.default)(['**'], {
66
+ cwd: context,
67
+ onlyFiles: true,
68
+ gitignore: true,
69
+ ignore: ['**/node_modules/**', '**/.git/**', '**/.svn/**'].concat(ignore),
70
+ dot: true,
71
+ })];
72
+ case 1:
73
+ files = _a.sent();
74
+ res = {};
75
+ for (_i = 0, files_1 = files; _i < files_1.length; _i++) {
76
+ file = files_1[_i];
77
+ name_1 = path_1.default.resolve(context, file);
78
+ res[file] = fs_extra_1.default.readFileSync(name_1);
79
+ }
80
+ return [2 /*return*/, normalizeFilePaths(res)];
81
+ }
82
+ });
83
+ });
84
+ }
85
+ exports.readFiles = readFiles;
86
+ /**
87
+ * 替换模板文件中的变量
88
+ * @param files
89
+ * @param ejsData
90
+ */
91
+ var replaceTplVars = function (files, ejsData) {
92
+ Object.keys(files).forEach(function (name) {
93
+ if (name.endsWith('.tpl')) {
94
+ var rawName = name.replace('.tpl', '');
95
+ var fileInfo = files[name].toString();
96
+ files[rawName] = ejs_1.default.render(fileInfo, ejsData);
97
+ delete files[name];
98
+ }
99
+ });
100
+ };
101
+ exports.replaceTplVars = replaceTplVars;
102
+ function writeFiles(dir, files) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ Object.keys(files).forEach(function (name) {
106
+ var filePath = path_1.default.join(dir, name);
107
+ fs_extra_1.default.ensureDirSync(path_1.default.dirname(filePath));
108
+ fs_extra_1.default.writeFileSync(filePath, files[name]);
109
+ });
110
+ return [2 /*return*/];
111
+ });
112
+ });
113
+ }
114
+ exports.writeFiles = writeFiles;
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@maxelms/create-plugin-cli",
3
+ "version": "1.1.0",
4
+ "main": "./bin/index.js",
5
+ "author": "jackc_001",
6
+ "bin": {
7
+ "create-plugin-cli": "./bin/index.js",
8
+ "maxelms-plugin-cli": "./bin/build.js"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "lib",
13
+ "templates",
14
+ "configuration-schema.json"
15
+ ],
16
+ "scripts": {
17
+ "test": "echo \"Error: no test specified\" && exit 1",
18
+ "build": "tsc",
19
+ "watch": "tsc -w",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "registry": "https://registry.npmjs.org/"
25
+ },
26
+ "dependencies": {
27
+ "archiver": "5.3.1",
28
+ "chalk": "4.0.0",
29
+ "commander": "8.2.0",
30
+ "del": "6.1.1",
31
+ "ejs": "3.1.6",
32
+ "figlet": "1.5.2",
33
+ "fs-extra": "10.0.0",
34
+ "globby": "11.0.4",
35
+ "inquirer": "8.2.0",
36
+ "slash": "3.0.0",
37
+ "uuid": "8.3.2"
38
+ },
39
+ "keywords": [],
40
+ "license": "ISC",
41
+ "devDependencies": {
42
+ "@types/ejs": "3.1.0",
43
+ "@types/figlet": "1.5.4",
44
+ "@types/fs-extra": "9.0.13",
45
+ "@types/inquirer": "8.1.3",
46
+ "@types/uuid": "8.3.4",
47
+ "typescript": "4.7.3"
48
+ },
49
+ "gitHead": "d034472e8762a7b6ff01bafec131911ded8b2d51"
50
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "<%= pluginName %>",
3
+ "version": "1.0.0",
4
+ "description": "<%= pluginName %>",
5
+ "main": "index.html",
6
+ "scripts": {
7
+ "start": "cross-env PORT=8080 http-server ./src --cors",
8
+ "build": "maxelms-plugin-cli -cp ./src -c",
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "keywords": [],
12
+ "author": "",
13
+ "license": "ISC",
14
+ "devDependencies": {
15
+ "@maxelms/create-plugin-cli": "<%= cliVersion %>",
16
+ "cross-env": "7.0.3",
17
+ "http-server": "14.1.1"
18
+ }
19
+ }
@@ -0,0 +1,5 @@
1
+ # Maxelms MicroApp
2
+
3
+ ## 功能介绍
4
+
5
+ ## 使用说明
@@ -0,0 +1,30 @@
1
+ {
2
+ "propName1": {
3
+ "label": "配置项一",
4
+ "type": "string",
5
+ "defaultValue": "配置项内容"
6
+ },
7
+ "propName2": {
8
+ "label": "配置项二",
9
+ "type": "number",
10
+ "defaultValue": 350
11
+ },
12
+ "propName3": {
13
+ "label": "配置项三",
14
+ "type": "select",
15
+ "options": [
16
+ {
17
+ "label": "选项1",
18
+ "value": "option1"
19
+ },
20
+ {
21
+ "label": "选项2",
22
+ "value": "option2"
23
+ },
24
+ {
25
+ "label": "选项3",
26
+ "value": "option3"
27
+ }
28
+ ]
29
+ }
30
+ }
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Maxelms MicroApp</title>
6
+ <link rel="stylesheet" href="./style.css" />
7
+ <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
8
+ </head>
9
+ <body>
10
+ <div id="micro-app">
11
+ <div>
12
+ <input id="input" />
13
+ </div>
14
+ </div>
15
+ <script src="./main.js" entry></script>
16
+ </body>
17
+ </html>
@@ -0,0 +1,31 @@
1
+ const render = ($, props) => {
2
+ const {
3
+ menuInfo,
4
+ userInfo,
5
+ originalMenuProps
6
+ } = props
7
+
8
+ const text = userInfo ? `当前用户:${userInfo?.username || ''}, 当前菜单:${(menuInfo || originalMenuProps)?.name || ''}` : '欢迎使用 Maxelms 微应用'
9
+ $('#micro-app #input')?.val(text)
10
+
11
+ return Promise.resolve();
12
+ };
13
+
14
+ (global => {
15
+ global['micro-app-<%= uniqueIdentifier %>'] = {
16
+ bootstrap: () => {
17
+ console.log('micro-app bootstrap');
18
+ return Promise.resolve();
19
+ },
20
+ mount: (props) => {
21
+ console.log('micro mount');
22
+ return render($, props)
23
+ },
24
+ unmount: () => {
25
+ console.log('micro-app unmount');
26
+ return Promise.resolve();
27
+ },
28
+ };
29
+ })(window);
30
+
31
+ if (!window.__POWERED_BY_QIANKUN__) render($, {})
@@ -0,0 +1,9 @@
1
+ {
2
+ "routes": [
3
+ {
4
+ "title": "首页",
5
+ "value": "/"
6
+ }
7
+ ],
8
+ "deviceTypes": ["pc"]
9
+ }
@@ -0,0 +1,11 @@
1
+ #micro-app {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ flex-direction: column;
6
+ text-align: center
7
+ }
8
+
9
+ #micro-app input {
10
+ width: 350px;
11
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+
3
+
4
+ "plugins": [
5
+ ["import", { "libraryName": "antd", "style": true }]
6
+ ]
7
+ }
@@ -0,0 +1,23 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /npm-debug.log*
6
+ /yarn-error.log
7
+ /yarn.lock
8
+ /package-lock.json
9
+
10
+ # production
11
+ /dist
12
+
13
+ # misc
14
+ .DS_Store
15
+
16
+ # umi
17
+ /src/.umi
18
+ /src/.umi-production
19
+ /src/.umi-test
20
+ /.env.local
21
+ /dist.maxplugin
22
+ /dist.zip
23
+ /.vscode
@@ -0,0 +1,15 @@
1
+ # 🚀 Welcome to your new awesome project!
2
+
3
+ This project has been created using **webpack-cli**, you can now run
4
+
5
+ ```
6
+ npm run build
7
+ ```
8
+
9
+ or
10
+
11
+ ```
12
+ yarn build
13
+ ```
14
+
15
+ to bundle your application
@@ -0,0 +1,2 @@
1
+ declare module "*.less"
2
+ declare module "*.svg"
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Webpack App</title>
6
+ </head>
7
+ <body>
8
+ <div id="root">
9
+ <h1>Hello world!</h1>
10
+ </div>
11
+ </body>
12
+
13
+ <script>
14
+
15
+ </script>
16
+ </html>