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

@nrwl/devkit should expose readWorkspace #5678

Closed
yjaaidi opened this issue May 15, 2021 · 1 comment · Fixed by #6398
Closed

@nrwl/devkit should expose readWorkspace #5678

yjaaidi opened this issue May 15, 2021 · 1 comment · Fixed by #6398
Labels

Comments

@yjaaidi
Copy link
Contributor

yjaaidi commented May 15, 2021

Description

Some generators could be "Angular CLI schematics" compatible but they are not, because they directly or indirectly call functions like readProjectConfiguration that make nx.json presence mandatory:

export function readProjectConfiguration(host: Tree, projectName: string) {
const workspace = readWorkspace(host);
if (!workspace.projects[projectName]) {
throw new Error(
`Cannot find configuration for '${projectName}' in ${getWorkspacePath(
host
)}.`
);
}
const nxJson = readJson<NxJsonConfiguration>(host, 'nx.json');
if (!nxJson.projects[projectName]) {
throw new Error(
`Cannot find configuration for '${projectName}' in nx.json`
);
}
return getProjectConfiguration(projectName, workspace, nxJson);
}

It would be nice to make the API more explicit on when nx.json is read & required.

Motivation

This improvement could:

  1. make some generators, Angular CLI compatible,
  2. encourage the implementation of Angular CLI schematics using @nrwl/devkit

Suggested Implementation

In order to avoid introducing any breaking change, we could add an optional boolean ignoreNxJson parameter to these functions. We could provide different signatures with different return types depending on the value of this option.

Alternate Implementations

Exposing readWorkspace could be a good start.

function readWorkspace(host: Tree): WorkspaceJsonConfiguration {

We, @jscutlery, would be happy to discuss this and provide a PR.

Cc. @edbzn

@vsavkin vsavkin added the scope: core core nx functionality label May 18, 2021
edbzn added a commit to edbzn/nx that referenced this issue Jul 16, 2021
Allow project configuration functions to work without nx.json by adding a new parameter `ignoreNxJson` to skip reading this file, this is particulary handy for regular Angular CLI projects.
edbzn added a commit to edbzn/nx that referenced this issue Jul 16, 2021
Allow project configuration functions to work without nx.json by adding a new parameter `ignoreNxJson` to skip reading this file, this is particulary handy for regular Angular CLI projects.
edbzn added a commit to edbzn/nx that referenced this issue Jul 16, 2021
Allow project configuration functions to work without nx.json by adding a new parameter `ignoreNxJson` to skip reading this file, this is particulary handy for regular Angular CLI projects.
edbzn added a commit to edbzn/nx that referenced this issue Jul 16, 2021
Allow project configuration functions to work without nx.json by adding a new parameter `ignoreNxJson` to skip reading this file, this is particulary handy for regular Angular CLI projects.
edbzn added a commit to edbzn/nx that referenced this issue Jul 26, 2021
Allow project configuration functions to work without nx.json configuration file, this is particulary handy for regular Angular CLI projects.
FrozenPandaz added a commit that referenced this issue Jul 29, 2021
* feat(devkit): make nx.json optional (#5678)

Allow project configuration functions to work without nx.json configuration file, this is particulary handy for regular Angular CLI projects.

* docs(devkit): make `NxJsonConfiguration` partial

Co-authored-by: Jason Jean <jasonjean1993@gmail.com>
FrozenPandaz added a commit that referenced this issue Jul 29, 2021
* feat(devkit): make nx.json optional (#5678)

Allow project configuration functions to work without nx.json configuration file, this is particulary handy for regular Angular CLI projects.

* docs(devkit): make `NxJsonConfiguration` partial

Co-authored-by: Jason Jean <jasonjean1993@gmail.com>
ManojBahuguna pushed a commit to ManojBahuguna/nx that referenced this issue Sep 16, 2021
* feat(devkit): make nx.json optional (nrwl#5678)

Allow project configuration functions to work without nx.json configuration file, this is particulary handy for regular Angular CLI projects.

* docs(devkit): make `NxJsonConfiguration` partial

Co-authored-by: Jason Jean <jasonjean1993@gmail.com>
@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

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

Successfully merging a pull request may close this issue.

2 participants