@nx/devkit 17.0.0-beta.4 → 17.0.0-beta.6
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/devkit",
|
|
3
|
-
"version": "17.0.0-beta.
|
|
3
|
+
"version": "17.0.0-beta.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more.",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"tmp": "~0.2.1",
|
|
35
35
|
"tslib": "^2.3.0",
|
|
36
36
|
"semver": "7.5.3",
|
|
37
|
-
"@nrwl/devkit": "17.0.0-beta.
|
|
37
|
+
"@nrwl/devkit": "17.0.0-beta.6"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"nx": ">= 16 <= 18"
|
|
@@ -14,6 +14,7 @@ export type ArtifactGenerationOptions = {
|
|
|
14
14
|
pascalCaseFile?: boolean;
|
|
15
15
|
project?: string;
|
|
16
16
|
suffix?: string;
|
|
17
|
+
derivedDirectory?: string;
|
|
17
18
|
};
|
|
18
19
|
export type NameAndDirectoryOptions = {
|
|
19
20
|
/**
|
|
@@ -40,3 +41,7 @@ export type NameAndDirectoryOptions = {
|
|
|
40
41
|
export declare function determineArtifactNameAndDirectoryOptions(tree: Tree, options: ArtifactGenerationOptions): Promise<NameAndDirectoryOptions & {
|
|
41
42
|
nameAndDirectoryFormat: NameAndDirectoryFormat;
|
|
42
43
|
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Function for setting cwd during testing
|
|
46
|
+
*/
|
|
47
|
+
export declare function setCwd(path: string): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.determineArtifactNameAndDirectoryOptions = void 0;
|
|
3
|
+
exports.setCwd = exports.determineArtifactNameAndDirectoryOptions = void 0;
|
|
4
4
|
const enquirer_1 = require("enquirer");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const nx_1 = require("../../nx");
|
|
@@ -9,7 +9,7 @@ const { createProjectRootMappingsFromProjectConfigurations, findProjectForPath,
|
|
|
9
9
|
async function determineArtifactNameAndDirectoryOptions(tree, options) {
|
|
10
10
|
const formats = getNameAndDirectoryOptionFormats(tree, options);
|
|
11
11
|
const format = options.nameAndDirectoryFormat ?? (await determineFormat(formats, options));
|
|
12
|
-
validateResolvedProject(formats[format]?.project, options, formats[format]?.directory);
|
|
12
|
+
validateResolvedProject(tree, formats[format]?.project, options, formats[format]?.directory);
|
|
13
13
|
return {
|
|
14
14
|
...formats[format],
|
|
15
15
|
nameAndDirectoryFormat: format,
|
|
@@ -77,7 +77,7 @@ function getNameAndDirectoryOptionFormats(tree, options) {
|
|
|
77
77
|
name: extractedName,
|
|
78
78
|
});
|
|
79
79
|
if (!options.project) {
|
|
80
|
-
validateResolvedProject(asProvidedOptions.project, options, asProvidedOptions.directory);
|
|
80
|
+
validateResolvedProject(tree, asProvidedOptions.project, options, asProvidedOptions.directory);
|
|
81
81
|
}
|
|
82
82
|
if (options.nameAndDirectoryFormat === 'as-provided') {
|
|
83
83
|
return {
|
|
@@ -142,11 +142,17 @@ function getDerivedOptions(tree, options, asProvidedOptions, extractedDirectory)
|
|
|
142
142
|
const baseDirectory = options.directory
|
|
143
143
|
? (0, names_1.names)(options.directory).fileName
|
|
144
144
|
: joinPathFragments(project.sourceRoot ?? joinPathFragments(project.root, 'src'), project.projectType === 'application' ? 'app' : 'lib', extractedDirectory ?? '');
|
|
145
|
-
const derivedDirectory = options.
|
|
146
|
-
?
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
const derivedDirectory = typeof options.derivedDirectory === 'string'
|
|
146
|
+
? joinPathFragments(project.sourceRoot ?? project.root, options.derivedDirectory, options.flat
|
|
147
|
+
? ''
|
|
148
|
+
: options.pascalCaseDirectory
|
|
149
|
+
? (0, names_1.names)(derivedName).className
|
|
150
|
+
: (0, names_1.names)(derivedName).fileName)
|
|
151
|
+
: options.flat
|
|
152
|
+
? normalizePath(baseDirectory)
|
|
153
|
+
: joinPathFragments(baseDirectory, options.pascalCaseDirectory
|
|
154
|
+
? (0, names_1.names)(derivedName).className
|
|
155
|
+
: (0, names_1.names)(derivedName).fileName);
|
|
150
156
|
if (options.directory &&
|
|
151
157
|
!isDirectoryUnderProjectRoot(derivedDirectory, project.root)) {
|
|
152
158
|
if (!options.nameAndDirectoryFormat) {
|
|
@@ -180,7 +186,7 @@ function getDerivedOptions(tree, options, asProvidedOptions, extractedDirectory)
|
|
|
180
186
|
project: projectName,
|
|
181
187
|
};
|
|
182
188
|
}
|
|
183
|
-
function validateResolvedProject(project, options, normalizedDirectory) {
|
|
189
|
+
function validateResolvedProject(tree, project, options, normalizedDirectory) {
|
|
184
190
|
if (project) {
|
|
185
191
|
return;
|
|
186
192
|
}
|
|
@@ -212,6 +218,13 @@ function isTTY() {
|
|
|
212
218
|
function getRelativeCwd() {
|
|
213
219
|
return normalizePath((0, path_1.relative)(workspaceRoot, getCwd()));
|
|
214
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Function for setting cwd during testing
|
|
223
|
+
*/
|
|
224
|
+
function setCwd(path) {
|
|
225
|
+
process.env.INIT_CWD = (0, path_1.join)(workspaceRoot, path);
|
|
226
|
+
}
|
|
227
|
+
exports.setCwd = setCwd;
|
|
215
228
|
function getCwd() {
|
|
216
229
|
return process.env.INIT_CWD?.startsWith(workspaceRoot)
|
|
217
230
|
? process.env.INIT_CWD
|