@nx/devkit 20.1.0-canary.20241025-1218502 → 20.1.0-canary.20241029-4b70d1b
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/devkit",
|
3
|
-
"version": "20.1.0-canary.
|
3
|
+
"version": "20.1.0-canary.20241029-4b70d1b",
|
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. Learn more about [extending Nx by leveraging the Nx Devkit](https://nx.dev/extending-nx/intro/getting-started) on our docs.",
|
6
6
|
"repository": {
|
@@ -34,4 +34,5 @@ export type ProjectNameAndRootOptions = {
|
|
34
34
|
importPath?: string;
|
35
35
|
};
|
36
36
|
export declare function determineProjectNameAndRootOptions(tree: Tree, options: ProjectGenerationOptions): Promise<ProjectNameAndRootOptions>;
|
37
|
+
export declare function resolveImportPath(tree: Tree, projectName: string, projectRoot: string): string;
|
37
38
|
export declare function ensureProjectName(tree: Tree, options: Omit<ProjectGenerationOptions, 'projectType'>, projectType: 'application' | 'library'): Promise<void>;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.determineProjectNameAndRootOptions = determineProjectNameAndRootOptions;
|
4
|
+
exports.resolveImportPath = resolveImportPath;
|
4
5
|
exports.ensureProjectName = ensureProjectName;
|
5
6
|
const enquirer_1 = require("enquirer");
|
6
7
|
const devkit_exports_1 = require("nx/src/devkit-exports");
|
@@ -45,20 +46,8 @@ async function determineProjectNameAndRootOptions(tree, options) {
|
|
45
46
|
}
|
46
47
|
let importPath = undefined;
|
47
48
|
if (options.projectType === 'library') {
|
48
|
-
importPath =
|
49
|
-
|
50
|
-
if (name.startsWith('@')) {
|
51
|
-
importPath = name;
|
52
|
-
}
|
53
|
-
else {
|
54
|
-
const npmScope = getNpmScope(tree);
|
55
|
-
importPath =
|
56
|
-
projectRoot === '.'
|
57
|
-
? (0, devkit_exports_1.readJson)(tree, 'package.json').name ??
|
58
|
-
getImportPath(npmScope, name)
|
59
|
-
: getImportPath(npmScope, name);
|
60
|
-
}
|
61
|
-
}
|
49
|
+
importPath =
|
50
|
+
options.importPath ?? resolveImportPath(tree, name, projectRoot);
|
62
51
|
}
|
63
52
|
return {
|
64
53
|
projectName: name,
|
@@ -70,6 +59,21 @@ async function determineProjectNameAndRootOptions(tree, options) {
|
|
70
59
|
projectRoot,
|
71
60
|
};
|
72
61
|
}
|
62
|
+
function resolveImportPath(tree, projectName, projectRoot) {
|
63
|
+
let importPath;
|
64
|
+
if (projectName.startsWith('@')) {
|
65
|
+
importPath = projectName;
|
66
|
+
}
|
67
|
+
else {
|
68
|
+
const npmScope = getNpmScope(tree);
|
69
|
+
importPath =
|
70
|
+
projectRoot === '.'
|
71
|
+
? (0, devkit_exports_1.readJson)(tree, 'package.json').name ??
|
72
|
+
getImportPath(npmScope, projectName)
|
73
|
+
: getImportPath(npmScope, projectName);
|
74
|
+
}
|
75
|
+
return importPath;
|
76
|
+
}
|
73
77
|
async function ensureProjectName(tree, options, projectType) {
|
74
78
|
if (!options.name) {
|
75
79
|
if (options.directory === '.' && getRelativeCwd() === '') {
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.promptWhenInteractive = promptWhenInteractive;
|
4
|
+
const enquirer_1 = require("enquirer");
|
5
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
6
|
+
async function promptWhenInteractive(questions, defaultValue) {
|
7
|
+
if (!isInteractive()) {
|
8
|
+
return defaultValue;
|
9
|
+
}
|
10
|
+
return await (0, enquirer_1.prompt)(questions);
|
11
|
+
}
|
12
|
+
function isInteractive() {
|
13
|
+
return (!(0, devkit_internals_1.isCI)() && !!process.stdout.isTTY && process.env.NX_INTERACTIVE === 'true');
|
14
|
+
}
|