@nx/node 0.0.0-pr-22179-271588f → 0.0.0-pr-26482-ebe2dba
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/LICENSE +1 -1
- package/package.json +9 -8
- package/src/generators/application/application.d.ts +1 -0
- package/src/generators/application/application.js +4 -3
- package/src/generators/application/files/common/webpack.config.js__tmpl__ +2 -2
- package/src/generators/e2e-project/e2e-project.js +30 -0
- package/src/generators/e2e-project/files/cli/jest.config.ts__tmpl__ +2 -2
- package/src/generators/e2e-project/files/server/common/jest.config.ts__tmpl__ +1 -1
- package/src/generators/setup-docker/files/Dockerfile__tmpl__ +1 -1
- package/src/generators/setup-docker/schema.d.ts +1 -0
- package/src/generators/setup-docker/schema.json +4 -0
- package/src/generators/setup-docker/setup-docker.js +8 -15
package/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/node",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-26482-ebe2dba",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.",
|
|
6
6
|
"repository": {
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
"Nest",
|
|
15
15
|
"Jest",
|
|
16
16
|
"Cypress",
|
|
17
|
-
"CLI"
|
|
17
|
+
"CLI",
|
|
18
|
+
"Backend"
|
|
18
19
|
],
|
|
19
|
-
"main": "./index
|
|
20
|
+
"main": "./index",
|
|
20
21
|
"typings": "./index.d.ts",
|
|
21
22
|
"author": "Victor Savkin",
|
|
22
23
|
"license": "MIT",
|
|
@@ -31,11 +32,11 @@
|
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"tslib": "^2.3.0",
|
|
34
|
-
"@nx/devkit": "0.0.0-pr-
|
|
35
|
-
"@nx/jest": "0.0.0-pr-
|
|
36
|
-
"@nx/js": "0.0.0-pr-
|
|
37
|
-
"@nx/eslint": "0.0.0-pr-
|
|
38
|
-
"@nrwl/node": "0.0.0-pr-
|
|
35
|
+
"@nx/devkit": "0.0.0-pr-26482-ebe2dba",
|
|
36
|
+
"@nx/jest": "0.0.0-pr-26482-ebe2dba",
|
|
37
|
+
"@nx/js": "0.0.0-pr-26482-ebe2dba",
|
|
38
|
+
"@nx/eslint": "0.0.0-pr-26482-ebe2dba",
|
|
39
|
+
"@nrwl/node": "0.0.0-pr-26482-ebe2dba"
|
|
39
40
|
},
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"access": "public"
|
|
@@ -3,6 +3,7 @@ import { Schema } from './schema';
|
|
|
3
3
|
export interface NormalizedSchema extends Schema {
|
|
4
4
|
appProjectRoot: string;
|
|
5
5
|
parsedTags: string[];
|
|
6
|
+
outputPath: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function addLintingToApplication(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
8
9
|
export declare function applicationGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
@@ -23,7 +23,7 @@ function getWebpackBuildConfig(project, options) {
|
|
|
23
23
|
options: {
|
|
24
24
|
target: 'node',
|
|
25
25
|
compiler: 'tsc',
|
|
26
|
-
outputPath:
|
|
26
|
+
outputPath: options.outputPath,
|
|
27
27
|
main: (0, devkit_1.joinPathFragments)(project.sourceRoot, 'main' + (options.js ? '.js' : '.ts')),
|
|
28
28
|
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
29
29
|
assets: [(0, devkit_1.joinPathFragments)(project.sourceRoot, 'assets')],
|
|
@@ -44,7 +44,7 @@ function getEsBuildConfig(project, options) {
|
|
|
44
44
|
defaultConfiguration: 'production',
|
|
45
45
|
options: {
|
|
46
46
|
platform: 'node',
|
|
47
|
-
outputPath:
|
|
47
|
+
outputPath: options.outputPath,
|
|
48
48
|
// Use CJS for Node apps for widest compatibility.
|
|
49
49
|
format: ['cjs'],
|
|
50
50
|
bundle: false,
|
|
@@ -120,7 +120,7 @@ function addAppFiles(tree, options) {
|
|
|
120
120
|
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
|
|
121
121
|
webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)
|
|
122
122
|
? {
|
|
123
|
-
outputPath:
|
|
123
|
+
outputPath: options.outputPath,
|
|
124
124
|
main: './src/main' + (options.js ? '.js' : '.ts'),
|
|
125
125
|
tsConfig: './tsconfig.app.json',
|
|
126
126
|
assets: ['./src/assets'],
|
|
@@ -407,6 +407,7 @@ async function normalizeOptions(host, options) {
|
|
|
407
407
|
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
408
408
|
rootProject: options.rootProject ?? false,
|
|
409
409
|
port: options.port ?? 3000,
|
|
410
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : appProjectRoot),
|
|
410
411
|
};
|
|
411
412
|
}
|
|
412
413
|
exports.default = applicationGenerator;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% if (webpackPluginOptions) { %>
|
|
2
|
-
const {
|
|
2
|
+
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
|
|
3
3
|
const { join } = require('path');
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
@@ -7,7 +7,7 @@ module.exports = {
|
|
|
7
7
|
path: join(__dirname, '<%= offset %><%= webpackPluginOptions.outputPath %>'),
|
|
8
8
|
},
|
|
9
9
|
plugins: [
|
|
10
|
-
new
|
|
10
|
+
new NxAppWebpackPlugin({
|
|
11
11
|
target: 'node',
|
|
12
12
|
compiler: 'tsc',
|
|
13
13
|
main: '<%= webpackPluginOptions.main %>',
|
|
@@ -9,6 +9,7 @@ const path = require("path");
|
|
|
9
9
|
const versions_1 = require("../../utils/versions");
|
|
10
10
|
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
11
11
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
12
|
+
const config_file_1 = require("@nx/jest/src/utils/config/config-file");
|
|
12
13
|
async function e2eProjectGenerator(host, options) {
|
|
13
14
|
return await e2eProjectGeneratorInternal(host, {
|
|
14
15
|
addPlugin: false,
|
|
@@ -34,14 +35,42 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
34
35
|
jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
|
|
35
36
|
passWithNoTests: true,
|
|
36
37
|
},
|
|
38
|
+
dependsOn: [`${options.project}:build`],
|
|
37
39
|
},
|
|
38
40
|
},
|
|
39
41
|
});
|
|
42
|
+
// TODO(@nicholas): Find a better way to get build target
|
|
43
|
+
// We remove the 'test' target from the e2e project because it is not needed
|
|
44
|
+
// The 'e2e' target is the one that should run the tests for the e2e project
|
|
45
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
46
|
+
const hasPlugin = nxJson.plugins?.some((p) => {
|
|
47
|
+
if (typeof p !== 'string' && p.plugin === '@nx/jest/plugin') {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (hasPlugin) {
|
|
52
|
+
(0, devkit_1.updateJson)(host, 'nx.json', (json) => {
|
|
53
|
+
return {
|
|
54
|
+
...json,
|
|
55
|
+
plugins: json.plugins?.map((p) => {
|
|
56
|
+
if (typeof p !== 'string' && p.plugin === '@nx/jest/plugin') {
|
|
57
|
+
return {
|
|
58
|
+
...p,
|
|
59
|
+
exclude: [...(p.exclude || []), `${options.e2eProjectRoot}/**/*`],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return p;
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const jestPreset = (0, config_file_1.findRootJestPreset)(host) ?? 'jest.preset.js';
|
|
40
68
|
if (options.projectType === 'server') {
|
|
41
69
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, {
|
|
42
70
|
...options,
|
|
43
71
|
...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
|
|
44
72
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
|
|
73
|
+
jestPreset,
|
|
45
74
|
tmpl: '',
|
|
46
75
|
});
|
|
47
76
|
if (options.isNest) {
|
|
@@ -60,6 +89,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
60
89
|
...(0, devkit_1.names)(options.rootProject ? 'cli' : options.project),
|
|
61
90
|
mainFile,
|
|
62
91
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
|
|
92
|
+
jestPreset,
|
|
63
93
|
tmpl: '',
|
|
64
94
|
});
|
|
65
95
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
export default {
|
|
3
3
|
displayName: '<%= e2eProjectName %>',
|
|
4
|
-
preset: '<%= offsetFromRoot
|
|
4
|
+
preset: '<%= offsetFromRoot %><%= jestPreset %>',
|
|
5
5
|
setupFiles: ['<rootDir>/src/test-setup.ts'],
|
|
6
6
|
testEnvironment: 'node',
|
|
7
7
|
transform: {
|
|
@@ -10,5 +10,5 @@ export default {
|
|
|
10
10
|
}],
|
|
11
11
|
},
|
|
12
12
|
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
13
|
-
coverageDirectory: '<%= offsetFromRoot
|
|
13
|
+
coverageDirectory: '<%= offsetFromRoot %>coverage/<%= e2eProjectName %>',
|
|
14
14
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
export default {
|
|
3
3
|
displayName: '<%= e2eProjectName %>',
|
|
4
|
-
preset: '<%= offsetFromRoot %>
|
|
4
|
+
preset: '<%= offsetFromRoot %><%= jestPreset %>',
|
|
5
5
|
globalSetup: '<rootDir>/src/support/global-setup.ts',
|
|
6
6
|
globalTeardown: '<rootDir>/src/support/global-teardown.ts',
|
|
7
7
|
setupFiles: ['<rootDir>/src/support/test-setup.ts'],
|
|
@@ -14,7 +14,7 @@ WORKDIR /app
|
|
|
14
14
|
RUN addgroup --system <%= project %> && \
|
|
15
15
|
adduser --system -G <%= project %> <%= project %>
|
|
16
16
|
|
|
17
|
-
COPY <%= buildLocation %> <%= project
|
|
17
|
+
COPY <%= buildLocation %> <%= project %>/
|
|
18
18
|
RUN chown -R <%= project %>:<%= project %> .
|
|
19
19
|
|
|
20
20
|
# You can remove this install step if you build with `--bundle` option.
|
|
@@ -12,22 +12,15 @@ function normalizeOptions(tree, setupOptions) {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
function addDocker(tree, options) {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'DockerFile'))) {
|
|
20
|
-
devkit_1.logger.info(`Skipping setup since a Dockerfile already exists inside ${project.root}`);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
const outputPath = project.targets[`${options.buildTarget}`]?.options.outputPath;
|
|
24
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, {
|
|
25
|
-
tmpl: '',
|
|
26
|
-
app: project.sourceRoot,
|
|
27
|
-
buildLocation: outputPath,
|
|
28
|
-
project: options.project,
|
|
29
|
-
});
|
|
15
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
16
|
+
if (!projectConfig) {
|
|
17
|
+
throw new Error(`Cannot find project configuration for ${options.project}`);
|
|
30
18
|
}
|
|
19
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), projectConfig.root, {
|
|
20
|
+
tmpl: '',
|
|
21
|
+
buildLocation: options.outputPath,
|
|
22
|
+
project: options.project,
|
|
23
|
+
});
|
|
31
24
|
}
|
|
32
25
|
function updateProjectConfig(tree, options) {
|
|
33
26
|
let projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|