UNPKG

3.35 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const cli_framework_1 = require("@ionic/cli-framework");
4const os = require("os");
5const path = require("path");
6exports.GLOBAL_OPTIONS = [
7 {
8 name: 'help',
9 summary: 'Display help for commands',
10 aliases: ['h'],
11 type: Boolean,
12 groups: ["hidden" /* HIDDEN */],
13 },
14 {
15 name: 'verbose',
16 summary: 'Print debug log messages',
17 type: Boolean,
18 },
19 {
20 name: 'quiet',
21 summary: 'Only print warning and error log messages',
22 type: Boolean,
23 },
24 {
25 name: 'interactive',
26 summary: 'Disable interactivity such as progress indicators and prompts',
27 type: Boolean,
28 default: true,
29 },
30 {
31 name: 'color',
32 summary: 'Disable colors in stdout',
33 type: Boolean,
34 default: true,
35 },
36 {
37 name: 'confirm',
38 summary: 'Automatically answer YES to confirmation prompts',
39 type: Boolean,
40 },
41 {
42 name: 'project',
43 summary: 'The project ID to use in a multi-app configuration setup',
44 groups: ["hidden" /* HIDDEN */],
45 },
46 {
47 name: 'json',
48 summary: 'Use JSON when operating with stdout, if possible',
49 type: Boolean,
50 groups: ["hidden" /* HIDDEN */],
51 },
52];
53exports.CONFIG_FILE = 'config.json';
54exports.DEFAULT_CONFIG_DIRECTORY = path.resolve(os.homedir(), '.ionic');
55class Config extends cli_framework_1.BaseConfig {
56 constructor(p, options) {
57 super(p, options);
58 const c = this.c;
59 // <4.0.0 config migration
60 if (c.state) {
61 // start fresh
62 this.c = {
63 'version': '4.0.0',
64 'telemetry': c.telemetry,
65 'npmClient': c.npmClient,
66 'interactive': c.interactive,
67 'user.id': c.user && c.user.id,
68 'user.email': c.user && c.user.email,
69 'git.setup': c.git && c.git.setup,
70 'tokens.user': c.tokens && c.tokens.user,
71 'tokens.telemetry': c.tokens && c.tokens.telemetry,
72 'features.ssl-commands': c.features && c.features['ssl-commands'],
73 };
74 }
75 }
76 provideDefaults(config) {
77 return {
78 'version': '4.0.0',
79 'telemetry': true,
80 'npmClient': 'npm',
81 };
82 }
83 getAPIUrl() {
84 return this.get('urls.api', 'https://api.ionicjs.com');
85 }
86 getDashUrl() {
87 return this.get('urls.dash', 'https://dashboard.ionicframework.com');
88 }
89 getGitHost() {
90 return this.get('git.host', 'git.ionicjs.com');
91 }
92 getGitPort() {
93 return this.get('git.port', 22);
94 }
95 getHTTPConfig() {
96 const { c } = this;
97 return {
98 userAgent: `node/superagent/Ionic CLI ${c.version}`,
99 ssl: {
100 cafile: c['ssl.cafile'],
101 certfile: c['ssl.certfile'],
102 keyfile: c['ssl.keyfile'],
103 },
104 proxy: c['proxy'],
105 };
106 }
107}
108exports.Config = Config;
109function parseGlobalOptions(pargv) {
110 return cli_framework_1.parseArgs(pargv, cli_framework_1.metadataOptionsToParseArgsOptions(exports.GLOBAL_OPTIONS));
111}
112exports.parseGlobalOptions = parseGlobalOptions;