Skip to content

Commit

Permalink
chore(repo): remove dependency from dep-graph to workspace and run-co… (
Browse files Browse the repository at this point in the history
#6497)

* chore(repo): remove dependency from dep-graph to workspace and run-command

* chore(repo): change default build config for dep-graph

Co-authored-by: Philip Fulcher <philip@nrwl.io>
  • Loading branch information
FrozenPandaz and philipjfulcher committed Jul 23, 2021
1 parent 1ac16b4 commit 9e82524
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 62 deletions.
43 changes: 27 additions & 16 deletions dep-graph/dep-graph/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,43 @@
"main": "dep-graph/dep-graph/src/main.ts",
"polyfills": "dep-graph/dep-graph/src/polyfills.ts",
"tsConfig": "dep-graph/dep-graph/tsconfig.app.json",
"assets": [
"dep-graph/dep-graph/src/favicon.ico",
"dep-graph/dep-graph/src/assets"
],
"styles": ["dep-graph/dep-graph/src/styles.scss"],
"scripts": []
"scripts": [],
"assets": [],
"optimization": true,
"outputHashing": "none",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"configurations": {
"release": {
"dev": {
"fileReplacements": [
{
"replace": "dep-graph/dep-graph/src/environments/environment.ts",
"with": "dep-graph/dep-graph/src/environments/environment.release.ts"
"with": "dep-graph/dep-graph/src/environments/environment.dev.ts"
}
],
"assets": [],
"optimization": true,
"assets": [
"dep-graph/dep-graph/src/favicon.ico",
"dep-graph/dep-graph/src/assets"
],
"optimization": false,
"outputHashing": "none",
"sourceMap": false,
"sourceMap": true,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"extractLicenses": false,
"vendorChunk": true,
"budgets": [
{
"type": "initial",
Expand Down Expand Up @@ -72,12 +86,9 @@
"serve": {
"executor": "@nrwl/web:dev-server",
"options": {
"buildTarget": "dep-graph-dep-graph:build-base"
"buildTarget": "dep-graph-dep-graph:build-base:dev"
},
"configurations": {
"release": {
"buildTarget": "dep-graph-dep-graph:build-base:release"
},
"watch": {
"buildTarget": "dep-graph-dep-graph:build-base:watch"
}
Expand Down
5 changes: 3 additions & 2 deletions dep-graph/dep-graph/src/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DepGraphClientResponse } from '@nrwl/workspace';
import { ProjectGraph } from '@nrwl/workspace/src/core/project-graph';
// nx-ignore-next-line
import type { DepGraphClientResponse } from '@nrwl/workspace/src/command-line/dep-graph';
import { ProjectGraph } from '@nrwl/devkit';
import { combineLatest, fromEvent, Subject } from 'rxjs';
import { startWith, takeUntil } from 'rxjs/operators';
import { DebuggerPanel } from './debugger-panel';
Expand Down
3 changes: 2 additions & 1 deletion dep-graph/dep-graph/src/app/fetch-project-graph-service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DepGraphClientResponse } from '@nrwl/workspace';
// nx-ignore-next-line
import { DepGraphClientResponse } from '@nrwl/workspace/src/command-line/dep-graph';
import { ProjectGraphService } from './models';

export class FetchProjectGraphService implements ProjectGraphService {
Expand Down
3 changes: 2 additions & 1 deletion dep-graph/dep-graph/src/app/local-project-graph-service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DepGraphClientResponse } from '@nrwl/workspace';
// nx-ignore-next-line
import { DepGraphClientResponse } from '@nrwl/workspace/src/command-line/dep-graph';
import { ProjectGraphService } from './models';

export class LocalProjectGraphService implements ProjectGraphService {
Expand Down
7 changes: 4 additions & 3 deletions dep-graph/dep-graph/src/app/mock-project-graph-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ProjectGraphDependency } from '@nrwl/devkit';
import { DepGraphClientProject, DepGraphClientResponse } from '@nrwl/workspace';
import { ProjectGraphDependency, ProjectGraphNode } from '@nrwl/devkit';
// nx-ignore-next-line
import { DepGraphClientResponse } from '@nrwl/workspace/src/command-line/dep-graph';
import { ProjectGraphService } from '../app/models';

export class MockProjectGraphService implements ProjectGraphService {
Expand Down Expand Up @@ -58,7 +59,7 @@ export class MockProjectGraphService implements ProjectGraphService {
return new Promise((resolve) => resolve(this.response));
}

private createNewProject(): DepGraphClientProject {
private createNewProject(): ProjectGraphNode {
const type = Math.random() > 0.25 ? 'lib' : 'app';
const name = `${type}-${this.response.projects.length + 1}`;

Expand Down
3 changes: 2 additions & 1 deletion dep-graph/dep-graph/src/app/models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DepGraphClientResponse } from '@nrwl/workspace';
// nx-ignore-next-line
import { DepGraphClientResponse } from '@nrwl/workspace/src/command-line/dep-graph';

export interface ProjectGraphList {
id: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { FetchProjectGraphService } from '../app/fetch-project-graph-service';
import { Environment } from '../app/models';
import { projectGraphs } from '../graphs';

export const environment: Environment = {
environment: 'release',
environment: 'dev',
appConfig: {
showDebugger: false,
projectGraphs: [
{
id: 'local',
label: 'local',
url: 'projectGraph.json',
},
],
defaultProjectGraph: 'local',
showDebugger: true,
projectGraphs,
defaultProjectGraph: 'nx',
projectGraphService: new FetchProjectGraphService(),
},
};
15 changes: 10 additions & 5 deletions dep-graph/dep-graph/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { FetchProjectGraphService } from '../app/fetch-project-graph-service';
import { Environment } from '../app/models';
import { projectGraphs } from '../graphs';

export const environment: Environment = {
environment: 'dev',
environment: 'release',
appConfig: {
showDebugger: true,
projectGraphs,
defaultProjectGraph: 'nx',
showDebugger: false,
projectGraphs: [
{
id: 'local',
label: 'local',
url: 'projectGraph.json',
},
],
defaultProjectGraph: 'local',
projectGraphService: new FetchProjectGraphService(),
},
};
9 changes: 3 additions & 6 deletions dep-graph/dep-graph/src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { WorkspaceConfiguration } from '@nrwl/devkit';
import {
DepGraphClientResponse,
ProjectGraph,
ProjectGraphNode,
} from '@nrwl/workspace';
// nx-ignore-next-line
import { DepGraphClientResponse } from '@nrwl/workspace/src/command-line/dep-graph';
import { ProjectGraph, ProjectGraphNode } from '@nrwl/devkit';
import { ProjectGraphList } from './graphs';

export declare global {
Expand Down
5 changes: 1 addition & 4 deletions packages/workspace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ export {
export { output } from './src/utilities/output';
export { commandsObject } from './src/command-line/nx-commands';
export { supportedNxCommands } from './src/command-line/supported-nx-commands';
export {
DepGraphClientProject,
DepGraphClientResponse,
} from './src/command-line/dep-graph';

export {
readWorkspaceJson,
readNxJson,
Expand Down
4 changes: 1 addition & 3 deletions packages/workspace/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"root": "packages/workspace",
"sourceRoot": "packages/workspace",
"projectType": "library",
"implicitDependencies": ["dep-graph-dep-graph"],
"targets": {
"test": {
"executor": "@nrwl/jest:jest",
Expand Down Expand Up @@ -61,9 +62,6 @@
"outputs": ["build/packages/workspace"],
"options": {
"commands": [
{
"command": "nx build-base dep-graph-dep-graph --configuration release"
},
{
"command": "node ./scripts/copy-dep-graph.js"
},
Expand Down
13 changes: 3 additions & 10 deletions packages/workspace/src/command-line/dep-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,9 @@ import {
import { writeJsonFile } from '../utilities/fileutils';
import { output } from '../utilities/output';

export interface DepGraphClientProject {
name: string;
type: string;
data: {
tags: string[];
root: string;
};
}
export interface DepGraphClientResponse {
hash: string;
projects: DepGraphClientProject[];
projects: ProjectGraphNode[];
dependencies: Record<string, ProjectGraphDependency[]>;
layout: { appsDir: string; libsDir: string };
changes: {
Expand Down Expand Up @@ -512,13 +504,14 @@ async function createDepGraphClientResponse(): Promise<DepGraphClientResponse> {
performance.mark('dep graph response generation:start');

const layout = workspaceLayout();
const projects: DepGraphClientProject[] = Object.values(graph.nodes).map(
const projects: ProjectGraphNode[] = Object.values(graph.nodes).map(
(project) => ({
name: project.name,
type: project.type,
data: {
tags: project.data.tags,
root: project.data.root,
files: [],
},
})
);
Expand Down

0 comments on commit 9e82524

Please sign in to comment.