-
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.
fix(react): normalize remote name and directory correctly when using …
…new project root format
- Loading branch information
1 parent
42d93b0
commit 428d6b3
Showing
5 changed files
with
75 additions
and
15 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
38 changes: 38 additions & 0 deletions
38
packages/react/src/generators/host/lib/normalize-remote.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Tree, joinPathFragments } from '@nx/devkit'; | ||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils'; | ||
import { NormalizedSchema } from '../schema'; | ||
|
||
export async function normalizeRemoteName( | ||
tree: Tree, | ||
remote: string, | ||
options: NormalizedSchema | ||
) { | ||
const { projectName: remoteName } = await determineProjectNameAndRootOptions( | ||
tree, | ||
{ | ||
name: remote, | ||
projectType: 'application', | ||
directory: options.directory, | ||
projectNameAndRootFormat: options.projectNameAndRootFormat, | ||
callingGenerator: '@nx/react:host', | ||
} | ||
); | ||
|
||
return remoteName; | ||
} | ||
|
||
export function normalizeRemoteDirectory( | ||
remote: string, | ||
options: NormalizedSchema | ||
) { | ||
if (options.projectNameAndRootFormat === 'derived' || !options.directory) { | ||
return options.directory; | ||
} | ||
|
||
/** | ||
* With the `as-provided` format, the provided directory would be the root | ||
* of the host application. Append the remote name to the host parent | ||
* directory to get the remote directory. | ||
*/ | ||
return joinPathFragments(options.directory, '..', remote); | ||
} |
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