Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show deprecated messages for things that will be dropped as of NativeScript v.6.0.0 #4578

Merged
merged 2 commits into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/commands/clean-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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,
release: this.$options.release,
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions lib/common/services/commands-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class CommandsService implements ICommandsService {
}

this.$options.setupOptions(projectData);
this.$options.printMessagesForDeprecatedOptions(this.$logger);
}

public allCommands(opts: { includeDevCommands: boolean }): string[] {
Expand Down
3 changes: 2 additions & 1 deletion lib/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,21 @@ 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 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 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 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: <TODO: add link here>`);
}
}

private getCorrectOptionName(optionName: string): string {
const secondaryOptionName = this.getNonDashedOptionName(optionName);
return _.includes(this.optionNames, secondaryOptionName) ? secondaryOptionName : optionName;
Expand Down
5 changes: 5 additions & 0 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 });
await this.$preparePlatformJSService.preparePlatform({
platform,
Expand Down
2 changes: 2 additions & 0 deletions test/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down