@maxelms/create-plugin-cli 1.1.20 → 1.1.22

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 (30) hide show
  1. package/bin/compress.js +6 -3
  2. package/package.json +1 -1
  3. package/templates/playground/dist/main.js +1 -1
  4. package/templates/vue3-micro-button/src/App.vue.tpl +8 -2
  5. package/templates/vue3-micro-button/src/main.js +1 -3
  6. package/templates/vue3-micro-field/src/App.vue.tpl +14 -5
  7. package/templates/vue3-micro-field/src/main.js +1 -3
  8. package/templates/vue3-micro-plugin/src/App.vue.tpl +12 -3
  9. package/templates/vue3-micro-plugin/src/main.js +1 -3
  10. package/templates/vue3vite-micro-button/.editorconfig +6 -0
  11. package/templates/vue3vite-micro-button/.gitignore.tpl +23 -0
  12. package/templates/vue3vite-micro-button/.prettierrc.json +7 -0
  13. package/templates/vue3vite-micro-button/.vscode/extensions.json +9 -0
  14. package/templates/vue3vite-micro-button/README.md +48 -0
  15. package/templates/vue3vite-micro-button/env.d.ts +1 -0
  16. package/templates/vue3vite-micro-button/eslint.config.js +29 -0
  17. package/templates/vue3vite-micro-button/index.html +13 -0
  18. package/templates/vue3vite-micro-button/package.json.tpl +56 -0
  19. package/templates/vue3vite-micro-button/public/configuration.json +30 -0
  20. package/templates/vue3vite-micro-button/public/favicon.ico +0 -0
  21. package/templates/vue3vite-micro-button/scripts/devDistServe.cjs +16 -0
  22. package/templates/vue3vite-micro-button/src/App.vue.tpl +35 -0
  23. package/templates/vue3vite-micro-button/src/main.ts +39 -0
  24. package/templates/vue3vite-micro-button/src/typings.d.ts +8 -0
  25. package/templates/vue3vite-micro-button/tsconfig.app.json +14 -0
  26. package/templates/vue3vite-micro-button/tsconfig.json +14 -0
  27. package/templates/vue3vite-micro-button/tsconfig.node.json +19 -0
  28. package/templates/vue3vite-micro-button/tsconfig.vitest.json +11 -0
  29. package/templates/vue3vite-micro-button/vite.config.ts +24 -0
  30. package/templates/vue3vite-micro-button/vitest.config.ts +14 -0
@@ -16,10 +16,16 @@ if (process.env.NODE_ENV === 'development') {
16
16
 
17
17
  export default {
18
18
  name: 'App',
19
+ props: {
20
+ masterProps: {
21
+ type: Object,
22
+ default: () => ({})
23
+ }
24
+ },
19
25
  data() {
20
26
  return {
21
27
  visible: false,
22
- buttonName: this.$root?.masterProps?.originalButtonProps?.name,
28
+ buttonName: this.masterProps?.originalButtonProps?.name,
23
29
  }
24
30
  },
25
31
  components: {
@@ -29,7 +35,7 @@ export default {
29
35
 
30
36
  },
31
37
  created() {
32
-
38
+ console.log(this.masterProps)
33
39
  }
34
40
  }
35
41
  </script>
@@ -15,9 +15,7 @@ const vms = {}
15
15
  const render = (props) => {
16
16
  const { containerId } = props || {}
17
17
  createApp(App, {
18
- data: {
19
- masterProps: props || {}
20
- },
18
+ masterProps: props || {}
21
19
  }).mount(containerId ? `#${containerId} #root` : '#root');
22
20
  }
23
21
 
@@ -23,6 +23,12 @@ export default {
23
23
  name: 'App',
24
24
  components: {
25
25
  },
26
+ props: {
27
+ masterProps: {
28
+ type: Object,
29
+ default: () => ({})
30
+ }
31
+ },
26
32
  methods: {
27
33
  change(e) {
28
34
  this.onChange && this.onChange({
@@ -34,24 +40,27 @@ export default {
34
40
  computed: {
35
41
  /** value、onChange 是字段组件作为表单受控组件的必要属性 */
36
42
  value () {
37
- return this.$root?.masterProps?.value?.value || "欢迎使用 Maxelms 字段组件"
43
+ return this.masterProps?.value?.value || "欢迎使用 Maxelms 字段组件"
38
44
  },
39
45
  onChange () {
40
- return this.$root?.masterProps?.onChange
46
+ return this.masterProps?.onChange
41
47
  },
42
48
  /** 是否禁用 */
43
49
  disabled () {
44
- return this.$root?.masterProps?.configurations?.propName3
50
+ return this.masterProps?.configurations?.propName3
45
51
  },
46
52
  /** 控件宽度 */
47
53
  width () {
48
- return this.$root?.masterProps?.configurations?.propName2 || 350
54
+ return this.masterProps?.configurations?.propName2 || 350
49
55
  },
50
56
  /** 提示文本 */
51
57
  placeholder () {
52
- return this.$root?.masterProps?.configurations?.propName1
58
+ return this.masterProps?.configurations?.propName1
53
59
  },
54
60
  },
61
+ created() {
62
+ console.log(this.masterProps)
63
+ }
55
64
  }
56
65
  </script>
57
66
 
@@ -15,9 +15,7 @@ const vms = {}
15
15
  const render = (props) => {
16
16
  const { containerId } = props || {}
17
17
  createApp(App, {
18
- data: {
19
- masterProps: props || {}
20
- },
18
+ masterProps: props || {}
21
19
  }).mount(containerId ? `#${containerId} #root` : '#root');
22
20
  }
23
21
 
@@ -19,6 +19,12 @@ if (process.env.NODE_ENV === 'development') {
19
19
 
20
20
  export default {
21
21
  name: 'App',
22
+ props: {
23
+ masterProps: {
24
+ type: Object,
25
+ default: () => ({})
26
+ }
27
+ },
22
28
  components: {
23
29
  },
24
30
  methods: {
@@ -27,17 +33,20 @@ export default {
27
33
  computed: {
28
34
  /** 是否禁用 */
29
35
  disabled () {
30
- return this.$root?.masterProps?.configurations?.propName3
36
+ return this.masterProps?.configurations?.propName3
31
37
  },
32
38
  /** 控件宽度 */
33
39
  width () {
34
- return this.$root?.masterProps?.configurations?.propName2 || 350
40
+ return this.masterProps?.configurations?.propName2 || 350
35
41
  },
36
42
  /** 提示文本 */
37
43
  placeholder () {
38
- return this.$root?.masterProps?.configurations?.propName1
44
+ return this.masterProps?.configurations?.propName1
39
45
  },
40
46
  },
47
+ created () {
48
+ console.log('masterProps', this.masterProps)
49
+ }
41
50
  }
42
51
  </script>
43
52
 
@@ -15,9 +15,7 @@ const vms = {}
15
15
  const render = (props) => {
16
16
  const { containerId } = props || {}
17
17
  createApp(App, {
18
- data: {
19
- masterProps: props || {}
20
- },
18
+ masterProps: props || {}
21
19
  }).mount(containerId ? `#${containerId} #root` : '#root');
22
20
  }
23
21
 
@@ -0,0 +1,6 @@
1
+ [*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}]
2
+ charset = utf-8
3
+ indent_size = 2
4
+ indent_style = space
5
+ insert_final_newline = true
6
+ trim_trailing_whitespace = true
@@ -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,7 @@
1
+
2
+ {
3
+ "$schema": "https://json.schemastore.org/prettierrc",
4
+ "semi": false,
5
+ "singleQuote": true,
6
+ "printWidth": 100
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "recommendations": [
3
+ "Vue.volar",
4
+ "vitest.explorer",
5
+ "dbaeumer.vscode-eslint",
6
+ "EditorConfig.EditorConfig",
7
+ "esbenp.prettier-vscode"
8
+ ]
9
+ }
@@ -0,0 +1,48 @@
1
+ ### 本地使用代理到主应用环境
2
+ npm run proxy(可以控制 DIST_PROT 修改静态资源端口号)
3
+
4
+ # vue-project
5
+
6
+ This template should help get you started developing with Vue 3 in Vite.
7
+
8
+ ## Recommended IDE Setup
9
+
10
+ [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
11
+
12
+ ## Type Support for `.vue` Imports in TS
13
+
14
+ TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
15
+
16
+ ## Customize configuration
17
+
18
+ See [Vite Configuration Reference](https://vite.dev/config/).
19
+
20
+ ## Project Setup
21
+
22
+ ```sh
23
+ pnpm install
24
+ ```
25
+
26
+ ### Compile and Hot-Reload for Development
27
+
28
+ ```sh
29
+ pnpm dev
30
+ ```
31
+
32
+ ### Type-Check, Compile and Minify for Production
33
+
34
+ ```sh
35
+ pnpm build
36
+ ```
37
+
38
+ ### Run Unit Tests with [Vitest](https://vitest.dev/)
39
+
40
+ ```sh
41
+ pnpm test:unit
42
+ ```
43
+
44
+ ### Lint with [ESLint](https://eslint.org/)
45
+
46
+ ```sh
47
+ pnpm lint
48
+ ```
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,29 @@
1
+ import pluginVue from 'eslint-plugin-vue'
2
+ import vueTsEslintConfig from '@vue/eslint-config-typescript'
3
+ import pluginVitest from '@vitest/eslint-plugin'
4
+ import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
5
+
6
+ export default [
7
+ {
8
+ name: 'app/files-to-lint',
9
+ files: ['**/*.{ts,mts,tsx,vue}'],
10
+ },
11
+
12
+ {
13
+ name: 'app/files-to-ignore',
14
+ ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
15
+ },
16
+
17
+ ...pluginVue.configs['flat/essential'],
18
+ ...vueTsEslintConfig(),
19
+ {
20
+ ...pluginVitest.configs.recommended,
21
+ files: ['src/**/__tests__/*'],
22
+ },
23
+ skipFormatting,
24
+ {
25
+ rules: {
26
+ '@typescript-eslint/no-explicit-any': 'off',
27
+ }
28
+ },
29
+ ]
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" href="/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Maxelms MicroApp</title>
8
+ </head>
9
+ <body>
10
+ <div id="micro-app" style="height: 100%"></div>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "<%= pluginName %>",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "start": "vite",
8
+ "proxy": "npm run build && cross-env DIST_PROT=9966 node scripts/devDistServe.cjs",
9
+ "build": "run-p type-check \"build-only {@}\" -- && maxelms-plugin-cli -c",
10
+ "preview": "vite preview",
11
+ "test:unit": "vitest",
12
+ "build-only": "vite build",
13
+ "type-check": "vue-tsc --build",
14
+ "lint": "eslint . --fix",
15
+ "format": "prettier --write src/"
16
+ },
17
+ "dependencies": {
18
+ "@esbuild/darwin-arm64": "0.24.0",
19
+ "@maxelms/create-pulgin-api": "1.0.0",
20
+ "@rollup/rollup-darwin-arm64": "4.28.1",
21
+ "pinia": "2.2.6",
22
+ "vue": "3.5.13",
23
+ "vue-router": "4.4.5"
24
+ },
25
+ "devDependencies": {
26
+ "@maxelms/create-plugin-cli": "<%= cliVersion %>",
27
+ "@tsconfig/node22": "22.0.0",
28
+ "@types/jsdom": "21.1.7",
29
+ "@types/node": "22.9.3",
30
+ "@vitejs/plugin-vue": "5.2.1",
31
+ "@vitejs/plugin-vue-jsx": "4.1.1",
32
+ "@vitest/eslint-plugin": "1.1.10",
33
+ "@vue/eslint-config-prettier": "10.1.0",
34
+ "@vue/eslint-config-typescript": "14.1.3",
35
+ "@vue/test-utils": "2.4.6",
36
+ "@vue/tsconfig": "0.7.0",
37
+ "cors": "2.8.5",
38
+ "cross-env": "7.0.3",
39
+ "eslint": "9.14.0",
40
+ "eslint-plugin-vue": "9.30.0",
41
+ "express": "4.21.2",
42
+ "jsdom": "25.0.1",
43
+ "npm-run-all2": "7.0.1",
44
+ "prettier": "3.3.3",
45
+ "typescript": "5.6.3",
46
+ "vite": "6.0.1",
47
+ "vite-plugin-vue-devtools": "7.6.5",
48
+ "vitest": "2.1.5",
49
+ "vue-tsc": "2.1.10"
50
+ },
51
+ "resolutions": {
52
+ "magic-string": "0.30.15",
53
+ "@esbuild/darwin-arm64": "0.24.0",
54
+ "esbuild": "0.24.0"
55
+ }
56
+ }
@@ -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,16 @@
1
+ const express = require('express');
2
+ const cors = require('cors');
3
+ const path = require('path');
4
+ const { DIST_PROT = '3000' } = process.env
5
+
6
+ const app = express();
7
+
8
+ // 启用 CORS 中间件
9
+ app.use(cors());
10
+
11
+ // 设置静态文件目录
12
+ app.use(express.static(path.join(__dirname, '../dist')));
13
+
14
+ app.listen(DIST_PROT, () => {
15
+ console.log(`Server running at http://localhost:${DIST_PROT}/`);
16
+ });
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <div id="app">
3
+ <!-- 集成在 系统 中时会走该逻辑 -->
4
+ <!-- <span v-if="buttonName" @click="visible = true">{{buttonName}}</span> -->
5
+ <!-- 由于独立开发时没有 系统 传递的上下文数据,会渲染一个按钮辅助开发 -->
6
+ <button v-if="!buttonName" @click="visible = !visible">自定义按钮</button>
7
+ <div v-show="visible">展示按钮</div>
8
+ </div>
9
+ </template>
10
+
11
+ <script>
12
+
13
+ export default {
14
+ name: 'App',
15
+ data() {
16
+ return {
17
+ visible: false,
18
+ buttonName: this.$root?.masterProps?.originalButtonProps?.name,
19
+ }
20
+ },
21
+ components: {
22
+
23
+ },
24
+ methods: {
25
+
26
+ },
27
+ created() {
28
+
29
+ }
30
+ }
31
+ </script>
32
+
33
+ <style>
34
+
35
+ </style>
@@ -0,0 +1,39 @@
1
+ import { createApp } from 'vue'
2
+ import { createPinia } from 'pinia'
3
+ import { registerPlugin, poweredByMaxelms } from '@maxelms/create-pulgin-api'
4
+ import App from './App.vue'
5
+ // const subId = window.__MAXELMS_GLOBAL_ENV__?.popoverContainerId?.replace(/^maxelms-ma-popover-container-/, '') || ''
6
+
7
+ // Vue.config.productionTip = false
8
+ window.__SINGLETON_MODE__ = true
9
+
10
+ const vms: any = {}
11
+
12
+ if (poweredByMaxelms && registerPlugin) {
13
+ registerPlugin({
14
+ mount(props) {
15
+ render(props)
16
+ },
17
+ update(props) {
18
+ if (vms[props.containerId]) {
19
+ vms[props.containerId].masterProps = props
20
+ }
21
+ },
22
+ unmount(props) {
23
+ vms[props.containerId]?.$destroy?.()
24
+ vms[props.containerId] = null
25
+ }
26
+ });
27
+ } else {
28
+ render()
29
+ }
30
+
31
+ function render(props: any = {}) {
32
+ const { containerId } = props
33
+ console.log(containerId)
34
+ vms[containerId] = createApp(App, {
35
+ configurations: props || {},
36
+ })
37
+ vms[containerId].use(createPinia())
38
+ vms[containerId].mount(containerId ? `#${containerId} #micro-app` : '#micro-app')
39
+ }
@@ -0,0 +1,8 @@
1
+ declare module "*.vue"
2
+
3
+ interface Window {
4
+ __SINGLETON_MODE__?: any
5
+ __MAXELMS_GLOBAL_ENV__?: {
6
+ popoverContainerId: string
7
+ };
8
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "@vue/tsconfig/tsconfig.dom.json",
3
+ "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
4
+ "exclude": ["src/**/__tests__/*"],
5
+ "compilerOptions": {
6
+ "noImplicitAny": true,
7
+ "composite": true,
8
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
9
+
10
+ "paths": {
11
+ "@/*": ["./src/*"]
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ {
5
+ "path": "./tsconfig.node.json"
6
+ },
7
+ {
8
+ "path": "./tsconfig.app.json"
9
+ },
10
+ {
11
+ "path": "./tsconfig.vitest.json"
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "@tsconfig/node22/tsconfig.json",
3
+ "include": [
4
+ "vite.config.*",
5
+ "vitest.config.*",
6
+ "cypress.config.*",
7
+ "nightwatch.conf.*",
8
+ "playwright.config.*"
9
+ ],
10
+ "compilerOptions": {
11
+ "composite": true,
12
+ "noEmit": true,
13
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
14
+
15
+ "module": "ESNext",
16
+ "moduleResolution": "Bundler",
17
+ "types": ["node"]
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "./tsconfig.app.json",
3
+ "exclude": [],
4
+ "compilerOptions": {
5
+ "composite": true,
6
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
7
+
8
+ "lib": [],
9
+ "types": ["node", "jsdom"]
10
+ }
11
+ }
@@ -0,0 +1,24 @@
1
+ import { fileURLToPath, URL } from 'node:url'
2
+ import { defineConfig } from 'vite'
3
+ import vue from '@vitejs/plugin-vue'
4
+ import vueJsx from '@vitejs/plugin-vue-jsx'
5
+ import vueDevTools from 'vite-plugin-vue-devtools'
6
+
7
+ // https://vite.dev/config/
8
+ export default defineConfig({
9
+ plugins: [vue(), vueJsx(), vueDevTools()],
10
+ base: './',
11
+ resolve: {
12
+ alias: {
13
+ '@': fileURLToPath(new URL('./src', import.meta.url)),
14
+ },
15
+ },
16
+ build: {
17
+ target: 'es2015',
18
+ rollupOptions: {
19
+ output: {
20
+ format: 'umd',
21
+ },
22
+ },
23
+ },
24
+ })
@@ -0,0 +1,14 @@
1
+ import { fileURLToPath, URL } from 'node:url'
2
+ import { mergeConfig, defineConfig, configDefaults } from 'vitest/config'
3
+ import viteConfig from './vite.config'
4
+
5
+ export default mergeConfig(
6
+ viteConfig,
7
+ defineConfig({
8
+ test: {
9
+ environment: 'jsdom',
10
+ exclude: [...configDefaults.exclude, 'e2e/**'],
11
+ root: fileURLToPath(new URL('./', import.meta.url)),
12
+ },
13
+ }),
14
+ )