Skip to content

Commit

Permalink
Merge b81faf3 into 3efbf0e
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj authored Oct 9, 2023
2 parents 3efbf0e + b81faf3 commit 47f5728
Show file tree
Hide file tree
Showing 10 changed files with 377 additions and 362 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
],
"devDependencies": {
"@babel/core": "^7.23.0",
"@moonrepo/cli": "^1.14.2",
"@moonrepo/cli": "^1.15.0",
"@moonrepo/dev": "workspace:*",
"eslint": "^8.50.0",
"eslint": "^8.51.0",
"jest": "^29.7.0",
"jest-circus": "^29.7.0",
"lerna": "^7.3.0",
"packemon": "^3.2.1",
"packemon": "^3.2.2",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
},
"dependencies": {
"@moonrepo/dev": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-compat": "^4.2.0",
Expand All @@ -53,7 +53,7 @@
},
"devDependencies": {
"@types/eslint": "^8.44.3",
"eslint": "^8.50.0"
"eslint": "^8.51.0"
},
"funding": {
"type": "ko-fi",
Expand Down
2 changes: 0 additions & 2 deletions packages/jest-preset/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ tasks:
test:
args:
- '--no-coverage'
deps:
- 'babel-preset:build'
4 changes: 4 additions & 0 deletions packages/vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.7.0

- Added action graph support (requires moon >= 1.15).

## 0.6.0

- Added 19 new language icons (requires moon >= 0.25).
Expand Down
3 changes: 1 addition & 2 deletions packages/vscode-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ prefixed with "moon".
- **Run target** - Prompts the user for a target(s) and runs it in the terminal.
- **Refresh projects** - Refreshes the projects view. _This happens automatically when
`.moon/workspace.yml` changes!_
- **View dependency graph** - Opens a panel that renders an interactive dependency graph
visualization.
- **View action graph** - Opens a panel that renders an interactive action graph visualization.
- **View project graph** - Opens a panel that renders an interactive project graph visualization.

## Roadmap
Expand Down
18 changes: 9 additions & 9 deletions packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
"icon": "$(open-preview)"
},
{
"command": "moon.viewDepGraph",
"title": "moon: View dependency graph",
"command": "moon.viewActionGraph",
"title": "moon: View action graph",
"icon": "$(gather)"
},
{
Expand Down Expand Up @@ -127,7 +127,7 @@
"when": "false"
},
{
"command": "moon.viewDepGraph",
"command": "moon.viewActionGraph",
"when": "moon.hasBinary"
},
{
Expand All @@ -147,12 +147,12 @@
"group": "navigation"
},
{
"command": "moon.viewDepGraph",
"command": "moon.viewActionGraph",
"when": "view == moonProjects && moon.hasBinary",
"group": "navigation"
},
{
"command": "moon.viewDepGraph",
"command": "moon.viewActionGraph",
"when": "view == moonProjectsExternal && moon.hasBinary",
"group": "navigation"
},
Expand Down Expand Up @@ -259,16 +259,16 @@
"publish": "vsce publish --no-dependencies --no-git-tag-version --message 'Release [ci skip]'"
},
"dependencies": {
"@moonrepo/report": "^1.0.4",
"@moonrepo/report": "^1.1.0",
"execa": "^5.1.1",
"semver": "^7.5.4"
},
"devDependencies": {
"@moonrepo/types": "^1.6.1",
"@types/semver": "^7.5.2",
"@moonrepo/types": "^1.7.0",
"@types/semver": "^7.5.3",
"@types/vscode": "^1.66.0",
"@vscode/test-electron": "^2.2.1",
"esbuild": "^0.19.2",
"esbuild": "^0.19.4",
"vsce": "^2.15.0"
}
}
4 changes: 2 additions & 2 deletions packages/vscode-extension/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export async function runTargetByInput(workspaceRoot: string) {
}
}

export async function viewDepGraph(context: vscode.ExtensionContext, workspaceRoot: string) {
await new GraphVisualizerView(context, workspaceRoot, 'dep-graph').renderPanel();
export async function viewActionGraph(context: vscode.ExtensionContext, workspaceRoot: string) {
await new GraphVisualizerView(context, workspaceRoot, 'action-graph').renderPanel();
}

export async function viewProjectGraph(context: vscode.ExtensionContext, workspaceRoot: string) {
Expand Down
6 changes: 3 additions & 3 deletions packages/vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import vscode from 'vscode';
import { runTargetByInput, viewDepGraph, viewProjectGraph } from './commands';
import { runTargetByInput, viewActionGraph, viewProjectGraph } from './commands';
import { LastRunProvider } from './lastRunView';
import { findMoonBin, findWorkspaceRoot, isRealBin } from './moon';
import { ProjectsProvider } from './projectsView';
Expand Down Expand Up @@ -44,8 +44,8 @@ export async function activate(context: vscode.ExtensionContext) {
}),

// Create graph visualizers
vscode.commands.registerCommand('moon.viewDepGraph', () =>
viewDepGraph(context, workspaceRoot),
vscode.commands.registerCommand('moon.viewActionGraph', () =>
viewActionGraph(context, workspaceRoot),
),
vscode.commands.registerCommand('moon.viewProjectGraph', () =>
viewProjectGraph(context, workspaceRoot),
Expand Down
28 changes: 18 additions & 10 deletions packages/vscode-extension/src/graphVisualizerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { satisfies } from 'semver';
import vscode, { ViewColumn } from 'vscode';
import { execMoon, getMoonVersion } from './moon';

export type GraphType = 'dep-graph' | 'project-graph';
export type GraphType = 'action-graph' | 'project-graph';

export class GraphVisualizerView {
context: vscode.ExtensionContext;
Expand All @@ -18,8 +18,8 @@ export class GraphVisualizerView {
this.workspaceRoot = workspaceRoot;
this.type = type;
this.panel = vscode.window.createWebviewPanel(
type === 'dep-graph' ? 'moonDepGraph' : 'moonProjectGraph',
type === 'dep-graph' ? 'Dependency graph' : 'Project graph',
type === 'action-graph' ? 'moonActionGraph' : 'moonProjectGraph',
type === 'action-graph' ? 'Action graph' : 'Project graph',
ViewColumn.Active,
{
enableScripts: true,
Expand Down Expand Up @@ -63,16 +63,24 @@ export class GraphVisualizerView {
async renderPanel() {
const version = await getMoonVersion(this.workspaceRoot);

if (satisfies(version, '>=0.21.3')) {
const data = await execMoon([this.type, '--json'], this.workspaceRoot);

this.panel.webview.html = this.renderHtml(
`<script>window.GRAPH_DATA = '${data}';</script><div id="app"></div>`,
);
} else {
if (satisfies(version, '<0.21.3')) {
this.panel.webview.html = this.renderHtml(
`Graph visualization not available for this version of moon. Requires >= 0.21.3, found ${version}.`,
);

return;
}

let command: string = this.type;

if (command === 'action-graph' && satisfies(version, '<1.15.0')) {
command = 'dep-graph';
}

const data = await execMoon([command, '--json'], this.workspaceRoot);

this.panel.webview.html = this.renderHtml(
`<script>window.GRAPH_DATA = '${data}';</script><div id="app"></div>`,
);
}
}
Loading

0 comments on commit 47f5728

Please sign in to comment.