Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into pr/NicoVogel/1390
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Nov 1, 2022
2 parents ba16bf8 + 1d3ac22 commit 2ee8d50
Show file tree
Hide file tree
Showing 34 changed files with 248 additions and 183 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
NX_CLOUD_DISTRIBUTED_EXECUTION: true
node_version: 14
node_version: 16

jobs:
checks:
Expand All @@ -31,6 +31,8 @@ jobs:
agent: [1, 2, 3]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: ./.github/workflows/setup
with:
node_version: ${{ env.node_version }}
Expand All @@ -45,6 +47,8 @@ jobs:
- name: Set nx run variable
run: echo "NX_RUN_GROUP=run-group-e2e-${{ github.run_id}}-${{ github.run_attempt }}" >> $GITHUB_ENV
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: ./.github/workflows/setup
with:
node_version: ${{ env.node_version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
tags:
- 'v*.*.*'
env:
node_version: 14
node_version: 16

jobs:
publish:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ runs:
- run: yarn install --immutable
shell: bash
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
uses: nrwl/nx-set-shas@v3
with:
main-branch-name: 'master'
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
33 changes: 14 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,15 @@ We are trying to keep GitHub issues for bug reports and feature requests. Stack

## Running the Extension locally

In order to start Nx console in development mode, the repo needs to be built. Running `yarn watch` via the CLI or using the command prompt to execute `Tasks: Run Task -> Build and watch Nx Console` will automatically generate build artifacts whenever the code changes. </br>
In order to start Nx console in development mode, the repo needs to be built. Running `yarn watch` via the terminal or using the command prompt to execute `Tasks: Run Task -> Build and watch Nx Console` will automatically generate build artifacts whenever the code changes. </br>
Use the `F5` key or the debug menu option `Launch Client + Server` to start the Extension Development Host.

> :warning: Even though builds will be generated automatically, the Extension Development Host needs to be restarted in order to apply a new set of changes.
### Running Unit Tests

- Run `nps test` to run unit tests.

### Running Storybook

- Run `nps storybook` to launch the storybook instance
- Run `nps storybook-e2e` to run the e2e tests on the storybook instance

## Submitting a PR

Please follow the following guidelines:

Run the following commands to make sure the linting and the tests pass.

- `nps format.check`
- `nps lint`
- `nps test`
- `nps storybook-e2e`

If `nps format.check` fails, run `nps format`.

### Commit Message Guidelines

Commit message have to follow the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) format. A basic example is this:
Expand Down Expand Up @@ -81,3 +63,16 @@ feat: add links to angular.io to the generate screen
The generate screen shows links to docs explaining all command-line options in depth
```

### CI Checks

We have CI checks that runs the tests, builds, lints and e2e on each pull request and commit to the default branch. This uses the `affected` commands so it should be quicker than trying to run everything locally.

If you would like to run things locally, you can run the following commands:

- `yarn nx format:check` (if this fails, run `yarn nx format:write`)
- `yarn nx run-many --target=test`
- `yarn nx run-many --target=build`
- `yarn nx run-many --target=e2e`

And of course, you can use Nx Console itself to run individual tasks for whatever project you changed.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

<hr>

![Nx Console Screenshot](https://nx.dev/documentation/shared/nx-console-screenshot.png)
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx-console/master/static/nx-console-ui-dark.png">
<img alt="Nx Console - The UI for Nx & Lerna" src="https://raw.githubusercontent.com/nrwl/nx-console/master/static/nx-console-ui-light.png" width="100%">
</picture>

## Why Nx Console?

Expand Down
17 changes: 0 additions & 17 deletions apps/vscode-e2e/run-headless.ts

This file was deleted.

15 changes: 13 additions & 2 deletions apps/vscode/src/commands/refresh-workspace.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import { NxWorkspaceRefreshNotification } from '@nx-console/language-server/types';
import { checkIsNxWorkspace } from '@nx-console/shared/utils';
import { sendNotification } from '@nx-console/vscode/lsp-client';
import { getWorkspacePath, outputLogger } from '@nx-console/vscode/utils';
import { debounceTime, Subject } from 'rxjs';
import { commands } from 'vscode';
import { commands, window } from 'vscode';

export const REFRESH_WORKSPACE = 'nxConsole.refreshWorkspace';

const refresh = new Subject();

refresh.pipe(debounceTime(150)).subscribe(async () => {
const { nxWorkspace } = await import('@nx-console/shared/workspace');
await nxWorkspace(getWorkspacePath(), outputLogger, true);
const { daemonEnabled, workspaceType } = await nxWorkspace(
getWorkspacePath(),
outputLogger,
true
);
if (!daemonEnabled && workspaceType === 'nx') {
window.showErrorMessage(
'It looks like the Nx daemon is not enabled.\nPlease check your configuration and restart the daemon with `nx reset`.',
'OK'
);
}
sendNotification(NxWorkspaceRefreshNotification);
commands.executeCommand('nxConsole.refreshNxProjectsTree');
commands.executeCommand('nxConsole.refreshRunTargetTree');
Expand Down
6 changes: 5 additions & 1 deletion apps/vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ import {
refreshWorkspace,
REFRESH_WORKSPACE,
} from './commands/refresh-workspace';
import { WorkspaceCodeLensProvider } from '@nx-console/vscode/nx-workspace';
import {
stopDaemon,
WorkspaceCodeLensProvider,
} from '@nx-console/vscode/nx-workspace';

let runTargetTreeView: TreeView<RunTargetTreeItem>;
let nxProjectTreeView: TreeView<NxTreeItem>;
Expand Down Expand Up @@ -156,6 +159,7 @@ export async function activate(c: ExtensionContext) {
}

export async function deactivate() {
await stopDaemon();
getTelemetry().extensionDeactivated();
teardownTelemetry();
}
Expand Down
5 changes: 3 additions & 2 deletions apps/vscode/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"react",
"cli",
"monorepo",
"nx"
"nx",
"lerna"
],
"categories": [
"Other"
Expand Down Expand Up @@ -749,7 +750,7 @@
},
"nxConsole.enableTaskExecutionDryRunOnChange": {
"type": "boolean",
"default": false,
"default": true,
"description": "Configures whether to do dry runs on change when using \"Generate\" command"
}
}
Expand Down
29 changes: 20 additions & 9 deletions libs/shared/workspace/src/lib/get-nx-workspace-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
} from '@nrwl/devkit';
import { join } from 'path';
import {
getNxDaemonClient,
getNxProjectGraph,
getNxWorkspacePackageFileUtils,
} from './get-nx-workspace-package';
Expand All @@ -15,6 +16,8 @@ import { Logger } from '@nx-console/shared/schema';
export type NxWorkspaceConfiguration = ProjectsConfigurations &
NxJsonConfiguration;

let projectGraph: ProjectGraph | null = null;

/**
* There's a couple things that we need to handle here.
*
Expand All @@ -32,6 +35,7 @@ export async function getNxWorkspaceConfig(
): Promise<{
workspaceConfiguration: NxWorkspaceConfiguration;
configPath: string;
daemonEnabled?: boolean;
}> {
const version = await nxVersion(workspacePath);

Expand All @@ -40,11 +44,14 @@ export async function getNxWorkspaceConfig(
}

try {
const [nxWorkspacePackage, nxProjectGraph] = await Promise.all([
getNxWorkspacePackageFileUtils(workspacePath, logger),
getNxProjectGraph(workspacePath, logger),
]);
const [nxWorkspacePackage, nxProjectGraph, nxDaemonClient] =
await Promise.all([
getNxWorkspacePackageFileUtils(workspacePath, logger),
getNxProjectGraph(workspacePath, logger),
getNxDaemonClient(workspacePath, logger),
]);
const configFile = nxWorkspacePackage.workspaceFileName();
const isDaemonEnabled = nxDaemonClient.daemonClient.enabled();

let workspaceConfiguration: NxWorkspaceConfiguration;
try {
Expand All @@ -58,7 +65,6 @@ export async function getNxWorkspaceConfig(
).workspaceConfiguration;
}

let projectGraph: ProjectGraph | null = null;
try {
if (!isNxWorkspace) {
throw 'No project graph support';
Expand All @@ -71,10 +77,14 @@ export async function getNxWorkspaceConfig(
if (version.major < 13) {
projectGraph = (nxProjectGraph as any).createProjectGraph();
} else {
projectGraph = await nxProjectGraph.createProjectGraphAsync({
exitOnError: false,
resetDaemonClient: true,
});
// we always want to try to get the project graph on first load.
// So even if the daemon is disabled, we still want to try to get the project graph
if (isDaemonEnabled || projectGraph === null) {
projectGraph = await nxProjectGraph.createProjectGraphAsync({
exitOnError: false,
resetDaemonClient: true,
});
}
}
} catch {
//noop
Expand All @@ -85,6 +95,7 @@ export async function getNxWorkspaceConfig(
return {
workspaceConfiguration,
configPath: join(workspacePath, configFile),
daemonEnabled: isDaemonEnabled,
};
} catch (e) {
return readWorkspaceConfigs(format, workspacePath);
Expand Down
23 changes: 23 additions & 0 deletions libs/shared/workspace/src/lib/get-nx-workspace-package.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// import { getOutputChannel } from '@nx-console/utils';
import type * as NxFileUtils from 'nx/src/project-graph/file-utils';
import type * as NxProjectGraph from 'nx/src/project-graph/project-graph';
import type * as NxDaemonClient from 'nx/src/daemon/client/client';
import { platform } from 'os';
import { join } from 'path';
import { findNxPackagePath } from '@nx-console/shared/npm';
Expand All @@ -10,6 +11,28 @@ declare function __non_webpack_require__(importPath: string): any;

let RESOLVED_FILEUTILS_IMPORT: typeof NxFileUtils;
let RESOLVED_PROJECTGRAPH_IMPORT: typeof NxProjectGraph;
let RESOLVED_DAEMON_CLIENT: typeof NxDaemonClient;

export async function getNxDaemonClient(
workspacePath: string,
logger: Logger
): Promise<typeof NxDaemonClient> {
if (RESOLVED_DAEMON_CLIENT) {
return RESOLVED_DAEMON_CLIENT;
}

const importPath = await findNxPackagePath(
workspacePath,
join('src', 'daemon', 'client', 'client.js')
);
const backupPackage = await import('nx/src/daemon/client/client');
return getNxPackage(
importPath,
backupPackage,
RESOLVED_DAEMON_CLIENT,
logger
);
}

export async function getNxProjectGraph(
workspacePath: string,
Expand Down
2 changes: 2 additions & 0 deletions libs/shared/workspace/src/lib/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface NxWorkspace {
workspace: NxWorkspaceConfiguration;
workspaceType: 'ng' | 'nx';
configurationFilePath: string;
daemonEnabled?: boolean;
workspacePath: string;
isLerna: boolean;
workspaceLayout: {
Expand Down Expand Up @@ -106,6 +107,7 @@ async function _workspace(
workspaceType: isAngularWorkspace ? 'ng' : 'nx',
workspace: toWorkspaceFormat(config.workspaceConfiguration),
configurationFilePath: config.configPath,
daemonEnabled: config.daemonEnabled,
isLerna,
workspaceLayout: {
appsDir:
Expand Down
1 change: 1 addition & 0 deletions libs/vscode/nx-workspace/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './lib/find-workspace-json-target';
export * from './lib/reveal-workspace-json';
export * from './lib/workspace-codelens-provider';
export * from './lib/stop-daemon';
15 changes: 15 additions & 0 deletions libs/vscode/nx-workspace/src/lib/stop-daemon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { getPackageManagerCommand } from '@nrwl/devkit';
import { getWorkspacePath } from '@nx-console/vscode/utils';
import { exec } from 'child_process';
import { promisify } from 'util';

export async function stopDaemon() {
return promisify(exec)(
`${getPackageManagerCommand().exec} nx daemon --stop`,
{
cwd: getWorkspacePath(),
}
).catch((e) => {
console.log(e);
});
}
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {
"@monodon/typescript-nx-imports-plugin": "0.2.0",
"@nrwl/devkit": "14.8.2",
"@nrwl/devkit": "14.8.6",
"@yarnpkg/fslib": "2.6.1-rc.5",
"@yarnpkg/libzip": "2.2.3-rc.5",
"fast-glob": "^3.2.11",
Expand Down Expand Up @@ -49,16 +49,16 @@
"@angular/platform-browser": "14.2.3",
"@angular/platform-browser-dynamic": "14.2.3",
"@babel/core": "7.5.4",
"@nrwl/angular": "14.8.2",
"@nrwl/cypress": "14.8.2",
"@nrwl/eslint-plugin-nx": "14.8.2",
"@nrwl/jest": "14.8.2",
"@nrwl/js": "14.8.2",
"@nrwl/linter": "14.8.2",
"@nrwl/node": "14.8.2",
"@nrwl/nx-cloud": "14.7.0",
"@nrwl/storybook": "14.8.2",
"@nrwl/workspace": "14.8.2",
"@nrwl/angular": "14.8.6",
"@nrwl/cypress": "14.8.6",
"@nrwl/eslint-plugin-nx": "14.8.6",
"@nrwl/jest": "14.8.6",
"@nrwl/js": "14.8.6",
"@nrwl/linter": "14.8.6",
"@nrwl/node": "14.8.6",
"@nrwl/nx-cloud": "15.0.0",
"@nrwl/storybook": "14.8.6",
"@nrwl/workspace": "14.8.6",
"@storybook/addon-essentials": "6.5.9",
"@storybook/addon-knobs": "~6.4.0",
"@storybook/angular": "6.5.9",
Expand Down Expand Up @@ -94,7 +94,7 @@
"jest-preset-angular": "12.2.2",
"memfs": "^3.4.7",
"mocha": "^10.0.0",
"nx": "14.8.2",
"nx": "14.8.6",
"ovsx": "^0.3.0",
"prettier": "2.7.1",
"rimraf": "^3.0.2",
Expand Down
Binary file added static/nx-console-ui-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/nx-console-ui-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2ee8d50

Please sign in to comment.