1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | return new (P || (P = Promise))(function (resolve, reject) {
|
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
7 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 | });
|
9 | };
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | const path = require("path");
|
12 | const envinfo = require("envinfo");
|
13 | const util_1 = require("../../util");
|
14 | exports.default = (ctx) => {
|
15 | ctx.registerCommand({
|
16 | name: 'info',
|
17 | fn() {
|
18 | return __awaiter(this, void 0, void 0, function* () {
|
19 | const { rn } = ctx.runOpts;
|
20 | const { fs, chalk, PROJECT_CONFIG } = ctx.helper;
|
21 | const { appPath, configPath } = ctx.paths;
|
22 | if (!configPath || !fs.existsSync(configPath)) {
|
23 | console.log(chalk.red(`找不到项目配置文件${PROJECT_CONFIG},请确定当前目录是 Taro 项目根目录!`));
|
24 | process.exit(1);
|
25 | }
|
26 | if (rn) {
|
27 | const tempPath = path.join(appPath, '.rn_temp');
|
28 | if (fs.lstatSync(tempPath).isDirectory()) {
|
29 | process.chdir('.rn_temp');
|
30 | }
|
31 | }
|
32 | yield info({}, ctx);
|
33 | });
|
34 | }
|
35 | });
|
36 | };
|
37 | function info(options, ctx) {
|
38 | return __awaiter(this, void 0, void 0, function* () {
|
39 | const npmPackages = ctx.helper.UPDATE_PACKAGE_LIST.concat(['react', 'react-native', 'nervjs', 'expo', 'taro-ui']);
|
40 | const info = yield envinfo.run(Object.assign({}, {
|
41 | System: ['OS', 'Shell'],
|
42 | Binaries: ['Node', 'Yarn', 'npm'],
|
43 | npmPackages,
|
44 | npmGlobalPackages: ['typescript']
|
45 | }, options), {
|
46 | title: `Taro CLI ${util_1.getPkgVersion()} environment info`
|
47 | });
|
48 | console.log(info);
|
49 | });
|
50 | }
|