<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> This PR address a few things: 1. When we generate an app or a library using the new TS Solution they are not added to the workspaces/packages option. 2. Currently, when we use `pnpm` to generate a workspace the `pnpm-workspace.yaml` looks like below which is not correct ``` packages: - packages/** ``` ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> 1. Libraries and apps should be referenced correctly out of the box so that they can be symlinked after installation. 2. The intended `pnpm-workspace.yaml` should look similar to: ``` packages: - 'packages/**' - 'demo' ``` ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> --------- Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { readNxJson, Tree } from '@nx/devkit';
|
|
import {
|
|
determineProjectNameAndRootOptions,
|
|
ensureProjectName,
|
|
} from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
import { Schema } from '../schema';
|
|
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
|
|
|
export interface NormalizedSchema extends Schema {
|
|
importPath: string;
|
|
projectRoot: string;
|
|
isUsingTsSolutionConfig: boolean;
|
|
}
|
|
|
|
export async function normalizeOptions(
|
|
host: Tree,
|
|
options: Schema
|
|
): Promise<NormalizedSchema> {
|
|
await ensureProjectName(host, options, 'library');
|
|
const { projectRoot, importPath } = await determineProjectNameAndRootOptions(
|
|
host,
|
|
{
|
|
name: options.name,
|
|
projectType: 'library',
|
|
directory: options.directory,
|
|
importPath: options.importPath,
|
|
}
|
|
);
|
|
|
|
const nxJson = readNxJson(host);
|
|
const addPlugin =
|
|
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
nxJson.useInferencePlugins !== false;
|
|
options.addPlugin ??= addPlugin;
|
|
|
|
return {
|
|
...options,
|
|
importPath,
|
|
projectRoot,
|
|
isUsingTsSolutionConfig: isUsingTsSolutionSetup(host),
|
|
};
|
|
}
|