Skip to content

Commit

Permalink
update builder options to support pnp
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Jan 17, 2022
1 parent a2bd3ae commit 0dad3c3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 45 deletions.
13 changes: 0 additions & 13 deletions apps/vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
RunTargetTreeItem,
RunTargetTreeProvider,
} from '@nx-console/vscode/nx-run-target-view';
import { verifyNodeModules } from '@nx-console/vscode/verify';
import {
NxCommandsTreeItem,
NxCommandsTreeProvider,
Expand Down Expand Up @@ -87,18 +86,6 @@ export async function activate(c: ExtensionContext) {
const revealWebViewPanelCommand = commands.registerCommand(
'nxConsole.revealWebViewPanel',
async (runTargetTreeItem: RunTargetTreeItem, contextMenuUri?: Uri) => {
const workspacePath = WorkspaceConfigurationStore.instance.get(
'nxWorkspacePath',
''
);
if (!(await directoryExists(join(workspacePath, 'node_modules')))) {
const { validNodeModules: hasNodeModules } = await verifyNodeModules(
workspacePath
);
if (!hasNodeModules) {
return;
}
}
revealWebViewPanel({
runTargetTreeItem,
context,
Expand Down
12 changes: 9 additions & 3 deletions libs/server/src/lib/utils/read-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from '../utils/utils';
import { getTelemetry } from '../telemetry';
import { getOutputChannel } from './output-channel';
import { workspaceDependencyPath } from '@nx-console/npm';

export function readTargetDef(
targetName: string,
Expand Down Expand Up @@ -61,10 +62,15 @@ export async function readBuilderSchema(
projectDefaults?: { [name: string]: string }
): Promise<Option[] | undefined> {
try {
const [npmPackage, builderName] = builder.split(':');
const [packageName, builderName] = builder.split(':');
const packagePath = await workspaceDependencyPath(basedir, packageName);

if (!packagePath) {
return undefined;
}

const packageJson = await readAndCacheJsonFile(
path.join(npmPackage, 'package.json'),
path.join(basedir, 'node_modules')
path.join(packagePath, 'package.json')
);
const b = packageJson.json.builders || packageJson.json.executors;
const buildersPath = b.startsWith('.') ? b : `./${b}`;
Expand Down
8 changes: 0 additions & 8 deletions libs/vscode/tasks/src/lib/cli-task-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {

import { getTelemetry } from '@nx-console/server';
import { verifyWorkspace } from '@nx-console/vscode/nx-workspace';
import { verifyNodeModules } from '@nx-console/vscode/verify';
import { CliTask } from './cli-task';
import { CliTaskDefinition } from './cli-task-definition';
import { NxTask } from './nx-task';
Expand Down Expand Up @@ -75,13 +74,6 @@ export class CliTaskProvider implements TaskProvider {
}

async executeTask(definition: CliTaskDefinition) {
const { validNodeModules: hasNodeModules } = await verifyNodeModules(
this.getWorkspacePath()
);
if (!hasNodeModules) {
return;
}

const isDryRun = definition.flags.includes('--dry-run');
if (isDryRun && this.currentDryRun) {
this.deferredDryRun = definition;
Expand Down
1 change: 0 additions & 1 deletion libs/vscode/verify/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './lib/verify-builder-definition';
export * from './lib/verify-node-modules';
4 changes: 2 additions & 2 deletions libs/vscode/verify/src/lib/verify-builder-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ export async function verifyBuilderDefinition(

if (!options) {
window.showErrorMessage(
`Builder specified for ${project} ${command} was not found in your node_modules. Check that specified builder is correct and has a corresponding entry in package.json`,
`Builder specified for ${project} ${command} was not found in your dependencies. Check that specified builder is correct and has a corresponding entry in package.json`,
'Show definition'
);
getTelemetry().exception('Specified builder not found in node_modules');
getTelemetry().exception('Specified builder not found in dependencies');

return {
validBuilder: false,
Expand Down
18 changes: 0 additions & 18 deletions libs/vscode/verify/src/lib/verify-node-modules.ts

This file was deleted.

0 comments on commit 0dad3c3

Please sign in to comment.