@nx/devkit
Advanced tools
Comparing version 0.0.0-pr-29464-077bd35 to 0.0.0-pr-29464-0cee615
{ | ||
"name": "@nx/devkit", | ||
"version": "0.0.0-pr-29464-077bd35", | ||
"version": "0.0.0-pr-29464-0cee615", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "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.", |
@@ -34,6 +34,9 @@ import { type ProjectType, type Tree } from 'nx/src/devkit-exports'; | ||
*/ | ||
importPath?: string; | ||
importPath: string; | ||
}; | ||
export declare function determineProjectNameAndRootOptions(tree: Tree, options: ProjectGenerationOptions): Promise<ProjectNameAndRootOptions>; | ||
export declare function resolveImportPath(tree: Tree, projectName: string, projectRoot: string): string; | ||
export declare function ensureProjectName(tree: Tree, options: Omit<ProjectGenerationOptions, 'projectType'>, projectType: 'application' | 'library'): Promise<void>; | ||
export declare function ensureRootProjectName(options: { | ||
directory: string; | ||
name?: string; | ||
}, projectType: 'application' | 'library'): Promise<void>; |
@@ -5,3 +5,3 @@ "use strict"; | ||
exports.resolveImportPath = resolveImportPath; | ||
exports.ensureProjectName = ensureProjectName; | ||
exports.ensureRootProjectName = ensureRootProjectName; | ||
const enquirer_1 = require("enquirer"); | ||
@@ -48,7 +48,3 @@ const devkit_exports_1 = require("nx/src/devkit-exports"); | ||
} | ||
let importPath = undefined; | ||
if (options.projectType === 'library') { | ||
importPath = | ||
options.importPath ?? resolveImportPath(tree, name, projectRoot); | ||
} | ||
const importPath = options.importPath ?? resolveImportPath(tree, name, projectRoot); | ||
return { | ||
@@ -79,16 +75,10 @@ projectName: name, | ||
} | ||
async function ensureProjectName(tree, options, projectType) { | ||
if (!options.name) { | ||
if (options.directory === '.' && getRelativeCwd() === '') { | ||
const result = await (0, enquirer_1.prompt)({ | ||
type: 'input', | ||
name: 'name', | ||
message: `What do you want to name the ${projectType}?`, | ||
}).then(({ name }) => (options.name = name)); | ||
} | ||
const { projectName } = await determineProjectNameAndRootOptions(tree, { | ||
...options, | ||
projectType, | ||
async function ensureRootProjectName(options, projectType) { | ||
if (!options.name && options.directory === '.' && getRelativeCwd() === '') { | ||
const result = await (0, enquirer_1.prompt)({ | ||
type: 'input', | ||
name: 'name', | ||
message: `What do you want to name the ${projectType}?`, | ||
}); | ||
options.name = projectName; | ||
options.name = result.name; | ||
} | ||
@@ -95,0 +85,0 @@ } |
@@ -29,5 +29,5 @@ "use strict"; | ||
(0, devkit_exports_1.updateJson)(tree, updateConfigPath, (json) => { | ||
json.include = uniq([...json.include, 'src/**/*.js']); | ||
json.include = uniq([...(json.include ?? []), 'src/**/*.js']); | ||
json.exclude = uniq([ | ||
...json.exclude, | ||
...(json.exclude ?? []), | ||
'src/**/*.spec.js', | ||
@@ -34,0 +34,0 @@ 'src/**/*.test.js', |
import { CreateNodesContext, CreateNodesContextV2 } from 'nx/src/devkit-exports'; | ||
export declare function calculateHashForCreateNodes(projectRoot: string, options: object, context: CreateNodesContext | CreateNodesContextV2, additionalGlobs?: string[]): Promise<string>; | ||
export declare function calculateHashesForCreateNodes(projectRoots: string[], options: object, context: CreateNodesContext | CreateNodesContextV2, additionalGlobs?: string[][]): Promise<string[]>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.calculateHashForCreateNodes = calculateHashForCreateNodes; | ||
exports.calculateHashesForCreateNodes = calculateHashesForCreateNodes; | ||
const path_1 = require("path"); | ||
@@ -16,1 +17,13 @@ const devkit_exports_1 = require("nx/src/devkit-exports"); | ||
} | ||
async function calculateHashesForCreateNodes(projectRoots, options, context, additionalGlobs = []) { | ||
if (additionalGlobs.length && | ||
additionalGlobs.length !== projectRoots.length) { | ||
throw new Error('If additionalGlobs is provided, it must be the same length as projectRoots'); | ||
} | ||
return (0, devkit_internals_1.hashMultiGlobWithWorkspaceContext)(context.workspaceRoot, projectRoots.map((projectRoot, idx) => [ | ||
(0, path_1.join)(projectRoot, '**/*'), | ||
...(additionalGlobs.length ? additionalGlobs[idx] : []), | ||
])).then((hashes) => { | ||
return hashes.map((hash) => (0, devkit_exports_1.hashArray)([hash, (0, devkit_internals_1.hashObject)(options)])); | ||
}); | ||
} |
@@ -105,2 +105,3 @@ "use strict"; | ||
'bun.lockb', | ||
'bun.lock', | ||
'CHANGELOG.md', | ||
@@ -107,0 +108,0 @@ ]; |
209486
5151