diff --git a/packages/@ionic/cli-framework-prompts/src/index.ts b/packages/@ionic/cli-framework-prompts/src/index.ts index 153f031e00..a46722f693 100644 --- a/packages/@ionic/cli-framework-prompts/src/index.ts +++ b/packages/@ionic/cli-framework-prompts/src/index.ts @@ -1,5 +1,5 @@ import { TERMINAL_INFO } from '@ionic/utils-terminal'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; const debug = Debug('ionic:cli-framework-prompts'); diff --git a/packages/@ionic/cli-framework/src/lib/colors.ts b/packages/@ionic/cli-framework/src/lib/colors.ts index 6201cde2c7..cee61e2ad9 100644 --- a/packages/@ionic/cli-framework/src/lib/colors.ts +++ b/packages/@ionic/cli-framework/src/lib/colors.ts @@ -1,5 +1,5 @@ import { ColorFunction, Colors as BaseColors } from '@ionic/cli-framework-output'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; import * as lodash from 'lodash'; import { MetadataGroup } from '../definitions'; diff --git a/packages/@ionic/cli-framework/src/lib/help.ts b/packages/@ionic/cli-framework/src/lib/help.ts index 992abfde42..b6c88559d7 100644 --- a/packages/@ionic/cli-framework/src/lib/help.ts +++ b/packages/@ionic/cli-framework/src/lib/help.ts @@ -1,6 +1,6 @@ import { filter, map } from '@ionic/utils-array'; import { generateFillSpaceStringList, stringWidth, wordWrap } from '@ionic/utils-terminal'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import { CommandMetadata, CommandMetadataInput, CommandMetadataOption, Footnote, HydratedCommandMetadata, HydratedNamespaceMetadata, ICommand, INamespace, LinkFootnote, MetadataGroup, NamespaceLocateResult, NamespaceMetadata } from '../definitions'; @@ -223,7 +223,7 @@ export class NamespaceStringHelpFormatter, N e const filteredCommands = await filter(commands, async cmd => this.filterCommandCallback(cmd)); - const [ cmdDetails, nsDetails ] = await Promise.all([ + const [cmdDetails, nsDetails] = await Promise.all([ this.getListOfCommandDetails(filteredCommands.filter(cmd => cmd.namespace === this.namespace)), this.getListOfNamespaceDetails(filteredCommands.filter(cmd => cmd.namespace !== this.namespace)), ]); diff --git a/packages/@ionic/cli-framework/src/lib/options.ts b/packages/@ionic/cli-framework/src/lib/options.ts index b622b27c9e..dc5994737a 100644 --- a/packages/@ionic/cli-framework/src/lib/options.ts +++ b/packages/@ionic/cli-framework/src/lib/options.ts @@ -1,5 +1,5 @@ import * as lodash from 'lodash'; -import * as minimist from 'minimist'; +import minimist from 'minimist'; import { CommandLineOptions, CommandMetadataOption, HydratedParseArgsOptions, ParsedArg } from '../definitions'; @@ -19,7 +19,7 @@ export { ParsedArgs } from 'minimist'; */ export function stripOptions(pargv: readonly string[], { includeSeparated = true }: { includeSeparated?: boolean; }): string[] { const r = /^\-/; - const [ ownArgs, otherArgs ] = separateArgv(pargv); + const [ownArgs, otherArgs] = separateArgv(pargv); const filteredArgs = ownArgs.filter(arg => !r.test(arg)); if (!includeSeparated) { @@ -50,7 +50,7 @@ export function separateArgv(pargv: readonly string[]): [string[], string[]] { otherArgs.shift(); // strip separator } - return [ ownArgs, otherArgs ]; + return [ownArgs, otherArgs]; } /** @@ -166,8 +166,8 @@ export function filterCommandLineOptions(option const pairs = Object.keys(parsedArgs) .map((k): [string, O | undefined, ParsedArg | undefined] => [k, mapped.get(k), parsedArgs[k]]) - .filter(([ k, opt, value ]) => opt && predicate(opt, value)) - .map(([ k, opt, value ]) => [opt ? opt.name : k, value]); + .filter(([k, opt, value]) => opt && predicate(opt, value)) + .map(([k, opt, value]) => [opt ? opt.name : k, value]); return { ...initial, ...lodash.fromPairs(pairs) }; } @@ -221,7 +221,7 @@ export function unparseArgs(parsedArgs: minimist.ParsedArgs, { useDoubleQuotes, const dashKey = (k: string) => (k.length === 1 ? '-' : '--') + k; const pushPairs = (...pairs: [string, string | undefined][]) => { - for (const [ k, val ] of pairs) { + for (const [k, val] of pairs) { const key = dashKey(allowCamelCase ? k : k.replace(/[A-Z]/g, '-$&').toLowerCase()); if (useEquals) { @@ -274,7 +274,7 @@ export function unparseArgs(parsedArgs: minimist.ParsedArgs, { useDoubleQuotes, isKnown(k) ); - for (const [ key, val ] of pairedOptions) { + for (const [key, val] of pairedOptions) { if (val === true) { pushPairs([key, undefined]); } else if (val === false && !ignoreFalse) { diff --git a/packages/@ionic/cli-framework/src/lib/validators.ts b/packages/@ionic/cli-framework/src/lib/validators.ts index 17a0c0c142..a22ee49d81 100644 --- a/packages/@ionic/cli-framework/src/lib/validators.ts +++ b/packages/@ionic/cli-framework/src/lib/validators.ts @@ -1,4 +1,4 @@ -import * as chalk from 'chalk'; +import chalk from 'chalk'; import { ValidationError, Validator, Validators } from '../definitions'; import { InputValidationError } from '../errors'; diff --git a/packages/@ionic/cli-framework/src/utils/ipc.ts b/packages/@ionic/cli-framework/src/utils/ipc.ts index c35b8a9182..97102babc6 100644 --- a/packages/@ionic/cli-framework/src/utils/ipc.ts +++ b/packages/@ionic/cli-framework/src/utils/ipc.ts @@ -1,6 +1,6 @@ import { fork } from '@ionic/utils-subprocess'; import { ChildProcess } from 'child_process'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as fs from 'fs'; import { ERROR_IPC_UNKNOWN_PROCEDURE, IPCError } from '../errors'; diff --git a/packages/@ionic/cli/ionic-cli-7.1.5.tgz b/packages/@ionic/cli/ionic-cli-7.1.5.tgz new file mode 100644 index 0000000000..cdda1fe8d0 Binary files /dev/null and b/packages/@ionic/cli/ionic-cli-7.1.5.tgz differ diff --git a/packages/@ionic/cli/package.json b/packages/@ionic/cli/package.json index f634bfe893..66de878ce0 100644 --- a/packages/@ionic/cli/package.json +++ b/packages/@ionic/cli/package.json @@ -63,7 +63,7 @@ "ssh-config": "^1.1.1", "stream-combiner2": "^1.1.1", "superagent": "^8.0.9", - "superagent-proxy": "^3.0.0", + "proxy-agent": "^6.3.0", "tar": "^6.0.1", "tslib": "^2.0.1" }, @@ -77,7 +77,6 @@ "@types/semver": "^7.1.0", "@types/split2": "^2.1.6", "@types/superagent": "4.1.3", - "@types/superagent-proxy": "^3.0.0", "@types/tar": "^6.1.2", "jest": "^26.4.2", "jest-cli": "^26.0.1", diff --git a/packages/@ionic/cli/src/bootstrap.ts b/packages/@ionic/cli/src/bootstrap.ts index 9c3c1d7e9d..63ce9277d8 100644 --- a/packages/@ionic/cli/src/bootstrap.ts +++ b/packages/@ionic/cli/src/bootstrap.ts @@ -1,5 +1,5 @@ import { compileNodeModulesPaths, readPackageJsonFile } from '@ionic/cli-framework/utils/node'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as path from 'path'; import * as semver from 'semver'; diff --git a/packages/@ionic/cli/src/commands/capacitor/run.ts b/packages/@ionic/cli/src/commands/capacitor/run.ts index 5724e24e2c..0398a6e902 100644 --- a/packages/@ionic/cli/src/commands/capacitor/run.ts +++ b/packages/@ionic/cli/src/commands/capacitor/run.ts @@ -1,8 +1,8 @@ import { BaseError, Footnote, validators } from '@ionic/cli-framework'; import { sleepForever } from '@ionic/utils-process'; import { columnar } from '@ionic/utils-terminal'; -import * as chalk from 'chalk'; -import * as Debug from 'debug'; +import chalk from 'chalk'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import * as semver from 'semver'; @@ -233,7 +233,7 @@ For Android and iOS, you can setup Remote Debugging on your device with browser throw new FatalException(`Cannot run ${input('ionic capacitor run')} outside a project directory.`); } - const [ platform ] = inputs; + const [platform] = inputs; const doLiveReload = !!options['livereload']; const doOpenFlow = (await this.isOldCapacitor()) || options['open'] === true; @@ -297,7 +297,7 @@ For Android and iOS, you can setup Remote Debugging on your device with browser throw new FatalException(`Cannot run ${input('ionic capacitor run')} outside a project directory.`); } - const [ platform ] = inputs; + const [platform] = inputs; await this.runCapacitorRunHook('capacitor:run:before', inputs, options, { ...this.env, project: this.project }); @@ -326,7 +326,7 @@ For Android and iOS, you can setup Remote Debugging on your device with browser throw new FatalException(`Cannot run ${input('ionic capacitor run')} outside a project directory.`); } - const [ platform ] = inputs; + const [platform] = inputs; await this.runCapacitorRunHook('capacitor:run:before', inputs, options, { ...this.env, project: this.project }); await this.runCapacitor(['run', platform, ...(shouldSync ? [] : ['--no-sync']), '--target', String(options['target'])]); diff --git a/packages/@ionic/cli/src/commands/config/get.ts b/packages/@ionic/cli/src/commands/config/get.ts index 37969695b4..6a814a757f 100644 --- a/packages/@ionic/cli/src/commands/config/get.ts +++ b/packages/@ionic/cli/src/commands/config/get.ts @@ -1,7 +1,7 @@ import { MetadataGroup } from '@ionic/cli-framework'; import { strcmp } from '@ionic/cli-framework/utils/string'; import { columnar, prettyPath } from '@ionic/utils-terminal'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; import * as lodash from 'lodash'; import * as util from 'util'; diff --git a/packages/@ionic/cli/src/commands/cordova/run.ts b/packages/@ionic/cli/src/commands/cordova/run.ts index 81fc5556cf..5662d59e31 100644 --- a/packages/@ionic/cli/src/commands/cordova/run.ts +++ b/packages/@ionic/cli/src/commands/cordova/run.ts @@ -1,6 +1,6 @@ import { Footnote, MetadataGroup, validators } from '@ionic/cli-framework'; import { onBeforeExit, sleepForever } from '@ionic/utils-process'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import { CommandInstanceInfo, CommandLineInputs, CommandLineOptions, CommandMetadata, CommandMetadataOption, CommandPreRun, IShellRunOptions, ServeDetails } from '../../definitions'; @@ -212,7 +212,7 @@ Just like with ${input('ionic cordova build')}, you can pass additional options inputs[0] = p.trim(); } - const [ platform ] = inputs; + const [platform] = inputs; if (platform && options['native-run'] && !SUPPORTED_PLATFORMS.includes(platform)) { this.env.log.warn(`${input(platform)} is not supported by ${input('native-run')}. Using Cordova to run the app.`); @@ -298,7 +298,7 @@ Just like with ${input('ionic cordova build')}, you can pass additional options buildOpts.stdio = options['verbose'] ? 'inherit' : ['pipe', 'ignore', 'pipe']; if (options['native-run']) { - const [ platform ] = inputs; + const [platform] = inputs; await this.runCordova(filterArgumentsForCordova({ ...metadata, name: 'build' }, options), buildOpts); @@ -336,7 +336,7 @@ Just like with ${input('ionic cordova build')}, you can pass additional options if (options['native-run']) { const conf = await loadCordovaConfig(this.integration); - const [ platform ] = inputs; + const [platform] = inputs; await this.runCordova(filterArgumentsForCordova({ ...metadata, name: 'build' }, options), { stdio: 'inherit' }); diff --git a/packages/@ionic/cli/src/commands/integrations/list.ts b/packages/@ionic/cli/src/commands/integrations/list.ts index 450338e433..f629df1ca0 100644 --- a/packages/@ionic/cli/src/commands/integrations/list.ts +++ b/packages/@ionic/cli/src/commands/integrations/list.ts @@ -1,5 +1,5 @@ import { columnar } from '@ionic/utils-terminal'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; import { CommandLineInputs, CommandLineOptions, CommandMetadata, IntegrationName } from '../../definitions'; import { input, strong } from '../../lib/color'; diff --git a/packages/@ionic/cli/src/commands/link.ts b/packages/@ionic/cli/src/commands/link.ts index d06276877f..d9e4e5ad63 100644 --- a/packages/@ionic/cli/src/commands/link.ts +++ b/packages/@ionic/cli/src/commands/link.ts @@ -1,7 +1,7 @@ import { MetadataGroup, validators } from '@ionic/cli-framework'; import { createPromptChoiceSeparator } from '@ionic/cli-framework-prompts'; import { prettyPath } from '@ionic/utils-terminal'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import { PROJECT_FILE } from '../constants'; import { App, CommandInstanceInfo, CommandLineInputs, CommandLineOptions, CommandMetadata, CommandPreRun, GithubBranch, GithubRepo } from '../definitions'; @@ -468,7 +468,7 @@ If you are having issues linking, please get in touch with our Support[^support- } formatRepoName(fullName: string) { - const [ org, name ] = fullName.split('/'); + const [org, name] = fullName.split('/'); return `${weak(`${org} /`)} ${name}`; } diff --git a/packages/@ionic/cli/src/commands/live-update/manifest.ts b/packages/@ionic/cli/src/commands/live-update/manifest.ts index 832d6e0ea7..18cf415957 100644 --- a/packages/@ionic/cli/src/commands/live-update/manifest.ts +++ b/packages/@ionic/cli/src/commands/live-update/manifest.ts @@ -7,7 +7,7 @@ import * as crypto from 'crypto'; import * as fs from 'fs'; import lodash = require('lodash'); import * as path from 'path'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import { CommandMetadata } from '../../definitions'; import { input } from '../../lib/color'; @@ -62,7 +62,7 @@ export class LiveUpdatesManifestCommand extends LiveUpdatesCoreCommand { private async getFilesAndSizesAndHashesForGlobPattern(buildDir: string): Promise { const contents = await readdirp(buildDir, { filter: item => !/(css|js)\.map$/.test(item.path) }); const stats = await map(contents, async (f): Promise<[string, fs.Stats]> => [f, await stat(f)]); - const files = stats.filter(([ , s ]) => !s.isDirectory()); + const files = stats.filter(([, s]) => !s.isDirectory()); const items = await Promise.all(files.map(([f, s]) => this.getFileAndSizeAndHashForFile(buildDir, f, s))); @@ -113,7 +113,7 @@ export class LiveUpdatesManifestCommand extends LiveUpdatesCoreCommand { level: LOGGER_LEVELS.INFO, handlers: createDefaultLoggerHandlers(), }); - const shell = new Shell({ log }, { alterPath: p => { return prependNodeModulesBinToPath(this.env.ctx.execPath, p)} }); + const shell = new Shell({ log }, { alterPath: p => { return prependNodeModulesBinToPath(this.env.ctx.execPath, p) } }); debug('Getting config with Capacitor CLI: %O', args); @@ -126,7 +126,7 @@ export class LiveUpdatesManifestCommand extends LiveUpdatesCoreCommand { try { return JSON.parse(output); - } catch(e) { + } catch (e) { debug('Could not get config from Capacitor CLI (probably old version)', e); return; } diff --git a/packages/@ionic/cli/src/commands/login.ts b/packages/@ionic/cli/src/commands/login.ts index 9b9905a6e3..46f709c107 100644 --- a/packages/@ionic/cli/src/commands/login.ts +++ b/packages/@ionic/cli/src/commands/login.ts @@ -1,5 +1,5 @@ import { combine, validators } from '@ionic/cli-framework'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; import * as readline from 'readline'; import { CommandLineInputs, CommandLineOptions, CommandMetadata, CommandPreRun } from '../definitions'; @@ -155,7 +155,7 @@ If you are having issues logging in, please get in touch with our Support[^suppo } async run(inputs: CommandLineInputs, options: CommandLineOptions): Promise { - const [ email, password ] = inputs; + const [email, password] = inputs; if (email && password) { await this.logout(); @@ -182,7 +182,7 @@ If you are having issues logging in, please get in touch with our Support[^suppo await this.logout(); await this.env.session.webLogin(); } else { - return ; + return; } } diff --git a/packages/@ionic/cli/src/commands/monitoring/syncmaps.ts b/packages/@ionic/cli/src/commands/monitoring/syncmaps.ts index 4089dfb9f4..e27afa5a19 100644 --- a/packages/@ionic/cli/src/commands/monitoring/syncmaps.ts +++ b/packages/@ionic/cli/src/commands/monitoring/syncmaps.ts @@ -1,6 +1,6 @@ import { pathExists, readFile, readdirSafe } from '@ionic/utils-fs'; import { columnar, prettyPath } from '@ionic/utils-terminal'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as path from 'path'; import { APIResponseSuccess, CommandLineInputs, CommandLineOptions, CommandMetadata } from '../../definitions'; @@ -48,7 +48,7 @@ By default, ${input('ionic monitoring syncmaps')} will upload the sourcemap file const token = await this.env.session.getUserToken(); const appflowId = await this.project.requireAppflowId(); - const [ snapshotId ] = inputs; + const [snapshotId] = inputs; const doBuild = options.build ? true : false; const cordova = this.project.requireIntegration('cordova'); diff --git a/packages/@ionic/cli/src/commands/start.ts b/packages/@ionic/cli/src/commands/start.ts index 5d976f38e8..8328e3efc1 100644 --- a/packages/@ionic/cli/src/commands/start.ts +++ b/packages/@ionic/cli/src/commands/start.ts @@ -2,8 +2,8 @@ import { MetadataGroup, validators } from '@ionic/cli-framework'; import { isValidURL, slugify } from '@ionic/cli-framework/utils/string'; import { mkdir, pathExists, remove, unlink } from '@ionic/utils-fs'; import { columnar, prettyPath } from '@ionic/utils-terminal'; -import * as chalk from 'chalk'; -import * as Debug from 'debug'; +import chalk from 'chalk'; +import { debug as Debug } from 'debug'; import * as path from 'path'; import { COLUMNAR_OPTIONS, PROJECT_FILE, ANGULAR_STANDALONE } from '../constants'; @@ -263,16 +263,16 @@ Use the ${input( const appIconBuffer = data.appIcon ? Buffer.from( - data.appIcon.replace(/^data:image\/\w+;base64,/, ''), - 'base64' - ) + data.appIcon.replace(/^data:image\/\w+;base64,/, ''), + 'base64' + ) : undefined; const splashBuffer = data.appSplash ? Buffer.from( - data.appSplash.replace(/^data:image\/\w+;base64,/, ''), - 'base64' - ) + data.appSplash.replace(/^data:image\/\w+;base64,/, ''), + 'base64' + ) : undefined; this.schema = { @@ -397,8 +397,8 @@ Use the ${input( let projectType = isValidURL(inputs[1]) ? 'custom' : options['type'] - ? String(options['type']) - : await this.getProjectType(); + ? String(options['type']) + : await this.getProjectType(); if (options['cordova']) { const { checkForUnsupportedProject } = await import( @@ -435,9 +435,9 @@ Use the ${input( this.env.log.nl(); this.env.log.msg( `${strong(`Every great app needs a name! ${emoji('😍', '')}`)}\n` + - `Please enter the full name of your app. You can change this at any time. To bypass this prompt next time, supply ${input( - 'name' - )}, the first argument to ${input('ionic start')}.\n\n` + `Please enter the full name of your app. You can change this at any time. To bypass this prompt next time, supply ${input( + 'name' + )}, the first argument to ${input('ionic start')}.\n\n` ); } @@ -459,9 +459,9 @@ Use the ${input( `${strong( `Let's pick the perfect starter template! ${emoji('💪', '')}` )}\n` + - `Starter templates are ready-to-go Ionic apps that come packed with everything you need to build your app. To bypass this prompt next time, supply ${input( - 'template' - )}, the second argument to ${input('ionic start')}.\n\n` + `Starter templates are ready-to-go Ionic apps that come packed with everything you need to build your app. To bypass this prompt next time, supply ${input( + 'template' + )}, the second argument to ${input('ionic start')}.\n\n` ); } @@ -589,9 +589,9 @@ Use the ${input( if (options['v1'] || options['v2']) { throw new FatalException( `The ${input('--v1')} and ${input('--v2')} flags have been removed.\n` + - `Use the ${input('--type')} option. (see ${input( - 'ionic start --help' - )})` + `Use the ${input('--type')} option. (see ${input( + 'ionic start --help' + )})` ); } @@ -670,9 +670,9 @@ Use the ${input( this.env.log.nl(); this.env.log.msg( `${strong(`Pick a framework! ${emoji('😁', '')}`)}\n\n` + - `Please select the JavaScript framework to use for your new app. To bypass this prompt next time, supply a value for the ${input( - '--type' - )} option.\n\n` + `Please select the JavaScript framework to use for your new app. To bypass this prompt next time, supply a value for the ${input( + '--type' + )} option.\n\n` ); } @@ -734,16 +734,16 @@ Use the ${input( if (appflowId) { throw new FatalException( `Git CLI not found on your PATH.\n` + - `Git must be installed to connect this app to Ionic. ${installationDocs}` + `Git must be installed to connect this app to Ionic. ${installationDocs}` ); } if (this.schema.cloned) { throw new FatalException( `Git CLI not found on your PATH.\n` + - `Git must be installed to clone apps with ${input( - 'ionic start' - )}. ${installationDocs}` + `Git must be installed to clone apps with ${input( + 'ionic start' + )}. ${installationDocs}` ); } } @@ -1038,9 +1038,8 @@ Use the ${input( if (starterTemplate && starterTemplate.type === 'managed') { return { ...starterTemplate, - archive: `${STARTER_BASE_URL}/${tag === 'latest' ? '' : `${tag}/`}${ - starterTemplate.id - }.tar.gz`, + archive: `${STARTER_BASE_URL}/${tag === 'latest' ? '' : `${tag}/`}${starterTemplate.id + }.tar.gz`, }; } @@ -1058,16 +1057,15 @@ Use the ${input( return { name: starter.name, projectType: starter.type, - archive: `${STARTER_BASE_URL}/${tag === 'latest' ? '' : `${tag}/`}${ - starter.id - }.tar.gz`, + archive: `${STARTER_BASE_URL}/${tag === 'latest' ? '' : `${tag}/`}${starter.id + }.tar.gz`, }; } else { throw new FatalException( `Unable to find starter template for ${input(template)}\n` + - `If this is not a typo, please make sure it is a valid starter template within the starters repo: ${strong( - 'https://github.com/ionic-team/starters' - )}` + `If this is not a typo, please make sure it is a valid starter template within the starters repo: ${strong( + 'https://github.com/ionic-team/starters' + )}` ); } } @@ -1078,9 +1076,9 @@ Use the ${input( if (!['custom', ...projectTypes].includes(type)) { throw new FatalException( `${input(type)} is not a valid project type.\n` + - `Please choose a different ${input('--type')}. Use ${input( - 'ionic start --list' - )} to list all available starter templates.` + `Please choose a different ${input('--type')}. Use ${input( + 'ionic start --list' + )} to list all available starter templates.` ); } } @@ -1089,9 +1087,9 @@ Use the ${input( if (!isValidProjectId(projectId)) { throw new FatalException( `${input(projectId)} is not a valid package or directory name.\n` + - `Please choose a different ${input( - '--project-id' - )}. Alphanumeric characters are always safe.` + `Please choose a different ${input( + '--project-id' + )}. Alphanumeric characters are always safe.` ); } } @@ -1162,11 +1160,11 @@ Use the ${input( )} within the app directory to see your app in the browser`, isCapacitor ? `Run ${input( - 'ionic capacitor add' - )} to add a native iOS or Android project using Capacitor` + 'ionic capacitor add' + )} to add a native iOS or Android project using Capacitor` : `Run ${input( - 'ionic cordova platform add' - )} to add a native iOS or Android project using Cordova`, + 'ionic cordova platform add' + )} to add a native iOS or Android project using Cordova`, `Generate your app icon and splash screens using ${input( cordovaResCommand )}`, diff --git a/packages/@ionic/cli/src/constants.ts b/packages/@ionic/cli/src/constants.ts index de126950c7..1d31eb7bed 100644 --- a/packages/@ionic/cli/src/constants.ts +++ b/packages/@ionic/cli/src/constants.ts @@ -1,4 +1,4 @@ -import * as chalk from 'chalk'; +import chalk from 'chalk'; import * as lodash from 'lodash'; import * as path from 'path'; diff --git a/packages/@ionic/cli/src/index.ts b/packages/@ionic/cli/src/index.ts index 9b72945baf..949d9057fc 100644 --- a/packages/@ionic/cli/src/index.ts +++ b/packages/@ionic/cli/src/index.ts @@ -1,7 +1,7 @@ import { BaseError, InputValidationError, PackageJson } from '@ionic/cli-framework'; import { readPackageJsonFile } from '@ionic/cli-framework/utils/node'; import { processExit } from '@ionic/utils-process'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as path from 'path'; import * as util from 'util'; @@ -126,7 +126,7 @@ export async function run(pargv: string[]): Promise { const location = await executor.locate(pargv); - const [ , [ cmd = '' ] = [] ] = location.path; + const [, [cmd = ''] = []] = location.path; if (!['config', 'completion', 'help', 'login', 'logout', 'version'].includes(cmd)) { await authenticateFromEnvironment(ienv); diff --git a/packages/@ionic/cli/src/lib/build.ts b/packages/@ionic/cli/src/lib/build.ts index 6889c8caf7..dc07de3a3b 100644 --- a/packages/@ionic/cli/src/lib/build.ts +++ b/packages/@ionic/cli/src/lib/build.ts @@ -2,7 +2,7 @@ import { BaseError, MetadataGroup } from '@ionic/cli-framework'; import { PromptModule } from '@ionic/cli-framework-prompts'; import { createProcessEnv } from '@ionic/utils-process'; import { ERROR_COMMAND_NOT_FOUND, SubprocessError } from '@ionic/utils-subprocess'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import { BaseBuildOptions, BuildOptions, CommandLineInputs, CommandLineOptions, CommandMetadata, CommandMetadataOption, IConfig, ILogger, IProject, IShell, NpmClient, Runner } from '../definitions'; @@ -62,7 +62,7 @@ export abstract class BuildRunner> implements Runner createBaseOptionsFromCommandLine(inputs: CommandLineInputs, options: CommandLineOptions): BaseBuildOptions { const separatedArgs = options['--']; - const [ platform ] = options['platform'] ? [String(options['platform'])] : inputs; + const [platform] = options['platform'] ? [String(options['platform'])] : inputs; const engine = this.determineEngineFromCommandLine(options); const project = options['project'] ? String(options['project']) : undefined; const verbose = !!options['verbose']; @@ -153,7 +153,7 @@ export abstract class BuildCLI { private _resolvedProgram?: string; - constructor(protected readonly e: BuildRunnerDeps) {} + constructor(protected readonly e: BuildRunnerDeps) { } get resolvedProgram() { if (this._resolvedProgram) { @@ -251,7 +251,7 @@ export abstract class BuildCLI { protected async promptToInstall(): Promise { const { pkgManagerArgs } = await import('./utils/npm'); - const [ manager, ...managerArgs ] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'install', pkg: this.pkg, saveDev: true, saveExact: true }); + const [manager, ...managerArgs] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'install', pkg: this.pkg, saveDev: true, saveExact: true }); this.e.log.nl(); @@ -283,7 +283,7 @@ abstract class PkgManagerBuildCLI extends BuildCLI { protected async buildArgs(options: BaseBuildOptions): Promise { const { pkgManagerArgs } = await import('./utils/npm'); - const [ , ...pkgArgs ] = await pkgManagerArgs(this.program, { command: 'run', script: this.script, scriptArgs: [...options['--'] || []] }); + const [, ...pkgArgs] = await pkgManagerArgs(this.program, { command: 'run', script: this.script, scriptArgs: [...options['--'] || []] }); return pkgArgs; } diff --git a/packages/@ionic/cli/src/lib/color.ts b/packages/@ionic/cli/src/lib/color.ts index e57bb07009..789ff736d6 100644 --- a/packages/@ionic/cli/src/lib/color.ts +++ b/packages/@ionic/cli/src/lib/color.ts @@ -1,5 +1,5 @@ import { Colors, DEFAULT_COLORS, HelpColors } from '@ionic/cli-framework'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; const HELP_COLORS: Partial = { title: chalk.bold, diff --git a/packages/@ionic/cli/src/lib/events.ts b/packages/@ionic/cli/src/lib/events.ts index f05e486e9a..3c52b85650 100644 --- a/packages/@ionic/cli/src/lib/events.ts +++ b/packages/@ionic/cli/src/lib/events.ts @@ -1,4 +1,4 @@ -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import { ServeDetails } from '../definitions'; diff --git a/packages/@ionic/cli/src/lib/hooks.ts b/packages/@ionic/cli/src/lib/hooks.ts index 93b71c5612..8f9fe41ea1 100644 --- a/packages/@ionic/cli/src/lib/hooks.ts +++ b/packages/@ionic/cli/src/lib/hooks.ts @@ -1,6 +1,6 @@ import { conform } from '@ionic/utils-array'; import { prettyPath } from '@ionic/utils-terminal'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import * as path from 'path'; @@ -24,7 +24,7 @@ export abstract class Hook { return `ionic:${this.name}`; } - constructor(protected readonly e: HookDeps) {} + constructor(protected readonly e: HookDeps) { } async run(input: HookInput) { const { pkgManagerArgs } = await import('./utils/npm'); @@ -35,7 +35,7 @@ export abstract class Hook { return; // TODO: will we need hooks outside a project? } - const [ pkg ] = await this.e.project.getPackageJson(undefined, { logErrors: false }); + const [pkg] = await this.e.project.getPackageJson(undefined, { logErrors: false }); if (!pkg) { return; @@ -47,7 +47,7 @@ export abstract class Hook { if (pkg.scripts && pkg.scripts[this.script]) { debug(`Invoking ${ancillary(this.script)} npm script.`); - const [ pkgManager, ...pkgArgs ] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'run', script: this.script }); + const [pkgManager, ...pkgArgs] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'run', script: this.script }); await this.e.shell.run(pkgManager, pkgArgs, { env: ctxEnvironment, }); diff --git a/packages/@ionic/cli/src/lib/http.ts b/packages/@ionic/cli/src/lib/http.ts index ff07e2da88..4363110e8e 100644 --- a/packages/@ionic/cli/src/lib/http.ts +++ b/packages/@ionic/cli/src/lib/http.ts @@ -1,4 +1,4 @@ -import * as chalk from 'chalk'; +import chalk from 'chalk'; import * as lodash from 'lodash'; import * as util from 'util'; @@ -36,7 +36,7 @@ export const ERROR_UNKNOWN_CONTENT_TYPE = 'UNKNOWN_CONTENT_TYPE'; export const ERROR_UNKNOWN_RESPONSE_FORMAT = 'UNKNOWN_RESPONSE_FORMAT'; export class Client implements IClient { - constructor(public config: IConfig) {} + constructor(public config: IConfig) { } async make(method: HttpMethod, path: string, contentType: ContentType = ContentType.JSON): Promise<{ req: SuperAgentRequest; }> { const url = path.startsWith('http://') || path.startsWith('https://') ? path : `${this.config.getAPIUrl()}${path}`; diff --git a/packages/@ionic/cli/src/lib/index.ts b/packages/@ionic/cli/src/lib/index.ts index 1effce3290..2d54055fcc 100644 --- a/packages/@ionic/cli/src/lib/index.ts +++ b/packages/@ionic/cli/src/lib/index.ts @@ -1,7 +1,7 @@ import { LOGGER_LEVELS } from '@ionic/cli-framework-output'; import { createPromptModule } from '@ionic/cli-framework-prompts'; import { TERMINAL_INFO, prettyPath } from '@ionic/utils-terminal'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as path from 'path'; import { ERROR_VERSION_TOO_OLD } from '../bootstrap'; @@ -49,13 +49,13 @@ export async function generateIonicEnvironment(ctx: IonicContext, pargv: string[ const proxyVars = PROXY_ENVIRONMENT_VARIABLES.map((e): [string, string | undefined] => [e, process.env[e]]).filter(([, v]) => !!v); const getInfo = async () => { - const osName = await import('os-name'); + const osName = (await import('os-name')).default; const semver = await import('semver'); const { getUpdateConfig } = await import('./updates'); const os = osName(); - const [ npm, nativeRun, cordovaRes ] = await Promise.all([ + const [npm, nativeRun, cordovaRes] = await Promise.all([ shell.cmdinfo('npm', ['-v']), shell.cmdinfo('native-run', ['--version']), shell.cmdinfo('cordova-res', ['--version']), diff --git a/packages/@ionic/cli/src/lib/integrations/capacitor/index.ts b/packages/@ionic/cli/src/lib/integrations/capacitor/index.ts index 223daabbcf..1fbc6ed3c3 100644 --- a/packages/@ionic/cli/src/lib/integrations/capacitor/index.ts +++ b/packages/@ionic/cli/src/lib/integrations/capacitor/index.ts @@ -1,8 +1,8 @@ import { parseArgs } from '@ionic/cli-framework'; import { mkdirp, pathExists } from '@ionic/utils-fs'; import { prettyPath } from '@ionic/utils-terminal'; -import * as chalk from 'chalk'; -import * as Debug from 'debug'; +import chalk from 'chalk'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import * as path from 'path'; @@ -99,17 +99,17 @@ export class Integration extends BaseIntegration { } async installCapacitorCore() { - const [ manager, ...managerArgs ] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'install', pkg: '@capacitor/core@latest' }); + const [manager, ...managerArgs] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'install', pkg: '@capacitor/core@latest' }); await this.e.shell.run(manager, managerArgs, { cwd: this.root }); } async installCapacitorCLI() { - const [ manager, ...managerArgs ] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'install', pkg: '@capacitor/cli@latest', saveDev: true }); + const [manager, ...managerArgs] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'install', pkg: '@capacitor/cli@latest', saveDev: true }); await this.e.shell.run(manager, managerArgs, { cwd: this.root }); } async installCapacitorPlugins() { - const [ manager, ...managerArgs ] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'install', pkg: ['@capacitor/haptics', '@capacitor/app', '@capacitor/keyboard', '@capacitor/status-bar'] }); + const [manager, ...managerArgs] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'install', pkg: ['@capacitor/haptics', '@capacitor/app', '@capacitor/keyboard', '@capacitor/status-bar'] }); await this.e.shell.run(manager, managerArgs, { cwd: this.root }); } @@ -131,10 +131,10 @@ export class Integration extends BaseIntegration { const bundleId = conf?.appId; const [ - [ capacitorCorePkg, capacitorCorePkgPath ], + [capacitorCorePkg, capacitorCorePkgPath], capacitorCLIVersion, - [ capacitorIOSPkg, capacitorIOSPkgPath ], - [ capacitorAndroidPkg, capacitorAndroidPkgPath ], + [capacitorIOSPkg, capacitorIOSPkgPath], + [capacitorAndroidPkg, capacitorAndroidPkgPath], ] = await (Promise.all([ this.e.project.getPackageJson('@capacitor/core'), this.getCapacitorCLIVersion(), @@ -219,7 +219,7 @@ export class Integration extends BaseIntegration { // Capacitor 1 returns the `command not found` error in stdout instead of stderror like in Capacitor 2 // This ensures that the output from the command is valid JSON to account for this return JSON.parse(output); - } catch(e) { + } catch (e) { debug('Could not get config from Capacitor CLI (probably old version)', e); return; } diff --git a/packages/@ionic/cli/src/lib/integrations/cordova/config.ts b/packages/@ionic/cli/src/lib/integrations/cordova/config.ts index 2bf00cf692..c342061cee 100644 --- a/packages/@ionic/cli/src/lib/integrations/cordova/config.ts +++ b/packages/@ionic/cli/src/lib/integrations/cordova/config.ts @@ -1,7 +1,7 @@ import { readPackageJsonFile } from '@ionic/cli-framework/utils/node'; import { readFile, writeFile } from '@ionic/utils-fs'; import { prettyPath } from '@ionic/utils-terminal'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as et from 'elementtree'; import * as path from 'path'; @@ -24,7 +24,7 @@ export class CordovaConfig { protected _sessionid?: string; protected saving = false; - constructor(readonly configXmlPath: string, readonly packageJsonPath: string) {} + constructor(readonly configXmlPath: string, readonly packageJsonPath: string) { } get doc(): et.ElementTree { if (!this._doc) { @@ -237,11 +237,11 @@ export async function loadCordovaConfig(integration: Required { .map(m => [m[1], m[2]]); const whitelistedPlugins = plugins - .filter(([ plugin, version ]) => whitelist.some(re => re.test(plugin))) - .map(([ plugin, version ]) => `${plugin} ${version}`); + .filter(([plugin, version]) => whitelist.some(re => re.test(plugin))) + .map(([plugin, version]) => `${plugin} ${version}`); const count = plugins.length - whitelistedPlugins.length; diff --git a/packages/@ionic/cli/src/lib/integrations/cordova/project.ts b/packages/@ionic/cli/src/lib/integrations/cordova/project.ts index aa0db6654c..7ffa6fb988 100644 --- a/packages/@ionic/cli/src/lib/integrations/cordova/project.ts +++ b/packages/@ionic/cli/src/lib/integrations/cordova/project.ts @@ -1,6 +1,6 @@ import { filter } from '@ionic/utils-array'; import { readJson, readdirSafe, statSafe } from '@ionic/utils-fs'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as path from 'path'; import { AndroidBuildOutput, LegacyAndroidBuildOutputEntry } from '../../../definitions'; diff --git a/packages/@ionic/cli/src/lib/ionitron.ts b/packages/@ionic/cli/src/lib/ionitron.ts index 8637fdef80..f2a4522ed0 100644 --- a/packages/@ionic/cli/src/lib/ionitron.ts +++ b/packages/@ionic/cli/src/lib/ionitron.ts @@ -1,4 +1,4 @@ -import * as chalk from 'chalk'; +import chalk from 'chalk'; export function getIonitronString(quote: string) { const quoteFormatted = quote diff --git a/packages/@ionic/cli/src/lib/open.ts b/packages/@ionic/cli/src/lib/open.ts index cb910a4120..e33f21c826 100644 --- a/packages/@ionic/cli/src/lib/open.ts +++ b/packages/@ionic/cli/src/lib/open.ts @@ -1,4 +1,4 @@ -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; const debug = Debug('ionic:lib:open'); @@ -7,7 +7,7 @@ export interface OpenUrlOptions { } export async function openUrl(target: string, options: OpenUrlOptions = {}): Promise { - const o = await import ('open'); + const o = (await import('open')).default; const p = await o(target, { ...options, wait: false, url: true }); const e = (err: Error) => debug('Error during open: %O', err); const n = p.on.bind(p); diff --git a/packages/@ionic/cli/src/lib/project/angular/generate.ts b/packages/@ionic/cli/src/lib/project/angular/generate.ts index ce64456439..7324685b27 100644 --- a/packages/@ionic/cli/src/lib/project/angular/generate.ts +++ b/packages/@ionic/cli/src/lib/project/angular/generate.ts @@ -1,5 +1,5 @@ import { unparseArgs, validators } from '@ionic/cli-framework'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import { AngularGenerateOptions, CommandLineInputs, CommandLineOptions, CommandMetadata } from '../../../definitions'; @@ -100,7 +100,7 @@ To test a generator before file modifications are made, use the ${input('--dry-r createOptionsFromCommandLine(inputs: CommandLineInputs, options: CommandLineOptions): AngularGenerateOptions { const [schematic, name] = inputs; - const baseOptions = {name, schematic} + const baseOptions = { name, schematic } const project = options['project'] ? String(options['project']) : 'app'; // TODO: this is a little gross, is there a better way to pass in all the diff --git a/packages/@ionic/cli/src/lib/project/angular/index.ts b/packages/@ionic/cli/src/lib/project/angular/index.ts index 56ff341d95..71803ab1d7 100644 --- a/packages/@ionic/cli/src/lib/project/angular/index.ts +++ b/packages/@ionic/cli/src/lib/project/angular/index.ts @@ -1,4 +1,4 @@ -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import * as path from 'path'; @@ -13,11 +13,11 @@ export class AngularProject extends Project { async getInfo(): Promise { const [ - [ ionicAngularPkg, ionicAngularPkgPath ], - [ ionicAngularToolkitPkg, ionicAngularToolkitPkgPath ], - [ angularCLIPkg, angularCLIPkgPath ], - [ angularDevKitBuildAngularPkg, angularDevKitBuildAngularPkgPath ], - [ angularDevKitSchematicsPkg, angularDevKitSchematicsPkgPath ], + [ionicAngularPkg, ionicAngularPkgPath], + [ionicAngularToolkitPkg, ionicAngularToolkitPkgPath], + [angularCLIPkg, angularCLIPkgPath], + [angularDevKitBuildAngularPkg, angularDevKitBuildAngularPkgPath], + [angularDevKitSchematicsPkg, angularDevKitSchematicsPkgPath], ] = await Promise.all([ this.getPackageJson('@ionic/angular'), this.getPackageJson('@ionic/angular-toolkit'), diff --git a/packages/@ionic/cli/src/lib/project/angular/serve.ts b/packages/@ionic/cli/src/lib/project/angular/serve.ts index 21f75d27c9..444f1aafda 100644 --- a/packages/@ionic/cli/src/lib/project/angular/serve.ts +++ b/packages/@ionic/cli/src/lib/project/angular/serve.ts @@ -2,7 +2,7 @@ import { MetadataGroup, ParsedArgs, unparseArgs } from '@ionic/cli-framework'; import { str2num } from '@ionic/cli-framework/utils/string'; import { findClosestOpenPort } from '@ionic/utils-network'; import { stripAnsi } from '@ionic/utils-terminal'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; import { AngularServeOptions, CommandLineInputs, CommandLineOptions, CommandMetadata, ServeDetails } from '../../../definitions'; import { input, strong, weak } from '../../color'; @@ -123,7 +123,7 @@ The dev server can use HTTPS via the ${input('--ssl')} option ${chalk.bold.red(' } async serveProject(options: AngularServeOptions): Promise { - const [ externalIP, availableInterfaces ] = await this.selectExternalIP(options); + const [externalIP, availableInterfaces] = await this.selectExternalIP(options); const port = options.port = await findClosestOpenPort(options.port); @@ -200,7 +200,7 @@ export class AngularServeCLI extends ServeCLI { if (this.resolvedProgram === this.program) { return [...this.buildArchitectCommand(options), ...args]; } else { - const [ , ...pkgArgs ] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'run', script: this.script, scriptArgs: [...args] }); + const [, ...pkgArgs] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'run', script: this.script, scriptArgs: [...args] }); return pkgArgs; } } diff --git a/packages/@ionic/cli/src/lib/project/index.ts b/packages/@ionic/cli/src/lib/project/index.ts index 77449ca6dd..9e42e3db94 100644 --- a/packages/@ionic/cli/src/lib/project/index.ts +++ b/packages/@ionic/cli/src/lib/project/index.ts @@ -4,7 +4,7 @@ import { resolveValue } from '@ionic/cli-framework/utils/fn'; import { ERROR_INVALID_PACKAGE_JSON, compileNodeModulesPaths, isValidPackageName, readPackageJsonFile } from '@ionic/cli-framework/utils/node'; import { ensureDir, findBaseDirectory, readFile, writeFile, writeJson } from '@ionic/utils-fs'; import { TTY_WIDTH, prettyPath, wordWrap } from '@ionic/utils-terminal'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import * as path from 'path'; diff --git a/packages/@ionic/cli/src/lib/project/react-vite/index.ts b/packages/@ionic/cli/src/lib/project/react-vite/index.ts index daf9f78ac4..136ab3e124 100755 --- a/packages/@ionic/cli/src/lib/project/react-vite/index.ts +++ b/packages/@ionic/cli/src/lib/project/react-vite/index.ts @@ -1,5 +1,5 @@ -import * as chalk from 'chalk'; -import * as Debug from 'debug'; +import chalk from 'chalk'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import * as path from 'path'; diff --git a/packages/@ionic/cli/src/lib/project/react/index.ts b/packages/@ionic/cli/src/lib/project/react/index.ts index b713847d9d..05a05929a9 100644 --- a/packages/@ionic/cli/src/lib/project/react/index.ts +++ b/packages/@ionic/cli/src/lib/project/react/index.ts @@ -1,5 +1,5 @@ -import * as chalk from 'chalk'; -import * as Debug from 'debug'; +import chalk from 'chalk'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import * as path from 'path'; @@ -14,7 +14,7 @@ export class ReactProject extends Project { async getInfo(): Promise { const [ - [ ionicReactPkg, ionicReactPkgPath ], + [ionicReactPkg, ionicReactPkgPath], ] = await Promise.all([ this.getPackageJson('@ionic/react'), ]); diff --git a/packages/@ionic/cli/src/lib/project/vue-vite/index.ts b/packages/@ionic/cli/src/lib/project/vue-vite/index.ts index 1364760629..9304bd7b7f 100755 --- a/packages/@ionic/cli/src/lib/project/vue-vite/index.ts +++ b/packages/@ionic/cli/src/lib/project/vue-vite/index.ts @@ -1,5 +1,5 @@ -import * as chalk from 'chalk'; -import * as Debug from 'debug'; +import chalk from 'chalk'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import * as path from 'path'; diff --git a/packages/@ionic/cli/src/lib/project/vue/index.ts b/packages/@ionic/cli/src/lib/project/vue/index.ts index 22f1da0d67..da584e1e50 100644 --- a/packages/@ionic/cli/src/lib/project/vue/index.ts +++ b/packages/@ionic/cli/src/lib/project/vue/index.ts @@ -1,5 +1,5 @@ -import * as chalk from 'chalk'; -import * as Debug from 'debug'; +import chalk from 'chalk'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import * as path from 'path'; diff --git a/packages/@ionic/cli/src/lib/serve.ts b/packages/@ionic/cli/src/lib/serve.ts index 4d6b362565..0e8ff5b6eb 100644 --- a/packages/@ionic/cli/src/lib/serve.ts +++ b/packages/@ionic/cli/src/lib/serve.ts @@ -4,11 +4,11 @@ import { PromptModule } from '@ionic/cli-framework-prompts'; import { str2num } from '@ionic/cli-framework/utils/string'; import { NetworkInterface, getExternalIPv4Interfaces, isHostConnectable } from '@ionic/utils-network'; import { createProcessEnv, killProcessTree, onBeforeExit, processExit } from '@ionic/utils-process'; -import * as chalk from 'chalk'; -import * as Debug from 'debug'; +import chalk from 'chalk'; +import { debug as Debug } from 'debug'; import { EventEmitter } from 'events'; import * as lodash from 'lodash'; -import * as split2 from 'split2'; +import split2 from 'split2'; import * as stream from 'stream'; import { CommandLineInputs, CommandLineOptions, CommandMetadata, CommandMetadataOption, IConfig, ILogger, IProject, IShell, IonicEnvironmentFlags, NpmClient, Runner, ServeDetails, ServeOptions } from '../definitions'; @@ -138,7 +138,7 @@ export abstract class ServeRunner implements Runner implements Runner extends EventEmitter { return; } - const [ pkg ] = await this.e.project.getPackageJson(undefined, { logErrors: false }); + const [pkg] = await this.e.project.getPackageJson(undefined, { logErrors: false }); if (!pkg) { return; @@ -557,7 +557,7 @@ export abstract class ServeCLI extends EventEmitter { protected async promptToInstall(): Promise { const { pkgManagerArgs } = await import('./utils/npm'); - const [ manager, ...managerArgs ] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'install', pkg: this.pkg, saveDev: true, saveExact: true }); + const [manager, ...managerArgs] = await pkgManagerArgs(this.e.config.get('npmClient'), { command: 'install', pkg: this.pkg, saveDev: true, saveExact: true }); this.e.log.nl(); @@ -600,7 +600,7 @@ abstract class PkgManagerServeCLI extends ServeCLI { }; const scriptArgs = [...unparseArgs(args), ...options['--'] || []]; - const [ , ...pkgArgs ] = await pkgManagerArgs(this.program, { command: 'run', script: this.script, scriptArgs }); + const [, ...pkgArgs] = await pkgManagerArgs(this.program, { command: 'run', script: this.script, scriptArgs }); return pkgArgs; } diff --git a/packages/@ionic/cli/src/lib/shell.ts b/packages/@ionic/cli/src/lib/shell.ts index d392ecf873..e4a60a01de 100644 --- a/packages/@ionic/cli/src/lib/shell.ts +++ b/packages/@ionic/cli/src/lib/shell.ts @@ -2,12 +2,12 @@ import { LOGGER_LEVELS } from '@ionic/cli-framework-output'; import { createProcessEnv, killProcessTree, onBeforeExit } from '@ionic/utils-process'; import { ERROR_COMMAND_NOT_FOUND, Subprocess, SubprocessError, SubprocessOptions, WhichOptions, which } from '@ionic/utils-subprocess'; import { TERMINAL_INFO } from '@ionic/utils-terminal'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; import { ChildProcess, SpawnOptions } from 'child_process'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as path from 'path'; -import * as split2 from 'split2'; -import * as combineStreams from 'stream-combiner2'; +import split2 from 'split2'; +import combineStreams from 'stream-combiner2'; import { ILogger, IShell, IShellOutputOptions, IShellRunOptions, IShellSpawnOptions } from '../definitions'; import { isExitCodeException } from '../guards'; diff --git a/packages/@ionic/cli/src/lib/telemetry.ts b/packages/@ionic/cli/src/lib/telemetry.ts index 02ee09a35d..3ae1703037 100644 --- a/packages/@ionic/cli/src/lib/telemetry.ts +++ b/packages/@ionic/cli/src/lib/telemetry.ts @@ -1,4 +1,4 @@ -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as lodash from 'lodash'; import { IClient, IConfig, IProject, ISession, ITelemetry, InfoItem, IonicContext } from '../definitions'; @@ -44,7 +44,7 @@ export class Telemetry implements ITelemetry { async function getLeek({ config, version }: { config: IConfig; version: string; }): Promise { if (!_gaTracker) { - const Leek = await import('leek'); + const Leek = (await import('leek')).default; let telemetryToken = config.get('tokens.telemetry'); if (!telemetryToken) { diff --git a/packages/@ionic/cli/src/lib/utils/http.ts b/packages/@ionic/cli/src/lib/utils/http.ts index 74ca72ed3c..2498d5f7e5 100644 --- a/packages/@ionic/cli/src/lib/utils/http.ts +++ b/packages/@ionic/cli/src/lib/utils/http.ts @@ -1,6 +1,8 @@ import { conform } from '@ionic/utils-array'; import { readFile } from '@ionic/utils-fs'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; + +import superagentProxy from './superagent-proxy'; import { CreateRequestOptions, HttpMethod } from '../../definitions'; @@ -21,7 +23,7 @@ function getGlobalProxy(): { envvar: string; envval: string; } | undefined { } export async function createRequest(method: HttpMethod, url: string, { userAgent, proxy, ssl }: CreateRequestOptions): Promise<{ req: SuperAgentRequest; }> { - const superagent = await import('superagent'); + const superagent = (await import('superagent')).default; if (!proxy) { const gproxy = getGlobalProxy(); @@ -31,14 +33,13 @@ export async function createRequest(method: HttpMethod, url: string, { userAgent } } - const req = superagent(method, url); + const req = superagent(method, url) as SuperAgentRequest & { proxy?: (uri: string) => void }; req .set('User-Agent', userAgent) .redirects(25); if (proxy) { - const superagentProxy = await import('superagent-proxy'); superagentProxy(superagent); if (req.proxy) { diff --git a/packages/@ionic/cli/src/lib/utils/logger.ts b/packages/@ionic/cli/src/lib/utils/logger.ts index 27d4807022..0fae1f193f 100644 --- a/packages/@ionic/cli/src/lib/utils/logger.ts +++ b/packages/@ionic/cli/src/lib/utils/logger.ts @@ -1,6 +1,6 @@ import { DEFAULT_COLORS } from '@ionic/cli-framework'; import { CreateTaggedFormatterOptions, DEFAULT_LOGGER_HANDLERS, LOGGER_LEVELS, Logger as BaseLogger, LoggerFormatter, LoggerLevelWeight, createPrefixedFormatter, createTaggedFormatter } from '@ionic/cli-framework-output'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; import { ILogger } from '../../definitions'; import { weak } from '../color'; diff --git a/packages/@ionic/cli/src/lib/utils/superagent-proxy.ts b/packages/@ionic/cli/src/lib/utils/superagent-proxy.ts new file mode 100644 index 0000000000..0991879819 --- /dev/null +++ b/packages/@ionic/cli/src/lib/utils/superagent-proxy.ts @@ -0,0 +1,119 @@ +import { ProxyAgent } from 'proxy-agent'; +import { debug as Debug } from 'debug'; +import { SuperAgent, SuperAgentRequest } from 'superagent'; + +const debug = Debug('superagent-proxy'); + +/** + * Adds a `.proxy(uri)` function to the "superagent" module's Request class. + * + * ``` js + * var request = require('superagent'); + * require('superagent-proxy')(request); + * + * request + * .get(uri) + * .proxy(uri) + * .end(fn); + * ``` + * + * Or, you can pass in a `superagent.Request` instance, and it's like calling the + * `.proxy(uri)` function on it, but without extending the prototype: + * + * ``` js + * var request = require('superagent'); + * var proxy = require('superagent-proxy'); + * + * proxy(request.get(uri), uri).end(fn); + * ``` + * + * @param {Object} superagent The `superagent` exports object + * @api public + */ + +export default function setup(superagent: any, uri?: string): SuperAgent & { proxy: (uri?: string) => SuperAgent } { + const Request = superagent.Request; + if (Request) { + // the superagent exports object - extent Request with "proxy" + Request.prototype.proxy = proxy; + return superagent; + } else { + // assume it's a `superagent.Request` instance + return proxy.call(superagent, uri); + } +} + +/** + * Sets the proxy server to use for this HTTP(s) request. + * + * @param {String} uri proxy url + * @api public + */ + +function proxy(this: any, uri?: string) { + debug('Request#proxy(%0)', uri); + // we need to observe the `url` field from now on... Superagent sometimes + // re-uses the `req` instance but changes its `url` field (i.e. in the case of + // a redirect), so when that happens we need to potentially re-set the proxy + // agent + setupUrl(this); + + // attempt to get a proxying `http.Agent` instance + const agent = new ProxyAgent(uri !== undefined ? { getProxyForUrl: () => uri } : {}); + + // if we have an `http.Agent` instance then call the .agent() function + if (agent) this.agent(agent); + + // store the proxy URI in case of changes to the `url` prop in the future + this._proxyUri = uri; + + return this; +} + +/** + * Sets up a get/set descriptor for the `url` property of the provided `req` + * Request instance. This is so that we can re-run the "proxy agent" logic when + * the `url` field is changed, i.e. during a 302 Redirect scenario. + * + * @api private + */ + +function setupUrl(req: any): void { + var desc = Object.getOwnPropertyDescriptor(req, 'url'); + if (desc?.get == getUrl && desc?.set == setUrl) return; // already patched + + // save current value + req._url = req.url; + + if (desc) { + desc.get = getUrl; + desc.set = setUrl; + delete desc.value; + delete desc.writable; + + Object.defineProperty(req, 'url', desc); + debug('patched superagent Request "url" property for changes'); + } +} + +/** + * `url` property getter. + * + * @api protected + */ + +function getUrl(this: any): string { + return this._url; +} + +/** + * `url` property setter. + * + * @api protected + */ + +function setUrl(this: any, v: string): void { + debug('set `.url`: %o', v); + this._url = v; + proxy.call(this, this._proxyUri); +} diff --git a/packages/@ionic/cli/tsconfig.json b/packages/@ionic/cli/tsconfig.json index 6d50be6c3d..85d3dba781 100644 --- a/packages/@ionic/cli/tsconfig.json +++ b/packages/@ionic/cli/tsconfig.json @@ -10,7 +10,6 @@ "../../../types/leek.d.ts", "../../../types/ssh-config.d.ts", "../../../types/stream-combiner2.d.ts", - "../../../types/superagent-proxy.d.ts", "src/**/*.ts" ], "exclude": [ diff --git a/packages/@ionic/discover/src/comm.ts b/packages/@ionic/discover/src/comm.ts index ddb2e08018..5fb3af0776 100644 --- a/packages/@ionic/discover/src/comm.ts +++ b/packages/@ionic/discover/src/comm.ts @@ -1,7 +1,8 @@ -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as events from 'events'; import * as util from 'util'; -import * as WebSocket from 'ws'; +import WebSocket from 'ws'; + const debug = Debug('ionic:discover:comm'); diff --git a/packages/@ionic/discover/src/publisher.ts b/packages/@ionic/discover/src/publisher.ts index 82058ba4df..d36f2b112d 100644 --- a/packages/@ionic/discover/src/publisher.ts +++ b/packages/@ionic/discover/src/publisher.ts @@ -1,4 +1,4 @@ -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as dgram from 'dgram'; import * as events from 'events'; import { Netmask } from 'netmask'; @@ -156,23 +156,23 @@ export function prepareInterfaces(interfaces: NodeJS.Dict prev?.concat(current ? current : [])); if (flatValues) { - return flatValues - .filter((iface: os.NetworkInterfaceInfo) => iface.family === 'IPv4') - .map((iface: os.NetworkInterfaceInfo) => { - return { - address: iface.address, - broadcast: computeBroadcastAddress(iface.address, iface.netmask), - }; - }) - .filter((iface: any) => { - if (!set.has(iface.broadcast)) { - set.add(iface.broadcast); - - return true; - } - - return false; - }); + return flatValues + .filter((iface: os.NetworkInterfaceInfo) => iface.family === 'IPv4') + .map((iface: os.NetworkInterfaceInfo) => { + return { + address: iface.address, + broadcast: computeBroadcastAddress(iface.address, iface.netmask), + }; + }) + .filter((iface: any) => { + if (!set.has(iface.broadcast)) { + set.add(iface.broadcast); + + return true; + } + + return false; + }); } } diff --git a/packages/@ionic/utils-network/src/index.ts b/packages/@ionic/utils-network/src/index.ts index 23b3898fe1..05554d7ae3 100644 --- a/packages/@ionic/utils-network/src/index.ts +++ b/packages/@ionic/utils-network/src/index.ts @@ -1,4 +1,4 @@ -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as net from 'net'; import * as os from 'os'; @@ -105,7 +105,7 @@ export function isPortAvailableForHost(host: string, port: number): Promise { resolve(true); // found available host/port }) - .close(); + .close(); }) .on('error', (err: any) => { reject(err); diff --git a/packages/@ionic/utils-process/src/index.ts b/packages/@ionic/utils-process/src/index.ts index 71cfd9ba93..51ae15768d 100644 --- a/packages/@ionic/utils-process/src/index.ts +++ b/packages/@ionic/utils-process/src/index.ts @@ -1,9 +1,9 @@ import { createCaseInsensitiveObject } from '@ionic/utils-object'; import { TERMINAL_INFO } from '@ionic/utils-terminal'; -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as pathlib from 'path'; -import * as onSignalExit from 'signal-exit'; -import * as kill from 'tree-kill'; +import onSignalExit from 'signal-exit'; +import treeKill from 'tree-kill'; const debug = Debug('ionic:utils-process'); @@ -11,7 +11,7 @@ export const ERROR_TIMEOUT_REACHED = new Error('TIMEOUT_REACHED'); export function killProcessTree(pid: number, signal: string | number = 'SIGTERM'): Promise { return new Promise((resolve, reject) => { - kill(pid, signal, err => { + treeKill(pid, signal, err => { if (err) { debug('error while killing process tree for %d: %O', pid, err); return reject(err); @@ -157,7 +157,7 @@ const BEFORE_EXIT_SIGNAL_LISTENERS: BeforeExitSignalListeners = { SIGBREAK: beforeExitHandlerWrapper('SIGBREAK'), }; -for (const [ signal, fn ] of Object.entries(BEFORE_EXIT_SIGNAL_LISTENERS)) { +for (const [signal, fn] of Object.entries(BEFORE_EXIT_SIGNAL_LISTENERS)) { process.on(signal as BeforeExitSignal, fn); } diff --git a/packages/@ionic/utils-subprocess/src/index.ts b/packages/@ionic/utils-subprocess/src/index.ts index 0ff8bb63bb..4488ab57fd 100644 --- a/packages/@ionic/utils-subprocess/src/index.ts +++ b/packages/@ionic/utils-subprocess/src/index.ts @@ -4,7 +4,7 @@ import { createProcessEnv, getPathParts } from '@ionic/utils-process'; import { WritableStreamBuffer } from '@ionic/utils-stream'; import { TERMINAL_INFO } from '@ionic/utils-terminal'; import { ChildProcess, ForkOptions, SpawnOptions, fork as _fork } from 'child_process'; -import * as crossSpawn from 'cross-spawn'; +import crossSpawn from 'cross-spawn'; import * as os from 'os'; import * as pathlib from 'path'; @@ -42,7 +42,7 @@ export class SubprocessError extends Error { exitCode?: number; } -export interface SubprocessOptions extends SpawnOptions {} +export interface SubprocessOptions extends SpawnOptions { } export interface SubprocessBashifyOptions { diff --git a/packages/@ionic/utils-terminal/src/cursor.ts b/packages/@ionic/utils-terminal/src/cursor.ts index bd369cd0f3..def0352baa 100644 --- a/packages/@ionic/utils-terminal/src/cursor.ts +++ b/packages/@ionic/utils-terminal/src/cursor.ts @@ -1,4 +1,4 @@ -import * as onExit from 'signal-exit'; +import onExit from 'signal-exit'; import { EscapeCode } from './ansi'; diff --git a/packages/@ionic/utils-terminal/src/info.ts b/packages/@ionic/utils-terminal/src/info.ts index 688eb2a1f3..7230db5bdf 100644 --- a/packages/@ionic/utils-terminal/src/info.ts +++ b/packages/@ionic/utils-terminal/src/info.ts @@ -1,4 +1,4 @@ -import * as Debug from 'debug'; +import { debug as Debug } from 'debug'; import * as os from 'os'; const debug = Debug('ionic:utils-terminal:info'); diff --git a/packages/cli-scripts/src/docs/index.ts b/packages/cli-scripts/src/docs/index.ts index 7c803d0a60..dbcf12c72e 100644 --- a/packages/cli-scripts/src/docs/index.ts +++ b/packages/cli-scripts/src/docs/index.ts @@ -3,7 +3,7 @@ import { Command, CommandHelpSchemaFootnote, CommandHelpSchemaInput, CommandHelp import { strcmp } from '@ionic/cli-framework/utils/string'; import { CommandHelpSchema, NamespaceSchemaHelpFormatter } from '@ionic/cli/lib/help'; import { mkdirp, remove, writeFile } from '@ionic/utils-fs'; -import * as chalk from 'chalk'; +import chalk from 'chalk'; import * as lodash from 'lodash'; import * as path from 'path'; import stripAnsi = require('strip-ansi'); diff --git a/packages/cli-scripts/src/docs/utils.ts b/packages/cli-scripts/src/docs/utils.ts index c37b65c0e2..6f4247338d 100644 --- a/packages/cli-scripts/src/docs/utils.ts +++ b/packages/cli-scripts/src/docs/utils.ts @@ -1,7 +1,7 @@ import { Colors } from '@ionic/cli-framework'; import { COLORS } from '@ionic/cli/lib/color'; -import * as chalk from 'chalk'; -import * as escapeStringRegexp from 'escape-string-regexp'; +import chalk from 'chalk'; +import escapeStringRegexp from 'escape-string-regexp'; interface CodePair { open: string; @@ -36,7 +36,7 @@ export function convertHTMLEntities(str: string): string { function convertAnsiToMd(str: string, styles: readonly CodePair[], md: CodePair): string { const start = styles.map(style => style.open).join(''); const end = [...styles].reverse().map(style => style.close).join(''); - const re = new RegExp(escapeStringRegexp(start) + '(.*?)' + escapeStringRegexp(end) , 'g'); + const re = new RegExp(escapeStringRegexp(start) + '(.*?)' + escapeStringRegexp(end), 'g'); return str.replace(re, md.open + '$1' + md.close); } diff --git a/tsconfig.base.json b/tsconfig.base.json index 282786c623..d13a4a9107 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -6,14 +6,12 @@ "module": "commonjs", "moduleResolution": "node", "noFallthroughCasesInSwitch": true, + "esModuleInterop": true, "noUnusedLocals": true, "pretty": true, "strict": true, "target": "ES2021", "types": [], - "lib": [ - "ES2021", - "ES2022.Error" - ] + "lib": ["ES2021", "ES2022.Error"] } }