Skip to content

Commit 0fdd74a

Browse files
committed
fix: improve lock file handling by checking for pnpm-lock.yaml or falling back to package-lock.json
1 parent 4c0fe9f commit 0fdd74a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

adminforth/modules/codeInjector.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -733,11 +733,16 @@ class CodeInjector implements ICodeInjector {
733733

734734

735735
/* hash checking */
736-
// Here we use pnpm-lock.yaml, because this file will be anywat, even if user doesn't use it
737-
const spaPnpmLockPath = path.join(this.spaTmpPath(), 'pnpm-lock.yaml');
738-
const spaPnpmLock = yaml.parse(await fs.promises.readFile(spaPnpmLockPath, 'utf-8'));
739-
const spaLockHash = hashify(spaPnpmLock);
740-
736+
let spaLockHash = '';
737+
if (await this.doesUserHasPnpmLockFile(this.adminforth.config.customization.customComponentsDir)) {
738+
const spaPnpmLockPath = path.join(this.spaTmpPath(), 'pnpm-lock.yaml');
739+
const spaPnpmLock = yaml.parse(await fs.promises.readFile(spaPnpmLockPath, 'utf-8'));
740+
spaLockHash = hashify(spaPnpmLock);
741+
} else {
742+
const spaNpmLockPath = path.join(this.spaTmpPath(), 'package-lock.json');
743+
const spaNpmLock = JSON.parse(await fs.promises.readFile(spaNpmLockPath, 'utf-8'));
744+
spaLockHash = hashify(spaNpmLock);
745+
}
741746
/* customPackageLock */
742747
let usersLockHash: string = '';
743748
let usersPackages: string[] = [];
@@ -1050,9 +1055,7 @@ class CodeInjector implements ICodeInjector {
10501055
const skipBuild = buildHash === sourcesHash;
10511056
const skipExtract = messagesHash === sourcesHash;
10521057

1053-
afLogger.trace(`🪲 SPA build hash: ${buildHash}`);
10541058
afLogger.trace(`🪲 SPA messages hash: ${messagesHash}`);
1055-
afLogger.trace(`🪲 SPA sources hash: ${sourcesHash}`);
10561059

10571060
if (!skipBuild) {
10581061
// remove serveDir if exists

0 commit comments

Comments
 (0)