Skip to content

Commit dd848be

Browse files
committed
fix: add check, if user has pnmp, before installing frontend dependencies and update Dockerfile to use devforth/node20-pnpm image for the dev-demo
1 parent f151425 commit dd848be

4 files changed

Lines changed: 5648 additions & 5 deletions

File tree

adminforth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"rollout-doc": "cd documentation && pnpm build && pnpm deploy",
2121
"docs": "typedoc",
2222
"--comment_postinstall": "postinstall executed after package installed in other project package and when we do pnpm i in the package",
23-
"postinstall": "node -e \"const fs=require('fs');const path=require('path');const spaPath=path.join(__dirname,'dist','spa');if(fs.existsSync(spaPath) && !process.env.PNPM_INSTALL_SPA){process.env.PNPM_INSTALL_SPA=1;require('child_process').execSync('pnpm install --frozen-lockfile',{cwd:spaPath,stdio:'inherit'});console.log('installed spa dependencies');}\""
23+
"postinstall": "node scripts/postinstall.js"
2424
},
2525
"release": {
2626
"plugins": [

adminforth/scripts/postinstall.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
5+
const nodeBinary = process.execPath;
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename);
8+
const spaPath=path.join(__dirname,'dist','spa');
9+
10+
const pnpmPotentionalPath=path.join(nodeBinary,'..','pnpm');
11+
const doesUserProjectHasPnpm = fs.existsSync(pnpmPotentionalPath)
12+
console.log('doesUserProjectHasPnpm', doesUserProjectHasPnpm);
13+
if (doesUserProjectHasPnpm) {
14+
if(fs.existsSync(spaPath) && !process.env.PNPM_INSTALL_SPA){
15+
process.env.PNPM_INSTALL_SPA=1;
16+
require('child_process').execSync('pnpm install --frozen-lockfile',{cwd:spaPath,stdio:'inherit'});
17+
}
18+
} else {
19+
if(fs.existsSync(spaPath)){
20+
process.chdir(spaPath);
21+
require('child_process').execSync('npm ci',{stdio:'inherit'});
22+
}
23+
}
24+
25+
console.log('installed spa dependencies');

0 commit comments

Comments
 (0)