mali-applet-ui 1.1.68 → 1.1.69
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/env/index.d.ts +1 -0
- package/env/index.js +69 -16
- package/package.json +1 -1
package/env/index.d.ts
CHANGED
package/env/index.js
CHANGED
|
@@ -11,6 +11,8 @@ const pack = require('../package.json')
|
|
|
11
11
|
|
|
12
12
|
const apiURL = 'http://192.168.10.217:3000'
|
|
13
13
|
|
|
14
|
+
const envDir = 'env'
|
|
15
|
+
|
|
14
16
|
function hasEmptyConf (key) {
|
|
15
17
|
return !key || key === 'default'
|
|
16
18
|
}
|
|
@@ -141,7 +143,8 @@ function initEnvScript (rootPath, confs) {
|
|
|
141
143
|
uni_mpqiwei_build: 'npm run run_before && vue-cli-service uni-build',
|
|
142
144
|
run_before: 'node script/run-before',
|
|
143
145
|
clear: 'gulp clear_temp',
|
|
144
|
-
'generate:api': 'npx ts-codegen && eslint --fix --ext .js,.ts src/api'
|
|
146
|
+
'generate:api': 'npx ts-codegen && eslint --fix --ext .js,.ts src/api',
|
|
147
|
+
'get:api': 'npm run generate:api'
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
console.log('\n正在检查配置')
|
|
@@ -159,9 +162,9 @@ function initEnvScript (rootPath, confs) {
|
|
|
159
162
|
|
|
160
163
|
// 生成配置文件
|
|
161
164
|
const envName = `.env.${customName || 'default'}.${subName || 'default'}.${platform || 'default'}.${getEnvCode(mode)}`
|
|
162
|
-
if (!fs.existsSync(path.resolve(rootPath, envName))) {
|
|
165
|
+
if (!fs.existsSync(path.resolve(rootPath, `${envDir}/${envName}`))) {
|
|
163
166
|
console.log(`${pack.name} 生成配置文件 ${envName}`)
|
|
164
|
-
fs.writeFileSync(path.resolve(rootPath, envName), `# ${[customName ? getCustomName(customName) : '', subName ? getSubModuleName(subName) : '', getEnvName(mode)].filter(v => v).map(v => v).join('-')}\n`)
|
|
167
|
+
fs.writeFileSync(path.resolve(rootPath, `${envDir}/${envName}`), `# ${[customName ? getCustomName(customName) : '', subName ? getSubModuleName(subName) : '', getEnvName(mode)].filter(v => v).map(v => v).join('-')}\n`)
|
|
165
168
|
}
|
|
166
169
|
})
|
|
167
170
|
})
|
|
@@ -191,33 +194,81 @@ function initEnvScript (rootPath, confs) {
|
|
|
191
194
|
}
|
|
192
195
|
|
|
193
196
|
function parseEnv (rootPath) {
|
|
194
|
-
|
|
197
|
+
let envConfig = {}
|
|
198
|
+
|
|
195
199
|
envConfig.VUE_APP_MODE = process.env.VUE_APP_MODE || 'prod'
|
|
196
200
|
envConfig.VUE_APP_CUSTOM_MODULE = process.env.VUE_APP_CUSTOM_MODULE || 'default'
|
|
197
201
|
envConfig.VUE_APP_SUB_MODULE = process.env.VUE_APP_SUB_MODULE || 'default'
|
|
198
202
|
envConfig.VUE_APP_PLATFORM_NAME = process.env.VUE_APP_PLATFORM_NAME || 'default'
|
|
199
203
|
envConfig.VUE_APP_PUBLISH_DATE = XEUtils.toDateString(new Date(), 'yyyyMMddHHmmss')
|
|
200
204
|
|
|
201
|
-
const
|
|
205
|
+
const gName = '.env'
|
|
206
|
+
const cName = `${gName}.${envConfig.VUE_APP_CUSTOM_MODULE}`
|
|
202
207
|
const csName = `${cName}.${envConfig.VUE_APP_SUB_MODULE}`
|
|
203
208
|
const cspName = `${csName}.${envConfig.VUE_APP_PLATFORM_NAME}`
|
|
204
209
|
const envName = `${cspName}.${getEnvCode(envConfig.VUE_APP_MODE)}`
|
|
205
|
-
const
|
|
206
|
-
const cEnv = parseEnvFile(rootPath, cName)
|
|
207
|
-
const csEnv = parseEnvFile(rootPath, csName)
|
|
208
|
-
const cspEnv = parseEnvFile(rootPath, cspName)
|
|
209
|
-
const envEnv = parseEnvFile(rootPath, envName)
|
|
210
|
-
const localEnv = parseEnvFile(rootPath, `${envName}.local`)
|
|
210
|
+
const endFiles = [gName, cName, csName, cspName, envName, `${envName}.local`].map(fileName => `${envDir}/${fileName}`).concat([`${envName}.local`])
|
|
211
211
|
|
|
212
212
|
console.log('\n读取配置文件:')
|
|
213
|
-
|
|
213
|
+
if (fs.existsSync(path.resolve(rootPath, envDir))) {
|
|
214
|
+
endFiles.forEach(fileName => {
|
|
215
|
+
if (fs.existsSync(path.resolve(rootPath, fileName))) {
|
|
216
|
+
envConfig = Object.assign(envConfig, parseEnvFile(rootPath, fileName))
|
|
217
|
+
console.log(`${fileName}`)
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
} else {
|
|
221
|
+
console.log(`检测不到 Env 配置文件,路径:${envDir}/*`)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return envConfig
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function parseSwaggerEnv (rootPath) {
|
|
228
|
+
let swaggerConfig = {
|
|
229
|
+
VUE_APP_SWAGGER_API_SPECS_PATHS: []
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const gName = '.env'
|
|
233
|
+
const aName = `${gName}.api`
|
|
234
|
+
const endFiles = [aName, `${aName}.local`].map(fileName => `${envDir}/${fileName}`).concat([`${aName}.local`])
|
|
235
|
+
|
|
214
236
|
endFiles.forEach(fileName => {
|
|
215
|
-
|
|
216
|
-
console.log(`${fileName}`)
|
|
217
|
-
}
|
|
237
|
+
swaggerConfig = Object.assign(swaggerConfig, parseEnvFile(rootPath, fileName))
|
|
218
238
|
})
|
|
219
239
|
|
|
220
|
-
|
|
240
|
+
if (swaggerConfig.VUE_APP_SWAGGER_API_URL) {
|
|
241
|
+
swaggerConfig.VUE_APP_SWAGGER_API_SPECS_PATHS = (swaggerConfig.VUE_APP_SWAGGER_MODULES || 'default').split(',').map(name => {
|
|
242
|
+
return {
|
|
243
|
+
path: XEUtils.toFormatString(swaggerConfig.VUE_APP_SWAGGER_API_URL, { name }),
|
|
244
|
+
name
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return swaggerConfig
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function defineSwaggerConfig (defaultConfig = {}, defaultRootPath) {
|
|
253
|
+
const rootPath = defaultConfig.rootPath || defaultRootPath
|
|
254
|
+
|
|
255
|
+
if (!fs.existsSync(path.resolve(rootPath, `${envDir}/.env.api`))) {
|
|
256
|
+
console.log(`检测不到 Swagger 配置文件,路径:${envDir}/.env.api`)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const swaggerConfig = parseSwaggerEnv(rootPath)
|
|
260
|
+
return {
|
|
261
|
+
outputFolder: 'src/api',
|
|
262
|
+
apiSpecsPaths: swaggerConfig.VUE_APP_SWAGGER_API_SPECS_PATHS,
|
|
263
|
+
options: {
|
|
264
|
+
withComments: true,
|
|
265
|
+
typeWithPrefix: false,
|
|
266
|
+
backwardCompatible: false
|
|
267
|
+
},
|
|
268
|
+
importTopCode: '',
|
|
269
|
+
importHeaderCode: '/* eslint-disable no-use-before-define,camelcase */',
|
|
270
|
+
...(defaultConfig || {})
|
|
271
|
+
}
|
|
221
272
|
}
|
|
222
273
|
|
|
223
274
|
function initEnv (rootPath) {
|
|
@@ -452,6 +503,7 @@ ${process.env.BUILD_USER ? `>> 操作人:${process.env.BUILD_USER}` : ''}
|
|
|
452
503
|
<font color="comment">-自动化发版</font>`
|
|
453
504
|
}
|
|
454
505
|
|
|
506
|
+
exports.defineSwaggerConfig = defineSwaggerConfig
|
|
455
507
|
exports.getEnvCode = getEnvCode
|
|
456
508
|
exports.getEnvName = getEnvName
|
|
457
509
|
exports.getCustomName = getCustomName
|
|
@@ -470,6 +522,7 @@ exports.getBuildMsg = getBuildMsg
|
|
|
470
522
|
exports.getBuildSuccessMsg = getBuildSuccessMsg
|
|
471
523
|
|
|
472
524
|
module.exports = {
|
|
525
|
+
defineSwaggerConfig,
|
|
473
526
|
getEnvCode,
|
|
474
527
|
getEnvName,
|
|
475
528
|
getCustomName,
|