@ohos-ports/tarojs-cli 0.0.0-stage → 4.3.0-beta.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.
Files changed (223) hide show
  1. package/LICENSE +174 -0
  2. package/README.md +0 -3
  3. package/bin/taro +7 -0
  4. package/dist/cli.d.ts +6 -0
  5. package/dist/cli.js +252 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/customCommand.d.ts +5 -0
  8. package/dist/commands/customCommand.js +23 -0
  9. package/dist/commands/customCommand.js.map +1 -0
  10. package/dist/config/index.d.ts +8 -0
  11. package/dist/config/index.js +10 -0
  12. package/dist/config/index.js.map +1 -0
  13. package/dist/config/packagesManagement.d.ts +19 -0
  14. package/dist/config/packagesManagement.js +22 -0
  15. package/dist/config/packagesManagement.js.map +1 -0
  16. package/dist/create/constants.d.ts +1 -0
  17. package/dist/create/constants.js +5 -0
  18. package/dist/create/constants.js.map +1 -0
  19. package/dist/create/creator.d.ts +9 -0
  20. package/dist/create/creator.js +31 -0
  21. package/dist/create/creator.js.map +1 -0
  22. package/dist/create/fetchTemplate.d.ts +8 -0
  23. package/dist/create/fetchTemplate.js +137 -0
  24. package/dist/create/fetchTemplate.js.map +1 -0
  25. package/dist/create/page.d.ts +65 -0
  26. package/dist/create/page.js +252 -0
  27. package/dist/create/page.js.map +1 -0
  28. package/dist/create/plugin.d.ts +16 -0
  29. package/dist/create/plugin.js +48 -0
  30. package/dist/create/plugin.js.map +1 -0
  31. package/dist/create/project.d.ts +80 -0
  32. package/dist/create/project.js +519 -0
  33. package/dist/create/project.js.map +1 -0
  34. package/dist/doctor/index.d.ts +4 -0
  35. package/dist/doctor/index.js +32 -0
  36. package/dist/doctor/index.js.map +1 -0
  37. package/dist/index.d.ts +16 -0
  38. package/dist/index.js +21 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/presets/commands/build.d.ts +3 -0
  41. package/dist/presets/commands/build.js +239 -0
  42. package/dist/presets/commands/build.js.map +1 -0
  43. package/dist/presets/commands/config.d.ts +3 -0
  44. package/dist/presets/commands/config.js +88 -0
  45. package/dist/presets/commands/config.js.map +1 -0
  46. package/dist/presets/commands/create.d.ts +3 -0
  47. package/dist/presets/commands/create.js +91 -0
  48. package/dist/presets/commands/create.js.map +1 -0
  49. package/dist/presets/commands/global-config.d.ts +3 -0
  50. package/dist/presets/commands/global-config.js +139 -0
  51. package/dist/presets/commands/global-config.js.map +1 -0
  52. package/dist/presets/commands/help.d.ts +3 -0
  53. package/dist/presets/commands/help.js +29 -0
  54. package/dist/presets/commands/help.js.map +1 -0
  55. package/dist/presets/commands/info.d.ts +3 -0
  56. package/dist/presets/commands/info.js +79 -0
  57. package/dist/presets/commands/info.js.map +1 -0
  58. package/dist/presets/commands/init.d.ts +3 -0
  59. package/dist/presets/commands/init.js +59 -0
  60. package/dist/presets/commands/init.js.map +1 -0
  61. package/dist/presets/commands/inspect.d.ts +3 -0
  62. package/dist/presets/commands/inspect.js +118 -0
  63. package/dist/presets/commands/inspect.js.map +1 -0
  64. package/dist/presets/commands/update.d.ts +3 -0
  65. package/dist/presets/commands/update.js +171 -0
  66. package/dist/presets/commands/update.js.map +1 -0
  67. package/dist/presets/constant/hooks.d.ts +13 -0
  68. package/dist/presets/constant/hooks.js +17 -0
  69. package/dist/presets/constant/hooks.js.map +1 -0
  70. package/dist/presets/constant/index.d.ts +1 -0
  71. package/dist/presets/constant/index.js +18 -0
  72. package/dist/presets/constant/index.js.map +1 -0
  73. package/dist/presets/files/generateFrameworkInfo.d.ts +3 -0
  74. package/dist/presets/files/generateFrameworkInfo.js +30 -0
  75. package/dist/presets/files/generateFrameworkInfo.js.map +1 -0
  76. package/dist/presets/files/generateProjectConfig.d.ts +3 -0
  77. package/dist/presets/files/generateProjectConfig.js +40 -0
  78. package/dist/presets/files/generateProjectConfig.js.map +1 -0
  79. package/dist/presets/files/writeFileToDist.d.ts +3 -0
  80. package/dist/presets/files/writeFileToDist.js +17 -0
  81. package/dist/presets/files/writeFileToDist.js.map +1 -0
  82. package/dist/presets/hooks/build.d.ts +3 -0
  83. package/dist/presets/hooks/build.js +22 -0
  84. package/dist/presets/hooks/build.js.map +1 -0
  85. package/dist/presets/hooks/create.d.ts +3 -0
  86. package/dist/presets/hooks/create.js +11 -0
  87. package/dist/presets/hooks/create.js.map +1 -0
  88. package/dist/presets/index.d.ts +4 -0
  89. package/dist/presets/index.js +17 -0
  90. package/dist/presets/index.js.map +1 -0
  91. package/dist/presets/platforms/plugin.d.ts +3 -0
  92. package/dist/presets/platforms/plugin.js +76 -0
  93. package/dist/presets/platforms/plugin.js.map +1 -0
  94. package/dist/presets/platforms/rn.d.ts +3 -0
  95. package/dist/presets/platforms/rn.js +101 -0
  96. package/dist/presets/platforms/rn.js.map +1 -0
  97. package/dist/util/appConfig.d.ts +11 -0
  98. package/dist/util/appConfig.js +25 -0
  99. package/dist/util/appConfig.js.map +1 -0
  100. package/dist/util/createPage.d.ts +9 -0
  101. package/dist/util/createPage.js +117 -0
  102. package/dist/util/createPage.js.map +1 -0
  103. package/dist/util/defineConfig.d.ts +17 -0
  104. package/dist/util/defineConfig.js +12 -0
  105. package/dist/util/defineConfig.js.map +1 -0
  106. package/dist/util/index.d.ts +23 -0
  107. package/dist/util/index.js +125 -0
  108. package/dist/util/index.js.map +1 -0
  109. package/dist/util/types.d.ts +58 -0
  110. package/dist/util/types.js +3 -0
  111. package/dist/util/types.js.map +1 -0
  112. package/global.d.ts +4 -0
  113. package/index.js +3 -0
  114. package/package.json +76 -4
  115. package/postinstall.js +14 -0
  116. package/src/__tests__/__mocks__/presets.ts +15 -0
  117. package/src/__tests__/build-config.spec.ts +99 -0
  118. package/src/__tests__/cli.spec.ts +233 -0
  119. package/src/__tests__/config.spec.ts +232 -0
  120. package/src/__tests__/doctor-config.spec.ts +805 -0
  121. package/src/__tests__/doctor-eslint.spec.ts +31 -0
  122. package/src/__tests__/doctor-recommand.spec.ts +158 -0
  123. package/src/__tests__/doctor.spec.ts +77 -0
  124. package/src/__tests__/dotenv-parse.spec.ts +105 -0
  125. package/src/__tests__/env/.env +2 -0
  126. package/src/__tests__/fixtures/default/.env +3 -0
  127. package/src/__tests__/fixtures/default/.env.development +1 -0
  128. package/src/__tests__/fixtures/default/.env.local +1 -0
  129. package/src/__tests__/fixtures/default/.env.pre +3 -0
  130. package/src/__tests__/fixtures/default/.env.production +1 -0
  131. package/src/__tests__/fixtures/default/.env.uat +5 -0
  132. package/src/__tests__/fixtures/default/.env.uat.local +1 -0
  133. package/src/__tests__/fixtures/default/babel.config.js +10 -0
  134. package/src/__tests__/fixtures/default/config/dev.js +9 -0
  135. package/src/__tests__/fixtures/default/config/index.js +84 -0
  136. package/src/__tests__/fixtures/default/config/prod.js +18 -0
  137. package/src/__tests__/fixtures/default/package.json +38 -0
  138. package/src/__tests__/fixtures/default/src/app.config.js +11 -0
  139. package/src/__tests__/fixtures/default/src/app.js +16 -0
  140. package/src/__tests__/fixtures/default/src/app.scss +0 -0
  141. package/src/__tests__/fixtures/default/src/index.html +19 -0
  142. package/src/__tests__/fixtures/default/src/pages/index/index.config.js +3 -0
  143. package/src/__tests__/fixtures/default/src/pages/index/index.jsx +22 -0
  144. package/src/__tests__/fixtures/default/src/pages/index/index.scss +0 -0
  145. package/src/__tests__/info.spec.ts +74 -0
  146. package/src/__tests__/inspect.spec.ts +163 -0
  147. package/src/__tests__/project.spec.ts +304 -0
  148. package/src/__tests__/update.spec.ts +324 -0
  149. package/src/__tests__/utils/index.ts +54 -0
  150. package/src/cli.ts +250 -0
  151. package/src/commands/customCommand.ts +26 -0
  152. package/src/config/index.ts +7 -0
  153. package/src/config/manifest.default.json +35 -0
  154. package/src/config/packagesManagement.ts +20 -0
  155. package/src/config/rn-stylelint.json +5 -0
  156. package/src/config/tsconfig.json +24 -0
  157. package/src/create/constants.ts +1 -0
  158. package/src/create/creator.ts +37 -0
  159. package/src/create/fetchTemplate.ts +152 -0
  160. package/src/create/page.ts +299 -0
  161. package/src/create/plugin.ts +55 -0
  162. package/src/create/project.ts +591 -0
  163. package/src/doctor/index.ts +27 -0
  164. package/src/index.ts +24 -0
  165. package/src/presets/commands/build.ts +227 -0
  166. package/src/presets/commands/config.ts +86 -0
  167. package/src/presets/commands/create.ts +105 -0
  168. package/src/presets/commands/global-config.ts +140 -0
  169. package/src/presets/commands/help.ts +19 -0
  170. package/src/presets/commands/info.ts +77 -0
  171. package/src/presets/commands/init.ts +66 -0
  172. package/src/presets/commands/inspect.ts +138 -0
  173. package/src/presets/commands/update.ts +179 -0
  174. package/src/presets/constant/hooks.ts +14 -0
  175. package/src/presets/constant/index.ts +1 -0
  176. package/src/presets/files/generateFrameworkInfo.ts +30 -0
  177. package/src/presets/files/generateProjectConfig.ts +41 -0
  178. package/src/presets/files/writeFileToDist.ts +17 -0
  179. package/src/presets/hooks/build.ts +22 -0
  180. package/src/presets/hooks/create.ts +11 -0
  181. package/src/presets/index.ts +15 -0
  182. package/src/presets/platforms/plugin.ts +81 -0
  183. package/src/presets/platforms/rn.ts +113 -0
  184. package/src/util/appConfig.ts +29 -0
  185. package/src/util/createPage.ts +132 -0
  186. package/src/util/defineConfig.ts +22 -0
  187. package/src/util/index.ts +127 -0
  188. package/src/util/types.ts +81 -0
  189. package/templates/default/.husky/commit-msg +4 -0
  190. package/templates/default/_editorconfig +12 -0
  191. package/templates/default/_env.development +2 -0
  192. package/templates/default/_env.production +1 -0
  193. package/templates/default/_env.test +1 -0
  194. package/templates/default/_eslintrc +11 -0
  195. package/templates/default/_gitignore +8 -0
  196. package/templates/default/babel.config.js +14 -0
  197. package/templates/default/commitlint.config.mjs +1 -0
  198. package/templates/default/config/dev.js +10 -0
  199. package/templates/default/config/index.js +106 -0
  200. package/templates/default/config/prod.js +46 -0
  201. package/templates/default/package.json.tmpl +158 -0
  202. package/templates/default/project.config.json +15 -0
  203. package/templates/default/src/app.config.js +11 -0
  204. package/templates/default/src/app.css +0 -0
  205. package/templates/default/src/app.js +44 -0
  206. package/templates/default/src/index.html +17 -0
  207. package/templates/default/src/pages/index/index.config.js +3 -0
  208. package/templates/default/src/pages/index/index.css +0 -0
  209. package/templates/default/src/pages/index/index.jsx +15 -0
  210. package/templates/default/src/pages/index/index.vue +23 -0
  211. package/templates/default/stylelint.config.mjs +4 -0
  212. package/templates/default/template_creator.js +77 -0
  213. package/templates/default/tsconfig.json +32 -0
  214. package/templates/default/types/global.d.ts +35 -0
  215. package/templates/default/types/solid.d.ts +12 -0
  216. package/templates/default/types/vue.d.ts +10 -0
  217. package/templates/global-config/index.json +4 -0
  218. package/templates/global-config/package.json +5 -0
  219. package/templates/plugin-compile/README.md +32 -0
  220. package/templates/plugin-compile/index.js +3 -0
  221. package/templates/plugin-compile/package.json.tmpl +43 -0
  222. package/templates/plugin-compile/src/index.ts +153 -0
  223. package/templates/plugin-compile/tsconfig.json +29 -0
@@ -0,0 +1,106 @@
1
+ import { defineConfig{{#if typescript }}, type UserConfigExport{{/if}} } from '@tarojs/cli'
2
+ {{#if typescript }}{{#unless (eq compiler "Vite")}}import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'{{/unless}}{{/if}}
3
+ import devConfig from './dev'
4
+ import prodConfig from './prod'
5
+
6
+ // https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数
7
+ export default defineConfig{{#if typescript }}<'{{ to_lower_case compiler }}'>{{/if}}(async (merge, { command, mode }) => {
8
+ const baseConfig{{#if typescript }}: UserConfigExport<'{{ to_lower_case compiler }}'>{{/if}} = {
9
+ projectName: '{{ projectName }}',
10
+ date: '{{ date }}',
11
+ designWidth: 750,
12
+ deviceRatio: {
13
+ 640: 2.34 / 2,
14
+ 750: 1,
15
+ 375: 2,
16
+ 828: 1.81 / 2
17
+ },
18
+ sourceRoot: 'src',
19
+ outputRoot: 'dist',
20
+ plugins: [
21
+ "@tarojs/plugin-generator"
22
+ ],
23
+ defineConstants: {
24
+ },
25
+ copy: {
26
+ patterns: [
27
+ ],
28
+ options: {
29
+ }
30
+ },
31
+ framework: '{{ to_lower_case framework }}',
32
+ compiler: '{{ to_lower_case compiler }}',{{#if (eq compiler "Webpack5") }}
33
+ cache: {
34
+ enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
35
+ },{{/if}}{{#if (array_includes platforms "weapp" "alipay" "swan" "tt" "qq" "jd") }}
36
+ mini: {
37
+ postcss: {
38
+ pxtransform: {
39
+ enable: true,
40
+ config: {
41
+
42
+ }
43
+ },
44
+ cssModules: {
45
+ enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
46
+ config: {
47
+ namingPattern: 'module', // 转换模式,取值为 global/module
48
+ generateScopedName: '[name]__[local]___[hash:base64:5]'
49
+ }
50
+ }
51
+ },{{#if typescript }}{{#unless (eq compiler "Vite")}}
52
+ webpackChain(chain) {
53
+ chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
54
+ }{{/unless}}{{/if}}
55
+ },{{/if}}{{#if (array_includes platforms "h5" "harmony-hybrid") }}
56
+ h5: {
57
+ publicPath: '/',
58
+ staticDirectory: 'static',
59
+ {{#unless (eq compiler "Vite")}}
60
+ output: {
61
+ filename: 'js/[name].[hash:8].js',
62
+ chunkFilename: 'js/[name].[chunkhash:8].js'
63
+ },{{/unless}}
64
+ miniCssExtractPluginOption: {
65
+ ignoreOrder: true,
66
+ filename: 'css/[name].[hash].css',
67
+ chunkFilename: 'css/[name].[chunkhash].css'
68
+ },
69
+ postcss: {
70
+ autoprefixer: {
71
+ enable: true,
72
+ config: {}
73
+ },
74
+ cssModules: {
75
+ enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
76
+ config: {
77
+ namingPattern: 'module', // 转换模式,取值为 global/module
78
+ generateScopedName: '[name]__[local]___[hash:base64:5]'
79
+ }
80
+ }
81
+ }{{#if typescript }},{{#unless (eq compiler "Vite")}}
82
+ webpackChain(chain) {
83
+ chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
84
+ }{{/unless}}{{/if}}
85
+ },{{/if}}{{#if (array_includes platforms "rn") }}
86
+ rn: {
87
+ appName: 'taroDemo',
88
+ postcss: {
89
+ cssModules: {
90
+ enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
91
+ }
92
+ }
93
+ },{{/if}}
94
+ }
95
+
96
+ {{#if buildEs5 }}
97
+ process.env.BROWSERSLIST_ENV = process.env.NODE_ENV
98
+ {{/if}}
99
+
100
+ if (process.env.NODE_ENV === 'development') {
101
+ // 本地开发构建配置(不混淆压缩)
102
+ return merge({}, baseConfig, devConfig)
103
+ }
104
+ // 生产构建配置(默认开启压缩混淆等)
105
+ return merge({}, baseConfig, prodConfig)
106
+ })
@@ -0,0 +1,46 @@
1
+ {{#if typescript }}import type { UserConfigExport } from "@tarojs/cli"{{/if}}
2
+
3
+ export default {
4
+ mini: {},
5
+ h5: {
6
+ {{#if buildEs5 }}
7
+ {{#if (eq compiler 'Vite')}}
8
+ // 确保产物为 es5
9
+ legacy: true,
10
+ {{else if (eq compiler 'Webpack5')}}
11
+ compile: {
12
+ include: [
13
+ // 确保产物为 es5
14
+ filename => /node_modules\/(?!(@babel|core-js|style-loader|css-loader|react|react-dom))/.test(filename)
15
+ ]
16
+ },
17
+ {{/if}}
18
+ {{/if}}
19
+ /**
20
+ * WebpackChain 插件配置
21
+ * @docs https://github.com/neutrinojs/webpack-chain
22
+ */
23
+ // webpackChain (chain) {
24
+ // /**
25
+ // * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
26
+ // * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
27
+ // */
28
+ // chain.plugin('analyzer')
29
+ // .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
30
+ // /**
31
+ // * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
32
+ // * @docs https://github.com/chrisvfritz/prerender-spa-plugin
33
+ // */
34
+ // const path = require('path')
35
+ // const Prerender = require('prerender-spa-plugin')
36
+ // const staticDir = path.join(__dirname, '..', 'dist')
37
+ // chain
38
+ // .plugin('prerender')
39
+ // .use(new Prerender({
40
+ // staticDir,
41
+ // routes: [ '/pages/index/index' ],
42
+ // postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
43
+ // }))
44
+ // }
45
+ }
46
+ }{{#if typescript }} satisfies UserConfigExport<'{{ to_lower_case compiler }}'>{{/if}}
@@ -0,0 +1,158 @@
1
+ {
2
+ "name": "{{ projectName }}",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "description": "{{ description }}",
6
+ "templateInfo": {
7
+ "name": "{{ template }}",
8
+ "typescript": {{ typescript }},
9
+ "css": "{{ css }}",
10
+ "framework": "{{ framework }}"
11
+ },
12
+ "scripts": {
13
+ "prepare": "husky",
14
+ "new": "taro new"{{#if (array_includes platforms "weapp")}},
15
+ "build:weapp": "taro build --type weapp",
16
+ "dev:weapp": "npm run build:weapp -- --watch"{{/if}}{{#if (array_includes platforms "swan")}},
17
+ "build:swan": "taro build --type swan",
18
+ "dev:swan": "npm run build:swan -- --watch"{{/if}}{{#if (array_includes platforms "alipay")}},
19
+ "build:alipay": "taro build --type alipay",
20
+ "dev:alipay": "npm run build:alipay -- --watch"{{/if}}{{#if (array_includes platforms "tt")}},
21
+ "build:tt": "taro build --type tt",
22
+ "dev:tt": "npm run build:tt -- --watch"{{/if}}{{#if (array_includes platforms "h5")}},
23
+ "build:h5": "taro build --type h5",
24
+ "dev:h5": "npm run build:h5 -- --watch"{{/if}}{{#if (array_includes platforms "rn")}},
25
+ "build:rn": "taro build --type rn",
26
+ "dev:rn": "npm run build:rn -- --watch"{{/if}}{{#if (array_includes platforms "qq")}},
27
+ "build:qq": "taro build --type qq",
28
+ "dev:qq": "npm run build:qq -- --watch"{{/if}}{{#if (array_includes platforms "jd")}},
29
+ "build:jd": "taro build --type jd",
30
+ "dev:jd": "npm run build:jd -- --watch"{{/if}}{{#if (array_includes platforms "harmony-hybrid")}},
31
+ "build:harmony-hybrid": "taro build --type harmony-hybrid",
32
+ "dev:harmony-hybrid": "npm run build:harmony-hybrid -- --watch"{{/if}}
33
+ },
34
+ {{#if buildEs5 }}
35
+ "browserslist": {
36
+ "development": [
37
+ "defaults and fully supports es6-module",
38
+ "maintained node versions"
39
+ ],
40
+ "production": [
41
+ "last 3 versions",
42
+ "Android >= 4.1",
43
+ "ios >= 8"
44
+ ]
45
+ },
46
+ {{else}}
47
+ "browserslist": [
48
+ "defaults and fully supports es6-module",
49
+ "maintained node versions"
50
+ ],
51
+ {{/if}}
52
+ "author": "",
53
+ "dependencies": {
54
+ "@babel/runtime": "^7.24.4",
55
+ "@tarojs/components": "{{ version }}",
56
+ "@tarojs/helper": "{{ version }}",{{#if (array_includes platforms "weapp")}}
57
+ "@tarojs/plugin-platform-weapp": "{{ version }}",{{/if}}{{#if (array_includes platforms "alipay")}}
58
+ "@tarojs/plugin-platform-alipay": "{{ version }}",{{/if}}{{#if (array_includes platforms "tt")}}
59
+ "@tarojs/plugin-platform-tt": "{{ version }}",{{/if}}{{#if (array_includes platforms "swan")}}
60
+ "@tarojs/plugin-platform-swan": "{{ version }}",{{/if}}{{#if (array_includes platforms "jd")}}
61
+ "@tarojs/plugin-platform-jd": "{{ version }}",{{/if}}{{#if (array_includes platforms "qq")}}
62
+ "@tarojs/plugin-platform-qq": "{{ version }}",{{/if}}{{#if (array_includes platforms "h5")}}
63
+ "@tarojs/plugin-platform-h5": "{{ version }}",{{/if}}{{#if (array_includes platforms "harmony-hybrid")}}
64
+ "@tarojs/plugin-platform-harmony-hybrid": "{{ version }}",{{/if}}
65
+ "@tarojs/runtime": "{{ version }}",
66
+ "@tarojs/shared": "{{ version }}",
67
+ "@tarojs/taro": "{{ version }}",{{#if (includes "React" "Preact" s=framework)}}
68
+ "@tarojs/plugin-framework-react": "{{ version }}",{{/if}}{{#if (eq framework "React") }}
69
+ "@tarojs/react": "{{ version }}",
70
+ "react-dom": "^18.0.0",
71
+ "react": "^18.0.0"{{/if}}{{#if (eq framework "Preact") }}
72
+ "preact": "^10.5.15"{{/if}}{{#if (eq framework "Vue3") }}
73
+ "@tarojs/plugin-framework-vue3": "{{ version }}",
74
+ "vue": "^3.0.0"{{/if}}{{#if (eq framework "Solid") }}
75
+ "@tarojs/plugin-framework-solid": "{{ version }}",
76
+ "solid-js": "^1.8.16"{{/if}}
77
+ },{{#if (includes "Webpack5" s=compiler)}}
78
+ "devDependencies": {
79
+ "@tarojs/plugin-generator": "{{ version }}",
80
+ "@commitlint/cli": "^19.8.1",
81
+ "@commitlint/config-conventional": "^19.8.1",
82
+ "lint-staged": "^16.1.2",
83
+ "husky": "^9.1.7",
84
+ "stylelint-config-standard": "^38.0.0",
85
+ "@babel/core": "^7.24.4",
86
+ "@tarojs/cli": "{{ version }}",
87
+ "@babel/plugin-transform-class-properties": "7.25.9",
88
+ "@types/webpack-env": "^1.13.6",{{#if (includes "React" "Preact" s=framework)}}
89
+ "@types/react": "^18.0.0",{{/if}}{{#if (eq compiler "Webpack5") }}
90
+ "webpack": "5.91.0",
91
+ "@tarojs/taro-loader": "{{ version }}",
92
+ "@tarojs/webpack5-runner": "{{ version }}",{{/if}}{{#if (eq css "Sass") }}
93
+ "sass": "^1.75.0",{{/if}}{{#if (eq css "Less") }}
94
+ "less": "^4.2.0",{{/if}}{{#if (eq css "Stylus") }}
95
+ "stylus": "^0.63.0",{{/if}}
96
+ "babel-preset-taro": "{{ version }}",{{#if (eq framework "Vue3") }}
97
+ "css-loader": "^7.1.1",
98
+ "style-loader": "^3.3.4",
99
+ "@tarojs/test-utils-vue3": "^0.1.1",
100
+ "@vue/babel-plugin-jsx": "^1.2.2",
101
+ "@vue/compiler-sfc": "^3.0.0",
102
+ "vue-loader": "^17.4.2",
103
+ "eslint-plugin-vue": "^9.17.0",{{/if}}
104
+ "eslint-config-taro": "{{ version }}",
105
+ "eslint": "^8.57.0",{{#if (eq framework "React") }}
106
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
107
+ "react-refresh": "^0.14.0",{{/if}}{{#if (eq framework "Preact") }}
108
+ "@prefresh/webpack": "^4",
109
+ "@prefresh/core": "^1.5.2",
110
+ "@prefresh/babel-plugin": "^0.5.1",{{/if}}{{#if (includes "React" "Preact" s=framework)}}
111
+ "@babel/preset-react": "^7.24.1",
112
+ "eslint-plugin-react": "^7.34.1",
113
+ "eslint-plugin-react-hooks": "^4.4.0",{{/if}}
114
+ "stylelint": "^16.4.0"{{#if typescript }},
115
+ "typescript": "^5.4.5",
116
+ "tsconfig-paths-webpack-plugin": "^4.1.0"{{/if}},
117
+ "postcss": "^8.5.6",
118
+ "@types/node": "^18",
119
+ "@types/minimatch": "^5"
120
+ }{{/if}}{{#if (eq compiler "Vite") }}
121
+ "devDependencies": {
122
+ "@tarojs/plugin-generator": "{{ version }}",
123
+ "@commitlint/cli": "^19.8.1",
124
+ "@commitlint/config-conventional": "^19.8.1",
125
+ "lint-staged": "^16.1.2",
126
+ "husky": "^9.1.7",
127
+ "stylelint-config-standard": "^38.0.0",
128
+ "@babel/core": "^7.24.4",
129
+ "@babel/plugin-transform-class-properties": "7.25.9",
130
+ "@tarojs/cli": "{{ version }}",
131
+ "@tarojs/vite-runner": "{{ version }}",
132
+ "babel-preset-taro": "{{ version }}",
133
+ "eslint-config-taro": "{{ version }}",
134
+ "eslint": "^8.57.0",
135
+ "stylelint": "^16.4.0",
136
+ "terser": "^5.30.4",
137
+ "vite": "^4.2.0",{{#if (includes "React" "Preact" s=framework)}}
138
+ "@babel/preset-react": "^7.24.1",
139
+ "@types/react": "^18.0.0",
140
+ "@vitejs/plugin-react": "^4.3.0",
141
+ "eslint-plugin-react": "^7.34.1",
142
+ "eslint-plugin-react-hooks": "^4.4.0",{{/if}}{{#if (eq framework "Preact") }}
143
+ "@preact/preset-vite": "^2.8.2",
144
+ "@prefresh/core": "^1.5.2",
145
+ "@prefresh/babel-plugin": "^0.5.1",{{/if}}{{#if (eq framework "React") }}
146
+ "react-refresh": "^0.14.0",{{/if}}{{#if (eq framework "Vue3") }}
147
+ "@vitejs/plugin-vue": "^5.0.4",
148
+ "@vitejs/plugin-vue-jsx": "^3.1.0",
149
+ "eslint-plugin-vue": "^9.17.0",{{/if}}{{#if (eq framework "Solid") }}
150
+ "vite-plugin-solid": "2.10.0",{{/if}}{{#if (eq css "Sass") }}
151
+ "sass": "^1.75.0",{{/if}}{{#if (eq css "Less") }}
152
+ "less": "^4.2.0",{{/if}}{{#if (eq css "Stylus") }}
153
+ "stylus": "^0.63.0",{{/if}}{{#if typescript }}
154
+ "typescript": "^5.4.5",{{/if}}
155
+ "postcss": "^8.5.6",
156
+ "@types/minimatch": "^5"
157
+ }{{/if}}
158
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "miniprogramRoot": "./dist",
3
+ "projectname": "{{ projectName }}",
4
+ "description": "{{ description }}",
5
+ "appid": "touristappid",
6
+ "setting": {
7
+ "urlCheck": true,
8
+ "es6": false,
9
+ "enhance": false,
10
+ "compileHotReLoad": false,
11
+ "postcss": false,
12
+ "minified": false
13
+ },
14
+ "compileType": "miniprogram"
15
+ }
@@ -0,0 +1,11 @@
1
+ export default defineAppConfig({
2
+ pages: [
3
+ 'pages/index/index'
4
+ ],
5
+ window: {
6
+ backgroundTextStyle: 'light',
7
+ navigationBarBackgroundColor: '#fff',
8
+ navigationBarTitleText: 'WeChat',
9
+ navigationBarTextStyle: 'black'
10
+ }
11
+ })
File without changes
@@ -0,0 +1,44 @@
1
+ {{#if (includes "React" "Preact" s=framework)}}
2
+ {{#if typescript }}import { PropsWithChildren } from 'react'{{/if}}
3
+ import { useLaunch } from '@tarojs/taro'
4
+ {{/if}}{{#if (eq framework 'Vue3') }}
5
+ import { createApp } from 'vue'
6
+ {{/if}}{{#if (eq framework 'Solid') }}
7
+ {{#if typescript }}import { ParentProps } from 'solid-js'{{/if}}
8
+ import { useLaunch } from '@tarojs/taro'
9
+ {{/if}}
10
+
11
+ import './app.{{ cssExt }}'
12
+
13
+ {{#if (includes "React" "Preact" s=framework)}}
14
+ function App({ children }{{#if typescript }}: PropsWithChildren<any>{{/if}}) {
15
+ useLaunch(() => {
16
+ console.log('App launched.')
17
+ })
18
+
19
+ // children 是将要会渲染的页面
20
+ return children
21
+ }
22
+ {{/if}}
23
+
24
+ {{#if (eq framework 'Solid') }}
25
+ function App({ children }{{#if typescript }}: ParentProps{{/if}}) {
26
+ useLaunch(() => {
27
+ console.log('App launched.')
28
+ })
29
+
30
+ // children 是将要会渲染的页面
31
+ return children
32
+ }
33
+ {{/if}}
34
+
35
+ {{#if (eq framework 'Vue3') }}
36
+ const App = createApp({
37
+ onShow (options) {
38
+ console.log('App onShow.')
39
+ },
40
+ // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
41
+ })
42
+ {{/if}}
43
+
44
+ export default App
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
5
+ <meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
6
+ <meta name="apple-mobile-web-app-capable" content="yes">
7
+ <meta name="apple-touch-fullscreen" content="yes">
8
+ <meta name="format-detection" content="telephone=no,address=no">
9
+ <meta name="apple-mobile-web-app-status-bar-style" content="white">
10
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
11
+ <title>{{ projectName }}</title>
12
+ <script><%= htmlWebpackPlugin.options.script %></script>
13
+ </head>
14
+ <body>
15
+ <div id="app"></div>
16
+ </body>
17
+ </html>
@@ -0,0 +1,3 @@
1
+ export default definePageConfig({
2
+ navigationBarTitleText: '首页'
3
+ })
File without changes
@@ -0,0 +1,15 @@
1
+ import { View, Text } from '@tarojs/components'
2
+ import { useLoad } from '@tarojs/taro'
3
+ import './index.{{ cssExt }}'
4
+
5
+ export default function {{ to_pascal_case pageName }} () {
6
+ useLoad(() => {
7
+ console.log('Page loaded.')
8
+ })
9
+
10
+ return (
11
+ <View className='{{ pageName }}'>
12
+ <Text>Hello world!</Text>
13
+ </View>
14
+ )
15
+ }
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <view class="{{ pageName }}">
3
+ <text>\{{ msg }}</text>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ {{#if (eq framework 'Vue3') }}
9
+ import { ref } from 'vue'
10
+ {{/if}}
11
+ import './index.{{ cssExt }}'
12
+
13
+ export default {
14
+ {{#if (eq framework 'Vue3') }}
15
+ setup () {
16
+ const msg = ref('Hello world')
17
+ return {
18
+ msg
19
+ }
20
+ }
21
+ {{/if}}
22
+ }
23
+ </script>
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ export default {
3
+ extends: "stylelint-config-standard",
4
+ };
@@ -0,0 +1,77 @@
1
+ const path = require('path')
2
+
3
+ function createWhenTs (err, params) {
4
+ return !!params.typescript
5
+ }
6
+
7
+ function normalizePath (path) {
8
+ return path.replace(/\\/g, '/').replace(/\/{2,}/g, '/')
9
+ }
10
+
11
+ const SOURCE_ENTRY = '/src'
12
+ const PAGES_ENTRY = '/src/pages'
13
+
14
+ const handler = {
15
+ '/tsconfig.json': createWhenTs,
16
+ '/types/global.d.ts': createWhenTs,
17
+ '/types/vue.d.ts' (err, { framework, typescript }) {
18
+ return ['Vue3'].includes(framework) && !!typescript
19
+ },
20
+ '/types/solid.d.ts' (err, { framework, typescript }) {
21
+ return ['Solid'].includes(framework) && !!typescript
22
+ },
23
+ '/src/pages/index/index.jsx' (err, { pageDir = '', pageName = '', subPkg = '' }) {
24
+ return {
25
+ setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.jsx')),
26
+ setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.jsx'))
27
+ }
28
+ },
29
+ '/src/pages/index/index.css' (err, { pageDir = '', pageName = '', subPkg = '' }) {
30
+ return {
31
+ setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.css')),
32
+ setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.css'))
33
+ }
34
+ },
35
+ '/src/pages/index/index.vue' (err, { pageDir = '', pageName = '', subPkg = '' }) {
36
+ return {
37
+ setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.vue')),
38
+ setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.vue'))
39
+ }
40
+ },
41
+ '/src/pages/index/index.config.js' (err, { pageDir = '', pageName = '', subPkg = '' }) {
42
+ return {
43
+ setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.config.js')),
44
+ setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.config.js'))
45
+ }
46
+ },
47
+ '/_editorconfig' () {
48
+ return { setPageName: `/.editorconfig` }
49
+ },
50
+ '/_env.development' () {
51
+ return { setPageName: `/.env.development` }
52
+ },
53
+ '/_env.production' () {
54
+ return { setPageName: `/.env.production` }
55
+ },
56
+ '/_env.test' () {
57
+ return { setPageName: `/.env.test` }
58
+ },
59
+ '/_eslintrc' () {
60
+ return { setPageName: `/.eslintrc` }
61
+ },
62
+ '/_gitignore' () {
63
+ return { setPageName: `/.gitignore` }
64
+ }
65
+ }
66
+
67
+ const basePageFiles = [
68
+ '/src/pages/index/index.jsx',
69
+ '/src/pages/index/index.vue',
70
+ '/src/pages/index/index.css',
71
+ '/src/pages/index/index.config.js'
72
+ ]
73
+
74
+ module.exports = {
75
+ handler,
76
+ basePageFiles
77
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2017",
4
+ "module": "commonjs",
5
+ "removeComments": false,
6
+ "preserveConstEnums": true,
7
+ "moduleResolution": "node",
8
+ "experimentalDecorators": true,
9
+ "noImplicitAny": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "outDir": "lib",
12
+ "noUnusedLocals": true,
13
+ "noUnusedParameters": true,
14
+ "strictNullChecks": true,
15
+ "sourceMap": true,
16
+ "rootDir": ".",
17
+ "jsx": "{{#if (includes "Vue3" s=framework)}}preserve{{else if (eq framework 'Solid')}}preserve{{else}}react-jsx{{/if}}",{{#if (eq framework "Preact") }}
18
+ "skipLibCheck": true,{{/if}}
19
+ "allowJs": true,{{#if (eq framework "Solid")}}
20
+ "jsxImportSource": "solid-js",{{/if}}
21
+ "resolveJsonModule": true,
22
+ "typeRoots": [
23
+ "node_modules/@types"
24
+ ],
25
+ "paths": {
26
+ // TS5090 leading './'
27
+ "@/*": ["./src/*"]
28
+ }
29
+ },
30
+ "include": ["./src", "./types", "./config"],
31
+ "compileOnSave": false
32
+ }
@@ -0,0 +1,35 @@
1
+ /// <reference types="@tarojs/taro" />
2
+
3
+ declare module '*.png';
4
+ declare module '*.gif';
5
+ declare module '*.jpg';
6
+ declare module '*.jpeg';
7
+ declare module '*.svg';
8
+ declare module '*.css';
9
+ declare module '*.less';
10
+ declare module '*.scss';
11
+ declare module '*.sass';
12
+ declare module '*.styl';
13
+
14
+ declare namespace NodeJS {
15
+ interface ProcessEnv {
16
+ /** NODE 内置环境变量, 会影响到最终构建生成产物 */
17
+ NODE_ENV: 'development' | 'production',
18
+ /** 当前构建的平台 */
19
+ TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'qq' | 'jd' | 'harmony' | 'jdrn'
20
+ /**
21
+ * 当前构建的小程序 appid
22
+ * @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
23
+ * @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id
24
+ */
25
+ TARO_APP_ID: string
26
+ }
27
+ }
28
+
29
+ {{#if (includes "Vue3" s=framework)}}
30
+ declare module '@tarojs/components' {
31
+ export * from '@tarojs/components/types/index.vue3'
32
+ }{{else if (includes "Solid" s=framework)}}
33
+ declare module '@tarojs/components' {
34
+ export * from '@tarojs/components/types/index.solid'
35
+ }{{/if}}
@@ -0,0 +1,12 @@
1
+ export { }
2
+
3
+ declare module 'solid-js' {
4
+ namespace JSX {
5
+ interface Directives {
6
+ /** Note:如果需要定义自定义指令的类型,可以在这里做
7
+ * 参考官网文档https://docs.solidjs.com/reference/jsx-attributes/use
8
+ * model: [() => any, (v: any) => any]
9
+ */
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,10 @@
1
+ export {}
2
+
3
+ declare module 'vue' {
4
+ export interface GlobalComponents extends JSX.IntrinsicElements {
5
+ /** Note: Vue 在 runtime 中将 JSX.IntrinsicElements 通过 index signature 重复声明标签
6
+ * 这会导致插件无法正常跳转类型,可以手动覆盖声明标签活得更好的体验,参考如下:
7
+ * 'scroll-view': JSX.IntrinsicElements['scroll-view']
8
+ */
9
+ }
10
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "plugins": [],
3
+ "presets": []
4
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "taro-global-config",
3
+ "description": "taro-global-config",
4
+ "license": "ISC"
5
+ }