return tslib_1.__awaiter(this, void 0, void 0, function* () { const global = !env.meta.local; const startMsg = `${global ? 'Global' : 'Local'} plugin ${chalk_1.default.cyan(plugin.meta.name)}`; const updateMsg = `${startMsg} has an update available (${chalk_1.default.cyan(plugin.meta.version)} => ${chalk_1.default.cyan(latestVersion)})!`; const canInstall = global ? yield fs_1.pathAccessible(plugin.meta.filePath, fs.constants.W_OK) : true; if (canInstall) { const message = ionicPlugin.meta.distTag === plugin.meta.distTag ? `${updateMsg} Would you like to install it?` : `${startMsg} has a different dist-tag (${chalk_1.default.cyan('@' + plugin.meta.distTag)}) than the Ionic CLI (${chalk_1.default.cyan('@' + ionicPlugin.meta.distTag)}). Would you like to install the appropriate plugin version?`; const okmessage = ionicPlugin.meta.distTag === plugin.meta.distTag ? `Updated ${chalk_1.default.bold(plugin.meta.name)} to ${chalk_1.default.bold(latestVersion)}! 🎉` : `Installed ${chalk_1.default.bold(plugin.meta.name + '@' + ionicPlugin.meta.distTag)}`; const p = yield promptToInstallPlugin(env, plugin.meta.name, { message, reinstall: true, global, }); if (p) { unregisterPlugin(env, plugin); registerPlugin(env, p); env.log.ok(okmessage); return true; } env.log.info(`Not automatically updating ${chalk_1.default.bold(plugin.meta.name)}.`); } else { env.log.info(updateMsg); env.log.nl(); env.log.warn(`No write permissions for ${global ? 'global' : 'local'}${chalk_1.default.bold('node_modules')}--automatic plugin updates are disabled.\n` + `To fix, see ${chalk_1.default.bold('https://docs.npmjs.com/getting-started/fixing-npm-permissions')}\n`); } return false; });
return tslib_1.__awaiter(this, void 0, void 0, function* () { const global = !env.meta.local; const modulesDir = path.resolve(global ? path.dirname(path.dirname(path.dirname(env.meta.libPath))) : path.join(env.project.directory, 'node_modules')); const pluginPkgs = yield Promise.all(exports.KNOWN_PLUGINS .map(formatFullPluginName) .map((pkgName) => tslib_1.__awaiter(this, void 0, void 0, function* () { const pluginPath = path.resolve(modulesDir, path.normalize(pkgName)); const exists = yield fs_1.pathExists(pluginPath); return [pkgName, exists]; }))); const [, proxyVar] = http_1.getGlobalProxy(); if (proxyVar) { const proxyPluginPkg = formatFullPluginName('proxy'); env.log.debug(() => `Detected ${chalk_1.default.green(proxyVar)} in environment`); if (!pluginPkgs.find(v => v[0] === proxyPluginPkg && v[1])) { const canInstall = yield fs_1.pathAccessible(env.plugins.ionic.meta.filePath, fs.constants.W_OK); const proxyInstallArgs = yield npm_1.pkgManagerArgs(env, { pkg: proxyPluginPkg, global }); const installMsg = `Detected ${chalk_1.default.green(proxyVar)} in environment, but to proxy CLI requests, you'll need ${chalk_1.default.cyan(proxyPluginPkg)} installed.`; if (canInstall) { yield promptToInstallPlugin(env, proxyPluginPkg, { message: `${installMsg} Install now?`, reinstall: true, global, }); } else { env.log.warn(`${installMsg}\nYou can install it manually:\n\n${chalk_1.default.green(proxyInstallArgs.join(' '))}\n`); } } } const pluginPromises = pluginPkgs.map((pkg) => tslib_1.__awaiter(this, void 0, void 0, function* () { const [pkgName, exists] = pkg; if (exists) { try { return yield loadPlugin(env, pkgName, { askToInstall: false, global }); } catch (e) { if (e !== exports.ERROR_PLUGIN_INVALID) { throw e; } } } })); for (let p of pluginPromises) { const plugin = yield p; if (plugin) { registerPlugin(env, plugin); } } });
return tslib_1.__awaiter(this, void 0, void 0, function* () { const config = yield env.config.load(); const global = !env.meta.local; const ionicInstallArgs = yield pkgInstallPluginArgs(env, 'ionic', { global }); const updateMsg = `The Ionic CLI ${global ? '' : '(local version) '}has an update available (${chalk_1.default.cyan(ionicPlugin.meta.version)} => ${chalk_1.default.cyan(latestVersion)})!`; const canInstall = global ? yield fs_1.pathAccessible(ionicPlugin.meta.filePath, fs.constants.W_OK) : true; if (canInstall) { const confirm = yield env.prompt({ name: 'confirm', type: 'confirm', message: `${updateMsg} Would you like to install it?`, }); if (confirm) { const [installer, ...installerArgs] = ionicInstallArgs; yield env.shell.run(installer, installerArgs, {}); const revertArgs = yield npm_1.pkgManagerArgs(env, { pkg: `ionic@${ionicPlugin.meta.version}`, global }); env.log.nl(); env.log.ok(`Updated Ionic CLI to ${chalk_1.default.bold(latestVersion)}! 🎉`); env.log.nl(); env.log.msg(chalk_1.default.bold('Please re-run your command.')); env.log.nl(); throw new errors_1.FatalException(`${chalk_1.default.bold('Note')}: You can downgrade to your old version by running: ${chalk_1.default.green(revertArgs.join(' '))}`, 0); } else { config.state.lastNoResponseToUpdate = new Date().toISOString(); env.log.info(`Not automatically updating your CLI.`); } } else { env.log.info(updateMsg); env.log.nl(); env.log.warn(`No write permissions for ${global ? 'global' : 'local'} ${chalk_1.default.bold('node_modules')}--automatic CLI updates are disabled.\n` + `To fix, see ${chalk_1.default.bold('https://docs.npmjs.com/getting-started/fixing-npm-permissions')}\n\n` + `Or, install the CLI update manually:\n\n${chalk_1.default.green(ionicInstallArgs.join(' '))}\n`); } });