@tomjs/create-app 1.0.0 → 1.0.2

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 (177) hide show
  1. package/README.md +4 -0
  2. package/README.zh_CN.md +4 -0
  3. package/package.json +2 -2
  4. package/templates/base/core/.commitlintrc.cjs +3 -0
  5. package/templates/base/core/.editorconfig +15 -0
  6. package/templates/base/core/.eslintignore +14 -0
  7. package/templates/base/core/.gitattributes +203 -0
  8. package/templates/base/core/.husky/commit-msg +1 -0
  9. package/templates/base/core/.husky/pre-commit +1 -0
  10. package/templates/base/core/.prettierignore +17 -0
  11. package/templates/base/core/.prettierrc.cjs +1 -0
  12. package/templates/base/core/_eslintrc.cjs +7 -0
  13. package/templates/base/core/_gitignore +60 -0
  14. package/templates/base/core/_lintstagedrc.cjs +4 -0
  15. package/templates/base/core/package.json +30 -0
  16. package/templates/base/electron/.vscode/launch.json +28 -0
  17. package/templates/base/electron/.vscode/tasks.json +37 -0
  18. package/templates/base/electron/electron/env.d.ts +1 -0
  19. package/templates/base/electron/electron/main/index.ts +111 -0
  20. package/templates/base/electron/electron/polyfills.ts +4 -0
  21. package/templates/base/electron/electron/preload/index.ts +1 -0
  22. package/templates/base/electron/package.json +25 -0
  23. package/templates/base/electron/tsconfig.node.json +7 -0
  24. package/templates/base/node/LICENSE +21 -0
  25. package/templates/base/node/README.md +13 -0
  26. package/templates/base/node/README.zh_CN.md +13 -0
  27. package/templates/base/node/package.json +46 -0
  28. package/templates/base/node/test/index.test.ts +7 -0
  29. package/templates/base/react/_eslintrc.cjs +7 -0
  30. package/templates/base/react/_lintstagedrc.cjs +6 -0
  31. package/templates/base/react/package.json +19 -0
  32. package/templates/base/react/tsconfig.json +5 -0
  33. package/templates/base/react/tsconfig.node.json +7 -0
  34. package/templates/base/style/.stylelintignore +16 -0
  35. package/templates/base/style/.stylelintrc.cjs +3 -0
  36. package/templates/base/style/_lintstagedrc.cjs +5 -0
  37. package/templates/base/style/package.json +10 -0
  38. package/templates/base/vscode/.vscode/extensions.json +5 -0
  39. package/templates/base/vscode/.vscode/launch.json +21 -0
  40. package/templates/base/vscode/.vscode/settings.json +3 -0
  41. package/templates/base/vscode/.vscode/tasks.json +36 -0
  42. package/templates/base/vscode/.vscodeignore +73 -0
  43. package/templates/base/vscode/LICENSE +21 -0
  44. package/templates/base/vscode/_gitignore +63 -0
  45. package/templates/base/vscode/extension/env.d.ts +1 -0
  46. package/templates/base/vscode/extension/index.ts +21 -0
  47. package/templates/base/vscode/extension/views/helper.ts +27 -0
  48. package/templates/base/vscode/extension/views/panel.ts +48 -0
  49. package/templates/base/vscode/locales/en.json +6 -0
  50. package/templates/base/vscode/locales/zh-CN.json +5 -0
  51. package/templates/base/vscode/locales/zh-TW.json +5 -0
  52. package/templates/base/vscode/package.json +70 -0
  53. package/templates/base/vscode/resources/logo.png +0 -0
  54. package/templates/base/vscode/tsconfig.node.json +7 -0
  55. package/templates/base/vue/_eslintrc.cjs +7 -0
  56. package/templates/base/vue/_lintstagedrc.cjs +6 -0
  57. package/templates/base/vue/package.json +17 -0
  58. package/templates/base/vue/tsconfig.json +5 -0
  59. package/templates/base/vue/tsconfig.node.json +7 -0
  60. package/templates/config.json +105 -0
  61. package/templates/electron-react/README.md +3 -0
  62. package/templates/electron-react/electron/main/index.ts +128 -0
  63. package/templates/electron-react/index.html +15 -0
  64. package/templates/electron-react/package.json +26 -0
  65. package/templates/electron-react/public/img/icon.png +0 -0
  66. package/templates/electron-react/public/vite.svg +1 -0
  67. package/templates/electron-react/src/App.css +45 -0
  68. package/templates/electron-react/src/App.tsx +42 -0
  69. package/templates/electron-react/src/assets/electron.svg +10 -0
  70. package/templates/electron-react/src/assets/react.svg +1 -0
  71. package/templates/electron-react/src/index.css +69 -0
  72. package/templates/electron-react/src/main.tsx +11 -0
  73. package/templates/electron-react/src/vite-env.d.ts +1 -0
  74. package/templates/electron-react/vite.config.ts +27 -0
  75. package/templates/electron-vue/README.md +3 -0
  76. package/templates/electron-vue/electron/main/index.ts +123 -0
  77. package/templates/electron-vue/package.json +6 -0
  78. package/templates/electron-vue/public/img/icon.png +0 -0
  79. package/templates/electron-vue/public/vite.svg +1 -0
  80. package/templates/electron-vue/src/App.vue +55 -0
  81. package/templates/electron-vue/src/assets/electron.svg +10 -0
  82. package/templates/electron-vue/src/assets/vue.svg +1 -0
  83. package/templates/electron-vue/src/components/HelloWorld.vue +43 -0
  84. package/templates/electron-vue/src/main.ts +6 -0
  85. package/templates/electron-vue/src/style.css +80 -0
  86. package/templates/electron-vue/src/vite-env.d.ts +1 -0
  87. package/templates/electron-vue/vite.config.ts +26 -0
  88. package/templates/node/package.json +12 -0
  89. package/templates/node/src/index.ts +3 -0
  90. package/templates/node/tsconfig.json +4 -0
  91. package/templates/node/tsup.config.ts +19 -0
  92. package/templates/node-cli/.vscode/launch.json +23 -0
  93. package/templates/node-cli/index.d.ts +5 -0
  94. package/templates/node-cli/package.json +33 -0
  95. package/templates/node-cli/src/cli.ts +68 -0
  96. package/templates/node-cli/src/config.ts +28 -0
  97. package/templates/node-cli/src/constants.ts +1 -0
  98. package/templates/node-cli/src/index.ts +3 -0
  99. package/templates/node-cli/src/types.ts +1 -0
  100. package/templates/node-cli/tsconfig.json +4 -0
  101. package/templates/node-cli/tsup.config.ts +18 -0
  102. package/templates/node-cli/xxx.config.cjs +0 -0
  103. package/templates/node-cli-legacy/.vscode/launch.json +23 -0
  104. package/templates/node-cli-legacy/index.d.ts +5 -0
  105. package/templates/node-cli-legacy/package.json +31 -0
  106. package/templates/node-cli-legacy/src/cli.ts +45 -0
  107. package/templates/node-cli-legacy/src/config.ts +28 -0
  108. package/templates/node-cli-legacy/src/index.ts +3 -0
  109. package/templates/node-cli-legacy/src/types.ts +1 -0
  110. package/templates/node-cli-legacy/src/utils.ts +5 -0
  111. package/templates/node-cli-legacy/tsconfig.json +4 -0
  112. package/templates/node-cli-legacy/tsup.config.ts +18 -0
  113. package/templates/node-cli-legacy/xxx.config.cjs +0 -0
  114. package/templates/node-vite-plugin/package.json +19 -0
  115. package/templates/node-vite-plugin/src/index.ts +10 -0
  116. package/templates/node-vite-plugin/src/types.ts +1 -0
  117. package/templates/node-vite-plugin/test/index.test.ts +7 -0
  118. package/templates/node-vite-plugin/tsconfig.json +4 -0
  119. package/templates/node-vite-plugin/tsup.config.ts +18 -0
  120. package/templates/node-workspaces/package.json +10 -0
  121. package/templates/react/index.html +14 -0
  122. package/templates/react/package.json +12 -0
  123. package/templates/react/public/vite.svg +1 -0
  124. package/templates/react/src/App.css +42 -0
  125. package/templates/react/src/App.tsx +32 -0
  126. package/templates/react/src/assets/react.svg +1 -0
  127. package/templates/react/src/index.css +69 -0
  128. package/templates/react/src/main.tsx +11 -0
  129. package/templates/react/src/vite-env.d.ts +1 -0
  130. package/templates/react/vite.config.ts +7 -0
  131. package/templates/schema.json +110 -0
  132. package/templates/vscode/.vscode/extensions.json +5 -0
  133. package/templates/vscode/.vscode/launch.json +21 -0
  134. package/templates/vscode/.vscode/settings.json +3 -0
  135. package/templates/vscode/.vscode/tasks.json +36 -0
  136. package/templates/vscode/.vscodeignore +72 -0
  137. package/templates/vscode/LICENSE +21 -0
  138. package/templates/vscode/README.md +3 -0
  139. package/templates/vscode/_gitignore +63 -0
  140. package/templates/vscode/locales/en.json +5 -0
  141. package/templates/vscode/locales/zh-CN.json +5 -0
  142. package/templates/vscode/locales/zh-TW.json +5 -0
  143. package/templates/vscode/package.json +57 -0
  144. package/templates/vscode/resources/logo.png +0 -0
  145. package/templates/vscode/src/index.ts +15 -0
  146. package/templates/vscode/tsconfig.json +5 -0
  147. package/templates/vscode/tsup.config.ts +13 -0
  148. package/templates/vscode-react/README.md +3 -0
  149. package/templates/vscode-react/index.html +14 -0
  150. package/templates/vscode-react/package.json +1 -0
  151. package/templates/vscode-react/src/App.css +7 -0
  152. package/templates/vscode-react/src/App.tsx +51 -0
  153. package/templates/vscode-react/src/main.tsx +9 -0
  154. package/templates/vscode-react/src/utils/index.ts +1 -0
  155. package/templates/vscode-react/src/utils/vscode.ts +83 -0
  156. package/templates/vscode-react/src/vite-env.d.ts +1 -0
  157. package/templates/vscode-react/vite.config.ts +20 -0
  158. package/templates/vscode-vue/README.md +3 -0
  159. package/templates/vscode-vue/index.html +14 -0
  160. package/templates/vscode-vue/package.json +6 -0
  161. package/templates/vscode-vue/src/App.vue +58 -0
  162. package/templates/vscode-vue/src/main.ts +4 -0
  163. package/templates/vscode-vue/src/utils/index.ts +1 -0
  164. package/templates/vscode-vue/src/utils/vscode.ts +83 -0
  165. package/templates/vscode-vue/src/vite-env.d.ts +1 -0
  166. package/templates/vscode-vue/vite.config.ts +29 -0
  167. package/templates/vue/electron/main/index.ts +123 -0
  168. package/templates/vue/index.html +14 -0
  169. package/templates/vue/package.json +12 -0
  170. package/templates/vue/public/vite.svg +1 -0
  171. package/templates/vue/src/App.vue +32 -0
  172. package/templates/vue/src/assets/vue.svg +1 -0
  173. package/templates/vue/src/components/HelloWorld.vue +37 -0
  174. package/templates/vue/src/main.ts +6 -0
  175. package/templates/vue/src/style.css +80 -0
  176. package/templates/vue/src/vite-env.d.ts +1 -0
  177. package/templates/vue/vite.config.ts +7 -0
package/README.md CHANGED
@@ -46,6 +46,10 @@ Support templates:
46
46
  - electron-vue
47
47
  - electron-react
48
48
  - node
49
+ - node-cli
50
+ - node-cli-legacy
51
+ - node-vite-plugin
52
+ - node-workspaces
49
53
  - vscode
50
54
  - vscode-vue
51
55
  - vscode-react
package/README.zh_CN.md CHANGED
@@ -46,6 +46,10 @@ npm create @tomjs/app@latest my-app -- --template vue
46
46
  - electron-vue
47
47
  - electron-react
48
48
  - node
49
+ - node-cli
50
+ - node-cli-legacy
51
+ - node-vite-plugin
52
+ - node-workspaces
49
53
  - vscode
50
54
  - vscode-vue
51
55
  - vscode-react
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tomjs/create-app",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "description": "create tomjs web app",
6
6
  "keywords": [
7
7
  "tomjs",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "files": [
31
31
  "dist",
32
- "template/**"
32
+ "templates/**"
33
33
  ],
34
34
  "engines": {
35
35
  "node": ">=18"
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: [require.resolve('@tomjs/commitlint')],
3
+ };
@@ -0,0 +1,15 @@
1
+ # 🎨 editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ end_of_line = lf
8
+ indent_style = space
9
+ indent_size = 2
10
+ trim_trailing_whitespace = true
11
+ insert_final_newline = true
12
+
13
+ [*.md]
14
+ insert_final_newline = false
15
+ trim_trailing_whitespace = false
@@ -0,0 +1,14 @@
1
+ # IDE
2
+ .vscode
3
+ .idea
4
+ .history
5
+ .git
6
+
7
+ # temp
8
+ .cache
9
+ .temp
10
+ .tmp
11
+
12
+ # project
13
+ node_modules
14
+ dist
@@ -0,0 +1,203 @@
1
+ ## GITATTRIBUTES FOR WEB PROJECTS
2
+ #
3
+ # These settings are for any web project.
4
+ #
5
+ # Details per file setting:
6
+ # text These files should be normalized (i.e. convert CRLF to LF).
7
+ # binary These files are binary and should be left untouched.
8
+ #
9
+ # Note that binary is a macro for -text -diff.
10
+ ######################################################################
11
+
12
+ ## AUTO-DETECT
13
+ ## Handle line endings automatically for files detected as
14
+ ## text and leave all files detected as binary untouched.
15
+ ## This will handle all files NOT defined below.
16
+ * text eol=lf
17
+
18
+ ## SOURCE CODE
19
+ *.bat text eol=crlf
20
+ *.coffee text
21
+ *.css text
22
+ *.htm text
23
+ *.html text
24
+ *.inc text
25
+ *.ini text
26
+ *.java text
27
+ *.js text
28
+ *.json text
29
+ *.jsx text
30
+ *.less text
31
+ *.od text
32
+ *.onlydata text
33
+ *.php text
34
+ *.pl text
35
+ *.py text
36
+ *.rb text
37
+ *.sass text
38
+ *.scm text
39
+ *.scss text
40
+ *.sh text eol=lf
41
+ *.sql text
42
+ *.styl text
43
+ *.tag text
44
+ *.ts text
45
+ *.tsx text
46
+ *.xml text
47
+ *.xhtml text
48
+
49
+ ## DOCKER
50
+ *.dockerignore text
51
+ Dockerfile text
52
+
53
+ ## DOCUMENTATION
54
+ *.markdown text
55
+ *.md text
56
+ *.mdwn text
57
+ *.mdown text
58
+ *.mkd text
59
+ *.mkdn text
60
+ *.mdtxt text
61
+ *.mdtext text
62
+ *.txt text
63
+ AUTHORS text
64
+ CHANGELOG text
65
+ CHANGES text
66
+ CONTRIBUTING text
67
+ COPYING text
68
+ copyright text
69
+ *COPYRIGHT* text
70
+ INSTALL text
71
+ license text
72
+ LICENSE text
73
+ NEWS text
74
+ readme text
75
+ *README* text
76
+
77
+ ## TEMPLATES
78
+ *.dot text
79
+ *.ejs text
80
+ *.haml text
81
+ *.handlebars text
82
+ *.hbs text
83
+ *.hbt text
84
+ *.jade text
85
+ *.latte text
86
+ *.mustache text
87
+ *.njk text
88
+ *.phtml text
89
+ *.tmpl text
90
+ *.tpl text
91
+ *.twig text
92
+
93
+ ## LINTERS
94
+ .csslintrc text
95
+ .eslintrc text
96
+ .jscsrc text
97
+ .jshintrc text
98
+ .jshintignore text
99
+ .stylelintrc text
100
+
101
+ ## CONFIGS
102
+ *.bowerrc text
103
+ *.cnf text
104
+ *.conf text
105
+ *.config text
106
+ .browserslistrc text
107
+ .editorconfig text
108
+ .gitattributes text
109
+ .gitconfig text
110
+ .gitignore text
111
+ .htaccess text
112
+ *.npmignore text
113
+ *.yaml text
114
+ *.yml text
115
+ browserslist text
116
+ Makefile text
117
+ makefile text
118
+
119
+ ## HEROKU
120
+ Procfile text
121
+ .slugignore text
122
+
123
+ ## GRAPHICS
124
+ *.ai binary
125
+ *.bmp binary
126
+ *.eps binary
127
+ *.gif binary
128
+ *.ico binary
129
+ *.jng binary
130
+ *.jp2 binary
131
+ *.jpg binary
132
+ *.jpeg binary
133
+ *.jpx binary
134
+ *.jxr binary
135
+ *.pdf binary
136
+ *.png binary
137
+ *.psb binary
138
+ *.psd binary
139
+ *.svg text
140
+ *.svgz binary
141
+ *.tif binary
142
+ *.tiff binary
143
+ *.wbmp binary
144
+ *.webp binary
145
+
146
+ ## AUDIO
147
+ *.kar binary
148
+ *.m4a binary
149
+ *.mid binary
150
+ *.midi binary
151
+ *.mp3 binary
152
+ *.ogg binary
153
+ *.ra binary
154
+
155
+ ## VIDEO
156
+ *.3gpp binary
157
+ *.3gp binary
158
+ *.as binary
159
+ *.asf binary
160
+ *.asx binary
161
+ *.fla binary
162
+ *.flv binary
163
+ *.m4v binary
164
+ *.mng binary
165
+ *.mov binary
166
+ *.mp4 binary
167
+ *.mpeg binary
168
+ *.mpg binary
169
+ *.swc binary
170
+ *.swf binary
171
+ *.webm binary
172
+
173
+ ## ARCHIVES
174
+ *.7z binary
175
+ *.gz binary
176
+ *.rar binary
177
+ *.tar binary
178
+ *.zip binary
179
+
180
+ ## FONTS
181
+ *.ttf binary
182
+ *.eot binary
183
+ *.otf binary
184
+ *.woff binary
185
+ *.woff2 binary
186
+
187
+ ## EXECUTABLES
188
+ *.exe binary
189
+ *.pyc binary
190
+ *.jar binary
191
+ *.dll binary
192
+
193
+ ## DOCUMENT
194
+ *.doc binary
195
+ *.docx binary
196
+ *.xls binary
197
+ *.xlsx binary
198
+ *.ppt binary
199
+ *.pptx binary
200
+
201
+ ## EXTENSIONS
202
+ *.crx binary
203
+ *.xpi binary
@@ -0,0 +1 @@
1
+ pnpm commitlint --edit $1
@@ -0,0 +1 @@
1
+ pnpm lint-staged
@@ -0,0 +1,17 @@
1
+ # IDE
2
+ .vscode
3
+ .idea
4
+ .history
5
+ .git
6
+
7
+ # temp
8
+ .cache
9
+ .temp
10
+ .tmp
11
+
12
+ # project
13
+ node_modules
14
+ dist
15
+
16
+ # file
17
+ pnpm-lock.yaml
@@ -0,0 +1 @@
1
+ module.exports = require.resolve('@tomjs/prettier');
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ env: {
3
+ node: true,
4
+ es6: true,
5
+ },
6
+ extends: [require.resolve('@tomjs/eslint/node')],
7
+ };
@@ -0,0 +1,60 @@
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
+
57
+ # build output
58
+ build
59
+ dist
60
+ release
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ '*.{js,cjs,mjs,ts}': ['eslint --fix', 'prettier --write'],
3
+ '*.{json,md}': ['prettier --write'],
4
+ };
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "{{pkgName}}",
3
+ "version": "0.0.0",
4
+ "type": "commonjs",
5
+ "engines": {
6
+ "node": ">=16"
7
+ },
8
+ "packageManager": "pnpm@9.1.4",
9
+ "scripts": {
10
+ "lint": "run-s lint:eslint lint:prettier",
11
+ "lint:eslint": "eslint \"src/**/*.ts\" *.{js,cjs,mjs,ts} --fix --cache",
12
+ "lint:prettier": "prettier --write .",
13
+ "prepare": "husky"
14
+ },
15
+ "devDependencies": {
16
+ "@commitlint/cli": "^19.3.0",
17
+ "@tomjs/commitlint": "^3.3.0",
18
+ "@tomjs/eslint": "^3.1.1",
19
+ "@tomjs/prettier": "^1.4.1",
20
+ "@tomjs/tsconfig": "^1.6.0",
21
+ "@types/node": "^18.19.34",
22
+ "eslint": "^8.57.0",
23
+ "husky": "^9.0.11",
24
+ "lint-staged": "^15.2.5",
25
+ "npm-run-all": "^4.1.5",
26
+ "prettier": "^3.3.0",
27
+ "rimraf": "^5.0.7",
28
+ "typescript": "~5.4.5"
29
+ }
30
+ }
@@ -0,0 +1,28 @@
1
+ {
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
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "Debug Main Process",
9
+ "type": "node",
10
+ "request": "launch",
11
+ "cwd": "${workspaceFolder}",
12
+ "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
13
+ "windows": {
14
+ "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
15
+ },
16
+ "args": [
17
+ ".",
18
+ ],
19
+ "outFiles": [
20
+ "${workspaceFolder}/**/*.js",
21
+ "${workspaceFolder}/**/*.cjs",
22
+ "${workspaceFolder}/**/*.mjs",
23
+ "!**/node_modules/**"
24
+ ],
25
+ "preLaunchTask": "${defaultBuildTask}",
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
3
+ // for the documentation about the tasks.json format
4
+ "version": "2.0.0",
5
+ "tasks": [
6
+ {
7
+ "type": "npm",
8
+ "script": "dev",
9
+ "detail": "cross-env VITE_ELECTRON_DEBUG=1 vite",
10
+ "problemMatcher": {
11
+ "owner": "typescript",
12
+ "fileLocation": "relative",
13
+ "pattern": {
14
+ "regexp": "^([a-zA-Z]\\:\/?([\\w\\-]\/?)+\\.\\w+):(\\d+):(\\d+): (ERROR|WARNING)\\: (.*)$",
15
+ "file": 1,
16
+ "line": 3,
17
+ "column": 4,
18
+ "code": 5,
19
+ "message": 6
20
+ },
21
+ "background": {
22
+ "activeOnStart": true,
23
+ "beginsPattern": "^.*VITE v.* ready in \\d* ms.*$",
24
+ "endsPattern": "^.*\\[tomjs:electron\\] startup electron*$"
25
+ }
26
+ },
27
+ "isBackground": true,
28
+ "presentation": {
29
+ "reveal": "never"
30
+ },
31
+ "group": {
32
+ "kind": "build",
33
+ "isDefault": true
34
+ }
35
+ }
36
+ ]
37
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="@tomjs/vite-plugin-electron/env" />
@@ -0,0 +1,111 @@
1
+ import '../polyfills';
2
+
3
+ import { release } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { app, BrowserWindow, ipcMain, shell } from 'electron';
6
+
7
+ // Disable GPU Acceleration for Windows 7
8
+ if (release().startsWith('6.1')) app.disableHardwareAcceleration();
9
+
10
+ // Set application name for Windows 10+ notifications
11
+ if (process.platform === 'win32') app.setAppUserModelId(app.getName());
12
+
13
+ if (!app.requestSingleInstanceLock()) {
14
+ app.quit();
15
+ process.exit(0);
16
+ }
17
+
18
+ // Remove electron security warnings
19
+ // This warning only shows in development mode
20
+ // Read more on https://www.electronjs.org/docs/latest/tutorial/security
21
+ process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
22
+
23
+ const isDev = process.env.NODE_ENV === 'development';
24
+
25
+ let win: BrowserWindow | null = null;
26
+ // package.json "type":"module", must use mjs extension
27
+ const preload = join(__dirname, '../preload/index.mjs');
28
+ const serverUrl = process.env.VITE_DEV_SERVER_URL as string;
29
+ const rendererDist = join(__dirname, '../renderer');
30
+ const indexHtml = join(rendererDist, 'index.html');
31
+ const publicPath = serverUrl ? join(__dirname, '../../public') : rendererDist;
32
+
33
+ function createWindow() {
34
+ win = new BrowserWindow({
35
+ title: 'Main window',
36
+ width: 800,
37
+ height: 700,
38
+ icon: join(publicPath, 'img/icon.png'),
39
+ webPreferences: {
40
+ preload,
41
+ // Warning: Enable nodeIntegration and disable contextIsolation is not secure in production
42
+ // Consider using contextBridge.exposeInMainWorld
43
+ // Read more on https://www.electronjs.org/docs/latest/tutorial/context-isolation
44
+ nodeIntegration: true,
45
+ contextIsolation: false,
46
+ },
47
+ });
48
+
49
+ if (isDev) {
50
+ win.loadURL(serverUrl);
51
+ // Open devTool if the app is not packaged
52
+ win.webContents.openDevTools();
53
+ } else {
54
+ win.loadFile(indexHtml);
55
+ }
56
+
57
+ // Test actively push message to the Electron-Renderer
58
+ win.webContents.on('did-finish-load', () => {
59
+ win?.webContents.send('main-process-message', new Date().toLocaleString());
60
+ });
61
+
62
+ // Make all links open with the browser, not with the application
63
+ win.webContents.setWindowOpenHandler(({ url }) => {
64
+ if (url.startsWith('https:')) shell.openExternal(url);
65
+ return { action: 'deny' };
66
+ });
67
+ // win.webContents.on('will-navigate', (event, url) => { }) #344
68
+ }
69
+
70
+ app.whenReady().then(async () => {
71
+ createWindow();
72
+ });
73
+
74
+ app.on('window-all-closed', () => {
75
+ win = null;
76
+ if (process.platform !== 'darwin') app.quit();
77
+ });
78
+
79
+ app.on('second-instance', () => {
80
+ if (win) {
81
+ // Focus on the main window if the user tried to open another
82
+ if (win.isMinimized()) win.restore();
83
+ win.focus();
84
+ }
85
+ });
86
+
87
+ app.on('activate', () => {
88
+ const allWindows = BrowserWindow.getAllWindows();
89
+ if (allWindows.length) {
90
+ allWindows[0].focus();
91
+ } else {
92
+ createWindow();
93
+ }
94
+ });
95
+
96
+ // New window example arg: new windows url
97
+ ipcMain.handle('open-win', (_, arg) => {
98
+ const childWindow = new BrowserWindow({
99
+ webPreferences: {
100
+ preload,
101
+ nodeIntegration: true,
102
+ contextIsolation: false,
103
+ },
104
+ });
105
+
106
+ if (serverUrl) {
107
+ childWindow.loadURL(`${serverUrl}#${arg}`);
108
+ } else {
109
+ childWindow.loadFile(indexHtml, { hash: arg });
110
+ }
111
+ });
@@ -0,0 +1,4 @@
1
+ import { dirname } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+
4
+ global.__dirname = dirname(fileURLToPath(import.meta.url));
@@ -0,0 +1 @@
1
+ console.log('Electron Preload Process!');
@@ -0,0 +1,25 @@
1
+ {
2
+ "type": "module",
3
+ "engines": {
4
+ "node": ">=18"
5
+ },
6
+ "main": "dist/main/index.mjs",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "debug": "cross-env VITE_ELECTRON_DEBUG=1 npm run dev",
10
+ "build": "npm run clean && vite build",
11
+ "release": "cross-env VITE_ELECTRON_BUILDER=1 npm run build",
12
+ "clean": "rimraf ./dist",
13
+ "lint:eslint": "eslint \"{src,electron}/**/*.{ts,tsx}\" *.{js,cjs,mjs,ts} --fix --cache"
14
+ },
15
+ "dependencies": {
16
+ "@tomjs/electron-devtools-installer": "^2.2.1"
17
+ },
18
+ "devDependencies": {
19
+ "@tomjs/vite-plugin-electron": "^1.9.0",
20
+ "electron": "^30.0.9",
21
+ "electron-builder": "^24.13.3",
22
+ "vite": "^5.2.12",
23
+ "vite-plugin-electron-renderer": "^0.14.5"
24
+ }
25
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "@tomjs/tsconfig/node.json",
3
+ "compilerOptions": {
4
+ "composite": true
5
+ },
6
+ "include": ["electron", "package.json", "vite.config.ts"]
7
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) {{dateYear}}-PRESENT {{gitUserName}}<{{gitUserEmail}}>
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.
@@ -0,0 +1,13 @@
1
+ # {{pkgName}}
2
+
3
+ [![npm](https://img.shields.io/npm/v/{{pkgName}})](https://www.npmjs.com/package/{{pkgName}}) ![node-current (scoped)](https://img.shields.io/node/v/{{pkgName}}) ![NPM](https://img.shields.io/npm/l/{{pkgName}}) [![Docs](https://www.paka.dev/badges/v0/cute.svg)](https://www.paka.dev/npm/{{pkgName}})
4
+
5
+ **English** | [中文](./README.zh_CN.md)
6
+
7
+ > Basic template
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ {{pkgInstall}}
13
+ ```
@@ -0,0 +1,13 @@
1
+ # {{pkgName}}
2
+
3
+ [![npm](https://img.shields.io/npm/v/{{pkgName}})](https://www.npmjs.com/package/{{pkgName}}) ![node-current (scoped)](https://img.shields.io/node/v/{{pkgName}}) ![NPM](https://img.shields.io/npm/l/{{pkgName}}) [![Docs](https://www.paka.dev/badges/v0/cute.svg)](https://www.paka.dev/npm/{{pkgName}})
4
+
5
+ [English](./README.md) | **中文**
6
+
7
+ > 基础模板
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ {{pkgInstall}}
13
+ ```