11import * as helpers from "../common/helpers" ;
22import * as path from "path" ;
33import * as semver from "semver" ;
4+ import { EOL } from "os" ;
45
56export class WorkflowService implements IWorkflowService {
7+ private legacyWorkflowDeprecationMessage = `With the upcoming NativeScript 6.0 the Webpack workflow will become the only way of build apps.
8+ More info about the reason for this change and how to migrate your project can be found in the link below:
9+ <TODO: add link here>` ;
10+ private webpackWorkflowConfirmMessage = `Do you want to switch your app to the Webpack workflow?` ;
11+
612 constructor ( private $bundleValidatorHelper : IBundleValidatorHelper ,
713 private $fs : IFileSystem ,
814 private $logger : ILogger ,
@@ -37,9 +43,17 @@ export class WorkflowService implements IWorkflowService {
3743 }
3844
3945 private async handleWebpackWorkflowSwitch ( projectData : IProjectData , skipWarnings : boolean , force : boolean ) : Promise < boolean > {
40- let hasSwitched = false ;
46+ let hasSwitched = force ;
4147 if ( force || helpers . isInteractive ( ) ) {
42- hasSwitched = force || await this . $prompter . confirm ( "Please use webpack!" , ( ) => true ) ;
48+ if ( ! force ) {
49+ this . $logger . info ( ) ;
50+ this . $logger . printMarkdown ( `
51+ __Improve your project by switching to the Webpack workflow.__
52+
53+ \`${ this . legacyWorkflowDeprecationMessage } \`` ) ;
54+ hasSwitched = await this . $prompter . confirm ( this . webpackWorkflowConfirmMessage , ( ) => true ) ;
55+ }
56+
4357 if ( hasSwitched ) {
4458 this . $projectDataService . setUseLegacyWorkflow ( projectData . projectDir , false ) ;
4559 await this . ensureWebpackPluginInstalled ( projectData ) ;
@@ -54,11 +68,17 @@ export class WorkflowService implements IWorkflowService {
5468 }
5569
5670 private showLegacyWorkflowWarning ( ) {
57- this . $logger . warn ( "TODO: <Add a legacy workflow warning here>" ) ;
71+ const legacyWorkflowWarning = `You are using the Legacy Workflow.${ EOL } ${ EOL } ${ this . legacyWorkflowDeprecationMessage } ` ;
72+ const warningWithBorders = helpers . getMessageWithBorders ( legacyWorkflowWarning ) ;
73+
74+ this . $logger . warn ( warningWithBorders ) ;
5875 }
5976
6077 private showNoBundleWarning ( ) {
61- this . $logger . warn ( "TODO: <Add a `--no-bundle` workflow warning here>" ) ;
78+ const legacyWorkflowWarning = `You are using the '--no-bundle' flag which is switching to the Legacy Workflow.${ EOL } ${ EOL } ${ this . legacyWorkflowDeprecationMessage } ` ;
79+ const warningWithBorders = helpers . getMessageWithBorders ( legacyWorkflowWarning ) ;
80+
81+ this . $logger . warn ( warningWithBorders ) ;
6282 }
6383
6484 private async ensureWebpackPluginInstalled ( projectData : IProjectData ) {
@@ -81,8 +101,8 @@ export class WorkflowService implements IWorkflowService {
81101 if ( ! isInstalledVersionSupported ) {
82102 const webpackConfigPath = path . join ( projectData . projectDir , webpackConfigFileName ) ;
83103 if ( this . $fs . exists ( webpackConfigPath ) ) {
84- this . $logger . info ( `<TODO: Add a webpack cofnig backup info here>` ) ;
85104 this . $fs . rename ( webpackConfigPath , `${ webpackConfigPath } .bak` ) ;
105+ this . $logger . warn ( `The 'nativescript-dev-webpack' plugin was updated and your '${ webpackConfigFileName } ' was replaced. You can find your old '${ webpackConfigPath } ' in '${ webpackConfigPath } .bak'.` ) ;
86106 }
87107
88108 const installResult = await this . $packageManager . install ( `${ webpackPluginName } @latest` , projectData . projectDir , {
0 commit comments