fix(core): add outputs to nx.json for nx init in monorepo (#22061)
This commit is contained in:
parent
587fe6a63b
commit
22de9b5b84
@ -113,7 +113,7 @@ export async function addNxToNest(options: Options, packageJson: PackageJson) {
|
||||
repoRoot,
|
||||
[],
|
||||
[...cacheableOperations, ...nestCacheableScripts],
|
||||
{}
|
||||
scriptOutputs
|
||||
);
|
||||
|
||||
const pmc = getPackageManagerCommand();
|
||||
@ -121,12 +121,7 @@ export async function addNxToNest(options: Options, packageJson: PackageJson) {
|
||||
updateGitIgnore(repoRoot);
|
||||
addDepsToPackageJson(repoRoot);
|
||||
addNestPluginToPackageJson(repoRoot);
|
||||
markRootPackageJsonAsNxProject(
|
||||
repoRoot,
|
||||
cacheableOperations,
|
||||
scriptOutputs,
|
||||
pmc
|
||||
);
|
||||
markRootPackageJsonAsNxProject(repoRoot, cacheableOperations, pmc);
|
||||
|
||||
createProjectJson(repoRoot, packageJson, nestCLIConfiguration);
|
||||
removeFile(repoRoot, 'nest-cli.json');
|
||||
|
||||
@ -72,18 +72,13 @@ export async function addNxToNpmRepo(options: Options) {
|
||||
: false);
|
||||
}
|
||||
|
||||
createNxJsonFile(repoRoot, [], cacheableOperations, {});
|
||||
createNxJsonFile(repoRoot, [], cacheableOperations, scriptOutputs);
|
||||
|
||||
const pmc = getPackageManagerCommand();
|
||||
|
||||
updateGitIgnore(repoRoot);
|
||||
addDepsToPackageJson(repoRoot);
|
||||
markRootPackageJsonAsNxProject(
|
||||
repoRoot,
|
||||
cacheableOperations,
|
||||
scriptOutputs,
|
||||
pmc
|
||||
);
|
||||
markRootPackageJsonAsNxProject(repoRoot, cacheableOperations, pmc);
|
||||
|
||||
output.log({ title: '📦 Installing dependencies' });
|
||||
|
||||
|
||||
@ -39,14 +39,14 @@ export function createNxJsonFile(
|
||||
nxJson.targetDefaults[scriptName] ??= {};
|
||||
nxJson.targetDefaults[scriptName] = { dependsOn: [`^${scriptName}`] };
|
||||
}
|
||||
for (const [scriptName, output] of Object.entries(scriptOutputs)) {
|
||||
if (!output) {
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
nxJson.targetDefaults[scriptName] ??= {};
|
||||
nxJson.targetDefaults[scriptName].outputs = [`{projectRoot}/${output}`];
|
||||
}
|
||||
for (const [scriptName, output] of Object.entries(scriptOutputs)) {
|
||||
if (!output) {
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
nxJson.targetDefaults[scriptName] ??= {};
|
||||
nxJson.targetDefaults[scriptName].outputs = [`{projectRoot}/${output}`];
|
||||
}
|
||||
|
||||
for (const target of cacheableOperations) {
|
||||
@ -171,20 +171,12 @@ export function addVsCodeRecommendedExtensions(
|
||||
export function markRootPackageJsonAsNxProject(
|
||||
repoRoot: string,
|
||||
cacheableScripts: string[],
|
||||
scriptOutputs: { [script: string]: string },
|
||||
pmc: PackageManagerCommands
|
||||
) {
|
||||
const json = readJsonFile<PackageJson>(
|
||||
joinPathFragments(repoRoot, `package.json`)
|
||||
);
|
||||
json.nx = { targets: {} };
|
||||
for (let script of Object.keys(scriptOutputs)) {
|
||||
if (scriptOutputs[script]) {
|
||||
json.nx.targets[script] = {
|
||||
outputs: [`{projectRoot}/${scriptOutputs[script]}`],
|
||||
};
|
||||
}
|
||||
}
|
||||
json.nx = {};
|
||||
for (let script of cacheableScripts) {
|
||||
const scriptDefinition = json.scripts[script];
|
||||
if (!scriptDefinition) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user