@nx/next 17.0.3 → 17.0.4
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/LICENSE +1 -1
- package/README.md +9 -4
- package/generators.json +2 -2
- package/migrations.json +24 -0
- package/package.json +12 -10
- package/plugin.d.ts +1 -0
- package/plugin.js +5 -0
- package/plugins/component-testing.d.ts +1 -11
- package/plugins/component-testing.js +26 -10
- package/plugins/with-nx.d.ts +1 -1
- package/plugins/with-nx.js +68 -86
- package/plugins/with-stylus.js +1 -1
- package/src/executors/build/build.impl.js +20 -9
- package/src/executors/build/lib/create-next-config-file.js +5 -2
- package/src/executors/build/lib/test-fixtures/ensure-exts/baz.json +1 -0
- package/src/executors/build/lib/update-package-json.js +10 -1
- package/src/executors/build/schema.json +1 -1
- package/src/executors/export/export.impl.js +9 -9
- package/src/executors/server/custom-server.impl.js +3 -2
- package/src/executors/server/schema.json +4 -0
- package/src/executors/server/server.impl.js +13 -11
- package/src/generators/application/application.js +24 -0
- package/src/generators/application/files/app/page.tsx__tmpl__ +1 -1
- package/src/generators/application/files/common/specs/__fileName__.spec.tsx__tmpl__ +10 -3
- package/src/generators/application/files/common/tsconfig.json__tmpl__ +5 -5
- package/src/generators/application/files/pages/__fileName__.tsx__tmpl__ +1 -1
- package/src/generators/application/lib/add-e2e.js +27 -3
- package/src/generators/application/lib/add-linting.js +13 -16
- package/src/generators/application/lib/add-plugin.d.ts +2 -0
- package/src/generators/application/lib/add-plugin.js +25 -0
- package/src/generators/application/lib/add-project.js +43 -33
- package/src/generators/application/lib/create-application-files.helpers.js +67 -5
- package/src/generators/application/lib/create-application-files.js +23 -11
- package/src/generators/application/lib/normalize-options.d.ts +3 -0
- package/src/generators/application/lib/normalize-options.js +31 -0
- package/src/generators/application/schema.d.ts +2 -0
- package/src/generators/application/schema.json +9 -3
- package/src/generators/component/component.d.ts +4 -4
- package/src/generators/component/component.js +3 -2
- package/src/generators/component/schema.json +7 -7
- package/src/generators/custom-server/custom-server.d.ts +1 -1
- package/src/generators/custom-server/custom-server.js +34 -9
- package/src/generators/custom-server/files/server/main.ts__tmpl__ +4 -4
- package/src/generators/custom-server/files/tsconfig.server.json__tmpl__ +2 -0
- package/src/generators/custom-server/schema.json +1 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +1 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +23 -10
- package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
- package/src/generators/cypress-component-configuration/schema.json +1 -1
- package/src/generators/init/init.d.ts +4 -3
- package/src/generators/init/init.js +30 -44
- package/src/generators/init/lib/add-plugin.d.ts +2 -0
- package/src/generators/init/lib/add-plugin.js +26 -0
- package/src/generators/init/schema.d.ts +3 -4
- package/src/generators/init/schema.json +11 -23
- package/src/generators/library/lib/normalize-options.js +5 -0
- package/src/generators/library/library.js +19 -1
- package/src/generators/library/schema.d.ts +2 -1
- package/src/generators/library/schema.json +3 -3
- package/src/generators/page/page.js +21 -4
- package/src/generators/page/schema.d.ts +3 -3
- package/src/generators/page/schema.json +5 -5
- package/src/migrations/update-17-2-7/remove-eslint-rules-patch.d.ts +2 -0
- package/src/migrations/update-17-2-7/remove-eslint-rules-patch.js +15 -0
- package/src/plugins/plugin.d.ts +11 -0
- package/src/plugins/plugin.js +184 -0
- package/src/utils/add-gitignore-entry.js +1 -1
- package/src/utils/add-swc-to-custom-server.d.ts +2 -0
- package/src/utils/add-swc-to-custom-server.js +37 -0
- package/src/utils/styles.d.ts +4 -4
- package/src/utils/types.d.ts +1 -0
- package/src/utils/versions.d.ts +6 -2
- package/src/utils/versions.js +7 -3
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const devkit_1 = require("@nx/devkit");
|
|
4
4
|
const export_1 = require("next/dist/export");
|
|
5
|
-
const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
6
5
|
const nextTrace = require("next/dist/trace");
|
|
7
6
|
const os_1 = require("os");
|
|
8
7
|
const child_process_1 = require("child_process");
|
|
9
8
|
const chalk = require("chalk");
|
|
9
|
+
const semver_1 = require("semver");
|
|
10
10
|
// platform specific command name
|
|
11
11
|
const pmCmd = (0, os_1.platform)() === 'win32' ? `npx.cmd` : 'npx';
|
|
12
12
|
/**
|
|
@@ -22,15 +22,15 @@ const pmCmd = (0, os_1.platform)() === 'win32' ? `npx.cmd` : 'npx';
|
|
|
22
22
|
* Read https://nextjs.org/docs/pages/building-your-application/deploying/static-exports
|
|
23
23
|
**/
|
|
24
24
|
async function exportExecutor(options, context) {
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
context.configurationName);
|
|
29
|
-
dependencies = result.dependencies;
|
|
25
|
+
const nextJsVersion = require('next/package.json').version;
|
|
26
|
+
if ((0, semver_1.satisfies)(nextJsVersion, '>=14.0.0')) {
|
|
27
|
+
throw new Error('The export command has been removed in Next.js 14. Please update your Next config to use the output property. Read more: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports');
|
|
30
28
|
}
|
|
29
|
+
// Returns { project: ProjectGraphNode; target: string; configuration?: string;}
|
|
31
30
|
const buildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context);
|
|
32
31
|
try {
|
|
33
|
-
const
|
|
32
|
+
const buildTargetName = (0, devkit_1.targetToTargetString)(buildTarget);
|
|
33
|
+
const args = getBuildTargetCommand(buildTargetName);
|
|
34
34
|
(0, child_process_1.execFileSync)(pmCmd, args, {
|
|
35
35
|
stdio: [0, 1, 2],
|
|
36
36
|
});
|
|
@@ -52,7 +52,7 @@ async function exportExecutor(options, context) {
|
|
|
52
52
|
return { success: true };
|
|
53
53
|
}
|
|
54
54
|
exports.default = exportExecutor;
|
|
55
|
-
function getBuildTargetCommand(
|
|
56
|
-
const cmd = ['nx', 'run',
|
|
55
|
+
function getBuildTargetCommand(buildTarget) {
|
|
56
|
+
const cmd = ['nx', 'run', buildTarget];
|
|
57
57
|
return cmd;
|
|
58
58
|
}
|
|
@@ -10,13 +10,14 @@ async function* serveExecutor(options, context) {
|
|
|
10
10
|
? 'development'
|
|
11
11
|
: 'production';
|
|
12
12
|
// Setting port that the custom server should use.
|
|
13
|
-
process.env.PORT = options.port;
|
|
13
|
+
process.env.PORT = options.port ? `${options.port}` : process.env.PORT;
|
|
14
|
+
options.port = parseInt(process.env.PORT);
|
|
14
15
|
const projectRoot = context.projectGraph.nodes[context.projectName].data.root;
|
|
15
16
|
yield* runCustomServer(projectRoot, options, context);
|
|
16
17
|
}
|
|
17
18
|
exports.default = serveExecutor;
|
|
18
19
|
async function* runCustomServer(root, options, context) {
|
|
19
|
-
process.env.NX_NEXT_DIR
|
|
20
|
+
process.env.NX_NEXT_DIR ??= root;
|
|
20
21
|
process.env.NX_NEXT_PUBLIC_DIR = (0, path_1.join)(root, 'public');
|
|
21
22
|
const baseUrl = `http://${options.hostname || 'localhost'}:${options.port}`;
|
|
22
23
|
const customServerBuild = await (0, devkit_1.runExecutor)((0, devkit_1.parseTargetString)(options.customServerTarget, context), {
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
"turbo": {
|
|
53
53
|
"type": "boolean",
|
|
54
54
|
"description": "Activate the incremental bundler for Next.js, which is implemented in Rust. Please note, this feature is exclusively available in development mode."
|
|
55
|
+
},
|
|
56
|
+
"experimentalHttps": {
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"description": "Enable HTTPS support for the Next.js development server."
|
|
55
59
|
}
|
|
56
60
|
},
|
|
57
61
|
"required": ["buildTarget"],
|
|
@@ -8,14 +8,15 @@ const create_cli_options_1 = require("../../utils/create-cli-options");
|
|
|
8
8
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
9
9
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
10
10
|
async function* serveExecutor(options, context) {
|
|
11
|
+
const buildOptions = (0, devkit_1.readTargetOptions)((0, devkit_1.parseTargetString)(options.buildTarget, context), context);
|
|
12
|
+
const projectRoot = context.workspace.projects[context.projectName].root;
|
|
13
|
+
// This is required for the default custom server to work. See the @nx/next:app generator.
|
|
14
|
+
const nextDir = !options.dev && (0, path_1.resolve)(context.root, buildOptions.outputPath);
|
|
15
|
+
process.env.NX_NEXT_DIR ??= options.dev ? projectRoot : nextDir;
|
|
11
16
|
if (options.customServerTarget) {
|
|
12
17
|
return yield* (0, custom_server_impl_1.default)(options, context);
|
|
13
18
|
}
|
|
14
|
-
const
|
|
15
|
-
const projectRoot = context.workspace.projects[context.projectName].root;
|
|
16
|
-
const { port, keepAliveTimeout, hostname } = options;
|
|
17
|
-
// This is required for the default custom server to work. See the @nx/next:app generator.
|
|
18
|
-
process.env.NX_NEXT_DIR = projectRoot;
|
|
19
|
+
const { keepAliveTimeout, hostname } = options;
|
|
19
20
|
// Cast to any to overwrite NODE_ENV
|
|
20
21
|
process.env.NODE_ENV = process.env.NODE_ENV
|
|
21
22
|
? process.env.NODE_ENV
|
|
@@ -23,17 +24,18 @@ async function* serveExecutor(options, context) {
|
|
|
23
24
|
? 'development'
|
|
24
25
|
: 'production';
|
|
25
26
|
// Setting port that the custom server should use.
|
|
26
|
-
process.env.PORT = `${options.port}
|
|
27
|
-
|
|
27
|
+
process.env.PORT = options.port ? `${options.port}` : process.env.PORT;
|
|
28
|
+
options.port = parseInt(process.env.PORT);
|
|
29
|
+
const args = (0, create_cli_options_1.createCliOptions)({ port: options.port, hostname });
|
|
28
30
|
if (keepAliveTimeout && !options.dev) {
|
|
29
31
|
args.push(`--keepAliveTimeout=${keepAliveTimeout}`);
|
|
30
32
|
}
|
|
31
|
-
const nextDir = (0, path_1.resolve)(context.root, buildOptions.outputPath);
|
|
32
33
|
const mode = options.dev ? 'dev' : 'start';
|
|
33
34
|
const turbo = options.turbo && options.dev ? '--turbo' : '';
|
|
35
|
+
const experimentalHttps = options.experimentalHttps && options.dev ? '--experimental-https' : '';
|
|
34
36
|
const nextBin = require.resolve('next/dist/bin/next');
|
|
35
37
|
yield* (0, async_iterable_1.createAsyncIterable)(async ({ done, next, error }) => {
|
|
36
|
-
const server = (0, child_process_1.fork)(nextBin, [mode, ...args, turbo], {
|
|
38
|
+
const server = (0, child_process_1.fork)(nextBin, [mode, ...args, turbo, experimentalHttps], {
|
|
37
39
|
cwd: options.dev ? projectRoot : nextDir,
|
|
38
40
|
stdio: 'inherit',
|
|
39
41
|
});
|
|
@@ -54,10 +56,10 @@ async function* serveExecutor(options, context) {
|
|
|
54
56
|
process.on('SIGINT', () => killServer());
|
|
55
57
|
process.on('SIGTERM', () => killServer());
|
|
56
58
|
process.on('SIGHUP', () => killServer());
|
|
57
|
-
await (0, wait_for_port_open_1.waitForPortOpen)(port, { host: options.hostname });
|
|
59
|
+
await (0, wait_for_port_open_1.waitForPortOpen)(options.port, { host: options.hostname });
|
|
58
60
|
next({
|
|
59
61
|
success: true,
|
|
60
|
-
baseUrl: `http://${options.hostname ?? 'localhost'}:${port}`,
|
|
62
|
+
baseUrl: `http://${options.hostname ?? 'localhost'}:${options.port}`,
|
|
61
63
|
});
|
|
62
64
|
});
|
|
63
65
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const js_1 = require("@nx/js");
|
|
6
|
+
const versions_1 = require("@nx/react/src/utils/versions");
|
|
5
7
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
6
8
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
7
9
|
const add_jest_1 = require("./lib/add-jest");
|
|
@@ -15,8 +17,11 @@ const add_linting_1 = require("./lib/add-linting");
|
|
|
15
17
|
const custom_server_1 = require("../custom-server/custom-server");
|
|
16
18
|
const update_cypress_tsconfig_1 = require("./lib/update-cypress-tsconfig");
|
|
17
19
|
const show_possible_warnings_1 = require("./lib/show-possible-warnings");
|
|
20
|
+
const versions_2 = require("../../utils/versions");
|
|
21
|
+
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
18
22
|
async function applicationGenerator(host, schema) {
|
|
19
23
|
return await applicationGeneratorInternal(host, {
|
|
24
|
+
addPlugin: false,
|
|
20
25
|
projectNameAndRootFormat: 'derived',
|
|
21
26
|
...schema,
|
|
22
27
|
});
|
|
@@ -26,6 +31,12 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
26
31
|
const tasks = [];
|
|
27
32
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
28
33
|
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
|
34
|
+
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
35
|
+
js: options.js,
|
|
36
|
+
skipPackageJson: options.skipPackageJson,
|
|
37
|
+
skipFormat: true,
|
|
38
|
+
});
|
|
39
|
+
tasks.push(jsInitTask);
|
|
29
40
|
const nextTask = await (0, init_1.nextInitGenerator)(host, {
|
|
30
41
|
...options,
|
|
31
42
|
skipFormat: true,
|
|
@@ -53,9 +64,22 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
53
64
|
compiler: options.swc ? 'swc' : 'tsc',
|
|
54
65
|
});
|
|
55
66
|
}
|
|
67
|
+
if (!options.skipPackageJson) {
|
|
68
|
+
const devDependencies = {
|
|
69
|
+
'@types/react': versions_1.typesReactVersion,
|
|
70
|
+
'@types/react-dom': versions_1.typesReactDomVersion,
|
|
71
|
+
};
|
|
72
|
+
if (schema.unitTestRunner && schema.unitTestRunner !== 'none') {
|
|
73
|
+
devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
|
|
74
|
+
}
|
|
75
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, devDependencies));
|
|
76
|
+
}
|
|
56
77
|
if (!options.skipFormat) {
|
|
57
78
|
await (0, devkit_1.formatFiles)(host);
|
|
58
79
|
}
|
|
80
|
+
tasks.push(() => {
|
|
81
|
+
(0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
|
|
82
|
+
});
|
|
59
83
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
60
84
|
}
|
|
61
85
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
|
-
|
|
3
|
+
<% if (src && !appDir) { %>
|
|
4
|
+
import Index from '../src/pages/index';
|
|
5
|
+
<% } else if (!appDir) { %>
|
|
4
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
|
+
<% } %>
|
|
5
12
|
|
|
6
|
-
describe('Index'
|
|
13
|
+
describe(<%- appDir ? `'Page'` : `'Index'` %>, () => {
|
|
7
14
|
it('should render successfully', () => {
|
|
8
|
-
const { baseElement } = render(
|
|
15
|
+
const { baseElement } = render(<%- appDir ? `<Page />` : `<Index />` %>);
|
|
9
16
|
expect(baseElement).toBeTruthy();
|
|
10
17
|
});
|
|
11
18
|
});
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"plugins": [{ "name": "next" }]
|
|
16
16
|
},
|
|
17
17
|
"include": [
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
18
|
+
"<%= rootPath %>**/*.ts",
|
|
19
|
+
"<%= rootPath %>**/*.tsx",
|
|
20
|
+
"<%= rootPath %>**/*.js",
|
|
21
|
+
"<%= rootPath %>**/*.jsx",
|
|
22
22
|
<% if (appDir) { %>
|
|
23
23
|
"<%= layoutTypeSrcPath %>",
|
|
24
24
|
"<%= layoutTypeDistPath %>",
|
|
25
25
|
<% } %>
|
|
26
26
|
"next-env.d.ts"
|
|
27
27
|
],
|
|
28
|
-
"exclude": ["node_modules", "jest.config.ts", "
|
|
28
|
+
"exclude": ["node_modules", "jest.config.ts", "<%= rootPath %>**/*.spec.ts", "<%= rootPath %>**/*.test.ts"]
|
|
29
29
|
}
|
|
@@ -4,9 +4,22 @@ exports.addE2e = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const eslint_1 = require("@nx/eslint");
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
|
7
|
+
const web_1 = require("@nx/web");
|
|
7
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');
|
|
8
13
|
if (options.e2eTestRunner === 'cypress') {
|
|
9
14
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
15
|
+
if (!hasPlugin) {
|
|
16
|
+
await (0, web_1.webStaticServeGenerator)(host, {
|
|
17
|
+
buildTarget: `${options.projectName}:build`,
|
|
18
|
+
outputPath: `${options.outputPath}/out`,
|
|
19
|
+
targetName: 'serve-static',
|
|
20
|
+
spa: true,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
10
23
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
11
24
|
root: options.e2eProjectRoot,
|
|
12
25
|
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
@@ -20,8 +33,17 @@ async function addE2e(host, options) {
|
|
|
20
33
|
project: options.e2eProjectName,
|
|
21
34
|
directory: 'src',
|
|
22
35
|
skipFormat: true,
|
|
23
|
-
devServerTarget: `${options.projectName}
|
|
36
|
+
devServerTarget: `${options.projectName}:${options.e2eWebServerTarget}`,
|
|
37
|
+
baseUrl: options.e2eWebServerAddress,
|
|
24
38
|
jsx: true,
|
|
39
|
+
webServerCommands: hasPlugin
|
|
40
|
+
? {
|
|
41
|
+
default: `nx run ${options.projectName}:${options.e2eWebServerTarget}`,
|
|
42
|
+
}
|
|
43
|
+
: undefined,
|
|
44
|
+
ciWebServerCommand: hasPlugin
|
|
45
|
+
? `nx run ${options.projectName}:serve-static`
|
|
46
|
+
: undefined,
|
|
25
47
|
});
|
|
26
48
|
}
|
|
27
49
|
else if (options.e2eTestRunner === 'playwright') {
|
|
@@ -33,6 +55,7 @@ async function addE2e(host, options) {
|
|
|
33
55
|
implicitDependencies: [options.projectName],
|
|
34
56
|
});
|
|
35
57
|
return configurationGenerator(host, {
|
|
58
|
+
rootProject: options.rootProject,
|
|
36
59
|
project: options.e2eProjectName,
|
|
37
60
|
skipFormat: true,
|
|
38
61
|
skipPackageJson: options.skipPackageJson,
|
|
@@ -40,8 +63,9 @@ async function addE2e(host, options) {
|
|
|
40
63
|
js: false,
|
|
41
64
|
linter: options.linter,
|
|
42
65
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
43
|
-
webServerAddress:
|
|
44
|
-
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx
|
|
66
|
+
webServerAddress: `http://127.0.0.1:${options.e2ePort}`,
|
|
67
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${options.e2eWebServerTarget} ${options.projectName}`,
|
|
68
|
+
addPlugin: options.addPlugin,
|
|
45
69
|
});
|
|
46
70
|
}
|
|
47
71
|
return () => { };
|
|
@@ -5,35 +5,27 @@ const eslint_1 = require("@nx/eslint");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const lint_1 = require("@nx/react/src/utils/lint");
|
|
7
7
|
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
8
|
-
const
|
|
8
|
+
const versions_1 = require("../../../utils/versions");
|
|
9
9
|
async function addLinting(host, options) {
|
|
10
|
-
const
|
|
10
|
+
const tasks = [];
|
|
11
|
+
tasks.push(await (0, eslint_1.lintProjectGenerator)(host, {
|
|
11
12
|
linter: options.linter,
|
|
12
13
|
project: options.projectName,
|
|
13
14
|
tsConfigPaths: [
|
|
14
15
|
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
15
16
|
],
|
|
16
17
|
unitTestRunner: options.unitTestRunner,
|
|
17
|
-
eslintFilePatterns: [
|
|
18
|
-
(0, lint_project_1.mapLintPattern)(options.appProjectRoot, '{ts,tsx,js,jsx}', options.rootProject),
|
|
19
|
-
],
|
|
20
18
|
skipFormat: true,
|
|
21
19
|
rootProject: options.rootProject,
|
|
22
|
-
|
|
20
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
21
|
+
addPlugin: options.addPlugin,
|
|
22
|
+
}));
|
|
23
23
|
if (options.linter === eslint_1.Linter.EsLint && (0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
24
24
|
(0, eslint_file_1.addExtendsToLintConfig)(host, options.appProjectRoot, [
|
|
25
25
|
'plugin:@nx/react-typescript',
|
|
26
26
|
'next',
|
|
27
27
|
'next/core-web-vitals',
|
|
28
28
|
]);
|
|
29
|
-
// Turn off @next/next/no-html-link-for-pages since there is an issue with nextjs throwing linting errors
|
|
30
|
-
// TODO(nicholas): remove after Vercel updates nextjs linter to only lint ["*.ts", "*.tsx", "*.js", "*.jsx"]
|
|
31
|
-
(0, eslint_file_1.addOverrideToLintConfig)(host, options.appProjectRoot, {
|
|
32
|
-
files: ['*.*'],
|
|
33
|
-
rules: {
|
|
34
|
-
'@next/next/no-html-link-for-pages': 'off',
|
|
35
|
-
},
|
|
36
|
-
}, { insertAtTheEnd: false });
|
|
37
29
|
(0, eslint_file_1.updateOverrideInLintConfig)(host, options.appProjectRoot, (o) => Array.isArray(o.files) &&
|
|
38
30
|
o.files.some((f) => f.match(/\*\.ts$/)) &&
|
|
39
31
|
o.files.some((f) => f.match(/\*\.tsx$/)) &&
|
|
@@ -59,7 +51,12 @@ async function addLinting(host, options) {
|
|
|
59
51
|
}
|
|
60
52
|
(0, eslint_file_1.addIgnoresToLintConfig)(host, options.appProjectRoot, ['.next/**/*']);
|
|
61
53
|
}
|
|
62
|
-
|
|
63
|
-
|
|
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);
|
|
64
61
|
}
|
|
65
62
|
exports.addLinting = addLinting;
|
|
@@ -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;
|
|
@@ -2,46 +2,56 @@
|
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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,
|
|
17
22
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
buildTarget: `${options.projectName}:build:development`,
|
|
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`,
|
|
31
35
|
dev: true,
|
|
32
36
|
},
|
|
33
|
-
|
|
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: {
|
|
34
51
|
buildTarget: `${options.projectName}:build:production`,
|
|
35
|
-
dev: false,
|
|
36
52
|
},
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
targets.export = {
|
|
40
|
-
executor: '@nx/next:export',
|
|
41
|
-
options: {
|
|
42
|
-
buildTarget: `${options.projectName}:build:production`,
|
|
43
|
-
},
|
|
44
|
-
};
|
|
53
|
+
};
|
|
54
|
+
}
|
|
45
55
|
const project = {
|
|
46
56
|
root: options.appProjectRoot,
|
|
47
57
|
sourceRoot: options.appProjectRoot,
|
|
@@ -249,10 +249,44 @@ function createAppJsx(name) {
|
|
|
249
249
|
<path d="M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z" />
|
|
250
250
|
</svg>
|
|
251
251
|
<span>
|
|
252
|
-
Install Nx Console
|
|
253
|
-
<span>
|
|
252
|
+
Install Nx Console for VSCode
|
|
253
|
+
<span>The official VSCode extension for Nx.</span>
|
|
254
254
|
</span>
|
|
255
255
|
</a>
|
|
256
|
+
<a
|
|
257
|
+
id="nx-console-jetbrains"
|
|
258
|
+
className="button-pill rounded shadow"
|
|
259
|
+
href="https://plugins.jetbrains.com/plugin/21060-nx-console"
|
|
260
|
+
target="_blank"
|
|
261
|
+
rel="noreferrer"
|
|
262
|
+
>
|
|
263
|
+
<svg
|
|
264
|
+
height="48"
|
|
265
|
+
width="48"
|
|
266
|
+
viewBox="20 20 60 60"
|
|
267
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
268
|
+
>
|
|
269
|
+
<path d="m22.5 22.5h60v60h-60z" />
|
|
270
|
+
<g fill="#fff">
|
|
271
|
+
<path d="m29.03 71.25h22.5v3.75h-22.5z" />
|
|
272
|
+
<path d="m28.09 38 1.67-1.58a1.88 1.88 0 0 0 1.47.87c.64 0 1.06-.44 1.06-1.31v-5.98h2.58v6a3.48 3.48 0 0 1 -.87 2.6 3.56 3.56 0 0 1 -2.57.95 3.84 3.84 0 0 1 -3.34-1.55z" />
|
|
273
|
+
<path d="m36 30h7.53v2.19h-5v1.44h4.49v2h-4.42v1.49h5v2.21h-7.6z" />
|
|
274
|
+
<path d="m47.23 32.29h-2.8v-2.29h8.21v2.27h-2.81v7.1h-2.6z" />
|
|
275
|
+
<path d="m29.13 43.08h4.42a3.53 3.53 0 0 1 2.55.83 2.09 2.09 0 0 1 .6 1.53 2.16 2.16 0 0 1 -1.44 2.09 2.27 2.27 0 0 1 1.86 2.29c0 1.61-1.31 2.59-3.55 2.59h-4.44zm5 2.89c0-.52-.42-.8-1.18-.8h-1.29v1.64h1.24c.79 0 1.25-.26 1.25-.81zm-.9 2.66h-1.57v1.73h1.62c.8 0 1.24-.31 1.24-.86 0-.5-.4-.87-1.27-.87z" />
|
|
276
|
+
<path d="m38 43.08h4.1a4.19 4.19 0 0 1 3 1 2.93 2.93 0 0 1 .9 2.19 3 3 0 0 1 -1.93 2.89l2.24 3.27h-3l-1.88-2.84h-.87v2.84h-2.56zm4 4.5c.87 0 1.39-.43 1.39-1.11 0-.75-.54-1.12-1.4-1.12h-1.44v2.26z" />
|
|
277
|
+
<path d="m49.59 43h2.5l4 9.44h-2.79l-.67-1.69h-3.63l-.67 1.69h-2.71zm2.27 5.73-1-2.65-1.06 2.65z" />
|
|
278
|
+
<path d="m56.46 43.05h2.6v9.37h-2.6z" />
|
|
279
|
+
<path d="m60.06 43.05h2.42l3.37 5v-5h2.57v9.37h-2.26l-3.53-5.14v5.14h-2.57z" />
|
|
280
|
+
<path d="m68.86 51 1.45-1.73a4.84 4.84 0 0 0 3 1.13c.71 0 1.08-.24 1.08-.65 0-.4-.31-.6-1.59-.91-2-.46-3.53-1-3.53-2.93 0-1.74 1.37-3 3.62-3a5.89 5.89 0 0 1 3.86 1.25l-1.26 1.84a4.63 4.63 0 0 0 -2.62-.92c-.63 0-.94.25-.94.6 0 .42.32.61 1.63.91 2.14.46 3.44 1.16 3.44 2.91 0 1.91-1.51 3-3.79 3a6.58 6.58 0 0 1 -4.35-1.5z" />
|
|
281
|
+
</g>
|
|
282
|
+
</svg>
|
|
283
|
+
<span>
|
|
284
|
+
Install Nx Console for JetBrains
|
|
285
|
+
<span>
|
|
286
|
+
Available for WebStorm, Intellij IDEA Ultimate and more!
|
|
287
|
+
</span>
|
|
288
|
+
</span>
|
|
289
|
+
</a>
|
|
256
290
|
<div id="nx-cloud" className="rounded shadow">
|
|
257
291
|
<div>
|
|
258
292
|
<svg id="nx-cloud-logo" role="img" xmlns="http://www.w3.org/2000/svg" stroke="currentColor" fill="transparent" viewBox="0 0 24 24">
|
|
@@ -260,7 +294,7 @@ function createAppJsx(name) {
|
|
|
260
294
|
<path strokeWidth="2" d="M23 6v14.1667C23 21.7307 21.7307 23 20.1667 23H6c0-3.128 2.53867-5.6667 5.6667-5.6667 3.128 0 5.6666-2.5386 5.6666-5.6666C17.3333 8.53867 19.872 6 23 6Z" />
|
|
261
295
|
</svg>
|
|
262
296
|
<h2>
|
|
263
|
-
|
|
297
|
+
Nx Cloud
|
|
264
298
|
<span>
|
|
265
299
|
Enable faster CI & better DX
|
|
266
300
|
</span>
|
|
@@ -270,7 +304,7 @@ function createAppJsx(name) {
|
|
|
270
304
|
You can activate distributed tasks executions and caching by
|
|
271
305
|
running:
|
|
272
306
|
</p>
|
|
273
|
-
<pre>nx connect
|
|
307
|
+
<pre>nx connect</pre>
|
|
274
308
|
<a
|
|
275
309
|
href="https://nx.app/?utm_source=nx-project"
|
|
276
310
|
target="_blank"
|
|
@@ -327,9 +361,28 @@ function createAppJsx(name) {
|
|
|
327
361
|
<span># Generate UI lib</span>
|
|
328
362
|
nx g @nx/next:library ui
|
|
329
363
|
<span># Add a component</span>
|
|
330
|
-
nx g @nx/next:component button
|
|
364
|
+
nx g @nx/next:component ui/src/lib/button
|
|
331
365
|
</pre>
|
|
332
366
|
</details>
|
|
367
|
+
<details>
|
|
368
|
+
<summary>
|
|
369
|
+
<svg
|
|
370
|
+
fill="none"
|
|
371
|
+
stroke="currentColor"
|
|
372
|
+
viewBox="0 0 24 24"
|
|
373
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
374
|
+
>
|
|
375
|
+
<path
|
|
376
|
+
strokeLinecap="round"
|
|
377
|
+
strokeLinejoin="round"
|
|
378
|
+
strokeWidth="2"
|
|
379
|
+
d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
|
380
|
+
/>
|
|
381
|
+
</svg>
|
|
382
|
+
View project details
|
|
383
|
+
</summary>
|
|
384
|
+
<pre>nx show project ${name} --web</pre>
|
|
385
|
+
</details>
|
|
333
386
|
<details>
|
|
334
387
|
<summary>
|
|
335
388
|
<svg
|
|
@@ -650,6 +703,15 @@ function createStyleRules() {
|
|
|
650
703
|
#nx-console svg {
|
|
651
704
|
color: rgba(0, 122, 204, 1);
|
|
652
705
|
}
|
|
706
|
+
#nx-console-jetbrains {
|
|
707
|
+
margin-top: 2rem;
|
|
708
|
+
}
|
|
709
|
+
#nx-console-jetbrains:hover {
|
|
710
|
+
background-color: rgba(255, 49, 140, 1);
|
|
711
|
+
}
|
|
712
|
+
#nx-console-jetbrains svg {
|
|
713
|
+
color: rgba(255, 49, 140, 1);
|
|
714
|
+
}
|
|
653
715
|
#nx-repo:hover {
|
|
654
716
|
background-color: rgba(24, 23, 23, 1);
|
|
655
717
|
}
|