Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): automatically add root to the project.json projects #9977

Merged
merged 3 commits into from Apr 28, 2022

Conversation

FrozenPandaz
Copy link
Collaborator

Current Behavior

project.json requires root to be defined even though.. it sits at the project root.

Expected Behavior

project.json does not need to define root

Related Issue(s)

Fixes #

@nx-cloud
Copy link

nx-cloud bot commented Apr 24, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit f2c5396. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 13 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented Apr 24, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nx-dev ✅ Ready (Inspect) Visit Preview Apr 27, 2022 at 10:58PM (UTC)

@FrozenPandaz FrozenPandaz enabled auto-merge (squash) April 24, 2022 05:33
@AgentEnder AgentEnder self-requested a review April 24, 2022 20:26
@FrozenPandaz FrozenPandaz force-pushed the auto-root branch 2 times, most recently from eaf6c0c to 4a9e792 Compare April 26, 2022 20:59
@AgentEnder AgentEnder enabled auto-merge (squash) April 26, 2022 21:09
Copy link
Member

@AgentEnder AgentEnder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to go ahead and approve this. I left a few comments, one / two nitpicks and a suggestion that would ease future work.

@@ -1,6 +1,6 @@
import { readFileSync, readdirSync, statSync } from 'fs';
import * as path from 'path';
import type { Tree } from 'nx/src/config/tree';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could put a TS file called nx-reexports.ts or something in packages/devkit/src to avoid all of these deep imports.... I'm not sure that its worth changing NOW, but it may be good to do eventually to limit the places they happen.

import { toNewFormat, toOldFormatOrNull } from 'nx/src/config/workspaces';
import { Generator, GeneratorCallback } from 'nx/src/config/misc-interfaces';
import { parseJson, serializeJson } from 'nx/src/utils/json';
import { join, relative } from 'path';
import { join, relative, dirname } from 'path';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is dirname actually used in here? I see it added, but no usage added.

@@ -637,6 +640,9 @@ export function buildWorkspaceConfigurationFromGlobs(
// directory as a package.json should overwrite the inferred package.json
// project configuration.
const configuration = readJson(file);

configuration.root = directory;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we are now doing a little bit more, maybe we should abstract this out. Something like below. This isn't super important right now, but if we add any token support in the file, it will get more so.

function buildProjectConfigurationFromProjectJson(filePath) {
	const c = readJson<ProjectConfiguration>(filePath)
	c.root = dirname(filePath)
	return c
}

@FrozenPandaz FrozenPandaz merged commit 5e23c07 into nrwl:master Apr 28, 2022
@FrozenPandaz FrozenPandaz deleted the auto-root branch April 28, 2022 17:24
FrozenPandaz added a commit that referenced this pull request Apr 28, 2022
* fix(core): automatically add root to the project.json projects

* chore(core): move project-configuration generator utils to nx package

* fix(core): add migrations to remove root
FrozenPandaz added a commit that referenced this pull request Apr 29, 2022
FrozenPandaz added a commit that referenced this pull request Apr 29, 2022
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants