Example #1
0
 check() {
     return tslib_1.__awaiter(this, void 0, void 0, function* () {
         let running = yield this.task.running;
         if (running) {
             this.options = this.getOptions();
             this.statusItem.isProgress = false;
             this.statusItem.text = '?';
             this.statusItem.show();
         }
         else {
             this.onStop();
         }
     });
 }
Example #2
0
 getSnapshot(uuid, { fields = [] }) {
     return tslib_1.__awaiter(this, void 0, void 0, function* () {
         if (fields.indexOf('url') === -1) {
             fields.push('url');
         }
         const { req } = yield this.client.make('GET', `/deploy/snapshots/${uuid}`);
         req.set('Authorization', `Bearer ${this.appUserToken}`).query({ fields }).send();
         const res = yield this.client.do(req);
         if (!guards_1.isDeploySnapshotResponse(res)) {
             throw http_1.createFatalAPIFormat(req, res);
         }
         return res.data;
     });
 }
Example #3
0
function getPluginMeta(p) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const packageJson = yield npm_1.readPackageJsonFileOfResolvedModule(p);
        const name = packageJson.name;
        const version = packageJson.version || '';
        const distTag = determineDistTag(version);
        return {
            distTag,
            filePath: p,
            name,
            version,
        };
    });
}
Example #4
0
 run(inputs, options) {
     return tslib_1.__awaiter(this, void 0, void 0, function* () {
         const { expandPath, prettyPath } = yield Promise.resolve().then(() => require('@ionic/cli-utils/lib/utils/format'));
         const { ERROR_SSH_INVALID_PRIVKEY, ERROR_SSH_MISSING_PRIVKEY, validatePrivateKey } = yield Promise.resolve().then(() => require('@ionic/cli-utils/lib/ssh'));
         const { ensureHostAndKeyPath, getConfigPath } = yield Promise.resolve().then(() => require('@ionic/cli-utils/lib/ssh-config'));
         const keyPath = expandPath(inputs[0]);
         try {
             yield validatePrivateKey(keyPath);
         }
         catch (e) {
             if (e === ERROR_SSH_MISSING_PRIVKEY) {
                 throw new errors_1.FatalException(`${chalk_1.default.bold(keyPath)} does not appear to exist. Please specify a valid SSH private key.\n` +
                     `If you are having issues, try using ${chalk_1.default.green('ionic ssh setup')}.`);
             }
             else if (e === ERROR_SSH_INVALID_PRIVKEY) {
                 throw new errors_1.FatalException(`${chalk_1.default.bold(keyPath)} does not appear to be a valid SSH private key. (Missing '-----BEGIN RSA PRIVATE KEY-----' header.)\n` +
                     `If you are having issues, try using ${chalk_1.default.green('ionic ssh setup')}.`);
             }
             else {
                 throw e;
             }
         }
         const { SSHConfig } = yield Promise.resolve().then(() => require('@ionic/cli-utils/lib/ssh-config'));
         const sshConfigPath = getConfigPath();
         const text1 = yield fs_1.fileToString(sshConfigPath);
         const conf = SSHConfig.parse(text1);
         yield ensureHostAndKeyPath(conf, { host: yield this.env.config.getGitHost(), port: yield this.env.config.getGitPort() }, keyPath);
         const text2 = SSHConfig.stringify(conf);
         if (text1 === text2) {
             this.env.log.info(`${chalk_1.default.bold(prettyPath(keyPath))} is already your active SSH key.`);
             return;
         }
         else {
             const { diffPatch } = yield Promise.resolve().then(() => require('@ionic/cli-utils/lib/diff'));
             const diff = yield diffPatch(sshConfigPath, text1, text2);
             this.env.log.msg(diff);
             const confirm = yield this.env.prompt({
                 type: 'confirm',
                 name: 'confirm',
                 message: `May we make the above change(s) to '${prettyPath(sshConfigPath)}'?`
             });
             if (!confirm) {
                 // TODO: link to docs about manual git setup
                 throw new errors_1.FatalException();
             }
         }
         yield fs_1.fsWriteFile(sshConfigPath, text2, { encoding: 'utf8', mode: 0o600 });
         this.env.log.ok(`Your active Ionic SSH key has been set to ${chalk_1.default.bold(keyPath)}!`);
     });
 }
Example #5
0
 run(inputs, options) {
     return tslib_1.__awaiter(this, void 0, void 0, function* () {
         const { columnar } = yield Promise.resolve().then(() => require('@ionic/cli-utils/lib/utils/format'));
         const task = this.env.tasks.next('Gathering environment info');
         const initialValue = [];
         const results = yield this.env.hooks.fire('info', { env: this.env, project: this.env.project });
         const flattenedResults = results.reduce((acc, currentValue) => acc.concat(currentValue), initialValue);
         const cliDetails = flattenedResults.filter(item => item.type === 'cli-packages');
         const globalNpmDetails = flattenedResults.filter(item => item.type === 'global-packages');
         const localNpmDetails = flattenedResults.filter(item => item.type === 'local-packages');
         const systemDetails = flattenedResults.filter(item => item.type === 'system');
         const environmentDetails = flattenedResults.filter(item => item.type === 'environment');
         const miscDetails = flattenedResults.filter(item => item.type === 'misc');
         const ionicPkg = cliDetails.find(item => item.key === 'ionic');
         const pkgPath = ionicPkg && ionicPkg.path ? path.dirname(ionicPkg.path) : undefined;
         const splitInfo = (ary) => ary
             .sort((a, b) => string_1.strcmp(a.key.toLowerCase(), b.key.toLowerCase()))
             .map((item) => [`${item.key}${item.flair ? ' ' + chalk_1.default.dim('(' + item.flair + ')') : ''}`, chalk_1.default.dim(item.value) + (item.path && pkgPath && !item.path.startsWith(pkgPath) ? ` ${chalk_1.default.dim('(' + item.path + ')')}` : '')]);
         const format = (details) => columnar(details, { vsep: ':' }).split('\n').join('\n    ');
         task.end();
         if (!this.env.project.directory) {
             this.env.log.warn('You are not in an Ionic project directory. Project context may be missing.');
         }
         if (cliDetails.length > 0) {
             this.env.log.msg('\n' + chalk_1.default.bold('cli packages:') + (pkgPath ? ' ' + chalk_1.default.dim('(' + pkgPath + ')') : ''));
             this.env.log.msg(`\n    ${format(splitInfo(cliDetails))}`);
         }
         if (globalNpmDetails.length > 0) {
             this.env.log.msg('\n' + chalk_1.default.bold('global packages:'));
             this.env.log.msg(`\n    ${format(splitInfo(globalNpmDetails))}`);
         }
         if (localNpmDetails.length > 0) {
             this.env.log.msg('\n' + chalk_1.default.bold('local packages:'));
             this.env.log.msg(`\n    ${format(splitInfo(localNpmDetails))}`);
         }
         if (systemDetails.length > 0) {
             this.env.log.msg('\n' + chalk_1.default.bold('System:'));
             this.env.log.msg(`\n    ${format(splitInfo(systemDetails))}`);
         }
         if (environmentDetails.length > 0) {
             this.env.log.msg('\n' + chalk_1.default.bold('Environment Variables:'));
             this.env.log.msg(`\n    ${format(splitInfo(environmentDetails))}`);
         }
         if (miscDetails.length > 0) {
             this.env.log.msg('\n' + chalk_1.default.bold('Misc:'));
             this.env.log.msg(`\n    ${format(splitInfo(miscDetails))}`);
         }
         this.env.log.nl();
     });
 }
 RedisQueryResultCache.prototype.clear = function (queryRunner) {
     return tslib_1.__awaiter(this, void 0, void 0, function () {
         var _this = this;
         return tslib_1.__generator(this, function (_a) {
             return [2 /*return*/, new Promise(function (ok, fail) {
                     _this.client.flushdb(function (err, result) {
                         if (err)
                             return fail(err);
                         ok();
                     });
                 })];
         });
     });
 };
 MongoDriver.prototype.disconnect = function () {
     return tslib_1.__awaiter(this, void 0, void 0, function () {
         var _this = this;
         return tslib_1.__generator(this, function (_a) {
             return [2 /*return*/, new Promise(function (ok, fail) {
                     if (!_this.queryRunner)
                         return fail(new ConnectionIsNotSetError_1.ConnectionIsNotSetError("mongodb"));
                     var handler = function (err) { return err ? fail(err) : ok(); };
                     _this.queryRunner.databaseConnection.close(handler);
                     _this.queryRunner = undefined;
                 })];
         });
     });
 };
Example #8
0
function loadPlugin(env, pluginName, { message, askToInstall = true, reinstall = false, global = false }) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const mPath = global ? pluginName : path.join(env.project.directory, 'node_modules', ...pluginName.split('/'));
        let mResolvedPath;
        let m;
        if (!message) {
            message = `The plugin ${chalk.green(pluginName)} is not installed. Would you like to install it and continue?`;
        }
        env.log.debug(() => `Loading ${global ? 'global' : 'local'} plugin ${chalk.green(pluginName)}`);
        try {
            mResolvedPath = require.resolve(mPath);
            delete require.cache[mResolvedPath];
            m = require(mResolvedPath);
        }
        catch (e) {
            if (e.code !== 'MODULE_NOT_FOUND') {
                throw e;
            }
            if (!askToInstall) {
                env.log.debug(() => `Throwing ${chalk.red(exports.ERROR_PLUGIN_NOT_INSTALLED)} for ${global ? 'global' : 'local'} ${chalk.green(pluginName)}`);
                throw exports.ERROR_PLUGIN_NOT_INSTALLED;
            }
        }
        if (!m || reinstall) {
            const confirm = yield env.prompt({
                type: 'confirm',
                name: 'confirm',
                message,
                noninteractiveValue: true,
            });
            if (confirm) {
                const [installer, ...installerArgs] = yield pkgInstallPluginArgs(env, pluginName, { global });
                yield env.shell.run(installer, installerArgs, {});
                m = yield loadPlugin(env, pluginName, { askToInstall: false, global });
                mResolvedPath = require.resolve(mPath);
            }
            else {
                throw exports.ERROR_PLUGIN_NOT_INSTALLED;
            }
        }
        if (!guards_1.isPlugin(m) || !mResolvedPath) {
            env.log.debug(() => `Throwing ${chalk.red(exports.ERROR_PLUGIN_INVALID)} for ${global ? 'global' : 'local'} ${chalk.green(pluginName)}`);
            throw exports.ERROR_PLUGIN_INVALID;
        }
        m.meta = {
            filePath: mResolvedPath,
        };
        return m;
    });
}
Example #9
0
 execute(inputs, options) {
     return tslib_1.__awaiter(this, void 0, void 0, function* () {
         const config = yield this.env.config.load();
         yield this.runwrap(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
             if (guards_1.isCommandPreRun(this)) {
                 return this.preRun(inputs, options);
             }
         }));
         if (this.metadata.inputs) {
             for (let input of this.metadata.inputs) {
                 if (!input.validators) {
                     input.validators = [];
                 }
                 if (input.required !== false) {
                     input.validators.unshift(validators_1.validators.required);
                 }
             }
             try {
                 // Validate inputs again, this time with required validator (prompt input
                 // should've happened in preRun)
                 utils_1.validateInputs(inputs, this.metadata);
             }
             catch (e) {
                 if (!this.env.flags.interactive) {
                     this.env.log.warn(`Command ran non-interactively due to ${chalk.green('--no-interactive')} (or CI detected).`);
                 }
                 throw e;
             }
         }
         const runPromise = (() => tslib_1.__awaiter(this, void 0, void 0, function* () {
             yield this.runwrap(() => this.run(inputs, options));
         }))();
         const telemetryPromise = (() => tslib_1.__awaiter(this, void 0, void 0, function* () {
             if (config.telemetry !== false) {
                 let cmdInputs = [];
                 if (this.metadata.name === 'login' || this.metadata.name === 'logout') {
                     yield runPromise;
                 }
                 else if (this.metadata.name === 'help') {
                     cmdInputs = inputs;
                 }
                 else {
                     cmdInputs = yield this.getCleanInputsForTelemetry(inputs, options);
                 }
                 yield this.env.telemetry.sendCommand(`ionic ${this.metadata.fullName}`, cmdInputs);
             }
         }))();
         yield Promise.all([runPromise, telemetryPromise]);
     });
 }
Example #10
0
function parsePublicKeyFile(pubkeyPath) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        try {
            yield fs_1.fsStat(pubkeyPath);
        }
        catch (e) {
            if (e.code === 'ENOENT') {
                throw fs_1.ERROR_FILE_NOT_FOUND;
            }
            throw e;
        }
        return parsePublicKey((yield fs_1.fsReadFile(pubkeyPath, { encoding: 'utf8' })).trim());
    });
}
Example #11
0
function generate(args) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const { minimistOptionsToArray } = yield Promise.resolve().then(() => require('../utils/command'));
        if (!args.env.project.directory) {
            return [];
        }
        const appScriptsArgs = minimistOptionsToArray(args.options, { useEquals: false, ignoreFalse: true, allowCamelCase: true });
        process.argv = ['node', 'appscripts'].concat(appScriptsArgs);
        const AppScripts = yield app_scripts_1.importAppScripts(args.env);
        const context = AppScripts.generateContext();
        const [type, name] = args.inputs;
        const commandOptions = {
            module: false,
            constants: false,
        };
        if (args.options['module']) {
            commandOptions.module = true;
        }
        if (args.options['constants']) {
            commandOptions.constants = true;
        }
        switch (type) {
            case 'page':
                yield AppScripts.processPageRequest(context, name, commandOptions);
                break;
            case 'component':
                const componentData = yield getModules(context, 'component');
                yield AppScripts.processComponentRequest(context, name, componentData);
                break;
            case 'directive':
                const directiveData = yield getModules(context, 'directive');
                yield AppScripts.processDirectiveRequest(context, name, directiveData);
                break;
            case 'pipe':
                const pipeData = yield getModules(context, 'pipe');
                yield AppScripts.processPipeRequest(context, name, pipeData);
                break;
            case 'provider':
                const providerData = yield promptQuestions(context);
                yield AppScripts.processProviderRequest(context, name, providerData);
                break;
            case 'tabs':
                const tabsData = yield tabsPrompt(args.env);
                yield AppScripts.processTabsRequest(context, name, tabsData, commandOptions);
                break;
        }
        return [];
    });
}
Example #12
0
function generate(args) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        if (!args.env.project.directory) {
            return [];
        }
        const appScriptsArgs = cli_utils_1.minimistOptionsToArray(args.options, { useEquals: false, ignoreFalse: true, allowCamelCase: true });
        process.argv = ['node', 'appscripts'].concat(appScriptsArgs);
        const ionicAngularPackageJsonFilePath = path.resolve(args.env.project.directory, 'node_modules', 'ionic-angular', 'package.json'); // TODO
        try {
            const ionicAngularPackageJson = yield cli_utils_1.readPackageJsonFile(ionicAngularPackageJsonFilePath);
            if (ionicAngularPackageJson.version && Number(ionicAngularPackageJson.version.charAt(0)) < 3) {
                throw new Error(`The generate command is only available for projects that use ionic-angular >= 3.0.0`);
            }
        }
        catch (e) {
            args.env.log.error(`Error with ${chalk.bold(cli_utils_1.prettyPath(ionicAngularPackageJsonFilePath))} file: ${e}`);
        }
        const AppScripts = modules_1.load('@ionic/app-scripts');
        const context = AppScripts.generateContext();
        const [type, name] = args.inputs;
        const commandOptions = args.options;
        switch (type) {
            case 'page':
                yield AppScripts.processPageRequest(context, name, commandOptions);
                break;
            case 'component':
                const componentData = yield generate_1.getModules(context, 'component');
                yield AppScripts.processComponentRequest(context, name, componentData);
                break;
            case 'directive':
                const directiveData = yield generate_1.getModules(context, 'directive');
                yield AppScripts.processDirectiveRequest(context, name, directiveData);
                break;
            case 'pipe':
                const pipeData = yield generate_1.getModules(context, 'pipe');
                yield AppScripts.processPipeRequest(context, name, pipeData);
                break;
            case 'provider':
                const providerData = yield promptQuestions(context);
                yield AppScripts.processProviderRequest(context, name, providerData);
                break;
            case 'tabs':
                const tabsData = yield generate_1.tabsPrompt(args.env);
                yield AppScripts.processTabsRequest(context, name, tabsData, commandOptions);
                break;
        }
        return [];
    });
}
 SqljsDriver.prototype.connect = function () {
     return tslib_1.__awaiter(this, void 0, void 0, function () {
         var _a;
         return tslib_1.__generator(this, function (_b) {
             switch (_b.label) {
                 case 0:
                     _a = this;
                     return [4 /*yield*/, this.createDatabaseConnection()];
                 case 1:
                     _a.databaseConnection = _b.sent();
                     return [2 /*return*/];
             }
         });
     });
 };
Example #14
0
function getLatestPluginVersion(env, name, version) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const daemon = yield env.daemon.load();
        const distTag = determineDistTag(version);
        if (typeof daemon.latestVersions[distTag] === 'object') {
            if (daemon.latestVersions[distTag][name]) {
                const version = daemon.latestVersions[distTag][name];
                return version;
            }
        }
        else {
            env.daemon.populateDistTag(distTag);
        }
    });
}
Example #15
0
 const telemetryPromise = (() => tslib_1.__awaiter(this, void 0, void 0, function* () {
     if (config.telemetry !== false) {
         let cmdInputs = [];
         if (this.metadata.name === 'login' || this.metadata.name === 'logout') {
             yield runPromise;
         }
         else if (this.metadata.name === 'help') {
             cmdInputs = inputs;
         }
         else {
             cmdInputs = yield this.getCleanInputsForTelemetry(inputs, options);
         }
         yield this.env.telemetry.sendCommand(`ionic ${this.metadata.fullName}`, cmdInputs);
     }
 }))();
 RedisQueryResultCache.prototype.remove = function (identifiers, queryRunner) {
     return tslib_1.__awaiter(this, void 0, void 0, function () {
         var _this = this;
         return tslib_1.__generator(this, function (_a) {
             switch (_a.label) {
                 case 0: return [4 /*yield*/, Promise.all(identifiers.map(function (identifier) {
                         return _this.deleteKey(identifier);
                     }))];
                 case 1:
                     _a.sent();
                     return [2 /*return*/];
             }
         });
     });
 };
Example #17
0
 run(inputs, options) {
     return tslib_1.__awaiter(this, void 0, void 0, function* () {
         const [platform] = inputs;
         const { build } = yield Promise.resolve().then(() => require('@ionic/cli-utils/commands/build'));
         yield build(this.env, inputs, options);
         const project = yield this.env.project.load();
         if (project.integrations.cordova && project.integrations.cordova.enabled !== false) {
             const cordovaPrepareArgs = ['cordova', 'prepare', '--no-build'];
             if (platform) {
                 cordovaPrepareArgs.push(platform);
             }
             yield this.env.runCommand(cordovaPrepareArgs);
         }
     });
 }
Example #18
0
/**
 * Given a command object, backtrack through the command's namespace to compile
 * a list of command path items which represents how the command was
 * found/constructed.
 */
function generateCommandPath(cmd) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const ns = cmd.namespace;
        const cmdmeta = yield cmd.getMetadata();
        const _cmdpath = (namespace) => tslib_1.__awaiter(this, void 0, void 0, function* () {
            const nsmeta = yield namespace.getMetadata();
            const nspath = [nsmeta.name, namespace];
            if (!namespace.parent) {
                return [nspath];
            }
            return [...(yield _cmdpath(namespace.parent)), nspath];
        });
        return [...(yield _cmdpath(ns)), [cmdmeta.name, cmd]];
    });
}
 RedisQueryResultCache.prototype.disconnect = function () {
     return tslib_1.__awaiter(this, void 0, void 0, function () {
         var _this = this;
         return tslib_1.__generator(this, function (_a) {
             return [2 /*return*/, new Promise(function (ok, fail) {
                     _this.client.quit(function (err, result) {
                         if (err)
                             return fail(err);
                         ok();
                         _this.client = undefined;
                     });
                 })];
         });
     });
 };
Example #20
0
/**
 * @return Promise<[full pubkey, algorithm, public numbers, annotation]>
 */
function parsePublicKey(pubkey) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const r = /^(ssh-[A-z0-9]+)\s([A-z0-9+\/=]+)\s?(.+)?$/.exec(pubkey);
        if (!r) {
            throw exports.ERROR_SSH_INVALID_PUBKEY;
        }
        if (!r[3]) {
            r[3] = '';
        }
        r[1] = r[1].trim();
        r[2] = r[2].trim();
        r[3] = r[3].trim();
        return [pubkey, r[1], r[2], r[3]];
    });
}
 RelationQueryBuilder.prototype.loadMany = function () {
     return tslib_1.__awaiter(this, void 0, void 0, function () {
         var of, metadata;
         return tslib_1.__generator(this, function (_a) {
             of = this.expressionMap.of;
             if (!(of instanceof Object)) {
                 metadata = this.expressionMap.mainAlias.metadata;
                 if (metadata.hasMultiplePrimaryKeys)
                     throw new Error("Cannot load entity because only one primary key was specified, however entity contains multiple primary keys");
                 of = metadata.primaryColumns[0].createValueMap(of);
             }
             return [2 /*return*/, this.connection.relationLoader.load(this.expressionMap.relationMetadata, of)];
         });
     });
 };
Example #22
0
 ProxyEndpoint.prototype.read = function (id, options) {
     return tslib_1.__awaiter(this, void 0, void 0, function () {
         var doc;
         return tslib_1.__generator(this, function (_a) {
             switch (_a.label) {
                 case 0:
                     doc = new this.Record({ id: id });
                     return [4, doc.fetch(options)];
                 case 1:
                     _a.sent();
                     return [2, doc.toJSON()];
             }
         });
     });
 };
 RelationQueryBuilder.prototype.addAndRemove = function (added, removed) {
     return tslib_1.__awaiter(this, void 0, void 0, function () {
         return tslib_1.__generator(this, function (_a) {
             switch (_a.label) {
                 case 0: return [4 /*yield*/, this.remove(removed)];
                 case 1:
                     _a.sent();
                     return [4 /*yield*/, this.add(added)];
                 case 2:
                     _a.sent();
                     return [2 /*return*/];
             }
         });
     });
 };
Example #24
0
 const _locate = (depth, inputs, ns, namespaceDepthList) => tslib_1.__awaiter(this, void 0, void 0, function* () {
     const nsgetter = ns.namespaces.get(inputs[0]);
     if (!nsgetter) {
         const commands = ns.commands;
         const cmdgetter = commands.resolveAliases(inputs[0]);
         if (cmdgetter) {
             const cmd = yield cmdgetter();
             cmd.metadata.fullName = [...namespaceDepthList.slice(1), cmd.metadata.name].join(' ');
             return [depth + 1, inputs.slice(1), cmd];
         }
         return [depth, inputs, ns];
     }
     const newNamespace = yield nsgetter();
     return _locate(depth + 1, inputs.slice(1), newNamespace, [...namespaceDepthList, newNamespace.name]);
 });
Example #25
0
 ProxyEndpoint.prototype.list = function (options) {
     return tslib_1.__awaiter(this, void 0, void 0, function () {
         var coll;
         return tslib_1.__generator(this, function (_a) {
             switch (_a.label) {
                 case 0:
                     coll = new this.Record.Collection();
                     return [4, coll.fetch(options)];
                 case 1:
                     _a.sent();
                     return [2, coll.toJSON()];
             }
         });
     });
 };
Example #26
0
 yield Promise.all(commands.map((cmd) => tslib_1.__awaiter(this, void 0, void 0, function* () {
     const nsmeta = yield cmd.namespace.getMetadata();
     const aliases = [];
     if (cmd.namespace.parent) {
         const siblings = yield cmd.namespace.parent.getNamespaces();
         aliases.push(...(siblings.getAliases().get(nsmeta.name) || []).filter((a) => typeof a === 'string'));
     }
     summaries.set(nsmeta.name, nsmeta.summary);
     let entry = grouped.get(nsmeta.name);
     if (!entry) {
         entry = Object.assign({ namespace: cmd.namespace, commands: [], aliases }, nsmeta, { description: nsmeta.description ? nsmeta.description : '', groups: nsmeta.groups ? nsmeta.groups : [] });
         grouped.set(nsmeta.name, entry);
     }
     entry.commands.push(cmd);
 })));
Example #27
0
function formatHeader(env) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const config = yield env.config.load();
        const isLoggedIn = yield env.session.isLoggedIn();
        const now = new Date();
        const prefix = config.backend === backends_1.BACKEND_PRO && isLoggedIn ? chalk_1.default.blue('PRO') + ' ' : '';
        const version = env.plugins.ionic.meta.version;
        const suffix = now.getMonth() === 9 && now.getDate() === 31 ? ' 🎃' : '';
        return `   _             _
  (_) ___  _ __ (_) ___
  | |/ _ \\| '_ \\| |/ __|
  | | (_) | | | | | (__
  |_|\\___/|_| |_|_|\\___|  CLI ${prefix}${version}${suffix}\n`;
    });
}
 ConnectionOptionsReader.prototype.all = function () {
     return tslib_1.__awaiter(this, void 0, void 0, function () {
         var options;
         return tslib_1.__generator(this, function (_a) {
             switch (_a.label) {
                 case 0: return [4 /*yield*/, this.load()];
                 case 1:
                     options = _a.sent();
                     if (!options)
                         throw new Error("No connection options were found in any of configurations file.");
                     return [2 /*return*/, options];
             }
         });
     });
 };
Example #29
0
 Service.prototype.postJSON = function (url, body, headers) {
     return __awaiter(this, void 0, void 0, function () {
         var response, e_1, json, e_2;
         return __generator(this, function (_a) {
             switch (_a.label) {
                 case 0:
                     headers.append('Content-Type', 'application/json');
                     _a.label = 1;
                 case 1:
                     _a.trys.push([1, 3, , 4]);
                     return [4 /*yield*/, fetch(url, {
                             method: 'POST',
                             body: JSON.stringify(body),
                             headers: headers
                         })];
                 case 2:
                     response = _a.sent();
                     return [3 /*break*/, 4];
                 case 3:
                     e_1 = _a.sent();
                     // This could be an unhandled error on the backend, or it could be a
                     // network error. There's no way to no, since an unhandled error on the
                     // backend will fail to set the proper CORS header, and thus will be
                     // treated as a network error by fetch.
                     return [2 /*return*/, {
                             status: 0,
                             json: null
                         }];
                 case 4:
                     json = null;
                     _a.label = 5;
                 case 5:
                     _a.trys.push([5, 7, , 8]);
                     return [4 /*yield*/, response.json()];
                 case 6:
                     json = _a.sent();
                     return [3 /*break*/, 8];
                 case 7:
                     e_2 = _a.sent();
                     return [3 /*break*/, 8];
                 case 8: return [2 /*return*/, {
                         status: response.status,
                         json: json
                     }];
             }
         });
     });
 };
Example #30
0
 function showExpressionType(e) {
     return tslib_1.__awaiter(this, void 0, void 0, function* () {
         // If we are already showing we should wait for that to clear
         if (exprTypeTooltip)
             return;
         var pixelPt = pixelPositionFromMouseEvent(editorView, e);
         pixelPt.top += editor.element.getScrollTop();
         pixelPt.left += editor.element.getScrollLeft();
         var screenPt = editor.element.screenPositionForPixelPosition(pixelPt);
         var bufferPt = editor.bufferPositionForScreenPosition(screenPt);
         var curCharPixelPt = rawView.pixelPositionForBufferPosition([bufferPt.row, bufferPt.column]);
         var nextCharPixelPt = rawView.pixelPositionForBufferPosition([
             bufferPt.row,
             bufferPt.column + 1,
         ]);
         if (curCharPixelPt.left >= nextCharPixelPt.left)
             return;
         // find out show position
         var offset = editor.getLineHeightInPixels() * 0.7;
         var tooltipRect = {
             left: e.clientX,
             right: e.clientX,
             top: e.clientY - offset,
             bottom: e.clientY + offset,
         };
         exprTypeTooltip = new TooltipView(tooltipRect);
         const client = yield clientPromise;
         const result = yield client
             .executeQuickInfo({
             file: filePath,
             line: bufferPt.row + 1,
             offset: bufferPt.column + 1,
         })
             .catch(err => undefined);
         if (!result) {
             return;
         }
         const { displayString, documentation } = result.body;
         var message = `<b>${escape(displayString)}</b>`;
         if (documentation) {
             message =
                 message + `<br/><i>${escape(documentation).replace(/(?:\r\n|\r|\n)/g, "<br />")}</i>`;
         }
         if (exprTypeTooltip) {
             exprTypeTooltip.updateText(message);
         }
     });
 }