@@ -30,40 +30,40 @@ const presetOptions = [
3030 'empty [an empty workspace with a layout that works best for building apps]' ,
3131 } ,
3232 {
33- value : 'oss' ,
34- name :
35- 'oss [an empty workspace with a layout that works best for open-source projects]' ,
36- } ,
37- {
38- value : 'web-components' ,
39- name :
40- 'web components [a workspace with a single app built using web components]' ,
33+ value : Preset . React ,
34+ name : 'react [a workspace with a single React application]' ,
4135 } ,
4236 {
4337 value : Preset . Angular ,
4438 name : 'angular [a workspace with a single Angular application]' ,
4539 } ,
4640 {
47- value : Preset . AngularWithNest ,
48- name :
49- 'angular-nest [a workspace with a full stack application (Angular + Nest)]' ,
41+ value : Preset . NextJs ,
42+ name : 'next.js [a workspace with a single Next.js application]' ,
5043 } ,
5144 {
5245 value : Preset . Nest ,
5346 name : 'nest [a workspace with a single Nest application]' ,
5447 } ,
5548 {
56- value : Preset . React ,
57- name : 'react [a workspace with a single React application]' ,
49+ value : 'web-components' ,
50+ name :
51+ 'web components [a workspace with a single app built using web components]' ,
5852 } ,
5953 {
6054 value : Preset . ReactWithExpress ,
6155 name :
6256 'react-express [a workspace with a full stack application (React + Express)]' ,
6357 } ,
6458 {
65- value : Preset . NextJs ,
66- name : 'next.js [a workspace with a single Next.js application]' ,
59+ value : Preset . AngularWithNest ,
60+ name :
61+ 'angular-nest [a workspace with a full stack application (Angular + Nest)]' ,
62+ } ,
63+ {
64+ value : 'oss' ,
65+ name :
66+ 'oss [an empty workspace with a layout that works best for open-source projects]' ,
6767 } ,
6868] ;
6969
@@ -74,7 +74,7 @@ const angularCliVersion = 'ANGULAR_CLI_VERSION';
7474const prettierVersion = 'PRETTIER_VERSION' ;
7575
7676const parsedArgs = yargsParser ( process . argv , {
77- string : [ 'cli' , 'preset' , 'appName' , 'style' , 'defaultBase' ] ,
77+ string : [ 'cli' , 'preset' , 'appName' , 'style' , 'linter' , ' defaultBase'] ,
7878 alias : {
7979 appName : 'app-name' ,
8080 nxCloud : 'nx-cloud' ,
@@ -93,22 +93,25 @@ determineWorkspaceName(parsedArgs).then((name) => {
9393 return determineAppName ( preset , parsedArgs ) . then ( ( appName ) => {
9494 return determineStyle ( preset , parsedArgs ) . then ( ( style ) => {
9595 return determineCli ( preset , parsedArgs ) . then ( ( cli ) => {
96- return askAboutNxCloud ( parsedArgs ) . then ( ( cloud ) => {
97- const tmpDir = createSandbox ( packageManager ) ;
98- createApp (
99- tmpDir ,
100- cli ,
101- parsedArgs ,
102- name ,
103- preset ,
104- appName ,
105- style ,
106- cloud ,
107- parsedArgs . interactive ,
108- parsedArgs . defaultBase
109- ) ;
110- showNxWarning ( name ) ;
111- pointToTutorialAndCourse ( preset ) ;
96+ return determineLinter ( cli , parsedArgs ) . then ( ( linter ) => {
97+ return askAboutNxCloud ( parsedArgs ) . then ( ( cloud ) => {
98+ const tmpDir = createSandbox ( packageManager ) ;
99+ createApp (
100+ tmpDir ,
101+ cli ,
102+ parsedArgs ,
103+ name ,
104+ preset ,
105+ appName ,
106+ style ,
107+ linter ,
108+ cloud ,
109+ parsedArgs . interactive ,
110+ parsedArgs . defaultBase
111+ ) ;
112+ showNxWarning ( name ) ;
113+ pointToTutorialAndCourse ( preset ) ;
114+ } ) ;
112115 } ) ;
113116 } ) ;
114117 } ) ;
@@ -137,7 +140,9 @@ function showHelp() {
137140 cli CLI to power the Nx workspace (options: "nx", "angular")
138141
139142 style Default style option to be used when a non-empty preset is selected
140- options: ("css", "scss", "styl", "less") for React/Next.js also ("styled-components", "@emotion/styled")
143+ options: ("css", "scss", "styl", "less") for React/Next.js also ("styled-components", "@emotion/styled")
144+
145+ linter Default linter. Options: "eslint", "tslint".
141146
142147 interactive Enable interactive mode when using presets (boolean)
143148
@@ -376,6 +381,45 @@ function determineStyle(preset: Preset, parsedArgs: any) {
376381 return Promise . resolve ( parsedArgs . style ) ;
377382}
378383
384+ function determineLinter ( preset : Preset , parsedArgs : any ) {
385+ if ( ! parsedArgs . linter ) {
386+ if ( preset === Preset . Angular || preset === Preset . AngularWithNest ) {
387+ return inquirer
388+ . prompt ( [
389+ {
390+ name : 'linter' ,
391+ message : `Default linter ` ,
392+ default : 'tslint' ,
393+ type : 'list' ,
394+ choices : [
395+ {
396+ value : 'tslint' ,
397+ name : 'TSLint [ Used by Angular CLI ]' ,
398+ } ,
399+ {
400+ value : 'eslint' ,
401+ name : 'ESLint [ Modern linting tool ]' ,
402+ } ,
403+ ] ,
404+ } ,
405+ ] )
406+ . then ( ( a ) => a . linter ) ;
407+ } else {
408+ return Promise . resolve ( 'eslint' ) ;
409+ }
410+ } else {
411+ if ( parsedArgs . linter !== 'eslint' && parsedArgs . linter !== 'tslint' ) {
412+ output . error ( {
413+ title : 'Invalid linter' ,
414+ bodyLines : [ `It must be one of the following:` , '' , 'eslint' , 'tslint' ] ,
415+ } ) ;
416+ process . exit ( 1 ) ;
417+ } else {
418+ return Promise . resolve ( parsedArgs . linter ) ;
419+ }
420+ }
421+ }
422+
379423function createSandbox ( packageManager : string ) {
380424 console . log ( `Creating a sandbox with Nx...` ) ;
381425 const tmpDir = dirSync ( ) . name ;
@@ -408,6 +452,7 @@ function createApp(
408452 preset : Preset ,
409453 appName : string ,
410454 style : string | null ,
455+ linter : string ,
411456 nxCloud : boolean ,
412457 interactive : boolean ,
413458 defaultBase : string
@@ -424,6 +469,7 @@ function createApp(
424469 'nxCloud' ,
425470 'preset' ,
426471 'style' ,
472+ 'linter' ,
427473 ] ;
428474
429475 // These are the arguments that are passed to the schematic
@@ -434,14 +480,15 @@ function createApp(
434480
435481 const appNameArg = appName ? ` --appName="${ appName } "` : `` ;
436482 const styleArg = style ? ` --style="${ style } "` : `` ;
483+ const linterArg = ` --linter="${ linter } "` ;
437484 const nxCloudArg = nxCloud ? ` --nxCloud` : `` ;
438485 const interactiveArg = interactive
439486 ? ` --interactive=true`
440487 : ` --interactive=false` ;
441488 const defaultBaseArg = defaultBase ? ` --defaultBase="${ defaultBase } "` : `` ;
442489
443490 const packageExec = getPackageManagerExecuteCommand ( packageManager ) ;
444- const command = `new ${ name } ${ args } --preset="${ preset } "${ appNameArg } ${ styleArg } ${ nxCloudArg } ${ interactiveArg } ${ defaultBaseArg } --collection=@nrwl/workspace` ;
491+ const command = `new ${ name } ${ args } --preset="${ preset } "${ appNameArg } ${ styleArg } ${ linterArg } ${ nxCloudArg } ${ interactiveArg } ${ defaultBaseArg } --collection=@nrwl/workspace` ;
445492 console . log ( command ) ;
446493
447494 const collectionJsonPath = require . resolve (
0 commit comments