@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,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxNextCustomServer",
|
|
5
|
+
"title": "Add custom server",
|
|
6
|
+
"description": "Add a custom server to existing Next.js application.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The name of the project.",
|
|
12
|
+
"alias": "p",
|
|
13
|
+
"$default": {
|
|
14
|
+
"$source": "argv",
|
|
15
|
+
"index": 0
|
|
16
|
+
},
|
|
17
|
+
"x-dropdown": "project",
|
|
18
|
+
"x-prompt": "What is the name of the project to set up a custom server for?",
|
|
19
|
+
"x-priority": "important"
|
|
20
|
+
},
|
|
21
|
+
"compiler": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"enum": ["tsc", "swc"],
|
|
24
|
+
"default": "tsc",
|
|
25
|
+
"description": "The compiler used to build the custom server."
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"required": ["project"],
|
|
29
|
+
"examplesFile": "../../../docs/custom-server-examples.md"
|
|
30
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { InitSchema } from './schema';
|
|
3
|
+
export declare function nextInitGenerator(host: Tree, schema: InitSchema): Promise<GeneratorCallback>;
|
|
4
|
+
export default nextInitGenerator;
|
|
5
|
+
export declare const nextInitSchematic: (generatorOptions: InitSchema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nextInitSchematic = exports.nextInitGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const versions_1 = require("@nx/react/src/utils/versions");
|
|
7
|
+
const init_1 = require("@nx/react/src/generators/init/init");
|
|
8
|
+
const js_1 = require("@nx/js");
|
|
9
|
+
const versions_2 = require("../../utils/versions");
|
|
10
|
+
const add_gitignore_entry_1 = require("../../utils/add-gitignore-entry");
|
|
11
|
+
function updateDependencies(host) {
|
|
12
|
+
return (0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
13
|
+
'@nrwl/next': versions_2.nxVersion,
|
|
14
|
+
next: versions_2.nextVersion,
|
|
15
|
+
react: versions_1.reactVersion,
|
|
16
|
+
'react-dom': versions_1.reactDomVersion,
|
|
17
|
+
tslib: versions_2.tsLibVersion,
|
|
18
|
+
}, {
|
|
19
|
+
'eslint-config-next': versions_2.eslintConfigNextVersion,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
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 || 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
|
+
const reactTask = yield (0, init_1.default)(host, Object.assign(Object.assign({}, schema), { skipFormat: true }));
|
|
37
|
+
tasks.push(reactTask);
|
|
38
|
+
if (!schema.skipPackageJson) {
|
|
39
|
+
const installTask = updateDependencies(host);
|
|
40
|
+
tasks.push(installTask);
|
|
41
|
+
}
|
|
42
|
+
(0, add_gitignore_entry_1.addGitIgnoreEntry)(host);
|
|
43
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.nextInitGenerator = nextInitGenerator;
|
|
47
|
+
exports.default = nextInitGenerator;
|
|
48
|
+
exports.nextInitSchematic = (0, devkit_1.convertNxGenerator)(nextInitGenerator);
|
|
49
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/next/src/generators/init/init.ts"],"names":[],"mappings":";;;;AAAA,uCAOoB;AAEpB,2DAA6E;AAC7E,6DAAoE;AACpE,+BAA0D;AAE1D,mDAK8B;AAE9B,yEAAoE;A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C,MAAM,CAAC,eAAe,EAAE;YAC3B,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAC7C,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SACzB;QAED,IAAA,uCAAiB,EAAC,IAAI,CAAC,CAAC;QAExB,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAAK,CAAC,CAAC;IACpC,CAAC;CAAA;AAxCD,8CAwCC;AAED,kBAAe,iBAAiB,CAAC;AACpB,QAAA,iBAAiB,GAAG,IAAA,2BAAkB,EAAC,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxNextNgInit",
|
|
5
|
+
"title": "Init Next Plugin",
|
|
6
|
+
"description": "Init Next Plugin.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"unitTestRunner": {
|
|
10
|
+
"description": "Adds the specified unit test runner.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"enum": ["jest", "none"],
|
|
13
|
+
"default": "jest"
|
|
14
|
+
},
|
|
15
|
+
"e2eTestRunner": {
|
|
16
|
+
"description": "Adds the specified e2e test runner.",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"enum": ["cypress", "none"],
|
|
19
|
+
"default": "cypress"
|
|
20
|
+
},
|
|
21
|
+
"skipFormat": {
|
|
22
|
+
"description": "Skip formatting files.",
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"default": false
|
|
25
|
+
},
|
|
26
|
+
"js": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"default": false,
|
|
29
|
+
"description": "Use JavaScript instead of TypeScript"
|
|
30
|
+
},
|
|
31
|
+
"skipPackageJson": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"default": false,
|
|
34
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
35
|
+
"x-priority": "internal"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"required": []
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeOptions = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function normalizeOptions(host, options) {
|
|
6
|
+
var _a;
|
|
7
|
+
const name = (0, devkit_1.names)(options.name).fileName;
|
|
8
|
+
const projectDirectory = options.directory
|
|
9
|
+
? `${(0, devkit_1.names)(options.directory).fileName}/${name}`
|
|
10
|
+
: name;
|
|
11
|
+
const { libsDir } = (0, devkit_1.getWorkspaceLayout)(host);
|
|
12
|
+
const projectRoot = (0, devkit_1.joinPathFragments)(libsDir, projectDirectory);
|
|
13
|
+
const { npmScope } = (0, devkit_1.getWorkspaceLayout)(host);
|
|
14
|
+
return Object.assign(Object.assign({}, options), { importPath: (_a = options.importPath) !== null && _a !== void 0 ? _a : (0, devkit_1.getImportPath)(npmScope, projectDirectory), projectRoot });
|
|
15
|
+
}
|
|
16
|
+
exports.normalizeOptions = normalizeOptions;
|
|
17
|
+
//# sourceMappingURL=normalize-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../../../../../../../packages/next/src/generators/library/lib/normalize-options.ts"],"names":[],"mappings":";;;AAAA,uCAMoB;AAQpB,SAAgB,gBAAgB,CAC9B,IAAU,EACV,OAAe;;IAEf,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS;QACxC,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAI,IAAI,EAAE;QAChD,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,IAAA,0BAAiB,EAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACjE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC;IAC9C,uCACK,OAAO,KACV,UAAU,EAAE,MAAA,OAAO,CAAC,UAAU,mCAAI,IAAA,sBAAa,EAAC,QAAQ,EAAE,gBAAgB,CAAC,EAC3E,WAAW,IACX;AACJ,CAAC;AAjBD,4CAiBC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export declare function libraryGenerator(host: Tree, rawOptions: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export default libraryGenerator;
|
|
5
|
+
export declare const librarySchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.librarySchematic = exports.libraryGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const library_1 = require("@nx/react/src/generators/library/library");
|
|
7
|
+
const js_1 = require("@nx/js");
|
|
8
|
+
const init_1 = require("../init/init");
|
|
9
|
+
const normalize_options_1 = require("./lib/normalize-options");
|
|
10
|
+
function libraryGenerator(host, rawOptions) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const options = (0, normalize_options_1.normalizeOptions)(host, rawOptions);
|
|
13
|
+
const tasks = [];
|
|
14
|
+
const initTask = yield (0, init_1.nextInitGenerator)(host, Object.assign(Object.assign({}, options), { skipFormat: true }));
|
|
15
|
+
tasks.push(initTask);
|
|
16
|
+
const libTask = yield (0, library_1.libraryGenerator)(host, Object.assign(Object.assign({}, options), { compiler: 'swc', skipFormat: true }));
|
|
17
|
+
tasks.push(libTask);
|
|
18
|
+
const indexPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src', `index.${options.js ? 'js' : 'ts'}`);
|
|
19
|
+
const indexContent = host.read(indexPath, 'utf-8');
|
|
20
|
+
host.write(indexPath, `// Use this file to export React client components (e.g. those with 'use client' directive) or other non-server utilities\n${indexContent}`);
|
|
21
|
+
// Additional entry for Next.js libraries so React Server Components are exported from a separate entry point.
|
|
22
|
+
// This is needed because RSC exported from `src/index.ts` will mark the entire file as server-only and throw an error when used from a client component.
|
|
23
|
+
// See: https://github.com/nrwl/nx/issues/15830
|
|
24
|
+
const serverEntryPath = (0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'server.' + (options.js ? 'js' : 'ts'));
|
|
25
|
+
host.write((0, devkit_1.joinPathFragments)(options.projectRoot, 'src', `server.${options.js ? 'js' : 'ts'}`), `// Use this file to export React server components\n`);
|
|
26
|
+
(0, js_1.addTsConfigPath)(host, `${options.importPath}/server`, [serverEntryPath]);
|
|
27
|
+
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, '.babelrc'), (json) => {
|
|
28
|
+
if (options.style === '@emotion/styled') {
|
|
29
|
+
json.presets = [
|
|
30
|
+
[
|
|
31
|
+
'@nrwl/next/babel',
|
|
32
|
+
{
|
|
33
|
+
'preset-react': {
|
|
34
|
+
runtime: 'automatic',
|
|
35
|
+
importSource: '@emotion/react',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
else if (options.style === 'styled-jsx') {
|
|
42
|
+
// next.js doesn't require the `styled-jsx/babel' plugin as it is already
|
|
43
|
+
// built-into the `next/babel` preset
|
|
44
|
+
json.presets = ['@nrwl/next/babel'];
|
|
45
|
+
json.plugins = (json.plugins || []).filter((x) => x !== 'styled-jsx/babel');
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
json.presets = ['@nrwl/next/babel'];
|
|
49
|
+
}
|
|
50
|
+
return json;
|
|
51
|
+
});
|
|
52
|
+
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.json'), (json) => {
|
|
53
|
+
if (options.style === '@emotion/styled') {
|
|
54
|
+
json.compilerOptions.jsxImportSource = '@emotion/react';
|
|
55
|
+
}
|
|
56
|
+
return json;
|
|
57
|
+
});
|
|
58
|
+
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'), (json) => {
|
|
59
|
+
if (!json.files) {
|
|
60
|
+
json.files = [];
|
|
61
|
+
}
|
|
62
|
+
json.files = json.files.map((path) => {
|
|
63
|
+
if (path.endsWith('react/typings/image.d.ts')) {
|
|
64
|
+
return path.replace('@nrwl/react/typings/image.d.ts', '@nrwl/next/typings/image.d.ts');
|
|
65
|
+
}
|
|
66
|
+
return path;
|
|
67
|
+
});
|
|
68
|
+
return json;
|
|
69
|
+
});
|
|
70
|
+
if (!options.skipFormat) {
|
|
71
|
+
yield (0, devkit_1.formatFiles)(host);
|
|
72
|
+
}
|
|
73
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.libraryGenerator = libraryGenerator;
|
|
77
|
+
exports.default = libraryGenerator;
|
|
78
|
+
exports.librarySchematic = (0, devkit_1.convertNxGenerator)(libraryGenerator);
|
|
79
|
+
//# sourceMappingURL=library.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library.js","sourceRoot":"","sources":["../../../../../../packages/next/src/generators/library/library.ts"],"names":[],"mappings":";;;;AAAA,uCAQoB;AACpB,sEAAqG;AACrG,+BAAyC;AAEzC,uCAAiD;AAEjD,+DAA2D;AAE3D,SAAsB,gBAAgB,CAAC,IAAU,EAAE,UAAkB;;QACnE,MAAM,OAAO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AE;gBACf,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;aACjB;YACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE;gBAC3C,IAAI,IAAI,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAAE;oBAC7C,OAAO,IAAI,CAAC,OAAO,CACjB,gCAAgC,EAChC,+BAA+B,CAChC,CAAC;iBACH;gBACD,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAAK,CAAC,CAAC;IACpC,CAAC;CAAA;AA9GD,4CA8GC;AAED,kBAAe,gBAAgB,CAAC;AACnB,QAAA,gBAAgB,GAAG,IAAA,2BAAkB,EAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Linter } from '@nx/linter';
|
|
2
|
+
import type { SupportedStyles } from '@nx/react';
|
|
3
|
+
|
|
4
|
+
export interface Schema {
|
|
5
|
+
name: string;
|
|
6
|
+
directory?: string;
|
|
7
|
+
style: SupportedStyles;
|
|
8
|
+
skipTsConfig?: boolean;
|
|
9
|
+
skipFormat?: boolean;
|
|
10
|
+
tags?: string;
|
|
11
|
+
pascalCaseFiles?: boolean;
|
|
12
|
+
routing?: boolean;
|
|
13
|
+
appProject?: string;
|
|
14
|
+
unitTestRunner: 'jest' | 'none';
|
|
15
|
+
linter: Linter;
|
|
16
|
+
component?: boolean;
|
|
17
|
+
publishable?: boolean;
|
|
18
|
+
buildable?: boolean;
|
|
19
|
+
importPath?: string;
|
|
20
|
+
js?: boolean;
|
|
21
|
+
globalCss?: boolean;
|
|
22
|
+
strict?: boolean;
|
|
23
|
+
setParserOptionsProject?: boolean;
|
|
24
|
+
skipPackageJson?: boolean;
|
|
25
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxReactLibrary",
|
|
5
|
+
"title": "Create a React Library for Nx",
|
|
6
|
+
"description": "Create a React Library for an Nx workspace.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Library name",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-prompt": "What name would you like to use for the library?",
|
|
17
|
+
"pattern": "^[a-zA-Z].*$",
|
|
18
|
+
"x-priority": "important"
|
|
19
|
+
},
|
|
20
|
+
"directory": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "A directory where the lib is placed.",
|
|
23
|
+
"alias": "dir",
|
|
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
|
+
"unitTestRunner": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"enum": ["jest", "none"],
|
|
76
|
+
"description": "Test runner to use for unit tests.",
|
|
77
|
+
"default": "jest"
|
|
78
|
+
},
|
|
79
|
+
"tags": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"description": "Add tags to the library (used for linting).",
|
|
82
|
+
"alias": "t"
|
|
83
|
+
},
|
|
84
|
+
"skipFormat": {
|
|
85
|
+
"description": "Skip formatting files.",
|
|
86
|
+
"type": "boolean",
|
|
87
|
+
"default": false
|
|
88
|
+
},
|
|
89
|
+
"skipTsConfig": {
|
|
90
|
+
"type": "boolean",
|
|
91
|
+
"default": false,
|
|
92
|
+
"description": "Do not update tsconfig.json for development experience."
|
|
93
|
+
},
|
|
94
|
+
"pascalCaseFiles": {
|
|
95
|
+
"type": "boolean",
|
|
96
|
+
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
|
97
|
+
"alias": "P",
|
|
98
|
+
"default": false
|
|
99
|
+
},
|
|
100
|
+
"routing": {
|
|
101
|
+
"type": "boolean",
|
|
102
|
+
"description": "Generate library with routes."
|
|
103
|
+
},
|
|
104
|
+
"appProject": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"description": "The application project to add the library route to.",
|
|
107
|
+
"alias": "a"
|
|
108
|
+
},
|
|
109
|
+
"publishable": {
|
|
110
|
+
"type": "boolean",
|
|
111
|
+
"description": "Create a publishable library."
|
|
112
|
+
},
|
|
113
|
+
"buildable": {
|
|
114
|
+
"type": "boolean",
|
|
115
|
+
"default": false,
|
|
116
|
+
"description": "Generate a buildable library."
|
|
117
|
+
},
|
|
118
|
+
"importPath": {
|
|
119
|
+
"type": "string",
|
|
120
|
+
"description": "The library name used to import it, like `@myorg/my-awesome-lib`."
|
|
121
|
+
},
|
|
122
|
+
"component": {
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"description": "Generate a default component.",
|
|
125
|
+
"default": true
|
|
126
|
+
},
|
|
127
|
+
"js": {
|
|
128
|
+
"type": "boolean",
|
|
129
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
130
|
+
"default": false
|
|
131
|
+
},
|
|
132
|
+
"globalCss": {
|
|
133
|
+
"type": "boolean",
|
|
134
|
+
"description": "When true, the stylesheet is generated using global CSS instead of CSS modules (e.g. file is `*.css` rather than `*.module.css`).",
|
|
135
|
+
"default": false
|
|
136
|
+
},
|
|
137
|
+
"strict": {
|
|
138
|
+
"type": "boolean",
|
|
139
|
+
"description": "Whether to enable tsconfig strict mode or not.",
|
|
140
|
+
"default": true
|
|
141
|
+
},
|
|
142
|
+
"setParserOptionsProject": {
|
|
143
|
+
"type": "boolean",
|
|
144
|
+
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
|
|
145
|
+
"default": false
|
|
146
|
+
},
|
|
147
|
+
"skipPackageJson": {
|
|
148
|
+
"type": "boolean",
|
|
149
|
+
"default": false,
|
|
150
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
151
|
+
"x-priority": "internal"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"required": ["name"],
|
|
155
|
+
"examplesFile": "../../../docs/library-examples.md"
|
|
156
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export declare function pageGenerator(host: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
|
+
export default pageGenerator;
|
|
5
|
+
export declare const pageSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pageSchematic = exports.pageGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = require("@nx/react");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const styles_1 = require("../../utils/styles");
|
|
8
|
+
/*
|
|
9
|
+
* This schematic is basically the React component one, but for Next we need
|
|
10
|
+
* extra dependencies for css, sass, less, styl style options, and make sure
|
|
11
|
+
* it is under `pages` folder.
|
|
12
|
+
*/
|
|
13
|
+
function pageGenerator(host, options) {
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const directory = options.directory ? `pages/${options.directory}` : 'pages';
|
|
16
|
+
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 }));
|
|
17
|
+
const styledTask = (0, styles_1.addStyleDependencies)(host, options.style);
|
|
18
|
+
if (!options.skipFormat) {
|
|
19
|
+
yield (0, devkit_1.formatFiles)(host);
|
|
20
|
+
}
|
|
21
|
+
return (0, devkit_1.runTasksInSerial)(componentTask, styledTask);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.pageGenerator = pageGenerator;
|
|
25
|
+
exports.default = pageGenerator;
|
|
26
|
+
exports.pageSchematic = (0, devkit_1.convertNxGenerator)(pageGenerator);
|
|
27
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../../../../../packages/next/src/generators/page/page.ts"],"names":[],"mappings":";;;;AAAA,qCAA0E;AAC1E,uCAKoB;AAEpB,+CAA0D;AAG1D;;;;GAIG;AACH,SAAsB,aAAa,CAAC,IAAU,EAAE,OAAe;;QAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QAC7E,MAAM,aAAa,GAAG,MAAM,IAAA,0BAAuB,EAAC,IAAI,kCACnD,OAAO,KACV,SAAS,EACT,eAAe,EAAE,KAAK,EACtB,MAAM,EAAE,KAAK,EACb,cAAc,EAAE,KAAK,EACrB,OAAO,EAAE,KAAK,EACd,SAAS,EAAE,CAAC,OAAO,CAAC,SAAS,EAC7B,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EACpB,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAC7C,UAAU,EAAE,IAAI,IAChB,CAAC;QAEH,MAAM,UAAU,GAAG,IAAA,6BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAE7D,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,IAAA,yBAAgB,EAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC;CAAA;AAtBD,sCAsBC;AAED,kBAAe,aAAa,CAAC;AAChB,QAAA,aAAa,GAAG,IAAA,2BAAkB,EAAC,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SupportedStyles } from '@nx/react';
|
|
2
|
+
|
|
3
|
+
export interface Schema {
|
|
4
|
+
name: string;
|
|
5
|
+
project: string;
|
|
6
|
+
style: SupportedStyles;
|
|
7
|
+
directory?: string;
|
|
8
|
+
fileName?: string;
|
|
9
|
+
withTests?: boolean;
|
|
10
|
+
js?: boolean;
|
|
11
|
+
flat?: boolean;
|
|
12
|
+
skipFormat?: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxNextReactPage",
|
|
5
|
+
"title": "Create a Page for Next",
|
|
6
|
+
"description": "Create a Page 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
|
+
"directory": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "Create the page under this directory (can be nested). Will be created under `pages/`.",
|
|
32
|
+
"alias": "dir",
|
|
33
|
+
"x-priority": "important"
|
|
34
|
+
},
|
|
35
|
+
"style": {
|
|
36
|
+
"description": "The file extension to be used for style files.",
|
|
37
|
+
"type": "string",
|
|
38
|
+
"alias": "s",
|
|
39
|
+
"default": "css",
|
|
40
|
+
"x-prompt": {
|
|
41
|
+
"message": "Which stylesheet format would you like to use?",
|
|
42
|
+
"type": "list",
|
|
43
|
+
"items": [
|
|
44
|
+
{ "value": "css", "label": "CSS" },
|
|
45
|
+
{
|
|
46
|
+
"value": "scss",
|
|
47
|
+
"label": "SASS(.scss) [ http://sass-lang.com ]"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"value": "less",
|
|
51
|
+
"label": "LESS [ http://lesscss.org ]"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"value": "styled-components",
|
|
55
|
+
"label": "styled-components [ https://styled-components.com ]"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"value": "@emotion/styled",
|
|
59
|
+
"label": "emotion [ https://emotion.sh ]"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"value": "styled-jsx",
|
|
63
|
+
"label": "styled-jsx [ https://www.npmjs.com/package/styled-jsx ]"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"value": "none",
|
|
67
|
+
"label": "None"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"value": "styl",
|
|
71
|
+
"label": "Stylus(.styl) [ http://stylus-lang.com ] (DEPRECATED)"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"x-priority": "important"
|
|
76
|
+
},
|
|
77
|
+
"withTests": {
|
|
78
|
+
"type": "boolean",
|
|
79
|
+
"description": "When true, creates a `spec.ts` test file for the new page.",
|
|
80
|
+
"default": false
|
|
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
|
+
"skipFormat": {
|
|
99
|
+
"description": "Skip formatting files.",
|
|
100
|
+
"type": "boolean",
|
|
101
|
+
"default": false,
|
|
102
|
+
"x-priority": "internal"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"required": ["name", "project"],
|
|
106
|
+
"examplesFile": "../../../docs/page-examples.md"
|
|
107
|
+
}
|