"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateIonicEnvironment = void 0; const cli_framework_output_1 = require("@ionic/cli-framework-output"); const cli_framework_prompts_1 = require("@ionic/cli-framework-prompts"); const utils_terminal_1 = require("@ionic/utils-terminal"); const Debug = require("debug"); const path = require("path"); const bootstrap_1 = require("../bootstrap"); const color_1 = require("./color"); const config_1 = require("./config"); const environment_1 = require("./environment"); const http_1 = require("./http"); const project_1 = require("./project"); const prompts_1 = require("./prompts"); const session_1 = require("./session"); const shell_1 = require("./shell"); const http_2 = require("./utils/http"); const logger_1 = require("./utils/logger"); const debug = Debug('ionic:lib'); async function generateIonicEnvironment(ctx, pargv) { process.chdir(ctx.execPath); const argv = config_1.parseGlobalOptions(pargv); const config = new config_1.Config(path.resolve(process.env['IONIC_CONFIG_DIRECTORY'] || config_1.DEFAULT_CONFIG_DIRECTORY, config_1.CONFIG_FILE)); debug('Terminal info: %o', utils_terminal_1.TERMINAL_INFO); if (config.get('interactive') === false || !utils_terminal_1.TERMINAL_INFO.tty || utils_terminal_1.TERMINAL_INFO.ci) { argv['interactive'] = false; } const flags = argv; // TODO debug('CLI global options: %o', flags); const log = new logger_1.Logger({ level: argv['quiet'] ? cli_framework_output_1.LOGGER_LEVELS.WARN : cli_framework_output_1.LOGGER_LEVELS.INFO, handlers: logger_1.createDefaultLoggerHandlers(), }); const prompt = await cli_framework_prompts_1.createPromptModule({ interactive: argv['interactive'], onFallback: prompts_1.createOnFallback({ flags, log }), }); const projectDir = await project_1.findProjectDirectory(ctx.execPath); const proxyVars = http_2.PROXY_ENVIRONMENT_VARIABLES.map((e) => [e, process.env[e]]).filter(([, v]) => !!v); const getInfo = async () => { const osName = await Promise.resolve().then(() => require('os-name')); const semver = await Promise.resolve().then(() => require('semver')); const { getUpdateConfig } = await Promise.resolve().then(() => require('./updates')); const os = osName(); const [npm, nativeRun, cordovaRes] = await Promise.all([ shell.cmdinfo('npm', ['-v']), shell.cmdinfo('native-run', ['--version']), shell.cmdinfo('cordova-res', ['--version']), ]); const { packages: latestVersions } = await getUpdateConfig({ config }); const latestNativeRun = latestVersions.find(pkg => pkg.name === 'native-run'); const latestCordovaRes = latestVersions.find(pkg => pkg.name === 'cordova-res'); const nativeRunUpdate = latestNativeRun && nativeRun ? semver.gt(latestNativeRun.version, nativeRun) : false; const cordovaResUpdate = latestCordovaRes && cordovaRes ? semver.gt(latestCordovaRes.version, cordovaRes) : false; const info = [ { group: 'ionic', name: 'Ionic CLI', key: 'version', value: ctx.version, path: ctx.libPath, }, { group: 'system', name: 'NodeJS', key: 'node_version', value: process.version, path: process.execPath }, { group: 'system', name: 'npm', key: 'npm_version', value: npm || 'not installed' }, { group: 'system', name: 'OS', key: 'os', value: os }, { group: 'utility', name: 'native-run', key: 'native_run_version', value: nativeRun || 'not installed', flair: nativeRunUpdate ? `update available: ${latestNativeRun ? color_1.success(latestNativeRun.version) : '???'}` : '', }, { group: 'utility', name: 'cordova-res', key: 'cordova_res_version', value: cordovaRes || 'not installed', flair: cordovaResUpdate ? `update available: ${latestCordovaRes ? color_1.success(latestCordovaRes.version) : '???'}` : '', }, ]; info.push(...proxyVars.map(([e, v]) => ({ group: 'environment', name: e, value: v || 'not set' }))); if (project) { info.push(...(await project.getInfo())); } return info; }; const shell = new shell_1.Shell({ log }, { alterPath: p => projectDir ? shell_1.prependNodeModulesBinToPath(projectDir, p) : p }); const client = new http_1.Client(config); const session = new session_1.ProSession({ config, client }); const deps = { client, config, ctx, flags, log, prompt, session, shell }; const env = new environment_1.Environment({ getInfo, ...deps }); if (process.env['IONIC_CLI_LOCAL_ERROR']) { if (process.env['IONIC_CLI_LOCAL_ERROR'] === bootstrap_1.ERROR_VERSION_TOO_OLD) { log.warn(`Detected locally installed Ionic CLI, but it's too old--using global CLI.`); } } if (typeof argv['yarn'] === 'boolean') { log.warn(`${color_1.input('--yarn')} / ${color_1.input('--no-yarn')} has been removed. Use ${color_1.input(`ionic config set -g npmClient ${argv['yarn'] ? 'yarn' : 'npm'}`)}.`); } const project = projectDir ? await project_1.createProjectFromDirectory(projectDir, argv, deps, { logErrors: !['start', 'init'].includes(argv._[0]) }) : undefined; if (project) { shell.alterPath = p => shell_1.prependNodeModulesBinToPath(project.directory, p); if (project.config.get('pro_id') && argv._[1] !== 'unset') { log.warn(`The ${color_1.input('pro_id')} field in ${color_1.strong(utils_terminal_1.prettyPath(project.filePath))} has been deprecated.\n` + `Ionic Pro has been renamed to Ionic Appflow! We've copied the value in ${color_1.input('pro_id')} to ${color_1.input('id')}, but you may want to unset the deprecated property: ${color_1.input('ionic config unset pro_id')}\n`); } } return { env, project }; } exports.generateIonicEnvironment = generateIonicEnvironment;
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 |
|