mali-applet-ui 1.1.54 → 1.1.56
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 +6 -0
- package/env/index.js +84 -0
- package/env/script/run-before.txt +7 -0
- package/env/script/run-build.txt +9 -0
- package/env/script/run-init.txt +4 -0
- package/env/script/run-upload.txt +25 -0
- package/package.json +1 -1
package/env/index.d.ts
CHANGED
|
@@ -7,6 +7,12 @@ export function parseEnv(dirPath: string): Record<string, string>
|
|
|
7
7
|
export function initEnv(dirPath: string, defaultEnv: Record<string, string>): Record<string, string>
|
|
8
8
|
export function initManifestConfig(dirPath: string, manifestJson: any): void
|
|
9
9
|
export function initManifestEnv(dirPath: string, manifestJson: any): Record<string, string>
|
|
10
|
+
export function initEnvScript(dirPath: string, confs: {
|
|
11
|
+
customName: string
|
|
12
|
+
subName: string
|
|
13
|
+
platform: '' | 'mp-weixin' | 'mp-qiwei' | 'mp-dingtalk' | 'h5-dingtalk' | 'h5-qiwei' | 'dingtalk'
|
|
14
|
+
modes: ('dev' | 'test' | 'demo' | 'pre' | 'prod')[]
|
|
15
|
+
}[]): any
|
|
10
16
|
export function uploadWxMiniprogram(version: string): void
|
|
11
17
|
export function getSCSSAdditionalData(envConfig?: an): string
|
|
12
18
|
|
package/env/index.js
CHANGED
|
@@ -99,6 +99,80 @@ function getSCSSAdditionalData (conf) {
|
|
|
99
99
|
return rest.join('\n')
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
function getUniPlatform (platform) {
|
|
103
|
+
if (['h5-dingtalk', 'h5-qiwei'].includes(platform)) {
|
|
104
|
+
return 'h5'
|
|
105
|
+
}
|
|
106
|
+
return 'mp-weixin'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function getPlatformRunName (platform) {
|
|
110
|
+
return platform.replace('-', '')
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function initEnvScript (rootPath, confs) {
|
|
114
|
+
const pack = JSON.parse(fs.readFileSync(path.resolve(rootPath, 'package.json')))
|
|
115
|
+
const scripts = {
|
|
116
|
+
update: 'npm install --legacy-peer-deps',
|
|
117
|
+
'eslint-fix': 'eslint --fix --ext .vue,.js src',
|
|
118
|
+
uni_h5dingtalk_serve: 'npm run run_before && vue-cli-service uni-serve',
|
|
119
|
+
uni_h5qiwei_serve: 'npm run run_before && vue-cli-service uni-serve',
|
|
120
|
+
uni_mpweixin_build: 'npm run run_before && vue-cli-service uni-build',
|
|
121
|
+
uni_h5dingtalk_build: 'npm run run_before && vue-cli-service uni-build && gulp build_h5_zip',
|
|
122
|
+
uni_h5qiwei_build: 'npm run run_before && vue-cli-service uni-build && gulp build_h5_zip',
|
|
123
|
+
uni_mpweixin_serve: 'npm run run_before && vue-cli-service uni-build --watch',
|
|
124
|
+
uni_mpweixin_upload: 'npm run run_before && node script/run-build && vue-cli-service uni-build && node script/run-deploy',
|
|
125
|
+
uni_mpdingtalk_build: 'npm run run_before && uniapp-cli custom mp-dingtalk',
|
|
126
|
+
run_before: 'node script/run-before',
|
|
127
|
+
clear: 'gulp clear_temp'
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
console.log('\n正在检查配置')
|
|
131
|
+
confs.forEach(({ customName, subName, platform, modes }) => {
|
|
132
|
+
const names = [customName, subName, platform].filter(v => v)
|
|
133
|
+
const envs = [
|
|
134
|
+
customName ? `VUE_APP_CUSTOM_MODULE=${customName}` : '',
|
|
135
|
+
subName ? `VUE_APP_SUB_MODULE=${subName}` : '',
|
|
136
|
+
platform ? `VUE_APP_PLATFORM_NAME=${platform}` : ''
|
|
137
|
+
].filter(v => v)
|
|
138
|
+
scripts[`serve${names.length ? `:${names.join(':')}` : ''}`] = `cross-env ${envs.join(' ')} NODE_ENV=development UNI_PLATFORM=${getUniPlatform(platform)} UNI_OUTPUT_DIR=dist/dev/${[customName || 'default', subName || 'default', platform || 'default', 'dev'].join('_')} VUE_APP_MODE=dev npm run uni_${getPlatformRunName(platform)}_serve`
|
|
139
|
+
modes.forEach(mode => {
|
|
140
|
+
scripts[`build:${names.concat([mode]).join(':')}`] = `cross-env ${envs.join(' ')} NODE_ENV=production UNI_PLATFORM=${getUniPlatform(platform)} UNI_OUTPUT_DIR=dist/build/${[customName || 'default', subName || 'default', platform || 'default', mode].join('_')} VUE_APP_MODE=${mode} npm run uni_${getPlatformRunName(platform)}_build`
|
|
141
|
+
scripts[`deploy:${names.concat([mode]).join(':')}`] = `cross-env ${envs.join(' ')} NODE_ENV=production UNI_PLATFORM=${getUniPlatform(platform)} UNI_OUTPUT_DIR=dist/build/${[customName || 'default', subName || 'default', platform || 'default', mode].join('_')} VUE_APP_MODE=${mode} npm run uni_${getPlatformRunName(platform)}_upload`
|
|
142
|
+
|
|
143
|
+
// 生成配置文件
|
|
144
|
+
const envName = `.env.${customName || 'default'}.${subName || 'default'}.${platform || 'default'}.${getEnvCode(mode)}`
|
|
145
|
+
if (!fs.existsSync(path.resolve(rootPath, envName))) {
|
|
146
|
+
console.log(`${pack.name} 生成配置文件 ${envName}`)
|
|
147
|
+
fs.writeFileSync(path.resolve(rootPath, envName), `# ${[customName || '', getEnvName(mode)].map(v => v).join('-')}\n`)
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
console.log('生成运行脚本完成')
|
|
152
|
+
|
|
153
|
+
pack.scripts = scripts
|
|
154
|
+
fs.writeFileSync(path.resolve(rootPath, 'package.json'), `${JSON.stringify(pack, null, 2)}\n`)
|
|
155
|
+
|
|
156
|
+
// 生成脚本文件
|
|
157
|
+
if (!fs.existsSync(path.resolve(rootPath, 'script/run-before.js'))) {
|
|
158
|
+
console.log(`${pack.name} 生成脚本文件 script/run-before.js`)
|
|
159
|
+
fs.writeFileSync(path.resolve(rootPath, 'script/run-before.js'), fs.readFileSync(path.resolve(__dirname, 'script/run-before.txt'), { encoding: 'utf8' }))
|
|
160
|
+
}
|
|
161
|
+
if (!fs.existsSync(path.resolve(rootPath, 'script/run-build.js'))) {
|
|
162
|
+
console.log(`${pack.name} 生成脚本文件 script/run-build.js`)
|
|
163
|
+
fs.writeFileSync(path.resolve(rootPath, 'script/run-build.js'), fs.readFileSync(path.resolve(__dirname, 'script/run-build.txt'), { encoding: 'utf8' }))
|
|
164
|
+
}
|
|
165
|
+
if (!fs.existsSync(path.resolve(rootPath, 'script/run-upload.js'))) {
|
|
166
|
+
console.log(`${pack.name} 生成脚本文件 script/run-upload.js`)
|
|
167
|
+
fs.writeFileSync(path.resolve(rootPath, 'script/run-upload.js'), fs.readFileSync(path.resolve(__dirname, 'script/run-upload.txt'), { encoding: 'utf8' }))
|
|
168
|
+
}
|
|
169
|
+
if (!fs.existsSync(path.resolve(rootPath, 'script/run-init.js'))) {
|
|
170
|
+
console.log(`${pack.name} 生成脚本文件 script/run-init.js`)
|
|
171
|
+
fs.writeFileSync(path.resolve(rootPath, 'script/run-init.js'), fs.readFileSync(path.resolve(__dirname, 'script/run-init.txt'), { encoding: 'utf8' }))
|
|
172
|
+
}
|
|
173
|
+
console.log('初始化完成\n')
|
|
174
|
+
}
|
|
175
|
+
|
|
102
176
|
function parseEnv (rootPath) {
|
|
103
177
|
const envConfig = {}
|
|
104
178
|
envConfig.VUE_APP_MODE = process.env.VUE_APP_MODE || 'prod'
|
|
@@ -118,6 +192,14 @@ function parseEnv (rootPath) {
|
|
|
118
192
|
const envEnv = parseEnvFile(rootPath, envName)
|
|
119
193
|
const localEnv = parseEnvFile(rootPath, `${envName}.local`)
|
|
120
194
|
|
|
195
|
+
console.log('\n读取配置文件:')
|
|
196
|
+
const endFiles = ['.env', cName, csName, cspName, envName, `${envName}.local`]
|
|
197
|
+
endFiles.forEach(fileName => {
|
|
198
|
+
if (fs.existsSync(path.resolve(rootPath, fileName))) {
|
|
199
|
+
console.log(`${fileName}`)
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
|
|
121
203
|
return Object.assign({}, globalDev, cEnv, csEnv, cspEnv, envEnv, localEnv, envConfig)
|
|
122
204
|
}
|
|
123
205
|
|
|
@@ -344,6 +426,7 @@ exports.parseEnv = parseEnv
|
|
|
344
426
|
exports.initEnv = initEnv
|
|
345
427
|
exports.initManifestConfig = initManifestConfig
|
|
346
428
|
exports.initManifestEnv = initManifestEnv
|
|
429
|
+
exports.initEnvScript = initEnvScript
|
|
347
430
|
exports.uploadWxMiniprogram = uploadWxMiniprogram
|
|
348
431
|
exports.getSCSSAdditionalData = getSCSSAdditionalData
|
|
349
432
|
exports.sendMail = sendMail
|
|
@@ -361,6 +444,7 @@ module.exports = {
|
|
|
361
444
|
initEnv,
|
|
362
445
|
initManifestConfig,
|
|
363
446
|
initManifestEnv,
|
|
447
|
+
initEnvScript,
|
|
364
448
|
uploadWxMiniprogram,
|
|
365
449
|
getSCSSAdditionalData,
|
|
366
450
|
sendMail,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const { initManifestConfig } = require('mali-applet-ui/env')
|
|
4
|
+
|
|
5
|
+
initManifestConfig(path.resolve(__dirname, '../'), require('../conf/manifest.js'))
|
|
6
|
+
|
|
7
|
+
fs.writeFileSync(path.resolve(__dirname, '../src/pages.json'), JSON.stringify(require('../pages'), null, 2))
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// const path = require('path')
|
|
2
|
+
// const pack = require('../package.json')
|
|
3
|
+
// const { initEnv, sendQyWechatMsg, getBuildMsg } = require('mali-applet-ui/env')
|
|
4
|
+
|
|
5
|
+
// initEnv(path.resolve(__dirname, '../'))
|
|
6
|
+
|
|
7
|
+
// sendQyWechatMsg(process.env.VUE_APP_QY_WECHAT_WEBHOOK, {
|
|
8
|
+
// content: getBuildMsg(pack.description)
|
|
9
|
+
// })
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const md5 = require('md5')
|
|
4
|
+
const pack = require('../package.json')
|
|
5
|
+
const { initEnv, uploadWxMiniprogram, sendQyWechatMsg, getBuildSuccessMsg } = require('mali-applet-ui/env')
|
|
6
|
+
|
|
7
|
+
initEnv(path.resolve(__dirname, '../'))
|
|
8
|
+
|
|
9
|
+
// 上传包
|
|
10
|
+
uploadWxMiniprogram(path.resolve(__dirname, '../'), pack.version).then(() => {
|
|
11
|
+
if (process.env.VUE_APP_QY_WECHAT_WEBHOOK) {
|
|
12
|
+
sendQyWechatMsg(process.env.VUE_APP_QY_WECHAT_WEBHOOK, {
|
|
13
|
+
content: getBuildSuccessMsg(pack.description)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const qrImg = path.resolve(__dirname, `../conf/trialQr/${process.env.VUE_APP_MP_APPID}.png`)
|
|
17
|
+
if (fs.existsSync(qrImg)) {
|
|
18
|
+
sendQyWechatMsg(process.env.VUE_APP_QY_WECHAT_WEBHOOK, {
|
|
19
|
+
msgType: 'image',
|
|
20
|
+
base64: fs.readFileSync(qrImg).toString('base64'),
|
|
21
|
+
md5: md5(fs.readFileSync(qrImg))
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
})
|