@nx/next 20.1.2 → 20.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/next",
3
- "version": "20.1.2",
3
+ "version": "20.1.4",
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, Playwright, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
6
6
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "next": ">=14.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@nx/devkit": "20.1.2",
38
+ "@nx/devkit": "20.1.4",
39
39
  "@babel/plugin-proposal-decorators": "^7.22.7",
40
40
  "@svgr/webpack": "^8.0.1",
41
41
  "copy-webpack-plugin": "^10.2.4",
@@ -44,11 +44,11 @@
44
44
  "semver": "^7.5.3",
45
45
  "tslib": "^2.3.0",
46
46
  "webpack-merge": "^5.8.0",
47
- "@nx/js": "20.1.2",
48
- "@nx/eslint": "20.1.2",
49
- "@nx/react": "20.1.2",
50
- "@nx/web": "20.1.2",
51
- "@nx/webpack": "20.1.2",
47
+ "@nx/js": "20.1.4",
48
+ "@nx/eslint": "20.1.4",
49
+ "@nx/react": "20.1.4",
50
+ "@nx/web": "20.1.4",
51
+ "@nx/webpack": "20.1.4",
52
52
  "@phenomnomnominal/tsquery": "~5.0.1"
53
53
  },
54
54
  "publishConfig": {
@@ -154,7 +154,7 @@ function stripOuterQuotes(str) {
154
154
  }
155
155
  // Exported for testing
156
156
  function ensureFileExtensions(files, absoluteDir) {
157
- const extensions = ['.js', '.cjs', '.mjs', '.json'];
157
+ const extensions = ['.js', '.cjs', '.mjs', '.json', '.ts'];
158
158
  return files.map((file) => {
159
159
  const providedExt = (0, path_1.extname)(file);
160
160
  if (providedExt && extensions.includes(providedExt))
@@ -8,19 +8,17 @@
8
8
  "properties": {
9
9
  "path": {
10
10
  "type": "string",
11
- "description": "Path where the component will be generated.",
11
+ "description": "The file path to the component without the file extension. Relative to the current working directory.",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "Where should the component be generated?",
16
+ "x-prompt": "What is the component file path?",
17
17
  "x-priority": "important"
18
18
  },
19
19
  "name": {
20
20
  "type": "string",
21
- "description": "The name of the component.",
22
- "x-prompt": "What name would you like to use for the component?",
23
- "x-priority": "important"
21
+ "description": "The component symbol name. Defaults to the last segment of the file path."
24
22
  },
25
23
  "style": {
26
24
  "description": "The file extension to be used for style files.",
@@ -41,8 +41,31 @@ async function normalizeOptions(host, options) {
41
41
  // app/ is a reserved folder in nextjs so it is safe to check it's existence
42
42
  const isAppRouter = host.exists(`${project.root}/app`) ||
43
43
  host.exists(`${project.root}/src/app`);
44
+ let pageSymbolName = options.name;
45
+ if (!pageSymbolName) {
46
+ // if `name` is not provided, we use the last segment of the path
47
+ if (options.path !== '.' && options.path !== '') {
48
+ pageSymbolName = options.path.split('/').pop();
49
+ }
50
+ else {
51
+ // the user must have cd into a previously created directory, we need to
52
+ // resolve the cwd to get it
53
+ const cwd = (0, artifact_name_and_directory_utils_1.getRelativeCwd)();
54
+ if (cwd !== '.' && cwd !== '') {
55
+ pageSymbolName = cwd.split('/').pop();
56
+ }
57
+ else {
58
+ // this can only happen when running from the workspace root, in which
59
+ // case, we don't have a good way to automatically determine the name
60
+ throw new Error('Cannot determine the page name, please provide a `name` or `path` option.');
61
+ }
62
+ }
63
+ }
64
+ // the helper below expects a path to a file, but the `path` option here
65
+ // represents a directory, so we artificially add the symbol name to it
66
+ options.path = (0, devkit_1.joinPathFragments)(options.path, pageSymbolName);
44
67
  const { project: projectName, fileName } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
45
- name: options.name,
68
+ name: pageSymbolName,
46
69
  fileName: isAppRouter ? 'page' : 'index',
47
70
  path: options.path,
48
71
  fileExtension: 'tsx',
@@ -1,4 +1,3 @@
1
- import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
1
  import { SupportedStyles } from '@nx/react';
3
2
 
4
3
  export interface Schema {
@@ -8,19 +8,17 @@
8
8
  "properties": {
9
9
  "path": {
10
10
  "type": "string",
11
- "description": "Path where the page will be generated.",
11
+ "description": "The path to the directory where the page will be generated. Relative to the current working directory.",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "Where should the page be generated?",
16
+ "x-prompt": "Which directory do you want to create the page in?",
17
17
  "x-priority": "important"
18
18
  },
19
19
  "name": {
20
20
  "type": "string",
21
- "description": "The name of the page.",
22
- "x-prompt": "What name would you like to use for the page?",
23
- "x-priority": "important"
21
+ "description": "The page symbol name. Defaults to the page directory name."
24
22
  },
25
23
  "style": {
26
24
  "description": "The file extension to be used for style files.",
@@ -79,12 +77,6 @@
79
77
  "description": "Generate JavaScript files rather than TypeScript files.",
80
78
  "default": false
81
79
  },
82
- "flat": {
83
- "type": "boolean",
84
- "description": "Create component at the source root rather than its own directory.",
85
- "default": false,
86
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20."
87
- },
88
80
  "skipFormat": {
89
81
  "description": "Skip formatting files.",
90
82
  "type": "boolean",