@tarojs/cli 4.0.0-canary.9 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE +8 -8
  2. package/dist/cli.js +33 -24
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/customCommand.js.map +1 -1
  5. package/dist/create/creator.js +1 -1
  6. package/dist/create/creator.js.map +1 -1
  7. package/dist/create/fetchTemplate.d.ts +1 -0
  8. package/dist/create/fetchTemplate.js +33 -27
  9. package/dist/create/fetchTemplate.js.map +1 -1
  10. package/dist/create/page.d.ts +7 -0
  11. package/dist/create/page.js +15 -10
  12. package/dist/create/page.js.map +1 -1
  13. package/dist/create/plugin.js +1 -1
  14. package/dist/create/plugin.js.map +1 -1
  15. package/dist/create/project.js +33 -31
  16. package/dist/create/project.js.map +1 -1
  17. package/dist/presets/commands/build.js +53 -35
  18. package/dist/presets/commands/build.js.map +1 -1
  19. package/dist/presets/commands/config.js +1 -1
  20. package/dist/presets/commands/config.js.map +1 -1
  21. package/dist/presets/commands/create.js +6 -0
  22. package/dist/presets/commands/create.js.map +1 -1
  23. package/dist/presets/commands/global-config.js +9 -3
  24. package/dist/presets/commands/global-config.js.map +1 -1
  25. package/dist/presets/commands/help.js +2 -2
  26. package/dist/presets/commands/help.js.map +1 -1
  27. package/dist/presets/commands/info.js +3 -3
  28. package/dist/presets/commands/info.js.map +1 -1
  29. package/dist/presets/commands/init.js +2 -1
  30. package/dist/presets/commands/init.js.map +1 -1
  31. package/dist/presets/commands/inspect.js +6 -6
  32. package/dist/presets/commands/inspect.js.map +1 -1
  33. package/dist/presets/commands/update.js +3 -3
  34. package/dist/presets/commands/update.js.map +1 -1
  35. package/dist/presets/constant/hooks.d.ts +1 -0
  36. package/dist/presets/constant/hooks.js +2 -1
  37. package/dist/presets/constant/hooks.js.map +1 -1
  38. package/dist/presets/files/generateFrameworkInfo.js.map +1 -1
  39. package/dist/presets/files/generateProjectConfig.js +1 -1
  40. package/dist/presets/files/generateProjectConfig.js.map +1 -1
  41. package/dist/presets/files/writeFileToDist.js +1 -1
  42. package/dist/presets/files/writeFileToDist.js.map +1 -1
  43. package/dist/presets/hooks/build.js +1 -0
  44. package/dist/presets/hooks/build.js.map +1 -1
  45. package/dist/presets/index.js +1 -1
  46. package/dist/presets/index.js.map +1 -1
  47. package/dist/presets/platforms/plugin.js +14 -4
  48. package/dist/presets/platforms/plugin.js.map +1 -1
  49. package/dist/presets/platforms/rn.js +8 -9
  50. package/dist/presets/platforms/rn.js.map +1 -1
  51. package/dist/util/createPage.js +1 -1
  52. package/dist/util/createPage.js.map +1 -1
  53. package/dist/util/defineConfig.d.ts +1 -1
  54. package/dist/util/index.d.ts +1 -0
  55. package/dist/util/index.js +7 -3
  56. package/dist/util/index.js.map +1 -1
  57. package/package.json +27 -34
  58. package/src/__tests__/__mocks__/presets.ts +1 -1
  59. package/src/__tests__/build-config.spec.ts +2 -1
  60. package/src/__tests__/cli.spec.ts +12 -1
  61. package/src/__tests__/config.spec.ts +2 -1
  62. package/src/__tests__/doctor-config.spec.ts +2 -2
  63. package/src/__tests__/doctor-eslint.spec.ts +2 -28
  64. package/src/__tests__/doctor-recommand.spec.ts +2 -1
  65. package/src/__tests__/dotenv-parse.spec.ts +2 -2
  66. package/src/__tests__/fixtures/default/config/index.js +6 -0
  67. package/src/__tests__/info.spec.ts +2 -2
  68. package/src/__tests__/inspect.spec.ts +8 -3
  69. package/src/__tests__/update.spec.ts +3 -4
  70. package/src/__tests__/utils/index.ts +2 -1
  71. package/src/cli.ts +26 -17
  72. package/src/create/creator.ts +2 -1
  73. package/src/create/fetchTemplate.ts +39 -31
  74. package/src/create/page.ts +31 -16
  75. package/src/create/plugin.ts +2 -1
  76. package/src/create/project.ts +40 -40
  77. package/src/index.ts +2 -1
  78. package/src/presets/commands/build.ts +49 -33
  79. package/src/presets/commands/config.ts +1 -1
  80. package/src/presets/commands/create.ts +6 -0
  81. package/src/presets/commands/global-config.ts +17 -14
  82. package/src/presets/commands/info.ts +2 -1
  83. package/src/presets/commands/init.ts +2 -1
  84. package/src/presets/commands/inspect.ts +3 -2
  85. package/src/presets/commands/update.ts +3 -2
  86. package/src/presets/constant/hooks.ts +1 -0
  87. package/src/presets/files/generateProjectConfig.ts +1 -1
  88. package/src/presets/files/writeFileToDist.ts +1 -1
  89. package/src/presets/hooks/build.ts +1 -0
  90. package/src/presets/index.ts +1 -1
  91. package/src/presets/platforms/plugin.ts +13 -2
  92. package/src/presets/platforms/rn.ts +17 -6
  93. package/src/util/createPage.ts +1 -2
  94. package/src/util/defineConfig.ts +1 -1
  95. package/src/util/index.ts +6 -1
  96. package/templates/default/{_env.dev → _env.development} +1 -1
  97. package/templates/default/_env.production +1 -0
  98. package/templates/default/_env.test +1 -1
  99. package/templates/default/_eslintrc +1 -1
  100. package/templates/default/package.json.tmpl +63 -73
  101. package/templates/default/src/app.js +14 -12
  102. package/templates/default/src/pages/index/index.jsx +1 -2
  103. package/templates/default/src/pages/index/index.vue +0 -7
  104. package/templates/default/template_creator.js +22 -17
  105. package/templates/default/tsconfig.json +3 -2
  106. package/templates/default/types/global.d.ts +2 -2
  107. package/templates/plugin-compile/README.md +1 -1
  108. package/templates/plugin-compile/package.json.tmpl +3 -4
  109. package/templates/plugin-compile/src/index.ts +1 -1
  110. package/dist/config/babylon.d.ts +0 -3
  111. package/dist/config/babylon.js +0 -16
  112. package/dist/config/babylon.js.map +0 -1
  113. package/src/__tests__/fixtures/nerv/babel.config.js +0 -10
  114. package/src/__tests__/fixtures/nerv/config/dev.js +0 -9
  115. package/src/__tests__/fixtures/nerv/config/index.js +0 -70
  116. package/src/__tests__/fixtures/nerv/config/prod.js +0 -18
  117. package/src/__tests__/fixtures/nerv/package.json +0 -59
  118. package/src/__tests__/fixtures/nerv/src/app.config.ts +0 -11
  119. package/src/__tests__/fixtures/nerv/src/app.tsx +0 -10
  120. package/src/__tests__/fixtures/nerv/src/index.html +0 -19
  121. package/src/__tests__/fixtures/nerv/src/pages/index/index.config.ts +0 -3
  122. package/src/__tests__/fixtures/nerv/src/pages/index/index.tsx +0 -25
  123. package/src/__tests__/fixtures/vue/babel.config.js +0 -10
  124. package/src/__tests__/fixtures/vue/config/dev.js +0 -9
  125. package/src/__tests__/fixtures/vue/config/index.js +0 -70
  126. package/src/__tests__/fixtures/vue/config/prod.js +0 -18
  127. package/src/__tests__/fixtures/vue/package.json +0 -54
  128. package/src/__tests__/fixtures/vue/src/app.config.js +0 -11
  129. package/src/__tests__/fixtures/vue/src/app.js +0 -12
  130. package/src/__tests__/fixtures/vue/src/index.html +0 -19
  131. package/src/__tests__/fixtures/vue/src/pages/index/index.config.js +0 -3
  132. package/src/__tests__/fixtures/vue/src/pages/index/index.vue +0 -15
  133. package/src/config/babylon.ts +0 -16
  134. package/templates/default/__tests__/index.test.js.tmpl +0 -12
  135. package/templates/default/_env.prod +0 -1
  136. package/templates/default/jest.config.js +0 -6
  137. package/templates/default/project.tt.json +0 -9
@@ -1,19 +0,0 @@
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></title>
12
- <script>
13
- !function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
14
- </script>
15
- </head>
16
- <body>
17
- <div id="app"></div>
18
- </body>
19
- </html>
@@ -1,3 +0,0 @@
1
- export default {
2
- navigationBarTitleText: '首页'
3
- }
@@ -1,25 +0,0 @@
1
- import Nerv, { Component } from 'nervjs'
2
- import { View, Text } from '@tarojs/components'
3
-
4
- const a = 1
5
-
6
- export default class Index extends Component {
7
-
8
- componentWillMount () { }
9
-
10
- componentDidMount () { }
11
-
12
- componentWillUnmount () { }
13
-
14
- componentDidShow () { }
15
-
16
- componentDidHide () { }
17
-
18
- render () {
19
- return (
20
- <View className='index'>
21
- <Text>Hello world!</Text>
22
- </View>
23
- )
24
- }
25
- }
@@ -1,10 +0,0 @@
1
- // babel-preset-taro 更多选项和默认值:
2
- // https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3
- module.exports = {
4
- presets: [
5
- ['taro', {
6
- framework: 'vue',
7
- ts: false
8
- }]
9
- ]
10
- }
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- env: {
3
- NODE_ENV: '"development"'
4
- },
5
- defineConstants: {
6
- },
7
- mini: {},
8
- h5: {}
9
- }
@@ -1,70 +0,0 @@
1
- const config = {
2
- projectName: 't4',
3
- date: '2020-5-28',
4
- designWidth: 750,
5
- deviceRatio: {
6
- 640: 2.34 / 2,
7
- 750: 1,
8
- 828: 1.81 / 2
9
- },
10
- sourceRoot: 'src',
11
- outputRoot: 'dist',
12
- plugins: [],
13
- defineConstants: {
14
- },
15
- copy: {
16
- patterns: [
17
- ],
18
- options: {
19
- }
20
- },
21
- framework: 'vue',
22
- mini: {
23
- postcss: {
24
- pxtransform: {
25
- enable: true,
26
- config: {
27
-
28
- }
29
- },
30
- url: {
31
- enable: true,
32
- config: {
33
- limit: 1024 // 设定转换尺寸上限
34
- }
35
- },
36
- cssModules: {
37
- enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
38
- config: {
39
- namingPattern: 'module', // 转换模式,取值为 global/module
40
- generateScopedName: '[name]__[local]___[hash:base64:5]'
41
- }
42
- }
43
- }
44
- },
45
- h5: {
46
- publicPath: '/',
47
- staticDirectory: 'static',
48
- postcss: {
49
- autoprefixer: {
50
- enable: true,
51
- config: {
52
- }
53
- },
54
- cssModules: {
55
- enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
56
- config: {
57
- namingPattern: 'module', // 转换模式,取值为 global/module
58
- generateScopedName: '[name]__[local]___[hash:base64:5]'
59
- }
60
- }
61
- }
62
- }
63
- }
64
-
65
- module.exports = function (merge) {
66
- if (process.env.NODE_ENV === 'development') {
67
- return merge({}, config, require('./dev'))
68
- }
69
- return merge({}, config, require('./prod'))
70
- }
@@ -1,18 +0,0 @@
1
- module.exports = {
2
- env: {
3
- NODE_ENV: '"production"'
4
- },
5
- defineConstants: {
6
- },
7
- mini: {},
8
- h5: {
9
- /**
10
- * 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
11
- * 参考代码如下:
12
- * webpackChain (chain) {
13
- * chain.plugin('analyzer')
14
- * .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
15
- * }
16
- */
17
- }
18
- }
@@ -1,54 +0,0 @@
1
- {
2
- "name": "t4",
3
- "version": "1.0.0",
4
- "private": true,
5
- "description": "",
6
- "templateInfo": {
7
- "name": "default",
8
- "typescript": false,
9
- "css": "none"
10
- },
11
- "scripts": {
12
- "build:weapp": "taro build --type weapp",
13
- "build:swan": "taro build --type swan",
14
- "build:alipay": "taro build --type alipay",
15
- "build:tt": "taro build --type tt",
16
- "build:h5": "taro build --type h5",
17
- "build:rn": "taro build --type rn",
18
- "build:qq": "taro build --type qq",
19
- "build:quickapp": "taro build --type quickapp",
20
- "dev:weapp": "npm run build:weapp -- --watch",
21
- "dev:swan": "npm run build:swan -- --watch",
22
- "dev:alipay": "npm run build:alipay -- --watch",
23
- "dev:tt": "npm run build:tt -- --watch",
24
- "dev:h5": "npm run build:h5 -- --watch",
25
- "dev:rn": "npm run build:rn -- --watch",
26
- "dev:qq": "npm run build:qq -- --watch",
27
- "dev:quickapp": "npm run build:quickapp -- --watch"
28
- },
29
- "browserslist": [
30
- "last 3 versions",
31
- "Android >= 4.1",
32
- "ios >= 8"
33
- ],
34
- "author": "",
35
- "dependencies": {
36
- "@babel/runtime": "^7.7.7",
37
- "@tarojs/components": "3.0.0-rc.0",
38
- "@tarojs/runtime": "3.0.0-rc.0",
39
- "@tarojs/taro": "3.0.0-rc.0",
40
- "vue-template-compiler": "^2.5.0",
41
- "vue": "^2.5.0"
42
- },
43
- "devDependencies": {
44
- "@types/webpack-env": "^1.13.6",
45
- "@tarojs/mini-runner": "3.0.0-rc.0",
46
- "@babel/core": "^7.8.0",
47
- "@tarojs/webpack-runner": "3.0.0-rc.0",
48
- "babel-preset-taro": "3.0.0-rc.0",
49
- "eslint": "^8.12.0",
50
- "eslint-config-taro": "3.0.0-rc.0",
51
- "eslint-plugin-vue": "^9.x",
52
- "stylelint": "9.3.0"
53
- }
54
- }
@@ -1,11 +0,0 @@
1
- export default {
2
- pages: [
3
- 'pages/index/index'
4
- ],
5
- window: {
6
- backgroundTextStyle: 'light',
7
- navigationBarBackgroundColor: '#fff',
8
- navigationBarTitleText: 'WeChat',
9
- navigationBarTextStyle: 'black'
10
- }
11
- }
@@ -1,12 +0,0 @@
1
- import Vue from 'vue'
2
-
3
- const App = new Vue({
4
- onShow (options) {
5
- },
6
- render(h) {
7
- // this.$slots.default 是将要会渲染的页面
8
- return h('block', this.$slots.default)
9
- }
10
- })
11
-
12
- export default App
@@ -1,19 +0,0 @@
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></title>
12
- <script>
13
- !function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
14
- </script>
15
- </head>
16
- <body>
17
- <div id="app"></div>
18
- </body>
19
- </html>
@@ -1,3 +0,0 @@
1
- export default {
2
- navigationBarTitleText: '首页'
3
- }
@@ -1,15 +0,0 @@
1
- <template>
2
- <view class="index">
3
- <text>{{ msg }}</text>
4
- </view>
5
- </template>
6
-
7
- <script>
8
- export default {
9
- data() {
10
- return {
11
- msg: 'Hello world!'
12
- }
13
- }
14
- }
15
- </script>
@@ -1,16 +0,0 @@
1
- import type { ParserOptions } from '@babel/parser'
2
-
3
- const config: ParserOptions = {
4
- sourceType: 'module',
5
- plugins: [
6
- 'typescript',
7
- 'classProperties',
8
- 'jsx',
9
- 'asyncGenerators',
10
- 'objectRestSpread',
11
- 'decorators',
12
- 'dynamicImport'
13
- ]
14
- }
15
-
16
- export default config
@@ -1,12 +0,0 @@
1
- {{#if (includes "React" "Preact" s=framework)}}import TestUtils from '@tarojs/test-utils-react'{{/if}}{{#if (eq framework "Vue3") }}import TestUtils from '@tarojs/test-utils-vue3'{{/if}}{{#if (eq framework "Vue") }}import TestUtils from '@tarojs/test-utils-vue'{{/if}}
2
-
3
- describe('Testing', () => {
4
-
5
- test('Test', async () => {
6
- const testUtils = new TestUtils()
7
- await testUtils.createApp()
8
- await testUtils.PageLifecycle.onShow('pages/index/index')
9
- expect(testUtils.html()).toMatchSnapshot()
10
- })
11
-
12
- })
@@ -1 +0,0 @@
1
- # TARO_APP_ID="生产环境下的小程序appid"
@@ -1,6 +0,0 @@
1
- {{#if (includes "React" "Preact" s=framework)}}const defineJestConfig = require('@tarojs/test-utils-react/dist/jest.js').default{{/if}}{{#if (eq framework "Vue3") }}const defineJestConfig = require('@tarojs/test-utils-vue3/dist/jest.js').default{{/if}}{{#if (eq framework "Vue") }}const defineJestConfig = require('@tarojs/test-utils-vue/dist/jest.js').default{{/if}}
2
-
3
- module.exports = defineJestConfig({
4
- testEnvironment: 'jsdom',
5
- testMatch: ['<rootDir>/__tests__/?(*.)+(spec|test).[jt]s?(x)']
6
- })
@@ -1,9 +0,0 @@
1
- {
2
- "miniprogramRoot": "./",
3
- "projectname": "{{ projectName }}",
4
- "appid": "testAppId",
5
- "setting": {
6
- "es6": false,
7
- "minified": false
8
- }
9
- }