UNPKG

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