Skip to content

Commit 5074b82

Browse files
committed
fix(nx): fix style selection on windows
1 parent 166a21a commit 5074b82

File tree

3 files changed

+60
-75
lines changed

3 files changed

+60
-75
lines changed

packages/create-nx-workspace/bin/create-nx-workspace.ts

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ const packageManager = determinePackageManager();
6060
determineWorkspaceName(parsedArgs).then(name => {
6161
determinePreset(parsedArgs).then(preset => {
6262
return determineAppName(preset, parsedArgs).then(appName => {
63-
return determineCli(preset, parsedArgs).then(cli => {
64-
const tmpDir = createSandbox(packageManager, cli);
65-
createApp(tmpDir, cli, parsedArgs, name, preset, appName);
66-
showNxWarning();
67-
showCliWarning(preset, parsedArgs);
63+
return determineStyle(preset).then(style => {
64+
return determineCli(preset, parsedArgs).then(cli => {
65+
const tmpDir = createSandbox(packageManager, cli);
66+
createApp(tmpDir, cli, parsedArgs, name, preset, appName, style);
67+
showNxWarning();
68+
showCliWarning(preset, parsedArgs);
69+
});
6870
});
6971
});
7072
});
@@ -126,7 +128,7 @@ function determineWorkspaceName(parsedArgs: any) {
126128
.prompt([
127129
{
128130
name: 'WorkspaceName',
129-
message: `Workspace name (e.g., org name) `,
131+
message: `Workspace name (e.g., org name) `,
130132
type: 'string'
131133
}
132134
])
@@ -141,8 +143,6 @@ function determineWorkspaceName(parsedArgs: any) {
141143
return a.WorkspaceName;
142144
});
143145
}
144-
145-
return workspaceName;
146146
}
147147

148148
function determinePreset(parsedArgs: any): Promise<string> {
@@ -165,7 +165,7 @@ function determinePreset(parsedArgs: any): Promise<string> {
165165
.prompt([
166166
{
167167
name: 'Preset',
168-
message: `What to create in the new workspace`,
168+
message: `What to create in the new workspace `,
169169
default: 'empty',
170170
type: 'list',
171171
choices: presetOptions
@@ -187,7 +187,7 @@ function determineAppName(preset: string, parsedArgs: any): Promise<string> {
187187
.prompt([
188188
{
189189
name: 'AppName',
190-
message: `Application name `,
190+
message: `Application name `,
191191
type: 'string'
192192
}
193193
])
@@ -241,7 +241,7 @@ function determineCli(preset: string, parsedArgs: any) {
241241
.prompt([
242242
{
243243
name: 'CLI',
244-
message: `CLI to power the Nx workspace `,
244+
message: `CLI to power the Nx workspace `,
245245
default: 'nx',
246246
type: 'list',
247247
choices: [
@@ -262,6 +262,46 @@ function determineCli(preset: string, parsedArgs: any) {
262262
}
263263
}
264264

265+
function determineStyle(preset: string) {
266+
if (preset === 'empty') return Promise.resolve(null);
267+
return inquirer
268+
.prompt([
269+
{
270+
name: 'style',
271+
message: `Which stylesheet format would you like to use?`,
272+
default: 'css',
273+
type: 'list',
274+
choices: [
275+
{
276+
value: 'css',
277+
name: 'CSS'
278+
},
279+
{
280+
value: 'scss',
281+
name: 'SASS(.scss) [ http://sass-lang.com ]'
282+
},
283+
{
284+
value: 'styl',
285+
name: 'Stylus(.styl)[ http://stylus-lang.com ]'
286+
},
287+
{
288+
value: 'less',
289+
name: 'LESS [ http://lesscss.org ]'
290+
},
291+
{
292+
value: 'styled-components',
293+
name: 'styled-components [ https://styled-components.com ]'
294+
},
295+
{
296+
value: '@emotion/styled',
297+
name: 'emotion [ https://emotion.sh]'
298+
}
299+
]
300+
}
301+
])
302+
.then(a => a.style);
303+
}
304+
265305
function createSandbox(
266306
packageManager: string,
267307
cli: { package: string; version: string }
@@ -294,7 +334,8 @@ function createApp(
294334
parsedArgs: any,
295335
name: string,
296336
preset: string,
297-
appName: string
337+
appName: string,
338+
style: string | null
298339
) {
299340
// creating the app itself
300341
const args = [
@@ -309,7 +350,11 @@ function createApp(
309350
? ''
310351
: ` --preset=${preset} --appName=${appName}`;
311352

312-
console.log(`new ${args}${presetArg} --collection=@nrwl/workspace`);
353+
const styleArg = style ? ` --style=${style}` : ``;
354+
355+
console.log(
356+
`new ${args}${presetArg}${styleArg} --collection=@nrwl/workspace`
357+
);
313358
execSync(
314359
`"${path.join(
315360
tmpDir,

packages/workspace/src/schematics/ng-new/schema.json

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,7 @@
1717
"style": {
1818
"description": "The file extension to be used for style files.",
1919
"type": "string",
20-
"default": "css",
21-
"x-prompt": {
22-
"message": "Which stylesheet format would you like to use?",
23-
"type": "list",
24-
"items": [
25-
{
26-
"value": "css",
27-
"label": "CSS"
28-
},
29-
{
30-
"value": "scss",
31-
"label": "SASS(.scss) [ http://sass-lang.com ]"
32-
},
33-
{
34-
"value": "styl",
35-
"label": "Stylus(.styl)[ http://stylus-lang.com ]"
36-
},
37-
{
38-
"value": "less",
39-
"label": "LESS [ http://lesscss.org ]"
40-
},
41-
{
42-
"value": "styled-components",
43-
"label": "styled-components [ https://styled-components.com ]"
44-
},
45-
{
46-
"value": "@emotion/styled",
47-
"label": "emotion [ https://emotion.sh ]"
48-
}
49-
]
50-
}
20+
"default": "css"
5121
},
5222
"directory": {
5323
"type": "string",

packages/workspace/src/schematics/tao-new/schema.json

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,7 @@
1717
"style": {
1818
"description": "The file extension to be used for style files.",
1919
"type": "string",
20-
"default": "css",
21-
"x-prompt": {
22-
"message": "Which stylesheet format would you like to use?",
23-
"type": "list",
24-
"items": [
25-
{
26-
"value": "css",
27-
"label": "CSS"
28-
},
29-
{
30-
"value": "scss",
31-
"label": "SASS(.scss) [ http://sass-lang.com ]"
32-
},
33-
{
34-
"value": "styl",
35-
"label": "Stylus(.styl)[ http://stylus-lang.com ]"
36-
},
37-
{
38-
"value": "less",
39-
"label": "LESS [ http://lesscss.org ]"
40-
},
41-
{
42-
"value": "styled-components",
43-
"label": "styled-components [ https://styled-components.com ]"
44-
},
45-
{
46-
"value": "@emotion/styled",
47-
"label": "emotion [ https://emotion.sh ]"
48-
}
49-
]
50-
}
20+
"default": "css"
5121
},
5222
"directory": {
5323
"type": "string",

0 commit comments

Comments
 (0)