@nx/next 19.8.0 → 20.0.0-beta.0
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/generators.json +2 -2
- package/package.json +9 -9
- package/src/generators/application/application.js +0 -1
- package/src/generators/application/lib/normalize-options.js +0 -1
- package/src/generators/component/component.d.ts +3 -19
- package/src/generators/component/component.js +1 -28
- package/src/generators/component/schema.json +0 -29
- package/src/generators/library/lib/normalize-options.js +0 -1
- package/src/generators/library/library.js +0 -1
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +0 -6
- package/src/generators/page/page.d.ts +0 -1
- package/src/generators/page/page.js +11 -47
- package/src/generators/page/schema.d.ts +2 -9
package/generators.json
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"description": "Create an application."
|
|
18
18
|
},
|
|
19
19
|
"page": {
|
|
20
|
-
"factory": "./src/generators/page/page
|
|
20
|
+
"factory": "./src/generators/page/page",
|
|
21
21
|
"schema": "./src/generators/page/schema.json",
|
|
22
22
|
"description": "Create a page."
|
|
23
23
|
},
|
|
24
24
|
"component": {
|
|
25
|
-
"factory": "./src/generators/component/component
|
|
25
|
+
"factory": "./src/generators/component/component",
|
|
26
26
|
"schema": "./src/generators/component/schema.json",
|
|
27
27
|
"description": "Create a component."
|
|
28
28
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.0.0-beta.0",
|
|
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, Playwright, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"next": ">=14.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@nx/devkit": "
|
|
38
|
+
"@nx/devkit": "20.0.0-beta.0",
|
|
39
39
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
40
40
|
"@svgr/webpack": "^8.0.1",
|
|
41
41
|
"chalk": "^4.1.0",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"semver": "^7.5.3",
|
|
47
47
|
"tslib": "^2.3.0",
|
|
48
48
|
"webpack-merge": "^5.8.0",
|
|
49
|
-
"@nx/js": "
|
|
50
|
-
"@nx/eslint": "
|
|
51
|
-
"@nx/react": "
|
|
52
|
-
"@nx/web": "
|
|
53
|
-
"@nx/webpack": "
|
|
54
|
-
"@nx/workspace": "
|
|
49
|
+
"@nx/js": "20.0.0-beta.0",
|
|
50
|
+
"@nx/eslint": "20.0.0-beta.0",
|
|
51
|
+
"@nx/react": "20.0.0-beta.0",
|
|
52
|
+
"@nx/web": "20.0.0-beta.0",
|
|
53
|
+
"@nx/webpack": "20.0.0-beta.0",
|
|
54
|
+
"@nx/workspace": "20.0.0-beta.0",
|
|
55
55
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
56
|
-
"@nrwl/next": "
|
|
56
|
+
"@nrwl/next": "20.0.0-beta.0"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
@@ -24,7 +24,6 @@ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-projec
|
|
|
24
24
|
async function applicationGenerator(host, schema) {
|
|
25
25
|
return await applicationGeneratorInternal(host, {
|
|
26
26
|
addPlugin: false,
|
|
27
|
-
projectNameAndRootFormat: 'derived',
|
|
28
27
|
...schema,
|
|
29
28
|
});
|
|
30
29
|
}
|
|
@@ -12,7 +12,6 @@ async function normalizeOptions(host, options) {
|
|
|
12
12
|
directory: options.directory,
|
|
13
13
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
14
14
|
rootProject: options.rootProject,
|
|
15
|
-
callingGenerator: '@nx/next:application',
|
|
16
15
|
});
|
|
17
16
|
options.rootProject = appProjectRoot === '.';
|
|
18
17
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import type { SupportedStyles } from '@nx/react';
|
|
3
|
+
import { type NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
3
4
|
interface Schema {
|
|
4
5
|
name: string;
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20.
|
|
7
|
-
*/
|
|
8
|
-
project?: string;
|
|
9
6
|
style: SupportedStyles;
|
|
10
7
|
directory?: string;
|
|
11
|
-
|
|
12
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
|
13
|
-
*/
|
|
14
|
-
flat?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
|
|
17
|
-
*/
|
|
18
|
-
pascalCaseFiles?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
|
|
21
|
-
*/
|
|
22
|
-
pascalCaseDirectory?: boolean;
|
|
23
|
-
nameAndDirectoryFormat?: 'as-provided' | 'derived';
|
|
8
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
24
9
|
skipFormat?: boolean;
|
|
25
10
|
}
|
|
26
|
-
export declare function componentGenerator(host: Tree,
|
|
27
|
-
export declare function componentGeneratorInternal(host: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
11
|
+
export declare function componentGenerator(host: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
28
12
|
export default componentGenerator;
|
|
@@ -1,52 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.componentGenerator = componentGenerator;
|
|
4
|
-
exports.componentGeneratorInternal = componentGeneratorInternal;
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const react_1 = require("@nx/react");
|
|
7
6
|
const styles_1 = require("../../utils/styles");
|
|
8
7
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
9
|
-
// TODO(v20): Remove this logic once we no longer derive directory.
|
|
10
|
-
function maybeGetDerivedDirectory(host, options) {
|
|
11
|
-
if (!options.project)
|
|
12
|
-
return options.directory;
|
|
13
|
-
const workspace = (0, devkit_1.getProjects)(host);
|
|
14
|
-
const projectType = workspace.get(options.project).projectType;
|
|
15
|
-
return options.directory
|
|
16
|
-
? options.directory
|
|
17
|
-
: projectType === 'application'
|
|
18
|
-
? 'components'
|
|
19
|
-
: undefined;
|
|
20
|
-
}
|
|
21
|
-
async function componentGenerator(host, schema) {
|
|
22
|
-
return componentGeneratorInternal(host, {
|
|
23
|
-
nameAndDirectoryFormat: 'derived',
|
|
24
|
-
...schema,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
8
|
/*
|
|
28
9
|
* This schematic is basically the React one, but for Next we need
|
|
29
10
|
* extra dependencies for css, sass, less style options.
|
|
30
11
|
*/
|
|
31
|
-
async function
|
|
12
|
+
async function componentGenerator(host, options) {
|
|
32
13
|
const { artifactName: name, directory, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
33
|
-
artifactType: 'component',
|
|
34
|
-
callingGenerator: '@nx/next:component',
|
|
35
14
|
name: options.name,
|
|
36
15
|
directory: options.directory,
|
|
37
|
-
derivedDirectory: maybeGetDerivedDirectory(host, options),
|
|
38
|
-
flat: options.flat,
|
|
39
16
|
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
40
|
-
project: options.project,
|
|
41
17
|
fileExtension: 'tsx',
|
|
42
|
-
pascalCaseFile: options.pascalCaseFiles,
|
|
43
|
-
pascalCaseDirectory: options.pascalCaseDirectory,
|
|
44
18
|
});
|
|
45
19
|
const componentInstall = await (0, react_1.componentGenerator)(host, {
|
|
46
20
|
...options,
|
|
47
21
|
name,
|
|
48
22
|
nameAndDirectoryFormat: 'as-provided', // already determined the directory so use as is
|
|
49
|
-
project: undefined,
|
|
50
23
|
directory,
|
|
51
24
|
classComponent: false,
|
|
52
25
|
routing: false,
|
|
@@ -6,15 +6,6 @@
|
|
|
6
6
|
"description": "Create a React Component for Next.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"project": {
|
|
10
|
-
"type": "string",
|
|
11
|
-
"description": "The name of the project.",
|
|
12
|
-
"alias": "p",
|
|
13
|
-
"$default": {
|
|
14
|
-
"$source": "projectName"
|
|
15
|
-
},
|
|
16
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
|
|
17
|
-
},
|
|
18
9
|
"name": {
|
|
19
10
|
"type": "string",
|
|
20
11
|
"description": "The name of the component.",
|
|
@@ -93,26 +84,6 @@
|
|
|
93
84
|
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
94
85
|
"default": false
|
|
95
86
|
},
|
|
96
|
-
"flat": {
|
|
97
|
-
"type": "boolean",
|
|
98
|
-
"description": "Create component at the source root rather than its own directory.",
|
|
99
|
-
"default": false,
|
|
100
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
|
|
101
|
-
},
|
|
102
|
-
"pascalCaseFiles": {
|
|
103
|
-
"type": "boolean",
|
|
104
|
-
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
|
105
|
-
"alias": "P",
|
|
106
|
-
"default": false,
|
|
107
|
-
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
|
108
|
-
},
|
|
109
|
-
"pascalCaseDirectory": {
|
|
110
|
-
"type": "boolean",
|
|
111
|
-
"description": "Use pascal case directory name (e.g. `App/App.tsx`).",
|
|
112
|
-
"alias": "R",
|
|
113
|
-
"default": false,
|
|
114
|
-
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
|
115
|
-
},
|
|
116
87
|
"skipFormat": {
|
|
117
88
|
"description": "Skip formatting files.",
|
|
118
89
|
"type": "boolean",
|
|
@@ -10,7 +10,6 @@ async function normalizeOptions(host, options) {
|
|
|
10
10
|
directory: options.directory,
|
|
11
11
|
importPath: options.importPath,
|
|
12
12
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
13
|
-
callingGenerator: '@nx/next:library',
|
|
14
13
|
});
|
|
15
14
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
16
15
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
@@ -91,12 +91,6 @@
|
|
|
91
91
|
"default": false,
|
|
92
92
|
"description": "Do not update tsconfig.json for development experience."
|
|
93
93
|
},
|
|
94
|
-
"pascalCaseFiles": {
|
|
95
|
-
"type": "boolean",
|
|
96
|
-
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
|
97
|
-
"alias": "P",
|
|
98
|
-
"default": false
|
|
99
|
-
},
|
|
100
94
|
"routing": {
|
|
101
95
|
"type": "boolean",
|
|
102
96
|
"description": "Generate library with routes."
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
3
|
export declare function pageGenerator(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
|
-
export declare function pageGeneratorInternal(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
5
4
|
export default pageGenerator;
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pageGenerator = pageGenerator;
|
|
4
|
-
exports.pageGeneratorInternal = pageGeneratorInternal;
|
|
5
4
|
const react_1 = require("@nx/react");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
6
|
const styles_1 = require("../../utils/styles");
|
|
8
7
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
9
|
-
async function pageGenerator(host, schema) {
|
|
10
|
-
return pageGeneratorInternal(host, {
|
|
11
|
-
nameAndDirectoryFormat: 'derived',
|
|
12
|
-
...schema,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
8
|
/*
|
|
16
9
|
* This schematic is basically the React component one, but for Next we need
|
|
17
10
|
* extra dependencies for css, sass, less style options, and make sure
|
|
18
11
|
* it is under `pages` folder.
|
|
19
12
|
*/
|
|
20
|
-
async function
|
|
13
|
+
async function pageGenerator(host, schema) {
|
|
21
14
|
const options = await normalizeOptions(host, schema);
|
|
22
15
|
const componentTask = await (0, react_1.componentGenerator)(host, {
|
|
23
16
|
...options,
|
|
@@ -40,49 +33,20 @@ async function pageGeneratorInternal(host, schema) {
|
|
|
40
33
|
return (0, devkit_1.runTasksInSerial)(componentTask, styledTask);
|
|
41
34
|
}
|
|
42
35
|
async function normalizeOptions(host, options) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
host.exists(`${project.root}/src/app`);
|
|
54
|
-
routerDirectory = isAppRouter ? 'app' : 'pages';
|
|
55
|
-
derivedDirectory = options.directory
|
|
56
|
-
? `${routerDirectory}/${options.directory}`
|
|
57
|
-
: `${routerDirectory}`;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// Get the project name first so we can determine the router directory
|
|
61
|
-
const { project: determinedProjectName } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
62
|
-
artifactType: 'page',
|
|
63
|
-
callingGenerator: '@nx/next:page',
|
|
64
|
-
name: options.name,
|
|
65
|
-
directory: options.directory,
|
|
66
|
-
});
|
|
67
|
-
const project = (0, devkit_1.readProjectConfiguration)(host, determinedProjectName);
|
|
68
|
-
// app/ is a reserved folder in nextjs so it is safe to check it's existence
|
|
69
|
-
isAppRouter =
|
|
70
|
-
host.exists(`${project.root}/app`) ||
|
|
71
|
-
host.exists(`${project.root}/src/app`);
|
|
72
|
-
routerDirectory = isAppRouter ? 'app' : 'pages';
|
|
73
|
-
// New behavior, use directory as is without detecting whether we're using app or pages router.
|
|
74
|
-
derivedDirectory = options.directory;
|
|
75
|
-
}
|
|
76
|
-
const { artifactName: name, project: projectName, fileName, directory, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
77
|
-
artifactType: 'page',
|
|
78
|
-
callingGenerator: '@nx/next:page',
|
|
36
|
+
// Get the project name first so we can determine the router directory
|
|
37
|
+
const { project: determinedProjectName } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
38
|
+
name: options.name,
|
|
39
|
+
directory: options.directory,
|
|
40
|
+
});
|
|
41
|
+
const project = (0, devkit_1.readProjectConfiguration)(host, determinedProjectName);
|
|
42
|
+
// app/ is a reserved folder in nextjs so it is safe to check it's existence
|
|
43
|
+
const isAppRouter = host.exists(`${project.root}/app`) ||
|
|
44
|
+
host.exists(`${project.root}/src/app`);
|
|
45
|
+
const { project: projectName, fileName, directory, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
79
46
|
name: options.name,
|
|
80
47
|
fileName: isAppRouter ? 'page' : 'index',
|
|
81
48
|
directory: options.directory,
|
|
82
|
-
derivedDirectory,
|
|
83
|
-
flat: options.flat,
|
|
84
49
|
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
85
|
-
project: options.project,
|
|
86
50
|
fileExtension: 'tsx',
|
|
87
51
|
});
|
|
88
52
|
return {
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
+
import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
1
2
|
import { SupportedStyles } from '@nx/react';
|
|
2
3
|
|
|
3
4
|
export interface Schema {
|
|
4
5
|
name: string;
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20.
|
|
7
|
-
*/
|
|
8
|
-
project?: string;
|
|
9
6
|
style: SupportedStyles;
|
|
10
7
|
directory?: string;
|
|
11
8
|
fileName?: string;
|
|
12
9
|
withTests?: boolean;
|
|
13
10
|
js?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
|
16
|
-
*/
|
|
17
|
-
flat?: boolean;
|
|
18
11
|
skipFormat?: boolean;
|
|
19
|
-
nameAndDirectoryFormat?:
|
|
12
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
20
13
|
}
|