Skip to content

Commit 3990b02

Browse files
committed
fix(vscode-extension): Resolved startup issues
1 parent ec3c0e7 commit 3990b02

File tree

77 files changed

+2281
-2149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2281
-2149
lines changed

apps/cli/src/program/cli-program.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const createCLIAcidicProgram = async (): Promise<number> => {
1010
"The Acidic Engine CLI is an application used to build full-stack apps with a design-first approach.",
1111
documentationUrl: "https://acidic.io/docs",
1212
licenseUrl: "https://acidic.io/license",
13-
title: {
13+
banner: {
1414
name: "Acidic CLI"
1515
},
1616
by: {
+5-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
//import { SchemaTreeView } from "@acidic/vscode-components";
22
import { ServiceGraph } from "@acidic/service-graph";
3+
import { MemoExoticComponent, memo } from "react";
34
import "../style/global.css";
45

5-
export function App() {
6+
export const App: MemoExoticComponent<() => JSX.Element> = memo(() => {
67
return (
7-
<div>
8-
{/*<SchemaTreeView repository="Acidic Repository" />*/}
8+
<div className="h-full w-full">
99
<h1>Acidic Service Graph</h1>
10-
<ServiceGraph />
10+
<ServiceGraph className="h-full w-full" />
1111
</div>
1212
);
13-
}
14-
15-
export default App;
13+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./App";

apps/vscode-extension/client/main.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { StrictMode } from "react";
22
import * as ReactDOM from "react-dom/client";
3-
4-
import App from "./app/App";
3+
import { App } from "./app";
54

65
const root = ReactDOM.createRoot(
76
document.getElementById("root") as HTMLElement
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4+
5+
html {
6+
height: 100%;
7+
width: 100%;
8+
margin: 0;
9+
padding: 0;
10+
}
11+
12+
body {
13+
background-color: #fff;
14+
height: 100vh;
15+
width: 100vw;
16+
margin: 0;
17+
padding: 0;
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
&nbsp;
2+
3+
# Generate
4+
5+
The `Generate` action allows you to choose a generator and then opens a form listing out all the options for that generator. As you make changes to the form, the generator is executed in `--dry-run` mode in a terminal so you can preview the results of running the generator in real time.
6+
7+
[See the Demo](https://youtu.be/-nUr66MWRiE)
8+
9+
&nbsp;
10+
11+
## From the Command Palette
12+
13+
You can also launch the `Generate` action from the Command Palette (`⇧⌘P`) by selecting `nx: generate (ui)`.
14+
15+
[See the Demo](https://youtu.be/Sk2XjFwF8Zo)
16+
17+
You can even construct the generator options while staying entirely within the Command Palette. Use `⇧⌘P` to open the Command Palette, then select `nx: generate`. After choosing a generator, select any of the listed options to modify the generator command. When you're satisfied with the constructed command, choose the `Execute` command at the top of the list.
18+
19+
[See the Demo](https://youtu.be/q5NTTqRYq9c)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
&nbsp;
2+
3+
# Run
4+
5+
The `Run` action allows you to choose an executor command and then opens a form listing out all the options for that builder. The frequently used executor commands `build`, `serve`, `test`, `e2e` and `lint` also have their own dedicated actions.
6+
7+
[See the Demo](https://youtu.be/rNImFxo9gYs)
8+
9+
&nbsp;
10+
11+
## From the Command Palette
12+
13+
You can also construct the executor command options while staying entirely within the Command Palette. Use `⇧⌘P` to open the Command Palette, then select `nx: test`. After choosing a project, select any of the listed options to modify the executor command options. When you're satisfied with the constructed command, choose the `Execute` command at the top of the list.
14+
15+
[See the Demo](https://youtu.be/CsUkSyQcxwQ)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
nbsp;
2+
3+
# Common Nx Commands
4+
5+
You can also launch other common Nx commands with the options listed out in the Command Palette.
6+
7+
- `run-many`: Run task for multiple projects
8+
- `affected`: Run task for affected projects
9+
10+
[See the Demo](https://youtu.be/v6Tso0lB6S4)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
&nbsp;
2+
3+
# Projects
4+
5+
- Clicking on the name of any project will navigate to that project's definition in the `workspace.json` (or `angular.json`) file. Clicking on the name of any builder command will navigate to that builder command's definition in the `workspace.json` (or `angular.json`) file.
6+
7+
- Clicking the ![Refresh](https://raw.githubusercontent.com/nrwl/nx-console/ba40a1c4a53d48b89a05a2f0d77a4139f9de6cc2/apps/vscode/src/assets/refresh-light.svg) Refresh icon next to the `PROJECTS` header will repopulate the Projects pane from the `workspace.json` (or `angular.json`) file.
8+
9+
- Clicking the ![Folder](https://raw.githubusercontent.com/nrwl/nx-console/ba40a1c4a53d48b89a05a2f0d77a4139f9de6cc2/apps/vscode/src/assets/folder-light.svg) Folder icon next to a project will reveal that project's folder in the VSCode Explorer pane.
10+
11+
- Clicking the ![Execute](https://raw.githubusercontent.com/nrwl/nx-console/ba40a1c4a53d48b89a05a2f0d77a4139f9de6cc2/apps/vscode/src/assets/continue-light.svg) Execute icon next to an executor command will execute that command without prompting for options.
12+
13+
[See the Demo](https://youtu.be/ve_N3unDqAg)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
&nbsp;
2+
3+
# Streamlining
4+
5+
If you find yourself running the same command many times, here are few tips to save yourself some key strokes.
6+
7+
## Rerun Last Task
8+
9+
If you want to rerun the last task with all the same options specified, bring up the Command Palette (`⇧⌘P`) and choose `Rerun Last Task`.
10+
11+
&nbsp;
12+
13+
## Keyboard Shortcuts
14+
15+
You can also set up custom tasks and assign keyboard shortcuts to them. In .vscode/tasks.json add a task like this:
16+
17+
```json
18+
{
19+
"label": "Test Affected",
20+
"type": "shell",
21+
"command": "nx affected --target=test"
22+
}
23+
```
24+
25+
Then from the Command Palette (`⇧⌘P`) choose `Preferences: Open Keyboard Shortcuts (JSON)`. Then add the following shortcut:
26+
27+
```json
28+
{
29+
"key": "ctrl+cmd+t",
30+
"command": "workbench.action.tasks.runTask",
31+
"args": "Test Affected"
32+
}
33+
```
34+
35+
Now, pressing `^⌘T` will run `nx affected --target=test`.
36+
37+
&nbsp;
38+
39+
Here is more information on [VSCode tasks](https://code.visualstudio.com/docs/editor/tasks) and [keyboard shortcuts](https://code.visualstudio.com/docs/getstarted/keybindings).

apps/vscode-extension/esbuild.extension.config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const { esbuildDecorators } = require("@anatine/esbuild-decorators");
2-
const esbuildPluginPino = require("esbuild-plugin-pino");
32

43
module.exports = {
54
mainFields: ["module", "main"],
@@ -19,7 +18,6 @@ module.exports = {
1918
plugins: [
2019
esbuildDecorators({
2120
tsconfig: "apps/vscode-extension/tsconfig.extension.json"
22-
}),
23-
esbuildPluginPino({ transports: ["pino-pretty"] })
21+
})
2422
]
2523
};

apps/vscode-extension/extension/main.ts

+24-28
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { createAcidicConfig } from "@acidic/config";
22
import {
33
CommandName,
44
LOCATE_YOUR_WORKSPACE,
5-
ServiceTreeProvider,
65
SupportTreeProvider,
76
WorkspaceConfigStore,
8-
getCommandId
7+
createLogger,
8+
getCommandId,
9+
initServiceTree
910
} from "@acidic/vscode-state";
1011
import {
1112
findWorkspaceRootSafe,
@@ -18,7 +19,6 @@ import {
1819
ExtensionContext,
1920
FileSystemWatcher,
2021
RelativePattern,
21-
WebviewPanel,
2222
commands,
2323
window,
2424
workspace
@@ -38,17 +38,18 @@ let logger: StormLog;
3838
let hasWorkspaceRoot = false;
3939
let workspaceFileWatcher: FileSystemWatcher | undefined;
4040

41-
export function activate(_context: ExtensionContext) {
41+
export async function activate(_context: ExtensionContext) {
4242
try {
4343
window.setStatusBarMessage("Starting Acidic Workspace");
4444
commands.executeCommand("setContext", "hasWorkspaceRoot", false);
45+
commands.executeCommand("setContext", "isWorkspaceLoading", true);
4546

4647
context = _context;
4748

4849
context.subscriptions.push(
4950
commands.registerCommand(
5051
LOCATE_YOUR_WORKSPACE.command?.command || "",
51-
() => manuallySelectWorkspaceDefinition()
52+
async () => manuallySelectWorkspaceDefinition()
5253
)
5354
);
5455

@@ -64,7 +65,7 @@ export function activate(_context: ExtensionContext) {
6465
: undefined
6566
);
6667
if (workspaceRoot) {
67-
loadAcidicWorkspace(workspaceRoot);
68+
await loadAcidicWorkspace(workspaceRoot);
6869
} else {
6970
writeStatusBarMessage("Acidic Workspace is ready");
7071
}
@@ -174,6 +175,15 @@ async function loadAcidicWorkspace(workspaceRoot: string) {
174175
}
175176
}
176177

178+
function handleWorkspaceReady() {
179+
commands.executeCommand("setContext", "isWorkspaceLoading", false);
180+
ReactPanel.createOrShow(context, "Acidic Workspace");
181+
182+
window.showInformationMessage(
183+
"Acidic Workspace successfully loaded services"
184+
);
185+
}
186+
177187
async function loadWorkspaceRoot(workspacePath: string): Promise<boolean> {
178188
try {
179189
if (
@@ -191,37 +201,27 @@ async function loadWorkspaceRoot(workspacePath: string): Promise<boolean> {
191201
const workspaceRoot = findWorkspaceRootSafe(workspacePath);
192202
if (workspaceRoot) {
193203
process.env.STORM_WORKSPACE_ROOT = workspaceRoot;
204+
194205
hasWorkspaceRoot = true;
206+
commands.executeCommand("setContext", "hasWorkspaceRoot", true);
195207

196208
await loadStormConfig(workspaceRoot);
197209
const config = createAcidicConfig(workspaceRoot);
198-
// logger = createLogger(config);
210+
logger = createLogger(config);
199211

200212
WorkspaceConfigStore.fromContext(context, logger);
201213
WorkspaceConfigStore.instance.setWorkspaceRoot(workspaceRoot);
202214

203-
client = startLanguageClient(context);
204-
205-
const serviceExplorerProvider = new ServiceTreeProvider(workspaceRoot);
206-
window.registerTreeDataProvider(
207-
"acidicWorkspace.views.services",
208-
serviceExplorerProvider
209-
);
210-
commands.registerCommand(
211-
getCommandId(CommandName.REFRESH_SCHEMA_START),
212-
() => serviceExplorerProvider.refresh()
213-
);
215+
// client = startLanguageClient(context);
214216

215-
let panel: WebviewPanel | undefined = undefined;
216217
context.subscriptions.push(
217218
commands.registerCommand(
218-
getCommandId(CommandName.OPEN_SCHEMA_EXPLORER),
219-
() => {
220-
ReactPanel.createOrShow({ ...context, logger }, "Acidic Workspace");
221-
}
219+
getCommandId(CommandName.SET_WORKSPACE_READY),
220+
handleWorkspaceReady
222221
)
223222
);
224223

224+
initServiceTree(context, config, logger, handleWorkspaceReady);
225225
if (workspaceFileWatcher) {
226226
workspaceFileWatcher.dispose();
227227
}
@@ -243,9 +243,7 @@ async function loadWorkspaceRoot(workspacePath: string): Promise<boolean> {
243243
);
244244

245245
if (workspaceRoot === workspacePath) {
246-
window.showInformationMessage(
247-
`Acidic Workspace successfully initialized from ${workspaceRoot}`
248-
);
246+
writeStatusBarMessage("Acidic Workspace successfully initialized");
249247
} else {
250248
window.showWarningMessage(
251249
`Acidic Workspace could not use "${workspacePath}" as a workspace root directory; however, parent folder "${workspaceRoot}" was successfully use to initialize.`
@@ -256,8 +254,6 @@ async function loadWorkspaceRoot(workspacePath: string): Promise<boolean> {
256254
} else {
257255
window.showErrorMessage(`Unable to load workspace from ${workspacePath}`);
258256
}
259-
260-
commands.executeCommand("setContext", "hasWorkspaceRoot", hasWorkspaceRoot);
261257
} catch (error) {
262258
console.error(error);
263259
window.showErrorMessage(

0 commit comments

Comments
 (0)