feat(gatsby): add preset gatsby (#5485)
This commit is contained in:
parent
d767261fea
commit
84e387b238
@ -75,6 +75,18 @@ describe('create-nx-workspace', () => {
|
||||
expectNoAngularDevkit();
|
||||
});
|
||||
|
||||
it('should be able to create an gatsby workspace', () => {
|
||||
const wsName = uniq('gatsby');
|
||||
const appName = uniq('app');
|
||||
runCreateWorkspace(wsName, {
|
||||
preset: 'next',
|
||||
style: 'css',
|
||||
appName,
|
||||
});
|
||||
|
||||
expectNoAngularDevkit();
|
||||
});
|
||||
|
||||
it('should be able to create an web-components workspace', () => {
|
||||
const wsName = uniq('web-components');
|
||||
const appName = uniq('app');
|
||||
|
||||
@ -50,11 +50,10 @@ const presetOptions: { name: Preset; message: string }[] = [
|
||||
message:
|
||||
'next.js [a workspace with a single Next.js application]',
|
||||
},
|
||||
// TODO: Re-enable when gatsby preset is implemented
|
||||
// {
|
||||
// name: Preset.Gatsby,
|
||||
// message: 'gatsby [a workspace with a single Gatsby application]',
|
||||
// },
|
||||
{
|
||||
name: Preset.Gatsby,
|
||||
message: 'gatsby [a workspace with a single Gatsby application]',
|
||||
},
|
||||
{
|
||||
name: Preset.Nest,
|
||||
message: 'nest [a workspace with a single Nest application]',
|
||||
@ -361,8 +360,7 @@ function determineStyle(preset: Preset, parsedArgs: any) {
|
||||
Preset.ReactWithExpress,
|
||||
Preset.React,
|
||||
Preset.NextJs,
|
||||
// TODO: Re-enable when gatsby preset is implemented
|
||||
// Preset.Gatsby,
|
||||
Preset.Gatsby,
|
||||
].includes(preset)
|
||||
) {
|
||||
choices.push(
|
||||
@ -375,13 +373,16 @@ function determineStyle(preset: Preset, parsedArgs: any) {
|
||||
name: '@emotion/styled',
|
||||
message:
|
||||
'emotion [ https://emotion.sh ]',
|
||||
},
|
||||
{
|
||||
}
|
||||
);
|
||||
// TODO: Remove below if condition when Gatsby supports styled-jsx
|
||||
if (Preset.Gatsby !== preset) {
|
||||
choices.push({
|
||||
name: 'styled-jsx',
|
||||
message:
|
||||
'styled-jsx [ https://www.npmjs.com/package/styled-jsx ]',
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!parsedArgs.style) {
|
||||
@ -600,8 +601,7 @@ function pointToTutorialAndCourse(preset: Preset) {
|
||||
case Preset.React:
|
||||
case Preset.ReactWithExpress:
|
||||
case Preset.NextJs:
|
||||
// TODO: Re-enable when gatsby preset is implemented
|
||||
// case Preset.Gatsby:
|
||||
case Preset.Gatsby:
|
||||
output.addVerticalSeparator();
|
||||
output.note({
|
||||
title,
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
"@nrwl/devkit",
|
||||
"@nrwl/eslint-plugin-nx",
|
||||
"@nrwl/express",
|
||||
"@nrwl/gatsby",
|
||||
"@nrwl/jest",
|
||||
"@nrwl/linter",
|
||||
"@nrwl/nest",
|
||||
|
||||
@ -140,4 +140,19 @@ describe('preset', () => {
|
||||
expect(tree.exists('apps/proj/src/main.ts')).toBe(true);
|
||||
expect(tree.exists('apps/proj/.eslintrc.json')).toBe(true);
|
||||
});
|
||||
|
||||
it('should create files (preset = gatsby)', async () => {
|
||||
await presetGenerator(tree, {
|
||||
name: 'proj',
|
||||
preset: 'gatsby',
|
||||
style: 'css',
|
||||
linter: 'eslint',
|
||||
cli: 'nx',
|
||||
});
|
||||
|
||||
expect(tree.exists('/apps/proj/src/pages/index.tsx')).toBe(true);
|
||||
expect(readJson(tree, '/workspace.json').cli.defaultCollection).toBe(
|
||||
'@nrwl/gatsby'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -154,6 +154,16 @@ async function createPreset(tree: Tree, options: Schema) {
|
||||
linter: options.linter,
|
||||
});
|
||||
setDefaultCollection(tree, '@nrwl/express');
|
||||
} else if (options.preset === 'gatsby') {
|
||||
const {
|
||||
applicationGenerator: gatsbyApplicationGenerator,
|
||||
} = require('@nrwl' + '/gatsby');
|
||||
await gatsbyApplicationGenerator(tree, {
|
||||
name: options.name,
|
||||
linter: options.linter,
|
||||
style: options.style,
|
||||
});
|
||||
setDefaultCollection(tree, '@nrwl/gatsby');
|
||||
} else {
|
||||
throw new Error(`Invalid preset ${options.preset}`);
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ export interface Schema {
|
||||
| 'angular'
|
||||
| 'react'
|
||||
| 'next'
|
||||
| 'gatsby'
|
||||
| 'web-components'
|
||||
| 'angular-nest'
|
||||
| 'react-express'
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
"@nrwl/cypress": ["./packages/cypress"],
|
||||
"@nrwl/cypress/*": ["./packages/cypress/*"],
|
||||
"@nrwl/express": ["./packages/express"],
|
||||
"@nrwl/gatsby": ["./packages/gatsby"],
|
||||
"@nrwl/nest": ["./packages/nest"],
|
||||
"@nrwl/next": ["./packages/next"],
|
||||
"@nrwl/node": ["./packages/node"],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user