@nx/next 16.0.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/CHANGELOG.md +8 -0
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/babel.d.ts +0 -0
- package/babel.js +13 -0
- package/babel.js.map +1 -0
- package/executors.json +36 -0
- package/generators.json +72 -0
- package/index.d.ts +8 -0
- package/index.js +20 -0
- package/index.js.map +1 -0
- package/migrations.json +312 -0
- package/package.json +64 -0
- package/plugins/with-less.d.ts +2 -0
- package/plugins/with-less.js +79 -0
- package/plugins/with-less.js.map +1 -0
- package/plugins/with-nx.d.ts +13 -0
- package/plugins/with-nx.js +278 -0
- package/plugins/with-nx.js.map +1 -0
- package/plugins/with-stylus.d.ts +2 -0
- package/plugins/with-stylus.js +79 -0
- package/plugins/with-stylus.js.map +1 -0
- package/src/executors/build/build.impl.d.ts +6 -0
- package/src/executors/build/build.impl.js +62 -0
- package/src/executors/build/build.impl.js.map +1 -0
- package/src/executors/build/compat.d.ts +2 -0
- package/src/executors/build/compat.js +6 -0
- package/src/executors/build/compat.js.map +1 -0
- package/src/executors/build/lib/check-project.d.ts +1 -0
- package/src/executors/build/lib/check-project.js +13 -0
- package/src/executors/build/lib/check-project.js.map +1 -0
- package/src/executors/build/lib/create-next-config-file.d.ts +3 -0
- package/src/executors/build/lib/create-next-config-file.js +15 -0
- package/src/executors/build/lib/create-next-config-file.js.map +1 -0
- package/src/executors/build/lib/update-package-json.d.ts +3 -0
- package/src/executors/build/lib/update-package-json.js +24 -0
- package/src/executors/build/lib/update-package-json.js.map +1 -0
- package/src/executors/build/schema.json +68 -0
- package/src/executors/export/compat.d.ts +2 -0
- package/src/executors/export/compat.js +6 -0
- package/src/executors/export/compat.js.map +1 -0
- package/src/executors/export/export.impl.d.ts +6 -0
- package/src/executors/export/export.impl.js +53 -0
- package/src/executors/export/export.impl.js.map +1 -0
- package/src/executors/export/schema.json +30 -0
- package/src/executors/server/compat.d.ts +2 -0
- package/src/executors/server/compat.js +6 -0
- package/src/executors/server/compat.js.map +1 -0
- package/src/executors/server/lib/default-server.d.ts +6 -0
- package/src/executors/server/lib/default-server.js +31 -0
- package/src/executors/server/lib/default-server.js.map +1 -0
- package/src/executors/server/lib/tsnode-register.d.ts +1 -0
- package/src/executors/server/lib/tsnode-register.js +23 -0
- package/src/executors/server/lib/tsnode-register.js.map +1 -0
- package/src/executors/server/schema.json +56 -0
- package/src/executors/server/server.impl.d.ts +7 -0
- package/src/executors/server/server.impl.js +114 -0
- package/src/executors/server/server.impl.js.map +1 -0
- package/src/generators/application/application.d.ts +4 -0
- package/src/generators/application/application.js +43 -0
- package/src/generators/application/application.js.map +1 -0
- package/src/generators/application/files/app/api/hello/route.ts__tmpl__ +4 -0
- package/src/generators/application/files/app/global.__stylesExt____tmpl__ +1 -0
- package/src/generators/application/files/app/layout.tsx__tmpl__ +22 -0
- package/src/generators/application/files/app/page.module.__style__ +1 -0
- package/src/generators/application/files/app/page.tsx__tmpl__ +28 -0
- package/src/generators/application/files/common/.babelrc__tmpl__ +21 -0
- package/src/generators/application/files/common/index.d.ts__tmpl__ +18 -0
- package/src/generators/application/files/common/next-env.d.ts__tmpl__ +5 -0
- package/src/generators/application/files/common/next.config.js__tmpl__ +112 -0
- package/src/generators/application/files/common/public/.gitkeep +0 -0
- package/src/generators/application/files/common/public/favicon.ico +0 -0
- package/src/generators/application/files/common/specs/__fileName__.spec.tsx__tmpl__ +11 -0
- package/src/generators/application/files/common/tsconfig.json__tmpl__ +18 -0
- package/src/generators/application/files/pages/__fileName__.module.__style__ +1 -0
- package/src/generators/application/files/pages/__fileName__.tsx__tmpl__ +28 -0
- package/src/generators/application/files/pages/_app.tsx__tmpl__ +18 -0
- package/src/generators/application/files/pages/_document.tsx__tmpl__ +33 -0
- package/src/generators/application/files/pages/styles.__stylesExt____tmpl__ +1 -0
- package/src/generators/application/lib/add-cypress.d.ts +3 -0
- package/src/generators/application/lib/add-cypress.js +18 -0
- package/src/generators/application/lib/add-cypress.js.map +1 -0
- package/src/generators/application/lib/add-jest.d.ts +3 -0
- package/src/generators/application/lib/add-jest.js +36 -0
- package/src/generators/application/lib/add-jest.js.map +1 -0
- package/src/generators/application/lib/add-linting.d.ts +3 -0
- package/src/generators/application/lib/add-linting.js +66 -0
- package/src/generators/application/lib/add-linting.js.map +1 -0
- package/src/generators/application/lib/add-project.d.ts +3 -0
- package/src/generators/application/lib/add-project.js +56 -0
- package/src/generators/application/lib/add-project.js.map +1 -0
- package/src/generators/application/lib/create-application-files.d.ts +3 -0
- package/src/generators/application/lib/create-application-files.helpers.d.ts +2 -0
- package/src/generators/application/lib/create-application-files.helpers.js +785 -0
- package/src/generators/application/lib/create-application-files.helpers.js.map +1 -0
- package/src/generators/application/lib/create-application-files.js +40 -0
- package/src/generators/application/lib/create-application-files.js.map +1 -0
- package/src/generators/application/lib/normalize-options.d.ts +13 -0
- package/src/generators/application/lib/normalize-options.js +35 -0
- package/src/generators/application/lib/normalize-options.js.map +1 -0
- package/src/generators/application/lib/set-defaults.d.ts +3 -0
- package/src/generators/application/lib/set-defaults.js +14 -0
- package/src/generators/application/lib/set-defaults.js.map +1 -0
- package/src/generators/application/lib/update-jest-config.d.ts +3 -0
- package/src/generators/application/lib/update-jest-config.js +16 -0
- package/src/generators/application/lib/update-jest-config.js.map +1 -0
- package/src/generators/application/schema.d.ts +19 -0
- package/src/generators/application/schema.json +131 -0
- package/src/generators/component/component.d.ts +15 -0
- package/src/generators/component/component.js +34 -0
- package/src/generators/component/component.js.map +1 -0
- package/src/generators/component/schema.json +119 -0
- package/src/generators/custom-server/custom-server.d.ts +4 -0
- package/src/generators/custom-server/custom-server.js +79 -0
- package/src/generators/custom-server/custom-server.js.map +1 -0
- package/src/generators/custom-server/files/server/main.ts__tmpl__ +46 -0
- package/src/generators/custom-server/files/tsconfig.server.json__tmpl__ +15 -0
- package/src/generators/custom-server/schema.d.ts +4 -0
- package/src/generators/custom-server/schema.json +30 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +49 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +39 -0
- package/src/generators/library/lib/normalize-options.d.ts +7 -0
- package/src/generators/library/lib/normalize-options.js +17 -0
- package/src/generators/library/lib/normalize-options.js.map +1 -0
- package/src/generators/library/library.d.ts +5 -0
- package/src/generators/library/library.js +79 -0
- package/src/generators/library/library.js.map +1 -0
- package/src/generators/library/schema.d.ts +25 -0
- package/src/generators/library/schema.json +156 -0
- package/src/generators/page/page.d.ts +5 -0
- package/src/generators/page/page.js +27 -0
- package/src/generators/page/page.js.map +1 -0
- package/src/generators/page/schema.d.ts +13 -0
- package/src/generators/page/schema.json +107 -0
- package/src/migrations/update-12-10-0/fix-page-dir-for-eslint.d.ts +3 -0
- package/src/migrations/update-12-10-0/fix-page-dir-for-eslint.js +34 -0
- package/src/migrations/update-12-10-0/fix-page-dir-for-eslint.js.map +1 -0
- package/src/migrations/update-12-8-0/remove-styled-jsx-babel-plugin.d.ts +3 -0
- package/src/migrations/update-12-8-0/remove-styled-jsx-babel-plugin.js +26 -0
- package/src/migrations/update-12-8-0/remove-styled-jsx-babel-plugin.js.map +1 -0
- package/src/migrations/update-13-0-0/update-emotion-setup.d.ts +3 -0
- package/src/migrations/update-13-0-0/update-emotion-setup.js +39 -0
- package/src/migrations/update-13-0-0/update-emotion-setup.js.map +1 -0
- package/src/migrations/update-13-0-0/update-to-webpack-5.d.ts +3 -0
- package/src/migrations/update-13-0-0/update-to-webpack-5.js +32 -0
- package/src/migrations/update-13-0-0/update-to-webpack-5.js.map +1 -0
- package/src/migrations/update-13-0-3/fix-less.d.ts +3 -0
- package/src/migrations/update-13-0-3/fix-less.js +27 -0
- package/src/migrations/update-13-0-3/fix-less.js.map +1 -0
- package/src/migrations/update-13-1-1/enable-swc.d.ts +3 -0
- package/src/migrations/update-13-1-1/enable-swc.js +46 -0
- package/src/migrations/update-13-1-1/enable-swc.js.map +1 -0
- package/src/migrations/update-14-0-0/add-default-development-configurations.d.ts +3 -0
- package/src/migrations/update-14-0-0/add-default-development-configurations.js +36 -0
- package/src/migrations/update-14-0-0/add-default-development-configurations.js.map +1 -0
- package/src/migrations/update-14-4-3/add-dev-output-path.d.ts +3 -0
- package/src/migrations/update-14-4-3/add-dev-output-path.js +24 -0
- package/src/migrations/update-14-4-3/add-dev-output-path.js.map +1 -0
- package/src/migrations/update-14-5-3/add-gitignore-entry.d.ts +3 -0
- package/src/migrations/update-14-5-3/add-gitignore-entry.js +15 -0
- package/src/migrations/update-14-5-3/add-gitignore-entry.js.map +1 -0
- package/src/migrations/update-14-5-3/update-dev-output-path.d.ts +3 -0
- package/src/migrations/update-14-5-3/update-dev-output-path.js +29 -0
- package/src/migrations/update-14-5-3/update-dev-output-path.js.map +1 -0
- package/src/migrations/update-14-5-7/update-next-eslint.d.ts +3 -0
- package/src/migrations/update-14-5-7/update-next-eslint.js +32 -0
- package/src/migrations/update-14-5-7/update-next-eslint.js.map +1 -0
- package/src/migrations/update-15-8-8/add-style-packages.d.ts +3 -0
- package/src/migrations/update-15-8-8/add-style-packages.js +28 -0
- package/src/migrations/update-15-8-8/add-style-packages.js.map +1 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
- package/src/utils/add-gitignore-entry.d.ts +2 -0
- package/src/utils/add-gitignore-entry.js +18 -0
- package/src/utils/add-gitignore-entry.js.map +1 -0
- package/src/utils/config-invalid-function.fixture.d.ts +0 -0
- package/src/utils/config-invalid-function.fixture.js +2 -0
- package/src/utils/config-invalid-function.fixture.js.map +1 -0
- package/src/utils/config-not-a-function.fixture.d.ts +0 -0
- package/src/utils/config-not-a-function.fixture.js +2 -0
- package/src/utils/config-not-a-function.fixture.js.map +1 -0
- package/src/utils/config.d.ts +15 -0
- package/src/utils/config.fixture.d.ts +0 -0
- package/src/utils/config.fixture.js +4 -0
- package/src/utils/config.fixture.js.map +1 -0
- package/src/utils/config.js +87 -0
- package/src/utils/config.js.map +1 -0
- package/src/utils/constants.d.ts +1 -0
- package/src/utils/constants.js +5 -0
- package/src/utils/constants.js.map +1 -0
- package/src/utils/create-copy-plugin.d.ts +2 -0
- package/src/utils/create-copy-plugin.js +63 -0
- package/src/utils/create-copy-plugin.js.map +1 -0
- package/src/utils/generate-globs.d.ts +5 -0
- package/src/utils/generate-globs.js +30 -0
- package/src/utils/generate-globs.js.map +1 -0
- package/src/utils/styles.d.ts +40 -0
- package/src/utils/styles.js +56 -0
- package/src/utils/styles.js.map +1 -0
- package/src/utils/types.d.ts +53 -0
- package/src/utils/types.js +3 -0
- package/src/utils/types.js.map +1 -0
- package/src/utils/versions.d.ts +9 -0
- package/src/utils/versions.js +13 -0
- package/src/utils/versions.js.map +1 -0
- package/tailwind.d.ts +2 -0
- package/tailwind.js +7 -0
- package/tailwind.js.map +1 -0
- package/typings/image.d.ts +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-application-files.helpers.js","sourceRoot":"","sources":["../../../../../../../packages/next/src/generators/application/lib/create-application-files.helpers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO;;;;;;sBAMa,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmYvB,CAAC;AACJ,CAAC;AA3YD,oCA2YC;AAED,SAAgB,gBAAgB;IAC9B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4XN,CAAC;AACJ,CAAC;AA9XD,4CA8XC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createApplicationFiles = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const js_1 = require("@nx/js");
|
|
7
|
+
const create_application_files_helpers_1 = require("./create-application-files.helpers");
|
|
8
|
+
function createApplicationFiles(host, options) {
|
|
9
|
+
const templateVariables = Object.assign(Object.assign(Object.assign({}, (0, devkit_1.names)(options.name)), options), { tmpl: '', rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot), appContent: (0, create_application_files_helpers_1.createAppJsx)(options.name), styleContent: (0, create_application_files_helpers_1.createStyleRules)(), pageStyleContent: `.page {}`, stylesExt: options.style === 'less' || options.style === 'styl'
|
|
10
|
+
? options.style
|
|
11
|
+
: 'css' });
|
|
12
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/common'), options.appProjectRoot, templateVariables);
|
|
13
|
+
if (options.appDir) {
|
|
14
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), (0, path_1.join)(options.appProjectRoot, 'app'), templateVariables);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/pages'), (0, path_1.join)(options.appProjectRoot, 'pages'), templateVariables);
|
|
18
|
+
}
|
|
19
|
+
if (options.unitTestRunner === 'none') {
|
|
20
|
+
host.delete(`${options.appProjectRoot}/specs/${options.fileName}.spec.tsx`);
|
|
21
|
+
}
|
|
22
|
+
// SWC will be disabled if custom babelrc is provided.
|
|
23
|
+
// Check for `!== false` because `create-nx-workspace` is not passing default values.
|
|
24
|
+
if (options.swc !== false) {
|
|
25
|
+
host.delete(`${options.appProjectRoot}/.babelrc`);
|
|
26
|
+
}
|
|
27
|
+
if (options.styledModule) {
|
|
28
|
+
host.delete(`${options.appProjectRoot}/pages/${options.fileName}.module.${options.style}`);
|
|
29
|
+
}
|
|
30
|
+
if (options.style !== 'styled-components') {
|
|
31
|
+
host.delete(`${options.appProjectRoot}/pages/_document.tsx`);
|
|
32
|
+
}
|
|
33
|
+
if (options.js) {
|
|
34
|
+
host.delete(`${options.appProjectRoot}/index.d.ts`);
|
|
35
|
+
(0, devkit_1.toJS)(host);
|
|
36
|
+
host.delete(`${options.appProjectRoot}/next-env.d.js`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.createApplicationFiles = createApplicationFiles;
|
|
40
|
+
//# sourceMappingURL=create-application-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-application-files.js","sourceRoot":"","sources":["../../../../../../../packages/next/src/generators/application/lib/create-application-files.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,uCAA8D;AAC9D,+BAAuD;AAGvD,yFAG4C;AAE5C,SAAgB,sBAAsB,CAAC,IAAU,EAAE,OAAyB;IAC1E,MAAM,iBAAiB,iDAClB,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,GACnB,OAAO,KACV,IAAI,EAAE,EAAE,EACR,gBAAgB,EAAE,IAAA,kCAA6B,EAC7C,IAAI,EACJ,OAAO,CAAC,cAAc,CACvB,EACD,UAAU,EAAE,IAAA,+CAAY,EAAC,OAAO,CAAC,IAAI,CAAC,EACtC,YAAY,EAAE,IAAA,mDAAgB,GAAE,EAChC,gBAAgB,EAAE,UAAU,EAC5B,SAAS,EACP,OAAO,CAAC,KAAK,KAAK,MAAM,IAAI,OAAO,CAAC,KAAK,KAAK,MAAM;YAClD,CAAC,CAAC,OAAO,CAAC,KAAK;YACf,CAAC,CAAC,KAAK,GACZ,CAAC;IAEF,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,WAAI,EAAC,SAAS,EAAE,iBAAiB,CAAC,EAClC,OAAO,CAAC,cAAc,EACtB,iBAAiB,CAClB,CAAC;IAEF,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,WAAI,EAAC,SAAS,EAAE,cAAc,CAAC,EAC/B,IAAA,WAAI,EAAC,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC,EACnC,iBAAiB,CAClB,CAAC;KACH;SAAM;QACL,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,WAAI,EAAC,SAAS,EAAE,gBAAgB,CAAC,EACjC,IAAA,WAAI,EAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,EACrC,iBAAiB,CAClB,CAAC;KACH;IAED,IAAI,OAAO,CAAC,cAAc,KAAK,MAAM,EAAE;QACrC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,cAAc,UAAU,OAAO,CAAC,QAAQ,WAAW,CAAC,CAAC;KAC7E;IAED,sDAAsD;IACtD,qFAAqF;IACrF,IAAI,OAAO,CAAC,GAAG,KAAK,KAAK,EAAE;QACzB,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,cAAc,WAAW,CAAC,CAAC;KACnD;IAED,IAAI,OAAO,CAAC,YAAY,EAAE;QACxB,IAAI,CAAC,MAAM,CACT,GAAG,OAAO,CAAC,cAAc,UAAU,OAAO,CAAC,QAAQ,WAAW,OAAO,CAAC,KAAK,EAAE,CAC9E,CAAC;KACH;IAED,IAAI,OAAO,CAAC,KAAK,KAAK,mBAAmB,EAAE;QACzC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,cAAc,sBAAsB,CAAC,CAAC;KAC9D;IAED,IAAI,OAAO,CAAC,EAAE,EAAE;QACd,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,cAAc,aAAa,CAAC,CAAC;QACpD,IAAA,aAAI,EAAC,IAAI,CAAC,CAAC;QACX,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,cAAc,gBAAgB,CAAC,CAAC;KACxD;AACH,CAAC;AAlED,wDAkEC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from '../schema';
|
|
3
|
+
export interface NormalizedSchema extends Schema {
|
|
4
|
+
projectName: string;
|
|
5
|
+
appProjectRoot: string;
|
|
6
|
+
e2eProjectName: string;
|
|
7
|
+
e2eProjectRoot: string;
|
|
8
|
+
parsedTags: string[];
|
|
9
|
+
fileName: string;
|
|
10
|
+
styledModule: null | string;
|
|
11
|
+
js?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function normalizeOptions(host: Tree, options: Schema): NormalizedSchema;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeOptions = void 0;
|
|
4
|
+
const assertion_1 = require("@nx/react/src/utils/assertion");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const linter_1 = require("@nx/linter");
|
|
7
|
+
function normalizeOptions(host, options) {
|
|
8
|
+
var _a;
|
|
9
|
+
const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
|
|
10
|
+
const appDirectory = projectDirectory
|
|
11
|
+
? `${(0, devkit_1.names)(projectDirectory).fileName}/${(0, devkit_1.names)(options.name).fileName}`
|
|
12
|
+
: (0, devkit_1.names)(options.name).fileName;
|
|
13
|
+
const appsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : (0, devkit_1.getWorkspaceLayout)(host).appsDir;
|
|
14
|
+
const appProjectName = appDirectory.replace(new RegExp('/', 'g'), '-');
|
|
15
|
+
const e2eProjectName = `${appProjectName}-e2e`;
|
|
16
|
+
const appProjectRoot = (0, devkit_1.joinPathFragments)(appsDir, appDirectory);
|
|
17
|
+
const e2eProjectRoot = (0, devkit_1.joinPathFragments)(appsDir, `${appDirectory}-e2e`);
|
|
18
|
+
const parsedTags = options.tags
|
|
19
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
20
|
+
: [];
|
|
21
|
+
const fileName = 'index';
|
|
22
|
+
const appDir = (_a = options.appDir) !== null && _a !== void 0 ? _a : false;
|
|
23
|
+
const styledModule = /^(css|scss|less|styl)$/.test(options.style)
|
|
24
|
+
? null
|
|
25
|
+
: options.style;
|
|
26
|
+
(0, assertion_1.assertValidStyle)(options.style);
|
|
27
|
+
return Object.assign(Object.assign({}, options), { appDir, name: (0, devkit_1.names)(options.name).fileName, projectName: appProjectName, linter: options.linter || linter_1.Linter.EsLint, unitTestRunner: options.unitTestRunner || 'jest', e2eTestRunner: options.e2eTestRunner || 'cypress', style: options.style || 'css', appProjectRoot,
|
|
28
|
+
e2eProjectRoot,
|
|
29
|
+
e2eProjectName,
|
|
30
|
+
parsedTags,
|
|
31
|
+
fileName,
|
|
32
|
+
styledModule });
|
|
33
|
+
}
|
|
34
|
+
exports.normalizeOptions = normalizeOptions;
|
|
35
|
+
//# sourceMappingURL=normalize-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../../../../../../../packages/next/src/generators/application/lib/normalize-options.ts"],"names":[],"mappings":";;;AAAA,6DAAiE;AACjE,uCAMoB;AACpB,uCAAoC;AAepC,SAAgB,gBAAgB,CAC9B,IAAU,EACV,OAAe;;IAEf,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,GAAG,IAAA,+BAAsB,EAClE,OAAO,CAAC,SAAS,CAClB,CAAC;IAEF,MAAM,YAAY,GAAG,gBAAgB;QACnC,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC,QAAQ,IAAI,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;QACvE,CAAC,CAAC,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAEjC,MAAM,OAAO,GAAG,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC;IAEpE,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACvE,MAAM,cAAc,GAAG,GAAG,cAAc,MAAM,CAAC;IAE/C,MAAM,cAAc,GAAG,IAAA,0BAAiB,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAChE,MAAM,cAAc,GAAG,IAAA,0BAAiB,EAAC,OAAO,EAAE,GAAG,YAAY,MAAM,CAAC,CAAC;IAEzE,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI;QAC7B,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9C,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,QAAQ,GAAG,OAAO,CAAC;IAEzB,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,KAAK,CAAC;IAEvC,MAAM,YAAY,GAAG,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC/D,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAElB,IAAA,4BAAgB,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAEhC,uCACK,OAAO,KACV,MAAM,EACN,IAAI,EAAE,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAClC,WAAW,EAAE,cAAc,EAC3B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,eAAM,CAAC,MAAM,EACvC,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,MAAM,EAChD,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,SAAS,EACjD,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK,EAC7B,cAAc;QACd,cAAc;QACd,cAAc;QACd,UAAU;QACV,QAAQ;QACR,YAAY,IACZ;AACJ,CAAC;AAlDD,4CAkDC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setDefaults = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function setDefaults(host, options) {
|
|
6
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
7
|
+
nxJson.generators = nxJson.generators || {};
|
|
8
|
+
nxJson.generators['@nrwl/next'] = nxJson.generators['@nrwl/next'] || {};
|
|
9
|
+
const prev = nxJson.generators['@nrwl/next'];
|
|
10
|
+
nxJson.generators = Object.assign(Object.assign({}, nxJson.generators), { '@nrwl/next': Object.assign(Object.assign({}, prev), { application: Object.assign({ style: options.style, linter: options.linter }, prev.application) }) });
|
|
11
|
+
(0, devkit_1.updateNxJson)(host, nxJson);
|
|
12
|
+
}
|
|
13
|
+
exports.setDefaults = setDefaults;
|
|
14
|
+
//# sourceMappingURL=set-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-defaults.js","sourceRoot":"","sources":["../../../../../../../packages/next/src/generators/application/lib/set-defaults.ts"],"names":[],"mappings":";;;AAAA,uCAA4D;AAI5D,SAAgB,WAAW,CAAC,IAAU,EAAE,OAAyB;IAC/D,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;IAEhC,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;IAC5C,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IACxE,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAE7C,MAAM,CAAC,UAAU,mCACZ,MAAM,CAAC,UAAU,KACpB,YAAY,kCACP,IAAI,KACP,WAAW,kBACT,KAAK,EAAE,OAAO,CAAC,KAAK,EACpB,MAAM,EAAE,OAAO,CAAC,MAAM,IACnB,IAAI,CAAC,WAAW,OAGxB,CAAC;IACF,IAAA,qBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC;AAnBD,kCAmBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateJestConfig = void 0;
|
|
4
|
+
function updateJestConfig(host, options) {
|
|
5
|
+
if (options.unitTestRunner !== 'jest') {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const configPath = `${options.appProjectRoot}/jest.config.${options.js ? 'js' : 'ts'}`;
|
|
9
|
+
const originalContent = host.read(configPath, 'utf-8');
|
|
10
|
+
const content = originalContent
|
|
11
|
+
.replace('transform: {', "transform: {\n '^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',")
|
|
12
|
+
.replace(`'babel-jest'`, `['babel-jest', { presets: ['@nrwl/next/babel'] }]`);
|
|
13
|
+
host.write(configPath, content);
|
|
14
|
+
}
|
|
15
|
+
exports.updateJestConfig = updateJestConfig;
|
|
16
|
+
//# sourceMappingURL=update-jest-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-jest-config.js","sourceRoot":"","sources":["../../../../../../../packages/next/src/generators/application/lib/update-jest-config.ts"],"names":[],"mappings":";;;AAGA,SAAgB,gBAAgB,CAAC,IAAU,EAAE,OAAyB;IACpE,IAAI,OAAO,CAAC,cAAc,KAAK,MAAM,EAAE;QACrC,OAAO;KACR;IAED,MAAM,UAAU,GAAG,GAAG,OAAO,CAAC,cAAc,gBAC1C,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IACtB,EAAE,CAAC;IACH,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,eAAe;SAC5B,OAAO,CACN,cAAc,EACd,wFAAwF,CACzF;SACA,OAAO,CACN,cAAc,EACd,mDAAmD,CACpD,CAAC;IACJ,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAClC,CAAC;AAnBD,4CAmBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Linter } from '@nx/linter';
|
|
2
|
+
import { SupportedStyles } from '@nx/react';
|
|
3
|
+
|
|
4
|
+
export interface Schema {
|
|
5
|
+
name: string;
|
|
6
|
+
style?: SupportedStyles;
|
|
7
|
+
skipFormat?: boolean;
|
|
8
|
+
directory?: string;
|
|
9
|
+
tags?: string;
|
|
10
|
+
unitTestRunner?: 'jest' | 'none';
|
|
11
|
+
e2eTestRunner?: 'cypress' | 'none';
|
|
12
|
+
linter?: Linter;
|
|
13
|
+
js?: boolean;
|
|
14
|
+
setParserOptionsProject?: boolean;
|
|
15
|
+
swc?: boolean;
|
|
16
|
+
customServer?: boolean;
|
|
17
|
+
skipPackageJson?: boolean;
|
|
18
|
+
appDir?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxNextApp",
|
|
5
|
+
"title": "Create a Next.js Application for Nx",
|
|
6
|
+
"description": "Create a Next.js Application for Nx.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"description": "The name of the application.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-prompt": "What name would you like to use for the application?",
|
|
17
|
+
"pattern": "^[a-zA-Z].*$",
|
|
18
|
+
"x-priority": "important"
|
|
19
|
+
},
|
|
20
|
+
"directory": {
|
|
21
|
+
"description": "The directory of the new application.",
|
|
22
|
+
"type": "string",
|
|
23
|
+
"alias": "d",
|
|
24
|
+
"x-priority": "important"
|
|
25
|
+
},
|
|
26
|
+
"style": {
|
|
27
|
+
"description": "The file extension to be used for style files.",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"default": "css",
|
|
30
|
+
"alias": "s",
|
|
31
|
+
"x-prompt": {
|
|
32
|
+
"message": "Which stylesheet format would you like to use?",
|
|
33
|
+
"type": "list",
|
|
34
|
+
"items": [
|
|
35
|
+
{ "value": "css", "label": "CSS" },
|
|
36
|
+
{
|
|
37
|
+
"value": "scss",
|
|
38
|
+
"label": "SASS(.scss) [ http://sass-lang.com ]"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"value": "less",
|
|
42
|
+
"label": "LESS [ http://lesscss.org ]"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"value": "styled-components",
|
|
46
|
+
"label": "styled-components [ https://styled-components.com ]"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"value": "@emotion/styled",
|
|
50
|
+
"label": "emotion [ https://emotion.sh ]"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"value": "styled-jsx",
|
|
54
|
+
"label": "styled-jsx [ https://www.npmjs.com/package/styled-jsx ]"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"value": "none",
|
|
58
|
+
"label": "None"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"value": "styl",
|
|
62
|
+
"label": "Stylus(.styl) [ http://stylus-lang.com ] (DEPRECATED)"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"linter": {
|
|
68
|
+
"description": "The tool to use for running lint checks.",
|
|
69
|
+
"type": "string",
|
|
70
|
+
"enum": ["eslint"],
|
|
71
|
+
"default": "eslint"
|
|
72
|
+
},
|
|
73
|
+
"skipFormat": {
|
|
74
|
+
"description": "Skip formatting files.",
|
|
75
|
+
"type": "boolean",
|
|
76
|
+
"default": false,
|
|
77
|
+
"x-priority": "internal"
|
|
78
|
+
},
|
|
79
|
+
"unitTestRunner": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"enum": ["jest", "none"],
|
|
82
|
+
"description": "Test runner to use for unit tests.",
|
|
83
|
+
"default": "jest"
|
|
84
|
+
},
|
|
85
|
+
"e2eTestRunner": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"enum": ["cypress", "none"],
|
|
88
|
+
"description": "Test runner to use for end to end (E2E) tests.",
|
|
89
|
+
"default": "cypress"
|
|
90
|
+
},
|
|
91
|
+
"tags": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"description": "Add tags to the application (used for linting).",
|
|
94
|
+
"alias": "t"
|
|
95
|
+
},
|
|
96
|
+
"js": {
|
|
97
|
+
"type": "boolean",
|
|
98
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
99
|
+
"default": false
|
|
100
|
+
},
|
|
101
|
+
"setParserOptionsProject": {
|
|
102
|
+
"type": "boolean",
|
|
103
|
+
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
|
|
104
|
+
"default": false
|
|
105
|
+
},
|
|
106
|
+
"swc": {
|
|
107
|
+
"description": "Enable the Rust-based compiler SWC to compile JS/TS files.",
|
|
108
|
+
"type": "boolean",
|
|
109
|
+
"default": true
|
|
110
|
+
},
|
|
111
|
+
"customServer": {
|
|
112
|
+
"description": "Use a custom Express server for the Next.js application.",
|
|
113
|
+
"type": "boolean",
|
|
114
|
+
"default": false
|
|
115
|
+
},
|
|
116
|
+
"skipPackageJson": {
|
|
117
|
+
"type": "boolean",
|
|
118
|
+
"default": false,
|
|
119
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
120
|
+
"x-priority": "internal"
|
|
121
|
+
},
|
|
122
|
+
"appDir": {
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"default": false,
|
|
125
|
+
"description": "Enable experimental app directory for the project",
|
|
126
|
+
"x-prompt": "Do you want to use experimental app/ in this project?"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"required": [],
|
|
130
|
+
"examplesFile": "../../../docs/application-examples.md"
|
|
131
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import type { SupportedStyles } from '@nx/react';
|
|
3
|
+
interface Schema {
|
|
4
|
+
name: string;
|
|
5
|
+
project: string;
|
|
6
|
+
style: SupportedStyles;
|
|
7
|
+
directory?: string;
|
|
8
|
+
flat?: boolean;
|
|
9
|
+
pascalCaseFiles?: boolean;
|
|
10
|
+
pascalCaseDirectory?: boolean;
|
|
11
|
+
skipFormat?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function componentGenerator(host: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
14
|
+
export default componentGenerator;
|
|
15
|
+
export declare const componentSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.componentSchematic = exports.componentGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const react_1 = require("@nx/react");
|
|
7
|
+
const styles_1 = require("../../utils/styles");
|
|
8
|
+
function getDirectory(host, options) {
|
|
9
|
+
const workspace = (0, devkit_1.getProjects)(host);
|
|
10
|
+
const projectType = workspace.get(options.project).projectType;
|
|
11
|
+
return options.directory
|
|
12
|
+
? options.directory
|
|
13
|
+
: projectType === 'application'
|
|
14
|
+
? 'components'
|
|
15
|
+
: undefined;
|
|
16
|
+
}
|
|
17
|
+
/*
|
|
18
|
+
* This schematic is basically the React one, but for Next we need
|
|
19
|
+
* extra dependencies for css, sass, less, styl style options.
|
|
20
|
+
*/
|
|
21
|
+
function componentGenerator(host, options) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const componentInstall = yield (0, react_1.componentGenerator)(host, Object.assign(Object.assign({}, options), { directory: getDirectory(host, options), classComponent: false, routing: false, skipFormat: true }));
|
|
24
|
+
const styledInstall = (0, styles_1.addStyleDependencies)(host, options.style);
|
|
25
|
+
if (!options.skipFormat) {
|
|
26
|
+
yield (0, devkit_1.formatFiles)(host);
|
|
27
|
+
}
|
|
28
|
+
return (0, devkit_1.runTasksInSerial)(styledInstall, componentInstall);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.componentGenerator = componentGenerator;
|
|
32
|
+
exports.default = componentGenerator;
|
|
33
|
+
exports.componentSchematic = (0, devkit_1.convertNxGenerator)(componentGenerator);
|
|
34
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../../../packages/next/src/generators/component/component.ts"],"names":[],"mappings":";;;;AAAA,uCAMoB;AAEpB,qCAA0E;AAE1E,+CAA0D;AAa1D,SAAS,YAAY,CAAC,IAAU,EAAE,OAAe;IAC/C,MAAM,SAAS,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC;IAE/D,OAAO,OAAO,CAAC,SAAS;QACtB,CAAC,CAAC,OAAO,CAAC,SAAS;QACnB,CAAC,CAAC,WAAW,KAAK,aAAa;YAC/B,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAsB,kBAAkB,CAAC,IAAU,EAAE,OAAe;;QAClE,MAAM,gBAAgB,GAAG,MAAM,IAAA,0BAAuB,EAAC,IAAI,kCACtD,OAAO,KACV,SAAS,EAAE,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,EACtC,cAAc,EAAE,KAAK,EACrB,OAAO,EAAE,KAAK,EACd,UAAU,EAAE,IAAI,IAChB,CAAC;QAEH,MAAM,aAAa,GAAG,IAAA,6BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAEhE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,IAAA,yBAAgB,EAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;IAC3D,CAAC;CAAA;AAhBD,gDAgBC;AAED,kBAAe,kBAAkB,CAAC;AACrB,QAAA,kBAAkB,GAAG,IAAA,2BAAkB,EAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxNextReactComponent",
|
|
5
|
+
"title": "Create a React Component for Next",
|
|
6
|
+
"description": "Create a React Component for Next.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The name of the project.",
|
|
12
|
+
"alias": "p",
|
|
13
|
+
"$default": {
|
|
14
|
+
"$source": "projectName"
|
|
15
|
+
},
|
|
16
|
+
"x-prompt": "What is the name of the project for this component?",
|
|
17
|
+
"x-priority": "important"
|
|
18
|
+
},
|
|
19
|
+
"name": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "The name of the component.",
|
|
22
|
+
"$default": {
|
|
23
|
+
"$source": "argv",
|
|
24
|
+
"index": 0
|
|
25
|
+
},
|
|
26
|
+
"x-prompt": "What name would you like to use for the component?",
|
|
27
|
+
"x-priority": "important"
|
|
28
|
+
},
|
|
29
|
+
"style": {
|
|
30
|
+
"description": "The file extension to be used for style files.",
|
|
31
|
+
"type": "string",
|
|
32
|
+
"alias": "s",
|
|
33
|
+
"default": "css",
|
|
34
|
+
"x-prompt": {
|
|
35
|
+
"message": "Which stylesheet format would you like to use?",
|
|
36
|
+
"type": "list",
|
|
37
|
+
"items": [
|
|
38
|
+
{ "value": "css", "label": "CSS" },
|
|
39
|
+
{
|
|
40
|
+
"value": "scss",
|
|
41
|
+
"label": "SASS(.scss) [ http://sass-lang.com ]"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"value": "less",
|
|
45
|
+
"label": "LESS [ http://lesscss.org ]"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"value": "styled-components",
|
|
49
|
+
"label": "styled-components [ https://styled-components.com ]"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"value": "@emotion/styled",
|
|
53
|
+
"label": "emotion [ https://emotion.sh ]"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"value": "styled-jsx",
|
|
57
|
+
"label": "styled-jsx [ https://www.npmjs.com/package/styled-jsx ]"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"value": "none",
|
|
61
|
+
"label": "None"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"value": "styl",
|
|
65
|
+
"label": "Stylus(.styl) [ http://stylus-lang.com ] (DEPRECATED)"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"skipTests": {
|
|
71
|
+
"type": "boolean",
|
|
72
|
+
"description": "When true, does not create `spec.ts` test files for the new component.",
|
|
73
|
+
"default": false,
|
|
74
|
+
"x-priority": "internal"
|
|
75
|
+
},
|
|
76
|
+
"directory": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "Create the component under this directory (can be nested).",
|
|
79
|
+
"alias": "dir",
|
|
80
|
+
"x-priority": "important"
|
|
81
|
+
},
|
|
82
|
+
"export": {
|
|
83
|
+
"type": "boolean",
|
|
84
|
+
"description": "When true, the component is exported from the project index.ts (if it exists).",
|
|
85
|
+
"alias": "e",
|
|
86
|
+
"default": false
|
|
87
|
+
},
|
|
88
|
+
"js": {
|
|
89
|
+
"type": "boolean",
|
|
90
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
91
|
+
"default": false
|
|
92
|
+
},
|
|
93
|
+
"flat": {
|
|
94
|
+
"type": "boolean",
|
|
95
|
+
"description": "Create component at the source root rather than its own directory.",
|
|
96
|
+
"default": false
|
|
97
|
+
},
|
|
98
|
+
"pascalCaseFiles": {
|
|
99
|
+
"type": "boolean",
|
|
100
|
+
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
|
101
|
+
"alias": "P",
|
|
102
|
+
"default": false
|
|
103
|
+
},
|
|
104
|
+
"pascalCaseDirectory": {
|
|
105
|
+
"type": "boolean",
|
|
106
|
+
"description": "Use pascal case directory name (e.g. `App/App.tsx`).",
|
|
107
|
+
"alias": "R",
|
|
108
|
+
"default": false
|
|
109
|
+
},
|
|
110
|
+
"skipFormat": {
|
|
111
|
+
"description": "Skip formatting files.",
|
|
112
|
+
"type": "boolean",
|
|
113
|
+
"default": false,
|
|
114
|
+
"x-priority": "internal"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"required": ["name", "project"],
|
|
118
|
+
"examplesFile": "../../../docs/component-examples.md"
|
|
119
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Tree } from '@nx/devkit';
|
|
2
|
+
import { CustomServerSchema } from './schema';
|
|
3
|
+
export declare function customServerGenerator(host: Tree, options: CustomServerSchema): Promise<void>;
|
|
4
|
+
export declare const customServerSchematic: (generatorOptions: CustomServerSchema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.customServerSchematic = exports.customServerGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
function customServerGenerator(host, options) {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
10
|
+
if (((_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.build) === null || _b === void 0 ? void 0 : _b.executor) !== '@nrwl/next:build') {
|
|
11
|
+
devkit_1.logger.error(`Project ${options.project} is not a Next.js project. Did you generate it with "nx g @nrwl/next:app"?`);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const outputPath = (_e = (_d = (_c = project.targets) === null || _c === void 0 ? void 0 : _c.build) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.outputPath;
|
|
15
|
+
const root = (_h = (_g = (_f = project.targets) === null || _f === void 0 ? void 0 : _f.build) === null || _g === void 0 ? void 0 : _g.options) === null || _h === void 0 ? void 0 : _h.root;
|
|
16
|
+
if (!root ||
|
|
17
|
+
!outputPath ||
|
|
18
|
+
!((_l = (_k = (_j = project.targets) === null || _j === void 0 ? void 0 : _j.build) === null || _k === void 0 ? void 0 : _k.configurations) === null || _l === void 0 ? void 0 : _l.development) ||
|
|
19
|
+
!((_p = (_o = (_m = project.targets) === null || _m === void 0 ? void 0 : _m.build) === null || _o === void 0 ? void 0 : _o.configurations) === null || _p === void 0 ? void 0 : _p.production)) {
|
|
20
|
+
devkit_1.logger.error(`Project ${options.project} has invalid config. Did you generate it with "nx g @nrwl/next:app"?`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (((_q = project.targets) === null || _q === void 0 ? void 0 : _q['build-custom-server']) ||
|
|
24
|
+
((_r = project.targets) === null || _r === void 0 ? void 0 : _r['serve-custom-server'])) {
|
|
25
|
+
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.`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, 'files'), project.root, Object.assign(Object.assign({}, options), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(project.root), projectRoot: project.root, tmpl: '' }));
|
|
29
|
+
project.targets.build.dependsOn = ['build-custom-server'];
|
|
30
|
+
project.targets.serve.options.customServerTarget = `${options.project}:serve-custom-server`;
|
|
31
|
+
project.targets.serve.configurations.development.customServerTarget = `${options.project}:serve-custom-server:development`;
|
|
32
|
+
project.targets.serve.configurations.production.customServerTarget = `${options.project}:serve-custom-server:production`;
|
|
33
|
+
project.targets['build-custom-server'] = {
|
|
34
|
+
executor: '@nrwl/js:tsc',
|
|
35
|
+
defaultConfiguration: 'production',
|
|
36
|
+
options: {
|
|
37
|
+
outputPath,
|
|
38
|
+
main: `${root}/server/main.ts`,
|
|
39
|
+
tsConfig: `${root}/tsconfig.server.json`,
|
|
40
|
+
clean: false,
|
|
41
|
+
assets: [],
|
|
42
|
+
},
|
|
43
|
+
configurations: {
|
|
44
|
+
development: {},
|
|
45
|
+
production: {},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
project.targets['serve-custom-server'] = {
|
|
49
|
+
executor: '@nrwl/js:node',
|
|
50
|
+
defaultConfiguration: 'development',
|
|
51
|
+
options: {
|
|
52
|
+
buildTarget: `${options.project}:build-custom-server`,
|
|
53
|
+
},
|
|
54
|
+
configurations: {
|
|
55
|
+
development: {
|
|
56
|
+
buildTarget: `${options.project}:build-custom-server:development`,
|
|
57
|
+
},
|
|
58
|
+
production: {
|
|
59
|
+
buildTarget: `${options.project}:build-custom-server:production`,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.project, project);
|
|
64
|
+
(0, devkit_1.updateJson)(host, 'nx.json', (json) => {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
var _c;
|
|
67
|
+
(_a = json.tasksRunnerOptions) !== null && _a !== void 0 ? _a : (json.tasksRunnerOptions = {});
|
|
68
|
+
(_b = (_c = json.tasksRunnerOptions).default) !== null && _b !== void 0 ? _b : (_c.default = { options: {} });
|
|
69
|
+
json.tasksRunnerOptions.default.options.cacheableOperations = [
|
|
70
|
+
...json.tasksRunnerOptions.default.options.cacheableOperations,
|
|
71
|
+
'build-custom-server',
|
|
72
|
+
];
|
|
73
|
+
return json;
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.customServerGenerator = customServerGenerator;
|
|
78
|
+
exports.customServerSchematic = (0, devkit_1.convertNxGenerator)(customServerGenerator);
|
|
79
|
+
//# sourceMappingURL=custom-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-server.js","sourceRoot":"","sources":["../../../../../../packages/next/src/generators/custom-server/custom-server.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is only a minimal custom server to get started.
|
|
3
|
+
* You may want to consider using Express or another server framework, and enable security features such as CORS.
|
|
4
|
+
*
|
|
5
|
+
* For more examples, see the Next.js repo:
|
|
6
|
+
* - Express: https://github.com/vercel/next.js/tree/canary/examples/custom-server-express
|
|
7
|
+
* - Hapi: https://github.com/vercel/next.js/tree/canary/examples/custom-server-hapi
|
|
8
|
+
*/
|
|
9
|
+
import { createServer } from 'http';
|
|
10
|
+
import { parse } from 'url';
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
import next from 'next';
|
|
13
|
+
|
|
14
|
+
// Next.js server options:
|
|
15
|
+
// - The environment variable is set by `@nrwl/next:server` when running the dev server.
|
|
16
|
+
// - The fallback `__dirname` is for production builds.
|
|
17
|
+
// - Feel free to change this to suit your needs.
|
|
18
|
+
const dir = process.env.NX_NEXT_DIR || path.join(__dirname, '..');
|
|
19
|
+
const dev = process.env.NODE_ENV === 'development';
|
|
20
|
+
|
|
21
|
+
// HTTP Server options:
|
|
22
|
+
// - Feel free to change this to suit your needs.
|
|
23
|
+
const hostname = process.env.HOST || 'localhost';
|
|
24
|
+
const port = process.env.PORT ? parseInt(process.env.PORT) : 4200;
|
|
25
|
+
|
|
26
|
+
async function main() {
|
|
27
|
+
const nextApp = next({ dev, dir });
|
|
28
|
+
const handle = nextApp.getRequestHandler();
|
|
29
|
+
|
|
30
|
+
await nextApp.prepare();
|
|
31
|
+
|
|
32
|
+
const server = createServer((req, res) => {
|
|
33
|
+
const parsedUrl = parse(req.url, true);
|
|
34
|
+
handle(req, res, parsedUrl);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
server.listen(port, hostname);
|
|
38
|
+
|
|
39
|
+
console.log(`[ ready ] on http://${hostname}:${port}`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
main().catch((err) => {
|
|
43
|
+
console.error(err);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
});
|
|
46
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"noEmit": false,
|
|
6
|
+
"incremental": true,
|
|
7
|
+
"tsBuildInfoFile": "<%= offsetFromRoot %>/tmp/buildcache/<%= projectRoot %>/server",
|
|
8
|
+
"types": [
|
|
9
|
+
"node"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
"server/**/*.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|