fix(core): run init generators from extended collections during nx add (#30280)
<!-- 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 --> When the `init` generator is in an extended collection, `nx add` will not run it. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> When the `init` generator is in an extended collection, `nx add` will run it. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
5b034965d8
commit
121d9973a8
@ -10,13 +10,13 @@ import { output } from '../../utils/output';
|
||||
import { GeneratorsJsonEntry } from '../../config/misc-interfaces';
|
||||
import { workspaceRoot } from '../../utils/workspace-root';
|
||||
import { addDepsToPackageJson, runInstall } from './implementation/utils';
|
||||
import { getPluginCapabilities } from '../../utils/plugins';
|
||||
import { isAngularPluginInstalled } from '../../adapter/angular-json';
|
||||
import {
|
||||
isAggregateCreateNodesError,
|
||||
isProjectConfigurationsError,
|
||||
isProjectsWithNoNameError,
|
||||
} from '../../project-graph/error-types';
|
||||
import { getGeneratorInformation } from '../generate/generator-utils';
|
||||
|
||||
export function runPackageManagerInstallPlugins(
|
||||
repoRoot: string,
|
||||
@ -46,19 +46,8 @@ export async function installPlugin(
|
||||
verbose: boolean = false,
|
||||
pmc: PackageManagerCommands = getPackageManagerCommand()
|
||||
): Promise<void> {
|
||||
const capabilities = await getPluginCapabilities(repoRoot, plugin, {});
|
||||
const generators = capabilities?.generators;
|
||||
if (!generators) {
|
||||
throw new Error(`No generators found in ${plugin}.`);
|
||||
}
|
||||
|
||||
const initGenerator = findInitGenerator(generators);
|
||||
if (!initGenerator) {
|
||||
output.log({
|
||||
title: `No "init" generator found in ${plugin}. Skipping initialization.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
getGeneratorInformation(plugin, 'init', workspaceRoot, {});
|
||||
execSync(
|
||||
`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${
|
||||
updatePackageScripts ? '--updatePackageScripts' : ''
|
||||
@ -69,6 +58,13 @@ export async function installPlugin(
|
||||
windowsHide: false,
|
||||
}
|
||||
);
|
||||
} catch {
|
||||
// init generator does not exist, so this function should noop
|
||||
output.log({
|
||||
title: `No "init" generator found in ${plugin}. Skipping initialization.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user