@nx/next 0.0.0-pr-22179-271588f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -0
  3. package/babel.d.ts +0 -0
  4. package/babel.js +12 -0
  5. package/executors.json +20 -0
  6. package/generators.json +47 -0
  7. package/index.d.ts +8 -0
  8. package/index.js +19 -0
  9. package/migrations.json +106 -0
  10. package/package.json +60 -0
  11. package/plugin.d.ts +1 -0
  12. package/plugin.js +5 -0
  13. package/plugins/component-testing.d.ts +2 -0
  14. package/plugins/component-testing.js +96 -0
  15. package/plugins/with-less.d.ts +3 -0
  16. package/plugins/with-less.js +79 -0
  17. package/plugins/with-nx.d.ts +25 -0
  18. package/plugins/with-nx.js +297 -0
  19. package/plugins/with-stylus.d.ts +3 -0
  20. package/plugins/with-stylus.js +12 -0
  21. package/src/executors/build/build.impl.d.ts +5 -0
  22. package/src/executors/build/build.impl.js +106 -0
  23. package/src/executors/build/lib/check-project.d.ts +1 -0
  24. package/src/executors/build/lib/check-project.js +12 -0
  25. package/src/executors/build/lib/create-next-config-file.d.ts +14 -0
  26. package/src/executors/build/lib/create-next-config-file.js +162 -0
  27. package/src/executors/build/lib/test-fixtures/ensure-exts/baz.json +1 -0
  28. package/src/executors/build/lib/update-package-json.d.ts +3 -0
  29. package/src/executors/build/lib/update-package-json.js +30 -0
  30. package/src/executors/build/schema.json +76 -0
  31. package/src/executors/export/export.impl.d.ts +17 -0
  32. package/src/executors/export/export.impl.js +58 -0
  33. package/src/executors/export/schema.json +30 -0
  34. package/src/executors/server/custom-server.impl.d.ts +6 -0
  35. package/src/executors/server/custom-server.impl.js +36 -0
  36. package/src/executors/server/schema.json +63 -0
  37. package/src/executors/server/server.impl.d.ts +6 -0
  38. package/src/executors/server/server.impl.js +66 -0
  39. package/src/generators/application/application.d.ts +4 -0
  40. package/src/generators/application/application.js +85 -0
  41. package/src/generators/application/files/app/api/hello/route.ts__tmpl__ +4 -0
  42. package/src/generators/application/files/app/global.__stylesExt____tmpl__ +1 -0
  43. package/src/generators/application/files/app/page.module.__style__ +1 -0
  44. package/src/generators/application/files/app/page.tsx__tmpl__ +30 -0
  45. package/src/generators/application/files/app-default-layout/layout.tsx__tmpl__ +18 -0
  46. package/src/generators/application/files/app-styled-components/layout.tsx__tmpl__ +21 -0
  47. package/src/generators/application/files/app-styled-components/registry.tsx__tmpl__ +33 -0
  48. package/src/generators/application/files/app-styled-jsx/layout.tsx__tmpl__ +16 -0
  49. package/src/generators/application/files/app-styled-jsx/registry.tsx__tmpl__ +23 -0
  50. package/src/generators/application/files/common/__dot__babelrc +21 -0
  51. package/src/generators/application/files/common/index.d.ts__tmpl__ +13 -0
  52. package/src/generators/application/files/common/next-env.d.ts__tmpl__ +5 -0
  53. package/src/generators/application/files/common/next.config.js__tmpl__ +82 -0
  54. package/src/generators/application/files/common/public/.gitkeep +0 -0
  55. package/src/generators/application/files/common/public/favicon.ico +0 -0
  56. package/src/generators/application/files/common/specs/__fileName__.spec.tsx__tmpl__ +18 -0
  57. package/src/generators/application/files/common/tsconfig.json__tmpl__ +29 -0
  58. package/src/generators/application/files/pages/__fileName__.module.__style__ +1 -0
  59. package/src/generators/application/files/pages/__fileName__.tsx__tmpl__ +30 -0
  60. package/src/generators/application/files/pages/_app.tsx__tmpl__ +18 -0
  61. package/src/generators/application/files/pages/_document.tsx__tmpl__ +33 -0
  62. package/src/generators/application/files/pages/styles.__stylesExt____tmpl__ +1 -0
  63. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  64. package/src/generators/application/lib/add-e2e.js +72 -0
  65. package/src/generators/application/lib/add-jest.d.ts +3 -0
  66. package/src/generators/application/lib/add-jest.js +38 -0
  67. package/src/generators/application/lib/add-linting.d.ts +3 -0
  68. package/src/generators/application/lib/add-linting.js +62 -0
  69. package/src/generators/application/lib/add-plugin.d.ts +2 -0
  70. package/src/generators/application/lib/add-plugin.js +25 -0
  71. package/src/generators/application/lib/add-project.d.ts +3 -0
  72. package/src/generators/application/lib/add-project.js +66 -0
  73. package/src/generators/application/lib/create-application-files.d.ts +3 -0
  74. package/src/generators/application/lib/create-application-files.helpers.d.ts +2 -0
  75. package/src/generators/application/lib/create-application-files.helpers.js +846 -0
  76. package/src/generators/application/lib/create-application-files.js +114 -0
  77. package/src/generators/application/lib/normalize-options.d.ts +14 -0
  78. package/src/generators/application/lib/normalize-options.js +56 -0
  79. package/src/generators/application/lib/set-defaults.d.ts +3 -0
  80. package/src/generators/application/lib/set-defaults.js +14 -0
  81. package/src/generators/application/lib/show-possible-warnings.d.ts +3 -0
  82. package/src/generators/application/lib/show-possible-warnings.js +10 -0
  83. package/src/generators/application/lib/update-cypress-tsconfig.d.ts +3 -0
  84. package/src/generators/application/lib/update-cypress-tsconfig.js +16 -0
  85. package/src/generators/application/lib/update-jest-config.d.ts +3 -0
  86. package/src/generators/application/lib/update-jest-config.js +15 -0
  87. package/src/generators/application/schema.d.ts +24 -0
  88. package/src/generators/application/schema.json +146 -0
  89. package/src/generators/component/component.d.ts +28 -0
  90. package/src/generators/component/component.js +66 -0
  91. package/src/generators/component/schema.json +125 -0
  92. package/src/generators/custom-server/custom-server.d.ts +3 -0
  93. package/src/generators/custom-server/custom-server.js +104 -0
  94. package/src/generators/custom-server/files/server/main.ts__tmpl__ +46 -0
  95. package/src/generators/custom-server/files/tsconfig.server.json__tmpl__ +17 -0
  96. package/src/generators/custom-server/schema.d.ts +4 -0
  97. package/src/generators/custom-server/schema.json +30 -0
  98. package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +5 -0
  99. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +87 -0
  100. package/src/generators/cypress-component-configuration/schema.d.ts +6 -0
  101. package/src/generators/cypress-component-configuration/schema.json +42 -0
  102. package/src/generators/init/init.d.ts +5 -0
  103. package/src/generators/init/init.js +46 -0
  104. package/src/generators/init/lib/add-plugin.d.ts +2 -0
  105. package/src/generators/init/lib/add-plugin.js +26 -0
  106. package/src/generators/init/schema.d.ts +7 -0
  107. package/src/generators/init/schema.json +34 -0
  108. package/src/generators/library/lib/normalize-options.d.ts +7 -0
  109. package/src/generators/library/lib/normalize-options.js +26 -0
  110. package/src/generators/library/library.d.ts +5 -0
  111. package/src/generators/library/library.js +92 -0
  112. package/src/generators/library/schema.d.ts +28 -0
  113. package/src/generators/library/schema.json +156 -0
  114. package/src/generators/page/page.d.ts +5 -0
  115. package/src/generators/page/page.js +96 -0
  116. package/src/generators/page/schema.d.ts +20 -0
  117. package/src/generators/page/schema.json +111 -0
  118. package/src/migrations/update-15-8-8/add-style-packages.d.ts +3 -0
  119. package/src/migrations/update-15-8-8/add-style-packages.js +23 -0
  120. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  121. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  122. package/src/migrations/update-16-3-0/remove-root-build-option.d.ts +2 -0
  123. package/src/migrations/update-16-3-0/remove-root-build-option.js +17 -0
  124. package/src/migrations/update-16-4-0/update-nx-next-dependency.d.ts +2 -0
  125. package/src/migrations/update-16-4-0/update-nx-next-dependency.js +17 -0
  126. package/src/migrations/update-17-2-7/remove-eslint-rules-patch.d.ts +2 -0
  127. package/src/migrations/update-17-2-7/remove-eslint-rules-patch.js +15 -0
  128. package/src/plugins/plugin.d.ts +11 -0
  129. package/src/plugins/plugin.js +182 -0
  130. package/src/utils/add-gitignore-entry.d.ts +2 -0
  131. package/src/utils/add-gitignore-entry.js +17 -0
  132. package/src/utils/add-swc-to-custom-server.d.ts +2 -0
  133. package/src/utils/add-swc-to-custom-server.js +37 -0
  134. package/src/utils/compose-plugins.d.ts +3 -0
  135. package/src/utils/compose-plugins.js +22 -0
  136. package/src/utils/config-invalid-function.fixture.d.ts +0 -0
  137. package/src/utils/config-invalid-function.fixture.js +1 -0
  138. package/src/utils/config-not-a-function.fixture.d.ts +0 -0
  139. package/src/utils/config-not-a-function.fixture.js +1 -0
  140. package/src/utils/config.d.ts +13 -0
  141. package/src/utils/config.js +24 -0
  142. package/src/utils/constants.d.ts +1 -0
  143. package/src/utils/constants.js +4 -0
  144. package/src/utils/create-cli-options.d.ts +1 -0
  145. package/src/utils/create-cli-options.js +13 -0
  146. package/src/utils/create-copy-plugin.d.ts +2 -0
  147. package/src/utils/create-copy-plugin.js +64 -0
  148. package/src/utils/generate-globs.d.ts +5 -0
  149. package/src/utils/generate-globs.js +29 -0
  150. package/src/utils/styles.d.ts +67 -0
  151. package/src/utils/styles.js +67 -0
  152. package/src/utils/types.d.ts +57 -0
  153. package/src/utils/types.js +2 -0
  154. package/src/utils/versions.d.ts +12 -0
  155. package/src/utils/versions.js +15 -0
  156. package/tailwind.d.ts +2 -0
  157. package/tailwind.js +6 -0
  158. package/typings/image.d.ts +12 -0
@@ -0,0 +1,82 @@
1
+ //@ts-check
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
4
+ const { composePlugins, withNx } = require('@nx/next');
5
+
6
+ <% if (style === 'less') { %>
7
+ // This plugin is needed until this PR is merged.
8
+ // https://github.com/vercel/next.js/pull/23185
9
+ const { withLess } = require('@nx/next/plugins/with-less');
10
+
11
+ /**
12
+ * @type {import('@nx/next/plugins/with-nx').WithNxOptions}
13
+ **/
14
+ const nextConfig = {
15
+ nx: {
16
+ // Set this to true if you would like to to use SVGR
17
+ // See: https://github.com/gregberge/svgr
18
+ svgr: false,
19
+ },
20
+ };
21
+
22
+ const plugins = [
23
+ // Add more Next.js plugins to this list if needed.
24
+ withLess,
25
+ withNx,
26
+ ];
27
+
28
+ module.exports = composePlugins(...plugins)(nextConfig);
29
+ <% } else if (
30
+ style === 'styled-components'
31
+ ||style === '@emotion/styled'
32
+ || style === 'styled-jsx'
33
+ || style === 'none'
34
+ ) { %>
35
+ /**
36
+ * @type {import('@nx/next/plugins/with-nx').WithNxOptions}
37
+ **/
38
+ const nextConfig = {
39
+ nx: {
40
+ // Set this to true if you would like to to use SVGR
41
+ // See: https://github.com/gregberge/svgr
42
+ svgr: false,
43
+ },
44
+ <% if (style === 'styled-components') { %>
45
+ compiler: {
46
+ // For other options, see https://styled-components.com/docs/tooling#babel-plugin
47
+ styledComponents: true,
48
+ },
49
+ <% } else if (style === '@emotion/styled') { %>
50
+ compiler: {
51
+ // For other options, see https://nextjs.org/docs/architecture/nextjs-compiler#emotion
52
+ emotion: true,
53
+ },
54
+ <% } %>
55
+ };
56
+
57
+ const plugins = [
58
+ // Add more Next.js plugins to this list if needed.
59
+ withNx,
60
+ ];
61
+
62
+ module.exports = composePlugins(...plugins)(nextConfig);
63
+ <% } else {
64
+ // Defaults to CSS/SASS (which don't need plugin as of Next 9.3) %>
65
+ /**
66
+ * @type {import('@nx/next/plugins/with-nx').WithNxOptions}
67
+ **/
68
+ const nextConfig = {
69
+ nx: {
70
+ // Set this to true if you would like to use SVGR
71
+ // See: https://github.com/gregberge/svgr
72
+ svgr: false,
73
+ },
74
+ };
75
+
76
+ const plugins = [
77
+ // Add more Next.js plugins to this list if needed.
78
+ withNx,
79
+ ];
80
+
81
+ module.exports = composePlugins(...plugins)(nextConfig);
82
+ <% } %>
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ <% if (src && !appDir) { %>
4
+ import Index from '../src/pages/index';
5
+ <% } else if (!appDir) { %>
6
+ import Index from '../pages/index';
7
+ <% } else if (appDir && src) {%>
8
+ import Page from '../src/app/page';
9
+ <% } else { %>
10
+ import Page from '../app/page';
11
+ <% } %>
12
+
13
+ describe(<%- appDir ? `'Page'` : `'Index'` %>, () => {
14
+ it('should render successfully', () => {
15
+ const { baseElement } = render(<%- appDir ? `<Page />` : `<Index />` %>);
16
+ expect(baseElement).toBeTruthy();
17
+ });
18
+ });
@@ -0,0 +1,29 @@
1
+ {
2
+ "extends": "<%= rootTsConfigPath %>",
3
+ "compilerOptions": {
4
+ "jsx": "preserve",
5
+ <% if (style === '@emotion/styled') { %>"jsxImportSource": "@emotion/react",<% } %>
6
+ "allowJs": true,
7
+ "esModuleInterop": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "strict": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "noEmit": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "incremental": true,
15
+ "plugins": [{ "name": "next" }]
16
+ },
17
+ "include": [
18
+ "<%= rootPath %>**/*.ts",
19
+ "<%= rootPath %>**/*.tsx",
20
+ "<%= rootPath %>**/*.js",
21
+ "<%= rootPath %>**/*.jsx",
22
+ <% if (appDir) { %>
23
+ "<%= layoutTypeSrcPath %>",
24
+ "<%= layoutTypeDistPath %>",
25
+ <% } %>
26
+ "next-env.d.ts"
27
+ ],
28
+ "exclude": ["node_modules", "jest.config.ts", "<%= rootPath %>**/*.spec.ts", "<%= rootPath %>**/*.test.ts"]
29
+ }
@@ -0,0 +1 @@
1
+ <%- pageStyleContent %>
@@ -0,0 +1,30 @@
1
+ <% if (style !== 'none') { %>
2
+ <% if (styledModule && styledModule !== 'styled-jsx') {
3
+ var wrapper = 'StyledPage';
4
+ %>import styled from '<%= styledModule %>';<% } else {
5
+ var wrapper = 'div';
6
+ %>
7
+ <%- style !== 'styled-jsx' ? `import styles from './${fileName}.module.${style}';` : '' %>
8
+ <% }
9
+ %>
10
+
11
+ <% if (styledModule && styledModule !== 'styled-jsx') { %>
12
+ const StyledPage = styled.div`<%- pageStyleContent %>`;
13
+ <% }%>
14
+ <% } %>
15
+
16
+ export function Index() {
17
+ /*
18
+ * Replace the elements below with your own.
19
+ *
20
+ * Note: The corresponding styles are in the ./<%= fileName %>.<%= style %> file.
21
+ */
22
+ return (
23
+ <<%= wrapper %><% if (!styledModule) {%> className={styles.page}<% } %>>
24
+ <%- styledModule === 'styled-jsx' && style !== 'none' ? `<style jsx>{\`${pageStyleContent}\`}</style>` : `` %>
25
+ <%- appContent %>
26
+ </<%= wrapper %>>
27
+ );
28
+ }
29
+
30
+ export default Index;
@@ -0,0 +1,18 @@
1
+ import { AppProps } from 'next/app';
2
+ import Head from 'next/head';
3
+ import './styles.<%= stylesExt %>';
4
+
5
+ function CustomApp({ Component, pageProps }: AppProps) {
6
+ return (
7
+ <>
8
+ <Head>
9
+ <title>Welcome to <%= name %>!</title>
10
+ </Head>
11
+ <main className="app">
12
+ <Component {...pageProps}/>
13
+ </main>
14
+ </>
15
+ );
16
+ };
17
+
18
+ export default CustomApp;
@@ -0,0 +1,33 @@
1
+ /* eslint-disable react/display-name */
2
+ import Document, { Html, Head, Main, NextScript, DocumentContext, DocumentInitialProps } from 'next/document';
3
+ import { ServerStyleSheet } from 'styled-components';
4
+
5
+ export default class CustomDocument extends Document {
6
+ static async getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps> {
7
+ const originalRenderPage = ctx.renderPage;
8
+
9
+ const sheet = new ServerStyleSheet();
10
+
11
+ ctx.renderPage = () => originalRenderPage({
12
+ enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
13
+ enhanceComponent: (Component) => Component,
14
+ });
15
+
16
+ const intialProps = await Document.getInitialProps(ctx);
17
+ const styles = sheet.getStyleElement();
18
+
19
+ return {...intialProps, styles };
20
+ }
21
+
22
+ render() {
23
+ return (
24
+ <Html>
25
+ <Head>{this.props.styles}</Head>
26
+ <body>
27
+ <Main />
28
+ <NextScript />
29
+ </body>
30
+ </Html>
31
+ );
32
+ }
33
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function addE2e(host: Tree, options: NormalizedSchema): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addE2e = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const eslint_1 = require("@nx/eslint");
6
+ const versions_1 = require("../../../utils/versions");
7
+ const web_1 = require("@nx/web");
8
+ async function addE2e(host, options) {
9
+ const nxJson = (0, devkit_1.readNxJson)(host);
10
+ const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
11
+ ? p === '@nx/next/plugin'
12
+ : p.plugin === '@nx/next/plugin');
13
+ if (options.e2eTestRunner === 'cypress') {
14
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
15
+ if (!hasPlugin) {
16
+ (0, web_1.webStaticServeGenerator)(host, {
17
+ buildTarget: `${options.projectName}:build`,
18
+ outputPath: `${options.outputPath}/out`,
19
+ targetName: 'serve-static',
20
+ });
21
+ }
22
+ (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
23
+ root: options.e2eProjectRoot,
24
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
25
+ targets: {},
26
+ tags: [],
27
+ implicitDependencies: [options.projectName],
28
+ });
29
+ return configurationGenerator(host, {
30
+ ...options,
31
+ linter: eslint_1.Linter.EsLint,
32
+ project: options.e2eProjectName,
33
+ directory: 'src',
34
+ skipFormat: true,
35
+ devServerTarget: `${options.projectName}:${hasPlugin ? 'start' : 'serve'}`,
36
+ baseUrl: `http://localhost:${hasPlugin ? '3000' : '4200'}`,
37
+ jsx: true,
38
+ webServerCommands: hasPlugin
39
+ ? {
40
+ default: `nx run ${options.projectName}:start`,
41
+ }
42
+ : undefined,
43
+ ciWebServerCommand: hasPlugin
44
+ ? `nx run ${options.projectName}:serve-static`
45
+ : undefined,
46
+ });
47
+ }
48
+ else if (options.e2eTestRunner === 'playwright') {
49
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
50
+ (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
51
+ root: options.e2eProjectRoot,
52
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
53
+ targets: {},
54
+ implicitDependencies: [options.projectName],
55
+ });
56
+ return configurationGenerator(host, {
57
+ rootProject: options.rootProject,
58
+ project: options.e2eProjectName,
59
+ skipFormat: true,
60
+ skipPackageJson: options.skipPackageJson,
61
+ directory: 'src',
62
+ js: false,
63
+ linter: options.linter,
64
+ setParserOptionsProject: options.setParserOptionsProject,
65
+ webServerAddress: `http://127.0.0.1:${hasPlugin ? '3000' : '4200'}`,
66
+ webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${hasPlugin ? 'start' : 'serve'} ${options.projectName}`,
67
+ addPlugin: options.addPlugin,
68
+ });
69
+ }
70
+ return () => { };
71
+ }
72
+ exports.addE2e = addE2e;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function addJest(host: Tree, options: NormalizedSchema): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addJest = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../../utils/versions");
6
+ async function addJest(host, options) {
7
+ if (options.unitTestRunner !== 'jest') {
8
+ return () => { };
9
+ }
10
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
11
+ const jestTask = await configurationGenerator(host, {
12
+ ...options,
13
+ project: options.projectName,
14
+ supportTsx: true,
15
+ skipSerializers: true,
16
+ setupFile: 'none',
17
+ compiler: 'babel',
18
+ skipFormat: true,
19
+ });
20
+ const tsConfigSpecJson = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.spec.json'));
21
+ (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'), (json) => {
22
+ json.compilerOptions ??= {};
23
+ json.compilerOptions.types ??= [];
24
+ json.compilerOptions.types.push(...(tsConfigSpecJson?.compilerOptions?.types ?? []));
25
+ return json;
26
+ });
27
+ (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.spec.json'), (json) => {
28
+ json.compilerOptions.jsx = 'react';
29
+ // have to override exclude otherwise lint will fail with setParserOptionsProject and jest.config.ts
30
+ if (options.setParserOptionsProject) {
31
+ const tsConfig = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'));
32
+ json.exclude = tsConfig.exclude.filter((e) => e !== 'jest.config.ts');
33
+ }
34
+ return json;
35
+ });
36
+ return jestTask;
37
+ }
38
+ exports.addJest = addJest;
@@ -0,0 +1,3 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addLinting = void 0;
4
+ const eslint_1 = require("@nx/eslint");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const lint_1 = require("@nx/react/src/utils/lint");
7
+ const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
8
+ const versions_1 = require("../../../utils/versions");
9
+ async function addLinting(host, options) {
10
+ const tasks = [];
11
+ tasks.push(await (0, eslint_1.lintProjectGenerator)(host, {
12
+ linter: options.linter,
13
+ project: options.projectName,
14
+ tsConfigPaths: [
15
+ (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
16
+ ],
17
+ unitTestRunner: options.unitTestRunner,
18
+ skipFormat: true,
19
+ rootProject: options.rootProject,
20
+ setParserOptionsProject: options.setParserOptionsProject,
21
+ addPlugin: options.addPlugin,
22
+ }));
23
+ if (options.linter === eslint_1.Linter.EsLint && (0, eslint_file_1.isEslintConfigSupported)(host)) {
24
+ (0, eslint_file_1.addExtendsToLintConfig)(host, options.appProjectRoot, [
25
+ 'plugin:@nx/react-typescript',
26
+ 'next',
27
+ 'next/core-web-vitals',
28
+ ]);
29
+ (0, eslint_file_1.updateOverrideInLintConfig)(host, options.appProjectRoot, (o) => Array.isArray(o.files) &&
30
+ o.files.some((f) => f.match(/\*\.ts$/)) &&
31
+ o.files.some((f) => f.match(/\*\.tsx$/)) &&
32
+ o.files.some((f) => f.match(/\*\.js$/)) &&
33
+ o.files.some((f) => f.match(/\*\.jsx$/)), (o) => ({
34
+ ...o,
35
+ rules: {
36
+ ...o.rules,
37
+ '@next/next/no-html-link-for-pages': [
38
+ 'error',
39
+ `${options.appProjectRoot}/pages`,
40
+ ],
41
+ },
42
+ }));
43
+ // add jest specific config
44
+ if (options.unitTestRunner === 'jest') {
45
+ (0, eslint_file_1.addOverrideToLintConfig)(host, options.appProjectRoot, {
46
+ files: ['*.spec.ts', '*.spec.tsx', '*.spec.js', '*.spec.jsx'],
47
+ env: {
48
+ jest: true,
49
+ },
50
+ });
51
+ }
52
+ (0, eslint_file_1.addIgnoresToLintConfig)(host, options.appProjectRoot, ['.next/**/*']);
53
+ }
54
+ if (!options.skipPackageJson) {
55
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, {
56
+ ...lint_1.extraEslintDependencies.devDependencies,
57
+ 'eslint-config-next': versions_1.eslintConfigNextVersion,
58
+ }));
59
+ }
60
+ return (0, devkit_1.runTasksInSerial)(...tasks);
61
+ }
62
+ exports.addLinting = addLinting;
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function addPlugin(tree: Tree): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addPlugin = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function addPlugin(tree) {
6
+ const nxJson = (0, devkit_1.readNxJson)(tree);
7
+ nxJson.plugins ??= [];
8
+ for (const plugin of nxJson.plugins) {
9
+ if (typeof plugin === 'string'
10
+ ? plugin === '@nx/next/plugin'
11
+ : plugin.plugin === '@nx/next/plugin') {
12
+ return;
13
+ }
14
+ }
15
+ nxJson.plugins.push({
16
+ plugin: '@nx/next/plugin',
17
+ options: {
18
+ buildTargetName: 'build',
19
+ serveTargetName: 'serve',
20
+ exportTargetName: 'export',
21
+ },
22
+ });
23
+ (0, devkit_1.updateNxJson)(tree, nxJson);
24
+ }
25
+ exports.addPlugin = addPlugin;
@@ -0,0 +1,3 @@
1
+ import { NormalizedSchema } from './normalize-options';
2
+ import { Tree } from '@nx/devkit';
3
+ export declare function addProject(host: Tree, options: NormalizedSchema): void;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addProject = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
6
+ function addProject(host, options) {
7
+ const targets = {};
8
+ // Check if plugin exists in nx.json and if it doesn't then we can continue
9
+ // with the default targets.
10
+ const nxJson = (0, devkit_1.readNxJson)(host);
11
+ const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
12
+ ? p === '@nx/next/plugin'
13
+ : p.plugin === '@nx/next/plugin');
14
+ if (!hasPlugin) {
15
+ (0, add_build_target_defaults_1.addBuildTargetDefaults)(host, '@nx/next:build');
16
+ targets.build = {
17
+ executor: '@nx/next:build',
18
+ outputs: ['{options.outputPath}'],
19
+ defaultConfiguration: 'production',
20
+ options: {
21
+ outputPath: options.outputPath,
22
+ },
23
+ configurations: {
24
+ development: {
25
+ outputPath: options.appProjectRoot,
26
+ },
27
+ production: {},
28
+ },
29
+ };
30
+ targets.serve = {
31
+ executor: '@nx/next:server',
32
+ defaultConfiguration: 'development',
33
+ options: {
34
+ buildTarget: `${options.projectName}:build`,
35
+ dev: true,
36
+ },
37
+ configurations: {
38
+ development: {
39
+ buildTarget: `${options.projectName}:build:development`,
40
+ dev: true,
41
+ },
42
+ production: {
43
+ buildTarget: `${options.projectName}:build:production`,
44
+ dev: false,
45
+ },
46
+ },
47
+ };
48
+ targets.export = {
49
+ executor: '@nx/next:export',
50
+ options: {
51
+ buildTarget: `${options.projectName}:build:production`,
52
+ },
53
+ };
54
+ }
55
+ const project = {
56
+ root: options.appProjectRoot,
57
+ sourceRoot: options.appProjectRoot,
58
+ projectType: 'application',
59
+ targets,
60
+ tags: options.parsedTags,
61
+ };
62
+ (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
63
+ ...project,
64
+ });
65
+ }
66
+ exports.addProject = addProject;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function createApplicationFiles(host: Tree, options: NormalizedSchema): void;
@@ -0,0 +1,2 @@
1
+ export declare function createAppJsx(name: string): string;
2
+ export declare function createStyleRules(): string;