@nx/next 16.6.0 → 16.7.0-beta.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/next",
3
- "version": "16.6.0",
3
+ "version": "16.7.0-beta.1",
4
4
  "private": false,
5
5
  "description": "The Next.js plugin for Nx contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides:\n\n\n- Scaffolding for creating, building, serving, linting, and testing Next.js applications.\n\n- Integration with building, serving, and exporting a Next.js application.\n\n- Integration with React libraries within the workspace. \n\nWhen using Next.js in Nx, you get the out-of-the-box support for TypeScript, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
6
6
  "repository": {
@@ -35,13 +35,13 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@babel/plugin-proposal-decorators": "^7.22.7",
38
- "@nrwl/next": "16.6.0",
39
- "@nx/devkit": "16.6.0",
40
- "@nx/js": "16.6.0",
41
- "@nx/linter": "16.6.0",
42
- "@nx/react": "16.6.0",
43
- "@nx/web": "16.6.0",
44
- "@nx/workspace": "16.6.0",
38
+ "@nrwl/next": "16.7.0-beta.1",
39
+ "@nx/devkit": "16.7.0-beta.1",
40
+ "@nx/js": "16.7.0-beta.1",
41
+ "@nx/linter": "16.7.0-beta.1",
42
+ "@nx/react": "16.7.0-beta.1",
43
+ "@nx/web": "16.7.0-beta.1",
44
+ "@nx/workspace": "16.7.0-beta.1",
45
45
  "@svgr/webpack": "^8.0.1",
46
46
  "chalk": "^4.1.0",
47
47
  "copy-webpack-plugin": "^10.2.4",
@@ -57,5 +57,5 @@
57
57
  "access": "public"
58
58
  },
59
59
  "types": "./index.d.ts",
60
- "gitHead": "d02a8dbf06c85de78c0c76f64a17f10ae8085739"
60
+ "gitHead": "50a145bb64edcf76985184a9a83d1449dcd4f3d9"
61
61
  }
@@ -39,7 +39,12 @@ function buildExecutor(options, context) {
39
39
  // We can retrieve it inside plugins/with-nx
40
40
  (_d = (_g = process.env).NX_NEXT_OUTPUT_PATH) !== null && _d !== void 0 ? _d : (_g.NX_NEXT_OUTPUT_PATH = outputPath);
41
41
  const args = (0, create_cli_options_1.createCliOptions)({ experimentalAppOnly, profile, debug });
42
- const command = `npx next build ${args.join(' ')}`;
42
+ const isYarnBerry = (0, devkit_1.detectPackageManager)() === 'yarn' &&
43
+ (0, semver_1.gte)((0, devkit_1.getPackageManagerVersion)('yarn', devkit_1.workspaceRoot), '2.0.0');
44
+ const buildCommand = isYarnBerry
45
+ ? `yarn next build ${projectRoot}`
46
+ : 'npx next build';
47
+ const command = `${buildCommand} ${args.join(' ')}`;
43
48
  const execSyncOptions = {
44
49
  stdio: 'inherit',
45
50
  encoding: 'utf-8',
@@ -58,7 +58,7 @@ function serveExecutor(options, context) {
58
58
  process.on('SIGINT', () => killServer());
59
59
  process.on('SIGTERM', () => killServer());
60
60
  process.on('SIGHUP', () => killServer());
61
- yield (0, wait_for_port_open_1.waitForPortOpen)(port);
61
+ yield (0, wait_for_port_open_1.waitForPortOpen)(port, { host: options.hostname });
62
62
  next({
63
63
  success: true,
64
64
  baseUrl: `http://${(_a = options.hostname) !== null && _a !== void 0 ? _a : 'localhost'}:${port}`,
@@ -1,4 +1,4 @@
1
- import { Tree } from '@nx/devkit';
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
- export declare function applicationGenerator(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
3
+ export declare function applicationGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
4
  export declare const applicationSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
@@ -4,7 +4,7 @@ exports.applicationSchematic = exports.applicationGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const normalize_options_1 = require("./lib/normalize-options");
7
- const add_cypress_1 = require("./lib/add-cypress");
7
+ const add_e2e_1 = require("./lib/add-e2e");
8
8
  const add_jest_1 = require("./lib/add-jest");
9
9
  const add_project_1 = require("./lib/add-project");
10
10
  const create_application_files_1 = require("./lib/create-application-files");
@@ -18,20 +18,26 @@ const update_cypress_tsconfig_1 = require("./lib/update-cypress-tsconfig");
18
18
  const show_possible_warnings_1 = require("./lib/show-possible-warnings");
19
19
  function applicationGenerator(host, schema) {
20
20
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
+ const tasks = [];
21
22
  const options = (0, normalize_options_1.normalizeOptions)(host, schema);
22
23
  (0, show_possible_warnings_1.showPossibleWarnings)(host, options);
23
24
  const nextTask = yield (0, init_1.nextInitGenerator)(host, Object.assign(Object.assign({}, options), { skipFormat: true }));
25
+ tasks.push(nextTask);
24
26
  (0, create_application_files_1.createApplicationFiles)(host, options);
25
27
  (0, add_project_1.addProject)(host, options);
26
- const cypressTask = yield (0, add_cypress_1.addCypress)(host, options);
28
+ const e2eTask = yield (0, add_e2e_1.addE2e)(host, options);
29
+ tasks.push(e2eTask);
27
30
  const jestTask = yield (0, add_jest_1.addJest)(host, options);
31
+ tasks.push(jestTask);
28
32
  const lintTask = yield (0, add_linting_1.addLinting)(host, options);
29
- (0, update_jest_config_1.updateJestConfig)(host, options);
30
- (0, update_cypress_tsconfig_1.updateCypressTsConfig)(host, options);
33
+ tasks.push(lintTask);
31
34
  const styledTask = (0, styles_1.addStyleDependencies)(host, {
32
35
  style: options.style,
33
36
  swc: !host.exists((0, devkit_1.joinPathFragments)(options.appProjectRoot, '.babelrc')),
34
37
  });
38
+ tasks.push(styledTask);
39
+ (0, update_jest_config_1.updateJestConfig)(host, options);
40
+ (0, update_cypress_tsconfig_1.updateCypressTsConfig)(host, options);
35
41
  (0, set_defaults_1.setDefaults)(host, options);
36
42
  if (options.customServer) {
37
43
  yield (0, custom_server_1.customServerGenerator)(host, {
@@ -42,7 +48,7 @@ function applicationGenerator(host, schema) {
42
48
  if (!options.skipFormat) {
43
49
  yield (0, devkit_1.formatFiles)(host);
44
50
  }
45
- return (0, devkit_1.runTasksInSerial)(nextTask, cypressTask, jestTask, lintTask, styledTask);
51
+ return (0, devkit_1.runTasksInSerial)(...tasks);
46
52
  });
47
53
  }
48
54
  exports.applicationGenerator = applicationGenerator;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function addE2e(host: Tree, options: NormalizedSchema): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addE2e = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const linter_1 = require("@nx/linter");
7
+ const versions_1 = require("../../../utils/versions");
8
+ function addE2e(host, options) {
9
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
+ if (options.e2eTestRunner === 'cypress') {
11
+ const { cypressProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
12
+ return cypressProjectGenerator(host, Object.assign(Object.assign({}, options), { linter: linter_1.Linter.EsLint, name: options.e2eProjectName, directory: options.directory, project: options.projectName, skipFormat: true }));
13
+ }
14
+ else if (options.e2eTestRunner === 'playwright') {
15
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
16
+ (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
17
+ root: options.e2eProjectRoot,
18
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, ''),
19
+ targets: {},
20
+ implicitDependencies: [options.projectName],
21
+ });
22
+ return configurationGenerator(host, {
23
+ project: options.e2eProjectName,
24
+ skipFormat: true,
25
+ skipPackageJson: options.skipPackageJson,
26
+ directory: 'src',
27
+ js: false,
28
+ linter: options.linter,
29
+ setParserOptionsProject: options.setParserOptionsProject,
30
+ webServerAddress: 'http://127.0.0.1:4200',
31
+ webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
32
+ });
33
+ }
34
+ return () => { };
35
+ });
36
+ }
37
+ exports.addE2e = addE2e;
@@ -8,7 +8,7 @@ export interface Schema {
8
8
  directory?: string;
9
9
  tags?: string;
10
10
  unitTestRunner?: 'jest' | 'none';
11
- e2eTestRunner?: 'cypress' | 'none';
11
+ e2eTestRunner?: 'cypress' | 'playwright' | 'none';
12
12
  linter?: Linter;
13
13
  js?: boolean;
14
14
  setParserOptionsProject?: boolean;
@@ -84,8 +84,9 @@
84
84
  },
85
85
  "e2eTestRunner": {
86
86
  "type": "string",
87
- "enum": ["cypress", "none"],
87
+ "enum": ["cypress", "playwright", "none"],
88
88
  "description": "Test runner to use for end to end (E2E) tests.",
89
+ "x-prompt": "Which E2E test runner would you like to use?",
89
90
  "default": "cypress"
90
91
  },
91
92
  "tags": {
@@ -28,11 +28,21 @@ function nextInitGenerator(host, schema) {
28
28
  const jestTask = yield jestInitGenerator(host, schema);
29
29
  tasks.push(jestTask);
30
30
  }
31
- if (!schema.e2eTestRunner || schema.e2eTestRunner === 'cypress') {
31
+ if (schema.e2eTestRunner === 'cypress') {
32
32
  const { cypressInitGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
33
33
  const cypressTask = yield cypressInitGenerator(host, {});
34
34
  tasks.push(cypressTask);
35
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
36
46
  const reactTask = yield (0, init_1.default)(host, Object.assign(Object.assign({}, schema), { skipFormat: true }));
37
47
  tasks.push(reactTask);
38
48
  if (!schema.skipPackageJson) {
@@ -1,6 +1,6 @@
1
1
  export interface InitSchema {
2
2
  unitTestRunner?: 'jest' | 'none';
3
- e2eTestRunner?: 'cypress' | 'none';
3
+ e2eTestRunner?: 'cypress' | 'playwright' | 'none';
4
4
  skipFormat?: boolean;
5
5
  js?: boolean;
6
6
  skipPackageJson?: boolean;
@@ -1,3 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import { NormalizedSchema } from './normalize-options';
3
- export declare function addCypress(host: Tree, options: NormalizedSchema): Promise<() => void>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addCypress = void 0;
4
- const tslib_1 = require("tslib");
5
- const devkit_1 = require("@nx/devkit");
6
- const linter_1 = require("@nx/linter");
7
- const versions_1 = require("../../../utils/versions");
8
- function addCypress(host, options) {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- if (options.e2eTestRunner !== 'cypress') {
11
- return () => { };
12
- }
13
- const { cypressProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
14
- return cypressProjectGenerator(host, Object.assign(Object.assign({}, options), { linter: linter_1.Linter.EsLint, name: options.e2eProjectName, directory: options.directory, project: options.projectName, skipFormat: true }));
15
- });
16
- }
17
- exports.addCypress = addCypress;