1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const util_1 = require("../../util");
|
4 | exports.default = (ctx) => {
|
5 | ctx.registerMethod('generateFrameworkInfo', ({ platform }) => {
|
6 | const { getInstalledNpmPkgVersion, processTypeEnum, printLog, chalk } = ctx.helper;
|
7 | const { nodeModulesPath } = ctx.paths;
|
8 | const { date, outputRoot } = ctx.initialConfig;
|
9 | const frameworkInfoFileName = '.frameworkinfo';
|
10 | const frameworkName = `@tarojs/taro-${platform}`;
|
11 | const frameworkVersion = getInstalledNpmPkgVersion(frameworkName, nodeModulesPath);
|
12 | if (frameworkVersion) {
|
13 | const frameworkinfo = {
|
14 | toolName: 'Taro',
|
15 | toolCliVersion: util_1.getPkgVersion(),
|
16 | toolFrameworkVersion: frameworkVersion,
|
17 | createTime: date ? new Date(date).getTime() : Date.now()
|
18 | };
|
19 | ctx.writeFileToDist({
|
20 | filePath: frameworkInfoFileName,
|
21 | content: JSON.stringify(frameworkinfo, null, 2)
|
22 | });
|
23 | printLog(processTypeEnum.GENERATE, '框架信息', `${outputRoot}/${frameworkInfoFileName}`);
|
24 | }
|
25 | else {
|
26 | printLog(processTypeEnum.WARNING, '依赖安装', chalk.red(`项目依赖 ${frameworkName} 未安装,或安装有误!`));
|
27 | }
|
28 | });
|
29 | };
|