@nx/next 17.0.4 → 17.0.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/LICENSE +1 -1
- package/README.md +4 -9
- package/generators.json +2 -2
- package/migrations.json +0 -24
- package/package.json +10 -12
- package/plugins/component-testing.d.ts +11 -1
- package/plugins/component-testing.js +10 -26
- package/plugins/with-nx.d.ts +1 -1
- package/plugins/with-nx.js +86 -68
- package/plugins/with-stylus.js +1 -1
- package/src/executors/build/build.impl.js +9 -20
- package/src/executors/build/lib/create-next-config-file.js +2 -5
- package/src/executors/build/lib/test-fixtures/ensure-exts/baz.json +0 -1
- package/src/executors/build/lib/update-package-json.js +1 -10
- 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 +2 -3
- package/src/executors/server/schema.json +0 -4
- package/src/executors/server/server.impl.js +11 -13
- package/src/generators/application/application.js +0 -24
- package/src/generators/application/files/app/page.tsx__tmpl__ +1 -1
- package/src/generators/application/files/common/specs/__fileName__.spec.tsx__tmpl__ +3 -10
- 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 +3 -27
- package/src/generators/application/lib/add-linting.js +16 -13
- package/src/generators/application/lib/add-project.js +33 -43
- package/src/generators/application/lib/create-application-files.helpers.js +5 -67
- package/src/generators/application/lib/create-application-files.js +11 -23
- package/src/generators/application/lib/normalize-options.d.ts +0 -3
- package/src/generators/application/lib/normalize-options.js +0 -31
- package/src/generators/application/schema.d.ts +0 -2
- package/src/generators/application/schema.json +3 -9
- package/src/generators/component/component.d.ts +4 -4
- package/src/generators/component/component.js +2 -3
- 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 +9 -34
- package/src/generators/custom-server/files/server/main.ts__tmpl__ +4 -4
- package/src/generators/custom-server/files/tsconfig.server.json__tmpl__ +0 -2
- package/src/generators/custom-server/schema.json +1 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +0 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +10 -23
- package/src/generators/cypress-component-configuration/schema.d.ts +0 -1
- package/src/generators/cypress-component-configuration/schema.json +1 -1
- package/src/generators/init/init.d.ts +3 -4
- package/src/generators/init/init.js +44 -30
- package/src/generators/init/schema.d.ts +4 -3
- package/src/generators/init/schema.json +23 -11
- package/src/generators/library/lib/normalize-options.js +0 -5
- package/src/generators/library/library.js +1 -19
- package/src/generators/library/schema.d.ts +1 -2
- package/src/generators/library/schema.json +3 -3
- package/src/generators/page/page.js +4 -21
- package/src/generators/page/schema.d.ts +3 -3
- package/src/generators/page/schema.json +5 -5
- package/src/utils/add-gitignore-entry.js +1 -1
- package/src/utils/styles.d.ts +4 -4
- package/src/utils/types.d.ts +0 -1
- package/src/utils/versions.d.ts +2 -6
- package/src/utils/versions.js +3 -7
- package/plugin.d.ts +0 -1
- package/plugin.js +0 -5
- package/src/generators/application/lib/add-plugin.d.ts +0 -2
- package/src/generators/application/lib/add-plugin.js +0 -25
- package/src/generators/init/lib/add-plugin.d.ts +0 -2
- package/src/generators/init/lib/add-plugin.js +0 -26
- package/src/migrations/update-17-2-7/remove-eslint-rules-patch.d.ts +0 -2
- package/src/migrations/update-17-2-7/remove-eslint-rules-patch.js +0 -15
- package/src/plugins/plugin.d.ts +0 -11
- package/src/plugins/plugin.js +0 -184
- package/src/utils/add-swc-to-custom-server.d.ts +0 -2
- package/src/utils/add-swc-to-custom-server.js +0 -37
|
@@ -10,14 +10,13 @@ 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
|
|
14
|
-
options.port = parseInt(process.env.PORT);
|
|
13
|
+
process.env.PORT = options.port;
|
|
15
14
|
const projectRoot = context.projectGraph.nodes[context.projectName].data.root;
|
|
16
15
|
yield* runCustomServer(projectRoot, options, context);
|
|
17
16
|
}
|
|
18
17
|
exports.default = serveExecutor;
|
|
19
18
|
async function* runCustomServer(root, options, context) {
|
|
20
|
-
process.env.NX_NEXT_DIR
|
|
19
|
+
process.env.NX_NEXT_DIR = root;
|
|
21
20
|
process.env.NX_NEXT_PUBLIC_DIR = (0, path_1.join)(root, 'public');
|
|
22
21
|
const baseUrl = `http://${options.hostname || 'localhost'}:${options.port}`;
|
|
23
22
|
const customServerBuild = await (0, devkit_1.runExecutor)((0, devkit_1.parseTargetString)(options.customServerTarget, context), {
|
|
@@ -52,10 +52,6 @@
|
|
|
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."
|
|
59
55
|
}
|
|
60
56
|
},
|
|
61
57
|
"required": ["buildTarget"],
|
|
@@ -8,15 +8,14 @@ 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;
|
|
16
11
|
if (options.customServerTarget) {
|
|
17
12
|
return yield* (0, custom_server_impl_1.default)(options, context);
|
|
18
13
|
}
|
|
19
|
-
const
|
|
14
|
+
const buildOptions = (0, devkit_1.readTargetOptions)((0, devkit_1.parseTargetString)(options.buildTarget, context.projectGraph), context);
|
|
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;
|
|
20
19
|
// Cast to any to overwrite NODE_ENV
|
|
21
20
|
process.env.NODE_ENV = process.env.NODE_ENV
|
|
22
21
|
? process.env.NODE_ENV
|
|
@@ -24,18 +23,17 @@ async function* serveExecutor(options, context) {
|
|
|
24
23
|
? 'development'
|
|
25
24
|
: 'production';
|
|
26
25
|
// Setting port that the custom server should use.
|
|
27
|
-
process.env.PORT =
|
|
28
|
-
|
|
29
|
-
const args = (0, create_cli_options_1.createCliOptions)({ port: options.port, hostname });
|
|
26
|
+
process.env.PORT = `${options.port}`;
|
|
27
|
+
const args = (0, create_cli_options_1.createCliOptions)({ port, hostname });
|
|
30
28
|
if (keepAliveTimeout && !options.dev) {
|
|
31
29
|
args.push(`--keepAliveTimeout=${keepAliveTimeout}`);
|
|
32
30
|
}
|
|
31
|
+
const nextDir = (0, path_1.resolve)(context.root, buildOptions.outputPath);
|
|
33
32
|
const mode = options.dev ? 'dev' : 'start';
|
|
34
33
|
const turbo = options.turbo && options.dev ? '--turbo' : '';
|
|
35
|
-
const experimentalHttps = options.experimentalHttps && options.dev ? '--experimental-https' : '';
|
|
36
34
|
const nextBin = require.resolve('next/dist/bin/next');
|
|
37
35
|
yield* (0, async_iterable_1.createAsyncIterable)(async ({ done, next, error }) => {
|
|
38
|
-
const server = (0, child_process_1.fork)(nextBin, [mode, ...args, turbo
|
|
36
|
+
const server = (0, child_process_1.fork)(nextBin, [mode, ...args, turbo], {
|
|
39
37
|
cwd: options.dev ? projectRoot : nextDir,
|
|
40
38
|
stdio: 'inherit',
|
|
41
39
|
});
|
|
@@ -56,10 +54,10 @@ async function* serveExecutor(options, context) {
|
|
|
56
54
|
process.on('SIGINT', () => killServer());
|
|
57
55
|
process.on('SIGTERM', () => killServer());
|
|
58
56
|
process.on('SIGHUP', () => killServer());
|
|
59
|
-
await (0, wait_for_port_open_1.waitForPortOpen)(
|
|
57
|
+
await (0, wait_for_port_open_1.waitForPortOpen)(port, { host: options.hostname });
|
|
60
58
|
next({
|
|
61
59
|
success: true,
|
|
62
|
-
baseUrl: `http://${options.hostname ?? 'localhost'}:${
|
|
60
|
+
baseUrl: `http://${options.hostname ?? 'localhost'}:${port}`,
|
|
63
61
|
});
|
|
64
62
|
});
|
|
65
63
|
}
|
|
@@ -2,8 +2,6 @@
|
|
|
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");
|
|
7
5
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
8
6
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
9
7
|
const add_jest_1 = require("./lib/add-jest");
|
|
@@ -17,11 +15,8 @@ const add_linting_1 = require("./lib/add-linting");
|
|
|
17
15
|
const custom_server_1 = require("../custom-server/custom-server");
|
|
18
16
|
const update_cypress_tsconfig_1 = require("./lib/update-cypress-tsconfig");
|
|
19
17
|
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");
|
|
22
18
|
async function applicationGenerator(host, schema) {
|
|
23
19
|
return await applicationGeneratorInternal(host, {
|
|
24
|
-
addPlugin: false,
|
|
25
20
|
projectNameAndRootFormat: 'derived',
|
|
26
21
|
...schema,
|
|
27
22
|
});
|
|
@@ -31,12 +26,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
31
26
|
const tasks = [];
|
|
32
27
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
33
28
|
(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);
|
|
40
29
|
const nextTask = await (0, init_1.nextInitGenerator)(host, {
|
|
41
30
|
...options,
|
|
42
31
|
skipFormat: true,
|
|
@@ -64,22 +53,9 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
64
53
|
compiler: options.swc ? 'swc' : 'tsc',
|
|
65
54
|
});
|
|
66
55
|
}
|
|
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
|
-
}
|
|
77
56
|
if (!options.skipFormat) {
|
|
78
57
|
await (0, devkit_1.formatFiles)(host);
|
|
79
58
|
}
|
|
80
|
-
tasks.push(() => {
|
|
81
|
-
(0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
|
|
82
|
-
});
|
|
83
59
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
84
60
|
}
|
|
85
61
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
|
-
|
|
4
|
-
import Index from '../src/pages/index';
|
|
5
|
-
<% } else if (!appDir) { %>
|
|
3
|
+
|
|
6
4
|
import Index from '../pages/index';
|
|
7
|
-
<% } else if (appDir && src) {%>
|
|
8
|
-
import Page from '../src/app/page';
|
|
9
|
-
<% } else { %>
|
|
10
|
-
import Page from '../app/page';
|
|
11
|
-
<% } %>
|
|
12
5
|
|
|
13
|
-
describe(
|
|
6
|
+
describe('Index', () => {
|
|
14
7
|
it('should render successfully', () => {
|
|
15
|
-
const { baseElement } = render(
|
|
8
|
+
const { baseElement } = render(<Index />);
|
|
16
9
|
expect(baseElement).toBeTruthy();
|
|
17
10
|
});
|
|
18
11
|
});
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"plugins": [{ "name": "next" }]
|
|
16
16
|
},
|
|
17
17
|
"include": [
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
18
|
+
"**/*.ts",
|
|
19
|
+
"**/*.tsx",
|
|
20
|
+
"**/*.js",
|
|
21
|
+
"**/*.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", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
|
29
29
|
}
|
|
@@ -4,22 +4,9 @@ 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");
|
|
8
7
|
async function addE2e(host, options) {
|
|
9
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
10
|
-
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
11
|
-
? p === '@nx/next/plugin'
|
|
12
|
-
: p.plugin === '@nx/next/plugin');
|
|
13
8
|
if (options.e2eTestRunner === 'cypress') {
|
|
14
9
|
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
|
-
}
|
|
23
10
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
24
11
|
root: options.e2eProjectRoot,
|
|
25
12
|
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
@@ -33,17 +20,8 @@ async function addE2e(host, options) {
|
|
|
33
20
|
project: options.e2eProjectName,
|
|
34
21
|
directory: 'src',
|
|
35
22
|
skipFormat: true,
|
|
36
|
-
devServerTarget: `${options.projectName}
|
|
37
|
-
baseUrl: options.e2eWebServerAddress,
|
|
23
|
+
devServerTarget: `${options.projectName}:serve`,
|
|
38
24
|
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,
|
|
47
25
|
});
|
|
48
26
|
}
|
|
49
27
|
else if (options.e2eTestRunner === 'playwright') {
|
|
@@ -55,7 +33,6 @@ async function addE2e(host, options) {
|
|
|
55
33
|
implicitDependencies: [options.projectName],
|
|
56
34
|
});
|
|
57
35
|
return configurationGenerator(host, {
|
|
58
|
-
rootProject: options.rootProject,
|
|
59
36
|
project: options.e2eProjectName,
|
|
60
37
|
skipFormat: true,
|
|
61
38
|
skipPackageJson: options.skipPackageJson,
|
|
@@ -63,9 +40,8 @@ async function addE2e(host, options) {
|
|
|
63
40
|
js: false,
|
|
64
41
|
linter: options.linter,
|
|
65
42
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
66
|
-
webServerAddress:
|
|
67
|
-
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx
|
|
68
|
-
addPlugin: options.addPlugin,
|
|
43
|
+
webServerAddress: 'http://127.0.0.1:4200',
|
|
44
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.projectName}`,
|
|
69
45
|
});
|
|
70
46
|
}
|
|
71
47
|
return () => { };
|
|
@@ -5,27 +5,35 @@ 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 lint_project_1 = require("@nx/eslint/src/generators/lint-project/lint-project");
|
|
9
9
|
async function addLinting(host, options) {
|
|
10
|
-
const
|
|
11
|
-
tasks.push(await (0, eslint_1.lintProjectGenerator)(host, {
|
|
10
|
+
const lintTask = await (0, eslint_1.lintProjectGenerator)(host, {
|
|
12
11
|
linter: options.linter,
|
|
13
12
|
project: options.projectName,
|
|
14
13
|
tsConfigPaths: [
|
|
15
14
|
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
16
15
|
],
|
|
17
16
|
unitTestRunner: options.unitTestRunner,
|
|
17
|
+
eslintFilePatterns: [
|
|
18
|
+
(0, lint_project_1.mapLintPattern)(options.appProjectRoot, '{ts,tsx,js,jsx}', options.rootProject),
|
|
19
|
+
],
|
|
18
20
|
skipFormat: true,
|
|
19
21
|
rootProject: options.rootProject,
|
|
20
|
-
|
|
21
|
-
addPlugin: options.addPlugin,
|
|
22
|
-
}));
|
|
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 });
|
|
29
37
|
(0, eslint_file_1.updateOverrideInLintConfig)(host, options.appProjectRoot, (o) => Array.isArray(o.files) &&
|
|
30
38
|
o.files.some((f) => f.match(/\*\.ts$/)) &&
|
|
31
39
|
o.files.some((f) => f.match(/\*\.tsx$/)) &&
|
|
@@ -51,12 +59,7 @@ async function addLinting(host, options) {
|
|
|
51
59
|
}
|
|
52
60
|
(0, eslint_file_1.addIgnoresToLintConfig)(host, options.appProjectRoot, ['.next/**/*']);
|
|
53
61
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
...lint_1.extraEslintDependencies.devDependencies,
|
|
57
|
-
'eslint-config-next': versions_1.eslintConfigNextVersion,
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
62
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
63
|
+
return (0, devkit_1.runTasksInSerial)(lintTask, installTask);
|
|
61
64
|
}
|
|
62
65
|
exports.addLinting = addLinting;
|
|
@@ -2,56 +2,46 @@
|
|
|
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");
|
|
6
5
|
function addProject(host, options) {
|
|
7
6
|
const targets = {};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
outputs: ['{options.outputPath}'],
|
|
19
|
-
defaultConfiguration: 'production',
|
|
20
|
-
options: {
|
|
21
|
-
outputPath: options.outputPath,
|
|
7
|
+
targets.build = {
|
|
8
|
+
executor: '@nx/next:build',
|
|
9
|
+
outputs: ['{options.outputPath}'],
|
|
10
|
+
defaultConfiguration: 'production',
|
|
11
|
+
options: {
|
|
12
|
+
outputPath: options.outputPath,
|
|
13
|
+
},
|
|
14
|
+
configurations: {
|
|
15
|
+
development: {
|
|
16
|
+
outputPath: options.appProjectRoot,
|
|
22
17
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
production: {},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
targets.serve = {
|
|
22
|
+
executor: '@nx/next:server',
|
|
23
|
+
defaultConfiguration: 'development',
|
|
24
|
+
options: {
|
|
25
|
+
buildTarget: `${options.projectName}:build`,
|
|
26
|
+
dev: true,
|
|
27
|
+
},
|
|
28
|
+
configurations: {
|
|
29
|
+
development: {
|
|
30
|
+
buildTarget: `${options.projectName}:build:development`,
|
|
35
31
|
dev: true,
|
|
36
32
|
},
|
|
37
|
-
|
|
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: {
|
|
33
|
+
production: {
|
|
51
34
|
buildTarget: `${options.projectName}:build:production`,
|
|
35
|
+
dev: false,
|
|
52
36
|
},
|
|
53
|
-
}
|
|
54
|
-
}
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
targets.export = {
|
|
40
|
+
executor: '@nx/next:export',
|
|
41
|
+
options: {
|
|
42
|
+
buildTarget: `${options.projectName}:build:production`,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
55
45
|
const project = {
|
|
56
46
|
root: options.appProjectRoot,
|
|
57
47
|
sourceRoot: options.appProjectRoot,
|
|
@@ -249,44 +249,10 @@ 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
|
|
253
|
+
<span>Plugin for VSCode</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>
|
|
290
256
|
<div id="nx-cloud" className="rounded shadow">
|
|
291
257
|
<div>
|
|
292
258
|
<svg id="nx-cloud-logo" role="img" xmlns="http://www.w3.org/2000/svg" stroke="currentColor" fill="transparent" viewBox="0 0 24 24">
|
|
@@ -294,7 +260,7 @@ function createAppJsx(name) {
|
|
|
294
260
|
<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" />
|
|
295
261
|
</svg>
|
|
296
262
|
<h2>
|
|
297
|
-
|
|
263
|
+
NxCloud
|
|
298
264
|
<span>
|
|
299
265
|
Enable faster CI & better DX
|
|
300
266
|
</span>
|
|
@@ -304,7 +270,7 @@ function createAppJsx(name) {
|
|
|
304
270
|
You can activate distributed tasks executions and caching by
|
|
305
271
|
running:
|
|
306
272
|
</p>
|
|
307
|
-
<pre>nx connect</pre>
|
|
273
|
+
<pre>nx connect-to-nx-cloud</pre>
|
|
308
274
|
<a
|
|
309
275
|
href="https://nx.app/?utm_source=nx-project"
|
|
310
276
|
target="_blank"
|
|
@@ -361,28 +327,9 @@ function createAppJsx(name) {
|
|
|
361
327
|
<span># Generate UI lib</span>
|
|
362
328
|
nx g @nx/next:library ui
|
|
363
329
|
<span># Add a component</span>
|
|
364
|
-
nx g @nx/next:component ui
|
|
330
|
+
nx g @nx/next:component button --project=ui
|
|
365
331
|
</pre>
|
|
366
332
|
</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>
|
|
386
333
|
<details>
|
|
387
334
|
<summary>
|
|
388
335
|
<svg
|
|
@@ -703,15 +650,6 @@ function createStyleRules() {
|
|
|
703
650
|
#nx-console svg {
|
|
704
651
|
color: rgba(0, 122, 204, 1);
|
|
705
652
|
}
|
|
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
|
-
}
|
|
715
653
|
#nx-repo:hover {
|
|
716
654
|
background-color: rgba(24, 23, 23, 1);
|
|
717
655
|
}
|
|
@@ -9,14 +9,6 @@ function createApplicationFiles(host, options) {
|
|
|
9
9
|
const offsetFromRoot = (0, devkit_1.offsetFromRoot)(options.appProjectRoot);
|
|
10
10
|
const layoutTypeSrcPath = (0, devkit_1.joinPathFragments)(offsetFromRoot, options.appProjectRoot, '.next/types/**/*.ts');
|
|
11
11
|
const layoutTypeDistPath = (0, devkit_1.joinPathFragments)(offsetFromRoot, options.outputPath, '.next/types/**/*.ts');
|
|
12
|
-
// scope tsconfig to the project directory so that it doesn't include other projects/libs
|
|
13
|
-
const rootPath = options.rootProject
|
|
14
|
-
? options.src
|
|
15
|
-
? 'src/'
|
|
16
|
-
: options.appDir
|
|
17
|
-
? 'app/'
|
|
18
|
-
: 'pages/'
|
|
19
|
-
: '';
|
|
20
12
|
const templateVariables = {
|
|
21
13
|
...(0, devkit_1.names)(options.name),
|
|
22
14
|
...options,
|
|
@@ -24,7 +16,6 @@ function createApplicationFiles(host, options) {
|
|
|
24
16
|
tmpl: '',
|
|
25
17
|
offsetFromRoot,
|
|
26
18
|
layoutTypeSrcPath,
|
|
27
|
-
rootPath,
|
|
28
19
|
layoutTypeDistPath,
|
|
29
20
|
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot),
|
|
30
21
|
appContent: (0, create_application_files_helpers_1.createAppJsx)(options.projectName),
|
|
@@ -32,27 +23,23 @@ function createApplicationFiles(host, options) {
|
|
|
32
23
|
pageStyleContent: `.page {}`,
|
|
33
24
|
stylesExt: options.style === 'less' ? options.style : 'css',
|
|
34
25
|
};
|
|
35
|
-
const generatedAppFilePath = options.src
|
|
36
|
-
? (0, path_1.join)(options.appProjectRoot, 'src')
|
|
37
|
-
: options.appProjectRoot;
|
|
38
26
|
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/common'), options.appProjectRoot, templateVariables);
|
|
39
27
|
if (options.appDir) {
|
|
40
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), (0, path_1.join)(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
28
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), (0, path_1.join)(options.appProjectRoot, 'app'), templateVariables);
|
|
29
|
+
// RSC is not possible to unit test without extra helpers for data fetching. Leaving it to the user to figure out.
|
|
30
|
+
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'specs', `index.spec.${options.js ? 'jsx' : 'tsx'}`));
|
|
44
31
|
if (options.style === 'styled-components') {
|
|
45
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-styled-components'), (0, path_1.join)(
|
|
32
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-styled-components'), (0, path_1.join)(options.appProjectRoot, 'app'), templateVariables);
|
|
46
33
|
}
|
|
47
34
|
else if (options.style === 'styled-jsx') {
|
|
48
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-styled-jsx'), (0, path_1.join)(
|
|
35
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-styled-jsx'), (0, path_1.join)(options.appProjectRoot, 'app'), templateVariables);
|
|
49
36
|
}
|
|
50
37
|
else {
|
|
51
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-default-layout'), (0, path_1.join)(
|
|
38
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app-default-layout'), (0, path_1.join)(options.appProjectRoot, 'app'), templateVariables);
|
|
52
39
|
}
|
|
53
40
|
}
|
|
54
41
|
else {
|
|
55
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/pages'), (0, path_1.join)(
|
|
42
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/pages'), (0, path_1.join)(options.appProjectRoot, 'pages'), templateVariables);
|
|
56
43
|
}
|
|
57
44
|
if (options.rootProject) {
|
|
58
45
|
(0, devkit_1.updateJson)(host, 'tsconfig.base.json', (json) => {
|
|
@@ -77,6 +64,7 @@ function createApplicationFiles(host, options) {
|
|
|
77
64
|
...new Set([
|
|
78
65
|
...(updatedJson.exclude || []),
|
|
79
66
|
...(appJSON.exclude || []),
|
|
67
|
+
'**e2e/**/*',
|
|
80
68
|
`dist/${options.projectName}/**/*`,
|
|
81
69
|
]),
|
|
82
70
|
],
|
|
@@ -96,14 +84,14 @@ function createApplicationFiles(host, options) {
|
|
|
96
84
|
}
|
|
97
85
|
if (options.styledModule) {
|
|
98
86
|
if (options.appDir) {
|
|
99
|
-
host.delete(`${
|
|
87
|
+
host.delete(`${options.appProjectRoot}/app/page.module.${options.style}`);
|
|
100
88
|
}
|
|
101
89
|
else {
|
|
102
|
-
host.delete(`${
|
|
90
|
+
host.delete(`${options.appProjectRoot}/pages/${options.fileName}.module.${options.style}`);
|
|
103
91
|
}
|
|
104
92
|
}
|
|
105
93
|
if (options.style !== 'styled-components') {
|
|
106
|
-
host.delete(`${
|
|
94
|
+
host.delete(`${options.appProjectRoot}/pages/_document.tsx`);
|
|
107
95
|
}
|
|
108
96
|
if (options.js) {
|
|
109
97
|
host.delete(`${options.appProjectRoot}/index.d.ts`);
|
|
@@ -6,9 +6,6 @@ export interface NormalizedSchema extends Schema {
|
|
|
6
6
|
outputPath: string;
|
|
7
7
|
e2eProjectName: string;
|
|
8
8
|
e2eProjectRoot: string;
|
|
9
|
-
e2eWebServerAddress: string;
|
|
10
|
-
e2eWebServerTarget: string;
|
|
11
|
-
e2ePort: number;
|
|
12
9
|
parsedTags: string[];
|
|
13
10
|
fileName: string;
|
|
14
11
|
styledModule: null | string;
|