@nx/next 16.3.2 → 16.4.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.3.2",
3
+ "version": "16.4.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.14.5",
38
- "@nrwl/next": "16.3.2",
39
- "@nx/devkit": "16.3.2",
40
- "@nx/js": "16.3.2",
41
- "@nx/linter": "16.3.2",
42
- "@nx/react": "16.3.2",
43
- "@nx/web": "16.3.2",
44
- "@nx/workspace": "16.3.2",
38
+ "@nrwl/next": "16.4.0-beta.1",
39
+ "@nx/devkit": "16.4.0-beta.1",
40
+ "@nx/js": "16.4.0-beta.1",
41
+ "@nx/linter": "16.4.0-beta.1",
42
+ "@nx/react": "16.4.0-beta.1",
43
+ "@nx/web": "16.4.0-beta.1",
44
+ "@nx/workspace": "16.4.0-beta.1",
45
45
  "@svgr/webpack": "^8.0.1",
46
46
  "chalk": "^4.1.0",
47
47
  "copy-webpack-plugin": "^10.2.4",
@@ -61,5 +61,5 @@
61
61
  "access": "public"
62
62
  },
63
63
  "types": "./index.d.ts",
64
- "gitHead": "097c1ca05f2fd825a6d7c70659350acd8455e144"
64
+ "gitHead": "1c4fb934b607f0d93bb23bff2cf0f39b31a8fa43"
65
65
  }
@@ -1,5 +1,5 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
- export declare function pageGenerator(host: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
3
+ export declare function pageGenerator(host: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
4
4
  export default pageGenerator;
5
5
  export declare const pageSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
@@ -10,14 +10,13 @@ const styles_1 = require("../../utils/styles");
10
10
  * extra dependencies for css, sass, less, styl style options, and make sure
11
11
  * it is under `pages` folder.
12
12
  */
13
- function pageGenerator(host, options) {
13
+ function pageGenerator(host, schema) {
14
14
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
- const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
16
- const directory = options.directory ? `pages/${options.directory}` : 'pages';
17
- const componentTask = yield (0, react_1.componentGenerator)(host, Object.assign(Object.assign({}, options), { directory, pascalCaseFiles: false, export: false, classComponent: false, routing: false, skipTests: !options.withTests, flat: !!options.flat, fileName: !options.flat ? 'index' : undefined, skipFormat: true }));
15
+ const options = normalizeOptions(host, schema);
16
+ const componentTask = yield (0, react_1.componentGenerator)(host, Object.assign(Object.assign({}, options), { project: schema.project, pascalCaseFiles: false, export: false, classComponent: false, routing: false, skipTests: !options.withTests, flat: !!options.flat, skipFormat: true }));
18
17
  const styledTask = (0, styles_1.addStyleDependencies)(host, {
19
18
  style: options.style,
20
- swc: !host.exists((0, devkit_1.joinPathFragments)(project.root, '.babelrc')),
19
+ swc: !host.exists((0, devkit_1.joinPathFragments)(options.project.root, '.babelrc')),
21
20
  });
22
21
  if (!options.skipFormat) {
23
22
  yield (0, devkit_1.formatFiles)(host);
@@ -26,5 +25,16 @@ function pageGenerator(host, options) {
26
25
  });
27
26
  }
28
27
  exports.pageGenerator = pageGenerator;
28
+ function normalizeOptions(host, options) {
29
+ const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
30
+ // app/ is a reserved folder in nextjs so it is safe to check it's existence
31
+ const isAppRouter = host.exists(`${project.root}/app`);
32
+ const routerDirectory = isAppRouter ? 'app' : 'pages';
33
+ const directory = options.directory
34
+ ? `${routerDirectory}/${options.directory}`
35
+ : `${routerDirectory}`;
36
+ const fileName = isAppRouter ? 'page' : !options.flat ? 'index' : undefined;
37
+ return Object.assign(Object.assign({}, options), { project, directory, fileName });
38
+ }
29
39
  exports.default = pageGenerator;
30
40
  exports.pageSchematic = (0, devkit_1.convertNxGenerator)(pageGenerator);