@elora-cloud/elora-cli
Version:
elora build cli 前端打包脚手架
45 lines (42 loc) • 1.68 kB
JavaScript
import { execSync } from 'node:child_process';
import process from 'node:process';
import prompts from 'prompts';
import { Plugin } from 'release-it';
class EloraCliReleasePlugin extends Plugin {
async beforeRelease() {
// log an empty line
console.log('building.....');
execSync('pnpm build', { stdio: 'inherit' });
execSync('elora changelog', { stdio: 'inherit' });
}
async afterRelease() {
// 发布完成后,进行版本的最终发布
let registry = 'https://registry.npmjs.org/';
if (process.env.ELORA_CLI_PUBLISH_REGISTRY) {
registry = process.env.ELORA_CLI_PUBLISH_REGISTRY;
}
const response = await prompts({
type: 'confirm',
name: 'confirm',
message: '需要二次确认吗?',
});
let authCodeOpt = '';
// 如果需要二次确认,询问输入确认码
if (response.confirm) {
const confirmationCodeResponse = await prompts({
type: 'text',
name: 'confirmationCode',
message: '请输入二次确认码',
});
// 输出二次确认码,可以在这里添加校验或逻辑
authCodeOpt = ` --otp=${confirmationCodeResponse.confirmationCode}`;
}
if (process.env.ELORA_CLI_PUBLISH_TAG) {
execSync(`pnpm publish --registry=${registry}${authCodeOpt}--tag=${process.env.ELORA_CLI_PUBLISH_TAG}`);
}
else {
execSync(`pnpm publish --registry=${registry}${authCodeOpt}`);
}
}
}
export { EloraCliReleasePlugin, EloraCliReleasePlugin as default };