@nx/next 20.0.0-beta.5 → 20.0.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/migrations.json +0 -36
- package/package.json +7 -9
- package/src/executors/build/build.impl.js +7 -8
- package/src/executors/build/lib/check-project.js +2 -2
- package/src/executors/build/lib/create-next-config-file.js +15 -14
- package/src/generators/application/application.js +2 -0
- package/src/generators/application/lib/normalize-options.js +2 -3
- package/src/generators/application/schema.d.ts +2 -4
- package/src/generators/application/schema.json +12 -15
- package/src/generators/component/component.d.ts +2 -4
- package/src/generators/component/component.js +1 -4
- package/src/generators/component/schema.json +9 -14
- package/src/generators/init/init.js +2 -0
- package/src/generators/library/lib/normalize-options.js +2 -3
- package/src/generators/library/library.js +2 -0
- package/src/generators/library/schema.d.ts +2 -4
- package/src/generators/library/schema.json +15 -17
- package/src/generators/page/page.js +3 -6
- package/src/generators/page/schema.d.ts +2 -3
- package/src/generators/page/schema.json +7 -21
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
- package/src/migrations/update-16-3-0/remove-root-build-option.d.ts +0 -2
- package/src/migrations/update-16-3-0/remove-root-build-option.js +0 -17
- package/src/migrations/update-16-4-0/update-nx-next-dependency.d.ts +0 -2
- package/src/migrations/update-16-4-0/update-nx-next-dependency.js +0 -17
package/migrations.json
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generators": {
|
|
3
|
-
"update-16-0-0-add-nx-packages": {
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"version": "16.0.0-beta.1",
|
|
6
|
-
"description": "Replace @nrwl/next with @nx/next",
|
|
7
|
-
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
8
|
-
},
|
|
9
|
-
"update-16-3-0-remove-root-build-option": {
|
|
10
|
-
"cli": "nx",
|
|
11
|
-
"version": "16.3.0-beta.9",
|
|
12
|
-
"description": "Remove root build option from project configurations since it is not needed.",
|
|
13
|
-
"implementation": "./src/migrations/update-16-3-0/remove-root-build-option"
|
|
14
|
-
},
|
|
15
|
-
"update-16-4-0-update-next-dependency": {
|
|
16
|
-
"cli": "nx",
|
|
17
|
-
"version": "16.4.0-beta.3",
|
|
18
|
-
"description": "Update package.json moving @nx/next from dependency to devDependency",
|
|
19
|
-
"implementation": "./src/migrations/update-16-4-0/update-nx-next-dependency"
|
|
20
|
-
},
|
|
21
3
|
"update-17-2-7": {
|
|
22
4
|
"cli": "nx",
|
|
23
5
|
"version": "17.2.7",
|
|
@@ -26,24 +8,6 @@
|
|
|
26
8
|
}
|
|
27
9
|
},
|
|
28
10
|
"packageJsonUpdates": {
|
|
29
|
-
"16.0.0": {
|
|
30
|
-
"version": "16.0.0-beta.0",
|
|
31
|
-
"packages": {
|
|
32
|
-
"next": {
|
|
33
|
-
"version": "13.3.0",
|
|
34
|
-
"alwaysAddToPackageJson": false
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"16.4.0-beta.4": {
|
|
39
|
-
"version": "16.4.0-beta.4",
|
|
40
|
-
"packages": {
|
|
41
|
-
"stylus": {
|
|
42
|
-
"version": "^0.59.0",
|
|
43
|
-
"alwaysAddToPackageJson": false
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
11
|
"17.3.1-beta.0": {
|
|
48
12
|
"version": "17.3.1-beta.0",
|
|
49
13
|
"packages": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "20.0.0-beta.
|
|
3
|
+
"version": "20.0.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, Playwright, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
|
|
6
6
|
"repository": {
|
|
@@ -35,23 +35,21 @@
|
|
|
35
35
|
"next": ">=14.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@nx/devkit": "20.0.0-beta.
|
|
38
|
+
"@nx/devkit": "20.0.0-beta.6",
|
|
39
39
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
40
40
|
"@svgr/webpack": "^8.0.1",
|
|
41
41
|
"copy-webpack-plugin": "^10.2.4",
|
|
42
42
|
"file-loader": "^6.2.0",
|
|
43
|
-
"fs-extra": "^11.1.0",
|
|
44
43
|
"ignore": "^5.0.4",
|
|
45
44
|
"picocolors": "^1.1.0",
|
|
46
45
|
"semver": "^7.5.3",
|
|
47
46
|
"tslib": "^2.3.0",
|
|
48
47
|
"webpack-merge": "^5.8.0",
|
|
49
|
-
"@nx/js": "20.0.0-beta.
|
|
50
|
-
"@nx/eslint": "20.0.0-beta.
|
|
51
|
-
"@nx/react": "20.0.0-beta.
|
|
52
|
-
"@nx/web": "20.0.0-beta.
|
|
53
|
-
"@nx/webpack": "20.0.0-beta.
|
|
54
|
-
"@nx/workspace": "20.0.0-beta.5",
|
|
48
|
+
"@nx/js": "20.0.0-beta.6",
|
|
49
|
+
"@nx/eslint": "20.0.0-beta.6",
|
|
50
|
+
"@nx/react": "20.0.0-beta.6",
|
|
51
|
+
"@nx/web": "20.0.0-beta.6",
|
|
52
|
+
"@nx/webpack": "20.0.0-beta.6",
|
|
55
53
|
"@phenomnomnominal/tsquery": "~5.0.1"
|
|
56
54
|
},
|
|
57
55
|
"publishConfig": {
|
|
@@ -4,9 +4,9 @@ exports.default = buildExecutor;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const js_1 = require("@nx/js");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
const
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
8
9
|
const semver_1 = require("semver");
|
|
9
|
-
const fileutils_1 = require("@nx/workspace/src/utilities/fileutils");
|
|
10
10
|
const semver_2 = require("@nx/devkit/src/utils/semver");
|
|
11
11
|
const update_package_json_1 = require("./lib/update-package-json");
|
|
12
12
|
const create_next_config_file_1 = require("./lib/create-next-config-file");
|
|
@@ -22,7 +22,7 @@ async function buildExecutor(options, context) {
|
|
|
22
22
|
(0, check_project_1.checkPublicDirectory)(projectRoot);
|
|
23
23
|
// Set `__NEXT_REACT_ROOT` based on installed ReactDOM version
|
|
24
24
|
const packageJsonPath = (0, path_1.join)(projectRoot, 'package.json');
|
|
25
|
-
const packageJson = (0,
|
|
25
|
+
const packageJson = (0, node_fs_1.existsSync)(packageJsonPath)
|
|
26
26
|
? (0, devkit_1.readJsonFile)(packageJsonPath)
|
|
27
27
|
: undefined;
|
|
28
28
|
const rootPackageJson = (0, devkit_1.readJsonFile)((0, path_1.join)(context.root, 'package.json'));
|
|
@@ -51,9 +51,7 @@ async function buildExecutor(options, context) {
|
|
|
51
51
|
childProcess.kill();
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
(0, fs_extra_1.mkdir)(options.outputPath);
|
|
56
|
-
}
|
|
54
|
+
await (0, promises_1.mkdir)(options.outputPath, { recursive: true });
|
|
57
55
|
const builtPackageJson = (0, js_1.createPackageJson)(context.projectName, context.projectGraph, {
|
|
58
56
|
target: context.targetName,
|
|
59
57
|
root: context.root,
|
|
@@ -70,7 +68,7 @@ async function buildExecutor(options, context) {
|
|
|
70
68
|
if (options.generateLockfile) {
|
|
71
69
|
const packageManager = (0, devkit_1.detectPackageManager)(context.root);
|
|
72
70
|
const lockFile = (0, js_1.createLockFile)(builtPackageJson, context.projectGraph, packageManager);
|
|
73
|
-
(0,
|
|
71
|
+
(0, node_fs_1.writeFileSync)(`${options.outputPath}/${(0, js_1.getLockFileName)(packageManager)}`, lockFile, {
|
|
74
72
|
encoding: 'utf-8',
|
|
75
73
|
});
|
|
76
74
|
}
|
|
@@ -78,8 +76,9 @@ async function buildExecutor(options, context) {
|
|
|
78
76
|
// This is the default behavior when running `nx build <app>`.
|
|
79
77
|
if (options.outputPath.replace(/\/$/, '') !== projectRoot) {
|
|
80
78
|
(0, create_next_config_file_1.createNextConfigFile)(options, context);
|
|
81
|
-
(0,
|
|
79
|
+
(0, node_fs_1.cpSync)((0, path_1.join)(projectRoot, 'public'), (0, path_1.join)(options.outputPath, 'public'), {
|
|
82
80
|
dereference: true,
|
|
81
|
+
recursive: true,
|
|
83
82
|
});
|
|
84
83
|
}
|
|
85
84
|
return { success: true };
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkPublicDirectory = checkPublicDirectory;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
function checkPublicDirectory(root) {
|
|
8
|
-
if ((0,
|
|
8
|
+
if ((0, node_fs_1.readdirSync)((0, path_1.join)(root, 'public')).length === 0) {
|
|
9
9
|
devkit_1.logger.warn('public directory cannot be empty. This may result in errors during the deployment. Consider adding a public/.gitkeep file');
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -8,7 +8,7 @@ exports.getRelativeImports = getRelativeImports;
|
|
|
8
8
|
exports.ensureFileExtensions = ensureFileExtensions;
|
|
9
9
|
const devkit_1 = require("@nx/devkit");
|
|
10
10
|
const ts = require("typescript");
|
|
11
|
-
const
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
12
|
const path_1 = require("path");
|
|
13
13
|
const js_1 = require("@nx/js");
|
|
14
14
|
function createNextConfigFile(options, context) {
|
|
@@ -22,21 +22,21 @@ function createNextConfigFile(options, context) {
|
|
|
22
22
|
// If user passed a config then it is relative to the workspace root, need to normalize it to be relative to the project root.
|
|
23
23
|
options.nextConfig ? (0, path_1.relative)(projectRoot, options.nextConfig) : undefined);
|
|
24
24
|
const configAbsolutePath = (0, path_1.join)(projectRoot, configRelativeToProjectRoot);
|
|
25
|
-
if (!(0,
|
|
25
|
+
if (!(0, node_fs_1.existsSync)(configAbsolutePath)) {
|
|
26
26
|
throw new Error('next.config.js not found');
|
|
27
27
|
}
|
|
28
28
|
// Copy config file and our `.nx-helpers` folder to remove dependency on @nrwl/next for production build.
|
|
29
29
|
const helpersPath = (0, path_1.join)(options.outputPath, '.nx-helpers');
|
|
30
|
-
(0,
|
|
31
|
-
(0,
|
|
32
|
-
(0,
|
|
33
|
-
(0,
|
|
30
|
+
(0, node_fs_1.mkdirSync)(helpersPath, { recursive: true });
|
|
31
|
+
(0, node_fs_1.copyFileSync)((0, path_1.join)(__dirname, '../../../utils/compose-plugins.js'), (0, path_1.join)(helpersPath, 'compose-plugins.js'));
|
|
32
|
+
(0, node_fs_1.writeFileSync)((0, path_1.join)(helpersPath, 'with-nx.js'), getWithNxContent());
|
|
33
|
+
(0, node_fs_1.writeFileSync)((0, path_1.join)(helpersPath, 'compiled.js'), `
|
|
34
34
|
const withNx = require('./with-nx');
|
|
35
35
|
module.exports = withNx;
|
|
36
36
|
module.exports.withNx = withNx;
|
|
37
37
|
module.exports.composePlugins = require('./compose-plugins').composePlugins;
|
|
38
38
|
`);
|
|
39
|
-
(0,
|
|
39
|
+
(0, node_fs_1.writeFileSync)((0, path_1.join)(options.outputPath, configRelativeToProjectRoot), (0, node_fs_1.readFileSync)(configAbsolutePath)
|
|
40
40
|
.toString()
|
|
41
41
|
.replace(/["']@nx\/next["']/, `'./.nx-helpers/compiled.js'`)
|
|
42
42
|
// TODO(v17): Remove this once users have all migrated to new @nx scope and import from '@nx/next' not the deep import paths.
|
|
@@ -45,17 +45,18 @@ function createNextConfigFile(options, context) {
|
|
|
45
45
|
// Find all relative imports needed by next.config.js and copy them to the dist folder.
|
|
46
46
|
const moduleFilesToCopy = getRelativeFilesToCopy(configRelativeToProjectRoot, projectRoot);
|
|
47
47
|
for (const moduleFile of moduleFilesToCopy) {
|
|
48
|
-
|
|
48
|
+
const moduleFileDir = (0, path_1.dirname)((0, path_1.join)(context.root, options.outputPath, moduleFile));
|
|
49
|
+
(0, node_fs_1.mkdirSync)(moduleFileDir, { recursive: true });
|
|
49
50
|
// We already generate a build version of package.json in the dist folder.
|
|
50
51
|
if (moduleFile !== 'package.json') {
|
|
51
|
-
(0,
|
|
52
|
+
(0, node_fs_1.copyFileSync)((0, path_1.join)(context.root, projectRoot, moduleFile), (0, path_1.join)(context.root, options.outputPath, moduleFile));
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
function readSource(getFile) {
|
|
56
57
|
return {
|
|
57
58
|
file: getFile(),
|
|
58
|
-
content: (0,
|
|
59
|
+
content: (0, node_fs_1.readFileSync)(getFile()).toString(),
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
// Exported for testing
|
|
@@ -89,13 +90,13 @@ function getWithNxContent({ file, content } = readSource(() => (0, path_1.join)(
|
|
|
89
90
|
function findNextConfigPath(dirname, userDefinedConfigPath) {
|
|
90
91
|
if (userDefinedConfigPath) {
|
|
91
92
|
const file = userDefinedConfigPath;
|
|
92
|
-
if ((0,
|
|
93
|
+
if ((0, node_fs_1.existsSync)((0, path_1.join)(dirname, file)))
|
|
93
94
|
return file;
|
|
94
95
|
throw new Error(`Cannot find the Next.js config file: ${userDefinedConfigPath}. Is the path correct in project.json?`);
|
|
95
96
|
}
|
|
96
97
|
const candidates = ['next.config.js', 'next.config.cjs', 'next.config.mjs'];
|
|
97
98
|
for (const candidate of candidates) {
|
|
98
|
-
if ((0,
|
|
99
|
+
if ((0, node_fs_1.existsSync)((0, path_1.join)(dirname, candidate)))
|
|
99
100
|
return candidate;
|
|
100
101
|
}
|
|
101
102
|
throw new Error(`Cannot find any of the following files in your project: ${candidates.join(', ')}. Is this a Next.js project?`);
|
|
@@ -110,7 +111,7 @@ function getRelativeFilesToCopy(fileName, cwd) {
|
|
|
110
111
|
return;
|
|
111
112
|
seen.add(currFile);
|
|
112
113
|
const absoluteFilePath = (0, path_1.join)(cwd, currFile);
|
|
113
|
-
const content = (0,
|
|
114
|
+
const content = (0, node_fs_1.readFileSync)(absoluteFilePath).toString();
|
|
114
115
|
const files = getRelativeImports({ file: currFile, content });
|
|
115
116
|
const modules = ensureFileExtensions(files, (0, path_1.dirname)(absoluteFilePath));
|
|
116
117
|
const relativeDirPath = (0, path_1.dirname)(currFile);
|
|
@@ -153,7 +154,7 @@ function ensureFileExtensions(files, absoluteDir) {
|
|
|
153
154
|
const providedExt = (0, path_1.extname)(file);
|
|
154
155
|
if (providedExt && extensions.includes(providedExt))
|
|
155
156
|
return file;
|
|
156
|
-
const ext = extensions.find((ext) => (0,
|
|
157
|
+
const ext = extensions.find((ext) => (0, node_fs_1.existsSync)((0, path_1.join)(absoluteDir, file + ext)));
|
|
157
158
|
if (ext) {
|
|
158
159
|
return file + ext;
|
|
159
160
|
}
|
|
@@ -4,6 +4,7 @@ exports.applicationGenerator = applicationGenerator;
|
|
|
4
4
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
8
|
const react_1 = require("@nx/react");
|
|
8
9
|
const versions_1 = require("@nx/react/src/utils/versions");
|
|
9
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
@@ -28,6 +29,7 @@ async function applicationGenerator(host, schema) {
|
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
31
|
async function applicationGeneratorInternal(host, schema) {
|
|
32
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'next', 'application');
|
|
31
33
|
const tasks = [];
|
|
32
34
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
33
35
|
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
|
@@ -6,15 +6,14 @@ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project
|
|
|
6
6
|
const eslint_1 = require("@nx/eslint");
|
|
7
7
|
const assertion_1 = require("@nx/react/src/utils/assertion");
|
|
8
8
|
async function normalizeOptions(host, options) {
|
|
9
|
-
|
|
9
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
10
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
10
11
|
name: options.name,
|
|
11
12
|
projectType: 'application',
|
|
12
13
|
directory: options.directory,
|
|
13
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
14
14
|
rootProject: options.rootProject,
|
|
15
15
|
});
|
|
16
16
|
options.rootProject = appProjectRoot === '.';
|
|
17
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
18
17
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
19
18
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
20
19
|
nxJson.useInferencePlugins !== false;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
|
3
2
|
import type { SupportedStyles } from '@nx/react';
|
|
4
3
|
|
|
5
4
|
export interface Schema {
|
|
6
|
-
|
|
5
|
+
directory: string;
|
|
6
|
+
name?: string;
|
|
7
7
|
style?: SupportedStyles;
|
|
8
8
|
skipFormat?: boolean;
|
|
9
|
-
directory?: string;
|
|
10
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
9
|
tags?: string;
|
|
12
10
|
unitTestRunner?: 'jest' | 'none';
|
|
13
11
|
e2eTestRunner?: 'cypress' | 'playwright' | 'none';
|
|
@@ -6,28 +6,22 @@
|
|
|
6
6
|
"description": "Create a Next.js Application for Nx.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
10
|
-
"description": "The
|
|
9
|
+
"directory": {
|
|
10
|
+
"description": "The directory of the new application.",
|
|
11
11
|
"type": "string",
|
|
12
|
+
"alias": "dir",
|
|
12
13
|
"$default": {
|
|
13
14
|
"$source": "argv",
|
|
14
15
|
"index": 0
|
|
15
16
|
},
|
|
16
|
-
"x-prompt": "
|
|
17
|
-
"pattern": "^[a-zA-Z][^:]*$",
|
|
18
|
-
"x-priority": "important"
|
|
17
|
+
"x-prompt": "Which directory do you want to create the application in?"
|
|
19
18
|
},
|
|
20
|
-
"
|
|
21
|
-
"description": "The
|
|
19
|
+
"name": {
|
|
20
|
+
"description": "The name of the application.",
|
|
22
21
|
"type": "string",
|
|
23
|
-
"
|
|
22
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
|
24
23
|
"x-priority": "important"
|
|
25
24
|
},
|
|
26
|
-
"projectNameAndRootFormat": {
|
|
27
|
-
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
28
|
-
"type": "string",
|
|
29
|
-
"enum": ["as-provided", "derived"]
|
|
30
|
-
},
|
|
31
25
|
"style": {
|
|
32
26
|
"description": "The file extension to be used for style files.",
|
|
33
27
|
"type": "string",
|
|
@@ -37,7 +31,10 @@
|
|
|
37
31
|
"message": "Which stylesheet format would you like to use?",
|
|
38
32
|
"type": "list",
|
|
39
33
|
"items": [
|
|
40
|
-
{
|
|
34
|
+
{
|
|
35
|
+
"value": "css",
|
|
36
|
+
"label": "CSS"
|
|
37
|
+
},
|
|
41
38
|
{
|
|
42
39
|
"value": "scss",
|
|
43
40
|
"label": "SASS(.scss) [ https://sass-lang.com ]"
|
|
@@ -145,6 +142,6 @@
|
|
|
145
142
|
"x-priority": "internal"
|
|
146
143
|
}
|
|
147
144
|
},
|
|
148
|
-
"required": [],
|
|
145
|
+
"required": ["directory"],
|
|
149
146
|
"examplesFile": "../../../docs/application-examples.md"
|
|
150
147
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
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';
|
|
4
3
|
interface Schema {
|
|
5
|
-
|
|
4
|
+
path: string;
|
|
5
|
+
name?: string;
|
|
6
6
|
style: SupportedStyles;
|
|
7
|
-
directory?: string;
|
|
8
|
-
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
9
7
|
skipFormat?: boolean;
|
|
10
8
|
}
|
|
11
9
|
export declare function componentGenerator(host: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
@@ -12,15 +12,12 @@ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/a
|
|
|
12
12
|
async function componentGenerator(host, options) {
|
|
13
13
|
const { artifactName: name, directory, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
14
14
|
name: options.name,
|
|
15
|
-
|
|
16
|
-
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
15
|
+
path: options.path,
|
|
17
16
|
fileExtension: 'tsx',
|
|
18
17
|
});
|
|
19
18
|
const componentInstall = await (0, react_1.componentGenerator)(host, {
|
|
20
19
|
...options,
|
|
21
20
|
name,
|
|
22
|
-
nameAndDirectoryFormat: 'as-provided', // already determined the directory so use as is
|
|
23
|
-
directory,
|
|
24
21
|
classComponent: false,
|
|
25
22
|
routing: false,
|
|
26
23
|
skipFormat: true,
|
|
@@ -6,13 +6,19 @@
|
|
|
6
6
|
"description": "Create a React Component for Next.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
9
|
+
"path": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"description": "
|
|
11
|
+
"description": "Path where the component will be generated.",
|
|
12
12
|
"$default": {
|
|
13
13
|
"$source": "argv",
|
|
14
14
|
"index": 0
|
|
15
15
|
},
|
|
16
|
+
"x-prompt": "Where should the component be generated?",
|
|
17
|
+
"x-priority": "important"
|
|
18
|
+
},
|
|
19
|
+
"name": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "The name of the component.",
|
|
16
22
|
"x-prompt": "What name would you like to use for the component?",
|
|
17
23
|
"x-priority": "important"
|
|
18
24
|
},
|
|
@@ -62,17 +68,6 @@
|
|
|
62
68
|
"default": false,
|
|
63
69
|
"x-priority": "internal"
|
|
64
70
|
},
|
|
65
|
-
"directory": {
|
|
66
|
-
"type": "string",
|
|
67
|
-
"description": "The directory at which to create the component file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
|
|
68
|
-
"alias": "dir",
|
|
69
|
-
"x-priority": "important"
|
|
70
|
-
},
|
|
71
|
-
"nameAndDirectoryFormat": {
|
|
72
|
-
"description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
|
|
73
|
-
"type": "string",
|
|
74
|
-
"enum": ["as-provided", "derived"]
|
|
75
|
-
},
|
|
76
71
|
"export": {
|
|
77
72
|
"type": "boolean",
|
|
78
73
|
"description": "When true, the component is exported from the project index.ts (if it exists).",
|
|
@@ -91,6 +86,6 @@
|
|
|
91
86
|
"x-priority": "internal"
|
|
92
87
|
}
|
|
93
88
|
},
|
|
94
|
-
"required": ["
|
|
89
|
+
"required": ["path"],
|
|
95
90
|
"examplesFile": "../../../docs/component-examples.md"
|
|
96
91
|
}
|
|
@@ -4,6 +4,7 @@ exports.nextInitGenerator = nextInitGenerator;
|
|
|
4
4
|
exports.nextInitGeneratorInternal = nextInitGeneratorInternal;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
8
|
const versions_1 = require("@nx/react/src/utils/versions");
|
|
8
9
|
const add_gitignore_entry_1 = require("../../utils/add-gitignore-entry");
|
|
9
10
|
const versions_2 = require("../../utils/versions");
|
|
@@ -23,6 +24,7 @@ function nextInitGenerator(tree, schema) {
|
|
|
23
24
|
return nextInitGeneratorInternal(tree, { addPlugin: false, ...schema });
|
|
24
25
|
}
|
|
25
26
|
async function nextInitGeneratorInternal(host, schema) {
|
|
27
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'next', 'init');
|
|
26
28
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
27
29
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
28
30
|
nxJson.useInferencePlugins !== false;
|
|
@@ -4,14 +4,13 @@ exports.normalizeOptions = normalizeOptions;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
6
|
async function normalizeOptions(host, options) {
|
|
7
|
-
|
|
7
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
|
|
8
|
+
const { projectRoot, importPath } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
8
9
|
name: options.name,
|
|
9
10
|
projectType: 'library',
|
|
10
11
|
directory: options.directory,
|
|
11
12
|
importPath: options.importPath,
|
|
12
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
13
13
|
});
|
|
14
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
15
14
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
15
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
16
|
nxJson.useInferencePlugins !== false;
|
|
@@ -5,6 +5,7 @@ exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const library_1 = require("@nx/react/src/generators/library/library");
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
9
|
const versions_1 = require("@nx/react/src/utils/versions");
|
|
9
10
|
const init_1 = require("../init/init");
|
|
10
11
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
@@ -16,6 +17,7 @@ async function libraryGenerator(host, rawOptions) {
|
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
async function libraryGeneratorInternal(host, rawOptions) {
|
|
20
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'next', 'library');
|
|
19
21
|
const options = await (0, normalize_options_1.normalizeOptions)(host, rawOptions);
|
|
20
22
|
const tasks = [];
|
|
21
23
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
|
3
2
|
import type { SupportedStyles } from '@nx/react';
|
|
4
3
|
|
|
5
4
|
export interface Schema {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
5
|
+
directory: string;
|
|
6
|
+
name?: string;
|
|
9
7
|
style: SupportedStyles;
|
|
10
8
|
skipTsConfig?: boolean;
|
|
11
9
|
skipFormat?: boolean;
|
|
@@ -6,28 +6,22 @@
|
|
|
6
6
|
"description": "Create a React Library for an Nx workspace.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
9
|
+
"directory": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"description": "
|
|
11
|
+
"description": "A directory where the lib is placed.",
|
|
12
|
+
"alias": "dir",
|
|
12
13
|
"$default": {
|
|
13
14
|
"$source": "argv",
|
|
14
15
|
"index": 0
|
|
15
16
|
},
|
|
16
|
-
"x-prompt": "
|
|
17
|
-
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
|
|
18
|
-
"x-priority": "important"
|
|
17
|
+
"x-prompt": "Which directory do you want to create the library in?"
|
|
19
18
|
},
|
|
20
|
-
"
|
|
19
|
+
"name": {
|
|
21
20
|
"type": "string",
|
|
22
|
-
"description": "
|
|
23
|
-
"
|
|
21
|
+
"description": "Library name",
|
|
22
|
+
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
|
|
24
23
|
"x-priority": "important"
|
|
25
24
|
},
|
|
26
|
-
"projectNameAndRootFormat": {
|
|
27
|
-
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
28
|
-
"type": "string",
|
|
29
|
-
"enum": ["as-provided", "derived"]
|
|
30
|
-
},
|
|
31
25
|
"style": {
|
|
32
26
|
"description": "The file extension to be used for style files.",
|
|
33
27
|
"type": "string",
|
|
@@ -37,7 +31,10 @@
|
|
|
37
31
|
"message": "Which stylesheet format would you like to use?",
|
|
38
32
|
"type": "list",
|
|
39
33
|
"items": [
|
|
40
|
-
{
|
|
34
|
+
{
|
|
35
|
+
"value": "css",
|
|
36
|
+
"label": "CSS"
|
|
37
|
+
},
|
|
41
38
|
{
|
|
42
39
|
"value": "scss",
|
|
43
40
|
"label": "SASS(.scss) [ https://sass-lang.com ]"
|
|
@@ -73,8 +70,9 @@
|
|
|
73
70
|
},
|
|
74
71
|
"unitTestRunner": {
|
|
75
72
|
"type": "string",
|
|
76
|
-
"enum": ["
|
|
77
|
-
"description": "Test runner to use for unit tests."
|
|
73
|
+
"enum": ["vitest", "jest", "none"],
|
|
74
|
+
"description": "Test runner to use for unit tests.",
|
|
75
|
+
"default": "vitest"
|
|
78
76
|
},
|
|
79
77
|
"tags": {
|
|
80
78
|
"type": "string",
|
|
@@ -145,6 +143,6 @@
|
|
|
145
143
|
"x-priority": "internal"
|
|
146
144
|
}
|
|
147
145
|
},
|
|
148
|
-
"required": ["
|
|
146
|
+
"required": ["directory"],
|
|
149
147
|
"examplesFile": "../../../docs/library-examples.md"
|
|
150
148
|
}
|
|
@@ -15,7 +15,6 @@ async function pageGenerator(host, schema) {
|
|
|
15
15
|
const componentTask = await (0, react_1.componentGenerator)(host, {
|
|
16
16
|
...options,
|
|
17
17
|
isNextPage: true,
|
|
18
|
-
nameAndDirectoryFormat: 'as-provided', // already determined the directory so use as is
|
|
19
18
|
export: false,
|
|
20
19
|
classComponent: false,
|
|
21
20
|
routing: false,
|
|
@@ -36,22 +35,20 @@ async function normalizeOptions(host, options) {
|
|
|
36
35
|
// Get the project name first so we can determine the router directory
|
|
37
36
|
const { project: determinedProjectName } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
38
37
|
name: options.name,
|
|
39
|
-
|
|
38
|
+
path: options.path,
|
|
40
39
|
});
|
|
41
40
|
const project = (0, devkit_1.readProjectConfiguration)(host, determinedProjectName);
|
|
42
41
|
// app/ is a reserved folder in nextjs so it is safe to check it's existence
|
|
43
42
|
const isAppRouter = host.exists(`${project.root}/app`) ||
|
|
44
43
|
host.exists(`${project.root}/src/app`);
|
|
45
|
-
const { project: projectName, fileName
|
|
44
|
+
const { project: projectName, fileName } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
46
45
|
name: options.name,
|
|
47
46
|
fileName: isAppRouter ? 'page' : 'index',
|
|
48
|
-
|
|
49
|
-
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
47
|
+
path: options.path,
|
|
50
48
|
fileExtension: 'tsx',
|
|
51
49
|
});
|
|
52
50
|
return {
|
|
53
51
|
...options,
|
|
54
|
-
directory,
|
|
55
52
|
fileName,
|
|
56
53
|
projectName,
|
|
57
54
|
};
|
|
@@ -2,12 +2,11 @@ import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-
|
|
|
2
2
|
import { SupportedStyles } from '@nx/react';
|
|
3
3
|
|
|
4
4
|
export interface Schema {
|
|
5
|
-
|
|
5
|
+
path: string;
|
|
6
|
+
name?: string;
|
|
6
7
|
style: SupportedStyles;
|
|
7
|
-
directory?: string;
|
|
8
8
|
fileName?: string;
|
|
9
9
|
withTests?: boolean;
|
|
10
10
|
js?: boolean;
|
|
11
11
|
skipFormat?: boolean;
|
|
12
|
-
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
13
12
|
}
|
|
@@ -6,36 +6,22 @@
|
|
|
6
6
|
"description": "Create a Page for Next.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
9
|
+
"path": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"description": "
|
|
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
|
-
"name": {
|
|
19
|
-
"type": "string",
|
|
20
|
-
"description": "The name of the component.",
|
|
11
|
+
"description": "Path where the page will be generated.",
|
|
21
12
|
"$default": {
|
|
22
13
|
"$source": "argv",
|
|
23
14
|
"index": 0
|
|
24
15
|
},
|
|
25
|
-
"x-prompt": "
|
|
16
|
+
"x-prompt": "Where should the page be generated?",
|
|
26
17
|
"x-priority": "important"
|
|
27
18
|
},
|
|
28
|
-
"
|
|
19
|
+
"name": {
|
|
29
20
|
"type": "string",
|
|
30
|
-
"description": "The
|
|
31
|
-
"
|
|
21
|
+
"description": "The name of the page.",
|
|
22
|
+
"x-prompt": "What name would you like to use for the page?",
|
|
32
23
|
"x-priority": "important"
|
|
33
24
|
},
|
|
34
|
-
"nameAndDirectoryFormat": {
|
|
35
|
-
"description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
|
|
36
|
-
"type": "string",
|
|
37
|
-
"enum": ["as-provided", "derived"]
|
|
38
|
-
},
|
|
39
25
|
"style": {
|
|
40
26
|
"description": "The file extension to be used for style files.",
|
|
41
27
|
"type": "string",
|
|
@@ -106,6 +92,6 @@
|
|
|
106
92
|
"x-priority": "internal"
|
|
107
93
|
}
|
|
108
94
|
},
|
|
109
|
-
"required": ["
|
|
95
|
+
"required": ["path"],
|
|
110
96
|
"examplesFile": "../../../docs/page-examples.md"
|
|
111
97
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = replacePackage;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
-
async function replacePackage(tree) {
|
|
7
|
-
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/next', '@nx/next');
|
|
8
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
9
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = update;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
async function update(tree) {
|
|
7
|
-
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/next:build', (options, projectName, targetName) => {
|
|
8
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
9
|
-
delete projectConfig.targets[targetName].options.root;
|
|
10
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
11
|
-
});
|
|
12
|
-
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/next:build', (options, projectName, targetName) => {
|
|
13
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
14
|
-
delete projectConfig.targets[targetName].options.root;
|
|
15
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = update;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
async function update(tree) {
|
|
6
|
-
if (tree.exists('./package.json')) {
|
|
7
|
-
(0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
|
|
8
|
-
if (packageJson.dependencies['@nx/next']) {
|
|
9
|
-
packageJson.devDependencies['@nx/next'] =
|
|
10
|
-
packageJson.dependencies['@nx/next'];
|
|
11
|
-
delete packageJson.dependencies['@nx/next'];
|
|
12
|
-
}
|
|
13
|
-
return packageJson;
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
17
|
-
}
|