-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nextjs): use helper to determine project name and root in projec…
…ts generators (#18733)
- Loading branch information
1 parent
2638bb0
commit 18ba93a
Showing
15 changed files
with
152 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 15 additions & 11 deletions
26
packages/next/src/generators/library/lib/normalize-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
import { getWorkspaceLayout, joinPathFragments, names, Tree } from '@nx/devkit'; | ||
import { getImportPath } from '@nx/js/src/utils/get-import-path'; | ||
import { Tree } from '@nx/devkit'; | ||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils'; | ||
import { Schema } from '../schema'; | ||
|
||
export interface NormalizedSchema extends Schema { | ||
importPath: string; | ||
projectRoot: string; | ||
} | ||
|
||
export function normalizeOptions( | ||
export async function normalizeOptions( | ||
host: Tree, | ||
options: Schema | ||
): NormalizedSchema { | ||
const name = names(options.name).fileName; | ||
const projectDirectory = options.directory | ||
? `${names(options.directory).fileName}/${name}` | ||
: name; | ||
): Promise<NormalizedSchema> { | ||
const { projectRoot, importPath, projectNameAndRootFormat } = | ||
await determineProjectNameAndRootOptions(host, { | ||
name: options.name, | ||
projectType: 'library', | ||
directory: options.directory, | ||
importPath: options.importPath, | ||
projectNameAndRootFormat: options.projectNameAndRootFormat, | ||
callingGenerator: '@nx/next:library', | ||
}); | ||
options.projectNameAndRootFormat = projectNameAndRootFormat; | ||
|
||
const { libsDir } = getWorkspaceLayout(host); | ||
const projectRoot = joinPathFragments(libsDir, projectDirectory); | ||
return { | ||
...options, | ||
importPath: options.importPath ?? getImportPath(host, projectDirectory), | ||
importPath, | ||
projectRoot, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
18ba93a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-dev-nrwl.vercel.app