@dcloudio/uni-cli-shared 2.0.1-33320211224001 → 2.0.1-33420211228004

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/lib/cache.js CHANGED
@@ -82,11 +82,14 @@ function updateComponentJson (name, jsonObj, usingComponents = true, type = 'Com
82
82
 
83
83
  const oldJsonStr = getJsonFile(name)
84
84
  if (oldJsonStr) { // update
85
- if (usingComponents) { // merge usingComponents
85
+ if (usingComponents) { // merge usingComponents
86
86
  // 其实直接拿新的 merge 到旧的应该就行
87
87
  const oldJsonObj = JSON.parse(oldJsonStr)
88
- jsonObj.usingComponents = oldJsonObj.usingComponents || {}
88
+ jsonObj.usingComponents = oldJsonObj.usingComponents || {}
89
89
  jsonObj.usingAutoImportComponents = oldJsonObj.usingAutoImportComponents || {}
90
+ if (oldJsonObj.genericComponents) {
91
+ jsonObj.genericComponents = oldJsonObj.genericComponents
92
+ }
90
93
  if (oldJsonObj.usingGlobalComponents) { // 复制 global components(针对不支持全局 usingComponents 的平台)
91
94
  jsonObj.usingGlobalComponents = oldJsonObj.usingGlobalComponents
92
95
  }
@@ -351,4 +354,4 @@ module.exports = {
351
354
  updateGenericComponents,
352
355
  getChangedJsonFileMap,
353
356
  getSpecialMethods
354
- }
357
+ }
package/lib/package.js CHANGED
@@ -1,14 +1,11 @@
1
1
  const uniI18n = require('@dcloudio/uni-cli-i18n')
2
2
 
3
- const PLATFORMS = [
4
- 'h5',
5
- 'app-plus',
6
- 'mp-weixin',
7
- 'mp-qq',
8
- 'mp-baidu',
9
- 'mp-alipay',
10
- 'mp-toutiao'
11
- ]
3
+ function isPlainObject (a) {
4
+ if (a === null) {
5
+ return false
6
+ }
7
+ return typeof a === 'object'
8
+ }
12
9
 
13
10
  module.exports = {
14
11
  initCustomScript (name, pkgPath) {
@@ -27,13 +24,22 @@ module.exports = {
27
24
  }
28
25
 
29
26
  if (!scriptOptions.env || !scriptOptions.env.UNI_PLATFORM) {
30
- console.error(uniI18n.__('cliShared.requireConfigUniPlatform', { 0: `package.json->uni-app->scripts->${name}->env ` }))
27
+ console.error(uniI18n.__('cliShared.requireConfigUniPlatform', {
28
+ 0: `package.json->uni-app->scripts->${name}->env `
29
+ }))
31
30
  process.exit(0)
32
31
  }
33
32
 
34
- if (PLATFORMS.indexOf(scriptOptions.env.UNI_PLATFORM) === -1) {
35
- console.error(uniI18n.__('cliShared.supportPlatform', { 0: 'UNI_PLATFORM', 1: JSON.stringify(PLATFORMS) }))
36
- process.exit(0)
33
+ if (isPlainObject(scriptOptions.define)) {
34
+ Object.keys(uniAppOptions.scripts).forEach(scriptName => {
35
+ if (scriptName !== name) {
36
+ const define = uniAppOptions.scripts[scriptName].define
37
+ Object.keys(define).forEach(name => {
38
+ define[name] = false
39
+ })
40
+ Object.assign(scriptOptions.define, define)
41
+ }
42
+ })
37
43
  }
38
44
 
39
45
  process.env.UNI_PLATFORM = scriptOptions.env.UNI_PLATFORM
@@ -44,4 +50,4 @@ module.exports = {
44
50
 
45
51
  return scriptOptions
46
52
  }
47
- }
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.1-33320211224001",
3
+ "version": "2.0.1-33420211228004",
4
4
  "description": "uni-cli-shared",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -23,5 +23,5 @@
23
23
  "postcss-urlrewrite": "^0.2.2",
24
24
  "strip-json-comments": "^2.0.1"
25
25
  },
26
- "gitHead": "30f3c9d6642904e10fa2ea878ad02a348ecb137d"
26
+ "gitHead": "46925c288cdb3a955c9eb78de2972d94b2f8d249"
27
27
  }