Skip to content

Commit

Permalink
fix(core): read in projects from angular.json when called from conver… (
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Dec 29, 2022
1 parent 7bbacea commit 99708af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/devkit/src/utils/convert-nx-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import { ProjectGraph } from 'nx/src/config/project-graph';
export function convertNxExecutor(executor: Executor) {
const builderFunction = (options, builderContext) => {
const workspaces = new Workspaces(builderContext.workspaceRoot);
const workspaceConfig = workspaces.readWorkspaceConfiguration();
const workspaceConfig = workspaces.readWorkspaceConfiguration({
_includeProjectsFromAngularJson: true,
});

const promise = async () => {
let projectGraph: ProjectGraph;
Expand Down
20 changes: 16 additions & 4 deletions packages/nx/src/config/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ import { output } from '../utils/output';
import { joinPathFragments } from '../utils/path';

export function workspaceConfigName(
root: string
root: string,
opts?: {
includeProjectsFromAngularJson;
}
): 'angular.json' | 'workspace.json' | null {
// If a workspace doesn't have `@nrwl/angular` it's likely they do not want projects from `angular.json` to be considered by Nx.
if (existsSync(path.join(root, 'angular.json')) && isNrwlAngularInstalled()) {
if (
existsSync(path.join(root, 'angular.json')) &&
// Include projects from angular.json if explicitly required.
// e.g. when invoked from `packages/devkit/src/utils/convert-nx-executor.ts`
(opts?.includeProjectsFromAngularJson ||
// Or if a workspace has `@nrwl/angular` installed then projects from `angular.json` to be considered by Nx.
isNrwlAngularInstalled())
) {
return 'angular.json';
} else if (existsSync(path.join(root, 'workspace.json'))) {
return 'workspace.json';
Expand Down Expand Up @@ -72,6 +81,7 @@ export class Workspaces {

readWorkspaceConfiguration(opts?: {
_ignorePluginInference?: boolean;
_includeProjectsFromAngularJson?: boolean;
}): ProjectsConfigurations & NxJsonConfiguration {
if (
this.cachedWorkspaceConfig &&
Expand All @@ -86,7 +96,9 @@ export class Workspaces {
(path) => readJsonFile(join(this.root, path))
);

const workspaceFile = workspaceConfigName(this.root);
const workspaceFile = workspaceConfigName(this.root, {
includeProjectsFromAngularJson: opts?._includeProjectsFromAngularJson,
});

if (workspaceFile) {
workspace.projects = this.mergeWorkspaceJsonAndGlobProjects(
Expand Down

1 comment on commit 99708af

@vercel
Copy link

@vercel vercel bot commented on 99708af Dec 29, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx.dev
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app

Please sign in to comment.