From 395e476a791ee3546ec4e81d766d63f54faa8adf Mon Sep 17 00:00:00 2001 From: fatme Date: Tue, 30 Apr 2019 11:37:49 +0300 Subject: [PATCH 1/2] feat: show deprecated messages for things that will be dropped as of NativeScript v.6.0.0 https://github.com/NativeScript/nativescript-cli/issues/4518 --- lib/commands/clean-app.ts | 15 ++++++++++----- lib/common/services/commands-service.ts | 1 + lib/declarations.d.ts | 3 ++- lib/options.ts | 14 ++++++++++++++ lib/services/platform-service.ts | 5 +++++ test/platform-service.ts | 2 ++ 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/lib/commands/clean-app.ts b/lib/commands/clean-app.ts index e22c1a4c64..5f97252d0a 100644 --- a/lib/commands/clean-app.ts +++ b/lib/commands/clean-app.ts @@ -10,12 +10,15 @@ export class CleanAppCommandBase extends ValidatePlatformCommandBase implements $platformService: IPlatformService, protected $errors: IErrors, protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, - $platformsData: IPlatformsData) { + $platformsData: IPlatformsData, + private $logger: ILogger) { super($options, $platformsData, $platformService, $projectData); this.$projectData.initializeProjectData(); } public async execute(args: string[]): Promise { + this.$logger.warn(`"tns clean-app ${this.platform.toLowerCase()}" command has been deprecated and will be removed in the upcoming NativeScript CLI v.6.0.0. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); + const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: !!this.$options.bundle, release: this.$options.release, @@ -49,8 +52,9 @@ export class CleanAppIosCommand extends CleanAppCommandBase implements ICommand protected $platformsData: IPlatformsData, protected $errors: IErrors, $platformService: IPlatformService, - $projectData: IProjectData) { - super($options, $projectData, $platformService, $errors, $devicePlatformsConstants, $platformsData); + $projectData: IProjectData, + $logger: ILogger) { + super($options, $projectData, $platformService, $errors, $devicePlatformsConstants, $platformsData, $logger); } protected get platform(): string { @@ -66,8 +70,9 @@ export class CleanAppAndroidCommand extends CleanAppCommandBase implements IComm protected $platformsData: IPlatformsData, protected $errors: IErrors, $platformService: IPlatformService, - $projectData: IProjectData) { - super($options, $projectData, $platformService, $errors, $devicePlatformsConstants, $platformsData); + $projectData: IProjectData, + $logger: ILogger) { + super($options, $projectData, $platformService, $errors, $devicePlatformsConstants, $platformsData, $logger); } protected get platform(): string { diff --git a/lib/common/services/commands-service.ts b/lib/common/services/commands-service.ts index d441a2959a..315bbfa6e1 100644 --- a/lib/common/services/commands-service.ts +++ b/lib/common/services/commands-service.ts @@ -37,6 +37,7 @@ export class CommandsService implements ICommandsService { } this.$options.setupOptions(projectData); + this.$options.printMessagesForDeprecatedOptions(this.$logger); } public allCommands(opts: { includeDevCommands: boolean }): string[] { diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index dfaf0d258f..e1c56e57be 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -569,9 +569,10 @@ interface IOptions extends IRelease, IDeviceIdentifier, IJustLaunch, IAvd, IAvai link: boolean; analyticsLogFile: string; performance: Object; - setupOptions(projectData: IProjectData): void; cleanupLogFile: string; workflow: boolean; + setupOptions(projectData: IProjectData): void; + printMessagesForDeprecatedOptions(logger: ILogger): void; } interface IEnvOptions { diff --git a/lib/options.ts b/lib/options.ts index 44793f0fcb..eeee8c0eed 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -204,6 +204,20 @@ export class Options { }); } + public printMessagesForDeprecatedOptions($logger: ILogger) { + if (this.argv.platformTemplate) { + $logger.warn(`"--platformTemplate" option has been deprecated and will be removed in the upcoming NativeScript CLI v.6.0.0. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); + } + + if (this.argv.syncAllFiles) { + $logger.warn(`"--syncAllFiles" option has been deprecated and will be removed in the upcoming NativeScript CLI v.6.0.0. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); + } + + if (this.argv.bundle) { + $logger.warn(`"--bundle" option has been deprecated and as of NativeScript CLI v.6.0.0 Webpack workflow will become the only way of building apps.`); + } + } + private getCorrectOptionName(optionName: string): string { const secondaryOptionName = this.getNonDashedOptionName(optionName); return _.includes(this.optionNames, secondaryOptionName) ? secondaryOptionName : optionName; diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index ed8a29c189..2c6fe89d66 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -319,6 +319,11 @@ export class PlatformService extends EventEmitter implements IPlatformService { this.$logger.out("Preparing project..."); const platformData = this.$platformsData.getPlatformData(platform, projectData); + const frameworkVersion = this.getCurrentPlatformVersion(platform, projectData); + if (semver.lt(semver.coerce(frameworkVersion), semver.coerce('5.1.0'))) { + this.$logger.warn(`Runtime versions lower than 5.1.0 have been deprecated and will not be supported as of v.6.0.0 of NativeScript CLI. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); + } + const projectFilesConfig = helpers.getProjectFilesConfig({ isReleaseBuild: appFilesUpdaterOptions.release }); await this.$preparePlatformJSService.preparePlatform({ platform, diff --git a/test/platform-service.ts b/test/platform-service.ts index e7039b33f1..5ae8e12f63 100644 --- a/test/platform-service.ts +++ b/test/platform-service.ts @@ -516,6 +516,7 @@ describe('Platform Service Tests', () => { platformService = testInjector.resolve("platformService"); const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: false, release: release, useHotModuleReload: false }; + platformService.getCurrentPlatformVersion = () => "5.1.1"; await platformService.preparePlatform({ platform: platformToTest, appFilesUpdaterOptions, @@ -950,6 +951,7 @@ describe('Platform Service Tests', () => { projectData.appResourcesDirectoryPath = projectData.getAppResourcesDirectoryPath(); platformService = testInjector.resolve("platformService"); + platformService.getCurrentPlatformVersion = () => "5.1.1"; const oldLoggerWarner = testInjector.resolve("$logger").warn; let warnings: string = ""; try { From d5725e0efcb84a3f831901a4672b02419acf89b1 Mon Sep 17 00:00:00 2001 From: fatme Date: Tue, 7 May 2019 09:21:27 +0300 Subject: [PATCH 2/2] fix PR comments --- lib/commands/clean-app.ts | 2 +- lib/options.ts | 7 ++++--- lib/services/platform-service.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/commands/clean-app.ts b/lib/commands/clean-app.ts index 5f97252d0a..e95daf8a9e 100644 --- a/lib/commands/clean-app.ts +++ b/lib/commands/clean-app.ts @@ -17,7 +17,7 @@ export class CleanAppCommandBase extends ValidatePlatformCommandBase implements } public async execute(args: string[]): Promise { - this.$logger.warn(`"tns clean-app ${this.platform.toLowerCase()}" command has been deprecated and will be removed in the upcoming NativeScript CLI v.6.0.0. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); + this.$logger.warn(`"tns clean-app ${this.platform.toLowerCase()}" command has been deprecated and will be removed in the upcoming NativeScript CLI v6.0.0. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: !!this.$options.bundle, diff --git a/lib/options.ts b/lib/options.ts index eeee8c0eed..0e5f1045bf 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -206,15 +206,16 @@ export class Options { public printMessagesForDeprecatedOptions($logger: ILogger) { if (this.argv.platformTemplate) { - $logger.warn(`"--platformTemplate" option has been deprecated and will be removed in the upcoming NativeScript CLI v.6.0.0. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); + $logger.warn(`"--platformTemplate" option has been deprecated and will be removed in the upcoming NativeScript CLI v6.0.0. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); } if (this.argv.syncAllFiles) { - $logger.warn(`"--syncAllFiles" option has been deprecated and will be removed in the upcoming NativeScript CLI v.6.0.0. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); + $logger.warn(`"--syncAllFiles" option has been deprecated and will be removed in the upcoming NativeScript CLI v6.0.0. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); } if (this.argv.bundle) { - $logger.warn(`"--bundle" option has been deprecated and as of NativeScript CLI v.6.0.0 Webpack workflow will become the only way of building apps.`); + $logger.warn(`"--bundle" option has been deprecated and as of NativeScript CLI v6.0.0 Webpack workflow will become the only way of building apps. + More info about the reasons for this change and how to migrate your project can be found in the link below: `); } } diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index 2c6fe89d66..4589674cbd 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -321,7 +321,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { const platformData = this.$platformsData.getPlatformData(platform, projectData); const frameworkVersion = this.getCurrentPlatformVersion(platform, projectData); if (semver.lt(semver.coerce(frameworkVersion), semver.coerce('5.1.0'))) { - this.$logger.warn(`Runtime versions lower than 5.1.0 have been deprecated and will not be supported as of v.6.0.0 of NativeScript CLI. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); + this.$logger.warn(`Runtime versions lower than 5.1.0 have been deprecated and will not be supported as of v6.0.0 of NativeScript CLI. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`); } const projectFilesConfig = helpers.getProjectFilesConfig({ isReleaseBuild: appFilesUpdaterOptions.release });