@@ -259,7 +259,7 @@ class CodeInjector implements ICodeInjector {
259259 try {
260260 npmLock = JSON . parse ( await fs . promises . readFile ( npmLockPath , 'utf-8' ) ) ;
261261 } catch ( npmLockError ) {
262- throw new Error ( `Custom pnpm-lock.yaml does not exist in ${ dir } , but package.json does.
262+ throw new Error ( `Custom pnpm-lock.yaml or package-lock.json does not exist in ${ dir } , but package.json does.
263263 We can't determine version of packages without pnpm-lock.yaml or package-lock.json. Please run pnpm install or npm install in ${ dir } ` ) ;
264264 }
265265
@@ -723,9 +723,10 @@ class CodeInjector implements ICodeInjector {
723723
724724
725725 /* hash checking */
726- const spaPnpmLockPath = path . join ( this . spaTmpPath ( ) , 'pnpm-lock.yaml' ) ;
727- const spaPnpmLock = yaml . parse ( await fs . promises . readFile ( spaPnpmLockPath , 'utf-8' ) ) ;
728- const spaLockHash = hashify ( spaPnpmLock ) ;
726+ // Here we use pnpm-lock.yaml, because this file will be anywat, even if user doesn't use it
727+ const spaPnpmLockPath = path . join ( this . spaTmpPath ( ) , 'pnpm-lock.yaml' ) ;
728+ const spaPnpmLock = yaml . parse ( await fs . promises . readFile ( spaPnpmLockPath , 'utf-8' ) ) ;
729+ const spaLockHash = hashify ( spaPnpmLock ) ;
729730
730731 /* customPackageLock */
731732 let usersLockHash : string = '' ;
@@ -1039,7 +1040,8 @@ class CodeInjector implements ICodeInjector {
10391040 } else {
10401041
10411042 const command = 'run dev' ;
1042- afLogger . info ( `⚙️ spawn: pnpm ${ command } ...` ) ;
1043+ const usersPackageManager = await this . doesUserHasPnpmLockFile ( this . adminforth . config . customization . customComponentsDir ) ? 'pnpm' : 'npm' ;
1044+ afLogger . info ( `⚙️ spawn: ${ usersPackageManager } ${ command } ...` ) ;
10431045 if ( process . env . VITE_ADMINFORTH_PUBLIC_PATH ) {
10441046 afLogger . info ( `⚠️ Your VITE_ADMINFORTH_PUBLIC_PATH: ${ process . env . VITE_ADMINFORTH_PUBLIC_PATH } has no effect` ) ;
10451047 }
@@ -1050,13 +1052,13 @@ class CodeInjector implements ICodeInjector {
10501052 } ;
10511053
10521054 const nodeBinary = process . execPath ;
1053- const pnpmPath = path . join ( path . dirname ( nodeBinary ) , 'pnpm' ) ;
1055+ const packageManagerPath = path . join ( path . dirname ( nodeBinary ) , usersPackageManager ) ;
10541056
10551057 let devServer ;
10561058 if ( process . platform === 'win32' ) {
1057- devServer = spawn ( 'pnpm' , command . split ( ' ' ) , { cwd, env, shell : true } ) ;
1059+ devServer = spawn ( usersPackageManager , command . split ( ' ' ) , { cwd, env, shell : true } ) ;
10581060 } else {
1059- devServer = spawn ( `${ nodeBinary } ` , [ `${ pnpmPath } ` , ...command . split ( ' ' ) ] , { cwd, env } ) ;
1061+ devServer = spawn ( `${ nodeBinary } ` , [ `${ packageManagerPath } ` , ...command . split ( ' ' ) ] , { cwd, env } ) ;
10601062 }
10611063 devServer . stdout . on ( 'data' , ( data ) => {
10621064 if ( data . includes ( '➜' ) ) {
0 commit comments