@@ -82,7 +82,8 @@ import {Project} from '../project/project.js'
8282import { Session } from '@shopify/cli-kit/node/session'
8383import { vi } from 'vitest'
8484import { joinPath } from '@shopify/cli-kit/node/path'
85- import { PackageManager } from '@shopify/cli-kit/node/node-package-manager'
85+ import { ProjectPackageManager } from '@shopify/cli-kit/node/node-package-manager'
86+ import { AbortError } from '@shopify/cli-kit/node/error'
8687
8788export const DEFAULT_CONFIG = {
8889 application_url : 'https://myapp.com' ,
@@ -154,7 +155,7 @@ export function testAppWithConfig(options?: TestAppWithConfigOptions): AppLinked
154155
155156interface TestProjectOptions {
156157 directory ?: string
157- packageManager ?: PackageManager
158+ packageManager ?: ProjectPackageManager | 'unknown'
158159 nodeDependencies ?: Record < string , string >
159160 usesWorkspaces ?: boolean
160161}
@@ -164,9 +165,11 @@ interface TestProjectOptions {
164165 * Use this when a service needs a Project for packageManager, usesWorkspaces, or directory.
165166 */
166167export function testProject ( options : TestProjectOptions = { } ) : Project {
168+ const packageManager = options . packageManager ?? 'yarn'
169+
167170 return {
168171 directory : options . directory ?? '/tmp/project' ,
169- packageManager : options . packageManager ?? 'yarn' ,
172+ packageManager,
170173 nodeDependencies : options . nodeDependencies ?? { } ,
171174 usesWorkspaces : options . usesWorkspaces ?? false ,
172175 appConfigFiles : [ ] ,
@@ -177,6 +180,13 @@ export function testProject(options: TestProjectOptions = {}): Project {
177180 appConfigByName : ( ) => undefined ,
178181 appConfigByClientId : ( ) => undefined ,
179182 defaultAppConfig : undefined ,
183+ requirePackageManagerForOperations : ( ) => {
184+ if ( packageManager === 'unknown' ) {
185+ throw new AbortError ( 'Could not determine the project package manager.' )
186+ }
187+
188+ return packageManager
189+ } ,
180190 } as unknown as Project
181191}
182192
0 commit comments