@nx/node 19.1.0-beta.0 → 19.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -8
- package/src/generators/e2e-project/e2e-project.js +4 -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/setup-docker.js +24 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/node",
|
|
3
|
-
"version": "19.1.0-beta.
|
|
3
|
+
"version": "19.1.0-beta.2",
|
|
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": "19.1.0-beta.
|
|
35
|
-
"@nx/jest": "19.1.0-beta.
|
|
36
|
-
"@nx/js": "19.1.0-beta.
|
|
37
|
-
"@nx/eslint": "19.1.0-beta.
|
|
38
|
-
"@nrwl/node": "19.1.0-beta.
|
|
35
|
+
"@nx/devkit": "19.1.0-beta.2",
|
|
36
|
+
"@nx/jest": "19.1.0-beta.2",
|
|
37
|
+
"@nx/js": "19.1.0-beta.2",
|
|
38
|
+
"@nx/eslint": "19.1.0-beta.2",
|
|
39
|
+
"@nrwl/node": "19.1.0-beta.2"
|
|
39
40
|
},
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"access": "public"
|
|
@@ -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,
|
|
@@ -63,11 +64,13 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
63
64
|
};
|
|
64
65
|
});
|
|
65
66
|
}
|
|
67
|
+
const jestPreset = (0, config_file_1.findRootJestPreset)(host) ?? 'jest.preset.js';
|
|
66
68
|
if (options.projectType === 'server') {
|
|
67
69
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, {
|
|
68
70
|
...options,
|
|
69
71
|
...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
|
|
70
72
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
|
|
73
|
+
jestPreset,
|
|
71
74
|
tmpl: '',
|
|
72
75
|
});
|
|
73
76
|
if (options.isNest) {
|
|
@@ -86,6 +89,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
86
89
|
...(0, devkit_1.names)(options.rootProject ? 'cli' : options.project),
|
|
87
90
|
mainFile,
|
|
88
91
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
|
|
92
|
+
jestPreset,
|
|
89
93
|
tmpl: '',
|
|
90
94
|
});
|
|
91
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.
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setupDockerGenerator = exports.updateProjectConfig = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
+
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
7
|
+
const project_graph_1 = require("nx/src/project-graph/project-graph");
|
|
6
8
|
function normalizeOptions(tree, setupOptions) {
|
|
7
9
|
return {
|
|
8
10
|
...setupOptions,
|
|
@@ -12,18 +14,33 @@ function normalizeOptions(tree, setupOptions) {
|
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
16
|
function addDocker(tree, options) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
// Inferred targets are only available in the project graph
|
|
18
|
+
const projectConfig = (0, project_graph_1.readCachedProjectConfiguration)(options.project);
|
|
19
|
+
if (!projectConfig ||
|
|
20
|
+
!projectConfig.targets ||
|
|
21
|
+
!projectConfig.targets[options.buildTarget]) {
|
|
17
22
|
return;
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
// Returns an string like {workspaceRoot}/dist/apps/{projectName}
|
|
25
|
+
// Non crystalized projects would return {options.outputPath}
|
|
26
|
+
const tokenizedOutputPath = projectConfig.targets[`${options.buildTarget}`]?.outputs?.[0];
|
|
27
|
+
const maybeBuildOptions = projectConfig.targets[`${options.buildTarget}`]?.options;
|
|
28
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'DockerFile'))) {
|
|
29
|
+
devkit_1.logger.info(`Skipping setup since a Dockerfile already exists inside ${projectConfig.root}`);
|
|
30
|
+
}
|
|
31
|
+
else if (!tokenizedOutputPath) {
|
|
32
|
+
devkit_1.logger.error(`Skipping setup since the output path for the build target ${options.buildTarget} is not defined.`);
|
|
21
33
|
}
|
|
22
34
|
else {
|
|
23
|
-
const outputPath =
|
|
24
|
-
|
|
35
|
+
const outputPath = (0, utils_1.interpolate)(tokenizedOutputPath, {
|
|
36
|
+
projectName: projectConfig.name,
|
|
37
|
+
projectRoot: projectConfig.root,
|
|
38
|
+
workspaceRoot: '',
|
|
39
|
+
options: maybeBuildOptions || '',
|
|
40
|
+
});
|
|
41
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), projectConfig.root, {
|
|
25
42
|
tmpl: '',
|
|
26
|
-
app:
|
|
43
|
+
app: projectConfig.sourceRoot,
|
|
27
44
|
buildLocation: outputPath,
|
|
28
45
|
project: options.project,
|
|
29
46
|
});
|