@nx/node 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 +61 -0
- package/executors.json +26 -0
- package/generators.json +62 -0
- package/index.d.ts +3 -0
- package/index.js +10 -0
- package/index.js.map +1 -0
- package/migrations.json +60 -0
- package/package.json +48 -0
- package/src/executors/node/compat.d.ts +2 -0
- package/src/executors/node/compat.js +6 -0
- package/src/executors/node/compat.js.map +1 -0
- package/src/executors/node/node.impl.d.ts +4 -0
- package/src/executors/node/node.impl.js +14 -0
- package/src/executors/node/node.impl.js.map +1 -0
- package/src/executors/node/schema.json +74 -0
- package/src/executors/webpack/compat.d.ts +2 -0
- package/src/executors/webpack/compat.js +6 -0
- package/src/executors/webpack/compat.js.map +1 -0
- package/src/executors/webpack/schema.json +275 -0
- package/src/executors/webpack/webpack.impl.d.ts +8 -0
- package/src/executors/webpack/webpack.impl.js +19 -0
- package/src/executors/webpack/webpack.impl.js.map +1 -0
- package/src/generators/application/application.d.ts +10 -0
- package/src/generators/application/application.js +277 -0
- package/src/generators/application/application.js.map +1 -0
- package/src/generators/application/files/common/src/assets/.gitkeep +0 -0
- package/src/generators/application/files/common/src/main.ts__tmpl__ +1 -0
- package/src/generators/application/files/common/tsconfig.app.json +10 -0
- package/src/generators/application/files/common/tsconfig.json +10 -0
- package/src/generators/application/files/common/webpack.config.js__tmpl__ +8 -0
- package/src/generators/application/files/express/src/main.ts__tmpl__ +14 -0
- package/src/generators/application/files/fastify/src/app/app.spec.ts__tmpl__ +20 -0
- package/src/generators/application/files/fastify/src/app/app.ts__tmpl__ +27 -0
- package/src/generators/application/files/fastify/src/app/plugins/sensible.ts__tmpl__ +12 -0
- package/src/generators/application/files/fastify/src/app/routes/root.ts__tmpl__ +7 -0
- package/src/generators/application/files/fastify/src/main.ts__tmpl__ +23 -0
- package/src/generators/application/files/koa/src/main.ts__tmpl__ +14 -0
- package/src/generators/application/schema.d.ts +26 -0
- package/src/generators/application/schema.json +123 -0
- package/src/generators/e2e-project/e2e-project.d.ts +5 -0
- package/src/generators/e2e-project/e2e-project.js +108 -0
- package/src/generators/e2e-project/e2e-project.js.map +1 -0
- package/src/generators/e2e-project/files/cli/jest.config.ts__tmpl__ +14 -0
- package/src/generators/e2e-project/files/cli/src/__fileName__/__fileName__.spec.ts__tmpl__ +13 -0
- package/src/generators/e2e-project/files/cli/src/test-setup.ts__tmpl__ +1 -0
- package/src/generators/e2e-project/files/cli/tsconfig.json__tmpl__ +13 -0
- package/src/generators/e2e-project/files/cli/tsconfig.spec.json__tmpl__ +12 -0
- package/src/generators/e2e-project/files/server/common/jest.config.ts__tmpl__ +16 -0
- package/src/generators/e2e-project/files/server/common/src/__fileName__/__fileName__.spec.ts__tmpl__ +10 -0
- package/src/generators/e2e-project/files/server/common/src/support/global-setup.ts__tmpl__ +11 -0
- package/src/generators/e2e-project/files/server/common/src/support/global-teardown.ts__tmpl__ +7 -0
- package/src/generators/e2e-project/files/server/common/src/support/test-setup.ts__tmpl__ +10 -0
- package/src/generators/e2e-project/files/server/common/tsconfig.json__tmpl__ +13 -0
- package/src/generators/e2e-project/files/server/common/tsconfig.spec.json__tmpl__ +12 -0
- package/src/generators/e2e-project/files/server/nest/src/__fileName__/__fileName__.spec.ts__tmpl__ +10 -0
- package/src/generators/e2e-project/schema.d.ts +11 -0
- package/src/generators/e2e-project/schema.json +65 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +37 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/schema.d.ts +6 -0
- package/src/generators/init/schema.json +27 -0
- package/src/generators/library/files/lib/package.json__tmpl__ +4 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ +7 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.ts__tmpl__ +3 -0
- package/src/generators/library/files/lib/tsconfig.lib.json +11 -0
- package/src/generators/library/library.d.ts +14 -0
- package/src/generators/library/library.js +108 -0
- package/src/generators/library/library.js.map +1 -0
- package/src/generators/library/schema.d.ts +24 -0
- package/src/generators/library/schema.json +129 -0
- package/src/generators/setup-docker/files/Dockerfile__tmpl__ +24 -0
- package/src/generators/setup-docker/schema.d.ts +6 -0
- package/src/generators/setup-docker/schema.json +29 -0
- package/src/generators/setup-docker/setup-docker.d.ts +6 -0
- package/src/generators/setup-docker/setup-docker.js +54 -0
- package/src/generators/setup-docker/setup-docker.js.map +1 -0
- package/src/migrations/update-13-0-0/remove-deprecated-options-13-0-0.d.ts +2 -0
- package/src/migrations/update-13-0-0/remove-deprecated-options-13-0-0.js +31 -0
- package/src/migrations/update-13-0-0/remove-deprecated-options-13-0-0.js.map +1 -0
- package/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.d.ts +2 -0
- package/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.js +33 -0
- package/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.js.map +1 -0
- package/src/migrations/update-13-8-5/rename-build-to-webpack.d.ts +2 -0
- package/src/migrations/update-13-8-5/rename-build-to-webpack.js +17 -0
- package/src/migrations/update-13-8-5/rename-build-to-webpack.js.map +1 -0
- package/src/migrations/update-13-8-5/rename-execute-to-node.d.ts +2 -0
- package/src/migrations/update-13-8-5/rename-execute-to-node.js +17 -0
- package/src/migrations/update-13-8-5/rename-execute-to-node.js.map +1 -0
- package/src/migrations/update-13-8-5/update-package-to-tsc.d.ts +2 -0
- package/src/migrations/update-13-8-5/update-package-to-tsc.js +39 -0
- package/src/migrations/update-13-8-5/update-package-to-tsc.js.map +1 -0
- package/src/migrations/update-14-7-6/update-webpack-executor.d.ts +2 -0
- package/src/migrations/update-14-7-6/update-webpack-executor.js +21 -0
- package/src/migrations/update-14-7-6/update-webpack-executor.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/versions.d.ts +13 -0
- package/src/utils/versions.js +17 -0
- package/src/utils/versions.js.map +1 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
|
|
3
|
+
const host = process.env.HOST ?? 'localhost';
|
|
4
|
+
const port = process.env.PORT ? Number(process.env.PORT) : <%= port %>;
|
|
5
|
+
|
|
6
|
+
const app = express();
|
|
7
|
+
|
|
8
|
+
app.get('/', (req, res) => {
|
|
9
|
+
res.send({ 'message': 'Hello API'});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
app.listen(port, host, () => {
|
|
13
|
+
console.log(`[ ready ] http://${host}:${port}`);
|
|
14
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Fastify, { FastifyInstance } from 'fastify';
|
|
2
|
+
import { app } from './app';
|
|
3
|
+
|
|
4
|
+
describe('GET /', () => {
|
|
5
|
+
let server: FastifyInstance;
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
server = Fastify();
|
|
9
|
+
server.register(app);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should respond with a message', async () => {
|
|
13
|
+
const response = await server.inject({
|
|
14
|
+
method: 'GET',
|
|
15
|
+
url: '/'
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
expect(response.json()).toEqual({ message: 'Hello API' })
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
|
|
3
|
+
import AutoLoad from '@fastify/autoload';
|
|
4
|
+
|
|
5
|
+
/* eslint-disable-next-line */
|
|
6
|
+
export interface AppOptions { }
|
|
7
|
+
|
|
8
|
+
export async function app(fastify: FastifyInstance, opts: AppOptions) {
|
|
9
|
+
// Place here your custom code!
|
|
10
|
+
|
|
11
|
+
// Do not touch the following lines
|
|
12
|
+
|
|
13
|
+
// This loads all plugins defined in plugins
|
|
14
|
+
// those should be support plugins that are reused
|
|
15
|
+
// through your application
|
|
16
|
+
fastify.register(AutoLoad, {
|
|
17
|
+
dir: path.join(__dirname, 'plugins'),
|
|
18
|
+
options: { ...opts },
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// This loads all plugins defined in routes
|
|
22
|
+
// define your routes in one of these
|
|
23
|
+
fastify.register(AutoLoad, {
|
|
24
|
+
dir: path.join(__dirname, 'routes'),
|
|
25
|
+
options: { ...opts },
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
|
|
2
|
+
import fp from 'fastify-plugin';
|
|
3
|
+
import sensible from '@fastify/sensible';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This plugins adds some utilities to handle http errors
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/fastify/fastify-sensible
|
|
9
|
+
*/
|
|
10
|
+
export default fp(async function(fastify: FastifyInstance) {
|
|
11
|
+
fastify.register(sensible);
|
|
12
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Fastify from 'fastify';
|
|
2
|
+
import { app } from './app/app';
|
|
3
|
+
|
|
4
|
+
const host = process.env.HOST ?? 'localhost';
|
|
5
|
+
const port = process.env.PORT ? Number(process.env.PORT) : <%= port %>;
|
|
6
|
+
|
|
7
|
+
// Instantiate Fastify with some config
|
|
8
|
+
const server = Fastify({
|
|
9
|
+
logger: true,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Register your application as a normal plugin.
|
|
13
|
+
server.register(app);
|
|
14
|
+
|
|
15
|
+
// Start listening.
|
|
16
|
+
server.listen({ port, host }, (err) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
server.log.error(err);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
} else {
|
|
21
|
+
console.log(`[ ready ] http://${host}:${port}`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import koa from 'koa';
|
|
2
|
+
|
|
3
|
+
const host = process.env.HOST ?? 'localhost';
|
|
4
|
+
const port = process.env.PORT ? Number(process.env.PORT) : <%= port %>;
|
|
5
|
+
|
|
6
|
+
const app = new koa();
|
|
7
|
+
|
|
8
|
+
app.use(async ctx =>{
|
|
9
|
+
ctx.body = { 'message': 'Hello API'};
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
app.listen(port, host, () => {
|
|
13
|
+
console.log(`[ ready ] http://${host}:${port}`);
|
|
14
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Linter } from '@nx/linter';
|
|
2
|
+
|
|
3
|
+
export interface Schema {
|
|
4
|
+
name: string;
|
|
5
|
+
skipFormat?: boolean;
|
|
6
|
+
skipPackageJson?: boolean;
|
|
7
|
+
directory?: string;
|
|
8
|
+
unitTestRunner?: 'jest' | 'none';
|
|
9
|
+
e2eTestRunner?: 'jest' | 'none';
|
|
10
|
+
linter?: Linter;
|
|
11
|
+
tags?: string;
|
|
12
|
+
frontendProject?: string;
|
|
13
|
+
babelJest?: boolean;
|
|
14
|
+
js?: boolean;
|
|
15
|
+
pascalCaseFiles?: boolean;
|
|
16
|
+
setParserOptionsProject?: boolean;
|
|
17
|
+
standaloneConfig?: boolean;
|
|
18
|
+
bundler?: 'esbuild' | 'webpack';
|
|
19
|
+
framework?: NodeJsFrameWorks;
|
|
20
|
+
port?: number;
|
|
21
|
+
rootProject?: boolean;
|
|
22
|
+
docker?: boolean;
|
|
23
|
+
isNest?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type NodeJsFrameWorks = 'express' | 'koa' | 'fastify' | 'nest' | 'none';
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "SchematicsNxNodeApp",
|
|
5
|
+
"title": "Nx Application Options Schema",
|
|
6
|
+
"description": "Nx Application Options Schema.",
|
|
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 node application?",
|
|
17
|
+
"x-priority": "important"
|
|
18
|
+
},
|
|
19
|
+
"directory": {
|
|
20
|
+
"description": "The directory of the new application.",
|
|
21
|
+
"type": "string",
|
|
22
|
+
"x-priority": "important"
|
|
23
|
+
},
|
|
24
|
+
"skipFormat": {
|
|
25
|
+
"description": "Skip formatting files",
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"default": false,
|
|
28
|
+
"x-priority": "internal"
|
|
29
|
+
},
|
|
30
|
+
"skipPackageJson": {
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"default": false,
|
|
33
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
34
|
+
"x-priority": "internal"
|
|
35
|
+
},
|
|
36
|
+
"linter": {
|
|
37
|
+
"description": "The tool to use for running lint checks.",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": ["eslint"],
|
|
40
|
+
"default": "eslint"
|
|
41
|
+
},
|
|
42
|
+
"unitTestRunner": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"enum": ["jest", "none"],
|
|
45
|
+
"description": "Test runner to use for unit tests.",
|
|
46
|
+
"default": "jest"
|
|
47
|
+
},
|
|
48
|
+
"tags": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Add tags to the application (used for linting)."
|
|
51
|
+
},
|
|
52
|
+
"frontendProject": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Frontend project that needs to access this application. This sets up proxy configuration.",
|
|
55
|
+
"x-priority": "important"
|
|
56
|
+
},
|
|
57
|
+
"babelJest": {
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"description": "Use `babel` instead of `ts-jest`.",
|
|
60
|
+
"default": false
|
|
61
|
+
},
|
|
62
|
+
"pascalCaseFiles": {
|
|
63
|
+
"type": "boolean",
|
|
64
|
+
"description": "Use pascal case file names.",
|
|
65
|
+
"alias": "P",
|
|
66
|
+
"default": false
|
|
67
|
+
},
|
|
68
|
+
"js": {
|
|
69
|
+
"type": "boolean",
|
|
70
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
71
|
+
"default": false
|
|
72
|
+
},
|
|
73
|
+
"setParserOptionsProject": {
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
|
|
76
|
+
"default": false
|
|
77
|
+
},
|
|
78
|
+
"standaloneConfig": {
|
|
79
|
+
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
|
80
|
+
"type": "boolean",
|
|
81
|
+
"default": true,
|
|
82
|
+
"x-deprecated": "Nx only supports standaloneConfig"
|
|
83
|
+
},
|
|
84
|
+
"bundler": {
|
|
85
|
+
"description": "Bundler which is used to package the application",
|
|
86
|
+
"type": "string",
|
|
87
|
+
"enum": ["esbuild", "webpack"],
|
|
88
|
+
"default": "esbuild",
|
|
89
|
+
"x-priority": "important"
|
|
90
|
+
},
|
|
91
|
+
"framework": {
|
|
92
|
+
"description": "Generate the node application using a framework",
|
|
93
|
+
"type": "string",
|
|
94
|
+
"enum": ["express", "fastify", "koa", "nest", "none"],
|
|
95
|
+
"default": "none",
|
|
96
|
+
"x-prompt": "Which framework do you want to use?",
|
|
97
|
+
"x-priority": "important"
|
|
98
|
+
},
|
|
99
|
+
"port": {
|
|
100
|
+
"description": "The port which the server will be run on",
|
|
101
|
+
"type": "number",
|
|
102
|
+
"default": 3000
|
|
103
|
+
},
|
|
104
|
+
"rootProject": {
|
|
105
|
+
"description": "Create node application at the root of the workspace",
|
|
106
|
+
"type": "boolean",
|
|
107
|
+
"default": false,
|
|
108
|
+
"hidden": true,
|
|
109
|
+
"x-priority": "internal"
|
|
110
|
+
},
|
|
111
|
+
"e2eTestRunner": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"enum": ["jest", "none"],
|
|
114
|
+
"description": "Test runner to use for end to end (e2e) tests",
|
|
115
|
+
"default": "jest"
|
|
116
|
+
},
|
|
117
|
+
"docker": {
|
|
118
|
+
"type": "boolean",
|
|
119
|
+
"description": "Add a docker build target"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"required": ["name"]
|
|
123
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export declare function e2eProjectGenerator(host: Tree, _options: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export default e2eProjectGenerator;
|
|
5
|
+
export declare const e2eProjectSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.e2eProjectSchematic = exports.e2eProjectGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const linter_1 = require("@nx/linter");
|
|
8
|
+
const versions_1 = require("../../utils/versions");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const global_eslint_config_1 = require("@nx/linter/src/generators/init/global-eslint-config");
|
|
11
|
+
function e2eProjectGenerator(host, _options) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
const tasks = [];
|
|
15
|
+
const options = normalizeOptions(host, _options);
|
|
16
|
+
const appProject = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
17
|
+
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
18
|
+
root: options.e2eProjectRoot,
|
|
19
|
+
implicitDependencies: [options.project],
|
|
20
|
+
targets: {
|
|
21
|
+
e2e: {
|
|
22
|
+
executor: '@nrwl/jest:jest',
|
|
23
|
+
outputs: ['{workspaceRoot}/coverage/{e2eProjectRoot}'],
|
|
24
|
+
options: {
|
|
25
|
+
jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
|
|
26
|
+
passWithNoTests: true,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
if (options.projectType === 'server') {
|
|
32
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.rootProject ? 'server' : options.project)), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot), tmpl: '' }));
|
|
33
|
+
if (options.isNest) {
|
|
34
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/nest'), options.e2eProjectRoot, Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.rootProject ? 'server' : options.project)), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot), tmpl: '' }));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (options.projectType === 'cli') {
|
|
38
|
+
const mainFile = (_b = (_a = appProject.targets.build) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.outputPath;
|
|
39
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/cli'), options.e2eProjectRoot, Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.rootProject ? 'cli' : options.project)), { mainFile, offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot), tmpl: '' }));
|
|
40
|
+
}
|
|
41
|
+
// axios is more than likely used in the application code, so install it as a regular dependency.
|
|
42
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { axios: versions_1.axiosVersion }, {});
|
|
43
|
+
tasks.push(installTask);
|
|
44
|
+
if (options.linter === linter_1.Linter.EsLint) {
|
|
45
|
+
const linterTask = yield (0, linter_1.lintProjectGenerator)(host, {
|
|
46
|
+
project: options.e2eProjectName,
|
|
47
|
+
linter: linter_1.Linter.EsLint,
|
|
48
|
+
skipFormat: true,
|
|
49
|
+
tsConfigPaths: [
|
|
50
|
+
(0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'tsconfig.json'),
|
|
51
|
+
],
|
|
52
|
+
eslintFilePatterns: [`${options.e2eProjectRoot}/**/*.{js,ts}`],
|
|
53
|
+
setParserOptionsProject: false,
|
|
54
|
+
skipPackageJson: false,
|
|
55
|
+
rootProject: options.rootProject,
|
|
56
|
+
});
|
|
57
|
+
tasks.push(linterTask);
|
|
58
|
+
(0, devkit_1.updateJson)(host, (0, path_1.join)(options.e2eProjectRoot, '.eslintrc.json'), (json) => {
|
|
59
|
+
if (options.rootProject) {
|
|
60
|
+
json.plugins = ['@nrwl/nx'];
|
|
61
|
+
json.extends = [];
|
|
62
|
+
}
|
|
63
|
+
json.overrides = [
|
|
64
|
+
...(options.rootProject
|
|
65
|
+
? [global_eslint_config_1.globalTypeScriptOverrides, global_eslint_config_1.globalJavaScriptOverrides]
|
|
66
|
+
: []),
|
|
67
|
+
/**
|
|
68
|
+
* In order to ensure maximum efficiency when typescript-eslint generates TypeScript Programs
|
|
69
|
+
* behind the scenes during lint runs, we need to make sure the project is configured to use its
|
|
70
|
+
* own specific tsconfigs, and not fall back to the ones in the root of the workspace.
|
|
71
|
+
*/
|
|
72
|
+
{
|
|
73
|
+
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
|
|
74
|
+
/**
|
|
75
|
+
* Having an empty rules object present makes it more obvious to the user where they would
|
|
76
|
+
* extend things from if they needed to
|
|
77
|
+
*/
|
|
78
|
+
rules: {},
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
return json;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (!options.skipFormat) {
|
|
85
|
+
yield (0, devkit_1.formatFiles)(host);
|
|
86
|
+
}
|
|
87
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.e2eProjectGenerator = e2eProjectGenerator;
|
|
91
|
+
function normalizeOptions(tree, options) {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
|
|
94
|
+
const appsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : (0, devkit_1.getWorkspaceLayout)(tree).appsDir;
|
|
95
|
+
const name = (_a = options.name) !== null && _a !== void 0 ? _a : `${options.project}-e2e`;
|
|
96
|
+
const appDirectory = projectDirectory
|
|
97
|
+
? `${(0, devkit_1.names)(projectDirectory).fileName}/${(0, devkit_1.names)(name).fileName}`
|
|
98
|
+
: (0, devkit_1.names)(name).fileName;
|
|
99
|
+
const e2eProjectName = appDirectory.replace(new RegExp('/', 'g'), '-');
|
|
100
|
+
const e2eProjectRoot = options.rootProject
|
|
101
|
+
? 'e2e'
|
|
102
|
+
: (0, devkit_1.joinPathFragments)(appsDir, appDirectory);
|
|
103
|
+
return Object.assign(Object.assign({}, options), { e2eProjectRoot,
|
|
104
|
+
e2eProjectName, port: (_b = options.port) !== null && _b !== void 0 ? _b : 3000, rootProject: !!options.rootProject });
|
|
105
|
+
}
|
|
106
|
+
exports.default = e2eProjectGenerator;
|
|
107
|
+
exports.e2eProjectSchematic = (0, devkit_1.convertNxGenerator)(e2eProjectGenerator);
|
|
108
|
+
//# sourceMappingURL=e2e-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2e-project.js","sourceRoot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ACF,MAAM,OAAO,GAAG,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC;IACpE,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,GAAG,OAAO,CAAC,OAAO,MAAM,CAAC;IAEtD,MAAM,YAAY,GAAG,gBAAgB;QACnC,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC,QAAQ,IAAI,IAAA,cAAK,EAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;QAC/D,CAAC,CAAC,IAAA,cAAK,EAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAEzB,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAEvE,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW;QACxC,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,IAAA,0BAAiB,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAE7C,uCACK,OAAO,KACV,cAAc;QACd,cAAc,EACd,IAAI,EAAE,MAAA,OAAO,CAAC,IAAI,mCAAI,IAAI,EAC1B,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,IAClC;AACJ,CAAC;AAED,kBAAe,mBAAmB,CAAC;AACtB,QAAA,mBAAmB,GAAG,IAAA,2BAAkB,EAAC,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export default {
|
|
3
|
+
displayName: '<%= e2eProjectName %>',
|
|
4
|
+
preset: '<%= offsetFromRoot %>/jest.preset.js',
|
|
5
|
+
setupFiles: ['<rootDir>/src/test-setup.ts'],
|
|
6
|
+
testEnvironment: 'node',
|
|
7
|
+
transform: {
|
|
8
|
+
'^.+\\.[tj]s$': ['ts-jest', {
|
|
9
|
+
tsconfig: '<rootDir>/tsconfig.spec.json',
|
|
10
|
+
}],
|
|
11
|
+
},
|
|
12
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
13
|
+
coverageDirectory: '<%= offsetFromRoot %>/coverage/<%= e2eProjectName %>',
|
|
14
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
describe('CLI tests', () => {
|
|
5
|
+
it('should print a message', () => {
|
|
6
|
+
const cliPath = join(process.cwd(), "<%= mainFile %>");
|
|
7
|
+
|
|
8
|
+
const output = execSync(`node ${cliPath}`).toString();
|
|
9
|
+
|
|
10
|
+
expect(output).toMatch(/Hello World/);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "<%= offsetFromRoot %><% if (rootProject) { %>tsconfig.json<% } else { %>tsconfig.base.json<% } %>",
|
|
3
|
+
"files": [],
|
|
4
|
+
"include": [],
|
|
5
|
+
"references": [
|
|
6
|
+
{
|
|
7
|
+
"path": "./tsconfig.spec.json"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"esModuleInterop": true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export default {
|
|
3
|
+
displayName: '<%= e2eProjectName %>',
|
|
4
|
+
preset: '<%= offsetFromRoot %>jest.preset.js',
|
|
5
|
+
globalSetup: '<rootDir>/src/support/global-setup.ts',
|
|
6
|
+
globalTeardown: '<rootDir>/src/support/global-teardown.ts',
|
|
7
|
+
setupFiles: ['<rootDir>/src/support/test-setup.ts'],
|
|
8
|
+
testEnvironment: 'node',
|
|
9
|
+
transform: {
|
|
10
|
+
'^.+\\.[tj]s$': ['ts-jest', {
|
|
11
|
+
tsconfig: '<rootDir>/tsconfig.spec.json',
|
|
12
|
+
}],
|
|
13
|
+
},
|
|
14
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
15
|
+
coverageDirectory: '<%= offsetFromRoot %>coverage/<%= e2eProjectName %>',
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
var __TEARDOWN_MESSAGE__: string;
|
|
3
|
+
|
|
4
|
+
module.exports = async function() {
|
|
5
|
+
// Start services that that the app needs to run (e.g. database, docker-compose, etc.).
|
|
6
|
+
console.log('\nSetting up...\n');
|
|
7
|
+
|
|
8
|
+
// Hint: Use `globalThis` to pass variables to global teardown.
|
|
9
|
+
globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n';
|
|
10
|
+
};
|
|
11
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
|
|
5
|
+
module.exports = async function() {
|
|
6
|
+
// Configure axios for tests to use.
|
|
7
|
+
const host = process.env.HOST ?? 'localhost';
|
|
8
|
+
const port = process.env.PORT ?? '<%= port %>';
|
|
9
|
+
axios.defaults.baseURL = `http://${host}:${port}`;
|
|
10
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "<%= offsetFromRoot %><% if (rootProject) { %>tsconfig.json<% } else { %>tsconfig.base.json<% } %>",
|
|
3
|
+
"files": [],
|
|
4
|
+
"include": [],
|
|
5
|
+
"references": [
|
|
6
|
+
{
|
|
7
|
+
"path": "./tsconfig.spec.json"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"esModuleInterop": true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "SchematicsNxNodeE2eProject",
|
|
5
|
+
"title": "Node E2E Project Generator",
|
|
6
|
+
"description": "Generate an E2E project for a Node server application.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The name of the project.",
|
|
12
|
+
"$default": { "$source": "argv", "index": 0 },
|
|
13
|
+
"x-dropdown": "project",
|
|
14
|
+
"x-prompt": "What project is this for?"
|
|
15
|
+
},
|
|
16
|
+
"directory": {
|
|
17
|
+
"description": "The directory of the e2e project.",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"x-priority": "important"
|
|
20
|
+
},
|
|
21
|
+
"name": {
|
|
22
|
+
"description": "The name of the e2e project. Defaults to the project name with '-e2e' suffix.",
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"projectType": {
|
|
26
|
+
"description": "The type of application that is being tested.",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": ["server", "cli"],
|
|
29
|
+
"default": "server"
|
|
30
|
+
},
|
|
31
|
+
"port": {
|
|
32
|
+
"description": "The port that the server runs on. Only application for server application.",
|
|
33
|
+
"type": "number",
|
|
34
|
+
"default": 3000
|
|
35
|
+
},
|
|
36
|
+
"linter": {
|
|
37
|
+
"description": "Linter to be used for the E2E project",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": ["eslint", "none"],
|
|
40
|
+
"default": "eslint"
|
|
41
|
+
},
|
|
42
|
+
"isNest": {
|
|
43
|
+
"description": "Is the E2E server project nest",
|
|
44
|
+
"type": "boolean",
|
|
45
|
+
"default": false,
|
|
46
|
+
"hidden": true,
|
|
47
|
+
"x-priority": "internal"
|
|
48
|
+
},
|
|
49
|
+
"rootProject": {
|
|
50
|
+
"description": "Create node application at the root of the workspace.",
|
|
51
|
+
"type": "boolean",
|
|
52
|
+
"default": false,
|
|
53
|
+
"hidden": true,
|
|
54
|
+
"x-priority": "internal"
|
|
55
|
+
},
|
|
56
|
+
"skipFormat": {
|
|
57
|
+
"description": "Skip formatting files.",
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"default": false,
|
|
60
|
+
"hidden": true,
|
|
61
|
+
"x-priority": "internal"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": ["project"]
|
|
65
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export declare function initGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export default initGenerator;
|
|
5
|
+
export declare const initSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|