@dcloudio/vue-cli-plugin-uni 2.0.0-alpha-32920211101001 → 2.0.0-alpha-32920211110001

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/commands/build.js CHANGED
@@ -3,7 +3,9 @@ const path = require('path')
3
3
  const {
4
4
  runByHBuilderX,
5
5
  isInHBuilderX,
6
- parseJson
6
+ parseJson,
7
+ parsePagesJson,
8
+ parseManifestJson
7
9
  } = require('@dcloudio/uni-cli-shared')
8
10
 
9
11
  const uniI18n = require('@dcloudio/uni-cli-i18n')
@@ -32,7 +34,8 @@ module.exports = (api, options) => {
32
34
  '--auto-host': 'specify automator host',
33
35
  '--auto-port': 'specify automator port',
34
36
  '--subpackage': 'specify subpackage',
35
- '--plugin': 'specify plugin'
37
+ '--plugin': 'specify plugin',
38
+ '--manifest': 'build manifest.json'
36
39
  }
37
40
  }, async (args) => {
38
41
  for (const key in defaults) {
@@ -41,6 +44,10 @@ module.exports = (api, options) => {
41
44
  }
42
45
  }
43
46
 
47
+ if (args.manifest && process.env.UNI_PLATFORM === 'app-plus') {
48
+ return buildManifestJson()
49
+ }
50
+
44
51
  const platforms = ['mp-weixin', 'mp-qq', 'mp-baidu', 'mp-alipay', 'mp-toutiao', 'mp-lark']
45
52
  if (args.subpackage && platforms.includes(process.env.UNI_PLATFORM)) {
46
53
  process.env.UNI_SUBPACKGE = args.subpackage
@@ -135,7 +142,10 @@ async function build (args, api, options) {
135
142
  log()
136
143
 
137
144
  if (!runByHBuilderX && !runByAliIde) {
138
- logWithSpinner(uniI18n.__('pluginUni.startCompileProjectToPlatform', { 0: process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM, 1: process.env.UNI_MP_PLUGIN ? uniI18n.__('plugin') : uniI18n.__('platform') }))
145
+ logWithSpinner(uniI18n.__('pluginUni.startCompileProjectToPlatform', {
146
+ 0: process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM,
147
+ 1: process.env.UNI_MP_PLUGIN ? uniI18n.__('plugin') : uniI18n.__('platform')
148
+ }))
139
149
  }
140
150
 
141
151
  const targetDir = api.resolve(options.outputDir)
@@ -161,7 +171,8 @@ async function build (args, api, options) {
161
171
  process.env.UNI_USING_V3_NATIVE ||
162
172
  (process.UNI_NVUE_ENTRY && Object.keys(process.UNI_NVUE_ENTRY).length)
163
173
  ) {
164
- webpackConfigs.push(require('@dcloudio/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js')(process.UNI_NVUE_ENTRY))
174
+ webpackConfigs.push(require('@dcloudio/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js')(process
175
+ .UNI_NVUE_ENTRY))
165
176
  }
166
177
 
167
178
  return new Promise((resolve, reject) => {
@@ -178,7 +189,8 @@ async function build (args, api, options) {
178
189
  return reject('Build failed with errors.')
179
190
  }
180
191
 
181
- if (!args.silent && (process.env.UNI_PLATFORM !== 'app-plus' || process.env.UNI_AUTOMATOR_WS_ENDPOINT)) {
192
+ if (!args.silent && (process.env.UNI_PLATFORM !== 'app-plus' || process.env
193
+ .UNI_AUTOMATOR_WS_ENDPOINT)) {
182
194
  const targetDirShort = path.relative(
183
195
  api.service.context,
184
196
  process.env.UNI_OUTPUT_DIR
@@ -195,7 +207,8 @@ async function build (args, api, options) {
195
207
  console.log('https://uniapp.dcloud.io/uniCloud/hosting')
196
208
  }
197
209
  } else {
198
- const dirMsg = runByHBuilderX ? '' : `The ${chalk.cyan(targetDirShort)} directory is ready. `
210
+ const dirMsg = runByHBuilderX ? ''
211
+ : `The ${chalk.cyan(targetDirShort)} directory is ready. `
199
212
  done(`Build complete. ${dirMsg}Watching for changes...`)
200
213
  }
201
214
  }
@@ -221,7 +234,9 @@ function analysisPluginDir () {
221
234
 
222
235
  if (!fs.pathExistsSync(pluginJsonPath)) {
223
236
  console.log()
224
- console.error(uniI18n.__('pluginUni.fileNoExistsCheckAfterRetry', { 0: pluginJsonName }))
237
+ console.error(uniI18n.__('pluginUni.fileNoExistsCheckAfterRetry', {
238
+ 0: pluginJsonName
239
+ }))
225
240
  console.log()
226
241
  process.exit(0)
227
242
  }
@@ -235,8 +250,35 @@ function analysisPluginDir () {
235
250
 
236
251
  if (UNI_MP_PLUGIN_MAIN && !fs.pathExistsSync(mainFilePath)) {
237
252
  console.log()
238
- console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', { 0: UNI_MP_PLUGIN_MAIN }))
253
+ console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', {
254
+ 0: UNI_MP_PLUGIN_MAIN
255
+ }))
239
256
  console.log()
240
257
  process.exit(0)
241
258
  }
242
259
  }
260
+
261
+ function buildManifestJson () {
262
+ const fs = require('fs-extra')
263
+ const inputDir = process.env.UNI_INPUT_DIR
264
+ const outputDir = process.env.UNI_OUTPUT_DIR
265
+ const pagesJsonPath = path.resolve(inputDir, 'pages.json')
266
+ const manifestJsonPath = path.resolve(inputDir, 'manifest.json')
267
+
268
+ const pagesJson = parsePagesJson(fs.readFileSync(pagesJsonPath, 'utf8'))
269
+ const manifestJson = parseManifestJson(fs.readFileSync(manifestJsonPath, 'utf8'))
270
+
271
+ const res = require('@dcloudio/webpack-uni-pages-loader/lib/platforms/app-plus/index.js')(pagesJson,
272
+ manifestJson,
273
+ false)
274
+ if (res && res[0]) {
275
+ fs.outputFileSync(
276
+ path.resolve(outputDir, 'manifest.json'),
277
+ res[0].content
278
+ )
279
+ }
280
+ const {
281
+ done
282
+ } = require('@vue/cli-shared-utils')
283
+ done('Build complete.')
284
+ }
@@ -13,6 +13,9 @@ class Upate {
13
13
  this._isAlpha = false
14
14
  this._uniId = ''
15
15
  this._appId = ''
16
+ this._wt = 0
17
+ this._lc = ''
18
+ this._lcin = []
16
19
  }
17
20
 
18
21
  get uniId () {
@@ -47,6 +50,30 @@ class Upate {
47
50
  this._isAlpha = value
48
51
  }
49
52
 
53
+ get wt () {
54
+ return this._wt
55
+ }
56
+
57
+ set wt (value) {
58
+ this._wt = value
59
+ }
60
+
61
+ get lc () {
62
+ return this._lc
63
+ }
64
+
65
+ set lc (value) {
66
+ this._lc = value
67
+ }
68
+
69
+ get lcin () {
70
+ return this._lcin
71
+ }
72
+
73
+ set lcin (value) {
74
+ this._lcin = value
75
+ }
76
+
50
77
  get versionType () {
51
78
  return (this.isAlpha ? 'a' : 'r')
52
79
  }
@@ -156,6 +183,9 @@ class Upate {
156
183
  data.appid = this.uniId
157
184
  data.vtype = this.versionType
158
185
  data.vcode = this.compilerVersion
186
+ data.wt = this._wt
187
+ data.lc = this._lc
188
+ data.in = this._lcin
159
189
 
160
190
  delete data.lastCheck
161
191
 
@@ -234,6 +264,28 @@ Object.assign(Upate.prototype, {
234
264
  DEFAULT_INTERVAL: 1000 * 60 * 60 * 24
235
265
  })
236
266
 
267
+ function getLc () {
268
+ const result = []
269
+ const localeDir = path.join(process.env.UNI_CLI_CONTEXT, 'src/locale')
270
+ if (!fs.existsSync(localeDir)) {
271
+ return result
272
+ }
273
+
274
+ const files = fs.readdirSync(localeDir)
275
+ for (let i = files.length - 1; i >= 0; i--) {
276
+ const filePath = files[i]
277
+ const extName = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase()
278
+ if (extName !== 'json') {
279
+ continue
280
+ }
281
+
282
+ if (files[i].indexOf('uni-app.') < 0) {
283
+ result.push(filePath.substring(0, filePath.lastIndexOf('.')))
284
+ }
285
+ }
286
+ return result
287
+ }
288
+
237
289
  module.exports = async function checkUpdate () {
238
290
  const {
239
291
  isInHBuilderX,
@@ -255,6 +307,10 @@ module.exports = async function checkUpdate () {
255
307
  update.uniId = manifest.appid
256
308
  const appIdKey = process.env.UNI_PLATFORM.includes('quickapp') ? 'package' : 'appid'
257
309
  update.appId = manifest[process.env.UNI_PLATFORM] ? (manifest[process.env.UNI_PLATFORM][appIdKey] || '') : ''
310
+ const cf = manifest['mp-weixin'] ? manifest['mp-weixin'].cloudfunctionRoot : ''
311
+ update.wt = (cf && cf.length) ? 1 : 0
312
+ update.lc = manifest.locale ? manifest.locale : ''
313
+ update.lcin = getLc().join(',')
258
314
  update.check()
259
315
  } catch (e) {
260
316
  }
@@ -15,7 +15,7 @@ function resolve (dir) {
15
15
  }
16
16
 
17
17
  function resolveModule (dir) {
18
- return path.resolve(__dirname, '../../..', dir)
18
+ return path.resolve(process.env.UNI_CLI_CONTEXT, './node_modules', dir)
19
19
  }
20
20
 
21
21
  module.exports = function configureWebpack (platformOptions, manifestPlatformOptions, vueOptions, api) {
@@ -184,8 +184,9 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
184
184
  platformWebpackConfig = platformWebpackConfig(webpackConfig, vueOptions, api)
185
185
  }
186
186
  // 移除 node_modules 目录,避免受路径上的 node_modules 影响
187
- webpackConfig.resolve.modules = webpackConfig.resolve.modules.filter(module => module !==
188
- 'node_modules')
187
+ if (require('@dcloudio/uni-cli-shared/lib/util').isInHBuilderX) {
188
+ webpackConfig.resolve.modules = webpackConfig.resolve.modules.filter(module => module !== 'node_modules')
189
+ }
189
190
 
190
191
  const plugins = []
191
192
 
@@ -298,6 +299,17 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
298
299
  }
299
300
  } catch (e) {}
300
301
 
302
+ const resolveLoaderAlias = {}
303
+ const modules = ['@vue/cli-plugin-babel', '@vue/cli-service']
304
+ modules.forEach(m => {
305
+ const { dependencies } = require(`${m}/package.json`)
306
+ Object.keys(dependencies).forEach(key => {
307
+ if (/-loader$/.test(key)) {
308
+ resolveLoaderAlias[key] = require.resolve(key)
309
+ }
310
+ })
311
+ })
312
+
301
313
  return merge({
302
314
  devtool: false,
303
315
  resolve: {
@@ -325,6 +337,9 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
325
337
  noParse: /^(vue|vue-router|vuex|vuex-router-sync)$/,
326
338
  rules
327
339
  },
340
+ resolveLoader: {
341
+ alias: resolveLoaderAlias
342
+ },
328
343
  plugins,
329
344
  performance: {
330
345
  assetFilter (assetFilename) {
@@ -334,4 +349,4 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
334
349
  watchOptions: require('./util').getWatchOptions()
335
350
  }, platformWebpackConfig)
336
351
  }
337
- }
352
+ }
package/lib/env.js CHANGED
@@ -107,11 +107,13 @@ if (process.env.UNI_CLOUD_SPACES) {
107
107
  }
108
108
 
109
109
  // 初始化环境变量
110
- const defaultOutputDir = '../../../../dist/' +
110
+ process.env.UNI_CLI_CONTEXT = require('@dcloudio/uni-cli-shared/lib/util').getCLIContext()
111
+
112
+ const defaultOutputDir = './dist/' +
111
113
  (process.env.NODE_ENV === 'production' ? 'build' : 'dev') + '/' +
112
114
  (process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM)
113
115
 
114
- process.env.UNI_OUTPUT_DEFAULT_DIR = path.resolve(__dirname, defaultOutputDir)
116
+ process.env.UNI_OUTPUT_DEFAULT_DIR = path.resolve(process.env.UNI_CLI_CONTEXT, defaultOutputDir)
115
117
  if (process.env.UNI_OUTPUT_DIR && process.env.UNI_OUTPUT_DIR.indexOf('./') === 0) {
116
118
  process.env.UNI_OUTPUT_DIR = path.resolve(process.cwd(), process.env.UNI_OUTPUT_DIR)
117
119
  }
@@ -124,8 +126,6 @@ if (process.env.UNI_PLATFORM === 'app-plus') {
124
126
  process.env.UNI_OUTPUT_TMP_DIR = path.resolve(process.env.UNI_OUTPUT_DIR, '../.tmp/app-plus')
125
127
  }
126
128
 
127
- process.env.UNI_CLI_CONTEXT = path.resolve(__dirname, '../../../../')
128
-
129
129
  process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
130
130
 
131
131
  if (process.env.NODE_ENV === 'production') { // 发行模式,不启用 cache
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/vue-cli-plugin-uni",
3
- "version": "2.0.0-alpha-32920211101001",
3
+ "version": "2.0.0-alpha-32920211110001",
4
4
  "description": "uni-app plugin for vue-cli 3",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -17,7 +17,7 @@
17
17
  "author": "fxy060608",
18
18
  "license": "Apache-2.0",
19
19
  "dependencies": {
20
- "@dcloudio/uni-stat": "^2.0.0-alpha-32920211101001",
20
+ "@dcloudio/uni-stat": "^2.0.0-alpha-32920211110001",
21
21
  "buffer-json": "^2.0.0",
22
22
  "copy-webpack-plugin": "^5.1.1",
23
23
  "cross-env": "^5.2.0",
@@ -37,5 +37,5 @@
37
37
  "wrap-loader": "^0.2.0",
38
38
  "xregexp": "4.0.0"
39
39
  },
40
- "gitHead": "b41670524d25864c988d3581fb76213360c68377"
40
+ "gitHead": "15d9991409fe19a87c764c3132c1395dc3b891a2"
41
41
  }