@nx/next 16.8.0-beta.4 → 16.8.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -9
- package/plugins/component-testing.d.ts +0 -1
- package/plugins/component-testing.js +14 -8
- package/plugins/with-less.js +19 -14
- package/plugins/with-nx.js +27 -28
- package/plugins/with-stylus.js +18 -14
- package/src/executors/build/build.impl.js +60 -66
- package/src/executors/build/lib/create-next-config-file.js +2 -4
- package/src/executors/build/lib/update-package-json.js +2 -4
- package/src/executors/export/export.impl.js +29 -32
- package/src/executors/server/custom-server.impl.js +27 -45
- package/src/executors/server/server.impl.js +52 -56
- package/src/generators/application/application.js +38 -37
- package/src/generators/application/lib/add-e2e.js +35 -31
- package/src/generators/application/lib/add-jest.js +29 -26
- package/src/generators/application/lib/add-linting.js +50 -47
- package/src/generators/application/lib/add-project.js +3 -1
- package/src/generators/application/lib/create-application-files.js +26 -8
- package/src/generators/application/lib/normalize-options.js +40 -33
- package/src/generators/application/lib/set-defaults.js +5 -7
- package/src/generators/application/lib/update-cypress-tsconfig.js +4 -1
- package/src/generators/component/component.js +16 -13
- package/src/generators/custom-server/custom-server.js +66 -65
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +55 -57
- package/src/generators/init/init.js +36 -33
- package/src/generators/library/lib/normalize-options.js +14 -14
- package/src/generators/library/library.js +52 -47
- package/src/generators/page/page.js +21 -14
- package/src/migrations/update-12-10-0/fix-page-dir-for-eslint.js +23 -24
- package/src/migrations/update-12-8-0/remove-styled-jsx-babel-plugin.js +13 -16
- package/src/migrations/update-13-0-0/update-emotion-setup.js +24 -27
- package/src/migrations/update-13-0-0/update-to-webpack-5.js +20 -23
- package/src/migrations/update-13-0-3/fix-less.js +15 -18
- package/src/migrations/update-13-1-1/enable-swc.js +28 -32
- package/src/migrations/update-14-0-0/add-default-development-configurations.js +22 -27
- package/src/migrations/update-14-4-3/add-dev-output-path.js +11 -15
- package/src/migrations/update-14-5-3/add-gitignore-entry.js +3 -6
- package/src/migrations/update-14-5-3/update-dev-output-path.js +14 -19
- package/src/migrations/update-14-5-7/update-next-eslint.js +18 -22
- package/src/migrations/update-15-8-8/add-style-packages.js +14 -18
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-3-0/remove-root-build-option.js +10 -13
- package/src/migrations/update-16-4-0/update-nx-next-dependency.js +12 -15
- package/src/utils/compose-plugins.js +12 -15
- package/src/utils/create-copy-plugin.js +6 -4
- package/src/utils/generate-globs.js +1 -1
- package/src/utils/styles.js +31 -11
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const export_1 = require("next/dist/export");
|
|
6
5
|
const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
@@ -22,37 +21,35 @@ const pmCmd = (0, os_1.platform)() === 'win32' ? `npx.cmd` : 'npx';
|
|
|
22
21
|
};
|
|
23
22
|
* Read https://nextjs.org/docs/pages/building-your-application/deploying/static-exports
|
|
24
23
|
**/
|
|
25
|
-
function exportExecutor(options, context) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return { success: true };
|
|
55
|
-
});
|
|
24
|
+
async function exportExecutor(options, context) {
|
|
25
|
+
let dependencies = [];
|
|
26
|
+
if (!options.buildLibsFromSource) {
|
|
27
|
+
const result = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, 'build', // this should be generalized
|
|
28
|
+
context.configurationName);
|
|
29
|
+
dependencies = result.dependencies;
|
|
30
|
+
}
|
|
31
|
+
const buildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context.projectGraph);
|
|
32
|
+
try {
|
|
33
|
+
const args = getBuildTargetCommand(options);
|
|
34
|
+
(0, child_process_1.execFileSync)(pmCmd, args, {
|
|
35
|
+
stdio: [0, 1, 2],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new Error(`Build target failed: ${chalk.bold(options.buildTarget)}`);
|
|
40
|
+
}
|
|
41
|
+
const buildOptions = (0, devkit_1.readTargetOptions)(buildTarget, context);
|
|
42
|
+
const projectRoot = context.projectGraph.nodes[context.projectName].data.root;
|
|
43
|
+
// Taken from:
|
|
44
|
+
// https://github.com/vercel/next.js/blob/ead56eaab68409e96c19f7d9139747bac1197aa9/packages/next/cli/next-export.ts#L13
|
|
45
|
+
const nextExportCliSpan = nextTrace.trace('next-export-cli');
|
|
46
|
+
await (0, export_1.default)(projectRoot, {
|
|
47
|
+
statusMessage: 'Exporting',
|
|
48
|
+
silent: options.silent,
|
|
49
|
+
threads: options.threads,
|
|
50
|
+
outdir: `${buildOptions.outputPath}/exported`,
|
|
51
|
+
}, nextExportCliSpan);
|
|
52
|
+
return { success: true };
|
|
56
53
|
}
|
|
57
54
|
exports.default = exportExecutor;
|
|
58
55
|
function getBuildTargetCommand(options) {
|
|
@@ -1,53 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const path_1 = require("path");
|
|
6
|
-
function serveExecutor(options, context) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(runCustomServer(projectRoot, options, context))));
|
|
18
|
-
});
|
|
5
|
+
async function* serveExecutor(options, context) {
|
|
6
|
+
// Cast to any to overwrite NODE_ENV
|
|
7
|
+
process.env.NODE_ENV = process.env.NODE_ENV
|
|
8
|
+
? process.env.NODE_ENV
|
|
9
|
+
: options.dev
|
|
10
|
+
? 'development'
|
|
11
|
+
: 'production';
|
|
12
|
+
// Setting port that the custom server should use.
|
|
13
|
+
process.env.PORT = options.port;
|
|
14
|
+
const projectRoot = context.projectGraph.nodes[context.projectName].data.root;
|
|
15
|
+
yield* runCustomServer(projectRoot, options, context);
|
|
19
16
|
}
|
|
20
17
|
exports.default = serveExecutor;
|
|
21
|
-
function runCustomServer(root, options, context) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
for (var _d = true, customServerBuild_1 = tslib_1.__asyncValues(customServerBuild), customServerBuild_1_1; customServerBuild_1_1 = yield tslib_1.__await(customServerBuild_1.next()), _a = customServerBuild_1_1.done, !_a; _d = true) {
|
|
32
|
-
_c = customServerBuild_1_1.value;
|
|
33
|
-
_d = false;
|
|
34
|
-
const result = _c;
|
|
35
|
-
if (!result.success) {
|
|
36
|
-
return yield tslib_1.__await(result);
|
|
37
|
-
}
|
|
38
|
-
yield yield tslib_1.__await({
|
|
39
|
-
success: true,
|
|
40
|
-
baseUrl,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
18
|
+
async function* runCustomServer(root, options, context) {
|
|
19
|
+
process.env.NX_NEXT_DIR = root;
|
|
20
|
+
process.env.NX_NEXT_PUBLIC_DIR = (0, path_1.join)(root, 'public');
|
|
21
|
+
const baseUrl = `http://${options.hostname || 'localhost'}:${options.port}`;
|
|
22
|
+
const customServerBuild = await (0, devkit_1.runExecutor)((0, devkit_1.parseTargetString)(options.customServerTarget, context.projectGraph), {
|
|
23
|
+
watch: options.dev ? true : false,
|
|
24
|
+
}, context);
|
|
25
|
+
for await (const result of customServerBuild) {
|
|
26
|
+
if (!result.success) {
|
|
27
|
+
return result;
|
|
43
28
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
return yield tslib_1.__await({ success: true });
|
|
52
|
-
});
|
|
29
|
+
yield {
|
|
30
|
+
success: true,
|
|
31
|
+
baseUrl,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return { success: true };
|
|
53
35
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const path_1 = require("path");
|
|
6
5
|
const child_process_1 = require("child_process");
|
|
@@ -8,61 +7,58 @@ const custom_server_impl_1 = require("./custom-server.impl");
|
|
|
8
7
|
const create_cli_options_1 = require("../../utils/create-cli-options");
|
|
9
8
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
10
9
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
|
11
|
-
function serveExecutor(options, context) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
baseUrl: `http://${(_a = options.hostname) !== null && _a !== void 0 ? _a : 'localhost'}:${port}`,
|
|
64
|
-
});
|
|
65
|
-
})))));
|
|
10
|
+
async function* serveExecutor(options, context) {
|
|
11
|
+
if (options.customServerTarget) {
|
|
12
|
+
return yield* (0, custom_server_impl_1.default)(options, context);
|
|
13
|
+
}
|
|
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;
|
|
19
|
+
// Cast to any to overwrite NODE_ENV
|
|
20
|
+
process.env.NODE_ENV = process.env.NODE_ENV
|
|
21
|
+
? process.env.NODE_ENV
|
|
22
|
+
: options.dev
|
|
23
|
+
? 'development'
|
|
24
|
+
: 'production';
|
|
25
|
+
// Setting port that the custom server should use.
|
|
26
|
+
process.env.PORT = `${options.port}`;
|
|
27
|
+
const args = (0, create_cli_options_1.createCliOptions)({ port, hostname });
|
|
28
|
+
if (keepAliveTimeout && !options.dev) {
|
|
29
|
+
args.push(`--keepAliveTimeout=${keepAliveTimeout}`);
|
|
30
|
+
}
|
|
31
|
+
const nextDir = (0, path_1.resolve)(context.root, buildOptions.outputPath);
|
|
32
|
+
const mode = options.dev ? 'dev' : 'start';
|
|
33
|
+
const turbo = options.turbo && options.dev ? '--turbo' : '';
|
|
34
|
+
const nextBin = require.resolve('next/dist/bin/next');
|
|
35
|
+
yield* (0, async_iterable_1.createAsyncIterable)(async ({ done, next, error }) => {
|
|
36
|
+
const server = (0, child_process_1.fork)(nextBin, [mode, ...args, turbo], {
|
|
37
|
+
cwd: options.dev ? projectRoot : nextDir,
|
|
38
|
+
stdio: 'inherit',
|
|
39
|
+
});
|
|
40
|
+
server.once('exit', (code) => {
|
|
41
|
+
if (code === 0) {
|
|
42
|
+
done();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
error(new Error(`Next.js app exited with code ${code}`));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const killServer = () => {
|
|
49
|
+
if (server.connected) {
|
|
50
|
+
server.kill('SIGTERM');
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
process.on('exit', () => killServer());
|
|
54
|
+
process.on('SIGINT', () => killServer());
|
|
55
|
+
process.on('SIGTERM', () => killServer());
|
|
56
|
+
process.on('SIGHUP', () => killServer());
|
|
57
|
+
await (0, wait_for_port_open_1.waitForPortOpen)(port, { host: options.hostname });
|
|
58
|
+
next({
|
|
59
|
+
success: true,
|
|
60
|
+
baseUrl: `http://${options.hostname ?? 'localhost'}:${port}`,
|
|
61
|
+
});
|
|
66
62
|
});
|
|
67
63
|
}
|
|
68
64
|
exports.default = serveExecutor;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.applicationSchematic = exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
7
6
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
@@ -16,46 +15,48 @@ const add_linting_1 = require("./lib/add-linting");
|
|
|
16
15
|
const custom_server_1 = require("../custom-server/custom-server");
|
|
17
16
|
const update_cypress_tsconfig_1 = require("./lib/update-cypress-tsconfig");
|
|
18
17
|
const show_possible_warnings_1 = require("./lib/show-possible-warnings");
|
|
19
|
-
function applicationGenerator(host, schema) {
|
|
20
|
-
return
|
|
21
|
-
|
|
18
|
+
async function applicationGenerator(host, schema) {
|
|
19
|
+
return await applicationGeneratorInternal(host, {
|
|
20
|
+
projectNameAndRootFormat: 'derived',
|
|
21
|
+
...schema,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
exports.applicationGenerator = applicationGenerator;
|
|
25
|
-
function applicationGeneratorInternal(host, schema) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(0, update_jest_config_1.updateJestConfig)(host, options);
|
|
46
|
-
(0, update_cypress_tsconfig_1.updateCypressTsConfig)(host, options);
|
|
47
|
-
(0, set_defaults_1.setDefaults)(host, options);
|
|
48
|
-
if (options.customServer) {
|
|
49
|
-
yield (0, custom_server_1.customServerGenerator)(host, {
|
|
50
|
-
project: options.projectName,
|
|
51
|
-
compiler: options.swc ? 'swc' : 'tsc',
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
if (!options.skipFormat) {
|
|
55
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
56
|
-
}
|
|
57
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
25
|
+
async function applicationGeneratorInternal(host, schema) {
|
|
26
|
+
const tasks = [];
|
|
27
|
+
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
28
|
+
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
|
29
|
+
const nextTask = await (0, init_1.nextInitGenerator)(host, {
|
|
30
|
+
...options,
|
|
31
|
+
skipFormat: true,
|
|
32
|
+
});
|
|
33
|
+
tasks.push(nextTask);
|
|
34
|
+
(0, create_application_files_1.createApplicationFiles)(host, options);
|
|
35
|
+
(0, add_project_1.addProject)(host, options);
|
|
36
|
+
const e2eTask = await (0, add_e2e_1.addE2e)(host, options);
|
|
37
|
+
tasks.push(e2eTask);
|
|
38
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options);
|
|
39
|
+
tasks.push(jestTask);
|
|
40
|
+
const lintTask = await (0, add_linting_1.addLinting)(host, options);
|
|
41
|
+
tasks.push(lintTask);
|
|
42
|
+
const styledTask = (0, styles_1.addStyleDependencies)(host, {
|
|
43
|
+
style: options.style,
|
|
44
|
+
swc: !host.exists((0, devkit_1.joinPathFragments)(options.appProjectRoot, '.babelrc')),
|
|
58
45
|
});
|
|
46
|
+
tasks.push(styledTask);
|
|
47
|
+
(0, update_jest_config_1.updateJestConfig)(host, options);
|
|
48
|
+
(0, update_cypress_tsconfig_1.updateCypressTsConfig)(host, options);
|
|
49
|
+
(0, set_defaults_1.setDefaults)(host, options);
|
|
50
|
+
if (options.customServer) {
|
|
51
|
+
await (0, custom_server_1.customServerGenerator)(host, {
|
|
52
|
+
project: options.projectName,
|
|
53
|
+
compiler: options.swc ? 'swc' : 'tsc',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (!options.skipFormat) {
|
|
57
|
+
await (0, devkit_1.formatFiles)(host);
|
|
58
|
+
}
|
|
59
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
59
60
|
}
|
|
60
61
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
61
62
|
exports.applicationSchematic = (0, devkit_1.convertNxGenerator)(applicationGenerator);
|
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addE2e = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const linter_1 = require("@nx/linter");
|
|
7
6
|
const versions_1 = require("../../../utils/versions");
|
|
8
|
-
function addE2e(host, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
7
|
+
async function addE2e(host, options) {
|
|
8
|
+
if (options.e2eTestRunner === 'cypress') {
|
|
9
|
+
const { cypressProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
10
|
+
return cypressProjectGenerator(host, {
|
|
11
|
+
...options,
|
|
12
|
+
linter: linter_1.Linter.EsLint,
|
|
13
|
+
name: options.e2eProjectName,
|
|
14
|
+
directory: options.e2eProjectRoot,
|
|
15
|
+
// the name and root are already normalized, instruct the generator to use them as is
|
|
16
|
+
projectNameAndRootFormat: 'as-provided',
|
|
17
|
+
project: options.projectName,
|
|
18
|
+
skipFormat: true,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
else if (options.e2eTestRunner === 'playwright') {
|
|
22
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
|
23
|
+
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
24
|
+
root: options.e2eProjectRoot,
|
|
25
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
26
|
+
targets: {},
|
|
27
|
+
implicitDependencies: [options.projectName],
|
|
28
|
+
});
|
|
29
|
+
return configurationGenerator(host, {
|
|
30
|
+
project: options.e2eProjectName,
|
|
31
|
+
skipFormat: true,
|
|
32
|
+
skipPackageJson: options.skipPackageJson,
|
|
33
|
+
directory: 'src',
|
|
34
|
+
js: false,
|
|
35
|
+
linter: options.linter,
|
|
36
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
37
|
+
webServerAddress: 'http://127.0.0.1:4200',
|
|
38
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.projectName}`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return () => { };
|
|
38
42
|
}
|
|
39
43
|
exports.addE2e = addE2e;
|
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addJest = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const versions_1 = require("../../../utils/versions");
|
|
7
|
-
function addJest(host, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
async function addJest(host, options) {
|
|
7
|
+
if (options.unitTestRunner !== 'jest') {
|
|
8
|
+
return () => { };
|
|
9
|
+
}
|
|
10
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
|
11
|
+
const jestTask = await configurationGenerator(host, {
|
|
12
|
+
...options,
|
|
13
|
+
project: options.projectName,
|
|
14
|
+
supportTsx: true,
|
|
15
|
+
skipSerializers: true,
|
|
16
|
+
setupFile: 'none',
|
|
17
|
+
compiler: 'babel',
|
|
18
|
+
skipFormat: true,
|
|
19
|
+
});
|
|
20
|
+
const tsConfigSpecJson = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.spec.json'));
|
|
21
|
+
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'), (json) => {
|
|
22
|
+
json.compilerOptions ??= {};
|
|
23
|
+
json.compilerOptions.types ??= [];
|
|
24
|
+
json.compilerOptions.types.push(...(tsConfigSpecJson?.compilerOptions?.types ?? []));
|
|
25
|
+
return json;
|
|
26
|
+
});
|
|
27
|
+
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.spec.json'), (json) => {
|
|
28
|
+
json.compilerOptions.jsx = 'react';
|
|
29
|
+
// have to override exclude otherwise lint will fail with setParserOptionsProject and jest.config.ts
|
|
30
|
+
if (options.setParserOptionsProject) {
|
|
31
|
+
const tsConfig = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'));
|
|
32
|
+
json.exclude = tsConfig.exclude.filter((e) => e !== 'jest.config.ts');
|
|
11
33
|
}
|
|
12
|
-
|
|
13
|
-
const jestTask = yield configurationGenerator(host, Object.assign(Object.assign({}, options), { project: options.projectName, supportTsx: true, skipSerializers: true, setupFile: 'none', compiler: 'babel', skipFormat: true }));
|
|
14
|
-
const tsConfigSpecJson = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.spec.json'));
|
|
15
|
-
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'), (json) => {
|
|
16
|
-
var _a, _b, _c, _d;
|
|
17
|
-
var _e;
|
|
18
|
-
(_a = json.compilerOptions) !== null && _a !== void 0 ? _a : (json.compilerOptions = {});
|
|
19
|
-
(_b = (_e = json.compilerOptions).types) !== null && _b !== void 0 ? _b : (_e.types = []);
|
|
20
|
-
json.compilerOptions.types.push(...((_d = (_c = tsConfigSpecJson === null || tsConfigSpecJson === void 0 ? void 0 : tsConfigSpecJson.compilerOptions) === null || _c === void 0 ? void 0 : _c.types) !== null && _d !== void 0 ? _d : []));
|
|
21
|
-
return json;
|
|
22
|
-
});
|
|
23
|
-
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.spec.json'), (json) => {
|
|
24
|
-
json.compilerOptions.jsx = 'react';
|
|
25
|
-
// have to override exclude otherwise lint will fail with setParserOptionsProject and jest.config.ts
|
|
26
|
-
if (options.setParserOptionsProject) {
|
|
27
|
-
const tsConfig = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'));
|
|
28
|
-
json.exclude = tsConfig.exclude.filter((e) => e !== 'jest.config.ts');
|
|
29
|
-
}
|
|
30
|
-
return json;
|
|
31
|
-
});
|
|
32
|
-
return jestTask;
|
|
34
|
+
return json;
|
|
33
35
|
});
|
|
36
|
+
return jestTask;
|
|
34
37
|
}
|
|
35
38
|
exports.addJest = addJest;
|
|
@@ -1,59 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addLinting = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const linter_1 = require("@nx/linter");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
6
|
const lint_1 = require("@nx/react/src/utils/lint");
|
|
8
7
|
const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
|
|
9
|
-
function addLinting(host, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
async function addLinting(host, options) {
|
|
9
|
+
const lintTask = await (0, linter_1.lintProjectGenerator)(host, {
|
|
10
|
+
linter: options.linter,
|
|
11
|
+
project: options.projectName,
|
|
12
|
+
tsConfigPaths: [
|
|
13
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
14
|
+
],
|
|
15
|
+
unitTestRunner: options.unitTestRunner,
|
|
16
|
+
eslintFilePatterns: [`${options.appProjectRoot}/**/*.{ts,tsx,js,jsx}`],
|
|
17
|
+
skipFormat: true,
|
|
18
|
+
rootProject: options.rootProject,
|
|
19
|
+
});
|
|
20
|
+
if (options.linter === linter_1.Linter.EsLint && (0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
21
|
+
(0, eslint_file_1.addExtendsToLintConfig)(host, options.appProjectRoot, [
|
|
22
|
+
'plugin:@nx/react-typescript',
|
|
23
|
+
'next',
|
|
24
|
+
'next/core-web-vitals',
|
|
25
|
+
]);
|
|
26
|
+
// Turn off @next/next/no-html-link-for-pages since there is an issue with nextjs throwing linting errors
|
|
27
|
+
// TODO(nicholas): remove after Vercel updates nextjs linter to only lint ["*.ts", "*.tsx", "*.js", "*.jsx"]
|
|
28
|
+
(0, eslint_file_1.addOverrideToLintConfig)(host, options.appProjectRoot, {
|
|
29
|
+
files: ['*.*'],
|
|
30
|
+
rules: {
|
|
31
|
+
'@next/next/no-html-link-for-pages': 'off',
|
|
32
|
+
},
|
|
33
|
+
}, { insertAtTheEnd: false });
|
|
34
|
+
(0, eslint_file_1.updateOverrideInLintConfig)(host, options.appProjectRoot, (o) => Array.isArray(o.files) &&
|
|
35
|
+
o.files.some((f) => f.match(/\*\.ts$/)) &&
|
|
36
|
+
o.files.some((f) => f.match(/\*\.tsx$/)) &&
|
|
37
|
+
o.files.some((f) => f.match(/\*\.js$/)) &&
|
|
38
|
+
o.files.some((f) => f.match(/\*\.jsx$/)), (o) => ({
|
|
39
|
+
...o,
|
|
40
|
+
rules: {
|
|
41
|
+
...o.rules,
|
|
42
|
+
'@next/next/no-html-link-for-pages': [
|
|
43
|
+
'error',
|
|
44
|
+
`${options.appProjectRoot}/pages`,
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
}));
|
|
48
|
+
// add jest specific config
|
|
49
|
+
if (options.unitTestRunner === 'jest') {
|
|
30
50
|
(0, eslint_file_1.addOverrideToLintConfig)(host, options.appProjectRoot, {
|
|
31
|
-
files: ['
|
|
32
|
-
|
|
33
|
-
|
|
51
|
+
files: ['*.spec.ts', '*.spec.tsx', '*.spec.js', '*.spec.jsx'],
|
|
52
|
+
env: {
|
|
53
|
+
jest: true,
|
|
34
54
|
},
|
|
35
|
-
}
|
|
36
|
-
(0, eslint_file_1.updateOverrideInLintConfig)(host, options.appProjectRoot, (o) => Array.isArray(o.files) &&
|
|
37
|
-
o.files.some((f) => f.match(/\*\.ts$/)) &&
|
|
38
|
-
o.files.some((f) => f.match(/\*\.tsx$/)) &&
|
|
39
|
-
o.files.some((f) => f.match(/\*\.js$/)) &&
|
|
40
|
-
o.files.some((f) => f.match(/\*\.jsx$/)), (o) => (Object.assign(Object.assign({}, o), { rules: Object.assign(Object.assign({}, o.rules), { '@next/next/no-html-link-for-pages': [
|
|
41
|
-
'error',
|
|
42
|
-
`${options.appProjectRoot}/pages`,
|
|
43
|
-
] }) })));
|
|
44
|
-
// add jest specific config
|
|
45
|
-
if (options.unitTestRunner === 'jest') {
|
|
46
|
-
(0, eslint_file_1.addOverrideToLintConfig)(host, options.appProjectRoot, {
|
|
47
|
-
files: ['*.spec.ts', '*.spec.tsx', '*.spec.js', '*.spec.jsx'],
|
|
48
|
-
env: {
|
|
49
|
-
jest: true,
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
(0, eslint_file_1.addIgnoresToLintConfig)(host, options.appProjectRoot, ['.next/**/*']);
|
|
55
|
+
});
|
|
54
56
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
(0, eslint_file_1.addIgnoresToLintConfig)(host, options.appProjectRoot, ['.next/**/*']);
|
|
58
|
+
}
|
|
59
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
60
|
+
return (0, devkit_1.runTasksInSerial)(lintTask, installTask);
|
|
58
61
|
}
|
|
59
62
|
exports.addLinting = addLinting;
|