43 lines
857 B
JavaScript
43 lines
857 B
JavaScript
const path = require('path')
|
|
const ci = require('miniprogram-ci')
|
|
const projectConfig = require('../../project.config.json')
|
|
|
|
function requireEnv(name) {
|
|
const value = process.env[name]
|
|
|
|
if (!value) {
|
|
throw new Error(`Missing required environment variable: ${name}`)
|
|
}
|
|
|
|
return value
|
|
}
|
|
|
|
function createProject() {
|
|
return new ci.Project({
|
|
appid: process.env.WEAPP_APPID || projectConfig.appid,
|
|
type: 'miniProgram',
|
|
projectPath: process.cwd(),
|
|
privateKeyPath: requireEnv('WEAPP_PRIVATE_KEY_PATH'),
|
|
ignores: ['node_modules/**/*']
|
|
})
|
|
}
|
|
|
|
function getBaseSetting() {
|
|
return {
|
|
es6: true,
|
|
minifyJS: true,
|
|
minifyWXML: true,
|
|
minifyWXSS: true
|
|
}
|
|
}
|
|
|
|
function getPreviewOutput() {
|
|
return path.join(process.cwd(), 'dist', 'preview.jpg')
|
|
}
|
|
|
|
module.exports = {
|
|
createProject,
|
|
getBaseSetting,
|
|
getPreviewOutput
|
|
}
|