1
1
import * as helpers from "../common/helpers" ;
2
2
import * as path from "path" ;
3
3
import * as semver from "semver" ;
4
+ import { EOL } from "os" ;
4
5
5
6
export 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
+
6
12
constructor ( private $bundleValidatorHelper : IBundleValidatorHelper ,
7
13
private $fs : IFileSystem ,
8
14
private $logger : ILogger ,
@@ -37,9 +43,17 @@ export class WorkflowService implements IWorkflowService {
37
43
}
38
44
39
45
private async handleWebpackWorkflowSwitch ( projectData : IProjectData , skipWarnings : boolean , force : boolean ) : Promise < boolean > {
40
- let hasSwitched = false ;
46
+ let hasSwitched = force ;
41
47
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
+
43
57
if ( hasSwitched ) {
44
58
this . $projectDataService . setUseLegacyWorkflow ( projectData . projectDir , false ) ;
45
59
await this . ensureWebpackPluginInstalled ( projectData ) ;
@@ -54,11 +68,17 @@ export class WorkflowService implements IWorkflowService {
54
68
}
55
69
56
70
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 ) ;
58
75
}
59
76
60
77
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 ) ;
62
82
}
63
83
64
84
private async ensureWebpackPluginInstalled ( projectData : IProjectData ) {
@@ -81,8 +101,8 @@ export class WorkflowService implements IWorkflowService {
81
101
if ( ! isInstalledVersionSupported ) {
82
102
const webpackConfigPath = path . join ( projectData . projectDir , webpackConfigFileName ) ;
83
103
if ( this . $fs . exists ( webpackConfigPath ) ) {
84
- this . $logger . info ( `<TODO: Add a webpack cofnig backup info here>` ) ;
85
104
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'.` ) ;
86
106
}
87
107
88
108
const installResult = await this . $packageManager . install ( `${ webpackPluginName } @latest` , projectData . projectDir , {
0 commit comments