@nx/nest 0.0.0-pr-3-e51e28c → 0.0.0-pr-30418-4e2b721
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 +5 -5
- package/src/generators/application/application.js +1 -0
- package/src/generators/application/lib/normalize-options.js +4 -1
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +4 -0
- package/src/generators/library/lib/add-project.js +1 -0
- package/src/generators/library/lib/create-files.js +1 -1
- package/src/generators/library/lib/normalize-options.js +4 -6
- package/src/generators/library/library.js +18 -3
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/nest",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-30418-4e2b721",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Nest contains executors and generators for allowing your workspace to create powerful Nest best in class APIs.",
|
|
6
6
|
"repository": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@nestjs/schematics": "^9.1.0",
|
|
35
|
-
"@nx/devkit": "0.0.0-pr-
|
|
36
|
-
"@nx/js": "0.0.0-pr-
|
|
37
|
-
"@nx/eslint": "0.0.0-pr-
|
|
38
|
-
"@nx/node": "0.0.0-pr-
|
|
35
|
+
"@nx/devkit": "0.0.0-pr-30418-4e2b721",
|
|
36
|
+
"@nx/js": "0.0.0-pr-30418-4e2b721",
|
|
37
|
+
"@nx/eslint": "0.0.0-pr-30418-4e2b721",
|
|
38
|
+
"@nx/node": "0.0.0-pr-30418-4e2b721",
|
|
39
39
|
"tslib": "^2.3.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
@@ -5,8 +5,9 @@ exports.toNodeApplicationGeneratorOptions = toNodeApplicationGeneratorOptions;
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
7
7
|
const eslint_1 = require("@nx/eslint");
|
|
8
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
9
|
async function normalizeOptions(tree, options) {
|
|
9
|
-
await (0, project_name_and_root_utils_1.
|
|
10
|
+
await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
|
|
10
11
|
const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
11
12
|
name: options.name,
|
|
12
13
|
projectType: 'application',
|
|
@@ -26,6 +27,7 @@ async function normalizeOptions(tree, options) {
|
|
|
26
27
|
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
27
28
|
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
28
29
|
e2eTestRunner: options.e2eTestRunner ?? 'jest',
|
|
30
|
+
useProjectJson: options.useProjectJson ?? !(0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree),
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
function toNodeApplicationGeneratorOptions(options) {
|
|
@@ -45,5 +47,6 @@ function toNodeApplicationGeneratorOptions(options) {
|
|
|
45
47
|
bundler: 'webpack', // Some features require webpack plugins such as TS transformers
|
|
46
48
|
isNest: true,
|
|
47
49
|
addPlugin: options.addPlugin,
|
|
50
|
+
useProjectJson: options.useProjectJson,
|
|
48
51
|
};
|
|
49
52
|
}
|
|
@@ -78,6 +78,10 @@
|
|
|
78
78
|
"type": "boolean",
|
|
79
79
|
"description": "Adds strictNullChecks, noImplicitAny, strictBindCallApply, forceConsistentCasingInFileNames and noFallthroughCasesInSwitch to tsconfig.",
|
|
80
80
|
"default": false
|
|
81
|
+
},
|
|
82
|
+
"useProjectJson": {
|
|
83
|
+
"type": "boolean",
|
|
84
|
+
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
81
85
|
}
|
|
82
86
|
},
|
|
83
87
|
"additionalProperties": false,
|
|
@@ -4,8 +4,8 @@ exports.createFiles = createFiles;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function createFiles(tree, options) {
|
|
6
6
|
const substitutions = {
|
|
7
|
-
...options,
|
|
8
7
|
...(0, devkit_1.names)(options.projectName),
|
|
8
|
+
...options,
|
|
9
9
|
tmpl: '',
|
|
10
10
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
11
11
|
fileName: options.fileName,
|
|
@@ -7,9 +7,8 @@ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project
|
|
|
7
7
|
const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
|
|
8
8
|
const eslint_1 = require("@nx/eslint");
|
|
9
9
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
10
|
-
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
11
10
|
async function normalizeOptions(tree, options) {
|
|
12
|
-
await (0, project_name_and_root_utils_1.
|
|
11
|
+
await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library');
|
|
13
12
|
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
14
13
|
name: options.name,
|
|
15
14
|
projectType: 'library',
|
|
@@ -36,9 +35,7 @@ async function normalizeOptions(tree, options) {
|
|
|
36
35
|
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
37
36
|
parsedTags,
|
|
38
37
|
prefix: (0, get_npm_scope_1.getNpmScope)(tree), // we could also allow customizing this
|
|
39
|
-
projectName: isUsingTsSolutionsConfig
|
|
40
|
-
? (0, get_import_path_1.getImportPath)(tree, projectName)
|
|
41
|
-
: projectName,
|
|
38
|
+
projectName: isUsingTsSolutionsConfig && !options.name ? importPath : projectName,
|
|
42
39
|
projectRoot,
|
|
43
40
|
importPath,
|
|
44
41
|
service: options.service ?? false,
|
|
@@ -46,6 +43,7 @@ async function normalizeOptions(tree, options) {
|
|
|
46
43
|
testEnvironment: options.testEnvironment ?? 'node',
|
|
47
44
|
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
48
45
|
isUsingTsSolutionsConfig,
|
|
46
|
+
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionsConfig,
|
|
49
47
|
};
|
|
50
48
|
return normalized;
|
|
51
49
|
}
|
|
@@ -66,6 +64,6 @@ function toJsLibraryGeneratorOptions(options) {
|
|
|
66
64
|
unitTestRunner: options.unitTestRunner,
|
|
67
65
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
68
66
|
addPlugin: options.addPlugin,
|
|
69
|
-
useProjectJson:
|
|
67
|
+
useProjectJson: options.useProjectJson,
|
|
70
68
|
};
|
|
71
69
|
}
|
|
@@ -3,20 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.libraryGenerator = libraryGenerator;
|
|
4
4
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const js_1 = require("@nx/js");
|
|
7
|
-
const lib_1 = require("./lib");
|
|
8
|
-
const init_1 = require("../init/init");
|
|
9
6
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
7
|
+
const js_1 = require("@nx/js");
|
|
10
8
|
const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
|
|
9
|
+
const init_1 = require("../init/init");
|
|
10
|
+
const lib_1 = require("./lib");
|
|
11
11
|
async function libraryGenerator(tree, rawOptions) {
|
|
12
12
|
return await libraryGeneratorInternal(tree, {
|
|
13
13
|
addPlugin: false,
|
|
14
|
+
useProjectJson: true,
|
|
14
15
|
...rawOptions,
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
18
|
async function libraryGeneratorInternal(tree, rawOptions) {
|
|
18
19
|
const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
19
20
|
const jsLibraryTask = await (0, js_1.libraryGenerator)(tree, (0, lib_1.toJsLibraryGeneratorOptions)(options));
|
|
21
|
+
updatePackageJson(tree, options);
|
|
20
22
|
const initTask = await (0, init_1.default)(tree, rawOptions);
|
|
21
23
|
const depsTask = (0, ensure_dependencies_1.ensureDependencies)(tree);
|
|
22
24
|
(0, lib_1.deleteFiles)(tree, options);
|
|
@@ -37,3 +39,16 @@ async function libraryGeneratorInternal(tree, rawOptions) {
|
|
|
37
39
|
]);
|
|
38
40
|
}
|
|
39
41
|
exports.default = libraryGenerator;
|
|
42
|
+
function updatePackageJson(tree, options) {
|
|
43
|
+
const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
|
|
44
|
+
if (!tree.exists(packageJsonPath)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const packageJson = (0, devkit_1.readJson)(tree, packageJsonPath);
|
|
48
|
+
if (packageJson.type === 'module') {
|
|
49
|
+
// The @nx/js:lib generator can set the type to 'module' which would
|
|
50
|
+
// potentially break consumers of the library.
|
|
51
|
+
delete packageJson.type;
|
|
52
|
+
}
|
|
53
|
+
(0, devkit_1.writeJson)(tree, packageJsonPath, packageJson);
|
|
54
|
+
}
|
|
@@ -133,6 +133,10 @@
|
|
|
133
133
|
"description": "Don't include the directory in the name of the module of the library.",
|
|
134
134
|
"type": "boolean",
|
|
135
135
|
"default": false
|
|
136
|
+
},
|
|
137
|
+
"useProjectJson": {
|
|
138
|
+
"type": "boolean",
|
|
139
|
+
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
136
140
|
}
|
|
137
141
|
},
|
|
138
142
|
"additionalProperties": false,
|