diff --git a/lib/commands/add-platform.ts b/lib/commands/add-platform.ts index 20d42e5ef1..a75cff15bd 100644 --- a/lib/commands/add-platform.ts +++ b/lib/commands/add-platform.ts @@ -13,7 +13,7 @@ export class AddPlatformCommand extends ValidatePlatformCommandBase implements I } public async execute(args: string[]): Promise { - await this.$platformService.addPlatforms(args, this.$options.platformTemplate, this.$projectData, this.$options, this.$options.frameworkPath); + await this.$platformService.addPlatforms(args, this.$projectData, this.$options, this.$options.frameworkPath); } public async canExecute(args: string[]): Promise { diff --git a/lib/commands/appstore-upload.ts b/lib/commands/appstore-upload.ts index 03168cde65..50dd6b43b2 100644 --- a/lib/commands/appstore-upload.ts +++ b/lib/commands/appstore-upload.ts @@ -64,7 +64,6 @@ export class PublishIOS implements ICommand { const platformInfo: IPreparePlatformInfo = { platform, appFilesUpdaterOptions, - platformTemplate: this.$options.platformTemplate, projectData: this.$projectData, config: this.$options, env: this.$options.env diff --git a/lib/commands/build.ts b/lib/commands/build.ts index 0c4f091f19..4d77ce696e 100644 --- a/lib/commands/build.ts +++ b/lib/commands/build.ts @@ -24,7 +24,6 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase { const platformInfo: IPreparePlatformInfo = { platform, appFilesUpdaterOptions, - platformTemplate: this.$options.platformTemplate, projectData: this.$projectData, config: this.$options, env: this.$options.env diff --git a/lib/commands/clean-app.ts b/lib/commands/clean-app.ts index e22c1a4c64..b825b7e071 100644 --- a/lib/commands/clean-app.ts +++ b/lib/commands/clean-app.ts @@ -25,7 +25,6 @@ export class CleanAppCommandBase extends ValidatePlatformCommandBase implements appFilesUpdaterOptions, platform: this.platform.toLowerCase(), config: this.$options, - platformTemplate: this.$options.platformTemplate, projectData: this.$projectData, env: this.$options.env }; diff --git a/lib/commands/install.ts b/lib/commands/install.ts index a92ee7a6ab..655097d6a8 100644 --- a/lib/commands/install.ts +++ b/lib/commands/install.ts @@ -34,7 +34,7 @@ export class InstallCommand implements ICommand { const platformProjectService = platformData.platformProjectService; await platformProjectService.validate(this.$projectData, this.$options); - await this.$platformService.addPlatforms([`${platform}@${frameworkPackageData.version}`], this.$options.platformTemplate, this.$projectData, this.$options, this.$options.frameworkPath); + await this.$platformService.addPlatforms([`${platform}@${frameworkPackageData.version}`], this.$projectData, this.$options, this.$options.frameworkPath); } catch (err) { error = `${error}${EOL}${err}`; } diff --git a/lib/commands/platform-clean.ts b/lib/commands/platform-clean.ts index d7e6a3a1c4..9837902c8e 100644 --- a/lib/commands/platform-clean.ts +++ b/lib/commands/platform-clean.ts @@ -10,7 +10,7 @@ export class CleanCommand implements ICommand { } public async execute(args: string[]): Promise { - await this.$platformService.cleanPlatforms(args, this.$options.platformTemplate, this.$projectData, this.$options); + await this.$platformService.cleanPlatforms(args, this.$projectData, this.$options); } public async canExecute(args: string[]): Promise { diff --git a/lib/commands/prepare.ts b/lib/commands/prepare.ts index 409ddf16c6..afa0387614 100644 --- a/lib/commands/prepare.ts +++ b/lib/commands/prepare.ts @@ -21,7 +21,6 @@ export class PrepareCommand extends ValidatePlatformCommandBase implements IComm const platformInfo: IPreparePlatformInfo = { platform: args[0], appFilesUpdaterOptions, - platformTemplate: this.$options.platformTemplate, projectData: this.$projectData, config: this.$options, env: this.$options.env diff --git a/lib/commands/update-platform.ts b/lib/commands/update-platform.ts index df40f4f8a5..61d62f779c 100644 --- a/lib/commands/update-platform.ts +++ b/lib/commands/update-platform.ts @@ -10,7 +10,7 @@ export class UpdatePlatformCommand implements ICommand { } public async execute(args: string[]): Promise { - await this.$platformService.updatePlatforms(args, this.$options.platformTemplate, this.$projectData, this.$options); + await this.$platformService.updatePlatforms(args, this.$projectData, this.$options); } public async canExecute(args: string[]): Promise { diff --git a/lib/commands/update.ts b/lib/commands/update.ts index 1649284c41..afbd5f7c0a 100644 --- a/lib/commands/update.ts +++ b/lib/commands/update.ts @@ -94,12 +94,12 @@ export class UpdateCommand extends ValidatePlatformCommandBase implements IComma if (args.length === 1) { for (const platform of platforms.packagePlatforms) { - await this.$platformService.addPlatforms([platform + "@" + args[0]], this.$options.platformTemplate, this.$projectData, this.$options, this.$options.frameworkPath); + await this.$platformService.addPlatforms([platform + "@" + args[0]], this.$projectData, this.$options, this.$options.frameworkPath); } await this.$pluginsService.add(`${constants.TNS_CORE_MODULES_NAME}@${args[0]}`, this.$projectData); } else { - await this.$platformService.addPlatforms(platforms.packagePlatforms, this.$options.platformTemplate, this.$projectData, this.$options, this.$options.frameworkPath); + await this.$platformService.addPlatforms(platforms.packagePlatforms, this.$projectData, this.$options, this.$options.frameworkPath); await this.$pluginsService.add(constants.TNS_CORE_MODULES_NAME, this.$projectData); } diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index e7c4a4456d..208ca92bad 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -441,11 +441,6 @@ interface IBundleString { bundle: string; } -interface IPlatformTemplate { - platformTemplate: string; -} - - interface IClean { clean: boolean; } @@ -499,7 +494,7 @@ interface IAndroidBundleOptions { aab: boolean; } -interface IOptions extends IRelease, IDeviceIdentifier, IJustLaunch, IAvd, IAvailableDevices, IProfileDir, IHasEmulatorOption, IBundleString, IPlatformTemplate, IHasEmulatorOption, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, IAndroidBundleOptions, INpmInstallConfigurationOptions, IPort, IEnvOptions, IPluginSeedOptions, IGenerateOptions { +interface IOptions extends IRelease, IDeviceIdentifier, IJustLaunch, IAvd, IAvailableDevices, IProfileDir, IHasEmulatorOption, IBundleString, IHasEmulatorOption, IClean, IProvision, ITeamIdentifier, IAndroidReleaseOptions, IAndroidBundleOptions, INpmInstallConfigurationOptions, IPort, IEnvOptions, IPluginSeedOptions, IGenerateOptions { argv: IYargArgv; validateOptions(commandSpecificDashedOptions?: IDictionary): void; options: IDictionary; @@ -589,11 +584,11 @@ interface IDeviceEmulator extends IHasEmulatorOption, IDeviceIdentifier { } interface IRunPlatformOptions extends IJustLaunch, IDeviceEmulator { } -interface IDeployPlatformOptions extends IAndroidReleaseOptions, IPlatformTemplate, IRelease, IClean, IDeviceEmulator, IProvision, ITeamIdentifier, IProjectDir { +interface IDeployPlatformOptions extends IAndroidReleaseOptions, IRelease, IClean, IDeviceEmulator, IProvision, ITeamIdentifier, IProjectDir { forceInstall?: boolean; } -interface IUpdatePlatformOptions extends IPlatformTemplate { +interface IUpdatePlatformOptions { currentVersion: string; newVersion: string; canUpdate: boolean; diff --git a/lib/definitions/platform.d.ts b/lib/definitions/platform.d.ts index 3462e437e1..650017d684 100644 --- a/lib/definitions/platform.d.ts +++ b/lib/definitions/platform.d.ts @@ -15,9 +15,9 @@ interface IBuildPlatformAction { } interface IPlatformService extends IBuildPlatformAction, NodeJS.EventEmitter { - cleanPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, framework?: string): Promise; + cleanPlatforms(platforms: string[], projectData: IProjectData, config: IPlatformOptions, framework?: string): Promise; - addPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, frameworkPath?: string): Promise; + addPlatforms(platforms: string[], projectData: IProjectData, config: IPlatformOptions, frameworkPath?: string): Promise; /** * Gets list of all installed platforms (the ones for which /platforms/ exists). @@ -48,7 +48,7 @@ interface IPlatformService extends IBuildPlatformAction, NodeJS.EventEmitter { */ removePlatforms(platforms: string[], projectData: IProjectData): Promise; - updatePlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise; + updatePlatforms(platforms: string[], projectData: IProjectData, config: IPlatformOptions): Promise; /** * Ensures that the specified platform and its dependencies are installed. @@ -316,7 +316,6 @@ interface IAddPlatformInfo extends IProjectDataComposition, IPlatformDataComposi frameworkDir: string; installedVersion: string; config: IPlatformOptions; - platformTemplate?: string; } interface IPreparePlatformJSInfo extends IPreparePlatformCoreInfo, ICopyAppFilesData { @@ -335,7 +334,7 @@ interface IPreparePlatformCoreInfo extends IPreparePlatformInfoBase, IOptionalPr platformSpecificData: IPlatformSpecificData; } -interface IPreparePlatformInfo extends IPreparePlatformInfoBase, IPlatformConfig, IPlatformTemplate, ISkipNativeCheckOptional { } +interface IPreparePlatformInfo extends IPreparePlatformInfoBase, IPlatformConfig, ISkipNativeCheckOptional { } interface IPlatformConfig { config: IPlatformOptions; diff --git a/lib/definitions/project.d.ts b/lib/definitions/project.d.ts index 05d67d21ab..fa5f35b915 100644 --- a/lib/definitions/project.d.ts +++ b/lib/definitions/project.d.ts @@ -336,10 +336,9 @@ interface ILocalBuildService { * Builds a project locally. * @param {string} platform Platform for which to build. * @param {IPlatformBuildData} platformBuildOptions Additional options for controlling the build. - * @param {string} platformTemplate The name of the template. * @return {Promise} Path to the build output. */ - build(platform: string, platformBuildOptions: IPlatformBuildData, platformTemplate?: string): Promise; + build(platform: string, platformBuildOptions: IPlatformBuildData): Promise; /** * Removes build artifacts specific to the platform * @param {ICleanNativeAppData} data Data describing the clean app process diff --git a/lib/helpers/deploy-command-helper.ts b/lib/helpers/deploy-command-helper.ts index de2d02f31a..a5a0e9d652 100644 --- a/lib/helpers/deploy-command-helper.ts +++ b/lib/helpers/deploy-command-helper.ts @@ -17,7 +17,6 @@ export class DeployCommandHelper implements IDeployCommandHelper { device: this.$options.device, projectDir: this.$projectData.projectDir, emulator: this.$options.emulator, - platformTemplate: this.$options.platformTemplate, release: this.$options.release, forceInstall: true, provision: this.$options.provision, diff --git a/lib/options.ts b/lib/options.ts index 79931e43e7..09fdcdcec8 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -90,7 +90,6 @@ export class Options { compileSdk: { type: OptionType.Number, hasSensitiveValue: false }, port: { type: OptionType.Number, hasSensitiveValue: false }, copyTo: { type: OptionType.String, hasSensitiveValue: true }, - platformTemplate: { type: OptionType.String, hasSensitiveValue: true }, js: { type: OptionType.Boolean, hasSensitiveValue: false }, javascript: { type: OptionType.Boolean, hasSensitiveValue: false }, ng: { type: OptionType.Boolean, hasSensitiveValue: false }, diff --git a/lib/services/livesync/livesync-service.ts b/lib/services/livesync/livesync-service.ts index fa1eb1502b..878f4437f2 100644 --- a/lib/services/livesync/livesync-service.ts +++ b/lib/services/livesync/livesync-service.ts @@ -429,7 +429,6 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi nativePrepare: nativePrepare, filesToSync: options.filesToSync, filesToRemove: options.filesToRemove, - platformTemplate: null, skipModulesNativeCheck: options.skipModulesNativeCheck, config: platformSpecificOptions }; diff --git a/lib/services/local-build-service.ts b/lib/services/local-build-service.ts index b33f49051d..ae50dfb717 100644 --- a/lib/services/local-build-service.ts +++ b/lib/services/local-build-service.ts @@ -12,7 +12,7 @@ export class LocalBuildService extends EventEmitter implements ILocalBuildServic super(); } - public async build(platform: string, platformBuildOptions: IPlatformBuildData, platformTemplate?: string): Promise { + public async build(platform: string, platformBuildOptions: IPlatformBuildData): Promise { if (this.$mobileHelper.isAndroidPlatform(platform) && platformBuildOptions.release && (!platformBuildOptions.keyStorePath || !platformBuildOptions.keyStorePassword || !platformBuildOptions.keyStoreAlias || !platformBuildOptions.keyStoreAliasPassword)) { this.$errors.fail(ANDROID_RELEASE_BUILD_ERROR_MESSAGE); } @@ -21,7 +21,6 @@ export class LocalBuildService extends EventEmitter implements ILocalBuildServic const prepareInfo: IPreparePlatformInfo = { platform, appFilesUpdaterOptions: platformBuildOptions, - platformTemplate, projectData: this.$projectData, env: platformBuildOptions.env, config: { diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index e481600407..a670852b95 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -41,7 +41,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { super(); } - public async cleanPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, framworkPath?: string): Promise { + public async cleanPlatforms(platforms: string[], projectData: IProjectData, config: IPlatformOptions, framworkPath?: string): Promise { for (const platform of platforms) { const version: string = this.getCurrentPlatformVersion(platform, projectData); @@ -51,11 +51,11 @@ export class PlatformService extends EventEmitter implements IPlatformService { } await this.removePlatforms([platform], projectData); - await this.addPlatforms([platformWithVersion], platformTemplate, projectData, config); + await this.addPlatforms([platformWithVersion], projectData, config); } } - public async addPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, frameworkPath?: string): Promise { + public async addPlatforms(platforms: string[], projectData: IProjectData, config: IPlatformOptions, frameworkPath?: string): Promise { const platformsDir = projectData.platformsDir; this.$fs.ensureDirectoryExists(platformsDir); @@ -68,7 +68,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { this.$errors.failWithoutHelp(`Platform ${platform} already added`); } - await this.addPlatform(platform.toLowerCase(), platformTemplate, projectData, config, frameworkPath); + await this.addPlatform(platform.toLowerCase(), projectData, config, frameworkPath); } } @@ -83,7 +83,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { return version; } - private async addPlatform(platformParam: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, frameworkPath?: string, nativePrepare?: INativePrepare): Promise { + private async addPlatform(platformParam: string, projectData: IProjectData, config: IPlatformOptions, frameworkPath?: string, nativePrepare?: INativePrepare): Promise { const data = platformParam.split("@"); const platform = data[0].toLowerCase(); let version = data[1]; @@ -126,7 +126,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { let frameworkDir = path.join(downloadedPackagePath, constants.PROJECT_FRAMEWORK_FOLDER_NAME); frameworkDir = path.resolve(frameworkDir); installedPlatformVersion = - await this.addPlatformCore(platformData, frameworkDir, platformTemplate, projectData, config, nativePrepare); + await this.addPlatformCore(platformData, frameworkDir, projectData, config, nativePrepare); } catch (err) { this.$fs.deleteDirectory(platformPath); throw err; @@ -138,7 +138,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { this.$logger.out(`Platform ${platform} successfully added. v${installedPlatformVersion}`); } - private async addPlatformCore(platformData: IPlatformData, frameworkDir: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, nativePrepare?: INativePrepare): Promise { + private async addPlatformCore(platformData: IPlatformData, frameworkDir: string, projectData: IProjectData, config: IPlatformOptions, nativePrepare?: INativePrepare): Promise { const coreModuleData = this.$fs.readJson(path.join(frameworkDir, "..", "package.json")); const installedVersion = coreModuleData.version; @@ -147,8 +147,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { frameworkDir, installedVersion, projectData, - config, - platformTemplate + config }); if (!nativePrepare || !nativePrepare.skipNativePrepare) { @@ -287,7 +286,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { } private async initialPrepare(preparePlatformInfo: IPreparePlatformInfo) { - const { platform, appFilesUpdaterOptions, platformTemplate, projectData, config, nativePrepare } = preparePlatformInfo; + const { platform, appFilesUpdaterOptions, projectData, config, nativePrepare } = preparePlatformInfo; this.validatePlatform(platform, projectData); // We need dev-dependencies here, so before-prepare hooks will be executed correctly. @@ -298,7 +297,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { this.$errors.failWithoutHelp(`Unable to install dependencies. Make sure your package.json is valid and all dependencies are correct. Error is: ${err.message}`); } - await this.ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions, nativePrepare); + await this.ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions, nativePrepare); } /* Hooks are expected to use "filesToSync" parameter, as to give plugin authors additional information about the sync process.*/ @@ -535,7 +534,6 @@ export class PlatformService extends EventEmitter implements IPlatformService { await this.preparePlatform({ platform: deployInfo.platform, appFilesUpdaterOptions: deployInfo.appFilesUpdaterOptions, - platformTemplate: deployInfo.deployOptions.platformTemplate, projectData: deployInfo.projectData, config: deployInfo.config, nativePrepare: deployInfo.nativePrepare, @@ -649,7 +647,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { @helpers.hook('cleanApp') public async cleanDestinationApp(platformInfo: IPreparePlatformInfo): Promise { - await this.ensurePlatformInstalled(platformInfo.platform, platformInfo.platformTemplate, platformInfo.projectData, platformInfo.config, platformInfo.appFilesUpdaterOptions, platformInfo.nativePrepare); + await this.ensurePlatformInstalled(platformInfo.platform, platformInfo.projectData, platformInfo.config, platformInfo.appFilesUpdaterOptions, platformInfo.nativePrepare); const platformData = this.$platformsData.getPlatformData(platformInfo.platform, platformInfo.projectData); const appDestinationDirectoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME); @@ -716,16 +714,16 @@ export class PlatformService extends EventEmitter implements IPlatformService { } } - public async updatePlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise { + public async updatePlatforms(platforms: string[], projectData: IProjectData, config: IPlatformOptions): Promise { for (const platformParam of platforms) { const data = platformParam.split("@"), platform = data[0], version = data[1]; if (this.hasPlatformDirectory(platform, projectData)) { - await this.updatePlatform(platform, version, platformTemplate, projectData, config); + await this.updatePlatform(platform, version, projectData, config); } else { - await this.addPlatform(platformParam, platformTemplate, projectData, config); + await this.addPlatform(platformParam, projectData, config); } } } @@ -770,7 +768,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { } } - public async ensurePlatformInstalled(platform: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, appFilesUpdaterOptions: IAppFilesUpdaterOptions, nativePrepare?: INativePrepare): Promise { + public async ensurePlatformInstalled(platform: string, projectData: IProjectData, config: IPlatformOptions, appFilesUpdaterOptions: IAppFilesUpdaterOptions, nativePrepare?: INativePrepare): Promise { let requiresNativePlatformAdd = false; const platformData = this.$platformsData.getPlatformData(platform, projectData); @@ -780,7 +778,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { // In this case {N} CLI needs to add platform and keeps the already produced files from webpack const shouldPersistWebpackFiles = this.shouldPersistWebpackFiles(platform, projectData, prepareInfo, appFilesUpdaterOptions, nativePrepare); if (shouldPersistWebpackFiles) { - await this.persistWebpackFiles(platform, platformTemplate, projectData, config, platformData, nativePrepare); + await this.persistWebpackFiles(platform, projectData, config, platformData, nativePrepare); return; } @@ -790,10 +788,10 @@ export class PlatformService extends EventEmitter implements IPlatformService { // In case there's no prepare info, it means only platform add had been executed. So we've come from CLI and we do not need to prepare natively. requiresNativePlatformAdd = prepareInfo && prepareInfo.nativePlatformStatus === constants.NativePlatformStatus.requiresPlatformAdd; if (requiresNativePlatformAdd && shouldAddNativePlatform) { - await this.addPlatform(platform, platformTemplate, projectData, config, "", nativePrepare); + await this.addPlatform(platform, projectData, config, "", nativePrepare); } } else { - await this.addPlatform(platform, platformTemplate, projectData, config, "", nativePrepare); + await this.addPlatform(platform, projectData, config, "", nativePrepare); } } @@ -808,12 +806,12 @@ export class PlatformService extends EventEmitter implements IPlatformService { return result; } - private async persistWebpackFiles(platform: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, platformData: IPlatformData, nativePrepare?: INativePrepare): Promise { + private async persistWebpackFiles(platform: string, projectData: IProjectData, config: IPlatformOptions, platformData: IPlatformData, nativePrepare?: INativePrepare): Promise { const tmpDirectoryPath = path.join(projectData.projectDir, "platforms", `tmp-${platform}`); this.$fs.deleteDirectory(tmpDirectoryPath); this.$fs.ensureDirectoryExists(tmpDirectoryPath); this.$fs.copyFile(path.join(platformData.appDestinationDirectoryPath, "*"), tmpDirectoryPath); - await this.addPlatform(platform, platformTemplate, projectData, config, "", nativePrepare); + await this.addPlatform(platform, projectData, config, "", nativePrepare); this.$fs.copyFile(path.join(tmpDirectoryPath, "*"), platformData.appDestinationDirectoryPath); this.$fs.deleteDirectory(tmpDirectoryPath); } @@ -903,7 +901,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { return this.getLatestApplicationPackage(outputPath || platformData.getBuildOutputPath(buildConfig), platformData.getValidBuildOutputData(buildOutputOptions)); } - private async updatePlatform(platform: string, version: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise { + private async updatePlatform(platform: string, version: string, projectData: IProjectData, config: IPlatformOptions): Promise { const platformData = this.$platformsData.getPlatformData(platform, projectData); const data = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName); @@ -924,7 +922,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { } if (!semver.gt(currentVersion, newVersion)) { - await this.updatePlatformCore(platformData, { currentVersion, newVersion, canUpdate, platformTemplate }, projectData, config); + await this.updatePlatformCore(platformData, { currentVersion, newVersion, canUpdate }, projectData, config); } else if (semver.eq(currentVersion, newVersion)) { this.$errors.fail("Current and new version are the same."); } else { @@ -939,7 +937,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { let packageName = platformData.normalizedPlatformName.toLowerCase(); await this.removePlatforms([packageName], projectData); packageName = updateOptions.newVersion ? `${packageName}@${updateOptions.newVersion}` : packageName; - await this.addPlatform(packageName, updateOptions.platformTemplate, projectData, config); + await this.addPlatform(packageName, projectData, config); this.$logger.out("Successfully updated to version ", updateOptions.newVersion); } diff --git a/lib/services/prepare-platform-js-service.ts b/lib/services/prepare-platform-js-service.ts index f4675cbf93..0ea772d0bb 100644 --- a/lib/services/prepare-platform-js-service.ts +++ b/lib/services/prepare-platform-js-service.ts @@ -1,5 +1,3 @@ -import * as constants from "../constants"; -import * as path from "path"; import * as temp from "temp"; import { hook } from "../common/helpers"; import { PreparePlatformService } from "./prepare-platform-service"; @@ -12,22 +10,12 @@ export class PreparePlatformJSService extends PreparePlatformService implements constructor($fs: IFileSystem, $xmlValidator: IXmlValidator, $hooksService: IHooksService, - private $errors: IErrors, - private $logger: ILogger, - private $projectDataService: IProjectDataService, - private $packageManager: INodePackageManager) { + private $projectDataService: IProjectDataService) { super($fs, $hooksService, $xmlValidator); } public async addPlatform(info: IAddPlatformInfo): Promise { - const customTemplateOptions = await this.getPathToPlatformTemplate(info.platformTemplate, info.platformData.frameworkPackageName, info.projectData.projectDir); - info.config.pathToTemplate = customTemplateOptions && customTemplateOptions.pathToTemplate; - const frameworkPackageNameData: any = { version: info.installedVersion }; - if (customTemplateOptions) { - frameworkPackageNameData.template = customTemplateOptions.selectedTemplate; - } - this.$projectDataService.setNSValue(info.projectData.projectDir, info.platformData.frameworkPackageName, frameworkPackageNameData); } @@ -36,34 +24,6 @@ export class PreparePlatformJSService extends PreparePlatformService implements public async preparePlatform(config: IPreparePlatformJSInfo): Promise { // intentionally left blank, keep the support for before-prepareJSApp and after-prepareJSApp hooks } - - private async getPathToPlatformTemplate(selectedTemplate: string, frameworkPackageName: string, projectDir: string): Promise<{ selectedTemplate: string, pathToTemplate: string }> { - if (!selectedTemplate) { - // read data from package.json's nativescript key - // check the nativescript.tns-.template value - const nativescriptPlatformData = this.$projectDataService.getNSValue(projectDir, frameworkPackageName); - selectedTemplate = nativescriptPlatformData && nativescriptPlatformData.template; - } - - if (selectedTemplate) { - const tempDir = temp.mkdirSync("platform-template"); - this.$fs.writeJson(path.join(tempDir, constants.PACKAGE_JSON_FILE_NAME), {}); - try { - const npmInstallResult = await this.$packageManager.install(selectedTemplate, tempDir, { - disableNpmInstall: false, - frameworkPath: null, - ignoreScripts: false - }); - const pathToTemplate = path.join(tempDir, constants.NODE_MODULES_FOLDER_NAME, npmInstallResult.name); - return { selectedTemplate, pathToTemplate }; - } catch (err) { - this.$logger.trace("Error while trying to install specified template: ", err); - this.$errors.failWithoutHelp(`Unable to install platform template ${selectedTemplate}. Make sure the specified value is valid.`); - } - } - - return null; - } } $injector.register("preparePlatformJSService", PreparePlatformJSService); diff --git a/test/platform-service.ts b/test/platform-service.ts index 47c578fb85..45211b1546 100644 --- a/test/platform-service.ts +++ b/test/platform-service.ts @@ -147,22 +147,22 @@ describe('Platform Service Tests', () => { const fs = testInjector.resolve("fs"); fs.exists = () => false; const projectData: IProjectData = testInjector.resolve("projectData"); - await platformService.addPlatforms(["Android"], "", projectData, config); - await platformService.addPlatforms(["ANDROID"], "", projectData, config); - await platformService.addPlatforms(["AnDrOiD"], "", projectData, config); - await platformService.addPlatforms(["androiD"], "", projectData, config); - - await platformService.addPlatforms(["iOS"], "", projectData, config); - await platformService.addPlatforms(["IOS"], "", projectData, config); - await platformService.addPlatforms(["IoS"], "", projectData, config); - await platformService.addPlatforms(["iOs"], "", projectData, config); + await platformService.addPlatforms(["Android"], projectData, config); + await platformService.addPlatforms(["ANDROID"], projectData, config); + await platformService.addPlatforms(["AnDrOiD"], projectData, config); + await platformService.addPlatforms(["androiD"], projectData, config); + + await platformService.addPlatforms(["iOS"], projectData, config); + await platformService.addPlatforms(["IOS"], projectData, config); + await platformService.addPlatforms(["IoS"], projectData, config); + await platformService.addPlatforms(["iOs"], projectData, config); }); it("should fail if platform is already installed", async () => { const projectData: IProjectData = testInjector.resolve("projectData"); // By default fs.exists returns true, so the platforms directory should exists - await assert.isRejected(platformService.addPlatforms(["android"], "", projectData, config), "Platform android already added"); - await assert.isRejected(platformService.addPlatforms(["ios"], "", projectData, config), "Platform ios already added"); + await assert.isRejected(platformService.addPlatforms(["android"], projectData, config), "Platform android already added"); + await assert.isRejected(platformService.addPlatforms(["ios"], projectData, config), "Platform ios already added"); }); it("should fail if unable to extract runtime package", async () => { @@ -176,7 +176,7 @@ describe('Platform Service Tests', () => { }; const projectData: IProjectData = testInjector.resolve("projectData"); - await assert.isRejected(platformService.addPlatforms(["android"], "", projectData, config), errorMessage); + await assert.isRejected(platformService.addPlatforms(["android"], projectData, config), errorMessage); }); it("fails when path passed to frameworkPath does not exist", async () => { @@ -186,7 +186,7 @@ describe('Platform Service Tests', () => { const projectData: IProjectData = testInjector.resolve("projectData"); const frameworkPath = "invalidPath"; const errorMessage = format(AddPlaformErrors.InvalidFrameworkPathStringFormat, frameworkPath); - await assert.isRejected(platformService.addPlatforms(["android"], "", projectData, config, frameworkPath), errorMessage); + await assert.isRejected(platformService.addPlatforms(["android"], projectData, config, frameworkPath), errorMessage); }); const assertCorrectDataIsPassedToPacoteService = async (versionString: string): Promise => { @@ -217,9 +217,9 @@ describe('Platform Service Tests', () => { }; const projectData: IProjectData = testInjector.resolve("projectData"); - await platformService.addPlatforms(["android"], "", projectData, config); + await platformService.addPlatforms(["android"], projectData, config); assert.equal(packageNamePassedToPacoteService, `${packageName}@${versionString}`); - await platformService.addPlatforms(["ios"], "", projectData, config); + await platformService.addPlatforms(["ios"], projectData, config); assert.equal(packageNamePassedToPacoteService, `${packageName}@${versionString}`); }; it("should respect platform version in package.json's nativescript key", async () => { @@ -261,7 +261,7 @@ describe('Platform Service Tests', () => { const preparePlatformNativeService = testInjector.resolve("preparePlatformNativeService"); preparePlatformNativeService.addPlatform = async () => isNativePlatformAdded = true; - await platformService.addPlatforms(["android"], "", projectData, config); + await platformService.addPlatforms(["android"], projectData, config); assert.isTrue(isJsPlatformAdded); assert.isTrue(isNativePlatformAdded); @@ -275,7 +275,7 @@ describe('Platform Service Tests', () => { projectChangesService.getPrepareInfo = () => null; const projectData = testInjector.resolve("projectData"); - await assert.isRejected(platformService.addPlatforms(["android"], "", projectData, config), "Platform android already added"); + await assert.isRejected(platformService.addPlatforms(["android"], projectData, config), "Platform android already added"); }); // Workflow: tns run; tns platform add @@ -286,7 +286,7 @@ describe('Platform Service Tests', () => { projectChangesService.getPrepareInfo = () => ({ nativePlatformStatus: constants.NativePlatformStatus.alreadyPrepared }); const projectData = testInjector.resolve("projectData"); - await assert.isRejected(platformService.addPlatforms(["android"], "", projectData, config), "Platform android already added"); + await assert.isRejected(platformService.addPlatforms(["android"], projectData, config), "Platform android already added"); }); }); }); @@ -315,7 +315,7 @@ describe('Platform Service Tests', () => { it("shouldn't fail when platforms are added", async () => { const projectData: IProjectData = testInjector.resolve("projectData"); testInjector.resolve("fs").exists = () => false; - await platformService.addPlatforms(["android"], "", projectData, config); + await platformService.addPlatforms(["android"], projectData, config); testInjector.resolve("fs").exists = () => true; await platformService.removePlatforms(["android"], projectData); @@ -345,10 +345,10 @@ describe('Platform Service Tests', () => { return Promise.resolve(); }; - await platformService.cleanPlatforms(["android"], "", projectData, config); + await platformService.cleanPlatforms(["android"], projectData, config); nsValueObject[VERSION_STRING] = versionString; - await platformService.cleanPlatforms(["ios"], "", projectData, config); + await platformService.cleanPlatforms(["ios"], projectData, config); }); }); @@ -366,7 +366,7 @@ describe('Platform Service Tests', () => { packageInstallationManager.getLatestVersion = async () => "0.2.0"; const projectData: IProjectData = testInjector.resolve("projectData"); - await assert.isRejected(platformService.updatePlatforms(["android"], "", projectData, null)); + await assert.isRejected(platformService.updatePlatforms(["android"], projectData, null)); }); }); }); @@ -1001,7 +1001,6 @@ describe('Platform Service Tests', () => { describe("ensurePlatformInstalled", () => { const platform = "android"; - const platformTemplate = "testPlatformTemplate"; const appFilesUpdaterOptions = { bundle: true }; let areWebpackFilesPersisted = false; @@ -1079,7 +1078,7 @@ describe('Platform Service Tests', () => { usbLiveSyncService.isInitialized = testCase.isWebpackWatcherStarted === undefined ? true : testCase.isWebpackWatcherStarted; mockPrepareInfo(testCase.prepareInfo); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions, testCase.nativePrepare); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions, testCase.nativePrepare); assert.deepEqual(areWebpackFilesPersisted, testCase.areWebpackFilesPersisted); }); }); @@ -1087,64 +1086,64 @@ describe('Platform Service Tests', () => { it("should not persist webpack files after the second execution of `tns preview --bundle` or `tns cloud run --bundle`", async () => { // First execution of `tns preview --bundle` mockPrepareInfo(null); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions, { skipNativePrepare: true }); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions, { skipNativePrepare: true }); assert.isTrue(areWebpackFilesPersisted); // Second execution of `tns preview --bundle` reset(); mockPrepareInfo({ nativePlatformStatus: constants.NativePlatformStatus.requiresPlatformAdd }); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions, { skipNativePrepare: true }); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions, { skipNativePrepare: true }); assert.isFalse(areWebpackFilesPersisted); }); it("should not persist webpack files after the second execution of `tns run --bundle`", async () => { // First execution of `tns run --bundle` mockPrepareInfo(null); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions); assert.isTrue(areWebpackFilesPersisted); // Second execution of `tns run --bundle` reset(); mockPrepareInfo({ nativePlatformStatus: constants.NativePlatformStatus.alreadyPrepared }); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions); assert.isFalse(areWebpackFilesPersisted); }); it("should handle correctly the following sequence of commands: `tns preview --bundle`, `tns run --bundle` and `tns preview --bundle`", async () => { // First execution of `tns preview --bundle` mockPrepareInfo(null); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions, { skipNativePrepare: true }); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions, { skipNativePrepare: true }); assert.isTrue(areWebpackFilesPersisted); // Execution of `tns run --bundle` reset(); mockPrepareInfo({ nativePlatformStatus: constants.NativePlatformStatus.requiresPlatformAdd }); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions); assert.isTrue(areWebpackFilesPersisted); // Execution of `tns preview --bundle` reset(); mockPrepareInfo({ nativePlatformStatus: constants.NativePlatformStatus.alreadyPrepared }); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions, { skipNativePrepare: true }); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions, { skipNativePrepare: true }); assert.isFalse(areWebpackFilesPersisted); }); it("should handle correctly the following sequence of commands: `tns preview --bundle`, `tns run --bundle` and `tns build --bundle`", async () => { // Execution of `tns preview --bundle` mockPrepareInfo(null); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions, { skipNativePrepare: true }); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions, { skipNativePrepare: true }); assert.isTrue(areWebpackFilesPersisted); // Execution of `tns run --bundle` reset(); mockPrepareInfo({ nativePlatformStatus: constants.NativePlatformStatus.requiresPlatformAdd }); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions); assert.isTrue(areWebpackFilesPersisted); // Execution of `tns build --bundle` reset(); mockPrepareInfo({ nativePlatformStatus: constants.NativePlatformStatus.alreadyPrepared }); - await (platformService).ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions); + await (platformService).ensurePlatformInstalled(platform, projectData, config, appFilesUpdaterOptions); assert.isFalse(areWebpackFilesPersisted); }); });