@nx/next 17.3.0-beta.4 → 17.3.0-beta.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/next",
3
- "version": "17.3.0-beta.4",
3
+ "version": "17.3.0-beta.6",
4
4
  "private": false,
5
5
  "description": "The Next.js plugin for Nx contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides:\n\n\n- Scaffolding for creating, building, serving, linting, and testing Next.js applications.\n\n- Integration with building, serving, and exporting a Next.js application.\n\n- Integration with React libraries within the workspace. \n\nWhen using Next.js in Nx, you get the out-of-the-box support for TypeScript, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
6
6
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "next": ">=13.0.0"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "17.3.0-beta.4",
37
+ "@nx/devkit": "17.3.0-beta.6",
38
38
  "@babel/plugin-proposal-decorators": "^7.22.7",
39
39
  "@svgr/webpack": "^8.0.1",
40
40
  "chalk": "^4.1.0",
@@ -45,12 +45,12 @@
45
45
  "url-loader": "^4.1.1",
46
46
  "tslib": "^2.3.0",
47
47
  "webpack-merge": "^5.8.0",
48
- "@nx/js": "17.3.0-beta.4",
49
- "@nx/eslint": "17.3.0-beta.4",
50
- "@nx/react": "17.3.0-beta.4",
51
- "@nx/web": "17.3.0-beta.4",
52
- "@nx/workspace": "17.3.0-beta.4",
53
- "@nrwl/next": "17.3.0-beta.4"
48
+ "@nx/js": "17.3.0-beta.6",
49
+ "@nx/eslint": "17.3.0-beta.6",
50
+ "@nx/react": "17.3.0-beta.6",
51
+ "@nx/web": "17.3.0-beta.6",
52
+ "@nx/workspace": "17.3.0-beta.6",
53
+ "@nrwl/next": "17.3.0-beta.6"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
  import { render } from '@testing-library/react';
3
-
3
+ <% if (src) { %>
4
+ import Index from '../src/pages/index';
5
+ <% } else { %>
4
6
  import Index from '../pages/index';
5
-
7
+ <% } %>
6
8
  describe('Index', () => {
7
9
  it('should render successfully', () => {
8
10
  const { baseElement } = render(<Index />);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addProject = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
5
6
  function addProject(host, options) {
6
7
  const targets = {};
7
8
  // Check if plugin exists in nx.json and if it doesn't then we can continue
@@ -11,6 +12,7 @@ function addProject(host, options) {
11
12
  ? p === '@nx/next/plugin'
12
13
  : p.plugin === '@nx/next/plugin');
13
14
  if (!hasPlugin) {
15
+ (0, add_build_target_defaults_1.addBuildTargetDefaults)(host, '@nx/next:build');
14
16
  targets.build = {
15
17
  executor: '@nx/next:build',
16
18
  outputs: ['{options.outputPath}'],
@@ -23,23 +23,26 @@ function createApplicationFiles(host, options) {
23
23
  pageStyleContent: `.page {}`,
24
24
  stylesExt: options.style === 'less' ? options.style : 'css',
25
25
  };
26
+ const generatedAppFilePath = options.src
27
+ ? (0, path_1.join)(options.appProjectRoot, 'src')
28
+ : options.appProjectRoot;
26
29
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/common'), options.appProjectRoot, templateVariables);
27
30
  if (options.appDir) {
28
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), (0, path_1.join)(options.appProjectRoot, 'app'), templateVariables);
31
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), (0, path_1.join)(generatedAppFilePath, 'app'), templateVariables);
29
32
  // RSC is not possible to unit test without extra helpers for data fetching. Leaving it to the user to figure out.
30
33
  host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'specs', `index.spec.${options.js ? 'jsx' : 'tsx'}`));
31
34
  if (options.style === 'styled-components') {
32
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-styled-components'), (0, path_1.join)(options.appProjectRoot, 'app'), templateVariables);
35
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-styled-components'), (0, path_1.join)(generatedAppFilePath, 'app'), templateVariables);
33
36
  }
34
37
  else if (options.style === 'styled-jsx') {
35
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-styled-jsx'), (0, path_1.join)(options.appProjectRoot, 'app'), templateVariables);
38
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-styled-jsx'), (0, path_1.join)(generatedAppFilePath, 'app'), templateVariables);
36
39
  }
37
40
  else {
38
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-default-layout'), (0, path_1.join)(options.appProjectRoot, 'app'), templateVariables);
41
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-default-layout'), (0, path_1.join)(generatedAppFilePath, 'app'), templateVariables);
39
42
  }
40
43
  }
41
44
  else {
42
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/pages'), (0, path_1.join)(options.appProjectRoot, 'pages'), templateVariables);
45
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/pages'), (0, path_1.join)(generatedAppFilePath, 'pages'), templateVariables);
43
46
  }
44
47
  if (options.rootProject) {
45
48
  (0, devkit_1.updateJson)(host, 'tsconfig.base.json', (json) => {
@@ -83,14 +86,14 @@ function createApplicationFiles(host, options) {
83
86
  }
84
87
  if (options.styledModule) {
85
88
  if (options.appDir) {
86
- host.delete(`${options.appProjectRoot}/app/page.module.${options.style}`);
89
+ host.delete(`${generatedAppFilePath}/app/page.module.${options.style}`);
87
90
  }
88
91
  else {
89
- host.delete(`${options.appProjectRoot}/pages/${options.fileName}.module.${options.style}`);
92
+ host.delete(`${generatedAppFilePath}/pages/${options.fileName}.module.${options.style}`);
90
93
  }
91
94
  }
92
95
  if (options.style !== 'styled-components') {
93
- host.delete(`${options.appProjectRoot}/pages/_document.tsx`);
96
+ host.delete(`${generatedAppFilePath}/pages/_document.tsx`);
94
97
  }
95
98
  if (options.js) {
96
99
  host.delete(`${options.appProjectRoot}/index.d.ts`);
@@ -25,6 +25,7 @@ async function normalizeOptions(host, options) {
25
25
  : [];
26
26
  const fileName = 'index';
27
27
  const appDir = options.appDir ?? true;
28
+ const src = options.src ?? true;
28
29
  const styledModule = /^(css|scss|less)$/.test(options.style)
29
30
  ? null
30
31
  : options.style;
@@ -32,6 +33,7 @@ async function normalizeOptions(host, options) {
32
33
  return {
33
34
  ...options,
34
35
  appDir,
36
+ src,
35
37
  appProjectRoot,
36
38
  e2eProjectName,
37
39
  e2eProjectRoot,
@@ -18,5 +18,6 @@ export interface Schema {
18
18
  customServer?: boolean;
19
19
  skipPackageJson?: boolean;
20
20
  appDir?: boolean;
21
+ src?: boolean;
21
22
  rootProject?: boolean;
22
23
  }
@@ -127,6 +127,12 @@
127
127
  "description": "Enable the App Router for this project.",
128
128
  "x-prompt": "Would you like to use the App Router (recommended)?"
129
129
  },
130
+ "src": {
131
+ "type": "boolean",
132
+ "default": true,
133
+ "description": "Generate a `src` directory for the project.",
134
+ "x-prompt": "Would you like to use `src/` directory?"
135
+ },
130
136
  "rootProject": {
131
137
  "description": "Create an application at the root of the workspace.",
132
138
  "type": "boolean",
@@ -15,7 +15,7 @@ function updateDependencies(host, schema) {
15
15
  'react-dom': versions_1.reactDomVersion,
16
16
  }, {
17
17
  '@nx/next': versions_2.nxVersion,
18
- }));
18
+ }, undefined, schema.keepExistingVersions));
19
19
  return (0, devkit_1.runTasksInSerial)(...tasks);
20
20
  }
21
21
  async function nextInitGenerator(host, schema) {
@@ -1,4 +1,5 @@
1
1
  export interface InitSchema {
2
2
  skipFormat?: boolean;
3
3
  skipPackageJson?: boolean;
4
+ keepExistingVersions?: boolean;
4
5
  }
@@ -16,6 +16,12 @@
16
16
  "default": false,
17
17
  "description": "Do not add dependencies to `package.json`.",
18
18
  "x-priority": "internal"
19
+ },
20
+ "keepExistingVersions": {
21
+ "type": "boolean",
22
+ "x-priority": "internal",
23
+ "description": "Keep existing dependencies versions",
24
+ "default": false
19
25
  }
20
26
  },
21
27
  "required": []