@tomjs/create-app 1.7.0 → 2.0.1
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/README.md +14 -21
- package/README.zh_CN.md +14 -21
- package/dist/index.js +9 -22
- package/package.json +49 -52
- package/templates/{base/core → config/base}/.editorconfig +0 -4
- package/templates/config/base/.vscode/settings.json +50 -0
- package/templates/{base/core/_gitignore → config/base/_.gitignore} +1 -3
- package/templates/config/base/_commitlint.config.mjs +3 -0
- package/templates/config/base/_eslint.config.mjs +8 -0
- package/templates/config/base/lint-staged.config.mjs +3 -0
- package/templates/config/base/package.json +24 -0
- package/templates/config/base/pnpm-workspace.yaml +3 -0
- package/templates/config/base/simple-git-hooks.mjs +4 -0
- package/templates/{vscode → config/public}/LICENSE +1 -1
- package/templates/config/public/README.md +20 -0
- package/templates/config/public/README.zh_CN.md +20 -0
- package/templates/config/public/package.json +10 -0
- package/templates/config/style/lint-staged.config.mjs +7 -0
- package/templates/config/style/package.json +12 -0
- package/templates/config/style/stylelint.config.mjs +3 -0
- package/templates/{base/electron → electron-react}/.vscode/launch.json +23 -3
- package/templates/electron-react/.vscode/tasks.json +67 -0
- package/templates/electron-react/README.md +1 -1
- package/templates/electron-react/_eslint.config.mjs +8 -0
- package/templates/electron-react/electron/main/index.ts +71 -40
- package/templates/electron-react/electron/preload/index.ts +4 -0
- package/templates/electron-react/index.html +1 -2
- package/templates/electron-react/package.json +35 -1
- package/templates/electron-react/pnpm-workspace.yaml +6 -0
- package/templates/electron-react/src/App.css +6 -2
- package/templates/electron-react/src/App.tsx +12 -5
- package/templates/electron-react/src/index.css +14 -9
- package/templates/electron-react/tsconfig.json +9 -0
- package/templates/{base/electron → electron-react}/tsconfig.node.json +1 -1
- package/templates/electron-react/vite.config.ts +9 -22
- package/templates/electron-vue/.vscode/launch.json +48 -0
- package/templates/electron-vue/.vscode/tasks.json +67 -0
- package/templates/electron-vue/README.md +1 -1
- package/templates/electron-vue/_eslint.config.mjs +8 -0
- package/templates/electron-vue/electron/env.d.ts +1 -0
- package/templates/electron-vue/electron/main/index.ts +46 -30
- package/templates/electron-vue/electron/preload/index.ts +4 -0
- package/templates/electron-vue/index.html +1 -2
- package/templates/electron-vue/package.json +31 -2
- package/templates/electron-vue/pnpm-workspace.yaml +5 -0
- package/templates/electron-vue/src/App.vue +1 -1
- package/templates/electron-vue/src/style.css +15 -10
- package/templates/electron-vue/tsconfig.json +5 -0
- package/templates/electron-vue/tsconfig.node.json +7 -0
- package/templates/electron-vue/vite.config.ts +3 -21
- package/templates/{node-cli-legacy → node-base}/.vscode/launch.json +3 -6
- package/templates/node-base/package.json +15 -0
- package/templates/node-base/src/index.ts +5 -0
- package/templates/{node-cli-legacy → node-base}/tsconfig.json +1 -1
- package/templates/node-cli/.vscode/i18n-ally-custom-framework.yml +35 -0
- package/templates/node-cli/.vscode/launch.json +3 -6
- package/templates/node-cli/.vscode/settings.json +56 -0
- package/templates/node-cli/_.gitignore +59 -0
- package/templates/node-cli/locales/en-US.json +12 -0
- package/templates/node-cli/locales/zh-CN.json +12 -0
- package/templates/node-cli/package.json +20 -20
- package/templates/node-cli/src/app.ts +19 -0
- package/templates/node-cli/src/config.ts +2 -2
- package/templates/node-cli/src/index.ts +78 -1
- package/templates/node-cli/src/types.ts +5 -1
- package/templates/node-cli/src/utils/exec.ts +68 -0
- package/templates/node-cli/src/utils/index.ts +3 -0
- package/templates/node-cli/src/utils/lang.ts +104 -0
- package/templates/node-cli/src/utils/util.ts +20 -0
- package/templates/node-cli/tsconfig.json +2 -2
- package/templates/node-cli/{tsup.config.ts → tsdown.config.ts} +3 -4
- package/templates/node-vite/examples/react/README.md +1 -0
- package/templates/node-vite/examples/react/_eslint.config.mjs +6 -0
- package/templates/{react → node-vite/examples/react}/index.html +1 -2
- package/templates/node-vite/examples/react/package.json +27 -0
- package/templates/{react → node-vite/examples/react}/src/App.css +5 -2
- package/templates/{react → node-vite/examples/react}/src/App.tsx +8 -9
- package/templates/{react → node-vite/examples/react}/src/index.css +15 -11
- package/templates/node-vite/examples/react/src/main.tsx +10 -0
- package/templates/node-vite/examples/react/tsconfig.json +5 -0
- package/templates/node-vite/examples/react/vite.config.ts +14 -0
- package/templates/node-vite/examples/vue/README.md +1 -0
- package/templates/node-vite/examples/vue/_eslint.config.mjs +6 -0
- package/templates/{vue → node-vite/examples/vue}/index.html +1 -2
- package/templates/node-vite/examples/vue/package.json +22 -0
- package/templates/{vue → node-vite/examples/vue}/src/App.vue +3 -3
- package/templates/node-vite/examples/vue/src/components/HelloWorld.vue +19 -0
- package/templates/{vue → node-vite/examples/vue}/src/main.ts +0 -1
- package/templates/{vue → node-vite/examples/vue}/src/style.css +16 -12
- package/templates/{base → node-vite/examples}/vue/tsconfig.json +2 -2
- package/templates/{vue → node-vite/examples/vue}/vite.config.ts +1 -1
- package/templates/node-vite/package.json +16 -0
- package/templates/node-vite/pnpm-lock.yaml +2293 -0
- package/templates/node-vite/pnpm-workspace.yaml +6 -0
- package/templates/{node → node-vite}/tsconfig.json +1 -1
- package/templates/{node-cli-legacy/tsup.config.ts → node-vite/tsdown.config.ts} +4 -5
- package/templates/vscode-base/.vscode/settings.json +59 -0
- package/templates/{vscode → vscode-base}/.vscode/tasks.json +2 -2
- package/templates/{base/node → vscode-base}/LICENSE +1 -1
- package/templates/{vscode/_gitignore → vscode-base/_.gitignore} +1 -0
- package/templates/vscode-base/locales/zh-CN.json +6 -0
- package/templates/{vscode → vscode-base}/package.json +12 -19
- package/templates/vscode-base/resources/logo.png +0 -0
- package/templates/vscode-base/resources/logo.svg +1 -0
- package/templates/{vscode/tsup.config.ts → vscode-base/tsdown.config.ts} +3 -3
- package/templates/{base/vscode → vscode-react}/.vscode/launch.json +14 -1
- package/templates/vscode-react/.vscode/settings.json +59 -0
- package/templates/{base/vscode → vscode-react}/.vscode/tasks.json +10 -1
- package/templates/{base/vscode → vscode-react}/LICENSE +1 -1
- package/templates/vscode-react/README.md +2 -2
- package/templates/{base/vscode/_gitignore → vscode-react/_.gitignore} +2 -1
- package/templates/{base/vscode → vscode-react}/extension/views/helper.ts +5 -4
- package/templates/{base/vscode → vscode-react}/extension/views/panel.ts +2 -1
- package/templates/vscode-react/package.json +65 -1
- package/templates/vscode-react/pnpm-workspace.yaml +5 -0
- package/templates/vscode-react/src/App.css +1 -1
- package/templates/vscode-react/src/App.tsx +16 -10
- package/templates/vscode-react/src/utils/vscode.ts +2 -81
- package/templates/vscode-react/src/vite-env.d.ts +1 -0
- package/templates/vscode-react/tsconfig.json +5 -0
- package/templates/vscode-react/vite.config.ts +4 -5
- package/templates/vscode-vue/.vscode/extensions.json +5 -0
- package/templates/vscode-vue/.vscode/launch.json +34 -0
- package/templates/vscode-vue/.vscode/settings.json +59 -0
- package/templates/{base/electron → vscode-vue}/.vscode/tasks.json +14 -6
- package/templates/vscode-vue/.vscodeignore +73 -0
- package/templates/vscode-vue/LICENSE +21 -0
- package/templates/vscode-vue/README.md +2 -2
- package/templates/vscode-vue/_.gitignore +65 -0
- package/templates/vscode-vue/extension/env.d.ts +1 -0
- package/templates/vscode-vue/extension/index.ts +21 -0
- package/templates/vscode-vue/extension/views/helper.ts +28 -0
- package/templates/vscode-vue/extension/views/panel.ts +49 -0
- package/templates/vscode-vue/locales/en.json +6 -0
- package/templates/vscode-vue/package.json +56 -2
- package/templates/vscode-vue/pnpm-workspace.yaml +4 -0
- package/templates/vscode-vue/src/App.vue +17 -11
- package/templates/vscode-vue/src/utils/vscode.ts +2 -81
- package/templates/vscode-vue/src/vite-env.d.ts +1 -0
- package/templates/vscode-vue/tsconfig.json +5 -0
- package/templates/vscode-vue/tsconfig.node.json +7 -0
- package/templates/vscode-vue/vite.config.ts +0 -4
- package/templates/web-react/README.md +1 -0
- package/templates/web-react/_eslint.config.mjs +6 -0
- package/templates/web-react/index.html +13 -0
- package/templates/web-react/package.json +27 -0
- package/templates/web-react/public/vite.svg +1 -0
- package/templates/web-react/src/App.css +45 -0
- package/templates/web-react/src/App.tsx +31 -0
- package/templates/web-react/src/assets/react.svg +1 -0
- package/templates/web-react/src/index.css +73 -0
- package/templates/web-react/src/main.tsx +10 -0
- package/templates/web-react/tsconfig.app.json +28 -0
- package/templates/web-react/tsconfig.json +7 -0
- package/templates/web-react/tsconfig.node.json +26 -0
- package/templates/web-react/vite.config.ts +14 -0
- package/templates/web-vue/README.md +1 -0
- package/templates/web-vue/_eslint.config.mjs +6 -0
- package/templates/web-vue/index.html +13 -0
- package/templates/web-vue/package.json +22 -0
- package/templates/web-vue/public/vite.svg +1 -0
- package/templates/web-vue/src/App.vue +32 -0
- package/templates/web-vue/src/assets/vue.svg +1 -0
- package/templates/web-vue/src/components/HelloWorld.vue +19 -0
- package/templates/web-vue/src/main.ts +5 -0
- package/templates/web-vue/src/style.css +84 -0
- package/templates/web-vue/tsconfig.app.json +4 -0
- package/templates/web-vue/tsconfig.json +7 -0
- package/templates/web-vue/tsconfig.node.json +7 -0
- package/templates/web-vue/vite.config.ts +7 -0
- package/templates/base/core/.commitlintrc.cjs +0 -3
- package/templates/base/core/.eslintignore +0 -14
- package/templates/base/core/.husky/commit-msg +0 -1
- package/templates/base/core/.husky/pre-commit +0 -1
- package/templates/base/core/.prettierignore +0 -17
- package/templates/base/core/.prettierrc.cjs +0 -1
- package/templates/base/core/_eslintrc.cjs +0 -7
- package/templates/base/core/_lintstagedrc.cjs +0 -4
- package/templates/base/core/package.json +0 -31
- package/templates/base/electron/electron/main/index.ts +0 -111
- package/templates/base/electron/electron/polyfills.ts +0 -4
- package/templates/base/electron/electron/preload/index.ts +0 -1
- package/templates/base/electron/package.json +0 -25
- package/templates/base/node/README.md +0 -13
- package/templates/base/node/README.zh_CN.md +0 -13
- package/templates/base/node/package.json +0 -48
- package/templates/base/node/test/index.test.ts +0 -7
- package/templates/base/package/package.json +0 -8
- package/templates/base/react/_eslintrc.cjs +0 -7
- package/templates/base/react/_lintstagedrc.cjs +0 -6
- package/templates/base/react/package.json +0 -19
- package/templates/base/react/tsconfig.json +0 -5
- package/templates/base/style/.stylelintignore +0 -16
- package/templates/base/style/.stylelintrc.cjs +0 -3
- package/templates/base/style/_lintstagedrc.cjs +0 -5
- package/templates/base/style/package.json +0 -10
- package/templates/base/vscode/.vscode/settings.json +0 -10
- package/templates/base/vscode/package.json +0 -67
- package/templates/base/vue/_eslintrc.cjs +0 -7
- package/templates/base/vue/_lintstagedrc.cjs +0 -6
- package/templates/base/vue/package.json +0 -17
- package/templates/config.json +0 -108
- package/templates/electron-react/public/img/icon.png +0 -0
- package/templates/electron-vue/public/img/icon.png +0 -0
- package/templates/node/package.json +0 -10
- package/templates/node/src/index.ts +0 -3
- package/templates/node/tsup.config.ts +0 -19
- package/templates/node-cli/index.d.ts +0 -5
- package/templates/node-cli/src/cli.ts +0 -68
- package/templates/node-cli/xxx.config.cjs +0 -0
- package/templates/node-cli-legacy/index.d.ts +0 -5
- package/templates/node-cli-legacy/package.json +0 -30
- package/templates/node-cli-legacy/src/cli.ts +0 -45
- package/templates/node-cli-legacy/src/config.ts +0 -28
- package/templates/node-cli-legacy/src/index.ts +0 -3
- package/templates/node-cli-legacy/src/types.ts +0 -1
- package/templates/node-cli-legacy/src/utils.ts +0 -5
- package/templates/node-vite-plugin/package.json +0 -18
- package/templates/node-vite-plugin/test/index.test.ts +0 -7
- package/templates/node-vite-plugin/tsconfig.json +0 -4
- package/templates/node-vite-plugin/tsup.config.ts +0 -18
- package/templates/node-workspaces/package.json +0 -8
- package/templates/react/package.json +0 -12
- package/templates/react/src/main.tsx +0 -11
- package/templates/react/src/vite-env.d.ts +0 -1
- package/templates/react/vite.config.ts +0 -7
- package/templates/schema.json +0 -110
- package/templates/vscode/.vscode/settings.json +0 -10
- package/templates/vscode/README.md +0 -3
- package/templates/vue/package.json +0 -12
- package/templates/vue/src/components/HelloWorld.vue +0 -37
- package/templates/vue/src/vite-env.d.ts +0 -1
- package/templates/{base/core → config/base}/.gitattributes +0 -0
- package/templates/{node-cli-legacy/xxx.config.cjs → config/base/README.md} +0 -0
- package/templates/{base/electron → electron-react}/electron/env.d.ts +0 -0
- package/templates/{react → node-vite/examples/react}/public/vite.svg +0 -0
- package/templates/{react → node-vite/examples/react}/src/assets/react.svg +0 -0
- package/templates/{base → node-vite/examples}/react/tsconfig.node.json +0 -0
- package/templates/{vue → node-vite/examples/vue}/public/vite.svg +0 -0
- package/templates/{vue → node-vite/examples/vue}/src/assets/vue.svg +0 -0
- package/templates/{base → node-vite/examples}/vue/tsconfig.node.json +0 -0
- package/templates/{node-vite-plugin → node-vite}/src/index.ts +0 -0
- package/templates/{node-vite-plugin → node-vite}/src/types.ts +0 -0
- package/templates/{base/vscode → vscode-base}/.vscode/extensions.json +0 -0
- package/templates/{vscode → vscode-base}/.vscode/launch.json +0 -0
- package/templates/{vscode → vscode-base}/.vscodeignore +0 -0
- package/templates/{base/vscode → vscode-base}/README.md +0 -0
- package/templates/{vscode → vscode-base}/locales/en.json +0 -0
- package/templates/{vscode → vscode-base}/src/index.ts +1 -1
- package/templates/{vscode → vscode-base}/tsconfig.json +0 -0
- package/templates/{vscode → vscode-react}/.vscode/extensions.json +0 -0
- package/templates/{base/vscode → vscode-react}/.vscodeignore +0 -0
- package/templates/{base/vscode → vscode-react}/extension/env.d.ts +0 -0
- package/templates/{base/vscode → vscode-react}/extension/index.ts +1 -1
- /package/templates/{base/vscode → vscode-react}/locales/en.json +0 -0
- /package/templates/{base/vscode → vscode-react}/locales/zh-CN.json +0 -0
- /package/templates/{base/vscode → vscode-react}/resources/logo.png +0 -0
- /package/templates/{base/vscode → vscode-react}/resources/logo.svg +0 -0
- /package/templates/{base/vscode → vscode-react}/tsconfig.node.json +0 -0
- /package/templates/{vscode → vscode-vue}/locales/zh-CN.json +0 -0
- /package/templates/{vscode → vscode-vue}/resources/logo.png +0 -0
- /package/templates/{vscode → vscode-vue}/resources/logo.svg +0 -0
|
@@ -2,19 +2,18 @@ import path from 'node:path';
|
|
|
2
2
|
import vscode from '@tomjs/vite-plugin-vscode';
|
|
3
3
|
import react from '@vitejs/plugin-react-swc';
|
|
4
4
|
import { defineConfig } from 'vite';
|
|
5
|
-
import pkg from './package.json';
|
|
6
5
|
|
|
7
6
|
// https://vitejs.dev/config/
|
|
8
7
|
export default defineConfig(() => {
|
|
9
|
-
process.env.APP_BUILD_TIME = Date.now() + '';
|
|
10
|
-
process.env.APP_VERSION = pkg.version;
|
|
11
|
-
|
|
12
8
|
return {
|
|
13
9
|
resolve: {
|
|
14
10
|
alias: {
|
|
15
11
|
'@': path.join(__dirname, 'src'),
|
|
16
12
|
},
|
|
17
13
|
},
|
|
18
|
-
plugins: [
|
|
14
|
+
plugins: [
|
|
15
|
+
react(),
|
|
16
|
+
vscode(),
|
|
17
|
+
],
|
|
19
18
|
};
|
|
20
19
|
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// A launch configuration that compiles the extension and then opens it inside a new window
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
{
|
|
6
|
+
"version": "0.2.0",
|
|
7
|
+
"configurations": [
|
|
8
|
+
{
|
|
9
|
+
"name": "Debug Extension",
|
|
10
|
+
"type": "extensionHost",
|
|
11
|
+
"request": "launch",
|
|
12
|
+
"args": [
|
|
13
|
+
"--disable-extensions",
|
|
14
|
+
"--extensionDevelopmentPath=${workspaceFolder}"
|
|
15
|
+
],
|
|
16
|
+
"outFiles": [
|
|
17
|
+
"${workspaceFolder}/dist/extension/*.js"
|
|
18
|
+
],
|
|
19
|
+
"preLaunchTask": "npm: dev"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "Preview Extension",
|
|
23
|
+
"type": "extensionHost",
|
|
24
|
+
"request": "launch",
|
|
25
|
+
"args": [
|
|
26
|
+
"--extensionDevelopmentPath=${workspaceFolder}"
|
|
27
|
+
],
|
|
28
|
+
"outFiles": [
|
|
29
|
+
"${workspaceFolder}/dist/extension/*.js"
|
|
30
|
+
],
|
|
31
|
+
"preLaunchTask": "npm: build"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"i18n-ally.localesPaths": ["locales"],
|
|
3
|
+
"i18n-ally.sourceLanguage": "zh-CN",
|
|
4
|
+
"i18n-ally.displayLanguage": "zh-CN",
|
|
5
|
+
"i18n-ally.keepFulfilled": true,
|
|
6
|
+
"i18n-ally.keystyle": "flat",
|
|
7
|
+
"i18n-ally.sortKeys": true,
|
|
8
|
+
"i18n-ally.translate.promptSource": true,
|
|
9
|
+
"i18n-ally.translate.saveAsCandidates": true,
|
|
10
|
+
|
|
11
|
+
// Disable the default formatter, use eslint instead
|
|
12
|
+
"prettier.enable": false,
|
|
13
|
+
"editor.formatOnSave": false,
|
|
14
|
+
|
|
15
|
+
// Auto fix
|
|
16
|
+
"editor.codeActionsOnSave": {
|
|
17
|
+
"source.fixAll.eslint": "explicit",
|
|
18
|
+
"source.organizeImports": "never"
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
// Silent the stylistic rules in your IDE, but still auto fix them
|
|
22
|
+
"eslint.rules.customizations": [
|
|
23
|
+
{ "rule": "style/*", "severity": "off", "fixable": true },
|
|
24
|
+
{ "rule": "format/*", "severity": "off", "fixable": true },
|
|
25
|
+
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
|
26
|
+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
|
27
|
+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
|
28
|
+
{ "rule": "*-order", "severity": "off", "fixable": true },
|
|
29
|
+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
|
30
|
+
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
|
31
|
+
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
|
32
|
+
{ "rule": "*semi", "severity": "off", "fixable": true }
|
|
33
|
+
],
|
|
34
|
+
|
|
35
|
+
// Enable eslint for all supported languages
|
|
36
|
+
"eslint.validate": [
|
|
37
|
+
"javascript",
|
|
38
|
+
"javascriptreact",
|
|
39
|
+
"typescript",
|
|
40
|
+
"typescriptreact",
|
|
41
|
+
"vue",
|
|
42
|
+
"html",
|
|
43
|
+
"markdown",
|
|
44
|
+
"json",
|
|
45
|
+
"jsonc",
|
|
46
|
+
"yaml",
|
|
47
|
+
"toml",
|
|
48
|
+
"xml",
|
|
49
|
+
"gql",
|
|
50
|
+
"graphql",
|
|
51
|
+
"astro",
|
|
52
|
+
"svelte",
|
|
53
|
+
"css",
|
|
54
|
+
"less",
|
|
55
|
+
"scss",
|
|
56
|
+
"pcss",
|
|
57
|
+
"postcss"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
2
|
+
// for the documentation about the tasks.json format
|
|
1
3
|
{
|
|
2
|
-
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
3
|
-
// for the documentation about the tasks.json format
|
|
4
4
|
"version": "2.0.0",
|
|
5
5
|
"tasks": [
|
|
6
6
|
{
|
|
7
7
|
"type": "npm",
|
|
8
8
|
"script": "dev",
|
|
9
|
-
"detail": "cross-env VITE_ELECTRON_DEBUG=1 vite",
|
|
10
9
|
"problemMatcher": {
|
|
11
10
|
"owner": "typescript",
|
|
12
11
|
"fileLocation": "relative",
|
|
13
12
|
"pattern": {
|
|
14
|
-
"regexp": "^([a-zA-Z]
|
|
13
|
+
"regexp": "^([a-zA-Z]\\:/?([\\w\\-]/?)+\\.\\w+):(\\d+):(\\d+): (ERROR|WARNING)\\: (.*)$",
|
|
15
14
|
"file": 1,
|
|
16
15
|
"line": 3,
|
|
17
16
|
"column": 4,
|
|
@@ -20,8 +19,8 @@
|
|
|
20
19
|
},
|
|
21
20
|
"background": {
|
|
22
21
|
"activeOnStart": true,
|
|
23
|
-
"beginsPattern": "^.*
|
|
24
|
-
"endsPattern": "
|
|
22
|
+
"beginsPattern": "^.*extension build start*$",
|
|
23
|
+
"endsPattern": "^.*extension (build|rebuild) success.*$"
|
|
25
24
|
}
|
|
26
25
|
},
|
|
27
26
|
"isBackground": true,
|
|
@@ -32,6 +31,15 @@
|
|
|
32
31
|
"kind": "build",
|
|
33
32
|
"isDefault": true
|
|
34
33
|
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"type": "npm",
|
|
37
|
+
"script": "build",
|
|
38
|
+
"group": {
|
|
39
|
+
"kind": "build",
|
|
40
|
+
"isDefault": true
|
|
41
|
+
},
|
|
42
|
+
"problemMatcher": []
|
|
35
43
|
}
|
|
36
44
|
]
|
|
37
45
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# logs
|
|
2
|
+
*.log
|
|
3
|
+
lerna-debug.log*
|
|
4
|
+
logs
|
|
5
|
+
npm-debug.log*
|
|
6
|
+
pnpm-debug.log*
|
|
7
|
+
yarn-debug.log*
|
|
8
|
+
yarn-error.log*
|
|
9
|
+
|
|
10
|
+
# diagnostic reports (https://nodejs.org/api/report.html)
|
|
11
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
12
|
+
|
|
13
|
+
# runtime data
|
|
14
|
+
*.pid
|
|
15
|
+
*.pid.lock
|
|
16
|
+
*.seed
|
|
17
|
+
pids
|
|
18
|
+
|
|
19
|
+
# dependency directory
|
|
20
|
+
node_modules
|
|
21
|
+
|
|
22
|
+
# cache
|
|
23
|
+
.cache
|
|
24
|
+
.npm
|
|
25
|
+
.tmp
|
|
26
|
+
.temp
|
|
27
|
+
.eslintcache
|
|
28
|
+
.stylelintcache
|
|
29
|
+
tsconfig.tsbuildinfo
|
|
30
|
+
|
|
31
|
+
# environment
|
|
32
|
+
*.local
|
|
33
|
+
|
|
34
|
+
# macOS
|
|
35
|
+
.DS_Store
|
|
36
|
+
|
|
37
|
+
# package files
|
|
38
|
+
*.7z
|
|
39
|
+
*.gz
|
|
40
|
+
*.gzip
|
|
41
|
+
*.rar
|
|
42
|
+
*.tar
|
|
43
|
+
*.tar.*
|
|
44
|
+
*.tgz
|
|
45
|
+
*.zip
|
|
46
|
+
*.vsix
|
|
47
|
+
|
|
48
|
+
# IDEA
|
|
49
|
+
.idea
|
|
50
|
+
|
|
51
|
+
# vscode
|
|
52
|
+
.vscode
|
|
53
|
+
.history
|
|
54
|
+
|
|
55
|
+
# project
|
|
56
|
+
src
|
|
57
|
+
extensions
|
|
58
|
+
locales
|
|
59
|
+
|
|
60
|
+
.husky
|
|
61
|
+
.commitlintrc*
|
|
62
|
+
.editorconfig
|
|
63
|
+
.eslintrc*
|
|
64
|
+
.eslintignore
|
|
65
|
+
.gitattributes
|
|
66
|
+
.gitignore
|
|
67
|
+
.lintstagedrc*
|
|
68
|
+
.prettierrc*
|
|
69
|
+
.prettierignore
|
|
70
|
+
pnpm-lock.yaml
|
|
71
|
+
tsconfig.json
|
|
72
|
+
tsconfig.*.json
|
|
73
|
+
*.config.ts
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) {{dateYear}}-PRESENT {{gitUserName}}
|
|
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.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# extension
|
|
1
|
+
# extension
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
vscode extension
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# logs
|
|
2
|
+
*.log
|
|
3
|
+
lerna-debug.log*
|
|
4
|
+
logs
|
|
5
|
+
npm-debug.log*
|
|
6
|
+
pnpm-debug.log*
|
|
7
|
+
yarn-debug.log*
|
|
8
|
+
yarn-error.log*
|
|
9
|
+
|
|
10
|
+
# diagnostic reports (https://nodejs.org/api/report.html)
|
|
11
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
12
|
+
|
|
13
|
+
# runtime data
|
|
14
|
+
*.pid
|
|
15
|
+
*.pid.lock
|
|
16
|
+
*.seed
|
|
17
|
+
pids
|
|
18
|
+
|
|
19
|
+
# dependency directory
|
|
20
|
+
bower_components
|
|
21
|
+
jspm_packages
|
|
22
|
+
node_modules
|
|
23
|
+
web_modules
|
|
24
|
+
|
|
25
|
+
# cache
|
|
26
|
+
.cache
|
|
27
|
+
.npm
|
|
28
|
+
.tmp
|
|
29
|
+
.temp
|
|
30
|
+
.eslintcache
|
|
31
|
+
.stylelintcache
|
|
32
|
+
tsconfig.tsbuildinfo
|
|
33
|
+
|
|
34
|
+
# environment
|
|
35
|
+
*.local
|
|
36
|
+
|
|
37
|
+
# macOS
|
|
38
|
+
.DS_Store
|
|
39
|
+
|
|
40
|
+
# package files
|
|
41
|
+
*.7z
|
|
42
|
+
*.gz
|
|
43
|
+
*.gzip
|
|
44
|
+
*.rar
|
|
45
|
+
*.tar
|
|
46
|
+
*.tar.*
|
|
47
|
+
*.tgz
|
|
48
|
+
*.zip
|
|
49
|
+
*.vsix
|
|
50
|
+
|
|
51
|
+
# IDEA
|
|
52
|
+
.idea
|
|
53
|
+
|
|
54
|
+
# vscode
|
|
55
|
+
.history
|
|
56
|
+
.vscode/i18n-ally-reviews.yml
|
|
57
|
+
|
|
58
|
+
# build output
|
|
59
|
+
build
|
|
60
|
+
dist
|
|
61
|
+
release
|
|
62
|
+
|
|
63
|
+
package.nls.json
|
|
64
|
+
package.nls.*.json
|
|
65
|
+
src/vscode.d.ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@tomjs/vite-plugin-vscode/env" />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ExtensionContext } from 'vscode';
|
|
2
|
+
import { i18n, initExtension } from '@tomjs/vscode';
|
|
3
|
+
import { commands, window } from 'vscode';
|
|
4
|
+
import { MainPanel } from './views/panel';
|
|
5
|
+
|
|
6
|
+
export function activate(context: ExtensionContext) {
|
|
7
|
+
initExtension(context);
|
|
8
|
+
|
|
9
|
+
context.subscriptions.push(
|
|
10
|
+
commands.registerCommand('tomjs.xxx.showHello', async () => {
|
|
11
|
+
window.showInformationMessage(i18n.t('tomjs.commands.hello'));
|
|
12
|
+
}),
|
|
13
|
+
);
|
|
14
|
+
context.subscriptions.push(
|
|
15
|
+
commands.registerCommand('tomjs.xxx.showPanel', async () => {
|
|
16
|
+
MainPanel.render(context);
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function deactivate() {}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Disposable, ExtensionContext, Webview } from 'vscode';
|
|
2
|
+
import { window } from 'vscode';
|
|
3
|
+
|
|
4
|
+
export class WebviewHelper {
|
|
5
|
+
public static setupHtml(webview: Webview, context: ExtensionContext) {
|
|
6
|
+
return __getWebviewHtml__({
|
|
7
|
+
serverUrl: process.env.VITE_DEV_SERVER_URL,
|
|
8
|
+
webview,
|
|
9
|
+
context,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public static setupWebviewHooks(webview: Webview, disposables: Disposable[]) {
|
|
14
|
+
webview.onDidReceiveMessage(
|
|
15
|
+
(message: any) => {
|
|
16
|
+
const command = message.command;
|
|
17
|
+
const text = message.text;
|
|
18
|
+
console.log(`command: ${command}`);
|
|
19
|
+
switch (command) {
|
|
20
|
+
case 'hello':
|
|
21
|
+
window.showInformationMessage(text);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
undefined,
|
|
25
|
+
disposables,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Disposable, ExtensionContext, WebviewPanel } from 'vscode';
|
|
2
|
+
import { ViewColumn, window } from 'vscode';
|
|
3
|
+
import { WebviewHelper } from './helper';
|
|
4
|
+
|
|
5
|
+
export class MainPanel {
|
|
6
|
+
public static currentPanel: MainPanel | undefined;
|
|
7
|
+
private readonly _panel: WebviewPanel;
|
|
8
|
+
private _disposables: Disposable[] = [];
|
|
9
|
+
|
|
10
|
+
private constructor(panel: WebviewPanel, context: ExtensionContext) {
|
|
11
|
+
this._panel = panel;
|
|
12
|
+
|
|
13
|
+
this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
|
|
14
|
+
this._panel.webview.html = WebviewHelper.setupHtml(this._panel.webview, context);
|
|
15
|
+
|
|
16
|
+
WebviewHelper.setupWebviewHooks(this._panel.webview, this._disposables);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public static render(context: ExtensionContext) {
|
|
20
|
+
if (MainPanel.currentPanel) {
|
|
21
|
+
MainPanel.currentPanel._panel.reveal(ViewColumn.One);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const panel = window.createWebviewPanel('showHelloWorld', 'Hello World', ViewColumn.One, {
|
|
25
|
+
enableScripts: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
MainPanel.currentPanel = new MainPanel(panel, context);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Cleans up and disposes of webview resources when the webview panel is closed.
|
|
34
|
+
*/
|
|
35
|
+
public dispose() {
|
|
36
|
+
MainPanel.currentPanel = undefined;
|
|
37
|
+
|
|
38
|
+
// Dispose of the current webview panel
|
|
39
|
+
this._panel.dispose();
|
|
40
|
+
|
|
41
|
+
// Dispose of all disposables (i.e. commands) for the current webview panel
|
|
42
|
+
while (this._disposables.length) {
|
|
43
|
+
const disposable = this._disposables.pop();
|
|
44
|
+
if (disposable) {
|
|
45
|
+
disposable.dispose();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,9 +1,63 @@
|
|
|
1
1
|
{
|
|
2
|
+
"publisher": "",
|
|
3
|
+
"name": "vscode-vue",
|
|
4
|
+
"displayName": "%displayName%",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"description": "%description%",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"vscode"
|
|
10
|
+
],
|
|
11
|
+
"categories": [
|
|
12
|
+
"Other"
|
|
13
|
+
],
|
|
14
|
+
"main": "dist/extension/index.js",
|
|
15
|
+
"icon": "resources/logo.png",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=14.16.0",
|
|
18
|
+
"vscode": "^1.56.0"
|
|
19
|
+
},
|
|
20
|
+
"activationEvents": [],
|
|
21
|
+
"contributes": {
|
|
22
|
+
"commands": [
|
|
23
|
+
{
|
|
24
|
+
"command": "tomjs.xxx.showHello",
|
|
25
|
+
"title": "%tomjs.commands.hello%",
|
|
26
|
+
"category": "%displayName%"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"command": "tomjs.xxx.showPanel",
|
|
30
|
+
"title": "%tomjs.commands.panel%",
|
|
31
|
+
"category": "%displayName%"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"vsce": {
|
|
36
|
+
"dependencies": false,
|
|
37
|
+
"yarn": false
|
|
38
|
+
},
|
|
2
39
|
"scripts": {
|
|
40
|
+
"dev": "run-p dev:*",
|
|
41
|
+
"dev:vsd": "vscode-dev --watch",
|
|
42
|
+
"dev:dist": "vite",
|
|
3
43
|
"build": "vscode-dev && vue-tsc --noEmit && vite build",
|
|
4
|
-
"
|
|
44
|
+
"preview": "vite preview"
|
|
5
45
|
},
|
|
6
46
|
"dependencies": {
|
|
7
|
-
"
|
|
47
|
+
"@tomjs/node": "^2.2.3",
|
|
48
|
+
"@tomjs/vscode": "^2.5.0",
|
|
49
|
+
"@tomjs/vscode-webview": "^2.0.2",
|
|
50
|
+
"@vscode/webview-ui-toolkit": "^1.4.0",
|
|
51
|
+
"vue": "^3.5.25",
|
|
52
|
+
"vue-i18n": "^11.2.2"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@tomjs/vite-plugin-vscode": "^5.1.0",
|
|
56
|
+
"@tomjs/vscode-dev": "^3.0.2",
|
|
57
|
+
"@types/vscode": "^1.56.0",
|
|
58
|
+
"@types/vscode-webview": "^1.57.5",
|
|
59
|
+
"@vitejs/plugin-vue": "^6.0.2",
|
|
60
|
+
"vite": "^7.2.4",
|
|
61
|
+
"vue-tsc": "^3.1.5"
|
|
8
62
|
}
|
|
9
63
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { allComponents, provideVSCodeDesignSystem } from '@vscode/webview-ui-toolkit';
|
|
3
3
|
import { ref } from 'vue';
|
|
4
|
-
import {
|
|
4
|
+
import { vscodeApi } from './utils';
|
|
5
5
|
|
|
6
6
|
provideVSCodeDesignSystem().register(allComponents);
|
|
7
7
|
|
|
8
8
|
function onPostMessage() {
|
|
9
|
-
|
|
9
|
+
vscodeApi.postMessage({
|
|
10
10
|
command: 'hello',
|
|
11
11
|
text: 'Hey there partner! 🤠',
|
|
12
12
|
});
|
|
@@ -15,19 +15,21 @@ function onPostMessage() {
|
|
|
15
15
|
const message = ref('');
|
|
16
16
|
const state = ref('');
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
18
|
+
function onSetState() {
|
|
19
|
+
vscodeApi.setState(state.value);
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
state.value =
|
|
24
|
-
}
|
|
22
|
+
function onGetState() {
|
|
23
|
+
state.value = vscodeApi.getState() as string;
|
|
24
|
+
}
|
|
25
25
|
</script>
|
|
26
26
|
|
|
27
27
|
<template>
|
|
28
28
|
<main>
|
|
29
29
|
<h1>Hello Vue!</h1>
|
|
30
|
-
<vscode-button @click="onPostMessage">
|
|
30
|
+
<vscode-button @click="onPostMessage">
|
|
31
|
+
Test VSCode Message
|
|
32
|
+
</vscode-button>
|
|
31
33
|
<div>
|
|
32
34
|
<vscode-text-field :value="message" @input="e => (message = e.target.value)">
|
|
33
35
|
Please enter a message
|
|
@@ -40,8 +42,12 @@ const onGetState = () => {
|
|
|
40
42
|
</vscode-text-field>
|
|
41
43
|
<div>State is: {{ state }}</div>
|
|
42
44
|
<div>
|
|
43
|
-
<vscode-button @click="onSetState">
|
|
44
|
-
|
|
45
|
+
<vscode-button @click="onSetState">
|
|
46
|
+
setState
|
|
47
|
+
</vscode-button>
|
|
48
|
+
<vscode-button style="margin-left: 8px" @click="onGetState">
|
|
49
|
+
getState
|
|
50
|
+
</vscode-button>
|
|
45
51
|
</div>
|
|
46
52
|
</div>
|
|
47
53
|
</main>
|
|
@@ -1,83 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A utility wrapper around the acquireVsCodeApi() function, which enables
|
|
5
|
-
* message passing and state management between the webview and extension
|
|
6
|
-
* contexts.
|
|
7
|
-
*
|
|
8
|
-
* This utility also enables webview code to be run in a web browser-based
|
|
9
|
-
* dev server by using native web browser features that mock the functionality
|
|
10
|
-
* enabled by acquireVsCodeApi.
|
|
11
|
-
*/
|
|
12
|
-
class VSCodeAPIWrapper {
|
|
13
|
-
private readonly vsCodeApi: WebviewApi<unknown> | undefined;
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
// Check if the acquireVsCodeApi function exists in the current development
|
|
17
|
-
// context (i.e. VS Code development window or web browser)
|
|
18
|
-
if (typeof acquireVsCodeApi === 'function') {
|
|
19
|
-
this.vsCodeApi = acquireVsCodeApi();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// private init() {
|
|
24
|
-
// // TODO 环境变量判断
|
|
25
|
-
// }
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Post a message (i.e. send arbitrary data) to the owner of the webview.
|
|
29
|
-
*
|
|
30
|
-
* @remarks When running webview code inside a web browser, postMessage will instead
|
|
31
|
-
* log the given message to the console.
|
|
32
|
-
*
|
|
33
|
-
* @param message Abitrary data (must be JSON serializable) to send to the extension context.
|
|
34
|
-
*/
|
|
35
|
-
public postMessage(message: unknown) {
|
|
36
|
-
if (this.vsCodeApi) {
|
|
37
|
-
this.vsCodeApi.postMessage(message);
|
|
38
|
-
} else {
|
|
39
|
-
window.parent.postMessage({ type: 'page:message', data: message }, '*');
|
|
40
|
-
console.log(message);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Get the persistent state stored for this webview.
|
|
46
|
-
*
|
|
47
|
-
* @remarks When running webview source code inside a web browser, getState will retrieve state
|
|
48
|
-
* from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
|
|
49
|
-
*
|
|
50
|
-
* @return The current state or `undefined` if no state has been set.
|
|
51
|
-
*/
|
|
52
|
-
public getState(): unknown | undefined {
|
|
53
|
-
if (this.vsCodeApi) {
|
|
54
|
-
return this.vsCodeApi.getState();
|
|
55
|
-
} else {
|
|
56
|
-
const state = localStorage.getItem('vscodeState');
|
|
57
|
-
return state ? JSON.parse(state) : undefined;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Set the persistent state stored for this webview.
|
|
63
|
-
*
|
|
64
|
-
* @remarks When running webview source code inside a web browser, setState will set the given
|
|
65
|
-
* state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
|
|
66
|
-
*
|
|
67
|
-
* @param newState New persisted state. This must be a JSON serializable object. Can be retrieved
|
|
68
|
-
* using {@link getState}.
|
|
69
|
-
*
|
|
70
|
-
* @return The new state.
|
|
71
|
-
*/
|
|
72
|
-
public setState<T extends unknown | undefined>(newState: T): T {
|
|
73
|
-
if (this.vsCodeApi) {
|
|
74
|
-
return this.vsCodeApi.setState(newState);
|
|
75
|
-
} else {
|
|
76
|
-
localStorage.setItem('vscodeState', JSON.stringify(newState));
|
|
77
|
-
return newState;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
1
|
+
import { WebviewApi } from '@tomjs/vscode-webview';
|
|
81
2
|
|
|
82
3
|
// Exports class singleton to prevent multiple invocations of acquireVsCodeApi.
|
|
83
|
-
export const
|
|
4
|
+
export const vscodeApi = new WebviewApi<string>();
|