Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0759213

Browse files
Cammisulivsavkin
authored andcommittedSep 17, 2020
feat(core): add nest preset
(cherry picked from commit 10d3d0d)
1 parent 156dd33 commit 0759213

File tree

5 files changed

+53
-10
lines changed

5 files changed

+53
-10
lines changed
 

‎e2e/workspace/src/create-nx-workspace.test.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
forEachCli,
3-
runCreateWorkspace,
4-
uniq,
5-
readJson,
6-
} from '@nrwl/e2e/utils';
1+
import { forEachCli, runCreateWorkspace, uniq } from '@nrwl/e2e/utils';
72

83
forEachCli(() => {
94
describe('create-nx-workspace', () => {
@@ -88,5 +83,14 @@ forEachCli(() => {
8883
base: 'main',
8984
});
9085
});
86+
87+
it('should be able to create a nest workspace', () => {
88+
const wsName = uniq('nest');
89+
const appName = uniq('app');
90+
runCreateWorkspace(wsName, {
91+
preset: 'nest',
92+
appName,
93+
});
94+
});
9195
});
9296
});

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

+23-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ enum Preset {
1919
React = 'react',
2020
ReactWithExpress = 'react-express',
2121
NextJs = 'next',
22+
Nest = 'nest',
2223
}
2324

2425
const presetOptions = [
@@ -46,6 +47,10 @@ const presetOptions = [
4647
name:
4748
'angular-nest [a workspace with a full stack application (Angular + Nest)]',
4849
},
50+
{
51+
value: Preset.Nest,
52+
name: 'nest [a workspace with a single Nest application]',
53+
},
4954
{
5055
value: Preset.React,
5156
name: 'react [a workspace with a single React application]',
@@ -260,7 +265,8 @@ function determineCli(preset: Preset, parsedArgs: any) {
260265
case Preset.WebComponents:
261266
case Preset.React:
262267
case Preset.ReactWithExpress:
263-
case Preset.NextJs: {
268+
case Preset.NextJs:
269+
case Preset.Nest: {
264270
return Promise.resolve(nx);
265271
}
266272
default: {
@@ -291,7 +297,11 @@ function determineCli(preset: Preset, parsedArgs: any) {
291297
}
292298

293299
function determineStyle(preset: Preset, parsedArgs: any) {
294-
if (preset === Preset.Empty || preset === Preset.OSS) {
300+
if (
301+
preset === Preset.Empty ||
302+
preset === Preset.OSS ||
303+
preset === Preset.Nest
304+
) {
295305
return Promise.resolve(null);
296306
}
297307

@@ -524,6 +534,17 @@ function pointToTutorialAndCourse(preset: Preset) {
524534
],
525535
});
526536
break;
537+
// TODO(Cammisuli): include this after the nx.dev site is updated with the node flavour
538+
// case Preset.Nest:
539+
// output.addVerticalSeparator();
540+
// output.note({
541+
// title,
542+
// bodyLines: [
543+
// `https://nx.dev/node/tutorial/01-create-application`,
544+
// ...pointToCourse(),
545+
// ],
546+
// });
547+
// break;
527548
}
528549
}
529550

‎packages/workspace/src/schematics/preset/preset.ts

+8
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ function createPreset(options: Schema): Rule {
115115
setDefaultCollection('@nrwl/react'),
116116
connectReactAndExpress(options),
117117
]);
118+
} else if (options.preset === 'nest') {
119+
return chain([
120+
externalSchematic('@nrwl/nest', 'application', {
121+
name: options.name,
122+
linter,
123+
}),
124+
setDefaultCollection('@nrwl/nest'),
125+
]);
118126
} else {
119127
throw new Error(`Invalid preset ${options.preset}`);
120128
}

‎packages/workspace/src/schematics/preset/schema.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ export interface Schema {
1111
| 'next'
1212
| 'web-components'
1313
| 'angular-nest'
14-
| 'react-express';
14+
| 'react-express'
15+
| 'nest';
1516
}

‎packages/workspace/src/schematics/shared-new/shared-new.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export interface Schema {
4646
| 'web-components'
4747
| 'angular-nest'
4848
| 'react-express'
49-
| 'next';
49+
| 'next'
50+
| 'nest';
5051
commit?: { name: string; email: string; message?: string };
5152
defaultBase?: string;
5253
}
@@ -203,6 +204,14 @@ function addPresetDependencies(options: Schema) {
203204
},
204205
false
205206
);
207+
} else if (options.preset === 'nest') {
208+
return addDepsToPackageJson(
209+
{},
210+
{
211+
'@nrwl/nest': nxVersion,
212+
},
213+
false
214+
);
206215
} else {
207216
return noop();
208217
}

0 commit comments

Comments
 (0)
Please sign in to comment.