diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f08d69c90d..091b57d8e3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,6 +55,35 @@ jobs: - name: Test run: npm test + lint: + name: Lint & Format + runs-on: ubuntu-latest + + steps: + + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 + with: + egress-policy: audit + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: '24.x' + cache: 'npm' + + - name: Install + run: npm ci --ignore-scripts + + - name: Lint + run: npm run lint + + - name: Check formatting + run: npm run format.check + doctor: name: Doctor (Node ${{ matrix.node-version }}) runs-on: ubuntu-latest diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 0000000000..4c9b5aa384 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,12 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "useTabs": true, + "printWidth": 80, + "sortPackageJson": false, + "ignorePatterns": [ + "lib/common/test/resources/**", + "lib/common/vendor/**", + "lib/common/bin/**", + "test/files/**" + ] +} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 0000000000..0c3bcff1cf --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,49 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "ignorePatterns": [ + "lib/common/test/resources/**", + "lib/common/vendor/**", + "lib/common/bin/**", + "test/files/**", + "vendor/**", + "resources/**", + "packages/**", + "docs/**", + "docs-cli/**" + ], + "rules": { + "no-unused-vars": [ + "warn", + { + "args": "none", + "caughtErrors": "none", + "varsIgnorePattern": "^_", + "ignoreRestSiblings": true + } + ], + "eqeqeq": ["error", "always", { "null": "ignore" }], + "no-debugger": "error", + "no-eval": "error", + "no-var": "error", + "prefer-const": [ + "error", + { "destructuring": "all", "ignoreReadBeforeAssign": true } + ], + "no-new-wrappers": "error", + "no-redeclare": "error", + "no-unused-expressions": [ + "error", + { "allowShortCircuit": true, "allowTernary": true } + ], + "no-empty": "warn", + "no-fallthrough": "error" + }, + "overrides": [ + { + "files": ["**/*.d.ts"], + "rules": { + "no-var": "off" + } + } + ] +} diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index 3c53558cd9..0000000000 --- a/.prettierrc.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "useTabs": true, - "overrides": [ - { - "files": "*.json", - "options": { - "useTabs": false - } - } - ] -} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c850110d71..3ec5bcc560 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,9 +50,10 @@ Before you submit a Pull Request, consider the following guidelines. ```bash npm test ``` -* Ensure that your code is formatted. +* Ensure that your code is formatted and lints cleanly. ```bash - npm run prettier + npm run format + npm run lint ``` * Commit your changes following the [commit message guidelines](https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#-commit-message-guidelines) (the commit message is used to generate release notes). ```bash diff --git a/lib/android-tools-info.ts b/lib/android-tools-info.ts index 5ceb095968..22a67f003d 100644 --- a/lib/android-tools-info.ts +++ b/lib/android-tools-info.ts @@ -17,7 +17,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { private $errors: IErrors, private $logger: ILogger, private $options: IOptions, - protected $staticConfig: Config.IStaticConfig + protected $staticConfig: Config.IStaticConfig, ) {} @cache() @@ -29,18 +29,18 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { infoData.androidHomeEnvVar = androidToolsInfo.androidHome; infoData.compileSdkVersion = this.getCompileSdkVersion( infoData.installedTargets, - infoData.compileSdkVersion + infoData.compileSdkVersion, ); infoData.targetSdkVersion = this.getTargetSdk(infoData.compileSdkVersion); infoData.generateTypings = this.shouldGenerateTypings(); this.$logger.trace( "Installed Android Targets are: ", - infoData.installedTargets + infoData.installedTargets, ); this.$logger.trace( "Selected buildToolsVersion is:", - infoData.buildToolsVersion + infoData.buildToolsVersion, ); return infoData; @@ -55,7 +55,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { androidToolsInfo .validateInfo({ projectDir: options.projectDir }) .map((warning) => - this.printMessage(warning.warning, showWarningsAsErrors) + this.printMessage(warning.warning, showWarningsAsErrors), ).length > 0; if (options && options.validateTargetSdk) { @@ -78,7 +78,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { projectDir: options.projectDir, }) .map((warning) => - this.printMessage(warning.warning, options.showWarningsAsErrors) + this.printMessage(warning.warning, options.showWarningsAsErrors), ).length > 0; if (!detectedErrors) { @@ -95,7 +95,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { public validateJavacVersion( installedJavacVersion: string, - options?: IAndroidToolsInfoOptions + options?: IAndroidToolsInfoOptions, ): boolean { const showWarningsAsErrors = options && options.showWarningsAsErrors; @@ -103,7 +103,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { androidToolsInfo .validateJavacVersion(installedJavacVersion) .map((warning) => - this.printMessage(warning.warning, showWarningsAsErrors) + this.printMessage(warning.warning, showWarningsAsErrors), ).length > 0 ); } @@ -118,8 +118,8 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { `Error while executing '${path.join( androidToolsInfo.androidHome, "platform-tools", - "adb" - )} help'. Error is: ${err.message}` + "adb", + )} help'. Error is: ${err.message}`, ); } @@ -128,7 +128,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { @cache() public validateAndroidHomeEnvVariable( - options?: IAndroidToolsInfoOptions + options?: IAndroidToolsInfoOptions, ): boolean { const showWarningsAsErrors = options && options.showWarningsAsErrors; @@ -136,7 +136,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { androidToolsInfo .validateAndroidHomeEnvVariable() .map((warning) => - this.printMessage(warning.warning, showWarningsAsErrors) + this.printMessage(warning.warning, showWarningsAsErrors), ).length > 0 ); } @@ -163,7 +163,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { private getCompileSdkVersion( installedTargets: string[], - latestCompileSdk: number + latestCompileSdk: number, ): number { const userSpecifiedCompileSdk = this.$options.compileSdk; @@ -171,7 +171,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { const androidCompileSdk = `${androidToolsInfo.ANDROID_TARGET_PREFIX}-${userSpecifiedCompileSdk}`; if (!_.includes(installedTargets, androidCompileSdk)) { this.$errors.fail( - `You have specified '${userSpecifiedCompileSdk}' for compile sdk, but it is not installed on your system.` + `You have specified '${userSpecifiedCompileSdk}' for compile sdk, but it is not installed on your system.`, ); } diff --git a/lib/base-package-manager.ts b/lib/base-package-manager.ts index 12b24df7d1..99fe6c11d3 100644 --- a/lib/base-package-manager.ts +++ b/lib/base-package-manager.ts @@ -17,17 +17,17 @@ export abstract class BasePackageManager implements INodePackageManager { public abstract install( packageName: string, pathToSave: string, - config: INodePackageManagerInstallOptions + config: INodePackageManagerInstallOptions, ): Promise; public abstract uninstall( packageName: string, config?: IDictionary, - path?: string + path?: string, ): Promise; - public abstract view(packageName: string, config: Object): Promise; + public abstract view(packageName: string, config: object): Promise; public abstract search( filter: string[], - config: IDictionary + config: IDictionary, ): Promise; public abstract searchNpms(keyword: string): Promise; public abstract getRegistryPackageData(packageName: string): Promise; @@ -38,7 +38,7 @@ export abstract class BasePackageManager implements INodePackageManager { protected $fs: IFileSystem, private $hostInfo: IHostInfo, private $pacoteService: IPacoteService, - private packageManager: string + private packageManager: string, ) {} public async isRegistered(packageName: string): Promise { @@ -65,7 +65,7 @@ export abstract class BasePackageManager implements INodePackageManager { } public async getPackageNameParts( - fullPackageName: string + fullPackageName: string, ): Promise { // support @ syntax, for example typescript@1.0.0 // support @ syntax, for example @nativescript/vue-template@1.0.0 @@ -84,7 +84,7 @@ export abstract class BasePackageManager implements INodePackageManager { } public async getPackageFullName( - packageNameParts: INpmPackageNameParts + packageNameParts: INpmPackageNameParts, ): Promise { return packageNameParts.version ? `${packageNameParts.name}@${packageNameParts.version}` @@ -104,7 +104,7 @@ export abstract class BasePackageManager implements INodePackageManager { protected async processPackageManagerInstall( packageName: string, params: string[], - opts: { cwd: string; isInstallingAllDependencies: boolean } + opts: { cwd: string; isInstallingAllDependencies: boolean }, ): Promise { const npmExecutable = this.getPackageManagerExecutableName(); const stdioValue = isInteractive() ? "inherit" : "pipe"; diff --git a/lib/bun-package-manager.ts b/lib/bun-package-manager.ts index cfd5ffc057..d93878b0d1 100644 --- a/lib/bun-package-manager.ts +++ b/lib/bun-package-manager.ts @@ -25,7 +25,7 @@ export class BunPackageManager extends BasePackageManager { $hostInfo: IHostInfo, private $logger: ILogger, private $httpClient: Server.IHttpClient, - $pacoteService: IPacoteService + $pacoteService: IPacoteService, ) { super($childProcess, $fs, $hostInfo, $pacoteService, "bun"); } @@ -34,7 +34,7 @@ export class BunPackageManager extends BasePackageManager { public async install( packageName: string, pathToSave: string, - config: INodePackageManagerInstallOptions + config: INodePackageManagerInstallOptions, ): Promise { if (config.disableNpmInstall) { return; @@ -60,7 +60,7 @@ export class BunPackageManager extends BasePackageManager { const result = await this.processPackageManagerInstall( packageName, params, - { cwd, isInstallingAllDependencies } + { cwd, isInstallingAllDependencies }, ); return result; } catch (err) { @@ -74,7 +74,7 @@ export class BunPackageManager extends BasePackageManager { public async uninstall( packageName: string, config?: any, - cwd?: string + cwd?: string, ): Promise { const flags = this.getFlagsString(config, false); return this.$childProcess.exec(`bun remove ${packageName} ${flags}`, { @@ -84,14 +84,14 @@ export class BunPackageManager extends BasePackageManager { // Bun does not have a `view` command; use npm. @exported("bun") - public async view(packageName: string, config: Object): Promise { + public async view(packageName: string, config: object): Promise { const wrappedConfig = _.extend({}, config, { json: true }); // always require view response as JSON const flags = this.getFlagsString(wrappedConfig, false); let viewResult: any; try { viewResult = await this.$childProcess.exec( - `npm view ${packageName} ${flags}` + `npm view ${packageName} ${flags}`, ); } catch (e) { this.$errors.fail(e.message); @@ -119,7 +119,7 @@ export class BunPackageManager extends BasePackageManager { // https://github.com/npms-io/npms-api/issues/112. Better to switch to // https://registry.npmjs.org/ const httpRequestResult = await this.$httpClient.httpRequest( - `https://api.npms.io/v2/search?q=keywords:${keyword}` + `https://api.npms.io/v2/search?q=keywords:${keyword}`, ); const result: INpmsResult = JSON.parse(httpRequestResult.body); return result; @@ -132,15 +132,15 @@ export class BunPackageManager extends BasePackageManager { const registry = await this.$childProcess.exec(`npm config get registry`); const url = registry.trim() + packageName; this.$logger.trace( - `Trying to get data from npm registry for package ${packageName}, url is: ${url}` + `Trying to get data from npm registry for package ${packageName}, url is: ${url}`, ); const responseData = (await this.$httpClient.httpRequest(url)).body; this.$logger.trace( - `Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}` + `Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}`, ); const jsonData = JSON.parse(responseData); this.$logger.trace( - `Successfully parsed data from npm registry for package ${packageName}.` + `Successfully parsed data from npm registry for package ${packageName}.`, ); return jsonData; } diff --git a/lib/commands/add-platform.ts b/lib/commands/add-platform.ts index fdf6b93eb4..2c840858ab 100644 --- a/lib/commands/add-platform.ts +++ b/lib/commands/add-platform.ts @@ -22,13 +22,13 @@ export class AddPlatformCommand $platformValidationService: IPlatformValidationService, $projectData: IProjectData, $platformsDataService: IPlatformsDataService, - private $errors: IErrors + private $errors: IErrors, ) { super( $options, $platformsDataService, $platformValidationService, - $projectData + $projectData, ); this.$projectData.initializeProjectData(); } @@ -37,14 +37,14 @@ export class AddPlatformCommand await this.$platformCommandHelper.addPlatforms( args, this.$projectData, - this.$options.frameworkPath + this.$options.frameworkPath, ); } public async canExecute(args: string[]): Promise { if (!args || args.length === 0) { this.$errors.failWithHelp( - "No platform specified. Please specify a platform to add." + "No platform specified. Please specify a platform to add.", ); } @@ -55,11 +55,11 @@ export class AddPlatformCommand if ( !this.$platformValidationService.isPlatformSupportedForOS( arg, - this.$projectData + this.$projectData, ) ) { this.$errors.fail( - `Applications for platform ${arg} cannot be built on this OS` + `Applications for platform ${arg} cannot be built on this OS`, ); } diff --git a/lib/commands/apple-login.ts b/lib/commands/apple-login.ts index c6e45c5326..7cb6b71376 100644 --- a/lib/commands/apple-login.ts +++ b/lib/commands/apple-login.ts @@ -16,7 +16,7 @@ export class AppleLogin implements ICommand { private $errors: IErrors, private $injector: IInjector, private $logger: ILogger, - private $prompter: IPrompter + private $prompter: IPrompter, ) {} public async execute(args: string[]): Promise { @@ -38,7 +38,7 @@ export class AppleLogin implements ICommand { }); if (!user.areCredentialsValid) { this.$errors.fail( - `Invalid username and password combination. Used '${username}' as the username.` + `Invalid username and password combination. Used '${username}' as the username.`, ); } diff --git a/lib/commands/appstore-list.ts b/lib/commands/appstore-list.ts index 910d038b57..b526b0f591 100644 --- a/lib/commands/appstore-list.ts +++ b/lib/commands/appstore-list.ts @@ -27,7 +27,7 @@ export class ListiOSApps implements ICommand { private $platformValidationService: IPlatformValidationService, private $errors: IErrors, private $prompter: IPrompter, - private $options: IOptions + private $options: IOptions, ) { this.$projectData.initializeProjectData(); } @@ -36,11 +36,11 @@ export class ListiOSApps implements ICommand { if ( !this.$platformValidationService.isPlatformSupportedForOS( this.$devicePlatformsConstants.iOS, - this.$projectData + this.$projectData, ) ) { this.$errors.fail( - `Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS` + `Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`, ); } @@ -61,17 +61,16 @@ export class ListiOSApps implements ICommand { { username, password }, { sessionBase64: this.$options.appleSessionBase64, - } + }, ); if (!user.areCredentialsValid) { this.$errors.fail( - `Invalid username and password combination. Used '${username}' as the username.` + `Invalid username and password combination. Used '${username}' as the username.`, ); } - const applications = await this.$applePortalApplicationService.getApplications( - user - ); + const applications = + await this.$applePortalApplicationService.getApplications(user); if (!applications || !applications.length) { this.$logger.info("Seems you don't have any applications yet."); @@ -87,7 +86,7 @@ export class ListiOSApps implements ICommand { application.versionSets[0].inFlightVersion.version) || ""; return [application.name, application.bundleId, version]; - }) + }), ); this.$logger.info(table.toString()); diff --git a/lib/commands/appstore-upload.ts b/lib/commands/appstore-upload.ts index 1d80a11715..3a891aa8a5 100644 --- a/lib/commands/appstore-upload.ts +++ b/lib/commands/appstore-upload.ts @@ -34,14 +34,14 @@ export class PublishIOS implements ICommand { private $hostInfo: IHostInfo, private $errors: IErrors, private $buildController: BuildController, - private $platformValidationService: IPlatformValidationService + private $platformValidationService: IPlatformValidationService, ) { this.$projectData.initializeProjectData(); } public async execute(args: string[]): Promise { await this.$itmsTransporterService.validate( - this.$options.appleApplicationSpecificPassword + this.$options.appleApplicationSpecificPassword, ); const username = @@ -59,11 +59,11 @@ export class PublishIOS implements ICommand { sessionBase64: this.$options.appleSessionBase64, requireInteractiveConsole: true, requireApplicationSpecificPassword: true, - } + }, ); if (!user.areCredentialsValid) { this.$errors.fail( - `Invalid username and password combination. Used '${username}' as the username.` + `Invalid username and password combination. Used '${username}' as the username.`, ); } @@ -75,7 +75,7 @@ export class PublishIOS implements ICommand { if (!mobileProvisionIdentifier && !ipaFilePath) { this.$logger.warn( - "No mobile provision identifier set. A default mobile provision will be used. You can set one in app/App_Resources/iOS/build.xcconfig" + "No mobile provision identifier set. A default mobile provision will be used. You can set one in app/App_Resources/iOS/build.xcconfig", ); } @@ -88,7 +88,7 @@ export class PublishIOS implements ICommand { // This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here. this.$logger.info( "Building .ipa with the selected mobile provision and/or certificate. " + - mobileProvisionIdentifier + mobileProvisionIdentifier, ); this.$options.provision = mobileProvisionIdentifier; @@ -96,17 +96,17 @@ export class PublishIOS implements ICommand { const buildData = new IOSBuildData( this.$projectData.projectDir, platform, - { ...this.$options.argv, buildForAppStore: true, watch: false } + { ...this.$options.argv, buildForAppStore: true, watch: false }, ); ipaFilePath = await this.$buildController.prepareAndBuild(buildData); } else { this.$logger.info( - "No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission." + "No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission.", ); const buildData = new IOSBuildData( this.$projectData.projectDir, platform, - { ...this.$options.argv, buildForAppStore: true, watch: false } + { ...this.$options.argv, buildForAppStore: true, watch: false }, ); ipaFilePath = await this.$buildController.prepareAndBuild(buildData); this.$logger.info(`Export at: ${ipaFilePath}`); @@ -133,11 +133,11 @@ export class PublishIOS implements ICommand { if ( !this.$platformValidationService.isPlatformSupportedForOS( this.$devicePlatformsConstants.iOS, - this.$projectData + this.$projectData, ) ) { this.$errors.fail( - `Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS` + `Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`, ); } diff --git a/lib/commands/clean.ts b/lib/commands/clean.ts index 62a00bf8ce..26b14508e1 100644 --- a/lib/commands/clean.ts +++ b/lib/commands/clean.ts @@ -273,7 +273,7 @@ export class CleanCommand implements ICommand { ); spinner.warn(`This action cannot be undone!`); - let confirmed = await this.$prompter.confirm( + const confirmed = await this.$prompter.confirm( "Are you sure you want to clean the selected projects?", ); if (!confirmed) { @@ -337,7 +337,7 @@ export class CleanCommand implements ICommand { private async getNSProjectPathsInDirectory( dir = process.cwd(), ): Promise { - let nsDirs: string[] = []; + const nsDirs: string[] = []; const getFiles = async (dir: string) => { if (dir.includes("node_modules")) { diff --git a/lib/commands/command-base.ts b/lib/commands/command-base.ts index 0f4e1f834c..2a5143931d 100644 --- a/lib/commands/command-base.ts +++ b/lib/commands/command-base.ts @@ -12,7 +12,7 @@ export abstract class ValidatePlatformCommandBase { protected $options: IOptions, protected $platformsDataService: IPlatformsDataService, protected $platformValidationService: IPlatformValidationService, - protected $projectData: IProjectData + protected $projectData: IProjectData, ) {} abstract allowedParameters: ICommandParameter[]; @@ -20,12 +20,12 @@ export abstract class ValidatePlatformCommandBase { public async canExecuteCommandBase( platform: string, - options?: ICanExecuteCommandOptions + options?: ICanExecuteCommandOptions, ): Promise { options = options || {}; const validatePlatformOutput = await this.validatePlatformBase( platform, - options.notConfiguredEnvOptions + options.notConfiguredEnvOptions, ); const canExecute = this.canExecuteCommand(validatePlatformOutput); let result = canExecute; @@ -35,7 +35,7 @@ export abstract class ValidatePlatformCommandBase { this.$options.provision, this.$options.teamId, this.$projectData, - platform + platform, ); } @@ -44,23 +44,23 @@ export abstract class ValidatePlatformCommandBase { private async validatePlatformBase( platform: string, - notConfiguredEnvOptions: INotConfiguredEnvOptions + notConfiguredEnvOptions: INotConfiguredEnvOptions, ): Promise { const platformData = this.$platformsDataService.getPlatformData( platform, - this.$projectData + this.$projectData, ); const platformProjectService = platformData.platformProjectService; const result = await platformProjectService.validate( this.$projectData, this.$options, - notConfiguredEnvOptions + notConfiguredEnvOptions, ); return result; } private canExecuteCommand( - validatePlatformOutput: IValidatePlatformOutput + validatePlatformOutput: IValidatePlatformOutput, ): boolean { return ( validatePlatformOutput && diff --git a/lib/commands/config.ts b/lib/commands/config.ts index a37506bf47..a96c38eb0d 100644 --- a/lib/commands/config.ts +++ b/lib/commands/config.ts @@ -38,7 +38,9 @@ export class ConfigListCommand implements ICommand { .join("\n") ); } else { - return color.yellow(typeof value === 'undefined' ? 'undefined' : value.toString()); + return color.yellow( + typeof value === "undefined" ? "undefined" : value.toString(), + ); } } } diff --git a/lib/commands/create-project.ts b/lib/commands/create-project.ts index c817d1e188..64f952f77d 100644 --- a/lib/commands/create-project.ts +++ b/lib/commands/create-project.ts @@ -35,7 +35,7 @@ export class CreateProjectCommand implements ICommand { private $errors: IErrors, private $options: IOptions, private $prompter: IPrompter, - private $stringParameter: ICommandParameter + private $stringParameter: ICommandParameter, ) {} public async execute(args: string[]): Promise { @@ -55,7 +55,7 @@ export class CreateProjectCommand implements ICommand { this.$options.template ) { this.$errors.failWithHelp( - "You cannot use a flavor option like --ng, --vue, --react, --solid, --svelte, --tsc and --js together with --template." + "You cannot use a flavor option like --ng, --vue, --react, --solid, --svelte, --tsc and --js together with --template.", ); } @@ -115,7 +115,7 @@ export class CreateProjectCommand implements ICommand { this.printInteractiveCreationIntroIfNeeded(); projectName = await this.$prompter.getString( `${getNextInteractiveAdverb()}, what will be the name of your app?`, - { allowEmpty: false } + { allowEmpty: false }, ); this.$logger.info(); } @@ -130,7 +130,7 @@ export class CreateProjectCommand implements ICommand { this.printInteractiveCreationIntroIfNeeded(); selectedTemplate = await this.interactiveFlavorAndTemplateSelection( getNextInteractiveAdverb(), - getNextInteractiveAdverb() + getNextInteractiveAdverb(), ); } @@ -147,12 +147,12 @@ export class CreateProjectCommand implements ICommand { private async interactiveFlavorAndTemplateSelection( flavorAdverb: string, - templateAdverb: string + templateAdverb: string, ) { const selectedFlavor = await this.interactiveFlavorSelection(flavorAdverb); const selectedTemplate: string = await this.interactiveTemplateSelection( selectedFlavor, - templateAdverb + templateAdverb, ); return selectedTemplate; @@ -191,7 +191,7 @@ export class CreateProjectCommand implements ICommand { key: constants.JsFlavorName, description: "Use NativeScript without any framework", }, - ] + ], ); return flavorSelection; } @@ -210,7 +210,7 @@ can skip this prompt next time using the --template option, or using --ng, --rea private async interactiveTemplateSelection( flavorSelection: string, - adverb: string + adverb: string, ) { const selectedFlavorTemplates: { key?: string; @@ -255,10 +255,10 @@ can skip this prompt next time using the --template option, or using --ng, --rea }); const selectedTemplateKey = await this.$prompter.promptForDetailedChoice( `${adverb}, which template would you like to start from:`, - templateChoices + templateChoices, ); selectedTemplate = selectedFlavorTemplates.find( - (t) => t.key === selectedTemplateKey + (t) => t.key === selectedTemplateKey, ).value; } else { selectedTemplate = selectedFlavorTemplates[0].value; @@ -472,14 +472,14 @@ can skip this prompt next time using the --template option, or using --ng, --rea ].join(" "), "", `Now you can navigate to your project with ${color.cyan( - `cd ${relativePath}` + `cd ${relativePath}`, )} and then:`, "", ...runDebugNotes, ``, `For more options consult the docs or run ${color.green("ns --help")}`, "", - ].join("\n") + ].join("\n"), ); // todo: add back ns preview // this.$logger.printMarkdown( diff --git a/lib/commands/extensibility/install-extension.ts b/lib/commands/extensibility/install-extension.ts index 55c1718551..87f57d7de6 100644 --- a/lib/commands/extensibility/install-extension.ts +++ b/lib/commands/extensibility/install-extension.ts @@ -10,26 +10,26 @@ export class InstallExtensionCommand implements ICommand { constructor( private $extensibilityService: IExtensibilityService, private $stringParameterBuilder: IStringParameterBuilder, - private $logger: ILogger + private $logger: ILogger, ) {} public async execute(args: string[]): Promise { const extensionData = await this.$extensibilityService.installExtension( - args[0] + args[0], ); this.$logger.info( - `Successfully installed extension ${extensionData.extensionName}.` + `Successfully installed extension ${extensionData.extensionName}.`, ); await this.$extensibilityService.loadExtension(extensionData.extensionName); this.$logger.info( - `Successfully loaded extension ${extensionData.extensionName}.` + `Successfully loaded extension ${extensionData.extensionName}.`, ); } allowedParameters: ICommandParameter[] = [ this.$stringParameterBuilder.createMandatoryParameter( - "You have to provide a valid name for extension that you want to install." + "You have to provide a valid name for extension that you want to install.", ), ]; } diff --git a/lib/commands/extensibility/list-extensions.ts b/lib/commands/extensibility/list-extensions.ts index b25ab89dfc..3dde5497ea 100644 --- a/lib/commands/extensibility/list-extensions.ts +++ b/lib/commands/extensibility/list-extensions.ts @@ -7,11 +7,12 @@ import { IExtensibilityService } from "../../common/definitions/extensibility"; export class ListExtensionsCommand implements ICommand { constructor( private $extensibilityService: IExtensibilityService, - private $logger: ILogger + private $logger: ILogger, ) {} public async execute(args: string[]): Promise { - const installedExtensions = this.$extensibilityService.getInstalledExtensions(); + const installedExtensions = + this.$extensibilityService.getInstalledExtensions(); if (_.keys(installedExtensions).length) { this.$logger.info("Installed extensions:"); const data = _.map(installedExtensions, (version, name) => { diff --git a/lib/commands/extensibility/uninstall-extension.ts b/lib/commands/extensibility/uninstall-extension.ts index cea51bc26d..83e06206aa 100644 --- a/lib/commands/extensibility/uninstall-extension.ts +++ b/lib/commands/extensibility/uninstall-extension.ts @@ -10,7 +10,7 @@ export class UninstallExtensionCommand implements ICommand { constructor( private $extensibilityService: IExtensibilityService, private $stringParameterBuilder: IStringParameterBuilder, - private $logger: ILogger + private $logger: ILogger, ) {} public async execute(args: string[]): Promise { @@ -21,7 +21,7 @@ export class UninstallExtensionCommand implements ICommand { allowedParameters: ICommandParameter[] = [ this.$stringParameterBuilder.createMandatoryParameter( - "You have to provide a valid name for extension that you want to uninstall." + "You have to provide a valid name for extension that you want to uninstall.", ), ]; } diff --git a/lib/commands/fonts.ts b/lib/commands/fonts.ts index bcdf0a996e..cffd5f2a6c 100644 --- a/lib/commands/fonts.ts +++ b/lib/commands/fonts.ts @@ -14,7 +14,7 @@ export class FontsCommand implements ICommand { private $projectData: IProjectData, private $fs: IFileSystem, private $logger: ILogger, - private $projectConfigService: IProjectConfigService + private $projectConfigService: IProjectConfigService, ) { this.$projectData.initializeProjectData(); } @@ -25,14 +25,14 @@ export class FontsCommand implements ICommand { const defaultFontsFolderPaths = [ path.join( this.$projectConfigService.getValue("appPath") ?? "", - constants.FONTS_DIR + constants.FONTS_DIR, ), path.join(constants.APP_FOLDER_NAME, constants.FONTS_DIR), path.join(constants.SRC_DIR, constants.FONTS_DIR), ].map((entry) => path.resolve(this.$projectData.projectDir, entry)); const fontsFolderPath = defaultFontsFolderPaths.find((entry) => - this.$fs.exists(entry) + this.$fs.exists(entry), ); if (!fontsFolderPath) { diff --git a/lib/commands/generate-assets.ts b/lib/commands/generate-assets.ts index 5133cea3e0..f97f6673dc 100644 --- a/lib/commands/generate-assets.ts +++ b/lib/commands/generate-assets.ts @@ -11,7 +11,7 @@ import { injector } from "../common/yok"; export abstract class GenerateCommandBase implements ICommand { public allowedParameters: ICommandParameter[] = [ this.$stringParameterBuilder.createMandatoryParameter( - "You have to provide path to image to generate other images based on it." + "You have to provide path to image to generate other images based on it.", ), ]; @@ -20,7 +20,7 @@ export abstract class GenerateCommandBase implements ICommand { protected $injector: IInjector, protected $projectData: IProjectData, protected $stringParameterBuilder: IStringParameterBuilder, - protected $assetsGenerationService: IAssetsGenerationService + protected $assetsGenerationService: IAssetsGenerationService, ) { this.$projectData.initializeProjectData(); } @@ -32,32 +32,33 @@ export abstract class GenerateCommandBase implements ICommand { protected abstract generate( imagePath: string, - background?: string + background?: string, ): Promise; } export class GenerateIconsCommand extends GenerateCommandBase - implements ICommand { + implements ICommand +{ constructor( protected $options: IOptions, $injector: IInjector, protected $projectData: IProjectData, protected $stringParameterBuilder: IStringParameterBuilder, - $assetsGenerationService: IAssetsGenerationService + $assetsGenerationService: IAssetsGenerationService, ) { super( $options, $injector, $projectData, $stringParameterBuilder, - $assetsGenerationService + $assetsGenerationService, ); } protected async generate( imagePath: string, - background?: string + background?: string, ): Promise { await this.$assetsGenerationService.generateIcons({ imagePath, @@ -71,26 +72,27 @@ injector.registerCommand("resources|generate|icons", GenerateIconsCommand); export class GenerateSplashScreensCommand extends GenerateCommandBase - implements ICommand { + implements ICommand +{ constructor( protected $options: IOptions, $injector: IInjector, protected $projectData: IProjectData, protected $stringParameterBuilder: IStringParameterBuilder, - $assetsGenerationService: IAssetsGenerationService + $assetsGenerationService: IAssetsGenerationService, ) { super( $options, $injector, $projectData, $stringParameterBuilder, - $assetsGenerationService + $assetsGenerationService, ); } protected async generate( imagePath: string, - background?: string + background?: string, ): Promise { await this.$assetsGenerationService.generateSplashScreens({ imagePath, @@ -102,5 +104,5 @@ export class GenerateSplashScreensCommand injector.registerCommand( "resources|generate|splashes", - GenerateSplashScreensCommand + GenerateSplashScreensCommand, ); diff --git a/lib/commands/install.ts b/lib/commands/install.ts index 32de375055..ad91a1d38d 100644 --- a/lib/commands/install.ts +++ b/lib/commands/install.ts @@ -27,7 +27,7 @@ export class InstallCommand implements ICommand { private $logger: ILogger, private $fs: IFileSystem, private $stringParameter: ICommandParameter, - private $packageManager: INodePackageManager + private $packageManager: INodePackageManager, ) { this.$projectData.initializeProjectData(); } @@ -42,30 +42,30 @@ export class InstallCommand implements ICommand { let error: string = ""; await this.$pluginsService.ensureAllDependenciesAreInstalled( - this.$projectData + this.$projectData, ); for (const platform of this.$mobileHelper.platformNames) { const platformData = this.$platformsDataService.getPlatformData( platform, - this.$projectData + this.$projectData, ); const frameworkPackageData = this.$projectDataService.getRuntimePackage( this.$projectData.projectDir, - platformData.platformNameLowerCase + platformData.platformNameLowerCase, ); if (frameworkPackageData && frameworkPackageData.version) { try { const platformProjectService = platformData.platformProjectService; await platformProjectService.validate( this.$projectData, - this.$options + this.$options, ); await this.$platformCommandHelper.addPlatforms( [`${platform}@${frameworkPackageData.version}`], this.$projectData, - this.$options.frameworkPath + this.$options.frameworkPath, ); } catch (err) { error = `${error}${EOL}${err}`; diff --git a/lib/commands/list-platforms.ts b/lib/commands/list-platforms.ts index 83c56e443c..b78081b9b9 100644 --- a/lib/commands/list-platforms.ts +++ b/lib/commands/list-platforms.ts @@ -10,24 +10,22 @@ export class ListPlatformsCommand implements ICommand { constructor( private $platformCommandHelper: IPlatformCommandHelper, private $projectData: IProjectData, - private $logger: ILogger + private $logger: ILogger, ) { this.$projectData.initializeProjectData(); } public async execute(args: string[]): Promise { - const installedPlatforms = this.$platformCommandHelper.getInstalledPlatforms( - this.$projectData - ); + const installedPlatforms = + this.$platformCommandHelper.getInstalledPlatforms(this.$projectData); if (installedPlatforms.length > 0) { - const preparedPlatforms = this.$platformCommandHelper.getPreparedPlatforms( - this.$projectData - ); + const preparedPlatforms = + this.$platformCommandHelper.getPreparedPlatforms(this.$projectData); if (preparedPlatforms.length > 0) { this.$logger.info( "The project is prepared for: ", - helpers.formatListOfNames(preparedPlatforms, "and") + helpers.formatListOfNames(preparedPlatforms, "and"), ); } else { this.$logger.info("The project is not prepared for any platform"); @@ -35,16 +33,16 @@ export class ListPlatformsCommand implements ICommand { this.$logger.info( "Installed platforms: ", - helpers.formatListOfNames(installedPlatforms, "and") + helpers.formatListOfNames(installedPlatforms, "and"), ); } else { const formattedPlatformsList = helpers.formatListOfNames( this.$platformCommandHelper.getAvailablePlatforms(this.$projectData), - "and" + "and", ); this.$logger.info( "Available platforms for this OS: ", - formattedPlatformsList + formattedPlatformsList, ); this.$logger.info("No installed platforms found. Use $ ns platform add"); } diff --git a/lib/commands/migrate.ts b/lib/commands/migrate.ts index 879f3b5e80..5895870e56 100644 --- a/lib/commands/migrate.ts +++ b/lib/commands/migrate.ts @@ -11,7 +11,7 @@ export class MigrateCommand implements ICommand { private $migrateController: IMigrateController, private $staticConfig: Config.IStaticConfig, private $projectData: IProjectData, - private $logger: ILogger + private $logger: ILogger, ) { this.$projectData.initializeProjectData(); } @@ -24,14 +24,13 @@ export class MigrateCommand implements ICommand { this.$devicePlatformsConstants.iOS, ], }; - const shouldMigrateResult = await this.$migrateController.shouldMigrate( - migrationData - ); + const shouldMigrateResult = + await this.$migrateController.shouldMigrate(migrationData); if (!shouldMigrateResult) { const cliVersion = this.$staticConfig.version; this.$logger.printMarkdown( - `__Project is compatible with NativeScript \`v${cliVersion}\`__` + `__Project is compatible with NativeScript \`v${cliVersion}\`__`, ); return; } diff --git a/lib/commands/native-add.ts b/lib/commands/native-add.ts index 3b5ca90f37..3402daa0da 100644 --- a/lib/commands/native-add.ts +++ b/lib/commands/native-add.ts @@ -13,7 +13,7 @@ export class NativeAddCommand implements ICommand { constructor( protected $projectData: IProjectData, protected $logger: ILogger, - protected $errors: IErrors + protected $errors: IErrors, ) { this.$projectData.initializeProjectData(); } @@ -26,7 +26,7 @@ export class NativeAddCommand implements ICommand { protected failWithUsage(): void { this.$errors.failWithHelp( - "Usage: ns native add [swift|objective-c|java|kotlin] [class name]" + "Usage: ns native add [swift|objective-c|java|kotlin] [class name]", ); } public async canExecute(args: string[]): Promise { @@ -80,7 +80,7 @@ export class NativeAddAndroidCommand extends NativeAddSingleCommand { private generateJavaClassContent( packageName: string, - classSimpleName: string + classSimpleName: string, ): string { return ( (packageName.length > 0 ? `package ${packageName};` : "") + @@ -98,7 +98,7 @@ public class ${classSimpleName} { private generateKotlinClassContent( packageName: string, - classSimpleName: string + classSimpleName: string, ): string { return ( (packageName.length > 0 ? `package ${packageName};` : "") + @@ -115,28 +115,28 @@ class ${classSimpleName} { ); } public doJavaKotlin(className: string, extension: string): void { - const fileExt = extension == "java" ? extension : "kt"; + const fileExt = extension === "java" ? extension : "kt"; const packageName = this.getPackageName(className); const classSimpleName = this.getClassSimpleName(className); const packagePath = path.join( this.getAndroidSourcePathBase(), - ...packageName.split(".") + ...packageName.split("."), ); const filePath = path.join(packagePath, `${classSimpleName}.${fileExt}`); if (fs.existsSync(filePath)) { this.$errors.failWithHelp( - `${extension} file '${filePath}' already exists.` + `${extension} file '${filePath}' already exists.`, ); return; } - if (extension == "kotlin" && !this.checkAndUpdateGradleProperties()) { + if (extension === "kotlin" && !this.checkAndUpdateGradleProperties()) { return; } const fileContent = - extension == "java" + extension === "java" ? this.generateJavaClassContent(packageName, classSimpleName) : this.generateKotlinClassContent(packageName, classSimpleName); @@ -144,8 +144,8 @@ class ${classSimpleName} { fs.writeFileSync(filePath, fileContent); this.$logger.info( `${capitalizeFirstLetter( - extension - )} file '${filePath}' generated successfully.` + extension, + )} file '${filePath}' generated successfully.`, ); } @@ -164,7 +164,7 @@ class ${classSimpleName} { if (useKotlin === "false") { this.$errors.failWithHelp( - "The useKotlin property is set to false. Stopping processing. Kotlin must be enabled in gradle.properties to use." + "The useKotlin property is set to false. Stopping processing. Kotlin must be enabled in gradle.properties to use.", ); return false; } @@ -175,13 +175,13 @@ class ${classSimpleName} { } else { fs.appendFileSync(filePath, `${EOL}useKotlin=true${EOL}`); this.$logger.info( - 'Added "useKotlin=true" property to gradle.properties.' + 'Added "useKotlin=true" property to gradle.properties.', ); } } else { fs.writeFileSync(filePath, `useKotlin=true${EOL}`); this.$logger.info( - 'Created gradle.properties with "useKotlin=true" property.' + 'Created gradle.properties with "useKotlin=true" property.', ); } return true; @@ -234,14 +234,14 @@ export class NativeAddObjectiveCCommand extends NativeAddSingleCommand { // Modify/Generate moduleMap this.generateOrUpdateModuleMap( `${className}.h`, - path.join(iosSourceBase, "module.modulemap") + path.join(iosSourceBase, "module.modulemap"), ); } } private generateOrUpdateModuleMap( headerFileName: string, - moduleMapPath: string + moduleMapPath: string, ): void { const moduleName = "LocalModule"; const headerPath = headerFileName; @@ -259,14 +259,14 @@ export class NativeAddObjectiveCCommand extends NativeAddSingleCommand { if (moduleMapContent.includes(headerDeclaration)) { // Header is already present in the module map this.$logger.warn( - `Header '${headerFileName}' is already added to the module map.` + `Header '${headerFileName}' is already added to the module map.`, ); return; } const updatedModuleMapContent = moduleMapContent.replace( new RegExp(`module ${moduleName} {\\s*([^}]*)\\s*}`, "s"), - `module ${moduleName} {${EOL} $1${EOL} ${headerDeclaration}${EOL}}` + `module ${moduleName} {${EOL} $1${EOL} ${headerDeclaration}${EOL}}`, ); fs.writeFileSync(moduleMapPath, updatedModuleMapContent); @@ -279,25 +279,25 @@ export class NativeAddObjectiveCCommand extends NativeAddSingleCommand { } this.$logger.info( - `Module map '${moduleMapPath}' has been updated with the header '${headerFileName}'.` + `Module map '${moduleMapPath}' has been updated with the header '${headerFileName}'.`, ); } private generateObjectiveCFiles( className: string, classFilePath: string, - interfaceFilePath: string + interfaceFilePath: string, ): boolean { if (fs.existsSync(classFilePath)) { this.$errors.failWithHelp( - `Error: File '${classFilePath}' already exists.` + `Error: File '${classFilePath}' already exists.`, ); return false; } if (fs.existsSync(interfaceFilePath)) { this.$errors.failWithHelp( - `Error: File '${interfaceFilePath}' already exists.` + `Error: File '${interfaceFilePath}' already exists.`, ); return false; } @@ -324,12 +324,12 @@ export class NativeAddObjectiveCCommand extends NativeAddSingleCommand { fs.writeFileSync(classFilePath, classContent); this.$logger.trace( - `Objective-C class file '${classFilePath}' generated successfully.` + `Objective-C class file '${classFilePath}' generated successfully.`, ); fs.writeFileSync(interfaceFilePath, interfaceContent); this.$logger.trace( - `Objective-C interface file '${interfaceFilePath}' generated successfully.` + `Objective-C interface file '${interfaceFilePath}' generated successfully.`, ); return true; } @@ -385,5 +385,5 @@ injector.registerCommand(["native|add|kotlin"], NativeAddKotlinCommand); injector.registerCommand(["native|add|swift"], NativeAddSwiftCommand); injector.registerCommand( ["native|add|objective-c"], - NativeAddObjectiveCCommand + NativeAddObjectiveCCommand, ); diff --git a/lib/commands/platform-clean.ts b/lib/commands/platform-clean.ts index 2cce2cd10c..60cdf69973 100644 --- a/lib/commands/platform-clean.ts +++ b/lib/commands/platform-clean.ts @@ -19,7 +19,7 @@ export class CleanCommand implements ICommand { private $platformCommandHelper: IPlatformCommandHelper, private $platformValidationService: IPlatformValidationService, private $platformEnvironmentRequirements: IPlatformEnvironmentRequirements, - private $projectData: IProjectData + private $projectData: IProjectData, ) { this.$projectData.initializeProjectData(); } @@ -28,34 +28,35 @@ export class CleanCommand implements ICommand { await this.$platformCommandHelper.cleanPlatforms( args, this.$projectData, - this.$options.frameworkPath + this.$options.frameworkPath, ); } public async canExecute(args: string[]): Promise { if (!args || args.length === 0) { this.$errors.failWithHelp( - "No platform specified. Please specify a platform to clean." + "No platform specified. Please specify a platform to clean.", ); } _.each(args, (platform) => { this.$platformValidationService.validatePlatform( platform, - this.$projectData + this.$projectData, ); }); for (const platform of args) { this.$platformValidationService.validatePlatformInstalled( platform, - this.$projectData + this.$projectData, ); - const currentRuntimeVersion = this.$platformCommandHelper.getCurrentPlatformVersion( - platform, - this.$projectData - ); + const currentRuntimeVersion = + this.$platformCommandHelper.getCurrentPlatformVersion( + platform, + this.$projectData, + ); await this.$platformEnvironmentRequirements.checkEnvironmentRequirements({ platform, projectDir: this.$projectData.projectDir, diff --git a/lib/commands/plugin/add-plugin.ts b/lib/commands/plugin/add-plugin.ts index b7102ba0f7..cb89d6108f 100644 --- a/lib/commands/plugin/add-plugin.ts +++ b/lib/commands/plugin/add-plugin.ts @@ -11,7 +11,7 @@ export class AddPluginCommand implements ICommand { constructor( private $pluginsService: IPluginsService, private $projectData: IProjectData, - private $errors: IErrors + private $errors: IErrors, ) { this.$projectData.initializeProjectData(); } @@ -26,13 +26,13 @@ export class AddPluginCommand implements ICommand { } const installedPlugins = await this.$pluginsService.getAllInstalledPlugins( - this.$projectData + this.$projectData, ); const pluginName = args[0].toLowerCase(); if ( _.some( installedPlugins, - (plugin: IPluginData) => plugin.name.toLowerCase() === pluginName + (plugin: IPluginData) => plugin.name.toLowerCase() === pluginName, ) ) { this.$errors.fail(`Plugin "${pluginName}" is already installed.`); diff --git a/lib/commands/plugin/build-plugin.ts b/lib/commands/plugin/build-plugin.ts index 09c2800f99..82f39e1e89 100644 --- a/lib/commands/plugin/build-plugin.ts +++ b/lib/commands/plugin/build-plugin.ts @@ -21,7 +21,7 @@ export class BuildPluginCommand implements ICommand { private $logger: ILogger, private $fs: IFileSystem, private $options: IOptions, - private $tempService: ITempService + private $tempService: ITempService, ) { this.pluginProjectPath = path.resolve(this.$options.path || "."); } @@ -30,13 +30,13 @@ export class BuildPluginCommand implements ICommand { const platformsAndroidPath = path.join( this.pluginProjectPath, constants.PLATFORMS_DIR_NAME, - "android" + "android", ); let pluginName = ""; const pluginPackageJsonPath = path.join( this.pluginProjectPath, - constants.PACKAGE_JSON_FILE_NAME + constants.PACKAGE_JSON_FILE_NAME, ); if (this.$fs.exists(pluginPackageJsonPath)) { @@ -47,9 +47,8 @@ export class BuildPluginCommand implements ICommand { } } - const tempAndroidProject = await this.$tempService.mkdirSync( - "android-project" - ); + const tempAndroidProject = + await this.$tempService.mkdirSync("android-project"); const options: IPluginBuildOptions = { gradlePath: this.$options.gradlePath, @@ -60,19 +59,17 @@ export class BuildPluginCommand implements ICommand { tempPluginDirPath: tempAndroidProject, }; - const androidPluginBuildResult = await this.$androidPluginBuildService.buildAar( - options - ); + const androidPluginBuildResult = + await this.$androidPluginBuildService.buildAar(options); if (androidPluginBuildResult) { this.$logger.info( - `${pluginName} successfully built aar at ${platformsAndroidPath}.${EOL}Temporary Android project can be found at ${tempAndroidProject}.` + `${pluginName} successfully built aar at ${platformsAndroidPath}.${EOL}Temporary Android project can be found at ${tempAndroidProject}.`, ); } - const migratedIncludeGradle = this.$androidPluginBuildService.migrateIncludeGradle( - options - ); + const migratedIncludeGradle = + this.$androidPluginBuildService.migrateIncludeGradle(options); if (migratedIncludeGradle) { this.$logger.info(`${pluginName} include gradle updated.`); @@ -85,12 +82,12 @@ export class BuildPluginCommand implements ICommand { path.join( this.pluginProjectPath, constants.PLATFORMS_DIR_NAME, - "android" - ) + "android", + ), ) ) { this.$errors.fail( - "No plugin found at the current directory, or the plugin does not need to have its platforms/android components built into an `.aar`." + "No plugin found at the current directory, or the plugin does not need to have its platforms/android components built into an `.aar`.", ); } diff --git a/lib/commands/plugin/create-plugin.ts b/lib/commands/plugin/create-plugin.ts index 2e6f9ea2d4..30f5782bf7 100644 --- a/lib/commands/plugin/create-plugin.ts +++ b/lib/commands/plugin/create-plugin.ts @@ -27,7 +27,7 @@ export class CreatePluginCommand implements ICommand { private $fs: IFileSystem, private $childProcess: IChildProcess, private $prompter: IPrompter, - private $packageManager: INodePackageManager + private $packageManager: INodePackageManager, ) {} public async execute(args: string[]): Promise { @@ -51,7 +51,7 @@ export class CreatePluginCommand implements ICommand { this.$logger.printMarkdown( "Solution for `%s` was successfully created.", - pluginRepoName + pluginRepoName, ); } @@ -65,10 +65,10 @@ export class CreatePluginCommand implements ICommand { private async setupSeed( projectDir: string, - pluginRepoName: string + pluginRepoName: string, ): Promise { this.$logger.printMarkdown( - "Executing initial plugin configuration script..." + "Executing initial plugin configuration script...", ); const config = this.$options; @@ -85,15 +85,15 @@ export class CreatePluginCommand implements ICommand { const gitHubUsername = await this.getGitHubUsername(config.username); const pluginNameSource = await this.getPluginNameSource( config.pluginName, - pluginRepoName + pluginRepoName, ); const includeTypescriptDemo = await this.getShouldIncludeDemoResult( config.includeTypeScriptDemo, - this.includeTypeScriptDemoMessage + this.includeTypeScriptDemoMessage, ); const includeAngularDemo = await this.getShouldIncludeDemoResult( config.includeAngularDemo, - this.includeAngularDemoMessage + this.includeAngularDemoMessage, ); if ( @@ -104,7 +104,7 @@ export class CreatePluginCommand implements ICommand { !config.includeTypeScriptDemo) ) { this.$logger.printMarkdown( - "Using default values for plugin creation options since your shell is not interactive." + "Using default values for plugin creation options since your shell is not interactive.", ); } @@ -123,7 +123,7 @@ export class CreatePluginCommand implements ICommand { process.execPath, params, "close", - { stdio: "inherit", cwd, timeout: 10000 } + { stdio: "inherit", cwd, timeout: 10000 }, ); if (outputScript && outputScript.stdout) { this.$logger.printMarkdown(outputScript.stdout); @@ -140,15 +140,15 @@ export class CreatePluginCommand implements ICommand { private async downloadPackage( selectedTemplate: string, - projectDir: string + projectDir: string, ): Promise { if (selectedTemplate) { this.$logger.printMarkdown( - "Make sure your custom template is compatible with the Plugin Seed at https://github.com/NativeScript/nativescript-plugin-seed/" + "Make sure your custom template is compatible with the Plugin Seed at https://github.com/NativeScript/nativescript-plugin-seed/", ); } else { this.$logger.printMarkdown( - "Downloading the latest version of NativeScript Plugin Seed..." + "Downloading the latest version of NativeScript Plugin Seed...", ); } @@ -182,7 +182,7 @@ export class CreatePluginCommand implements ICommand { private async getPluginNameSource( pluginNameSource: string, - pluginRepoName: string + pluginRepoName: string, ): Promise { if (!pluginNameSource) { // remove nativescript- prefix for naming plugin files @@ -205,7 +205,7 @@ export class CreatePluginCommand implements ICommand { private async getShouldIncludeDemoResult( includeDemoOption: string, - message: string + message: string, ): Promise { let shouldIncludeDemo = !!includeDemoOption; if (!includeDemoOption && isInteractive()) { diff --git a/lib/commands/plugin/list-plugins.ts b/lib/commands/plugin/list-plugins.ts index 365396657c..06afb0a1eb 100644 --- a/lib/commands/plugin/list-plugins.ts +++ b/lib/commands/plugin/list-plugins.ts @@ -15,19 +15,20 @@ export class ListPluginsCommand implements ICommand { constructor( private $pluginsService: IPluginsService, private $projectData: IProjectData, - private $logger: ILogger + private $logger: ILogger, ) { this.$projectData.initializeProjectData(); } public async execute(args: string[]): Promise { - const installedPlugins: IPackageJsonDepedenciesResult = this.$pluginsService.getDependenciesFromPackageJson( - this.$projectData.projectDir - ); + const installedPlugins: IPackageJsonDepedenciesResult = + this.$pluginsService.getDependenciesFromPackageJson( + this.$projectData.projectDir, + ); const headers: string[] = ["Plugin", "Version"]; const dependenciesData: string[][] = this.createTableCells( - installedPlugins.dependencies + installedPlugins.dependencies, ); const dependenciesTable: any = createTable(headers, dependenciesData); @@ -39,12 +40,12 @@ export class ListPluginsCommand implements ICommand { installedPlugins.devDependencies.length ) { const devDependenciesData: string[][] = this.createTableCells( - installedPlugins.devDependencies + installedPlugins.devDependencies, ); const devDependenciesTable: any = createTable( headers, - devDependenciesData + devDependenciesData, ); this.$logger.info("Dev Dependencies:"); @@ -54,18 +55,18 @@ export class ListPluginsCommand implements ICommand { } const viewDependenciesCommand: string = color.cyan( - "npm view grep dependencies" + "npm view grep dependencies", ); const viewDevDependenciesCommand: string = color.cyan( - "npm view grep devDependencies" + "npm view grep devDependencies", ); this.$logger.warn("NOTE:"); this.$logger.warn( - `If you want to check the dependencies of installed plugin use ${viewDependenciesCommand}` + `If you want to check the dependencies of installed plugin use ${viewDependenciesCommand}`, ); this.$logger.warn( - `If you want to check the dev dependencies of installed plugin use ${viewDevDependenciesCommand}` + `If you want to check the dev dependencies of installed plugin use ${viewDevDependenciesCommand}`, ); } diff --git a/lib/commands/plugin/remove-plugin.ts b/lib/commands/plugin/remove-plugin.ts index 29f5cdfae9..e27c2b716c 100644 --- a/lib/commands/plugin/remove-plugin.ts +++ b/lib/commands/plugin/remove-plugin.ts @@ -12,7 +12,7 @@ export class RemovePluginCommand implements ICommand { private $pluginsService: IPluginsService, private $errors: IErrors, private $logger: ILogger, - private $projectData: IProjectData + private $projectData: IProjectData, ) { this.$projectData.initializeProjectData(); } @@ -29,9 +29,8 @@ export class RemovePluginCommand implements ICommand { let pluginNames: string[] = []; try { // try installing the plugins, so we can get information from node_modules about their native code, libs, etc. - const installedPlugins = await this.$pluginsService.getAllInstalledPlugins( - this.$projectData - ); + const installedPlugins = + await this.$pluginsService.getAllInstalledPlugins(this.$projectData); pluginNames = installedPlugins.map((pl) => pl.name); } catch (err) { this.$logger.trace("Error while installing plugins. Error is:", err); diff --git a/lib/commands/plugin/update-plugin.ts b/lib/commands/plugin/update-plugin.ts index 64d736068e..aecf220534 100644 --- a/lib/commands/plugin/update-plugin.ts +++ b/lib/commands/plugin/update-plugin.ts @@ -9,7 +9,7 @@ export class UpdatePluginCommand implements ICommand { constructor( private $pluginsService: IPluginsService, private $projectData: IProjectData, - private $errors: IErrors + private $errors: IErrors, ) { this.$projectData.initializeProjectData(); } @@ -18,9 +18,8 @@ export class UpdatePluginCommand implements ICommand { let pluginNames = args; if (!pluginNames || args.length === 0) { - const installedPlugins = await this.$pluginsService.getAllInstalledPlugins( - this.$projectData - ); + const installedPlugins = + await this.$pluginsService.getAllInstalledPlugins(this.$projectData); pluginNames = installedPlugins.map((p) => p.name); } @@ -36,10 +35,10 @@ export class UpdatePluginCommand implements ICommand { } const installedPlugins = await this.$pluginsService.getAllInstalledPlugins( - this.$projectData + this.$projectData, ); const installedPluginNames: string[] = installedPlugins.map( - (pl) => pl.name + (pl) => pl.name, ); const pluginName = args[0].toLowerCase(); diff --git a/lib/commands/preview.ts b/lib/commands/preview.ts index 872267b260..07ea955ae2 100644 --- a/lib/commands/preview.ts +++ b/lib/commands/preview.ts @@ -19,7 +19,7 @@ export class PreviewCommand implements ICommand { private $projectData: IProjectData, private $packageManager: IPackageManager, private $childProcess: IChildProcess, - private $options: IOptions + private $options: IOptions, ) {} private getPreviewCLIPath(): string { @@ -37,7 +37,7 @@ export class PreviewCommand implements ICommand { { "save-dev": true, "save-exact": true, - } as any + } as any, ); } @@ -58,6 +58,7 @@ export class PreviewCommand implements ICommand { break; case PackageManagers.bun: installCommand = "bun add --dev @nativescript/preview-cli"; + break; case PackageManagers.npm: default: installCommand = "npm install --save-dev @nativescript/preview-cli"; @@ -78,7 +79,7 @@ export class PreviewCommand implements ICommand { color.cyan(" ./node_modules/.bin/preview-cli"), "", "And if you are still having issues, try again - or reach out on Discord/open an issue on GitHub.", - ].join("\n") + ].join("\n"), ); this.$errors.fail("Running preview failed."); @@ -93,7 +94,7 @@ export class PreviewCommand implements ICommand { [previewCLIBinPath, ...commandArgs], { stdio: "inherit", - } + }, ); } diff --git a/lib/commands/remove-platform.ts b/lib/commands/remove-platform.ts index db5c5cb427..b4b0703f53 100644 --- a/lib/commands/remove-platform.ts +++ b/lib/commands/remove-platform.ts @@ -15,7 +15,7 @@ export class RemovePlatformCommand implements ICommand { private $errors: IErrors, private $platformCommandHelper: IPlatformCommandHelper, private $platformValidationService: IPlatformValidationService, - private $projectData: IProjectData + private $projectData: IProjectData, ) { this.$projectData.initializeProjectData(); } @@ -27,14 +27,14 @@ export class RemovePlatformCommand implements ICommand { public async canExecute(args: string[]): Promise { if (!args || args.length === 0) { this.$errors.failWithHelp( - "No platform specified. Please specify a platform to remove." + "No platform specified. Please specify a platform to remove.", ); } _.each(args, (platform) => { this.$platformValidationService.validatePlatform( platform, - this.$projectData + this.$projectData, ); }); diff --git a/lib/commands/resources/resources-update.ts b/lib/commands/resources/resources-update.ts index 5e87439003..e669aa4108 100644 --- a/lib/commands/resources/resources-update.ts +++ b/lib/commands/resources/resources-update.ts @@ -10,14 +10,14 @@ export class ResourcesUpdateCommand implements ICommand { constructor( private $projectData: IProjectData, private $errors: IErrors, - private $androidResourcesMigrationService: IAndroidResourcesMigrationService + private $androidResourcesMigrationService: IAndroidResourcesMigrationService, ) { this.$projectData.initializeProjectData(); } public async execute(args: string[]): Promise { await this.$androidResourcesMigrationService.migrate( - this.$projectData.getAppResourcesDirectoryPath() + this.$projectData.getAppResourcesDirectoryPath(), ); } @@ -30,17 +30,17 @@ export class ResourcesUpdateCommand implements ICommand { for (const platform of args) { if (!this.$androidResourcesMigrationService.canMigrate(platform)) { this.$errors.fail( - `The ${platform} does not need to have its resources updated.` + `The ${platform} does not need to have its resources updated.`, ); } if ( this.$androidResourcesMigrationService.hasMigrated( - this.$projectData.getAppResourcesDirectoryPath() + this.$projectData.getAppResourcesDirectoryPath(), ) ) { this.$errors.fail( - "The App_Resources have already been updated for the Android platform." + "The App_Resources have already been updated for the Android platform.", ); } } diff --git a/lib/commands/run.ts b/lib/commands/run.ts index 8b7e789c1b..0efb446811 100644 --- a/lib/commands/run.ts +++ b/lib/commands/run.ts @@ -30,20 +30,20 @@ export class RunCommandBase implements ICommand { private $migrateController: IMigrateController, private $options: IOptions, private $projectData: IProjectData, - private $keyCommandHelper: IKeyCommandHelper + private $keyCommandHelper: IKeyCommandHelper, ) {} public allowedParameters: ICommandParameter[] = []; public async execute(args: string[]): Promise { await this.$liveSyncCommandHelper.executeCommandLiveSync( this.platform, - this.liveSyncCommandHelperAdditionalOptions + this.liveSyncCommandHelperAdditionalOptions, ); if (process.env.NS_IS_INTERACTIVE) { this.$keyCommandHelper.attachKeyCommands( this.platform as IKeyCommandPlatform, - "run" + "run", ); } } @@ -64,7 +64,7 @@ export class RunCommandBase implements ICommand { : [ this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS, - ]; + ]; if (!this.$options.force) { await this.$migrateController.validate({ @@ -100,7 +100,7 @@ export class RunIosCommand implements ICommand { protected $injector: IInjector, protected $options: IOptions, protected $platformValidationService: IPlatformValidationService, - protected $projectDataService: IProjectDataService + protected $projectDataService: IProjectDataService, ) {} public async execute(args: string[]): Promise { @@ -113,11 +113,11 @@ export class RunIosCommand implements ICommand { if ( !this.$platformValidationService.isPlatformSupportedForOS( this.platform, - projectData + projectData, ) ) { this.$errors.fail( - `Applications for platform ${this.platform} can not be built on this OS` + `Applications for platform ${this.platform} can not be built on this OS`, ); } @@ -127,7 +127,7 @@ export class RunIosCommand implements ICommand { this.$options.provision, this.$options.teamId, projectData, - this.platform.toLowerCase() + this.platform.toLowerCase(), )); return result; } @@ -154,7 +154,7 @@ export class RunAndroidCommand implements ICommand { private $injector: IInjector, private $options: IOptions, private $platformValidationService: IPlatformValidationService, - private $projectData: IProjectData + private $projectData: IProjectData, ) {} public async execute(args: string[]): Promise { @@ -167,11 +167,11 @@ export class RunAndroidCommand implements ICommand { if ( !this.$platformValidationService.isPlatformSupportedForOS( this.$devicePlatformsConstants.Android, - this.$projectData + this.$projectData, ) ) { this.$errors.fail( - `Applications for platform ${this.$devicePlatformsConstants.Android} can not be built on this OS` + `Applications for platform ${this.$devicePlatformsConstants.Android} can not be built on this OS`, ); } @@ -190,7 +190,7 @@ export class RunAndroidCommand implements ICommand { this.$options.provision, this.$options.teamId, this.$projectData, - this.$devicePlatformsConstants.Android.toLowerCase() + this.$devicePlatformsConstants.Android.toLowerCase(), ); } } @@ -208,7 +208,7 @@ export class RunVisionOSCommand extends RunIosCommand { protected $injector: IInjector, protected $options: IOptions, protected $platformValidationService: IPlatformValidationService, - protected $projectDataService: IProjectDataService + protected $projectDataService: IProjectDataService, ) { super( $devicePlatformsConstants, @@ -216,7 +216,7 @@ export class RunVisionOSCommand extends RunIosCommand { $injector, $options, $platformValidationService, - $projectDataService + $projectDataService, ); } } diff --git a/lib/commands/test-init.ts b/lib/commands/test-init.ts index 32b55ad04c..c76567e2b0 100644 --- a/lib/commands/test-init.ts +++ b/lib/commands/test-init.ts @@ -36,7 +36,7 @@ class TestInitCommand implements ICommand { private $resources: IResourceLoader, private $pluginsService: IPluginsService, private $logger: ILogger, - private $testInitializationService: ITestInitializationService + private $testInitializationService: ITestInitializationService, ) { this.$projectData.initializeProjectData(); } @@ -48,11 +48,11 @@ class TestInitCommand implements ICommand { this.$options.framework || (await this.$prompter.promptForChoice( "Select testing framework:", - TESTING_FRAMEWORKS + TESTING_FRAMEWORKS, )); if (TESTING_FRAMEWORKS.indexOf(frameworkToInstall) === -1) { this.$errors.failWithHelp( - `Unknown or unsupported unit testing framework: ${frameworkToInstall}.` + `Unknown or unsupported unit testing framework: ${frameworkToInstall}.`, ); } @@ -64,19 +64,18 @@ class TestInitCommand implements ICommand { let modulesToInstall: IDependencyInformation[] = []; try { - modulesToInstall = this.$testInitializationService.getDependencies( - frameworkToInstall - ); + modulesToInstall = + this.$testInitializationService.getDependencies(frameworkToInstall); } catch (err) { this.$errors.fail( - `Unable to install the unit testing dependencies. Error: '${err.message}'` + `Unable to install the unit testing dependencies. Error: '${err.message}'`, ); } modulesToInstall = modulesToInstall.filter( (moduleToInstall) => !moduleToInstall.projectType || - moduleToInstall.projectType === projectFilesExtension + moduleToInstall.projectType === projectFilesExtension, ); for (const mod of modulesToInstall) { @@ -101,7 +100,7 @@ class TestInitCommand implements ICommand { for (const peerDependency in modulePeerDependencies) { const isPeerDependencyExcluded = _.includes( mod.excludedPeerDependencies, - peerDependency + peerDependency, ); if (isPeerDependencyExcluded) { continue; @@ -122,7 +121,7 @@ class TestInitCommand implements ICommand { frameworkPath: this.$options.frameworkPath, ignoreScripts: this.$options.ignoreScripts, path: this.$options.path, - } + }, ); } catch (e) { this.$logger.error(e.message); @@ -132,7 +131,7 @@ class TestInitCommand implements ICommand { await this.$pluginsService.add( "@nativescript/unit-test-runner", - this.$projectData + this.$projectData, ); this.$logger.clearScreen(); @@ -142,11 +141,11 @@ class TestInitCommand implements ICommand { const testsDir = path.join(this.$projectData.appDirectoryPath, "tests"); const projectTestsDir = path.relative( this.$projectData.projectDir, - testsDir + testsDir, ); const relativeTestsDir = path.relative( this.$projectData.appDirectoryPath, - testsDir + testsDir, ); let shouldCreateSampleTests = true; if (this.$fs.exists(testsDir)) { @@ -157,8 +156,8 @@ class TestInitCommand implements ICommand { `Note: The "${projectTestsDir}" directory already exists, will not create example tests in the project.`, `You may create "${specFilenamePattern}" files anywhere you'd like.`, "", - ].join("\n") - ) + ].join("\n"), + ), ); shouldCreateSampleTests = false; } @@ -170,7 +169,7 @@ class TestInitCommand implements ICommand { .map((fw) => `'${fw}'`) .join(", "); const testFiles = `'${fromWindowsRelativePathToUnix( - relativeTestsDir + relativeTestsDir, )}/**/*${projectFilesExtension}'`; const karmaConfTemplate = this.$resources.readText("test/karma.conf.js"); const karmaConf = _.template(karmaConfTemplate)({ @@ -182,43 +181,43 @@ class TestInitCommand implements ICommand { this.$fs.writeFile(path.join(projectDir, "karma.conf.js"), karmaConf); const exampleFilePath = this.$resources.resolvePath( - `test/example.${frameworkToInstall}${projectFilesExtension}` + `test/example.${frameworkToInstall}${projectFilesExtension}`, ); const targetExampleTestPath = path.join( testsDir, - `example.spec${projectFilesExtension}` + `example.spec${projectFilesExtension}`, ); if (shouldCreateSampleTests && this.$fs.exists(exampleFilePath)) { this.$fs.copyFile(exampleFilePath, targetExampleTestPath); const targetExampleTestRelativePath = path.relative( projectDir, - targetExampleTestPath + targetExampleTestPath, ); bufferedLogs.push( - `Added example test: ${color.yellow(targetExampleTestRelativePath)}` + `Added example test: ${color.yellow(targetExampleTestRelativePath)}`, ); } // test main entry const testMainResourcesPath = this.$resources.resolvePath( - `test/test-main${projectFilesExtension}` + `test/test-main${projectFilesExtension}`, ); const testMainPath = path.join( this.$projectData.appDirectoryPath, - `test${projectFilesExtension}` + `test${projectFilesExtension}`, ); if (!this.$fs.exists(testMainPath)) { this.$fs.copyFile(testMainResourcesPath, testMainPath); const testMainRelativePath = path.relative(projectDir, testMainPath); bufferedLogs.push( - `Main test entrypoint created: ${color.yellow(testMainRelativePath)}` + `Main test entrypoint created: ${color.yellow(testMainRelativePath)}`, ); } const testTsConfigTemplate = this.$resources.readText( - "test/tsconfig.spec.json" + "test/tsconfig.spec.json", ); const testTsConfig = _.template(testTsConfigTemplate)({ basePath: this.$projectData.getAppDirectoryRelativePath(), @@ -226,7 +225,7 @@ class TestInitCommand implements ICommand { this.$fs.writeFile( path.join(projectDir, "tsconfig.spec.json"), - testTsConfig + testTsConfig, ); bufferedLogs.push(`Added/replaced ${color.yellow("tsconfig.spec.json")}`); @@ -242,11 +241,11 @@ class TestInitCommand implements ICommand { ...bufferedLogs, "", color.yellow( - `Note: @nativescript/unit-test-runner was included in "dependencies" as a convenience to automatically adjust your app's Info.plist on iOS and AndroidManifest.xml on Android to ensure the socket connects properly.` + `Note: @nativescript/unit-test-runner was included in "dependencies" as a convenience to automatically adjust your app's Info.plist on iOS and AndroidManifest.xml on Android to ensure the socket connects properly.`, ), "", color.yellow( - `For production you may want to move to "devDependencies" and manage the settings yourself.` + `For production you may want to move to "devDependencies" and manage the settings yourself.`, ), "", "", @@ -255,7 +254,7 @@ class TestInitCommand implements ICommand { ` ${greyDollarSign} ${color.green("ns test ios")}`, ` ${greyDollarSign} ${color.green("ns test android")}`, "", - ].join("\n") + ].join("\n"), ); } } diff --git a/lib/commands/update-platform.ts b/lib/commands/update-platform.ts index da127b4ac5..b6f9632838 100644 --- a/lib/commands/update-platform.ts +++ b/lib/commands/update-platform.ts @@ -22,7 +22,7 @@ export class UpdatePlatformCommand implements ICommand { private $platformEnvironmentRequirements: IPlatformEnvironmentRequirements, private $platformCommandHelper: IPlatformCommandHelper, private $platformValidationService: IPlatformValidationService, - private $projectData: IProjectData + private $projectData: IProjectData, ) { this.$projectData.initializeProjectData(); } @@ -34,7 +34,7 @@ export class UpdatePlatformCommand implements ICommand { public async canExecute(args: string[]): Promise { if (!args || args.length === 0) { this.$errors.failWithHelp( - "No platform specified. Please specify platforms to update." + "No platform specified. Please specify platforms to update.", ); } @@ -42,27 +42,29 @@ export class UpdatePlatformCommand implements ICommand { const platform = arg.split("@")[0]; this.$platformValidationService.validatePlatform( platform, - this.$projectData + this.$projectData, ); }); for (const arg of args) { const [platform, versionToBeInstalled] = arg.split("@"); - const checkEnvironmentRequirementsInput: ICheckEnvironmentRequirementsInput = { - platform, - options: this.$options, - }; + const checkEnvironmentRequirementsInput: ICheckEnvironmentRequirementsInput = + { + platform, + options: this.$options, + }; // If version is not specified, we know the command will install the latest compatible Android runtime. // The latest compatible Android runtime supports Java version, so we do not need to pass it here. // Passing projectDir to the @nativescript/doctor validation will cause it to check the runtime from the current package.json // So in this case, where we do not want to validate the runtime, just do not pass both projectDir and runtimeVersion. if (versionToBeInstalled) { - checkEnvironmentRequirementsInput.projectDir = this.$projectData.projectDir; + checkEnvironmentRequirementsInput.projectDir = + this.$projectData.projectDir; checkEnvironmentRequirementsInput.runtimeVersion = versionToBeInstalled; } await this.$platformEnvironmentRequirements.checkEnvironmentRequirements( - checkEnvironmentRequirementsInput + checkEnvironmentRequirementsInput, ); } diff --git a/lib/commands/update.ts b/lib/commands/update.ts index 890b0d66bc..dc812bfb03 100644 --- a/lib/commands/update.ts +++ b/lib/commands/update.ts @@ -20,7 +20,7 @@ export class UpdateCommand implements ICommand { private $errors: IErrors, private $logger: ILogger, private $projectData: IProjectData, - private $markingModeService: IMarkingModeService + private $markingModeService: IMarkingModeService, ) { this.$projectData.initializeProjectData(); } @@ -42,7 +42,7 @@ export class UpdateCommand implements ICommand { })) ) { this.$logger.printMarkdown( - `__${UpdateCommand.PROJECT_UP_TO_DATE_MESSAGE}__` + `__${UpdateCommand.PROJECT_UP_TO_DATE_MESSAGE}__`, ); return; } diff --git a/lib/common/bootstrap.ts b/lib/common/bootstrap.ts index 9905f452b9..c888e7297b 100644 --- a/lib/common/bootstrap.ts +++ b/lib/common/bootstrap.ts @@ -42,15 +42,15 @@ injector.requireCommand("autocomplete|status", "./commands/autocompletion"); injector.requireCommand( ["device|*list", "devices|*list"], - "./commands/device/list-devices" + "./commands/device/list-devices", ); injector.requireCommand( ["device|android", "devices|android"], - "./commands/device/list-devices" + "./commands/device/list-devices", ); injector.requireCommand( ["device|ios", "devices|ios"], - "./commands/device/list-devices" + "./commands/device/list-devices", ); injector.requireCommand("device|log", "./commands/device/device-log-stream"); @@ -58,11 +58,11 @@ injector.requireCommand("device|run", "./commands/device/run-application"); injector.requireCommand("device|stop", "./commands/device/stop-application"); injector.requireCommand( "device|list-applications", - "./commands/device/list-applications" + "./commands/device/list-applications", ); injector.requireCommand( "device|uninstall", - "./commands/device/uninstall-application" + "./commands/device/uninstall-application", ); injector.requireCommand("device|list-files", "./commands/device/list-files"); injector.requireCommand("device|get-file", "./commands/device/get-file"); @@ -70,82 +70,82 @@ injector.requireCommand("device|put-file", "./commands/device/put-file"); injector.require( "iosDeviceOperations", - "./mobile/ios/device/ios-device-operations" + "./mobile/ios/device/ios-device-operations", ); injector.require("deviceDiscovery", "./mobile/mobile-core/device-discovery"); injector.require( "iOSDeviceDiscovery", - "./mobile/mobile-core/ios-device-discovery" + "./mobile/mobile-core/ios-device-discovery", ); injector.require( "iOSSimulatorDiscovery", - "./mobile/mobile-core/ios-simulator-discovery" + "./mobile/mobile-core/ios-simulator-discovery", ); injector.require( "androidDeviceDiscovery", - "./mobile/mobile-core/android-device-discovery" + "./mobile/mobile-core/android-device-discovery", ); injector.require( "androidEmulatorDiscovery", - "./mobile/mobile-core/android-emulator-discovery" + "./mobile/mobile-core/android-emulator-discovery", ); injector.require("iOSDevice", "./mobile/ios/device/ios-device"); injector.require( "iOSDeviceProductNameMapper", - "./mobile/ios/ios-device-product-name-mapper" + "./mobile/ios/ios-device-product-name-mapper", ); injector.require("androidDevice", "./mobile/android/android-device"); injector.require("adb", "./mobile/android/android-debug-bridge"); injector.require( "androidDebugBridgeResultHandler", - "./mobile/android/android-debug-bridge-result-handler" + "./mobile/android/android-debug-bridge-result-handler", ); injector.require( "androidVirtualDeviceService", - "./mobile/android/android-virtual-device-service" + "./mobile/android/android-virtual-device-service", ); injector.require( "androidIniFileParser", - "./mobile/android/android-ini-file-parser" + "./mobile/android/android-ini-file-parser", ); injector.require( "androidGenymotionService", - "./mobile/android/genymotion/genymotion-service" + "./mobile/android/genymotion/genymotion-service", ); injector.require( "virtualBoxService", - "./mobile/android/genymotion/virtualbox-service" + "./mobile/android/genymotion/virtualbox-service", ); injector.require("logcatHelper", "./mobile/android/logcat-helper"); injector.require("iOSSimResolver", "./mobile/ios/simulator/ios-sim-resolver"); injector.require( "iOSSimulatorLogProvider", - "./mobile/ios/simulator/ios-simulator-log-provider" + "./mobile/ios/simulator/ios-simulator-log-provider", ); injector.require( "localToDevicePathDataFactory", - "./mobile/local-to-device-path-data-factory" + "./mobile/local-to-device-path-data-factory", ); injector.requirePublic( "devicesService", - "./mobile/mobile-core/devices-service" + "./mobile/mobile-core/devices-service", ); injector.requirePublic( "androidProcessService", - "./mobile/mobile-core/android-process-service" + "./mobile/mobile-core/android-process-service", ); injector.require("projectNameValidator", "./validators/project-name-validator"); injector.require( "androidEmulatorServices", - "./mobile/android/android-emulator-services" + "./mobile/android/android-emulator-services", ); injector.require( "iOSEmulatorServices", - "./mobile/ios/simulator/ios-emulator-services" + "./mobile/ios/simulator/ios-emulator-services", ); injector.require("wp8EmulatorServices", "./mobile/wp8/wp8-emulator-services"); @@ -157,18 +157,18 @@ injector.require("mobileHelper", "./mobile/mobile-helper"); injector.require("emulatorHelper", "./mobile/emulator-helper"); injector.require( "devicePlatformsConstants", - "./mobile/device-platforms-constants" + "./mobile/device-platforms-constants", ); injector.require("helpService", "./services/help-service"); injector.require( "messageContractGenerator", - "./services/message-contract-generator" + "./services/message-contract-generator", ); injector.require("proxyService", "./services/proxy-service"); injector.requireCommand("dev-preuninstall", "./commands/preuninstall"); injector.requireCommand( "dev-generate-messages", - "./commands/generate-messages" + "./commands/generate-messages", ); injector.requireCommand("doctor|*all", "./commands/doctor"); injector.requireCommand("doctor|ios", "./commands/doctor"); diff --git a/lib/common/codeGeneration/code-generation.d.ts b/lib/common/codeGeneration/code-generation.d.ts index fb35ce3323..edf692c052 100644 --- a/lib/common/codeGeneration/code-generation.d.ts +++ b/lib/common/codeGeneration/code-generation.d.ts @@ -1,6 +1,6 @@ import { IDictionary } from "../declarations"; -declare module CodeGeneration { +declare namespace CodeGeneration { interface IModel { id: string; properties: IDictionary; diff --git a/lib/common/codeGeneration/code-printer.ts b/lib/common/codeGeneration/code-printer.ts index 53e1c772ba..662b670f23 100644 --- a/lib/common/codeGeneration/code-printer.ts +++ b/lib/common/codeGeneration/code-printer.ts @@ -12,7 +12,7 @@ export class CodePrinter { public composeBlock( block: CodeGeneration.IBlock, - indentSize?: number + indentSize?: number, ): string { indentSize = indentSize === undefined ? 0 : indentSize; let content = this.getIndentation(indentSize); @@ -27,12 +27,12 @@ export class CodePrinter { if (codeEntity.codeEntityType === CodeEntityType.Line) { content += this.composeLine( codeEntity, - indentSize + 1 + indentSize + 1, ); } else if (codeEntity.codeEntityType === CodeEntityType.Block) { content += this.composeBlock( codeEntity, - indentSize + 1 + indentSize + 1, ); } }); diff --git a/lib/common/commands/analytics.ts b/lib/common/commands/analytics.ts index 95d91db0fa..146b98c716 100644 --- a/lib/common/commands/analytics.ts +++ b/lib/common/commands/analytics.ts @@ -16,7 +16,7 @@ export class AnalyticsCommandParameter implements ICommandParameter { return true; default: this.$errors.failWithHelp( - `The value '${validationValue}' is not valid. Valid values are 'enable', 'disable' and 'status'.` + `The value '${validationValue}' is not valid. Valid values are 'enable', 'disable' and 'status'.`, ); } } @@ -29,7 +29,7 @@ class AnalyticsCommand implements ICommand { private $errors: IErrors, private $options: IOptions, private settingName: string, - private humanReadableSettingName: string + private humanReadableSettingName: string, ) {} public allowedParameters = [new AnalyticsCommandParameter(this.$errors)]; @@ -54,8 +54,8 @@ class AnalyticsCommand implements ICommand { await this.$analyticsService.getStatusMessage( this.settingName, this.$options.json, - this.humanReadableSettingName - ) + this.humanReadableSettingName, + ), ); break; } @@ -68,7 +68,7 @@ export class UsageReportingCommand extends AnalyticsCommand { $logger: ILogger, $errors: IErrors, $options: IOptions, - $staticConfig: Config.IStaticConfig + $staticConfig: Config.IStaticConfig, ) { super( $analyticsService, @@ -76,7 +76,7 @@ export class UsageReportingCommand extends AnalyticsCommand { $errors, $options, $staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME, - "Usage reporting" + "Usage reporting", ); } } @@ -88,7 +88,7 @@ export class ErrorReportingCommand extends AnalyticsCommand { $logger: ILogger, $errors: IErrors, $options: IOptions, - $staticConfig: Config.IStaticConfig + $staticConfig: Config.IStaticConfig, ) { super( $analyticsService, @@ -96,7 +96,7 @@ export class ErrorReportingCommand extends AnalyticsCommand { $errors, $options, $staticConfig.ERROR_REPORT_SETTING_NAME, - "Error reporting" + "Error reporting", ); } } diff --git a/lib/common/commands/autocompletion.ts b/lib/common/commands/autocompletion.ts index 926c1a613c..b94febf5f0 100644 --- a/lib/common/commands/autocompletion.ts +++ b/lib/common/commands/autocompletion.ts @@ -7,7 +7,7 @@ export class AutoCompleteCommand implements ICommand { constructor( private $autoCompletionService: IAutoCompletionService, private $logger: ILogger, - private $prompter: IPrompter + private $prompter: IPrompter, ) {} public disableAnalytics = true; @@ -24,13 +24,13 @@ export class AutoCompleteCommand implements ICommand { } } else { this.$logger.info( - "If you are using bash or zsh, you can enable command-line completion." + "If you are using bash or zsh, you can enable command-line completion.", ); const message = "Do you want to enable it now?"; const autoCompetionStatus = await this.$prompter.confirm( message, - () => true + () => true, ); if (autoCompetionStatus) { await this.$autoCompletionService.enableAutoCompletion(); @@ -47,7 +47,7 @@ injector.registerCommand("autocomplete|*default", AutoCompleteCommand); export class DisableAutoCompleteCommand implements ICommand { constructor( private $autoCompletionService: IAutoCompletionService, - private $logger: ILogger + private $logger: ILogger, ) {} public disableAnalytics = true; @@ -66,7 +66,7 @@ injector.registerCommand("autocomplete|disable", DisableAutoCompleteCommand); export class EnableAutoCompleteCommand implements ICommand { constructor( private $autoCompletionService: IAutoCompletionService, - private $logger: ILogger + private $logger: ILogger, ) {} public disableAnalytics = true; @@ -85,7 +85,7 @@ injector.registerCommand("autocomplete|enable", EnableAutoCompleteCommand); export class AutoCompleteStatusCommand implements ICommand { constructor( private $autoCompletionService: IAutoCompletionService, - private $logger: ILogger + private $logger: ILogger, ) {} public disableAnalytics = true; diff --git a/lib/common/commands/device/device-log-stream.ts b/lib/common/commands/device/device-log-stream.ts index 313e607314..ab2c880ed1 100644 --- a/lib/common/commands/device/device-log-stream.ts +++ b/lib/common/commands/device/device-log-stream.ts @@ -16,7 +16,7 @@ export class OpenDeviceLogStreamCommand implements ICommand { private $deviceLogProvider: Mobile.IDeviceLogProvider, private $loggingLevels: Mobile.ILoggingLevels, $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider, - $cleanupService: ICleanupService + $cleanupService: ICleanupService, ) { $iOSSimulatorLogProvider.setShouldDispose(false); $cleanupService.setShouldDispose(false); @@ -35,7 +35,7 @@ export class OpenDeviceLogStreamCommand implements ICommand { if (this.$devicesService.deviceCount > 1) { await this.$commandsService.tryExecuteCommand("device", []); this.$errors.failWithHelp( - OpenDeviceLogStreamCommand.NOT_SPECIFIED_DEVICE_ERROR_MESSAGE + OpenDeviceLogStreamCommand.NOT_SPECIFIED_DEVICE_ERROR_MESSAGE, ); } @@ -46,5 +46,5 @@ export class OpenDeviceLogStreamCommand implements ICommand { injector.registerCommand( ["device|log", "devices|log"], - OpenDeviceLogStreamCommand + OpenDeviceLogStreamCommand, ); diff --git a/lib/common/commands/device/get-file.ts b/lib/common/commands/device/get-file.ts index ebe632ae52..fb54b1b60b 100644 --- a/lib/common/commands/device/get-file.ts +++ b/lib/common/commands/device/get-file.ts @@ -10,7 +10,7 @@ export class GetFileCommand implements ICommand { private $stringParameter: ICommandParameter, private $projectData: IProjectData, private $errors: IErrors, - private $options: IOptions + private $options: IOptions, ) {} public allowedParameters: ICommandParameter[] = [ @@ -33,7 +33,7 @@ export class GetFileCommand implements ICommand { } if (!this.$projectData.projectIdentifiers) { this.$errors.fail( - "Please enter application identifier or execute this command in project." + "Please enter application identifier or execute this command in project.", ); } } @@ -47,7 +47,7 @@ export class GetFileCommand implements ICommand { await device.fileSystem.getFile( args[0], appIdentifier, - this.$options.file + this.$options.file, ); }; await this.$devicesService.execute(action); @@ -56,5 +56,5 @@ export class GetFileCommand implements ICommand { injector.registerCommand( ["device|get-file", "devices|get-file"], - GetFileCommand + GetFileCommand, ); diff --git a/lib/common/commands/device/list-applications.ts b/lib/common/commands/device/list-applications.ts index 567c0987ba..d9323ded81 100644 --- a/lib/common/commands/device/list-applications.ts +++ b/lib/common/commands/device/list-applications.ts @@ -9,7 +9,7 @@ export class ListApplicationsCommand implements ICommand { constructor( private $devicesService: Mobile.IDevicesService, private $logger: ILogger, - private $options: IOptions + private $options: IOptions, ) {} allowedParameters: ICommandParameter[] = []; @@ -22,16 +22,17 @@ export class ListApplicationsCommand implements ICommand { const output: string[] = []; const action = async (device: Mobile.IDevice) => { - const applications = await device.applicationManager.getInstalledApplications(); + const applications = + await device.applicationManager.getInstalledApplications(); output.push( util.format( "%s=====Installed applications on device with UDID '%s' are:", EOL, - device.deviceInfo.identifier - ) + device.deviceInfo.identifier, + ), ); _.each(applications, (applicationId: string) => - output.push(applicationId) + output.push(applicationId), ); }; await this.$devicesService.execute(action); @@ -41,5 +42,5 @@ export class ListApplicationsCommand implements ICommand { } injector.registerCommand( ["device|list-applications", "devices|list-applications"], - ListApplicationsCommand + ListApplicationsCommand, ); diff --git a/lib/common/commands/device/list-devices.ts b/lib/common/commands/device/list-devices.ts index d4b5dfb9a7..7a6380f97e 100644 --- a/lib/common/commands/device/list-devices.ts +++ b/lib/common/commands/device/list-devices.ts @@ -15,7 +15,7 @@ export class ListDevicesCommand implements ICommand { private $logger: ILogger, private $stringParameter: ICommandParameter, private $mobileHelper: Mobile.IMobileHelper, - private $options: IOptions + private $options: IOptions, ) {} public allowedParameters = [this.$stringParameter]; @@ -35,17 +35,17 @@ export class ListDevicesCommand implements ICommand { `${ args[0] } is not a valid device platform. The valid platforms are ${formatListOfNames( - this.$mobileHelper.platformNames - )}` + this.$mobileHelper.platformNames, + )}`, ); } - const availableEmulatorsOutput = await this.$devicesService.getEmulatorImages( - { platform } - ); - const emulators = this.$emulatorHelper.getEmulatorsFromAvailableEmulatorsOutput( - availableEmulatorsOutput - ); + const availableEmulatorsOutput = + await this.$devicesService.getEmulatorImages({ platform }); + const emulators = + this.$emulatorHelper.getEmulatorsFromAvailableEmulatorsOutput( + availableEmulatorsOutput, + ); devices.available = emulators; if (!this.$options.json) { @@ -78,7 +78,7 @@ export class ListDevicesCommand implements ICommand { "Status", "Connection Type", ], - [] + [], ); let action: (_device: Mobile.IDevice) => Promise; if (this.$options.json) { @@ -124,7 +124,7 @@ export class ListDevicesCommand implements ICommand { "Image Identifier", // "Error Help", ], - [] + [], ); for (const info of emulators) { table.push([ @@ -146,15 +146,14 @@ injector.registerCommand(["device|*list", "devices|*list"], ListDevicesCommand); class ListAndroidDevicesCommand implements ICommand { constructor( private $injector: IInjector, - private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants + private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, ) {} public allowedParameters: ICommandParameter[] = []; public async execute(args: string[]): Promise { - const listDevicesCommand: ICommand = this.$injector.resolve( - ListDevicesCommand - ); + const listDevicesCommand: ICommand = + this.$injector.resolve(ListDevicesCommand); const platform = this.$devicePlatformsConstants.Android; await listDevicesCommand.execute([platform]); } @@ -162,21 +161,20 @@ class ListAndroidDevicesCommand implements ICommand { injector.registerCommand( ["device|android", "devices|android"], - ListAndroidDevicesCommand + ListAndroidDevicesCommand, ); class ListiOSDevicesCommand implements ICommand { constructor( private $injector: IInjector, - private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants + private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, ) {} public allowedParameters: ICommandParameter[] = []; public async execute(args: string[]): Promise { - const listDevicesCommand: ICommand = this.$injector.resolve( - ListDevicesCommand - ); + const listDevicesCommand: ICommand = + this.$injector.resolve(ListDevicesCommand); const platform = this.$devicePlatformsConstants.iOS; await listDevicesCommand.execute([platform]); } diff --git a/lib/common/commands/device/list-files.ts b/lib/common/commands/device/list-files.ts index 1b603306ae..902b774436 100644 --- a/lib/common/commands/device/list-files.ts +++ b/lib/common/commands/device/list-files.ts @@ -10,7 +10,7 @@ export class ListFilesCommand implements ICommand { private $stringParameter: ICommandParameter, private $options: IOptions, private $projectData: IProjectData, - private $errors: IErrors + private $errors: IErrors, ) {} public allowedParameters: ICommandParameter[] = [ @@ -34,7 +34,7 @@ export class ListFilesCommand implements ICommand { } if (!this.$projectData.projectIdentifiers) { this.$errors.fail( - "Please enter application identifier or execute this command in project." + "Please enter application identifier or execute this command in project.", ); } } @@ -53,5 +53,5 @@ export class ListFilesCommand implements ICommand { injector.registerCommand( ["device|list-files", "devices|list-files"], - ListFilesCommand + ListFilesCommand, ); diff --git a/lib/common/commands/device/put-file.ts b/lib/common/commands/device/put-file.ts index 280afb9f57..9fff58c20c 100644 --- a/lib/common/commands/device/put-file.ts +++ b/lib/common/commands/device/put-file.ts @@ -10,7 +10,7 @@ export class PutFileCommand implements ICommand { private $stringParameter: ICommandParameter, private $options: IOptions, private $projectData: IProjectData, - private $errors: IErrors + private $errors: IErrors, ) {} allowedParameters: ICommandParameter[] = [ @@ -34,7 +34,7 @@ export class PutFileCommand implements ICommand { } if (!this.$projectData.projectIdentifiers) { this.$errors.fail( - "Please enter application identifier or execute this command in project." + "Please enter application identifier or execute this command in project.", ); } } @@ -52,5 +52,5 @@ export class PutFileCommand implements ICommand { } injector.registerCommand( ["device|put-file", "devices|put-file"], - PutFileCommand + PutFileCommand, ); diff --git a/lib/common/commands/device/run-application.ts b/lib/common/commands/device/run-application.ts index 10a56a2952..1e4a64a4ce 100644 --- a/lib/common/commands/device/run-application.ts +++ b/lib/common/commands/device/run-application.ts @@ -9,7 +9,7 @@ export class RunApplicationOnDeviceCommand implements ICommand { private $errors: IErrors, private $stringParameter: ICommandParameter, private $staticConfig: Config.IStaticConfig, - private $options: IOptions + private $options: IOptions, ) {} public allowedParameters: ICommandParameter[] = [ @@ -26,7 +26,7 @@ export class RunApplicationOnDeviceCommand implements ICommand { if (this.$devicesService.deviceCount > 1) { this.$errors.failWithHelp( "More than one device found. Specify device explicitly with --device option. To discover device ID, use $%s device command.", - this.$staticConfig.CLIENT_NAME.toLowerCase() + this.$staticConfig.CLIENT_NAME.toLowerCase(), ); } @@ -36,12 +36,12 @@ export class RunApplicationOnDeviceCommand implements ICommand { appId: args[0], projectName: args[1], projectDir: null, - }) + }), ); } } injector.registerCommand( ["device|run", "devices|run"], - RunApplicationOnDeviceCommand + RunApplicationOnDeviceCommand, ); diff --git a/lib/common/commands/device/stop-application.ts b/lib/common/commands/device/stop-application.ts index 9e0106f72f..29f7f3efcc 100644 --- a/lib/common/commands/device/stop-application.ts +++ b/lib/common/commands/device/stop-application.ts @@ -6,7 +6,7 @@ export class StopApplicationOnDeviceCommand implements ICommand { constructor( private $devicesService: Mobile.IDevicesService, private $stringParameter: ICommandParameter, - private $options: IOptions + private $options: IOptions, ) {} allowedParameters: ICommandParameter[] = [ @@ -34,5 +34,5 @@ export class StopApplicationOnDeviceCommand implements ICommand { injector.registerCommand( ["device|stop", "devices|stop"], - StopApplicationOnDeviceCommand + StopApplicationOnDeviceCommand, ); diff --git a/lib/common/commands/device/uninstall-application.ts b/lib/common/commands/device/uninstall-application.ts index af79be554f..44c2a61eb3 100644 --- a/lib/common/commands/device/uninstall-application.ts +++ b/lib/common/commands/device/uninstall-application.ts @@ -6,7 +6,7 @@ export class UninstallApplicationCommand implements ICommand { constructor( private $devicesService: Mobile.IDevicesService, private $stringParameter: ICommandParameter, - private $options: IOptions + private $options: IOptions, ) {} allowedParameters: ICommandParameter[] = [this.$stringParameter]; @@ -24,5 +24,5 @@ export class UninstallApplicationCommand implements ICommand { } injector.registerCommand( ["device|uninstall", "devices|uninstall"], - UninstallApplicationCommand + UninstallApplicationCommand, ); diff --git a/lib/common/commands/doctor.ts b/lib/common/commands/doctor.ts index 40b4fecbc7..b2aad9cfc0 100644 --- a/lib/common/commands/doctor.ts +++ b/lib/common/commands/doctor.ts @@ -6,7 +6,7 @@ import { PlatformTypes } from "../../constants"; export class DoctorCommand implements ICommand { constructor( private $doctorService: IDoctorService, - private $projectHelper: IProjectHelper + private $projectHelper: IProjectHelper, ) {} public allowedParameters: ICommandParameter[] = []; @@ -24,7 +24,7 @@ injector.registerCommand("doctor|*all", DoctorCommand); export class DoctorIosCommand implements ICommand { constructor( private $doctorService: IDoctorService, - private $projectHelper: IProjectHelper + private $projectHelper: IProjectHelper, ) {} public allowedParameters: ICommandParameter[] = []; @@ -44,7 +44,7 @@ injector.registerCommand("doctor|ios", DoctorIosCommand); export class DoctorAndroidCommand implements ICommand { constructor( private $doctorService: IDoctorService, - private $projectHelper: IProjectHelper + private $projectHelper: IProjectHelper, ) {} public allowedParameters: ICommandParameter[] = []; diff --git a/lib/common/commands/generate-messages.ts b/lib/common/commands/generate-messages.ts index cbab874bdb..95aea56980 100644 --- a/lib/common/commands/generate-messages.ts +++ b/lib/common/commands/generate-messages.ts @@ -11,7 +11,7 @@ export class GenerateMessages implements ICommand { constructor( private $fs: IFileSystem, private $messageContractGenerator: IServiceContractGenerator, - private $options: IOptions + private $options: IOptions, ) {} allowedParameters: ICommandParameter[] = []; @@ -26,20 +26,20 @@ export class GenerateMessages implements ICommand { if (this.$options.default) { interfaceFilePath = path.join( innerMessagesDirectory, - GenerateMessages.MESSAGES_DEFINITIONS_FILE_NAME + GenerateMessages.MESSAGES_DEFINITIONS_FILE_NAME, ); implementationFilePath = path.join( innerMessagesDirectory, - GenerateMessages.MESSAGES_IMPLEMENTATION_FILE_NAME + GenerateMessages.MESSAGES_IMPLEMENTATION_FILE_NAME, ); } else { interfaceFilePath = path.join( outerMessagesDirectory, - GenerateMessages.MESSAGES_DEFINITIONS_FILE_NAME + GenerateMessages.MESSAGES_DEFINITIONS_FILE_NAME, ); implementationFilePath = path.join( outerMessagesDirectory, - GenerateMessages.MESSAGES_IMPLEMENTATION_FILE_NAME + GenerateMessages.MESSAGES_IMPLEMENTATION_FILE_NAME, ); } diff --git a/lib/common/commands/help.ts b/lib/common/commands/help.ts index 0a4fe24503..2835287003 100644 --- a/lib/common/commands/help.ts +++ b/lib/common/commands/help.ts @@ -9,7 +9,7 @@ export class HelpCommand implements ICommand { constructor( private $injector: IInjector, private $helpService: IHelpService, - private $options: IOptions + private $options: IOptions, ) {} public enableHooks = false; @@ -24,7 +24,7 @@ export class HelpCommand implements ICommand { let commandArguments = _.tail(args); const hierarchicalCommand = this.$injector.buildHierarchicalCommand( args[0], - commandArguments + commandArguments, ); if (hierarchicalCommand) { commandName = hierarchicalCommand.commandName; diff --git a/lib/common/commands/package-manager-get.ts b/lib/common/commands/package-manager-get.ts index a258fcb110..6700211d22 100644 --- a/lib/common/commands/package-manager-get.ts +++ b/lib/common/commands/package-manager-get.ts @@ -6,7 +6,7 @@ export class PackageManagerGetCommand implements ICommand { constructor( private $errors: IErrors, private $logger: ILogger, - private $userSettingsService: IUserSettingsService + private $userSettingsService: IUserSettingsService, ) {} public allowedParameters: ICommandParameter[] = []; @@ -15,16 +15,15 @@ export class PackageManagerGetCommand implements ICommand { if (args && args.length) { this.$errors.failWithHelp( `The arguments '${args.join( - " " - )}' are not valid for the 'package-manager get' command.` + " ", + )}' are not valid for the 'package-manager get' command.`, ); } - const result = await this.$userSettingsService.getSettingValue( - "packageManager" - ); + const result = + await this.$userSettingsService.getSettingValue("packageManager"); this.$logger.printMarkdown( - `Your current package manager is \`${result || "npm"}\`.` + `Your current package manager is \`${result || "npm"}\`.`, ); } } diff --git a/lib/common/commands/package-manager-set.ts b/lib/common/commands/package-manager-set.ts index 7f9c1924e0..3d8aecc339 100644 --- a/lib/common/commands/package-manager-set.ts +++ b/lib/common/commands/package-manager-set.ts @@ -8,7 +8,7 @@ export class PackageManagerCommand implements ICommand { private $userSettingsService: IUserSettingsService, private $errors: IErrors, private $logger: ILogger, - private $stringParameter: ICommandParameter + private $stringParameter: ICommandParameter, ) {} public allowedParameters: ICommandParameter[] = [this.$stringParameter]; @@ -19,21 +19,21 @@ export class PackageManagerCommand implements ICommand { if (supportedPackageManagers.indexOf(packageManagerName) === -1) { this.$errors.fail( `${packageManagerName} is not a valid package manager. Supported values are: ${supportedPackageManagers.join( - ", " - )}.` + ", ", + )}.`, ); } await this.$userSettingsService.saveSetting( "packageManager", - packageManagerName + packageManagerName, ); this.$logger.printMarkdown( - `Please ensure you have the directory containing \`${packageManagerName}\` executable available in your PATH.` + `Please ensure you have the directory containing \`${packageManagerName}\` executable available in your PATH.`, ); this.$logger.printMarkdown( - `You've successfully set \`${packageManagerName}\` as your package manager.` + `You've successfully set \`${packageManagerName}\` as your package manager.`, ); } } diff --git a/lib/common/commands/post-install.ts b/lib/common/commands/post-install.ts index f66d6ef343..c3ef0be0e5 100644 --- a/lib/common/commands/post-install.ts +++ b/lib/common/commands/post-install.ts @@ -10,7 +10,7 @@ export class PostInstallCommand implements ICommand { public async execute(args: string[]): Promise { this.$errors.fail( - "This command is deprecated. Use `ns dev-post-install-cli` instead" + "This command is deprecated. Use `ns dev-post-install-cli` instead", ); } } diff --git a/lib/common/commands/preuninstall.ts b/lib/common/commands/preuninstall.ts index 4d086a0bee..506d0ee2d1 100644 --- a/lib/common/commands/preuninstall.ts +++ b/lib/common/commands/preuninstall.ts @@ -26,7 +26,7 @@ export class PreUninstallCommand implements ICommand { private $fs: IFileSystem, // private $opener: IOpener, private $packageInstallationManager: IPackageInstallationManager, - private $settingsService: ISettingsService + private $settingsService: ISettingsService, ) {} public async execute(args: string[]): Promise { @@ -49,7 +49,7 @@ export class PreUninstallCommand implements ICommand { } this.$fs.deleteFile( - path.join(this.$settingsService.getProfileDir(), "KillSwitches", "cli") + path.join(this.$settingsService.getProfileDir(), "KillSwitches", "cli"), ); await this.$analyticsService.finishTracking(); } diff --git a/lib/common/commands/proxy/proxy-base.ts b/lib/common/commands/proxy/proxy-base.ts index e989dce6fa..50ffb67203 100644 --- a/lib/common/commands/proxy/proxy-base.ts +++ b/lib/common/commands/proxy/proxy-base.ts @@ -9,7 +9,7 @@ export abstract class ProxyCommandBase implements ICommand { protected $analyticsService: IAnalyticsService, protected $logger: ILogger, protected $proxyService: IProxyService, - private commandName: string + private commandName: string, ) {} public abstract execute(args: string[]): Promise; diff --git a/lib/common/commands/proxy/proxy-clear.ts b/lib/common/commands/proxy/proxy-clear.ts index aa1981cbc9..175659b312 100644 --- a/lib/common/commands/proxy/proxy-clear.ts +++ b/lib/common/commands/proxy/proxy-clear.ts @@ -7,7 +7,7 @@ export class ProxyClearCommand extends ProxyCommandBase { constructor( protected $analyticsService: IAnalyticsService, protected $logger: ILogger, - protected $proxyService: IProxyService + protected $proxyService: IProxyService, ) { super($analyticsService, $logger, $proxyService, proxyClearCommandName); } diff --git a/lib/common/commands/proxy/proxy-get.ts b/lib/common/commands/proxy/proxy-get.ts index 143b38384b..0c66831598 100644 --- a/lib/common/commands/proxy/proxy-get.ts +++ b/lib/common/commands/proxy/proxy-get.ts @@ -8,7 +8,7 @@ export class ProxyGetCommand extends ProxyCommandBase { constructor( protected $analyticsService: IAnalyticsService, protected $logger: ILogger, - protected $proxyService: IProxyService + protected $proxyService: IProxyService, ) { super($analyticsService, $logger, $proxyService, proxyGetCommandName); } diff --git a/lib/common/commands/proxy/proxy-set.ts b/lib/common/commands/proxy/proxy-set.ts index ee9b1f8a38..62f6880373 100644 --- a/lib/common/commands/proxy/proxy-set.ts +++ b/lib/common/commands/proxy/proxy-set.ts @@ -35,7 +35,7 @@ export class ProxySetCommand extends ProxyCommandBase { protected $analyticsService: IAnalyticsService, protected $logger: ILogger, protected $options: IOptions, - protected $proxyService: IProxyService + protected $proxyService: IProxyService, ) { super($analyticsService, $logger, $proxyService, proxySetCommandName); } @@ -49,7 +49,7 @@ export class ProxySetCommand extends ProxyCommandBase { if (noUrl) { if (!isInteractive()) { this.$errors.failWithHelp( - "Console is not interactive - you need to supply all command parameters." + "Console is not interactive - you need to supply all command parameters.", ); } else { urlString = await this.$prompter.getString("Url", { @@ -61,13 +61,13 @@ export class ProxySetCommand extends ProxyCommandBase { let urlObj = parse(urlString); if ((!urlObj.protocol || !urlObj.hostname) && !isInteractive()) { this.$errors.fail( - "The url you have entered is invalid please enter a valid url containing a valid protocol and hostname." + "The url you have entered is invalid please enter a valid url containing a valid protocol and hostname.", ); } while (!urlObj.protocol || !urlObj.hostname) { this.$logger.warn( - "The url you have entered is invalid please enter a valid url containing a valid protocol and hostname." + "The url you have entered is invalid please enter a valid url containing a valid protocol and hostname.", ); urlString = await this.$prompter.getString("Url", { allowEmpty: false }); urlObj = parse(urlString); @@ -86,7 +86,7 @@ export class ProxySetCommand extends ProxyCommandBase { password !== authCredentials.password) ) { this.$errors.fail( - "The credentials you have provided in the url address mismatch those passed as command line arguments." + "The credentials you have provided in the url address mismatch those passed as command line arguments.", ); } username = username || authCredentials.username; @@ -95,11 +95,11 @@ export class ProxySetCommand extends ProxyCommandBase { if (!isInteractive()) { if (noPort) { this.$errors.fail( - `The port you have specified (${port || "none"}) is not valid.` + `The port you have specified (${port || "none"}) is not valid.`, ); } else if (this.isPasswordRequired(username, password)) { this.$errors.failWithHelp( - "Console is not interactive - you need to supply all command parameters." + "Console is not interactive - you need to supply all command parameters.", ); } } @@ -114,7 +114,7 @@ export class ProxySetCommand extends ProxyCommandBase { if (!username) { this.$logger.info( - "In case your proxy requires authentication, please specify username and password. If authentication is not required, just leave it empty." + "In case your proxy requires authentication, please specify username and password. If authentication is not required, just leave it empty.", ); username = await this.$prompter.getString("Username", { defaultAction: () => "", @@ -134,7 +134,7 @@ export class ProxySetCommand extends ProxyCommandBase { if (!this.$hostInfo.isWindows) { this.$logger.warn( - `Note that storing credentials is not supported on ${platform()} yet.` + `Note that storing credentials is not supported on ${platform()} yet.`, ); } @@ -146,7 +146,7 @@ export class ProxySetCommand extends ProxyCommandBase { EOL; this.$logger.warn( - `${messageNote}Run '${clientName} proxy set --help' for more information.` + `${messageNote}Run '${clientName} proxy set --help' for more information.`, ); await this.$proxyService.setCache(settings); diff --git a/lib/common/constants.ts b/lib/common/constants.ts index 447efc7ca0..0f1ae1bcc1 100644 --- a/lib/common/constants.ts +++ b/lib/common/constants.ts @@ -63,8 +63,10 @@ export class EmulatorDiscoveryNames { export const DEVICE_LOG_EVENT_NAME = "deviceLogData"; export const IOS_LOG_PREDICATE = 'senderImagePath contains "NativeScript"'; -export const IOS_APP_CRASH_LOG_REG_EXP = /Fatal JavaScript exception \- application has been terminated/; -export const FAIL_LIVESYNC_LOG_REGEX = /Failed to refresh the application with RefreshRequest./; +export const IOS_APP_CRASH_LOG_REG_EXP = + /Fatal JavaScript exception - application has been terminated/; +export const FAIL_LIVESYNC_LOG_REGEX = + /Failed to refresh the application with RefreshRequest./; export const TARGET_FRAMEWORK_IDENTIFIERS = { Cordova: "Cordova", diff --git a/lib/common/declarations.d.ts b/lib/common/declarations.d.ts index 7051536343..7a0b5ee59e 100644 --- a/lib/common/declarations.d.ts +++ b/lib/common/declarations.d.ts @@ -6,7 +6,6 @@ import { } from "./definitions/google-analytics"; import * as child_process from "child_process"; -// tslint:disable-next-line:interface-name interface Object { [key: string]: any; } @@ -16,7 +15,6 @@ interface IStringDictionary extends IDictionary {} /** * Describes iTunes Connect application types */ -// tslint:disable-next-line:interface-name interface IiTunesConnectApplicationType { /** * Applications developed for iOS @@ -39,7 +37,6 @@ interface IiTunesConnectApplicationType { /** * Descibes iTunes Connect applications */ -// tslint:disable-next-line:interface-name interface IiTunesConnectApplication { /** * Unique Apple ID for each application. Automatically generated and assigned by Apple. @@ -154,7 +151,7 @@ interface IContentDeliveryBody { }; } -declare module Server { +declare namespace Server { interface IResponse { response: any; body?: any; @@ -1069,13 +1066,11 @@ interface IHostInfo { getMacOSVersion(): Promise; } -// tslint:disable-next-line:interface-name interface GenericFunction extends Function { (...args: any[]): T; } declare global { - // tslint:disable-next-line:interface-name interface Function { $inject: { args: string[]; @@ -1087,7 +1082,6 @@ declare global { * Extends Nodejs' Error interface. * The native interface already has name and message properties */ - // tslint:disable-next-line:interface-name interface Error { /** * Error's stack trace @@ -1588,7 +1582,6 @@ interface IDeferPromise extends IPromiseActions { /** * Describes service used for interaction with Notification Center */ -// tslint:disable-next-line:interface-name interface IiOSNotificationService { /** * Posts a notification and waits for a response. diff --git a/lib/common/decorators.ts b/lib/common/decorators.ts index c951fda9f2..8daaadf904 100644 --- a/lib/common/decorators.ts +++ b/lib/common/decorators.ts @@ -31,9 +31,9 @@ import { injector } from "./yok"; */ export function cache(): any { return ( - target: Object, + target: object, propertyKey: string, - descriptor: TypedPropertyDescriptor + descriptor: TypedPropertyDescriptor, ): TypedPropertyDescriptor => { let result: any; const propName: string = descriptor.value ? "value" : "get"; @@ -61,9 +61,9 @@ interface MemoizeOptions { let memoizeIDCounter = 0; export function memoize(options: MemoizeOptions): any { return ( - target: Object, + target: object, propertyKey: string, - descriptor: TypedPropertyDescriptor + descriptor: TypedPropertyDescriptor, ): TypedPropertyDescriptor => { // todo: remove once surely working as intended. const DEBUG = false; @@ -150,7 +150,7 @@ export function invokeBefore(methodName: string, methodArgs?: any[]): any { return ( target: any, propertyKey: string, - descriptor: TypedPropertyDescriptor + descriptor: TypedPropertyDescriptor, ): TypedPropertyDescriptor => { const originalValue = descriptor.value; descriptor.value = async function (...args: any[]) { @@ -168,9 +168,9 @@ export function invokeInit(): any { export function exported(moduleName: string): any { return ( - target: Object, + target: object, propertyKey: string, - descriptor: TypedPropertyDescriptor + descriptor: TypedPropertyDescriptor, ): TypedPropertyDescriptor => { injector.publicApi.__modules__[moduleName] = injector.publicApi.__modules__[moduleName] || {}; @@ -193,14 +193,13 @@ export function performanceLog(localInjector?: IInjector): any { return function ( target: any, propertyKey: string, - descriptor: PropertyDescriptor + descriptor: PropertyDescriptor, ): any { const originalMethod = descriptor.value; const className = target.constructor.name; const trackName = `${className}${AnalyticsEventLabelDelimiter}${propertyKey}`; - const performanceService: IPerformanceService = localInjector.resolve( - "performanceService" - ); + const performanceService: IPerformanceService = + localInjector.resolve("performanceService"); //needed for the returned function to have the same name as the original - used in hooks decorator const functionWrapper = { @@ -221,7 +220,7 @@ export function performanceLog(localInjector?: IInjector): any { trackName, start, end, - args + args, ); }) .catch((err) => { @@ -230,7 +229,7 @@ export function performanceLog(localInjector?: IInjector): any { trackName, start, end, - args + args, ); }); } @@ -252,13 +251,13 @@ export function performanceLog(localInjector?: IInjector): any { // inspired by https://github.com/NativeScript/NativeScript/blob/55dfe25938569edbec89255008e5ad9804901305/tns-core-modules/globals/globals.ts#L121-L137 export function deprecated( additionalInfo?: string, - localInjector?: IInjector + localInjector?: IInjector, ): any { const isDeprecatedMessage = " is deprecated."; return ( - target: Object, + target: object, key: string, - descriptor: TypedPropertyDescriptor + descriptor: TypedPropertyDescriptor, ): TypedPropertyDescriptor => { localInjector = localInjector || injector; additionalInfo = additionalInfo || ""; @@ -270,7 +269,7 @@ export function deprecated( descriptor.value = function (...args: any[]) { $logger.warn( - `${key.toString()}${isDeprecatedMessage} ${additionalInfo}` + `${key.toString()}${isDeprecatedMessage} ${additionalInfo}`, ); return originalMethod.apply(this, args); @@ -283,7 +282,7 @@ export function deprecated( const originalSetter = descriptor.set; descriptor.set = function (...args: any[]) { $logger.warn( - `${key.toString()}${isDeprecatedMessage} ${additionalInfo}` + `${key.toString()}${isDeprecatedMessage} ${additionalInfo}`, ); originalSetter.apply(this, args); @@ -294,7 +293,7 @@ export function deprecated( const originalGetter = descriptor.get; descriptor.get = function (...args: any[]) { $logger.warn( - `${key.toString()}${isDeprecatedMessage} ${additionalInfo}` + `${key.toString()}${isDeprecatedMessage} ${additionalInfo}`, ); return originalGetter.apply(this, args); @@ -311,7 +310,7 @@ export function deprecated( ((target).name || ((target).constructor && (target).constructor.name))) || target - }${isDeprecatedMessage} ${additionalInfo}` + }${isDeprecatedMessage} ${additionalInfo}`, ); return target; diff --git a/lib/common/definitions/commands-service.d.ts b/lib/common/definitions/commands-service.d.ts index 8aafba931d..975d58ee45 100644 --- a/lib/common/definitions/commands-service.d.ts +++ b/lib/common/definitions/commands-service.d.ts @@ -3,11 +3,11 @@ interface ICommandsService { allCommands(opts: { includeDevCommands: boolean }): string[]; tryExecuteCommand( commandName: string, - commandArguments: string[] + commandArguments: string[], ): Promise; executeCommandUnchecked( commandName: string, - commandArguments: string[] + commandArguments: string[], ): Promise; } diff --git a/lib/common/definitions/config.d.ts b/lib/common/definitions/config.d.ts index b44acce3d2..c2486c2329 100644 --- a/lib/common/definitions/config.d.ts +++ b/lib/common/definitions/config.d.ts @@ -1,4 +1,4 @@ -declare module Config { +declare namespace Config { interface IStaticConfig { PROJECT_FILE_NAME: string; CLIENT_NAME_KEY_IN_PROJECT_FILE?: string; diff --git a/lib/common/definitions/json-file-settings-service.d.ts b/lib/common/definitions/json-file-settings-service.d.ts index 3c20e52e83..41d0598bad 100644 --- a/lib/common/definitions/json-file-settings-service.d.ts +++ b/lib/common/definitions/json-file-settings-service.d.ts @@ -11,12 +11,12 @@ interface IUseCacheOpts { interface IJsonFileSettingsService { getSettingValue( settingName: string, - cacheOpts?: ICacheTimeoutOpts + cacheOpts?: ICacheTimeoutOpts, ): Promise; saveSetting( key: string, value: T, - cacheOpts?: IUseCacheOpts + cacheOpts?: IUseCacheOpts, ): Promise; removeSetting(key: string): Promise; loadUserSettingsFile(): Promise; diff --git a/lib/common/definitions/logger.d.ts b/lib/common/definitions/logger.d.ts index d0f6d7835c..f8633aea8f 100644 --- a/lib/common/definitions/logger.d.ts +++ b/lib/common/definitions/logger.d.ts @@ -34,8 +34,7 @@ declare global { layout: Layout; } - interface Log4JSEmitAppenderConfiguration - extends Log4JSAppenderConfiguration { + interface Log4JSEmitAppenderConfiguration extends Log4JSAppenderConfiguration { emitter: EventEmitter; } } diff --git a/lib/common/definitions/mobile.d.ts b/lib/common/definitions/mobile.d.ts index e5db0a23c1..edc11a6255 100644 --- a/lib/common/definitions/mobile.d.ts +++ b/lib/common/definitions/mobile.d.ts @@ -13,7 +13,7 @@ import { } from "../declarations"; declare global { - export module Mobile { + export namespace Mobile { /** * Describes available information for a device. */ diff --git a/lib/common/dispatchers.ts b/lib/common/dispatchers.ts index 1fa9edb065..4c30308159 100644 --- a/lib/common/dispatchers.ts +++ b/lib/common/dispatchers.ts @@ -29,7 +29,7 @@ export class CommandDispatcher implements ICommandDispatcher { private $options: IOptions, private $versionsService: IVersionsService, private $packageManager: IPackageManager, - private $terminalSpinnerService: ITerminalSpinnerService + private $terminalSpinnerService: ITerminalSpinnerService, ) {} public async dispatchCommand(): Promise { @@ -45,7 +45,7 @@ export class CommandDispatcher implements ICommandDispatcher { __dirname, "..", "..", - "package.json" + "package.json", ), }); this.$logger.trace("System information:"); @@ -76,7 +76,7 @@ export class CommandDispatcher implements ICommandDispatcher { await this.$commandsService.tryExecuteCommand( commandName, - commandArguments + commandArguments, ); } @@ -84,7 +84,7 @@ export class CommandDispatcher implements ICommandDispatcher { private async resolveCommand( commandName: string, commandArguments: string[], - argv: string[] + argv: string[], ) { // just a hook point return { commandName, commandArguments, argv }; @@ -142,14 +142,14 @@ export class CommandDispatcher implements ICommandDispatcher { nativescriptCliVersion.latestVersion, { loose: true, - } + }, ) ) { // up-to-date spinner.succeed("Up to date."); } else { spinner.info( - `New version of NativeScript CLI is available (${nativescriptCliVersion.latestVersion}), run '${updateCommand}' to update.` + `New version of NativeScript CLI is available (${nativescriptCliVersion.latestVersion}), run '${updateCommand}' to update.`, ); } } diff --git a/lib/common/helpers.ts b/lib/common/helpers.ts index d688eafb3d..0b6183f21c 100644 --- a/lib/common/helpers.ts +++ b/lib/common/helpers.ts @@ -117,7 +117,7 @@ export function regExpEscape(input: string): string { } export function getShortPluginName(pluginName: string): string { - return sanitizePluginName(pluginName).replace(/[\-]/g, "_"); + return sanitizePluginName(pluginName).replace(/[-]/g, "_"); } function sanitizePluginName(pluginName: string): string { @@ -153,10 +153,9 @@ export function deferPromise(): IDeferPromise { let reject: (reason?: any) => void; let isResolved = false; let isRejected = false; - let promise: Promise; let result: T | PromiseLike; - promise = new Promise((innerResolve, innerReject) => { + const promise = new Promise((innerResolve, innerReject) => { resolve = (value?: T | PromiseLike) => { isResolved = true; result = value; @@ -519,7 +518,7 @@ export function decorateMethod( after: (method2: any, self2: any, result2: any, args2: any[]) => Promise, ) { return ( - target: Object, + target: object, propertyKey: string, descriptor: TypedPropertyDescriptor, ) => { @@ -853,9 +852,9 @@ export function getFormattedMilliseconds(date: Date): string { //THE SOFTWARE. const CLASS_NAME = /class\s+([A-Z].+?)(?:\s+.*?)?\{/; -const CONSTRUCTOR_ARGS = /constructor\s*([^\(]*)\(\s*([^\)]*)\)/m; +const CONSTRUCTOR_ARGS = /constructor\s*([^(]*)\(\s*([^)]*)\)/m; const FN_NAME_AND_ARGS = - /^(?:function)?\s*([^\(]*)\(\s*([^\)]*)\)\s*(=>)?\s*[{_]/m; + /^(?:function)?\s*([^(]*)\(\s*([^)]*)\)\s*(=>)?\s*[{_]/m; const FN_ARG_SPLIT = /,/; const FN_ARG = /^\s*(_?)(\S+?)\1\s*$/; diff --git a/lib/common/host-info.ts b/lib/common/host-info.ts index 3ec7dacbe6..c91c7de37a 100644 --- a/lib/common/host-info.ts +++ b/lib/common/host-info.ts @@ -24,7 +24,10 @@ export class HostInfo implements IHostInfo { return this.$injector.resolve("logger"); } - constructor(private $errors: IErrors, private $injector: IInjector) {} + constructor( + private $errors: IErrors, + private $injector: IInjector, + ) {} public get isWindows() { return process.platform === HostInfo.WIN32_NAME; @@ -65,26 +68,26 @@ export class HostInfo implements IHostInfo { this.$logger.trace("Trying to get macOS version."); let macOSVersion: string; try { - const systemProfileOutput = await this.$childProcess.exec( - systemProfileCommand - ); + const systemProfileOutput = + await this.$childProcess.exec(systemProfileCommand); - const versionRegExp = /System Version:\s+?macOS\s+?(\d+\.\d+)(\.\d+)?\s+/g; + const versionRegExp = + /System Version:\s+?macOS\s+?(\d+\.\d+)(\.\d+)?\s+/g; const regExpMatchers = versionRegExp.exec(systemProfileOutput); macOSVersion = regExpMatchers && regExpMatchers[1]; if (macOSVersion) { this.$logger.trace( - `macOS version based on system_profiler is ${macOSVersion}.` + `macOS version based on system_profiler is ${macOSVersion}.`, ); return macOSVersion; } this.$logger.trace( - `Unable to get macOS version from ${systemProfileCommand} output.` + `Unable to get macOS version from ${systemProfileCommand} output.`, ); } catch (err) { this.$logger.trace( - `Unable to get macOS version from ${systemProfileCommand}. Error is: ${err}` + `Unable to get macOS version from ${systemProfileCommand}. Error is: ${err}`, ); } @@ -95,7 +98,7 @@ export class HostInfo implements IHostInfo { const majorVersion = osRelease && _.first(osRelease.split(".")); macOSVersion = majorVersion && `10.${+majorVersion - 4}`; this.$logger.trace( - `macOS version based on os.release() (${osRelease}) is ${macOSVersion}.` + `macOS version based on os.release() (${osRelease}) is ${macOSVersion}.`, ); return macOSVersion; } @@ -128,7 +131,7 @@ export class HostInfo implements IHostInfo { return true; } catch (e) { this.$errors.fail( - message || "An error occurred while reading the registry." + message || "An error occurred while reading the registry.", ); } } else { diff --git a/lib/common/logger/appenders/emit-appender.ts b/lib/common/logger/appenders/emit-appender.ts index 6033b61ed7..1ca0ca79e8 100644 --- a/lib/common/logger/appenders/emit-appender.ts +++ b/lib/common/logger/appenders/emit-appender.ts @@ -19,7 +19,7 @@ function emitAppender(layout: Function, emitter: EventEmitter) { export function configure( config: Log4JSEmitAppenderConfiguration, - layouts: any + layouts: any, ) { if (!config.emitter) { throw new Error("Emitter must be passed to emit-appender"); diff --git a/lib/common/messages/messages.ts b/lib/common/messages/messages.ts index 7e7de06703..3aa9099b6a 100644 --- a/lib/common/messages/messages.ts +++ b/lib/common/messages/messages.ts @@ -4,7 +4,6 @@ import { injector } from "../yok"; -/* tslint:disable:all */ export class Messages implements IMessages { Devices = { NotFoundDeviceByIdentifierErrorMessage: @@ -16,4 +15,3 @@ export class Messages implements IMessages { }; } injector.register("messages", Messages); -/* tslint:enable */ diff --git a/lib/common/mobile/android/android-debug-bridge-result-handler.ts b/lib/common/mobile/android/android-debug-bridge-result-handler.ts index 3cca8088e5..2bbac31f09 100644 --- a/lib/common/mobile/android/android-debug-bridge-result-handler.ts +++ b/lib/common/mobile/android/android-debug-bridge-result-handler.ts @@ -4,335 +4,340 @@ import { IErrors } from "../../declarations"; import { injector } from "../../yok"; export class AndroidDebugBridgeResultHandler - implements Mobile.IAndroidDebugBridgeResultHandler { - private static ANDROID_DEBUG_BRIDGE_ERRORS: Mobile.IAndroidDebugBridgeError[] = [ - { - name: "device unauthorized", - description: - "The device is not authorized. Please use the --emulator flag to run the application on on an emulator", - resultCode: 1, - }, - { - name: "No space left on device", - description: "No space left on device.", - resultCode: 1, - }, - { - name: "INSTALL_FAILED_ALREADY_EXISTS", - description: "The package is already installed.", - resultCode: -1, - }, - { - name: "INSTALL_FAILED_INVALID_APK", - description: "The package archive file is invalid.", - resultCode: -2, - }, - { - name: "INSTALL_FAILED_INVALID_URI", - description: "The URI passed in is invalid.", - resultCode: -3, - }, - { - name: "INSTALL_FAILED_INSUFFICIENT_STORAGE", - description: - "The package manager service found that the device didn't have enough storage space to install the app.", - resultCode: -4, - }, - { - name: "INSTALL_FAILED_DUPLICATE_PACKAGE", - description: "A package is already installed with the same name.", - resultCode: -5, - }, - { - name: "INSTALL_FAILED_NO_SHARED_USER", - description: "The requested shared user does not exist.", - resultCode: -6, - }, - { - name: "INSTALL_FAILED_UPDATE_INCOMPATIBLE", - description: - "A previously installed package of the same name has a different signature than the new package (and the old package's data was not removed).", - resultCode: -7, - }, - { - name: "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE", - description: - "The new package is requested a shared user which is already installed on the device and does not have matching signature.", - resultCode: -8, - }, - { - name: "INSTALL_FAILED_MISSING_SHARED_LIBRARY", - description: - "The new package uses a shared library that is not available.", - resultCode: -9, - }, - { - name: "INSTALL_FAILED_REPLACE_COULDNT_DELETE", - description: - "The new package uses a shared library that is not available.", - resultCode: -10, - }, - { - name: "INSTALL_FAILED_DEXOPT", - description: - "The new package failed while optimizing and validating its dex files, either because there was not enough storage or the validation failed.", - resultCode: -11, - }, - { - name: "INSTALL_FAILED_OLDER_SDK", - description: - "The new package failed because the current SDK version is older than that required by the package.", - resultCode: -12, - }, - { - name: "INSTALL_FAILED_CONFLICTING_PROVIDER", - description: - "The new package failed because it contains a content provider with the same authority as a provider already installed in the system.", - resultCode: -13, - }, - { - name: "INSTALL_FAILED_NEWER_SDK", - description: - "The new package failed because the current SDK version is newer than that required by the package.", - resultCode: -14, - }, - { - name: "INSTALL_FAILED_TEST_ONLY", - description: - "The new package failed because it has specified that it is a test-only package and the caller has not supplied the #INSTALL_ALLOW_TEST flag.", - resultCode: -15, - }, - { - name: "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE", - description: - "The package being installed contains native code, but none that is compatible with the device's CPU_ABI.", - resultCode: -16, - }, - { - name: "INSTALL_FAILED_MISSING_FEATURE", - description: "The new package uses a feature that is not available.", - resultCode: -17, - }, - { - name: "INSTALL_FAILED_CONTAINER_ERROR", - description: - "A secure container mount point couldn't be accessed on external media.", - resultCode: -18, - }, - { - name: "INSTALL_FAILED_INVALID_INSTALL_LOCATION", - description: - "The new package couldn't be installed in the specified install location.", - resultCode: -19, - }, - { - name: "INSTALL_FAILED_MEDIA_UNAVAILABLE", - description: - "The new package couldn't be installed in the specified install location because the media is not available.", - resultCode: -20, - }, - { - name: "INSTALL_FAILED_VERIFICATION_TIMEOUT", - description: - "The new package couldn't be installed because the verification timed out.", - resultCode: -21, - }, - { - name: "INSTALL_FAILED_VERIFICATION_FAILURE", - description: - "The new package couldn't be installed because the verification did not succeed.", - resultCode: -22, - }, - { - name: "INSTALL_FAILED_PACKAGE_CHANGED", - description: - "The package changed from what the calling program expected.", - resultCode: -23, - }, - { - name: "INSTALL_FAILED_UID_CHANGED", - description: - "The new package is assigned a different UID than it previously held.", - resultCode: -24, - }, - { - name: "INSTALL_FAILED_VERSION_DOWNGRADE", - description: - "The new package has an older version code than the currently installed package.", - resultCode: -25, - }, - { - name: "INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE", - description: - "The new package has target SDK low enough to not support runtime permissions.", - resultCode: -26, - }, - { - name: "INSTALL_PARSE_FAILED_NOT_APK", - description: - "The parser was given a path that is not a file, or does not end with the expected '.apk' extension.", - resultCode: -100, - }, - { - name: "INSTALL_PARSE_FAILED_BAD_MANIFEST", - description: - "The parser was unable to retrieve the AndroidManifest.xml file.", - resultCode: -101, - }, - { - name: "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION", - description: "The parser encountered an unexpected exception.", - resultCode: -102, - }, - { - name: "INSTALL_PARSE_FAILED_NO_CERTIFICATES", - description: "The parser did not find any certificates in the .apk.", - resultCode: -103, - }, - { - name: "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES", - description: - "The parser found inconsistent certificates on the files in the .apk.", - resultCode: -104, - }, - { - name: "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING", - description: - "the parser encountered a CertificateEncodingException in one of the files in the .apk.", - resultCode: -105, - }, - { - name: "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME", - description: - "The parser encountered a bad or missing package name in the manifest.", - resultCode: -106, - }, - { - name: "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID", - description: - "The parser encountered a bad shared user id name in the manifest.", - resultCode: -107, - }, - { - name: "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED", - description: - "The parser encountered some structural problem in the manifest.", - resultCode: -108, - }, - { - name: "INSTALL_PARSE_FAILED_MANIFEST_EMPTY", - description: - "The parser did not find any actionable tags (instrumentation or application) in the manifest.", - resultCode: -109, - }, - { - name: "INSTALL_FAILED_INTERNAL_ERROR", - description: - "The system failed to install the package because of system issues.", - resultCode: -110, - }, - { - name: "INSTALL_FAILED_USER_RESTRICTED", - description: - "The system failed to install the package because the user is restricted from installing apps.", - resultCode: -111, - }, - { - name: "INSTALL_FAILED_DUPLICATE_PERMISSION", - description: - "The system failed to install the package because it is attempting to define a permission that is already defined by some existing package.", - resultCode: -112, - }, - { - name: "INSTALL_FAILED_NO_MATCHING_ABIS", - description: - "The system failed to install the package because its packaged native code did not match any of the ABIs supported by the system.", - resultCode: -113, - }, - { - name: "NO_NATIVE_LIBRARIES ", - description: - "The package being processed did not contain any native code.", - resultCode: -114, - }, - { - name: "INSTALL_FAILED_ABORTED", - description: "The instalation failed because it was aborted.", - resultCode: -115, - }, - { - name: "DELETE_FAILED_INTERNAL_ERROR", - description: - "The system failed to delete the package for an unspecified reason.", - resultCode: -1, - }, - { - name: "DELETE_FAILED_DEVICE_POLICY_MANAGER", - description: - "The system failed to delete the package because it is the active DevicePolicy manager.", - resultCode: -2, - }, - { - name: "DELETE_FAILED_USER_RESTRICTED", - description: - "The system failed to delete the package since the user is restricted.", - resultCode: -3, - }, - { - name: "DELETE_FAILED_OWNER_BLOCKED", - description: - "The system failed to delete the package because a profile or device owner has marked the package as uninstallable.", - resultCode: -4, - }, - { - name: "DELETE_FAILED_ABORTED", - description: "The delete failed because it was aborted.", - resultCode: -5, - }, - { - name: "MOVE_FAILED_INSUFFICIENT_STORAGE", - description: - "The package hasn't been successfully moved by the system because of insufficient memory on specified media.", - resultCode: -1, - }, - { - name: "MOVE_FAILED_DOESNT_EXIST", - description: "The specified package doesn't exist.", - resultCode: -2, - }, - { - name: "MOVE_FAILED_SYSTEM_PACKAGE", - description: - "The specified package cannot be moved since its a system package.", - resultCode: -3, - }, - { - name: "MOVE_FAILED_FORWARD_LOCKED", - description: - "The specified package cannot be moved since its forward locked.", - resultCode: -4, - }, - { - name: "MOVE_FAILED_INVALID_LOCATION", - description: - "The specified package cannot be moved to the specified location.", - resultCode: -5, - }, - { - name: "MOVE_FAILED_INTERNAL_ERROR", - description: - "The specified package cannot be moved to the specified location.", - resultCode: -6, - }, - { - name: "MOVE_FAILED_OPERATION_PENDING", - description: - "The specified package already has an operation pending in the PackageHandler queue.", - resultCode: -7, - }, - ]; + implements Mobile.IAndroidDebugBridgeResultHandler +{ + private static ANDROID_DEBUG_BRIDGE_ERRORS: Mobile.IAndroidDebugBridgeError[] = + [ + { + name: "device unauthorized", + description: + "The device is not authorized. Please use the --emulator flag to run the application on on an emulator", + resultCode: 1, + }, + { + name: "No space left on device", + description: "No space left on device.", + resultCode: 1, + }, + { + name: "INSTALL_FAILED_ALREADY_EXISTS", + description: "The package is already installed.", + resultCode: -1, + }, + { + name: "INSTALL_FAILED_INVALID_APK", + description: "The package archive file is invalid.", + resultCode: -2, + }, + { + name: "INSTALL_FAILED_INVALID_URI", + description: "The URI passed in is invalid.", + resultCode: -3, + }, + { + name: "INSTALL_FAILED_INSUFFICIENT_STORAGE", + description: + "The package manager service found that the device didn't have enough storage space to install the app.", + resultCode: -4, + }, + { + name: "INSTALL_FAILED_DUPLICATE_PACKAGE", + description: "A package is already installed with the same name.", + resultCode: -5, + }, + { + name: "INSTALL_FAILED_NO_SHARED_USER", + description: "The requested shared user does not exist.", + resultCode: -6, + }, + { + name: "INSTALL_FAILED_UPDATE_INCOMPATIBLE", + description: + "A previously installed package of the same name has a different signature than the new package (and the old package's data was not removed).", + resultCode: -7, + }, + { + name: "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE", + description: + "The new package is requested a shared user which is already installed on the device and does not have matching signature.", + resultCode: -8, + }, + { + name: "INSTALL_FAILED_MISSING_SHARED_LIBRARY", + description: + "The new package uses a shared library that is not available.", + resultCode: -9, + }, + { + name: "INSTALL_FAILED_REPLACE_COULDNT_DELETE", + description: + "The new package uses a shared library that is not available.", + resultCode: -10, + }, + { + name: "INSTALL_FAILED_DEXOPT", + description: + "The new package failed while optimizing and validating its dex files, either because there was not enough storage or the validation failed.", + resultCode: -11, + }, + { + name: "INSTALL_FAILED_OLDER_SDK", + description: + "The new package failed because the current SDK version is older than that required by the package.", + resultCode: -12, + }, + { + name: "INSTALL_FAILED_CONFLICTING_PROVIDER", + description: + "The new package failed because it contains a content provider with the same authority as a provider already installed in the system.", + resultCode: -13, + }, + { + name: "INSTALL_FAILED_NEWER_SDK", + description: + "The new package failed because the current SDK version is newer than that required by the package.", + resultCode: -14, + }, + { + name: "INSTALL_FAILED_TEST_ONLY", + description: + "The new package failed because it has specified that it is a test-only package and the caller has not supplied the #INSTALL_ALLOW_TEST flag.", + resultCode: -15, + }, + { + name: "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE", + description: + "The package being installed contains native code, but none that is compatible with the device's CPU_ABI.", + resultCode: -16, + }, + { + name: "INSTALL_FAILED_MISSING_FEATURE", + description: "The new package uses a feature that is not available.", + resultCode: -17, + }, + { + name: "INSTALL_FAILED_CONTAINER_ERROR", + description: + "A secure container mount point couldn't be accessed on external media.", + resultCode: -18, + }, + { + name: "INSTALL_FAILED_INVALID_INSTALL_LOCATION", + description: + "The new package couldn't be installed in the specified install location.", + resultCode: -19, + }, + { + name: "INSTALL_FAILED_MEDIA_UNAVAILABLE", + description: + "The new package couldn't be installed in the specified install location because the media is not available.", + resultCode: -20, + }, + { + name: "INSTALL_FAILED_VERIFICATION_TIMEOUT", + description: + "The new package couldn't be installed because the verification timed out.", + resultCode: -21, + }, + { + name: "INSTALL_FAILED_VERIFICATION_FAILURE", + description: + "The new package couldn't be installed because the verification did not succeed.", + resultCode: -22, + }, + { + name: "INSTALL_FAILED_PACKAGE_CHANGED", + description: + "The package changed from what the calling program expected.", + resultCode: -23, + }, + { + name: "INSTALL_FAILED_UID_CHANGED", + description: + "The new package is assigned a different UID than it previously held.", + resultCode: -24, + }, + { + name: "INSTALL_FAILED_VERSION_DOWNGRADE", + description: + "The new package has an older version code than the currently installed package.", + resultCode: -25, + }, + { + name: "INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE", + description: + "The new package has target SDK low enough to not support runtime permissions.", + resultCode: -26, + }, + { + name: "INSTALL_PARSE_FAILED_NOT_APK", + description: + "The parser was given a path that is not a file, or does not end with the expected '.apk' extension.", + resultCode: -100, + }, + { + name: "INSTALL_PARSE_FAILED_BAD_MANIFEST", + description: + "The parser was unable to retrieve the AndroidManifest.xml file.", + resultCode: -101, + }, + { + name: "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION", + description: "The parser encountered an unexpected exception.", + resultCode: -102, + }, + { + name: "INSTALL_PARSE_FAILED_NO_CERTIFICATES", + description: "The parser did not find any certificates in the .apk.", + resultCode: -103, + }, + { + name: "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES", + description: + "The parser found inconsistent certificates on the files in the .apk.", + resultCode: -104, + }, + { + name: "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING", + description: + "the parser encountered a CertificateEncodingException in one of the files in the .apk.", + resultCode: -105, + }, + { + name: "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME", + description: + "The parser encountered a bad or missing package name in the manifest.", + resultCode: -106, + }, + { + name: "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID", + description: + "The parser encountered a bad shared user id name in the manifest.", + resultCode: -107, + }, + { + name: "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED", + description: + "The parser encountered some structural problem in the manifest.", + resultCode: -108, + }, + { + name: "INSTALL_PARSE_FAILED_MANIFEST_EMPTY", + description: + "The parser did not find any actionable tags (instrumentation or application) in the manifest.", + resultCode: -109, + }, + { + name: "INSTALL_FAILED_INTERNAL_ERROR", + description: + "The system failed to install the package because of system issues.", + resultCode: -110, + }, + { + name: "INSTALL_FAILED_USER_RESTRICTED", + description: + "The system failed to install the package because the user is restricted from installing apps.", + resultCode: -111, + }, + { + name: "INSTALL_FAILED_DUPLICATE_PERMISSION", + description: + "The system failed to install the package because it is attempting to define a permission that is already defined by some existing package.", + resultCode: -112, + }, + { + name: "INSTALL_FAILED_NO_MATCHING_ABIS", + description: + "The system failed to install the package because its packaged native code did not match any of the ABIs supported by the system.", + resultCode: -113, + }, + { + name: "NO_NATIVE_LIBRARIES ", + description: + "The package being processed did not contain any native code.", + resultCode: -114, + }, + { + name: "INSTALL_FAILED_ABORTED", + description: "The instalation failed because it was aborted.", + resultCode: -115, + }, + { + name: "DELETE_FAILED_INTERNAL_ERROR", + description: + "The system failed to delete the package for an unspecified reason.", + resultCode: -1, + }, + { + name: "DELETE_FAILED_DEVICE_POLICY_MANAGER", + description: + "The system failed to delete the package because it is the active DevicePolicy manager.", + resultCode: -2, + }, + { + name: "DELETE_FAILED_USER_RESTRICTED", + description: + "The system failed to delete the package since the user is restricted.", + resultCode: -3, + }, + { + name: "DELETE_FAILED_OWNER_BLOCKED", + description: + "The system failed to delete the package because a profile or device owner has marked the package as uninstallable.", + resultCode: -4, + }, + { + name: "DELETE_FAILED_ABORTED", + description: "The delete failed because it was aborted.", + resultCode: -5, + }, + { + name: "MOVE_FAILED_INSUFFICIENT_STORAGE", + description: + "The package hasn't been successfully moved by the system because of insufficient memory on specified media.", + resultCode: -1, + }, + { + name: "MOVE_FAILED_DOESNT_EXIST", + description: "The specified package doesn't exist.", + resultCode: -2, + }, + { + name: "MOVE_FAILED_SYSTEM_PACKAGE", + description: + "The specified package cannot be moved since its a system package.", + resultCode: -3, + }, + { + name: "MOVE_FAILED_FORWARD_LOCKED", + description: + "The specified package cannot be moved since its forward locked.", + resultCode: -4, + }, + { + name: "MOVE_FAILED_INVALID_LOCATION", + description: + "The specified package cannot be moved to the specified location.", + resultCode: -5, + }, + { + name: "MOVE_FAILED_INTERNAL_ERROR", + description: + "The specified package cannot be moved to the specified location.", + resultCode: -6, + }, + { + name: "MOVE_FAILED_OPERATION_PENDING", + description: + "The specified package already has an operation pending in the PackageHandler queue.", + resultCode: -7, + }, + ]; - constructor(private $logger: ILogger, private $errors: IErrors) {} + constructor( + private $logger: ILogger, + private $errors: IErrors, + ) {} public checkForErrors(adbResult: any): Mobile.IAndroidDebugBridgeError[] { const errors: Mobile.IAndroidDebugBridgeError[] = []; @@ -345,7 +350,7 @@ export class AndroidDebugBridgeResultHandler if (_.indexOf(adbResult, error.name) >= 0) { errors.push(error); } - } + }, ); } else { _.each( @@ -357,7 +362,7 @@ export class AndroidDebugBridgeResultHandler ) { errors.push(error); } - } + }, ); } } @@ -367,11 +372,11 @@ export class AndroidDebugBridgeResultHandler public handleErrors( errors: Mobile.IAndroidDebugBridgeError[], - treatErrorsAsWarnings?: boolean + treatErrorsAsWarnings?: boolean, ): void { _.each(errors, (error: Mobile.IAndroidDebugBridgeError) => { this.$logger.trace( - `Error name: ${error.name} result code: ${error.resultCode}` + `Error name: ${error.name} result code: ${error.resultCode}`, ); }); @@ -390,5 +395,5 @@ export class AndroidDebugBridgeResultHandler injector.register( "androidDebugBridgeResultHandler", - AndroidDebugBridgeResultHandler + AndroidDebugBridgeResultHandler, ); diff --git a/lib/common/mobile/android/android-debug-bridge.ts b/lib/common/mobile/android/android-debug-bridge.ts index 099e074df0..64165fb11a 100644 --- a/lib/common/mobile/android/android-debug-bridge.ts +++ b/lib/common/mobile/android/android-debug-bridge.ts @@ -17,7 +17,7 @@ export class AndroidDebugBridge implements Mobile.IAndroidDebugBridge { protected $errors: IErrors, protected $logger: ILogger, protected $staticConfig: Config.IStaticConfig, - protected $androidDebugBridgeResultHandler: Mobile.IAndroidDebugBridgeResultHandler + protected $androidDebugBridgeResultHandler: Mobile.IAndroidDebugBridgeResultHandler, ) {} @cache() @@ -27,7 +27,7 @@ export class AndroidDebugBridge implements Mobile.IAndroidDebugBridge { public async executeCommand( args: string[], - options?: Mobile.IAndroidDebugBridgeCommandOptions + options?: Mobile.IAndroidDebugBridgeCommandOptions, ): Promise { let event = "close"; const deviceIdentifier = options && options.deviceIdentifier; @@ -53,14 +53,14 @@ export class AndroidDebugBridge implements Mobile.IAndroidDebugBridge { command.args, event, childProcessOptions, - { throwError: false } + { throwError: false }, ); const errors = this.$androidDebugBridgeResultHandler.checkForErrors(result); if (errors && errors.length > 0) { this.$androidDebugBridgeResultHandler.handleErrors( errors, - treatErrorsAsWarnings + treatErrorsAsWarnings, ); } @@ -73,7 +73,7 @@ export class AndroidDebugBridge implements Mobile.IAndroidDebugBridge { @invokeInit() public getPropertyValue( deviceId: string, - propertyName: string + propertyName: string, ): Promise { return this.$childProcess.execFile(this.adbFilePath, [ "-s", @@ -125,7 +125,7 @@ export class AndroidDebugBridge implements Mobile.IAndroidDebugBridge { !!line && line.indexOf("List of devices attached") === -1 && line.indexOf("* daemon ") === -1 && - line.indexOf("adb server") === -1 + line.indexOf("adb server") === -1, ); resolve(adbDevices); @@ -147,7 +147,7 @@ export class AndroidDebugBridge implements Mobile.IAndroidDebugBridge { protected async composeCommand( params: string[], - identifier?: string + identifier?: string, ): Promise { const command = await this.$staticConfig.getAdbFilePath(); let deviceIdentifier: string[] = []; @@ -161,7 +161,7 @@ export class AndroidDebugBridge implements Mobile.IAndroidDebugBridge { public async executeShellCommand( args: string[], - options?: Mobile.IAndroidDebugBridgeCommandOptions + options?: Mobile.IAndroidDebugBridgeCommandOptions, ): Promise { args.unshift("shell"); const result = await this.executeCommand(args, options); @@ -171,10 +171,10 @@ export class AndroidDebugBridge implements Mobile.IAndroidDebugBridge { public async pushFile( localFilePath: string, - deviceFilePath: string + deviceFilePath: string, ): Promise { const fileDirectory = fromWindowsRelativePathToUnix( - path.dirname(deviceFilePath) + path.dirname(deviceFilePath), ); // starting from API level 28, the push command is returning an error if the directory does not exist await this.executeShellCommand(["mkdir", "-p", fileDirectory]); diff --git a/lib/common/mobile/android/android-device-file-system.ts b/lib/common/mobile/android/android-device-file-system.ts index 088abf87e6..16645d0ba4 100644 --- a/lib/common/mobile/android/android-device-file-system.ts +++ b/lib/common/mobile/android/android-device-file-system.ts @@ -17,12 +17,12 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { private $logger: ILogger, private $mobileHelper: Mobile.IMobileHelper, private $tempService: ITempService, - private $injector: IInjector + private $injector: IInjector, ) {} public async listFiles( devicePath: string, - appIdentifier?: string + appIdentifier?: string, ): Promise { let listCommandArgs = ["ls", "-a", devicePath]; if (appIdentifier) { @@ -35,7 +35,7 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { public async getFile( deviceFilePath: string, appIdentifier: string, - outputPath?: string + outputPath?: string, ): Promise { const stdout = !outputPath; @@ -65,7 +65,7 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { public async getFileContent( deviceFilePath: string, - appIdentifier: string + appIdentifier: string, ): Promise { const result = await this.adb.executeShellCommand(["cat", deviceFilePath]); return result; @@ -74,26 +74,26 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { public async putFile( localFilePath: string, deviceFilePath: string, - appIdentifier: string + appIdentifier: string, ): Promise { await this.adb.pushFile(localFilePath, deviceFilePath); } public async transferFiles( deviceAppData: Mobile.IDeviceAppData, - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): Promise { const directoriesToChmod: string[] = []; const transferredFiles: Mobile.ILocalToDevicePathData[] = []; const action = async ( - localToDevicePathData: Mobile.ILocalToDevicePathData + localToDevicePathData: Mobile.ILocalToDevicePathData, ) => { const fstat = this.$fs.getFsStats(localToDevicePathData.getLocalPath()); if (fstat.isFile()) { const devicePath = localToDevicePathData.getDevicePath(); await this.adb.pushFile( localToDevicePathData.getLocalPath(), - devicePath + devicePath, ); transferredFiles.push(localToDevicePathData); } else if (fstat.isDirectory()) { @@ -105,7 +105,7 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { await executeActionByChunks( localToDevicePaths, DEFAULT_CHUNK_SIZE, - action + action, ); const dirsChmodAction = (directoryToChmod: string) => @@ -114,7 +114,7 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { await executeActionByChunks( _.uniq(directoriesToChmod), DEFAULT_CHUNK_SIZE, - dirsChmodAction + dirsChmodAction, ); return transferredFiles; @@ -123,14 +123,14 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { public async transferDirectory( deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], - projectFilesPath: string + projectFilesPath: string, ): Promise { // starting from Android 9, adb push is throwing an exception when there are subfolders // the check could be removed when we start supporting only runtime versions with sockets const minAndroidWithoutAdbPushDir = "9.0.0"; const isAdbPushDirSupported = semver.lt( semver.coerce(deviceAppData.device.deviceInfo.version), - minAndroidWithoutAdbPushDir + minAndroidWithoutAdbPushDir, ); const deviceProjectDir = await deviceAppData.getDeviceProjectRootPath(); let transferredLocalToDevicePaths: Mobile.ILocalToDevicePathData[] = []; @@ -144,7 +144,7 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { if (transferredLocalToDevicePaths.length) { const filesToChmodOnDevice = transferredLocalToDevicePaths.map( - (localToDevicePath) => localToDevicePath.getDevicePath() + (localToDevicePath) => localToDevicePath.getDevicePath(), ); await this.chmodFiles(deviceProjectDir, filesToChmodOnDevice); } @@ -154,15 +154,15 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { private async chmodFiles( deviceProjectRoot: string, - filesToChmodOnDevice: string[] + filesToChmodOnDevice: string[], ) { const commandsDeviceFilePath = this.$mobileHelper.buildDevicePath( deviceProjectRoot, - "nativescript.commands.sh" + "nativescript.commands.sh", ); await this.createFileOnDevice( commandsDeviceFilePath, - `chmod 0777 ${filesToChmodOnDevice.join(" ")}` + `chmod 0777 ${filesToChmodOnDevice.join(" ")}`, ); await this.adb.executeShellCommand([commandsDeviceFilePath]); } @@ -171,19 +171,19 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { this.$logger.trace("Changed hashes are:", localToDevicePaths); const transferredFiles: Mobile.ILocalToDevicePathData[] = []; const transferFileAction = async ( - localToDevicePathData: Mobile.ILocalToDevicePathData + localToDevicePathData: Mobile.ILocalToDevicePathData, ) => { transferredFiles.push(localToDevicePathData); await this.transferFile( localToDevicePathData.getLocalPath(), - localToDevicePathData.getDevicePath() + localToDevicePathData.getDevicePath(), ); }; await executeActionByChunks( localToDevicePaths, DEFAULT_CHUNK_SIZE, - transferFileAction + transferFileAction, ); return transferredFiles; @@ -191,7 +191,7 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { public async transferFile( localPath: string, - devicePath: string + devicePath: string, ): Promise { this.$logger.trace(`Transfering ${localPath} to ${devicePath}`); const stats = this.$fs.getFsStats(localPath); @@ -204,7 +204,7 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { public async createFileOnDevice( deviceFilePath: string, - fileContent: string + fileContent: string, ): Promise { const hostTmpDir = await this.$tempService.mkdirSync("application-"); const commandsFileHostPath = path.join(hostTmpDir, "temp.commands.file"); @@ -217,21 +217,21 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { public async deleteFile( deviceFilePath: string, - appIdentifier: string + appIdentifier: string, ): Promise { await this.adb.executeShellCommand(["rm", "-rf", deviceFilePath]); } public async updateHashesOnDevice( hashes: IStringDictionary, - appIdentifier: string + appIdentifier: string, ): Promise { const deviceHashService = this.getDeviceHashService(appIdentifier); await deviceHashService.uploadHashFileToDevice(hashes); } public getDeviceHashService( - appIdentifier: string + appIdentifier: string, ): Mobile.IAndroidDeviceHashService { if (!this._deviceHashServices[appIdentifier]) { this._deviceHashServices[appIdentifier] = this.$injector.resolve( @@ -239,7 +239,7 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem { { adb: this.adb, appIdentifier, - } + }, ); } diff --git a/lib/common/mobile/android/android-device-hash-service.ts b/lib/common/mobile/android/android-device-hash-service.ts index 286f00a978..434b2c2029 100644 --- a/lib/common/mobile/android/android-device-hash-service.ts +++ b/lib/common/mobile/android/android-device-hash-service.ts @@ -7,7 +7,8 @@ import { IFileSystem, IStringDictionary } from "../../declarations"; import { ITempService } from "../../../definitions/temp-service"; export class AndroidDeviceHashService - implements Mobile.IAndroidDeviceHashService { + implements Mobile.IAndroidDeviceHashService +{ private static HASH_FILE_NAME = "hashes"; constructor( @@ -15,7 +16,7 @@ export class AndroidDeviceHashService private appIdentifier: string, private $fs: IFileSystem, private $mobileHelper: Mobile.IMobileHelper, - private $tempService: ITempService + private $tempService: ITempService, ) {} @cache() @@ -23,7 +24,7 @@ export class AndroidDeviceHashService return this.$mobileHelper.buildDevicePath( LiveSyncPaths.ANDROID_TMP_DIR_NAME, this.appIdentifier, - AndroidDeviceHashService.HASH_FILE_NAME + AndroidDeviceHashService.HASH_FILE_NAME, ); } @@ -52,12 +53,12 @@ export class AndroidDeviceHashService } public async updateHashes( - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): Promise { const oldShasums = (await this.getShasumsFromDevice()) || {}; await this.generateHashesFromLocalToDevicePaths( localToDevicePaths, - oldShasums + oldShasums, ); await this.uploadHashFileToDevice(oldShasums); @@ -65,10 +66,10 @@ export class AndroidDeviceHashService public async generateHashesFromLocalToDevicePaths( localToDevicePaths: Mobile.ILocalToDevicePathData[], - initialShasums: IStringDictionary = {} + initialShasums: IStringDictionary = {}, ): Promise { const action = async ( - localToDevicePathData: Mobile.ILocalToDevicePathData + localToDevicePathData: Mobile.ILocalToDevicePathData, ) => { const localPath = localToDevicePathData.getLocalPath(); if (this.$fs.getFsStats(localPath).isFile()) { @@ -81,14 +82,14 @@ export class AndroidDeviceHashService await executeActionByChunks( localToDevicePaths, DEFAULT_CHUNK_SIZE, - action + action, ); return initialShasums; } public getDevicePaths( - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): string[] { return _.map(localToDevicePaths, (localToDevicePathData) => { return `"${localToDevicePathData.getDevicePath()}"`; @@ -97,7 +98,7 @@ export class AndroidDeviceHashService public getChangedShasums( oldShasums: IStringDictionary, - currentShasums: IStringDictionary + currentShasums: IStringDictionary, ): IStringDictionary { if (!oldShasums) { return currentShasums; @@ -106,18 +107,18 @@ export class AndroidDeviceHashService return _.omitBy( currentShasums, (hash: string, pathToFile: string) => - !!oldShasums[pathToFile] && oldShasums[pathToFile] === hash + !!oldShasums[pathToFile] && oldShasums[pathToFile] === hash, ); } public async removeHashes( - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): Promise { const oldShasums = await this.getShasumsFromDevice(); if (oldShasums) { const fileToShasumDictionary = _.omit( oldShasums, - localToDevicePaths.map((ldp) => ldp.getLocalPath()) + localToDevicePaths.map((ldp) => ldp.getLocalPath()), ); await this.uploadHashFileToDevice(fileToShasumDictionary); return true; @@ -130,14 +131,14 @@ export class AndroidDeviceHashService private async getHashFileLocalPath(): Promise { return path.join( await this.getTempDir(), - AndroidDeviceHashService.HASH_FILE_NAME + AndroidDeviceHashService.HASH_FILE_NAME, ); } @cache() private getTempDir(): Promise { return this.$tempService.mkdirSync( - `android-device-hash-service-${this.appIdentifier}` + `android-device-hash-service-${this.appIdentifier}`, ); } diff --git a/lib/common/mobile/android/android-device.ts b/lib/common/mobile/android/android-device.ts index b230e02827..0c7884213f 100644 --- a/lib/common/mobile/android/android-device.ts +++ b/lib/common/mobile/android/android-device.ts @@ -59,7 +59,7 @@ export class AndroidDevice implements Mobile.IAndroidDevice { private $logger: ILogger, private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $logcatHelper: Mobile.ILogcatHelper, - private $injector: IInjector + private $injector: IInjector, ) {} @cache() @@ -69,11 +69,11 @@ export class AndroidDevice implements Mobile.IAndroidDevice { }); this.applicationManager = this.$injector.resolve( applicationManagerPath.AndroidApplicationManager, - { adb: this.adb, identifier: this.identifier } + { adb: this.adb, identifier: this.identifier }, ); this.fileSystem = this.$injector.resolve( fileSystemPath.AndroidDeviceFileSystem, - { adb: this.adb } + { adb: this.adb }, ); let details = await this.getDeviceDetails(["getprop"]); @@ -111,12 +111,14 @@ export class AndroidDevice implements Mobile.IAndroidDevice { : [DeviceConnectionType.USB]; if (this.isEmulator) { - this.deviceInfo.displayName = await this.$androidEmulatorServices.getRunningEmulatorName( - this.identifier - ); - this.deviceInfo.imageIdentifier = await this.$androidEmulatorServices.getRunningEmulatorImageIdentifier( - this.identifier - ); + this.deviceInfo.displayName = + await this.$androidEmulatorServices.getRunningEmulatorName( + this.identifier, + ); + this.deviceInfo.imageIdentifier = + await this.$androidEmulatorServices.getRunningEmulatorImageIdentifier( + this.identifier, + ); } this.$logger.trace(this.deviceInfo); @@ -146,12 +148,12 @@ export class AndroidDevice implements Mobile.IAndroidDevice { } private async getDeviceDetails( - shellCommandArgs: string[] + shellCommandArgs: string[], ): Promise { const parsedDetails: any = {}; this.$logger.trace( - `Trying to get information for Android device. Command is: ${shellCommandArgs}` + `Trying to get information for Android device. Command is: ${shellCommandArgs}`, ); try { @@ -161,16 +163,17 @@ export class AndroidDevice implements Mobile.IAndroidDevice { // sample line is "ro.build.version.release=4.4" in /system/build.prop // sample line from getprop is: [ro.build.version.release]: [6.0] // NOTE: some props do not have value: [ro.build.version.base_os]: [] - const match = /(?:\[?ro\.build\.version|ro\.product|ro\.build)\.(.+?)]?(?:\:|=)(?:\s*?\[)?(.*?)]?$/.exec( - value - ); + const match = + /(?:\[?ro\.build\.version|ro\.product|ro\.build)\.(.+?)]?(?::|=)(?:\s*?\[)?(.*?)]?$/.exec( + value, + ); if (match) { parsedDetails[match[1]] = match[2]; } }); } catch (err) { this.$logger.trace( - `Error while getting details from Android device. Command is: ${shellCommandArgs}. Error is: ${err}` + `Error while getting details from Android device. Command is: ${shellCommandArgs}. Error is: ${err}`, ); } @@ -189,7 +192,8 @@ export class AndroidDevice implements Mobile.IAndroidDevice { } private async getType(): Promise { - const runningEmulatorIds = await this.$androidEmulatorServices.getRunningEmulatorIds(); + const runningEmulatorIds = + await this.$androidEmulatorServices.getRunningEmulatorIds(); if ( _.find(runningEmulatorIds, (emulatorId) => emulatorId === this.identifier) ) { diff --git a/lib/common/mobile/android/android-emulator-services.ts b/lib/common/mobile/android/android-emulator-services.ts index 58e1d6b33c..ff5eb10bb6 100644 --- a/lib/common/mobile/android/android-emulator-services.ts +++ b/lib/common/mobile/android/android-emulator-services.ts @@ -3,7 +3,11 @@ import { getCurrentEpochTime, sleep } from "../../helpers"; import { EOL } from "os"; import * as _ from "lodash"; import { LoggerConfigData } from "../../../constants"; -import { IChildProcess, IUserSettingsService, IUtils } from "../../declarations"; +import { + IChildProcess, + IUserSettingsService, + IUtils, +} from "../../declarations"; import { injector } from "../../yok"; import * as semver from "semver"; @@ -197,7 +201,9 @@ export class AndroidEmulatorServices emulator.imageIdentifier, ); try { - const additionalArgs = await this.$userSettingsService.getSettingValue("androidEmulatorStartArgs"); + const additionalArgs = await this.$userSettingsService.getSettingValue< + string[] + >("androidEmulatorStartArgs"); if (additionalArgs?.length) { startEmulatorArgs.push(...additionalArgs); } diff --git a/lib/common/mobile/android/android-ini-file-parser.ts b/lib/common/mobile/android/android-ini-file-parser.ts index bcb478a4a8..00de5f274a 100644 --- a/lib/common/mobile/android/android-ini-file-parser.ts +++ b/lib/common/mobile/android/android-ini-file-parser.ts @@ -46,7 +46,7 @@ export class AndroidIniFileParser implements Mobile.IAndroidIniFileParser { } return result; }, - Object.create(null) + Object.create(null), ); } diff --git a/lib/common/mobile/android/android-log-filter.ts b/lib/common/mobile/android/android-log-filter.ts index 7030a9404d..db54a9e423 100644 --- a/lib/common/mobile/android/android-log-filter.ts +++ b/lib/common/mobile/android/android-log-filter.ts @@ -8,19 +8,19 @@ export class AndroidLogFilter implements Mobile.IPlatformLogFilter { // sample line is "11-23 12:39:07.310 1584 1597 I art : Background sticky concurrent mark sweep GC freed 21966(1780KB) AllocSpace objects, 4(80KB) LOS objects, 77% free, 840KB/3MB, paused 4.018ms total 158.629ms" // or '12-28 10:45:08.020 3329 3329 W chromium: [WARNING:data_reduction_proxy_settings.cc(328)] SPDY proxy OFF at startup' private static API_LEVEL_23_LINE_REGEX = - /.+?\s+?(?:[A-Z]\s+?)([A-Za-z \.]+?)\s*?\: (.*)/; + /.+?\s+?(?:[A-Z]\s+?)([A-Za-z .]+?)\s*?: (.*)/; constructor(private $loggingLevels: Mobile.ILoggingLevels) {} public filterData( data: string, - loggingOptions: Mobile.IDeviceLogOptions = {} + loggingOptions: Mobile.IDeviceLogOptions = {}, ): string { const specifiedLogLevel = (loggingOptions.logLevel || "").toUpperCase(); if (specifiedLogLevel === this.$loggingLevels.info) { const log = this.getConsoleLogFromLine( data, - loggingOptions.applicationPid + loggingOptions.applicationPid, ); if (log) { if (log.tag) { diff --git a/lib/common/mobile/android/device-android-debug-bridge.ts b/lib/common/mobile/android/device-android-debug-bridge.ts index 10214cb5fd..9d6c8d3da8 100644 --- a/lib/common/mobile/android/device-android-debug-bridge.ts +++ b/lib/common/mobile/android/device-android-debug-bridge.ts @@ -9,27 +9,28 @@ interface IComposeCommandResult { export class DeviceAndroidDebugBridge extends AndroidDebugBridge - implements Mobile.IDeviceAndroidDebugBridge { + implements Mobile.IDeviceAndroidDebugBridge +{ constructor( private identifier: string, protected $childProcess: IChildProcess, protected $errors: IErrors, protected $logger: ILogger, protected $staticConfig: Config.IStaticConfig, - protected $androidDebugBridgeResultHandler: Mobile.IAndroidDebugBridgeResultHandler + protected $androidDebugBridgeResultHandler: Mobile.IAndroidDebugBridgeResultHandler, ) { super( $childProcess, $errors, $logger, $staticConfig, - $androidDebugBridgeResultHandler + $androidDebugBridgeResultHandler, ); } public async sendBroadcastToDevice( action: string, - extras?: IStringDictionary + extras?: IStringDictionary, ): Promise { extras = extras || {}; const broadcastCommand = ["am", "broadcast", "-a", `${action}`]; @@ -47,7 +48,7 @@ export class DeviceAndroidDebugBridge } protected async composeCommand( - params: string[] + params: string[], ): Promise { return super.composeCommand(params, this.identifier); } diff --git a/lib/common/mobile/android/genymotion/genymotion-service.ts b/lib/common/mobile/android/genymotion/genymotion-service.ts index 25a3cf1f90..8a9cdd5b7a 100644 --- a/lib/common/mobile/android/genymotion/genymotion-service.ts +++ b/lib/common/mobile/android/genymotion/genymotion-service.ts @@ -14,7 +14,8 @@ import { IChildProcess, IFileSystem, IDictionary } from "../../../declarations"; import { injector } from "../../../yok"; export class AndroidGenymotionService - implements Mobile.IAndroidVirtualDeviceService { + implements Mobile.IAndroidVirtualDeviceService +{ constructor( private $adb: Mobile.IAndroidDebugBridge, private $childProcess: IChildProcess, @@ -22,30 +23,29 @@ export class AndroidGenymotionService private $emulatorHelper: Mobile.IEmulatorHelper, private $fs: IFileSystem, private $logger: ILogger, - private $virtualBoxService: Mobile.IVirtualBoxService + private $virtualBoxService: Mobile.IVirtualBoxService, ) {} public async getEmulatorImages( - adbDevicesOutput: string[] + adbDevicesOutput: string[], ): Promise { const availableEmulatorsOutput = await this.getEmulatorImagesCore(); - const runningEmulatorIds = await this.getRunningEmulatorIds( - adbDevicesOutput - ); + const runningEmulatorIds = + await this.getRunningEmulatorIds(adbDevicesOutput); const runningEmulators = await settlePromises( _.map(runningEmulatorIds, (emulatorId) => this.getRunningEmulatorData( emulatorId, - availableEmulatorsOutput.devices - ) - ) + availableEmulatorsOutput.devices, + ), + ), ); const devices = availableEmulatorsOutput.devices.map( (emulator) => this.$emulatorHelper.getEmulatorByImageIdentifier( emulator.imageIdentifier, - runningEmulators - ) || emulator + runningEmulators, + ) || emulator, ); return { devices, @@ -54,12 +54,12 @@ export class AndroidGenymotionService } public async getRunningEmulatorIds( - adbDevicesOutput: string[] + adbDevicesOutput: string[], ): Promise { const results = await Promise.all( []>_(adbDevicesOutput) .filter( - (r) => !r.match(AndroidVirtualDevice.RUNNING_AVD_EMULATOR_REGEX) + (r) => !r.match(AndroidVirtualDevice.RUNNING_AVD_EMULATOR_REGEX), ) .map(async (row) => { const match = row.match(/^(.+?)\s+device$/); @@ -74,7 +74,7 @@ export class AndroidGenymotionService return Promise.resolve(undefined); }) - .value() + .value(), ); return _(results) @@ -106,32 +106,32 @@ export class AndroidGenymotionService public async getRunningEmulatorName(emulatorId: string): Promise { const output = await this.$adb.getPropertyValue( emulatorId, - "ro.product.model" + "ro.product.model", ); this.$logger.trace(output); return (_.first(output.split(EOL))).trim(); } public async getRunningEmulatorImageIdentifier( - emulatorId: string + emulatorId: string, ): Promise { const adbDevices = await this.$adb.getDevicesSafe(); const emulatorImages = (await this.getEmulatorImages(adbDevices)).devices; const emulator = await this.getRunningEmulatorData( emulatorId, - emulatorImages + emulatorImages, ); return emulator ? emulator.imageIdentifier : null; } private async getRunningEmulatorData( runningEmulatorId: string, - availableEmulators: Mobile.IDeviceInfo[] + availableEmulators: Mobile.IDeviceInfo[], ): Promise { const emulatorName = await this.getRunningEmulatorName(runningEmulatorId); const runningEmulator = this.$emulatorHelper.getEmulatorByIdOrName( emulatorName, - availableEmulators + availableEmulators, ); if (!runningEmulator) { return null; @@ -139,7 +139,7 @@ export class AndroidGenymotionService this.$emulatorHelper.setRunningAndroidEmulatorProperties( runningEmulatorId, - runningEmulator + runningEmulator, ); return runningEmulator; @@ -161,7 +161,7 @@ export class AndroidGenymotionService } private async parseListVmsOutput( - vms: Mobile.IVirtualBoxVm[] + vms: Mobile.IVirtualBoxVm[], ): Promise { const configurationError = await this.getConfigurationError(); const devices: Mobile.IDeviceInfo[] = []; @@ -169,7 +169,7 @@ export class AndroidGenymotionService for (const vm of vms) { try { const output = await this.$virtualBoxService.enumerateGuestProperties( - vm.id + vm.id, ); if ( output && @@ -182,8 +182,8 @@ export class AndroidGenymotionService vm.id, vm.name, output.error, - configurationError - ) + configurationError, + ), ); } } catch (err) { @@ -199,7 +199,7 @@ export class AndroidGenymotionService id: string, name: string, error: string, - configurationError: string + configurationError: string, ): Mobile.IDeviceInfo { return { identifier: null, @@ -231,7 +231,7 @@ export class AndroidGenymotionService private async isGenymotionEmulator(emulatorId: string): Promise { const manufacturer = await this.$adb.getPropertyValue( emulatorId, - "ro.product.manufacturer" + "ro.product.manufacturer", ); if (manufacturer && manufacturer.match(/^Genymotion/i)) { return true; @@ -239,7 +239,7 @@ export class AndroidGenymotionService const buildProduct = await this.$adb.getPropertyValue( emulatorId, - "ro.build.product" + "ro.build.product", ); if (buildProduct && _.includes(buildProduct.toLowerCase(), "vbox")) { return true; @@ -264,14 +264,14 @@ In case you have installed Genymotion in a different location, please add the pa this.pathToEmulatorExecutable, [], {}, - { throwError: false } + { throwError: false }, ); // When player is spawned, it always prints message on stderr. if ( result && result.stderr && result.stderr.indexOf( - AndroidVirtualDevice.GENYMOTION_DEFAULT_STDERR_STRING + AndroidVirtualDevice.GENYMOTION_DEFAULT_STDERR_STRING, ) === -1 ) { this.$logger.trace("Configuration error for Genymotion", result); diff --git a/lib/common/mobile/android/genymotion/virtualbox-service.ts b/lib/common/mobile/android/genymotion/virtualbox-service.ts index cba5236d90..3c49f81c59 100644 --- a/lib/common/mobile/android/genymotion/virtualbox-service.ts +++ b/lib/common/mobile/android/genymotion/virtualbox-service.ts @@ -17,7 +17,7 @@ export class VirtualBoxService implements Mobile.IVirtualBoxService { private $childProcess: IChildProcess, private $fs: IFileSystem, private $hostInfo: IHostInfo, - private $logger: ILogger + private $logger: ILogger, ) {} public async listVms(): Promise { @@ -48,7 +48,7 @@ export class VirtualBoxService implements Mobile.IVirtualBoxService { } public async enumerateGuestProperties( - id: string + id: string, ): Promise { let result: ISpawnResult = null; const vBoxManagePath = await this.getvBoxManagePath(); @@ -92,12 +92,12 @@ export class VirtualBoxService implements Mobile.IVirtualBoxService { */ const result: any = await getWinRegPropertyValue( "\\Software\\Oracle\\VirtualBox", - "InstallDir" + "InstallDir", ); searchPath = result && result.value ? result.value : null; } catch (err) { this.$logger.trace( - `Error while trying to get InstallDir property for \\Software\\Oracle\\VirtualBox. More info: ${err}.` + `Error while trying to get InstallDir property for \\Software\\Oracle\\VirtualBox. More info: ${err}.`, ); } @@ -124,7 +124,7 @@ export class VirtualBoxService implements Mobile.IVirtualBoxService { ]; const result = searchPaths .map((searchPath) => - path.join(searchPath, this.vBoxManageExecutableNames[process.platform]) + path.join(searchPath, this.vBoxManageExecutableNames[process.platform]), ) .find((searchPath) => this.$fs.exists(searchPath)); return result; diff --git a/lib/common/mobile/android/logcat-helper.ts b/lib/common/mobile/android/logcat-helper.ts index 76268ec07e..ee56eb0cce 100644 --- a/lib/common/mobile/android/logcat-helper.ts +++ b/lib/common/mobile/android/logcat-helper.ts @@ -22,7 +22,7 @@ export class LogcatHelper implements Mobile.ILogcatHelper { private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $logger: ILogger, private $injector: IInjector, - private $devicesService: Mobile.IDevicesService + private $devicesService: Mobile.IDevicesService, ) { this.mapDevicesLoggingData = Object.create(null); } @@ -40,7 +40,7 @@ export class LogcatHelper implements Mobile.ILogcatHelper { const logcatStream = await this.getLogcatStream( deviceIdentifier, - options.pid + options.pid, ); const lineStream = byline(logcatStream.stdout); @@ -57,7 +57,7 @@ export class LogcatHelper implements Mobile.ILogcatHelper { if (code !== 0) { this.$logger.trace( - "ADB process exited with code " + code.toString() + "ADB process exited with code " + code.toString(), ); } } catch (err) { @@ -71,14 +71,14 @@ export class LogcatHelper implements Mobile.ILogcatHelper { this.$deviceLogProvider.logData( line, this.$devicePlatformsConstants.Android, - deviceIdentifier + deviceIdentifier, ); } }); const appStartTrackingStream = await this.getAppStartTrackingLogcatStream( deviceIdentifier, - options.appId + options.appId, ); this.mapDevicesLoggingData[deviceIdentifier].appStartTrackingProcess = @@ -92,11 +92,11 @@ export class LogcatHelper implements Mobile.ILogcatHelper { if (!this.mapDevicesLoggingData[deviceIdentifier]?.loggingProcess) return; const lines = (lineBuffer.toString() || "").split("\n"); - for (let line of lines) { + for (const line of lines) { // 2024-06-26 16:43:22.286 630-659 ActivityManager system_server I Start proc 8854:org.nativescript.uitestsapp/u0a190 for next-top-activity {org.nativescript.uitestsapp/com.tns.NativeScriptActivity} const startProc = /Start proc (?[0-9]+):(?.+?)\//.exec( - line + line, ); if ( @@ -115,7 +115,7 @@ export class LogcatHelper implements Mobile.ILogcatHelper { public async dump(deviceIdentifier: string): Promise { const adb: Mobile.IDeviceAndroidDebugBridge = this.$injector.resolve( DeviceAndroidDebugBridge, - { identifier: deviceIdentifier } + { identifier: deviceIdentifier }, ); const logcatDumpStream = await adb.executeCommand(["logcat", "-d"], { returnChildProcess: true, @@ -167,18 +167,17 @@ export class LogcatHelper implements Mobile.ILogcatHelper { !!device.deviceInfo.version && semver.gte( semver.coerce(device.deviceInfo.version), - minAndroidWithLogcatPidSupport + minAndroidWithLogcatPidSupport, ) ); } private async getLogcatStream(deviceIdentifier: string, pid?: string) { - const isLogcatPidSupported = await this.isLogcatPidSupported( - deviceIdentifier - ); + const isLogcatPidSupported = + await this.isLogcatPidSupported(deviceIdentifier); const adb: Mobile.IDeviceAndroidDebugBridge = this.$injector.resolve( DeviceAndroidDebugBridge, - { identifier: deviceIdentifier } + { identifier: deviceIdentifier }, ); // -T 1 - shows only new logs after starting adb logcat @@ -211,11 +210,11 @@ export class LogcatHelper implements Mobile.ILogcatHelper { private async getAppStartTrackingLogcatStream( deviceIdentifier: string, - appId?: string + appId?: string, ) { const adb: Mobile.IDeviceAndroidDebugBridge = this.$injector.resolve( DeviceAndroidDebugBridge, - { identifier: deviceIdentifier } + { identifier: deviceIdentifier }, ); // -b system - shows the system buffer/logs only diff --git a/lib/common/mobile/application-manager-base.ts b/lib/common/mobile/application-manager-base.ts index c61e89a6bd..5a2ecbb996 100644 --- a/lib/common/mobile/application-manager-base.ts +++ b/lib/common/mobile/application-manager-base.ts @@ -17,7 +17,7 @@ export abstract class ApplicationManagerBase constructor( protected $logger: ILogger, protected $hooksService: IHooksService, - protected $deviceLogProvider: Mobile.IDeviceLogProvider + protected $deviceLogProvider: Mobile.IDeviceLogProvider, ) { super(); } @@ -31,11 +31,10 @@ export abstract class ApplicationManagerBase public async reinstallApplication( appIdentifier: string, packageFilePath: string, - buildData?: IBuildData + buildData?: IBuildData, ): Promise { - const isApplicationInstalled = await this.isApplicationInstalled( - appIdentifier - ); + const isApplicationInstalled = + await this.isApplicationInstalled(appIdentifier); if (isApplicationInstalled && buildData?.clean) { await this.uninstallApplication(appIdentifier); @@ -45,7 +44,7 @@ export abstract class ApplicationManagerBase } public async restartApplication( - appData: Mobile.IApplicationData + appData: Mobile.IApplicationData, ): Promise { await this.stopApplication(appData); await this.startApplication(appData); @@ -73,20 +72,20 @@ export abstract class ApplicationManagerBase const newAppIdentifiers = _.difference( currentlyInstalledAppIdentifiers, - previouslyInstalledAppIdentifiers + previouslyInstalledAppIdentifiers, ); const removedAppIdentifiers = _.difference( previouslyInstalledAppIdentifiers, - currentlyInstalledAppIdentifiers + currentlyInstalledAppIdentifiers, ); this.lastInstalledAppIdentifiers = currentlyInstalledAppIdentifiers; _.each(newAppIdentifiers, (appIdentifier) => - this.emit("applicationInstalled", appIdentifier) + this.emit("applicationInstalled", appIdentifier), ); _.each(removedAppIdentifiers, (appIdentifier) => - this.emit("applicationUninstalled", appIdentifier) + this.emit("applicationUninstalled", appIdentifier), ); await this.checkForAvailableDebuggableAppsChanges(); @@ -100,7 +99,7 @@ export abstract class ApplicationManagerBase resolve(); } } - } + }, ); } @@ -108,13 +107,13 @@ export abstract class ApplicationManagerBase } public async tryStartApplication( - appData: Mobile.IApplicationData + appData: Mobile.IApplicationData, ): Promise { try { await this.startApplication(appData); } catch (err) { this.$logger.trace( - `Unable to start application ${appData.appId} with name ${appData.projectName}. Error is: ${err.message}` + `Unable to start application ${appData.appId} with name ${appData.projectName}. Error is: ${err.message}`, ); } } @@ -122,21 +121,21 @@ export abstract class ApplicationManagerBase public abstract installApplication( packageFilePath: string, appIdentifier?: string, - buildData?: IBuildData + buildData?: IBuildData, ): Promise; public abstract uninstallApplication(appIdentifier: string): Promise; public abstract startApplication( - appData: Mobile.IApplicationData + appData: Mobile.IApplicationData, ): Promise; public abstract stopApplication( - appData: Mobile.IApplicationData + appData: Mobile.IApplicationData, ): Promise; public abstract getInstalledApplications(): Promise; public abstract getDebuggableApps(): Promise< Mobile.IDeviceApplicationInformation[] >; public abstract getDebuggableAppViews( - appIdentifiers: string[] + appIdentifiers: string[], ): Promise>; private async checkForAvailableDebuggableAppsChanges(): Promise { @@ -147,12 +146,12 @@ export abstract class ApplicationManagerBase const newAvailableDebuggableApps = _.differenceBy( currentlyAvailableDebuggableApps, previouslyAvailableDebuggableApps, - "appIdentifier" + "appIdentifier", ); const notAvailableAppsForDebugging = _.differenceBy( previouslyAvailableDebuggableApps, currentlyAvailableDebuggableApps, - "appIdentifier" + "appIdentifier", ); this.lastAvailableDebuggableApps = currentlyAvailableDebuggableApps; @@ -161,7 +160,7 @@ export abstract class ApplicationManagerBase newAvailableDebuggableApps, (appInfo: Mobile.IDeviceApplicationInformation) => { this.emit("debuggableAppFound", appInfo); - } + }, ); _.each( @@ -175,7 +174,7 @@ export abstract class ApplicationManagerBase // Prevent emitting debuggableViewLost when application cannot be debugged anymore. delete this.lastAvailableDebuggableAppViews[appInfo.appIdentifier]; } - } + }, ); const cordovaDebuggableAppIdentifiers = _(currentlyAvailableDebuggableApps) @@ -184,7 +183,7 @@ export abstract class ApplicationManagerBase .value(); const currentlyAvailableAppViews = await this.getDebuggableAppViews( - cordovaDebuggableAppIdentifiers + cordovaDebuggableAppIdentifiers, ); _.each( @@ -196,12 +195,12 @@ export abstract class ApplicationManagerBase const newAvailableViews = _.differenceBy( currentlyAvailableViews, previouslyAvailableViews, - "id" + "id", ); const notAvailableViews = _.differenceBy( previouslyAvailableViews, currentlyAvailableViews, - "id" + "id", ); _.each(notAvailableViews, (debugWebViewInfo) => { @@ -216,12 +215,12 @@ export abstract class ApplicationManagerBase const keptViews = _.differenceBy( currentlyAvailableViews, newAvailableViews, - "id" + "id", ); _.each(keptViews, (view) => { const previousTimeViewInfo = _.find( previouslyAvailableViews, - (previousView) => previousView.id === view.id + (previousView) => previousView.id === view.id, ); if (!_.isEqual(view, previousTimeViewInfo)) { this.emit("debuggableViewChanged", appIdentifier, view); @@ -230,7 +229,7 @@ export abstract class ApplicationManagerBase this.lastAvailableDebuggableAppViews[appIdentifier] = currentlyAvailableViews; - } + }, ); } } diff --git a/lib/common/mobile/device-emitter.ts b/lib/common/mobile/device-emitter.ts index afb13823fd..37de63d56d 100644 --- a/lib/common/mobile/device-emitter.ts +++ b/lib/common/mobile/device-emitter.ts @@ -9,7 +9,7 @@ import { injector } from "../yok"; export class DeviceEmitter extends EventEmitter { constructor( private $deviceLogProvider: EventEmitter, - private $devicesService: Mobile.IDevicesService + private $devicesService: Mobile.IDevicesService, ) { super(); @@ -24,24 +24,22 @@ export class DeviceEmitter extends EventEmitter { this.attachApplicationChangedHandlers(device); // await: Do not await as this will require to mark the lambda with async keyword, but there's no way to await the lambda itself. - /* tslint:disable:no-floating-promises */ device.openDeviceLogStream(); - /* tslint:enable:no-floating-promises */ - } + }, ); this.$devicesService.on( DeviceDiscoveryEventNames.DEVICE_LOST, (device: Mobile.IDevice) => { this.emit(DeviceDiscoveryEventNames.DEVICE_LOST, device.deviceInfo); - } + }, ); this.$devicesService.on( DeviceDiscoveryEventNames.DEVICE_UPDATED, (device: Mobile.IDevice) => { this.emit(DeviceDiscoveryEventNames.DEVICE_UPDATED, device.deviceInfo); - } + }, ); this.$deviceLogProvider.on("data", (identifier: string, data: any) => { @@ -52,14 +50,14 @@ export class DeviceEmitter extends EventEmitter { EmulatorDiscoveryNames.EMULATOR_IMAGE_FOUND, (emulator: Mobile.IDeviceInfo) => { this.emit(EmulatorDiscoveryNames.EMULATOR_IMAGE_FOUND, emulator); - } + }, ); this.$devicesService.on( EmulatorDiscoveryNames.EMULATOR_IMAGE_LOST, (emulator: Mobile.IDeviceInfo) => { this.emit(EmulatorDiscoveryNames.EMULATOR_IMAGE_LOST, emulator); - } + }, ); } @@ -70,9 +68,9 @@ export class DeviceEmitter extends EventEmitter { this.emit( "applicationInstalled", device.deviceInfo.identifier, - appIdentifier + appIdentifier, ); - } + }, ); device.applicationManager.on( @@ -81,68 +79,68 @@ export class DeviceEmitter extends EventEmitter { this.emit( "applicationUninstalled", device.deviceInfo.identifier, - appIdentifier + appIdentifier, ); - } + }, ); device.applicationManager.on( "debuggableAppFound", (debuggableAppInfo: Mobile.IDeviceApplicationInformation) => { this.emit("debuggableAppFound", debuggableAppInfo); - } + }, ); device.applicationManager.on( "debuggableAppLost", (debuggableAppInfo: Mobile.IDeviceApplicationInformation) => { this.emit("debuggableAppLost", debuggableAppInfo); - } + }, ); device.applicationManager.on( "debuggableViewFound", ( appIdentifier: string, - debuggableWebViewInfo: Mobile.IDebugWebViewInfo + debuggableWebViewInfo: Mobile.IDebugWebViewInfo, ) => { this.emit( "debuggableViewFound", device.deviceInfo.identifier, appIdentifier, - debuggableWebViewInfo + debuggableWebViewInfo, ); - } + }, ); device.applicationManager.on( "debuggableViewLost", ( appIdentifier: string, - debuggableWebViewInfo: Mobile.IDebugWebViewInfo + debuggableWebViewInfo: Mobile.IDebugWebViewInfo, ) => { this.emit( "debuggableViewLost", device.deviceInfo.identifier, appIdentifier, - debuggableWebViewInfo + debuggableWebViewInfo, ); - } + }, ); device.applicationManager.on( "debuggableViewChanged", ( appIdentifier: string, - debuggableWebViewInfo: Mobile.IDebugWebViewInfo + debuggableWebViewInfo: Mobile.IDebugWebViewInfo, ) => { this.emit( "debuggableViewChanged", device.deviceInfo.identifier, appIdentifier, - debuggableWebViewInfo + debuggableWebViewInfo, ); - } + }, ); } } diff --git a/lib/common/mobile/device-log-emitter.ts b/lib/common/mobile/device-log-emitter.ts index dbb59149a5..3234c50b29 100644 --- a/lib/common/mobile/device-log-emitter.ts +++ b/lib/common/mobile/device-log-emitter.ts @@ -8,7 +8,7 @@ export class DeviceLogEmitter extends DeviceLogProviderBase { protected $logFilter: Mobile.ILogFilter, $logger: ILogger, private $loggingLevels: Mobile.ILoggingLevels, - protected $logSourceMapService: Mobile.ILogSourceMapService + protected $logSourceMapService: Mobile.ILogSourceMapService, ) { super($logFilter, $logger, $logSourceMapService); } @@ -16,18 +16,18 @@ export class DeviceLogEmitter extends DeviceLogProviderBase { public logData( line: string, platform: string, - deviceIdentifier: string + deviceIdentifier: string, ): void { this.setDefaultLogLevelForDevice(deviceIdentifier); const loggingOptions = this.getDeviceLogOptionsForDevice( - deviceIdentifier + deviceIdentifier, ) || { logLevel: this.$loggingLevels.info, projectDir: null }; let data = this.$logFilter.filterData(platform, line, loggingOptions); data = this.$logSourceMapService.replaceWithOriginalFileLocations( platform, data, - loggingOptions + loggingOptions, ); if (data) { @@ -42,7 +42,7 @@ export class DeviceLogEmitter extends DeviceLogProviderBase { deviceIdentifier, (deviceLogOptions: Mobile.IDeviceLogOptions) => deviceLogOptions.logLevel, - logLevel.toUpperCase() + logLevel.toUpperCase(), ); } else { this.$logFilter.loggingLevel = logLevel.toUpperCase(); @@ -50,9 +50,8 @@ export class DeviceLogEmitter extends DeviceLogProviderBase { _.keys(this.devicesLogOptions).forEach((deviceId) => { this.devicesLogOptions[deviceId] = this.devicesLogOptions[deviceId] || {}; - this.devicesLogOptions[ - deviceId - ].logLevel = this.$logFilter.loggingLevel; + this.devicesLogOptions[deviceId].logLevel = + this.$logFilter.loggingLevel; }); } } diff --git a/lib/common/mobile/device-log-provider-base.ts b/lib/common/mobile/device-log-provider-base.ts index 1329cde6da..6d55ae776b 100644 --- a/lib/common/mobile/device-log-provider-base.ts +++ b/lib/common/mobile/device-log-provider-base.ts @@ -11,17 +11,17 @@ export abstract class DeviceLogProviderBase constructor( protected $logFilter: Mobile.ILogFilter, protected $logger: ILogger, - protected $logSourceMapService: Mobile.ILogSourceMapService + protected $logSourceMapService: Mobile.ILogSourceMapService, ) { super(); } public async setSourceFileLocation( - pathToOriginalFile: string + pathToOriginalFile: string, ): Promise { try { await this.$logSourceMapService.setSourceMapConsumerForFile( - pathToOriginalFile + pathToOriginalFile, ); } catch (err) { this.$logger.trace("Error while trying to set source map file", err); @@ -31,23 +31,23 @@ export abstract class DeviceLogProviderBase public abstract logData( lineText: string, platform: string, - deviceIdentifier: string + deviceIdentifier: string, ): void; public abstract setLogLevel( logLevel: string, - deviceIdentifier?: string + deviceIdentifier?: string, ): void; public setApplicationPidForDevice( deviceIdentifier: string, - pid: string + pid: string, ): void { this.setDeviceLogOptionsProperty( deviceIdentifier, (deviceLogOptions: Mobile.IDeviceLogOptions) => deviceLogOptions.applicationPid, - pid + pid, ); } @@ -56,31 +56,31 @@ export abstract class DeviceLogProviderBase deviceIdentifier, (deviceLogOptions: Mobile.IDeviceLogOptions) => deviceLogOptions.applicationId, - appId + appId, ); } public setProjectNameForDevice( deviceIdentifier: string, - projectName: string + projectName: string, ): void { this.setDeviceLogOptionsProperty( deviceIdentifier, (deviceLogOptions: Mobile.IDeviceLogOptions) => deviceLogOptions.projectName, - projectName + projectName, ); } public setProjectDirForDevice( deviceIdentifier: string, - projectDir: string + projectDir: string, ): void { this.setDeviceLogOptionsProperty( deviceIdentifier, (deviceLogOptions: Mobile.IDeviceLogOptions) => deviceLogOptions.projectDir, - projectDir + projectDir, ); } @@ -107,7 +107,7 @@ export abstract class DeviceLogProviderBase } protected getDeviceLogOptionsForDevice( - deviceIdentifier: string + deviceIdentifier: string, ): Mobile.IDeviceLogOptions { const loggingOptions = this.devicesLogOptions[deviceIdentifier]; if (!loggingOptions) { @@ -120,7 +120,7 @@ export abstract class DeviceLogProviderBase protected setDeviceLogOptionsProperty( deviceIdentifier: string, propNameFunction: Function, - propertyValue: string | boolean + propertyValue: string | boolean, ): void { const propertyName = getPropertyName(propNameFunction); diff --git a/lib/common/mobile/device-log-provider.ts b/lib/common/mobile/device-log-provider.ts index d5c548f780..8ecb1a1a3f 100644 --- a/lib/common/mobile/device-log-provider.ts +++ b/lib/common/mobile/device-log-provider.ts @@ -94,7 +94,7 @@ export class DeviceLogProvider extends DeviceLogProviderBase { // todo: extract into an injectable printer/logger service let shouldPrepend = false; - let splitIndexes: number[] = []; + const splitIndexes: number[] = []; const lines = data .split(/\n(CONSOLE)/) .map((line, index, lines) => { diff --git a/lib/common/mobile/ios/device/ios-application-manager.ts b/lib/common/mobile/ios/device/ios-application-manager.ts index b1199c1d8c..1777f6df07 100644 --- a/lib/common/mobile/ios/device/ios-application-manager.ts +++ b/lib/common/mobile/ios/device/ios-application-manager.ts @@ -22,7 +22,7 @@ export class IOSApplicationManager extends ApplicationManagerBase { private $iOSNotificationService: IiOSNotificationService, private $iosDeviceOperations: IIOSDeviceOperations, private $options: IOptions, - protected $deviceLogProvider: Mobile.IDeviceLogProvider + protected $deviceLogProvider: Mobile.IDeviceLogProvider, ) { super($logger, $hooksService, $deviceLogProvider); } @@ -43,9 +43,9 @@ export class IOSApplicationManager extends ApplicationManagerBase { [this.device.deviceInfo.identifier], (err: IOSDeviceLib.IDeviceError) => { this.$errors.fail( - `Failed to install ${packageFilePath} on device with identifier ${err.deviceId}. Error is: ${err.message}` + `Failed to install ${packageFilePath} on device with identifier ${err.deviceId}. Error is: ${err.message}`, ); - } + }, ); } @@ -56,14 +56,14 @@ export class IOSApplicationManager extends ApplicationManagerBase { const applicationsOnDeviceInfo = _.first( (await this.$iosDeviceOperations.apps([deviceIdentifier]))[ deviceIdentifier - ] + ], ); const applicationsOnDevice = applicationsOnDeviceInfo ? applicationsOnDeviceInfo.response : []; this.$logger.trace( "Result when getting applications information: ", - JSON.stringify(applicationsOnDevice, null, 2) + JSON.stringify(applicationsOnDevice, null, 2), ); this.applicationsLiveSyncInfos = _.map(applicationsOnDevice, (app) => ({ @@ -81,26 +81,26 @@ export class IOSApplicationManager extends ApplicationManagerBase { [this.device.deviceInfo.identifier], (err: IOSDeviceLib.IDeviceError) => { this.$logger.warn( - `Failed to uninstall ${appIdentifier} on device with identifier ${err.deviceId}` + `Failed to uninstall ${appIdentifier} on device with identifier ${err.deviceId}`, ); - } + }, ); this.$logger.trace( "Application %s has been uninstalled successfully.", - appIdentifier + appIdentifier, ); } public async startApplication( - appData: Mobile.IStartApplicationData + appData: Mobile.IStartApplicationData, ): Promise { if (!(await this.isApplicationInstalled(appData.appId))) { this.$errors.fail( "Invalid application id: %s. All available application ids are: %s%s ", appData.appId, EOL, - this.applicationsLiveSyncInfos.join(EOL) + this.applicationsLiveSyncInfos.join(EOL), ); } @@ -108,12 +108,12 @@ export class IOSApplicationManager extends ApplicationManagerBase { await this.runApplicationCore(appData); this.$logger.info( - `Successfully run application ${appData.appId} on device with ID ${this.device.deviceInfo.identifier}.` + `Successfully run application ${appData.appId} on device with ID ${this.device.deviceInfo.identifier}.`, ); } public async stopApplication( - appData: Mobile.IApplicationData + appData: Mobile.IApplicationData, ): Promise { const { appId } = appData; @@ -132,14 +132,14 @@ export class IOSApplicationManager extends ApplicationManagerBase { await action(); } catch (err) { this.$logger.trace( - `Error when trying to stop application ${appId} on device ${this.device.deviceInfo.identifier}: ${err}. Retrying stop operation.` + `Error when trying to stop application ${appId} on device ${this.device.deviceInfo.identifier}: ${err}. Retrying stop operation.`, ); await action(); } } public async restartApplication( - appData: Mobile.IStartApplicationData + appData: Mobile.IStartApplicationData, ): Promise { try { await this.setDeviceLogData(appData); @@ -148,22 +148,22 @@ export class IOSApplicationManager extends ApplicationManagerBase { } catch (err) { await this.$iOSNotificationService.postNotification( this.device.deviceInfo.identifier, - `${appData.appId}:NativeScript.LiveSync.RestartApplication` + `${appData.appId}:NativeScript.LiveSync.RestartApplication`, ); throw err; } } private async setDeviceLogData( - appData: Mobile.IApplicationData + appData: Mobile.IApplicationData, ): Promise { this.$deviceLogProvider.setProjectNameForDevice( this.device.deviceInfo.identifier, - appData.projectName + appData.projectName, ); this.$deviceLogProvider.setProjectDirForDevice( this.device.deviceInfo.identifier, - appData.projectDir + appData.projectDir, ); if (!this.$options.justlaunch) { await this.startDeviceLog(); @@ -171,7 +171,7 @@ export class IOSApplicationManager extends ApplicationManagerBase { } private async runApplicationCore( - appData: Mobile.IStartApplicationData + appData: Mobile.IStartApplicationData, ): Promise { const waitForDebugger = (!!appData.waitForDebugger).toString(); await this.$iosDeviceOperations.start([ @@ -195,7 +195,7 @@ export class IOSApplicationManager extends ApplicationManagerBase { } public getDebuggableAppViews( - appIdentifiers: string[] + appIdentifiers: string[], ): Promise> { // Implement when we can find debuggable applications for iOS. return Promise.resolve(null); diff --git a/lib/common/mobile/ios/device/ios-device.ts b/lib/common/mobile/ios/device/ios-device.ts index 90dd12e7bc..7791955339 100644 --- a/lib/common/mobile/ios/device/ios-device.ts +++ b/lib/common/mobile/ios/device/ios-device.ts @@ -30,16 +30,16 @@ export class IOSDevice extends IOSDeviceBase { private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $iOSDeviceProductNameMapper: Mobile.IiOSDeviceProductNameMapper, private $iosDeviceOperations: IIOSDeviceOperations, - private $mobileHelper: Mobile.IMobileHelper + private $mobileHelper: Mobile.IMobileHelper, ) { super(); this.applicationManager = this.$injector.resolve( applicationManagerPath.IOSApplicationManager, - { device: this, devicePointer: this.deviceActionInfo } + { device: this, devicePointer: this.deviceActionInfo }, ); this.fileSystem = this.$injector.resolve( fileSystemPath.IOSDeviceFileSystem, - { device: this, devicePointer: this.deviceActionInfo } + { device: this, devicePointer: this.deviceActionInfo }, ); const productType = deviceActionInfo.productType; const isTablet = this.$mobileHelper.isiOSTablet(productType); @@ -58,7 +58,7 @@ export class IOSDevice extends IOSDeviceBase { isTablet: isTablet, displayName: this.$iOSDeviceProductNameMapper.resolveProductName( - deviceActionInfo.deviceName + deviceActionInfo.deviceName, ) || deviceActionInfo.deviceName, model: this.$iOSDeviceProductNameMapper.resolveProductName(productType), version: deviceActionInfo.productVersion, @@ -81,7 +81,8 @@ export class IOSDevice extends IOSDeviceBase { public get isOnlyWiFiConnected(): boolean { const result = this.deviceInfo.connectionTypes.every( - (connectionType) => connectionType === constants.DeviceConnectionType.Wifi + (connectionType) => + connectionType === constants.DeviceConnectionType.Wifi, ); return result; } @@ -92,7 +93,7 @@ export class IOSDevice extends IOSDeviceBase { this._deviceLogHandler = this.actionOnDeviceLog.bind(this); this.$iosDeviceOperations.on( commonConstants.DEVICE_LOG_EVENT_NAME, - this._deviceLogHandler + this._deviceLogHandler, ); this.$iosDeviceOperations.startDeviceLog(this.deviceInfo.identifier); } @@ -102,7 +103,7 @@ export class IOSDevice extends IOSDeviceBase { await this.$iOSSocketRequestExecutor.executeAttachRequest( this, constants.AWAIT_NOTIFICATION_TIMEOUT_SECONDS, - appId + appId, ); const port = await super.getDebuggerPort(appId); const deviceId = this.deviceInfo.identifier; @@ -113,7 +114,7 @@ export class IOSDevice extends IOSDeviceBase { await this.$iosDeviceOperations.connectToPort([ { deviceId: deviceId, port: port }, ]) - )[deviceId] + )[deviceId], ); const _socket = new net.Socket(); _socket.connect(deviceResponse.port, deviceResponse.host); @@ -128,7 +129,7 @@ export class IOSDevice extends IOSDeviceBase { this.$deviceLogProvider.logData( response.message, this.$devicePlatformsConstants.iOS, - this.deviceInfo.identifier + this.deviceInfo.identifier, ); } } @@ -137,7 +138,7 @@ export class IOSDevice extends IOSDeviceBase { if (this._deviceLogHandler) { this.$iosDeviceOperations.removeListener( commonConstants.DEVICE_LOG_EVENT_NAME, - this._deviceLogHandler + this._deviceLogHandler, ); } } @@ -146,7 +147,7 @@ export class IOSDevice extends IOSDeviceBase { let activeArchitecture = ""; if (productType) { productType = productType.toLowerCase().trim(); - const majorVersionAsString = productType.match(/.*?(\d+)\,(\d+)/)[1]; + const majorVersionAsString = productType.match(/.*?(\d+),(\d+)/)[1]; const majorVersion = parseInt(majorVersionAsString); let isArm64Architecture = false; //https://en.wikipedia.org/wiki/List_of_iOS_devices diff --git a/lib/common/mobile/ios/ios-device-base.ts b/lib/common/mobile/ios/ios-device-base.ts index 83b2ab56b5..6425ab5e05 100644 --- a/lib/common/mobile/ios/ios-device-base.ts +++ b/lib/common/mobile/ios/ios-device-base.ts @@ -15,7 +15,7 @@ export abstract class IOSDeviceBase implements Mobile.IiOSDevice { abstract isEmulator: boolean; abstract isOnlyWiFiConnected: boolean; abstract openDeviceLogStream( - options?: Mobile.IiOSLogStreamOptions + options?: Mobile.IiOSLogStreamOptions, ): Promise; @performanceLog() @@ -23,7 +23,7 @@ export abstract class IOSDeviceBase implements Mobile.IiOSDevice { appId: string, projectName: string, projectDir: string, - ensureAppStarted: boolean = false + ensureAppStarted: boolean = false, ): Promise { return this.$lockService.executeActionWithLock(async () => { if (this.cachedSockets[appId]) { @@ -41,7 +41,7 @@ export abstract class IOSDeviceBase implements Mobile.IiOSDevice { } } catch (err) { this.$logger.trace( - `Unable to start application ${appId} on device ${this.deviceInfo.identifier} in getDebugSocket method. Error is: ${err}` + `Unable to start application ${appId} on device ${this.deviceInfo.identifier} in getDebugSocket method. Error is: ${err}`, ); } @@ -57,14 +57,12 @@ export abstract class IOSDeviceBase implements Mobile.IiOSDevice { }, `ios-debug-socket-${this.deviceInfo.identifier}-${appId}.lock`); } - protected abstract getDebugSocketCore( - appId: string - ): Promise; + protected abstract getDebugSocketCore(appId: string): Promise; protected async attachToDebuggerFoundEvent( appId: string, projectName: string, - projectDir: string + projectDir: string, ): Promise { await this.startDeviceLogProcess(projectName, projectDir); await this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(appId); @@ -106,16 +104,16 @@ export abstract class IOSDeviceBase implements Mobile.IiOSDevice { private async startDeviceLogProcess( projectName: string, - projectDir: string + projectDir: string, ): Promise { if (projectName) { this.$deviceLogProvider.setProjectNameForDevice( this.deviceInfo.identifier, - projectName + projectName, ); this.$deviceLogProvider.setProjectDirForDevice( this.deviceInfo.identifier, - projectDir + projectDir, ); } diff --git a/lib/common/mobile/ios/ios-log-filter.ts b/lib/common/mobile/ios/ios-log-filter.ts index e5f1188659..a63f3799f1 100644 --- a/lib/common/mobile/ios/ios-log-filter.ts +++ b/lib/common/mobile/ios/ios-log-filter.ts @@ -1,13 +1,14 @@ import { injector } from "../../yok"; export class IOSLogFilter implements Mobile.IPlatformLogFilter { - protected infoFilterRegex = /^.*?(AppBuilder|Cordova|NativeScript).*?(:.*?|:.*?|:.*?)$/im; + protected infoFilterRegex = + /^.*?(AppBuilder|Cordova|NativeScript).*?(:.*?|:.*?|:.*?)$/im; constructor(private $loggingLevels: Mobile.ILoggingLevels) {} public filterData( data: string, - loggingOptions: Mobile.IDeviceLogOptions = {} + loggingOptions: Mobile.IDeviceLogOptions = {}, ): string { const specifiedLogLevel = (loggingOptions.logLevel || "").toUpperCase(); const pid = loggingOptions && loggingOptions.applicationPid; diff --git a/lib/common/mobile/ios/simulator/ios-emulator-services.ts b/lib/common/mobile/ios/simulator/ios-emulator-services.ts index c7510ab1ed..f2ec06d9b5 100644 --- a/lib/common/mobile/ios/simulator/ios-emulator-services.ts +++ b/lib/common/mobile/ios/simulator/ios-emulator-services.ts @@ -14,11 +14,11 @@ class IosEmulatorServices implements Mobile.IiOSSimulatorService { private $logger: ILogger, private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $iOSSimResolver: Mobile.IiOSSimResolver, - private $mobileHelper: Mobile.IMobileHelper + private $mobileHelper: Mobile.IMobileHelper, ) {} public async startEmulator( - options: Mobile.IStartEmulatorOptions + options: Mobile.IStartEmulatorOptions, ): Promise { let error = null; @@ -31,7 +31,7 @@ class IosEmulatorServices implements Mobile.IiOSSimulatorService { const { devices } = await this.tryGetiOSSimDevices(); options.emulatorIdOrName = devices.find( (device) => - device.platform === this.$devicePlatformsConstants.visionOS + device.platform === this.$devicePlatformsConstants.visionOS, )?.id; } @@ -62,20 +62,20 @@ class IosEmulatorServices implements Mobile.IiOSSimulatorService { } public async getRunningEmulatorImageIdentifier( - emulatorId: string + emulatorId: string, ): Promise { return ""; } public async postDarwinNotification( notification: string, - deviceId: string + deviceId: string, ): Promise { return this.$iOSSimResolver.iOSSim.sendNotification(notification, deviceId); } public async connectToPort( - data: Mobile.IConnectToPortData + data: Mobile.IConnectToPortData, ): Promise { try { // node v17+ resolves localhost to ::1 (ipv6) instead of 127.0.0.1 (ipv4) @@ -127,7 +127,7 @@ class IosEmulatorServices implements Mobile.IiOSSimulatorService { } private convertSimDeviceToDeviceInfo( - simDevice: Mobile.IiSimDevice + simDevice: Mobile.IiSimDevice, ): Mobile.IDeviceInfo { return { imageIdentifier: simDevice.id, diff --git a/lib/common/mobile/ios/simulator/ios-sim-resolver.ts b/lib/common/mobile/ios/simulator/ios-sim-resolver.ts index aac666f2be..78b80e7b58 100644 --- a/lib/common/mobile/ios/simulator/ios-sim-resolver.ts +++ b/lib/common/mobile/ios/simulator/ios-sim-resolver.ts @@ -18,7 +18,7 @@ export class IOSSimResolver implements Mobile.IiOSSimResolver { return path.join( require.resolve(IOSSimResolver.iOSSimName), "..", - IOSSimResolver.iOSStandaloneExecutableName + IOSSimResolver.iOSStandaloneExecutableName, ); } } diff --git a/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts b/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts index 45202bde0e..d0cd13369d 100644 --- a/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts +++ b/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts @@ -27,14 +27,14 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { protected $deviceLogProvider: Mobile.IDeviceLogProvider, private $tempService: ITempService, $logger: ILogger, - $hooksService: IHooksService + $hooksService: IHooksService, ) { super($logger, $hooksService, $deviceLogProvider); } public async getInstalledApplications(): Promise { return this.iosSim.getInstalledApplications( - this.device.deviceInfo.identifier + this.device.deviceInfo.identifier, ); } @@ -48,7 +48,7 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { await this.$fs.unzip(packageFilePath, dir); const app = _.find( this.$fs.readDirectory(dir), - (directory) => path.extname(directory) === ".app" + (directory) => path.extname(directory) === ".app", ); if (app) { packageFilePath = path.join(dir, app); @@ -57,7 +57,7 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { await this.iosSim.installApplication( this.device.deviceInfo.identifier, - packageFilePath + packageFilePath, ); } @@ -65,32 +65,32 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { await this.detachNativeDebugger(appIdentifier); return this.iosSim.uninstallApplication( this.device.deviceInfo.identifier, - appIdentifier + appIdentifier, ); } public async startApplication( - appData: Mobile.IStartApplicationData + appData: Mobile.IStartApplicationData, ): Promise { const args = process.env.IOS_SIMULATOR_RUN_ARGS || ""; const options = appData.waitForDebugger ? { waitForDebugger: true, args: `--nativescript-debug-brk ${args}`.trim(), - } + } : args - ? { args } - : {}; + ? { args } + : {}; await this.setDeviceLogData(appData); const launchResult = await this.iosSim.startApplication( this.device.deviceInfo.identifier, appData.appId, - options + options, ); const pid = getPidFromiOSSimulatorLogs(appData.appId, launchResult); this.$deviceLogProvider.setApplicationPidForDevice( this.device.deviceInfo.identifier, - pid + pid, ); if (appData.waitForDebugger) { this.attachNativeDebugger(appData.appId, pid); @@ -98,7 +98,7 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { } public async stopApplication( - appData: Mobile.IApplicationData + appData: Mobile.IApplicationData, ): Promise { const { appId } = appData; @@ -108,7 +108,7 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { await this.iosSim.stopApplication( this.device.deviceInfo.identifier, appData.appId, - appData.projectName + appData.projectName, ); } @@ -119,7 +119,7 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { } public async getDebuggableAppViews( - appIdentifiers: string[] + appIdentifiers: string[], ): Promise> { // Implement when we can find debuggable applications for iOS. return Promise.resolve(null); @@ -156,15 +156,15 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { } private async setDeviceLogData( - appData: Mobile.IApplicationData + appData: Mobile.IApplicationData, ): Promise { this.$deviceLogProvider.setProjectNameForDevice( this.device.deviceInfo.identifier, - appData.projectName + appData.projectName, ); this.$deviceLogProvider.setProjectDirForDevice( this.device.deviceInfo.identifier, - appData.projectDir + appData.projectDir, ); if (!this.$options.justlaunch) { diff --git a/lib/common/mobile/ios/simulator/ios-simulator-device.ts b/lib/common/mobile/ios/simulator/ios-simulator-device.ts index fa52f04088..ed159675b5 100644 --- a/lib/common/mobile/ios/simulator/ios-simulator-device.ts +++ b/lib/common/mobile/ios/simulator/ios-simulator-device.ts @@ -28,16 +28,16 @@ export class IOSSimulator extends IOSDeviceBase implements Mobile.IiOSDevice { private $iOSEmulatorServices: Mobile.IiOSSimulatorService, private $iOSNotification: IiOSNotification, private $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider, - protected $logger: ILogger + protected $logger: ILogger, ) { super(); this.applicationManager = this.$injector.resolve( applicationManagerPath.IOSSimulatorApplicationManager, - { iosSim: this.$iOSSimResolver.iOSSim, device: this } + { iosSim: this.$iOSSimResolver.iOSSim, device: this }, ); this.fileSystem = this.$injector.resolve( fileSystemPath.IOSSimulatorFileSystem, - { iosSim: this.$iOSSimResolver.iOSSim } + { iosSim: this.$iOSSimResolver.iOSSim }, ); this.deviceInfo = { imageIdentifier: this.simulator.id, @@ -65,7 +65,7 @@ export class IOSSimulator extends IOSDeviceBase implements Mobile.IiOSDevice { @cache() public async openDeviceLogStream( - options?: Mobile.IiOSLogStreamOptions + options?: Mobile.IiOSLogStreamOptions, ): Promise { options = options || {}; options.predicate = options.hasOwnProperty("predicate") @@ -73,7 +73,7 @@ export class IOSSimulator extends IOSDeviceBase implements Mobile.IiOSDevice { : constants.IOS_LOG_PREDICATE; return this.$iOSSimulatorLogProvider.startLogProcess( this.simulator.id, - options + options, ); } @@ -81,11 +81,11 @@ export class IOSSimulator extends IOSDeviceBase implements Mobile.IiOSDevice { let socket: net.Socket; const attachRequestMessage = this.$iOSNotification.getAttachRequest( appId, - this.deviceInfo.identifier + this.deviceInfo.identifier, ); await this.$iOSEmulatorServices.postDarwinNotification( attachRequestMessage, - this.deviceInfo.identifier + this.deviceInfo.identifier, ); // Retry posting the notification every five seconds, in case the AttachRequest @@ -94,7 +94,7 @@ export class IOSSimulator extends IOSDeviceBase implements Mobile.IiOSDevice { this.$iOSEmulatorServices .postDarwinNotification( attachRequestMessage, - this.deviceInfo.identifier + this.deviceInfo.identifier, ) .catch((e) => this.$logger.error(e)); }, 5e3); diff --git a/lib/common/mobile/ios/simulator/ios-simulator-file-system.ts b/lib/common/mobile/ios/simulator/ios-simulator-file-system.ts index 900cf79b0a..47b8ddb635 100644 --- a/lib/common/mobile/ios/simulator/ios-simulator-file-system.ts +++ b/lib/common/mobile/ios/simulator/ios-simulator-file-system.ts @@ -7,7 +7,7 @@ export class IOSSimulatorFileSystem implements Mobile.IDeviceFileSystem { constructor( private iosSim: any, private $fs: IFileSystem, - private $logger: ILogger + private $logger: ILogger, ) {} public async listFiles(devicePath: string): Promise { @@ -17,7 +17,7 @@ export class IOSSimulatorFileSystem implements Mobile.IDeviceFileSystem { public async getFile( deviceFilePath: string, appIdentifier: string, - outputFilePath?: string + outputFilePath?: string, ): Promise { if (outputFilePath) { shelljs.cp("-f", deviceFilePath, outputFilePath); @@ -26,7 +26,7 @@ export class IOSSimulatorFileSystem implements Mobile.IDeviceFileSystem { public async getFileContent( deviceFilePath: string, - appIdentifier: string + appIdentifier: string, ): Promise { const result = this.$fs.readText(deviceFilePath); return result; @@ -35,29 +35,29 @@ export class IOSSimulatorFileSystem implements Mobile.IDeviceFileSystem { public async putFile( localFilePath: string, deviceFilePath: string, - appIdentifier: string + appIdentifier: string, ): Promise { shelljs.cp("-f", localFilePath, deviceFilePath); } public async deleteFile( deviceFilePath: string, - appIdentifier: string + appIdentifier: string, ): Promise { shelljs.rm("-rf", deviceFilePath); } public async transferFiles( deviceAppData: Mobile.IDeviceAppData, - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): Promise { await Promise.all( _.map(localToDevicePaths, (localToDevicePathData) => this.transferFile( localToDevicePathData.getLocalPath(), - localToDevicePathData.getDevicePath() - ) - ) + localToDevicePathData.getDevicePath(), + ), + ), ); return localToDevicePaths; } @@ -65,11 +65,11 @@ export class IOSSimulatorFileSystem implements Mobile.IDeviceFileSystem { public async transferDirectory( deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], - projectFilesPath: string + projectFilesPath: string, ): Promise { const destinationPath = await deviceAppData.getDeviceProjectRootPath(); this.$logger.trace( - `Transferring from ${projectFilesPath} to ${destinationPath}` + `Transferring from ${projectFilesPath} to ${destinationPath}`, ); const sourcePath = path.join(projectFilesPath, "*"); shelljs.cp("-Rf", sourcePath, destinationPath); @@ -78,10 +78,10 @@ export class IOSSimulatorFileSystem implements Mobile.IDeviceFileSystem { public async transferFile( localFilePath: string, - deviceFilePath: string + deviceFilePath: string, ): Promise { this.$logger.trace( - `Transferring from ${localFilePath} to ${deviceFilePath}` + `Transferring from ${localFilePath} to ${deviceFilePath}`, ); if (this.$fs.getFsStats(localFilePath).isDirectory()) { this.$fs.ensureDirectoryExists(deviceFilePath); @@ -93,7 +93,7 @@ export class IOSSimulatorFileSystem implements Mobile.IDeviceFileSystem { public updateHashesOnDevice( hashes: IStringDictionary, - appIdentifier: string + appIdentifier: string, ): Promise { return; } diff --git a/lib/common/mobile/ios/simulator/ios-simulator-log-provider.ts b/lib/common/mobile/ios/simulator/ios-simulator-log-provider.ts index a13dd2055e..079963bc4a 100644 --- a/lib/common/mobile/ios/simulator/ios-simulator-log-provider.ts +++ b/lib/common/mobile/ios/simulator/ios-simulator-log-provider.ts @@ -10,7 +10,8 @@ import { injector } from "../../../yok"; export class IOSSimulatorLogProvider extends EventEmitter - implements Mobile.IiOSSimulatorLogProvider, IDisposable, IShouldDispose { + implements Mobile.IiOSSimulatorLogProvider, IDisposable, IShouldDispose +{ public shouldDispose: boolean; private simulatorsLoggingEnabled: IDictionary = {}; private simulatorsLogProcess: IDictionary = {}; @@ -19,7 +20,7 @@ export class IOSSimulatorLogProvider private $iOSSimResolver: Mobile.IiOSSimResolver, private $logger: ILogger, private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, - private $deviceLogProvider: Mobile.IDeviceLogProvider + private $deviceLogProvider: Mobile.IDeviceLogProvider, ) { super(); this.shouldDispose = true; @@ -31,20 +32,21 @@ export class IOSSimulatorLogProvider public async startLogProcess( deviceId: string, - options?: Mobile.IiOSLogStreamOptions + options?: Mobile.IiOSLogStreamOptions, ): Promise { if (!this.simulatorsLoggingEnabled[deviceId]) { - const deviceLogChildProcess: ChildProcess = await this.$iOSSimResolver.iOSSim.getDeviceLogProcess( - deviceId, - options ? options.predicate : null - ); + const deviceLogChildProcess: ChildProcess = + await this.$iOSSimResolver.iOSSim.getDeviceLogProcess( + deviceId, + options ? options.predicate : null, + ); const action = (data: Buffer | string) => { const message = data.toString(); this.$deviceLogProvider.logData( message, this.$devicePlatformsConstants.iOS, - deviceId + deviceId, ); }; @@ -55,7 +57,7 @@ export class IOSSimulatorLogProvider deviceLogChildProcess.once("error", (err) => { this.$logger.trace( - `Error is thrown for device with identifier ${deviceId}. More info: ${err.message}.` + `Error is thrown for device with identifier ${deviceId}. More info: ${err.message}.`, ); this.simulatorsLoggingEnabled[deviceId] = false; }); @@ -82,7 +84,7 @@ export class IOSSimulatorLogProvider if (logProcess) { logProcess.kill(signal); } - } + }, ); } } diff --git a/lib/common/mobile/local-to-device-path-data-factory.ts b/lib/common/mobile/local-to-device-path-data-factory.ts index 83c2dfdb4c..f4ac841a44 100644 --- a/lib/common/mobile/local-to-device-path-data-factory.ts +++ b/lib/common/mobile/local-to-device-path-data-factory.ts @@ -10,7 +10,7 @@ class LocalToDevicePathData implements Mobile.ILocalToDevicePathData { private filePath: string, private localProjectRootPath: string, private onDeviceFileName: string, - public deviceProjectRootPath: string + public deviceProjectRootPath: string, ) {} public getLocalPath(): string { @@ -22,7 +22,7 @@ class LocalToDevicePathData implements Mobile.ILocalToDevicePathData { const devicePath = path.join( this.deviceProjectRootPath, path.dirname(this.getRelativeToProjectBasePath()), - this.onDeviceFileName + this.onDeviceFileName, ); this.devicePath = helpers.fromWindowsRelativePathToUnix(devicePath); } @@ -34,7 +34,7 @@ class LocalToDevicePathData implements Mobile.ILocalToDevicePathData { if (!this.relativeToProjectBasePath) { this.relativeToProjectBasePath = path.relative( this.localProjectRootPath, - this.filePath + this.filePath, ); } @@ -43,18 +43,19 @@ class LocalToDevicePathData implements Mobile.ILocalToDevicePathData { } export class LocalToDevicePathDataFactory - implements Mobile.ILocalToDevicePathDataFactory { + implements Mobile.ILocalToDevicePathDataFactory +{ create( filePath: string, localProjectRootPath: string, onDeviceFileName: string, - deviceProjectRootPath: string + deviceProjectRootPath: string, ): Mobile.ILocalToDevicePathData { return new LocalToDevicePathData( filePath, localProjectRootPath, onDeviceFileName, - deviceProjectRootPath + deviceProjectRootPath, ); } } diff --git a/lib/common/mobile/log-filter.ts b/lib/common/mobile/log-filter.ts index 5cd3850d9d..47e9e04885 100644 --- a/lib/common/mobile/log-filter.ts +++ b/lib/common/mobile/log-filter.ts @@ -7,7 +7,7 @@ export class LogFilter implements Mobile.ILogFilter { constructor( private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $injector: IInjector, - private $loggingLevels: Mobile.ILoggingLevels + private $loggingLevels: Mobile.ILoggingLevels, ) {} public get loggingLevel(): string { @@ -23,7 +23,7 @@ export class LogFilter implements Mobile.ILogFilter { public filterData( platform: string, data: string, - loggingOptions: Mobile.IDeviceLogOptions = {} + loggingOptions: Mobile.IDeviceLogOptions = {}, ): string { loggingOptions = loggingOptions || {}; const deviceLogFilter = this.getDeviceLogFilterInstance(platform); @@ -37,7 +37,7 @@ export class LogFilter implements Mobile.ILogFilter { } private getDeviceLogFilterInstance( - platform: string + platform: string, ): Mobile.IPlatformLogFilter { if (platform) { if ( diff --git a/lib/common/mobile/mobile-core/android-device-discovery.ts b/lib/common/mobile/mobile-core/android-device-discovery.ts index d928282f12..76a069f8ec 100644 --- a/lib/common/mobile/mobile-core/android-device-discovery.ts +++ b/lib/common/mobile/mobile-core/android-device-discovery.ts @@ -19,18 +19,18 @@ export class AndroidDeviceDiscovery constructor( private $injector: IInjector, private $adb: Mobile.IAndroidDebugBridge, - private $mobileHelper: Mobile.IMobileHelper + private $mobileHelper: Mobile.IMobileHelper, ) { super(); } private async createAndAddDevice( - adbDeviceInfo: IAdbAndroidDeviceInfo + adbDeviceInfo: IAdbAndroidDeviceInfo, ): Promise { this._devices.push(adbDeviceInfo); const device: Mobile.IAndroidDevice = this.$injector.resolve( AndroidDevice, - { identifier: adbDeviceInfo.identifier, status: adbDeviceInfo.status } + { identifier: adbDeviceInfo.identifier, status: adbDeviceInfo.status }, ); await device.init(); this.addDevice(device); @@ -42,7 +42,7 @@ export class AndroidDeviceDiscovery } public async startLookingForDevices( - options?: Mobile.IDeviceLookingOptions + options?: Mobile.IDeviceLookingOptions, ): Promise { if ( options && @@ -72,7 +72,7 @@ export class AndroidDeviceDiscovery identifier: identifier, status: status, }; - } + }, ); _(this._devices) @@ -82,12 +82,13 @@ export class AndroidDeviceDiscovery _.find( currentDevices, (device) => - device.identifier === d.identifier && device.status === d.status + device.identifier === d.identifier && + device.status === d.status, ) - ) + ), ) .each((d: IAdbAndroidDeviceInfo) => - this.deleteAndRemoveDevice(d.identifier) + this.deleteAndRemoveDevice(d.identifier), ); await Promise.all( @@ -99,12 +100,12 @@ export class AndroidDeviceDiscovery this._devices, (device) => device.identifier === d.identifier && - device.status === d.status + device.status === d.status, ) - ) + ), ) .map((d: IAdbAndroidDeviceInfo) => this.createAndAddDevice(d)) - .value() + .value(), ); } diff --git a/lib/common/mobile/mobile-core/android-emulator-discovery.ts b/lib/common/mobile/mobile-core/android-emulator-discovery.ts index 9cc7fecd4c..5452980e82 100644 --- a/lib/common/mobile/mobile-core/android-emulator-discovery.ts +++ b/lib/common/mobile/mobile-core/android-emulator-discovery.ts @@ -6,18 +6,19 @@ import { injector } from "../../yok"; export class AndroidEmulatorDiscovery extends EventEmitter - implements Mobile.IDeviceDiscovery { + implements Mobile.IDeviceDiscovery +{ private _emulators: IDictionary = {}; constructor( private $androidEmulatorServices: Mobile.IEmulatorPlatformService, - private $mobileHelper: Mobile.IMobileHelper + private $mobileHelper: Mobile.IMobileHelper, ) { super(); } public async startLookingForDevices( - options?: Mobile.IDeviceLookingOptions + options?: Mobile.IDeviceLookingOptions, ): Promise { if ( options && @@ -27,7 +28,8 @@ export class AndroidEmulatorDiscovery return; } - const availableEmulatorsOutput = await this.$androidEmulatorServices.getEmulatorImages(); + const availableEmulatorsOutput = + await this.$androidEmulatorServices.getEmulatorImages(); const currentEmulators = availableEmulatorsOutput.devices; const cachedEmulators = _.values(this._emulators); @@ -37,8 +39,8 @@ export class AndroidEmulatorDiscovery _.some( currentEmulators, (emulator) => - emulator && e && emulator.imageIdentifier === e.imageIdentifier - ) + emulator && e && emulator.imageIdentifier === e.imageIdentifier, + ), ) .value(); @@ -48,8 +50,8 @@ export class AndroidEmulatorDiscovery _.some( cachedEmulators, (emulator) => - emulator && e && emulator.imageIdentifier === e.imageIdentifier - ) + emulator && e && emulator.imageIdentifier === e.imageIdentifier, + ), ) .value(); diff --git a/lib/common/mobile/mobile-core/android-process-service.ts b/lib/common/mobile/mobile-core/android-process-service.ts index 74b1f1e367..e21cda9e9d 100644 --- a/lib/common/mobile/mobile-core/android-process-service.ts +++ b/lib/common/mobile/mobile-core/android-process-service.ts @@ -18,14 +18,14 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { private $cleanupService: ICleanupService, private $injector: IInjector, private $net: INet, - private $staticConfig: IStaticConfig + private $staticConfig: IStaticConfig, ) { this._devicesAdbs = {}; this._forwardedLocalPorts = {}; } public async forwardFreeTcpToAbstractPort( - portForwardInputData: Mobile.IPortForwardData + portForwardInputData: Mobile.IPortForwardData, ): Promise { const adb = await this.setupForPortForwarding(portForwardInputData); return this.forwardPort(portForwardInputData, adb); @@ -34,7 +34,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { public async mapAbstractToTcpPort( deviceIdentifier: string, appIdentifier: string, - framework: string + framework: string, ): Promise { const adb = await this.setupForPortForwarding({ deviceIdentifier, @@ -50,15 +50,14 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { this.$errors.fail(applicationNotStartedErrorMessage); } - const abstractPortsInformation = await this.getAbstractPortsInformation( - adb - ); + const abstractPortsInformation = + await this.getAbstractPortsInformation(adb); const abstractPort = await this.getAbstractPortForApplication( adb, processId, appIdentifier, abstractPortsInformation, - framework + framework, ); if (!abstractPort) { @@ -71,7 +70,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { appIdentifier, abstractPort: `localabstract:${abstractPort}`, }, - adb + adb, ); return forwardedTcpPort && forwardedTcpPort.toString(); } @@ -79,7 +78,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { public async getMappedAbstractToTcpPorts( deviceIdentifier: string, appIdentifiers: string[], - framework: string + framework: string, ): Promise> { const adb = this.getAdb(deviceIdentifier), abstractPortsInformation = await this.getAbstractPortsInformation(adb), @@ -101,7 +100,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { processId, appIdentifier, abstractPortsInformation, - framework + framework, ); if (!abstractPort) { @@ -112,20 +111,20 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { adb, deviceIdentifier, abstractPort, - adbForwardList + adbForwardList, ); if (localPort) { localPorts[appIdentifier] = localPort; } - }) + }), ); return localPorts; } public async getDebuggableApps( - deviceIdentifier: string + deviceIdentifier: string, ): Promise { const adb = this.getAdb(deviceIdentifier); const androidWebViewPortInformation = ( @@ -152,21 +151,21 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { (await this.getApplicationInfoFromWebViewPortInformation( adb, deviceIdentifier, - line + line, )) || (await this.getNativeScriptApplicationInformation( adb, deviceIdentifier, - line - )) - ) + line, + )), + ), ); return _(portInformation) .filter((deviceAppInfo) => !!deviceAppInfo) .groupBy((element) => element.framework) .map((group: Mobile.IDeviceApplicationInformation[]) => - _.uniqBy(group, (g) => g.appIdentifier) + _.uniqBy(group, (g) => g.appIdentifier), ) .flatten() .value(); @@ -175,7 +174,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { @exported("androidProcessService") public async getAppProcessId( deviceIdentifier: string, - appIdentifier: string + appIdentifier: string, ): Promise { const adb = this.getAdb(deviceIdentifier); const processId = (await this.getProcessIds(adb, [appIdentifier]))[ @@ -187,25 +186,24 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { private async forwardPort( portForwardInputData: Mobile.IPortForwardData, - adb: Mobile.IDeviceAndroidDebugBridge + adb: Mobile.IDeviceAndroidDebugBridge, ): Promise { let localPort = await this.getAlreadyMappedPort( adb, portForwardInputData.deviceIdentifier, - portForwardInputData.abstractPort + portForwardInputData.abstractPort, ); if (!localPort) { localPort = await this.$net.getFreePort(); await adb.executeCommand( ["forward", `tcp:${localPort}`, portForwardInputData.abstractPort], - { deviceIdentifier: portForwardInputData.deviceIdentifier } + { deviceIdentifier: portForwardInputData.deviceIdentifier }, ); } - this._forwardedLocalPorts[ - portForwardInputData.deviceIdentifier - ] = localPort; + this._forwardedLocalPorts[portForwardInputData.deviceIdentifier] = + localPort; await this.$cleanupService.addCleanupCommand({ command: await this.$staticConfig.getAdbFilePath(), args: [ @@ -220,7 +218,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { } private async setupForPortForwarding( - portForwardInputData?: Mobile.IPortForwardDataBase + portForwardInputData?: Mobile.IPortForwardDataBase, ): Promise { const adb = this.getAdb(portForwardInputData.deviceIdentifier); @@ -230,7 +228,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { private async getApplicationInfoFromWebViewPortInformation( adb: Mobile.IDeviceAndroidDebugBridge, deviceIdentifier: string, - information: string + information: string, ): Promise { // Need to search by processId to check for old Android webviews (@webview_devtools_remote_). const processIdRegExp = /@webview_devtools_remote_(.+)/g; @@ -241,14 +239,13 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { const processId = processIdMatches[1]; cordovaAppIdentifier = await this.getApplicationIdentifierFromPid( adb, - processId + processId, ); } else { // Search for appIdentifier (@_devtools_remote). const chromeAppIdentifierRegExp = /@(.+)_devtools_remote\s?/g; - const chromeAppIdentifierMatches = chromeAppIdentifierRegExp.exec( - information - ); + const chromeAppIdentifierMatches = + chromeAppIdentifierRegExp.exec(information); if (chromeAppIdentifierMatches && chromeAppIdentifierMatches.length > 0) { cordovaAppIdentifier = chromeAppIdentifierMatches[1]; @@ -269,13 +266,12 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { private async getNativeScriptApplicationInformation( adb: Mobile.IDeviceAndroidDebugBridge, deviceIdentifier: string, - information: string + information: string, ): Promise { // Search for appIdentifier (@). const nativeScriptAppIdentifierRegExp = /@(.+)-(debug|inspectorServer)/g; - const nativeScriptAppIdentifierMatches = nativeScriptAppIdentifierRegExp.exec( - information - ); + const nativeScriptAppIdentifierMatches = + nativeScriptAppIdentifierRegExp.exec(information); if ( nativeScriptAppIdentifierMatches && @@ -297,7 +293,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { processId: string | number, appIdentifier: string, abstractPortsInformation: string, - framework: string + framework: string, ): Promise { // The result will look like this (without the columns names): // Num RefCount Protocol Flags Type St Inode Path @@ -311,23 +307,23 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { return this.getCordovaPortInformation( abstractPortsInformation, appIdentifier, - processId + processId, ); case TARGET_FRAMEWORK_IDENTIFIERS.NativeScript.toLowerCase(): return this.getNativeScriptPortInformation( abstractPortsInformation, - appIdentifier + appIdentifier, ); default: return ( this.getCordovaPortInformation( abstractPortsInformation, appIdentifier, - processId + processId, ) || this.getNativeScriptPortInformation( abstractPortsInformation, - appIdentifier + appIdentifier, ) ); } @@ -336,39 +332,39 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { private getCordovaPortInformation( abstractPortsInformation: string, appIdentifier: string, - processId: string | number + processId: string | number, ): string { return ( this.getPortInformation( abstractPortsInformation, - `${appIdentifier}_devtools_remote` + `${appIdentifier}_devtools_remote`, ) || this.getPortInformation(abstractPortsInformation, processId) ); } private getNativeScriptPortInformation( abstractPortsInformation: string, - appIdentifier: string + appIdentifier: string, ): string { return this.getPortInformation( abstractPortsInformation, - `${appIdentifier}-debug` + `${appIdentifier}-debug`, ); } private async getAbstractPortsInformation( - adb: Mobile.IDeviceAndroidDebugBridge + adb: Mobile.IDeviceAndroidDebugBridge, ): Promise { return adb.executeShellCommand(["cat", "/proc/net/unix"]); } private getPortInformation( abstractPortsInformation: string, - searchedInfo: string | number + searchedInfo: string | number, ): string { const processRegExp = new RegExp( `\\w+:\\s+(?:\\w+\\s+){1,6}@(.*?${searchedInfo})$`, - "gm" + "gm", ); const match = processRegExp.exec(abstractPortsInformation); @@ -377,7 +373,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { private async getProcessIds( adb: Mobile.IDeviceAndroidDebugBridge, - appIdentifiers: string[] + appIdentifiers: string[], ): Promise> { // Process information will look like this (without the columns names): // USER PID PPID VSIZE RSS WCHAN PC NAME @@ -386,9 +382,11 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { const processIdInformation: string = await adb.executeShellCommand(["ps"]); _.each(appIdentifiers, (appIdentifier) => { const processIdRegExp = new RegExp(`^\\w*\\s*(\\d+).*?${appIdentifier}$`); - result[appIdentifier] = this.getFirstMatchingGroupFromMultilineResult< - number - >(processIdInformation, processIdRegExp); + result[appIdentifier] = + this.getFirstMatchingGroupFromMultilineResult( + processIdInformation, + processIdRegExp, + ); }); return result; @@ -398,7 +396,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { adb: Mobile.IDeviceAndroidDebugBridge, deviceIdentifier: string, abstractPort: string, - adbForwardList?: any + adbForwardList?: any, ): Promise { const allForwardedPorts: string = adbForwardList || (await adb.executeCommand(["forward", "--list"])) || ""; @@ -409,12 +407,12 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { // 5e2e580b tcp:63160 localabstract:webview_devtools_remote_7987 // 5e2e580b tcp:57577 localabstract:com.telerik.nrel-debug const regex = new RegExp( - `${deviceIdentifier}\\s+?tcp:(\\d+?)\\s+?.*?${abstractPort}$` + `${deviceIdentifier}\\s+?tcp:(\\d+?)\\s+?.*?${abstractPort}$`, ); return this.getFirstMatchingGroupFromMultilineResult( allForwardedPorts, - regex + regex, ); } @@ -424,7 +422,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { DeviceAndroidDebugBridge, { identifier: deviceIdentifier, - } + }, ); } @@ -434,7 +432,7 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { private async getApplicationIdentifierFromPid( adb: Mobile.IDeviceAndroidDebugBridge, pid: string, - psData?: string + psData?: string, ): Promise { psData = psData || (await adb.executeShellCommand(["ps"])); // Process information will look like this (without the columns names): @@ -442,13 +440,13 @@ export class AndroidProcessService implements Mobile.IAndroidProcessService { // u0_a63 25512 1334 1519560 96040 ffffffff f76a8f75 S com.telerik.appbuildertabstest return this.getFirstMatchingGroupFromMultilineResult( psData, - new RegExp(`\\s+${pid}(?:\\s+\\d+){3}\\s+.*\\s+(.*?)$`) + new RegExp(`\\s+${pid}(?:\\s+\\d+){3}\\s+.*\\s+(.*?)$`), ); } private getFirstMatchingGroupFromMultilineResult( input: string, - regex: RegExp + regex: RegExp, ): T { let result: T; diff --git a/lib/common/mobile/mobile-core/device-discovery.ts b/lib/common/mobile/mobile-core/device-discovery.ts index 8b166c485b..dab8c7292a 100644 --- a/lib/common/mobile/mobile-core/device-discovery.ts +++ b/lib/common/mobile/mobile-core/device-discovery.ts @@ -6,7 +6,8 @@ import { injector } from "../../yok"; export class DeviceDiscovery extends EventEmitter - implements Mobile.IDeviceDiscovery { + implements Mobile.IDeviceDiscovery +{ private devices: IDictionary = {}; public async startLookingForDevices(): Promise { diff --git a/lib/common/mobile/mobile-core/devices-service.ts b/lib/common/mobile/mobile-core/devices-service.ts index 15bf11787f..1bb0cca473 100644 --- a/lib/common/mobile/mobile-core/devices-service.ts +++ b/lib/common/mobile/mobile-core/devices-service.ts @@ -270,12 +270,10 @@ export class DevicesService ); } - /* tslint:disable:no-unused-variable */ @exported("devicesService") public setLogLevel(logLevel: string, deviceIdentifier?: string): void { this.$deviceLogProvider.setLogLevel(logLevel, deviceIdentifier); } - /* tslint:enable:no-unused-variable */ @exported("devicesService") public isAppInstalledOnDevices( diff --git a/lib/common/mobile/mobile-core/ios-device-discovery.ts b/lib/common/mobile/mobile-core/ios-device-discovery.ts index d7b5a210e9..7e62708512 100644 --- a/lib/common/mobile/mobile-core/ios-device-discovery.ts +++ b/lib/common/mobile/mobile-core/ios-device-discovery.ts @@ -9,13 +9,13 @@ export class IOSDeviceDiscovery extends DeviceDiscovery { private $logger: ILogger, private $mobileHelper: Mobile.IMobileHelper, private $iosDeviceOperations: IIOSDeviceOperations, - private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants + private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, ) { super(); } public async startLookingForDevices( - options?: Mobile.IDeviceLookingOptions + options?: Mobile.IDeviceLookingOptions, ): Promise { this.$logger.trace("Options for ios-device-discovery", options); @@ -51,12 +51,12 @@ export class IOSDeviceDiscovery extends DeviceDiscovery { (deviceInfo: IOSDeviceLib.IDeviceActionInfo) => { this.removeDevice(deviceInfo.deviceId); }, - options + options, ); } private createDevice( - deviceActionInfo: IOSDeviceLib.IDeviceActionInfo + deviceActionInfo: IOSDeviceLib.IDeviceActionInfo, ): IOSDevice { const device = this.$injector.resolve(IOSDevice, { deviceActionInfo: deviceActionInfo, diff --git a/lib/common/mobile/mobile-core/ios-simulator-discovery.ts b/lib/common/mobile/mobile-core/ios-simulator-discovery.ts index d5bf542073..399d291eb0 100644 --- a/lib/common/mobile/mobile-core/ios-simulator-discovery.ts +++ b/lib/common/mobile/mobile-core/ios-simulator-discovery.ts @@ -15,13 +15,13 @@ export class IOSSimulatorDiscovery extends DeviceDiscovery { private $iOSSimResolver: Mobile.IiOSSimResolver, private $mobileHelper: Mobile.IMobileHelper, private $hostInfo: IHostInfo, - private $iOSEmulatorServices: Mobile.IiOSSimulatorService + private $iOSEmulatorServices: Mobile.IiOSSimulatorService, ) { super(); } public async startLookingForDevices( - options?: Mobile.IDeviceLookingOptions + options?: Mobile.IDeviceLookingOptions, ): Promise { if ( options && @@ -36,7 +36,8 @@ export class IOSSimulatorDiscovery extends DeviceDiscovery { private async checkForDevices(): Promise { if (this.$hostInfo.isDarwin) { - const currentSimulators: Mobile.IiSimDevice[] = await this.$iOSSimResolver.iOSSim.getRunningSimulators(); + const currentSimulators: Mobile.IiSimDevice[] = + await this.$iOSSimResolver.iOSSim.getRunningSimulators(); // Remove old simulators _(this.cachedSimulators) @@ -47,8 +48,8 @@ export class IOSSimulatorDiscovery extends DeviceDiscovery { simulator && s && simulator.id === s.id && - simulator.state === s.state - ) + simulator.state === s.state, + ), ) .each((s) => this.deleteAndRemoveDevice(s)); @@ -61,8 +62,8 @@ export class IOSSimulatorDiscovery extends DeviceDiscovery { simulator && s && simulator.id === s.id && - simulator.state === s.state - ) + simulator.state === s.state, + ), ) .each((s) => this.createAndAddDevice(s)); } @@ -83,7 +84,7 @@ export class IOSSimulatorDiscovery extends DeviceDiscovery { if ( !_.find( this.availableSimulators, - (s) => s.imageIdentifier === simulator.imageIdentifier + (s) => s.imageIdentifier === simulator.imageIdentifier, ) ) { lostSimulators.push(simulator); @@ -110,7 +111,7 @@ export class IOSSimulatorDiscovery extends DeviceDiscovery { private createAndAddDevice(simulator: Mobile.IiSimDevice): void { this.cachedSimulators.push(_.cloneDeep(simulator)); this.addDevice( - this.$injector.resolve(IOSSimulator, { simulator: simulator }) + this.$injector.resolve(IOSSimulator, { simulator: simulator }), ); } diff --git a/lib/common/mobile/mobile-helper.ts b/lib/common/mobile/mobile-helper.ts index 666f2ffae9..a7e13750ce 100644 --- a/lib/common/mobile/mobile-helper.ts +++ b/lib/common/mobile/mobile-helper.ts @@ -13,7 +13,7 @@ export class MobileHelper implements Mobile.IMobileHelper { private $errors: IErrors, private $fs: IFileSystem, private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, - private $tempService: ITempService + private $tempService: ITempService, ) {} public get platformNames(): string[] { @@ -77,7 +77,7 @@ export class MobileHelper implements Mobile.IMobileHelper { this.$errors.fail( "'%s' is not a valid device platform. Valid platforms are %s.", platform, - helpers.formatListOfNames(this.platformNames) + helpers.formatListOfNames(this.platformNames), ); } @@ -86,7 +86,7 @@ export class MobileHelper implements Mobile.IMobileHelper { public buildDevicePath(...args: string[]): string { return this.correctDevicePath( - args.join(MobileHelper.DEVICE_PATH_SEPARATOR) + args.join(MobileHelper.DEVICE_PATH_SEPARATOR), ); } @@ -101,7 +101,7 @@ export class MobileHelper implements Mobile.IMobileHelper { public async getDeviceFileContent( device: Mobile.IDevice, deviceFilePath: string, - projectData: IProjectData + projectData: IProjectData, ): Promise { const uniqueFilePath = await this.$tempService.path({ suffix: ".tmp" }); const platform = device.deviceInfo.platform.toLowerCase(); @@ -109,7 +109,7 @@ export class MobileHelper implements Mobile.IMobileHelper { await device.fileSystem.getFile( deviceFilePath, projectData.projectIdentifiers[platform], - uniqueFilePath + uniqueFilePath, ); } catch (e) { return null; diff --git a/lib/common/mobile/wp8/wp8-emulator-services.ts b/lib/common/mobile/wp8/wp8-emulator-services.ts index d36a715894..09d8918ada 100644 --- a/lib/common/mobile/wp8/wp8-emulator-services.ts +++ b/lib/common/mobile/wp8/wp8-emulator-services.ts @@ -13,7 +13,10 @@ class Wp8EmulatorServices implements Mobile.IEmulatorPlatformService { : process.env.ProgramFiles; } - constructor(private $logger: ILogger, private $childProcess: IChildProcess) {} + constructor( + private $logger: ILogger, + private $childProcess: IChildProcess, + ) {} public async getEmulatorId(): Promise { return ""; @@ -24,7 +27,7 @@ class Wp8EmulatorServices implements Mobile.IEmulatorPlatformService { } public async getRunningEmulatorImageIdentifier( - emulatorId: string + emulatorId: string, ): Promise { return null; } @@ -39,7 +42,7 @@ class Wp8EmulatorServices implements Mobile.IEmulatorPlatformService { public async runApplicationOnEmulator( app: string, - emulatorOptions?: Mobile.IRunApplicationOnEmulatorOptions + emulatorOptions?: Mobile.IRunApplicationOnEmulatorOptions, ): Promise { this.$logger.info("Starting Windows Phone Emulator"); const emulatorStarter = this.getPathToEmulatorStarter(); @@ -67,7 +70,7 @@ class Wp8EmulatorServices implements Mobile.IEmulatorPlatformService { return path.join( Wp8EmulatorServices.programFilesPath, Wp8EmulatorServices.WP8_LAUNCHER_PATH, - Wp8EmulatorServices.WP8_LAUNCHER + Wp8EmulatorServices.WP8_LAUNCHER, ); } } diff --git a/lib/common/project-helper.ts b/lib/common/project-helper.ts index faef33ed0f..28d937ca2f 100644 --- a/lib/common/project-helper.ts +++ b/lib/common/project-helper.ts @@ -11,7 +11,7 @@ export class ProjectHelper implements IProjectHelper { private $fs: IFileSystem, private $staticConfig: Config.IStaticConfig, private $errors: IErrors, - private $options: IOptions + private $options: IOptions, ) {} private cachedProjectDir = ""; @@ -27,7 +27,7 @@ export class ProjectHelper implements IProjectHelper { this.$logger.trace("Looking for project in '%s'", projectDir); const projectFilePath = path.join( projectDir, - this.$staticConfig.PROJECT_FILE_NAME + this.$staticConfig.PROJECT_FILE_NAME, ); if ( @@ -43,7 +43,7 @@ export class ProjectHelper implements IProjectHelper { if (dir === projectDir) { this.$logger.trace( "No project found at or above '%s'.", - this.$options.path || path.resolve(".") + this.$options.path || path.resolve("."), ); break; } @@ -68,7 +68,7 @@ export class ProjectHelper implements IProjectHelper { public sanitizeName(appName: string): string { const sanitizedName = _.filter(appName.split(""), (c) => - /[a-zA-Z0-9]/.test(c) + /[a-zA-Z0-9]/.test(c), ).join(""); return sanitizedName; } @@ -83,7 +83,7 @@ export class ProjectHelper implements IProjectHelper { } catch (err) { this.$errors.fail( "The project file is corrupted. Additional technical information: %s", - err + err, ); } diff --git a/lib/common/prompter.ts b/lib/common/prompter.ts index db33475b13..cda5629a03 100644 --- a/lib/common/prompter.ts +++ b/lib/common/prompter.ts @@ -29,7 +29,7 @@ export class Prompter implements IPrompter { if (!helpers.isInteractive()) { if (_.some(questions, (s) => !s.default)) { throw new Error( - "Console is not interactive and no default action specified." + "Console is not interactive and no default action specified.", ); } else { const result: any = {}; @@ -52,7 +52,7 @@ export class Prompter implements IPrompter { public async getPassword( message: string, - options?: IAllowEmpty + options?: IAllowEmpty, ): Promise { const schema: IPrompterQuestion = { message, @@ -70,7 +70,7 @@ export class Prompter implements IPrompter { public async getString( message: string, - options?: IPrompterOptions + options?: IPrompterOptions, ): Promise { const schema: IPrompterQuestion = { message, @@ -96,7 +96,7 @@ export class Prompter implements IPrompter { | string[] | { title: string; description?: string; value?: string }[], multiple: boolean = false, - options: any = {} + options: any = {}, ): Promise { const schema: IPrompterAnswers = { message: promptMessage, @@ -108,9 +108,8 @@ export class Prompter implements IPrompter { const result = await this.get([schema]); - type ArrayElement< - ArrayType extends readonly unknown[] - > = ArrayType extends readonly (infer ElementType)[] ? ElementType : never; + type ArrayElement = + ArrayType extends readonly (infer ElementType)[] ? ElementType : never; type Choice = ArrayElement; @@ -135,7 +134,7 @@ export class Prompter implements IPrompter { public async promptForDetailedChoice( promptMessage: string, - choices: { key: string; description: string }[] + choices: { key: string; description: string }[], ): Promise { const inquirerChoices = choices.map((choice) => { return { @@ -158,7 +157,7 @@ export class Prompter implements IPrompter { public async confirm( message: string, - defaultAction?: () => boolean + defaultAction?: () => boolean, ): Promise { const schema = { type: "confirm", @@ -231,21 +230,21 @@ export class Prompter implements IPrompter { this.cleanListener( stream, memoryleakEvent.eventName, - memoryleakEvent.listenerName - ) + memoryleakEvent.listenerName, + ), ); } private cleanListener( stream: NodeJS.WritableStream, eventName: string, - listenerName: string + listenerName: string, ): void { const eventListeners: any[] = process.stdout.listeners(eventName); const listenerFunction: (...args: any[]) => void = _.find( eventListeners, - (func: any) => func.name === listenerName + (func: any) => func.name === listenerName, ); if (listenerFunction) { diff --git a/lib/common/resource-loader.ts b/lib/common/resource-loader.ts index e651394df6..a9648e2c51 100644 --- a/lib/common/resource-loader.ts +++ b/lib/common/resource-loader.ts @@ -5,7 +5,7 @@ import { injector } from "./yok"; export class ResourceLoader implements IResourceLoader { constructor( private $fs: IFileSystem, - private $staticConfig: Config.IStaticConfig + private $staticConfig: Config.IStaticConfig, ) {} resolvePath(resourcePath: string): string { diff --git a/lib/common/services/auto-completion-service.ts b/lib/common/services/auto-completion-service.ts index 3e187ee9fe..601a579fd5 100644 --- a/lib/common/services/auto-completion-service.ts +++ b/lib/common/services/auto-completion-service.ts @@ -31,7 +31,7 @@ export class AutoCompletionService implements IAutoCompletionService { private $childProcess: IChildProcess, private $logger: ILogger, private $staticConfig: Config.IStaticConfig, - private $hostInfo: IHostInfo + private $hostInfo: IHostInfo, ) {} public disableAnalytics = true; @@ -47,7 +47,7 @@ export class AutoCompletionService implements IAutoCompletionService { @cache() private get cliRunCommandsFile(): string { let cliRunCommandsFile = this.getHomePath( - util.format(".%src", this.$staticConfig.CLIENT_NAME.toLowerCase()) + util.format(".%src", this.$staticConfig.CLIENT_NAME.toLowerCase()), ); if (this.$hostInfo.isWindows) { // on Windows bash, file is incorrectly written as C:\Users\, which leads to errors when trying to execute the script: @@ -62,14 +62,14 @@ export class AutoCompletionService implements IAutoCompletionService { private getTabTabObsoleteRegex(clientName: string): RegExp { const tabTabStartPoint = util.format( AutoCompletionService.TABTAB_COMPLETION_START_REGEX_PATTERN, - clientName.toLowerCase() + clientName.toLowerCase(), ); const tabTabEndPoint = util.format( AutoCompletionService.TABTAB_COMPLETION_END_REGEX_PATTERN, - clientName.toLowerCase() + clientName.toLowerCase(), ); const tabTabRegex = new RegExp( - util.format("%s[\\s\\S]*%s", tabTabStartPoint, tabTabEndPoint) + util.format("%s[\\s\\S]*%s", tabTabStartPoint, tabTabEndPoint), ); return tabTabRegex; } @@ -79,8 +79,8 @@ export class AutoCompletionService implements IAutoCompletionService { util.format( "%s[\\s\\S]*%s", AutoCompletionService.GENERATED_TABTAB_COMPLETION_START, - AutoCompletionService.GENERATED_TABTAB_COMPLETION_END - ) + AutoCompletionService.GENERATED_TABTAB_COMPLETION_END, + ), ); } @@ -94,19 +94,19 @@ export class AutoCompletionService implements IAutoCompletionService { const text = this.$fs.readText(file); let newText = text.replace( this.getTabTabObsoleteRegex(this.$staticConfig.CLIENT_NAME), - "" + "", ); if (this.$staticConfig.CLIENT_NAME_ALIAS) { newText = newText.replace( this.getTabTabObsoleteRegex(this.$staticConfig.CLIENT_NAME_ALIAS), - "" + "", ); } if (newText !== text) { this.$logger.trace( "Remove obsolete AutoCompletion from file %s.", - file + file, ); this.$fs.writeFile(file, newText); } @@ -114,7 +114,7 @@ export class AutoCompletionService implements IAutoCompletionService { if (error.code !== "ENOENT") { this.$logger.trace( "Error while trying to disable autocompletion for '%s' file. Error is:\n%s", - error.toString() + error.toString(), ); } } @@ -129,7 +129,7 @@ export class AutoCompletionService implements IAutoCompletionService { newText = newText.replace( this.getTabTabObsoleteRegex("nativescript"), - "" + "", ); newText = newText.replace(this.getTabTabObsoleteRegex("tns"), ""); @@ -138,7 +138,7 @@ export class AutoCompletionService implements IAutoCompletionService { } catch (error) { this.$logger.trace( "Error while trying to disable autocompletion for '%s' file. Error is:\n%s", - error.toString() + error.toString(), ); return text; @@ -154,7 +154,7 @@ export class AutoCompletionService implements IAutoCompletionService { "\n%s\n%s\n%s\n", ns, tns, - AutoCompletionService.GENERATED_TABTAB_COMPLETION_END + AutoCompletionService.GENERATED_TABTAB_COMPLETION_END, ); } @@ -162,16 +162,16 @@ export class AutoCompletionService implements IAutoCompletionService { private get completionShellScriptContent() { const startText = util.format( AutoCompletionService.COMPLETION_START_COMMENT_PATTERN, - this.$staticConfig.CLIENT_NAME.toLowerCase() + this.$staticConfig.CLIENT_NAME.toLowerCase(), ); const content = util.format( "if [ -f %s ]; then \n source %s \nfi", this.cliRunCommandsFile, - this.cliRunCommandsFile + this.cliRunCommandsFile, ); const endText = util.format( AutoCompletionService.COMPLETION_END_COMMENT_PATTERN, - this.$staticConfig.CLIENT_NAME.toLowerCase() + this.$staticConfig.CLIENT_NAME.toLowerCase(), ); return util.format("\n%s\n%s\n%s\n", startText, content, endText); } @@ -193,13 +193,13 @@ export class AutoCompletionService implements IAutoCompletionService { public disableAutoCompletion(): void { _.each(this.shellProfiles, (shellFile) => - this.removeAutoCompletionFromShellScript(shellFile) + this.removeAutoCompletionFromShellScript(shellFile), ); this.removeObsoleteAutoCompletion(); if (this.scriptsOk && this.scriptsUpdated) { this.$logger.info( - "Restart your shell to disable command auto-completion." + "Restart your shell to disable command auto-completion.", ); } } @@ -207,13 +207,13 @@ export class AutoCompletionService implements IAutoCompletionService { public async enableAutoCompletion(): Promise { await this.updateCLIShellScript(); _.each(this.shellProfiles, (shellFile) => - this.addAutoCompletionToShellScript(shellFile) + this.addAutoCompletionToShellScript(shellFile), ); this.removeObsoleteAutoCompletion(); if (this.scriptsOk && this.scriptsUpdated) { this.$logger.info( - "Restart your shell to enable command auto-completion." + "Restart your shell to enable command auto-completion.", ); } } @@ -241,7 +241,7 @@ export class AutoCompletionService implements IAutoCompletionService { this.$logger.trace( "Error while checking is autocompletion enabled in file %s. Error is: '%s'", fileName, - err.toString() + err.toString(), ); } @@ -253,7 +253,7 @@ export class AutoCompletionService implements IAutoCompletionService { const text = this.$fs.readText(fileName); return !!( text.match( - this.getTabTabObsoleteRegex(this.$staticConfig.CLIENT_NAME) + this.getTabTabObsoleteRegex(this.$staticConfig.CLIENT_NAME), ) || text.match(this.getTabTabObsoleteRegex(this.$staticConfig.CLIENT_NAME)) ); @@ -261,7 +261,7 @@ export class AutoCompletionService implements IAutoCompletionService { this.$logger.trace( "Error while checking is obsolete autocompletion enabled in file %s. Error is: '%s'", fileName, - err.toString() + err.toString(), ); } } @@ -274,7 +274,7 @@ export class AutoCompletionService implements IAutoCompletionService { ) { this.$logger.trace( "AutoCompletion is not enabled in %s file. Trying to enable it.", - fileName + fileName, ); this.$fs.appendFile(fileName, this.completionShellScriptContent); this.scriptsUpdated = true; @@ -282,7 +282,7 @@ export class AutoCompletionService implements IAutoCompletionService { } catch (err) { this.$logger.info( "Unable to update %s. Command-line completion might not work.", - fileName + fileName, ); // When npm is installed with sudo, in some cases the installation cannot write to shell profiles // Advise the user how to enable autocompletion after the installation is completed. @@ -293,7 +293,7 @@ export class AutoCompletionService implements IAutoCompletionService { ) { this.$logger.info( "To enable command-line completion, run '$ %s autocomplete enable'.", - this.$staticConfig.CLIENT_NAME + this.$staticConfig.CLIENT_NAME, ); } @@ -307,7 +307,7 @@ export class AutoCompletionService implements IAutoCompletionService { if (this.isNewAutoCompletionEnabledInFile(fileName)) { this.$logger.trace( "AutoCompletion is enabled in %s file. Trying to disable it.", - fileName + fileName, ); let data = this.$fs.readText(fileName); data = data.replace(this.completionShellScriptContent, ""); @@ -319,7 +319,7 @@ export class AutoCompletionService implements IAutoCompletionService { if (err.code !== "ENOENT") { this.$logger.info( "Failed to update %s. Auto-completion may still work or work incorrectly. ", - fileName + fileName, ); this.$logger.info(err); this.scriptsOk = false; @@ -335,9 +335,9 @@ export class AutoCompletionService implements IAutoCompletionService { if (this.$fs.exists(filePath)) { const contents = this.$fs.readText(filePath); const regExp = new RegExp( - AutoCompletionService.GENERATED_TABTAB_COMPLETION_START + AutoCompletionService.GENERATED_TABTAB_COMPLETION_START, ); - let matchCondition = contents.match(regExp); + const matchCondition = contents.match(regExp); if (matchCondition) { doUpdate = false; @@ -350,20 +350,20 @@ export class AutoCompletionService implements IAutoCompletionService { ).toLowerCase(); const pathToExecutableFile = path.join( __dirname, - `../../../bin/${clientExecutableFileName}.js` + `../../../bin/${clientExecutableFileName}.js`, ); if (this.$fs.exists(filePath)) { const existingText = this.$fs.readText(filePath); let newText = existingText.replace( this.getTabTabCompletionsRegex(), - "" + "", ); newText = this.removeOboleteTabTabCompletion(newText); if (newText !== existingText) { this.$logger.trace( "Remove existing AutoCompletion from file %s.", - filePath + filePath, ); this.$fs.writeFile(filePath, newText); } @@ -372,10 +372,10 @@ export class AutoCompletionService implements IAutoCompletionService { this.$fs.appendFile( filePath, - `\n${AutoCompletionService.GENERATED_TABTAB_COMPLETION_START}\n` + `\n${AutoCompletionService.GENERATED_TABTAB_COMPLETION_START}\n`, ); await this.$childProcess.exec( - `"${process.argv[0]}" "${pathToExecutableFile}" completion_generate_script >> "${filePath}"` + `"${process.argv[0]}" "${pathToExecutableFile}" completion_generate_script >> "${filePath}"`, ); this.$fs.appendFile(filePath, this.completionAliasDefinition); @@ -384,7 +384,7 @@ export class AutoCompletionService implements IAutoCompletionService { } catch (err) { this.$logger.info( "Failed to update %s. Auto-completion may not work. ", - filePath + filePath, ); this.$logger.trace(err); this.scriptsOk = false; diff --git a/lib/common/services/help-service.ts b/lib/common/services/help-service.ts index 28b1c93164..d1859e6623 100644 --- a/lib/common/services/help-service.ts +++ b/lib/common/services/help-service.ts @@ -32,8 +32,7 @@ export class HelpService implements IHelpService { private static RELATIVE_PATH_TO_IMAGES_REGEX = /@RELATIVE_PATH_TO_IMAGES@/g; private static RELATIVE_PATH_TO_INDEX_REGEX = /@RELATIVE_PATH_TO_INDEX@/g; private static EXTENSION_NAME_REGEX = /@EXTENSION_NAME@/g; - private static MARKDOWN_LINK_REGEX = - /\[([\w \-\`\<\>\*\:\\]+?)\]\([\s\S]+?\)/g; + private static MARKDOWN_LINK_REGEX = /\[([\w \-`\<>\*:\\]+?)\]\([\s\S]+?\)/g; private static SPAN_REGEX = /([\s\S]*?)(?:\r?\n)?([\s\S]*?)<\/span>(?:\r?\n)*/g; private static NEW_LINE_REGEX = /<\/?\s*?br\s*?\/?>/g; //
,


diff --git a/lib/common/services/ios-notification-service.ts b/lib/common/services/ios-notification-service.ts index 0f44317a3e..8ab4ab2095 100644 --- a/lib/common/services/ios-notification-service.ts +++ b/lib/common/services/ios-notification-service.ts @@ -9,10 +9,10 @@ export class IOSNotificationService implements IiOSNotificationService { public async awaitNotification( deviceIdentifier: string, socket: number, - timeout: number + timeout: number, ): Promise { - const notificationResponse = await this.$iosDeviceOperations.awaitNotificationResponse( - [ + const notificationResponse = + await this.$iosDeviceOperations.awaitNotificationResponse([ { deviceId: deviceIdentifier, socket: socket, @@ -20,8 +20,7 @@ export class IOSNotificationService implements IiOSNotificationService { responseCommandType: constants.IOS_RELAY_NOTIFICATION_COMMAND_TYPE, responsePropertyName: "Name", }, - ] - ); + ]); return _.first(notificationResponse[deviceIdentifier]).response; } @@ -29,7 +28,7 @@ export class IOSNotificationService implements IiOSNotificationService { public async postNotification( deviceIdentifier: string, notification: string, - commandType?: string + commandType?: string, ): Promise { commandType = commandType || constants.IOS_POST_NOTIFICATION_COMMAND_TYPE; const response = await this.$iosDeviceOperations.postNotification([ diff --git a/lib/common/services/json-file-settings-service.ts b/lib/common/services/json-file-settings-service.ts index d58da1e8fa..9d1d0c5655 100644 --- a/lib/common/services/json-file-settings-service.ts +++ b/lib/common/services/json-file-settings-service.ts @@ -16,14 +16,14 @@ export class JsonFileSettingsService implements IJsonFileSettingsService { jsonFileSettingsPath: string, private $fs: IFileSystem, private $lockService: ILockService, - private $logger: ILogger + private $logger: ILogger, ) { this.jsonSettingsFilePath = jsonFileSettingsPath; } public async getSettingValue( settingName: string, - cacheOpts?: { cacheTimeout: number } + cacheOpts?: { cacheTimeout: number }, ): Promise { const action = async (): Promise => { await this.loadUserSettingsFile(); @@ -52,14 +52,14 @@ export class JsonFileSettingsService implements IJsonFileSettingsService { return this.$lockService.executeActionWithLock( action, - this.lockFilePath + this.lockFilePath, ); } public async saveSetting( key: string, value: T, - cacheOpts?: { useCaching: boolean } + cacheOpts?: { useCaching: boolean }, ): Promise { const settingObject: any = {}; settingObject[key] = value; @@ -77,13 +77,13 @@ export class JsonFileSettingsService implements IJsonFileSettingsService { return this.$lockService.executeActionWithLock( action, - this.lockFilePath + this.lockFilePath, ); } public saveSettings( data?: any, - cacheOpts?: { useCaching: boolean } + cacheOpts?: { useCaching: boolean }, ): Promise { const action = async (): Promise => { await this.loadUserSettingsFile(); @@ -100,7 +100,7 @@ export class JsonFileSettingsService implements IJsonFileSettingsService { time: Date.now(), value: data[propertyName], modifiedByCacheMechanism: true, - } + } : data[propertyName]; }); @@ -109,7 +109,7 @@ export class JsonFileSettingsService implements IJsonFileSettingsService { return this.$lockService.executeActionWithLock( action, - this.lockFilePath + this.lockFilePath, ); } @@ -122,7 +122,7 @@ export class JsonFileSettingsService implements IJsonFileSettingsService { private async loadUserSettingsData(): Promise { if (!this.$fs.exists(this.jsonSettingsFilePath)) { const unexistingDirs = this.getUnexistingDirectories( - this.jsonSettingsFilePath + this.jsonSettingsFilePath, ); this.$fs.writeFile(this.jsonSettingsFilePath, null); @@ -142,7 +142,7 @@ export class JsonFileSettingsService implements IJsonFileSettingsService { this.jsonSettingsData = parseJson(data); } catch (err) { this.$logger.trace( - `Error while trying to parseJson ${data} data from ${this.jsonSettingsFilePath} file. Err is: ${err}` + `Error while trying to parseJson ${data} data from ${this.jsonSettingsFilePath} file. Err is: ${err}`, ); this.$fs.deleteFile(this.jsonSettingsFilePath); } diff --git a/lib/common/services/lock-service.ts b/lib/common/services/lock-service.ts index 515173cd52..121e32d070 100644 --- a/lib/common/services/lock-service.ts +++ b/lib/common/services/lock-service.ts @@ -16,7 +16,7 @@ export class LockService implements ILockService { private getAbsoluteLockFilePath(relativeLockFilePath: string) { return path.join( this.$settingsService.getProfileDir(), - relativeLockFilePath + relativeLockFilePath, ); } @@ -34,13 +34,13 @@ export class LockService implements ILockService { constructor( private $fs: IFileSystem, private $settingsService: ISettingsService, - private $cleanupService: ICleanupService + private $cleanupService: ICleanupService, ) {} public async executeActionWithLock( action: () => Promise, lockFilePath?: string, - lockOpts?: ILockOptions + lockOpts?: ILockOptions, ): Promise { const releaseFunc = await this.lock(lockFilePath, lockOpts); @@ -54,11 +54,11 @@ export class LockService implements ILockService { public async lock( lockFilePath?: string, - lockOpts?: ILockOptions + lockOpts?: ILockOptions, ): Promise<() => void> { const { filePath, fileOpts } = this.getLockFileSettings( lockFilePath, - lockOpts + lockOpts, ); for (const pathToClean of this.getPathsForCleanupAction(filePath)) { @@ -99,7 +99,7 @@ export class LockService implements ILockService { private getLockFileSettings( filePath?: string, - fileOpts?: ILockOptions + fileOpts?: ILockOptions, ): { filePath: string; fileOpts: ILockOptions } { if (filePath && !path.isAbsolute(filePath)) { filePath = this.getAbsoluteLockFilePath(filePath); diff --git a/lib/common/services/message-contract-generator.ts b/lib/common/services/message-contract-generator.ts index 0ccb4578fa..da0e082b60 100644 --- a/lib/common/services/message-contract-generator.ts +++ b/lib/common/services/message-contract-generator.ts @@ -13,7 +13,7 @@ import { injector } from "../yok"; export class MessageContractGenerator implements IServiceContractGenerator { constructor( private $fs: IFileSystem, - private $messagesService: IMessagesService + private $messagesService: IMessagesService, ) {} public async generate(): Promise { @@ -22,7 +22,7 @@ export class MessageContractGenerator implements IServiceContractGenerator { implementationsFile.writeLine("//"); implementationsFile.writeLine( - "// automatically generated code; do not edit manually!" + "// automatically generated code; do not edit manually!", ); implementationsFile.writeLine("//"); implementationsFile.writeLine("/* tslint:disable:all */"); @@ -30,13 +30,13 @@ export class MessageContractGenerator implements IServiceContractGenerator { interfacesFile.writeLine("//"); interfacesFile.writeLine( - "// automatically generated code; do not edit manually!" + "// automatically generated code; do not edit manually!", ); interfacesFile.writeLine("//"); interfacesFile.writeLine("/* tslint:disable:all */"); const messagesClass = new Block( - "export class Messages implements IMessages" + "export class Messages implements IMessages", ); const messagesInterface = new Block("interface IMessages"); @@ -76,7 +76,7 @@ export class MessageContractGenerator implements IServiceContractGenerator { propertyValue: string, block: CodeGeneration.IBlock, depth: number, - options: { shouldGenerateInterface: boolean } + options: { shouldGenerateInterface: boolean }, ): void { _.each(jsonContents, (val: any, key: string) => { let newPropertyValue = propertyValue + key; @@ -101,7 +101,7 @@ export class MessageContractGenerator implements IServiceContractGenerator { newPropertyValue + ".", newBlock, depth + 1, - options + options, ); block.addBlock(newBlock); }); diff --git a/lib/common/services/messages-service.ts b/lib/common/services/messages-service.ts index aefabf2a31..5ebdb3c292 100644 --- a/lib/common/services/messages-service.ts +++ b/lib/common/services/messages-service.ts @@ -37,7 +37,7 @@ export class MessagesService implements IMessagesService { public set pathsToMessageJsonFiles(pathsToMessageJsonFiles: string[]) { this._pathsToMessageJsonFiles = pathsToMessageJsonFiles.concat( - this.pathToDefaultMessageJson + this.pathToDefaultMessageJson, ); this.refreshMessageJsonContentsCache(); } @@ -52,12 +52,12 @@ export class MessagesService implements IMessagesService { const messageValue = this.getMessageFromJsonRecursive( keys, jsonFileContents, - 0 + 0, ); if (messageValue) { result = this.getFormatedMessage.apply( this, - [messageValue].concat(argsArray) + [messageValue].concat(argsArray), ); return false; } @@ -69,7 +69,7 @@ export class MessagesService implements IMessagesService { private getMessageFromJsonRecursive( keys: string[], jsonContents: any, - index: number + index: number, ): string { if (index >= keys.length) { return null; diff --git a/lib/common/services/micro-templating-service.ts b/lib/common/services/micro-templating-service.ts index 432f44b876..89d00e82b3 100644 --- a/lib/common/services/micro-templating-service.ts +++ b/lib/common/services/micro-templating-service.ts @@ -14,20 +14,20 @@ export class MicroTemplateService implements IMicroTemplateService { // Use ( ) in order to use $1 to get whole expression later this.dynamicCallRegex = new RegExp( util.format("(%s)", this.$injector.dynamicCallRegex.source), - "g" + "g", ); } public async parseContent( data: string, - options: { isHtml: boolean } + options: { isHtml: boolean }, ): Promise { const localVariables = this.getLocalVariables(options); const compiledTemplate = _.template( data.replace( this.dynamicCallRegex, - 'this.$injector.getDynamicCallData("$1")' - ) + 'this.$injector.getDynamicCallData("$1")', + ), ); // When debugging parsing, uncomment the line below: // console.log(compiledTemplate.source); diff --git a/lib/common/services/project-files-manager.ts b/lib/common/services/project-files-manager.ts index 59e091b960..a6fe5cfcc6 100644 --- a/lib/common/services/project-files-manager.ts +++ b/lib/common/services/project-files-manager.ts @@ -16,26 +16,26 @@ export class ProjectFilesManager implements IProjectFilesManager { private $fs: IFileSystem, private $localToDevicePathDataFactory: Mobile.ILocalToDevicePathDataFactory, private $logger: ILogger, - private $projectFilesProvider: IProjectFilesProvider + private $projectFilesProvider: IProjectFilesProvider, ) {} public getProjectFiles( projectFilesPath: string, excludedProjectDirsAndFiles?: string[], filter?: (filePath: string, stat: IFsStats) => boolean, - opts?: any + opts?: any, ): string[] { const projectFiles = this.$fs.enumerateFilesInDirectorySync( projectFilesPath, (filePath, stat) => { const isFileExcluded = this.isFileExcluded( path.relative(projectFilesPath, filePath), - excludedProjectDirsAndFiles + excludedProjectDirsAndFiles, ); const isFileFiltered = filter ? filter(filePath, stat) : false; return !isFileExcluded && !isFileFiltered; }, - opts + opts, ); this.$logger.trace("enumerateProjectFiles: %s", util.inspect(projectFiles)); @@ -45,10 +45,10 @@ export class ProjectFilesManager implements IProjectFilesManager { public isFileExcluded( filePath: string, - excludedProjectDirsAndFiles?: string[] + excludedProjectDirsAndFiles?: string[], ): boolean { const isInExcludedList = !!_.find(excludedProjectDirsAndFiles, (pattern) => - minimatch(filePath, pattern, { nocase: true }) + minimatch(filePath, pattern, { nocase: true }), ); return ( isInExcludedList || this.$projectFilesProvider.isFileExcluded(filePath) @@ -60,9 +60,10 @@ export class ProjectFilesManager implements IProjectFilesManager { projectFilesPath: string, files: string[], excludedProjectDirsAndFiles: string[], - projectFilesConfig?: IProjectFilesConfig + projectFilesConfig?: IProjectFilesConfig, ): Promise { - const deviceProjectRootPath = await deviceAppData.getDeviceProjectRootPath(); + const deviceProjectRootPath = + await deviceAppData.getDeviceProjectRootPath(); files = files || @@ -70,7 +71,7 @@ export class ProjectFilesManager implements IProjectFilesManager { projectFilesPath, excludedProjectDirsAndFiles, null, - { enumerateDirectories: true } + { enumerateDirectories: true }, ); const localToDevicePaths = Promise.all( files @@ -78,8 +79,8 @@ export class ProjectFilesManager implements IProjectFilesManager { this.$projectFilesProvider.getProjectFileInfo( projectFile, deviceAppData.platform, - projectFilesConfig - ) + projectFilesConfig, + ), ) .filter((projectFileInfo) => projectFileInfo.shouldIncludeFile) .map(async (projectFileInfo) => @@ -87,9 +88,9 @@ export class ProjectFilesManager implements IProjectFilesManager { projectFileInfo.filePath, projectFilesPath, projectFileInfo.onDeviceFileName, - deviceProjectRootPath - ) - ) + deviceProjectRootPath, + ), + ), ); return localToDevicePaths; @@ -99,7 +100,7 @@ export class ProjectFilesManager implements IProjectFilesManager { directoryPath: string, platform: string, projectFilesConfig: IProjectFilesConfig, - excludedDirs?: string[] + excludedDirs?: string[], ): void { const contents = this.$fs.readDirectory(directoryPath); const files: string[] = []; @@ -111,7 +112,7 @@ export class ProjectFilesManager implements IProjectFilesManager { this.processPlatformSpecificFilesCore( platform, this.$fs.enumerateFilesInDirectorySync(filePath), - projectFilesConfig + projectFilesConfig, ); } else if (fsStat.isFile()) { files.push(filePath); @@ -124,21 +125,21 @@ export class ProjectFilesManager implements IProjectFilesManager { private processPlatformSpecificFilesCore( platform: string, files: string[], - projectFilesConfig: IProjectFilesConfig + projectFilesConfig: IProjectFilesConfig, ): void { // Renames the files that have `platform` as substring and removes the files from other platform _.each(files, (filePath) => { const projectFileInfo = this.$projectFilesProvider.getProjectFileInfo( filePath, platform, - projectFilesConfig + projectFilesConfig, ); if (!projectFileInfo.shouldIncludeFile) { this.$fs.deleteFile(filePath); } else if (projectFileInfo.onDeviceFileName) { const onDeviceFilePath = path.join( path.dirname(filePath), - projectFileInfo.onDeviceFileName + projectFileInfo.onDeviceFileName, ); // Fix .js.map entries @@ -157,7 +158,7 @@ export class ProjectFilesManager implements IProjectFilesManager { let fileContent = this.$fs.readText(filePath); fileContent = fileContent.replace( new RegExp(oldName, "g"), - newName + newName, ); this.$fs.writeFile(filePath, fileContent); } @@ -172,7 +173,7 @@ export class ProjectFilesManager implements IProjectFilesManager { private getFileName(filePath: string, extension: string): string { return path.basename( - filePath.replace(extension === ".map" ? ".js.map" : ".js", "") + filePath.replace(extension === ".map" ? ".js.map" : ".js", ""), ); } } diff --git a/lib/common/services/project-files-provider-base.ts b/lib/common/services/project-files-provider-base.ts index 6a2bba3659..7fbdc542a1 100644 --- a/lib/common/services/project-files-provider-base.ts +++ b/lib/common/services/project-files-provider-base.ts @@ -8,29 +8,28 @@ import { IProjectFileInfo, } from "../declarations"; -export abstract class ProjectFilesProviderBase - implements IProjectFilesProvider { +export abstract class ProjectFilesProviderBase implements IProjectFilesProvider { abstract isFileExcluded(filePath: string): boolean; abstract mapFilePath( filePath: string, platform: string, projectData: any, - projectFilesConfig: IProjectFilesConfig + projectFilesConfig: IProjectFilesConfig, ): string; constructor( private $mobileHelper: Mobile.IMobileHelper, - protected $options: IOptions + protected $options: IOptions, ) {} public getPreparedFilePath( filePath: string, - projectFilesConfig?: IProjectFilesConfig + projectFilesConfig?: IProjectFilesConfig, ): string { const projectFileInfo = this.getProjectFileInfo( filePath, "", - projectFilesConfig + projectFilesConfig, ); return path.join(path.dirname(filePath), projectFileInfo.onDeviceFileName); } @@ -38,7 +37,7 @@ export abstract class ProjectFilesProviderBase public getProjectFileInfo( filePath: string, platform: string, - projectFilesConfig?: IProjectFilesConfig + projectFilesConfig?: IProjectFilesConfig, ): IProjectFileInfo { if (!filePath) { return { @@ -51,7 +50,7 @@ export abstract class ProjectFilesProviderBase let parsed = this.parseFile( filePath, this.$mobileHelper.platformNames, - platform || "" + platform || "", ); const basicConfigurations = [ Configurations.Debug.toLowerCase(), @@ -60,7 +59,7 @@ export abstract class ProjectFilesProviderBase if (!parsed) { const validValues = basicConfigurations.concat( (projectFilesConfig && projectFilesConfig.additionalConfigurations) || - [] + [], ), value = (projectFilesConfig && projectFilesConfig.configuration) || @@ -80,7 +79,7 @@ export abstract class ProjectFilesProviderBase private parseFile( filePath: string, validValues: string[], - value: string + value: string, ): IProjectFileInfo { const regex = util.format("^(.+?)[.](%s)([.].+?)$", validValues.join("|")); const parsed = filePath.match(new RegExp(regex, "i")); diff --git a/lib/common/services/proxy-service.ts b/lib/common/services/proxy-service.ts index 5c3cdccc93..857fca8010 100644 --- a/lib/common/services/proxy-service.ts +++ b/lib/common/services/proxy-service.ts @@ -16,11 +16,11 @@ export class ProxyService implements IProxyService { constructor( private $settingsService: ISettingsService, - private $staticConfig: Config.IStaticConfig + private $staticConfig: Config.IStaticConfig, ) { this.proxyCacheFilePath = path.join( this.$settingsService.getProfileDir(), - Proxy.CACHE_FILE_NAME + Proxy.CACHE_FILE_NAME, ); this.credentialsKey = `${this.$staticConfig.CLIENT_NAME}_PROXY`; } diff --git a/lib/common/services/qr.ts b/lib/common/services/qr.ts index 3328d89e61..7813847e60 100644 --- a/lib/common/services/qr.ts +++ b/lib/common/services/qr.ts @@ -6,7 +6,7 @@ import { IQrCodeGenerator } from "../declarations"; export class QrCodeGenerator implements IQrCodeGenerator { constructor( private $staticConfig: Config.IStaticConfig, - private $logger: ILogger + private $logger: ILogger, ) {} public async generateDataUri(data: string): Promise { diff --git a/lib/common/services/settings-service.ts b/lib/common/services/settings-service.ts index 8cbbf502ae..78342700a9 100644 --- a/lib/common/services/settings-service.ts +++ b/lib/common/services/settings-service.ts @@ -13,7 +13,7 @@ export class SettingsService implements ISettingsService { constructor( private $staticConfig: Config.IStaticConfig, - private $hostInfo: IHostInfo + private $hostInfo: IHostInfo, ) { this._profileDir = this.getDefaultProfileDir(); } @@ -39,7 +39,7 @@ export class SettingsService implements ISettingsService { : path.join(homedir(), ".local", "share"); return path.join( defaultProfileDirLocation, - this.$staticConfig.PROFILE_DIR_NAME + this.$staticConfig.PROFILE_DIR_NAME, ); } } diff --git a/lib/common/services/xcode-select-service.ts b/lib/common/services/xcode-select-service.ts index 733d9c56e4..49e3816fbc 100644 --- a/lib/common/services/xcode-select-service.ts +++ b/lib/common/services/xcode-select-service.ts @@ -16,7 +16,7 @@ export class XcodeSelectService implements IXcodeSelectService { private $childProcess: IChildProcess, private $errors: IErrors, private $hostInfo: IHostInfo, - private $injector: IInjector + private $injector: IInjector, ) {} public async getDeveloperDirectoryPath(): Promise { @@ -29,13 +29,13 @@ export class XcodeSelectService implements IXcodeSelectService { ["-print-path"], "close", {}, - { throwError: false } + { throwError: false }, ), result = childProcess.stdout.trim(); if (!result) { this.$errors.fail( - "Cannot find path to Xcode.app - make sure you've installed Xcode correctly." + "Cannot find path to Xcode.app - make sure you've installed Xcode correctly.", ); } @@ -52,7 +52,7 @@ export class XcodeSelectService implements IXcodeSelectService { const xcodeVer = await sysInfo.getXcodeVersion(); if (!xcodeVer) { this.$errors.fail( - "xcodebuild execution failed. Make sure that you have latest Xcode and tools installed." + "xcodebuild execution failed. Make sure that you have latest Xcode and tools installed.", ); } diff --git a/lib/common/test/test-bootstrap.ts b/lib/common/test/test-bootstrap.ts index 9020758cab..fe7741f266 100644 --- a/lib/common/test/test-bootstrap.ts +++ b/lib/common/test/test-bootstrap.ts @@ -23,7 +23,7 @@ injector.register("analyticsService", { async getStatusMessage( settingName: string, jsonFormat: boolean, - readableSettingName: string + readableSettingName: string, ): Promise { return "Fake message"; }, diff --git a/lib/common/test/unit-tests/android-application-manager.ts b/lib/common/test/unit-tests/android-application-manager.ts index 775972b194..59fa8bfac2 100644 --- a/lib/common/test/unit-tests/android-application-manager.ts +++ b/lib/common/test/unit-tests/android-application-manager.ts @@ -79,15 +79,13 @@ class AndroidDebugBridgeStub { if (passedIdentifier === invalidIdentifier) { return "invalid output string"; } else { - const testString = this.validTestInput[ - AndroidDebugBridgeStub.methodCallCount - ]; + const testString = + this.validTestInput[AndroidDebugBridgeStub.methodCallCount]; return testString; } } else { - this.startedWithActivityManager = this.checkIfStartedWithActivityManager( - args - ); + this.startedWithActivityManager = + this.checkIfStartedWithActivityManager(args); if (this.startedWithActivityManager) { this.validIdentifierPassed = this.checkIfValidIdentifierPassed(args); } @@ -103,7 +101,7 @@ class AndroidDebugBridgeStub { public async pushFile( localFilePath: string, - deviceFilePath: string + deviceFilePath: string, ): Promise { await this.executeShellCommand(["push", localFilePath, deviceFilePath]); } @@ -121,9 +119,8 @@ class AndroidDebugBridgeStub { private checkIfValidIdentifierPassed(args: string[]): boolean { if (args && args.length) { const possibleIdentifier = args[args.length - 1]; - const validTestString = this.expectedValidTestInput[ - AndroidDebugBridgeStub.methodCallCount - ]; + const validTestString = + this.expectedValidTestInput[AndroidDebugBridgeStub.methodCallCount]; return possibleIdentifier === validTestString; } @@ -150,7 +147,7 @@ function createTestInjector(options?: { justLaunch?: boolean }): IInjector { testInjector.register("androidProcessService", AndroidProcessServiceStub); testInjector.register( "androidBundleToolService", - AndroidBundleToolServiceStub + AndroidBundleToolServiceStub, ); testInjector.register("fs", FileSystemStub); testInjector.register("httpClient", {}); @@ -171,7 +168,7 @@ describe("android-application-manager", () => { function setup(options?: { justLaunch?: boolean }) { testInjector = createTestInjector(options); androidApplicationManager = testInjector.resolve( - "androidApplicationManager" + "androidApplicationManager", ); androidDebugBridge = testInjector.resolve("adb"); logcatHelper = testInjector.resolve("logcatHelper"); @@ -217,7 +214,7 @@ describe("android-application-manager", () => { setup(); await androidApplicationManager.startApplication( - _.extend({}, validStartOptions, { justLaunch: true }) + _.extend({}, validStartOptions, { justLaunch: true }), ); assert.equal(logcatHelper.StartCallCount, 0); @@ -227,7 +224,7 @@ describe("android-application-manager", () => { setup({ justLaunch: true }); await androidApplicationManager.startApplication( - _.extend({}, validStartOptions, { justLaunch: false }) + _.extend({}, validStartOptions, { justLaunch: false }), ); assert.equal(logcatHelper.StartCallCount, 0); @@ -237,7 +234,7 @@ describe("android-application-manager", () => { setup({ justLaunch: true }); await androidApplicationManager.startApplication( - _.extend({}, validStartOptions, { justLaunch: true }) + _.extend({}, validStartOptions, { justLaunch: true }), ); assert.equal(logcatHelper.StartCallCount, 0); @@ -262,7 +259,7 @@ describe("android-application-manager", () => { assert.equal( deviceLogProvider.currentDevicePids[validDeviceIdentifier], - expectedPid + expectedPid, ); }); @@ -279,8 +276,8 @@ describe("android-application-manager", () => { assert.isTrue(logger.traceOutput.indexOf("Wasn't able to get pid") > -1); assert.isTrue( logger.output.indexOf( - `Unable to find running "${validIdentifier}" application on device ` - ) === -1 + `Unable to find running "${validIdentifier}" application on device `, + ) === -1, ); }); @@ -291,20 +288,19 @@ describe("android-application-manager", () => { androidApplicationManager.PID_CHECK_TIMEOUT = expectedPidTimeout; androidProcessService.GetAppProcessIdResult = null; - const startApplicationPromise = androidApplicationManager.startApplication( - validStartOptions - ); + const startApplicationPromise = + androidApplicationManager.startApplication(validStartOptions); startApplicationPromise.catch(() => { assert.isTrue(logcatHelper.DumpCallCount > 0); assert.isTrue( - logger.traceOutput.indexOf("Wasn't able to get pid") > -1 + logger.traceOutput.indexOf("Wasn't able to get pid") > -1, ); }); return assert.isRejected( startApplicationPromise, - `Unable to find running "${validIdentifier}" application on device ` + `Unable to find running "${validIdentifier}" application on device `, ); }); }); @@ -312,17 +308,19 @@ describe("android-application-manager", () => { describe("installApplication", () => { afterEach(function () { androidDebugBridge.calledInstallApplication = false; - const bundleToolService = testInjector.resolve< - AndroidBundleToolServiceStub - >("androidBundleToolService"); + const bundleToolService = + testInjector.resolve( + "androidBundleToolService", + ); bundleToolService.isBuildApksCalled = false; bundleToolService.isInstallApksCalled = false; }); it("should install apk using adb", async () => { - const bundleToolService = testInjector.resolve< - AndroidBundleToolServiceStub - >("androidBundleToolService"); + const bundleToolService = + testInjector.resolve( + "androidBundleToolService", + ); await androidApplicationManager.installApplication("myApp.apk"); @@ -332,9 +330,10 @@ describe("android-application-manager", () => { }); it("should install aab using bundletool", async () => { - const bundleToolService = testInjector.resolve< - AndroidBundleToolServiceStub - >("androidBundleToolService"); + const bundleToolService = + testInjector.resolve( + "androidBundleToolService", + ); await androidApplicationManager.installApplication("myApp.aab"); @@ -345,14 +344,15 @@ describe("android-application-manager", () => { it("should skip aab build when already built", async () => { const fsStub = testInjector.resolve("fs"); - const bundleToolService = testInjector.resolve< - AndroidBundleToolServiceStub - >("androidBundleToolService"); + const bundleToolService = + testInjector.resolve( + "androidBundleToolService", + ); await androidApplicationManager.installApplication( "myApp.aab", "my.app", - validSigning + validSigning, ); assert.isTrue(bundleToolService.isBuildApksCalled); @@ -365,7 +365,7 @@ describe("android-application-manager", () => { await androidApplicationManager.installApplication( "myApp.aab", "my.app", - validSigning + validSigning, ); assert.isFalse(bundleToolService.isBuildApksCalled); @@ -398,7 +398,7 @@ describe("android-application-manager", () => { assert.equal( deviceLogProvider.currentDevicePids[validDeviceIdentifier], - null + null, ); }); }); diff --git a/lib/common/test/unit-tests/android-log-filter.ts b/lib/common/test/unit-tests/android-log-filter.ts index b6191294b9..221694526e 100644 --- a/lib/common/test/unit-tests/android-log-filter.ts +++ b/lib/common/test/unit-tests/android-log-filter.ts @@ -696,7 +696,8 @@ const androidApiLevel23MapForPid8141 = [ { input: "07-25 06:37:04.998 8141 8141 W System.err: at com.tns.Runtime.callJSMethodNative(Native Method)", - output: "System.err: at com.tns.Runtime.callJSMethodNative(Native Method)", + output: + "System.err: at com.tns.Runtime.callJSMethodNative(Native Method)", }, { input: @@ -707,7 +708,8 @@ const androidApiLevel23MapForPid8141 = [ { input: "07-25 06:37:04.998 8141 8141 W System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)", - output: "System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)", + output: + "System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)", }, { input: diff --git a/lib/common/test/unit-tests/appbuilder/device-log-provider.ts b/lib/common/test/unit-tests/appbuilder/device-log-provider.ts index 6cdeeba552..877ba0df82 100644 --- a/lib/common/test/unit-tests/appbuilder/device-log-provider.ts +++ b/lib/common/test/unit-tests/appbuilder/device-log-provider.ts @@ -12,7 +12,7 @@ function createTestInjector(loggingLevel: string, emptyFilteredData?: boolean) { filterData: ( platform: string, data: string, - loggingOptions: Mobile.IDeviceLogOptions + loggingOptions: Mobile.IDeviceLogOptions, ) => { return emptyFilteredData ? null : `${loggingOptions.logLevel} ${data}`; }, @@ -46,7 +46,7 @@ describe("proton deviceLogProvider", () => { "data", (deviceIdentifier: string, data: string) => { emittedData = data; - } + }, ); deviceLogProvider.logData(testData, "platform"); assert.deepStrictEqual(emittedData, filteredInfoData); @@ -61,12 +61,12 @@ describe("proton deviceLogProvider", () => { "data", (deviceIdentifier: string, data: string) => { emittedData = data; - } + }, ); deviceLogProvider.logData(testData, "platform"); assert.deepStrictEqual( emittedData, - "some default value that should NOT be changed" + "some default value that should NOT be changed", ); }); }); @@ -82,7 +82,7 @@ describe("proton deviceLogProvider", () => { (deviceIdentifier: string, data: string) => { emittedData = data; expectedDeviceIdentifier = deviceIdentifier; - } + }, ); deviceLogProvider.logData(testData, "platform", "deviceId"); assert.deepStrictEqual(emittedData, filteredInfoData); @@ -100,12 +100,12 @@ describe("proton deviceLogProvider", () => { (deviceIdentifier: string, data: string) => { emittedData = data; expectedDeviceIdentifier = deviceIdentifier; - } + }, ); deviceLogProvider.logData(testData, "platform"); assert.deepStrictEqual( emittedData, - "some default value that should NOT be changed" + "some default value that should NOT be changed", ); assert.deepStrictEqual(expectedDeviceIdentifier, null); }); diff --git a/lib/common/test/unit-tests/helpers.ts b/lib/common/test/unit-tests/helpers.ts index ac924e7cbc..07281673a8 100644 --- a/lib/common/test/unit-tests/helpers.ts +++ b/lib/common/test/unit-tests/helpers.ts @@ -580,7 +580,6 @@ describe("helpers", () => { }); describe("getPidFromiOSSimulatorLogs", () => { - // tslint:disable-next-line:interface-name interface IiOSSimulatorPidTestData extends ITestData { appId?: string; } diff --git a/lib/common/test/unit-tests/host-info.ts b/lib/common/test/unit-tests/host-info.ts index e1631c80ba..91120f5356 100644 --- a/lib/common/test/unit-tests/host-info.ts +++ b/lib/common/test/unit-tests/host-info.ts @@ -60,7 +60,7 @@ describe("hostInfo", () => { childProcess.exec = async ( command: string, options?: any, - execOptions?: IExecOptions + execOptions?: IExecOptions, ): Promise => { calledCommand = command; return `Software: @@ -76,7 +76,7 @@ describe("hostInfo", () => { assert.deepStrictEqual(macOSVersion, "10.13"); assert.equal( calledCommand, - "system_profiler SPSoftwareDataType -detailLevel mini" + "system_profiler SPSoftwareDataType -detailLevel mini", ); }); @@ -88,7 +88,7 @@ describe("hostInfo", () => { childProcess.exec = async ( command: string, options?: any, - execOptions?: IExecOptions + execOptions?: IExecOptions, ): Promise => { calledCommand = command; return `Software: @@ -104,7 +104,7 @@ describe("hostInfo", () => { assert.deepStrictEqual(macOSVersion, "10.14"); assert.equal( calledCommand, - "system_profiler SPSoftwareDataType -detailLevel mini" + "system_profiler SPSoftwareDataType -detailLevel mini", ); }); @@ -115,7 +115,7 @@ describe("hostInfo", () => { childProcess.exec = async ( command: string, options?: any, - execOptions?: IExecOptions + execOptions?: IExecOptions, ): Promise => { throw new Error("Err"); }; @@ -133,7 +133,7 @@ describe("hostInfo", () => { childProcess.exec = async ( command: string, options?: any, - execOptions?: IExecOptions + execOptions?: IExecOptions, ): Promise => { return "Non-matching data"; }; diff --git a/lib/common/test/unit-tests/ios-log-filter.ts b/lib/common/test/unit-tests/ios-log-filter.ts index ed07a29e11..8aa7bd2d96 100644 --- a/lib/common/test/unit-tests/ios-log-filter.ts +++ b/lib/common/test/unit-tests/ios-log-filter.ts @@ -147,7 +147,7 @@ describe("iOSLogFilter", () => { inputData: string, expectedOutput: string, _logLevel?: string, - _pid?: string + _pid?: string, ) => { const testInjector = new Yok(); testInjector.register("loggingLevels", LoggingLevels); @@ -162,7 +162,7 @@ describe("iOSLogFilter", () => { assert.deepStrictEqual( filteredData, expectedOutput, - `The actual result '${filteredData}' did NOT match expected output '${expectedOutput}'.` + `The actual result '${filteredData}' did NOT match expected output '${expectedOutput}'.`, ); }; @@ -208,7 +208,7 @@ describe("iOSLogFilter", () => { testData.input, testData.pid13309Output, logLevel, - pid + pid, ); }); }); diff --git a/lib/common/test/unit-tests/log-filter.ts b/lib/common/test/unit-tests/log-filter.ts index 04526a2943..10dd80be45 100644 --- a/lib/common/test/unit-tests/log-filter.ts +++ b/lib/common/test/unit-tests/log-filter.ts @@ -49,7 +49,7 @@ describe("logFilter", () => { assert.deepStrictEqual( logFilter.loggingLevel, infoLogLevel, - "Default level should be INFO." + "Default level should be INFO.", ); }); @@ -58,7 +58,7 @@ describe("logFilter", () => { assert.deepStrictEqual( logFilter.loggingLevel, fullLogLevel, - "Default level should be FULL." + "Default level should be FULL.", ); }); @@ -67,7 +67,7 @@ describe("logFilter", () => { assert.deepStrictEqual( logFilter.loggingLevel, infoLogLevel, - "Default level should be INFO." + "Default level should be INFO.", ); }); @@ -76,7 +76,7 @@ describe("logFilter", () => { assert.deepStrictEqual( logFilter.loggingLevel, infoLogLevel, - "Default level should be INFO." + "Default level should be INFO.", ); }); }); @@ -123,7 +123,7 @@ describe("logFilter", () => { const actualData = logFilter.filterData( "invalidPlatform", testData, - null + null, ); assert.deepStrictEqual(actualData, testData); }); diff --git a/lib/common/test/unit-tests/logger.ts b/lib/common/test/unit-tests/logger.ts index 0c2ce48a9a..b785272f0a 100644 --- a/lib/common/test/unit-tests/logger.ts +++ b/lib/common/test/unit-tests/logger.ts @@ -76,7 +76,7 @@ describe("logger", () => { it(`${methodName} should obfuscate password parameter when the string is larger`, () => { const dataFilePath = path.join( __dirname, - "./mocks/nativescript-cloud-npmjs-result.txt" + "./mocks/nativescript-cloud-npmjs-result.txt", ); const data = fs.readText(dataFilePath); const before = Date.now(); @@ -91,7 +91,7 @@ describe("logger", () => { it(`${methodName} should not get slower when the string is really large`, () => { const dataFilePath = path.join( __dirname, - "./mocks/tns-android-npmjs-result.txt" + "./mocks/tns-android-npmjs-result.txt", ); const data = fs.readText(dataFilePath); const before = Date.now(); @@ -100,9 +100,9 @@ describe("logger", () => { assert.notEqual( outputs[methodName].indexOf( - "https://github.com/NativeScript/android-runtime" + "https://github.com/NativeScript/android-runtime", ), - -1 + -1, ); assert.isTrue(after - before < 50); }); @@ -116,7 +116,7 @@ describe("logger", () => { assert.deepStrictEqual( outputs[methodName], `{ certificate${passwordString}: '${passwordReplacement}', otherProperty: 'pass' }`, - `logger.${methodName} should obfuscate ${passwordString} properties` + `logger.${methodName} should obfuscate ${passwordString} properties`, ); }); @@ -128,7 +128,7 @@ describe("logger", () => { assert.deepStrictEqual( outputs[methodName], `{ certificate${passwordString}: '${passwordReplacement}' }`, - `logger.${methodName} should obfuscate ${passwordString} properties` + `logger.${methodName} should obfuscate ${passwordString} properties`, ); }); @@ -140,7 +140,7 @@ describe("logger", () => { assert.deepStrictEqual( outputs[methodName], `{ certificate${passwordString}: "${passwordReplacement}", otherProperty: "pass" }`, - `logger.${methodName} should obfuscate ${passwordString} properties` + `logger.${methodName} should obfuscate ${passwordString} properties`, ); }); @@ -152,7 +152,7 @@ describe("logger", () => { assert.deepStrictEqual( outputs[methodName], `{ certificate${passwordString}: "${passwordReplacement}" }`, - `logger.${methodName} should obfuscate ${passwordString} properties` + `logger.${methodName} should obfuscate ${passwordString} properties`, ); }); @@ -164,7 +164,7 @@ describe("logger", () => { assert.deepStrictEqual( outputs[methodName], `{ proto: 'https', host: 'platform.telerik.com', path: '/appbuilder/api/itmstransporter/applications?username=dragon.telerikov%40yahoo.com&${passwordString}=${passwordReplacement}', method: 'POST' }`, - `logger.${methodName} should obfuscate ${passwordString} when in query parameter` + `logger.${methodName} should obfuscate ${passwordString} when in query parameter`, ); }); @@ -176,7 +176,7 @@ describe("logger", () => { assert.deepStrictEqual( outputs[methodName], `{ proto: 'https', host: 'platform.telerik.com', path: '/appbuilder/api/itmstransporter/applications?username=dragon.telerikov%40yahoo.com&${passwordString}=${passwordReplacement}&data=someOtherData', method: 'POST' }`, - `logger.${methodName} should obfuscate ${passwordString} when in query parameter` + `logger.${methodName} should obfuscate ${passwordString} when in query parameter`, ); }); }); @@ -194,7 +194,7 @@ describe("logger", () => { assert.deepStrictEqual( outputs.trace, `${request}${requestBody}`, - "logger.trace should not obfuscate body of request unless it is towards api/itmstransporter" + "logger.trace should not obfuscate body of request unless it is towards api/itmstransporter", ); }); }); @@ -215,12 +215,12 @@ describe("logger", () => { assert.deepStrictEqual( outputs.context, {}, - "Nothing should be added to logger context." + "Nothing should be added to logger context.", ); assert.deepStrictEqual( outputs.removedContext, {}, - "Removed context should be empty." + "Removed context should be empty.", ); }); @@ -230,12 +230,12 @@ describe("logger", () => { assert.deepStrictEqual( outputs.context, { [LoggerConfigData.skipNewLine]: true }, - `${LoggerConfigData.skipNewLine} should be set with value true.` + `${LoggerConfigData.skipNewLine} should be set with value true.`, ); assert.deepStrictEqual( outputs.removedContext, { [LoggerConfigData.skipNewLine]: true }, - `Removed context should contain ${LoggerConfigData.skipNewLine}` + `Removed context should contain ${LoggerConfigData.skipNewLine}`, ); }); }); @@ -284,12 +284,12 @@ describe("logger", () => { assert.deepStrictEqual( outputs.context, { [LoggerConfigData.skipNewLine]: true }, - `${LoggerConfigData.skipNewLine} should be set with value true.` + `${LoggerConfigData.skipNewLine} should be set with value true.`, ); assert.deepStrictEqual( outputs.removedContext, { [LoggerConfigData.skipNewLine]: true }, - `Removed context should contain ${LoggerConfigData.skipNewLine}` + `Removed context should contain ${LoggerConfigData.skipNewLine}`, ); }); }); @@ -302,12 +302,12 @@ describe("logger", () => { assert.deepStrictEqual( outputs.context, { [LoggerConfigData.useStderr]: true }, - `${LoggerConfigData.useStderr} should be set with value true.` + `${LoggerConfigData.useStderr} should be set with value true.`, ); assert.deepStrictEqual( outputs.removedContext, { [LoggerConfigData.useStderr]: true }, - `Removed context should contain ${LoggerConfigData.useStderr}` + `Removed context should contain ${LoggerConfigData.useStderr}`, ); }); @@ -317,12 +317,12 @@ describe("logger", () => { assert.deepStrictEqual( outputs.context, { [LoggerConfigData.useStderr]: false }, - `${LoggerConfigData.useStderr} should be set with value false.` + `${LoggerConfigData.useStderr} should be set with value false.`, ); assert.deepStrictEqual( outputs.removedContext, { [LoggerConfigData.useStderr]: true }, - `Removed context should contain ${LoggerConfigData.useStderr}` + `Removed context should contain ${LoggerConfigData.useStderr}`, ); }); }); diff --git a/lib/common/test/unit-tests/messages-service.ts b/lib/common/test/unit-tests/messages-service.ts index db9886dcab..31905f1376 100644 --- a/lib/common/test/unit-tests/messages-service.ts +++ b/lib/common/test/unit-tests/messages-service.ts @@ -9,7 +9,7 @@ import { IInjector } from "../../definitions/yok"; function createTestInjector( jsonContents: any, - options?: { useRealFsExists: boolean } + options?: { useRealFsExists: boolean }, ): IInjector { const testInjector = new Yok(); testInjector.register("fs", { @@ -32,7 +32,7 @@ describe("messages-service", () => { assert.deepStrictEqual( 1, service.pathsToMessageJsonFiles.length, - "Messages service should initialize with a default json file." + "Messages service should initialize with a default json file.", ); }); @@ -44,7 +44,7 @@ describe("messages-service", () => { assert.deepStrictEqual( 2, service.pathsToMessageJsonFiles.length, - "Messages service should append the default json file." + "Messages service should append the default json file.", ); }); @@ -66,7 +66,7 @@ describe("messages-service", () => { assert.deepStrictEqual( stringMessage, resultMessage, - "Messages service should return the given message if not found as key in any json file in `pathsToMessageJsonFiles` property." + "Messages service should return the given message if not found as key in any json file in `pathsToMessageJsonFiles` property.", ); }); @@ -81,7 +81,7 @@ describe("messages-service", () => { assert.deepStrictEqual( expectedMessage, resultMessage, - "Messages service should apply util.format." + "Messages service should apply util.format.", ); }); @@ -93,7 +93,7 @@ describe("messages-service", () => { assert.deepStrictEqual( jsonContents.KEY, service.getMessage("KEY"), - "Messages service should return correct value from json file by given key." + "Messages service should return correct value from json file by given key.", ); }); @@ -109,7 +109,7 @@ describe("messages-service", () => { assert.deepStrictEqual( expectedMessage, actualMessage, - "Messages service should util.format value from json file by given key when value is format." + "Messages service should util.format value from json file by given key when value is format.", ); }); @@ -125,7 +125,7 @@ describe("messages-service", () => { assert.deepStrictEqual( jsonContents.KEY.NESTED_KEY, service.getMessage("KEY.NESTED_KEY"), - "Messages service should return correct value from json file by given complex key." + "Messages service should return correct value from json file by given complex key.", ); }); @@ -142,7 +142,7 @@ describe("messages-service", () => { "..", "resources", "messages", - "errorMessages.json" + "errorMessages.json", ), injector = createTestInjector({}); @@ -159,12 +159,12 @@ describe("messages-service", () => { assert.notDeepEqual( commonJsonContents.KEY, service.getMessage("KEY"), - "Messages service should return correct value from json file when value is overriden by client." + "Messages service should return correct value from json file when value is overriden by client.", ); assert.deepStrictEqual( clientJsonContents.KEY, service.getMessage("KEY"), - "Messages service should return correct value from json file when value is overriden by client." + "Messages service should return correct value from json file when value is overriden by client.", ); }); }); diff --git a/lib/common/test/unit-tests/mobile/android-debug-bridge.ts b/lib/common/test/unit-tests/mobile/android-debug-bridge.ts index a2d07be1f3..90b23f37a2 100644 --- a/lib/common/test/unit-tests/mobile/android-debug-bridge.ts +++ b/lib/common/test/unit-tests/mobile/android-debug-bridge.ts @@ -51,14 +51,14 @@ describe("androidDebugBridge", () => { }); injector.register( "androidDebugBridgeResultHandler", - AndroidDebugBridgeResultHandler + AndroidDebugBridgeResultHandler, ); injector.register("childProcess", { spawnFromEvent: async ( command: string, args: string[], event: string, - opts?: any + opts?: any, ): Promise => { isAdbSpawnedFromEvent = command.indexOf(adbPath) !== -1; spawnedArgs = args; @@ -75,7 +75,7 @@ describe("androidDebugBridge", () => { spawn: async ( command: string, args?: string[], - opts?: any + opts?: any, ): Promise => { isAdbSpawnedFromChildProcess = command.indexOf(adbPath) !== -1; spawnedArgs = args; @@ -230,11 +230,11 @@ describe("androidDebugBridge", () => { assert.deepStrictEqual( result, [], - "When adb get devices fail, getDevicesSafe must return empty array" + "When adb get devices fail, getDevicesSafe must return empty array", ); assert.isTrue( logger.traceOutput.indexOf("Getting adb devices failed with error") !== - -1 + -1, ); }); }); diff --git a/lib/common/test/unit-tests/mobile/android-device-discovery.ts b/lib/common/test/unit-tests/mobile/android-device-discovery.ts index 178162ad49..40c0408c05 100644 --- a/lib/common/test/unit-tests/mobile/android-device-discovery.ts +++ b/lib/common/test/unit-tests/mobile/android-device-discovery.ts @@ -14,7 +14,10 @@ import { IDictionary } from "../../../declarations"; class AndroidDeviceMock { public deviceInfo: any = {}; - constructor(public identifier: string, public status: string) { + constructor( + public identifier: string, + public status: string, + ) { this.deviceInfo.identifier = identifier; this.deviceInfo.status = status; } @@ -46,7 +49,7 @@ function createTestInjector(): IInjector { injector.register("logger", {}); injector.register( "androidDebugBridgeResultHandler", - AndroidDebugBridgeResultHandler + AndroidDebugBridgeResultHandler, ); injector.register("mobileHelper", { isAndroidPlatform: () => { @@ -65,7 +68,7 @@ function createTestInjector(): IInjector { args: string[], event: string, options?: any, - spawnFromEventOptions?: any + spawnFromEventOptions?: any, ) => { return Promise.resolve(args); }, @@ -88,7 +91,7 @@ function createTestInjector(): IInjector { ) { return new AndroidDeviceMock( ctorArguments["identifier"], - ctorArguments["status"] + ctorArguments["status"], ); } else { return originalResolve.apply(injector, [param, ctorArguments]); @@ -121,7 +124,7 @@ describe("androidDeviceDiscovery", () => { DeviceDiscoveryEventNames.DEVICE_FOUND, (device: Mobile.IDevice) => { devicesFound.push(device); - } + }, ); // As startLookingForDevices is blocking, we should emit data on the next tick, so the future will be resolved and we'll receive the data. @@ -134,11 +137,11 @@ describe("androidDeviceDiscovery", () => { await androidDeviceDiscovery.startLookingForDevices(); assert.isTrue( devicesFound.length === 1, - "We should have found ONE device." + "We should have found ONE device.", ); assert.deepStrictEqual( devicesFound[0].deviceInfo.identifier, - androidDeviceIdentifier + androidDeviceIdentifier, ); assert.deepStrictEqual(devicesFound[0].status, androidDeviceStatus); }); @@ -146,10 +149,11 @@ describe("androidDeviceDiscovery", () => { describe("ensureAdbServerStarted", () => { it("should spawn adb with start-server parameter", async () => { - const ensureAdbServerStartedOutput = await androidDeviceDiscovery.ensureAdbServerStarted(); + const ensureAdbServerStartedOutput = + await androidDeviceDiscovery.ensureAdbServerStarted(); assert.isTrue( _.includes(ensureAdbServerStartedOutput, "start-server"), - "start-server should be passed to adb." + "start-server should be passed to adb.", ); }); }); @@ -164,7 +168,7 @@ describe("androidDeviceDiscovery", () => { devicesFound.push(device); resolve(); }); - } + }, ); setTimeout(() => { @@ -177,11 +181,11 @@ describe("androidDeviceDiscovery", () => { await promise; assert.isTrue( devicesFound.length === 1, - "We should have found ONE device." + "We should have found ONE device.", ); assert.deepStrictEqual( devicesFound[0].deviceInfo.identifier, - androidDeviceIdentifier + androidDeviceIdentifier, ); assert.deepStrictEqual(devicesFound[0].status, androidDeviceStatus); }); @@ -197,7 +201,7 @@ describe("androidDeviceDiscovery", () => { resolve(); } }); - } + }, ); setTimeout(() => { @@ -210,16 +214,16 @@ describe("androidDeviceDiscovery", () => { await promise; assert.isTrue( devicesFound.length === 2, - "We should have found two devices." + "We should have found two devices.", ); assert.deepStrictEqual( devicesFound[0].deviceInfo.identifier, - androidDeviceIdentifier + androidDeviceIdentifier, ); assert.deepStrictEqual(devicesFound[0].status, androidDeviceStatus); assert.deepStrictEqual( devicesFound[1].deviceInfo.identifier, - "secondDevice" + "secondDevice", ); assert.deepStrictEqual(devicesFound[1].status, androidDeviceStatus); }); @@ -229,7 +233,7 @@ describe("androidDeviceDiscovery", () => { DeviceDiscoveryEventNames.DEVICE_FOUND, (device: Mobile.IDevice) => { throw new Error("Devices should not be found."); - } + }, ); setTimeout(() => { @@ -241,12 +245,12 @@ describe("androidDeviceDiscovery", () => { await androidDeviceDiscovery.startLookingForDevices(); assert.isTrue( devicesFound.length === 0, - "We should have NOT found devices." + "We should have NOT found devices.", ); }); const validateDeviceFoundWhenAdbReportsAdditionalMessages = async ( - adbMessage: string + adbMessage: string, ) => { let promise: Promise; androidDeviceDiscovery.on( @@ -256,7 +260,7 @@ describe("androidDeviceDiscovery", () => { devicesFound.push(device); resolve(); }); - } + }, ); setTimeout(() => { @@ -269,11 +273,11 @@ describe("androidDeviceDiscovery", () => { await promise; assert.isTrue( devicesFound.length === 1, - "We should have found ONE device." + "We should have found ONE device.", ); assert.deepStrictEqual( devicesFound[0].deviceInfo.identifier, - androidDeviceIdentifier + androidDeviceIdentifier, ); assert.deepStrictEqual(devicesFound[0].status, androidDeviceStatus); }; @@ -306,7 +310,7 @@ describe("androidDeviceDiscovery", () => { devicesFound.push(device); resolve(); }); - } + }, ); setTimeout(() => { @@ -317,7 +321,7 @@ describe("androidDeviceDiscovery", () => { await androidDeviceDiscovery.startLookingForDevices(); await promise; androidDeviceDiscovery.removeAllListeners( - DeviceDiscoveryEventNames.DEVICE_FOUND + DeviceDiscoveryEventNames.DEVICE_FOUND, ); }); @@ -326,7 +330,7 @@ describe("androidDeviceDiscovery", () => { DeviceDiscoveryEventNames.DEVICE_FOUND, (device: Mobile.IDevice) => { throw new Error("Should not report same device as found"); - } + }, ); setTimeout(() => { @@ -337,11 +341,11 @@ describe("androidDeviceDiscovery", () => { await androidDeviceDiscovery.startLookingForDevices(); assert.isTrue( devicesFound.length === 1, - "We should have found ONE device." + "We should have found ONE device.", ); assert.deepStrictEqual( devicesFound[0].deviceInfo.identifier, - androidDeviceIdentifier + androidDeviceIdentifier, ); assert.deepStrictEqual(devicesFound[0].status, androidDeviceStatus); }); @@ -353,7 +357,7 @@ describe("androidDeviceDiscovery", () => { DeviceDiscoveryEventNames.DEVICE_LOST, (device: Mobile.IDevice) => { promise = Promise.resolve(device); - } + }, ); setTimeout(() => { @@ -365,11 +369,11 @@ describe("androidDeviceDiscovery", () => { const lostDevice = await promise; assert.deepStrictEqual( lostDevice.deviceInfo.identifier, - androidDeviceIdentifier + androidDeviceIdentifier, ); assert.deepStrictEqual( lostDevice.deviceInfo.status, - androidDeviceStatus + androidDeviceStatus, ); }); @@ -380,7 +384,7 @@ describe("androidDeviceDiscovery", () => { DeviceDiscoveryEventNames.DEVICE_LOST, (device: Mobile.IDevice) => { promise = Promise.resolve(device); - } + }, ); const output = `List of devices attached${EOL}`; @@ -394,20 +398,20 @@ describe("androidDeviceDiscovery", () => { const lostDevice = await promise; assert.deepStrictEqual( lostDevice.deviceInfo.identifier, - androidDeviceIdentifier + androidDeviceIdentifier, ); assert.deepStrictEqual( lostDevice.deviceInfo.status, - androidDeviceStatus + androidDeviceStatus, ); androidDeviceDiscovery.on( DeviceDiscoveryEventNames.DEVICE_LOST, (device: Mobile.IDevice) => { throw new Error( - "Should not report device as removed next time after it has been already reported." + "Should not report device as removed next time after it has been already reported.", ); - } + }, ); setTimeout(() => { @@ -427,10 +431,10 @@ describe("androidDeviceDiscovery", () => { (device: Mobile.IDevice) => { _.remove( devicesFound, - (d) => d.deviceInfo.identifier === device.deviceInfo.identifier + (d) => d.deviceInfo.identifier === device.deviceInfo.identifier, ); deviceLostPromise = Promise.resolve(device); - } + }, ); androidDeviceDiscovery.on( @@ -438,7 +442,7 @@ describe("androidDeviceDiscovery", () => { (device: Mobile.IDevice) => { devicesFound.push(device); deviceFoundPromise = Promise.resolve(device); - } + }, ); const output = `List of devices attached${EOL}${androidDeviceIdentifier} unauthorized${EOL}${EOL}`; @@ -452,21 +456,21 @@ describe("androidDeviceDiscovery", () => { const lostDevice = await deviceLostPromise; assert.deepStrictEqual( lostDevice.deviceInfo.identifier, - androidDeviceIdentifier + androidDeviceIdentifier, ); assert.deepStrictEqual( lostDevice.deviceInfo.status, - androidDeviceStatus + androidDeviceStatus, ); await deviceFoundPromise; assert.isTrue( devicesFound.length === 1, - "We should have found ONE device." + "We should have found ONE device.", ); assert.deepStrictEqual( devicesFound[0].deviceInfo.identifier, - androidDeviceIdentifier + androidDeviceIdentifier, ); assert.deepStrictEqual(devicesFound[0].status, "unauthorized"); @@ -479,7 +483,7 @@ describe("androidDeviceDiscovery", () => { await androidDeviceDiscovery.startLookingForDevices(); assert.isTrue( devicesFound.length === 1, - "We should have found ONE device." + "We should have found ONE device.", ); }); }); @@ -489,7 +493,7 @@ describe("androidDeviceDiscovery", () => { DeviceDiscoveryEventNames.DEVICE_FOUND, (device: Mobile.IDevice) => { throw new Error("Devices should not be found."); - } + }, ); const error = new Error("ADB Error"); @@ -528,7 +532,7 @@ describe("androidDeviceDiscovery", () => { DeviceDiscoveryEventNames.DEVICE_FOUND, (device: Mobile.IDevice) => { throw new Error("Devices should not be found."); - } + }, ); const error = new Error("ADB Error"); try { diff --git a/lib/common/test/unit-tests/mobile/android-device-file-system.ts b/lib/common/test/unit-tests/mobile/android-device-file-system.ts index e2e9232192..d7f346f733 100644 --- a/lib/common/test/unit-tests/mobile/android-device-file-system.ts +++ b/lib/common/test/unit-tests/mobile/android-device-file-system.ts @@ -34,7 +34,7 @@ class AndroidDebugBridgeMock { public async pushFile( localFilePath: string, - deviceFilePath: string + deviceFilePath: string, ): Promise { await this.executeCommand(["push", localFilePath, deviceFilePath]); } @@ -49,17 +49,17 @@ class LocalToDevicePathDataMock { public getDevicePath(): string { return `${LiveSyncPaths.ANDROID_TMP_DIR_NAME}/${path.basename( - this.filePath + this.filePath, )}`; } } -function mockFsStats(options: { - isDirectory: boolean; - isFile: boolean; -}): ( - filePath: string -) => { isDirectory: () => boolean; isFile: () => boolean } { +function mockFsStats(options: { isDirectory: boolean; isFile: boolean }): ( + filePath: string, +) => { + isDirectory: () => boolean; + isFile: () => boolean; +} { return (filePath: string) => ({ isDirectory: (): boolean => options.isDirectory, isFile: (): boolean => options.isFile, @@ -117,7 +117,7 @@ function setup(options?: { deviceAndroidVersion?: string }) { `${projectRoot}/${unmodifiedFileName}`, ]; const localToDevicePaths = _.map(files, (file) => - injector.resolve(LocalToDevicePathDataMock, { filePath: file }) + injector.resolve(LocalToDevicePathDataMock, { filePath: file }), ); const deviceAppData = createDeviceAppData(options.deviceAndroidVersion); @@ -149,7 +149,7 @@ describe("AndroidDeviceFileSystem", () => { await androidDeviceFileSystem.transferDirectory( testSetup.deviceAppData, testSetup.localToDevicePaths, - testSetup.projectRoot + testSetup.projectRoot, ); assert.isTrue(isAdbPushExecuted); @@ -164,7 +164,7 @@ describe("AndroidDeviceFileSystem", () => { await androidDeviceFileSystem.transferDirectory( testSetup.deviceAppData, testSetup.localToDevicePaths, - testSetup.projectRoot + testSetup.projectRoot, ); assert.isTrue(isAdbPushExecuted); @@ -179,7 +179,7 @@ describe("AndroidDeviceFileSystem", () => { await androidDeviceFileSystem.transferDirectory( testSetup.deviceAppData, testSetup.localToDevicePaths, - testSetup.projectRoot + testSetup.projectRoot, ); assert.isTrue(isAdbPushExecuted); @@ -194,7 +194,7 @@ describe("AndroidDeviceFileSystem", () => { await androidDeviceFileSystem.transferDirectory( testSetup.deviceAppData, testSetup.localToDevicePaths, - testSetup.projectRoot + testSetup.projectRoot, ); assert.isTrue(isAdbPushExecuted); diff --git a/lib/common/test/unit-tests/mobile/android-virtual-device-service.ts b/lib/common/test/unit-tests/mobile/android-virtual-device-service.ts index 583f8da101..d2ca9e3b63 100644 --- a/lib/common/test/unit-tests/mobile/android-virtual-device-service.ts +++ b/lib/common/test/unit-tests/mobile/android-virtual-device-service.ts @@ -49,7 +49,7 @@ const avdManagerOutputWithInvalidDevice = function getValueFromIniFilesData( propertyName: string, iniFilePath: string, - iniFilesData: IDictionary + iniFilesData: IDictionary, ) { return ( iniFilesData && @@ -64,22 +64,22 @@ function mockParseIniFile(iniFilePath: string, data: any) { avdId: getValueFromIniFilesData( "avdId", iniFilePath, - data && data.iniFilesData + data && data.iniFilesData, ), path: getValueFromIniFilesData( "path", iniFilePath, - data && data.iniFilesData + data && data.iniFilesData, ), device: getValueFromIniFilesData( "device", iniFilePath, - data && data.iniFilesData + data && data.iniFilesData, ), target: getValueFromIniFilesData( "target", iniFilePath, - data && data.iniFilesData + data && data.iniFilesData, ), targetNum: 17, }; @@ -94,7 +94,7 @@ function createTestInjector(data: { const testInjector = new Yok(); testInjector.register( "androidVirtualDeviceService", - AndroidVirtualDeviceService + AndroidVirtualDeviceService, ); testInjector.register("androidIniFileParser", { parseIniFile: (iniFilePath: string) => mockParseIniFile(iniFilePath, data), @@ -264,7 +264,7 @@ describe("androidVirtualDeviceService", () => { imageIdentifier: "Nexus_5_API_27", version: "8.1.0", model: "Nexus 5X", - }) + }), ); assert.deepStrictEqual( result.devices[1], @@ -273,7 +273,7 @@ describe("androidVirtualDeviceService", () => { imageIdentifier: "Nexus_5X_API_28", version: "9.0.0", model: "Nexus 5X", - }) + }), ); assert.deepStrictEqual( result.devices[2], @@ -282,7 +282,7 @@ describe("androidVirtualDeviceService", () => { imageIdentifier: "Nexus_6P_API_28", version: "9.0.0", model: "Nexus 6P", - }) + }), ); assert.deepStrictEqual(result.errors, []); }); @@ -310,7 +310,7 @@ describe("androidVirtualDeviceService", () => { identifier: "emulator-5554", version: "8.1.0", model: "Nexus 5X", - }) + }), ); assert.deepStrictEqual( result[1], @@ -319,7 +319,7 @@ describe("androidVirtualDeviceService", () => { imageIdentifier: "Nexus_5X_API_28", version: "9.0.0", model: "Nexus 5X", - }) + }), ); assert.deepStrictEqual( result[2], @@ -328,7 +328,7 @@ describe("androidVirtualDeviceService", () => { imageIdentifier: "Nexus_6P_API_28", version: "9.0.0", model: "Nexus 6P", - }) + }), ); }); // In this case we should fallback to list avd directory and should't report errors from avdmanager @@ -382,7 +382,7 @@ describe("androidVirtualDeviceService", () => { model: "Nexus 5X", imageIdentifier: "Nexus_5_API_27", version: "8.1.0", - }) + }), ); assert.deepStrictEqual( result.devices[1], @@ -391,7 +391,7 @@ describe("androidVirtualDeviceService", () => { model: "Nexus 5X", imageIdentifier: "Nexus_5X_API_28", version: "9.0.0", - }) + }), ); assert.deepStrictEqual( result.devices[2], @@ -400,7 +400,7 @@ describe("androidVirtualDeviceService", () => { model: "Nexus 6P", imageIdentifier: "Nexus_6P_API_28", version: "9.0.0", - }) + }), ); assert.deepStrictEqual( result.devices[3], @@ -409,7 +409,7 @@ describe("androidVirtualDeviceService", () => { model: "Pixel 2 XL", imageIdentifier: "Pixel_2_XL_API_28", version: "9.0.0", - }) + }), ); assert.deepStrictEqual(result.errors, []); }); @@ -419,11 +419,12 @@ describe("androidVirtualDeviceService", () => { iniFilesData: getIniFilesData({ includePixel: true }), }; const testInjector = createTestInjector(mockData); - const avdService = testInjector.resolve< - Mobile.IAndroidVirtualDeviceService - >("androidVirtualDeviceService"); + const avdService = + testInjector.resolve( + "androidVirtualDeviceService", + ); const androidIniFileParser = testInjector.resolve( - "androidIniFileParser" + "androidIniFileParser", ); androidIniFileParser.parseIniFile = (iniFilePath: string) => { if (iniFilePath.indexOf("Pixel_2_XL_API_28") !== -1) { @@ -443,7 +444,7 @@ describe("androidVirtualDeviceService", () => { model: "Nexus 5X", imageIdentifier: "Nexus_5_API_27", version: "8.1.0", - }) + }), ); assert.deepStrictEqual( result.devices[1], @@ -452,7 +453,7 @@ describe("androidVirtualDeviceService", () => { model: "Nexus 5X", imageIdentifier: "Nexus_5X_API_28", version: "9.0.0", - }) + }), ); assert.deepStrictEqual( result.devices[2], @@ -461,7 +462,7 @@ describe("androidVirtualDeviceService", () => { model: "Nexus 6P", imageIdentifier: "Nexus_6P_API_28", version: "9.0.0", - }) + }), ); assert.deepStrictEqual(result.errors, []); }); @@ -474,19 +475,19 @@ describe("androidVirtualDeviceService", () => { beforeEach(() => { const testInjector = createTestInjector({}); androidVirtualDeviceService = testInjector.resolve( - "androidVirtualDeviceService" + "androidVirtualDeviceService", ); }); it("should return [] when there are no running emulators", async () => { const emulators = await androidVirtualDeviceService.getRunningEmulatorIds( - [] + [], ); assert.deepStrictEqual(emulators, []); }); it("should return the devices when there are running emulators", async () => { const emulators = await androidVirtualDeviceService.getRunningEmulatorIds( - ["emulator-5554 device", "emulator-5556 device"] + ["emulator-5554 device", "emulator-5556 device"], ); assert.deepStrictEqual(emulators, ["emulator-5554", "emulator-5556"]); }); diff --git a/lib/common/test/unit-tests/mobile/android/logcat-helper.ts b/lib/common/test/unit-tests/mobile/android/logcat-helper.ts index e9107f97ef..5751f8fdcc 100644 --- a/lib/common/test/unit-tests/mobile/android/logcat-helper.ts +++ b/lib/common/test/unit-tests/mobile/android/logcat-helper.ts @@ -103,9 +103,7 @@ function startLogcatHelper( startOptions: { deviceIdentifier: string; pid?: string }, ) { const logcatHelper = injector.resolve("logcatHelper"); - /* tslint:disable:no-floating-promises */ logcatHelper.start(startOptions); - /* tslint:enable:no-floating-promises */ } describe("logcat-helper", () => { diff --git a/lib/common/test/unit-tests/mobile/application-manager-base.ts b/lib/common/test/unit-tests/mobile/application-manager-base.ts index c81200dd97..6e014db416 100644 --- a/lib/common/test/unit-tests/mobile/application-manager-base.ts +++ b/lib/common/test/unit-tests/mobile/application-manager-base.ts @@ -357,9 +357,7 @@ describe("ApplicationManagerBase", () => { }, ); - /* tslint:disable:no-floating-promises */ applicationManager.checkForApplicationUpdates(); - /* tslint:enable:no-floating-promises */ }), ); diff --git a/lib/common/test/unit-tests/mobile/device-log-provider.ts b/lib/common/test/unit-tests/mobile/device-log-provider.ts index 46f6929a90..4d1e6c23c5 100644 --- a/lib/common/test/unit-tests/mobile/device-log-provider.ts +++ b/lib/common/test/unit-tests/mobile/device-log-provider.ts @@ -580,8 +580,8 @@ level0_1: { [ `Aug 23 14:38:58 mcsofvladimirov appTestLogs[8455]: CONSOLE LOG file:///app/bundle.js:284:20: multiline`, `\tmessage`, - `\sfrom`, - `\t\sconsole.log`, + `sfrom`, + `\tsconsole.log`, ].join("\n"), ); assertData( @@ -589,8 +589,8 @@ level0_1: { [ `CONSOLE LOG file: app/main-view-model.js:34:0 multiline`, `\tmessage`, - `\sfrom`, - `\t\sconsole.log\n`, + `sfrom`, + `\tsconsole.log\n`, ].join("\n"), ); }); diff --git a/lib/common/test/unit-tests/mobile/devices-service.ts b/lib/common/test/unit-tests/mobile/devices-service.ts index ae319ce0b9..65ca0cc119 100644 --- a/lib/common/test/unit-tests/mobile/devices-service.ts +++ b/lib/common/test/unit-tests/mobile/devices-service.ts @@ -297,9 +297,7 @@ function mockSetInterval(testCaseCallback?: Function): void { await callback(); }; - /* tslint:disable:no-floating-promises */ execution(); - /* tslint:enable:no-floating-promises */ return nodeJsTimer; }; @@ -2412,9 +2410,7 @@ describe("devicesService", () => { await callback(); }; - /* tslint:disable:no-floating-promises */ execution(); - /* tslint:enable:no-floating-promises */ return { ref: () => { diff --git a/lib/common/test/unit-tests/mobile/genymotion/genymotion-service.ts b/lib/common/test/unit-tests/mobile/genymotion/genymotion-service.ts index c4357d23d4..8b6eb10740 100644 --- a/lib/common/test/unit-tests/mobile/genymotion/genymotion-service.ts +++ b/lib/common/test/unit-tests/mobile/genymotion/genymotion-service.ts @@ -284,7 +284,7 @@ describe("GenymotionService", () => { testInjector = createTestInjector(); androidGenymotionService = testInjector.resolve( "androidGenymotionService", - AndroidGenymotionService + AndroidGenymotionService, ); adb = testInjector.resolve("adb"); }); @@ -292,7 +292,7 @@ describe("GenymotionService", () => { function mockAdbGetPropertyValue( deviceIds: string[], propName: string, - propertyValue: string + propertyValue: string, ) { adb.getPropertyValue = (deviceId: string, propertyName: string) => { if (_.includes(deviceIds, deviceId) && propName === propertyName) { @@ -305,9 +305,7 @@ describe("GenymotionService", () => { function mockVirtualBoxService( output: Mobile.IVirtualBoxListVmsOutput, - mapEnumerateGuestPropertiesOutput?: IDictionary< - Mobile.IVirtualBoxEnumerateGuestPropertiesOutput - > + mapEnumerateGuestPropertiesOutput?: IDictionary, ) { virtualBoxService = testInjector.resolve("virtualBoxService"); virtualBoxService.listVms = () => Promise.resolve(output); @@ -350,7 +348,7 @@ describe("GenymotionService", () => { mockVirtualBoxService( { vms, error: null }, - mapEnumerateGuestPropertiesOutput + mapEnumerateGuestPropertiesOutput, ); const result = await androidGenymotionService.getEmulatorImages([]); assert.lengthOf(result.devices, 4); @@ -360,7 +358,7 @@ describe("GenymotionService", () => { displayName: "Google Nexus 4 - 5.0.0 - API 21 - 768x1280", imageIdentifier: "9d9beef2-cc60-4a54-bcc0-cc1dbf89811f", version: "5.0", - }) + }), ); assert.deepStrictEqual( result.devices[1], @@ -368,7 +366,7 @@ describe("GenymotionService", () => { displayName: "Custom Tablet - 6.0.0 - API 23 - 1536x2048", imageIdentifier: "da83e290-4d54-4b94-8654-540cf0c96604", version: "5.0", - }) + }), ); assert.deepStrictEqual( result.devices[2], @@ -376,7 +374,7 @@ describe("GenymotionService", () => { displayName: "Custom Phone - 5.1.0 - API 22 - 768x1280", imageIdentifier: "94761c90-759f-4ae4-8eb3-8929a57a7ceb", version: "5.0", - }) + }), ); assert.deepStrictEqual( result.devices[3], @@ -384,7 +382,7 @@ describe("GenymotionService", () => { displayName: "test", imageIdentifier: "4a1bf7cd-a7b4-45ef-8cb0-c5a0aafad211", version: "5.0", - }) + }), ); assert.deepStrictEqual(result.errors, []); }); @@ -401,14 +399,14 @@ describe("GenymotionService", () => { mockVirtualBoxService( { vms, error: null }, - mapEnumerateGuestPropertiesOutput + mapEnumerateGuestPropertiesOutput, ); const childProcess = testInjector.resolve("childProcess"); childProcess.trySpawnFromCloseEvent = async ( command: string, args: string[], options?: any, - spawnFromEventOptions?: ISpawnFromEventOptions + spawnFromEventOptions?: ISpawnFromEventOptions, ): Promise => { return { stderr: "some error" }; }; @@ -426,7 +424,7 @@ describe("GenymotionService", () => { imageIdentifier: "9d9beef2-cc60-4a54-bcc0-cc1dbf89811f", version: "5.0", errorHelp, - }) + }), ); assert.deepStrictEqual( result.devices[1], @@ -435,7 +433,7 @@ describe("GenymotionService", () => { imageIdentifier: "da83e290-4d54-4b94-8654-540cf0c96604", version: "5.0", errorHelp, - }) + }), ); assert.deepStrictEqual(result.errors, []); }); @@ -452,14 +450,14 @@ describe("GenymotionService", () => { mockVirtualBoxService( { vms, error: null }, - mapEnumerateGuestPropertiesOutput + mapEnumerateGuestPropertiesOutput, ); const childProcess = testInjector.resolve("childProcess"); childProcess.trySpawnFromCloseEvent = async ( command: string, args: string[], options?: any, - spawnFromEventOptions?: ISpawnFromEventOptions + spawnFromEventOptions?: ISpawnFromEventOptions, ): Promise => { return { stderr: AndroidVirtualDevice.GENYMOTION_DEFAULT_STDERR_STRING, @@ -475,7 +473,7 @@ describe("GenymotionService", () => { displayName: "Google Nexus 4 - 5.0.0 - API 21 - 768x1280", imageIdentifier: "9d9beef2-cc60-4a54-bcc0-cc1dbf89811f", version: "5.0", - }) + }), ); assert.deepStrictEqual( result.devices[1], @@ -483,7 +481,7 @@ describe("GenymotionService", () => { displayName: "Custom Tablet - 6.0.0 - API 23 - 1536x2048", imageIdentifier: "da83e290-4d54-4b94-8654-540cf0c96604", version: "5.0", - }) + }), ); assert.deepStrictEqual(result.errors, []); }); @@ -505,10 +503,10 @@ describe("GenymotionService", () => { }; mockVirtualBoxService( { vms, error: null }, - mapEnumerateGuestPropertiesOutput + mapEnumerateGuestPropertiesOutput, ); (androidGenymotionService).isGenymotionEmulator = ( - emulatorId: string + emulatorId: string, ) => Promise.resolve(true); androidGenymotionService.getRunningEmulatorName = (emulatorId: string) => Promise.resolve("test"); @@ -522,7 +520,7 @@ describe("GenymotionService", () => { displayName: "Google Nexus 4 - 5.0.0 - API 21 - 768x1280", imageIdentifier: "9d9beef2-cc60-4a54-bcc0-cc1dbf89811f", version: "5.0", - }) + }), ); assert.deepStrictEqual( result.devices[1], @@ -530,7 +528,7 @@ describe("GenymotionService", () => { displayName: "Custom Tablet - 6.0.0 - API 23 - 1536x2048", imageIdentifier: "da83e290-4d54-4b94-8654-540cf0c96604", version: "5.0", - }) + }), ); assert.deepStrictEqual( result.devices[2], @@ -538,7 +536,7 @@ describe("GenymotionService", () => { displayName: "Custom Phone - 5.1.0 - API 22 - 768x1280", imageIdentifier: "94761c90-759f-4ae4-8eb3-8929a57a7ceb", version: "5.0", - }) + }), ); assert.deepStrictEqual( result.devices[3], @@ -547,7 +545,7 @@ describe("GenymotionService", () => { identifier: "192.168.56.101:5555", imageIdentifier: "4a1bf7cd-a7b4-45ef-8cb0-c5a0aafad211", version: "5.0", - }) + }), ); assert.deepStrictEqual(result.errors, []); }); @@ -557,7 +555,7 @@ describe("GenymotionService", () => { it("should return [] when there are no running emulators", async () => { mockAdbGetPropertyValue([], "", ""); const emulators = await androidGenymotionService.getRunningEmulatorIds( - [] + [], ); assert.deepStrictEqual(emulators, []); }); @@ -565,7 +563,7 @@ describe("GenymotionService", () => { mockAdbGetPropertyValue( ["192.168.56.101:5555", "192.168.56.102:5555"], "ro.build.product", - "vbox" + "vbox", ); const emulators = await androidGenymotionService.getRunningEmulatorIds([ "192.168.56.101:5555 device", diff --git a/lib/common/test/unit-tests/mobile/ios-simulator-discovery.ts b/lib/common/test/unit-tests/mobile/ios-simulator-discovery.ts index 3c111a9b78..6c738b6422 100644 --- a/lib/common/test/unit-tests/mobile/ios-simulator-discovery.ts +++ b/lib/common/test/unit-tests/mobile/ios-simulator-discovery.ts @@ -86,7 +86,7 @@ describe("ios-simulator-discovery", () => { let expectedDeviceInfo: Mobile.IDeviceInfo = null; const detectNewSimulatorAttached = async ( - runningSimulator: any + runningSimulator: any, ): Promise => { return new Promise(async (resolve, reject) => { currentlyRunningSimulators.push(_.cloneDeep(runningSimulator)); @@ -94,25 +94,25 @@ describe("ios-simulator-discovery", () => { DeviceDiscoveryEventNames.DEVICE_FOUND, (device: Mobile.IiOSDevice) => { resolve(device); - } + }, ); await iOSSimulatorDiscovery.startLookingForDevices(); }); }; const detectSimulatorDetached = async ( - simulatorId: string + simulatorId: string, ): Promise => { _.remove( currentlyRunningSimulators, - (simulator) => simulator.id === simulatorId + (simulator) => simulator.id === simulatorId, ); return new Promise(async (resolve, reject) => { iOSSimulatorDiscovery.once( DeviceDiscoveryEventNames.DEVICE_LOST, (device: Mobile.IiOSDevice) => { resolve(device); - } + }, ); await iOSSimulatorDiscovery.startLookingForDevices(); }); @@ -120,11 +120,11 @@ describe("ios-simulator-discovery", () => { const detectSimulatorChanged = async ( oldId: string, - newId: string + newId: string, ): Promise => { const currentlyRunningSimulator = _.find( currentlyRunningSimulators, - (simulator) => simulator.id === oldId + (simulator) => simulator.id === oldId, ); currentlyRunningSimulator.id = newId; let lostDevicePromise: Promise; @@ -134,14 +134,14 @@ describe("ios-simulator-discovery", () => { DeviceDiscoveryEventNames.DEVICE_LOST, (device: Mobile.IDevice) => { lostDevicePromise = Promise.resolve(device); - } + }, ); iOSSimulatorDiscovery.on( DeviceDiscoveryEventNames.DEVICE_FOUND, (device: Mobile.IDevice) => { foundDevicePromise = Promise.resolve(device); - } + }, ); await iOSSimulatorDiscovery.startLookingForDevices(); @@ -187,7 +187,7 @@ describe("ios-simulator-discovery", () => { const device = await detectNewSimulatorAttached(defaultRunningSimulator); assert.deepStrictEqual(device.deviceInfo, expectedDeviceInfo); const lostDevice = await detectSimulatorDetached( - device.deviceInfo.identifier + device.deviceInfo.identifier, ); assert.deepStrictEqual(lostDevice, device); }); @@ -199,7 +199,7 @@ describe("ios-simulator-discovery", () => { const devices = await detectSimulatorChanged( device.deviceInfo.identifier, - newId + newId, ); assert.deepStrictEqual(devices.deviceLost, device); expectedDeviceInfo.identifier = newId; @@ -211,7 +211,7 @@ describe("ios-simulator-discovery", () => { let device = await detectNewSimulatorAttached(defaultRunningSimulator); assert.deepStrictEqual(device.deviceInfo, expectedDeviceInfo); const lostDevice = await detectSimulatorDetached( - device.deviceInfo.identifier + device.deviceInfo.identifier, ); assert.deepStrictEqual(lostDevice, device); @@ -226,9 +226,9 @@ describe("ios-simulator-discovery", () => { DeviceDiscoveryEventNames.DEVICE_FOUND, (d: Mobile.IDevice) => { throw new Error( - "Device found should not be raised for the same device." + "Device found should not be raised for the same device.", ); - } + }, ); await iOSSimulatorDiscovery.startLookingForDevices(); @@ -241,9 +241,9 @@ describe("ios-simulator-discovery", () => { DeviceDiscoveryEventNames.DEVICE_FOUND, (device: Mobile.IDevice) => { throw new Error( - "Device found should not be raised when OS is not OS X." + "Device found should not be raised when OS is not OS X.", ); - } + }, ); await iOSSimulatorDiscovery.startLookingForDevices(); }); @@ -254,16 +254,16 @@ describe("ios-simulator-discovery", () => { DeviceDiscoveryEventNames.DEVICE_FOUND, (device: Mobile.IDevice) => { throw new Error( - "Device found should not be raised when OS is not OS X." + "Device found should not be raised when OS is not OS X.", ); - } + }, ); await (iOSSimulatorDiscovery).checkForDevices(); }); it("find correctly two simulators", async () => { const firstSimulator = await detectNewSimulatorAttached( - defaultRunningSimulator + defaultRunningSimulator, ); assert.deepStrictEqual(firstSimulator.deviceInfo, expectedDeviceInfo); @@ -275,11 +275,11 @@ describe("ios-simulator-discovery", () => { }; const secondSimulator = await detectNewSimulatorAttached( - secondRunningSimulator + secondRunningSimulator, ); assert.deepStrictEqual( secondSimulator.deviceInfo, - getDeviceInfo(secondRunningSimulator) + getDeviceInfo(secondRunningSimulator), ); }); }); diff --git a/lib/common/test/unit-tests/mocks/decorators-invoke-before.ts b/lib/common/test/unit-tests/mocks/decorators-invoke-before.ts index 9ab2abf835..c24f271e1d 100644 --- a/lib/common/test/unit-tests/mocks/decorators-invoke-before.ts +++ b/lib/common/test/unit-tests/mocks/decorators-invoke-before.ts @@ -55,7 +55,7 @@ export class InvokeBeforeDecoratorsTest { @invokeBefore("promisifiedInvokedBeforeThrowingMethod") public async methodPromisifiedInvokeBeforeThrowing( - num: number + num: number, ): Promise { this.counter++; return num; @@ -69,7 +69,7 @@ export class InvokeBeforeDecoratorsTest { @invokeBefore("promisifiedInvokedBeforeMethod", ["arg1"]) public async methodPromisifiedInvokeBeforeWithArgs( - num: number + num: number, ): Promise { this.counter++; return num; diff --git a/lib/common/test/unit-tests/preuninstall.ts b/lib/common/test/unit-tests/preuninstall.ts index 249d1c24f0..0bdad99556 100644 --- a/lib/common/test/unit-tests/preuninstall.ts +++ b/lib/common/test/unit-tests/preuninstall.ts @@ -37,7 +37,7 @@ describe("preuninstall", () => { testInjector.register("analyticsService", { trackEventActionInGoogleAnalytics: async ( - data: IEventActionData + data: IEventActionData, ): Promise => undefined, finishTracking: async (): Promise => undefined, }); @@ -56,9 +56,8 @@ describe("preuninstall", () => { deletedFiles.push(pathToFile); }; - const preUninstallCommand: ICommand = testInjector.resolveCommand( - "dev-preuninstall" - ); + const preUninstallCommand: ICommand = + testInjector.resolveCommand("dev-preuninstall"); await preUninstallCommand.execute([]); assert.deepStrictEqual(deletedFiles, [ path.join(profileDir, "KillSwitches", "cli"), @@ -94,12 +93,11 @@ describe("preuninstall", () => { ]; const testInjector = createTestInjector(); - const analyticsService = testInjector.resolve( - "analyticsService" - ); + const analyticsService = + testInjector.resolve("analyticsService"); let trackedData: IEventActionData[] = []; analyticsService.trackEventActionInGoogleAnalytics = async ( - data: IEventActionData + data: IEventActionData, ): Promise => { trackedData.push(data); }; @@ -109,9 +107,8 @@ describe("preuninstall", () => { isFinishTrackingCalled = true; }; - const preUninstallCommand: ICommand = testInjector.resolveCommand( - "dev-preuninstall" - ); + const preUninstallCommand: ICommand = + testInjector.resolveCommand("dev-preuninstall"); for (const testCase of testData) { helpers.isInteractive = () => testCase.isInteractive; helpers.doesCurrentNpmCommandMatch = () => @@ -126,7 +123,7 @@ describe("preuninstall", () => { ]); assert.isTrue( isFinishTrackingCalled, - "At the end of the command, finishTracking must be called" + "At the end of the command, finishTracking must be called", ); trackedData = []; } @@ -144,24 +141,24 @@ describe("preuninstall", () => { }; const extensibilityService = testInjector.resolve( - "extensibilityService" + "extensibilityService", ); let isRemoveAllExtensionsCalled = false; extensibilityService.removeAllExtensions = () => { isRemoveAllExtensionsCalled = true; }; - const packageInstallationManager = testInjector.resolve< - IPackageInstallationManager - >("packageInstallationManager"); + const packageInstallationManager = + testInjector.resolve( + "packageInstallationManager", + ); let isClearInspectorCacheCalled = false; packageInstallationManager.clearInspectorCache = () => { isClearInspectorCacheCalled = true; }; - const preUninstallCommand: ICommand = testInjector.resolveCommand( - "dev-preuninstall" - ); + const preUninstallCommand: ICommand = + testInjector.resolveCommand("dev-preuninstall"); await preUninstallCommand.execute([]); assert.deepStrictEqual(deletedFiles, [ path.join(profileDir, "KillSwitches", "cli"), @@ -169,11 +166,11 @@ describe("preuninstall", () => { assert.isTrue( isRemoveAllExtensionsCalled, - "When uninstall is called, `removeAllExtensions` method must be called" + "When uninstall is called, `removeAllExtensions` method must be called", ); assert.isTrue( isClearInspectorCacheCalled, - "When uninstall is called, `clearInspectorCache` method must be called" + "When uninstall is called, `clearInspectorCache` method must be called", ); }); diff --git a/lib/common/test/unit-tests/project-files-provider-base.ts b/lib/common/test/unit-tests/project-files-provider-base.ts index ea6150140d..7c4e843aec 100644 --- a/lib/common/test/unit-tests/project-files-provider-base.ts +++ b/lib/common/test/unit-tests/project-files-provider-base.ts @@ -13,13 +13,13 @@ class ProjectFilesProvider extends ProjectFilesProviderBase { public isFileExcluded(filePath: string): boolean { throw new Error( - "Testing ProjectFilesProviderBase should not test abstract member isFileExcluded." + "Testing ProjectFilesProviderBase should not test abstract member isFileExcluded.", ); } public mapFilePath(filePath: string, platform: string): string { throw new Error( - "Testing ProjectFilesProviderBase should not test abstract member mapFilePath." + "Testing ProjectFilesProviderBase should not test abstract member mapFilePath.", ); } } @@ -50,7 +50,7 @@ describe("ProjectFilesProviderBase", () => { const filePath = "/test/filePath.ts", preparedPath = projectFilesProviderBase.getPreparedFilePath( filePath, - {} + {}, ); assert.deepStrictEqual(preparedPath, expectedFilePath); @@ -60,7 +60,7 @@ describe("ProjectFilesProviderBase", () => { const filePath = "/test/filePath.android.ts", preparedPath = projectFilesProviderBase.getPreparedFilePath( filePath, - {} + {}, ); assert.deepStrictEqual(preparedPath, expectedFilePath); @@ -70,7 +70,7 @@ describe("ProjectFilesProviderBase", () => { const filePath = "/test/filePath.iOS.ts", preparedPath = projectFilesProviderBase.getPreparedFilePath( filePath, - {} + {}, ); assert.deepStrictEqual(preparedPath, expectedFilePath); @@ -80,7 +80,7 @@ describe("ProjectFilesProviderBase", () => { const filePath = "/test/filePath.AnDroId.ts", preparedPath = projectFilesProviderBase.getPreparedFilePath( filePath, - {} + {}, ); assert.deepStrictEqual(preparedPath, expectedFilePath); @@ -90,7 +90,7 @@ describe("ProjectFilesProviderBase", () => { const filePath = "/test/filePath.debug.ts", preparedPath = projectFilesProviderBase.getPreparedFilePath( filePath, - {} + {}, ); assert.deepStrictEqual(preparedPath, expectedFilePath); @@ -100,7 +100,7 @@ describe("ProjectFilesProviderBase", () => { const filePath = "/test/filePath.DebUG.ts", preparedPath = projectFilesProviderBase.getPreparedFilePath( filePath, - {} + {}, ); assert.deepStrictEqual(preparedPath, expectedFilePath); @@ -110,7 +110,7 @@ describe("ProjectFilesProviderBase", () => { const filePath = "/test/filePath.release.ts", preparedPath = projectFilesProviderBase.getPreparedFilePath( filePath, - {} + {}, ); assert.deepStrictEqual(preparedPath, expectedFilePath); @@ -120,7 +120,7 @@ describe("ProjectFilesProviderBase", () => { describe("getProjectFileInfo", () => { const getExpectedProjectFileInfo = ( filePath: string, - shouldIncludeFile: boolean + shouldIncludeFile: boolean, ) => { return { filePath: filePath, @@ -134,12 +134,12 @@ describe("ProjectFilesProviderBase", () => { projectFileInfo = projectFilesProviderBase.getProjectFileInfo( filePath, "", - {} + {}, ); assert.deepStrictEqual( projectFileInfo, - getExpectedProjectFileInfo(filePath, true) + getExpectedProjectFileInfo(filePath, true), ); }); @@ -148,12 +148,12 @@ describe("ProjectFilesProviderBase", () => { projectFileInfo = projectFilesProviderBase.getProjectFileInfo( filePath, "android", - {} + {}, ); assert.deepStrictEqual( projectFileInfo, - getExpectedProjectFileInfo(filePath, true) + getExpectedProjectFileInfo(filePath, true), ); }); @@ -162,12 +162,12 @@ describe("ProjectFilesProviderBase", () => { projectFileInfo = projectFilesProviderBase.getProjectFileInfo( filePath, "android", - {} + {}, ); assert.deepStrictEqual( projectFileInfo, - getExpectedProjectFileInfo(filePath, true) + getExpectedProjectFileInfo(filePath, true), ); }); @@ -176,12 +176,12 @@ describe("ProjectFilesProviderBase", () => { projectFileInfo = projectFilesProviderBase.getProjectFileInfo( filePath, "android", - {} + {}, ); assert.deepStrictEqual( projectFileInfo, - getExpectedProjectFileInfo(filePath, false) + getExpectedProjectFileInfo(filePath, false), ); }); @@ -190,12 +190,12 @@ describe("ProjectFilesProviderBase", () => { projectFileInfo = projectFilesProviderBase.getProjectFileInfo( filePath, "android", - {} + {}, ); assert.deepStrictEqual( projectFileInfo, - getExpectedProjectFileInfo(filePath, true) + getExpectedProjectFileInfo(filePath, true), ); }); @@ -204,12 +204,12 @@ describe("ProjectFilesProviderBase", () => { projectFileInfo = projectFilesProviderBase.getProjectFileInfo( filePath, "android", - {} + {}, ); assert.deepStrictEqual( projectFileInfo, - getExpectedProjectFileInfo(filePath, false) + getExpectedProjectFileInfo(filePath, false), ); }); @@ -219,12 +219,12 @@ describe("ProjectFilesProviderBase", () => { const projectFileInfo = projectFilesProviderBase.getProjectFileInfo( filePath, "android", - { configuration: "release" } + { configuration: "release" }, ); assert.deepStrictEqual( projectFileInfo, - getExpectedProjectFileInfo(filePath, true) + getExpectedProjectFileInfo(filePath, true), ); }); }); diff --git a/lib/common/test/unit-tests/services/files-hash-service.ts b/lib/common/test/unit-tests/services/files-hash-service.ts index e4cda33d2d..7761d2b73b 100644 --- a/lib/common/test/unit-tests/services/files-hash-service.ts +++ b/lib/common/test/unit-tests/services/files-hash-service.ts @@ -40,8 +40,8 @@ function removeFileHashes(hashes: IStringDictionary) { !!_.find( hashes, (newHash: string, newFilePath: string) => - newHash === hash && newFilePath === filePath - ) + newHash === hash && newFilePath === filePath, + ), ); return result; } @@ -100,7 +100,7 @@ describe("filesHashService", () => { const filesHashService = mockFilesHashService(testCase.newHashes); const changes = await filesHashService.getChanges( _.keys(testCase.newHashes), - testCase.oldHashes + testCase.oldHashes, ); assert.deepStrictEqual(changes, testCase.expectedChanges); }); @@ -113,11 +113,11 @@ describe("filesHashService", () => { const filesHashService = mockFilesHashService(testCase.newHashes); const hasChanges = filesHashService.hasChangesInShasums( testCase.newHashes, - testCase.oldHashes + testCase.oldHashes, ); assert.deepStrictEqual( hasChanges, - !!_.keys(testCase.expectedChanges).length + !!_.keys(testCase.expectedChanges).length, ); }); }); diff --git a/lib/common/test/unit-tests/services/help-service.ts b/lib/common/test/unit-tests/services/help-service.ts index 585bdfd98c..25e4c1c724 100644 --- a/lib/common/test/unit-tests/services/help-service.ts +++ b/lib/common/test/unit-tests/services/help-service.ts @@ -201,7 +201,7 @@ and another one`, commandArguments: [], }); assert.isTrue( - injector.resolve("logger").output.indexOf("bla woot bla") >= 0 + injector.resolve("logger").output.indexOf("bla woot bla") >= 0, ); }); @@ -526,15 +526,14 @@ and another one`, describe("extensions tests", () => { const assertData = async ( expectedEnumerateFilesInDirectorySyncCalledCounter: number, - extensionsData?: IExtensionData[] + extensionsData?: IExtensionData[], ): Promise => { const injector = createTestInjector({ isProjectTypeResult: false, isPlatformResult: true, }); - const $staticConfig = injector.resolve( - "staticConfig" - ); + const $staticConfig = + injector.resolve("staticConfig"); $staticConfig.MAN_PAGES_DIR = "man_pages_dir"; $staticConfig.HTML_PAGES_DIR = "html_pages_dir"; $staticConfig.CLIENT_NAME = "client name"; @@ -558,7 +557,7 @@ and another one`, }); const $extensibilityService = injector.resolve( - "extensibilityService" + "extensibilityService", ); extensionsData = extensionsData || []; extensionsData.push({ @@ -568,8 +567,8 @@ and another one`, pathToExtension: "extension3path", }); - $extensibilityService.getInstalledExtensionsData = (): IExtensionData[] => - extensionsData; + $extensibilityService.getInstalledExtensionsData = + (): IExtensionData[] => extensionsData; const helpService = injector.resolve("helpService"); await helpService.showCommandLineHelp({ @@ -582,7 +581,7 @@ and another one`, assert.equal( enumerateFilesInDirectorySyncCalledCounter, expectedEnumerateFilesInDirectorySyncCalledCounter, - `The enumerateFilesInDirectorySync method must be called exactly ${enumerateFilesInDirectorySyncCalledCounter} times.` + `The enumerateFilesInDirectorySync method must be called exactly ${enumerateFilesInDirectorySyncCalledCounter} times.`, ); }; diff --git a/lib/common/test/unit-tests/services/json-file-settings-service.ts b/lib/common/test/unit-tests/services/json-file-settings-service.ts index 9dac594142..f79aaf9af4 100644 --- a/lib/common/test/unit-tests/services/json-file-settings-service.ts +++ b/lib/common/test/unit-tests/services/json-file-settings-service.ts @@ -25,11 +25,11 @@ describe("jsonFileSettingsService", () => { }, setCurrentUserAsOwner: async ( path: string, - owner: string + owner: string, ): Promise => undefined, readText: ( filename: string, - encoding?: IReadFileOptions | string + encoding?: IReadFileOptions | string, ): string => JSON.stringify(dataInFile[filename]), deleteFile: (filePath: string): void => { deletedFiles.push(filePath); @@ -38,7 +38,7 @@ describe("jsonFileSettingsService", () => { filename: string, data: any, space?: string, - encoding?: string + encoding?: string, ): void => { dataPassedToWriteJson.push({ filename, data }); }, @@ -47,7 +47,7 @@ describe("jsonFileSettingsService", () => { executeActionWithLock: async ( action: () => Promise, lockFilePath?: string, - lockOpts?: ILockOptions + lockOpts?: ILockOptions, ): Promise => { return action(); }, @@ -70,12 +70,13 @@ describe("jsonFileSettingsService", () => { dataInFile = { [jsonFileSettingsPath]: { prop1: 1 } }; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); - const result = await jsonFileSettingsService.getSettingValue( - "prop1" - ); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); + const result = + await jsonFileSettingsService.getSettingValue("prop1"); assert.equal(result, 1); }); @@ -83,12 +84,13 @@ describe("jsonFileSettingsService", () => { dataInFile = { [jsonFileSettingsPath]: { prop1: 1 } }; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); - const result = await jsonFileSettingsService.getSettingValue( - "prop2" - ); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); + const result = + await jsonFileSettingsService.getSettingValue("prop2"); assert.equal(result, null); }); @@ -105,12 +107,13 @@ describe("jsonFileSettingsService", () => { }; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); - const result = await jsonFileSettingsService.getSettingValue( - "prop1" - ); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); + const result = + await jsonFileSettingsService.getSettingValue("prop1"); assert.equal(result, 1); }); @@ -118,12 +121,14 @@ describe("jsonFileSettingsService", () => { dataInFile = { [jsonFileSettingsPath]: { prop1: 1 } }; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); const result = await jsonFileSettingsService.getSettingValue( "prop1", - { cacheTimeout: 10000 } + { cacheTimeout: 10000 }, ); assert.equal(result, null); }); @@ -141,12 +146,14 @@ describe("jsonFileSettingsService", () => { }; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); const result = await jsonFileSettingsService.getSettingValue( "prop1", - { cacheTimeout: 100000 } + { cacheTimeout: 100000 }, ); assert.equal(result, 1); }); @@ -164,9 +171,11 @@ describe("jsonFileSettingsService", () => { }; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); const result = await new Promise((resolve, reject) => { setTimeout(() => { @@ -183,9 +192,11 @@ describe("jsonFileSettingsService", () => { describe("saveSettings", () => { it("writes passed data without cache when cache data is not passed", async () => { const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); const settingsToSave: any = { prop1: { innerProp1: 1, @@ -210,9 +221,11 @@ describe("jsonFileSettingsService", () => { }; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); const settingsToSave: any = { prop1: { innerProp1: 1, @@ -241,9 +254,11 @@ describe("jsonFileSettingsService", () => { const time = 1234; Date.now = () => time; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); const settingsToSave: any = { prop1: { innerProp1: 1, @@ -281,9 +296,11 @@ describe("jsonFileSettingsService", () => { const timeForPassedData = 123; Date.now = () => time; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); const settingsToSave: any = { prop1: { time: timeForPassedData, @@ -324,9 +341,11 @@ describe("jsonFileSettingsService", () => { describe("saveSetting", () => { it("writes passed data without cache when cache data is not passed", async () => { const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); await jsonFileSettingsService.saveSetting("prop1", { innerProp1: 1, @@ -341,14 +360,16 @@ describe("jsonFileSettingsService", () => { const time = 1234; Date.now = () => time; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); await jsonFileSettingsService.saveSetting( "prop1", { innerProp1: 1 }, - { useCaching: true } + { useCaching: true }, ); assert.deepStrictEqual(dataPassedToWriteJson, [ @@ -372,9 +393,11 @@ describe("jsonFileSettingsService", () => { const timeForPassedData = 123; Date.now = () => time; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); await jsonFileSettingsService.saveSetting( "prop1", @@ -385,7 +408,7 @@ describe("jsonFileSettingsService", () => { innerProp1: 1, }, }, - { useCaching: true } + { useCaching: true }, ); assert.deepStrictEqual(dataPassedToWriteJson, [ @@ -411,9 +434,11 @@ describe("jsonFileSettingsService", () => { [jsonFileSettingsPath]: { prop1: 1, prop2: { innerProp1: 2 } }, }; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); await jsonFileSettingsService.removeSetting("prop2"); assert.deepStrictEqual(dataPassedToWriteJson, [ { @@ -443,9 +468,11 @@ describe("jsonFileSettingsService", () => { }; const testInjector = createTestInjector(); - const jsonFileSettingsService = testInjector.resolve< - IJsonFileSettingsService - >("jsonFileSettingsService", { jsonFileSettingsPath }); + const jsonFileSettingsService = + testInjector.resolve( + "jsonFileSettingsService", + { jsonFileSettingsPath }, + ); await jsonFileSettingsService.removeSetting("prop2"); assert.deepStrictEqual(dataPassedToWriteJson, [ { diff --git a/lib/common/test/unit-tests/services/net-service.ts b/lib/common/test/unit-tests/services/net-service.ts index 9d35773158..78cb9688e1 100644 --- a/lib/common/test/unit-tests/services/net-service.ts +++ b/lib/common/test/unit-tests/services/net-service.ts @@ -35,14 +35,14 @@ describe("net", () => { testInjector: IInjector, platform: string, port?: number, - iteration?: number + iteration?: number, ): void => { const childProcess = testInjector.resolve("childProcess"); childProcess.exec = async ( command: string, options?: any, - execOptions?: IExecOptions + execOptions?: IExecOptions, ): Promise => { const platformsDataService: IDictionary = { linux: { @@ -146,14 +146,13 @@ Active Connections it("returns false when netstat command fails", async () => { const testInjector = createTestInjector(platform); - const childProcess = testInjector.resolve( - "childProcess" - ); + const childProcess = + testInjector.resolve("childProcess"); const error = new Error("test error"); childProcess.exec = async ( command: string, options?: any, - execOptions?: IExecOptions + execOptions?: IExecOptions, ): Promise => { execCalledCount++; return Promise.reject(error); @@ -178,7 +177,7 @@ Active Connections const net = testInjector.resolve(Net); await assert.isRejected( net.waitForPortToListen({ port: 18181, timeout: 50, interval: 1 }), - `Unable to check for free ports on ${invalidPlatform}. Supported platforms are: darwin, linux, win32` + `Unable to check for free ports on ${invalidPlatform}. Supported platforms are: darwin, linux, win32`, ); }); @@ -189,7 +188,7 @@ Active Connections const net = testInjector.resolve(Net); await assert.isRejected( net.waitForPortToListen(null), - "You must pass port and timeout for check." + "You must pass port and timeout for check.", ); }); }); diff --git a/lib/common/test/unit-tests/stubs.ts b/lib/common/test/unit-tests/stubs.ts index 3180fedc34..f24fec619f 100644 --- a/lib/common/test/unit-tests/stubs.ts +++ b/lib/common/test/unit-tests/stubs.ts @@ -1,5 +1,3 @@ -/* tslint:disable:no-empty */ - import * as util from "util"; import { EventEmitter } from "events"; import * as _ from "lodash"; @@ -22,7 +20,7 @@ import { export class LockServiceStub implements ILockService { public async lock( lockFilePath?: string, - lockOpts?: ILockOptions + lockOpts?: ILockOptions, ): Promise<() => void> { return () => {}; } @@ -32,7 +30,7 @@ export class LockServiceStub implements ILockService { public async executeActionWithLock( action: () => Promise, lockFilePath?: string, - lockOpts?: ILockOptions + lockOpts?: ILockOptions, ): Promise { const result = await action(); return result; @@ -107,7 +105,7 @@ export class ErrorsStub implements IErrors { async beginCommand( action: () => Promise, - printHelpCommand: () => Promise + printHelpCommand: () => Promise, ): Promise { return action(); } @@ -153,25 +151,25 @@ export class AndroidProcessServiceStub async mapAbstractToTcpPort( deviceIdentifier: string, appIdentifier: string, - framework: string + framework: string, ): Promise { return this.MapAbstractToTcpPortResult; } async getDebuggableApps( - deviceIdentifier: string + deviceIdentifier: string, ): Promise { return this.GetDebuggableAppsResult; } async getMappedAbstractToTcpPorts( deviceIdentifier: string, appIdentifiers: string[], - framework: string + framework: string, ): Promise> { return this.GetMappedAbstractToTcpPortsResult; } async getAppProcessId( deviceIdentifier: string, - appIdentifier: string + appIdentifier: string, ): Promise { while (this.GetAppProcessIdFailAttempts) { this.GetAppProcessIdFailAttempts--; @@ -181,7 +179,7 @@ export class AndroidProcessServiceStub return this.GetAppProcessIdResult; } async forwardFreeTcpToAbstractPort( - portForwardInputData: Mobile.IPortForwardData + portForwardInputData: Mobile.IPortForwardData, ): Promise { return this.ForwardFreeTcpToAbstractPortResult; } diff --git a/lib/common/test/unit-tests/xcode-select-service.ts b/lib/common/test/unit-tests/xcode-select-service.ts index 84eff8ad0f..eb6d6ee66a 100644 --- a/lib/common/test/unit-tests/xcode-select-service.ts +++ b/lib/common/test/unit-tests/xcode-select-service.ts @@ -17,7 +17,7 @@ function createTestInjector(config: { spawnFromEvent: ( command: string, args: string[], - event: string + event: string, ): Promise => Promise.resolve({ stdout: config.xcodeSelectStdout, @@ -26,7 +26,7 @@ function createTestInjector(config: { testInjector.register("sysInfo", { getSysInfo: ( pathToPackageJson: string, - androidToolsInfo?: { pathToAdb: string; pathToAndroid: string } + androidToolsInfo?: { pathToAdb: string; pathToAndroid: string }, ) => { return Promise.resolve({ xcodeVer: config.xcodeVersionOutput, @@ -75,7 +75,7 @@ describe("xcode-select-service", () => { assert.deepStrictEqual( await service.getDeveloperDirectoryPath(), defaultXcodeSelectStdout, - "xcode-select service should get correct trimmed path to Developer directory on Mac OS X." + "xcode-select service should get correct trimmed path to Developer directory on Mac OS X.", ); }); @@ -89,7 +89,7 @@ describe("xcode-select-service", () => { assert.deepStrictEqual( await service.getDeveloperDirectoryPath(), defaultXcodeSelectStdout, - "xcode-select service should get correct trimmed path to Developer directory on Mac OS X." + "xcode-select service should get correct trimmed path to Developer directory on Mac OS X.", ); }); @@ -106,12 +106,12 @@ describe("xcode-select-service", () => { assert.strictEqual( xcodeVersion.major, "7", - "xcodeSelectService should get correct Xcode version" + "xcodeSelectService should get correct Xcode version", ); assert.strictEqual( xcodeVersion.minor, "3", - "xcodeSelectService should get correct Xcode version" + "xcodeSelectService should get correct Xcode version", ); }); @@ -125,7 +125,7 @@ describe("xcode-select-service", () => { assert.deepStrictEqual( await service.getDeveloperDirectoryPath(), defaultXcodeSelectStdout, - "xcode-select service should get correct path to Developer directory on Mac OS X." + "xcode-select service should get correct path to Developer directory on Mac OS X.", ); }); @@ -141,7 +141,7 @@ describe("xcode-select-service", () => { assert.deepStrictEqual( await service.getContentsDirectoryPath(), expected, - "xcode-select service should get correct path to Contents directory on Mac OS X." + "xcode-select service should get correct path to Contents directory on Mac OS X.", ); }); @@ -157,7 +157,7 @@ describe("xcode-select-service", () => { assert.deepStrictEqual( executionStopped, true, - "xcode-select service should stop executon unless on Mac OS X." + "xcode-select service should stop executon unless on Mac OS X.", ); }); @@ -173,7 +173,7 @@ describe("xcode-select-service", () => { assert.deepStrictEqual( executionStopped, true, - "xcode-select service should stop executon unless on Mac OS X." + "xcode-select service should stop executon unless on Mac OS X.", ); }); @@ -186,7 +186,7 @@ describe("xcode-select-service", () => { assert.deepStrictEqual( executionStopped, true, - "xcode-select service should stop executon when Developer directory is empty on Mac OS X." + "xcode-select service should stop executon when Developer directory is empty on Mac OS X.", ); }); @@ -199,7 +199,7 @@ describe("xcode-select-service", () => { assert.deepStrictEqual( executionStopped, true, - "xcode-select service should stop executon when Contents directory is empty on Mac OS X." + "xcode-select service should stop executon when Contents directory is empty on Mac OS X.", ); }); }); diff --git a/lib/common/utils.ts b/lib/common/utils.ts index 290e4c4346..9e7aebcdc6 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -3,7 +3,10 @@ import { IUtils } from "./declarations"; import { injector } from "./yok"; export class Utils implements IUtils { - constructor(private $options: IOptions, private $logger: ILogger) {} + constructor( + private $options: IOptions, + private $logger: ILogger, + ) {} public getParsedTimeout(defaultTimeout: number): number { let timeout = defaultTimeout; @@ -15,7 +18,7 @@ export class Utils implements IUtils { this.$logger.warn( "Specify timeout in a number of seconds to wait. Default value: " + timeout + - " seconds will be used." + " seconds will be used.", ); } } diff --git a/lib/common/validators/project-name-validator.ts b/lib/common/validators/project-name-validator.ts index d825a89bdb..602d387922 100644 --- a/lib/common/validators/project-name-validator.ts +++ b/lib/common/validators/project-name-validator.ts @@ -55,19 +55,19 @@ export class ProjectNameValidator implements IProjectNameValidator { if (helpers.isNullOrWhitespace(name)) { return new ValidationResult.ValidationResult( - ProjectNameValidator.EMPTY_FILENAME_ERROR_MESSAGE + ProjectNameValidator.EMPTY_FILENAME_ERROR_MESSAGE, ); } if (!validNameRegex.test(name)) { return new ValidationResult.ValidationResult( - ProjectNameValidator.NOT_VALID_NAME_ERROR_MESSAGE + ProjectNameValidator.NOT_VALID_NAME_ERROR_MESSAGE, ); } if ( _.includes(ProjectNameValidator.INVALID_FILENAMES, name.split(".")[0]) ) { return new ValidationResult.ValidationResult( - ProjectNameValidator.RESERVED_NAME_ERROR_MESSAGE + ProjectNameValidator.RESERVED_NAME_ERROR_MESSAGE, ); } if ( @@ -75,27 +75,27 @@ export class ProjectNameValidator implements IProjectNameValidator { _.includes(ProjectNameValidator.INVALID_EXTENSIONS, ext) ) { return new ValidationResult.ValidationResult( - ProjectNameValidator.INVALID_EXTENSION_ERROR_MESSAGE + ProjectNameValidator.INVALID_EXTENSION_ERROR_MESSAGE, ); } if (name.length > ProjectNameValidator.MAX_FILENAME_LENGTH) { return new ValidationResult.ValidationResult( - ProjectNameValidator.TOO_LONG_NAME_ERROR_MESSAGE + ProjectNameValidator.TOO_LONG_NAME_ERROR_MESSAGE, ); } if (_.startsWith(name, " ")) { return new ValidationResult.ValidationResult( - ProjectNameValidator.LEADING_SPACES_ERROR_MESSAGE + ProjectNameValidator.LEADING_SPACES_ERROR_MESSAGE, ); } if (_.endsWith(name, ".")) { return new ValidationResult.ValidationResult( - ProjectNameValidator.TRAILING_DOTS_ERROR_MESSAGE + ProjectNameValidator.TRAILING_DOTS_ERROR_MESSAGE, ); } if (_.endsWith(name, " ")) { return new ValidationResult.ValidationResult( - ProjectNameValidator.TRAILING_SPACES_ERROR_MESSAGE + ProjectNameValidator.TRAILING_SPACES_ERROR_MESSAGE, ); } @@ -103,9 +103,8 @@ export class ProjectNameValidator implements IProjectNameValidator { } public validate(name: string): boolean { - const validationResult: ValidationResult.ValidationResult = this.validateName( - name - ); + const validationResult: ValidationResult.ValidationResult = + this.validateName(name); const isSuccessful = validationResult.isSuccessful; if (!isSuccessful) { diff --git a/lib/common/verify-node-version.ts b/lib/common/verify-node-version.ts index 5a759c6478..1830e08af9 100644 --- a/lib/common/verify-node-version.ts +++ b/lib/common/verify-node-version.ts @@ -5,7 +5,7 @@ import { ISystemWarning } from "./declarations"; import { SystemWarningsSeverity } from "../definitions/system-warnings"; // Use only ES5 code here - pure JavaScript can be executed with any Node.js version (even 0.10, 0.12). -/* tslint:disable:no-var-keyword no-var-requires prefer-const*/ +/* eslint-disable no-var, prefer-const */ var os = require("os"); var semver = require("semver"); var util = require("util"); @@ -111,4 +111,3 @@ export function getNodeWarning(): ISystemWarning { return nodeWarn; } -/* tslint:enable */ diff --git a/lib/common/yok.ts b/lib/common/yok.ts index 9187a8d030..1293a989df 100644 --- a/lib/common/yok.ts +++ b/lib/common/yok.ts @@ -470,12 +470,11 @@ export class Yok extends Injector implements IInjector { * @deprecated Legacy command-registry lookup. */ public resolveCommand(name: string): ICommand { - let command: ICommand; const commandModuleName = this.createCommandName(name); if (!this.has(commandModuleName)) { return null; } - command = this.resolve(commandModuleName); + const command: ICommand = this.resolve(commandModuleName); return command; } @@ -484,13 +483,12 @@ export class Yok extends Injector implements IInjector { * @deprecated Legacy command-registry lookup. */ public resolveKeyCommand(name: string): IKeyCommand { - let command: IKeyCommand; const commandModuleName = this.createKeyCommandName(name); if (!this.has(commandModuleName)) { return null; } - command = this.resolve(commandModuleName); + const command: IKeyCommand = this.resolve(commandModuleName); return command; } diff --git a/lib/config.ts b/lib/config.ts index 16291dfadb..4fd005005a 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -122,7 +122,7 @@ export class StaticConfig implements IStaticConfig { ["version"], "exit", undefined, - { throwError: false } + { throwError: false }, ); if (proc.stderr) { @@ -160,7 +160,7 @@ export class StaticConfig implements IStaticConfig { "resources", "platform-tools", "android", - process.platform + process.platform, ); const pathToPackageJson = path.join(__dirname, "..", "package.json"); const nsCliVersion = require(pathToPackageJson).version; diff --git a/lib/constants.ts b/lib/constants.ts index 1c50e69870..2669adbaa2 100644 --- a/lib/constants.ts +++ b/lib/constants.ts @@ -100,14 +100,14 @@ export class LiveSyncTrackActionNames { static DEVICE_INFO = `Device Info for ${liveSyncOperation}`; } -export const PackageJsonKeysToKeep: Array = [ +export const PackageJsonKeysToKeep: Array = [ "name", "main", "android", "version", "pluginsData", ]; -export const TemplatesV2PackageJsonKeysToRemove: Array = [ +export const TemplatesV2PackageJsonKeysToRemove: Array = [ "name", "version", "displayName", diff --git a/lib/controllers/build-controller.ts b/lib/controllers/build-controller.ts index f5ebb1666c..57e3dc35cd 100644 --- a/lib/controllers/build-controller.ts +++ b/lib/controllers/build-controller.ts @@ -26,7 +26,7 @@ export class BuildController extends EventEmitter implements IBuildController { private $mobileHelper: Mobile.IMobileHelper, private $projectDataService: IProjectDataService, private $projectChangesService: IProjectChangesService, - private $prepareController: IPrepareController + private $prepareController: IPrepareController, ) { super(); } @@ -48,11 +48,11 @@ export class BuildController extends EventEmitter implements IBuildController { const platform = buildData.platform.toLowerCase(); const projectData = this.$projectDataService.getProjectData( - buildData.projectDir + buildData.projectDir, ); const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); const action = constants.TrackActionNames.Build; @@ -76,7 +76,7 @@ export class BuildController extends EventEmitter implements IBuildController { if (buildData.clean) { await platformData.platformProjectService.cleanProject( - platformData.projectRoot + platformData.projectRoot, ); } @@ -94,14 +94,14 @@ export class BuildController extends EventEmitter implements IBuildController { platformData.platformProjectService.buildProject( platformData.projectRoot, projectData, - buildData - ) + buildData, + ), ); const buildInfoFileDir = platformData.getBuildOutputPath(buildData); this.$buildInfoFileService.saveLocalBuildInfo( platformData, - buildInfoFileDir + buildInfoFileDir, ); const endTime = performance.now(); @@ -112,14 +112,14 @@ export class BuildController extends EventEmitter implements IBuildController { const result = await this.$buildArtifactsService.getLatestAppPackagePath( platformData, - buildData + buildData, ); if (buildData.copyTo) { this.$buildArtifactsService.copyLatestAppPackage( buildData.copyTo, platformData, - buildData + buildData, ); } else { this.$logger.info(`The build result is located at: ${result}`); @@ -141,11 +141,11 @@ export class BuildController extends EventEmitter implements IBuildController { public async shouldBuild(buildData: IBuildData): Promise { const projectData = this.$projectDataService.getProjectData( - buildData.projectDir + buildData.projectDir, ); const platformData = this.$platformsDataService.getPlatformData( buildData.platform, - projectData + projectData, ); const outputPath = buildData.outputPath || platformData.getBuildOutputPath(buildData); @@ -154,7 +154,7 @@ export class BuildController extends EventEmitter implements IBuildController { (await this.$projectChangesService.checkForChanges( platformData, projectData, - buildData + buildData, )); if (changesInfo.changesRequireBuild) { @@ -165,23 +165,21 @@ export class BuildController extends EventEmitter implements IBuildController { return true; } - const validBuildOutputData = platformData.getValidBuildOutputData( - buildData - ); + const validBuildOutputData = + platformData.getValidBuildOutputData(buildData); const packages = this.$buildArtifactsService.getAllAppPackages( outputPath, - validBuildOutputData + validBuildOutputData, ); if (packages.length === 0) { return true; } - const prepareInfo = this.$projectChangesService.getPrepareInfo( - platformData - ); + const prepareInfo = + this.$projectChangesService.getPrepareInfo(platformData); const buildInfo = this.$buildInfoFileService.getLocalBuildInfo( platformData, - buildData + buildData, ); if (!prepareInfo || !buildInfo) { return true; diff --git a/lib/controllers/debug-controller.ts b/lib/controllers/debug-controller.ts index 330906112c..4fb116fb21 100644 --- a/lib/controllers/debug-controller.ts +++ b/lib/controllers/debug-controller.ts @@ -43,7 +43,7 @@ export class DebugController extends EventEmitter implements IDebugController { private $liveSyncProcessDataService: ILiveSyncProcessDataService, private $logger: ILogger, private $mobileHelper: Mobile.IMobileHelper, - private $projectDataService: IProjectDataService + private $projectDataService: IProjectDataService, ) { super(); } @@ -52,18 +52,18 @@ export class DebugController extends EventEmitter implements IDebugController { public async startDebug(debugData: IDebugData): Promise { const { debugOptions: options } = debugData; const device = this.$devicesService.getDeviceByIdentifier( - debugData.deviceIdentifier + debugData.deviceIdentifier, ); if (!device) { this.$errors.fail( - `Cannot find device with identifier ${debugData.deviceIdentifier}.` + `Cannot find device with identifier ${debugData.deviceIdentifier}.`, ); } if (device.deviceInfo.status !== CONNECTED_STATUS) { this.$errors.fail( - `The device with identifier ${debugData.deviceIdentifier} is unreachable. Make sure it is Trusted and try again.` + `The device with identifier ${debugData.deviceIdentifier} is unreachable. Make sure it is Trusted and try again.`, ); } @@ -81,18 +81,18 @@ export class DebugController extends EventEmitter implements IDebugController { if ( !(await device.applicationManager.isApplicationInstalled( - debugData.applicationIdentifier + debugData.applicationIdentifier, )) ) { this.$errors.fail( - `The application ${debugData.applicationIdentifier} is not installed on device with identifier ${debugData.deviceIdentifier}.` + `The application ${debugData.applicationIdentifier} is not installed on device with identifier ${debugData.deviceIdentifier}.`, ); } const debugService = this.getDeviceDebugService(device); if (!debugService) { this.$errors.fail( - `Unsupported device OS: ${device.deviceInfo.platform}. You can debug your applications only on iOS or Android.` + `Unsupported device OS: ${device.deviceInfo.platform}. You can debug your applications only on iOS or Android.`, ); } @@ -101,12 +101,12 @@ export class DebugController extends EventEmitter implements IDebugController { return this.getDebugInformation( debugResultInfo, - device.deviceInfo.identifier + device.deviceInfo.identifier, ); } public enableDebugging( - enableDebuggingData: IEnableDebuggingData + enableDebuggingData: IEnableDebuggingData, ): Promise[] { const { deviceIdentifiers } = enableDebuggingData; @@ -114,27 +114,26 @@ export class DebugController extends EventEmitter implements IDebugController { this.enableDebuggingCore( enableDebuggingData.projectDir, deviceIdentifier, - enableDebuggingData.debugOptions - ) + enableDebuggingData.debugOptions, + ), ); } public async disableDebugging( - disableDebuggingData: IDisableDebuggingData + disableDebuggingData: IDisableDebuggingData, ): Promise { const { deviceIdentifiers, projectDir } = disableDebuggingData; for (const deviceIdentifier of deviceIdentifiers) { - const liveSyncProcessInfo = this.$liveSyncProcessDataService.getPersistedData( - projectDir - ); + const liveSyncProcessInfo = + this.$liveSyncProcessDataService.getPersistedData(projectDir); if (liveSyncProcessInfo.currentSyncAction) { await liveSyncProcessInfo.currentSyncAction; } const currentDeviceDescriptor = this.getDeviceDescriptor( projectDir, - deviceIdentifier + deviceIdentifier, ); if (currentDeviceDescriptor) { @@ -144,11 +143,11 @@ export class DebugController extends EventEmitter implements IDebugController { } const currentDevice = this.$devicesService.getDeviceByIdentifier( - currentDeviceDescriptor.identifier + currentDeviceDescriptor.identifier, ); if (!currentDevice) { this.$errors.fail( - `Couldn't disable debugging for ${deviceIdentifier}. Could not find device.` + `Couldn't disable debugging for ${deviceIdentifier}. Could not find device.`, ); } @@ -159,7 +158,7 @@ export class DebugController extends EventEmitter implements IDebugController { } public async attachDebugger( - attachDebuggerData: IAttachDebuggerData + attachDebuggerData: IAttachDebuggerData, ): Promise { // Default values if (attachDebuggerData.debugOptions) { @@ -179,12 +178,12 @@ export class DebugController extends EventEmitter implements IDebugController { } const projectData = this.$projectDataService.getProjectData( - attachDebuggerData.projectDir + attachDebuggerData.projectDir, ); const debugData = this.$debugDataService.getDebugData( attachDebuggerData.deviceIdentifier, projectData, - attachDebuggerData.debugOptions + attachDebuggerData.debugOptions, ); // const platformData = this.$platformsDataService.getPlatformData(settings.platform, projectData); @@ -193,7 +192,7 @@ export class DebugController extends EventEmitter implements IDebugController { const debugInfo = await this.startDebug(debugData); const result = this.printDebugInformation( debugInfo, - attachDebuggerData.debugOptions.forceDebuggerAttachedEvent + attachDebuggerData.debugOptions.forceDebuggerAttachedEvent, ); return result; } @@ -202,11 +201,11 @@ export class DebugController extends EventEmitter implements IDebugController { public async enableDebuggingCoreWithoutWaitingCurrentAction( projectDir: string, deviceIdentifier: string, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): Promise { const deviceDescriptor = this.getDeviceDescriptor( projectDir, - deviceIdentifier + deviceIdentifier, ); if (!deviceDescriptor) { this.$errors.fail(`Couldn't enable debugging for ${deviceIdentifier}`); @@ -215,9 +214,8 @@ export class DebugController extends EventEmitter implements IDebugController { deviceDescriptor.debuggingEnabled = true; deviceDescriptor.debugOptions = debugOptions; - const currentDeviceInstance = this.$devicesService.getDeviceByIdentifier( - deviceIdentifier - ); + const currentDeviceInstance = + this.$devicesService.getDeviceByIdentifier(deviceIdentifier); const attachDebuggerData: IAttachDebuggerData = { deviceIdentifier, isEmulator: currentDeviceInstance.isEmulator, @@ -233,7 +231,7 @@ export class DebugController extends EventEmitter implements IDebugController { } catch (err) { this.$logger.trace( "Couldn't attach debugger, will modify options and try again.", - err + err, ); attachDebuggerData.debugOptions.start = false; try { @@ -241,7 +239,7 @@ export class DebugController extends EventEmitter implements IDebugController { } catch (innerErr) { this.$logger.trace( "Couldn't attach debugger with modified options.", - innerErr + innerErr, ); throw err; } @@ -252,7 +250,7 @@ export class DebugController extends EventEmitter implements IDebugController { public printDebugInformation( debugInformation: IDebugInformation, - fireDebuggerAttachedEvent: boolean = true + fireDebuggerAttachedEvent: boolean = true, ): IDebugInformation { if (!!debugInformation.url) { if (fireDebuggerAttachedEvent) { @@ -261,8 +259,8 @@ export class DebugController extends EventEmitter implements IDebugController { this.$logger.info( color.green( - `To start debugging, open the following URL in Chrome:${EOL}${debugInformation.url}${EOL}` - ) + `To start debugging, open the following URL in Chrome:${EOL}${debugInformation.url}${EOL}`, + ), ); } @@ -277,14 +275,13 @@ export class DebugController extends EventEmitter implements IDebugController { private getDeviceDescriptor( projectDir: string, - deviceIdentifier: string + deviceIdentifier: string, ): ILiveSyncDeviceDescriptor { - const deviceDescriptors = this.$liveSyncProcessDataService.getDeviceDescriptors( - projectDir - ); + const deviceDescriptors = + this.$liveSyncProcessDataService.getDeviceDescriptors(projectDir); const currentDeviceDescriptor = _.find( deviceDescriptors, - (d) => d.identifier === deviceIdentifier + (d) => d.identifier === deviceIdentifier, ); return currentDeviceDescriptor; @@ -294,21 +291,19 @@ export class DebugController extends EventEmitter implements IDebugController { if (!this._platformDebugServices[device.deviceInfo.identifier]) { const devicePlatform = device.deviceInfo.platform; if (this.$mobileHelper.isiOSPlatform(devicePlatform)) { - this._platformDebugServices[ - device.deviceInfo.identifier - ] = this.$injector.resolve("iOSDeviceDebugService", { device }); + this._platformDebugServices[device.deviceInfo.identifier] = + this.$injector.resolve("iOSDeviceDebugService", { device }); } else if (this.$mobileHelper.isAndroidPlatform(devicePlatform)) { - this._platformDebugServices[ - device.deviceInfo.identifier - ] = this.$injector.resolve("androidDeviceDebugService", { device }); + this._platformDebugServices[device.deviceInfo.identifier] = + this.$injector.resolve("androidDeviceDebugService", { device }); } else { this.$errors.fail( - DebugCommandErrors.UNSUPPORTED_DEVICE_OS_FOR_DEBUGGING + DebugCommandErrors.UNSUPPORTED_DEVICE_OS_FOR_DEBUGGING, ); } this.attachConnectionErrorHandlers( - this._platformDebugServices[device.deviceInfo.identifier] + this._platformDebugServices[device.deviceInfo.identifier], ); } @@ -316,20 +311,20 @@ export class DebugController extends EventEmitter implements IDebugController { } private attachConnectionErrorHandlers( - platformDebugService: IDeviceDebugService + platformDebugService: IDeviceDebugService, ) { let connectionErrorHandler = (e: Error) => this.emit(CONNECTION_ERROR_EVENT_NAME, e); connectionErrorHandler = connectionErrorHandler.bind(this); platformDebugService.on( CONNECTION_ERROR_EVENT_NAME, - connectionErrorHandler + connectionErrorHandler, ); } private getDebugInformation( debugResultInfo: IDebugResultInfo, - deviceIdentifier: string + deviceIdentifier: string, ): IDebugInformation { const debugInfo: IDebugInformation = { url: debugResultInfo.debugUrl, @@ -352,11 +347,10 @@ export class DebugController extends EventEmitter implements IDebugController { private async enableDebuggingCore( projectDir: string, deviceIdentifier: string, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): Promise { - const liveSyncProcessInfo = this.$liveSyncProcessDataService.getPersistedData( - projectDir - ); + const liveSyncProcessInfo = + this.$liveSyncProcessDataService.getPersistedData(projectDir); if (liveSyncProcessInfo && liveSyncProcessInfo.currentSyncAction) { await liveSyncProcessInfo.currentSyncAction; } @@ -364,7 +358,7 @@ export class DebugController extends EventEmitter implements IDebugController { return this.enableDebuggingCoreWithoutWaitingCurrentAction( projectDir, deviceIdentifier, - debugOptions + debugOptions, ); } } diff --git a/lib/controllers/deploy-controller.ts b/lib/controllers/deploy-controller.ts index beea13ef08..d727f20937 100644 --- a/lib/controllers/deploy-controller.ts +++ b/lib/controllers/deploy-controller.ts @@ -5,7 +5,7 @@ export class DeployController { constructor( private $deviceInstallAppService: IDeviceInstallAppService, private $devicesService: Mobile.IDevicesService, - private $prepareController: IPrepareController + private $prepareController: IPrepareController, ) {} public async deploy(data: IDeployData): Promise { @@ -14,7 +14,7 @@ export class DeployController { const executeAction = async (device: Mobile.IDevice) => { const deviceDescriptor = _.find( deviceDescriptors, - (dd) => dd.identifier === device.deviceInfo.identifier + (dd) => dd.identifier === device.deviceInfo.identifier, ); const prepareData = { ...deviceDescriptor.buildData, @@ -27,7 +27,7 @@ export class DeployController { await this.$deviceInstallAppService.installOnDevice( device, { ...deviceDescriptor.buildData, buildForDevice: !device.isEmulator }, - packageFilePath + packageFilePath, ); }; @@ -37,8 +37,8 @@ export class DeployController { _.some( deviceDescriptors, (deviceDescriptor) => - deviceDescriptor.identifier === device.deviceInfo.identifier - ) + deviceDescriptor.identifier === device.deviceInfo.identifier, + ), ); } } diff --git a/lib/controllers/migrate-controller.ts b/lib/controllers/migrate-controller.ts index 3db61d6cd4..389ce0b8a8 100644 --- a/lib/controllers/migrate-controller.ts +++ b/lib/controllers/migrate-controller.ts @@ -1278,7 +1278,7 @@ export class MigrateController `./app/polyfills.ts`, ].map((possiblePath) => path.resolve(projectDir, possiblePath)); - let polyfillsPath = possiblePaths.find((possiblePath) => { + const polyfillsPath = possiblePaths.find((possiblePath) => { return this.$fs.exists(possiblePath); }); diff --git a/lib/controllers/platform-controller.ts b/lib/controllers/platform-controller.ts index 6e572bb149..dba924523f 100644 --- a/lib/controllers/platform-controller.ts +++ b/lib/controllers/platform-controller.ts @@ -26,26 +26,26 @@ export class PlatformController implements IPlatformController { private $projectDataService: IProjectDataService, private $platformsDataService: IPlatformsDataService, private $projectChangesService: IProjectChangesService, - private $mobileHelper: Mobile.IMobileHelper + private $mobileHelper: Mobile.IMobileHelper, ) {} public async addPlatform( addPlatformData: IAddPlatformData, - projectData?: IProjectData + projectData?: IProjectData, ): Promise { const [platform, version] = addPlatformData.platform .toLowerCase() .split("@"); projectData ??= this.$projectDataService.getProjectData( - addPlatformData.projectDir + addPlatformData.projectDir, ); const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); this.$logger.trace( - `Creating NativeScript project for the ${platform} platform` + `Creating NativeScript project for the ${platform} platform`, ); this.$logger.trace(`Path: ${platformData.projectRoot}`); this.$logger.trace(`Package: ${projectData.projectIdentifiers[platform]}`); @@ -57,7 +57,7 @@ export class PlatformController implements IPlatformController { platformData, projectData, addPlatformData.frameworkPath, - version + version, ); this.$logger.trace("Determined package to install is", packageToInstall); @@ -67,17 +67,17 @@ export class PlatformController implements IPlatformController { projectData, platformData, packageToInstall, - addPlatformData + addPlatformData, ); this.$fs.ensureDirectoryExists( - path.join(projectData.platformsDir, platform) + path.join(projectData.platformsDir, platform), ); if (this.$mobileHelper.isAndroidPlatform(platform)) { const gradlePropertiesPath = path.resolve( platformData.projectRoot, - "gradle.properties" + "gradle.properties", ); const commentHeader = "# App configuration"; const appPath = projectData.getAppDirectoryRelativePath(); @@ -108,35 +108,35 @@ export class PlatformController implements IPlatformController { } } this.$logger.info( - `Platform ${platform} successfully added. v${installedPlatformVersion}` + `Platform ${platform} successfully added. v${installedPlatformVersion}`, ); } public async addPlatformIfNeeded( addPlatformData: IAddPlatformData, - projectData?: IProjectData + projectData?: IProjectData, ): Promise { if (addPlatformData.hostProjectPath) { this.$logger.trace( - "Not adding platform because --hostProjectPath is provided." + "Not adding platform because --hostProjectPath is provided.", ); return; } const [platform] = addPlatformData.platform.toLowerCase().split("@"); projectData ??= this.$projectDataService.getProjectData( - addPlatformData.projectDir + addPlatformData.projectDir, ); const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); const shouldAddPlatform = this.shouldAddPlatform( platformData, projectData, - addPlatformData.nativePrepare + addPlatformData.nativePrepare, ); if (shouldAddPlatform) { await this.addPlatform(addPlatformData, projectData); @@ -147,20 +147,20 @@ export class PlatformController implements IPlatformController { platformData: IPlatformData, projectData: IProjectData, frameworkPath?: string, - version?: string + version?: string, ): Promise { let result = null; if (frameworkPath) { if (!this.$fs.exists(frameworkPath)) { this.$errors.fail( - `Invalid frameworkPath: ${frameworkPath}. Please ensure the specified frameworkPath exists.` + `Invalid frameworkPath: ${frameworkPath}. Please ensure the specified frameworkPath exists.`, ); } result = "file:" + path.resolve(frameworkPath); } else { const desiredRuntimePackage = this.$projectDataService.getRuntimePackage( projectData.projectDir, - platformData.platformNameLowerCase as SupportedPlatform + platformData.platformNameLowerCase as SupportedPlatform, ); if (version) { @@ -171,7 +171,7 @@ export class PlatformController implements IPlatformController { // if no version is explicitly added, then we use the latest desiredRuntimePackage.version = await this.$packageInstallationManager.getLatestCompatibleVersion( - desiredRuntimePackage.name + desiredRuntimePackage.name, ); } // const currentPlatformData = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName); @@ -186,11 +186,11 @@ export class PlatformController implements IPlatformController { private shouldAddPlatform( platformData: IPlatformData, projectData: IProjectData, - nativePrepare: INativePrepare + nativePrepare: INativePrepare, ): boolean { const platformName = platformData.platformNameLowerCase; const hasPlatformDirectory = this.$fs.exists( - path.join(projectData.platformsDir, platformName) + path.join(projectData.platformsDir, platformName), ); const shouldAddNativePlatform = @@ -207,7 +207,7 @@ export class PlatformController implements IPlatformController { if (hasPlatformDirectory && !shouldAddPlatform) { const platformDirectoryItemCount = this.$fs.readDirectory( - path.join(projectData.platformsDir, platformName) + path.join(projectData.platformsDir, platformName), ).length; // 2 is a magic number to approximate a valid platform folder @@ -216,7 +216,7 @@ export class PlatformController implements IPlatformController { if (platformDirectoryItemCount <= 2) { this.$logger.warn( `The platforms/${platformName} folder appears to be invalid. If the build fails, run 'ns clean' and rebuild the app.`, - { wrapMessageWithBorders: true } + { wrapMessageWithBorders: true }, ); } } diff --git a/lib/controllers/update-controller-base.ts b/lib/controllers/update-controller-base.ts index 5919ebc3bd..ffa757bb0d 100644 --- a/lib/controllers/update-controller-base.ts +++ b/lib/controllers/update-controller-base.ts @@ -20,7 +20,7 @@ export class UpdateControllerBase { protected $platformsDataService: IPlatformsDataService, protected $packageInstallationManager: IPackageInstallationManager, protected $packageManager: IPackageManager, - protected $pacoteService: IPacoteService + protected $pacoteService: IPacoteService, ) { this.getPackageManifest = _.memoize(this._getPackageManifest, (...args) => { return args.join("@"); @@ -30,7 +30,7 @@ export class UpdateControllerBase { protected restoreBackup( folders: string[], backupDir: string, - projectDir: string + projectDir: string, ): void { for (const folder of folders) { this.$fs.deleteDirectory(path.join(projectDir, folder)); @@ -47,7 +47,7 @@ export class UpdateControllerBase { protected backup( folders: string[], backupDir: string, - projectDir: string + projectDir: string, ): void { this.$fs.deleteDirectory(backupDir); this.$fs.createDirectory(backupDir); @@ -62,7 +62,7 @@ export class UpdateControllerBase { protected hasDependency( dependency: IDependency, - projectData: IProjectData + projectData: IProjectData, ): boolean { const devDependencies = Object.keys(projectData.devDependencies); const dependencies = Object.keys(projectData.dependencies); @@ -80,10 +80,11 @@ export class UpdateControllerBase { projectData: IProjectData; }): boolean { const lowercasePlatform = platform.toLowerCase(); - const currentPlatformVersion = this.$platformCommandHelper.getCurrentPlatformVersion( - lowercasePlatform, - projectData - ); + const currentPlatformVersion = + this.$platformCommandHelper.getCurrentPlatformVersion( + lowercasePlatform, + projectData, + ); return !!currentPlatformVersion; } @@ -95,19 +96,20 @@ export class UpdateControllerBase { projectData: IProjectData; }) { const lowercasePlatform = platform.toLowerCase(); - const currentPlatformVersion = this.$platformCommandHelper.getCurrentPlatformVersion( - lowercasePlatform, - projectData - ); + const currentPlatformVersion = + this.$platformCommandHelper.getCurrentPlatformVersion( + lowercasePlatform, + projectData, + ); const platformData = this.$platformsDataService.getPlatformData( lowercasePlatform, - projectData + projectData, ); if (currentPlatformVersion) { return ( (await this.$packageInstallationManager.getMaxSatisfyingVersionSafe( platformData.frameworkPackageName, - currentPlatformVersion + currentPlatformVersion, )) || currentPlatformVersion ); } @@ -115,7 +117,7 @@ export class UpdateControllerBase { private async _getPackageManifest( templateName: string, - version: string + version: string, ): Promise { const packageVersion = semver.valid(version) || @@ -124,11 +126,11 @@ export class UpdateControllerBase { if (packageVersion && semver.valid(packageVersion)) { return await this.$pacoteService.manifest( `${templateName}@${packageVersion}`, - { fullMetadata: true } + { fullMetadata: true }, ); } else { throw new Error( - `Failed to get information for package: ${templateName}@${version}` + `Failed to get information for package: ${templateName}@${version}`, ); } } diff --git a/lib/controllers/update-controller.ts b/lib/controllers/update-controller.ts index bcb4a5abf0..5c4a619661 100644 --- a/lib/controllers/update-controller.ts +++ b/lib/controllers/update-controller.ts @@ -27,7 +27,8 @@ import { export class UpdateController extends UpdateControllerBase - implements IUpdateController { + implements IUpdateController +{ static readonly updatableDependencies: IDependency[] = [ // dependencies { @@ -80,7 +81,7 @@ export class UpdateController private $projectDataService: IProjectDataService, private $projectBackupService: IProjectBackupService, private $projectCleanupService: IProjectCleanupService, - private $terminalSpinnerService: ITerminalSpinnerService + private $terminalSpinnerService: ITerminalSpinnerService, ) { super( $fs, @@ -88,14 +89,14 @@ export class UpdateController $platformsDataService, $packageInstallationManager, $packageManager, - $pacoteService + $pacoteService, ); } public async update(updateOptions: IUpdateOptions): Promise { this.spinner = this.$terminalSpinnerService.createSpinner(); const projectData = this.$projectDataService.getProjectData( - updateOptions.projectDir + updateOptions.projectDir, ); updateOptions.version = updateOptions.version || PackageVersion.LATEST; @@ -125,28 +126,28 @@ export class UpdateController this.$logger.info(""); this.$logger.printMarkdown( "Project has been successfully updated. The next step is to run `ns run ` to ensure everything is working properly." + - "\n\nPlease note that you may need additional changes to complete the update." + "\n\nPlease note that you may need additional changes to complete the update.", ); } public async shouldUpdate(updateOptions: IUpdateOptions): Promise { const projectData = this.$projectDataService.getProjectData( - updateOptions.projectDir + updateOptions.projectDir, ); updateOptions.version = updateOptions.version || PackageVersion.LATEST; for (const dependency of UpdateController.updatableDependencies) { this.$logger.trace( - `Checking if ${dependency.packageName} needs to be updated...` + `Checking if ${dependency.packageName} needs to be updated...`, ); const desiredVersion = await this.getVersionFromTagOrVersion( dependency.packageName, - updateOptions.version + updateOptions.version, ); if (typeof desiredVersion === "boolean") { this.$logger.trace( - `Package ${dependency.packageName} does not have version/tag ${updateOptions.version}. Skipping.` + `Package ${dependency.packageName} does not have version/tag ${updateOptions.version}. Skipping.`, ); continue; @@ -155,12 +156,12 @@ export class UpdateController const shouldUpdate = await this.shouldUpdateDependency( projectData, dependency, - desiredVersion + desiredVersion, ); if (shouldUpdate) { this.$logger.trace( - `shouldUpdate is true because '${dependency.packageName} needs to be updated.'` + `shouldUpdate is true because '${dependency.packageName} needs to be updated.'`, ); return true; } @@ -171,7 +172,7 @@ export class UpdateController private async updateDependencies( projectData: IProjectData, - version: string + version: string, ): Promise { for (const dependency of UpdateController.updatableDependencies) { await this.updateDependency(projectData, dependency, version); @@ -181,7 +182,7 @@ export class UpdateController private async updateDependency( projectData: IProjectData, dependency: IDependency, - version: string + version: string, ): Promise { if (!this.hasDependency(dependency, projectData)) { return; @@ -189,15 +190,15 @@ export class UpdateController const desiredVersion = await this.getVersionFromTagOrVersion( dependency.packageName, - version + version, ); if (typeof desiredVersion === "boolean") { this.$logger.info( ` - ${color.yellow( - dependency.packageName + dependency.packageName, )} does not have version/tag ${color.green(version)}. ` + - color.yellow("Skipping.") + color.yellow("Skipping."), ); return; @@ -206,7 +207,7 @@ export class UpdateController const shouldUpdate = await this.shouldUpdateDependency( projectData, dependency, - desiredVersion + desiredVersion, ); if (!shouldUpdate) { @@ -233,36 +234,37 @@ export class UpdateController dependency.packageName, updatedVersion, dependency.isDev, - projectData.projectDir + projectData.projectDir, ); this.$logger.info( ` - ${color.yellow( - dependency.packageName - )} has been updated to ${color.green(updatedVersion)}` + dependency.packageName, + )} has been updated to ${color.green(updatedVersion)}`, ); } private async shouldUpdateDependency( projectData: IProjectData, dependency: IDependency, - desiredVersion: string + desiredVersion: string, ): Promise { - const installedVersion = await this.$packageInstallationManager.getInstalledDependencyVersion( - dependency.packageName, - projectData.projectDir - ); + const installedVersion = + await this.$packageInstallationManager.getInstalledDependencyVersion( + dependency.packageName, + projectData.projectDir, + ); if (!installedVersion) { return false; } - return installedVersion != desiredVersion; + return installedVersion !== desiredVersion; } private async getVersionFromTagOrVersion( packageName: string, - versionOrTag: string + versionOrTag: string, ): Promise { if (semver.valid(versionOrTag) || semver.validRange(versionOrTag)) { return versionOrTag; @@ -270,7 +272,7 @@ export class UpdateController const version = await this.$packageManager.getTagVersion( packageName, - versionOrTag + versionOrTag, ); if (!version) { diff --git a/lib/data/controller-data-base.ts b/lib/data/controller-data-base.ts index 80e7fcb8a8..5c08fe3486 100644 --- a/lib/data/controller-data-base.ts +++ b/lib/data/controller-data-base.ts @@ -4,7 +4,11 @@ import { IControllerDataBase } from "../definitions/data"; export class ControllerDataBase implements IControllerDataBase { public nativePrepare?: INativePrepare; - constructor(public projectDir: string, public platform: string, data: any) { + constructor( + public projectDir: string, + public platform: string, + data: any, + ) { this.nativePrepare = data.nativePrepare; } } diff --git a/lib/data/platform-data.ts b/lib/data/platform-data.ts index 89ff99a77c..88f5cc8d35 100644 --- a/lib/data/platform-data.ts +++ b/lib/data/platform-data.ts @@ -3,7 +3,11 @@ import { ControllerDataBase } from "./controller-data-base"; export class AddPlatformData extends ControllerDataBase { public frameworkPath?: string; - constructor(public projectDir: string, public platform: string, data: any) { + constructor( + public projectDir: string, + public platform: string, + data: any, + ) { super(projectDir, platform, data); this.frameworkPath = data.frameworkPath; diff --git a/lib/data/run-data.ts b/lib/data/run-data.ts index 9a8df7d105..470cbb1d91 100644 --- a/lib/data/run-data.ts +++ b/lib/data/run-data.ts @@ -2,6 +2,6 @@ export class RunData { constructor( public projectDir: string, public liveSyncInfo: ILiveSyncInfo, - public deviceDescriptors: ILiveSyncDeviceDescriptor[] + public deviceDescriptors: ILiveSyncDeviceDescriptor[], ) {} } diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index a2c0bb09c6..b1c258eaf5 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -53,7 +53,7 @@ interface INodePackageManager { * @param {IDictionary} config Additional options that can be passed to manipulate view. * @return {Promise} Object, containing information about the package. */ - view(packageName: string, config: Object): Promise; + view(packageName: string, config: object): Promise; /** * Checks if the specified string is name of a packaged published in the NPM registry. @@ -380,7 +380,7 @@ interface INpm5InstallCliResult { * Time elapsed. * @type {Number} */ - elapsed: Number; + elapsed: number; } /** @@ -562,7 +562,7 @@ interface IDebugInformation extends IPort, Mobile.IDeviceIdentifier { } interface IPort { - port: Number; + port: number; } interface IPluginSeedOptions { @@ -655,8 +655,8 @@ interface IOptions template: string; certificate: string; certificatePassword: string; - var: Object; - default: Boolean; + var: object; + default: boolean; count: number; hooks: boolean; debug: boolean; @@ -699,7 +699,7 @@ interface IOptions background: string; hmr: boolean; link: boolean; - performance: Object; + performance: object; cleanupLogFile: string; appleApplicationSpecificPassword: string; appleSessionBase64: string; @@ -922,7 +922,6 @@ interface IAppDebugSocketProxyFactory extends NodeJS.EventEmitter { removeAllProxies(): void; } -// tslint:disable-next-line:interface-name interface IiOSNotification extends NodeJS.EventEmitter { getAttachRequest(appId: string, deviceId: string): string; getReadyForAttach(appId: string): string; @@ -930,7 +929,6 @@ interface IiOSNotification extends NodeJS.EventEmitter { getAppRefreshStarted(appId: string): string; } -// tslint:disable-next-line:interface-name interface IiOSSocketRequestExecutor { executeAttachRequest( device: Mobile.IiOSDevice, diff --git a/lib/definitions/build.d.ts b/lib/definitions/build.d.ts index e64a318c6d..3937a4ffe4 100644 --- a/lib/definitions/build.d.ts +++ b/lib/definitions/build.d.ts @@ -28,9 +28,7 @@ interface IiOSBuildData extends IBuildData { } interface IAndroidBuildData - extends IBuildData, - IAndroidSigningData, - IHasAndroidBundle { + extends IBuildData, IAndroidSigningData, IHasAndroidBundle { gradlePath?: string; gradleArgs?: string; } @@ -56,35 +54,35 @@ interface IBuildDataService { interface IBuildArtifactsService { getAllAppPackages( buildOutputPath: string, - validBuildOutputData: IValidBuildOutputData + validBuildOutputData: IValidBuildOutputData, ): IApplicationPackage[]; getLatestAppPackagePath( platformData: IPlatformData, - buildOutputOptions: IBuildOutputOptions + buildOutputOptions: IBuildOutputOptions, ): Promise; copyLatestAppPackage( targetPath: string, platformData: IPlatformData, - buildOutputOptions: IBuildOutputOptions + buildOutputOptions: IBuildOutputOptions, ): void; } interface IBuildInfoFileService { getLocalBuildInfo( platformData: IPlatformData, - buildData: IBuildData + buildData: IBuildData, ): IBuildInfo; getDeviceBuildInfo( device: Mobile.IDevice, - projectData: IProjectData + projectData: IProjectData, ): Promise; saveLocalBuildInfo( platformData: IPlatformData, - buildInfoFileDirname: string + buildInfoFileDirname: string, ): void; saveDeviceBuildInfo( device: Mobile.IDevice, projectData: IProjectData, - outputFilePath: string + outputFilePath: string, ): Promise; } diff --git a/lib/definitions/debug.d.ts b/lib/definitions/debug.d.ts index 2ebb7818f8..806a26f7c4 100644 --- a/lib/definitions/debug.d.ts +++ b/lib/definitions/debug.d.ts @@ -3,9 +3,7 @@ import { IDebugInformation } from "../declarations"; import { IProjectDir, IPlatform } from "../common/declarations"; interface IDebugData - extends IProjectDir, - Mobile.IDeviceIdentifier, - IOptionalDebuggingOptions { + extends IProjectDir, Mobile.IDeviceIdentifier, IOptionalDebuggingOptions { applicationIdentifier: string; projectName?: string; } @@ -102,7 +100,7 @@ interface IDebugDataService { getDebugData( deviceIdentifier: string, projectData: IProjectData, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): IDebugData; } @@ -124,7 +122,7 @@ interface IDeviceDebugService extends IPlatform, NodeJS.EventEmitter { */ debug( debugData: IAppDebugData, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): Promise; } @@ -149,18 +147,18 @@ interface IDebugController { stopDebug(deviceIdentifier: string): Promise; printDebugInformation( debugInformation: IDebugInformation, - fireDebuggerAttachedEvent?: boolean + fireDebuggerAttachedEvent?: boolean, ): IDebugInformation; enableDebuggingCoreWithoutWaitingCurrentAction( projectDir: string, deviceIdentifier: string, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): Promise; enableDebugging( - enableDebuggingData: IEnableDebuggingData + enableDebuggingData: IEnableDebuggingData, ): Promise[]; disableDebugging(disableDebuggingData: IDisableDebuggingData): Promise; attachDebugger( - attachDebuggerData: IAttachDebuggerData + attachDebuggerData: IAttachDebuggerData, ): Promise; } diff --git a/lib/definitions/files-hash-service.d.ts b/lib/definitions/files-hash-service.d.ts index b52dc9ada8..90ff1fca63 100644 --- a/lib/definitions/files-hash-service.d.ts +++ b/lib/definitions/files-hash-service.d.ts @@ -10,7 +10,7 @@ interface IFilesHashService { * A map with key file's path and value - file's hash */ generateHashesForProject( - platformData: IPlatformData + platformData: IPlatformData, ): Promise; /** * Generates hashes for all prepared files (all files from app folder under platforms folder) @@ -21,15 +21,15 @@ interface IFilesHashService { */ saveHashesForProject( platformData: IPlatformData, - hashesFileDirectory: string + hashesFileDirectory: string, ): Promise; saveHashes(hashes: IStringDictionary, hashesFileDirectory: string): void; getChanges( files: string[], - oldHashes: IStringDictionary + oldHashes: IStringDictionary, ): Promise; hasChangesInShasums( oldHashes: IStringDictionary, - newHashes: IStringDictionary + newHashes: IStringDictionary, ): boolean; } diff --git a/lib/definitions/gradle.d.ts b/lib/definitions/gradle.d.ts index 7b9e8652c5..7c9106177c 100644 --- a/lib/definitions/gradle.d.ts +++ b/lib/definitions/gradle.d.ts @@ -4,7 +4,7 @@ import { ISpawnResult, ISpawnFromEventOptions } from "../common/declarations"; interface IGradleCommandService { executeCommand( gradleArgs: string[], - options: IGradleCommandOptions + options: IGradleCommandOptions, ): Promise; } @@ -19,11 +19,11 @@ interface IGradleCommandOptions { interface IGradleBuildService { buildProject( projectRoot: string, - buildData: IAndroidBuildData + buildData: IAndroidBuildData, ): Promise; cleanProject( projectRoot: string, - buildData: IAndroidBuildData + buildData: IAndroidBuildData, ): Promise; } diff --git a/lib/definitions/livesync.d.ts b/lib/definitions/livesync.d.ts index faba420116..20dfa252ed 100644 --- a/lib/definitions/livesync.d.ts +++ b/lib/definitions/livesync.d.ts @@ -94,10 +94,7 @@ declare global { * Describes a LiveSync operation. */ interface ILiveSyncInfo - extends IProjectDir, - IEnvOptions, - IRelease, - IHasUseHotModuleReloadOption { + extends IProjectDir, IEnvOptions, IRelease, IHasUseHotModuleReloadOption { emulator?: boolean; /** @@ -164,7 +161,7 @@ declare global { */ liveSync( deviceDescriptors: ILiveSyncDeviceDescriptor[], - liveSyncData: ILiveSyncInfo + liveSyncData: ILiveSyncInfo, ): Promise; /** @@ -177,7 +174,7 @@ declare global { stopLiveSync( projectDir: string, deviceIdentifiers?: string[], - stopOptions?: { shouldAwaitAllActions: boolean } + stopOptions?: { shouldAwaitAllActions: boolean }, ): Promise; /** @@ -188,7 +185,7 @@ declare global { * @returns {ILiveSyncDeviceDescriptor[]} Array of elements describing parameters used to start LiveSync on each device. */ getLiveSyncDeviceDescriptors( - projectDir: string + projectDir: string, ): ILiveSyncDeviceDescriptor[]; } @@ -205,8 +202,7 @@ declare global { } interface IEnableDebuggingData - extends IProjectDir, - IOptionalDebuggingOptions { + extends IProjectDir, IOptionalDebuggingOptions { deviceIdentifiers: string[]; } @@ -215,7 +211,8 @@ declare global { } interface IAttachDebuggerData - extends IProjectDir, + extends + IProjectDir, Mobile.IDeviceIdentifier, IOptionalDebuggingOptions, IIsEmulator, @@ -238,7 +235,8 @@ declare global { } interface ILiveSyncWatchInfo - extends IProjectDataComposition, + extends + IProjectDataComposition, IHasUseHotModuleReloadOption, IConnectTimeoutOption { filesToRemove: string[]; @@ -258,11 +256,11 @@ declare global { } interface IAndroidLiveSyncResultInfo - extends ILiveSyncResultInfo, - IAndroidLivesyncSyncOperationResult {} + extends ILiveSyncResultInfo, IAndroidLivesyncSyncOperationResult {} interface IFullSyncInfo - extends IProjectDataComposition, + extends + IProjectDataComposition, IHasUseHotModuleReloadOption, IConnectTimeoutOption { device: Mobile.IDevice; @@ -285,28 +283,28 @@ declare global { fullSync(syncInfo: IFullSyncInfo): Promise; liveSyncWatchAction( device: Mobile.IDevice, - liveSyncInfo: ILiveSyncWatchInfo + liveSyncInfo: ILiveSyncWatchInfo, ): Promise; tryRefreshApplication( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise; restartApplication( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise; shouldRestart( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise; getDeviceLiveSyncService( device: Mobile.IDevice, - projectData: IProjectData + projectData: IProjectData, ): INativeScriptDeviceLiveSyncService; getAppData(syncInfo: IFullSyncInfo): Promise; syncAfterInstall( device: Mobile.IDevice, - liveSyncInfo: ILiveSyncWatchInfo + liveSyncInfo: ILiveSyncWatchInfo, ): Promise; } @@ -325,7 +323,7 @@ declare global { */ tryRefreshApplication( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise; /** @@ -333,7 +331,7 @@ declare global { */ restartApplication( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise; /** @@ -341,7 +339,7 @@ declare global { */ shouldRestart( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise; /** @@ -354,7 +352,7 @@ declare global { removeFiles( deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], - projectFilesPath?: string + projectFilesPath?: string, ): Promise; /** @@ -371,12 +369,11 @@ declare global { projectFilesPath: string, projectData: IProjectData, liveSyncDeviceData: ILiveSyncDeviceDescriptor, - options: ITransferFilesOptions + options: ITransferFilesOptions, ): Promise; } - interface IAndroidNativeScriptDeviceLiveSyncService - extends INativeScriptDeviceLiveSyncService { + interface IAndroidNativeScriptDeviceLiveSyncService extends INativeScriptDeviceLiveSyncService { /** * Guarantees all remove/update operations have finished * @param {ILiveSyncResultInfo} liveSyncInfo Describes the LiveSync operation - for which project directory is the operation and other settings. @@ -384,13 +381,13 @@ declare global { */ finalizeSync( liveSyncInfo: ILiveSyncResultInfo, - projectData: IProjectData + projectData: IProjectData, ): Promise; } interface ILiveSyncSocket extends INetSocket { uid: string; - writeAsync(data: Buffer): Promise; + writeAsync(data: Buffer): Promise; } interface IAndroidLivesyncTool { @@ -441,7 +438,7 @@ declare global { * @returns {Promise} */ sendDoSyncOperation( - options?: IDoSyncOperationOptions + options?: IDoSyncOperationOptions, ): Promise; /** * Generates new operation identifier. @@ -513,7 +510,7 @@ declare global { interface IDevicePathProvider { getDeviceProjectRootPath( device: Mobile.IDevice, - options: IDeviceProjectRootOptions + options: IDeviceProjectRootOptions, ): Promise; getDeviceSyncZipPath(device: Mobile.IDevice): string; } @@ -522,8 +519,7 @@ declare global { * Describes additional options, that can be passed to LiveSyncCommandHelper. */ interface ILiveSyncCommandHelperAdditionalOptions - extends IBuildPlatformAction, - INativePrepare { + extends IBuildPlatformAction, INativePrepare { /** * A map representing devices which have debugging enabled initially. */ @@ -548,7 +544,7 @@ declare global { executeLiveSyncOperation( devices: Mobile.IDevice[], platform: string, - additionalOptions?: ILiveSyncCommandHelperAdditionalOptions + additionalOptions?: ILiveSyncCommandHelperAdditionalOptions, ): Promise; getPlatformsForOperation(platform: string): string[]; @@ -558,7 +554,7 @@ declare global { * @return {Promise} */ validatePlatform( - platform: string + platform: string, ): Promise>; /** @@ -569,12 +565,12 @@ declare global { */ executeCommandLiveSync( platform?: string, - additionalOptions?: ILiveSyncCommandHelperAdditionalOptions + additionalOptions?: ILiveSyncCommandHelperAdditionalOptions, ): Promise; createDeviceDescriptors( devices: Mobile.IDevice[], platform: string, - additionalOptions?: ILiveSyncCommandHelperAdditionalOptions + additionalOptions?: ILiveSyncCommandHelperAdditionalOptions, ): Promise; getDeviceInstances(platform?: string): Promise; getLiveSyncData(projectDir: string): ILiveSyncInfo; @@ -593,7 +589,7 @@ declare global { persistData( projectDir: string, deviceDescriptors: ILiveSyncDeviceDescriptor[], - platforms: string[] + platforms: string[], ): void; hasDeviceDescriptors(projectDir: string): boolean; getPlatforms(projectDir: string): string[]; diff --git a/lib/definitions/lock-service.d.ts b/lib/definitions/lock-service.d.ts index 3709e38f65..c6f36e37fc 100644 --- a/lib/definitions/lock-service.d.ts +++ b/lib/definitions/lock-service.d.ts @@ -22,7 +22,7 @@ declare global { executeActionWithLock( action: () => Promise, lockFilePath?: string, - lockOpts?: ILockOptions + lockOpts?: ILockOptions, ): Promise; // TODO: expose as decorator diff --git a/lib/definitions/marking-mode-service.d.ts b/lib/definitions/marking-mode-service.d.ts index c23fbbfdf4..611edb38a0 100644 --- a/lib/definitions/marking-mode-service.d.ts +++ b/lib/definitions/marking-mode-service.d.ts @@ -1,6 +1,6 @@ interface IMarkingModeService { handleMarkingModeFullDeprecation( - options: IMarkingModeFullDeprecationOptions + options: IMarkingModeFullDeprecationOptions, ): Promise; } diff --git a/lib/definitions/migrate.d.ts b/lib/definitions/migrate.d.ts index c4a9f5e83e..be5956423f 100644 --- a/lib/definitions/migrate.d.ts +++ b/lib/definitions/migrate.d.ts @@ -37,10 +37,10 @@ interface IMigrationDependency extends IDependency, IDependencyVersion { shouldMigrateAction?: ( dependency: IMigrationDependency, projectData: IProjectData, - loose: boolean + loose: boolean, ) => Promise; migrateAction?: ( projectData: IProjectData, - migrationBackupDirPath: string + migrationBackupDirPath: string, ) => Promise; } diff --git a/lib/definitions/nativescript-dev-xcode.d.ts b/lib/definitions/nativescript-dev-xcode.d.ts index 22fcca05f4..f2ec3e421e 100644 --- a/lib/definitions/nativescript-dev-xcode.d.ts +++ b/lib/definitions/nativescript-dev-xcode.d.ts @@ -22,18 +22,17 @@ declare module "nativescript-dev-xcode" { addFramework(filepath: string, options?: Options): void; removeFramework(filePath: string, options?: Options): void; - getProductFile(watchApptarget: target): any; addToPbxFrameworksBuildPhase(file); addToPbxCopyfilesBuildPhase(file, comment: string, targetid: string); pbxFrameworksBuildPhaseObj(targetid: string): any; - pbxBuildFileSection(): {[k: string] : any}; + pbxBuildFileSection(): { [k: string]: any }; addPbxGroup( filePathsArray: any[], name: string, path: string, - sourceTree: string + sourceTree: string, ): void; removePbxGroup(groupName: string, path: string): void; @@ -42,7 +41,7 @@ declare module "nativescript-dev-xcode" { findTargetKey(name: string); pbxTargetByName(name: string): target; - pbxNativeTargetSection(): {[key: string]: any}; + pbxNativeTargetSection(): { [key: string]: any }; addToHeaderSearchPaths(options?: Options): void; removeFromHeaderSearchPaths(options?: Options): void; @@ -50,31 +49,27 @@ declare module "nativescript-dev-xcode" { pbxXCBuildConfigurationSection(): any; - buildPhaseObject( - buildPhaseType: string, - comment: string, - target: tstring - ) + buildPhaseObject(buildPhaseType: string, comment: string, target: tstring); addTarget( targetName: string, targetType: string, targetPath?: string, parentTarget?: string, - productTargetType?: string + productTargetType?: string, ): target; addBuildPhase( filePathsArray: string[], buildPhaseType: string, comment: string, target?: string, - optionsOrFolderType?: Object | string, - subfolderPath?: string + optionsOrFolderType?: object | string, + subfolderPath?: string, ): any; addToBuildSettings( buildSetting: string, value: any, - targetUuid?: string + targetUuid?: string, ): void; addPbxGroup( filePathsArray: string[], @@ -86,15 +81,15 @@ declare module "nativescript-dev-xcode" { target?: string; uuid?: string; isMain?: boolean; - } + }, ): group; addBuildProperty( prop: string, value: any, build_name?: string, - productName?: string + productName?: string, ): void; - addToHeaderSearchPaths(file: string | Object, productName?: string): void; + addToHeaderSearchPaths(file: string | object, productName?: string): void; removeTargetsByProductType(targetType: string): void; getFirstTarget(): { uuid: string }; } @@ -106,6 +101,6 @@ declare module "nativescript-dev-xcode" { class group { uuid: string; - pbxGroup: Object; + pbxGroup: object; } } diff --git a/lib/definitions/pacote-service.d.ts b/lib/definitions/pacote-service.d.ts index b26087d1e3..bb7557eb6e 100644 --- a/lib/definitions/pacote-service.d.ts +++ b/lib/definitions/pacote-service.d.ts @@ -11,7 +11,7 @@ declare global { */ manifest( packageName: string, - options?: IPacoteManifestOptions + options?: IPacoteManifestOptions, ): Promise; /** * Downloads the specified package and extracts it in specified destination directory @@ -21,7 +21,7 @@ declare global { extractPackage( packageName: string, destinationDirectory: string, - options?: IPacoteExtractOptions + options?: IPacoteExtractOptions, ): Promise; } diff --git a/lib/definitions/platform.d.ts b/lib/definitions/platform.d.ts index ae27231d2d..0d01ba069f 100644 --- a/lib/definitions/platform.d.ts +++ b/lib/definitions/platform.d.ts @@ -25,7 +25,7 @@ interface IBuildPlatformAction { buildPlatform( platform: string, buildConfig: IBuildConfig, - projectData: IProjectData + projectData: IProjectData, ): Promise; } @@ -38,7 +38,7 @@ interface IPlatformData { appDestinationDirectoryPath: string; getBuildOutputPath(options: IBuildOutputOptions): string; getValidBuildOutputData( - buildOptions: IBuildOutputOptions + buildOptions: IBuildOutputOptions, ): IValidBuildOutputData; frameworkDirectoriesExtensions?: string[]; frameworkDirectoriesNames?: string[]; @@ -56,9 +56,7 @@ interface IValidBuildOutputData { } interface IBuildOutputOptions - extends Partial, - IRelease, - Partial { + extends Partial, IRelease, Partial { outputPath?: string; } @@ -68,7 +66,7 @@ interface IPlatformsDataService { interface INodeModulesBuilder { prepareNodeModules( - prepareNodeModulesData: IPrepareNodeModulesData + prepareNodeModulesData: IPrepareNodeModulesData, ): Promise; } @@ -80,7 +78,7 @@ interface IPrepareNodeModulesData { interface INodeModulesDependenciesBuilder { getProductionDependencies( projectPath: string, - ignore?: string[] + ignore?: string[], ): IDependencyData[]; } @@ -98,7 +96,7 @@ interface IBuildInfo { interface IPlatformEnvironmentRequirements { checkEnvironmentRequirements( - input: ICheckEnvironmentRequirementsInput + input: ICheckEnvironmentRequirementsInput, ): Promise; } @@ -124,11 +122,11 @@ interface IAddPlatformData extends IControllerDataBase { interface IPlatformController { addPlatform( addPlatformData: IAddPlatformData, - projectData?: IProjectData + projectData?: IProjectData, ): Promise; addPlatformIfNeeded( addPlatformData: IAddPlatformData, - projectData?: IProjectData + projectData?: IProjectData, ): Promise; } @@ -137,11 +135,11 @@ interface IAddPlatformService { projectData: IProjectData, platformData: IPlatformData, packageToInstall: string, - addPlatformData: IAddPlatformData + addPlatformData: IAddPlatformData, ): Promise; setPlatformVersion( platformData: IPlatformData, projectData: IProjectData, - frameworkVersion: string + frameworkVersion: string, ): Promise; } diff --git a/lib/definitions/plugins.d.ts b/lib/definitions/plugins.d.ts index 66bafe5d41..7d1b121eb0 100644 --- a/lib/definitions/plugins.d.ts +++ b/lib/definitions/plugins.d.ts @@ -9,14 +9,14 @@ interface IPluginsService { plugin: string, version: string, isDev: boolean, - projectDir: string + projectDir: string, ): void; removeFromPackageJson(plugin: string, projectDir: string): void; getAllInstalledPlugins(projectData: IProjectData): Promise; getAllProductionPlugins( projectData: IProjectData, platform: string, - dependencies?: IDependencyData[] + dependencies?: IDependencyData[], ): IPluginData[]; ensureAllDependenciesAreInstalled(projectData: IProjectData): Promise; @@ -26,10 +26,10 @@ interface IPluginsService { * @returns {IPackageJsonDepedenciesResult} */ getDependenciesFromPackageJson( - projectDir: string + projectDir: string, ): IPackageJsonDepedenciesResult; preparePluginNativeCode( - preparePluginNativeCodeData: IPreparePluginNativeCodeData + preparePluginNativeCodeData: IPreparePluginNativeCodeData, ): Promise; isNativeScriptPlugin(pluginPackageJsonPath: string): boolean; } diff --git a/lib/definitions/prepare.d.ts b/lib/definitions/prepare.d.ts index 0755bc52bb..dbb3ba7a5a 100644 --- a/lib/definitions/prepare.d.ts +++ b/lib/definitions/prepare.d.ts @@ -30,7 +30,7 @@ declare global { getPrepareData( projectDir: string, platform: string, - data: any + data: any, ): IPrepareData; } @@ -50,7 +50,7 @@ declare global { prepareNativePlatform( platformData: IPlatformData, projectData: IProjectData, - prepareData: IPrepareData + prepareData: IPrepareData, ): Promise; } } diff --git a/lib/definitions/project.d.ts b/lib/definitions/project.d.ts index 4dd9a85a6a..69dd455953 100644 --- a/lib/definitions/project.d.ts +++ b/lib/definitions/project.d.ts @@ -366,7 +366,7 @@ interface IProjectDataService { * @returns {any} The value of the property. * @deprecated no longer used - will be removed in 8.0. */ - getNSValueFromContent(jsonData: Object, propertyName: string): any; + getNSValueFromContent(jsonData: object, propertyName: string): any; } interface IProjectCleanupService { diff --git a/lib/definitions/prompter.d.ts b/lib/definitions/prompter.d.ts index abfbea86e6..6a2f0a69e1 100644 --- a/lib/definitions/prompter.d.ts +++ b/lib/definitions/prompter.d.ts @@ -16,11 +16,11 @@ declare global { | string[] | { title: string; description?: string; value?: string }[], multiple: boolean = false, - options: any = {} + options: any = {}, ): Promise; promptForDetailedChoice( promptMessage: string, - choices: { key: string; description: string }[] + choices: { key: string; description: string }[], ): Promise; confirm(prompt: string, defaultAction?: () => boolean): Promise; } diff --git a/lib/definitions/run.d.ts b/lib/definitions/run.d.ts index 1e29b16a3b..325b3a0328 100644 --- a/lib/definitions/run.d.ts +++ b/lib/definitions/run.d.ts @@ -32,16 +32,16 @@ declare global { installOnDevice( device: Mobile.IDevice, buildData: IBuildData, - packageFile?: string + packageFile?: string, ): Promise; installOnDeviceIfNeeded( device: Mobile.IDevice, buildData: IBuildData, - packageFile?: string + packageFile?: string, ): Promise; shouldInstall( device: Mobile.IDevice, - buildData: IBuildData + buildData: IBuildData, ): Promise; } } diff --git a/lib/definitions/terminal-spinner-service.d.ts b/lib/definitions/terminal-spinner-service.d.ts index 2eea77049c..0170d56e19 100644 --- a/lib/definitions/terminal-spinner-service.d.ts +++ b/lib/definitions/terminal-spinner-service.d.ts @@ -7,6 +7,6 @@ interface ITerminalSpinnerService { createSpinner(spinnerOptions?: ITerminalSpinnerOptions): ITerminalSpinner; execute( spinnerOptions: ITerminalSpinnerOptions, - action: () => Promise + action: () => Promise, ): Promise; } diff --git a/lib/detached-processes/cleanup-js-subprocess.ts b/lib/detached-processes/cleanup-js-subprocess.ts index 9c262d2c4c..5acaca24f6 100644 --- a/lib/detached-processes/cleanup-js-subprocess.ts +++ b/lib/detached-processes/cleanup-js-subprocess.ts @@ -42,7 +42,6 @@ const logMessage = (msg: string, type?: FileLogMessageType): void => { fileLogService.logData({ message: `[${uniqueId}] ${msg}`, type }); }; -/* tslint:disable:no-floating-promises */ (async () => { try { logMessage(`Requiring file ${jsFilePath}`); @@ -77,4 +76,3 @@ const logMessage = (msg: string, type?: FileLogMessageType): void => { ); } })(); -/* tslint:enable:no-floating-promises */ diff --git a/lib/device-path-provider.ts b/lib/device-path-provider.ts index 6995c41b31..1b5f37e139 100644 --- a/lib/device-path-provider.ts +++ b/lib/device-path-provider.ts @@ -9,20 +9,20 @@ export class DevicePathProvider implements IDevicePathProvider { constructor( private $mobileHelper: Mobile.IMobileHelper, private $iOSSimResolver: Mobile.IiOSSimResolver, - private $errors: IErrors + private $errors: IErrors, ) {} public async getDeviceProjectRootPath( device: Mobile.IDevice, - options: IDeviceProjectRootOptions + options: IDeviceProjectRootOptions, ): Promise { let projectRoot = ""; if (this.$mobileHelper.isApplePlatform(device.deviceInfo.platform)) { projectRoot = device.isEmulator ? await this.$iOSSimResolver.iOSSim.getApplicationPath( device.deviceInfo.identifier, - options.appIdentifier - ) + options.appIdentifier, + ) : LiveSyncPaths.IOS_DEVICE_PROJECT_ROOT_PATH; if (!projectRoot) { diff --git a/lib/device-sockets/ios/app-debug-socket-proxy-factory.ts b/lib/device-sockets/ios/app-debug-socket-proxy-factory.ts index 10ddd50209..915460b954 100644 --- a/lib/device-sockets/ios/app-debug-socket-proxy-factory.ts +++ b/lib/device-sockets/ios/app-debug-socket-proxy-factory.ts @@ -170,7 +170,6 @@ export class AppDebugSocketProxyFactory ); this.$logger.info("Frontend client connected."); - let appDebugSocket; if (currentAppSocket) { currentAppSocket.removeAllListeners(); currentAppSocket = null; @@ -181,7 +180,7 @@ export class AppDebugSocketProxyFactory } await device.destroyDebugSocket(appId); } - appDebugSocket = await device.getDebugSocket( + const appDebugSocket = await device.getDebugSocket( appId, projectName, projectDir, diff --git a/lib/device-sockets/ios/notification.ts b/lib/device-sockets/ios/notification.ts index 0bd9d1e9e5..56080727d1 100644 --- a/lib/device-sockets/ios/notification.ts +++ b/lib/device-sockets/ios/notification.ts @@ -15,28 +15,28 @@ export class IOSNotification extends EventEmitter implements IiOSNotification { this.emit(ATTACH_REQUEST_EVENT_NAME, { deviceId, appId }); return this.formatNotification( IOSNotification.ATTACH_REQUEST_NOTIFICATION_NAME, - appId + appId, ); } public getReadyForAttach(appId: string): string { return this.formatNotification( IOSNotification.READY_FOR_ATTACH_NOTIFICATION_NAME, - appId + appId, ); } public getRefreshRequest(appId: string): string { return this.formatNotification( IOSNotification.REFRESH_REQUEST_NOTIFICATION_NAME, - appId + appId, ); } public getAppRefreshStarted(appId: string): string { return this.formatNotification( IOSNotification.APP_REFRESH_STARTED_NOTIFICATION_NAME, - appId + appId, ); } diff --git a/lib/device-sockets/ios/socket-request-executor.ts b/lib/device-sockets/ios/socket-request-executor.ts index 819c72e189..40d4a12b41 100644 --- a/lib/device-sockets/ios/socket-request-executor.ts +++ b/lib/device-sockets/ios/socket-request-executor.ts @@ -10,18 +10,18 @@ export class IOSSocketRequestExecutor implements IiOSSocketRequestExecutor { constructor( private $errors: IErrors, private $iOSNotification: IiOSNotification, - private $iOSNotificationService: IiOSNotificationService + private $iOSNotificationService: IiOSNotificationService, ) {} public async executeAttachRequest( device: Mobile.IiOSDevice, timeout: number, - appId: string + appId: string, ): Promise { const deviceId = device.deviceInfo.identifier; const mainRequestName = this.$iOSNotification.getAttachRequest( appId, - deviceId + deviceId, ); const readyRequestName = this.$iOSNotification.getReadyForAttach(appId); await this.executeRequest( @@ -29,27 +29,26 @@ export class IOSSocketRequestExecutor implements IiOSSocketRequestExecutor { readyRequestName, appId, deviceId, - timeout + timeout, ); } public async executeRefreshRequest( device: Mobile.IiOSDevice, timeout: number, - appId: string + appId: string, ): Promise { const deviceId = device.deviceInfo.identifier; const mainRequestName = this.$iOSNotification.getRefreshRequest(appId); - const refreshRequestStartedName = this.$iOSNotification.getAppRefreshStarted( - appId - ); + const refreshRequestStartedName = + this.$iOSNotification.getAppRefreshStarted(appId); const result = await this.executeRequest( mainRequestName, refreshRequestStartedName, appId, deviceId, - timeout + timeout, ); return result; @@ -60,7 +59,7 @@ export class IOSSocketRequestExecutor implements IiOSSocketRequestExecutor { successfulyExecutedNotificationName: string, appId: string, deviceId: string, - timeout: number + timeout: number, ): Promise { let isSuccessful = false; @@ -70,22 +69,23 @@ export class IOSSocketRequestExecutor implements IiOSSocketRequestExecutor { const socket = await this.$iOSNotificationService.postNotification( deviceId, successfulyExecutedNotificationName, - constants.IOS_OBSERVE_NOTIFICATION_COMMAND_TYPE - ); - const notificationPromise = this.$iOSNotificationService.awaitNotification( - deviceId, - +socket, - timeout + constants.IOS_OBSERVE_NOTIFICATION_COMMAND_TYPE, ); + const notificationPromise = + this.$iOSNotificationService.awaitNotification( + deviceId, + +socket, + timeout, + ); await this.$iOSNotificationService.postNotification( deviceId, - mainRequestName + mainRequestName, ); await notificationPromise; isSuccessful = true; } catch (e) { this.$errors.fail( - `The application ${appId} does not appear to be running on ${deviceId} or is not built with debugging enabled. Try starting the application manually.` + `The application ${appId} does not appear to be running on ${deviceId} or is not built with debugging enabled. Try starting the application manually.`, ); } diff --git a/lib/helpers/android-bundle-validator-helper.ts b/lib/helpers/android-bundle-validator-helper.ts index 1ee944b797..4dcbcb4d1a 100644 --- a/lib/helpers/android-bundle-validator-helper.ts +++ b/lib/helpers/android-bundle-validator-helper.ts @@ -10,7 +10,8 @@ import { injector } from "../common/yok"; export class AndroidBundleValidatorHelper extends VersionValidatorHelper - implements IAndroidBundleValidatorHelper { + implements IAndroidBundleValidatorHelper +{ public static MIN_RUNTIME_VERSION = "5.0.0"; public static MIN_ANDROID_WITH_AAB_SUPPORT = "4.4.0"; @@ -19,7 +20,7 @@ export class AndroidBundleValidatorHelper protected $errors: IErrors, protected $options: IOptions, protected $projectDataService: IProjectDataService, - private $mobileHelper: Mobile.IMobileHelper + private $mobileHelper: Mobile.IMobileHelper, ) { super(); } @@ -27,7 +28,7 @@ export class AndroidBundleValidatorHelper public validateNoAab(): void { if (this.$options.aab) { this.$errors.failWithHelp( - AndroidBundleValidatorMessages.AAB_NOT_SUPPORTED_BY_COMMNAND_MESSAGE + AndroidBundleValidatorMessages.AAB_NOT_SUPPORTED_BY_COMMNAND_MESSAGE, ); } } @@ -36,7 +37,7 @@ export class AndroidBundleValidatorHelper if (this.$options.aab) { const runtimePackage = this.$projectDataService.getRuntimePackage( projectData.projectDir, - PlatformTypes.android + PlatformTypes.android, ); const androidRuntimeVersion = runtimePackage ? runtimePackage.version @@ -46,15 +47,15 @@ export class AndroidBundleValidatorHelper this.isValidVersion(androidRuntimeVersion) && this.isVersionLowerThan( androidRuntimeVersion, - AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION + AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION, ); if (shouldThrowError) { this.$errors.fail( util.format( AndroidBundleValidatorMessages.NOT_SUPPORTED_RUNTIME_VERSION, - AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION - ) + AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION, + ), ); } } @@ -62,7 +63,7 @@ export class AndroidBundleValidatorHelper public validateDeviceApiLevel( device: Mobile.IDevice, - buildData: IBuildData + buildData: IBuildData, ): void { if (this.$mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) { const androidBuildData = buildData; @@ -71,7 +72,7 @@ export class AndroidBundleValidatorHelper !!device.deviceInfo.version && semver.lt( semver.coerce(device.deviceInfo.version), - AndroidBundleValidatorHelper.MIN_ANDROID_WITH_AAB_SUPPORT + AndroidBundleValidatorHelper.MIN_ANDROID_WITH_AAB_SUPPORT, ) ) { this.$errors.fail( @@ -79,8 +80,8 @@ export class AndroidBundleValidatorHelper AndroidBundleValidatorMessages.NOT_SUPPORTED_ANDROID_VERSION, device.deviceInfo.identifier, device.deviceInfo.version, - AndroidBundleValidatorHelper.MIN_ANDROID_WITH_AAB_SUPPORT - ) + AndroidBundleValidatorHelper.MIN_ANDROID_WITH_AAB_SUPPORT, + ), ); } } diff --git a/lib/helpers/deploy-command-helper.ts b/lib/helpers/deploy-command-helper.ts index ee2a33473a..b24b557371 100644 --- a/lib/helpers/deploy-command-helper.ts +++ b/lib/helpers/deploy-command-helper.ts @@ -13,12 +13,12 @@ export class DeployCommandHelper { private $devicesService: Mobile.IDevicesService, private $deployController: DeployController, private $options: IOptions, - private $projectData: IProjectData + private $projectData: IProjectData, ) {} public async deploy( platform: string, - additionalOptions?: ILiveSyncCommandHelperAdditionalOptions + additionalOptions?: ILiveSyncCommandHelperAdditionalOptions, ) { const emulator = this.$options.emulator; await this.$devicesService.initialize({ @@ -34,7 +34,7 @@ export class DeployCommandHelper { .filter( (d) => !platform || - d.deviceInfo.platform.toLowerCase() === platform.toLowerCase() + d.deviceInfo.platform.toLowerCase() === platform.toLowerCase(), ); const deviceDescriptors: ILiveSyncDeviceDescriptor[] = devices.map((d) => { @@ -59,7 +59,7 @@ export class DeployCommandHelper { skipNativePrepare: additionalOptions && additionalOptions.skipNativePrepare, }, - } + }, ); this.$androidBundleValidatorHelper.validateDeviceApiLevel(d, buildData); @@ -69,8 +69,8 @@ export class DeployCommandHelper { additionalOptions.buildPlatform, d.deviceInfo.platform, buildData, - this.$projectData - ) + this.$projectData, + ) : this.$buildController.build.bind(this.$buildController, buildData); const info: ILiveSyncDeviceDescriptor = { diff --git a/lib/helpers/network-connectivity-validator.ts b/lib/helpers/network-connectivity-validator.ts index 05cb042596..a3430ac007 100644 --- a/lib/helpers/network-connectivity-validator.ts +++ b/lib/helpers/network-connectivity-validator.ts @@ -3,14 +3,16 @@ import { INetworkConnectivityValidator } from "../declarations"; import { injector } from "../common/yok"; import { IErrors } from "../common/declarations"; -export class NetworkConnectivityValidator - implements INetworkConnectivityValidator { +export class NetworkConnectivityValidator implements INetworkConnectivityValidator { private static DNS_LOOKUP_URL = "play.nativescript.org"; private static NO_INTERNET_ERROR_CODE = "ENOTFOUND"; private static NO_INTERNET_ERROR_MESSAGE = "No internet connection. Check your internet settings and try again."; - constructor(private $errors: IErrors, private $logger: ILogger) {} + constructor( + private $errors: IErrors, + private $logger: ILogger, + ) {} public async validate(): Promise { const isConnected = await this.isConnected(); diff --git a/lib/helpers/options-track-helper.ts b/lib/helpers/options-track-helper.ts index 13d17b354b..db6ef3d48f 100644 --- a/lib/helpers/options-track-helper.ts +++ b/lib/helpers/options-track-helper.ts @@ -73,7 +73,7 @@ export class OptionsTracker { value: any, shorthands: string[] = [], options: IDictionary = {}, - ): Boolean { + ): boolean { if (shorthands.indexOf(key) >= 0) { return true; } diff --git a/lib/helpers/platform-command-helper.ts b/lib/helpers/platform-command-helper.ts index daa4cb67c3..7708ed4833 100644 --- a/lib/helpers/platform-command-helper.ts +++ b/lib/helpers/platform-command-helper.ts @@ -30,17 +30,17 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { private $platformValidationService: PlatformValidationService, private $projectChangesService: IProjectChangesService, private $projectDataService: IProjectDataService, - private $tempService: ITempService + private $tempService: ITempService, ) {} public async addPlatforms( platforms: string[], projectData: IProjectData, - frameworkPath: string + frameworkPath: string, ): Promise { if (this.$options.hostProjectPath) { this.$logger.info( - "Ignoring platform add becuase of --hostProjectPath flag" + "Ignoring platform add becuase of --hostProjectPath flag", ); return; } @@ -55,7 +55,7 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { const isPlatformAdded = this.isPlatformAdded( platform, platformPath, - projectData + projectData, ); if (isPlatformAdded) { this.$errors.fail(`Platform ${platform} already added`); @@ -72,12 +72,12 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { public async cleanPlatforms( platforms: string[], projectData: IProjectData, - framworkPath: string + framworkPath: string, ): Promise { for (const platform of platforms) { const version: string = this.getCurrentPlatformVersion( platform, - projectData + projectData, ); await this.removePlatforms([platform], projectData); @@ -89,11 +89,11 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { public async removePlatforms( platforms: string[], - projectData: IProjectData + projectData: IProjectData, ): Promise { if (this.$options.hostProjectPath) { this.$logger.info( - "Ignoring platform remove becuase of --native-host flag" + "Ignoring platform remove becuase of --native-host flag", ); return; } @@ -101,17 +101,17 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { for (const platform of platforms) { this.$platformValidationService.validatePlatformInstalled( platform, - projectData + projectData, ); const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); let errorMessage; try { await platformData.platformProjectService.stopServices( - platformData.projectRoot + platformData.projectRoot, ); } catch (err) { errorMessage = err.message; @@ -120,12 +120,12 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { try { const platformDir = path.join( projectData.platformsDir, - platform.toLowerCase() + platform.toLowerCase(), ); this.$fs.deleteDirectory(platformDir); await this.$packageInstallationManager.uninstall( platformData.frameworkPackageName, - projectData.projectDir + projectData.projectDir, ); // this.$projectDataService.removeNSProperty( // projectData.projectDir, @@ -135,7 +135,7 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { this.$logger.info(`Platform ${platform} successfully removed.`); } catch (err) { this.$logger.error( - `Failed to remove ${platform} platform with errors:` + `Failed to remove ${platform} platform with errors:`, ); if (errorMessage) { this.$logger.error(errorMessage); @@ -147,7 +147,7 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { public async updatePlatforms( platforms: string[], - projectData: IProjectData + projectData: IProjectData, ): Promise { for (const platformParam of platforms) { const data = platformParam.split("@"), @@ -155,7 +155,7 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { version = data[1]; const hasPlatformDirectory = this.$fs.exists( - path.join(projectData.platformsDir, platform.toLowerCase()) + path.join(projectData.platformsDir, platform.toLowerCase()), ); if (hasPlatformDirectory) { await this.updatePlatform(platform, version, projectData); @@ -175,7 +175,7 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { const subDirs = this.$fs.readDirectory(projectData.platformsDir); const platforms = this.$mobileHelper.platformNames.map((p) => - p.toLowerCase() + p.toLowerCase(), ); return _.filter(subDirs, (p) => platforms.indexOf(p) > -1); } @@ -198,15 +198,15 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { public getCurrentPlatformVersion( platform: string, - projectData: IProjectData + projectData: IProjectData, ): string { const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); const currentPlatformData: any = this.$projectDataService.getRuntimePackage( projectData.projectDir, - platformData.platformNameLowerCase + platformData.platformNameLowerCase, ); const version = currentPlatformData && currentPlatformData.version; @@ -216,7 +216,7 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { private isPlatformAdded( platform: string, platformPath: string, - projectData: IProjectData + projectData: IProjectData, ): boolean { if (!this.$fs.exists(platformPath)) { return false; @@ -224,7 +224,7 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); const prepareInfo = this.$projectChangesService.getPrepareInfo(platformData); @@ -241,44 +241,43 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { private async updatePlatform( platform: string, version: string, - projectData: IProjectData + projectData: IProjectData, ): Promise { const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); const data = this.$projectDataService.getRuntimePackage( projectData.projectDir, - platformData.platformNameLowerCase + platformData.platformNameLowerCase, ); const currentVersion = data && data.version ? data.version : "0.2.0"; - const installedModuleDir = await this.$tempService.mkdirSync( - "runtime-to-update" - ); + const installedModuleDir = + await this.$tempService.mkdirSync("runtime-to-update"); let newVersion = version === constants.PackageVersion.NEXT ? await this.$packageInstallationManager.getNextVersion( - platformData.frameworkPackageName - ) + platformData.frameworkPackageName, + ) : version || - (await this.$packageInstallationManager.getLatestCompatibleVersion( - platformData.frameworkPackageName - )); + (await this.$packageInstallationManager.getLatestCompatibleVersion( + platformData.frameworkPackageName, + )); await this.$pacoteService.extractPackage( `${platformData.frameworkPackageName}@${newVersion}`, - installedModuleDir + installedModuleDir, ); const cachedPackageData = this.$fs.readJson( - path.join(installedModuleDir, "package.json") + path.join(installedModuleDir, "package.json"), ); newVersion = (cachedPackageData && cachedPackageData.version) || newVersion; if (!semver.valid(newVersion)) { this.$errors.fail( "The version %s is not valid. The version should consists from 3 parts separated by dot.", - newVersion + newVersion, ); } @@ -286,13 +285,13 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { await this.updatePlatformCore( platformData, { currentVersion, newVersion }, - projectData + projectData, ); } else if (semver.eq(currentVersion, newVersion)) { this.$errors.fail("Current and new version are the same."); } else { this.$errors.fail( - `Your current version: ${currentVersion} is higher than the one you're trying to install ${newVersion}.` + `Your current version: ${currentVersion} is higher than the one you're trying to install ${newVersion}.`, ); } } @@ -300,7 +299,7 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { private async updatePlatformCore( platformData: IPlatformData, updateOptions: IUpdatePlatformOptions, - projectData: IProjectData + projectData: IProjectData, ): Promise { let packageName = platformData.normalizedPlatformName.toLowerCase(); await this.removePlatforms([packageName], projectData); @@ -313,21 +312,21 @@ export class PlatformCommandHelper implements IPlatformCommandHelper { }); this.$logger.info( "Successfully updated to version ", - updateOptions.newVersion + updateOptions.newVersion, ); } private isPlatformPrepared( platform: string, - projectData: IProjectData + projectData: IProjectData, ): boolean { const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); return platformData.platformProjectService.isPlatformPrepared( platformData.projectRoot, - projectData + projectData, ); } } diff --git a/lib/helpers/version-validator-helper.ts b/lib/helpers/version-validator-helper.ts index 32fdf45577..34ed1a0066 100644 --- a/lib/helpers/version-validator-helper.ts +++ b/lib/helpers/version-validator-helper.ts @@ -24,7 +24,7 @@ export class VersionValidatorHelper { private compareCoerceVersions( version: string, minVersion: string, - condition: Function + condition: Function, ): boolean { return condition(semver.coerce(version), semver.coerce(minVersion)); } diff --git a/lib/key-commands/index.ts b/lib/key-commands/index.ts index 904e3bf3b8..e8952aad08 100644 --- a/lib/key-commands/index.ts +++ b/lib/key-commands/index.ts @@ -47,7 +47,7 @@ export class ShiftA implements IKeyCommand { private $logger: ILogger, private $liveSyncCommandHelper: ILiveSyncCommandHelper, private $childProcess: IChildProcess, - private $projectData: IProjectData + private $projectData: IProjectData, ) {} getAndroidStudioPath(): string | null { @@ -67,7 +67,7 @@ export class ShiftA implements IKeyCommand { "Android", "Android Studio", "bin", - "studio64.exe" + "studio64.exe", ); return fs.existsSync(studioPath) ? studioPath : null; } else if (os === "linux") { @@ -85,7 +85,7 @@ export class ShiftA implements IKeyCommand { if (!fs.existsSync(androidDir)) { const prepareCommand = injector.resolveCommand( - "prepare" + "prepare", ) as PrepareCommand; await prepareCommand.execute([this.platform]); if (this.isInteractive) { @@ -102,7 +102,7 @@ export class ShiftA implements IKeyCommand { if (!studioPath) { this.$logger.error( - "Android Studio is not installed, or is not in a standard location. Use NATIVESCRIPT_ANDROID_STUDIO_PATH." + "Android Studio is not installed, or is not in a standard location. Use NATIVESCRIPT_ANDROID_STUDIO_PATH.", ); return; } @@ -128,7 +128,7 @@ export class OpenAndroidCommand extends ShiftA { $liveSyncCommandHelper: ILiveSyncCommandHelper, $childProcess: IChildProcess, $projectData: IProjectData, - private $options: IOptions + private $options: IOptions, ) { super($logger, $liveSyncCommandHelper, $childProcess, $projectData); this.isInteractive = false; @@ -170,7 +170,7 @@ export class ShiftI implements IKeyCommand { private $childProcess: IChildProcess, private $projectData: IProjectData, private $xcodeSelectService: IXcodeSelectService, - private $xcodebuildArgsService: IXcodebuildArgsService + private $xcodebuildArgsService: IXcodebuildArgsService, ) {} async execute(): Promise { @@ -181,7 +181,7 @@ export class ShiftI implements IKeyCommand { if (!fs.existsSync(iosDir)) { const prepareCommand = injector.resolveCommand( - "prepare" + "prepare", ) as PrepareCommand; await prepareCommand.execute(["ios"]); @@ -190,11 +190,11 @@ export class ShiftI implements IKeyCommand { } } const platformData = this.$iOSProjectService.getPlatformData( - this.$projectData + this.$projectData, ); const xcprojectFile = this.$xcodebuildArgsService.getXcodeProjectArgs( platformData, - this.$projectData + this.$projectData, )[1]; if (fs.existsSync(xcprojectFile)) { @@ -221,7 +221,7 @@ export class OpenIOSCommand extends ShiftI { $projectData: IProjectData, $xcodeSelectService: IXcodeSelectService, $xcodebuildArgsService: IXcodebuildArgsService, - private $options: IOptions + private $options: IOptions, ) { super( $iOSProjectService, @@ -229,7 +229,7 @@ export class OpenIOSCommand extends ShiftI { $childProcess, $projectData, $xcodeSelectService, - $xcodebuildArgsService + $xcodebuildArgsService, ); this.isInteractive = false; } @@ -271,7 +271,7 @@ export class ShiftV implements IKeyCommand { private $projectData: IProjectData, private $xcodeSelectService: IXcodeSelectService, private $xcodebuildArgsService: IXcodebuildArgsService, - protected $options: IOptions + protected $options: IOptions, ) {} async execute(): Promise { @@ -281,12 +281,12 @@ export class ShiftV implements IKeyCommand { this.$projectData.initializeProjectData(); const visionOSDir = path.resolve( this.$projectData.platformsDir, - "visionos" + "visionos", ); if (!fs.existsSync(visionOSDir)) { const prepareCommand = injector.resolveCommand( - "prepare" + "prepare", ) as PrepareCommand; await prepareCommand.execute(["visionos"]); @@ -295,11 +295,11 @@ export class ShiftV implements IKeyCommand { } } const platformData = this.$iOSProjectService.getPlatformData( - this.$projectData + this.$projectData, ); const xcprojectFile = this.$xcodebuildArgsService.getXcodeProjectArgs( platformData, - this.$projectData + this.$projectData, )[1]; if (fs.existsSync(xcprojectFile)) { @@ -327,7 +327,7 @@ export class OpenVisionOSCommand extends ShiftV { $projectData: IProjectData, $xcodeSelectService: IXcodeSelectService, $xcodebuildArgsService: IXcodebuildArgsService, - protected $options: IOptions + protected $options: IOptions, ) { super( $iOSProjectService, @@ -336,7 +336,7 @@ export class OpenVisionOSCommand extends ShiftV { $projectData, $xcodeSelectService, $xcodebuildArgsService, - $options + $options, ); this.isInteractive = false; } @@ -356,16 +356,15 @@ export class R implements IKeyCommand { constructor(private $liveSyncCommandHelper: ILiveSyncCommandHelper) {} async execute(platform: string): Promise { - const devices = await this.$liveSyncCommandHelper.getDeviceInstances( - platform - ); + const devices = + await this.$liveSyncCommandHelper.getDeviceInstances(platform); await this.$liveSyncCommandHelper.executeLiveSyncOperation( devices, platform, { restartLiveSync: true, - } as ILiveSyncCommandHelperAdditionalOptions + } as ILiveSyncCommandHelperAdditionalOptions, ); } } @@ -380,9 +379,8 @@ export class ShiftR implements IKeyCommand { constructor(private $liveSyncCommandHelper: ILiveSyncCommandHelper) {} async execute(platform: string): Promise { - const devices = await this.$liveSyncCommandHelper.getDeviceInstances( - platform - ); + const devices = + await this.$liveSyncCommandHelper.getDeviceInstances(platform); await this.$liveSyncCommandHelper.executeLiveSyncOperation( devices, platform, @@ -390,7 +388,7 @@ export class ShiftR implements IKeyCommand { skipNativePrepare: false, forceRebuildNativeApp: true, restartLiveSync: true, - } as ILiveSyncCommandHelperAdditionalOptions + } as ILiveSyncCommandHelperAdditionalOptions, ); } } @@ -422,7 +420,7 @@ export class W implements IKeyCommand { process.stdout.write( paused ? color.gray("Paused watching file changes... Press 'w' to resume.") - : color.bgGreen("Resumed watching file changes") + : color.bgGreen("Resumed watching file changes"), ); } catch (e) {} } @@ -437,7 +435,7 @@ export class C implements IKeyCommand { constructor( private $childProcess: IChildProcess, - private $liveSyncCommandHelper: ILiveSyncCommandHelper + private $liveSyncCommandHelper: ILiveSyncCommandHelper, ) {} async execute(): Promise { diff --git a/lib/nativescript-cli-lib-bootstrap.ts b/lib/nativescript-cli-lib-bootstrap.ts index 4f3ebae595..5a350efe73 100644 --- a/lib/nativescript-cli-lib-bootstrap.ts +++ b/lib/nativescript-cli-lib-bootstrap.ts @@ -10,7 +10,7 @@ injector.overrideAlreadyRequiredModule = true; injector.requirePublicClass("deviceEmitter", "./common/mobile/device-emitter"); injector.requirePublicClass( "deviceLogProvider", - "./common/mobile/device-log-emitter" + "./common/mobile/device-log-emitter", ); injector.resolve("staticConfig").disableAnalytics = true; diff --git a/lib/nativescript-cli.ts b/lib/nativescript-cli.ts index cf122f948c..7ec95d0421 100644 --- a/lib/nativescript-cli.ts +++ b/lib/nativescript-cli.ts @@ -14,7 +14,7 @@ if (process.platform === "win32") { args[0] = replaceDashes(args[0] as string | string[]); } - if (args.length == 2) { + if (args.length === 2) { realcp(args[0] as string[], args[1] as string); } else { realcp(args[0] as string, args[1] as string[], args[2] as string); @@ -70,7 +70,6 @@ process.on = (event: string, listener: any): any => { } }; -/* tslint:disable:no-floating-promises */ (async () => { if (process.argv.includes("--get-yargs-completions")) { // This is a special case when we want to get the yargs completions as fast as possible... @@ -107,4 +106,3 @@ process.on = (event: string, listener: any): any => { await commandDispatcher.dispatchCommand(); injector.dispose(); })(); -/* tslint:enable:no-floating-promises */ diff --git a/lib/node-package-manager.ts b/lib/node-package-manager.ts index bf63cae523..66cfea0f27 100644 --- a/lib/node-package-manager.ts +++ b/lib/node-package-manager.ts @@ -25,7 +25,7 @@ export class NodePackageManager extends BasePackageManager { $hostInfo: IHostInfo, private $logger: ILogger, private $httpClient: Server.IHttpClient, - $pacoteService: IPacoteService + $pacoteService: IPacoteService, ) { super($childProcess, $fs, $hostInfo, $pacoteService, "npm"); } @@ -34,7 +34,7 @@ export class NodePackageManager extends BasePackageManager { public async install( packageName: string, pathToSave: string, - config: INodePackageManagerInstallOptions + config: INodePackageManagerInstallOptions, ): Promise { if (config.disableNpmInstall) { return; @@ -67,7 +67,7 @@ export class NodePackageManager extends BasePackageManager { if (config.frameworkPath) { relativePathFromCwdToSource = relative( config.frameworkPath, - pathToSave + pathToSave, ); if (this.$fs.exists(relativePathFromCwdToSource)) { packageName = relativePathFromCwdToSource; @@ -79,7 +79,7 @@ export class NodePackageManager extends BasePackageManager { const result = await this.processPackageManagerInstall( packageName, params, - { cwd, isInstallingAllDependencies } + { cwd, isInstallingAllDependencies }, ); return result; } catch (err) { @@ -104,7 +104,7 @@ export class NodePackageManager extends BasePackageManager { public async uninstall( packageName: string, config?: any, - path?: string + path?: string, ): Promise { const flags = this.getFlagsString(config, false); return this.$childProcess.exec(`npm uninstall ${packageName} ${flags}`, { @@ -119,14 +119,14 @@ export class NodePackageManager extends BasePackageManager { } @exported("npm") - public async view(packageName: string, config: Object): Promise { + public async view(packageName: string, config: object): Promise { const wrappedConfig = _.extend({}, config, { json: true }); // always require view response as JSON const flags = this.getFlagsString(wrappedConfig, false); let viewResult: any; try { viewResult = await this.$childProcess.exec( - `npm view ${packageName} ${flags}` + `npm view ${packageName} ${flags}`, ); } catch (e) { this.$errors.fail(e.message); @@ -142,7 +142,7 @@ export class NodePackageManager extends BasePackageManager { public async searchNpms(keyword: string): Promise { // TODO: Fix the generation of url - in case it contains @ or / , the call may fail. const httpRequestResult = await this.$httpClient.httpRequest( - `https://api.npms.io/v2/search?q=keywords:${keyword}` + `https://api.npms.io/v2/search?q=keywords:${keyword}`, ); const result: INpmsResult = JSON.parse(httpRequestResult.body); return result; @@ -152,15 +152,15 @@ export class NodePackageManager extends BasePackageManager { const registry = await this.$childProcess.exec(`npm config get registry`); const url = registry.trim() + packageName; this.$logger.trace( - `Trying to get data from npm registry for package ${packageName}, url is: ${url}` + `Trying to get data from npm registry for package ${packageName}, url is: ${url}`, ); const responseData = (await this.$httpClient.httpRequest(url)).body; this.$logger.trace( - `Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}` + `Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}`, ); const jsonData = JSON.parse(responseData); this.$logger.trace( - `Successfully parsed data from npm registry for package ${packageName}.` + `Successfully parsed data from npm registry for package ${packageName}.`, ); return jsonData; } diff --git a/lib/options.ts b/lib/options.ts index 4c91738aee..cac4b54bcd 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -393,7 +393,7 @@ export class Options { const args: string[] = argv._.slice(1); const commands = injector .getRegisteredCommandsNames(false) - .filter((c) => c != "/?"); // remove the /? command, looks weird... :D + .filter((c) => c !== "/?"); // remove the /? command, looks weird... :D const currentDepth = args.length > 0 ? args.length - 1 : 0; const current = current_ ?? args[currentDepth] ?? ""; // split all commands into their components ie. "device|list" => ["device", "list"] diff --git a/lib/package-installation-manager.ts b/lib/package-installation-manager.ts index 535ff2d942..0f3547cf77 100644 --- a/lib/package-installation-manager.ts +++ b/lib/package-installation-manager.ts @@ -26,7 +26,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { private $settingsService: ISettingsService, private $fs: IFileSystem, private $staticConfig: IStaticConfig, - private $projectDataService: IProjectDataService + private $projectDataService: IProjectDataService, ) {} public async getLatestVersion(packageName: string): Promise { @@ -39,7 +39,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { public async getLatestCompatibleVersion( packageName: string, - referenceVersion?: string + referenceVersion?: string, ): Promise { referenceVersion = referenceVersion || this.$staticConfig.version; const isPreReleaseVersion = semver.prerelease(referenceVersion) !== null; @@ -47,8 +47,8 @@ export class PackageInstallationManager implements IPackageInstallationManager { const compatibleVersionRange = isPreReleaseVersion ? `~${referenceVersion}` : `~${semver.major(referenceVersion)}.${semver.minor( - referenceVersion - )}.0`; + referenceVersion, + )}.0`; const latestVersion = await this.getLatestVersion(packageName); if (semver.satisfies(latestVersion, compatibleVersionRange)) { return latestVersion; @@ -57,14 +57,14 @@ export class PackageInstallationManager implements IPackageInstallationManager { return ( (await this.getMaxSatisfyingVersion( packageName, - compatibleVersionRange + compatibleVersionRange, )) || latestVersion ); } public async getMaxSatisfyingVersion( packageName: string, - versionRange: string + versionRange: string, ): Promise { const data = await this.$packageManager.view(packageName, { versions: true, @@ -89,7 +89,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { public async getMaxSatisfyingVersionSafe( packageName: string, - versionIdentifier: string + versionIdentifier: string, ): Promise { let maxDependencyVersion; if (semver.valid(versionIdentifier)) { @@ -97,12 +97,12 @@ export class PackageInstallationManager implements IPackageInstallationManager { } else if (semver.validRange(versionIdentifier)) { maxDependencyVersion = await this.getMaxSatisfyingVersion( packageName, - versionIdentifier + versionIdentifier, ); } else { maxDependencyVersion = await this.$packageManager.getTagVersion( packageName, - versionIdentifier + versionIdentifier, ); } @@ -111,7 +111,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { public async getInstalledDependencyVersion( packageName: string, - projectDir?: string + projectDir?: string, ): Promise { const projectData = this.$projectDataService.getProjectData(projectDir); const devDependencies = projectData.devDependencies || {}; @@ -120,7 +120,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { dependencies[packageName] || devDependencies[packageName]; const installedVersion = await this.getMaxSatisfyingVersionSafe( packageName, - referencedVersion + referencedVersion, ); return installedVersion; @@ -128,16 +128,15 @@ export class PackageInstallationManager implements IPackageInstallationManager { public async getLatestCompatibleVersionSafe( packageName: string, - referenceVersion?: string + referenceVersion?: string, ): Promise { let version = ""; - const canGetVersionFromNpm = await this.$packageManager.isRegistered( - packageName - ); + const canGetVersionFromNpm = + await this.$packageManager.isRegistered(packageName); if (canGetVersionFromNpm) { version = await this.getLatestCompatibleVersion( packageName, - referenceVersion + referenceVersion, ); } @@ -147,7 +146,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { public async install( packageToInstall: string, projectDir: string, - opts?: INpmInstallOptions + opts?: INpmInstallOptions, ): Promise { try { const pathToSave = projectDir; @@ -158,7 +157,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { packageToInstall, pathToSave, version, - dependencyType + dependencyType, ); } catch (error) { this.$logger.trace(error); @@ -170,13 +169,13 @@ export class PackageInstallationManager implements IPackageInstallationManager { public async uninstall( packageToUninstall: string, projectDir: string, - opts?: IDictionary + opts?: IDictionary, ): Promise { try { return await this.$packageManager.uninstall( packageToUninstall, opts, - projectDir + projectDir, ); } catch (error) { this.$logger.trace(error); @@ -187,12 +186,12 @@ export class PackageInstallationManager implements IPackageInstallationManager { public async getInspectorFromCache( inspectorNpmPackageName: string, - projectDir: string + projectDir: string, ): Promise { const inspectorPath = path.join( projectDir, constants.NODE_MODULES_FOLDER_NAME, - inspectorNpmPackageName + inspectorNpmPackageName, ); // local installation takes precedence over cache @@ -205,22 +204,22 @@ export class PackageInstallationManager implements IPackageInstallationManager { const pathToPackageInCache = path.join( cachePath, constants.NODE_MODULES_FOLDER_NAME, - inspectorNpmPackageName + inspectorNpmPackageName, ); const iOSFrameworkNSValue = this.$projectDataService.getRuntimePackage( projectDir, - constants.PlatformTypes.ios + constants.PlatformTypes.ios, ); const version = await this.getLatestCompatibleVersion( inspectorNpmPackageName, - iOSFrameworkNSValue.version + iOSFrameworkNSValue.version, ); let shouldInstall = !this.$fs.exists(pathToPackageInCache); if (!shouldInstall) { try { const installedVersion = this.$fs.readJson( - path.join(pathToPackageInCache, constants.PACKAGE_JSON_FILE_NAME) + path.join(pathToPackageInCache, constants.PACKAGE_JSON_FILE_NAME), ).version; shouldInstall = version !== installedVersion; } catch (err) { @@ -231,7 +230,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { if (shouldInstall) { await this.$childProcess.exec( `npm install ${inspectorNpmPackageName}@${version} --prefix ${cachePath}`, - { maxBuffer: 250 * 1024 } + { maxBuffer: 250 * 1024 }, ); } @@ -246,7 +245,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { private getInspectorCachePath(): string { return path.join( this.$settingsService.getProfileDir(), - constants.INSPECTOR_CACHE_DIRNAME + constants.INSPECTOR_CACHE_DIRNAME, ); } @@ -255,7 +254,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { const cacheDirPackageJsonLocation = path.join( cacheDirName, - constants.PACKAGE_JSON_FILE_NAME + constants.PACKAGE_JSON_FILE_NAME, ); if (!this.$fs.exists(cacheDirPackageJsonLocation)) { this.$fs.writeJson(cacheDirPackageJsonLocation, { @@ -265,7 +264,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { } } - private inspectorAlreadyInstalled(pathToInspector: string): Boolean { + private inspectorAlreadyInstalled(pathToInspector: string): boolean { if (this.$fs.exists(pathToInspector)) { return true; } @@ -277,7 +276,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { packageName: string, pathToSave: string, version: string, - dependencyType: string + dependencyType: string, ): Promise { const possiblePackageName = path.resolve(packageName); if (this.$fs.exists(possiblePackageName)) { @@ -290,14 +289,14 @@ export class PackageInstallationManager implements IPackageInstallationManager { packageName, pathToSave, version, - dependencyType + dependencyType, ); const installedPackageName = installResultInfo.name; const pathToInstalledPackage = path.join( pathToSave, "node_modules", - installedPackageName + installedPackageName, ); return pathToInstalledPackage; @@ -307,7 +306,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { packageName: string, pathToSave: string, version: string, - dependencyType: string + dependencyType: string, ): Promise { this.$logger.info(`Installing ${packageName}`); @@ -322,7 +321,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { return await this.$packageManager.install( packageName, pathToSave, - npmOptions + npmOptions, ); } @@ -332,7 +331,7 @@ export class PackageInstallationManager implements IPackageInstallationManager { */ private async getVersion( packageName: string, - version: string + version: string, ): Promise { let data: any = await this.$packageManager.view(packageName, { "dist-tags": true, diff --git a/lib/package-manager.ts b/lib/package-manager.ts index df6d18aa92..5fded98455 100644 --- a/lib/package-manager.ts +++ b/lib/package-manager.ts @@ -31,7 +31,7 @@ export class PackageManager implements IPackageManager { private $bun: INodePackageManager, private $logger: ILogger, private $userSettingsService: IUserSettingsService, - private $projectConfigService: IProjectConfigService + private $projectConfigService: IProjectConfigService, ) {} @cache() @@ -50,7 +50,7 @@ export class PackageManager implements IPackageManager { public install( packageName: string, pathToSave: string, - config: INodePackageManagerInstallOptions + config: INodePackageManagerInstallOptions, ): Promise { return this.packageManager.install(packageName, pathToSave, config); } @@ -59,20 +59,20 @@ export class PackageManager implements IPackageManager { public uninstall( packageName: string, config?: IDictionary, - path?: string + path?: string, ): Promise { return this.packageManager.uninstall(packageName, config, path); } @exported("packageManager") @invokeInit() - public view(packageName: string, config: Object): Promise { + public view(packageName: string, config: object): Promise { return this.packageManager.view(packageName, config); } @exported("packageManager") @invokeInit() public search( filter: string[], - config: IDictionary + config: IDictionary, ): Promise { return this.packageManager.search(filter, config); } @@ -89,14 +89,14 @@ export class PackageManager implements IPackageManager { @invokeInit() public async getPackageFullName( - packageNameParts: INpmPackageNameParts + packageNameParts: INpmPackageNameParts, ): Promise { return this.packageManager.getPackageFullName(packageNameParts); } @invokeInit() public async getPackageNameParts( - fullPackageName: string + fullPackageName: string, ): Promise { return this.packageManager.getPackageNameParts(fullPackageName); } @@ -113,7 +113,7 @@ export class PackageManager implements IPackageManager { public async getTagVersion( packageName: string, - tag: string + tag: string, ): Promise { let version: string = null; if (!tag) { @@ -125,7 +125,7 @@ export class PackageManager implements IPackageManager { version = result[tag]; } catch (err) { this.$logger.trace( - `Error while getting tag version from view command: ${err}` + `Error while getting tag version from view command: ${err}`, ); const registryData = await this.getRegistryPackageData(packageName); version = registryData["dist-tags"][tag]; @@ -140,7 +140,7 @@ export class PackageManager implements IPackageManager { pm = await this.$userSettingsService.getSettingValue("packageManager"); } catch (err) { this.$errors.fail( - `Unable to read package manager config from user settings ${err}` + `Unable to read package manager config from user settings ${err}`, ); } @@ -150,7 +150,7 @@ export class PackageManager implements IPackageManager { if (configPm) { this.$logger.trace( - `Determined packageManager to use from user config is: ${configPm}` + `Determined packageManager to use from user config is: ${configPm}`, ); pm = configPm; } @@ -158,7 +158,7 @@ export class PackageManager implements IPackageManager { // ignore error, but log info this.$logger.trace( "Tried to read cli.packageManager from project config and failed. Error is: ", - err + err, ); } diff --git a/lib/platform-command-param.ts b/lib/platform-command-param.ts index 2b8f7ef2ef..aeb18bc16c 100644 --- a/lib/platform-command-param.ts +++ b/lib/platform-command-param.ts @@ -6,7 +6,7 @@ import { ICommandParameter } from "./common/definitions/commands"; export class PlatformCommandParameter implements ICommandParameter { constructor( private $platformValidationService: IPlatformValidationService, - private $projectData: IProjectData + private $projectData: IProjectData, ) {} mandatory = true; async validate(value: string): Promise { diff --git a/lib/pnpm-package-manager.ts b/lib/pnpm-package-manager.ts index f2de683552..718bb7c137 100644 --- a/lib/pnpm-package-manager.ts +++ b/lib/pnpm-package-manager.ts @@ -26,7 +26,7 @@ export class PnpmPackageManager extends BasePackageManager { $hostInfo: IHostInfo, private $httpClient: Server.IHttpClient, private $logger: ILogger, - $pacoteService: IPacoteService + $pacoteService: IPacoteService, ) { super($childProcess, $fs, $hostInfo, $pacoteService, "pnpm"); } @@ -35,7 +35,7 @@ export class PnpmPackageManager extends BasePackageManager { public async install( packageName: string, pathToSave: string, - config: INodePackageManagerInstallOptions + config: INodePackageManagerInstallOptions, ): Promise { if (config.disableNpmInstall) { return; @@ -63,7 +63,7 @@ export class PnpmPackageManager extends BasePackageManager { const result = await this.processPackageManagerInstall( packageName, params, - { cwd, isInstallingAllDependencies } + { cwd, isInstallingAllDependencies }, ); return result; } catch (e) { @@ -76,7 +76,7 @@ export class PnpmPackageManager extends BasePackageManager { public uninstall( packageName: string, config?: IDictionary, - cwd?: string + cwd?: string, ): Promise { // pnpm does not want save option in remove. It saves it by default delete config["save"]; @@ -87,14 +87,14 @@ export class PnpmPackageManager extends BasePackageManager { } @exported("pnpm") - public async view(packageName: string, config: Object): Promise { + public async view(packageName: string, config: object): Promise { const wrappedConfig = _.extend({}, config, { json: true }); const flags = this.getFlagsString(wrappedConfig, false); let viewResult: any; try { viewResult = await this.$childProcess.exec( - `pnpm info ${packageName} ${flags}` + `pnpm info ${packageName} ${flags}`, ); } catch (e) { this.$errors.fail(e.message); @@ -110,7 +110,7 @@ export class PnpmPackageManager extends BasePackageManager { @exported("pnpm") public search( filter: string[], - config: IDictionary + config: IDictionary, ): Promise { const flags = this.getFlagsString(config, false); return this.$childProcess.exec(`pnpm search ${filter.join(" ")} ${flags}`); @@ -118,7 +118,7 @@ export class PnpmPackageManager extends BasePackageManager { public async searchNpms(keyword: string): Promise { const httpRequestResult = await this.$httpClient.httpRequest( - `https://api.npms.io/v2/search?q=keywords:${keyword}` + `https://api.npms.io/v2/search?q=keywords:${keyword}`, ); const result: INpmsResult = JSON.parse(httpRequestResult.body); return result; @@ -129,15 +129,15 @@ export class PnpmPackageManager extends BasePackageManager { const registry = await this.$childProcess.exec(`pnpm config get registry`); const url = `${registry.trim()}/${packageName}`; this.$logger.trace( - `Trying to get data from pnpm registry for package ${packageName}, url is: ${url}` + `Trying to get data from pnpm registry for package ${packageName}, url is: ${url}`, ); const responseData = (await this.$httpClient.httpRequest(url)).body; this.$logger.trace( - `Successfully received data from pnpm registry for package ${packageName}. Response data is: ${responseData}` + `Successfully received data from pnpm registry for package ${packageName}. Response data is: ${responseData}`, ); const jsonData = JSON.parse(responseData); this.$logger.trace( - `Successfully parsed data from pnpm registry for package ${packageName}.` + `Successfully parsed data from pnpm registry for package ${packageName}.`, ); return jsonData; } diff --git a/lib/providers/project-files-provider.ts b/lib/providers/project-files-provider.ts index c983e937c0..05c0e4c293 100644 --- a/lib/providers/project-files-provider.ts +++ b/lib/providers/project-files-provider.ts @@ -13,7 +13,7 @@ export class ProjectFilesProvider extends ProjectFilesProviderBase { constructor( private $platformsDataService: IPlatformsDataService, $mobileHelper: Mobile.IMobileHelper, - $options: IOptions + $options: IOptions, ) { super($mobileHelper, $options); } @@ -24,45 +24,45 @@ export class ProjectFilesProvider extends ProjectFilesProviderBase { filePath: string, platform: string, projectData: IProjectData, - projectFilesConfig: IProjectFilesConfig + projectFilesConfig: IProjectFilesConfig, ): string { const platformData = this.$platformsDataService.getPlatformData( platform.toLowerCase(), - projectData + projectData, ); const parsedFilePath = this.getPreparedFilePath( filePath, - projectFilesConfig + projectFilesConfig, ); let mappedFilePath = ""; let relativePath; if (parsedFilePath.indexOf(constants.NODE_MODULES_FOLDER_NAME) > -1) { relativePath = path.relative( path.join(projectData.projectDir, constants.NODE_MODULES_FOLDER_NAME), - parsedFilePath + parsedFilePath, ); mappedFilePath = path.join( platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME, constants.TNS_MODULES_FOLDER_NAME, - relativePath + relativePath, ); } else { relativePath = path.relative( projectData.appDirectoryPath, - parsedFilePath + parsedFilePath, ); mappedFilePath = path.join( platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, - relativePath + relativePath, ); } const appResourcesDirectoryPath = projectData.appResourcesDirectoryPath; const platformSpecificAppResourcesDirectoryPath = path.join( appResourcesDirectoryPath, - platformData.normalizedPlatformName + platformData.normalizedPlatformName, ); if ( parsedFilePath.indexOf(appResourcesDirectoryPath) > -1 && @@ -77,15 +77,15 @@ export class ProjectFilesProvider extends ProjectFilesProviderBase { const appResourcesRelativePath = path.relative( path.join( projectData.appResourcesDirectoryPath, - platformData.normalizedPlatformName + platformData.normalizedPlatformName, ), - parsedFilePath + parsedFilePath, ); mappedFilePath = path.join( platformData.platformProjectService.getAppResourcesDestinationDirectoryPath( - projectData + projectData, ), - appResourcesRelativePath + appResourcesRelativePath, ); } @@ -94,7 +94,7 @@ export class ProjectFilesProvider extends ProjectFilesProviderBase { public isFileExcluded(filePath: string): boolean { return !!_.find(ProjectFilesProvider.INTERNAL_NONPROJECT_FILES, (pattern) => - minimatch(filePath, pattern, { nocase: true }) + minimatch(filePath, pattern, { nocase: true }), ); } } diff --git a/lib/resolvers/livesync-service-resolver.ts b/lib/resolvers/livesync-service-resolver.ts index 714374117b..f69b104b08 100644 --- a/lib/resolvers/livesync-service-resolver.ts +++ b/lib/resolvers/livesync-service-resolver.ts @@ -6,7 +6,7 @@ export class LiveSyncServiceResolver implements ILiveSyncServiceResolver { constructor( private $errors: IErrors, private $injector: IInjector, - private $mobileHelper: Mobile.IMobileHelper + private $mobileHelper: Mobile.IMobileHelper, ) {} public resolveLiveSyncService(platform: string): IPlatformLiveSyncService { @@ -18,8 +18,8 @@ export class LiveSyncServiceResolver implements ILiveSyncServiceResolver { this.$errors.fail( `Invalid platform ${platform}. Supported platforms are: ${this.$mobileHelper.platformNames.join( - ", " - )}` + ", ", + )}`, ); } } diff --git a/lib/services/analytics/analytics.d.ts b/lib/services/analytics/analytics.d.ts index 6d682344e0..d6f7e7bd8b 100644 --- a/lib/services/analytics/analytics.d.ts +++ b/lib/services/analytics/analytics.d.ts @@ -39,8 +39,7 @@ interface IAnalyticsBroker { } interface IGoogleAnalyticsTrackingInformation - extends IGoogleAnalyticsData, - ITrackingInformation {} + extends IGoogleAnalyticsData, ITrackingInformation {} /** * Describes methods required to track in Google Analytics. diff --git a/lib/services/android-device-debug-service.ts b/lib/services/android-device-debug-service.ts index 90dcd65679..1384b70b15 100644 --- a/lib/services/android-device-debug-service.ts +++ b/lib/services/android-device-debug-service.ts @@ -16,7 +16,8 @@ import * as _ from "lodash"; export class AndroidDeviceDebugService extends DebugServiceBase - implements IDeviceDebugService { + implements IDeviceDebugService +{ private _packageName: string; private deviceIdentifier: string; @@ -33,7 +34,7 @@ export class AndroidDeviceDebugService private $androidProcessService: Mobile.IAndroidProcessService, private $staticConfig: IStaticConfig, private $net: INet, - private $deviceLogProvider: Mobile.IDeviceLogProvider + private $deviceLogProvider: Mobile.IDeviceLogProvider, ) { super(device, $devicesService); this.deviceIdentifier = device.deviceInfo.identifier; @@ -42,31 +43,31 @@ export class AndroidDeviceDebugService @performanceLog() public async debug( debugData: IDebugData, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): Promise { this._packageName = debugData.applicationIdentifier; const result = await this.debugCore( debugData.applicationIdentifier, - debugOptions + debugOptions, ); // TODO: extract this logic outside the debug service if (debugOptions.start && !debugOptions.justlaunch) { const pid = await this.$androidProcessService.getAppProcessId( this.deviceIdentifier, - debugData.applicationIdentifier + debugData.applicationIdentifier, ); if (pid) { this.$deviceLogProvider.setApplicationPidForDevice( this.deviceIdentifier, - pid + pid, ); this.$deviceLogProvider.setProjectDirForDevice( this.device.deviceInfo.identifier, - debugData.projectDir + debugData.projectDir, ); const device = await this.$devicesService.getDevice( - this.deviceIdentifier + this.deviceIdentifier, ); await device.openDeviceLogStream(); } @@ -82,7 +83,7 @@ export class AndroidDeviceDebugService private async removePortForwarding(packageName?: string): Promise { const port = await this.getForwardedDebugPort( this.device.deviceInfo.identifier, - packageName || this._packageName + packageName || this._packageName, ); return this.device.adb.executeCommand([ "forward", @@ -94,7 +95,7 @@ export class AndroidDeviceDebugService // TODO: Remove this method and reuse logic from androidProcessService private async getForwardedDebugPort( deviceId: string, - packageName: string + packageName: string, ): Promise { let port = -1; const forwardsResult = await this.device.adb.executeCommand([ @@ -107,7 +108,7 @@ export class AndroidDeviceDebugService //matches 123a188909e6czzc tcp:40001 localabstract:org.nativescript.testUnixSockets-debug const regexp = new RegExp( `(?:${deviceId} tcp:)([\\d]+)(?= localabstract:${unixSocketName})`, - "g" + "g", ); const match = regexp.exec(forwardsResult); @@ -130,7 +131,7 @@ export class AndroidDeviceDebugService // TODO: Remove this method and reuse logic from androidProcessService private async unixSocketForward( local: number, - remote: string + remote: string, ): Promise { await this.device.adb.executeCommand([ "forward", @@ -142,7 +143,7 @@ export class AndroidDeviceDebugService @performanceLog() private async debugCore( appId: string, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): Promise { const result: IDebugResultInfo = { debugUrl: null }; if (debugOptions.stop) { @@ -157,7 +158,7 @@ export class AndroidDeviceDebugService const debugPort = await this.getForwardedDebugPort( this.deviceIdentifier, - appId + appId, ); await this.printDebugPort(this.deviceIdentifier, debugPort); @@ -173,16 +174,16 @@ export class AndroidDeviceDebugService // TODO: extract this logic outside the debug service private async validateRunningApp( deviceId: string, - packageName: string + packageName: string, ): Promise { if (!(await this.isAppRunning(packageName, deviceId))) { this.$errors.fail( - `The application ${packageName} does not appear to be running on ${deviceId} or is not built with debugging enabled. Try starting the application manually.` + `The application ${packageName} does not appear to be running on ${deviceId} or is not built with debugging enabled. Try starting the application manually.`, ); } } - private async waitForDebugServer(appId: String): Promise { + private async waitForDebugServer(appId: string): Promise { const debuggerStartedFilePath = `${LiveSyncPaths.ANDROID_TMP_DIR_NAME}/${appId}-debugger-started`; const waitText: string = `0 ${debuggerStartedFilePath}`; let maxWait = 12; @@ -212,11 +213,10 @@ export class AndroidDeviceDebugService private async isAppRunning( appIdentifier: string, - deviceIdentifier: string + deviceIdentifier: string, ): Promise { - const debuggableApps = await this.$androidProcessService.getDebuggableApps( - deviceIdentifier - ); + const debuggableApps = + await this.$androidProcessService.getDebuggableApps(deviceIdentifier); return !!_.find(debuggableApps, (a) => a.appIdentifier === appIdentifier); } @@ -225,5 +225,5 @@ export class AndroidDeviceDebugService injector.register( "androidDeviceDebugService", AndroidDeviceDebugService, - false + false, ); diff --git a/lib/services/android-project-service.ts b/lib/services/android-project-service.ts index b0e53a53e5..84f6b4df94 100644 --- a/lib/services/android-project-service.ts +++ b/lib/services/android-project-service.ts @@ -89,7 +89,7 @@ function topologicalSortNativeDependencies( dependencies: NativeDependency[], start: NativeDependency[] = [], depth = 0, - total = 0 // do not pass in, we calculate it in the initial run! + total = 0, // do not pass in, we calculate it in the initial run! ): NativeDependency[] { // we set the total on the initial call - and never increment it, as it's used for esacaping the recursion if (total === 0) { @@ -101,18 +101,18 @@ function topologicalSortNativeDependencies( const allSubDependenciesProcessed = currentDependency.dependencies.every( (subDependency) => { return sortedDeps.some((dep) => dep.name === subDependency); - } + }, ); if (allSubDependenciesProcessed) { sortedDeps.push(currentDependency); } return sortedDeps; }, - start + start, ); const remainingDeps = dependencies.filter( - (nativeDep) => !sortedDeps.includes(nativeDep) + (nativeDep) => !sortedDeps.includes(nativeDep), ); // recurse if we still have remaining deps @@ -122,14 +122,16 @@ function topologicalSortNativeDependencies( remainingDeps, sortedDeps, depth + 1, - total + total, ); } return sortedDeps; } -export class AndroidProjectService extends projectServiceBaseLib.PlatformProjectServiceBase { +export class AndroidProjectService + extends projectServiceBaseLib.PlatformProjectServiceBase +{ private static VALUES_DIRNAME = "values"; private static VALUES_VERSION_DIRNAME_PREFIX = AndroidProjectService.VALUES_DIRNAME + "-v"; @@ -151,7 +153,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject private $filesHashService: IFilesHashService, private $gradleCommandService: IGradleCommandService, private $gradleBuildService: IGradleBuildService, - private $analyticsService: IAnalyticsService + private $analyticsService: IAnalyticsService, ) { super($fs, $projectDataService); } @@ -160,7 +162,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public getPlatformData(projectData: IProjectData): IPlatformData { if (!projectData && !this._platformData) { throw new Error( - "First call of getPlatformData without providing projectData." + "First call of getPlatformData without providing projectData.", ); } if (projectData && projectData.platformsDir) { @@ -168,8 +170,8 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject ? this.$options.hostProjectPath : path.join( projectData.platformsDir, - AndroidProjectService.ANDROID_PLATFORM_NAME - ); + AndroidProjectService.ANDROID_PLATFORM_NAME, + ); const appDestinationDirectoryArr = [ projectRoot, @@ -196,7 +198,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject const packageName = this.getProjectNameFromId(projectData); const runtimePackage = this.$projectDataService.getRuntimePackage( projectData.projectDir, - constants.PlatformTypes.android + constants.PlatformTypes.android, ); this._platformData = { @@ -213,14 +215,14 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject this.$options.hostProjectModuleName, constants.BUILD_DIR, constants.OUTPUTS_DIR, - constants.BUNDLE_DIR + constants.BUNDLE_DIR, ); } return path.join(...deviceBuildOutputArr); }, getValidBuildOutputData: ( - buildOptions: IBuildOutputOptions + buildOptions: IBuildOutputOptions, ): IValidBuildOutputData => { const buildMode = buildOptions.release ? Configurations.Release.toLowerCase() @@ -245,7 +247,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject regexes: [ new RegExp( `(${packageName}|${this.$options.hostProjectModuleName})-.*-(${Configurations.Debug}|${Configurations.Release})(-unsigned)?${constants.APK_EXTENSION_NAME}`, - "i" + "i", ), ], }; @@ -255,7 +257,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject relativeToFrameworkConfigurationFilePath: path.join( constants.SRC_DIR, constants.MAIN_DIR, - constants.MANIFEST_FILE_NAME + constants.MANIFEST_FILE_NAME, ), fastLivesyncFileExtensions: [".jpg", ".gif", ".png", ".bmp", ".webp"], // http://developer.android.com/guide/appendix/media-formats.html }; @@ -266,12 +268,12 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public getCurrentPlatformVersion( platformData: IPlatformData, - projectData: IProjectData + projectData: IProjectData, ): string { const currentPlatformData: IDictionary = this.$projectDataService.getRuntimePackage( projectData.projectDir, - platformData.platformNameLowerCase + platformData.platformNameLowerCase, ); return currentPlatformData && currentPlatformData[constants.VERSION_STRING]; @@ -282,11 +284,11 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject } public getAppResourcesDestinationDirectoryPath( - projectData: IProjectData + projectData: IProjectData, ): string { const appResourcesDirStructureHasMigrated = this.$androidResourcesMigrationService.hasMigrated( - projectData.getAppResourcesDirectoryPath() + projectData.getAppResourcesDirectoryPath(), ); if (appResourcesDirStructureHasMigrated) { @@ -299,7 +301,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public async validate( projectData: IProjectData, options: IOptions, - notConfiguredEnvOptions?: INotConfiguredEnvOptions + notConfiguredEnvOptions?: INotConfiguredEnvOptions, ): Promise { this.validatePackageName(projectData.projectIdentifiers.android); this.validateProjectName(projectData.projectName); @@ -326,23 +328,25 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public async createProject( frameworkDir: string, frameworkVersion: string, - projectData: IProjectData + projectData: IProjectData, ): Promise { - const packageName = projectData.nsConfig.android?.runtimePackageName || constants.SCOPED_ANDROID_RUNTIME_NAME; + const packageName = + projectData.nsConfig.android?.runtimePackageName || + constants.SCOPED_ANDROID_RUNTIME_NAME; if ( packageName === constants.SCOPED_ANDROID_RUNTIME_NAME && semver.lt( frameworkVersion, - AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE + AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE, ) ) { this.$errors.fail( - `The NativeScript CLI requires Android runtime ${AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE} or later to work properly.` + `The NativeScript CLI requires Android runtime ${AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE} or later to work properly.`, ); } this.$fs.ensureDirectoryExists( - this.getPlatformData(projectData).projectRoot + this.getPlatformData(projectData).projectRoot, ); const androidToolsInfo = this.$androidToolsInfo.getToolsInfo({ projectDir: projectData.projectDir, @@ -355,7 +359,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject this.getPlatformData(projectData).projectRoot, frameworkDir, "*", - "-R" + "-R", ); // TODO: Check if we actually need this and if it should be targetSdk or compileSdk @@ -365,7 +369,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject private getResDestinationDir(projectData: IProjectData): string { const appResourcesDirStructureHasMigrated = this.$androidResourcesMigrationService.hasMigrated( - projectData.getAppResourcesDirectoryPath() + projectData.getAppResourcesDirectoryPath(), ); if (appResourcesDirStructureHasMigrated) { @@ -374,7 +378,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject return path.join( appResourcesDestinationPath, constants.MAIN_DIR, - constants.RESOURCES_DIR + constants.RESOURCES_DIR, ); } else { return this.getLegacyAppResourcesDestinationDirPath(projectData); @@ -383,7 +387,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject private cleanResValues( targetSdkVersion: number, - projectData: IProjectData + projectData: IProjectData, ): void { const resDestinationDir = this.getResDestinationDir(projectData); const directoriesInResFolder = this.$fs.readDirectory(resDestinationDir); @@ -393,18 +397,18 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject dirName: dir, sdkNum: parseInt( dir.substr( - AndroidProjectService.VALUES_VERSION_DIRNAME_PREFIX.length - ) + AndroidProjectService.VALUES_VERSION_DIRNAME_PREFIX.length, + ), ), }; }) .filter( (dir) => dir.dirName.match( - AndroidProjectService.VALUES_VERSION_DIRNAME_PREFIX + AndroidProjectService.VALUES_VERSION_DIRNAME_PREFIX, ) && dir.sdkNum && - (!targetSdkVersion || targetSdkVersion < dir.sdkNum) + (!targetSdkVersion || targetSdkVersion < dir.sdkNum), ) .map((dir) => path.join(resDestinationDir, dir.dirName)); @@ -427,7 +431,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject this.getAppResourcesDestinationDirectoryPath(projectData); if ( this.$androidResourcesMigrationService.hasMigrated( - appResourcesDirectoryPath + appResourcesDirectoryPath, ) ) { stringsFilePath = path.join( @@ -435,13 +439,13 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject constants.MAIN_DIR, constants.RESOURCES_DIR, "values", - "strings.xml" + "strings.xml", ); } else { stringsFilePath = path.join( appResourcesDestinationDirectoryPath, "values", - "strings.xml" + "strings.xml", ); } @@ -450,18 +454,18 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject "-i", /__TITLE_ACTIVITY__/, projectData.projectName, - stringsFilePath + stringsFilePath, ); const gradleSettingsFilePath = path.join( this.getPlatformData(projectData).projectRoot, - "settings.gradle" + "settings.gradle", ); shell.sed( "-i", /__PROJECT_NAME__/, this.getProjectNameFromId(projectData), - gradleSettingsFilePath + gradleSettingsFilePath, ); try { @@ -473,12 +477,12 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject "-i", new RegExp(constants.PACKAGE_PLACEHOLDER_NAME), projectData.projectIdentifiers.android, - projectData.appGradlePath + projectData.appGradlePath, ); } } catch (e) { this.$logger.trace( - `Templates updated and no need for replace in app.gradle.` + `Templates updated and no need for replace in app.gradle.`, ); } } @@ -490,7 +494,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject "-i", /__PACKAGE__/, projectData.projectIdentifiers.android, - manifestPath + manifestPath, ); } @@ -518,14 +522,16 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject canUpdate: boolean, projectData: IProjectData, addPlatform?: Function, - removePlatforms?: (platforms: string[]) => Promise + removePlatforms?: (platforms: string[]) => Promise, ): Promise { - const packageName = projectData.nsConfig.android?.runtimePackageName || constants.SCOPED_ANDROID_RUNTIME_NAME; + const packageName = + projectData.nsConfig.android?.runtimePackageName || + constants.SCOPED_ANDROID_RUNTIME_NAME; if ( packageName === constants.SCOPED_ANDROID_RUNTIME_NAME && semver.eq( newVersion, - AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE + AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE, ) ) { const platformLowercase = @@ -543,18 +549,18 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public async buildProject( projectRoot: string, projectData: IProjectData, - buildData: IAndroidBuildData + buildData: IAndroidBuildData, ): Promise { const platformData = this.getPlatformData(projectData); await this.$gradleBuildService.buildProject( platformData.projectRoot, - buildData + buildData, ); const outputPath = platformData.getBuildOutputPath(buildData); await this.$filesHashService.saveHashesForProject( this._platformData, - outputPath + outputPath, ); await this.trackKotlinUsage(projectRoot); } @@ -562,20 +568,20 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public async buildForDeploy( projectRoot: string, projectData: IProjectData, - buildData?: IAndroidBuildData + buildData?: IAndroidBuildData, ): Promise { return this.buildProject(projectRoot, projectData, buildData); } public isPlatformPrepared( projectRoot: string, - projectData: IProjectData + projectData: IProjectData, ): boolean { return this.$fs.exists( path.join( this.getPlatformData(projectData).appDestinationDirectoryPath, - this.$options.hostProjectModuleName - ) + this.$options.hostProjectModuleName, + ), ); } @@ -588,12 +594,12 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject } public ensureConfigurationFileInAppResources( - projectData: IProjectData + projectData: IProjectData, ): void { const appResourcesDirectoryPath = projectData.appResourcesDirectoryPath; const appResourcesDirStructureHasMigrated = this.$androidResourcesMigrationService.hasMigrated( - appResourcesDirectoryPath + appResourcesDirectoryPath, ); let originalAndroidManifestFilePath; @@ -603,13 +609,13 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject this.$devicePlatformsConstants.Android, "src", "main", - this.getPlatformData(projectData).configurationFileName + this.getPlatformData(projectData).configurationFileName, ); } else { originalAndroidManifestFilePath = path.join( appResourcesDirectoryPath, this.$devicePlatformsConstants.Android, - this.getPlatformData(projectData).configurationFileName + this.getPlatformData(projectData).configurationFileName, ); } @@ -617,7 +623,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject if (!manifestExists) { this.$logger.warn( - "No manifest found in " + originalAndroidManifestFilePath + "No manifest found in " + originalAndroidManifestFilePath, ); return; } @@ -625,7 +631,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject if (!appResourcesDirStructureHasMigrated) { this.$fs.copyFile( originalAndroidManifestFilePath, - this.getPlatformData(projectData).configurationFilePath + this.getPlatformData(projectData).configurationFilePath, ); } } @@ -633,7 +639,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public prepareAppResources(projectData: IProjectData): void { const platformData = this.getPlatformData(projectData); const projectAppResourcesPath = projectData.getAppResourcesDirectoryPath( - projectData.projectDir + projectData.projectDir, ); const platformsAppResourcesPath = this.getAppResourcesDestinationDirectoryPath(projectData); @@ -644,7 +650,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject const appResourcesDirStructureHasMigrated = this.$androidResourcesMigrationService.hasMigrated( - projectAppResourcesPath + projectAppResourcesPath, ); if (appResourcesDirStructureHasMigrated) { this.$fs.copyFile( @@ -652,18 +658,18 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject projectAppResourcesPath, platformData.normalizedPlatformName, constants.SRC_DIR, - "*" + "*", ), - platformsAppResourcesPath + platformsAppResourcesPath, ); } else { this.$fs.copyFile( path.join( projectAppResourcesPath, platformData.normalizedPlatformName, - "*" + "*", ), - platformsAppResourcesPath + platformsAppResourcesPath, ); // https://github.com/NativeScript/android-runtime/issues/899 // App_Resources/Android/libs is reserved to user's aars and jars, but they should not be copied as resources @@ -680,12 +686,12 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public async preparePluginNativeCode( pluginData: IPluginData, - projectData: IProjectData + projectData: IProjectData, ): Promise { // build Android plugins which contain AndroidManifest.xml and/or resources const pluginPlatformsFolderPath = this.getPluginPlatformsFolderPath( pluginData, - AndroidProjectService.ANDROID_PLATFORM_NAME + AndroidProjectService.ANDROID_PLATFORM_NAME, ); if (this.$fs.exists(pluginPlatformsFolderPath)) { const options: IPluginBuildOptions = { @@ -712,14 +718,14 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public async removePluginNativeCode( pluginData: IPluginData, - projectData: IProjectData + projectData: IProjectData, ): Promise { // not implemented } public async beforePrepareAllPlugins( projectData: IProjectData, - dependencies?: IDependencyData[] + dependencies?: IDependencyData[], ): Promise { if (dependencies) { dependencies = this.filterUniqueDependencies(dependencies); @@ -729,41 +735,44 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public async handleNativeDependenciesChange( projectData: IProjectData, - opts: IRelease + opts: IRelease, ): Promise { return; } private filterUniqueDependencies( - dependencies: IDependencyData[] + dependencies: IDependencyData[], ): IDependencyData[] { - const depsDictionary = dependencies.reduce((dict, dep) => { - const collision = dict[dep.name]; - // in case there are multiple dependencies to the same module, the one declared in the package.json takes precedence - if (!collision || collision.depth > dep.depth) { - dict[dep.name] = dep; - } - return dict; - }, >{}); + const depsDictionary = dependencies.reduce( + (dict, dep) => { + const collision = dict[dep.name]; + // in case there are multiple dependencies to the same module, the one declared in the package.json takes precedence + if (!collision || collision.depth > dep.depth) { + dict[dep.name] = dep; + } + return dict; + }, + >{}, + ); return _.values(depsDictionary); } private provideDependenciesJson( projectData: IProjectData, - dependencies: IDependencyData[] + dependencies: IDependencyData[], ): IDependencyData[] { const platformDir = this.$options.hostProjectPath ? this.$options.hostProjectPath : path.join( projectData.platformsDir, - AndroidProjectService.ANDROID_PLATFORM_NAME - ); + AndroidProjectService.ANDROID_PLATFORM_NAME, + ); const dependenciesJsonPath = path.join( platformDir, - constants.DEPENDENCIES_JSON_NAME + constants.DEPENDENCIES_JSON_NAME, ); - let nativeDependencyData = dependencies.filter( - AndroidProjectService.isNativeAndroidDependency + const nativeDependencyData = dependencies.filter( + AndroidProjectService.isNativeAndroidDependency, ); let nativeDependencies = nativeDependencyData.map( @@ -775,12 +784,12 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject // filter out transient dependencies that don't have native dependencies return ( nativeDependencyData.findIndex( - (nativeDep) => nativeDep.name === dep + (nativeDep) => nativeDep.name === dep, ) !== -1 ); }), } as NativeDependency; - } + }, ); nativeDependencies = topologicalSortNativeDependencies(nativeDependencies); const jsonContent = JSON.stringify(nativeDependencies, null, 4); @@ -812,7 +821,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject cwd: projectRoot, message: "Gradle stop services...", stdio: "pipe", - } + }, ); return result; @@ -826,7 +835,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject public async cleanDeviceTempFolder( deviceIdentifier: string, - projectData: IProjectData + projectData: IProjectData, ): Promise { const adb = this.$injector.resolve(DeviceAndroidDebugBridge, { identifier: deviceIdentifier, @@ -847,7 +856,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject projectRoot: string, frameworkDir: string, files: string, - cpArg: string + cpArg: string, ): void { const paths = files.split(" ").map((p) => path.join(frameworkDir, p)); shell.cp(cpArg, paths, projectRoot); @@ -858,7 +867,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject //Enforce underscore limitation if (!/^[a-zA-Z]+(\.[a-zA-Z0-9][a-zA-Z0-9_]*)+$/.test(packageName)) { this.$errors.fail( - `Package name must look like: com.company.Name. Got: ${packageName}` + `Package name must look like: com.company.Name. Got: ${packageName}`, ); } @@ -880,7 +889,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject } private getLegacyAppResourcesDestinationDirPath( - projectData: IProjectData + projectData: IProjectData, ): string { const resourcePath: string[] = [ this.$options.hostProjectModuleName, @@ -891,12 +900,12 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject return path.join( this.getPlatformData(projectData).projectRoot, - ...resourcePath + ...resourcePath, ); } private getUpdatedAppResourcesDestinationDirPath( - projectData: IProjectData + projectData: IProjectData, ): string { const resourcePath: string[] = [ this.$options.hostProjectModuleName, @@ -905,7 +914,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject return path.join( this.getPlatformData(projectData).projectRoot, - ...resourcePath + ...resourcePath, ); } @@ -925,18 +934,18 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject private cleanUpPreparedResources(projectData: IProjectData): void { let resourcesDirPath = path.join( projectData.appResourcesDirectoryPath, - this.getPlatformData(projectData).normalizedPlatformName + this.getPlatformData(projectData).normalizedPlatformName, ); if ( this.$androidResourcesMigrationService.hasMigrated( - projectData.appResourcesDirectoryPath + projectData.appResourcesDirectoryPath, ) ) { resourcesDirPath = path.join( resourcesDirPath, constants.SRC_DIR, constants.MAIN_DIR, - constants.RESOURCES_DIR + constants.RESOURCES_DIR, ); } @@ -967,7 +976,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject } } catch (e) { this.$logger.trace( - `Failed to track android build statistics. Error is: ${e.message}` + `Failed to track android build statistics. Error is: ${e.message}`, ); } } @@ -976,7 +985,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject const staticsFilePath = path.join( projectRoot, constants.ANDROID_ANALYTICS_DATA_DIR, - constants.ANDROID_ANALYTICS_DATA_FILE + constants.ANDROID_ANALYTICS_DATA_FILE, ); let buildStatistics; @@ -985,7 +994,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject buildStatistics = this.$fs.readJson(staticsFilePath); } catch (e) { this.$logger.trace( - `Unable to read android build statistics file. Error is ${e.message}` + `Unable to read android build statistics file. Error is ${e.message}`, ); } } diff --git a/lib/services/android-resources-migration-service.ts b/lib/services/android-resources-migration-service.ts index 352d6cee44..62725fc43f 100644 --- a/lib/services/android-resources-migration-service.ts +++ b/lib/services/android-resources-migration-service.ts @@ -5,8 +5,7 @@ import { IAndroidResourcesMigrationService } from "../declarations"; import { IFileSystem, IErrors } from "../common/declarations"; import { injector } from "../common/yok"; -export class AndroidResourcesMigrationService - implements IAndroidResourcesMigrationService { +export class AndroidResourcesMigrationService implements IAndroidResourcesMigrationService { private static ANDROID_DIR = "Android"; private static ANDROID_DIR_TEMP = "Android-Updated"; private static ANDROID_DIR_OLD = "Android-Pre-v4"; @@ -15,7 +14,7 @@ export class AndroidResourcesMigrationService private $fs: IFileSystem, private $errors: IErrors, private $logger: ILogger, - private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants + private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, ) {} public canMigrate(platformString: string): boolean { @@ -31,51 +30,51 @@ export class AndroidResourcesMigrationService appResourcesDir, AndroidResourcesMigrationService.ANDROID_DIR, constants.SRC_DIR, - constants.MAIN_DIR - ) + constants.MAIN_DIR, + ), ); } public async migrate( appResourcesDir: string, - backupLocation?: string + backupLocation?: string, ): Promise { const originalAppResources = path.join( appResourcesDir, - AndroidResourcesMigrationService.ANDROID_DIR + AndroidResourcesMigrationService.ANDROID_DIR, ); const appResourcesDestination = path.join( appResourcesDir, - AndroidResourcesMigrationService.ANDROID_DIR_TEMP + AndroidResourcesMigrationService.ANDROID_DIR_TEMP, ); const appResourcesBackup = path.join( backupLocation || appResourcesDir, - AndroidResourcesMigrationService.ANDROID_DIR_OLD + AndroidResourcesMigrationService.ANDROID_DIR_OLD, ); try { await this.tryMigrate( originalAppResources, appResourcesDestination, - appResourcesBackup + appResourcesBackup, ); this.$logger.info( - `Successfully updated your project's application resources '/Android' directory structure.${EOL}The previous version of your Android application resources has been renamed to '/${AndroidResourcesMigrationService.ANDROID_DIR_OLD}'` + `Successfully updated your project's application resources '/Android' directory structure.${EOL}The previous version of your Android application resources has been renamed to '/${AndroidResourcesMigrationService.ANDROID_DIR_OLD}'`, ); } catch (error) { try { this.recover( originalAppResources, appResourcesDestination, - appResourcesBackup + appResourcesBackup, ); this.$logger.info( - "Failed to update resources. They should be in their initial state." + "Failed to update resources. They should be in their initial state.", ); } catch (err) { this.$logger.trace(err); this.$logger.info( - `Failed to update resources.${EOL} Backup of original content is inside "${appResourcesBackup}".${EOL}If "${originalAppResources} is missing copy from backup folder."` + `Failed to update resources.${EOL} Backup of original content is inside "${appResourcesBackup}".${EOL}If "${originalAppResources} is missing copy from backup folder."`, ); } finally { this.$errors.fail(error.message); @@ -86,27 +85,27 @@ export class AndroidResourcesMigrationService private async tryMigrate( originalAppResources: string, appResourcesDestination: string, - appResourcesBackup: string + appResourcesBackup: string, ): Promise { const appMainSourceSet = path.join( appResourcesDestination, constants.SRC_DIR, - constants.MAIN_DIR + constants.MAIN_DIR, ); const appResourcesMainSourceSetResourcesDestination = path.join( appMainSourceSet, - constants.RESOURCES_DIR + constants.RESOURCES_DIR, ); this.$fs.ensureDirectoryExists(appResourcesDestination); this.$fs.ensureDirectoryExists(appMainSourceSet); // create /java, /res and /assets in the App_Resources/Android/src/main directory this.$fs.ensureDirectoryExists( - appResourcesMainSourceSetResourcesDestination + appResourcesMainSourceSetResourcesDestination, ); this.$fs.ensureDirectoryExists(path.join(appMainSourceSet, "java")); this.$fs.ensureDirectoryExists( - path.join(appMainSourceSet, constants.ASSETS_DIR) + path.join(appMainSourceSet, constants.ASSETS_DIR), ); const isDirectory = (source: string) => @@ -119,7 +118,7 @@ export class AndroidResourcesMigrationService this.$fs.copyFile( path.join(originalAppResources, constants.APP_GRADLE_FILE_NAME), - path.join(appResourcesDestination, constants.APP_GRADLE_FILE_NAME) + path.join(appResourcesDestination, constants.APP_GRADLE_FILE_NAME), ); const appResourcesFiles = getAllFiles(originalAppResources); @@ -146,7 +145,7 @@ export class AndroidResourcesMigrationService this.$fs.copyFile( path.join(originalAppResources, constants.MANIFEST_FILE_NAME), - path.join(appMainSourceSet, constants.MANIFEST_FILE_NAME) + path.join(appMainSourceSet, constants.MANIFEST_FILE_NAME), ); // rename the legacy app_resources to ANDROID_DIR_OLD @@ -159,7 +158,7 @@ export class AndroidResourcesMigrationService private recover( originalAppResources: string, appResourcesDestination: string, - appResourcesBackup: string + appResourcesBackup: string, ): void { if (!this.$fs.exists(originalAppResources)) { this.$fs.rename(appResourcesBackup, originalAppResources); @@ -173,5 +172,5 @@ export class AndroidResourcesMigrationService injector.register( "androidResourcesMigrationService", - AndroidResourcesMigrationService + AndroidResourcesMigrationService, ); diff --git a/lib/services/android/gradle-build-args-service.ts b/lib/services/android/gradle-build-args-service.ts index 2d0ce3ddec..e76ad29f16 100644 --- a/lib/services/android/gradle-build-args-service.ts +++ b/lib/services/android/gradle-build-args-service.ts @@ -12,18 +12,18 @@ export class GradleBuildArgsService implements IGradleBuildArgsService { private $analyticsService: IAnalyticsService, private $staticConfig: Config.IStaticConfig, private $projectData: IProjectData, - private $logger: ILogger + private $logger: ILogger, ) {} public async getBuildTaskArgs( - buildData: IAndroidBuildData + buildData: IAndroidBuildData, ): Promise { const args = this.getBaseTaskArgs(buildData); args.unshift(this.getBuildTaskName(buildData)); if ( await this.$analyticsService.isEnabled( - this.$staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME + this.$staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME, ) ) { args.push("-PgatherAnalyticsData=true"); @@ -52,7 +52,7 @@ export class GradleBuildArgsService implements IGradleBuildArgsService { args.push( `-PappPath=${this.$projectData.getAppDirectoryPath()}`, - `-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}` + `-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`, ); if (buildData.gradleArgs) { args.push(buildData.gradleArgs); @@ -64,7 +64,7 @@ export class GradleBuildArgsService implements IGradleBuildArgsService { `-PksPath=${path.resolve(buildData.keyStorePath)}`, `-Palias=${buildData.keyStoreAlias}`, `-Ppassword=${buildData.keyStoreAliasPassword}`, - `-PksPassword=${buildData.keyStorePassword}` + `-PksPassword=${buildData.keyStorePassword}`, ); } diff --git a/lib/services/android/gradle-build-service.ts b/lib/services/android/gradle-build-service.ts index 4ce97ab89a..1cf0545137 100644 --- a/lib/services/android/gradle-build-service.ts +++ b/lib/services/android/gradle-build-service.ts @@ -12,22 +12,22 @@ import { injector } from "../../common/yok"; export class GradleBuildService extends EventEmitter - implements IGradleBuildService { + implements IGradleBuildService +{ constructor( private $childProcess: IChildProcess, private $gradleBuildArgsService: IGradleBuildArgsService, - private $gradleCommandService: IGradleCommandService + private $gradleCommandService: IGradleCommandService, ) { super(); } public async buildProject( projectRoot: string, - buildData: IAndroidBuildData + buildData: IAndroidBuildData, ): Promise { - const buildTaskArgs = await this.$gradleBuildArgsService.getBuildTaskArgs( - buildData - ); + const buildTaskArgs = + await this.$gradleBuildArgsService.getBuildTaskArgs(buildData); const spawnOptions = { emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: true, @@ -46,18 +46,17 @@ export class GradleBuildService (data: any) => this.emit(constants.BUILD_OUTPUT_EVENT_NAME, data), this.$gradleCommandService.executeCommand( buildTaskArgs, - gradleCommandOptions - ) + gradleCommandOptions, + ), ); } public async cleanProject( projectRoot: string, - buildData: IAndroidBuildData + buildData: IAndroidBuildData, ): Promise { - const cleanTaskArgs = this.$gradleBuildArgsService.getCleanTaskArgs( - buildData - ); + const cleanTaskArgs = + this.$gradleBuildArgsService.getCleanTaskArgs(buildData); const gradleCommandOptions = { cwd: projectRoot, message: "Gradle clean...", @@ -65,7 +64,7 @@ export class GradleBuildService }; await this.$gradleCommandService.executeCommand( cleanTaskArgs, - gradleCommandOptions + gradleCommandOptions, ); } } diff --git a/lib/services/android/gradle-command-service.ts b/lib/services/android/gradle-command-service.ts index bca2282bd7..138e57ee09 100644 --- a/lib/services/android/gradle-command-service.ts +++ b/lib/services/android/gradle-command-service.ts @@ -17,12 +17,12 @@ export class GradleCommandService implements IGradleCommandService { private $childProcess: IChildProcess, private $errors: IErrors, private $hostInfo: IHostInfo, - private $logger: ILogger + private $logger: ILogger, ) {} public async executeCommand( gradleArgs: string[], - options: IGradleCommandOptions + options: IGradleCommandOptions, ): Promise { const { message, cwd, stdio, spawnOptions } = options; this.$logger.info(message); @@ -43,7 +43,7 @@ export class GradleCommandService implements IGradleCommandService { gradleExecutable, sanitizedGradleArgs, childProcessOptions, - spawnOptions + spawnOptions, ); return result; @@ -53,7 +53,7 @@ export class GradleCommandService implements IGradleCommandService { gradleExecutable: string, gradleArgs: string[], childProcessOptions: { cwd: string; stdio: string; shell: boolean }, - spawnOptions: ISpawnFromEventOptions + spawnOptions: ISpawnFromEventOptions, ): Promise { try { const result = await this.$childProcess.spawnFromEvent( @@ -61,7 +61,7 @@ export class GradleCommandService implements IGradleCommandService { gradleArgs, "close", childProcessOptions, - spawnOptions + spawnOptions, ); return result; diff --git a/lib/services/apple-portal/apple-portal-application-service.ts b/lib/services/apple-portal/apple-portal-application-service.ts index a274be7ac2..16b9099734 100644 --- a/lib/services/apple-portal/apple-portal-application-service.ts +++ b/lib/services/apple-portal/apple-portal-application-service.ts @@ -9,25 +9,22 @@ import { IApplePortalApplication, } from "./definitions"; -export class ApplePortalApplicationService - implements IApplePortalApplicationService -{ +export class ApplePortalApplicationService implements IApplePortalApplicationService { constructor( private $applePortalSessionService: IApplePortalSessionService, private $errors: IErrors, - private $httpClient: Server.IHttpClient + private $httpClient: Server.IHttpClient, ) {} public async getApplications( - user: IApplePortalUserDetail + user: IApplePortalUserDetail, ): Promise { let result: IApplePortalApplicationSummary[] = []; for (const account of user.associatedAccounts) { const contentProviderId = account.contentProvider.contentProviderId; - const applications = await this.getApplicationsByProvider( - contentProviderId - ); + const applications = + await this.getApplicationsByProvider(contentProviderId); result = result.concat(applications.summaries); } @@ -35,7 +32,7 @@ export class ApplePortalApplicationService } public async getApplicationsByProvider( - contentProviderId: number + contentProviderId: number, ): Promise { const webSessionCookie = await this.$applePortalSessionService.createWebSession(contentProviderId); @@ -43,7 +40,7 @@ export class ApplePortalApplicationService await this.getApplicationsByUrl( webSessionCookie, "https://appstoreconnect.apple.com/iris/v1/apps?include=appStoreVersions", - summaries + summaries, ); return { summaries: summaries }; @@ -52,7 +49,7 @@ export class ApplePortalApplicationService private async getApplicationsByUrl( webSessionCookie: string, url: string, - summaries: IApplePortalApplicationSummary[] + summaries: IApplePortalApplicationSummary[], ): Promise { const response = await this.$httpClient.httpRequest({ url, @@ -66,8 +63,7 @@ export class ApplePortalApplicationService const data = result.data; for (const app of data) { - let summary: IApplePortalApplicationSummary; - summary = { + const summary: IApplePortalApplicationSummary = { bundleId: app.attributes.bundleId, adamId: app.id, name: app.attributes.name, @@ -80,30 +76,30 @@ export class ApplePortalApplicationService await this.getApplicationsByUrl( webSessionCookie, result.links.next, - summaries + summaries, ); } } public async getApplicationByBundleId( user: IApplePortalUserDetail, - bundleId: string + bundleId: string, ): Promise { const applications = await this.getApplications(user); if (!applications || !applications.length) { this.$errors.fail( - `Cannot find any registered applications for Apple ID ${user.userName} in iTunes Connect.` + `Cannot find any registered applications for Apple ID ${user.userName} in iTunes Connect.`, ); } const application = _.find( applications, - (app) => app.bundleId === bundleId + (app) => app.bundleId === bundleId, ); if (!application) { this.$errors.fail( - `Cannot find registered applications that match the specified identifier ${bundleId} in iTunes Connect.` + `Cannot find registered applications that match the specified identifier ${bundleId} in iTunes Connect.`, ); } @@ -112,5 +108,5 @@ export class ApplePortalApplicationService } injector.register( "applePortalApplicationService", - ApplePortalApplicationService + ApplePortalApplicationService, ); diff --git a/lib/services/apple-portal/apple-portal-cookie-service.ts b/lib/services/apple-portal/apple-portal-cookie-service.ts index ac73e660e2..e57bb16c9d 100644 --- a/lib/services/apple-portal/apple-portal-cookie-service.ts +++ b/lib/services/apple-portal/apple-portal-cookie-service.ts @@ -20,12 +20,12 @@ export class ApplePortalCookieService implements IApplePortalCookieService { const parsedCookies = this.parseCookiesData( cookiesData, - this.validWebSessionCookieNames + this.validWebSessionCookieNames, ); _.each( parsedCookies, (parsedCookie) => - (webSessionCookies[parsedCookie.key] = parsedCookie.cookie) + (webSessionCookies[parsedCookie.key] = parsedCookie.cookie), ); return _.values(webSessionCookies).join("; "); @@ -38,18 +38,18 @@ export class ApplePortalCookieService implements IApplePortalCookieService { public updateUserSessionCookie(cookiesData: string[]): void { const parsedCookies = this.parseCookiesData( cookiesData, - this.validUserSessionCookieNames + this.validUserSessionCookieNames, ); _.each( parsedCookies, (parsedCookie) => - (this.userSessionCookies[parsedCookie.key] = parsedCookie.cookie) + (this.userSessionCookies[parsedCookie.key] = parsedCookie.cookie), ); } private parseCookiesData( cookiesData: string[], - validCookieNames: string[] + validCookieNames: string[], ): IDictionary<{ key: string; value: string; cookie: string }> { const result: IDictionary<{ key: string; @@ -65,7 +65,7 @@ export class ApplePortalCookieService implements IApplePortalCookieService { if ( _.includes(validCookieNames, cookieKey) || _.some(validCookieNames, (validCookieName) => - cookieKey.startsWith(validCookieName) + cookieKey.startsWith(validCookieName), ) ) { result[cookieKey] = { diff --git a/lib/services/apple-portal/apple-portal-session-service.ts b/lib/services/apple-portal/apple-portal-session-service.ts index 700ba07465..7c5f17352c 100644 --- a/lib/services/apple-portal/apple-portal-session-service.ts +++ b/lib/services/apple-portal/apple-portal-session-service.ts @@ -26,12 +26,12 @@ export class ApplePortalSessionService implements IApplePortalSessionService { private $errors: IErrors, private $httpClient: Server.IHttpClient, private $logger: ILogger, - private $prompter: IPrompter + private $prompter: IPrompter, ) {} public async createUserSession( credentials: ICredentials, - opts?: IAppleCreateUserSessionOptions + opts?: IAppleCreateUserSessionOptions, ): Promise { const loginResult = await this.login(credentials, opts); @@ -42,7 +42,7 @@ export class ApplePortalSessionService implements IApplePortalSessionService { loginResult.scnt, loginResult.xAppleIdSessionId, authServiceKey, - loginResult.hashcash + loginResult.hashcash, ); } @@ -55,7 +55,7 @@ export class ApplePortalSessionService implements IApplePortalSessionService { }); this.$applePortalCookieService.updateUserSessionCookie( - sessionResponse.headers["set-cookie"] + sessionResponse.headers["set-cookie"], ); } @@ -69,7 +69,7 @@ export class ApplePortalSessionService implements IApplePortalSessionService { }); this.$applePortalCookieService.updateUserSessionCookie( - userDetailsResponse.headers["set-cookie"] + userDetailsResponse.headers["set-cookie"], ); const userdDetails = JSON.parse(userDetailsResponse.body).data; @@ -102,7 +102,7 @@ export class ApplePortalSessionService implements IApplePortalSessionService { }); const webSessionCookie = this.$applePortalCookieService.getWebSessionCookie( - webSessionResponse.headers["set-cookie"] + webSessionResponse.headers["set-cookie"], ); return webSessionCookie; @@ -110,7 +110,7 @@ export class ApplePortalSessionService implements IApplePortalSessionService { private async login( credentials: ICredentials, - opts?: IAppleCreateUserSessionOptions + opts?: IAppleCreateUserSessionOptions, ): Promise { const result = { scnt: null, @@ -122,7 +122,7 @@ export class ApplePortalSessionService implements IApplePortalSessionService { if (opts && opts.sessionBase64) { const decodedSession = Buffer.from(opts.sessionBase64, "base64").toString( - "utf8" + "utf8", ); this.$applePortalCookieService.updateUserSessionCookie([decodedSession]); @@ -201,7 +201,7 @@ For more details how to set up your environment, please execute "ns publish ios const hashcash = await this.fetchHashcash( loginConfig.authServiceUrl, - loginConfig.authServiceKey + loginConfig.authServiceKey, ); const completeUrl = `${loginConfig.authServiceUrl}/auth/signin/complete?isRememberMeEnabled=false`; @@ -222,7 +222,7 @@ For more details how to set up your environment, please execute "ns publish ios }); this.$applePortalCookieService.updateUserSessionCookie( - completeResponse.headers["set-cookie"] + completeResponse.headers["set-cookie"], ); } @@ -240,7 +240,7 @@ For more details how to set up your environment, please execute "ns publish ios config = JSON.parse(response.body); } catch (err) { this.$logger.trace( - `Error while executing request to ${this.loginConfigEndpoint}. More info: ${err}` + `Error while executing request to ${this.loginConfigEndpoint}. More info: ${err}`, ); } @@ -249,7 +249,7 @@ For more details how to set up your environment, please execute "ns publish ios private async fetchHashcash( authServiceUrl: string, - authServiceKey: string + authServiceKey: string, ): Promise { const loginUrl = `${authServiceUrl}/auth/signin?widgetKey=${authServiceKey}`; const response = await this.$httpClient.httpRequest({ @@ -268,7 +268,7 @@ For more details how to set up your environment, please execute "ns publish ios scnt: string, xAppleIdSessionId: string, authServiceKey: string, - hashcash: string + hashcash: string, ): Promise { const headers = { scnt: scnt, @@ -304,7 +304,7 @@ For more details how to set up your environment, please execute "ns publish ios const parsedAuthResponse = JSON.parse(authResponse.body); token = await this.$prompter.getString( `Please enter the ${parsedAuthResponse.securityCode.length} digit code`, - { allowEmpty: false } + { allowEmpty: false }, ); const body: any = { securityCode: { @@ -336,15 +336,15 @@ For more details how to set up your environment, please execute "ns publish ios }); this.$applePortalCookieService.updateUserSessionCookie( - authTrustResponse.headers["set-cookie"] + authTrustResponse.headers["set-cookie"], ); } else if (multiSMS) { this.$errors.fail( - `The NativeScript CLI does not support SMS authenticaton with multiple registered phone numbers.` + `The NativeScript CLI does not support SMS authenticaton with multiple registered phone numbers.`, ); } else { this.$errors.fail( - `Although response from Apple indicated activated Two-step Verification or Two-factor Authentication, NativeScript CLI don't know how to handle this response: ${data}` + `Although response from Apple indicated activated Two-step Verification or Two-factor Authentication, NativeScript CLI don't know how to handle this response: ${data}`, ); } } @@ -375,9 +375,9 @@ function getHashCanDateString(): string { const now = new Date(); return `${now.getFullYear()}${padTo2Digits(now.getMonth() + 1)}${padTo2Digits( - now.getDate() + now.getDate(), )}${padTo2Digits(now.getHours())}${padTo2Digits( - now.getMinutes() + now.getMinutes(), )}${padTo2Digits(now.getSeconds())}`; } function padTo2Digits(num: number) { diff --git a/lib/services/apple-portal/definitions.d.ts b/lib/services/apple-portal/definitions.d.ts index 4efbb0675e..01a1592359 100644 --- a/lib/services/apple-portal/definitions.d.ts +++ b/lib/services/apple-portal/definitions.d.ts @@ -4,7 +4,7 @@ interface IApplePortalSessionService { createWebSession(contentProviderId: number): Promise; createUserSession( credentials: ICredentials, - opts?: IAppleCreateUserSessionOptions + opts?: IAppleCreateUserSessionOptions, ): Promise; } @@ -16,14 +16,14 @@ interface IApplePortalCookieService { interface IApplePortalApplicationService { getApplications( - user: IApplePortalUserDetail + user: IApplePortalUserDetail, ): Promise; getApplicationsByProvider( - contentProviderId: number + contentProviderId: number, ): Promise; getApplicationByBundleId( user: IApplePortalUserDetail, - bundleId: string + bundleId: string, ): Promise; } diff --git a/lib/services/apple-portal/srp/srp-wrapper.ts b/lib/services/apple-portal/srp/srp-wrapper.ts index 993312c1a8..bc6ea3ca1c 100644 --- a/lib/services/apple-portal/srp/srp-wrapper.ts +++ b/lib/services/apple-portal/srp/srp-wrapper.ts @@ -24,7 +24,7 @@ export interface ServerSRPCompleteRequest { trustTokens: string[]; } -let srp = new Srp(Mode.GSA, Hash.SHA256, 2048); +const srp = new Srp(Mode.GSA, Hash.SHA256, 2048); const stringToU8Array = (str: string) => new TextEncoder().encode(str); const base64ToU8Array = (str: string) => Uint8Array.from(Buffer.from(str, "base64")); @@ -41,18 +41,18 @@ export class GSASRPAuthenticator { let passHash = new Uint8Array( await util.hash(srp.h, stringToU8Array(password) as any), ); - if (protocol == "s2k_fo") { + if (protocol === "s2k_fo") { passHash = stringToU8Array(util.toHex(passHash)) as any; } - let imported = await crypto.subtle.importKey( + const imported = await crypto.subtle.importKey( "raw", passHash, { name: "PBKDF2" }, false, ["deriveBits"], ); - let derived = await crypto.subtle.deriveBits( + const derived = await crypto.subtle.deriveBits( { name: "PBKDF2", hash: { name: "SHA-256" }, @@ -73,7 +73,7 @@ export class GSASRPAuthenticator { // provide fake passsword because we need to get data from server new Uint8Array(), ); - let a = Buffer.from(util.bytesFromBigint(this.srpClient.A)).toString( + const a = Buffer.from(util.bytesFromBigint(this.srpClient.A)).toString( "base64", ); return { @@ -89,12 +89,12 @@ export class GSASRPAuthenticator { Pick > { if (!this.srpClient) throw new Error("Not initialized"); - if (serverData.protocol != "s2k" && serverData.protocol != "s2k_fo") + if (serverData.protocol !== "s2k" && serverData.protocol !== "s2k_fo") throw new Error("Unsupported protocol " + serverData.protocol); - let salt = base64ToU8Array(serverData.salt); - let serverPub = base64ToU8Array(serverData.b); - let iterations = serverData.iteration; - let derived = await this.derivePassword( + const salt = base64ToU8Array(serverData.salt); + const serverPub = base64ToU8Array(serverData.b); + const iterations = serverData.iteration; + const derived = await this.derivePassword( serverData.protocol, password, salt, @@ -102,9 +102,9 @@ export class GSASRPAuthenticator { ); this.srpClient.p = derived; await this.srpClient.generate(salt, serverPub); - let m1 = Buffer.from(this.srpClient._M).toString("base64"); - let M2 = await this.srpClient.generateM2(); - let m2 = Buffer.from(M2).toString("base64"); + const m1 = Buffer.from(this.srpClient._M).toString("base64"); + const M2 = await this.srpClient.generateM2(); + const m2 = Buffer.from(M2).toString("base64"); return { accountName: this.username, m1, diff --git a/lib/services/build-artifacts-service.ts b/lib/services/build-artifacts-service.ts index 1a2bfc94af..896056b71c 100644 --- a/lib/services/build-artifacts-service.ts +++ b/lib/services/build-artifacts-service.ts @@ -14,25 +14,25 @@ export class BuildArtifactsService implements IBuildArtifactsService { constructor( private $errors: IErrors, private $fs: IFileSystem, - private $logger: ILogger + private $logger: ILogger, ) {} public async getLatestAppPackagePath( platformData: IPlatformData, - buildOutputOptions: IBuildOutputOptions + buildOutputOptions: IBuildOutputOptions, ): Promise { const outputPath = buildOutputOptions.outputPath || platformData.getBuildOutputPath(buildOutputOptions); const applicationPackage = this.getLatestApplicationPackage( outputPath, - platformData.getValidBuildOutputData(buildOutputOptions) + platformData.getValidBuildOutputData(buildOutputOptions), ); const packageFile = applicationPackage.packageName; if (!packageFile || !this.$fs.exists(packageFile)) { this.$errors.fail( - `Unable to find built application. Try 'ns build ${platformData.platformNameLowerCase}'.` + `Unable to find built application. Try 'ns build ${platformData.platformNameLowerCase}'.`, ); } @@ -41,14 +41,14 @@ export class BuildArtifactsService implements IBuildArtifactsService { public getAllAppPackages( buildOutputPath: string, - validBuildOutputData: IValidBuildOutputData + validBuildOutputData: IValidBuildOutputData, ): IApplicationPackage[] { const rootFiles = this.$fs .readDirectory(buildOutputPath) .map((filename) => path.join(buildOutputPath, filename)); let result = this.getApplicationPackagesCore( rootFiles, - validBuildOutputData.packageNames + validBuildOutputData.packageNames, ); if (result) { return result; @@ -57,7 +57,7 @@ export class BuildArtifactsService implements IBuildArtifactsService { const candidates = this.$fs.enumerateFilesInDirectorySync(buildOutputPath); result = this.getApplicationPackagesCore( candidates, - validBuildOutputData.packageNames + validBuildOutputData.packageNames, ); if (result) { return result; @@ -66,8 +66,8 @@ export class BuildArtifactsService implements IBuildArtifactsService { if (validBuildOutputData.regexes && validBuildOutputData.regexes.length) { const packages = candidates.filter((filepath) => _.some(validBuildOutputData.regexes, (regex) => - regex.test(path.basename(filepath)) - ) + regex.test(path.basename(filepath)), + ), ); return this.createApplicationPackages(packages); } @@ -78,7 +78,7 @@ export class BuildArtifactsService implements IBuildArtifactsService { public copyLatestAppPackage( targetPath: string, platformData: IPlatformData, - buildOutputOptions: IBuildOutputOptions + buildOutputOptions: IBuildOutputOptions, ): void { targetPath = path.resolve(targetPath); @@ -87,7 +87,7 @@ export class BuildArtifactsService implements IBuildArtifactsService { platformData.getBuildOutputPath(buildOutputOptions); const applicationPackage = this.getLatestApplicationPackage( outputPath, - platformData.getValidBuildOutputData(buildOutputOptions) + platformData.getValidBuildOutputData(buildOutputOptions), ); const packageFile = applicationPackage.packageName; @@ -99,7 +99,7 @@ export class BuildArtifactsService implements IBuildArtifactsService { ) { const sourceFileName = path.basename(packageFile); this.$logger.trace( - `Specified target path: '${targetPath}' is directory. Same filename will be used: '${sourceFileName}'.` + `Specified target path: '${targetPath}' is directory. Same filename will be used: '${sourceFileName}'.`, ); targetPath = path.join(targetPath, sourceFileName); } @@ -109,22 +109,22 @@ export class BuildArtifactsService implements IBuildArtifactsService { private getLatestApplicationPackage( buildOutputPath: string, - validBuildOutputData: IValidBuildOutputData + validBuildOutputData: IValidBuildOutputData, ): IApplicationPackage { let packages = this.getAllAppPackages( buildOutputPath, - validBuildOutputData + validBuildOutputData, ); const packageExtName = path.extname(validBuildOutputData.packageNames[0]); if (packages.length === 0) { this.$errors.fail( - `No ${packageExtName} found in ${buildOutputPath} directory.` + `No ${packageExtName} found in ${buildOutputPath} directory.`, ); } if (packages.length > 1) { this.$logger.warn( - `More than one ${packageExtName} found in ${buildOutputPath} directory. Using the last one produced from build.` + `More than one ${packageExtName} found in ${buildOutputPath} directory. Using the last one produced from build.`, ); } @@ -135,10 +135,10 @@ export class BuildArtifactsService implements IBuildArtifactsService { private getApplicationPackagesCore( candidates: string[], - validPackageNames: string[] + validPackageNames: string[], ): IApplicationPackage[] { const packages = candidates.filter((filePath) => - _.includes(validPackageNames, path.basename(filePath)) + _.includes(validPackageNames, path.basename(filePath)), ); if (packages.length > 0) { return this.createApplicationPackages(packages); diff --git a/lib/services/build-info-file-service.ts b/lib/services/build-info-file-service.ts index bdd5a2609b..25edb4070e 100644 --- a/lib/services/build-info-file-service.ts +++ b/lib/services/build-info-file-service.ts @@ -13,12 +13,12 @@ export class BuildInfoFileService implements IBuildInfoFileService { private $devicePathProvider: IDevicePathProvider, private $fs: IFileSystem, private $mobileHelper: Mobile.IMobileHelper, - private $projectChangesService: IProjectChangesService + private $projectChangesService: IProjectChangesService, ) {} public getLocalBuildInfo( platformData: IPlatformData, - buildData: IBuildData + buildData: IBuildData, ): IBuildInfo { const outputPath = buildData.outputPath || platformData.getBuildOutputPath(buildData); @@ -37,17 +37,17 @@ export class BuildInfoFileService implements IBuildInfoFileService { public async getDeviceBuildInfo( device: Mobile.IDevice, - projectData: IProjectData + projectData: IProjectData, ): Promise { const deviceFilePath = await this.getDeviceBuildInfoFilePath( device, - projectData + projectData, ); try { const deviceFileContent = await this.$mobileHelper.getDeviceFileContent( device, deviceFilePath, - projectData + projectData, ); return JSON.parse(deviceFileContent); } catch (e) { @@ -57,13 +57,12 @@ export class BuildInfoFileService implements IBuildInfoFileService { public saveLocalBuildInfo( platformData: IPlatformData, - buildInfoFileDirname: string + buildInfoFileDirname: string, ): void { const buildInfoFile = path.join(buildInfoFileDirname, buildInfoFileName); - const prepareInfo = this.$projectChangesService.getPrepareInfo( - platformData - ); + const prepareInfo = + this.$projectChangesService.getPrepareInfo(platformData); const buildInfo: IBuildInfo = { prepareTime: prepareInfo.changesRequireBuildTime, buildTime: new Date().toString(), @@ -75,11 +74,11 @@ export class BuildInfoFileService implements IBuildInfoFileService { public async saveDeviceBuildInfo( device: Mobile.IDevice, projectData: IProjectData, - outputFilePath: string + outputFilePath: string, ): Promise { const deviceFilePath = await this.getDeviceBuildInfoFilePath( device, - projectData + projectData, ); const appIdentifier = projectData.projectIdentifiers[device.deviceInfo.platform.toLowerCase()]; @@ -87,24 +86,22 @@ export class BuildInfoFileService implements IBuildInfoFileService { await device.fileSystem.putFile( path.join(outputFilePath, buildInfoFileName), deviceFilePath, - appIdentifier + appIdentifier, ); } private async getDeviceBuildInfoFilePath( device: Mobile.IDevice, - projectData: IProjectData + projectData: IProjectData, ): Promise { const platform = device.deviceInfo.platform.toLowerCase(); - const deviceRootPath = await this.$devicePathProvider.getDeviceProjectRootPath( - device, - { + const deviceRootPath = + await this.$devicePathProvider.getDeviceProjectRootPath(device, { appIdentifier: projectData.projectIdentifiers[platform], getDirname: true, - } - ); + }); const result = helpers.fromWindowsRelativePathToUnix( - path.join(deviceRootPath, buildInfoFileName) + path.join(deviceRootPath, buildInfoFileName), ); return result; diff --git a/lib/services/cocoapods-platform-manager.ts b/lib/services/cocoapods-platform-manager.ts index 1d4834b7d7..ea2cc1ff3e 100644 --- a/lib/services/cocoapods-platform-manager.ts +++ b/lib/services/cocoapods-platform-manager.ts @@ -16,25 +16,25 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager { public addPlatformSection( projectData: IProjectData, podfilePlatformData: IPodfilePlatformData, - projectPodfileContent: string + projectPodfileContent: string, ): string { const platformSectionData = this.getPlatformSectionData( - projectPodfileContent + projectPodfileContent, ); if (platformSectionData && platformSectionData.podfilePlatformData) { const shouldReplacePlatformSection = this.shouldReplacePlatformSection( projectData, platformSectionData.podfilePlatformData, - podfilePlatformData + podfilePlatformData, ); if (shouldReplacePlatformSection) { this.$logger.warn( - `Multiple identical platforms with different versions have been detected during the processing of podfiles. The current platform's content "${platformSectionData.podfilePlatformData.content}" from ${platformSectionData.podfilePlatformData.path} will be replaced with "${podfilePlatformData.content}" from ${podfilePlatformData.path}` + `Multiple identical platforms with different versions have been detected during the processing of podfiles. The current platform's content "${platformSectionData.podfilePlatformData.content}" from ${platformSectionData.podfilePlatformData.path} will be replaced with "${podfilePlatformData.content}" from ${podfilePlatformData.path}`, ); const newSection = this.buildPlatformSection(podfilePlatformData); projectPodfileContent = projectPodfileContent.replace( platformSectionData.platformSectionContent, - newSection.trim() + newSection.trim(), ); } } else { @@ -51,10 +51,10 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager { public removePlatformSection( moduleName: string, projectPodfileContent: string, - podfilePath: string + podfilePath: string, ): string { const platformSectionData = this.getPlatformSectionData( - projectPodfileContent + projectPodfileContent, ); if ( platformSectionData && @@ -63,23 +63,22 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager { ) { const podfileContentRegExp = new RegExp( `# Begin Podfile - ([\\s\\S]*?)# End Podfile`, - "mg" + "mg", ); const allPodfiles = projectPodfileContent.match(podfileContentRegExp) || []; - const selectedPlatformData = this.selectPlatformDataFromProjectPodfile( - allPodfiles - ); + const selectedPlatformData = + this.selectPlatformDataFromProjectPodfile(allPodfiles); const newPlatformSection = selectedPlatformData ? this.buildPlatformSection(selectedPlatformData) : ""; const regExp = new RegExp( `${platformSectionData.platformSectionContent}\\r?\\n`, - "mg" + "mg", ); projectPodfileContent = projectPodfileContent.replace( regExp, - newPlatformSection + newPlatformSection, ); } @@ -88,12 +87,12 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager { public replacePlatformRow( podfileContent: string, - podfilePath: string + podfilePath: string, ): { replacedContent: string; podfilePlatformData: IPodfilePlatformData } { let podfilePlatformData: IPodfilePlatformData = null; const platformRowRegExp = new RegExp( `^\\s*?(platform\\b\\s*?\\:\\s*?ios\\b(?:,\\s*?['"](.+)['"])?)`, - "gm" + "gm", ); const replacedContent = podfileContent.replace( platformRowRegExp, @@ -104,21 +103,19 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager { path: podfilePath, }; return `# ${substring.trim()}`; - } + }, ); return { replacedContent, podfilePlatformData }; } - private getPlatformSectionData( - projectPodfileContent: string - ): { + private getPlatformSectionData(projectPodfileContent: string): { podfilePlatformData: IPodfilePlatformData; platformSectionContent: string; } { const platformSectionRegExp = new RegExp( `${this.getPlatformSectionHeader()} ([\\s\\S]*?)with[\\s\\S]*?\\n([\\s\\S]*?(?:,\\s*?['"](.+)['"])?)\\n${this.getPlatformSectionFooter()}`, - "m" + "m", ); const match = platformSectionRegExp.exec(projectPodfileContent); let result = null; @@ -137,14 +134,14 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager { } private selectPlatformDataFromProjectPodfile( - allPodfiles: string[] + allPodfiles: string[], ): IPodfilePlatformData { const platformRowRegExp = new RegExp( `^\\s*?#\\s*?(platform\\b\\s*?\\:\\s*?ios\\b(?:,\\s*?['"](.+)['"])?)`, - "m" + "m", ); const podfilePathRegExp = new RegExp( - `# Begin Podfile - ([\\s\\S]*?)${EOL}` + `# Begin Podfile - ([\\s\\S]*?)${EOL}`, ); let selectedPlatformData: IPodfilePlatformData = null; _.each(allPodfiles, (podfileContent) => { @@ -167,7 +164,7 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager { !selectedPlatformData || semver.gt( semver.coerce(platformMatch[2]), - semver.coerce(selectedPlatformData.version) + semver.coerce(selectedPlatformData.version), ) ) { selectedPlatformData = { @@ -185,7 +182,7 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager { private shouldReplacePlatformSection( projectData: IProjectData, oldPodfilePlatformData: IPodfilePlatformData, - currentPodfilePlatformData: IPodfilePlatformData + currentPodfilePlatformData: IPodfilePlatformData, ): boolean { // The selected platform should be replaced in the following cases: // 1. When the pod file is from App_Resources and the selected platform is not from App_Resources @@ -196,7 +193,7 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager { const appResourcesPodfilePath = path.join( projectData.getAppResourcesDirectoryPath(), "iOS", - PODFILE_NAME + PODFILE_NAME, ); const isFromAppResources = oldPodfilePlatformData.path !== appResourcesPodfilePath && @@ -206,14 +203,14 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager { currentPodfilePlatformData.path === appResourcesPodfilePath && semver.gt( semver.coerce(currentPodfilePlatformData.version), - semver.coerce(oldPodfilePlatformData.version) + semver.coerce(oldPodfilePlatformData.version), ); const isPodfileWithGreaterPlatformVersion = !currentPodfilePlatformData.version || (oldPodfilePlatformData.version && semver.gt( semver.coerce(currentPodfilePlatformData.version), - semver.coerce(oldPodfilePlatformData.version) + semver.coerce(oldPodfilePlatformData.version), )); const result = isFromAppResources || diff --git a/lib/services/cocoapods-service.ts b/lib/services/cocoapods-service.ts index 17e433feae..4a015b97a0 100644 --- a/lib/services/cocoapods-service.ts +++ b/lib/services/cocoapods-service.ts @@ -35,11 +35,11 @@ export class CocoaPodsService implements ICocoaPodsService { private $logger: ILogger, private $config: IConfiguration, private $xcconfigService: IXcconfigService, - private $xcodeSelectService: XcodeSelectService + private $xcodeSelectService: XcodeSelectService, ) { this.getCocoaPodsFromPodfile = _.memoize( this._getCocoaPodsFromPodfile, - getHash + getHash, ); } @@ -57,7 +57,7 @@ export class CocoaPodsService implements ICocoaPodsService { public async executePodInstall( projectRoot: string, - xcodeProjPath: string + xcodeProjPath: string, ): Promise { this.$logger.info("Installing pods..."); let podTool = this.$config.USE_POD_SANDBOX ? "sandbox-pod" : "pod"; @@ -79,7 +79,7 @@ export class CocoaPodsService implements ICocoaPodsService { if (!res.includes("Bad CPU type in executable")) { this.$logger.trace( - "Running on arm64 but pod is installed under rosetta2 - running pod through rosetta2" + "Running on arm64 but pod is installed under rosetta2 - running pod through rosetta2", ); args.unshift(podTool); args.unshift("-x86_64"); @@ -92,7 +92,7 @@ export class CocoaPodsService implements ICocoaPodsService { args, "close", { cwd: projectRoot, stdio: ["pipe", process.stdout, process.stdout] }, - { throwError: false } + { throwError: false }, ); if (podInstallResult.exitCode !== 0) { @@ -113,28 +113,28 @@ ${versionResolutionHint}`); public async mergePodXcconfigFile( projectData: IProjectData, - platformData: IPlatformData + platformData: IPlatformData, ): Promise { const podFilesRootDirName = path.join( "Pods", "Target Support Files", - `Pods-${projectData.projectName}` + `Pods-${projectData.projectName}`, ); const podFolder = path.join(platformData.projectRoot, podFilesRootDirName); if (this.$fs.exists(podFolder)) { const pluginsXcconfigFilePaths = this.$xcconfigService.getPluginsXcconfigFilePaths( - platformData.projectRoot + platformData.projectRoot, ); for (const configuration in pluginsXcconfigFilePaths) { const pluginsXcconfigFilePath = pluginsXcconfigFilePaths[configuration]; const podXcconfigFilePath = path.join( podFolder, - `Pods-${projectData.projectName}.${configuration}.xcconfig` + `Pods-${projectData.projectName}.${configuration}.xcconfig`, ); await this.$xcconfigService.mergeFiles( podXcconfigFilePath, - pluginsXcconfigFilePath + pluginsXcconfigFilePath, ); } } @@ -142,13 +142,13 @@ ${versionResolutionHint}`); public async applyPodfileFromAppResources( projectData: IProjectData, - platformData: IPlatformData + platformData: IPlatformData, ): Promise { const { projectRoot, normalizedPlatformName } = platformData; const mainPodfilePath = path.join( projectData.appResourcesDirectoryPath, normalizedPlatformName, - PODFILE_NAME + PODFILE_NAME, ); const projectPodfilePath = this.getProjectPodfilePath(projectRoot); if ( @@ -159,14 +159,14 @@ ${versionResolutionHint}`); NS_BASE_PODFILE, mainPodfilePath, projectData, - platformData + platformData, ); } } public async applyPodfileArchExclusions( projectData: IProjectData, - platformData: IPlatformData + platformData: IPlatformData, ): Promise { const xcodeVersionData = await this.$xcodeSelectService.getXcodeVersion(); @@ -194,7 +194,7 @@ end`.trim(); "NativeScript-CLI-Architecture-Exclusions", exclusionsPodfile, projectData, - platformData + platformData, ); // clean up @@ -203,15 +203,15 @@ end`.trim(); public async applyPodfileFromExtensions( projectData: IProjectData, - platformData: IPlatformData + platformData: IPlatformData, ) { const extensionFolderPath = path.join( projectData.getAppResourcesDirectoryPath(), constants.iOSAppResourcesFolderName, - constants.NATIVE_EXTENSION_FOLDER + constants.NATIVE_EXTENSION_FOLDER, ); const projectPodfilePath = this.getProjectPodfilePath( - platformData.projectRoot + platformData.projectRoot, ); if ( @@ -235,7 +235,7 @@ end`.trim(); podfilePath: path.join( extensionFolderPath, name, - constants.PODFILE_NAME + constants.PODFILE_NAME, ), })); @@ -244,9 +244,9 @@ end`.trim(); const regExpToRemove = new RegExp( `${this.getExtensionPodfileHeader( podfilePath, - targetName + targetName, )}[\\s\\S]*?${this.getExtensionPodfileEnd()}`, - "mg" + "mg", ); projectPodFileContent = projectPodFileContent.replace(regExpToRemove, ""); @@ -270,7 +270,7 @@ end`.trim(); moduleName: string, podfilePath: string, projectData: IProjectData, - platformData: IPlatformData + platformData: IPlatformData, ): Promise { const nativeProjectPath = platformData.projectRoot; if (!this.$fs.exists(podfilePath)) { @@ -278,7 +278,7 @@ end`.trim(); moduleName, podfilePath, projectData, - nativeProjectPath + nativeProjectPath, ); return; } @@ -288,7 +288,7 @@ end`.trim(); podfilePath, moduleName, projectData, - platformData + platformData, ); const pathToProjectPodfile = this.getProjectPodfilePath(nativeProjectPath); const projectPodfileContent = this.$fs.exists(pathToProjectPodfile) @@ -301,24 +301,24 @@ end`.trim(); moduleName, podfilePath, projectData, - nativeProjectPath + nativeProjectPath, ); let finalPodfileContent = this.$fs.exists(pathToProjectPodfile) ? this.getPodfileContentWithoutTarget( projectData, - this.$fs.readText(pathToProjectPodfile) - ) + this.$fs.readText(pathToProjectPodfile), + ) : ""; if ( podfileContent.indexOf( - CocoaPodsService.PODFILE_POST_INSTALL_SECTION_NAME + CocoaPodsService.PODFILE_POST_INSTALL_SECTION_NAME, ) !== -1 ) { finalPodfileContent = this.addPostInstallHook( replacedFunctions, finalPodfileContent, - podfileContent + podfileContent, ); } @@ -326,7 +326,7 @@ end`.trim(); finalPodfileContent = this.$cocoaPodsPlatformManager.addPlatformSection( projectData, podfilePlatformData, - finalPodfileContent + finalPodfileContent, ); } @@ -334,7 +334,7 @@ end`.trim(); this.saveProjectPodfile( projectData, finalPodfileContent, - nativeProjectPath + nativeProjectPath, ); } } @@ -343,33 +343,33 @@ end`.trim(); moduleName: string, podfilePath: string, projectData: IProjectData, - projectRoot: string + projectRoot: string, ): void { if (this.$fs.exists(this.getProjectPodfilePath(projectRoot))) { let projectPodFileContent = this.$fs.readText( - this.getProjectPodfilePath(projectRoot) + this.getProjectPodfilePath(projectRoot), ); // Remove the data between #Begin Podfile and #EndPodfile const regExpToRemove = new RegExp( `${this.getPluginPodfileHeader( - podfilePath + podfilePath, )}[\\s\\S]*?${this.getPluginPodfileEnd()}`, - "mg" + "mg", ); projectPodFileContent = projectPodFileContent.replace(regExpToRemove, ""); projectPodFileContent = this.removePostInstallHook( moduleName, - projectPodFileContent + projectPodFileContent, ); projectPodFileContent = this.$cocoaPodsPlatformManager.removePlatformSection( moduleName, projectPodFileContent, - podfilePath + podfilePath, ); const defaultPodfileBeginning = this.getPodfileHeader( - projectData.projectName + projectData.projectName, ); const defaultContentWithPostInstallHook = `${defaultPodfileBeginning}${this.getPostInstallHookHeader()}end${EOL}end`; const defaultContentWithoutPostInstallHook = `${defaultPodfileBeginning}${EOL}end`; @@ -383,7 +383,7 @@ end`.trim(); } else { this.$fs.writeFile( this.getProjectPodfilePath(projectRoot), - projectPodFileContent + projectPodFileContent, ); } } @@ -391,11 +391,11 @@ end`.trim(); public getPluginPodfilePath(pluginData: IPluginData): string { const pluginPlatformsFolderPath = pluginData.pluginPlatformsFolderPath( - PlatformTypes.ios + PlatformTypes.ios, ); const pluginPodFilePath = path.join( pluginPlatformsFolderPath, - PODFILE_NAME + PODFILE_NAME, ); return pluginPodFilePath; } @@ -403,7 +403,7 @@ end`.trim(); private addPostInstallHook( replacedFunctions: IRubyFunction[], finalPodfileContent: string, - pluginPodfileContent: string + pluginPodfileContent: string, ): string { const postInstallHookStart = this.getPostInstallHookHeader(); let postInstallHookContent = ""; @@ -424,11 +424,11 @@ end`.trim(); if (index !== -1) { const regExp = new RegExp( `(${regExpEscape(postInstallHookStart)}[\\s\\S]*?)(\\bend\\b)`, - "m" + "m", ); finalPodfileContent = finalPodfileContent.replace( regExp, - `$1${postInstallHookContent.trimRight()}${EOL}$2` + `$1${postInstallHookContent.trimRight()}${EOL}$2`, ); } else { if (finalPodfileContent.length > 0) { @@ -444,13 +444,13 @@ end`.trim(); private getPodfileContentWithoutTarget( projectData: IProjectData, - projectPodfileContent: string + projectPodfileContent: string, ): string { const podFileHeader = this.getPodfileHeader(projectData.projectName); if (_.startsWith(projectPodfileContent, podFileHeader)) { projectPodfileContent = projectPodfileContent.substr( - podFileHeader.length + podFileHeader.length, ); const podFileFooter = this.getPodfileFooter(); @@ -458,7 +458,7 @@ end`.trim(); if (_.endsWith(projectPodfileContent, podFileFooter)) { projectPodfileContent = projectPodfileContent.substr( 0, - projectPodfileContent.length - podFileFooter.length + projectPodfileContent.length - podFileFooter.length, ); } } @@ -469,11 +469,11 @@ end`.trim(); private saveProjectPodfile( projectData: IProjectData, projectPodfileContent: string, - projectRoot: string + projectRoot: string, ): void { projectPodfileContent = this.getPodfileContentWithoutTarget( projectData, - projectPodfileContent + projectPodfileContent, ); const podFileHeader = this.getPodfileHeader(projectData.projectName); const podFileFooter = this.getPodfileFooter(); @@ -484,14 +484,14 @@ end`.trim(); private removePostInstallHook( moduleName: string, - projectPodFileContent: string + projectPodFileContent: string, ): string { const regExp = new RegExp( `^.*?${this.getHookBasicFuncNameForPlugin( CocoaPodsService.PODFILE_POST_INSTALL_SECTION_NAME, - moduleName + moduleName, )}.*?$\\r?\\n`, - "gm" + "gm", ); projectPodFileContent = projectPodFileContent.replace(regExp, ""); return projectPodFileContent; @@ -499,7 +499,7 @@ end`.trim(); private getHookBasicFuncNameForPlugin( hookName: string, - pluginName: string + pluginName: string, ): string { // nativescript-hook and nativescript_hook should have different names, so replace all _ with ___ first and then replace all special symbols with _ // This will lead to a clash in case plugins are called nativescript-hook and nativescript___hook @@ -512,13 +512,13 @@ end`.trim(); private replaceHookContent( hookName: string, podfileContent: string, - pluginName: string + pluginName: string, ): { replacedContent: string; newFunctions: IRubyFunction[] } { const hookStart = `${hookName} do`; const hookDefinitionRegExp = new RegExp( `${hookStart} *(\\|(\\w+)\\|)?`, - "g" + "g", ); const newFunctions: IRubyFunction[] = []; @@ -528,11 +528,11 @@ end`.trim(); substring: string, firstGroup: string, secondGroup: string, - index: number + index: number, ): string => { const newFunctionName = `${this.getHookBasicFuncNameForPlugin( hookName, - pluginName + pluginName, )}_${newFunctions.length}`; let newDefinition = `def ${newFunctionName}`; @@ -545,7 +545,7 @@ end`.trim(); newFunctions.push(rubyFunction); return newDefinition; - } + }, ); return { replacedContent, newFunctions }; @@ -563,11 +563,11 @@ end`.trim(); private getExtensionPodfileHeader( extensionPodFilePath: string, - targetName: string + targetName: string, ): string { const targetHeader = `target "${targetName.trim()}" do`; return `${this.getPluginPodfileHeader( - extensionPodFilePath + extensionPodFilePath, )}${EOL}${targetHeader}`; } @@ -583,7 +583,7 @@ end`.trim(); pluginPodFilePath: string, pluginName: string, projectData: IProjectData, - platformData: IPlatformData + platformData: IPlatformData, ): { podfileContent: string; replacedFunctions: IRubyFunction[]; @@ -593,11 +593,11 @@ end`.trim(); const data = this.replaceHookContent( CocoaPodsService.PODFILE_POST_INSTALL_SECTION_NAME, pluginPodfileContent, - pluginName + pluginName, ); const cocoapodsData = this.$cocoaPodsPlatformManager.replacePlatformRow( data.replacedContent, - pluginPodFilePath + pluginPodFilePath, ); const podfilePlatformData = cocoapodsData.podfilePlatformData; let replacedContent = cocoapodsData.replacedContent; @@ -610,13 +610,13 @@ end`.trim(); replacedContent = this.overridePodsFromFile( replacedContent, projectData, - platformData + platformData, ); } return { podfileContent: `${this.getPluginPodfileHeader( - pluginPodFilePath + pluginPodFilePath, )}${EOL}${replacedContent}${EOL}${this.getPluginPodfileEnd()}`, replacedFunctions: data.newFunctions, podfilePlatformData, @@ -625,19 +625,19 @@ end`.trim(); private getMainPodFilePath( projectData: IProjectData, - platformData: IPlatformData + platformData: IPlatformData, ): string { return path.join( projectData.appResourcesDirectoryPath, platformData.normalizedPlatformName, - PODFILE_NAME + PODFILE_NAME, ); } private isMainPodFile( podFilePath: string, projectData: IProjectData, - platformData: IPlatformData + platformData: IPlatformData, ): boolean { const mainPodfilePath = this.getMainPodFilePath(projectData, platformData); @@ -647,7 +647,7 @@ end`.trim(); private overridePodsFromFile( podfileContent: string, projectData: IProjectData, - platformData: IPlatformData + platformData: IPlatformData, ): string { const mainPodfilePath = this.getMainPodFilePath(projectData, platformData); @@ -657,7 +657,7 @@ end`.trim(); _.forEach(pods, (pod) => { podfileContent = podfileContent.replace( new RegExp(`^[ ]*pod\\s*["']${pod}['"].*$`, "gm"), - "#$&" + "#$&", ); }); } diff --git a/lib/services/debug-data-service.ts b/lib/services/debug-data-service.ts index 14ef2c626a..980c26fa5f 100644 --- a/lib/services/debug-data-service.ts +++ b/lib/services/debug-data-service.ts @@ -12,7 +12,7 @@ export class DebugDataService implements IDebugDataService { public getDebugData( deviceIdentifier: string, projectData: IProjectData, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): IDebugData { const device = this.$devicesService.getDeviceByIdentifier(deviceIdentifier); diff --git a/lib/services/device/device-install-app-service.ts b/lib/services/device/device-install-app-service.ts index 4c5d16b6f3..b520b1bc33 100644 --- a/lib/services/device/device-install-app-service.ts +++ b/lib/services/device/device-install-app-service.ts @@ -23,25 +23,25 @@ export class DeviceInstallAppService { private $logger: ILogger, private $mobileHelper: Mobile.IMobileHelper, private $projectDataService: IProjectDataService, - private $platformsDataService: IPlatformsDataService + private $platformsDataService: IPlatformsDataService, ) {} public async installOnDevice( device: Mobile.IDevice, buildData: IBuildData, - packageFile?: string + packageFile?: string, ): Promise { this.$logger.info( - `Installing on device ${device.deviceInfo.identifier}...` + `Installing on device ${device.deviceInfo.identifier}...`, ); const platform = device.deviceInfo.platform.toLowerCase(); const projectData = this.$projectDataService.getProjectData( - buildData.projectDir + buildData.projectDir, ); const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); await this.$analyticsService.trackEventActionInGoogleAnalytics({ @@ -53,13 +53,13 @@ export class DeviceInstallAppService { if (!packageFile) { packageFile = await this.$buildArtifactsService.getLatestAppPackagePath( platformData, - buildData + buildData, ); } await platformData.platformProjectService.cleanDeviceTempFolder( device.deviceInfo.identifier, - projectData + projectData, ); const appIdentifier = projectData.projectIdentifiers[platform]; @@ -69,7 +69,7 @@ export class DeviceInstallAppService { await device.applicationManager.reinstallApplication( appIdentifier, packageFile, - buildData + buildData, ); await this.updateHashesOnDevice({ @@ -83,19 +83,19 @@ export class DeviceInstallAppService { await this.$buildInfoFileService.saveDeviceBuildInfo( device, projectData, - outputFilePath + outputFilePath, ); } this.$logger.info( - `Successfully installed on device with identifier '${device.deviceInfo.identifier}'.` + `Successfully installed on device with identifier '${device.deviceInfo.identifier}'.`, ); } public async installOnDeviceIfNeeded( device: Mobile.IDevice, buildData: IBuildData, - packageFile?: string + packageFile?: string, ): Promise { const shouldInstall = await this.shouldInstall(device, buildData); if (shouldInstall) { @@ -105,31 +105,29 @@ export class DeviceInstallAppService { public async shouldInstall( device: Mobile.IDevice, - buildData: IBuildData + buildData: IBuildData, ): Promise { const projectData = this.$projectDataService.getProjectData( - buildData.projectDir + buildData.projectDir, ); const platformData = this.$platformsDataService.getPlatformData( device.deviceInfo.platform, - projectData + projectData, ); const platform = device.deviceInfo.platform; if ( !(await device.applicationManager.isApplicationInstalled( - projectData.projectIdentifiers[platform.toLowerCase()] + projectData.projectIdentifiers[platform.toLowerCase()], )) ) { return true; } - const deviceBuildInfo: IBuildInfo = await this.$buildInfoFileService.getDeviceBuildInfo( - device, - projectData - ); + const deviceBuildInfo: IBuildInfo = + await this.$buildInfoFileService.getDeviceBuildInfo(device, projectData); const localBuildInfo = this.$buildInfoFileService.getLocalBuildInfo( platformData, - { ...buildData, buildForDevice: !device.isEmulator } + { ...buildData, buildForDevice: !device.isEmulator }, ); return ( diff --git a/lib/services/doctor-service.ts b/lib/services/doctor-service.ts index 4ff1d3e003..2c6c395501 100644 --- a/lib/services/doctor-service.ts +++ b/lib/services/doctor-service.ts @@ -329,7 +329,7 @@ export class DoctorServiceImpl // import * as text from "text"; // import { a } from "text"; // import {a } from "text/abc" - const subDirPart = `[\"\']${c}[\"\'/]`; + const subDirPart = `["\']${c}["\'/]`; return `(\\brequire\\s*?\\(\\s*?${subDirPart})|(\\bimport\\b.*?from\\s*?${subDirPart})`; }); diff --git a/lib/services/files-hash-service.ts b/lib/services/files-hash-service.ts index b19fd690da..7fe20a9a55 100644 --- a/lib/services/files-hash-service.ts +++ b/lib/services/files-hash-service.ts @@ -13,7 +13,7 @@ export class FilesHashService implements IFilesHashService { constructor( private $fs: IFileSystem, private $logger: ILogger, - private $options: IOptions + private $options: IOptions, ) {} public async generateHashes(files: string[]): Promise { @@ -27,7 +27,7 @@ export class FilesHashService implements IFilesHashService { } } catch (err) { this.$logger.trace( - `Unable to generate hash for file ${file}. Error is: ${err}` + `Unable to generate hash for file ${file}. Error is: ${err}`, ); } }; @@ -38,11 +38,11 @@ export class FilesHashService implements IFilesHashService { } public async generateHashesForProject( - platformData: IPlatformData + platformData: IPlatformData, ): Promise { const appFilesPath = path.join( platformData.appDestinationDirectoryPath, - this.$options.hostProjectModuleName + this.$options.hostProjectModuleName, ); const files = this.$fs.enumerateFilesInDirectorySync(appFilesPath); const hashes = await this.generateHashes(files); @@ -51,7 +51,7 @@ export class FilesHashService implements IFilesHashService { public async saveHashesForProject( platformData: IPlatformData, - hashesFileDirectory: string + hashesFileDirectory: string, ): Promise { const hashes = await this.generateHashesForProject(platformData); this.saveHashes(hashes, hashesFileDirectory); @@ -60,7 +60,7 @@ export class FilesHashService implements IFilesHashService { public async getChanges( files: string[], - oldHashes: IStringDictionary + oldHashes: IStringDictionary, ): Promise { const newHashes = await this.generateHashes(files); return this.getChangesInShasums(oldHashes, newHashes); @@ -68,14 +68,14 @@ export class FilesHashService implements IFilesHashService { public hasChangesInShasums( oldHashes: IStringDictionary, - newHashes: IStringDictionary + newHashes: IStringDictionary, ): boolean { return !!_.keys(this.getChangesInShasums(oldHashes, newHashes)).length; } public saveHashes( hashes: IStringDictionary, - hashesFileDirectory: string + hashesFileDirectory: string, ): void { const hashesFilePath = path.join(hashesFileDirectory, HASHES_FILE_NAME); this.$fs.writeJson(hashesFilePath, hashes); @@ -83,17 +83,17 @@ export class FilesHashService implements IFilesHashService { public getChangesInShasums( oldHashes: IStringDictionary, - newHashes: IStringDictionary + newHashes: IStringDictionary, ): IStringDictionary { const addedFileHashes = _.omitBy( newHashes, (hash: string, pathToFile: string) => - !!oldHashes[pathToFile] && oldHashes[pathToFile] === hash + !!oldHashes[pathToFile] && oldHashes[pathToFile] === hash, ); const removedFileHashes = _.omitBy( oldHashes, (hash: string, pathToFile: string) => - !!newHashes[pathToFile] && newHashes[pathToFile] === hash + !!newHashes[pathToFile] && newHashes[pathToFile] === hash, ); const result = {}; _.extend(result, addedFileHashes, removedFileHashes); diff --git a/lib/services/hmr-status-service.ts b/lib/services/hmr-status-service.ts index 288dcabd86..5dc2bf6fd6 100644 --- a/lib/services/hmr-status-service.ts +++ b/lib/services/hmr-status-service.ts @@ -18,12 +18,12 @@ export class HmrStatusService implements IHmrStatusService { constructor( private $logParserService: ILogParserService, private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, - private $logger: ILogger + private $logger: ILogger, ) {} public getHmrStatus( deviceId: string, - operationHash: string + operationHash: string, ): Promise { return new Promise((resolve, reject) => { const key = `${deviceId}${operationHash}`; @@ -95,7 +95,7 @@ export class HmrStatusService implements IHmrStatusService { private handleHmrStatusFound( matches: RegExpMatchArray, - deviceId: string + deviceId: string, ): void { const message = matches[1].trim(); const hash = matches[2]; @@ -134,7 +134,7 @@ export class HmrStatusService implements IHmrStatusService { private setData( deviceId: string, operationHash: string, - status?: Number + status?: number, ): void { const key = `${deviceId}${operationHash}`; diff --git a/lib/services/ios-device-debug-service.ts b/lib/services/ios-device-debug-service.ts index bd9dea0ccd..7aa43b7f71 100644 --- a/lib/services/ios-device-debug-service.ts +++ b/lib/services/ios-device-debug-service.ts @@ -26,7 +26,8 @@ import { injector } from "../common/yok"; export class IOSDeviceDebugService extends DebugServiceBase - implements IDeviceDebugService { + implements IDeviceDebugService +{ private deviceIdentifier: string; constructor( @@ -38,12 +39,12 @@ export class IOSDeviceDebugService private $errors: IErrors, private $packageInstallationManager: IPackageInstallationManager, private $appDebugSocketProxyFactory: IAppDebugSocketProxyFactory, - private $projectDataService: IProjectDataService + private $projectDataService: IProjectDataService, ) { super(device, $devicesService); this.$appDebugSocketProxyFactory.on( CONNECTION_ERROR_EVENT_NAME, - (e: Error) => this.emit(CONNECTION_ERROR_EVENT_NAME, e) + (e: Error) => this.emit(CONNECTION_ERROR_EVENT_NAME, e), ); this.deviceIdentifier = this.device.deviceInfo.identifier; } @@ -55,7 +56,7 @@ export class IOSDeviceDebugService @performanceLog() public async debug( debugData: IDebugData, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): Promise { await this.validateOptions(debugOptions); const result: IDebugResultInfo = { debugUrl: null }; @@ -72,13 +73,13 @@ export class IOSDeviceDebugService private async validateOptions(debugOptions: IDebugOptions) { if (!this.$hostInfo.isWindows && !this.$hostInfo.isDarwin) { this.$errors.fail( - `Debugging on iOS devices is not supported for ${platform()} yet.` + `Debugging on iOS devices is not supported for ${platform()} yet.`, ); } if (debugOptions.debugBrk && debugOptions.start) { this.$errors.fail( - "Expected exactly one of the --debug-brk or --start options." + "Expected exactly one of the --debug-brk or --start options.", ); } @@ -97,7 +98,7 @@ export class IOSDeviceDebugService .map((type) => DeviceConnectionType[type]) .join(", "); this.$errors.fail( - `Debugging application requires a USB or LOCAL connection while the target device "${this.deviceIdentifier}" has connection type "${deviceConnectionTypes}".` + `Debugging application requires a USB or LOCAL connection while the target device "${this.deviceIdentifier}" has connection type "${deviceConnectionTypes}".`, ); } } @@ -106,7 +107,7 @@ export class IOSDeviceDebugService let projectName = debugData.projectName; if (!projectName && debugData.projectDir) { const projectData = this.$projectDataService.getProjectData( - debugData.projectDir + debugData.projectDir, ); projectName = projectData.projectName; } @@ -126,7 +127,7 @@ export class IOSDeviceDebugService @performanceLog() private async wireDebuggerClient( debugData: IDebugData, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): Promise { if ( (debugOptions.inspector || !debugOptions.client) && @@ -140,32 +141,33 @@ export class IOSDeviceDebugService private async setupWebAppDebugProxy( debugOptions: IDebugOptions, - debugData: IDebugData + debugData: IDebugData, ): Promise { if (debugOptions.chrome) { this.$logger.info( - "'--chrome' is the default behavior. Use --inspector to debug iOS applications using the Safari Web Inspector." + "'--chrome' is the default behavior. Use --inspector to debug iOS applications using the Safari Web Inspector.", ); } const projectName = this.getProjectName(debugData); - const webSocketProxy = await this.$appDebugSocketProxyFactory.ensureWebSocketProxy( - this.device, - debugData.applicationIdentifier, - projectName, - debugData.projectDir - ); + const webSocketProxy = + await this.$appDebugSocketProxyFactory.ensureWebSocketProxy( + this.device, + debugData.applicationIdentifier, + projectName, + debugData.projectDir, + ); return this.getChromeDebugUrl(debugOptions, webSocketProxy.options.port); } private async setupTcpAppDebugProxy( debugData: IDebugData, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): Promise { const projectName = this.getProjectName(debugData); const existingTcpProxy = this.$appDebugSocketProxyFactory.getTCPSocketProxy( this.deviceIdentifier, - debugData.applicationIdentifier + debugData.applicationIdentifier, ); const tcpSocketProxy = existingTcpProxy || @@ -173,13 +175,13 @@ export class IOSDeviceDebugService this.device, debugData.applicationIdentifier, projectName, - debugData.projectDir + debugData.projectDir, )); if (!existingTcpProxy) { const inspectorProcess = await this.openAppInspector( tcpSocketProxy.address(), debugData, - debugOptions + debugOptions, ); if (inspectorProcess) { tcpSocketProxy.on("close", async () => { @@ -195,18 +197,19 @@ export class IOSDeviceDebugService private async openAppInspector( fileDescriptor: string, debugData: IDebugData, - debugOptions: IDebugOptions + debugOptions: IDebugOptions, ): Promise { if (debugOptions.client) { - const inspectorPath = await this.$packageInstallationManager.getInspectorFromCache( - inspectorNpmPackageName, - debugData.projectDir - ); + const inspectorPath = + await this.$packageInstallationManager.getInspectorFromCache( + inspectorNpmPackageName, + debugData.projectDir, + ); const inspectorSourceLocation = path.join( inspectorPath, inspectorUiDir, - "Main.html" + "Main.html", ); const inspectorApplicationPath = path.join( inspectorPath, @@ -216,12 +219,12 @@ export class IOSDeviceDebugService inspectorAppName, "Contents", "MacOS", - "NativeScript Inspector" + "NativeScript Inspector", ); const inspectorProcess: ChildProcess = this.$childProcess.spawn( inspectorApplicationPath, - [inspectorSourceLocation, debugData.projectName, fileDescriptor] + [inspectorSourceLocation, debugData.projectName, fileDescriptor], ); inspectorProcess.on("error", (e: Error) => this.$logger.trace(e)); return inspectorProcess; diff --git a/lib/services/ios-extensions-service.ts b/lib/services/ios-extensions-service.ts index 5818dc1543..388de9c0ff 100644 --- a/lib/services/ios-extensions-service.ts +++ b/lib/services/ios-extensions-service.ts @@ -18,7 +18,7 @@ export class IOSExtensionsService implements IIOSExtensionsService { protected $fs: IFileSystem, protected $pbxprojDomXcode: IPbxprojDomXcode, protected $xcode: IXcode, - private $iOSNativeTargetService: IIOSNativeTargetService + private $iOSNativeTargetService: IIOSNativeTargetService, ) {} public async addExtensionsFromPath({ @@ -42,14 +42,14 @@ export class IOSExtensionsService implements IIOSExtensionsService { extensionFolder, IOSNativeTargetTypes.appExtension, project, - platformData + platformData, ); this.configureTarget( extensionFolder, path.join(extensionsFolderPath, extensionFolder), target, project, - projectData + projectData, ); targetUuids.push(target.uuid); addedExtensions = true; @@ -57,12 +57,12 @@ export class IOSExtensionsService implements IIOSExtensionsService { this.$fs.writeFile( pbxProjPath, - project.writeSync({ omitEmptyValues: true }) + project.writeSync({ omitEmptyValues: true }), ); this.$iOSNativeTargetService.prepareSigning( targetUuids, projectData, - pbxProjPath + pbxProjPath, ); return addedExtensions; @@ -73,7 +73,7 @@ export class IOSExtensionsService implements IIOSExtensionsService { extensionPath: string, target: IXcode.target, project: IXcode.project, - projectData: IProjectData + projectData: IProjectData, ) { const extJsonPath = path.join(extensionPath, "extension.json"); @@ -85,14 +85,14 @@ export class IOSExtensionsService implements IIOSExtensionsService { }, ], extensionName, - project + project, ); this.$iOSNativeTargetService.setConfigurationsFromJsonFile( extJsonPath, target.uuid, extensionName, - project + project, ); } @@ -100,11 +100,11 @@ export class IOSExtensionsService implements IIOSExtensionsService { const project = new this.$xcode.project(pbxProjPath); project.parseSync(); project.removeTargetsByProductType( - IOSNativeTargetProductTypes.appExtension + IOSNativeTargetProductTypes.appExtension, ); this.$fs.writeFile( pbxProjPath, - project.writeSync({ omitEmptyValues: true }) + project.writeSync({ omitEmptyValues: true }), ); } } diff --git a/lib/services/ios-log-filter.ts b/lib/services/ios-log-filter.ts index 04f58146dc..4496e2ad83 100644 --- a/lib/services/ios-log-filter.ts +++ b/lib/services/ios-log-filter.ts @@ -3,14 +3,14 @@ import { injector } from "../common/yok"; export class IOSLogFilter implements Mobile.IPlatformLogFilter { // Used to recognize output related to the current project // This looks for artifacts like: AppName[22432] or AppName(SomeTextHere)[23123] - private appOutputRegex: RegExp = /([^\s\(\)]+)(?:\(([^\s]+)\))?\[[0-9]+\]/; + private appOutputRegex: RegExp = /([^\s(\)]+)(?:\(([^\s]+)\))?\[[0-9]+\]/; // Used to trim the passed messages to a simpler output // Example: // This: "May 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] : CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE:" // Becomes: CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:3477:36: ORIGINAL STACKTRACE: protected infoFilterRegex = new RegExp( - `^.*(?::[ \t]?|:[ \t]?|:[ \t]?|\\(NativeScript\\)[ \t]?|${this.appOutputRegex.source}:[ \t]?){1}` + `^.*(?::[ \t]?|:[ \t]?|:[ \t]?|\\(NativeScript\\)[ \t]?|${this.appOutputRegex.source}:[ \t]?){1}`, ); // Used to post filter messages that slip through but are not coming from NativeScript itself. @@ -29,7 +29,7 @@ export class IOSLogFilter implements Mobile.IPlatformLogFilter { public filterData( data: string, - loggingOptions: Mobile.IDeviceLogOptions = {} + loggingOptions: Mobile.IDeviceLogOptions = {}, ): string { const specifiedLogLevel = (loggingOptions.logLevel || "").toUpperCase(); diff --git a/lib/services/ios-native-target-service.ts b/lib/services/ios-native-target-service.ts index 7f961f554a..8e82fe25e8 100644 --- a/lib/services/ios-native-target-service.ts +++ b/lib/services/ios-native-target-service.ts @@ -156,7 +156,7 @@ export class IOSNativeTargetService implements IIOSNativeTargetService { _.forEach( configurationJson.targetNamedBuildConfigurationProperties, (value, name: string) => { - var buildName: BuildNames = null; + let buildName: BuildNames = null; switch (name) { case "debug": { buildName = BuildNames.debug; diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 1c536a0a62..e945c4c435 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -1115,7 +1115,7 @@ export class IOSProjectService name = name.substr(1, name.length - 2); } - return name.replace(/\\\"/g, '"'); + return name.replace(/\\"/g, '"'); } private getLibSubpathRelativeToProjectPath( @@ -1135,7 +1135,7 @@ export class IOSProjectService private getPbxProjPath(projectData: IProjectData): string { if (this.$options.hostProjectPath) { - let xcodeProjectPath = this.$xcprojService.findXcodeProject( + const xcodeProjectPath = this.$xcprojService.findXcodeProject( this.$options.hostProjectPath, ); if (!xcodeProjectPath) { diff --git a/lib/services/ios-provision-service.ts b/lib/services/ios-provision-service.ts index 745243e388..76151342b7 100644 --- a/lib/services/ios-provision-service.ts +++ b/lib/services/ios-provision-service.ts @@ -27,12 +27,12 @@ export class IOSProvisionService { private $logger: ILogger, private $options: IOptions, private $devicesService: Mobile.IDevicesService, - private $mobileHelper: Mobile.IMobileHelper + private $mobileHelper: Mobile.IMobileHelper, ) {} public async pick( uuidOrName: string, - projectId: string + projectId: string, ): Promise { const match = (await this.queryProvisioningProfilesAndDevices(projectId)) .match; @@ -50,12 +50,12 @@ export class IOSProvisionService { const match = data.match; function formatSupportedDeviceCount( - prov: mobileprovision.provision.MobileProvision + prov: mobileprovision.provision.MobileProvision, ) { if (devices.length > 0 && prov.Type === "Development") { return ( prov.ProvisionedDevices.filter( - (device) => devices.indexOf(device) >= 0 + (device) => devices.indexOf(device) >= 0, ).length + "/" + devices.length + @@ -67,7 +67,7 @@ export class IOSProvisionService { } function formatTotalDeviceCount( - prov: mobileprovision.provision.MobileProvision + prov: mobileprovision.provision.MobileProvision, ) { if (prov.Type === "Development" && prov.ProvisionedDevices) { return prov.ProvisionedDevices.length + " total"; @@ -85,7 +85,7 @@ export class IOSProvisionService { "Type / Due", "Devices", ], - [] + [], ); function pushProvision(prov: mobileprovision.provision.MobileProvision) { @@ -113,7 +113,7 @@ export class IOSProvisionService { this.$logger.info( "There are also " + match.nonEligible.length + - " non-eligible provisioning profiles." + " non-eligible provisioning profiles.", ); this.$logger.info(); } @@ -122,13 +122,13 @@ export class IOSProvisionService { const teams = await this.getDevelopmentTeams(); const table = createTable( ["Team Name", "Team ID"], - teams.map((team) => [quoteString(team.name), team.id]) + teams.map((team) => [quoteString(team.name), team.id]), ); this.$logger.info(table.toString()); } private async queryProvisioningProfilesAndDevices( - projectId: string + projectId: string, ): Promise<{ devices: string[]; match: mobileprovision.provision.Result }> { const certificates = mobileprovision.cert.read(); const provisions = mobileprovision.provision.read(); @@ -170,7 +170,7 @@ export class IOSProvisionService { teams[provision.TeamName] = new Set(); } teams[provision.TeamName].add(id); - }) + }), ); const teamsArray = Object.keys(teams).reduce((arr, name) => { teams[name].forEach((id) => arr.push({ id, name })); diff --git a/lib/services/ios-watch-app-service.ts b/lib/services/ios-watch-app-service.ts index e6112d4cf5..099fbe4e4e 100644 --- a/lib/services/ios-watch-app-service.ts +++ b/lib/services/ios-watch-app-service.ts @@ -1097,7 +1097,11 @@ export class IOSWatchAppService implements IIOSWatchAppService { comment: string, target: string, ) { - let buildPhase = project.buildPhaseObject(buildPhaseType, comment, target); + const buildPhase = project.buildPhaseObject( + buildPhaseType, + comment, + target, + ); if (!buildPhase) { project.addBuildPhase([], buildPhaseType, comment, target); } @@ -1261,7 +1265,7 @@ export class IOSWatchAppService implements IIOSWatchAppService { .filter((t) => !!t); const targets = moduleDef.dependencies .map((dependency) => - currentTargetsArray.find((t) => t.name === `\"${dependency}\"`), + currentTargetsArray.find((t) => t.name === `"${dependency}"`), ) .filter((s) => !!s); if (targets.length) { @@ -1301,8 +1305,8 @@ export class IOSWatchAppService implements IIOSWatchAppService { config.sharedModulesBuildConfigurationProperties ) { const configurationProperties = { - ...(config.sharedModulesBuildConfigurationProperties || {}), - ...(moduleDef.buildConfigurationProperties || {}), + ...config.sharedModulesBuildConfigurationProperties, + ...moduleDef.buildConfigurationProperties, }; this.$iOSNativeTargetService.setXcodeTargetBuildConfigurationProperties( Object.keys(configurationProperties).map((k) => ({ diff --git a/lib/services/ios/export-options-plist-service.ts b/lib/services/ios/export-options-plist-service.ts index 3c40396a8c..59fa22d1a8 100644 --- a/lib/services/ios/export-options-plist-service.ts +++ b/lib/services/ios/export-options-plist-service.ts @@ -11,7 +11,7 @@ export class ExportOptionsPlistService implements IExportOptionsPlistService { constructor( private $fs: IFileSystem, private $tempService: ITempService, - private $projectData: IProjectData + private $projectData: IProjectData, ) {} private getExtensionProvisions() { @@ -19,14 +19,14 @@ export class ExportOptionsPlistService implements IExportOptionsPlistService { this.$projectData.getAppResourcesDirectoryPath(), constants.iOSAppResourcesFolderName, constants.NATIVE_EXTENSION_FOLDER, - constants.EXTENSION_PROVISIONING_FILENAME + constants.EXTENSION_PROVISIONING_FILENAME, ); if (!this.$fs.exists(provisioningJSONPath)) { return ""; } const provisioningJSON = this.$fs.readJson( - provisioningJSONPath + provisioningJSONPath, ) as IProvisioningJSON; return Object.entries(provisioningJSON) @@ -39,11 +39,11 @@ export class ExportOptionsPlistService implements IExportOptionsPlistService { public async createDevelopmentExportOptionsPlist( archivePath: string, projectData: IProjectData, - buildConfig: IBuildConfig + buildConfig: IBuildConfig, ): Promise { const exportOptionsMethod = this.getExportOptionsMethod( projectData, - archivePath + archivePath, ); const provision = buildConfig.provision || buildConfig.mobileProvisionIdentifier; @@ -87,7 +87,7 @@ export class ExportOptionsPlistService implements IExportOptionsPlistService { const exportFileDir = path.resolve(path.dirname(archivePath)); const exportFilePath = path.join( exportFileDir, - projectData.projectName + ".ipa" + projectData.projectName + ".ipa", ); return { exportFileDir, exportFilePath, exportOptionsPlistFilePath }; @@ -96,7 +96,7 @@ export class ExportOptionsPlistService implements IExportOptionsPlistService { public async createDistributionExportOptionsPlist( archivePath: string, projectData: IProjectData, - buildConfig: IBuildConfig + buildConfig: IBuildConfig, ): Promise { const provision = buildConfig.provision || buildConfig.mobileProvisionIdentifier; @@ -142,7 +142,7 @@ export class ExportOptionsPlistService implements IExportOptionsPlistService { const exportFileDir = path.resolve(path.dirname(archivePath)); const exportFilePath = path.join( exportFileDir, - projectData.projectName + ".ipa" + projectData.projectName + ".ipa", ); return { exportFileDir, exportFilePath, exportOptionsPlistFilePath }; @@ -150,17 +150,17 @@ export class ExportOptionsPlistService implements IExportOptionsPlistService { private getExportOptionsMethod( projectData: IProjectData, - archivePath: string + archivePath: string, ): string { const embeddedMobileProvisionPath = path.join( archivePath, "Products", "Applications", `${projectData.projectName}.app`, - "embedded.mobileprovision" + "embedded.mobileprovision", ); const provision = mobileProvisionFinder.provision.readFromFile( - embeddedMobileProvisionPath + embeddedMobileProvisionPath, ); return { diff --git a/lib/services/ios/xcodebuild-args-service.ts b/lib/services/ios/xcodebuild-args-service.ts index 9f6998b79c..3ce8cc3839 100644 --- a/lib/services/ios/xcodebuild-args-service.ts +++ b/lib/services/ios/xcodebuild-args-service.ts @@ -45,7 +45,7 @@ export class XcodebuildArgsService implements IXcodebuildArgsService { let destination = "generic/platform=iOS Simulator"; - let isvisionOS = this.$devicePlatformsConstants.isvisionOS( + const isvisionOS = this.$devicePlatformsConstants.isvisionOS( buildConfig.platform, ); @@ -90,7 +90,7 @@ export class XcodebuildArgsService implements IXcodebuildArgsService { projectData.projectName + ".xcarchive", ); let destination = "generic/platform=iOS"; - let isvisionOS = this.$devicePlatformsConstants.isvisionOS( + const isvisionOS = this.$devicePlatformsConstants.isvisionOS( buildConfig.platform, ); diff --git a/lib/services/ios/xcodebuild-service.ts b/lib/services/ios/xcodebuild-service.ts index 4f8308dfb5..08a90aa21f 100644 --- a/lib/services/ios/xcodebuild-service.ts +++ b/lib/services/ios/xcodebuild-service.ts @@ -7,18 +7,18 @@ export class XcodebuildService implements IXcodebuildService { constructor( private $exportOptionsPlistService: IExportOptionsPlistService, private $xcodebuildArgsService: IXcodebuildArgsService, - private $xcodebuildCommandService: IXcodebuildCommandService + private $xcodebuildCommandService: IXcodebuildCommandService, ) {} public async buildForDevice( platformData: IPlatformData, projectData: IProjectData, - buildConfig: IBuildConfig + buildConfig: IBuildConfig, ): Promise { const args = await this.$xcodebuildArgsService.getBuildForDeviceArgs( platformData, projectData, - buildConfig + buildConfig, ); await this.$xcodebuildCommandService.executeCommand(args, { cwd: platformData.projectRoot, @@ -27,7 +27,7 @@ export class XcodebuildService implements IXcodebuildService { const archivePath = await this.createDevelopmentArchive( platformData, projectData, - buildConfig + buildConfig, ); return archivePath; } @@ -35,12 +35,12 @@ export class XcodebuildService implements IXcodebuildService { public async buildForSimulator( platformData: IPlatformData, projectData: IProjectData, - buildConfig: IBuildConfig + buildConfig: IBuildConfig, ): Promise { const args = await this.$xcodebuildArgsService.getBuildForSimulatorArgs( platformData, projectData, - buildConfig + buildConfig, ); await this.$xcodebuildCommandService.executeCommand(args, { cwd: platformData.projectRoot, @@ -51,12 +51,12 @@ export class XcodebuildService implements IXcodebuildService { public async buildForAppStore( platformData: IPlatformData, projectData: IProjectData, - buildConfig: IBuildConfig + buildConfig: IBuildConfig, ): Promise { const args = await this.$xcodebuildArgsService.getBuildForDeviceArgs( platformData, projectData, - buildConfig + buildConfig, ); await this.$xcodebuildCommandService.executeCommand(args, { cwd: platformData.projectRoot, @@ -65,7 +65,7 @@ export class XcodebuildService implements IXcodebuildService { const archivePath = await this.createDistributionArchive( platformData, projectData, - buildConfig + buildConfig, ); return archivePath; } @@ -73,17 +73,17 @@ export class XcodebuildService implements IXcodebuildService { private async createDevelopmentArchive( platformData: IPlatformData, projectData: IProjectData, - buildConfig: IBuildConfig + buildConfig: IBuildConfig, ): Promise { const archivePath = path.join( platformData.getBuildOutputPath(buildConfig), - projectData.projectName + ".xcarchive" + projectData.projectName + ".xcarchive", ); const output = await this.$exportOptionsPlistService.createDevelopmentExportOptionsPlist( archivePath, projectData, - buildConfig + buildConfig, ); const args = [ "-exportArchive", @@ -105,17 +105,17 @@ export class XcodebuildService implements IXcodebuildService { private async createDistributionArchive( platformData: IPlatformData, projectData: IProjectData, - buildConfig: IBuildConfig + buildConfig: IBuildConfig, ): Promise { const archivePath = path.join( platformData.getBuildOutputPath(buildConfig), - projectData.projectName + ".xcarchive" + projectData.projectName + ".xcarchive", ); const output = await this.$exportOptionsPlistService.createDistributionExportOptionsPlist( archivePath, projectData, - buildConfig + buildConfig, ); const provision = buildConfig.provision || buildConfig.mobileProvisionIdentifier; diff --git a/lib/services/ip-service.ts b/lib/services/ip-service.ts index 6d7464ff80..02f47a3502 100644 --- a/lib/services/ip-service.ts +++ b/lib/services/ip-service.ts @@ -6,14 +6,14 @@ export class IPService implements IIPService { private static GET_IP_TIMEOUT = 1000; constructor( private $httpClient: Server.IHttpClient, - private $logger: ILogger + private $logger: ILogger, ) {} @cache() public async getCurrentIPv4Address(): Promise { const ipAddress = (await this.getIPAddressFromServiceReturningJSONWithIPProperty( - "https://api.myip.com" + "https://api.myip.com", )) || (await this.getIPAddressFromIpifyOrgAPI()) || null; @@ -22,7 +22,7 @@ export class IPService implements IIPService { } private async getIPAddressFromServiceReturningJSONWithIPProperty( - apiEndpoint: string + apiEndpoint: string, ): Promise { let ipAddress: string = null; try { @@ -39,7 +39,7 @@ export class IPService implements IIPService { } catch (err) { this.$logger.trace( `Unable to get information about current IP Address from ${apiEndpoint} Error is:`, - err + err, ); } @@ -63,7 +63,7 @@ export class IPService implements IIPService { } catch (err) { this.$logger.trace( `Unable to get information about current IP Address from ${ipifyOrgAPIEndpoint} Error is:`, - err + err, ); } diff --git a/lib/services/itmstransporter-service.ts b/lib/services/itmstransporter-service.ts index 714231af32..f2b1f37a75 100644 --- a/lib/services/itmstransporter-service.ts +++ b/lib/services/itmstransporter-service.ts @@ -26,7 +26,7 @@ export class ITMSTransporterService implements IITMSTransporterService { private $logger: ILogger, private $plistParser: IPlistParser, private $xcodeSelectService: IXcodeSelectService, - private $tempService: ITempService + private $tempService: ITempService, ) {} private get $projectData(): IProjectData { @@ -39,19 +39,19 @@ export class ITMSTransporterService implements IITMSTransporterService { if (+version.major < 14) { if (!this.$fs.exists(itmsTransporterPath)) { this.$errors.fail( - "iTMS Transporter not found on this machine - make sure your Xcode installation is not damaged." + "iTMS Transporter not found on this machine - make sure your Xcode installation is not damaged.", ); } } else { const altoolPath = await this.getAltoolPath(); if (!this.$fs.exists(altoolPath)) { this.$errors.fail( - "altool not found on this machine - make sure your Xcode installation is not damaged." + "altool not found on this machine - make sure your Xcode installation is not damaged.", ); } if (!appSpecificPassword) { this.$errors.fail( - "An app-specific password is required from xCode versions 14 and above, Use the --appleApplicationSpecificPassword to supply it." + "An app-specific password is required from xCode versions 14 and above, Use the --appleApplicationSpecificPassword to supply it.", ); } } @@ -74,10 +74,11 @@ export class ITMSTransporterService implements IITMSTransporterService { ? ITMSConstants.VerboseLoggingLevels.Verbose : ITMSConstants.VerboseLoggingLevels.Informational; const bundleId = await this.getBundleIdentifier(data); - const application = await this.$applePortalApplicationService.getApplicationByBundleId( - data.user, - bundleId - ); + const application = + await this.$applePortalApplicationService.getApplicationByBundleId( + data.user, + bundleId, + ); this.$fs.createDirectory(innerDirectory); @@ -91,12 +92,12 @@ export class ITMSTransporterService implements IITMSTransporterService { application.adamId, ipaFileName, ipaFileHash, - ipaFileSize + ipaFileSize, ); this.$fs.writeFile( path.join(innerDirectory, ITMSConstants.ApplicationMetadataFile), - metadata + metadata, ); const password = data.user.isTwoFactorAuthenticationEnabled @@ -117,7 +118,7 @@ export class ITMSTransporterService implements IITMSTransporterService { loggingLevel, ], "close", - { stdio: "inherit" } + { stdio: "inherit" }, ); } @@ -170,12 +171,12 @@ export class ITMSTransporterService implements IITMSTransporterService { path.extname(ipaFilePath) !== ".ipa" ) { this.$errors.fail( - `Cannot use specified ipa file ${ipaFilePath}. File either does not exist or is not an ipa file.` + `Cannot use specified ipa file ${ipaFilePath}. File either does not exist or is not an ipa file.`, ); } this.$logger.trace( - "--ipa set - extracting .ipa file to get app's bundle identifier" + "--ipa set - extracting .ipa file to get app's bundle identifier", ); const destinationDir = await this.$tempService.mkdirSync("ipa-"); await this.$fs.unzip(ipaFilePath, destinationDir); @@ -187,26 +188,26 @@ export class ITMSTransporterService implements IITMSTransporterService { allFiles.forEach((f) => this.$logger.trace(" - " + f)); allFiles = allFiles.filter( - (f) => path.extname(f).toLowerCase() === ".app" + (f) => path.extname(f).toLowerCase() === ".app", ); if (allFiles.length > 1) { this.$errors.fail( - "In the .ipa the ITMSTransporter is uploading there is more than one .app file. We don't know which one to upload." + "In the .ipa the ITMSTransporter is uploading there is more than one .app file. We don't know which one to upload.", ); } else if (allFiles.length <= 0) { this.$errors.fail( - "In the .ipa the ITMSTransporter is uploading there must be at least one .app file." + "In the .ipa the ITMSTransporter is uploading there must be at least one .app file.", ); } const appFile = path.join(payloadDir, allFiles[0]); const plistObject = await this.$plistParser.parseFile( - path.join(appFile, INFO_PLIST_FILE_NAME) + path.join(appFile, INFO_PLIST_FILE_NAME), ); const bundleId = plistObject && plistObject.CFBundleIdentifier; if (!bundleId) { this.$errors.fail( - `Unable to determine bundle identifier from ${ipaFilePath}.` + `Unable to determine bundle identifier from ${ipaFilePath}.`, ); } @@ -221,14 +222,14 @@ export class ITMSTransporterService implements IITMSTransporterService { @cache() private async getAltoolPath(): Promise { const xcodePath = await this.$xcodeSelectService.getContentsDirectoryPath(); - let itmsTransporterPath = path.join( + const itmsTransporterPath = path.join( xcodePath, "..", "Contents", "Developer", "usr", "bin", - ITMSConstants.altoolExecutableName + ITMSConstants.altoolExecutableName, ); return itmsTransporterPath; @@ -247,7 +248,7 @@ export class ITMSTransporterService implements IITMSTransporterService { "A", "itms", "bin", - ITMSConstants.iTMSExecutableName + ITMSConstants.iTMSExecutableName, ); const xcodeVersionData = await this.$xcodeSelectService.getXcodeVersion(); @@ -256,13 +257,13 @@ export class ITMSTransporterService implements IITMSTransporterService { xcodePath, "Applications", "Application Loader.app", - "Contents" + "Contents", ); itmsTransporterPath = path.join( loaderAppContentsPath, ITMSConstants.iTMSDirectoryName, "bin", - ITMSConstants.iTMSExecutableName + ITMSConstants.iTMSExecutableName, ); } @@ -273,7 +274,7 @@ export class ITMSTransporterService implements IITMSTransporterService { appleId: string, ipaFileName: string, ipaFileHash: string, - ipaFileSize: number + ipaFileSize: number, ): string { return ` diff --git a/lib/services/livesync-process-data-service.ts b/lib/services/livesync-process-data-service.ts index 27b4767254..90f2b7c0e6 100644 --- a/lib/services/livesync-process-data-service.ts +++ b/lib/services/livesync-process-data-service.ts @@ -8,22 +8,21 @@ export class LiveSyncProcessDataService implements ILiveSyncProcessDataService { public persistData( projectDir: string, deviceDescriptors: ILiveSyncDeviceDescriptor[], - platforms: string[] + platforms: string[], ): void { this.processes[projectDir] = this.processes[projectDir] || Object.create(null); this.processes[projectDir].actionsChain = this.processes[projectDir].actionsChain || Promise.resolve(); - this.processes[projectDir].currentSyncAction = this.processes[ - projectDir - ].actionsChain; + this.processes[projectDir].currentSyncAction = + this.processes[projectDir].actionsChain; this.processes[projectDir].isStopped = false; this.processes[projectDir].platforms = platforms; const currentDeviceDescriptors = this.getDeviceDescriptors(projectDir); this.processes[projectDir].deviceDescriptors = _.uniqBy( currentDeviceDescriptors.concat(deviceDescriptors), - "identifier" + "identifier", ); } diff --git a/lib/services/livesync/android-device-livesync-service-base.ts b/lib/services/livesync/android-device-livesync-service-base.ts index 6fd27c079e..d557845d1c 100644 --- a/lib/services/livesync/android-device-livesync-service-base.ts +++ b/lib/services/livesync/android-device-livesync-service-base.ts @@ -12,19 +12,19 @@ export abstract class AndroidDeviceLiveSyncServiceBase extends DeviceLiveSyncSer protected $platformsDataService: IPlatformsDataService, protected $filesHashService: IFilesHashService, protected $logger: ILogger, - protected device: Mobile.IAndroidDevice + protected device: Mobile.IAndroidDevice, ) { super($platformsDataService, device); } public abstract transferFilesOnDevice( deviceAppData: Mobile.IDeviceAppData, - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): Promise; public abstract transferDirectoryOnDevice( deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], - projectFilesPath: string + projectFilesPath: string, ): Promise; public async transferFiles( @@ -33,24 +33,25 @@ export abstract class AndroidDeviceLiveSyncServiceBase extends DeviceLiveSyncSer projectFilesPath: string, projectData: IProjectData, liveSyncDeviceDescriptor: ILiveSyncDeviceDescriptor, - options: ITransferFilesOptions + options: ITransferFilesOptions, ): Promise { const deviceHashService = this.device.fileSystem.getDeviceHashService( - deviceAppData.appIdentifier - ); - const currentHashes = await deviceHashService.generateHashesFromLocalToDevicePaths( - localToDevicePaths + deviceAppData.appIdentifier, ); + const currentHashes = + await deviceHashService.generateHashesFromLocalToDevicePaths( + localToDevicePaths, + ); const transferredFiles = await this.transferFilesCore( deviceAppData, localToDevicePaths, projectFilesPath, currentHashes, - options + options, ); await this.device.fileSystem.updateHashesOnDevice( currentHashes, - deviceAppData.appIdentifier + deviceAppData.appIdentifier, ); return transferredFiles; } @@ -60,38 +61,39 @@ export abstract class AndroidDeviceLiveSyncServiceBase extends DeviceLiveSyncSer localToDevicePaths: Mobile.ILocalToDevicePathData[], projectFilesPath: string, currentHashes: IStringDictionary, - options: ITransferFilesOptions + options: ITransferFilesOptions, ): Promise { if (options.force && options.isFullSync) { const hashFileDevicePath = this.device.fileSystem.getDeviceHashService( - deviceAppData.appIdentifier + deviceAppData.appIdentifier, ).hashFileDevicePath; await this.device.fileSystem.deleteFile( hashFileDevicePath, - deviceAppData.appIdentifier + deviceAppData.appIdentifier, ); this.$logger.trace( "Before transfer directory on device ", - localToDevicePaths + localToDevicePaths, ); await this.transferDirectoryOnDevice( deviceAppData, localToDevicePaths, - projectFilesPath + projectFilesPath, ); return localToDevicePaths; } - const localToDevicePathsToTransfer = await this.getLocalToDevicePathsToTransfer( - deviceAppData, - localToDevicePaths, - currentHashes, - options - ); + const localToDevicePathsToTransfer = + await this.getLocalToDevicePathsToTransfer( + deviceAppData, + localToDevicePaths, + currentHashes, + options, + ); this.$logger.trace("Files to transfer: ", localToDevicePathsToTransfer); await this.transferFilesOnDevice( deviceAppData, - localToDevicePathsToTransfer + localToDevicePathsToTransfer, ); return localToDevicePathsToTransfer; } @@ -100,7 +102,7 @@ export abstract class AndroidDeviceLiveSyncServiceBase extends DeviceLiveSyncSer deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], currentHashes: IStringDictionary, - options: ITransferFilesOptions + options: ITransferFilesOptions, ): Promise { if (options.force || !options.isFullSync) { return localToDevicePaths; @@ -109,7 +111,7 @@ export abstract class AndroidDeviceLiveSyncServiceBase extends DeviceLiveSyncSer const changedLocalToDevicePaths = await this.getChangedLocalToDevicePaths( deviceAppData.appIdentifier, localToDevicePaths, - currentHashes + currentHashes, ); return changedLocalToDevicePaths; } @@ -117,20 +119,19 @@ export abstract class AndroidDeviceLiveSyncServiceBase extends DeviceLiveSyncSer private async getChangedLocalToDevicePaths( appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[], - currentHashes: IStringDictionary + currentHashes: IStringDictionary, ): Promise { - const deviceHashService = this.device.fileSystem.getDeviceHashService( - appIdentifier - ); + const deviceHashService = + this.device.fileSystem.getDeviceHashService(appIdentifier); const oldHashes = (await deviceHashService.getShasumsFromDevice()) || {}; const changedHashes = deviceHashService.getChangedShasums( oldHashes, - currentHashes + currentHashes, ); const changedFiles = _.keys(changedHashes); const changedLocalToDevicePaths = localToDevicePaths.filter( (localToDevicePathData) => - changedFiles.indexOf(localToDevicePathData.getLocalPath()) >= 0 + changedFiles.indexOf(localToDevicePathData.getLocalPath()) >= 0, ); return changedLocalToDevicePaths; } diff --git a/lib/services/livesync/android-device-livesync-service.ts b/lib/services/livesync/android-device-livesync-service.ts index 81a4d20831..9ac728eed3 100644 --- a/lib/services/livesync/android-device-livesync-service.ts +++ b/lib/services/livesync/android-device-livesync-service.ts @@ -16,7 +16,8 @@ export class AndroidDeviceLiveSyncService extends AndroidDeviceLiveSyncServiceBase implements IAndroidNativeScriptDeviceLiveSyncService, - INativeScriptDeviceLiveSyncService { + INativeScriptDeviceLiveSyncService +{ private port: number; constructor( @@ -27,46 +28,46 @@ export class AndroidDeviceLiveSyncService protected platformsDataService: IPlatformsDataService, protected device: Mobile.IAndroidDevice, $filesHashService: IFilesHashService, - $logger: ILogger + $logger: ILogger, ) { super($injector, platformsDataService, $filesHashService, $logger, device); } public async transferFilesOnDevice( deviceAppData: Mobile.IDeviceAppData, - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): Promise { await this.device.fileSystem.transferFiles( deviceAppData, - localToDevicePaths + localToDevicePaths, ); } public async transferDirectoryOnDevice( deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], - projectFilesPath: string + projectFilesPath: string, ): Promise { await this.device.fileSystem.transferDirectory( deviceAppData, localToDevicePaths, - projectFilesPath + projectFilesPath, ); } public async restartApplication( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise { const devicePathRoot = util.format( ANDROID_DEVICE_APP_ROOT_TEMPLATE, - liveSyncInfo.deviceAppData.appIdentifier + liveSyncInfo.deviceAppData.appIdentifier, ); const devicePath = this.$mobileHelper.buildDevicePath( devicePathRoot, "code_cache", "secondary_dexes", - "proxyThumb" + "proxyThumb", ); await this.device.adb.executeShellCommand(["rm", "-rf", devicePath]); await this.device.applicationManager.restartApplication({ @@ -79,7 +80,7 @@ export class AndroidDeviceLiveSyncService public async shouldRestart( projectData: IProjectData, - liveSyncInfo: IAndroidLiveSyncResultInfo + liveSyncInfo: IAndroidLiveSyncResultInfo, ): Promise { let shouldRestart = false; const localToDevicePaths = liveSyncInfo.modifiedFilesData; @@ -92,8 +93,8 @@ export class AndroidDeviceLiveSyncService liveSyncInfo, localToDevicePath.getLocalPath(), projectData, - this.device.deviceInfo.platform - ) + this.device.deviceInfo.platform, + ), ); if (!canExecuteFastSync || liveSyncInfo.waitForDebugger) { @@ -105,18 +106,19 @@ export class AndroidDeviceLiveSyncService public async tryRefreshApplication( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise { let didRefresh = true; const deviceAppData = liveSyncInfo.deviceAppData; const localToDevicePaths = liveSyncInfo.modifiedFilesData; - const deviceProjectRootDirname = await this.$devicePathProvider.getDeviceProjectRootPath( - liveSyncInfo.deviceAppData.device, - { - appIdentifier: liveSyncInfo.deviceAppData.appIdentifier, - getDirname: true, - } - ); + const deviceProjectRootDirname = + await this.$devicePathProvider.getDeviceProjectRootPath( + liveSyncInfo.deviceAppData.device, + { + appIdentifier: liveSyncInfo.deviceAppData.appIdentifier, + getDirname: true, + }, + ); await this.device.adb.executeShellCommand([ "chmod", @@ -128,52 +130,54 @@ export class AndroidDeviceLiveSyncService didRefresh = await this.reloadApplicationFiles( deviceAppData, - localToDevicePaths + localToDevicePaths, ); return didRefresh; } private async cleanLivesyncDirectories( - deviceAppData: Mobile.IDeviceAppData + deviceAppData: Mobile.IDeviceAppData, ): Promise { - const deviceRootPath = await this.$devicePathProvider.getDeviceProjectRootPath( - deviceAppData.device, - { - appIdentifier: deviceAppData.appIdentifier, - getDirname: true, - } - ); + const deviceRootPath = + await this.$devicePathProvider.getDeviceProjectRootPath( + deviceAppData.device, + { + appIdentifier: deviceAppData.appIdentifier, + getDirname: true, + }, + ); await this.device.adb.executeShellCommand([ "rm", "-rf", this.$mobileHelper.buildDevicePath( deviceRootPath, - LiveSyncPaths.FULLSYNC_DIR_NAME + LiveSyncPaths.FULLSYNC_DIR_NAME, ), this.$mobileHelper.buildDevicePath( deviceRootPath, - LiveSyncPaths.SYNC_DIR_NAME + LiveSyncPaths.SYNC_DIR_NAME, ), this.$mobileHelper.buildDevicePath( deviceRootPath, - LiveSyncPaths.REMOVEDSYNC_DIR_NAME + LiveSyncPaths.REMOVEDSYNC_DIR_NAME, ), ]); } @performanceLog() public async beforeLiveSyncAction( - deviceAppData: Mobile.IDeviceAppData + deviceAppData: Mobile.IDeviceAppData, ): Promise { - const deviceRootPath = await this.$devicePathProvider.getDeviceProjectRootPath( - deviceAppData.device, - { - appIdentifier: deviceAppData.appIdentifier, - getDirname: true, - } - ); + const deviceRootPath = + await this.$devicePathProvider.getDeviceProjectRootPath( + deviceAppData.device, + { + appIdentifier: deviceAppData.appIdentifier, + getDirname: true, + }, + ); const deviceRootDir = path.dirname(deviceRootPath); const deviceRootBasename = path.basename(deviceRootPath); const listResult = await this.device.adb.executeShellCommand([ @@ -194,16 +198,15 @@ export class AndroidDeviceLiveSyncService private async reloadApplicationFiles( deviceAppData: Mobile.IDeviceAppData, - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): Promise { if (!this.port) { - this.port = await this.$androidProcessService.forwardFreeTcpToAbstractPort( - { + this.port = + await this.$androidProcessService.forwardFreeTcpToAbstractPort({ deviceIdentifier: deviceAppData.device.deviceInfo.identifier, appIdentifier: deviceAppData.appIdentifier, abstractPort: `localabstract:${deviceAppData.appIdentifier}-livesync`, - } - ); + }); } if (await this.awaitRuntimeReloadSuccessMessage()) { @@ -217,27 +220,28 @@ export class AndroidDeviceLiveSyncService @performanceLog() public async removeFiles( deviceAppData: Mobile.IDeviceAppData, - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): Promise { - const deviceRootPath = await this.$devicePathProvider.getDeviceProjectRootPath( - deviceAppData.device, - { - appIdentifier: deviceAppData.appIdentifier, - getDirname: true, - } - ); + const deviceRootPath = + await this.$devicePathProvider.getDeviceProjectRootPath( + deviceAppData.device, + { + appIdentifier: deviceAppData.appIdentifier, + getDirname: true, + }, + ); for (const localToDevicePathData of localToDevicePaths) { const relativeUnixPath = _.trimStart( helpers.fromWindowsRelativePathToUnix( - localToDevicePathData.getRelativeToProjectBasePath() + localToDevicePathData.getRelativeToProjectBasePath(), ), - "/" + "/", ); const deviceFilePath = this.$mobileHelper.buildDevicePath( deviceRootPath, LiveSyncPaths.REMOVEDSYNC_DIR_NAME, - relativeUnixPath + relativeUnixPath, ); await this.device.adb.executeShellCommand([ "mkdir", @@ -250,7 +254,7 @@ export class AndroidDeviceLiveSyncService } const deviceHashService = this.device.fileSystem.getDeviceHashService( - deviceAppData.appIdentifier + deviceAppData.appIdentifier, ); await deviceHashService.removeHashes(localToDevicePaths); } @@ -265,7 +269,7 @@ export class AndroidDeviceLiveSyncService process.env.NATIVESCRIPT_LIVESYNC_ADDRESS || "127.0.0.1", () => { socket.write(Buffer.from([0, 0, 0, 1, 1])); - } + }, ); socket.on("data", (data: any) => { isResolved = true; diff --git a/lib/services/livesync/android-livesync-service.ts b/lib/services/livesync/android-livesync-service.ts index 8ff185ca0d..2d71b8e816 100644 --- a/lib/services/livesync/android-livesync-service.ts +++ b/lib/services/livesync/android-livesync-service.ts @@ -27,7 +27,7 @@ export class AndroidLiveSyncService $devicePathProvider: IDevicePathProvider, $fs: IFileSystem, $logger: ILogger, - $options: IOptions + $options: IOptions, ) { super( $fs, @@ -35,46 +35,46 @@ export class AndroidLiveSyncService $platformsDataService, $projectFilesManager, $devicePathProvider, - $options + $options, ); } protected _getDeviceLiveSyncService( device: Mobile.IDevice, data: IProjectDir, - frameworkVersion: string + frameworkVersion: string, ): INativeScriptDeviceLiveSyncService { if ( semver.gt( frameworkVersion, - AndroidLiveSyncService.MIN_SOCKETS_LIVESYNC_RUNTIME_VERSION + AndroidLiveSyncService.MIN_SOCKETS_LIVESYNC_RUNTIME_VERSION, ) ) { return this.$injector.resolve( AndroidDeviceSocketsLiveSyncService, - { device, data } + { device, data }, ); } return this.$injector.resolve( AndroidDeviceLiveSyncService, - { device, data } + { device, data }, ); } @performanceLog() public async liveSyncWatchAction( device: Mobile.IDevice, - liveSyncInfo: ILiveSyncWatchInfo + liveSyncInfo: ILiveSyncWatchInfo, ): Promise { const liveSyncResult = await super.liveSyncWatchAction( device, - liveSyncInfo + liveSyncInfo, ); const result = await this.finalizeSync( device, liveSyncInfo.projectData, - liveSyncResult + liveSyncResult, ); return result; @@ -82,13 +82,13 @@ export class AndroidLiveSyncService @performanceLog() public async fullSync( - syncInfo: IFullSyncInfo + syncInfo: IFullSyncInfo, ): Promise { const liveSyncResult = await super.fullSync(syncInfo); const result = await this.finalizeSync( syncInfo.device, syncInfo.projectData, - liveSyncResult + liveSyncResult, ); return result; } @@ -96,14 +96,14 @@ export class AndroidLiveSyncService private async finalizeSync( device: Mobile.IDevice, projectData: IProjectData, - liveSyncResult: ILiveSyncResultInfo + liveSyncResult: ILiveSyncResultInfo, ): Promise { const liveSyncService = ( this.getDeviceLiveSyncService(device, projectData) ); const finalizeResult = await liveSyncService.finalizeSync( liveSyncResult, - projectData + projectData, ); const result = _.extend(liveSyncResult, finalizeResult); return result; diff --git a/lib/services/livesync/android-livesync-tool.ts b/lib/services/livesync/android-livesync-tool.ts index 9057a64c79..282fef3aaf 100644 --- a/lib/services/livesync/android-livesync-tool.ts +++ b/lib/services/livesync/android-livesync-tool.ts @@ -597,7 +597,7 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool { return this.$mobileHelper.buildDevicePath(relativeFilePath); } - private async writeToSocket(data: Buffer): Promise { + private async writeToSocket(data: Buffer): Promise { this.verifyActiveConnection(); const result = await this.socketConnection.writeAsync(data); return result; diff --git a/lib/services/livesync/device-livesync-service-base.ts b/lib/services/livesync/device-livesync-service-base.ts index a48ec66d19..148db8eb92 100644 --- a/lib/services/livesync/device-livesync-service-base.ts +++ b/lib/services/livesync/device-livesync-service-base.ts @@ -10,18 +10,18 @@ export abstract class DeviceLiveSyncServiceBase { constructor( protected platformsDataService: IPlatformsDataService, - protected device: Mobile.IDevice + protected device: Mobile.IDevice, ) {} public canExecuteFastSync( liveSyncResult: ILiveSyncResultInfo, filePath: string, projectData: IProjectData, - platform: string + platform: string, ): boolean { const fastSyncFileExtensions = this.getFastLiveSyncFileExtensions( platform, - projectData + projectData, ); return ( liveSyncResult.useHotModuleReload || @@ -33,7 +33,7 @@ export abstract class DeviceLiveSyncServiceBase { liveSyncResult: ILiveSyncResultInfo, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectData: IProjectData, - platform: string + platform: string, ) { return !_.some( localToDevicePaths, @@ -42,23 +42,24 @@ export abstract class DeviceLiveSyncServiceBase { liveSyncResult, localToDevicePath.getLocalPath(), projectData, - this.device.deviceInfo.platform - ) + this.device.deviceInfo.platform, + ), ); } @cache() private getFastLiveSyncFileExtensions( platform: string, - projectData: IProjectData + projectData: IProjectData, ): string[] { const platformData = this.platformsDataService.getPlatformData( platform, - projectData - ); - const fastSyncFileExtensions = DeviceLiveSyncServiceBase.FAST_SYNC_FILE_EXTENSIONS.concat( - platformData.fastLivesyncFileExtensions + projectData, ); + const fastSyncFileExtensions = + DeviceLiveSyncServiceBase.FAST_SYNC_FILE_EXTENSIONS.concat( + platformData.fastLivesyncFileExtensions, + ); return fastSyncFileExtensions; } @@ -69,7 +70,7 @@ export abstract class DeviceLiveSyncServiceBase { projectFilesPath: string, projectData: IProjectData, liveSyncDeviceDescriptor: ILiveSyncDeviceDescriptor, - options: ITransferFilesOptions + options: ITransferFilesOptions, ): Promise { let transferredFiles: Mobile.ILocalToDevicePathData[] = []; @@ -77,12 +78,12 @@ export abstract class DeviceLiveSyncServiceBase { transferredFiles = await this.device.fileSystem.transferDirectory( deviceAppData, localToDevicePaths, - projectFilesPath + projectFilesPath, ); } else { transferredFiles = await this.device.fileSystem.transferFiles( deviceAppData, - localToDevicePaths + localToDevicePaths, ); } @@ -91,7 +92,7 @@ export abstract class DeviceLiveSyncServiceBase { public async finalizeSync( liveSyncInfo: ILiveSyncResultInfo, - projectData: IProjectData + projectData: IProjectData, ): Promise { //implement in case a sync point for all remove/create operation is needed return { diff --git a/lib/services/livesync/ios-device-livesync-service.ts b/lib/services/livesync/ios-device-livesync-service.ts index 78c3150ff9..bc5535d924 100644 --- a/lib/services/livesync/ios-device-livesync-service.ts +++ b/lib/services/livesync/ios-device-livesync-service.ts @@ -16,7 +16,8 @@ let currentPageReloadId = 0; export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase - implements INativeScriptDeviceLiveSyncService { + implements INativeScriptDeviceLiveSyncService +{ private static MIN_RUNTIME_VERSION_WITH_REFRESH_NOTIFICATION = "6.1.0"; private socket: net.Socket; @@ -28,14 +29,14 @@ export class IOSDeviceLiveSyncService private $lockService: ILockService, protected platformsDataService: IPlatformsDataService, private $platformCommandHelper: IPlatformCommandHelper, - protected device: Mobile.IiOSDevice + protected device: Mobile.IiOSDevice, ) { super(platformsDataService, device); } private canRefreshWithNotification( projectData: IProjectData, - liveSyncInfo?: ILiveSyncResultInfo + liveSyncInfo?: ILiveSyncResultInfo, ): boolean { if (liveSyncInfo && liveSyncInfo.forceRefreshWithSocket) { return false; @@ -45,20 +46,21 @@ export class IOSDeviceLiveSyncService return false; } - const currentRuntimeVersion = this.$platformCommandHelper.getCurrentPlatformVersion( - this.$devicePlatformsConstants.iOS, - projectData - ); + const currentRuntimeVersion = + this.$platformCommandHelper.getCurrentPlatformVersion( + this.$devicePlatformsConstants.iOS, + projectData, + ); const canRefresh = semver.gte( semver.coerce(currentRuntimeVersion), - IOSDeviceLiveSyncService.MIN_RUNTIME_VERSION_WITH_REFRESH_NOTIFICATION + IOSDeviceLiveSyncService.MIN_RUNTIME_VERSION_WITH_REFRESH_NOTIFICATION, ); return canRefresh; } private async setupSocketIfNeeded( - projectData: IProjectData + projectData: IProjectData, ): Promise { // TODO: persist the sockets per app in order to support LiveSync on multiple apps on the same device if (this.socket) { @@ -73,12 +75,12 @@ export class IOSDeviceLiveSyncService appId, projectData.projectName, projectData.projectDir, - ensureAppStarted + ensureAppStarted, ); } catch (err) { this.$logger.trace( `Error while connecting to the debug socket. Error is:`, - err + err, ); } @@ -94,21 +96,21 @@ export class IOSDeviceLiveSyncService @performanceLog() public async removeFiles( deviceAppData: Mobile.IDeviceAppData, - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): Promise { await Promise.all( _.map(localToDevicePaths, (localToDevicePathData) => this.device.fileSystem.deleteFile( localToDevicePathData.getDevicePath(), - deviceAppData.appIdentifier - ) - ) + deviceAppData.appIdentifier, + ), + ), ); } public async shouldRestart( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise { let shouldRestart = false; const deviceAppData = liveSyncInfo.deviceAppData; @@ -120,7 +122,7 @@ export class IOSDeviceLiveSyncService liveSyncInfo, localToDevicePaths, projectData, - deviceAppData.platform + deviceAppData.platform, ); const isRefreshConnectionSetup = this.canRefreshWithNotification(projectData, liveSyncInfo) || @@ -135,7 +137,7 @@ export class IOSDeviceLiveSyncService public async tryRefreshApplication( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise { let didRefresh = true; const localToDevicePaths = liveSyncInfo.modifiedFilesData; @@ -146,24 +148,24 @@ export class IOSDeviceLiveSyncService (scriptRelatedFiles = _.concat( scriptRelatedFiles, localToDevicePaths.filter((file) => - minimatch(file.getDevicePath(), pattern, { nocase: true }) - ) - )) + minimatch(file.getDevicePath(), pattern, { nocase: true }), + ), + )), ); const scriptFiles = _.filter(localToDevicePaths, (localToDevicePath) => - _.endsWith(localToDevicePath.getDevicePath(), ".js") + _.endsWith(localToDevicePath.getDevicePath(), ".js"), ); const otherFiles = _.difference( localToDevicePaths, - _.concat(scriptFiles, scriptRelatedFiles) + _.concat(scriptFiles, scriptRelatedFiles), ); try { if (otherFiles.length) { didRefresh = await this.refreshApplicationCore( projectData, - liveSyncInfo + liveSyncInfo, ); } } catch (e) { @@ -175,7 +177,7 @@ export class IOSDeviceLiveSyncService private async refreshApplicationCore( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ) { let didRefresh = true; if (this.canRefreshWithNotification(projectData, liveSyncInfo)) { @@ -197,7 +199,7 @@ export class IOSDeviceLiveSyncService didRefresh = await this.$iOSSocketRequestExecutor.executeRefreshRequest( this.device, 5, - projectData.projectIdentifiers.ios + projectData.projectIdentifiers.ios, ); }, `ios-device-livesync-${this.device.deviceInfo.identifier}-${projectData.projectIdentifiers.ios}.lock`); @@ -206,7 +208,7 @@ export class IOSDeviceLiveSyncService public async restartApplication( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise { await this.device.applicationManager.restartApplication({ appId: liveSyncInfo.deviceAppData.appIdentifier, diff --git a/lib/services/livesync/livesync-socket.ts b/lib/services/livesync/livesync-socket.ts index d93dd5fde2..d5ea5facdb 100644 --- a/lib/services/livesync/livesync-socket.ts +++ b/lib/services/livesync/livesync-socket.ts @@ -3,9 +3,9 @@ import { injector } from "../../common/yok"; export class LiveSyncSocket extends net.Socket implements ILiveSyncSocket { public uid: string; - public writeAsync(data: Buffer): Promise { + public writeAsync(data: Buffer): Promise { return new Promise((resolve, reject) => { - const result: Boolean = this.write(data, () => resolve(result)); + const result: boolean = this.write(data, () => resolve(result)); }); } } diff --git a/lib/services/livesync/platform-livesync-service-base.ts b/lib/services/livesync/platform-livesync-service-base.ts index 277bb10728..1a7a8afab2 100644 --- a/lib/services/livesync/platform-livesync-service-base.ts +++ b/lib/services/livesync/platform-livesync-service-base.ts @@ -24,28 +24,28 @@ export abstract class PlatformLiveSyncServiceBase { protected $platformsDataService: IPlatformsDataService, protected $projectFilesManager: IProjectFilesManager, private $devicePathProvider: IDevicePathProvider, - private $options: IOptions + private $options: IOptions, ) {} public getDeviceLiveSyncService( device: Mobile.IDevice, - projectData: IProjectData + projectData: IProjectData, ): INativeScriptDeviceLiveSyncService { const platform = device.deviceInfo.platform.toLowerCase(); const platformData = this.$platformsDataService.getPlatformData( device.deviceInfo.platform, - projectData + projectData, ); const frameworkVersion = platformData.platformProjectService.getFrameworkVersion(projectData); const key = getHash( - `${device.deviceInfo.identifier}${projectData.projectIdentifiers[platform]}${projectData.projectDir}${frameworkVersion}` + `${device.deviceInfo.identifier}${projectData.projectIdentifiers[platform]}${projectData.projectDir}${frameworkVersion}`, ); if (!this._deviceLiveSyncServicesCache[key]) { this._deviceLiveSyncServicesCache[key] = this._getDeviceLiveSyncService( device, projectData, - frameworkVersion + frameworkVersion, ); } @@ -55,61 +55,61 @@ export abstract class PlatformLiveSyncServiceBase { protected abstract _getDeviceLiveSyncService( device: Mobile.IDevice, data: IProjectData, - frameworkVersion: string + frameworkVersion: string, ): INativeScriptDeviceLiveSyncService; public async shouldRestart( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise { const deviceLiveSyncService = this.getDeviceLiveSyncService( liveSyncInfo.deviceAppData.device, - projectData + projectData, ); const shouldRestart = await deviceLiveSyncService.shouldRestart( projectData, - liveSyncInfo + liveSyncInfo, ); return shouldRestart; } public async syncAfterInstall( device: Mobile.IDevice, - liveSyncInfo: ILiveSyncWatchInfo + liveSyncInfo: ILiveSyncWatchInfo, ): Promise { /* intentionally left blank */ } public async restartApplication( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise { const deviceLiveSyncService = this.getDeviceLiveSyncService( liveSyncInfo.deviceAppData.device, - projectData + projectData, ); this.$logger.info( - `Restarting application on device ${liveSyncInfo.deviceAppData.device.deviceInfo.identifier}...` + `Restarting application on device ${liveSyncInfo.deviceAppData.device.deviceInfo.identifier}...`, ); await deviceLiveSyncService.restartApplication(projectData, liveSyncInfo); } public async tryRefreshApplication( projectData: IProjectData, - liveSyncInfo: ILiveSyncResultInfo + liveSyncInfo: ILiveSyncResultInfo, ): Promise { let didRefresh = true; if (liveSyncInfo.isFullSync || liveSyncInfo.modifiedFilesData.length) { const deviceLiveSyncService = this.getDeviceLiveSyncService( liveSyncInfo.deviceAppData.device, - projectData + projectData, ); this.$logger.info( - `Refreshing application on device ${liveSyncInfo.deviceAppData.device.deviceInfo.identifier}...` + `Refreshing application on device ${liveSyncInfo.deviceAppData.device.deviceInfo.identifier}...`, ); didRefresh = await deviceLiveSyncService.tryRefreshApplication( projectData, - liveSyncInfo + liveSyncInfo, ); } @@ -121,11 +121,11 @@ export abstract class PlatformLiveSyncServiceBase { const device = syncInfo.device; const deviceLiveSyncService = this.getDeviceLiveSyncService( device, - syncInfo.projectData + syncInfo.projectData, ); const platformData = this.$platformsDataService.getPlatformData( device.deviceInfo.platform, - projectData + projectData, ); const deviceAppData = await this.getAppData(syncInfo); @@ -135,14 +135,14 @@ export abstract class PlatformLiveSyncServiceBase { const projectFilesPath = path.join( platformData.appDestinationDirectoryPath, - this.$options.hostProjectModuleName + this.$options.hostProjectModuleName, ); const localToDevicePaths = await this.$projectFilesManager.createLocalToDevicePaths( deviceAppData, projectFilesPath, null, - [] + [], ); const modifiedFilesData = await this.transferFiles( deviceAppData, @@ -150,7 +150,7 @@ export abstract class PlatformLiveSyncServiceBase { projectFilesPath, projectData, syncInfo.liveSyncDeviceData, - { isFullSync: true, force: syncInfo.force } + { isFullSync: true, force: syncInfo.force }, ); return { @@ -164,12 +164,12 @@ export abstract class PlatformLiveSyncServiceBase { @performanceLog() public async liveSyncWatchAction( device: Mobile.IDevice, - liveSyncInfo: ILiveSyncWatchInfo + liveSyncInfo: ILiveSyncWatchInfo, ): Promise { const projectData = liveSyncInfo.projectData; const deviceLiveSyncService = this.getDeviceLiveSyncService( device, - projectData + projectData, ); const syncInfo = _.merge({ device, watch: true }, liveSyncInfo); const deviceAppData = await this.getAppData(syncInfo); @@ -190,25 +190,25 @@ export abstract class PlatformLiveSyncServiceBase { if (skippedFiles.length) { this.$logger.trace( "The following files will not be synced as they do not exist:", - skippedFiles + skippedFiles, ); } if (existingFiles.length) { const platformData = this.$platformsDataService.getPlatformData( device.deviceInfo.platform, - projectData + projectData, ); const projectFilesPath = path.join( platformData.appDestinationDirectoryPath, - this.$options.hostProjectModuleName + this.$options.hostProjectModuleName, ); const localToDevicePaths = await this.$projectFilesManager.createLocalToDevicePaths( deviceAppData, projectFilesPath, existingFiles, - [] + [], ); modifiedLocalToDevicePaths.push(...localToDevicePaths); modifiedLocalToDevicePaths = await this.transferFiles( @@ -217,7 +217,7 @@ export abstract class PlatformLiveSyncServiceBase { projectFilesPath, projectData, liveSyncInfo.liveSyncDeviceData, - { isFullSync: false, force: liveSyncInfo.force } + { isFullSync: false, force: liveSyncInfo.force }, ); } } @@ -226,7 +226,7 @@ export abstract class PlatformLiveSyncServiceBase { const filePaths = liveSyncInfo.filesToRemove; const platformData = this.$platformsDataService.getPlatformData( device.deviceInfo.platform, - projectData + projectData, ); const mappedFiles = _(filePaths) @@ -235,21 +235,21 @@ export abstract class PlatformLiveSyncServiceBase { .value(); const projectFilesPath = path.join( platformData.appDestinationDirectoryPath, - APP_FOLDER_NAME + APP_FOLDER_NAME, ); const localToDevicePaths = await this.$projectFilesManager.createLocalToDevicePaths( deviceAppData, projectFilesPath, mappedFiles, - [] + [], ); modifiedLocalToDevicePaths.push(...localToDevicePaths); await deviceLiveSyncService.removeFiles( deviceAppData, localToDevicePaths, - projectFilesPath + projectFilesPath, ); } @@ -267,12 +267,12 @@ export abstract class PlatformLiveSyncServiceBase { projectFilesPath: string, projectData: IProjectData, liveSyncDeviceData: ILiveSyncDeviceDescriptor, - options: ITransferFilesOptions + options: ITransferFilesOptions, ): Promise { let transferredFiles: Mobile.ILocalToDevicePathData[] = []; const deviceLiveSyncService = this.getDeviceLiveSyncService( deviceAppData.device, - projectData + projectData, ); transferredFiles = await deviceLiveSyncService.transferFiles( @@ -281,31 +281,31 @@ export abstract class PlatformLiveSyncServiceBase { projectFilesPath, projectData, liveSyncDeviceData, - options + options, ); await deviceAppData.device.applicationManager.setTransferredAppFiles( - localToDevicePaths.map((l) => l.getLocalPath()) + localToDevicePaths.map((l) => l.getLocalPath()), ); this.logFilesSyncInformation( transferredFiles, "Successfully transferred %s on device %s.", this.$logger.info, - deviceAppData.device.deviceInfo.identifier + deviceAppData.device.deviceInfo.identifier, ); return transferredFiles; } public async getAppData( - syncInfo: IFullSyncInfo + syncInfo: IFullSyncInfo, ): Promise { const platform = syncInfo.device.deviceInfo.platform.toLowerCase(); const appIdentifier = syncInfo.projectData.projectIdentifiers[platform]; const deviceProjectRootOptions: IDeviceProjectRootOptions = _.assign( { appIdentifier }, - syncInfo + syncInfo, ); return { appIdentifier, @@ -314,10 +314,10 @@ export abstract class PlatformLiveSyncServiceBase { getDeviceProjectRootPath: () => this.$devicePathProvider.getDeviceProjectRootPath( syncInfo.device, - deviceProjectRootOptions + deviceProjectRootOptions, ), deviceSyncZipPath: this.$devicePathProvider.getDeviceSyncZipPath( - syncInfo.device + syncInfo.device, ), connectTimeout: syncInfo.connectTimeout, projectDir: syncInfo.projectData.projectDir, @@ -328,7 +328,7 @@ export abstract class PlatformLiveSyncServiceBase { localToDevicePaths: Mobile.ILocalToDevicePathData[], message: string, action: Function, - deviceIdentifier: string + deviceIdentifier: string, ): void { if (localToDevicePaths && localToDevicePaths.length < 10) { _.each(localToDevicePaths, (file: Mobile.ILocalToDevicePathData) => { @@ -336,15 +336,15 @@ export abstract class PlatformLiveSyncServiceBase { this.$logger, util.format( message, - color.yellow(path.basename(file.getLocalPath())) + color.yellow(path.basename(file.getLocalPath())), ), - deviceIdentifier + deviceIdentifier, ); }); } else { action.call( this.$logger, - util.format(message, "all files", deviceIdentifier) + util.format(message, "all files", deviceIdentifier), ); } } diff --git a/lib/services/log-parser-service.ts b/lib/services/log-parser-service.ts index f6c391e640..f6c439873e 100644 --- a/lib/services/log-parser-service.ts +++ b/lib/services/log-parser-service.ts @@ -7,12 +7,13 @@ import { injector } from "../common/yok"; export class LogParserService extends EventEmitter - implements ILogParserService { + implements ILogParserService +{ private parseRules: IDictionary = {}; constructor( private $deviceLogProvider: Mobile.IDeviceLogProvider, - private $errors: IErrors + private $errors: IErrors, ) { super(); } @@ -30,14 +31,14 @@ export class LogParserService private startParsingLogCore(): void { this.$deviceLogProvider.on( DEVICE_LOG_EVENT_NAME, - this.processDeviceLogResponse.bind(this) + this.processDeviceLogResponse.bind(this), ); } private processDeviceLogResponse( message: string, deviceIdentifier: string, - devicePlatform?: string + devicePlatform?: string, ) { const lines = message.split("\n"); _.forEach(lines, (line) => { diff --git a/lib/services/log-source-map-service.ts b/lib/services/log-source-map-service.ts index e52f88ecb7..c640f46f22 100644 --- a/lib/services/log-source-map-service.ts +++ b/lib/services/log-source-map-service.ts @@ -47,7 +47,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { private get $platformsDataService(): IPlatformsDataService { return this.$injector.resolve( - "platformsDataService" + "platformsDataService", ); } constructor( @@ -56,13 +56,13 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { private $injector: IInjector, private $options: IOptions, private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, - private $logger: ILogger + private $logger: ILogger, ) { this.getProjectData = _.memoize( - this.$projectDataService.getProjectData.bind(this.$projectDataService) + this.$projectDataService.getProjectData.bind(this.$projectDataService), ); this.getRuntimeVersion = _.memoize(this.getRuntimeVersionCore, (...args) => - args.join(LogSourceMapService.MEMOIZE_FUNCTION_RANDOM_KEY_FOR_JOIN) + args.join(LogSourceMapService.MEMOIZE_FUNCTION_RANDOM_KEY_FOR_JOIN), ); } @@ -75,7 +75,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { // Skip files bigger than 50MB if (this.$fs.getFileSize(filePath) > 50 * 1000 * 1000) { this.$logger.trace( - `Skipping source map for file ${filePath} because it is too big (> 50MB).` + `Skipping source map for file ${filePath} because it is too big (> 50MB).`, ); return; } @@ -86,9 +86,9 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { source, (filename) => { return this.$fs.readText( - path.join(path.dirname(filePath), filename) + path.join(path.dirname(filePath), filename), ); - } + }, ); } else { sourceMapRaw = sourceMapConverter.fromSource(source); @@ -105,7 +105,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { } } catch (err) { this.$logger.trace( - `Unable to set sourceMapConsumer for file ${filePath}. Error is: ${err}` + `Unable to set sourceMapConsumer for file ${filePath}. Error is: ${err}`, ); } } @@ -113,7 +113,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { public replaceWithOriginalFileLocations( platform: string, messageData: string, - loggingOptions: Mobile.IDeviceLogOptions + loggingOptions: Mobile.IDeviceLogOptions, ): string { if (!messageData || !loggingOptions || !loggingOptions.projectDir) { return messageData; @@ -134,13 +134,13 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { const originalLocation = this.getOriginalFileLocation( platform, parsedLine, - projectData + projectData, ); if (originalLocation && originalLocation.sourceFile) { const runtimeVersion = this.getRuntimeVersion( loggingOptions.projectDir, - platform + platform, ); const { sourceFile, line, column } = originalLocation; if ( @@ -148,7 +148,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { semver.gte(semver.coerce(runtimeVersion), "6.1.0") ) { const lastIndexOfFile = rawLine.lastIndexOf( - LogSourceMapService.FILE_PREFIX + LogSourceMapService.FILE_PREFIX, ); const firstPart = rawLine.substr(0, lastIndexOfFile); @@ -158,7 +158,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { .substring(lastIndexOfFile) .replace( /file:\/\/\/.+?:\d+:\d+/, - `${LogSourceMapService.FILE_PREFIX_REPLACEMENT}${sourceFile}:${line}:${column}` + `${LogSourceMapService.FILE_PREFIX_REPLACEMENT}${sourceFile}:${line}:${column}`, ) + "\n"; } else { @@ -178,17 +178,17 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { const projectData = this.getProjectData(projectDir); const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); const runtimeVersionData = this.$projectDataService.getRuntimePackage( projectData.projectDir, - platformData.platformNameLowerCase + platformData.platformNameLowerCase, ); runtimeVersion = runtimeVersionData && runtimeVersionData.version; } catch (err) { this.$logger.trace( `Unable to get runtime version for project directory: ${projectDir} and platform ${platform}. Error is: `, - err + err, ); } @@ -198,11 +198,11 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { private getOriginalFileLocation( platform: string, parsedLine: IParsedMessage, - projectData: IProjectData + projectData: IProjectData, ): IFileLocation { const fileLocation = path.join( this.getFilesLocation(platform, projectData), - this.$options.hostProjectModuleName + this.$options.hostProjectModuleName, ); if (parsedLine && parsedLine.filePath) { @@ -236,7 +236,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { }); if ( this.$fs.exists( - path.join(projectData.projectDir, platformSpecificFile) + path.join(projectData.projectDir, platformSpecificFile), ) ) { this.originalFilesLocationCache[sourceFile] = @@ -258,14 +258,14 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { private parseAndroidLog( projectData: IProjectData, - rawMessage: string + rawMessage: string, ): IParsedMessage { // "JS: at module.exports.push../main-view-model.ts.HelloWorldModel.onTap (file:///data/data/org.nativescript.sourceMap/files/app/bundle.js:303:17)" // "System.err: File: "file:///data/data/org.nativescript.sourceMap/files/app/bundle.js, line: 304, column: 8" const fileIndex = rawMessage.lastIndexOf(LogSourceMapService.FILE_PREFIX); const deviceProjectPath = util.format( ANDROID_DEVICE_APP_ROOT_TEMPLATE, - projectData.projectIdentifiers.android + projectData.projectIdentifiers.android, ); let separator = ","; let messageSuffix = ""; @@ -273,7 +273,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { if (fileIndex >= 0) { const fileSubstring = rawMessage.substring( - fileIndex + LogSourceMapService.FILE_PREFIX.length + fileIndex + LogSourceMapService.FILE_PREFIX.length, ); //"data/data/org.nativescript.sourceMap/files/app/bundle.js, line: 304, column: 8" parts = fileSubstring.split(separator); @@ -320,7 +320,7 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { if (fileIndex >= 0) { // "app/vendor.js:131:36: HMR: Hot Module Replacement Enabled. Waiting for signal." const fileSubstring = rawMessage.substring( - fileIndex + LogSourceMapService.FILE_PREFIX.length + fileIndex + LogSourceMapService.FILE_PREFIX.length, ); parts = fileSubstring.split(":"); @@ -345,12 +345,12 @@ export class LogSourceMapService implements Mobile.ILogSourceMapService { private getFilesLocation( platform: string, - projectData: IProjectData + projectData: IProjectData, ): string { try { const platformsData = this.$platformsDataService.getPlatformData( platform.toLowerCase(), - projectData + projectData, ); return platformsData.appDestinationDirectoryPath; } catch (err) { diff --git a/lib/services/marking-mode-service.ts b/lib/services/marking-mode-service.ts index ebe0474e54..894a506dbb 100644 --- a/lib/services/marking-mode-service.ts +++ b/lib/services/marking-mode-service.ts @@ -21,14 +21,14 @@ export class MarkingModeService implements IMarkingModeService { private $logger: ILogger, private $projectConfigService: IProjectConfigService, private $projectHelper: IProjectHelper, - private $projectDataService: IProjectDataService + private $projectDataService: IProjectDataService, ) {} public async handleMarkingModeFullDeprecation( - options: IMarkingModeFullDeprecationOptions + options: IMarkingModeFullDeprecationOptions, ): Promise { const markingModeValue = this.$projectConfigService.getValue( - "android.markingMode" + "android.markingMode", ); const { skipWarnings, forceSwitch } = options; @@ -43,7 +43,7 @@ export class MarkingModeService implements IMarkingModeService { // if version is null - we are about to add the latest runtime, so no need to warn const { version } = this.$projectDataService.getRuntimePackage( this.$projectHelper.projectDir, - PlatformTypes.android + PlatformTypes.android, ); const isMarkingModeFullDefault = version && semver.lt(semver.coerce(version), "7.0.0-rc.5"); diff --git a/lib/services/metadata-filtering-service.ts b/lib/services/metadata-filtering-service.ts index 3d46c5fe0e..ecd1689407 100644 --- a/lib/services/metadata-filtering-service.ts +++ b/lib/services/metadata-filtering-service.ts @@ -18,12 +18,12 @@ export class MetadataFilteringService implements IMetadataFilteringService { private $pluginsService: IPluginsService, private $mobileHelper: Mobile.IMobileHelper, private $platformsDataService: IPlatformsDataService, - private $logger: ILogger + private $logger: ILogger, ) {} public generateMetadataFilters( projectData: IProjectData, - platform: string + platform: string, ): void { this.generateWhitelist(projectData, platform); this.generateBlacklist(projectData, platform); @@ -33,28 +33,27 @@ export class MetadataFilteringService implements IMetadataFilteringService { const platformsDirPath = this.getPlatformsDirPath(projectData, platform); const pathToWhitelistFile = path.join( platformsDirPath, - MetadataFilteringConstants.WHITELIST_FILE_NAME + MetadataFilteringConstants.WHITELIST_FILE_NAME, ); this.$fs.deleteFile(pathToWhitelistFile); const nativeApiConfiguration = this.getNativeApiConfigurationForPlatform( projectData, - platform + platform, ); if (nativeApiConfiguration) { const whitelistedItems: string[] = []; if (nativeApiConfiguration["whitelist-plugins-usages"]) { const plugins = this.$pluginsService.getAllProductionPlugins( projectData, - platform + platform, ); for (const pluginData of plugins) { - const pathToPlatformsDir = pluginData.pluginPlatformsFolderPath( - platform - ); + const pathToPlatformsDir = + pluginData.pluginPlatformsFolderPath(platform); const pathToPluginsMetadataConfig = path.join( pathToPlatformsDir, - MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME + MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME, ); if (this.$fs.exists(pathToPluginsMetadataConfig)) { const pluginConfig: INativeApiUsagePluginConfiguration = @@ -63,17 +62,17 @@ export class MetadataFilteringService implements IMetadataFilteringService { `Adding content of ${pathToPluginsMetadataConfig} to whitelisted items of metadata filtering: ${JSON.stringify( pluginConfig, null, - 2 - )}` + 2, + )}`, ); const itemsToAdd = pluginConfig.uses || []; if (itemsToAdd.length) { whitelistedItems.push( - `// Added from: ${pathToPluginsMetadataConfig}` + `// Added from: ${pathToPluginsMetadataConfig}`, ); whitelistedItems.push(...itemsToAdd); whitelistedItems.push( - `// Finished part from ${pathToPluginsMetadataConfig}${os.EOL}` + `// Finished part from ${pathToPluginsMetadataConfig}${os.EOL}`, ); } } @@ -87,8 +86,8 @@ export class MetadataFilteringService implements IMetadataFilteringService { `Adding content from application to whitelisted items of metadata filtering: ${JSON.stringify( applicationWhitelistedItems, null, - 2 - )}` + 2, + )}`, ); whitelistedItems.push(`// Added from application`); @@ -106,28 +105,27 @@ export class MetadataFilteringService implements IMetadataFilteringService { const platformsDirPath = this.getPlatformsDirPath(projectData, platform); const pathToBlacklistFile = path.join( platformsDirPath, - MetadataFilteringConstants.BLACKLIST_FILE_NAME + MetadataFilteringConstants.BLACKLIST_FILE_NAME, ); this.$fs.deleteFile(pathToBlacklistFile); const nativeApiConfiguration = this.getNativeApiConfigurationForPlatform( projectData, - platform + platform, ); if (nativeApiConfiguration) { const blacklistedItems: string[] = nativeApiConfiguration.blacklist || []; if (nativeApiConfiguration["whitelist-plugins-usages"]) { const plugins = this.$pluginsService.getAllProductionPlugins( projectData, - platform + platform, ); for (const pluginData of plugins) { - const pathToPlatformsDir = pluginData.pluginPlatformsFolderPath( - platform - ); + const pathToPlatformsDir = + pluginData.pluginPlatformsFolderPath(platform); const pathToPluginsMetadataConfig = path.join( pathToPlatformsDir, - MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME + MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME, ); if (this.$fs.exists(pathToPluginsMetadataConfig)) { const pluginConfig: INativeApiUsagePluginConfiguration = @@ -136,17 +134,17 @@ export class MetadataFilteringService implements IMetadataFilteringService { `Adding content of ${pathToPluginsMetadataConfig} to whitelisted items of metadata filtering: ${JSON.stringify( pluginConfig, null, - 2 - )}` + 2, + )}`, ); const itemsToAdd = pluginConfig.blacklist || []; if (itemsToAdd.length) { blacklistedItems.push( - `// Added from: ${pathToPluginsMetadataConfig}` + `// Added from: ${pathToPluginsMetadataConfig}`, ); blacklistedItems.push(...itemsToAdd); blacklistedItems.push( - `// Finished part from ${pathToPluginsMetadataConfig}${os.EOL}` + `// Finished part from ${pathToPluginsMetadataConfig}${os.EOL}`, ); } } @@ -157,20 +155,18 @@ export class MetadataFilteringService implements IMetadataFilteringService { } } else { this.$logger.trace( - `There's no application configuration for metadata filtering for platform ${platform}. Full metadata will be generated.` + `There's no application configuration for metadata filtering for platform ${platform}. Full metadata will be generated.`, ); } } private getNativeApiConfigurationForPlatform( projectData: IProjectData, - platform: string + platform: string, ): INativeApiUsageConfiguration { let config: INativeApiUsageConfiguration = null; - const pathToApplicationConfigurationFile = this.getPathToApplicationConfigurationForPlatform( - projectData, - platform - ); + const pathToApplicationConfigurationFile = + this.getPathToApplicationConfigurationForPlatform(projectData, platform); if (this.$fs.exists(pathToApplicationConfigurationFile)) { config = this.$fs.readJson(pathToApplicationConfigurationFile); } @@ -180,23 +176,23 @@ export class MetadataFilteringService implements IMetadataFilteringService { private getPlatformsDirPath( projectData: IProjectData, - platform: string + platform: string, ): string { const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); return platformData.projectRoot; } private getPathToApplicationConfigurationForPlatform( projectData: IProjectData, - platform: string + platform: string, ): string { return path.join( projectData.appResourcesDirectoryPath, this.$mobileHelper.normalizePlatformName(platform), - MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME + MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME, ); } } diff --git a/lib/services/performance-service.ts b/lib/services/performance-service.ts index 3d4266ee56..d2c016aed2 100644 --- a/lib/services/performance-service.ts +++ b/lib/services/performance-service.ts @@ -17,7 +17,7 @@ export class PerformanceService implements IPerformanceService { private $options: IOptions, private $fs: IFileSystem, private $logger: ILogger, - private $analyticsService: IAnalyticsService + private $analyticsService: IAnalyticsService, ) { if (this.isPerformanceModuleSupported()) { this.performance = require("perf_hooks").performance; @@ -28,7 +28,7 @@ export class PerformanceService implements IPerformanceService { methodInfo: string, startTime: number, endTime: number, - args: any[] + args: any[], ): void { const executionTime = Math.floor(endTime - startTime); @@ -39,13 +39,13 @@ export class PerformanceService implements IPerformanceService { this.$options.performance, methodInfo, executionTime, - args + args, ); } else if (this.$options.performance) { this.$logger.info( PerformanceService.LOG_MESSAGE_TEMPLATE, methodInfo, - executionTime + executionTime, ); } } @@ -61,7 +61,7 @@ export class PerformanceService implements IPerformanceService { private isPerformanceModuleSupported(): boolean { return semver.gte( process.version, - PerformanceService.MIN_NODE_PERFORMANCE_MODULE_VERSION + PerformanceService.MIN_NODE_PERFORMANCE_MODULE_VERSION, ); } @@ -81,7 +81,7 @@ export class PerformanceService implements IPerformanceService { filePath: string, methodInfo: string, executionTime: number, - args: any[] + args: any[], ) { let methodArgs; @@ -103,12 +103,12 @@ export class PerformanceService implements IPerformanceService { } catch (e) { this.$logger.trace( PerformanceService.FAIL_LOG_MESSAGE_TEMPLATE, - methodInfo + methodInfo, ); this.$logger.info( PerformanceService.LOG_MESSAGE_TEMPLATE, methodInfo, - executionTime + executionTime, ); } } diff --git a/lib/services/platform-environment-requirements.ts b/lib/services/platform-environment-requirements.ts index 63dd5b8a0a..74c97dbc00 100644 --- a/lib/services/platform-environment-requirements.ts +++ b/lib/services/platform-environment-requirements.ts @@ -14,15 +14,13 @@ import { import { IInjector } from "../common/definitions/yok"; import { injector } from "../common/yok"; -export class PlatformEnvironmentRequirements - implements IPlatformEnvironmentRequirements -{ +export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequirements { constructor( private $doctorService: IDoctorService, private $errors: IErrors, private $analyticsService: IAnalyticsService, // @ts-ignore - required by the hook helper! - private $injector: IInjector + private $injector: IInjector, ) {} private static MISSING_LOCAL_SETUP_MESSAGE = @@ -30,7 +28,7 @@ export class PlatformEnvironmentRequirements @hook("checkEnvironment") public async checkEnvironmentRequirements( - input: ICheckEnvironmentRequirementsInput + input: ICheckEnvironmentRequirementsInput, ): Promise { const { platform, projectDir, runtimeVersion } = input; @@ -104,5 +102,5 @@ export class PlatformEnvironmentRequirements injector.register( "platformEnvironmentRequirements", - PlatformEnvironmentRequirements + PlatformEnvironmentRequirements, ); diff --git a/lib/services/platform-project-service-base.ts b/lib/services/platform-project-service-base.ts index c1d8b50687..7a76837f85 100644 --- a/lib/services/platform-project-service-base.ts +++ b/lib/services/platform-project-service-base.ts @@ -12,10 +12,11 @@ import { PlatformTypes } from "../constants"; export abstract class PlatformProjectServiceBase extends EventEmitter - implements IPlatformProjectServiceBase { + implements IPlatformProjectServiceBase +{ constructor( protected $fs: IFileSystem, - protected $projectDataService: IProjectDataService + protected $projectDataService: IProjectDataService, ) { super(); } @@ -24,7 +25,7 @@ export abstract class PlatformProjectServiceBase public getPluginPlatformsFolderPath( pluginData: IPluginData, - platform: string + platform: string, ): string { return pluginData.pluginPlatformsFolderPath(platform); } @@ -32,7 +33,7 @@ export abstract class PlatformProjectServiceBase public getFrameworkVersion(projectData: IProjectData): string { const frameworkData = this.$projectDataService.getRuntimePackage( projectData.projectDir, - this.getPlatformData(projectData).platformNameLowerCase + this.getPlatformData(projectData).platformNameLowerCase, ); return frameworkData && frameworkData.version; } @@ -40,11 +41,11 @@ export abstract class PlatformProjectServiceBase protected getAllNativeLibrariesForPlugin( pluginData: IPluginData, platform: string, - filter: (fileName: string, _pluginPlatformsFolderPath: string) => boolean + filter: (fileName: string, _pluginPlatformsFolderPath: string) => boolean, ): string[] { const pluginPlatformsFolderPath = this.getPluginPlatformsFolderPath( pluginData, - platform + platform, ); let nativeLibraries: string[] = []; @@ -53,11 +54,11 @@ export abstract class PlatformProjectServiceBase this.$fs.exists(pluginPlatformsFolderPath) ) { const platformsContents = this.$fs.readDirectory( - pluginPlatformsFolderPath + pluginPlatformsFolderPath, ); nativeLibraries = _(platformsContents) .filter((platformItemName) => - filter(platformItemName, pluginPlatformsFolderPath) + filter(platformItemName, pluginPlatformsFolderPath), ) .value(); } diff --git a/lib/services/platform/add-platform-service.ts b/lib/services/platform/add-platform-service.ts index b93aba4ea7..8bc92221a0 100644 --- a/lib/services/platform/add-platform-service.ts +++ b/lib/services/platform/add-platform-service.ts @@ -25,7 +25,7 @@ export class AddPlatformService implements IAddPlatformService { // private $projectDataService: IProjectDataService, private $packageManager: IPackageManager, private $terminalSpinnerService: ITerminalSpinnerService, - private $analyticsService: IAnalyticsService // private $tempService: ITempService + private $analyticsService: IAnalyticsService, // private $tempService: ITempService ) {} public async addProjectHost() {} @@ -34,7 +34,7 @@ export class AddPlatformService implements IAddPlatformService { projectData: IProjectData, platformData: IPlatformData, packageToInstall: string, - addPlatformData: IAddPlatformData + addPlatformData: IAddPlatformData, ): Promise { const spinner = this.$terminalSpinnerService.createSpinner(); @@ -46,10 +46,10 @@ export class AddPlatformService implements IAddPlatformService { // : await this.installPackage(projectData.projectDir, packageToInstall); const frameworkDirPath = await this.installPackage( projectData.projectDir, - packageToInstall + packageToInstall, ); const frameworkPackageJsonContent = this.$fs.readJson( - path.join(frameworkDirPath, "..", "package.json") + path.join(frameworkDirPath, "..", "package.json"), ); const frameworkVersion = frameworkPackageJsonContent.version; @@ -64,7 +64,7 @@ export class AddPlatformService implements IAddPlatformService { platformData, projectData, frameworkDirPath, - frameworkVersion + frameworkVersion, ); } @@ -72,7 +72,7 @@ export class AddPlatformService implements IAddPlatformService { } catch (err) { const platformPath = path.join( projectData.platformsDir, - platformData.platformNameLowerCase + platformData.platformNameLowerCase, ); this.$fs.deleteDirectory(platformPath); throw err; @@ -84,11 +84,11 @@ export class AddPlatformService implements IAddPlatformService { public async setPlatformVersion( platformData: IPlatformData, projectData: IProjectData, - frameworkVersion: string + frameworkVersion: string, ): Promise { await this.installPackage( projectData.projectDir, - `${platformData.frameworkPackageName}@${frameworkVersion}` + `${platformData.frameworkPackageName}@${frameworkVersion}`, ); } @@ -106,7 +106,7 @@ export class AddPlatformService implements IAddPlatformService { private async installPackage( projectDir: string, - packageName: string + packageName: string, ): Promise { const frameworkDir = this.resolveFrameworkDir(projectDir, packageName); if (frameworkDir && this.$fs.exists(frameworkDir)) { @@ -122,7 +122,7 @@ export class AddPlatformService implements IAddPlatformService { dev: true, "save-dev": true, "save-exact": true, - } as any + } as any, ); if (!installedPackage.name) { @@ -172,7 +172,7 @@ export class AddPlatformService implements IAddPlatformService { } catch (err) { this.$logger.trace( `Couldn't resolve installed framework. Continuing with install...`, - err + err, ); } return null; @@ -183,14 +183,14 @@ export class AddPlatformService implements IAddPlatformService { platformData: IPlatformData, projectData: IProjectData, frameworkDirPath: string, - frameworkVersion: string + frameworkVersion: string, ): Promise { // here we should use ios OR android const platformDir = this.$options.hostProjectPath ?? path.join( projectData.platformsDir, - platformData.normalizedPlatformName.toLowerCase() + platformData.normalizedPlatformName.toLowerCase(), ); this.$fs.deleteDirectory(platformDir); @@ -198,21 +198,21 @@ export class AddPlatformService implements IAddPlatformService { await platformData.platformProjectService.createProject( path.resolve(frameworkDirPath), frameworkVersion, - projectData + projectData, ); platformData.platformProjectService.ensureConfigurationFileInAppResources( - projectData + projectData, ); await platformData.platformProjectService.interpolateData(projectData); platformData.platformProjectService.afterCreateProject( platformData.projectRoot, - projectData + projectData, ); } private async trackPlatformVersion( frameworkVersion: string, - platformData: IPlatformData + platformData: IPlatformData, ): Promise { await this.$analyticsService.trackEventActionInGoogleAnalytics({ action: TrackActionNames.AddPlatform, diff --git a/lib/services/platform/platform-validation-service.ts b/lib/services/platform/platform-validation-service.ts index c29d96b9f8..18afa39894 100644 --- a/lib/services/platform/platform-validation-service.ts +++ b/lib/services/platform/platform-validation-service.ts @@ -12,7 +12,7 @@ export class PlatformValidationService implements IPlatformValidationService { private $fs: IFileSystem, private $logger: ILogger, private $mobileHelper: Mobile.IMobileHelper, - private $platformsDataService: IPlatformsDataService + private $platformsDataService: IPlatformsDataService, ) {} public isValidPlatform(platform: string, projectData: IProjectData): boolean { @@ -35,27 +35,27 @@ export class PlatformValidationService implements IPlatformValidationService { if (!this.isValidPlatform(platform, projectData)) { const platformNames = helpers.formatListOfNames( - this.$mobileHelper.platformNames + this.$mobileHelper.platformNames, ); this.$errors.fail( - `Invalid platform ${platform}. Valid platforms are ${platformNames}.` + `Invalid platform ${platform}. Valid platforms are ${platformNames}.`, ); } } public validatePlatformInstalled( platform: string, - projectData: IProjectData + projectData: IProjectData, ): void { this.validatePlatform(platform, projectData); const hasPlatformDirectory = this.$fs.exists( - path.join(projectData.platformsDir, platform.toLowerCase()) + path.join(projectData.platformsDir, platform.toLowerCase()), ); if (!hasPlatformDirectory) { this.$errors.fail( "The platform %s is not added to this project. Please use 'ns platform add '", - platform + platform, ); } } @@ -65,11 +65,11 @@ export class PlatformValidationService implements IPlatformValidationService { teamId: true | string, projectData: IProjectData, platform?: string, - aab?: boolean + aab?: boolean, ): Promise { if (platform && !this.$mobileHelper.isAndroidPlatform(platform) && aab) { this.$errors.fail( - "The --aab option is supported only for the Android platform." + "The --aab option is supported only for the Android platform.", ); } @@ -78,35 +78,35 @@ export class PlatformValidationService implements IPlatformValidationService { this.$logger.trace("Validate options for platform: " + platform); const platformData = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ); const result = await platformData.platformProjectService.validateOptions( projectData.projectIdentifiers[platform.toLowerCase()], provision, - teamId + teamId, ); return result; } else { let valid = true; const platforms = this.$mobileHelper.platformNames.map((p) => - p.toLowerCase() + p.toLowerCase(), ); for (const availablePlatform of platforms) { this.$logger.trace( - "Validate options for platform: " + availablePlatform + "Validate options for platform: " + availablePlatform, ); const platformData = this.$platformsDataService.getPlatformData( availablePlatform, - projectData + projectData, ); valid = valid && (await platformData.platformProjectService.validateOptions( projectData.projectIdentifiers[availablePlatform.toLowerCase()], provision, - teamId + teamId, )); } @@ -116,11 +116,11 @@ export class PlatformValidationService implements IPlatformValidationService { public isPlatformSupportedForOS( platform: string, - projectData: IProjectData + projectData: IProjectData, ): boolean { const targetedOS = this.$platformsDataService.getPlatformData( platform, - projectData + projectData, ).targetedOS; const res = !targetedOS || diff --git a/lib/services/platform/prepare-native-platform-service.ts b/lib/services/platform/prepare-native-platform-service.ts index a2e7703ddb..225d67a7be 100644 --- a/lib/services/platform/prepare-native-platform-service.ts +++ b/lib/services/platform/prepare-native-platform-service.ts @@ -8,15 +8,13 @@ import { IHooksService } from "../../common/declarations"; import { injector } from "../../common/yok"; import { IOptions } from "../../declarations"; -export class PrepareNativePlatformService - implements IPrepareNativePlatformService -{ +export class PrepareNativePlatformService implements IPrepareNativePlatformService { constructor( public $hooksService: IHooksService, private $nodeModulesBuilder: INodeModulesBuilder, private $projectChangesService: IProjectChangesService, private $metadataFilteringService: IMetadataFilteringService, - private $options: IOptions + private $options: IOptions, ) {} @performanceLog() @@ -24,13 +22,13 @@ export class PrepareNativePlatformService public async prepareNativePlatform( platformData: IPlatformData, projectData: IProjectData, - prepareData: IPrepareData + prepareData: IPrepareData, ): Promise { const { nativePrepare, release } = prepareData; const changesInfo = await this.$projectChangesService.checkForChanges( platformData, projectData, - prepareData + prepareData, ); if (nativePrepare && nativePrepare.skipNativePrepare) { return changesInfo.hasChanges; @@ -55,7 +53,7 @@ export class PrepareNativePlatformService if (hasChangesRequirePrepare || this.$options.hostProjectPath) { await platformData.platformProjectService.prepareProject( projectData, - prepareData + prepareData, ); } @@ -69,25 +67,25 @@ export class PrepareNativePlatformService if (hasNativeModulesChange || hasConfigChange) { await platformData.platformProjectService.processConfigurationFilesFromAppResources( projectData, - { release } + { release }, ); await platformData.platformProjectService.handleNativeDependenciesChange( projectData, - { release } + { release }, ); this.$metadataFilteringService.generateMetadataFilters( projectData, - platformData.platformNameLowerCase + platformData.platformNameLowerCase, ); } platformData.platformProjectService.interpolateConfigurationFile( - projectData + projectData, ); await this.$projectChangesService.setNativePlatformStatus( platformData, projectData, - { nativePlatformStatus: NativePlatformStatus.alreadyPrepared } + { nativePlatformStatus: NativePlatformStatus.alreadyPrepared }, ); return hasChanges; @@ -95,7 +93,7 @@ export class PrepareNativePlatformService private async cleanProject( platformData: IPlatformData, - options: { release: boolean } + options: { release: boolean }, ): Promise { // android build artifacts need to be cleaned up // when switching between debug, release and webpack builds @@ -117,7 +115,7 @@ export class PrepareNativePlatformService const { release: currentIsRelease } = options; if (previousWasRelease !== currentIsRelease) { await platformData.platformProjectService.cleanProject( - platformData.projectRoot + platformData.projectRoot, ); } } diff --git a/lib/services/platforms-data-service.ts b/lib/services/platforms-data-service.ts index 0f0ac30848..9704d692a5 100644 --- a/lib/services/platforms-data-service.ts +++ b/lib/services/platforms-data-service.ts @@ -10,7 +10,7 @@ export class PlatformsDataService implements IPlatformsDataService { constructor( private $options: IOptions, $androidProjectService: IPlatformProjectService, - $iOSProjectService: IPlatformProjectService + $iOSProjectService: IPlatformProjectService, ) { this.platformsDataService = { ios: $iOSProjectService, @@ -21,7 +21,7 @@ export class PlatformsDataService implements IPlatformsDataService { public getPlatformData( platform: string, - projectData: IProjectData + projectData: IProjectData, ): IPlatformData { const platformKey = platform && _.first(platform.toLowerCase().split("@")); let platformData: IPlatformData; diff --git a/lib/services/project-changes-service.ts b/lib/services/project-changes-service.ts index 12e7574bfc..dc5950f817 100644 --- a/lib/services/project-changes-service.ts +++ b/lib/services/project-changes-service.ts @@ -65,7 +65,7 @@ export class ProjectChangesService implements IProjectChangesService { private $logger: ILogger, private $options: IOptions, public $hooksService: IHooksService, - private $nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder + private $nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder, ) {} public get currentChanges(): IProjectChangesInfo { @@ -76,18 +76,18 @@ export class ProjectChangesService implements IProjectChangesService { public async checkForChanges( platformData: IPlatformData, projectData: IProjectData, - prepareData: IPrepareData + prepareData: IPrepareData, ): Promise { this._changesInfo = new ProjectChangesInfo(); const isNewPrepareInfo = await this.ensurePrepareInfo( platformData, projectData, - prepareData + prepareData, ); if (!isNewPrepareInfo) { let platformResourcesDir = path.join( projectData.appResourcesDirectoryPath, - platformData.normalizedPlatformName + platformData.normalizedPlatformName, ); if ( @@ -97,19 +97,19 @@ export class ProjectChangesService implements IProjectChangesService { ) { platformResourcesDir = path.join( projectData.appResourcesDirectoryPath, - this.$devicePlatformsConstants.iOS + this.$devicePlatformsConstants.iOS, ); } this._changesInfo.appResourcesChanged = this.containsNewerFiles( platformResourcesDir, - projectData + projectData, ); this.$nodeModulesDependenciesBuilder .getProductionDependencies( projectData.projectDir, - projectData.ignoredDependencies + projectData.ignoredDependencies, ) .filter( (dep) => @@ -118,9 +118,9 @@ export class ProjectChangesService implements IProjectChangesService { path.join( dep.directory, PLATFORMS_DIR_NAME, - platformData.platformNameLowerCase - ) - ) + platformData.platformNameLowerCase, + ), + ), ) .forEach((dep) => { this._changesInfo.nativeChanged = @@ -129,23 +129,23 @@ export class ProjectChangesService implements IProjectChangesService { path.join( dep.directory, PLATFORMS_DIR_NAME, - platformData.platformNameLowerCase + platformData.platformNameLowerCase, ), - projectData + projectData, ) || this.isFileModified( - path.join(dep.directory, PACKAGE_JSON_FILE_NAME) + path.join(dep.directory, PACKAGE_JSON_FILE_NAME), ); }); if (!this._changesInfo.nativeChanged) { this._prepareInfo.projectFileHash = this.getProjectFileStrippedHash( projectData.projectDir, - platformData + platformData, ); this._changesInfo.nativeChanged = this.isProjectFileChanged( projectData.projectDir, - platformData + platformData, ); } @@ -159,7 +159,7 @@ export class ProjectChangesService implements IProjectChangesService { this._changesInfo.nativeChanged || this._changesInfo.nsConfigChanged; this.$logger.trace( - `Set nativeChanged to ${this._changesInfo.nativeChanged}.` + `Set nativeChanged to ${this._changesInfo.nativeChanged}.`, ); if ( @@ -179,7 +179,7 @@ export class ProjectChangesService implements IProjectChangesService { } this.$logger.trace( - `Set value of configChanged to ${this._changesInfo.configChanged}` + `Set value of configChanged to ${this._changesInfo.configChanged}`, ); } @@ -190,7 +190,7 @@ export class ProjectChangesService implements IProjectChangesService { await platformData.platformProjectService.checkForChanges( this._changesInfo, prepareData, - projectData + projectData, ); } @@ -199,7 +199,7 @@ export class ProjectChangesService implements IProjectChangesService { `Setting all setting to true. Current options are: `, prepareData, " old prepare info is: ", - this._prepareInfo + this._prepareInfo, ); this._changesInfo.appResourcesChanged = true; this._changesInfo.configChanged = true; @@ -207,7 +207,7 @@ export class ProjectChangesService implements IProjectChangesService { } if (this._changesInfo.appResourcesChanged) { this.$logger.trace( - `Set configChanged to true, appResourcesChanged is: ${this._changesInfo.appResourcesChanged}` + `Set configChanged to true, appResourcesChanged is: ${this._changesInfo.appResourcesChanged}`, ); this._changesInfo.configChanged = true; } @@ -230,7 +230,7 @@ export class ProjectChangesService implements IProjectChangesService { public getPrepareInfoFilePath(platformData: IPlatformData): string { const prepareInfoFilePath = path.join( platformData.projectRoot, - prepareInfoFileName + prepareInfoFileName, ); return prepareInfoFilePath; @@ -258,7 +258,7 @@ export class ProjectChangesService implements IProjectChangesService { public async savePrepareInfo( platformData: IPlatformData, projectData: IProjectData, - prepareData: IPrepareData + prepareData: IPrepareData, ): Promise { if (!this._prepareInfo) { await this.ensurePrepareInfo(platformData, projectData, prepareData); @@ -276,7 +276,7 @@ export class ProjectChangesService implements IProjectChangesService { public async setNativePlatformStatus( platformData: IPlatformData, projectData: IProjectData, - addedPlatform: IAddedNativePlatform + addedPlatform: IAddedNativePlatform, ): Promise { this._prepareInfo = this._prepareInfo || this.getPrepareInfo(platformData); if ( @@ -298,13 +298,13 @@ export class ProjectChangesService implements IProjectChangesService { private async ensurePrepareInfo( platformData: IPlatformData, projectData: IProjectData, - prepareData: IPrepareData + prepareData: IPrepareData, ): Promise { this._prepareInfo = this.getPrepareInfo(platformData); if (this._prepareInfo) { const prepareInfoFile = path.join( platformData.projectRoot, - prepareInfoFileName + prepareInfoFileName, ); this._outputProjectMtime = this.$fs .getFsStats(prepareInfoFile) @@ -326,7 +326,7 @@ export class ProjectChangesService implements IProjectChangesService { changesRequireBuild: true, projectFileHash: this.getProjectFileStrippedHash( projectData.projectDir, - platformData + platformData, ), changesRequireBuildTime: null, }; @@ -343,7 +343,7 @@ export class ProjectChangesService implements IProjectChangesService { private getProjectFileStrippedHash( projectDir: string, - platformData: IPlatformData + platformData: IPlatformData, ): string { const projectFilePath = path.join(projectDir, PACKAGE_JSON_FILE_NAME); const projectFileContents = this.$fs.readJson(projectFilePath); @@ -352,7 +352,7 @@ export class ProjectChangesService implements IProjectChangesService { const projectFileStrippedContents = _.pick( projectFileContents, - relevantProperties + relevantProperties, ); // _(this.$devicePlatformsConstants) @@ -368,11 +368,11 @@ export class ProjectChangesService implements IProjectChangesService { private isProjectFileChanged( projectDir: string, - platformData: IPlatformData + platformData: IPlatformData, ): boolean { const projectFileStrippedContentsHash = this.getProjectFileStrippedHash( projectDir, - platformData + platformData, ); const prepareInfo = this.getPrepareInfo(platformData); return projectFileStrippedContentsHash !== prepareInfo.projectFileHash; @@ -403,7 +403,7 @@ export class ProjectChangesService implements IProjectChangesService { if (this.isFileModified(dir)) { this.$logger.trace( - `containsNewerFiles returns true for ${dir} as the dir itself has been modified.` + `containsNewerFiles returns true for ${dir} as the dir itself has been modified.`, ); return true; } @@ -417,7 +417,7 @@ export class ProjectChangesService implements IProjectChangesService { if (changed) { this.$logger.trace( - `containsNewerFiles returns true for ${dir}. The modified file is ${filePath}` + `containsNewerFiles returns true for ${dir}. The modified file is ${filePath}`, ); return true; } diff --git a/lib/services/project-cleanup-service.ts b/lib/services/project-cleanup-service.ts index 25d7b01edf..bd00dc8267 100644 --- a/lib/services/project-cleanup-service.ts +++ b/lib/services/project-cleanup-service.ts @@ -20,18 +20,18 @@ export class ProjectCleanupService implements IProjectCleanupService { private $fs: IFileSystem, private $logger: ILogger, private $projectHelper: IProjectHelper, - private $terminalSpinnerService: ITerminalSpinnerService + private $terminalSpinnerService: ITerminalSpinnerService, ) {} public async clean( pathsToClean: string[], - options?: IProjectCleanupOptions + options?: IProjectCleanupOptions, ): Promise { this.spinner = this.$terminalSpinnerService.createSpinner({ isSilent: options?.silent, }); - let stats = options?.stats ? new Map() : false; + const stats = options?.stats ? new Map() : false; let success = true; for (const pathToClean of pathsToClean) { @@ -39,10 +39,10 @@ export class ProjectCleanupService implements IProjectCleanupService { (error) => { this.$logger.trace( `Encountered error while cleaning. Error is: ${error.message}.`, - error + error, ); return { ok: false }; - } + }, ); if (stats && "size" in cleanRes) { stats.set(pathToClean, cleanRes.size); @@ -63,7 +63,7 @@ export class ProjectCleanupService implements IProjectCleanupService { public async cleanPath( pathToClean: string, - options?: IProjectCleanupOptions + options?: IProjectCleanupOptions, ): Promise { const dryRun = options?.dryRun ?? false; const logPrefix = dryRun ? color.grey("(dry run) ") : ""; @@ -78,7 +78,7 @@ export class ProjectCleanupService implements IProjectCleanupService { const filePath = path.resolve(this.$projectHelper.projectDir, pathToClean); const displayPath = color.yellow( - `${path.relative(this.$projectHelper.projectDir, filePath)}` + `${path.relative(this.$projectHelper.projectDir, filePath)}`, ); this.$logger.trace(`${logPrefix}Trying to clean '${filePath}'`); @@ -93,13 +93,13 @@ export class ProjectCleanupService implements IProjectCleanupService { if (stat.isDirectory()) { this.$logger.trace( - `${logPrefix}Path '${filePath}' is a directory, deleting.` + `${logPrefix}Path '${filePath}' is a directory, deleting.`, ); !dryRun && this.$fs.deleteDirectorySafe(filePath); fileType = "directory"; } else { this.$logger.trace( - `${logPrefix}Path '${filePath}' is a file, deleting.` + `${logPrefix}Path '${filePath}' is a file, deleting.`, ); !dryRun && this.$fs.deleteFile(filePath); fileType = "file"; @@ -122,7 +122,7 @@ export class ProjectCleanupService implements IProjectCleanupService { this.$logger.trace(`${logPrefix}Path '${filePath}' not found, skipping.`); this.spinner.info( - `${logPrefix}Skipping ${displayPath} because it doesn't exist.` + `${logPrefix}Skipping ${displayPath} because it doesn't exist.`, ); if (options?.stats) { diff --git a/lib/services/project-data-service.ts b/lib/services/project-data-service.ts index 31e5a2a342..07647cad7a 100644 --- a/lib/services/project-data-service.ts +++ b/lib/services/project-data-service.ts @@ -77,7 +77,7 @@ export class ProjectDataService implements IProjectDataService { ); } - public getNSValueFromContent(jsonData: Object, propertyName: string): any { + public getNSValueFromContent(jsonData: object, propertyName: string): any { try { return this.getPropertyValueFromJson( jsonData, @@ -569,7 +569,7 @@ export class ProjectDataService implements IProjectDataService { }; } - private getNsConfigDefaultObject(data?: Object): INsConfig { + private getNsConfigDefaultObject(data?: object): INsConfig { const config: INsConfig = {}; Object.assign(config, data); @@ -711,7 +711,7 @@ export class ProjectDataService implements IProjectDataService { } @exported("projectDataService") - public getNsConfigDefaultContent(data?: Object): string { + public getNsConfigDefaultContent(data?: object): string { const config = this.getNsConfigDefaultObject(data); return JSON.stringify(config); diff --git a/lib/services/project-service.ts b/lib/services/project-service.ts index 91bc4bce84..30b3a2e013 100644 --- a/lib/services/project-service.ts +++ b/lib/services/project-service.ts @@ -47,7 +47,7 @@ export class ProjectService implements IProjectService { private $projectTemplatesService: IProjectTemplatesService, private $tempService: ITempService, private $staticConfig: IStaticConfig, - private $childProcess: IChildProcess + private $childProcess: IChildProcess, ) {} public async validateProjectName(opts: { @@ -58,7 +58,7 @@ export class ProjectService implements IProjectService { let projectName = opts.projectName; if (!projectName) { this.$errors.failWithHelp( - "You must specify when creating a new project." + "You must specify when creating a new project.", ); } @@ -76,7 +76,7 @@ export class ProjectService implements IProjectService { @exported("projectService") @performanceLog() public async createProject( - projectOptions: IProjectSettings + projectOptions: IProjectSettings, ): Promise { const projectName = await this.validateProjectName({ projectName: projectOptions.projectName, @@ -85,7 +85,7 @@ export class ProjectService implements IProjectService { }); const projectDir = this.getValidProjectDir( projectOptions.pathToProject, - projectName + projectName, ); this.$fs.createDirectory(projectDir); @@ -94,10 +94,10 @@ export class ProjectService implements IProjectService { projectOptions.appId || this.$projectHelper.generateDefaultAppId( projectName, - constants.DEFAULT_APP_IDENTIFIER_PREFIX + constants.DEFAULT_APP_IDENTIFIER_PREFIX, ); this.$logger.trace( - `Creating a new NativeScript project with name ${projectName} and id ${appId} at location ${projectDir}` + `Creating a new NativeScript project with name ${projectName} and id ${appId} at location ${projectDir}`, ); const projectCreationData = await this.createProjectCore({ @@ -123,12 +123,12 @@ export class ProjectService implements IProjectService { await this.$childProcess.exec(`git init ${projectDir}`); await this.$childProcess.exec(`git -C ${projectDir} add --all`); await this.$childProcess.exec( - `git -C ${projectDir} commit --no-verify -m "init"` + `git -C ${projectDir} commit --no-verify -m "init"`, ); } catch (err) { this.$logger.trace( "Unable to initialize git repository. Error is: ", - err + err, ); } } @@ -141,9 +141,8 @@ export class ProjectService implements IProjectService { @exported("projectService") public isValidNativeScriptProject(pathToProject?: string): boolean { try { - const projectData = this.$projectDataService.getProjectData( - pathToProject - ); + const projectData = + this.$projectDataService.getProjectData(pathToProject); return ( !!projectData && @@ -160,7 +159,7 @@ export class ProjectService implements IProjectService { private getValidProjectDir( pathToProject: string, - projectName: string + projectName: string, ): string { const selectedPath = path.resolve(pathToProject || "."); const projectDir = path.join(selectedPath, projectName); @@ -169,20 +168,15 @@ export class ProjectService implements IProjectService { } private async createProjectCore( - projectCreationSettings: IProjectCreationSettings + projectCreationSettings: IProjectCreationSettings, ): Promise { - const { - template, - projectDir, - appId, - projectName, - ignoreScripts, - } = projectCreationSettings; + const { template, projectDir, appId, projectName, ignoreScripts } = + projectCreationSettings; try { const templateData = await this.$projectTemplatesService.prepareTemplate( template, - projectDir + projectDir, ); await this.extractTemplate(projectDir, templateData); @@ -213,7 +207,7 @@ export class ProjectService implements IProjectService { @performanceLog() private async extractTemplate( projectDir: string, - templateData: ITemplateData + templateData: ITemplateData, ): Promise { this.$fs.ensureDirectoryExists(projectDir); @@ -226,42 +220,39 @@ export class ProjectService implements IProjectService { @performanceLog() public async ensureAppResourcesExist(projectDir: string): Promise { const projectData = this.$projectDataService.getProjectData(projectDir); - const appResourcesDestinationPath = projectData.getAppResourcesDirectoryPath( - projectDir - ); + const appResourcesDestinationPath = + projectData.getAppResourcesDirectoryPath(projectDir); if (!this.$fs.exists(appResourcesDestinationPath)) { this.$logger.trace( - "Project does not have App_Resources - fetching from default template." + "Project does not have App_Resources - fetching from default template.", ); this.$fs.createDirectory(appResourcesDestinationPath); const tempDir = await this.$tempService.mkdirSync("ns-default-template"); // the template installed doesn't have App_Resources -> get from a default template await this.$pacoteService.extractPackage( constants.RESERVED_TEMPLATE_NAMES["default"], - tempDir - ); - const templateProjectData = this.$projectDataService.getProjectData( - tempDir - ); - const templateAppResourcesDir = templateProjectData.getAppResourcesDirectoryPath( - tempDir + tempDir, ); + const templateProjectData = + this.$projectDataService.getProjectData(tempDir); + const templateAppResourcesDir = + templateProjectData.getAppResourcesDirectoryPath(tempDir); this.$fs.copyFile( path.join(templateAppResourcesDir, "*"), - appResourcesDestinationPath + appResourcesDestinationPath, ); } } @performanceLog() private alterPackageJsonData( - projectCreationSettings: IProjectCreationSettings + projectCreationSettings: IProjectCreationSettings, ): void { const { projectDir, projectName } = projectCreationSettings; const projectFilePath = path.join( projectDir, - this.$staticConfig.PROJECT_FILE_NAME + this.$staticConfig.PROJECT_FILE_NAME, ); let packageJsonData = this.$fs.readJson(projectFilePath); diff --git a/lib/services/project-templates-service.ts b/lib/services/project-templates-service.ts index fe93071cc8..05f49787a8 100644 --- a/lib/services/project-templates-service.ts +++ b/lib/services/project-templates-service.ts @@ -29,28 +29,27 @@ export class ProjectTemplatesService implements IProjectTemplatesService { private $packageInstallationManager: IPackageInstallationManager, private $pacoteService: IPacoteService, private $packageManager: INodePackageManager, - private $staticConfig: IStaticConfig + private $staticConfig: IStaticConfig, ) {} @performanceLog() public async prepareTemplate( templateValue: string, - projectDir: string + projectDir: string, ): Promise { if (!templateValue) { templateValue = constants.RESERVED_TEMPLATE_NAMES["default"]; } - const templateNameParts = await this.$packageManager.getPackageNameParts( - templateValue - ); + const templateNameParts = + await this.$packageManager.getPackageNameParts(templateValue); templateValue = constants.RESERVED_TEMPLATE_NAMES[templateNameParts.name] || templateNameParts.name; const version = await this.getDesiredVersion( templateValue, - templateNameParts.version + templateNameParts.version, ); const fullTemplateName = await this.$packageManager.getPackageFullName({ @@ -58,13 +57,12 @@ export class ProjectTemplatesService implements IProjectTemplatesService { version: version, }); - const templatePackageJsonContent = await this.getTemplatePackageJsonContent( - fullTemplateName - ); + const templatePackageJsonContent = + await this.getTemplatePackageJsonContent(fullTemplateName); const templateNameToBeTracked = this.getTemplateNameToBeTracked( templateValue, - templatePackageJsonContent + templatePackageJsonContent, ); if (templateNameToBeTracked) { await this.$analyticsService.trackEventActionInGoogleAnalytics({ @@ -87,14 +85,13 @@ export class ProjectTemplatesService implements IProjectTemplatesService { } private async getTemplatePackageJsonContent( - templateName: string + templateName: string, ): Promise { if (!this.templatePackageContents[templateName]) { - this.templatePackageContents[ - templateName - ] = await this.$pacoteService.manifest(templateName, { - fullMetadata: true, - }); + this.templatePackageContents[templateName] = + await this.$pacoteService.manifest(templateName, { + fullMetadata: true, + }); } return this.templatePackageContents[templateName]; @@ -102,7 +99,7 @@ export class ProjectTemplatesService implements IProjectTemplatesService { private getTemplateNameToBeTracked( templateName: string, - packageJsonContent: any + packageJsonContent: any, ): string { try { if (this.$fs.exists(templateName)) { @@ -115,14 +112,14 @@ export class ProjectTemplatesService implements IProjectTemplatesService { return templateName; } catch (err) { this.$logger.trace( - `Unable to get template name to be tracked, error is: ${err}` + `Unable to get template name to be tracked, error is: ${err}`, ); } } private async getDesiredVersion( templateName: string, - defaultVersion?: string + defaultVersion?: string, ) { if (defaultVersion) { return defaultVersion; @@ -134,12 +131,12 @@ export class ProjectTemplatesService implements IProjectTemplatesService { try { const cliMajorVersion = semver.parse( - semver.coerce(this.$staticConfig.version) + semver.coerce(this.$staticConfig.version), ).major; return `^${cliMajorVersion}.0.0`; } catch (err) { return this.$packageInstallationManager.getLatestCompatibleVersionSafe( - templateName + templateName, ); } } diff --git a/lib/services/start-service.ts b/lib/services/start-service.ts index 7ed068916d..9bf6ed5289 100644 --- a/lib/services/start-service.ts +++ b/lib/services/start-service.ts @@ -21,13 +21,13 @@ export default class StartService implements IStartService { private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $projectData: IProjectData, private $logger: ILogger, - private $staticConfig: IStaticConfig + private $staticConfig: IStaticConfig, ) {} toggleVerbose(): void { this.verbose = true; this.$logger.info( - this.verbose ? `Verbose logging enabled` : `Verbose logging disabled` + this.verbose ? `Verbose logging enabled` : `Verbose logging disabled`, ); } @@ -49,7 +49,7 @@ export default class StartService implements IStartService { NS_IS_INTERACTIVE: true, ...process.env, }, - } + }, ); (this as any)[platformLowerCase].stdout.on("data", (data: Buffer) => { @@ -97,7 +97,7 @@ export default class StartService implements IStartService { addKeyCommandOverrides() { const keys: IValidKeyName[] = ["w", "r", "R"]; - for (let key of keys) { + for (const key of keys) { this.$keyCommandHelper.addOverride(key, async () => { this.ios?.send(key); this.android?.send(key); diff --git a/lib/services/test-initialization-service.ts b/lib/services/test-initialization-service.ts index 166ca77da5..9365b31af9 100644 --- a/lib/services/test-initialization-service.ts +++ b/lib/services/test-initialization-service.ts @@ -13,13 +13,16 @@ import { injector } from "../common/yok"; export class TestInitializationService implements ITestInitializationService { private configsPath = path.join(__dirname, "..", "..", "config"); - constructor(private $errors: IErrors, private $fs: IFileSystem) {} + constructor( + private $errors: IErrors, + private $fs: IFileSystem, + ) {} @cache() public getDependencies(selectedFramework: string): IDependencyInformation[] { const dependenciesPath = path.join( this.configsPath, - "test-dependencies.json" + "test-dependencies.json", ); const allDependencies: { name: string; @@ -29,22 +32,25 @@ export class TestInitializationService implements ITestInitializationService { const dependenciesVersionsPath = path.join( this.configsPath, - "test-deps-versions-generated.json" + "test-deps-versions-generated.json", ); const dependenciesVersions = this.$fs.readJson(dependenciesVersionsPath); - const targetFrameworkDependencies: IDependencyInformation[] = allDependencies - .filter( - (dependency) => - !dependency.framework || dependency.framework === selectedFramework - ) - .map((dependency) => { - const dependencyVersion = dependenciesVersions[dependency.name]; - if (!dependencyVersion) { - this.$errors.fail(`'${dependency}' is not a registered dependency.`); - } - return { ...dependency, version: dependencyVersion }; - }); + const targetFrameworkDependencies: IDependencyInformation[] = + allDependencies + .filter( + (dependency) => + !dependency.framework || dependency.framework === selectedFramework, + ) + .map((dependency) => { + const dependencyVersion = dependenciesVersions[dependency.name]; + if (!dependencyVersion) { + this.$errors.fail( + `'${dependency}' is not a registered dependency.`, + ); + } + return { ...dependency, version: dependencyVersion }; + }); return targetFrameworkDependencies; } @@ -57,7 +63,7 @@ export class TestInitializationService implements ITestInitializationService { const configsPath = path.join(__dirname, "..", "..", "config"); const dependenciesPath = path.join(configsPath, "test-dependencies.json"); const allDependencies: { name: string; framework?: string }[] = JSON.parse( - fs.readFileSync(dependenciesPath, { encoding: "utf-8" }) + fs.readFileSync(dependenciesPath, { encoding: "utf-8" }), ); const frameworks = _.uniqBy(allDependencies, "framework") .map((item) => item && item.framework) diff --git a/lib/services/timeline-profiler-service.ts b/lib/services/timeline-profiler-service.ts index 31b5805548..a58d011bed 100644 --- a/lib/services/timeline-profiler-service.ts +++ b/lib/services/timeline-profiler-service.ts @@ -11,7 +11,7 @@ export interface ITimelineProfilerService { } const TIMELINE_LOG_RE = - /Timeline:\s*(\d*.?\d*ms:\s*)?([^\:]*\:)?(.*)\((\d*.?\d*)ms\.?\s*-\s*(\d*.\d*)ms\.?\)/; + /Timeline:\s*(\d*.?\d*ms:\s*)?([^:]*:)?(.*)\((\d*.?\d*)ms\.?\s*-\s*(\d*.\d*)ms\.?\)/; enum ChromeTraceEventPhase { BEGIN = "B", @@ -40,7 +40,7 @@ export class TimelineProfilerService implements ITimelineProfilerService { constructor( private $projectConfigService: IProjectConfigService, private $fs: IFileSystem, - private $logger: ILogger + private $logger: ILogger, ) {} private attachExitHanlder() { @@ -110,24 +110,24 @@ export class TimelineProfilerService implements ITimelineProfilerService { const deviceTimelineFileName = `timeline-${deviceIdentifier}.json`; this.$fs.writeJson( path.resolve(process.cwd(), deviceTimelineFileName), - deviceTimeline.timeline + deviceTimeline.timeline, ); this.$logger.info( `Timeline data for device ${color.cyan( - deviceIdentifier - )} written to ${color.green(deviceTimelineFileName)}` + deviceIdentifier, + )} written to ${color.green(deviceTimelineFileName)}`, ); }); this.$logger.info( color.green( - "\n\nTo view the timeline data, open the following URL in Chrome, and load the json file:" - ) + "\n\nTo view the timeline data, open the following URL in Chrome, and load the json file:", + ), ); this.$logger.info( color.green( - "devtools://devtools/bundled/inspector.html?panel=timeline\n\n" - ) + "devtools://devtools/bundled/inspector.html?panel=timeline\n\n", + ), ); process.exit(); diff --git a/lib/services/user-settings-service.ts b/lib/services/user-settings-service.ts index 2ba6be9831..001fbd782d 100644 --- a/lib/services/user-settings-service.ts +++ b/lib/services/user-settings-service.ts @@ -17,7 +17,7 @@ export class UserSettingsService implements IUserSettingsService { private get $jsonFileSettingsService(): IJsonFileSettingsService { const userSettingsFilePath = path.join( this.$settingsService.getProfileDir(), - "user-settings.json" + "user-settings.json", ); return this.$injector.resolve("jsonFileSettingsService", { jsonFileSettingsPath: userSettingsFilePath, @@ -26,30 +26,30 @@ export class UserSettingsService implements IUserSettingsService { constructor( private $injector: IInjector, - private $settingsService: ISettingsService + private $settingsService: ISettingsService, ) {} public getSettingValue( settingName: string, - cacheOpts?: ICacheTimeoutOpts + cacheOpts?: ICacheTimeoutOpts, ): Promise { return this.$jsonFileSettingsService.getSettingValue( settingName, - cacheOpts + cacheOpts, ); } public saveSetting( key: string, value: T, - cacheOpts?: IUseCacheOpts + cacheOpts?: IUseCacheOpts, ): Promise { return this.$jsonFileSettingsService.saveSetting(key, value, cacheOpts); } public saveSettings( data: IDictionary<{}>, - cacheOpts?: IUseCacheOpts + cacheOpts?: IUseCacheOpts, ): Promise { return this.$jsonFileSettingsService.saveSettings(data, cacheOpts); } diff --git a/lib/services/versions-service.ts b/lib/services/versions-service.ts index 3710ab52bc..f95d182769 100644 --- a/lib/services/versions-service.ts +++ b/lib/services/versions-service.ts @@ -33,16 +33,17 @@ class VersionsService implements IVersionsService { private $staticConfig: Config.IStaticConfig, private $pluginsService: IPluginsService, private $projectDataService: IProjectDataService, - private $terminalSpinnerService: ITerminalSpinnerService + private $terminalSpinnerService: ITerminalSpinnerService, ) { this.projectData = this.getProjectData(); } public async getNativescriptCliVersion(): Promise { const currentCliVersion = this.$staticConfig.version; - const latestCliVersion = await this.$packageInstallationManager.getLatestVersion( - constants.NATIVESCRIPT_KEY_NAME - ); + const latestCliVersion = + await this.$packageInstallationManager.getLatestVersion( + constants.NATIVESCRIPT_KEY_NAME, + ); return { componentName: constants.NATIVESCRIPT_KEY_NAME, @@ -52,9 +53,10 @@ class VersionsService implements IVersionsService { } public async getTnsCoreModulesVersion(): Promise { - const latestTnsCoreModulesVersion = await this.$packageInstallationManager.getLatestVersion( - constants.TNS_CORE_MODULES_NAME - ); + const latestTnsCoreModulesVersion = + await this.$packageInstallationManager.getLatestVersion( + constants.TNS_CORE_MODULES_NAME, + ); const nativescriptCoreModulesInfo: IVersionInformation = { componentName: constants.TNS_CORE_MODULES_NAME, latestVersion: latestTnsCoreModulesVersion, @@ -65,23 +67,21 @@ class VersionsService implements IVersionsService { if (this.projectData) { const nodeModulesPath = path.join( this.projectData.projectDir, - constants.NODE_MODULES_FOLDER_NAME + constants.NODE_MODULES_FOLDER_NAME, ); const scopedPackagePath = path.join( nodeModulesPath, - constants.SCOPED_TNS_CORE_MODULES + constants.SCOPED_TNS_CORE_MODULES, ); const tnsCoreModulesPath = path.join( nodeModulesPath, - constants.TNS_CORE_MODULES_NAME + constants.TNS_CORE_MODULES_NAME, ); - const dependsOnNonScopedPackage = !!this.projectData.dependencies[ - constants.TNS_CORE_MODULES_NAME - ]; - const dependsOnScopedPackage = !!this.projectData.dependencies[ - constants.SCOPED_TNS_CORE_MODULES - ]; + const dependsOnNonScopedPackage = + !!this.projectData.dependencies[constants.TNS_CORE_MODULES_NAME]; + const dependsOnScopedPackage = + !!this.projectData.dependencies[constants.SCOPED_TNS_CORE_MODULES]; // ensure the dependencies are installed, so we can get their actual versions from node_modules if ( @@ -90,28 +90,30 @@ class VersionsService implements IVersionsService { (dependsOnScopedPackage && !this.$fs.exists(scopedPackagePath)) ) { await this.$pluginsService.ensureAllDependenciesAreInstalled( - this.projectData + this.projectData, ); } if (dependsOnNonScopedPackage && this.$fs.exists(tnsCoreModulesPath)) { const currentTnsCoreModulesVersion = this.$fs.readJson( - path.join(tnsCoreModulesPath, constants.PACKAGE_JSON_FILE_NAME) + path.join(tnsCoreModulesPath, constants.PACKAGE_JSON_FILE_NAME), ).version; - nativescriptCoreModulesInfo.currentVersion = currentTnsCoreModulesVersion; + nativescriptCoreModulesInfo.currentVersion = + currentTnsCoreModulesVersion; versionInformations.push(nativescriptCoreModulesInfo); } if (dependsOnScopedPackage && this.$fs.exists(scopedPackagePath)) { const scopedModulesInformation: IVersionInformation = { componentName: constants.SCOPED_TNS_CORE_MODULES, - latestVersion: await this.$packageInstallationManager.getLatestVersion( - constants.SCOPED_TNS_CORE_MODULES - ), + latestVersion: + await this.$packageInstallationManager.getLatestVersion( + constants.SCOPED_TNS_CORE_MODULES, + ), }; const currentScopedPackageVersion = this.$fs.readJson( - path.join(scopedPackagePath, constants.PACKAGE_JSON_FILE_NAME) + path.join(scopedPackagePath, constants.PACKAGE_JSON_FILE_NAME), ).version; scopedModulesInformation.currentVersion = currentScopedPackageVersion; versionInformations.push(scopedModulesInformation); @@ -124,15 +126,15 @@ class VersionsService implements IVersionsService { } public async getRuntimesVersions( - platform?: string + platform?: string, ): Promise { const iosRuntime = this.$projectDataService.getRuntimePackage( this.projectData.projectDir, - constants.PlatformTypes.ios + constants.PlatformTypes.ios, ); const androidRuntime = this.$projectDataService.getRuntimePackage( this.projectData.projectDir, - constants.PlatformTypes.android + constants.PlatformTypes.android, ); let runtimes: IBasePluginData[] = []; @@ -146,9 +148,8 @@ class VersionsService implements IVersionsService { const runtimesVersions: IVersionInformation[] = await Promise.all( runtimes.map(async (runtime: IBasePluginData) => { - const latestVersion = await this.$packageInstallationManager.getLatestVersion( - runtime.name - ); + const latestVersion = + await this.$packageInstallationManager.getLatestVersion(runtime.name); const runtimeInformation: IVersionInformation = { componentName: runtime.name, currentVersion: runtime.version, @@ -156,32 +157,33 @@ class VersionsService implements IVersionsService { }; return runtimeInformation; - }) + }), ); return runtimesVersions; } public async getAllComponentsVersions( - platform?: string + platform?: string, ): Promise { try { let allComponents: IVersionInformation[] = []; - const nativescriptCliInformation: IVersionInformation = await this.getNativescriptCliVersion(); + const nativescriptCliInformation: IVersionInformation = + await this.getNativescriptCliVersion(); if (nativescriptCliInformation) { allComponents.push(nativescriptCliInformation); } if (this.projectData) { - const nativescriptCoreModulesInformation: IVersionInformation[] = await this.getTnsCoreModulesVersion(); + const nativescriptCoreModulesInformation: IVersionInformation[] = + await this.getTnsCoreModulesVersion(); if (nativescriptCoreModulesInformation) { allComponents.push(...nativescriptCoreModulesInformation); } - const runtimesVersions: IVersionInformation[] = await this.getRuntimesVersions( - platform - ); + const runtimesVersions: IVersionInformation[] = + await this.getRuntimesVersions(platform); allComponents = allComponents.concat(runtimesVersions); } @@ -204,7 +206,7 @@ class VersionsService implements IVersionsService { } catch (error) { this.$logger.trace( "Error while trying to get component information. Error is: ", - error + error, ); return []; } @@ -217,12 +219,12 @@ class VersionsService implements IVersionsService { { text: `Getting NativeScript components versions information...`, }, - () => this.getAllComponentsVersions(platform) + () => this.getAllComponentsVersions(platform), ); if (!helpers.isInteractive()) { versionsInformation.map((componentInformation) => - this.$logger.info(componentInformation.message) + this.$logger.info(componentInformation.message), ); } @@ -257,7 +259,7 @@ class VersionsService implements IVersionsService { private hasUpdate(component: IVersionInformation): boolean { return !semver.satisfies( component.latestVersion, - semver.validRange(component.currentVersion) + semver.validRange(component.currentVersion), ); } } diff --git a/lib/services/xcproj-service.ts b/lib/services/xcproj-service.ts index ddc5fe0ec1..4c2e773124 100644 --- a/lib/services/xcproj-service.ts +++ b/lib/services/xcproj-service.ts @@ -9,11 +9,11 @@ import { injector } from "../common/yok"; class XcprojService implements IXcprojService { public getXcodeprojPath( projectData: IProjectData, - projectRoot: string + projectRoot: string, ): string { return path.join( projectRoot, - projectData.projectName + IosProjectConstants.XcodeProjExtName + projectData.projectName + IosProjectConstants.XcodeProjExtName, ); } diff --git a/lib/tools/config-manipulation/config-transformer.ts b/lib/tools/config-manipulation/config-transformer.ts index 50f926a530..07a6dea845 100644 --- a/lib/tools/config-manipulation/config-transformer.ts +++ b/lib/tools/config-manipulation/config-transformer.ts @@ -266,7 +266,7 @@ export class ConfigTransformer implements IConfigTransformer { if (!Node.isPropertyAssignment(property)) { continue; } - const name = property.getNameNode().getText().replace(/['\"]/g, ""); + const name = property.getNameNode().getText().replace(/['"]/g, ""); result[name] = this.getInitializerValue( property.getInitializerOrThrow(), ); @@ -344,7 +344,7 @@ export class ConfigTransformer implements IConfigTransformer { if (!Node.isPropertyAssignment(property)) { continue; } - const name = property.getNameNode().getText().replace(/['\"]/g, ""); + const name = property.getNameNode().getText().replace(/['"]/g, ""); result[name] = this.getInitializerValue( property.getInitializerOrThrow(), ); diff --git a/lib/tools/node-modules/node-modules-builder.ts b/lib/tools/node-modules/node-modules-builder.ts index ac61ce8b54..a8d7488760 100644 --- a/lib/tools/node-modules/node-modules-builder.ts +++ b/lib/tools/node-modules/node-modules-builder.ts @@ -11,26 +11,28 @@ export class NodeModulesBuilder implements INodeModulesBuilder { constructor( private $logger: ILogger, private $nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder, - private $pluginsService: IPluginsService + private $pluginsService: IPluginsService, ) {} public async prepareNodeModules({ platformData, projectData, }: IPrepareNodeModulesData): Promise { - let dependencies = this.$nodeModulesDependenciesBuilder.getProductionDependencies( - projectData.projectDir, - projectData.ignoredDependencies - ); - dependencies = await platformData.platformProjectService.beforePrepareAllPlugins( - projectData, - dependencies - ); + let dependencies = + this.$nodeModulesDependenciesBuilder.getProductionDependencies( + projectData.projectDir, + projectData.ignoredDependencies, + ); + dependencies = + await platformData.platformProjectService.beforePrepareAllPlugins( + projectData, + dependencies, + ); const pluginsData = this.$pluginsService.getAllProductionPlugins( projectData, platformData.platformNameLowerCase, - dependencies + dependencies, ); if (_.isEmpty(pluginsData)) { return; @@ -47,7 +49,7 @@ export class NodeModulesBuilder implements INodeModulesBuilder { this.$logger.trace( `Successfully prepared plugin ${ pluginData.name - } for ${platformData.normalizedPlatformName.toLowerCase()}.` + } for ${platformData.normalizedPlatformName.toLowerCase()}.`, ); } } diff --git a/lib/tools/node-modules/node-modules-dependencies-builder.ts b/lib/tools/node-modules/node-modules-dependencies-builder.ts index 9474b7eb79..c5f059f0f3 100644 --- a/lib/tools/node-modules/node-modules-dependencies-builder.ts +++ b/lib/tools/node-modules/node-modules-dependencies-builder.ts @@ -14,9 +14,7 @@ interface IDependencyDescription { depth: number; } -export class NodeModulesDependenciesBuilder - implements INodeModulesDependenciesBuilder -{ +export class NodeModulesDependenciesBuilder implements INodeModulesDependenciesBuilder { public constructor(private $fs: IFileSystem) {} public getProductionDependencies( diff --git a/lib/yarn-package-manager.ts b/lib/yarn-package-manager.ts index d4d08ad7f0..7d9ea51ae1 100644 --- a/lib/yarn-package-manager.ts +++ b/lib/yarn-package-manager.ts @@ -25,7 +25,7 @@ export class YarnPackageManager extends BasePackageManager { $hostInfo: IHostInfo, private $httpClient: Server.IHttpClient, private $logger: ILogger, - $pacoteService: IPacoteService + $pacoteService: IPacoteService, ) { super($childProcess, $fs, $hostInfo, $pacoteService, "yarn"); } @@ -34,7 +34,7 @@ export class YarnPackageManager extends BasePackageManager { public async install( packageName: string, pathToSave: string, - config: INodePackageManagerInstallOptions + config: INodePackageManagerInstallOptions, ): Promise { if (config.disableNpmInstall) { return; @@ -60,7 +60,7 @@ export class YarnPackageManager extends BasePackageManager { const result = await this.processPackageManagerInstall( packageName, params, - { cwd, isInstallingAllDependencies } + { cwd, isInstallingAllDependencies }, ); return result; } catch (e) { @@ -73,7 +73,7 @@ export class YarnPackageManager extends BasePackageManager { public uninstall( packageName: string, config?: IDictionary, - cwd?: string + cwd?: string, ): Promise { const flags = this.getFlagsString(config, false); return this.$childProcess.exec(`yarn remove ${packageName} ${flags}`, { @@ -82,14 +82,14 @@ export class YarnPackageManager extends BasePackageManager { } @exported("yarn") - public async view(packageName: string, config: Object): Promise { + public async view(packageName: string, config: object): Promise { const wrappedConfig = _.extend({}, config, { json: true }); const flags = this.getFlagsString(wrappedConfig, false); let viewResult: any; try { viewResult = await this.$childProcess.exec( - `yarn info ${packageName} ${flags}` + `yarn info ${packageName} ${flags}`, ); } catch (e) { this.$errors.fail(e.message); @@ -106,17 +106,17 @@ export class YarnPackageManager extends BasePackageManager { @exported("yarn") public search( filter: string[], - config: IDictionary + config: IDictionary, ): Promise { this.$errors.fail( - "Method not implemented. Yarn does not support searching for packages in the registry." + "Method not implemented. Yarn does not support searching for packages in the registry.", ); return null; } public async searchNpms(keyword: string): Promise { const httpRequestResult = await this.$httpClient.httpRequest( - `https://api.npms.io/v2/search?q=keywords:${keyword}` + `https://api.npms.io/v2/search?q=keywords:${keyword}`, ); const result: INpmsResult = JSON.parse(httpRequestResult.body); return result; @@ -127,15 +127,15 @@ export class YarnPackageManager extends BasePackageManager { const registry = await this.$childProcess.exec(`yarn config get registry`); const url = `${registry.trim()}/${packageName}`; this.$logger.trace( - `Trying to get data from yarn registry for package ${packageName}, url is: ${url}` + `Trying to get data from yarn registry for package ${packageName}, url is: ${url}`, ); const responseData = (await this.$httpClient.httpRequest(url)).body; this.$logger.trace( - `Successfully received data from yarn registry for package ${packageName}. Response data is: ${responseData}` + `Successfully received data from yarn registry for package ${packageName}. Response data is: ${responseData}`, ); const jsonData = JSON.parse(responseData); this.$logger.trace( - `Successfully parsed data from yarn registry for package ${packageName}.` + `Successfully parsed data from yarn registry for package ${packageName}.`, ); return jsonData; } diff --git a/lib/yarn2-package-manager.ts b/lib/yarn2-package-manager.ts index a8312abff3..d851af3799 100644 --- a/lib/yarn2-package-manager.ts +++ b/lib/yarn2-package-manager.ts @@ -26,7 +26,7 @@ export class Yarn2PackageManager extends BasePackageManager { $hostInfo: IHostInfo, private $httpClient: Server.IHttpClient, private $logger: ILogger, - $pacoteService: IPacoteService + $pacoteService: IPacoteService, ) { super($childProcess, $fs, $hostInfo, $pacoteService, "yarn2"); this.$hostInfo_ = $hostInfo; @@ -46,7 +46,7 @@ export class Yarn2PackageManager extends BasePackageManager { public async install( packageName: string, pathToSave: string, - config: INodePackageManagerInstallOptions + config: INodePackageManagerInstallOptions, ): Promise { if (config.disableNpmInstall) { return; @@ -76,7 +76,7 @@ export class Yarn2PackageManager extends BasePackageManager { const result = await this.processPackageManagerInstall( packageName, params, - { cwd, isInstallingAllDependencies } + { cwd, isInstallingAllDependencies }, ); return result; } catch (e) { @@ -89,7 +89,7 @@ export class Yarn2PackageManager extends BasePackageManager { public uninstall( packageName: string, config?: IDictionary, - cwd?: string + cwd?: string, ): Promise { const flags = this.getFlagsString(config, false); return this.$childProcess.exec(`yarn remove ${packageName} ${flags}`, { @@ -98,14 +98,14 @@ export class Yarn2PackageManager extends BasePackageManager { } @exported("yarn2") - public async view(packageName: string, config: Object): Promise { + public async view(packageName: string, config: object): Promise { const wrappedConfig = _.extend({}, config, { json: true }); const flags = this.getFlagsString(wrappedConfig, false); let viewResult: any; try { viewResult = await this.$childProcess.exec( - `yarn npm info ${packageName} ${flags}` + `yarn npm info ${packageName} ${flags}`, ); } catch (e) { this.$errors.fail(e.message); @@ -122,17 +122,17 @@ export class Yarn2PackageManager extends BasePackageManager { @exported("yarn2") public search( filter: string[], - config: IDictionary + config: IDictionary, ): Promise { this.$errors.fail( - "Method not implemented. Yarn does not support searching for packages in the registry." + "Method not implemented. Yarn does not support searching for packages in the registry.", ); return null; } public async searchNpms(keyword: string): Promise { const httpRequestResult = await this.$httpClient.httpRequest( - `https://api.npms.io/v2/search?q=keywords:${keyword}` + `https://api.npms.io/v2/search?q=keywords:${keyword}`, ); const result: INpmsResult = JSON.parse(httpRequestResult.body); return result; @@ -141,19 +141,19 @@ export class Yarn2PackageManager extends BasePackageManager { @exported("yarn2") public async getRegistryPackageData(packageName: string): Promise { const registry = await this.$childProcess.exec( - `yarn config get npmRegistryServer` + `yarn config get npmRegistryServer`, ); const url = `${registry.trim()}/${packageName}`; this.$logger.trace( - `Trying to get data from yarn registry for package ${packageName}, url is: ${url}` + `Trying to get data from yarn registry for package ${packageName}, url is: ${url}`, ); const responseData = (await this.$httpClient.httpRequest(url)).body; this.$logger.trace( - `Successfully received data from yarn registry for package ${packageName}. Response data is: ${responseData}` + `Successfully received data from yarn registry for package ${packageName}. Response data is: ${responseData}`, ); const jsonData = JSON.parse(responseData); this.$logger.trace( - `Successfully parsed data from yarn registry for package ${packageName}.` + `Successfully parsed data from yarn registry for package ${packageName}.`, ); return jsonData; } diff --git a/package-lock.json b/package-lock.json index 5002c61594..bd1a9cb758 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nativescript", - "version": "9.1.0-alpha.15", + "version": "9.1.0-alpha.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nativescript", - "version": "9.1.0-alpha.15", + "version": "9.1.0-alpha.17", "bundleDependencies": [ "universal-analytics" ], @@ -110,6 +110,8 @@ "fast-check": "3.23.2", "husky": "9.1.7", "lint-staged": "~15.5.2", + "oxfmt": "^0.61.0", + "oxlint": "^1.76.0", "sinon": "19.0.5", "source-map-support": "0.5.21", "vitest": "^4.1.10", @@ -1076,6 +1078,652 @@ "url": "https://github.com/sponsors/Boshen" } }, + "node_modules/@oxfmt/binding-android-arm-eabi": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-android-arm-eabi/-/binding-android-arm-eabi-0.61.0.tgz", + "integrity": "sha512-BaS+1OVvg9sr+Xav0+KdWedQRcAzrdoEcwMZeqoc2F6ieC1s/t5eM35YQoRPQ7vAqkZ+p3tbQb1r9I9mrV5oGA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-android-arm64": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-android-arm64/-/binding-android-arm64-0.61.0.tgz", + "integrity": "sha512-of8atAV0M1egGcVOMbgZCvc10sFOP3ayQBNQV5h5G3fNq8gACdEswfFk9bzGrdbM23rtg0Coxi7np7oPLcueNw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-darwin-arm64": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-darwin-arm64/-/binding-darwin-arm64-0.61.0.tgz", + "integrity": "sha512-7l8+5ov4BGwtAcmpzvEik/TG3bciwyw/S3e6j5GKH7pcQqcgCVxD3AuJeP6upto+SOTBKQ4wrrdbMt0gq8fHSQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-darwin-x64": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-darwin-x64/-/binding-darwin-x64-0.61.0.tgz", + "integrity": "sha512-Fnz4dDDXBb7udk+DmwelNjxbD6yptyxwCqwCH2ebo4RVLxVsRfFsn/AHJC49KIltPrVokamGv4SSOsiV50DTxQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-freebsd-x64": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-freebsd-x64/-/binding-freebsd-x64-0.61.0.tgz", + "integrity": "sha512-mddOebKNCP+AucmzfNsk3jgbr681qAUvgMqi865GW5gWLJ/AnzXbvjQRrny0e++NAN8aphav/aRSrfFxNsNjpA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-arm-gnueabihf": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-0.61.0.tgz", + "integrity": "sha512-svx59iYL+DbaZGZUIoice4W0CjRXGExnbz7Re+awIb60rVxBS2KrU7Hnlx+nZYanLGLpjneUEgo/VFEKkSZAyQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-arm-musleabihf": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-0.61.0.tgz", + "integrity": "sha512-BYK9MPJPCf6d+fLKMTruThmEyCtHzQ1zLcsrTlUVkmnoXIaHAbfpeLYQwX1tkjs7W11dyzoi6HFvKcdnvX1zNg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-arm64-gnu": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-0.61.0.tgz", + "integrity": "sha512-QUaCNLq2/EC6G5ljOuFanl9Lgw6ZWp4co7rs4+KOMUzbGfA4Lq58FHRjjF9sVIG+93XSbo343MxFATrOU1qctA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-arm64-musl": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm64-musl/-/binding-linux-arm64-musl-0.61.0.tgz", + "integrity": "sha512-S6uvJ6MXnRXl+zTs0CARNDvkE+cymj0EVWEKKsyKnlLlqTyQJBjw5s4D2pSIOZc+S46cy4STefzcr/sm0VzVPA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-ppc64-gnu": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-0.61.0.tgz", + "integrity": "sha512-6VDlRcytvZG6UlSIdAFKDLbppo9tvPxrWzle6vHldYFMeuDPQEfMKrkwezp7FaBq1wik9ra554ZZeRPsyIkFpg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-riscv64-gnu": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-0.61.0.tgz", + "integrity": "sha512-KkBTYbzExpbmn15XjKPLu2fRV2PVlq+KWt+brad5rwIa03vdYoaDRWiS7raHII/dCTR6Ro4UpYUCH4t6lif4WQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-riscv64-musl": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-0.61.0.tgz", + "integrity": "sha512-69tzIq7sJLVB9dxYYtvMzcSSsnZHSO+U2U19O2RqDqgj6+Q4O7HjSXdaszbcgqzhsUwzSH7z5kWvk8nmf6BHTg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-s390x-gnu": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-0.61.0.tgz", + "integrity": "sha512-Oqi/N0OvtOVXsPKAOOhKgGH3msRYF8BLJaNBbWiupRiKoKVyc8JRKPCfarkQJC+RgP9U8raUKLe+bNwd0HUMiA==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-x64-gnu": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-x64-gnu/-/binding-linux-x64-gnu-0.61.0.tgz", + "integrity": "sha512-3TKwv/ed4uwJSemAA8P9XcoqETpjQI4waquF9UilhA9Mn/dhr1PdUEXWlL74mtc6ZNfmKPA9+NEJm01nRF8CVA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-x64-musl": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-x64-musl/-/binding-linux-x64-musl-0.61.0.tgz", + "integrity": "sha512-uFso4u4nLkVSlMCpgjyvWV60Gt7GvDQHnk1mmRxHIkZTMB0ljpUKwCD9FYGgN9H97x2wYl0UwEjgRZaPIuhEhw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-openharmony-arm64": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-openharmony-arm64/-/binding-openharmony-arm64-0.61.0.tgz", + "integrity": "sha512-keGLkzeOvkMpNmPp4hffXWpfoSsY6e1K8++KXD4mSSfxdvM8q9QUDsYY689TB1k6Co832DZn1MnaaVx6cIBMWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-win32-arm64-msvc": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-0.61.0.tgz", + "integrity": "sha512-VzsAISkFxmNhJ5LBDEL9VuH6tJsVJMtqYit2LyIUf/HLnsCe4Pg9SMOjjVQzGWt0bnpyfJ94CrqTqcpNZzK+ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-win32-ia32-msvc": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-0.61.0.tgz", + "integrity": "sha512-xv4t7yzwJoYaLB6Zv28B3W+j7brEjsyv50rLTAQgmxJzddce9fAMCxed8dSAkbWES0zz2J29nYK5FaTuD2YBHg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-win32-x64-msvc": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-x64-msvc/-/binding-win32-x64-msvc-0.61.0.tgz", + "integrity": "sha512-6EZXFkqOwxdDYjIn3TSNnPk3ST5E5GiYd4FiM6UF/mCL/LZSfr6D6UygTfW3R1PCQP2quCKpCEGRlij8E3VYbg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-android-arm-eabi": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm-eabi/-/binding-android-arm-eabi-1.76.0.tgz", + "integrity": "sha512-ZHIE5Zt9AsPDcY4nOlofXt0YfneEeo+QrKMPcPzLf2Z6Q8VtV2W73d7SFJ920WUwyik783u/doKCs3KXdwG+7w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-android-arm64": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm64/-/binding-android-arm64-1.76.0.tgz", + "integrity": "sha512-shm/ngQilHK6bs+ElJWa4oHfNj5vL1Gl/iVEJldTQjpr0/67oSgr0KUpbmcnLig5Fo0v/l6j2567A7TOL89ONA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-arm64": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-arm64/-/binding-darwin-arm64-1.76.0.tgz", + "integrity": "sha512-rvJmrAPKSQ9aWJ6wIS6CK2tJjwzfW0ApQH9qokq6sfDvmHwoyIHxHFMq7z7i7GiV6fdE6s8qvBqWKPTu8RmT6Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-x64": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-x64/-/binding-darwin-x64-1.76.0.tgz", + "integrity": "sha512-U/zYdb7VYKGY6pA9Vd2rYl9O/HlCylcOlb5PGPvVLtg+oLGsk6H3XGKEMHKyqD3nmmtmlmwb/8SwU2vfSAtvMw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-freebsd-x64": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-freebsd-x64/-/binding-freebsd-x64-1.76.0.tgz", + "integrity": "sha512-WvKG9CAriuo0XNiFzpXjDngUZcRGFNpaK2kLyMUsnJlShxkT96u+BpJQ3KqdQwGOrvI14L6V8bAwXwAYNNY6Jg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-gnueabihf": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.76.0.tgz", + "integrity": "sha512-qJ5+RH99TqFRq3UCDxkW0zJJu9c+OAHFY72vGlxZLEpuO+MpKo3POgqb8sYipL9KYm8XY6ofb0HsOuvY6hQNqQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-musleabihf": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-1.76.0.tgz", + "integrity": "sha512-PvPCVptkgVARsucgIqFQQcSmJ6xc6GtnVB5bRBekRahTc9eObMtjHfMjy5M+C2tHt5UCMttWM9RuSk/H9NqYeg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-gnu": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.76.0.tgz", + "integrity": "sha512-3KeFDx8Bu4HPAXbuHZOr/oHvN+QT+JQhMw/NYPz7Z071xLSsG27Jfh9PIQVEY7hk1I+jr43ExqRIeJ6VKk2yLw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-musl": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.76.0.tgz", + "integrity": "sha512-oPFkkKTgl0K/EIg9fQ8oA3IGcI05/Mq1en04iFa41mmNPT+6KEiByVazTOZZJiHMBBrbsns1YJ2e1Scqwzesjw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-ppc64-gnu": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.76.0.tgz", + "integrity": "sha512-gN7yZ0eqflA5Fhf1wvHxGUltIV3FsvmB1zhNMDEK9vSHhc7E6qg9CuPeBgPZab66Tjzq6w6kHAtNEvnTHf4cyw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-gnu": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-1.76.0.tgz", + "integrity": "sha512-S/HqMbn22mQrjtErUxEoS/a55u8kIeXvreIxiJu5G7Le3UecEd6SQZxrDIpuhtgaFnsY/nVra3ytP+pRljDilA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-musl": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-1.76.0.tgz", + "integrity": "sha512-ZIga3097VJZolGZk6SrIAUokIGfRkxRlhiHDUznZptGBfwrhD7pNfD1rzEzsCwvk/1DX0A1bLz+liuNh5QKIVQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-s390x-gnu": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.76.0.tgz", + "integrity": "sha512-ZGiiA7pFzMJSyMWYZTVlPgbTsx+Vl8ihLGMIujPwaslUF7kIPPWAbVmAlTc+9lWDV+DCiB8Ikixu+lSHeOIIWQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-gnu": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.76.0.tgz", + "integrity": "sha512-JLiy5WuvEBFTT6ErIFV35SLzi0R7Iri6MKU6dZbTxfIx8pndbbPs3Mj780nMipBFcPkti+okAPOJ9POKkHFEgg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-musl": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-musl/-/binding-linux-x64-musl-1.76.0.tgz", + "integrity": "sha512-z7lgKQtbo/I1NIe8G5NHLesxJDv0tRSUWTpXKb9Pm3E9nKFKfO4IOSDtFroKgXtOYb0jQbcdH+0wzTyMXVes+A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-openharmony-arm64": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-openharmony-arm64/-/binding-openharmony-arm64-1.76.0.tgz", + "integrity": "sha512-JOjKymIpb9QcYfEhZsN6h4V9Ivd474W38cNIBRv6bg2TbIvogbMTH0Mg6YWW9TiRDqfcX+/Hyfsbo5vcSE5guQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-arm64-msvc": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.76.0.tgz", + "integrity": "sha512-pqDWZiwcmByWUEm1NFUBNiT6aentCcaoMWJv0HbXEmuYermJ4sg8ppVrshubYP2MZ6SHccJJcpr6x469PuDFIw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-ia32-msvc": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-1.76.0.tgz", + "integrity": "sha512-Ba0O659kgMv6pwO3z9PdO+K3aMxQRaw9HnG+e6AtOfgwcKFvYilciQYBoUBmxfQvOCKZe1SwjMkuB542NkuDMQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-x64-msvc": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.76.0.tgz", + "integrity": "sha512-5qcirPHO8nKfkoowEVWtpAoVTcYDy6g0UT0NGic450Qv8J2NrOqg4uQ8QppRP4MDTC7Xx47lbZnmadTH03CGGA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, "node_modules/@rigor789/resolve-package-path": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/@rigor789/resolve-package-path/-/resolve-package-path-1.0.7.tgz", @@ -6294,6 +6942,107 @@ "node": ">=8" } }, + "node_modules/oxfmt": { + "version": "0.61.0", + "resolved": "https://registry.npmjs.org/oxfmt/-/oxfmt-0.61.0.tgz", + "integrity": "sha512-DxdHBEMYpcEnHoUHjjOigUqV2TYKsvxLwUPXnVYBjgFdqrcQ/91OtwubtZ2PUodCs3sStI8R5Qw3fKNGK4e8wQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinypool": "2.1.0" + }, + "bin": { + "oxfmt": "bin/oxfmt" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/Boshen" + }, + "optionalDependencies": { + "@oxfmt/binding-android-arm-eabi": "0.61.0", + "@oxfmt/binding-android-arm64": "0.61.0", + "@oxfmt/binding-darwin-arm64": "0.61.0", + "@oxfmt/binding-darwin-x64": "0.61.0", + "@oxfmt/binding-freebsd-x64": "0.61.0", + "@oxfmt/binding-linux-arm-gnueabihf": "0.61.0", + "@oxfmt/binding-linux-arm-musleabihf": "0.61.0", + "@oxfmt/binding-linux-arm64-gnu": "0.61.0", + "@oxfmt/binding-linux-arm64-musl": "0.61.0", + "@oxfmt/binding-linux-ppc64-gnu": "0.61.0", + "@oxfmt/binding-linux-riscv64-gnu": "0.61.0", + "@oxfmt/binding-linux-riscv64-musl": "0.61.0", + "@oxfmt/binding-linux-s390x-gnu": "0.61.0", + "@oxfmt/binding-linux-x64-gnu": "0.61.0", + "@oxfmt/binding-linux-x64-musl": "0.61.0", + "@oxfmt/binding-openharmony-arm64": "0.61.0", + "@oxfmt/binding-win32-arm64-msvc": "0.61.0", + "@oxfmt/binding-win32-ia32-msvc": "0.61.0", + "@oxfmt/binding-win32-x64-msvc": "0.61.0" + }, + "peerDependencies": { + "svelte": "^5.0.0", + "vite-plus": "*" + }, + "peerDependenciesMeta": { + "svelte": { + "optional": true + }, + "vite-plus": { + "optional": true + } + } + }, + "node_modules/oxlint": { + "version": "1.76.0", + "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.76.0.tgz", + "integrity": "sha512-6QoFioEU4fNdiUx/2Eo6TRd6NG7H7njnRCz8rhB66cZmMHDTqcm1Rjvl8Wry+ZTQMBAmyb4Mlf62Mk5X+eHSOw==", + "dev": true, + "license": "MIT", + "bin": { + "oxlint": "bin/oxlint" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/Boshen" + }, + "optionalDependencies": { + "@oxlint/binding-android-arm-eabi": "1.76.0", + "@oxlint/binding-android-arm64": "1.76.0", + "@oxlint/binding-darwin-arm64": "1.76.0", + "@oxlint/binding-darwin-x64": "1.76.0", + "@oxlint/binding-freebsd-x64": "1.76.0", + "@oxlint/binding-linux-arm-gnueabihf": "1.76.0", + "@oxlint/binding-linux-arm-musleabihf": "1.76.0", + "@oxlint/binding-linux-arm64-gnu": "1.76.0", + "@oxlint/binding-linux-arm64-musl": "1.76.0", + "@oxlint/binding-linux-ppc64-gnu": "1.76.0", + "@oxlint/binding-linux-riscv64-gnu": "1.76.0", + "@oxlint/binding-linux-riscv64-musl": "1.76.0", + "@oxlint/binding-linux-s390x-gnu": "1.76.0", + "@oxlint/binding-linux-x64-gnu": "1.76.0", + "@oxlint/binding-linux-x64-musl": "1.76.0", + "@oxlint/binding-openharmony-arm64": "1.76.0", + "@oxlint/binding-win32-arm64-msvc": "1.76.0", + "@oxlint/binding-win32-ia32-msvc": "1.76.0", + "@oxlint/binding-win32-x64-msvc": "1.76.0" + }, + "peerDependencies": { + "oxlint-tsgolint": ">=7.0.2001", + "vite-plus": "*" + }, + "peerDependenciesMeta": { + "oxlint-tsgolint": { + "optional": true + }, + "vite-plus": { + "optional": true + } + } + }, "node_modules/p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", @@ -7913,6 +8662,16 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/tinypool": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-2.1.0.tgz", + "integrity": "sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.0.0 || >=22.0.0" + } + }, "node_modules/tinyrainbow": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.0.tgz", diff --git a/package.json b/package.json index d2a6daa425..e7dfdc28dd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nativescript", "main": "./dist/lib/nativescript-cli-lib.js", - "version": "9.1.0-alpha.15", + "version": "9.1.0-alpha.17", "author": "NativeScript ", "description": "Command-line interface for building NativeScript projects", "bin": { @@ -28,7 +28,10 @@ "tsc": "tsc", "test-watch": "node ./dev/tsc-to-vitest-watch.js", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", - "prettier": "prettier --write ./lib/**/*{.ts,.d.ts} ./test/**/*{.ts,.d.ts}", + "format": "oxfmt \"lib/**/*.ts\" \"test/**/*.ts\"", + "format.check": "oxfmt --check \"lib/**/*.ts\" \"test/**/*.ts\"", + "lint": "oxlint lib test", + "lint.fix": "oxlint lib test --fix", "build.release": "npm run clean.build && tsc -p tsconfig.release.json && node scripts/generate-test-deps.js && node scripts/copy-assets.js --release && node scripts/set-ga-id.js live --dir dist && node scripts/set-ga-id.js verify --dir dist", "pack.release": "npm run build.release && npm pack ./dist" }, @@ -133,6 +136,8 @@ "fast-check": "3.23.2", "husky": "9.1.7", "lint-staged": "~15.5.2", + "oxfmt": "^0.61.0", + "oxlint": "^1.76.0", "sinon": "19.0.5", "source-map-support": "0.5.21", "vitest": "^4.1.10", @@ -166,6 +171,6 @@ "node": ">=20.0.0" }, "lint-staged": { - "*.ts": "prettier --write" + "*.ts": "oxfmt" } } diff --git a/test/android-tools-info.ts b/test/android-tools-info.ts index 4db963b43f..54f535e4e2 100644 --- a/test/android-tools-info.ts +++ b/test/android-tools-info.ts @@ -42,15 +42,14 @@ describe("androidToolsInfo", () => { describe("validateJavacVersion", () => { it("throws error when passing showWarningsAsErrors to true and javac is not installed", () => { const testInjector = createTestInjector(); - const androidToolsInfo = testInjector.resolve( - AndroidToolsInfo - ); + const androidToolsInfo = + testInjector.resolve(AndroidToolsInfo); assert.throws( () => androidToolsInfo.validateJavacVersion(null, { showWarningsAsErrors: true, }), - "Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable." + "Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable.", ); }); }); diff --git a/test/bun-package-manager.ts b/test/bun-package-manager.ts index 758b620f54..c75326b38b 100644 --- a/test/bun-package-manager.ts +++ b/test/bun-package-manager.ts @@ -52,7 +52,7 @@ describe("node-package-manager", () => { const testInjector = createTestInjector(); const npm = testInjector.resolve("bun"); const templateNameParts = await npm.getPackageNameParts( - testCase.templateFullName + testCase.templateFullName, ); assert.strictEqual(templateNameParts.name, testCase.expectedName); assert.strictEqual(templateNameParts.version, testCase.expectedVersion); diff --git a/test/cocoapods-service.ts b/test/cocoapods-service.ts index 24281b5636..bf966e6f6f 100644 --- a/test/cocoapods-service.ts +++ b/test/cocoapods-service.ts @@ -61,7 +61,7 @@ function changeNewLineCharacter(input: string): string { describe("Cocoapods service", () => { if (require("os").platform() === "win32") { console.log( - "Skipping 'Cocoapods service' tests. They can work only on macOS and Linux" + "Skipping 'Cocoapods service' tests. They can work only on macOS and Linux", ); return; } @@ -92,7 +92,7 @@ describe("Cocoapods service", () => { injector: IInjector, podfileContent: string, projectPodfileContent?: string, - appResourcesPodfileContent?: string + appResourcesPodfileContent?: string, ): void => { const fs: IFileSystem = injector.resolve("fs"); @@ -567,21 +567,21 @@ end`, mockFileSystem( testInjector, testCase.input, - testCase.projectPodfileContent + testCase.projectPodfileContent, ); await cocoapodsService.applyPodfileToProject( testCase.pluginData ? testCase.pluginData.name : mockPluginData.name, cocoapodsService.getPluginPodfilePath( - testCase.pluginData || mockPluginData + testCase.pluginData || mockPluginData, ), mockProjectData, - mockPlatformData + mockPlatformData, ); assert.deepStrictEqual( changeNewLineCharacter(newPodfileContent), - changeNewLineCharacter(testCase.output) + changeNewLineCharacter(testCase.output), ); }); }); @@ -791,19 +791,19 @@ end`, mockFileSystem( testInjector, testCase.input, - testCase.projectPodfileContent + testCase.projectPodfileContent, ); cocoapodsService.removePodfileFromProject( mockPluginData.name, cocoapodsService.getPluginPodfilePath(mockPluginData), mockProjectData, - nativeProjectPath + nativeProjectPath, ); assert.deepStrictEqual( changeNewLineCharacter(newPodfileContent), - changeNewLineCharacter(testCase.output) + changeNewLineCharacter(testCase.output), ); }); }); @@ -818,7 +818,7 @@ end`, childProcess.exec = async ( command: string, options?: any, - execOptions?: IExecOptions + execOptions?: IExecOptions, ): Promise => { if (command === "arch -x86_64 pod --version") { // This is the command that is used to check if cocoapods is installed under Rosetta 2 @@ -835,7 +835,7 @@ end`, args: string[], event: string, options?: any, - spawnFromEventOptions?: ISpawnFromEventOptions + spawnFromEventOptions?: ISpawnFromEventOptions, ): Promise => ({ stdout: "", stderr: "", @@ -857,7 +857,7 @@ end`, args: string[], event: string, options?: any, - spawnFromEventOptions?: ISpawnFromEventOptions + spawnFromEventOptions?: ISpawnFromEventOptions, ): Promise => { commandCalled = command; return { @@ -880,7 +880,7 @@ end`, args: string[], event: string, options?: any, - spawnFromEventOptions?: ISpawnFromEventOptions + spawnFromEventOptions?: ISpawnFromEventOptions, ): Promise => { commandCalled = command; assert.deepStrictEqual(args, ["install"]); @@ -908,7 +908,7 @@ end`, args: string[], event: string, options?: any, - spawnFromEventOptions?: ISpawnFromEventOptions + spawnFromEventOptions?: ISpawnFromEventOptions, ): Promise => { return { stdout: "", @@ -919,7 +919,7 @@ end`, await assert.isRejected( cocoapodsService.executePodInstall(projectRoot, xcodeProjPath), - "'pod install' command failed." + "'pod install' command failed.", ); }); @@ -935,14 +935,14 @@ end`, args: string[], event: string, options?: any, - spawnFromEventOptions?: ISpawnFromEventOptions + spawnFromEventOptions?: ISpawnFromEventOptions, ): Promise => { return expectedResult; }; const result = await cocoapodsService.executePodInstall( projectRoot, - xcodeProjPath + xcodeProjPath, ); assert.deepStrictEqual(result, expectedResult); }); @@ -1084,13 +1084,13 @@ end`, pod.name, pod.path, projectData, - platformData + platformData, ); } assert.deepStrictEqual( projectPodfileContent, - testCase.expectedProjectPodfileContentAfterApply + testCase.expectedProjectPodfileContentAfterApply, ); for (const pod of testCase.podsToRemove) { @@ -1098,13 +1098,13 @@ end`, pod.name, pod.path, projectData, - projectPodfilePath + projectPodfilePath, ); } assert.deepStrictEqual( projectPodfileContent, - testCase.expectedProjectPodfileContentAfterRemove + testCase.expectedProjectPodfileContentAfterRemove, ); }); }); @@ -1365,13 +1365,13 @@ end`, pod.name, pod.path, projectData, - platformData + platformData, ); } assert.deepStrictEqual( projectPodfileContent, - testCase.expectedProjectPodfileContent + testCase.expectedProjectPodfileContent, ); }); }); @@ -1413,27 +1413,27 @@ end`, testInjector, testCase.pluginPodContent, testCase.projectPodfileContent, - testCase.appResourcesPodContent + testCase.appResourcesPodContent, ); await cocoapodsService.applyPodfileToProject( mockPluginData.name, cocoapodsService.getPluginPodfilePath(mockPluginData), projectDataMock, - mockPlatformData + mockPlatformData, ); assert.deepStrictEqual( changeNewLineCharacter(newPodfileContent), - changeNewLineCharacter(testCase.expectedOutput) + changeNewLineCharacter(testCase.expectedOutput), ); await cocoapodsService.applyPodfileFromAppResources( projectDataMock, - mockPlatformData + mockPlatformData, ); assert.deepStrictEqual( changeNewLineCharacter(newPodfileContent), - changeNewLineCharacter(testCase.expectedFinalOutput) + changeNewLineCharacter(testCase.expectedFinalOutput), ); }); @@ -1485,49 +1485,49 @@ end`, testInjector, testCase.pluginPodContent, testCase.projectPodfileContent, - testCase.appResourcesPodContent + testCase.appResourcesPodContent, ); await cocoapodsService.applyPodfileToProject( mockPluginData.name, cocoapodsService.getPluginPodfilePath(mockPluginData), projectDataMock, - mockPlatformData + mockPlatformData, ); assert.deepStrictEqual( changeNewLineCharacter(newPodfileContent), - changeNewLineCharacter(testCase.expectedOutput) + changeNewLineCharacter(testCase.expectedOutput), ); await cocoapodsService.applyPodfileFromAppResources( projectDataMock, - mockPlatformData + mockPlatformData, ); assert.deepStrictEqual( changeNewLineCharacter(newPodfileContent), - changeNewLineCharacter(testCase.expectedIntermidiatOutput) + changeNewLineCharacter(testCase.expectedIntermidiatOutput), ); mockFileSystem( testInjector, testCase.pluginPodContent, testCase.projectPodfileContent, - testCase.updatedAppResourcesPodContent + testCase.updatedAppResourcesPodContent, ); await cocoapodsService.applyPodfileToProject( mockPluginData.name, cocoapodsService.getPluginPodfilePath(mockPluginData), projectDataMock, - mockPlatformData + mockPlatformData, ); await cocoapodsService.applyPodfileFromAppResources( projectDataMock, - mockPlatformData + mockPlatformData, ); assert.deepStrictEqual( changeNewLineCharacter(newPodfileContent), - changeNewLineCharacter(testCase.expectedFinalOutput) + changeNewLineCharacter(testCase.expectedFinalOutput), ); }); @@ -1579,49 +1579,49 @@ end`, testInjector, testCase.pluginPodContent, testCase.projectPodfileContent, - testCase.appResourcesPodContent + testCase.appResourcesPodContent, ); await cocoapodsService.applyPodfileToProject( mockPluginData.name, cocoapodsService.getPluginPodfilePath(mockPluginData), projectDataMock, - mockPlatformData + mockPlatformData, ); assert.deepStrictEqual( changeNewLineCharacter(newPodfileContent), - changeNewLineCharacter(testCase.expectedOutput) + changeNewLineCharacter(testCase.expectedOutput), ); await cocoapodsService.applyPodfileFromAppResources( projectDataMock, - mockPlatformData + mockPlatformData, ); assert.deepStrictEqual( changeNewLineCharacter(newPodfileContent), - changeNewLineCharacter(testCase.expectedIntermidiatOutput) + changeNewLineCharacter(testCase.expectedIntermidiatOutput), ); mockFileSystem( testInjector, testCase.pluginPodContent, testCase.projectPodfileContent, - testCase.updatedAppResourcesPodContent + testCase.updatedAppResourcesPodContent, ); await cocoapodsService.applyPodfileToProject( mockPluginData.name, cocoapodsService.getPluginPodfilePath(mockPluginData), projectDataMock, - mockPlatformData + mockPlatformData, ); await cocoapodsService.applyPodfileFromAppResources( projectDataMock, - mockPlatformData + mockPlatformData, ); assert.deepStrictEqual( changeNewLineCharacter(newPodfileContent), - changeNewLineCharacter(testCase.expectedFinalOutput) + changeNewLineCharacter(testCase.expectedFinalOutput), ); }); }); diff --git a/test/commands/post-install.ts b/test/commands/post-install.ts index fb9464d082..7163e98f24 100644 --- a/test/commands/post-install.ts +++ b/test/commands/post-install.ts @@ -17,7 +17,7 @@ const createTestInjector = (): IInjector => { testInjector.register("commandsService", { tryExecuteCommand: async ( commandName: string, - commandArguments: string[] + commandArguments: string[], ): Promise => undefined, }); @@ -71,17 +71,15 @@ describe("post-install command", () => { isGenerateHtmlPagesCalled = true; }; - const analyticsService = testInjector.resolve( - "analyticsService" - ); + const analyticsService = + testInjector.resolve("analyticsService"); let isCheckConsentCalled = false; analyticsService.checkConsent = async (): Promise => { isCheckConsentCalled = true; }; - const commandsService = testInjector.resolve( - "commandsService" - ); + const commandsService = + testInjector.resolve("commandsService"); let isTryExecuteCommandCalled = false; commandsService.tryExecuteCommand = async (): Promise => { isTryExecuteCommandCalled = true; @@ -98,17 +96,17 @@ describe("post-install command", () => { assert.equal( isGenerateHtmlPagesCalled, opts.shouldCallMethod, - `post-install-cli command must ${hasNotInMsg} call helpService.generateHtmlPages` + `post-install-cli command must ${hasNotInMsg} call helpService.generateHtmlPages`, ); assert.equal( isCheckConsentCalled, opts.shouldCallMethod, - `post-install-cli command must ${hasNotInMsg} call analyticsService.checkConsent` + `post-install-cli command must ${hasNotInMsg} call analyticsService.checkConsent`, ); assert.equal( isTryExecuteCommandCalled, opts.shouldCallMethod, - `post-install-cli command must ${hasNotInMsg} call commandsService.tryExecuteCommand` + `post-install-cli command must ${hasNotInMsg} call commandsService.tryExecuteCommand`, ); }; diff --git a/test/config/config-json.ts b/test/config/config-json.ts index 9697b64339..fab216931f 100644 --- a/test/config/config-json.ts +++ b/test/config/config-json.ts @@ -14,7 +14,7 @@ describe("config.json", () => { assert.deepStrictEqual( data, expectedData, - "Data in config.json is not correct. Is this expected?" + "Data in config.json is not correct. Is this expected?", ); }); }); diff --git a/test/controllers/update-controller.ts b/test/controllers/update-controller.ts index a99cf9802d..83afd9cf8a 100644 --- a/test/controllers/update-controller.ts +++ b/test/controllers/update-controller.ts @@ -13,7 +13,7 @@ function createTestInjector(projectDir: string = projectFolder): IInjector { testInjector.register("errors", stubs.ErrorsStub); testInjector.register( "terminalSpinnerService", - stubs.TerminalSpinnerServiceStub + stubs.TerminalSpinnerServiceStub, ); testInjector.register("projectData", { projectDir, @@ -56,7 +56,9 @@ function createTestInjector(projectDir: string = projectFolder): IInjector { addToPackageJson() {}, }); - class PackageInstallationManagerStub extends stubs.PackageInstallationManagerStub { + class PackageInstallationManagerStub + extends stubs.PackageInstallationManagerStub + { getInstalledDependencyVersion = async (packageName: string) => { const projectData = testInjector.resolve("projectData"); const deps = { @@ -73,7 +75,7 @@ function createTestInjector(projectDir: string = projectFolder): IInjector { } testInjector.register( "packageInstallationManager", - PackageInstallationManagerStub + PackageInstallationManagerStub, ); testInjector.register("platformsDataService", stubs.NativeProjectDataStub); testInjector.register("pacoteService", stubs.PacoteServiceStub); @@ -94,7 +96,7 @@ function createTestInjector(projectDir: string = projectFolder): IInjector { function assertCalled(stub: sinon.SinonStub, ...args: any[]) { assert( stub.calledWith(...args), - `Expected a call with (${args.join(", ")}).` + `Expected a call with (${args.join(", ")}).`, ); } @@ -138,25 +140,24 @@ describe("update controller method tests", () => { assert.isTrue( hasError, - "expected updateController.update to throw an error" + "expected updateController.update to throw an error", ); assert.isTrue( backup._meta.createCalled, - "expected backup.create() to have been called" + "expected backup.create() to have been called", ); assert.isFalse(cleanCalled, "clean called even though backup failed"); assert.isTrue( backup._meta.removeCalled, - "expected backup.remove() to have been called" + "expected backup.remove() to have been called", ); }); it("handles exact versions", async () => { const testInjector = createTestInjector(); const updateController = testInjector.resolve("updateController"); - const pluginsService = testInjector.resolve( - "pluginsService" - ); + const pluginsService = + testInjector.resolve("pluginsService"); const stub = sinon.stub(pluginsService, "addToPackageJson"); @@ -175,9 +176,8 @@ describe("update controller method tests", () => { it("handles range versions", async () => { const testInjector = createTestInjector(); const updateController = testInjector.resolve("updateController"); - const pluginsService = testInjector.resolve( - "pluginsService" - ); + const pluginsService = + testInjector.resolve("pluginsService"); const stub = sinon.stub(pluginsService, "addToPackageJson"); @@ -196,9 +196,8 @@ describe("update controller method tests", () => { it("handles range versions", async () => { const testInjector = createTestInjector(); const updateController = testInjector.resolve("updateController"); - const pluginsService = testInjector.resolve( - "pluginsService" - ); + const pluginsService = + testInjector.resolve("pluginsService"); const stub = sinon.stub(pluginsService, "addToPackageJson"); @@ -217,9 +216,8 @@ describe("update controller method tests", () => { it("handles latest tag versions", async () => { const testInjector = createTestInjector(); const updateController = testInjector.resolve("updateController"); - const pluginsService = testInjector.resolve( - "pluginsService" - ); + const pluginsService = + testInjector.resolve("pluginsService"); const stub = sinon.stub(pluginsService, "addToPackageJson"); @@ -238,9 +236,8 @@ describe("update controller method tests", () => { it("handles existing tag versions", async () => { const testInjector = createTestInjector(); const updateController = testInjector.resolve("updateController"); - const pluginsService = testInjector.resolve( - "pluginsService" - ); + const pluginsService = + testInjector.resolve("pluginsService"); const stub = sinon.stub(pluginsService, "addToPackageJson"); @@ -259,9 +256,8 @@ describe("update controller method tests", () => { it("handles non-existing tag versions", async () => { const testInjector = createTestInjector(); const updateController = testInjector.resolve("updateController"); - const pluginsService = testInjector.resolve( - "pluginsService" - ); + const pluginsService = + testInjector.resolve("pluginsService"); const stub = sinon.stub(pluginsService, "addToPackageJson"); @@ -276,9 +272,8 @@ describe("update controller method tests", () => { it("handles partially existing tag versions", async () => { const testInjector = createTestInjector(); const updateController = testInjector.resolve("updateController"); - const pluginsService = testInjector.resolve( - "pluginsService" - ); + const pluginsService = + testInjector.resolve("pluginsService"); const stub = sinon.stub(pluginsService, "addToPackageJson"); @@ -294,9 +289,8 @@ describe("update controller method tests", () => { it("handles no version - falls back to latest", async () => { const testInjector = createTestInjector(); const updateController = testInjector.resolve("updateController"); - const pluginsService = testInjector.resolve( - "pluginsService" - ); + const pluginsService = + testInjector.resolve("pluginsService"); const stub = sinon.stub(pluginsService, "addToPackageJson"); diff --git a/test/helpers/platform-command-helper.ts b/test/helpers/platform-command-helper.ts index 6f8904404e..6c102d2e2d 100644 --- a/test/helpers/platform-command-helper.ts +++ b/test/helpers/platform-command-helper.ts @@ -65,12 +65,12 @@ describe("PlatformCommandHelper", () => { await platformCommandHelper.addPlatforms( [platform], projectData, - null + null, ); assert.isTrue(isAddPlatformCalled); }); - } + }, ); _.each(["ios", "android"], (platform) => { it(`should fail if ${platform} platform is already installed`, async () => { @@ -78,7 +78,7 @@ describe("PlatformCommandHelper", () => { await assert.isRejected( platformCommandHelper.addPlatforms([platform], projectData, ""), - `Platform ${platform} already added` + `Platform ${platform} already added`, ); }); }); @@ -99,7 +99,7 @@ describe("PlatformCommandHelper", () => { await platformCommandHelper.cleanPlatforms( [platform], injector.resolve("projectData"), - "" + "", ); }); }); diff --git a/test/ios-project-service.ts b/test/ios-project-service.ts index fa6d92fe6d..696490b104 100644 --- a/test/ios-project-service.ts +++ b/test/ios-project-service.ts @@ -615,7 +615,7 @@ describeOnMacOS("Cocoapods support", () => { const projectPodfilePath = join(platformsFolderPath, "Podfile"); assert.isTrue(fs.exists(projectPodfilePath)); - let actualProjectPodfileContent = fs.readText(projectPodfilePath); + const actualProjectPodfileContent = fs.readText(projectPodfilePath); const expectedPluginPodfileContent = [ "source 'https://github.com/CocoaPods/Specs.git'", "# platform :ios, '8.1'", @@ -832,7 +832,7 @@ describeOnMacOS("Source code support", () => { const platformsFolderPath = join(projectPath, "platforms", "ios"); fs.createDirectory(platformsFolderPath); - const pbxProj = await await getProjectWithoutPlugins(sourceFileNames); + const pbxProj = await getProjectWithoutPlugins(sourceFileNames); const pbxFileReference = pbxProj.hash.project.objects.PBXFileReference; const pbxFileReferenceValues = Object.keys(pbxFileReference).map( diff --git a/test/node-package-manager.ts b/test/node-package-manager.ts index 27efb270f3..6546684216 100644 --- a/test/node-package-manager.ts +++ b/test/node-package-manager.ts @@ -30,15 +30,13 @@ describe("node-package-manager", () => { expectedName: "some-template", }, { - name: - "should return both name and version when valid fullName with scope passed", + name: "should return both name and version when valid fullName with scope passed", templateFullName: "@nativescript/some-template@1.0.0", expectedVersion: "1.0.0", expectedName: "@nativescript/some-template", }, { - name: - "should return only name when version is not specified and the template is scoped", + name: "should return only name when version is not specified and the template is scoped", templateFullName: "@nativescript/some-template", expectedVersion: "", expectedName: "@nativescript/some-template", @@ -54,7 +52,7 @@ describe("node-package-manager", () => { const testInjector = createTestInjector(); const npm = testInjector.resolve("npm"); const templateNameParts = await npm.getPackageNameParts( - testCase.templateFullName + testCase.templateFullName, ); assert.strictEqual(templateNameParts.name, testCase.expectedName); assert.strictEqual(templateNameParts.version, testCase.expectedVersion); diff --git a/test/package-installation-manager.ts b/test/package-installation-manager.ts index ca2cbe409e..8e8a263086 100644 --- a/test/package-installation-manager.ts +++ b/test/package-installation-manager.ts @@ -55,7 +55,7 @@ function createTestInjector(): IInjector { testInjector.register("projectConfigService", ProjectConfigServiceStub); testInjector.register( "packageInstallationManager", - PackageInstallationManagerLib.PackageInstallationManager + PackageInstallationManagerLib.PackageInstallationManager, ); return testInjector; @@ -64,7 +64,7 @@ function createTestInjector(): IInjector { function mockNpm( testInjector: IInjector, versions: string[], - latestVersion: string + latestVersion: string, ) { testInjector.register("npm", { view: async (packageName: string, config: any): Promise => { @@ -274,7 +274,7 @@ describe("Npm installation manager tests", () => { mockNpm( testInjector, currentTestData.versions, - currentTestData.packageLatestVersion + currentTestData.packageLatestVersion, ); // Mock staticConfig.version @@ -283,7 +283,7 @@ describe("Npm installation manager tests", () => { // Mock packageInstallationManager.getLatestVersion const packageInstallationManager = testInjector.resolve( - "packageInstallationManager" + "packageInstallationManager", ); packageInstallationManager.getLatestVersion = (packageName: string) => Promise.resolve(currentTestData.packageLatestVersion); @@ -291,11 +291,11 @@ describe("Npm installation manager tests", () => { const actualLatestCompatibleVersion = await packageInstallationManager.getLatestCompatibleVersion( "", - currentTestData.referenceVersion + currentTestData.referenceVersion, ); assert.equal( actualLatestCompatibleVersion, - currentTestData.expectedResult + currentTestData.expectedResult, ); }); }); diff --git a/test/platform-commands.ts b/test/platform-commands.ts index 8efe669bd9..0e19faaccc 100644 --- a/test/platform-commands.ts +++ b/test/platform-commands.ts @@ -43,7 +43,7 @@ class PlatformData implements IPlatformData { platformNameLowerCase = "android"; platformProjectService: IPlatformProjectService = { validate: async ( - projectData: IProjectData + projectData: IProjectData, ): Promise => { return { checkEnvironmentRequirementsOutput: { @@ -84,7 +84,7 @@ class ErrorsNoFailStub implements IErrors { async beginCommand( action: () => Promise, - printHelpCommand: () => Promise + printHelpCommand: () => Promise, ): Promise { let result = false; try { @@ -111,7 +111,7 @@ class ErrorsNoFailStub implements IErrors { parsed: any, knownOpts: any, shorthands: any, - clientName?: string + clientName?: string, ): void { /* intentionally left blank */ } @@ -145,7 +145,7 @@ function createTestInjector() { testInjector.register("logger", stubs.LoggerStub); testInjector.register( "packageInstallationManager", - stubs.PackageInstallationManagerStub + stubs.PackageInstallationManagerStub, ); testInjector.register("projectData", stubs.ProjectDataStub); testInjector.register("platformsDataService", PlatformsDataService); @@ -156,19 +156,19 @@ function createTestInjector() { testInjector.register("commands-service", CommandsServiceLib.CommandsService); testInjector.registerCommand( "platform|add", - PlatformAddCommandLib.AddPlatformCommand + PlatformAddCommandLib.AddPlatformCommand, ); testInjector.registerCommand( "platform|remove", - PlatformRemoveCommandLib.RemovePlatformCommand + PlatformRemoveCommandLib.RemovePlatformCommand, ); testInjector.registerCommand( "platform|update", - PlatformUpdateCommandLib.UpdatePlatformCommand + PlatformUpdateCommandLib.UpdatePlatformCommand, ); testInjector.registerCommand( "platform|clean", - PlatformCleanCommandLib.CleanCommand + PlatformCleanCommandLib.CleanCommand, ); testInjector.register("resources", {}); testInjector.register("commandsService", { @@ -188,13 +188,13 @@ function createTestInjector() { }); testInjector.register( "projectFilesManager", - ProjectFilesManagerLib.ProjectFilesManager + ProjectFilesManagerLib.ProjectFilesManager, ); testInjector.register("hooksService", stubs.HooksServiceStub); testInjector.register( "localToDevicePathDataFactory", - LocalToDevicePathDataFactory + LocalToDevicePathDataFactory, ); testInjector.register("mobileHelper", MobileHelper); testInjector.register("projectFilesProvider", ProjectFilesProvider); @@ -204,7 +204,7 @@ function createTestInjector() { testInjector.register("childProcess", ChildProcessLib.ChildProcess); testInjector.register( "projectChangesService", - ProjectChangesLib.ProjectChangesService + ProjectChangesLib.ProjectChangesService, ); testInjector.register("analyticsService", { track: async () => async (): Promise => undefined, @@ -229,7 +229,7 @@ function createTestInjector() { checkEnvironmentRequirements: async ( platform?: string, projectDir?: string, - runtimeVersion?: string + runtimeVersion?: string, ): Promise => { return { canExecute: true, @@ -241,7 +241,7 @@ function createTestInjector() { extractPackage: async ( packageName: string, destinationDirectory: string, - options?: IPacoteExtractOptions + options?: IPacoteExtractOptions, ): Promise => undefined, }); testInjector.register("optionsTracker", { @@ -280,7 +280,7 @@ describe("Platform Service Tests", () => { it("is not executed when platform is not passed", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -296,7 +296,7 @@ describe("Platform Service Tests", () => { it("is not executed when platform is not valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { if (commandName !== "help") { @@ -316,7 +316,7 @@ describe("Platform Service Tests", () => { it("is executed when platform is valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -332,7 +332,7 @@ describe("Platform Service Tests", () => { it("is executed when all platforms are valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -351,7 +351,7 @@ describe("Platform Service Tests", () => { it("is not executed when at least one platform is not valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -372,7 +372,7 @@ describe("Platform Service Tests", () => { it("is not executed when platform is not passed", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -388,7 +388,7 @@ describe("Platform Service Tests", () => { it("is not executed when platform is not valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -406,7 +406,7 @@ describe("Platform Service Tests", () => { it("is executed when platform is valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -421,7 +421,7 @@ describe("Platform Service Tests", () => { it("is executed when all platforms are valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -440,7 +440,7 @@ describe("Platform Service Tests", () => { it("is not executed when at least one platform is not valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -467,7 +467,7 @@ describe("Platform Service Tests", () => { it("is not executed when platform is not passed", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -483,7 +483,7 @@ describe("Platform Service Tests", () => { it("is not executed when platform is not valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -502,7 +502,7 @@ describe("Platform Service Tests", () => { let commandsExecutedCount = 0; isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -525,7 +525,7 @@ describe("Platform Service Tests", () => { it("is not executed when platform is not added", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -542,7 +542,7 @@ describe("Platform Service Tests", () => { let commandsExecutedCount = 0; isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -569,7 +569,7 @@ describe("Platform Service Tests", () => { it("is not executed when at least one platform is not added", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -592,7 +592,7 @@ describe("Platform Service Tests", () => { it("is not executed when at least one platform is not valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -630,7 +630,7 @@ describe("Platform Service Tests", () => { assert.deepStrictEqual( platformActions, expectedPlatformActions, - "Expected `remove ios`, `add ios` calls to the platformService." + "Expected `remove ios`, `add ios` calls to the platformService.", ); }); }); @@ -639,7 +639,7 @@ describe("Platform Service Tests", () => { it("is not executed when platform is not passed", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -655,7 +655,7 @@ describe("Platform Service Tests", () => { it("is not executed when platform is not valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -673,7 +673,7 @@ describe("Platform Service Tests", () => { it("is executed when platform is valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -689,7 +689,7 @@ describe("Platform Service Tests", () => { it("is executed when all platforms are valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; @@ -708,7 +708,7 @@ describe("Platform Service Tests", () => { it("is not executed when at least one platform is not valid", async () => { isCommandExecuted = false; commandsService.executeCommandUnchecked = async ( - commandName: string + commandName: string, ): Promise => { if (commandName !== "help") { isCommandExecuted = true; diff --git a/test/post-install.ts b/test/post-install.ts index 2a5df27d34..a36ef23bc1 100644 --- a/test/post-install.ts +++ b/test/post-install.ts @@ -21,7 +21,7 @@ describe("postinstall.js", () => { childProcess.spawn = ( command: string, args?: string[], - options?: SpawnOptions + options?: SpawnOptions, ): ChildProcess => { isSpawnCalled = true; argsPassedToSpawn = args; @@ -32,7 +32,8 @@ describe("postinstall.js", () => { afterEach(() => { childProcess.spawn = originalSpawn; - helpers.isInstallingNativeScriptGlobally = originalIsInstallingNativeScriptGlobally; + helpers.isInstallingNativeScriptGlobally = + originalIsInstallingNativeScriptGlobally; }); it("calls post-install-cli command of CLI when it is global installation", () => { @@ -42,25 +43,25 @@ describe("postinstall.js", () => { assert.isTrue( isSpawnCalled, - "child_process.spawn must be called from postinstall.js" + "child_process.spawn must be called from postinstall.js", ); const expectedPathToCliExecutable = path.join( __dirname, "..", "bin", - "tns" + "tns", ); assert.isTrue( argsPassedToSpawn.indexOf(expectedPathToCliExecutable) !== -1, `The spawned args must contain path to TNS. - Expected path is: ${expectedPathToCliExecutable}, current args are: ${argsPassedToSpawn}.` + Expected path is: ${expectedPathToCliExecutable}, current args are: ${argsPassedToSpawn}.`, ); assert.isTrue( argsPassedToSpawn.indexOf(POST_INSTALL_COMMAND_NAME) !== -1, `The spawned args must contain the name of the post-install command. - Expected path is: ${expectedPathToCliExecutable}, current args are: ${argsPassedToSpawn}.` + Expected path is: ${expectedPathToCliExecutable}, current args are: ${argsPassedToSpawn}.`, ); }); @@ -69,7 +70,7 @@ describe("postinstall.js", () => { require(path.join(__dirname, "..", "postinstall")); assert.isFalse( isSpawnCalled, - "child_process.spawn must NOT be called from postinstall.js when CLI is not installed globally" + "child_process.spawn must NOT be called from postinstall.js when CLI is not installed globally", ); }); }); diff --git a/test/preuninstall.ts b/test/preuninstall.ts index da1dc4b571..4736cbff05 100644 --- a/test/preuninstall.ts +++ b/test/preuninstall.ts @@ -26,7 +26,7 @@ describe("preuninstall.js", () => { childProcess.spawn = ( command: string, args?: string[], - options?: SpawnOptions + options?: SpawnOptions, ): ChildProcess => { isSpawnCalled = true; argsPassedToSpawn = args; @@ -49,14 +49,14 @@ describe("preuninstall.js", () => { assert.isTrue( isSpawnCalled, - "child_process.spawn must be called from preuninstall.js" + "child_process.spawn must be called from preuninstall.js", ); const expectedPathToCliExecutable = path.join( __dirname, "..", "bin", - "tns" + "tns", ); assert.deepStrictEqual(argsPassedToSpawn, [ @@ -66,7 +66,7 @@ describe("preuninstall.js", () => { assert.deepStrictEqual( optionsPassedToSpawn, [{ stdio: "inherit" }], - "The stdio must be inherit as this way CLI's command can determine correctly if terminal is in interactive mode." + "The stdio must be inherit as this way CLI's command can determine correctly if terminal is in interactive mode.", ); assert.deepStrictEqual(dataPassedToConsoleError, []); @@ -79,18 +79,17 @@ describe("preuninstall.js", () => { it("passes --analyticsLogFile option when NS_CLI_PREUNINSTALL_ANALYTICS_LOG_FILE is set", () => { const content = readFileSync( - path.join(__dirname, "..", "preuninstall.js") + path.join(__dirname, "..", "preuninstall.js"), ).toString(); const originalEnvValue = process.env.NS_CLI_PREUNINSTALL_ANALYTICS_LOG_FILE; process.env.NS_CLI_PREUNINSTALL_ANALYTICS_LOG_FILE = "value from env analyticsLog.txt"; - /* tslint:disable:no-eval */ + // eslint-disable-next-line no-eval eval(content); - /* tslint:enable:no-eval */ process.env.NS_CLI_PREUNINSTALL_ANALYTICS_LOG_FILE = originalEnvValue; assert.isTrue( isSpawnCalled, - "child_process.spawn must be called from preuninstall.js" + "child_process.spawn must be called from preuninstall.js", ); // NOTE: As the script is eval'd, the `__dirname` in it is resolved to current file's location, @@ -106,7 +105,7 @@ describe("preuninstall.js", () => { assert.deepStrictEqual( optionsPassedToSpawn, [{ stdio: "inherit" }], - "The stdio must be inherit as this way CLI's command can determine correctly if terminal is in interactive mode." + "The stdio must be inherit as this way CLI's command can determine correctly if terminal is in interactive mode.", ); assert.deepStrictEqual(dataPassedToConsoleError, []); }); diff --git a/test/project-files-provider.ts b/test/project-files-provider.ts index a5edfc2314..08fcf4c730 100644 --- a/test/project-files-provider.ts +++ b/test/project-files-provider.ts @@ -72,11 +72,11 @@ describe("project-files-provider", () => { path.join(appSourceDir, "test.js"), "android", projectData, - {} + {}, ); assert.deepStrictEqual( mappedFilePath, - path.join(appDestinationDirectoryPath, "app", "test.js") + path.join(appDestinationDirectoryPath, "app", "test.js"), ); }); @@ -85,11 +85,11 @@ describe("project-files-provider", () => { path.join(appSourceDir, "App_Resources", "android", "test.js"), "android", projectData, - {} + {}, ); assert.deepStrictEqual( mappedFilePath, - path.join(appResourcesDestinationDirectoryPath, "test.js") + path.join(appResourcesDestinationDirectoryPath, "test.js"), ); }); @@ -98,7 +98,7 @@ describe("project-files-provider", () => { path.join(appSourceDir, "App_Resources", "android", "test.js"), "iOS", projectData, - {} + {}, ); assert.deepStrictEqual(mappedFilePath, null); }); @@ -108,7 +108,7 @@ describe("project-files-provider", () => { path.join(appSourceDir, "App_Resources", "test.js"), "android", projectData, - {} + {}, ); assert.deepStrictEqual(mappedFilePath, null); }); @@ -118,11 +118,11 @@ describe("project-files-provider", () => { path.join(appSourceDir, "test.android.js"), "android", projectData, - {} + {}, ); assert.deepStrictEqual( mappedFilePath, - path.join(appDestinationDirectoryPath, "app", "test.js") + path.join(appDestinationDirectoryPath, "app", "test.js"), ); }); @@ -131,11 +131,11 @@ describe("project-files-provider", () => { path.join(appSourceDir, "test.debug.js"), "android", projectData, - {} + {}, ); assert.deepStrictEqual( mappedFilePath, - path.join(appDestinationDirectoryPath, "app", "test.js") + path.join(appDestinationDirectoryPath, "app", "test.js"), ); }); }); diff --git a/test/project-name-service.ts b/test/project-name-service.ts index 10ec8b10ed..d9df1929de 100644 --- a/test/project-name-service.ts +++ b/test/project-name-service.ts @@ -14,9 +14,7 @@ const mockProjectNameValidator = { const dummyString: string = "dummyString"; function createTestInjector(): IInjector { - let testInjector: IInjector; - - testInjector = new Yok(); + const testInjector: IInjector = new Yok(); testInjector.register("projectNameService", ProjectNameService); testInjector.register("projectNameValidator", mockProjectNameValidator); testInjector.register("errors", ErrorsStub); diff --git a/test/project-service.ts b/test/project-service.ts index 21d1e5f1dc..817668868a 100644 --- a/test/project-service.ts +++ b/test/project-service.ts @@ -21,7 +21,6 @@ describe("projectService", () => { const invalidProjectName = "1invalid"; const dirToCreateProject: string = path.resolve("projectDir"); - /* tslint:disable:no-empty */ const getTestInjector = (opts: { projectName: string }): IInjector => { const testInjector = new yok.Yok(); testInjector.register("packageManager", { @@ -79,7 +78,7 @@ describe("projectService", () => { testInjector.register("hooksService", { executeAfterHooks: async ( commandName: string, - hookArguments?: IDictionary + hookArguments?: IDictionary, ): Promise => undefined, }); testInjector.register("pacoteService", { @@ -98,13 +97,12 @@ describe("projectService", () => { return testInjector; }; - /* tslint:enable:no-empty */ it("creates project with invalid name when projectNameService does not fail", async () => { const projectName = invalidProjectName; const testInjector = getTestInjector({ projectName }); const projectService = testInjector.resolve( - ProjectServiceLib.ProjectService + ProjectServiceLib.ProjectService, ); const projectDir = path.join(dirToCreateProject, projectName); const projectCreationData = await projectService.createProject({ @@ -125,7 +123,7 @@ describe("projectService", () => { const testInjector = getTestInjector({ projectName }); const options = testInjector.resolve("options"); const projectService = testInjector.resolve( - ProjectServiceLib.ProjectService + ProjectServiceLib.ProjectService, ); const projectDir = path.join(dirToCreateProject, projectName); @@ -145,7 +143,7 @@ describe("projectService", () => { `git init ${projectDir}`, `git -C ${projectDir} add --all`, `git -C ${projectDir} commit --no-verify -m "init"`, - ] + ], ); }); @@ -154,7 +152,7 @@ describe("projectService", () => { const testInjector = getTestInjector({ projectName }); const options = testInjector.resolve("options"); const projectService = testInjector.resolve( - ProjectServiceLib.ProjectService + ProjectServiceLib.ProjectService, ); // simulate --no-git @@ -169,22 +167,21 @@ describe("projectService", () => { assert.deepEqual( testInjector.resolve("childProcess")._getExecutedCommands(), - [] + [], ); }); it("fails when invalid name is passed when projectNameService fails", async () => { const projectName = invalidProjectName; const testInjector = getTestInjector({ projectName }); - const projectNameService = testInjector.resolve( - "projectNameService" - ); + const projectNameService = + testInjector.resolve("projectNameService"); const err = new Error("Invalid name"); projectNameService.ensureValidName = (name: string) => { throw err; }; const projectService = testInjector.resolve( - ProjectServiceLib.ProjectService + ProjectServiceLib.ProjectService, ); await assert.isRejected( projectService.createProject({ @@ -192,7 +189,7 @@ describe("projectService", () => { pathToProject: dirToCreateProject, template: constants.RESERVED_TEMPLATE_NAMES["default"], }), - err.message + err.message, ); }); @@ -202,7 +199,7 @@ describe("projectService", () => { const fs = testInjector.resolve("fs"); fs.isEmptyDir = (name: string) => false; const projectService = testInjector.resolve( - ProjectServiceLib.ProjectService + ProjectServiceLib.ProjectService, ); await assert.isRejected( projectService.createProject({ @@ -212,8 +209,8 @@ describe("projectService", () => { }), `Path already exists and is not empty ${path.join( dirToCreateProject, - projectName - )}` + projectName, + )}`, ); }); }); @@ -243,7 +240,7 @@ describe("projectService", () => { testInjector.register("hooksService", { executeAfterHooks: async ( commandName: string, - hookArguments?: IDictionary + hookArguments?: IDictionary, ): Promise => undefined, }); testInjector.register("pacoteService", { @@ -264,16 +261,15 @@ describe("projectService", () => { }); const projectService: IProjectService = testInjector.resolve( - ProjectServiceLib.ProjectService + ProjectServiceLib.ProjectService, ); assert.isTrue(projectService.isValidNativeScriptProject("some-dir")); }); it("returns correct data when multiple calls are executed", () => { const testInjector = getTestInjector(); - const projectDataService = testInjector.resolve( - "projectDataService" - ); + const projectDataService = + testInjector.resolve("projectDataService"); const projectData: any = { projectDir: "projectDir", projectId: "projectId", @@ -282,7 +278,7 @@ describe("projectService", () => { let returnedProjectData: any = null; projectDataService.getProjectData = ( - projectDir?: string + projectDir?: string, ): IProjectData => { projectData.projectDir = projectDir; returnedProjectData = projectData; @@ -290,7 +286,7 @@ describe("projectService", () => { }; const projectService: IProjectService = testInjector.resolve( - ProjectServiceLib.ProjectService + ProjectServiceLib.ProjectService, ); assert.isTrue(projectService.isValidNativeScriptProject("some-dir")); assert.equal(returnedProjectData.projectDir, "some-dir"); @@ -298,7 +294,7 @@ describe("projectService", () => { assert.equal(returnedProjectData.projectDir, "some-dir-2"); projectDataService.getProjectData = ( - projectDir?: string + projectDir?: string, ): IProjectData => { throw new Error("Err"); }; @@ -315,7 +311,7 @@ describe("projectService", () => { }); const projectService: IProjectService = testInjector.resolve( - ProjectServiceLib.ProjectService + ProjectServiceLib.ProjectService, ); assert.isFalse(projectService.isValidNativeScriptProject("some-dir")); }); @@ -326,7 +322,7 @@ describe("projectService", () => { }); const projectService: IProjectService = testInjector.resolve( - ProjectServiceLib.ProjectService + ProjectServiceLib.ProjectService, ); assert.isFalse(projectService.isValidNativeScriptProject("some-dir")); }); @@ -337,7 +333,7 @@ describe("projectService", () => { }); const projectService: IProjectService = testInjector.resolve( - ProjectServiceLib.ProjectService + ProjectServiceLib.ProjectService, ); assert.isFalse(projectService.isValidNativeScriptProject("some-dir")); }); diff --git a/test/project-templates-service.ts b/test/project-templates-service.ts index 10abc12520..d5a8f322b4 100644 --- a/test/project-templates-service.ts +++ b/test/project-templates-service.ts @@ -23,7 +23,7 @@ function createTestInjector( packageJsonContent?: any; packageVersion?: string; packageName?: string; - } = {} + } = {}, ): IInjector { const injector = new Yok(); injector.register("errors", stubs.ErrorsStub); @@ -38,7 +38,7 @@ function createTestInjector( public async install( packageName: string, pathToSave: string, - config: INodePackageManagerInstallOptions + config: INodePackageManagerInstallOptions, ): Promise { if (configuration.shouldNpmInstallThrow) { throw new Error("NPM install throws error."); @@ -47,7 +47,7 @@ function createTestInjector( return { name: "Some Result", version: "1" }; } async getPackageNameParts( - fullPackageName: string + fullPackageName: string, ): Promise { return { name: configuration.packageName || fullPackageName, @@ -58,11 +58,13 @@ function createTestInjector( injector.register("packageManager", NpmStub); - class NpmInstallationManagerStub extends stubs.PackageInstallationManagerStub { + class NpmInstallationManagerStub + extends stubs.PackageInstallationManagerStub + { async install( packageName: string, pathToSave?: string, - options?: INpmInstallOptions + options?: INpmInstallOptions, ): Promise { if (configuration.shouldNpmInstallThrow) { throw new Error("NPM install throws error."); @@ -140,16 +142,17 @@ describe("project-templates-service", () => { // }); it("uses defaultTemplate when undefined is passed as parameter", async () => { const testInjector = createTestInjector(); - const projectTemplatesService = testInjector.resolve< - IProjectTemplatesService - >("projectTemplatesService"); + const projectTemplatesService = + testInjector.resolve( + "projectTemplatesService", + ); const { templateName } = await projectTemplatesService.prepareTemplate( undefined, //constants.RESERVED_TEMPLATE_NAMES["default"], - "tempFolder" + "tempFolder", ); assert.strictEqual( templateName, - constants.RESERVED_TEMPLATE_NAMES["default"] + constants.RESERVED_TEMPLATE_NAMES["default"], ); // assert.strictEqual( // isDeleteDirectoryCalledForNodeModulesDir, @@ -166,19 +169,18 @@ describe("project-templates-service", () => { beforeEach(() => { testInjector = createTestInjector({ shouldNpmInstallThrow: false }); - analyticsService = testInjector.resolve( - "analyticsService" - ); + analyticsService = + testInjector.resolve("analyticsService"); const fs = testInjector.resolve("fs"); fs.exists = (filePath: string) => false; dataSentToGoogleAnalytics = []; analyticsService.trackEventActionInGoogleAnalytics = async ( - data: IEventActionData + data: IEventActionData, ): Promise => { dataSentToGoogleAnalytics.push(data); }; projectTemplatesService = testInjector.resolve( - "projectTemplatesService" + "projectTemplatesService", ); }); @@ -186,7 +188,7 @@ describe("project-templates-service", () => { const templateName = "template-from-npm"; await projectTemplatesService.prepareTemplate( templateName, - "tempFolder" + "tempFolder", ); assert.deepStrictEqual(dataSentToGoogleAnalytics, [ { @@ -206,13 +208,12 @@ describe("project-templates-service", () => { const localTemplatePath = "/Users/username/localtemplate"; const fs = testInjector.resolve("fs"); fs.exists = (filePath: string): boolean => true; - const pacoteService = testInjector.resolve( - "pacoteService" - ); + const pacoteService = + testInjector.resolve("pacoteService"); pacoteService.manifest = () => Promise.resolve({ name: templateName }); await projectTemplatesService.prepareTemplate( localTemplatePath, - "tempFolder" + "tempFolder", ); assert.deepStrictEqual(dataSentToGoogleAnalytics, [ { @@ -233,13 +234,12 @@ describe("project-templates-service", () => { const fs = testInjector.resolve("fs"); fs.exists = (localPath: string): boolean => path.basename(localPath) !== constants.PACKAGE_JSON_FILE_NAME; - const pacoteService = testInjector.resolve( - "pacoteService" - ); + const pacoteService = + testInjector.resolve("pacoteService"); pacoteService.manifest = () => Promise.resolve({}); await projectTemplatesService.prepareTemplate( localTemplatePath, - "tempFolder" + "tempFolder", ); assert.deepStrictEqual(dataSentToGoogleAnalytics, [ { @@ -287,16 +287,15 @@ describe("project-templates-service", () => { packageVersion: testCase.expectedVersion, packageName: testCase.expectedTemplateName, }); - const projectTemplatesService = testInjector.resolve< - IProjectTemplatesService - >("projectTemplatesService"); - const { - version, - templateName, - } = await projectTemplatesService.prepareTemplate( - testCase.templateName, - "tempFolder" - ); + const projectTemplatesService = + testInjector.resolve( + "projectTemplatesService", + ); + const { version, templateName } = + await projectTemplatesService.prepareTemplate( + testCase.templateName, + "tempFolder", + ); assert.strictEqual(version, testCase.expectedVersion); assert.strictEqual(templateName, testCase.expectedTemplateName); }); diff --git a/test/services/android-device-debug-service.ts b/test/services/android-device-debug-service.ts index 1d336df4e4..312ae009e5 100644 --- a/test/services/android-device-debug-service.ts +++ b/test/services/android-device-debug-service.ts @@ -19,7 +19,7 @@ class AndroidDeviceDebugServiceInheritor extends AndroidDeviceDebugService { $androidProcessService: Mobile.IAndroidProcessService, $staticConfig: IStaticConfig, $net: INet, - $deviceLogProvider: Mobile.IDeviceLogProvider + $deviceLogProvider: Mobile.IDeviceLogProvider, ) { super( { deviceInfo: { identifier: "123" } }, @@ -30,7 +30,7 @@ class AndroidDeviceDebugServiceInheritor extends AndroidDeviceDebugService { $androidProcessService, $staticConfig, $net, - $deviceLogProvider + $deviceLogProvider, ); } @@ -181,12 +181,13 @@ describe("androidDeviceDebugService", () => { for (const testCase of chromUrlTestCases) { it(`returns correct url when ${testCase.scenarioName}`, () => { const testInjector = createTestInjector(); - const androidDeviceDebugService = testInjector.resolve< - AndroidDeviceDebugServiceInheritor - >(AndroidDeviceDebugServiceInheritor); + const androidDeviceDebugService = + testInjector.resolve( + AndroidDeviceDebugServiceInheritor, + ); const actualChromeUrl = androidDeviceDebugService.getChromeDebugUrl( testCase.debugOptions, - expectedPort + expectedPort, ); assert.equal(actualChromeUrl, testCase.expectedChromeUrl); }); diff --git a/test/services/android-plugin-build-service.ts b/test/services/android-plugin-build-service.ts index c2107cf4c1..54470ecdcf 100644 --- a/test/services/android-plugin-build-service.ts +++ b/test/services/android-plugin-build-service.ts @@ -449,7 +449,7 @@ dependencies { const gradleWrappersContent = fs.readText( path.join(tempFolder, shortPluginName, "build.gradle"), ); - const androidVersionRegex = /com\.android\.tools\.build\:gradle\:(.*)['"]/g; + const androidVersionRegex = /com\.android\.tools\.build:gradle:(.*)['"]/g; const androidVersion = androidVersionRegex.exec(gradleWrappersContent)[1]; // in case it's a variable, return expected - not perfect, but should be the correct behavior... @@ -470,7 +470,7 @@ dependencies { "gradle-wrapper.properties", ), ); - const gradleVersionRegex = /gradle\-(.*)\-bin\.zip\r?\n/g; + const gradleVersionRegex = /gradle-(.*)-bin\.zip\r?\n/g; const gradleVersion = gradleVersionRegex.exec(buildGradleContent)[1]; return gradleVersion; diff --git a/test/services/android-project-service.ts b/test/services/android-project-service.ts index 1961548012..3da4f72b9e 100644 --- a/test/services/android-project-service.ts +++ b/test/services/android-project-service.ts @@ -102,7 +102,7 @@ describe("androidProjectService", () => { childProcess = injector.resolve("childProcess"); const getPlatformDataStub: sinon.SinonStub = sandbox.stub( androidProjectService, - "getPlatformData" + "getPlatformData", ); getPlatformDataStub.callsFake(() => { return { @@ -120,7 +120,7 @@ describe("androidProjectService", () => { await androidProjectService.buildProject( "local/local", projectData, - buildConfig + buildConfig, ); //assert @@ -136,7 +136,7 @@ describe("androidProjectService", () => { await androidProjectService.buildProject( "local/local", projectData, - buildConfig + buildConfig, ); //assert @@ -152,7 +152,7 @@ describe("androidProjectService", () => { await androidProjectService.buildProject( "local/local", projectData, - buildConfig + buildConfig, ); //assert @@ -169,7 +169,7 @@ describe("androidProjectService", () => { await androidProjectService.buildProject( "local/local", projectData, - buildConfig + buildConfig, ); //assert @@ -182,30 +182,30 @@ describe("androidProjectService", () => { const pathToAppResourcesDir = path.join(projectDir, "app", "App_Resources"); const pathToAppResourcesAndroid = path.join( pathToAppResourcesDir, - "Android" + "Android", ); const pathToPlatformsAndroid = path.join( projectDir, "platforms", - "android" + "android", ); const pathToResDirInPlatforms = path.join( pathToPlatformsAndroid, "app", "src", "main", - "res" + "res", ); const valuesV27Path = path.join(pathToResDirInPlatforms, "values-v27"); const valuesV28Path = path.join(pathToResDirInPlatforms, "values-v28"); const libsPath = path.join(pathToResDirInPlatforms, "libs"); const drawableHdpiPath = path.join( pathToResDirInPlatforms, - "drawable-hdpi" + "drawable-hdpi", ); const drawableLdpiPath = path.join( pathToResDirInPlatforms, - "drawable-ldpi" + "drawable-ldpi", ); let deletedDirs: string[] = []; let copiedFiles: { @@ -232,7 +232,7 @@ describe("androidProjectService", () => { }; fs.copyFile = ( sourceFileName: string, - destinationFileName: string + destinationFileName: string, ): void => { copiedFiles.push({ sourceFileName, destinationFileName }); }; @@ -245,7 +245,7 @@ describe("androidProjectService", () => { const androidToolsInfo = injector.resolve("androidToolsInfo"); androidToolsInfo.getToolsInfo = ( - config?: IProjectDir + config?: IProjectDir, ): IAndroidToolsInfoData => { return { compileSdkVersion, @@ -256,12 +256,12 @@ describe("androidProjectService", () => { describe("when new Android App_Resources structure is detected (post {N} 4.0 structure)", () => { const pathToSrcDirInAppResources = path.join( pathToAppResourcesAndroid, - "src" + "src", ); beforeEach(() => { const androidResourcesMigrationService = injector.resolve( - "androidResourcesMigrationService" + "androidResourcesMigrationService", ); androidResourcesMigrationService.hasMigrated = () => true; }); @@ -277,7 +277,7 @@ describe("androidProjectService", () => { "platforms", "android", "app", - "src" + "src", ), }, ]); @@ -333,7 +333,7 @@ describe("androidProjectService", () => { beforeEach(() => { const androidResourcesMigrationService = injector.resolve( - "androidResourcesMigrationService" + "androidResourcesMigrationService", ); androidResourcesMigrationService.hasMigrated = () => false; }); diff --git a/test/services/ios-debugger-port-service.ts b/test/services/ios-debugger-port-service.ts index 082bfa1b5c..46ec938ba8 100644 --- a/test/services/ios-debugger-port-service.ts +++ b/test/services/ios-debugger-port-service.ts @@ -153,7 +153,7 @@ describe("iOSDebuggerPortService", () => { deviceLogProvider.emit( DEVICE_LOG_EVENT_NAME, message, - device.deviceInfo.identifier + device.deviceInfo.identifier, ); } describe("getPort", () => { diff --git a/test/services/ios-device-debug-service.ts b/test/services/ios-device-debug-service.ts index ccbfbec5a4..d92b335d64 100644 --- a/test/services/ios-device-debug-service.ts +++ b/test/services/ios-device-debug-service.ts @@ -26,7 +26,7 @@ class IOSDeviceDebugServiceInheritor extends IOSDeviceDebugService { $errors: IErrors, $packageInstallationManager: IPackageInstallationManager, $appDebugSocketProxyFactory: IAppDebugSocketProxyFactory, - $projectDataService: IProjectDataService + $projectDataService: IProjectDataService, ) { super( { deviceInfo: { identifier: "123" } }, @@ -37,7 +37,7 @@ class IOSDeviceDebugServiceInheritor extends IOSDeviceDebugService { $errors, $packageInstallationManager, $appDebugSocketProxyFactory, - $projectDataService + $projectDataService, ); } @@ -65,7 +65,7 @@ const createTestInjector = (): IInjector => { testInjector.register("net", { getAvailablePortInRange: async ( startPort: number, - endPort?: number + endPort?: number, ): Promise => 41000, waitForPortToListen: async (opts: { port: number; @@ -216,12 +216,13 @@ describe("iOSDeviceDebugService", () => { for (const testCase of chromUrlTestCases) { it(`returns correct url when ${testCase.scenarioName}`, () => { const testInjector = createTestInjector(); - const iOSDeviceDebugService = testInjector.resolve< - IOSDeviceDebugServiceInheritor - >(IOSDeviceDebugServiceInheritor); + const iOSDeviceDebugService = + testInjector.resolve( + IOSDeviceDebugServiceInheritor, + ); const actualChromeUrl = iOSDeviceDebugService.getChromeDebugUrl( testCase.debugOptions, - expectedPort + expectedPort, ); assert.equal(actualChromeUrl, testCase.expectedChromeUrl); }); @@ -233,12 +234,13 @@ describe("iOSDeviceDebugService", () => { const hostInfo = testInjector.resolve("hostInfo"); hostInfo.isDarwin = hostInfo.isWindows = false; - const iOSDeviceDebugService = testInjector.resolve< - IOSDeviceDebugServiceInheritor - >(IOSDeviceDebugServiceInheritor); + const iOSDeviceDebugService = + testInjector.resolve( + IOSDeviceDebugServiceInheritor, + ); assert.isRejected( iOSDeviceDebugService.debug(null, null), - "Debugging on iOS devices is not supported for" + "Debugging on iOS devices is not supported for", ); }); }); diff --git a/test/services/ios-log-filter.ts b/test/services/ios-log-filter.ts index 2330e8958e..3d5d6e7c56 100644 --- a/test/services/ios-log-filter.ts +++ b/test/services/ios-log-filter.ts @@ -211,7 +211,7 @@ describe("iOSLogFilter", () => { assert.deepStrictEqual( output, - data.infoExpectedArr.filter((item) => item !== null).join("\n") + data.infoExpectedArr.filter((item) => item !== null).join("\n"), ); }); @@ -220,7 +220,7 @@ describe("iOSLogFilter", () => { logFilter = testInjector.resolve(IOSLogFilter); const actualData = logFilter.filterData( data.originalDataArr.join("\n"), - { logLevel: fullLogLevel, projectName: data.projectName } + { logLevel: fullLogLevel, projectName: data.projectName }, ); const actualArr = actualData.split("\n").map((line) => line.trim()); const expectedArr = data.originalDataArr @@ -252,7 +252,7 @@ describe("iOSLogFilter", () => { const actualArr = actualData.split("\n").map((line) => line.trim()); assert.deepStrictEqual( actualArr, - data.simulatorExpectedArr.filter((item) => item !== null) + data.simulatorExpectedArr.filter((item) => item !== null), ); }); @@ -261,11 +261,11 @@ describe("iOSLogFilter", () => { logFilter = testInjector.resolve(IOSLogFilter); const actualData = logFilter.filterData( data.originalDataArr.join("\n"), - { logLevel: infoLogLevel, projectName: data.projectName } + { logLevel: infoLogLevel, projectName: data.projectName }, ); const actualArr = actualData.split("\n").map((line) => line.trim()); const expectedArr = data.infoExpectedArr.filter( - (item) => item !== null + (item) => item !== null, ); assert.deepStrictEqual(actualArr, expectedArr); }); diff --git a/test/services/ios/export-options-plist-service.ts b/test/services/ios/export-options-plist-service.ts index 56e9ba8c0e..4e218c44d5 100644 --- a/test/services/ios/export-options-plist-service.ts +++ b/test/services/ios/export-options-plist-service.ts @@ -41,7 +41,7 @@ function expectPlistTemplateToContain(template: string, expected: string) { const trimmedExpected = expected.replace(/\s/g, ""); assert.isTrue( trimmedTemplate.indexOf(trimmedExpected) !== -1, - `Expected plist template to contain:\n\n${expected}\n\nbut it was:\n\n${template}` + `Expected plist template to contain:\n\n${expected}\n\nbut it was:\n\n${template}`, ); } @@ -92,7 +92,7 @@ describe("ExportOptionsPlistService", () => { provisioningJSON = testCase.provisioningJSON; } const exportOptionsPlistService = injector.resolve( - "exportOptionsPlistService" + "exportOptionsPlistService", ); exportOptionsPlistService.getExportOptionsMethod = () => provisionType; @@ -104,29 +104,29 @@ describe("ExportOptionsPlistService", () => { await exportOptionsPlistService.createDevelopmentExportOptionsPlist( archivePath, projectData, - testCase.buildConfig + testCase.buildConfig, ); expectPlistTemplateToContain( actualPlistTemplate, - `method${provisionType}` + `method${provisionType}`, ); expectPlistTemplateToContain( actualPlistTemplate, - `uploadBitcode` + `uploadBitcode`, ); expectPlistTemplateToContain( actualPlistTemplate, - `compileBitcode` + `compileBitcode`, ); if (testCase.expectedPlist) { expectPlistTemplateToContain( actualPlistTemplate, - testCase.expectedPlist + testCase.expectedPlist, ); } }); - } + }, ); }); }); @@ -172,7 +172,7 @@ describe("ExportOptionsPlistService", () => { provisioningJSON = testCase.provisioningJSON; } const exportOptionsPlistService = injector.resolve( - "exportOptionsPlistService" + "exportOptionsPlistService", ); exportOptionsPlistService.getExportOptionsMethod = () => "app-store"; @@ -183,30 +183,30 @@ describe("ExportOptionsPlistService", () => { await exportOptionsPlistService.createDistributionExportOptionsPlist( projectRoot, projectData, - testCase.buildConfig + testCase.buildConfig, ); expectPlistTemplateToContain( actualPlistTemplate, - `methodapp-store-connect` + `methodapp-store-connect`, ); expectPlistTemplateToContain( actualPlistTemplate, - `uploadBitcode` + `uploadBitcode`, ); expectPlistTemplateToContain( actualPlistTemplate, - `compileBitcode` + `compileBitcode`, ); expectPlistTemplateToContain( actualPlistTemplate, - `uploadSymbols` + `uploadSymbols`, ); if (testCase.expectedPlist) { expectPlistTemplateToContain( actualPlistTemplate, - testCase.expectedPlist + testCase.expectedPlist, ); } }); diff --git a/test/services/ios/xcodebuild-service.ts b/test/services/ios/xcodebuild-service.ts index 611f402c77..39b86676df 100644 --- a/test/services/ios/xcodebuild-service.ts +++ b/test/services/ios/xcodebuild-service.ts @@ -29,7 +29,7 @@ function createTestInjector(): IInjector { injector.register("xcodebuildCommandService", { executeCommand: async ( args: string[], - options: IXcodebuildCommandOptions + options: IXcodebuildCommandOptions, ) => { actualBuildArgs = args; actualBuildOptions = options; @@ -55,7 +55,7 @@ describe("xcodebuildService", () => { const buildResult = await xcodebuildService.buildForDevice( platformData, projectData, - {} + {}, ); const expectedBuildArgs = [ @@ -63,7 +63,7 @@ describe("xcodebuildService", () => { "-archivePath", path.join( platformData.getBuildOutputPath(), - `${projectName}.xcarchive` + `${projectName}.xcarchive`, ), "-exportPath", exportOptionsPlistOutput.exportFileDir, @@ -77,7 +77,7 @@ describe("xcodebuildService", () => { }); assert.deepStrictEqual( buildResult, - exportOptionsPlistOutput.exportFilePath + exportOptionsPlistOutput.exportFilePath, ); }); }); @@ -113,7 +113,7 @@ describe("xcodebuildService", () => { const buildResult = await xcodebuildService.buildForAppStore( platformData, projectData, - {} + {}, ); const expectedBuildArgs = [ @@ -121,7 +121,7 @@ describe("xcodebuildService", () => { "-archivePath", path.join( platformData.getBuildOutputPath(), - `${projectName}.xcarchive` + `${projectName}.xcarchive`, ), "-exportPath", exportOptionsPlistOutput.exportFileDir, @@ -133,7 +133,7 @@ describe("xcodebuildService", () => { assert.deepStrictEqual(actualBuildOptions, { cwd: projectRoot }); assert.deepStrictEqual( buildResult, - exportOptionsPlistOutput.exportFilePath + exportOptionsPlistOutput.exportFilePath, ); }); }); diff --git a/test/services/ip-service.ts b/test/services/ip-service.ts index e835c02890..93138a0ace 100644 --- a/test/services/ip-service.ts +++ b/test/services/ip-service.ts @@ -15,7 +15,7 @@ describe("ipService", () => { testInjector.register("httpClient", { httpRequest: async ( options: any, - proxySettings?: IProxySettings + proxySettings?: IProxySettings, ): Promise => {}, }); @@ -31,7 +31,7 @@ describe("ipService", () => { const httpRequestPassedOptions: any[] = []; httpClient.httpRequest = async ( options: any, - proxySettings?: IProxySettings + proxySettings?: IProxySettings, ): Promise => { httpRequestPassedOptions.push(options); return { body: JSON.stringify({ ip }) }; @@ -52,7 +52,7 @@ describe("ipService", () => { const httpRequestPassedOptions: any[] = []; httpClient.httpRequest = async ( options: any, - proxySettings?: IProxySettings + proxySettings?: IProxySettings, ): Promise => { httpRequestPassedOptions.push(options); if (options.url === "https://api.myip.com") { @@ -74,7 +74,7 @@ describe("ipService", () => { const logger = testInjector.resolve("logger"); assert.isTrue( logger.traceOutput.indexOf(errMsgForMyipCom) !== -1, - `Trace output\n'${logger.traceOutput}'\ndoes not contain expected message:\n${errMsgForMyipCom}` + `Trace output\n'${logger.traceOutput}'\ndoes not contain expected message:\n${errMsgForMyipCom}`, ); }); @@ -84,7 +84,7 @@ describe("ipService", () => { const httpRequestPassedOptions: any[] = []; httpClient.httpRequest = async ( options: any, - proxySettings?: IProxySettings + proxySettings?: IProxySettings, ): Promise => { httpRequestPassedOptions.push(options); if (options.url === "https://api.myip.com") { @@ -110,11 +110,11 @@ describe("ipService", () => { const logger = testInjector.resolve("logger"); assert.isTrue( logger.traceOutput.indexOf(errMsgForMyipCom) !== -1, - `Trace output\n'${logger.traceOutput}'\ndoes not contain expected message:\n${errMsgForMyipCom}` + `Trace output\n'${logger.traceOutput}'\ndoes not contain expected message:\n${errMsgForMyipCom}`, ); assert.isTrue( logger.traceOutput.indexOf(errMsgForIpifyOrg) !== -1, - `Trace output\n'${logger.traceOutput}'\ndoes not contain expected message:\n${errMsgForMyipCom}` + `Trace output\n'${logger.traceOutput}'\ndoes not contain expected message:\n${errMsgForMyipCom}`, ); }); @@ -124,7 +124,7 @@ describe("ipService", () => { let httpRequestCounter = 0; httpClient.httpRequest = async ( options: any, - proxySettings?: IProxySettings + proxySettings?: IProxySettings, ): Promise => { httpRequestCounter++; return { body: JSON.stringify({ ip }) }; diff --git a/test/services/livesync/android-device-livesync-service-base.ts b/test/services/livesync/android-device-livesync-service-base.ts index 1c7612b741..83f338a935 100644 --- a/test/services/livesync/android-device-livesync-service-base.ts +++ b/test/services/livesync/android-device-livesync-service-base.ts @@ -40,14 +40,14 @@ class AndroidDeviceLiveSyncServiceBaseMock extends AndroidDeviceLiveSyncServiceB $platformsDataService: any, $filesHashService: any, $logger: ILogger, - device: Mobile.IAndroidDevice + device: Mobile.IAndroidDevice, ) { super($injector, $platformsDataService, $filesHashService, $logger, device); } public async transferFilesOnDevice( deviceAppData: Mobile.IDeviceAppData, - localToDevicePaths: Mobile.ILocalToDevicePathData[] + localToDevicePaths: Mobile.ILocalToDevicePathData[], ): Promise { transferFilesOnDeviceParams.push({ deviceAppData, localToDevicePaths }); } @@ -55,7 +55,7 @@ class AndroidDeviceLiveSyncServiceBaseMock extends AndroidDeviceLiveSyncServiceB public async transferDirectoryOnDevice( deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], - projectFilesPath: string + projectFilesPath: string, ): Promise { transferDirectoryOnDeviceParams.push({ deviceAppData, @@ -74,7 +74,7 @@ class LocalToDevicePathDataMock { public getDevicePath(): string { return `${LiveSyncPaths.ANDROID_TMP_DIR_NAME}/${path.basename( - this.filePath + this.filePath, )}`; } } @@ -99,7 +99,7 @@ function createTestInjector() { } function mockDevice( - deviceHashService: Mobile.IAndroidDeviceHashService + deviceHashService: Mobile.IAndroidDeviceHashService, ): Mobile.IAndroidDevice { const device: Mobile.IAndroidDevice = { deviceInfo: mockDeviceInfo(), @@ -132,7 +132,7 @@ function mockDeviceInfo(): Mobile.IDeviceInfo { } function createDeviceAppData( - deviceHashService: Mobile.IAndroidDeviceHashService + deviceHashService: Mobile.IAndroidDeviceHashService, ): Mobile.IDeviceAppData { return { getDeviceProjectRootPath: async () => @@ -165,7 +165,7 @@ function mockDeviceApplicationManager(): Mobile.IDeviceApplicationManager { } function mockDeviceFileSystem( - deviceHashService: Mobile.IAndroidDeviceHashService + deviceHashService: Mobile.IAndroidDeviceHashService, ): Mobile.IAndroidDeviceFileSystem { return { deleteFile: async (deviceFilePath: string, appId: string) => { @@ -176,12 +176,12 @@ function mockDeviceFileSystem( }; } -function mockFsStats(options: { - isDirectory: boolean; - isFile: boolean; -}): ( - filePath: string -) => { isDirectory: () => boolean; isFile: () => boolean } { +function mockFsStats(options: { isDirectory: boolean; isFile: boolean }): ( + filePath: string, +) => { + isDirectory: () => boolean; + isFile: () => boolean; +} { return (filePath: string) => ({ isDirectory: (): boolean => options.isDirectory, isFile: (): boolean => options.isFile, @@ -226,19 +226,20 @@ function setup(options?: ITestSetupInput): ITestSetupOutput { appIdentifier, fs, injector.resolve("mobileHelper"), - { mkdirSync: async () => "" } + { mkdirSync: async () => "" }, ); const localToDevicePaths = _.keys(filesToShasums).map((file) => - injector.resolve(LocalToDevicePathDataMock, { filePath: file }) + injector.resolve(LocalToDevicePathDataMock, { filePath: file }), ); const deviceAppData = createDeviceAppData(deviceHashService); - const androidDeviceLiveSyncServiceBase = new AndroidDeviceLiveSyncServiceBaseMock( - injector, - mockPlatformsData(), - mockFilesHashService(), - mockLogger(), - mockDevice(deviceHashService) - ); + const androidDeviceLiveSyncServiceBase = + new AndroidDeviceLiveSyncServiceBaseMock( + injector, + mockPlatformsData(), + mockFilesHashService(), + mockLogger(), + mockDevice(deviceHashService), + ); fs.exists = () => options.existsHashesFile; fs.getFsStats = mockFsStats({ isDirectory: false, isFile: true }); @@ -268,7 +269,7 @@ function setup(options?: ITestSetupInput): ITestSetupOutput { async function transferFiles( testSetup: ITestSetupOutput, - options: { force: boolean; isFullSync: boolean } + options: { force: boolean; isFullSync: boolean }, ): Promise { const androidDeviceLiveSyncServiceBase = testSetup.androidDeviceLiveSyncServiceBase; @@ -278,7 +279,7 @@ async function transferFiles( testSetup.projectRoot, {}, {}, - options + options, ); return transferredFiles; } @@ -301,12 +302,12 @@ describe("AndroidDeviceLiveSyncServiceBase", () => { assert.equal(transferredFiles.length, 1); assert.equal( transferredFiles[0].getLocalPath(), - testSetup.changedFileLocalPath + testSetup.changedFileLocalPath, ); assert.equal(transferDirectoryOnDeviceParams.length, 1); assert.equal( transferDirectoryOnDeviceParams[0].localToDevicePaths.length, - 1 + 1, ); }); it("transfers only changed files when there are file changes", async () => { @@ -321,7 +322,7 @@ describe("AndroidDeviceLiveSyncServiceBase", () => { assert.equal(transferredFiles.length, 1); assert.equal( transferredFiles[0].getLocalPath(), - testSetup.changedFileLocalPath + testSetup.changedFileLocalPath, ); }); it("transfers only changed files when there are both changed and not changed files", async () => { @@ -337,7 +338,7 @@ describe("AndroidDeviceLiveSyncServiceBase", () => { assert.equal(transferredFiles.length, 1); assert.equal( transferredFiles[0].getLocalPath(), - testSetup.changedFileLocalPath + testSetup.changedFileLocalPath, ); }); it("does not transfer files when no file changes", async () => { @@ -365,11 +366,11 @@ describe("AndroidDeviceLiveSyncServiceBase", () => { assert.equal(transferredFiles.length, 2); assert.deepStrictEqual( transferredFiles[0].getLocalPath(), - testSetup.changedFileLocalPath + testSetup.changedFileLocalPath, ); assert.deepStrictEqual( transferredFiles[1].getLocalPath(), - testSetup.unchangedFileLocalPath + testSetup.unchangedFileLocalPath, ); }); it("transfers files which has different location and no changed files", async () => { @@ -386,7 +387,7 @@ describe("AndroidDeviceLiveSyncServiceBase", () => { assert.equal(transferredFiles.length, 1); assert.deepStrictEqual( transferredFiles[0].getLocalPath(), - testSetup.unchangedFileLocalPath + testSetup.unchangedFileLocalPath, ); }); it("transfers changed files with different location", async () => { @@ -402,7 +403,7 @@ describe("AndroidDeviceLiveSyncServiceBase", () => { assert.equal(transferredFiles.length, 1); assert.equal( transferredFiles[0].getLocalPath(), - testSetup.changedFileLocalPath + testSetup.changedFileLocalPath, ); }); }); @@ -419,7 +420,7 @@ describe("AndroidDeviceLiveSyncServiceBase", () => { assert.equal(transferredFiles.length, 1); assert.equal( transferredFiles[0].getLocalPath(), - testSetup.changedFileLocalPath + testSetup.changedFileLocalPath, ); assert.equal(transferDirectoryOnDeviceParams.length, 0); }); @@ -434,7 +435,7 @@ describe("AndroidDeviceLiveSyncServiceBase", () => { assert.equal(transferredFiles.length, 1); assert.equal( transferredFiles[0].getLocalPath(), - testSetup.changedFileLocalPath + testSetup.changedFileLocalPath, ); }); }); diff --git a/test/services/livesync/android-livesync-tool.ts b/test/services/livesync/android-livesync-tool.ts index 712cecd59f..57dc90aad6 100644 --- a/test/services/livesync/android-livesync-tool.ts +++ b/test/services/livesync/android-livesync-tool.ts @@ -27,7 +27,7 @@ class TestSocket extends LiveSyncSocket { data: Buffer | string, cb?: string | Function, encoding?: Function | string, - ): Promise { + ): Promise { if (data instanceof Buffer) { this.accomulatedData.push(data); } else { diff --git a/test/services/log-parser-service.ts b/test/services/log-parser-service.ts index e848a46113..ad3a6e0712 100644 --- a/test/services/log-parser-service.ts +++ b/test/services/log-parser-service.ts @@ -55,7 +55,7 @@ describe("iOSLogParserService", () => { deviceLogProvider.emit( DEVICE_LOG_EVENT_NAME, message, - device.deviceInfo.identifier + device.deviceInfo.identifier, ); } diff --git a/test/services/log-source-map-service.ts b/test/services/log-source-map-service.ts index eb7a22037d..7582bdd1c1 100644 --- a/test/services/log-source-map-service.ts +++ b/test/services/log-source-map-service.ts @@ -40,7 +40,7 @@ function createTestInjector(): IInjector { "..", "files", "sourceMapBundle", - platform.toLowerCase() + platform.toLowerCase(), ), frameworkPackageName: `tns-${platform.toLowerCase()}`, }; @@ -75,7 +75,7 @@ const testCases: IDictionary< message: "JS: at module.exports.push../main-view-model.ts.HelloWorldModel.onTap (file:///data/data/org.nativescript.sourceMap/files/app/bundle.js:303:17)", expected: `JS: at module.exports.push../main-view-model.ts.HelloWorldModel.onTap file: ${toPlatformSep( - "src/main-view-model.ts" + "src/main-view-model.ts", )}:30:16\n`, }, { @@ -83,7 +83,7 @@ const testCases: IDictionary< message: "System.err: Frame: function:'module.exports.push../main-view-model.ts.HelloWorldModel.onTap', file:'file:///data/data/org.nativescript.sourceMap/files/app/bundle.js', line: 304, column: 15", expected: `System.err: Frame: function:'module.exports.push../main-view-model.ts.HelloWorldModel.onTap', file:'file: ${toPlatformSep( - "src/main-view-model.ts" + "src/main-view-model.ts", )}:31:14\n`, }, { @@ -106,7 +106,7 @@ const testCases: IDictionary< message: "JS: at onTap (file:///data/data/org.nativescript.sourceMap/files/app/external.js:12:22)", expected: `JS: at onTap file: ${toPlatformSep( - "src/external-test.js" + "src/external-test.js", )}:3:4\n`, }, { @@ -114,7 +114,7 @@ const testCases: IDictionary< message: "System.err: Frame: function:'./external-test.js.onTap', file:'file:///data/data/org.nativescript.sourceMap/files/app/external.js', line: 13, column: 32", expected: `System.err: Frame: function:'./external-test.js.onTap', file:'file: ${toPlatformSep( - "src/external-test.js" + "src/external-test.js", )}:4:4\n`, }, ], @@ -123,28 +123,28 @@ const testCases: IDictionary< caseName: "console message", message: "CONSOLE LOG file:///app/bundle.js:294:20: Test.", expected: `CONSOLE LOG file: ${toPlatformSep( - "src/main-view-model.ts" + "src/main-view-model.ts", )}:29:20 Test.\n`, }, { caseName: "trace message", message: "CONSOLE TRACE file:///app/bundle.js:295:22: Test", expected: `CONSOLE TRACE file: ${toPlatformSep( - "src/main-view-model.ts" + "src/main-view-model.ts", )}:30:22 Test\n`, }, { caseName: "error message", message: "file:///app/bundle.js:296:32: JS ERROR Error: Test", expected: `file: ${toPlatformSep( - "src/main-view-model.ts" + "src/main-view-model.ts", )}:31:31 JS ERROR Error: Test\n`, }, { caseName: "error stack trace", message: "onTap@file:///app/bundle.js:296:32", expected: `onTap@file: ${toPlatformSep( - "src/main-view-model.ts" + "src/main-view-model.ts", )}:31:31\n`, }, { @@ -157,7 +157,7 @@ const testCases: IDictionary< runtimeVersion: "6.1.0", message: "onTap(file:///app/bundle.js:296:22)", expected: `onTap(file: ${toPlatformSep( - "src/main-view-model.ts" + "src/main-view-model.ts", )}:31:18)\n`, }, // External maps @@ -165,21 +165,21 @@ const testCases: IDictionary< caseName: "console message (external map)", message: "CONSOLE LOG file:///app/external.js:11:20: Test.", expected: `CONSOLE LOG file: ${toPlatformSep( - "src/external-test.js" + "src/external-test.js", )}:2:16 Test.\n`, }, { caseName: "trace message (external map)", message: "CONSOLE TRACE file:///app/external.js:12:22: Test", expected: `CONSOLE TRACE file: ${toPlatformSep( - "src/external-test.js" + "src/external-test.js", )}:3:4 Test\n`, }, { caseName: "error message (external map)", message: "file:///app/external.js:13:32: JS ERROR Error: Test", expected: `file: ${toPlatformSep( - "src/external-test.js" + "src/external-test.js", )}:4:4 JS ERROR Error: Test\n`, }, { @@ -202,7 +202,7 @@ describe("log-source-map-service", () => { __dirname, "..", "files", - "sourceMapBundle" + "sourceMapBundle", ); const fs = testInjector.resolve("fs"); const files = fs.enumerateFilesInDirectorySync(originalFilesLocation); @@ -226,7 +226,7 @@ describe("log-source-map-service", () => { const result = logSourceMapService.replaceWithOriginalFileLocations( platform.toLowerCase(), testCase.message, - { logLevel: "info", projectDir: "test" } + { logLevel: "info", projectDir: "test" }, ); assert.equal(result, testCase.expected); }); diff --git a/test/services/metadata-filtering-service.ts b/test/services/metadata-filtering-service.ts index f092e24db0..f98be0ce61 100644 --- a/test/services/metadata-filtering-service.ts +++ b/test/services/metadata-filtering-service.ts @@ -25,12 +25,12 @@ describe("metadataFilteringService", () => { const appResourcesNativeApiUsageFilePath = path.join( projectData.appResourcesDirectoryPath, platform, - MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME + MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME, ); const pluginPlatformsDir = path.join("pluginDir", platform); const pluginNativeApiUsageFilePath = path.join( pluginPlatformsDir, - MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME + MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME, ); const pluginsUses: string[] = ["pluginUses1", "pluginUses2"]; @@ -41,14 +41,14 @@ describe("metadataFilteringService", () => { testInjector.register("pluginsService", { getAllProductionPlugins: ( prjData: IProjectData, - dependencies?: IDependencyData[] + dependencies?: IDependencyData[], ): IPluginData[] => { const plugins = !!(input && input.hasPlugins) ? [ { pluginPlatformsFolderPath: (pl: string) => pluginPlatformsDir, }, - ] + ] : []; return plugins; @@ -96,14 +96,13 @@ describe("metadataFilteringService", () => { it("deletes previously generated files for metadata filtering", () => { const testInjector = createTestInjector(); - const metadataFilteringService: IMetadataFilteringService = testInjector.resolve( - MetadataFilteringService - ); + const metadataFilteringService: IMetadataFilteringService = + testInjector.resolve(MetadataFilteringService); const { fs } = mockFs({ testInjector, writeFileAction: (filePath: string, data: string) => { throw new Error( - `No data should be written when the ${MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME} does not exist in App_Resource/` + `No data should be written when the ${MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME} does not exist in App_Resource/`, ); }, }); @@ -119,9 +118,8 @@ describe("metadataFilteringService", () => { it(`generates ${MetadataFilteringConstants.BLACKLIST_FILE_NAME} when the file ${MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME} exists in App_Resources/`, () => { const testInjector = createTestInjector(); - const metadataFilteringService: IMetadataFilteringService = testInjector.resolve( - MetadataFilteringService - ); + const metadataFilteringService: IMetadataFilteringService = + testInjector.resolve(MetadataFilteringService); const { dataWritten } = mockFs({ testInjector, existingFiles: [appResourcesNativeApiUsageFilePath], @@ -137,7 +135,7 @@ describe("metadataFilteringService", () => { assert.deepStrictEqual(dataWritten, { [path.join( projectRoot, - MetadataFilteringConstants.BLACKLIST_FILE_NAME + MetadataFilteringConstants.BLACKLIST_FILE_NAME, )]: blacklistArray.join(EOL), }); }); @@ -149,7 +147,7 @@ describe("metadataFilteringService", () => { let finalContent = ""; if (input.pluginWhitelist) { finalContent += `// Added from: ${pluginNativeApiUsageFilePath}${EOL}${input.pluginWhitelist.join( - EOL + EOL, )}${EOL}// Finished part from ${pluginNativeApiUsageFilePath}${EOL}`; } @@ -159,7 +157,7 @@ describe("metadataFilteringService", () => { } finalContent += `// Added from application${EOL}${input.applicationWhitelist.join( - EOL + EOL, )}${EOL}// Finished part from application${EOL}`; } @@ -168,9 +166,8 @@ describe("metadataFilteringService", () => { it(`generates ${MetadataFilteringConstants.WHITELIST_FILE_NAME} when the file ${MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME} exists in App_Resources/`, () => { const testInjector = createTestInjector(); - const metadataFilteringService: IMetadataFilteringService = testInjector.resolve( - MetadataFilteringService - ); + const metadataFilteringService: IMetadataFilteringService = + testInjector.resolve(MetadataFilteringService); const { dataWritten } = mockFs({ testInjector, existingFiles: [appResourcesNativeApiUsageFilePath], @@ -185,7 +182,7 @@ describe("metadataFilteringService", () => { assert.deepStrictEqual(dataWritten, { [path.join( projectRoot, - MetadataFilteringConstants.WHITELIST_FILE_NAME + MetadataFilteringConstants.WHITELIST_FILE_NAME, )]: getExpectedWhitelistContent({ applicationWhitelist: whitelistArray, }), @@ -194,9 +191,8 @@ describe("metadataFilteringService", () => { it(`generates ${MetadataFilteringConstants.WHITELIST_FILE_NAME} with content from plugins when the file ${MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME} exists in App_Resources/ and whitelist-plugins-usages is true`, () => { const testInjector = createTestInjector({ hasPlugins: true }); - const metadataFilteringService: IMetadataFilteringService = testInjector.resolve( - MetadataFilteringService - ); + const metadataFilteringService: IMetadataFilteringService = + testInjector.resolve(MetadataFilteringService); const { dataWritten } = mockFs({ testInjector, existingFiles: [ @@ -215,16 +211,15 @@ describe("metadataFilteringService", () => { assert.deepStrictEqual(dataWritten, { [path.join( projectRoot, - MetadataFilteringConstants.WHITELIST_FILE_NAME + MetadataFilteringConstants.WHITELIST_FILE_NAME, )]: getExpectedWhitelistContent({ pluginWhitelist: whitelistArray }), }); }); it(`generates all files when both plugins and applications filters are included`, () => { const testInjector = createTestInjector({ hasPlugins: true }); - const metadataFilteringService: IMetadataFilteringService = testInjector.resolve( - MetadataFilteringService - ); + const metadataFilteringService: IMetadataFilteringService = + testInjector.resolve(MetadataFilteringService); const { dataWritten } = mockFs({ testInjector, existingFiles: [ @@ -250,20 +245,19 @@ describe("metadataFilteringService", () => { assert.deepStrictEqual(dataWritten, { [path.join( projectRoot, - MetadataFilteringConstants.WHITELIST_FILE_NAME + MetadataFilteringConstants.WHITELIST_FILE_NAME, )]: expectedWhitelist, [path.join( projectRoot, - MetadataFilteringConstants.BLACKLIST_FILE_NAME + MetadataFilteringConstants.BLACKLIST_FILE_NAME, )]: blacklistArray.join(EOL), }); }); it(`skips plugins ${MetadataFilteringConstants.NATIVE_API_USAGE_FILE_NAME} files when whitelist-plugins-usages in App_Resources is false`, () => { const testInjector = createTestInjector({ hasPlugins: true }); - const metadataFilteringService: IMetadataFilteringService = testInjector.resolve( - MetadataFilteringService - ); + const metadataFilteringService: IMetadataFilteringService = + testInjector.resolve(MetadataFilteringService); const { dataWritten } = mockFs({ testInjector, existingFiles: [ @@ -288,11 +282,11 @@ describe("metadataFilteringService", () => { assert.deepStrictEqual(dataWritten, { [path.join( projectRoot, - MetadataFilteringConstants.WHITELIST_FILE_NAME + MetadataFilteringConstants.WHITELIST_FILE_NAME, )]: expectedWhitelist, [path.join( projectRoot, - MetadataFilteringConstants.BLACKLIST_FILE_NAME + MetadataFilteringConstants.BLACKLIST_FILE_NAME, )]: blacklistArray.join(EOL), }); }); diff --git a/test/services/platform-environment-requirements.ts b/test/services/platform-environment-requirements.ts index 1215093b03..375e632f40 100644 --- a/test/services/platform-environment-requirements.ts +++ b/test/services/platform-environment-requirements.ts @@ -32,7 +32,7 @@ function createTestInjector() { testInjector.register("prompter", {}); testInjector.register( "platformEnvironmentRequirements", - PlatformEnvironmentRequirements + PlatformEnvironmentRequirements, ); testInjector.register("staticConfig", { SYS_REQUIREMENTS_LINK: "" }); @@ -50,7 +50,8 @@ describe("platformEnvironmentRequirements ", () => { describe("checkRequirements", () => { let testInjector: IInjector = null; - let platformEnvironmentRequirements: IPlatformEnvironmentRequirements = null; + let platformEnvironmentRequirements: IPlatformEnvironmentRequirements = + null; let promptForChoiceData: { message: string; choices: string[] }[] = []; function mockDoctorService(data: { @@ -85,7 +86,7 @@ describe("platformEnvironmentRequirements ", () => { beforeEach(() => { testInjector = createTestInjector(); platformEnvironmentRequirements = testInjector.resolve( - "platformEnvironmentRequirements" + "platformEnvironmentRequirements", ); process.stdout.isTTY = true; process.stdin.isTTY = true; @@ -98,9 +99,10 @@ describe("platformEnvironmentRequirements ", () => { it("should return true when environment is configured", async () => { mockDoctorService({ canExecuteLocalBuild: true }); - const result = await platformEnvironmentRequirements.checkEnvironmentRequirements( - { platform } - ); + const result = + await platformEnvironmentRequirements.checkEnvironmentRequirements({ + platform, + }); assert.isTrue(result.canExecute); assert.isTrue(promptForChoiceData.length === 0); }); @@ -108,9 +110,10 @@ describe("platformEnvironmentRequirements ", () => { it("should skip env check when NS_SKIP_ENV_CHECK environment variable is passed", async () => { (process.env).NS_SKIP_ENV_CHECK = true; - const output = await platformEnvironmentRequirements.checkEnvironmentRequirements( - { platform } - ); + const output = + await platformEnvironmentRequirements.checkEnvironmentRequirements({ + platform, + }); assert.isTrue(output.canExecute); assert.isTrue(promptForChoiceData.length === 0); @@ -126,7 +129,7 @@ describe("platformEnvironmentRequirements ", () => { await assert.isRejected( platformEnvironmentRequirements.checkEnvironmentRequirements({ platform, - }) + }), ); }); }); diff --git a/test/services/platform/add-platform-service.ts b/test/services/platform/add-platform-service.ts index 8519022c4a..b0962dd7ad 100644 --- a/test/services/platform/add-platform-service.ts +++ b/test/services/platform/add-platform-service.ts @@ -68,9 +68,9 @@ describe("AddPlatformService", () => { projectDir: projectData.projectDir, platform, nativePrepare, - } + }, ), - errorMessage + errorMessage, ); }); it(`shouldn't add native platform when skipNativePrepare is provided for ${platform}`, async () => { @@ -81,7 +81,7 @@ describe("AddPlatformService", () => { const platformsDataService = injector.resolve("platformsDataService"); const platformData = platformsDataService.getPlatformData( platform, - injector.resolve("projectData") + injector.resolve("projectData"), ); platformData.platformProjectService.createProject = () => (isCreateNativeProjectCalled = true); @@ -96,7 +96,7 @@ describe("AddPlatformService", () => { projectDir: projectData.projectDir, platform, nativePrepare: { skipNativePrepare: true }, - } + }, ); assert.isFalse(isCreateNativeProjectCalled); }); @@ -108,7 +108,7 @@ describe("AddPlatformService", () => { const platformsDataService = injector.resolve("platformsDataService"); const platformData = platformsDataService.getPlatformData( platform, - injector.resolve("projectData") + injector.resolve("projectData"), ); platformData.platformProjectService.createProject = () => (isCreateNativeProjectCalled = true); @@ -119,7 +119,7 @@ describe("AddPlatformService", () => { projectData, platformData, platform, - { projectDir: projectData.projectDir, platform, nativePrepare } + { projectDir: projectData.projectDir, platform, nativePrepare }, ); assert.isTrue(isCreateNativeProjectCalled); }); diff --git a/test/services/test-execution-service.ts b/test/services/test-execution-service.ts index ad6ad5c62a..42d24b3f7d 100644 --- a/test/services/test-execution-service.ts +++ b/test/services/test-execution-service.ts @@ -28,8 +28,7 @@ function getDependenciesObj(deps: string[]): IDictionary { describe("testExecutionService", () => { const testCases = [ { - name: - "should return false when the project has no dependencies and dev dependencies", + name: "should return false when the project has no dependencies and dev dependencies", expectedCanStartKarmaServer: false, projectData: { dependencies: {}, devDependencies: {} }, }, @@ -50,8 +49,7 @@ describe("testExecutionService", () => { }, }, { - name: - "should return true when the project has the required plugins as dependencies", + name: "should return true when the project has the required plugins as dependencies", expectedCanStartKarmaServer: true, projectData: { dependencies: getDependenciesObj([ @@ -62,8 +60,7 @@ describe("testExecutionService", () => { }, }, { - name: - "should return true when the project has the required plugins as dev dependencies", + name: "should return true when the project has the required plugins as dev dependencies", expectedCanStartKarmaServer: true, projectData: { dependencies: {}, @@ -74,8 +71,7 @@ describe("testExecutionService", () => { }, }, { - name: - "should return true when the project has the required plugins as dev and normal dependencies", + name: "should return true when the project has the required plugins as dev and normal dependencies", expectedCanStartKarmaServer: true, projectData: { dependencies: getDependenciesObj([karmaPluginName]), @@ -109,9 +105,8 @@ describe("testExecutionService", () => { }; // END MOCK - const canStartKarmaServer = await testExecutionService.canStartKarmaServer( - testCase.projectData - ); + const canStartKarmaServer = + await testExecutionService.canStartKarmaServer(testCase.projectData); assert.equal(canStartKarmaServer, testCase.expectedCanStartKarmaServer); // restore mock diff --git a/test/services/user-settings-service.ts b/test/services/user-settings-service.ts index a35b957d7e..0de273bb8b 100644 --- a/test/services/user-settings-service.ts +++ b/test/services/user-settings-service.ts @@ -12,7 +12,7 @@ describe("userSettingsService", () => { const profileDir = "my-profile-dir"; const expectedJsonFileSettingsFilePath = path.join( profileDir, - "user-settings.json" + "user-settings.json", ); const createTestInjector = (): IInjector => { @@ -23,7 +23,7 @@ describe("userSettingsService", () => { testInjector.register( "jsonFileSettingsService", - JsonFileSettingsServiceMock + JsonFileSettingsServiceMock, ); testInjector.register("userSettingsService", UserSettingsService); return testInjector; @@ -75,11 +75,11 @@ describe("userSettingsService", () => { assert.deepStrictEqual( dataPassedToJsonFileSettingsService, - testCase.expectedArgs + testCase.expectedArgs, ); assert.equal( jsonFileSettingsService.jsonFileSettingsPath, - expectedJsonFileSettingsFilePath + expectedJsonFileSettingsFilePath, ); }); } diff --git a/test/stubs.ts b/test/stubs.ts index 29545654d8..b1efe30656 100644 --- a/test/stubs.ts +++ b/test/stubs.ts @@ -1,5 +1,3 @@ -/* tslint:disable:no-empty */ - import * as util from "util"; import { assert } from "chai"; import { EventEmitter } from "events"; @@ -386,9 +384,7 @@ export class ErrorsStub implements IErrors { ): void {} } -export class PackageInstallationManagerStub - implements IPackageInstallationManager -{ +export class PackageInstallationManagerStub implements IPackageInstallationManager { clearInspectorCache(): void { return undefined; } @@ -477,7 +473,7 @@ export class NodePackageManagerStub implements INodePackageManager { return ""; } - public async view(packageName: string, config: Object): Promise { + public async view(packageName: string, config: object): Promise { return {}; } @@ -735,9 +731,7 @@ export class ProjectDataStub implements IProjectData { } } -export class AndroidPluginBuildServiceStub - implements IAndroidPluginBuildService -{ +export class AndroidPluginBuildServiceStub implements IAndroidPluginBuildService { buildAar(options: IPluginBuildOptions): Promise { return Promise.resolve(true); } @@ -1313,9 +1307,7 @@ export class CommandsService implements ICommandsService { } } -export class AndroidResourcesMigrationServiceStub - implements IAndroidResourcesMigrationService -{ +export class AndroidResourcesMigrationServiceStub implements IAndroidResourcesMigrationService { canMigrate(platformString: string): boolean { return true; } @@ -1329,9 +1321,7 @@ export class AndroidResourcesMigrationServiceStub } } -export class AndroidBundleValidatorHelper - implements IAndroidBundleValidatorHelper -{ +export class AndroidBundleValidatorHelper implements IAndroidBundleValidatorHelper { validateDeviceApiLevel(device: Mobile.IDevice, buildData: IBuildData): void { return; } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 8211d1c9c6..0000000000 --- a/tslint.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "rulesDirectory": "node_modules/tslint-microsoft-contrib", - "extends": [ - "tslint-config-prettier" - ], - "rules": { - "deprecation": true, - "class-name": true, - "curly": true, - "mocha-avoid-only": true, - "interface-name": true, - "jsdoc-format": true, - "max-line-length": [ - false, - 140 - ], - "prefer-const": true, - "no-construct": true, - "no-debugger": true, - "no-duplicate-variable": true, - "no-shadowed-variable": false, - "no-empty": true, - "no-eval": true, - "no-switch-case-fall-through": true, - "no-unused-expression": true, - "no-var-keyword": true, - "no-var-requires": false, - "no-floating-promises": true, - "quotemark": [ - false, - "double" - ], - "space-before-function-paren": false, - "switch-default": false, - "trailing-comma": [ - false, - { - "multiline": "always", - "singleline": "always" - } - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "use-isnan": true, - "variable-name": [ - true, - "ban-keywords", - "allow-leading-underscore" - ] - } -}