@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.
Files changed (47) hide show
  1. package/package.json +9 -9
  2. package/plugins/component-testing.d.ts +0 -1
  3. package/plugins/component-testing.js +14 -8
  4. package/plugins/with-less.js +19 -14
  5. package/plugins/with-nx.js +27 -28
  6. package/plugins/with-stylus.js +18 -14
  7. package/src/executors/build/build.impl.js +60 -66
  8. package/src/executors/build/lib/create-next-config-file.js +2 -4
  9. package/src/executors/build/lib/update-package-json.js +2 -4
  10. package/src/executors/export/export.impl.js +29 -32
  11. package/src/executors/server/custom-server.impl.js +27 -45
  12. package/src/executors/server/server.impl.js +52 -56
  13. package/src/generators/application/application.js +38 -37
  14. package/src/generators/application/lib/add-e2e.js +35 -31
  15. package/src/generators/application/lib/add-jest.js +29 -26
  16. package/src/generators/application/lib/add-linting.js +50 -47
  17. package/src/generators/application/lib/add-project.js +3 -1
  18. package/src/generators/application/lib/create-application-files.js +26 -8
  19. package/src/generators/application/lib/normalize-options.js +40 -33
  20. package/src/generators/application/lib/set-defaults.js +5 -7
  21. package/src/generators/application/lib/update-cypress-tsconfig.js +4 -1
  22. package/src/generators/component/component.js +16 -13
  23. package/src/generators/custom-server/custom-server.js +66 -65
  24. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +55 -57
  25. package/src/generators/init/init.js +36 -33
  26. package/src/generators/library/lib/normalize-options.js +14 -14
  27. package/src/generators/library/library.js +52 -47
  28. package/src/generators/page/page.js +21 -14
  29. package/src/migrations/update-12-10-0/fix-page-dir-for-eslint.js +23 -24
  30. package/src/migrations/update-12-8-0/remove-styled-jsx-babel-plugin.js +13 -16
  31. package/src/migrations/update-13-0-0/update-emotion-setup.js +24 -27
  32. package/src/migrations/update-13-0-0/update-to-webpack-5.js +20 -23
  33. package/src/migrations/update-13-0-3/fix-less.js +15 -18
  34. package/src/migrations/update-13-1-1/enable-swc.js +28 -32
  35. package/src/migrations/update-14-0-0/add-default-development-configurations.js +22 -27
  36. package/src/migrations/update-14-4-3/add-dev-output-path.js +11 -15
  37. package/src/migrations/update-14-5-3/add-gitignore-entry.js +3 -6
  38. package/src/migrations/update-14-5-3/update-dev-output-path.js +14 -19
  39. package/src/migrations/update-14-5-7/update-next-eslint.js +18 -22
  40. package/src/migrations/update-15-8-8/add-style-packages.js +14 -18
  41. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
  42. package/src/migrations/update-16-3-0/remove-root-build-option.js +10 -13
  43. package/src/migrations/update-16-4-0/update-nx-next-dependency.js +12 -15
  44. package/src/utils/compose-plugins.js +12 -15
  45. package/src/utils/create-copy-plugin.js +6 -4
  46. package/src/utils/generate-globs.js +1 -1
  47. package/src/utils/styles.js +31 -11
@@ -49,6 +49,8 @@ function addProject(host, options) {
49
49
  targets,
50
50
  tags: options.parsedTags,
51
51
  };
52
- (0, devkit_1.addProjectConfiguration)(host, options.projectName, Object.assign({}, project));
52
+ (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
53
+ ...project,
54
+ });
53
55
  }
54
56
  exports.addProject = addProject;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createApplicationFiles = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const path_1 = require("path");
6
5
  const devkit_1 = require("@nx/devkit");
7
6
  const js_1 = require("@nx/js");
@@ -10,11 +9,22 @@ function createApplicationFiles(host, options) {
10
9
  const offsetFromRoot = (0, devkit_1.offsetFromRoot)(options.appProjectRoot);
11
10
  const layoutTypeSrcPath = (0, devkit_1.joinPathFragments)(offsetFromRoot, options.appProjectRoot, '.next/types/**/*.ts');
12
11
  const layoutTypeDistPath = (0, devkit_1.joinPathFragments)(offsetFromRoot, options.outputPath, '.next/types/**/*.ts');
13
- const templateVariables = Object.assign(Object.assign(Object.assign({}, (0, devkit_1.names)(options.name)), options), { dot: '.', tmpl: '', offsetFromRoot,
12
+ const templateVariables = {
13
+ ...(0, devkit_1.names)(options.name),
14
+ ...options,
15
+ dot: '.',
16
+ tmpl: '',
17
+ offsetFromRoot,
14
18
  layoutTypeSrcPath,
15
- layoutTypeDistPath, rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot), appContent: (0, create_application_files_helpers_1.createAppJsx)(options.projectName), styleContent: (0, create_application_files_helpers_1.createStyleRules)(), pageStyleContent: `.page {}`, stylesExt: options.style === 'less' || options.style === 'styl'
19
+ layoutTypeDistPath,
20
+ rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot),
21
+ appContent: (0, create_application_files_helpers_1.createAppJsx)(options.projectName),
22
+ styleContent: (0, create_application_files_helpers_1.createStyleRules)(),
23
+ pageStyleContent: `.page {}`,
24
+ stylesExt: options.style === 'less' || options.style === 'styl'
16
25
  ? options.style
17
- : 'css' });
26
+ : 'css',
27
+ };
18
28
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/common'), options.appProjectRoot, templateVariables);
19
29
  if (options.appDir) {
20
30
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), (0, path_1.join)(options.appProjectRoot, 'app'), templateVariables);
@@ -36,23 +46,31 @@ function createApplicationFiles(host, options) {
36
46
  if (options.rootProject) {
37
47
  (0, devkit_1.updateJson)(host, 'tsconfig.base.json', (json) => {
38
48
  const appJSON = (0, devkit_1.readJson)(host, 'tsconfig.json');
39
- let { extends: _ } = json, updatedJson = tslib_1.__rest(json, ["extends"]);
49
+ let { extends: _, ...updatedJson } = json;
40
50
  // Don't generate the `paths` object or else workspace libs will not work later.
41
51
  // It'll be generated as needed when a lib is first added.
42
52
  delete json.compilerOptions.paths;
43
- updatedJson = Object.assign(Object.assign({}, devkit_1.updateJson), { compilerOptions: Object.assign(Object.assign({}, updatedJson.compilerOptions), appJSON.compilerOptions), include: [
53
+ updatedJson = {
54
+ ...devkit_1.updateJson,
55
+ compilerOptions: {
56
+ ...updatedJson.compilerOptions,
57
+ ...appJSON.compilerOptions,
58
+ },
59
+ include: [
44
60
  ...new Set([
45
61
  ...(updatedJson.include || []),
46
62
  ...(appJSON.include || []),
47
63
  ]),
48
- ], exclude: [
64
+ ],
65
+ exclude: [
49
66
  ...new Set([
50
67
  ...(updatedJson.exclude || []),
51
68
  ...(appJSON.exclude || []),
52
69
  '**e2e/**/*',
53
70
  `dist/${options.projectName}/**/*`,
54
71
  ]),
55
- ] });
72
+ ],
73
+ };
56
74
  return updatedJson;
57
75
  });
58
76
  host.delete('tsconfig.json');
@@ -1,43 +1,50 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
7
6
  const linter_1 = require("@nx/linter");
8
7
  const assertion_1 = require("@nx/react/src/utils/assertion");
9
- function normalizeOptions(host, options) {
10
- var _a;
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
13
- name: options.name,
14
- projectType: 'application',
15
- directory: options.directory,
16
- projectNameAndRootFormat: options.projectNameAndRootFormat,
17
- rootProject: options.rootProject,
18
- callingGenerator: '@nx/next:application',
19
- });
20
- options.rootProject = appProjectRoot === '.';
21
- options.projectNameAndRootFormat = projectNameAndRootFormat;
22
- const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
23
- const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
24
- const name = (0, devkit_1.names)(options.name).fileName;
25
- const outputPath = (0, devkit_1.joinPathFragments)('dist', appProjectRoot, ...(options.rootProject ? [name] : []));
26
- const parsedTags = options.tags
27
- ? options.tags.split(',').map((s) => s.trim())
28
- : [];
29
- const fileName = 'index';
30
- const appDir = (_a = options.appDir) !== null && _a !== void 0 ? _a : true;
31
- const styledModule = /^(css|scss|less|styl)$/.test(options.style)
32
- ? null
33
- : options.style;
34
- (0, assertion_1.assertValidStyle)(options.style);
35
- return Object.assign(Object.assign({}, options), { appDir,
36
- appProjectRoot,
37
- e2eProjectName,
38
- e2eProjectRoot, e2eTestRunner: options.e2eTestRunner || 'cypress', fileName, linter: options.linter || linter_1.Linter.EsLint, name,
39
- outputPath,
40
- parsedTags, projectName: appProjectName, style: options.style || 'css', styledModule, unitTestRunner: options.unitTestRunner || 'jest' });
8
+ async function normalizeOptions(host, options) {
9
+ const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
10
+ name: options.name,
11
+ projectType: 'application',
12
+ directory: options.directory,
13
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
14
+ rootProject: options.rootProject,
15
+ callingGenerator: '@nx/next:application',
41
16
  });
17
+ options.rootProject = appProjectRoot === '.';
18
+ options.projectNameAndRootFormat = projectNameAndRootFormat;
19
+ const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
20
+ const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
21
+ const name = (0, devkit_1.names)(options.name).fileName;
22
+ const outputPath = (0, devkit_1.joinPathFragments)('dist', appProjectRoot, ...(options.rootProject ? [name] : []));
23
+ const parsedTags = options.tags
24
+ ? options.tags.split(',').map((s) => s.trim())
25
+ : [];
26
+ const fileName = 'index';
27
+ const appDir = options.appDir ?? true;
28
+ const styledModule = /^(css|scss|less|styl)$/.test(options.style)
29
+ ? null
30
+ : options.style;
31
+ (0, assertion_1.assertValidStyle)(options.style);
32
+ return {
33
+ ...options,
34
+ appDir,
35
+ appProjectRoot,
36
+ e2eProjectName,
37
+ e2eProjectRoot,
38
+ e2eTestRunner: options.e2eTestRunner || 'cypress',
39
+ fileName,
40
+ linter: options.linter || linter_1.Linter.EsLint,
41
+ name,
42
+ outputPath,
43
+ parsedTags,
44
+ projectName: appProjectName,
45
+ style: options.style || 'css',
46
+ styledModule,
47
+ unitTestRunner: options.unitTestRunner || 'jest',
48
+ };
42
49
  }
43
50
  exports.normalizeOptions = normalizeOptions;
@@ -3,14 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setDefaults = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  function setDefaults(host, options) {
6
- var _a, _b, _c, _d, _e;
7
- var _f, _g, _h, _j;
8
6
  const nxJson = (0, devkit_1.readNxJson)(host);
9
- (_a = nxJson.generators) !== null && _a !== void 0 ? _a : (nxJson.generators = {});
10
- (_b = (_f = nxJson.generators)['@nx/next']) !== null && _b !== void 0 ? _b : (_f['@nx/next'] = {});
11
- (_c = (_g = nxJson.generators['@nx/next']).application) !== null && _c !== void 0 ? _c : (_g.application = {});
12
- (_d = (_h = nxJson.generators['@nx/next'].application).style) !== null && _d !== void 0 ? _d : (_h.style = options.style);
13
- (_e = (_j = nxJson.generators['@nx/next'].application).linter) !== null && _e !== void 0 ? _e : (_j.linter = options.linter);
7
+ nxJson.generators ??= {};
8
+ nxJson.generators['@nx/next'] ??= {};
9
+ nxJson.generators['@nx/next'].application ??= {};
10
+ nxJson.generators['@nx/next'].application.style ??= options.style;
11
+ nxJson.generators['@nx/next'].application.linter ??= options.linter;
14
12
  (0, devkit_1.updateNxJson)(host, nxJson);
15
13
  }
16
14
  exports.setDefaults = setDefaults;
@@ -7,7 +7,10 @@ function updateCypressTsConfig(host, options) {
7
7
  return;
8
8
  }
9
9
  (0, devkit_1.updateJson)(host, `${options.e2eProjectRoot}/tsconfig.json`, (json) => {
10
- return Object.assign(Object.assign({}, json), { exclude: [] });
10
+ return {
11
+ ...json,
12
+ exclude: [],
13
+ };
11
14
  });
12
15
  }
13
16
  exports.updateCypressTsConfig = updateCypressTsConfig;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.componentSchematic = exports.componentGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const react_1 = require("@nx/react");
7
6
  const styles_1 = require("../../utils/styles");
@@ -18,19 +17,23 @@ function getDirectory(host, options) {
18
17
  * This schematic is basically the React one, but for Next we need
19
18
  * extra dependencies for css, sass, less, styl style options.
20
19
  */
21
- function componentGenerator(host, options) {
22
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
- const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
24
- const componentInstall = yield (0, react_1.componentGenerator)(host, Object.assign(Object.assign({}, options), { directory: getDirectory(host, options), classComponent: false, routing: false, skipFormat: true }));
25
- const styledInstall = (0, styles_1.addStyleDependencies)(host, {
26
- style: options.style,
27
- swc: !host.exists((0, devkit_1.joinPathFragments)(project.root, '.babelrc')),
28
- });
29
- if (!options.skipFormat) {
30
- yield (0, devkit_1.formatFiles)(host);
31
- }
32
- return (0, devkit_1.runTasksInSerial)(styledInstall, componentInstall);
20
+ async function componentGenerator(host, options) {
21
+ const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
22
+ const componentInstall = await (0, react_1.componentGenerator)(host, {
23
+ ...options,
24
+ directory: getDirectory(host, options),
25
+ classComponent: false,
26
+ routing: false,
27
+ skipFormat: true,
33
28
  });
29
+ const styledInstall = (0, styles_1.addStyleDependencies)(host, {
30
+ style: options.style,
31
+ swc: !host.exists((0, devkit_1.joinPathFragments)(project.root, '.babelrc')),
32
+ });
33
+ if (!options.skipFormat) {
34
+ await (0, devkit_1.formatFiles)(host);
35
+ }
36
+ return (0, devkit_1.runTasksInSerial)(styledInstall, componentInstall);
34
37
  }
35
38
  exports.componentGenerator = componentGenerator;
36
39
  exports.default = componentGenerator;
@@ -1,79 +1,80 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.customServerSchematic = exports.customServerGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const path_1 = require("path");
7
- function customServerGenerator(host, options) {
8
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
11
- if (((_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.build) === null || _b === void 0 ? void 0 : _b.executor) !== '@nx/next:build' &&
12
- ((_d = (_c = project.targets) === null || _c === void 0 ? void 0 : _c.build) === null || _d === void 0 ? void 0 : _d.executor) !== '@nrwl/next:build') {
13
- devkit_1.logger.error(`Project ${options.project} is not a Next.js project. Did you generate it with "nx g @nx/next:app"?`);
14
- return;
15
- }
16
- const outputPath = (_g = (_f = (_e = project.targets) === null || _e === void 0 ? void 0 : _e.build) === null || _f === void 0 ? void 0 : _f.options) === null || _g === void 0 ? void 0 : _g.outputPath;
17
- const root = project.root;
18
- if (!root ||
19
- !outputPath ||
20
- !((_k = (_j = (_h = project.targets) === null || _h === void 0 ? void 0 : _h.build) === null || _j === void 0 ? void 0 : _j.configurations) === null || _k === void 0 ? void 0 : _k.development) ||
21
- !((_o = (_m = (_l = project.targets) === null || _l === void 0 ? void 0 : _l.build) === null || _m === void 0 ? void 0 : _m.configurations) === null || _o === void 0 ? void 0 : _o.production)) {
22
- devkit_1.logger.error(`Project ${options.project} has invalid config. Did you generate it with "nx g @nx/next:app"?`);
23
- return;
24
- }
25
- if (((_p = project.targets) === null || _p === void 0 ? void 0 : _p['build-custom-server']) ||
26
- ((_q = project.targets) === null || _q === void 0 ? void 0 : _q['serve-custom-server'])) {
27
- devkit_1.logger.warn(`Project ${options.project} has custom server targets already: build-custom-server, serve-custom-server. Remove these targets from project and try again.`);
28
- return;
29
- }
30
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files'), project.root, Object.assign(Object.assign({}, options), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(project.root), projectRoot: project.root, tmpl: '' }));
31
- project.targets.build.dependsOn = ['build-custom-server'];
32
- project.targets.serve.options.customServerTarget = `${options.project}:serve-custom-server`;
33
- project.targets.serve.configurations.development.customServerTarget = `${options.project}:serve-custom-server:development`;
34
- project.targets.serve.configurations.production.customServerTarget = `${options.project}:serve-custom-server:production`;
35
- project.targets['build-custom-server'] = {
36
- executor: '@nx/js:tsc',
37
- defaultConfiguration: 'production',
38
- options: {
39
- outputPath,
40
- main: `${root}/server/main.ts`,
41
- tsConfig: `${root}/tsconfig.server.json`,
42
- clean: false,
43
- assets: [],
44
- },
45
- configurations: {
46
- development: {},
47
- production: {},
48
- },
49
- };
50
- project.targets['serve-custom-server'] = {
51
- executor: '@nx/js:node',
52
- defaultConfiguration: 'development',
53
- options: {
54
- buildTarget: `${options.project}:build-custom-server`,
6
+ async function customServerGenerator(host, options) {
7
+ const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
8
+ if (project.targets?.build?.executor !== '@nx/next:build' &&
9
+ project.targets?.build?.executor !== '@nrwl/next:build') {
10
+ devkit_1.logger.error(`Project ${options.project} is not a Next.js project. Did you generate it with "nx g @nx/next:app"?`);
11
+ return;
12
+ }
13
+ const outputPath = project.targets?.build?.options?.outputPath;
14
+ const root = project.root;
15
+ if (!root ||
16
+ !outputPath ||
17
+ !project.targets?.build?.configurations?.development ||
18
+ !project.targets?.build?.configurations?.production) {
19
+ devkit_1.logger.error(`Project ${options.project} has invalid config. Did you generate it with "nx g @nx/next:app"?`);
20
+ return;
21
+ }
22
+ if (project.targets?.['build-custom-server'] ||
23
+ project.targets?.['serve-custom-server']) {
24
+ devkit_1.logger.warn(`Project ${options.project} has custom server targets already: build-custom-server, serve-custom-server. Remove these targets from project and try again.`);
25
+ return;
26
+ }
27
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files'), project.root, {
28
+ ...options,
29
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(project.root),
30
+ projectRoot: project.root,
31
+ tmpl: '',
32
+ });
33
+ project.targets.build.dependsOn = ['build-custom-server'];
34
+ project.targets.serve.options.customServerTarget = `${options.project}:serve-custom-server`;
35
+ project.targets.serve.configurations.development.customServerTarget = `${options.project}:serve-custom-server:development`;
36
+ project.targets.serve.configurations.production.customServerTarget = `${options.project}:serve-custom-server:production`;
37
+ project.targets['build-custom-server'] = {
38
+ executor: '@nx/js:tsc',
39
+ defaultConfiguration: 'production',
40
+ options: {
41
+ outputPath,
42
+ main: `${root}/server/main.ts`,
43
+ tsConfig: `${root}/tsconfig.server.json`,
44
+ clean: false,
45
+ assets: [],
46
+ },
47
+ configurations: {
48
+ development: {},
49
+ production: {},
50
+ },
51
+ };
52
+ project.targets['serve-custom-server'] = {
53
+ executor: '@nx/js:node',
54
+ defaultConfiguration: 'development',
55
+ options: {
56
+ buildTarget: `${options.project}:build-custom-server`,
57
+ },
58
+ configurations: {
59
+ development: {
60
+ buildTarget: `${options.project}:build-custom-server:development`,
55
61
  },
56
- configurations: {
57
- development: {
58
- buildTarget: `${options.project}:build-custom-server:development`,
59
- },
60
- production: {
61
- buildTarget: `${options.project}:build-custom-server:production`,
62
- },
62
+ production: {
63
+ buildTarget: `${options.project}:build-custom-server:production`,
63
64
  },
64
- };
65
- (0, devkit_1.updateProjectConfiguration)(host, options.project, project);
66
- (0, devkit_1.updateJson)(host, 'nx.json', (json) => {
67
- var _a, _b;
68
- var _c;
69
- (_a = json.tasksRunnerOptions) !== null && _a !== void 0 ? _a : (json.tasksRunnerOptions = {});
70
- (_b = (_c = json.tasksRunnerOptions).default) !== null && _b !== void 0 ? _b : (_c.default = { options: {} });
65
+ },
66
+ };
67
+ (0, devkit_1.updateProjectConfiguration)(host, options.project, project);
68
+ (0, devkit_1.updateJson)(host, 'nx.json', (json) => {
69
+ if (!json.tasksRunnerOptions?.default?.options?.cacheableOperations?.includes('build-custom-server')) {
70
+ json.tasksRunnerOptions ??= {};
71
+ json.tasksRunnerOptions.default ??= { options: {} };
71
72
  json.tasksRunnerOptions.default.options.cacheableOperations = [
72
73
  ...json.tasksRunnerOptions.default.options.cacheableOperations,
73
74
  'build-custom-server',
74
75
  ];
75
- return json;
76
- });
76
+ }
77
+ return json;
77
78
  });
78
79
  }
79
80
  exports.customServerGenerator = customServerGenerator;
@@ -1,75 +1,73 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cypressComponentConfiguration = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const ct_utils_1 = require("@nx/react/src/utils/ct-utils");
7
6
  const versions_1 = require("../../utils/versions");
8
7
  const react_1 = require("@nx/react");
9
8
  const path_1 = require("path");
10
- function cypressComponentConfiguration(tree, options) {
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- const tasks = [];
13
- const { componentConfigurationGenerator: baseCyCtConfig } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
14
- tasks.push(yield baseCyCtConfig(tree, {
15
- project: options.project,
16
- skipFormat: true,
17
- }));
18
- const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
19
- tasks.push(yield webpackInitGenerator(tree, {
20
- compiler: 'swc',
21
- uiFramework: 'react',
22
- skipFormat: true,
23
- }));
24
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
25
- projectConfig.targets['component-test'].options = Object.assign(Object.assign({}, projectConfig.targets['component-test'].options), { skipServe: true });
26
- (0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
27
- yield addFiles(tree, projectConfig, options);
28
- if (!options.skipFormat) {
29
- yield (0, devkit_1.formatFiles)(tree);
30
- }
31
- return (0, devkit_1.runTasksInSerial)(...tasks);
32
- });
9
+ async function cypressComponentConfiguration(tree, options) {
10
+ const tasks = [];
11
+ const { componentConfigurationGenerator: baseCyCtConfig } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
12
+ tasks.push(await baseCyCtConfig(tree, {
13
+ project: options.project,
14
+ skipFormat: true,
15
+ }));
16
+ const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
17
+ tasks.push(await webpackInitGenerator(tree, {
18
+ compiler: 'swc',
19
+ uiFramework: 'react',
20
+ skipFormat: true,
21
+ }));
22
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
23
+ projectConfig.targets['component-test'].options = {
24
+ ...projectConfig.targets['component-test'].options,
25
+ skipServe: true,
26
+ };
27
+ (0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
28
+ await addFiles(tree, projectConfig, options);
29
+ if (!options.skipFormat) {
30
+ await (0, devkit_1.formatFiles)(tree);
31
+ }
32
+ return (0, devkit_1.runTasksInSerial)(...tasks);
33
33
  }
34
34
  exports.cypressComponentConfiguration = cypressComponentConfiguration;
35
- function addFiles(tree, projectConfig, opts) {
36
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
37
- const { addMountDefinition, addDefaultCTConfig } = yield Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
38
- const ctFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
39
- const updatedCommandFile = yield addMountDefinition(tree.read(ctFile, 'utf-8'));
40
- tree.write(ctFile, `import { mount } from 'cypress/react18';\nimport './styles.ct.css';\n${updatedCommandFile}`);
41
- const cyFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts');
42
- const updatedCyConfig = yield addDefaultCTConfig(tree.read(cyFile, 'utf-8'));
43
- tree.write(cyFile, `import { nxComponentTestingPreset } from '@nx/next/plugins/component-testing';\n${updatedCyConfig}`);
44
- const isUsingTailwind = ['js', 'cjs'].some((ext) => tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, `tailwind.config.${ext}`)));
45
- tree.write((0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'styles.ct.css'), `/* This is where you can load global styles to apply to all components. */
35
+ async function addFiles(tree, projectConfig, opts) {
36
+ const { addMountDefinition, addDefaultCTConfig } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
37
+ const ctFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
38
+ const updatedCommandFile = await addMountDefinition(tree.read(ctFile, 'utf-8'));
39
+ tree.write(ctFile, `import { mount } from 'cypress/react18';\nimport './styles.ct.css';\n${updatedCommandFile}`);
40
+ const cyFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts');
41
+ const updatedCyConfig = await addDefaultCTConfig(tree.read(cyFile, 'utf-8'));
42
+ tree.write(cyFile, `import { nxComponentTestingPreset } from '@nx/next/plugins/component-testing';\n${updatedCyConfig}`);
43
+ const isUsingTailwind = ['js', 'cjs'].some((ext) => tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, `tailwind.config.${ext}`)));
44
+ tree.write((0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'styles.ct.css'), `/* This is where you can load global styles to apply to all components. */
46
45
  ${isUsingTailwind
47
- ? `@tailwind base;
46
+ ? `@tailwind base;
48
47
  @tailwind components;
49
48
  @tailwind utilities;`
50
- : ''}
49
+ : ''}
51
50
  `);
52
- if (opts.generateTests) {
53
- const filePaths = [];
54
- (0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.sourceRoot, (filePath) => {
55
- const fromProjectRootPath = (0, path_1.relative)(projectConfig.root, filePath);
56
- // we don't generate tests for pages/server-side/appDir components
57
- if (fromProjectRootPath.includes('pages') ||
58
- fromProjectRootPath.includes('server') ||
59
- fromProjectRootPath.includes('app')) {
60
- return;
61
- }
62
- if ((0, ct_utils_1.isComponent)(tree, filePath)) {
63
- filePaths.push(filePath);
64
- }
65
- });
66
- for (const filePath of filePaths) {
67
- yield (0, react_1.componentTestGenerator)(tree, {
68
- project: opts.project,
69
- componentPath: filePath,
70
- });
51
+ if (opts.generateTests) {
52
+ const filePaths = [];
53
+ (0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.sourceRoot, (filePath) => {
54
+ const fromProjectRootPath = (0, path_1.relative)(projectConfig.root, filePath);
55
+ // we don't generate tests for pages/server-side/appDir components
56
+ if (fromProjectRootPath.includes('pages') ||
57
+ fromProjectRootPath.includes('server') ||
58
+ fromProjectRootPath.includes('app')) {
59
+ return;
71
60
  }
61
+ if ((0, ct_utils_1.isComponent)(tree, filePath)) {
62
+ filePaths.push(filePath);
63
+ }
64
+ });
65
+ for (const filePath of filePaths) {
66
+ await (0, react_1.componentTestGenerator)(tree, {
67
+ project: opts.project,
68
+ componentPath: filePath,
69
+ });
72
70
  }
73
- });
71
+ }
74
72
  }
75
73
  exports.default = cypressComponentConfiguration;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nextInitSchematic = exports.nextInitGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const versions_1 = require("@nx/react/src/utils/versions");
7
6
  const init_1 = require("@nx/react/src/generators/init/init");
@@ -19,39 +18,43 @@ function updateDependencies(host) {
19
18
  'eslint-config-next': versions_2.eslintConfigNextVersion,
20
19
  });
21
20
  }
22
- function nextInitGenerator(host, schema) {
23
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
- const tasks = [];
25
- tasks.push(yield (0, js_1.initGenerator)(host, Object.assign(Object.assign({}, schema), { skipFormat: true })));
26
- if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
27
- const { jestInitGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_2.nxVersion);
28
- const jestTask = yield jestInitGenerator(host, schema);
29
- tasks.push(jestTask);
30
- }
31
- if (schema.e2eTestRunner === 'cypress') {
32
- const { cypressInitGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
33
- const cypressTask = yield cypressInitGenerator(host, {});
34
- tasks.push(cypressTask);
35
- }
36
- else if (schema.e2eTestRunner === 'playwright') {
37
- const { initGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_2.nxVersion);
38
- const playwrightTask = yield initGenerator(host, {
39
- skipFormat: true,
40
- skipPackageJson: schema.skipPackageJson,
41
- });
42
- tasks.push(playwrightTask);
43
- }
44
- // @ts-ignore
45
- // TODO(jack): remove once the React Playwright PR lands first
46
- const reactTask = yield (0, init_1.default)(host, Object.assign(Object.assign({}, schema), { skipFormat: true }));
47
- tasks.push(reactTask);
48
- if (!schema.skipPackageJson) {
49
- const installTask = updateDependencies(host);
50
- tasks.push(installTask);
51
- }
52
- (0, add_gitignore_entry_1.addGitIgnoreEntry)(host);
53
- return (0, devkit_1.runTasksInSerial)(...tasks);
21
+ async function nextInitGenerator(host, schema) {
22
+ const tasks = [];
23
+ tasks.push(await (0, js_1.initGenerator)(host, {
24
+ ...schema,
25
+ skipFormat: true,
26
+ }));
27
+ if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
28
+ const { jestInitGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_2.nxVersion);
29
+ const jestTask = await jestInitGenerator(host, schema);
30
+ tasks.push(jestTask);
31
+ }
32
+ if (schema.e2eTestRunner === 'cypress') {
33
+ const { cypressInitGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
34
+ const cypressTask = await cypressInitGenerator(host, {});
35
+ tasks.push(cypressTask);
36
+ }
37
+ else if (schema.e2eTestRunner === 'playwright') {
38
+ const { initGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_2.nxVersion);
39
+ const playwrightTask = await initGenerator(host, {
40
+ skipFormat: true,
41
+ skipPackageJson: schema.skipPackageJson,
42
+ });
43
+ tasks.push(playwrightTask);
44
+ }
45
+ // @ts-ignore
46
+ // TODO(jack): remove once the React Playwright PR lands first
47
+ const reactTask = await (0, init_1.default)(host, {
48
+ ...schema,
49
+ skipFormat: true,
54
50
  });
51
+ tasks.push(reactTask);
52
+ if (!schema.skipPackageJson) {
53
+ const installTask = updateDependencies(host);
54
+ tasks.push(installTask);
55
+ }
56
+ (0, add_gitignore_entry_1.addGitIgnoreEntry)(host);
57
+ return (0, devkit_1.runTasksInSerial)(...tasks);
55
58
  }
56
59
  exports.nextInitGenerator = nextInitGenerator;
57
60
  exports.default = nextInitGenerator;