UNPKG

@honor-minigame/cli

Version:

honor minigame pack cli

43 lines (34 loc) 1.33 kB
import path from 'path' import fs from 'fs-extra' import { sign } from '../package/index.js' import { SIGN_MODE } from '../common/constant.js' import { checkNodeVersion, getManifestJson } from '../utils/index.js' // laya打包 export async function layaPackAction(param = 'debug', target, isAlliance) { if (!checkNodeVersion()) { return } let options = {} const rootPath = target ? target : process.cwd() const signMode = param === SIGN_MODE.RELEASE ? SIGN_MODE.RELEASE : SIGN_MODE.DEBUG // laya3.0修改 domparserinone.js const domparserinonePath = path.join(rootPath, 'js/domparserinone.js') if (fs.existsSync(domparserinonePath)) { const fileContent = fs.readFileSync(domparserinonePath).toString() fs.writeFileSync(domparserinonePath, fileContent.replace(/exports/g, 'this')) } const manifestJsonPath = path.join(rootPath, 'manifest.json') if (!fs.existsSync(manifestJsonPath)) { console.warn(`### HONOR PACK ### 缺少manifest.json文件`) return } options = getManifestJson(manifestJsonPath, signMode, isAlliance) options = Object.assign(options, { projectPath: rootPath, signMode: signMode, output: path.join(rootPath, 'dist') }) console.info('### HONOR PACK ### 开始签名') // 开始签名 sign(options) }