npms-exam-kit 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/exam-kit.js +20 -14
- package/package.json +4 -2
package/bin/exam-kit.js
CHANGED
|
@@ -11,7 +11,7 @@ import { existsSync, readFileSync, writeFileSync, copyFileSync, mkdirSync, readd
|
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = dirname(__filename);
|
|
13
13
|
const ROOT = join(__dirname, '..');
|
|
14
|
-
const PROJECTS_DIR =
|
|
14
|
+
const PROJECTS_DIR = fileURLToPath(new URL('../projects', import.meta.url));
|
|
15
15
|
const execAsync = promisify(exec);
|
|
16
16
|
|
|
17
17
|
function read(p) { try { return existsSync(p) ? readFileSync(p, 'utf8') : ''; } catch { return ''; } }
|
|
@@ -521,15 +521,19 @@ async function main(){
|
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
const srcDir=join(PROJECTS_DIR,project==='SIMS'?'SIMS-master':'CRPMS-main');
|
|
524
|
-
if(!existsSync(srcDir)){
|
|
524
|
+
if(!existsSync(srcDir)){
|
|
525
|
+
log(chalk.red(` Error: source not found at: ${srcDir}`));
|
|
526
|
+
log(chalk.dim(` Package root: ${ROOT}`));
|
|
527
|
+
log(chalk.dim(` Projects dir: ${PROJECTS_DIR}`));
|
|
528
|
+
log(chalk.dim(` Available: ${existsSync(PROJECTS_DIR) ? inDir(PROJECTS_DIR).join(', ') : 'PROJECTS_DIR missing'}`));
|
|
529
|
+
process.exit(1);
|
|
530
|
+
}
|
|
525
531
|
|
|
526
|
-
|
|
527
|
-
log(chalk.bold(`\n Installing ${project}...`));
|
|
528
|
-
const spinChars=['⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏'];
|
|
529
|
-
let si=0;
|
|
530
|
-
const spin=setInterval(()=>{process.stdout.write(`\r ${chalk.cyan(spinChars[si++%spinChars.length])} Installing...`);},80);
|
|
532
|
+
// ── INSTALL ──
|
|
533
|
+
log(chalk.bold(`\n Installing ${project} → ${targetDir} ...`));
|
|
531
534
|
|
|
532
535
|
try{
|
|
536
|
+
// Copy files first (instant — no spinner needed)
|
|
533
537
|
const entries=readdirSync(srcDir);
|
|
534
538
|
for(const entry of entries){
|
|
535
539
|
if(entry==='node_modules')continue;
|
|
@@ -537,24 +541,27 @@ async function main(){
|
|
|
537
541
|
if(statSync(s).isDirectory())fs.copySync(s,d,{filter:f=>!f.includes('node_modules')});
|
|
538
542
|
else copyFileSync(s,d);
|
|
539
543
|
}
|
|
544
|
+
log(chalk.green(' ✓ Project files installed'));
|
|
545
|
+
for(const f of readdirSync(targetDir).filter(f=>f!=='node_modules'&&f!=='package-lock.json'&&f!=='checklist_report')){log(chalk.dim(` ${f}`));}
|
|
546
|
+
log('');
|
|
540
547
|
|
|
541
548
|
const beDir=join(targetDir,'backend-project'),feDir=join(targetDir,'frontend-project');
|
|
542
549
|
|
|
550
|
+
// Install backend dependencies
|
|
543
551
|
if(existsSync(beDir)&&existsSync(join(beDir,'package.json'))){
|
|
544
552
|
process.chdir(beDir);
|
|
545
|
-
log(chalk.cyan('
|
|
546
|
-
try{await execAsync('npm install',{timeout:
|
|
553
|
+
log(chalk.cyan(' Installing Backend dependencies...'));
|
|
554
|
+
try{await execAsync('npm install',{timeout:180000,windowsHide:true});log(chalk.green(' ✓ Backend dependencies installed\n'));}catch(e){log(chalk.yellow(` ⚠ Backend: ${e.message}\n`));}
|
|
547
555
|
}
|
|
556
|
+
|
|
557
|
+
// Install frontend dependencies
|
|
548
558
|
if(existsSync(feDir)&&existsSync(join(feDir,'package.json'))){
|
|
549
559
|
process.chdir(feDir);
|
|
550
560
|
log(chalk.cyan(' Installing Frontend dependencies...'));
|
|
551
|
-
try{await execAsync('npm install',{timeout:
|
|
561
|
+
try{await execAsync('npm install',{timeout:180000,windowsHide:true});log(chalk.green(' ✓ Frontend dependencies installed\n'));}catch(e){log(chalk.yellow(` ⚠ Frontend: ${e.message}\n`));}
|
|
552
562
|
}
|
|
553
563
|
|
|
554
564
|
process.chdir(targetDir);
|
|
555
|
-
clearInterval(spin);
|
|
556
|
-
process.stdout.write('\r \r');
|
|
557
|
-
log(chalk.green(' ✓ Project files installed\n'));
|
|
558
565
|
|
|
559
566
|
// Create .env
|
|
560
567
|
if(existsSync(join(beDir,'.env.example'))&&!existsSync(join(beDir,'.env'))){
|
|
@@ -584,7 +591,6 @@ async function main(){
|
|
|
584
591
|
log(chalk.bold.green('\n ✓ All done! Follow the steps above to run your project.\n'));
|
|
585
592
|
|
|
586
593
|
}catch(err){
|
|
587
|
-
clearInterval(spin);
|
|
588
594
|
log(chalk.red(`\n ✗ Error: ${err.message}`));
|
|
589
595
|
process.exit(1);
|
|
590
596
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npms-exam-kit",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "NESA National Practical Exam Projects Installer - SIMS & CRPMS",
|
|
5
|
-
"bin":
|
|
5
|
+
"bin": {
|
|
6
|
+
"npms-exam-kit": "bin/exam-kit.js"
|
|
7
|
+
},
|
|
6
8
|
"keywords": [
|
|
7
9
|
"nesa",
|
|
8
10
|
"exam",
|