Skip to content

Commit 4c0fe9f

Browse files
committed
fix: don't copy package.json/package-lock.json/pnpm-lock.yaml from the adminforth spa sr folder, if there is already package.json in tmp folder
1 parent 5dc8293 commit 4c0fe9f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

adminforth/modules/codeInjector.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,15 @@ class CodeInjector implements ICodeInjector {
446446
const spaDir = this.getSpaDir();
447447

448448
afLogger.trace(`🪲⚙️ fsExtra.copy from ${spaDir} -> ${this.spaTmpPath()}`);
449+
let isPackageJsonInSpaFolder = false;
449450

451+
try {
452+
await fs.promises.access(path.join(this.spaTmpPath(), 'package.json'));
453+
isPackageJsonInSpaFolder = true;
454+
afLogger.trace('🪲⚙️ package.json is in spa tmp folder, will not copy package.json from user spa folder to not break cache');
455+
} catch (e) {
456+
afLogger.trace('🪲⚙️ package.json is not in spa tmp folder, will copy package.json from user spa folder if it exists');
457+
}
450458
// try to rm <spa tmp path>/src/types directory
451459
try {
452460
await fs.promises.rm(path.join(this.spaTmpPath(), 'src', 'types'), { recursive: true });
@@ -460,7 +468,8 @@ class CodeInjector implements ICodeInjector {
460468
filter: (src) => {
461469
// /adminforth/* used for local development and /dist/* used for production
462470
const filterPasses = !src.includes(`${path.sep}adminforth${path.sep}spa${path.sep}node_modules`) && !src.includes(`${path.sep}adminforth${path.sep}spa${path.sep}dist`)
463-
&& !src.includes(`${path.sep}dist${path.sep}spa${path.sep}node_modules`) && !src.includes(`${path.sep}dist${path.sep}spa${path.sep}dist`);
471+
&& !src.includes(`${path.sep}dist${path.sep}spa${path.sep}node_modules`) && !src.includes(`${path.sep}dist${path.sep}spa${path.sep}dist`)
472+
&& !(isPackageJsonInSpaFolder && (src.endsWith('package.json') || src.endsWith('package-lock.json') || src.endsWith('pnpm-lock.yaml'))); // if package.json is in spa folder, don't copy it, to not break cache
464473
if (!filterPasses) {
465474
afLogger.trace(`🪲⚙️ fsExtra.copy filtered out, ${src}`);
466475
}

0 commit comments

Comments
 (0)