init
This commit is contained in:
14
scripts/ci/preview.js
Normal file
14
scripts/ci/preview.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const ci = require('miniprogram-ci')
|
||||
const { createProject, getBaseSetting, getPreviewOutput } = require('./shared')
|
||||
|
||||
ci.preview({
|
||||
project: createProject(),
|
||||
desc: process.env.WEAPP_DESC || 'codex preview',
|
||||
qrcodeFormat: 'image',
|
||||
qrcodeOutputDest: getPreviewOutput(),
|
||||
setting: getBaseSetting(),
|
||||
onProgressUpdate() {}
|
||||
}).catch(error => {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
42
scripts/ci/shared.js
Normal file
42
scripts/ci/shared.js
Normal file
@@ -0,0 +1,42 @@
|
||||
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
|
||||
}
|
||||
14
scripts/ci/upload.js
Normal file
14
scripts/ci/upload.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const ci = require('miniprogram-ci')
|
||||
const { createProject, getBaseSetting } = require('./shared')
|
||||
|
||||
ci.upload({
|
||||
project: createProject(),
|
||||
version: process.env.WEAPP_VERSION || '0.1.0',
|
||||
desc: process.env.WEAPP_DESC || 'codex upload',
|
||||
robot: Number(process.env.WEAPP_ROBOT || 1),
|
||||
setting: getBaseSetting(),
|
||||
onProgressUpdate() {}
|
||||
}).catch(error => {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user