Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nrwl/nx-console into zack…
Browse files Browse the repository at this point in the history
…/wip-move-context-menu
  • Loading branch information
ZackDeRose committed Apr 10, 2022
2 parents 5736239 + 4e5999c commit c591644
Show file tree
Hide file tree
Showing 58 changed files with 4,257 additions and 3,882 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.16.0
14.17.0
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [17.15.0](https://github.com/nrwl/nx-console/compare/v17.14.1...v17.15.0) (2022-04-06)


### Features

* add prompts to add nx to angular cli ([#1254](https://github.com/nrwl/nx-console/issues/1254)) ([a669307](https://github.com/nrwl/nx-console/commits/a6693076d8987f370207ed965d3e5a91bde11f54))
* adding run target to the commands ([#1249](https://github.com/nrwl/nx-console/issues/1249)) ([c4a0cbe](https://github.com/nrwl/nx-console/commits/c4a0cbe4887fc9a49638c8a456e5f6ee284ea191))
* making the contents of the run target view match the workspace ([#1250](https://github.com/nrwl/nx-console/issues/1250)) ([11a8f60](https://github.com/nrwl/nx-console/commits/11a8f60b8efac21808032c75b7922a3508868751))


### Bug Fixes

* make sure that arguments are unique for the UI form ([#1248](https://github.com/nrwl/nx-console/issues/1248)) ([10fd881](https://github.com/nrwl/nx-console/commits/10fd881649c2f04bf487e60f1ac343c7f2d10a8c))
* make sure to read schemas from both builders and executors for builder ([#1252](https://github.com/nrwl/nx-console/issues/1252)) ([f20cce9](https://github.com/nrwl/nx-console/commits/f20cce917043f69733e27766755dbc4a254d28a8))

### [17.14.1](https://github.com/nrwl/nx-console/compare/v17.14.0...v17.14.1) (2022-02-07)


Expand Down
5 changes: 3 additions & 2 deletions apps/vscode/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"generators": {},
"targets": {
"build": {
"executor": "@nrwl/node:build",
"executor": "@nrwl/node:webpack",
"options": {
"externalDependencies": ["vscode"],
"externalDependencies": ["vscode", "typescript"],
"webpackConfig": "apps/vscode/webpack.config.js",
"outputPath": "dist/apps/vscode",
"main": "apps/vscode/src/main.ts",
Expand Down Expand Up @@ -42,6 +42,7 @@
"sourceMap": false,
"optimization": true,
"extractLicenses": true,
"externalDependencies": ["vscode"],
"fileReplacements": [
{
"replace": "apps/vscode/src/environments/environment.ts",
Expand Down
9 changes: 6 additions & 3 deletions apps/vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
getGenerators,
teardownTelemetry,
watchFile,
directoryExists,
fileExists,
} from '@nx-console/server';
import {
Expand All @@ -46,13 +45,14 @@ import {
NxProjectTreeProvider,
} from '@nx-console/vscode/nx-project-view';
import { environment } from './environments/environment';
import { Awaited } from '@nx-console/schema';
import { AsyncReturnType } from 'type-fest';

import {
WorkspaceJsonSchema,
ProjectJsonSchema,
} from '@nx-console/vscode/json-schema';
import { enableTypeScriptPlugin } from '@nx-console/typescript-plugin';
import { NxConversion } from '@nx-console/vscode/nx-conversion';

let runTargetTreeView: TreeView<RunTargetTreeItem>;
let nxProjectTreeView: TreeView<NxProjectTreeItem>;
Expand Down Expand Up @@ -122,6 +122,8 @@ export async function activate(c: ExtensionContext) {
new WorkspaceJsonSchema(context);
new ProjectJsonSchema(context);

NxConversion.createInstance(context);

await enableTypeScriptPlugin(context);

getTelemetry().extensionActivated((Date.now() - startTime) / 1000);
Expand Down Expand Up @@ -257,14 +259,15 @@ async function setWorkspace(workspacePath: string) {
} else if (!isNxWorkspace && isAngularWorkspace) {
workspaceType = 'angular';
}
WorkspaceConfigurationStore.instance.set('workspaceType', workspaceType);

getTelemetry().record('WorkspaceType', { workspaceType });
}

async function setApplicationAndLibraryContext(workspacePath: string) {
const { getNxConfig } = await import('@nx-console/vscode/nx-workspace');

let nxConfig: Awaited<ReturnType<typeof getNxConfig>>;
let nxConfig: AsyncReturnType<typeof getNxConfig>;
try {
nxConfig = await getNxConfig(workspacePath);
} catch {
Expand Down
11 changes: 10 additions & 1 deletion apps/vscode/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "angular-console",
"displayName": "Nx Console",
"description": "Nx Console for Visual Studio Code",
"version": "17.14.1",
"version": "17.15.0",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx-console.git"
Expand Down Expand Up @@ -152,6 +152,10 @@
"command": "nx.generate.ui.lib",
"when": "isNxWorkspace && nx.hasLibraryGenerators"
},
{
"command": "nxConsole.makeNgFaster",
"when": "isAngularWorkspace"
},
{
"command": "ng.run.target",
"when": "isAngularWorkspace"
Expand Down Expand Up @@ -603,6 +607,11 @@
"category": "Nx",
"title": "Nx generate library",
"command": "nx.generate.ui.lib.fileexplorer"
},
{
"category": "Nx",
"title": "Make ng Faster with Nx",
"command": "nxConsole.makeNgFaster"
}
],
"configuration": {
Expand Down
2 changes: 1 addition & 1 deletion libs/npm/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
},
"build": {
"executor": "@nrwl/node:package",
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/npm",
Expand Down
2 changes: 1 addition & 1 deletion libs/npm/src/lib/pnp-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function pnpDependencies(workspacePath: string) {
if (!pkg?.packageDependencies) {
continue;
}
for (const [name, reference] of pkg?.packageDependencies) {
for (const [name, reference] of pkg?.packageDependencies ?? {}) {
// Unmet peer dependencies
if (reference === null) continue;
if (!Array.isArray(reference) && reference.startsWith('workspace:'))
Expand Down
51 changes: 49 additions & 2 deletions libs/npm/src/lib/workspace-dependencies.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { PartialDeep } from 'type-fest';
import { mocked } from 'ts-jest/utils';

import { workspaceDependencyPath } from './workspace-dependencies';
import * as pnpDependencies from './pnp-dependencies';

import * as pnpDependencies from './pnp-dependencies';
jest.mock(
'./pnp-dependencies',
(): Partial<typeof pnpDependencies> => ({
Expand All @@ -11,7 +13,33 @@ jest.mock(
),
})
);
const mockedPnpDependencies = mocked(pnpDependencies, true);
const mockedPnpDependencies = mocked(pnpDependencies);

import * as vscode from 'vscode';
jest.mock('vscode', (): PartialDeep<typeof vscode> => {
return {
FileType: {
Directory: 2,
SymbolicLink: 64,
},
Uri: {
file: jest.fn((path) => path as any),
},
workspace: {
fs: {
stat: jest.fn(() =>
Promise.resolve({
ctime: 0,
mtime: 0,
size: 0,
type: 2,
})
),
},
},
};
});
const mockedVsCode = mocked(vscode, true);

describe('workspace-dependencies path', () => {
it('should return a path to a workspace dependency when using node_modules', async () => {
Expand Down Expand Up @@ -46,4 +74,23 @@ describe('workspace-dependencies path', () => {
`"/workspace/tools/local/executor"`
);
});

it('should support symbolic directory links', async () => {
mockedVsCode.workspace.fs.stat.mockImplementationOnce(() => {
return Promise.resolve({
ctime: 0,
mtime: 0,
size: 0,
type: 66,
});
});

const dependencyPath = await workspaceDependencyPath(
'/workspace',
'@nrwl/nx'
);
expect(dependencyPath).toMatchInlineSnapshot(
`"/workspace/node_modules/@nrwl/nx"`
);
});
});
11 changes: 10 additions & 1 deletion libs/npm/src/lib/workspace-dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { join } from 'path';
import { FileType, Uri, workspace } from 'vscode';
import { npmDependencies } from './npm-dependencies';
import {
isWorkspaceInPnp,
Expand Down Expand Up @@ -36,5 +37,13 @@ export async function workspaceDependencyPath(
return pnpDependencyPath(workspacePath, workspaceDependencyName);
}

return join(workspacePath, 'node_modules', workspaceDependencyName);
const path = join(workspacePath, 'node_modules', workspaceDependencyName);
try {
const directoryType = (await workspace.fs.stat(Uri.file(path))).type;
return (directoryType & FileType.Directory) === FileType.Directory
? path
: undefined;
} catch {
return;
}
}
2 changes: 1 addition & 1 deletion libs/schema/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
},
"build": {
"executor": "@nrwl/node:package",
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/schema",
Expand Down
15 changes: 2 additions & 13 deletions libs/schema/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Schema } from '@nrwl/tao/src/shared/params';
import { Schema } from 'nx/src/utils/params';

export enum OptionType {
Any = 'any',
Expand All @@ -24,6 +24,7 @@ export interface Option extends CliOption {
items?: string[] | ItemsWithEnum;
aliases: string[];
isRequired: boolean;
'x-dropdown'?: 'projects';
}

export interface ItemTooltips {
Expand Down Expand Up @@ -115,15 +116,3 @@ export interface Targets {

export const WORKSPACE_GENERATOR_NAME_REGEX =
/^workspace-(schematic|generator):(.+)/;

/**
* Should be in Typescript 4.4+ remove this when we upgrade to that version
*/
export type Awaited<T> = T extends null | undefined
? T // special case for `null | undefined` when not in `--strictNullChecks` mode
: // eslint-disable-next-line @typescript-eslint/ban-types
T extends object & { then(onfulfilled: infer F): any } // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
? F extends (value: infer V) => any // if the argument to `then` is callable, extracts the argument
? Awaited<V> // recursively unwrap the value
: never // the argument to `then` was not callable
: T;
2 changes: 1 addition & 1 deletion libs/server/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"outputs": ["coverage/libs/server"]
},
"build": {
"executor": "@nrwl/node:package",
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/server",
Expand Down
1 change: 1 addition & 0 deletions libs/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export {
export { watchFile } from './lib/utils/watch-file';
export { buildProjectPath } from './lib/utils/build-project-path';
export { findConfig } from './lib/utils/find-config';
export { getShellExecutionForConfig } from './lib/utils/shell-execution';

This file was deleted.

Loading

0 comments on commit c591644

Please sign in to comment.