UNPKG

@tarojs/plugin-mini-ci

Version:

Taro 小程序端构建后支持CI(持续集成)的插件

54 lines 1.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path = require("node:path"); const process = require("node:process"); const hooks_1 = require("./hooks"); class BaseCI { constructor(ctx, pluginOpts) { var _a, _b; this.ctx = ctx; this.pluginOpts = pluginOpts; const { appPath } = ctx.paths; const { fs } = ctx.helper; const packageInfo = JSON.parse(fs.readFileSync(path.join(appPath, 'package.json'), { encoding: 'utf8' })); this.version = pluginOpts.version || ((_a = packageInfo.taroConfig) === null || _a === void 0 ? void 0 : _a.version); this.desc = pluginOpts.desc || ((_b = packageInfo.taroConfig) === null || _b === void 0 ? void 0 : _b.desc) || `CI构建自动构建于${new Date().toLocaleTimeString()}`; } setProjectPath(path) { this.projectPath = path; } /** 执行预览命令后触发 */ async triggerPreviewHooks(content) { const { success, data, error } = content; await this.ctx.applyPlugins({ name: hooks_1.ON_PREVIEW_COMPLETE, opts: { success, data: Object.assign({ version: this.version, desc: this.desc, projectPath: this.projectPath }, data), error }, }); if (!success) { process.exit(1); } } /** 执行上传命令后触发 */ async triggerUploadHooks(content) { const { success, data, error } = content; await this.ctx.applyPlugins({ name: hooks_1.ON_UPLOAD_COMPLETE, opts: { success, data: Object.assign({ version: this.version, desc: this.desc, projectPath: this.projectPath }, data), error }, }); if (!success) { process.exit(1); } } } exports.default = BaseCI; //# sourceMappingURL=BaseCi.js.map