From 9cc86705bf39efbb6e922b7a81091482b10ef774 Mon Sep 17 00:00:00 2001 From: Patrick Ruhkopf Date: Mon, 18 Mar 2024 16:51:13 -0400 Subject: [PATCH] fix: add npm dep type validation --- packages/filter-by-workspace-path/src/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/filter-by-workspace-path/src/index.ts b/packages/filter-by-workspace-path/src/index.ts index a6a6fd0..2d714cb 100644 --- a/packages/filter-by-workspace-path/src/index.ts +++ b/packages/filter-by-workspace-path/src/index.ts @@ -36,8 +36,13 @@ export default class FilterByWorkspacePathPlugin implements IPlugin { const currentDir = path.resolve('.') const npmResult = execSync('npm ls --omit=dev --depth 1 -json', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] }) const workspaceDeps: any = JSON.parse(npmResult).dependencies + const firstWsDep = workspaceDeps[Object.keys(workspaceDeps)[0] as any].resolved + if (!firstWsDep.startsWith('file:')) { + throw new Error('This plugin only works with workspaces that are defined as file: dependencies in the root package.json.') + } + // eslint-disable-next-line @typescript-eslint/no-magic-numbers - const currentWorkspace = workspaceDeps[Object.keys(workspaceDeps)[0] as any].resolved.substring(11) + const currentWorkspace = path.basename(firstWsDep.substring(5)) auto.hooks.onCreateLogParse.tap(this.name, (logParse) => { logParse.hooks.omitCommit.tap(this.name, (commit) => @@ -56,6 +61,7 @@ export default class FilterByWorkspacePathPlugin implements IPlugin { return origGetVersion(from, to) } + // TODO can be removed once https://github.com/intuit/auto/pull/2436 is released release.calcNextVersion = async (lastTag: string) => { const bump = await release.getSemverBump(lastTag) const matches = lastTag.match(/(\d+\.\d+\.\d+)/)