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