"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Command = void 0; const cli_framework_1 = require("@ionic/cli-framework"); const cli_framework_output_1 = require("@ionic/cli-framework-output"); const utils_terminal_1 = require("@ionic/utils-terminal"); const guards_1 = require("../guards"); const color_1 = require("./color"); const logger_1 = require("./utils/logger"); class Command extends cli_framework_1.BaseCommand { constructor(namespace) { super(namespace); this.namespace = namespace; this.taskChains = []; } get env() { return this.namespace.root.env; } get project() { return this.namespace.root.project; } createTaskChain() { let output; const formatter = logger_1.createFormatter(); if (this.env.flags.interactive) { output = new cli_framework_output_1.TTYOutputStrategy({ stream: process.stdout, colors: cli_framework_1.DEFAULT_COLORS }); this.env.log.handlers = new Set([new cli_framework_output_1.StreamHandler({ stream: output.stream, formatter })]); } else { this.env.log.handlers = logger_1.createDefaultLoggerHandlers(); output = new cli_framework_output_1.StreamOutputStrategy({ stream: this.env.log.createWriteStream(cli_framework_output_1.LOGGER_LEVELS.INFO, false), colors: cli_framework_1.DEFAULT_COLORS }); } const chain = output.createTaskChain(); this.taskChains.push(chain); chain.on('end', () => { this.env.log.handlers = logger_1.createDefaultLoggerHandlers(); }); return chain; } async execute(inputs, options, runinfo) { if (guards_1.isCommandPreRun(this)) { await this.preRun(inputs, options, runinfo); } try { await this.validate(inputs); } catch (e) { if (!this.env.flags.interactive) { this.env.log.warn(`Command ran non-interactively due to ${color_1.input('--no-interactive')} flag, CI being detected, non-TTY, or a config setting.`); } throw e; } const runPromise = this.run(inputs, options, runinfo); const telemetryPromise = (async () => { if (this.env.config.get('telemetry') !== false && !utils_terminal_1.TERMINAL_INFO.ci && utils_terminal_1.TERMINAL_INFO.tty) { const { Telemetry } = await Promise.resolve().then(() => require('./telemetry')); let cmdInputs = []; const metadata = await this.getMetadata(); if (metadata.name === 'login' || metadata.name === 'logout') { // This is a hack to wait until the selected commands complete before // sending telemetry data. These commands update `this.env` in some // way, which is used in the `Telemetry` instance. await runPromise; } else if (metadata.name === 'completion') { // Ignore telemetry for these commands. return; } else if (metadata.name === 'help') { cmdInputs = inputs; } else { cmdInputs = await this.getCleanInputsForTelemetry(inputs, options); } const cmd = this; const path = await cli_framework_1.generateCommandPath(cmd); const telemetry = new Telemetry({ client: this.env.client, config: this.env.config, getInfo: this.env.getInfo, ctx: this.env.ctx, project: this.project, session: this.env.session }); await telemetry.sendCommand(path.map(([p]) => p).join(' '), cmdInputs); } })(); await Promise.all([runPromise, telemetryPromise]); } async getCleanInputsForTelemetry(inputs, options) { const initialOptions = { _: [] }; const metadata = await this.getMetadata(); const filteredInputs = inputs.map((input, i) => metadata.inputs && (metadata.inputs[i] && metadata.inputs[i].private) ? '*****' : input); const filteredOptions = Object.keys(options) .filter(optionName => { if (optionName === '_') { return false; } const metadataOption = metadata.options && metadata.options.find(o => { return o.name === optionName || (typeof o.aliases !== 'undefined' && o.aliases.includes(optionName)); }); if (metadataOption && metadataOption.aliases && metadataOption.aliases.includes(optionName)) { return false; // exclude aliases } if (!metadataOption) { return true; // include unknown options } if (metadataOption.private) { return false; // exclude private options } if (typeof metadataOption.default !== 'undefined' && metadataOption.default === options[optionName]) { return false; // exclude options that match their default value (means it wasn't supplied by user) } return true; }) .reduce((allOptions, optionName) => { allOptions[optionName] = options[optionName]; return allOptions; }, initialOptions); const optionInputs = cli_framework_1.unparseArgs(filteredOptions, { useDoubleQuotes: true }); return filteredInputs.concat(optionInputs); } } exports.Command = Command;
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
doctor | Folder | 0755 |
|
|
integrations | Folder | 0755 |
|
|
oauth | Folder | 0755 |
|
|
project | Folder | 0755 |
|
|
utils | Folder | 0755 |
|
|
app.d.ts | File | 1.15 KB | 0644 |
|
app.js | File | 2.5 KB | 0644 |
|
build.d.ts | File | 3.43 KB | 0644 |
|
build.js | File | 8.51 KB | 0644 |
|
color.d.ts | File | 484 B | 0644 |
|
color.js | File | 768 B | 0644 |
|
command.d.ts | File | 924 B | 0644 |
|
command.js | File | 5.47 KB | 0644 |
|
config.d.ts | File | 843 B | 0644 |
|
config.js | File | 3.83 KB | 0644 |
|
cordova-res.d.ts | File | 1.07 KB | 0644 |
|
cordova-res.js | File | 2.62 KB | 0644 |
|
diff.d.ts | File | 100 B | 0644 |
|
diff.js | File | 709 B | 0644 |
|
environment.d.ts | File | 1004 B | 0644 |
|
environment.js | File | 516 B | 0644 |
|
errors.d.ts | File | 891 B | 0644 |
|
errors.js | File | 1.77 KB | 0644 |
|
events.d.ts | File | 240 B | 0644 |
|
events.js | File | 498 B | 0644 |
|
executor.d.ts | File | 1 KB | 0644 |
|
executor.js | File | 3.7 KB | 0644 |
|
generate.d.ts | File | 923 B | 0644 |
|
generate.js | File | 351 B | 0644 |
|
git.d.ts | File | 747 B | 0644 |
|
git.js | File | 1.66 KB | 0644 |
|
help.d.ts | File | 2.4 KB | 0644 |
|
help.js | File | 3.66 KB | 0644 |
|
helper.d.ts | File | 252 B | 0644 |
|
helper.js | File | 654 B | 0644 |
|
hooks.d.ts | File | 841 B | 0644 |
|
hooks.js | File | 4.72 KB | 0644 |
|
http.d.ts | File | 2.62 KB | 0644 |
|
http.js | File | 7.56 KB | 0644 |
|
index.d.ts | File | 226 B | 0644 |
|
index.js | File | 6.09 KB | 0644 |
|
ionitron.d.ts | File | 148 B | 0644 |
|
ionitron.js | File | 4.72 KB | 0644 |
|
namespace.d.ts | File | 854 B | 0644 |
|
namespace.js | File | 686 B | 0644 |
|
native-run.d.ts | File | 1.5 KB | 0644 |
|
native-run.js | File | 4.98 KB | 0644 |
|
open.d.ts | File | 164 B | 0644 |
|
open.js | File | 507 B | 0644 |
|
prompts.d.ts | File | 402 B | 0644 |
|
prompts.js | File | 716 B | 0644 |
|
security.d.ts | File | 511 B | 0644 |
|
security.js | File | 785 B | 0644 |
|
serve.d.ts | File | 5.79 KB | 0644 |
|
serve.js | File | 22.4 KB | 0644 |
|
session.d.ts | File | 921 B | 0644 |
|
session.js | File | 7.82 KB | 0644 |
|
shell.d.ts | File | 1.95 KB | 0644 |
|
shell.js | File | 8.41 KB | 0644 |
|
snapshot.d.ts | File | 765 B | 0644 |
|
snapshot.js | File | 1.13 KB | 0644 |
|
ssh-config.d.ts | File | 646 B | 0644 |
|
ssh-config.js | File | 3.04 KB | 0644 |
|
ssh.d.ts | File | 1.67 KB | 0644 |
|
ssh.js | File | 3.53 KB | 0644 |
|
start.d.ts | File | 1.34 KB | 0644 |
|
start.js | File | 12.1 KB | 0644 |
|
telemetry.d.ts | File | 972 B | 0644 |
|
telemetry.js | File | 3.59 KB | 0644 |
|
updates.d.ts | File | 1.01 KB | 0644 |
|
updates.js | File | 3.82 KB | 0644 |
|
user.d.ts | File | 865 B | 0644 |
|
user.js | File | 2.37 KB | 0644 |
|