npms-exam-kit 3.0.5 → 3.0.7
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 +18 -31
- package/package.json +2 -3
package/bin/exam-kit.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { dirname, join } from 'path';
|
|
4
|
-
import fs from 'fs-extra';
|
|
5
4
|
import chalk from 'chalk';
|
|
6
5
|
import inquirer from 'inquirer';
|
|
7
6
|
import { exec } from 'child_process';
|
|
8
7
|
import { promisify } from 'util';
|
|
9
|
-
import { existsSync, readFileSync, writeFileSync, copyFileSync, mkdirSync, readdirSync, statSync, cpSync } from 'fs';
|
|
8
|
+
import { existsSync, readFileSync, writeFileSync, copyFileSync, mkdirSync, readdirSync, statSync, cpSync, rmSync } from 'fs';
|
|
10
9
|
|
|
11
10
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
11
|
const __dirname = dirname(__filename);
|
|
@@ -508,19 +507,18 @@ async function main(){
|
|
|
508
507
|
]}]);
|
|
509
508
|
|
|
510
509
|
const targetDir=join(process.cwd());
|
|
510
|
+
const sourceName=project==='SIMS'?'SIMS-master':'CRPMS-main';
|
|
511
|
+
const installDir=join(targetDir,sourceName);
|
|
511
512
|
|
|
512
|
-
// Check if project already
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
if(existsSync(join(targetDir,'frontend-project')))exist.push('frontend-project');
|
|
516
|
-
if(exist.length>0){
|
|
517
|
-
log(chalk.yellow(` Warning: ${exist.join(', ')} already exists here.`));
|
|
513
|
+
// Check if project folder already exists
|
|
514
|
+
if(existsSync(installDir)){
|
|
515
|
+
log(chalk.yellow(` Warning: ${sourceName} already exists here.`));
|
|
518
516
|
const {overwrite}=await inquirer.prompt([{type:'confirm',name:'overwrite',message:'Overwrite?',default:false}]);
|
|
519
517
|
if(!overwrite){log(chalk.yellow(' Cancelled.'));process.exit(0);}
|
|
520
|
-
|
|
518
|
+
rmSync(installDir,{recursive:true,force:true});
|
|
521
519
|
}
|
|
522
520
|
|
|
523
|
-
const srcDir=join(PROJECTS_DIR,
|
|
521
|
+
const srcDir=join(PROJECTS_DIR,sourceName);
|
|
524
522
|
if(!existsSync(srcDir)){
|
|
525
523
|
log(chalk.red(` Error: source not found at: ${srcDir}`));
|
|
526
524
|
log(chalk.dim(` Package root: ${ROOT}`));
|
|
@@ -530,28 +528,17 @@ async function main(){
|
|
|
530
528
|
}
|
|
531
529
|
|
|
532
530
|
// ── INSTALL ──
|
|
533
|
-
log(chalk.bold(`\n Installing ${project} → ${
|
|
534
|
-
|
|
535
|
-
// DEBUG: show source paths
|
|
536
|
-
log(chalk.dim(` Script: ${import.meta.url}`));
|
|
537
|
-
log(chalk.dim(` Projects dir: ${PROJECTS_DIR}`));
|
|
538
|
-
log(chalk.dim(` Source: ${srcDir}`));
|
|
539
|
-
log(chalk.dim(` Source contents: ${inDir(srcDir).join(', ')}`));
|
|
531
|
+
log(chalk.bold(`\n Installing ${project} → ${installDir} ...`));
|
|
540
532
|
|
|
541
533
|
try{
|
|
542
|
-
// Copy
|
|
543
|
-
|
|
544
|
-
for(const entry of entries){
|
|
545
|
-
if(entry==='node_modules')continue;
|
|
546
|
-
const s=join(srcDir,entry),d=join(targetDir,entry);
|
|
547
|
-
if(statSync(s).isDirectory())cpSync(s,d,{recursive:true,force:true});
|
|
548
|
-
else copyFileSync(s,d);
|
|
549
|
-
}
|
|
534
|
+
// Copy entire project folder
|
|
535
|
+
cpSync(srcDir,installDir,{recursive:true,force:true});
|
|
550
536
|
log(chalk.green(' ✓ Project files installed'));
|
|
551
|
-
|
|
537
|
+
log(chalk.dim(` ${sourceName}/`));
|
|
538
|
+
for(const f of readdirSync(installDir)){log(chalk.dim(` ${f}`));}
|
|
552
539
|
log('');
|
|
553
540
|
|
|
554
|
-
const beDir=join(
|
|
541
|
+
const beDir=join(installDir,'backend-project'),feDir=join(installDir,'frontend-project');
|
|
555
542
|
|
|
556
543
|
// Install backend dependencies
|
|
557
544
|
if(existsSync(beDir)&&existsSync(join(beDir,'package.json'))){
|
|
@@ -577,22 +564,22 @@ async function main(){
|
|
|
577
564
|
|
|
578
565
|
// ── AUTO-ASSESS ──
|
|
579
566
|
log(chalk.bold(' Running auto-assessment...\n'));
|
|
580
|
-
const checks=buildChecklist(
|
|
567
|
+
const checks=buildChecklist(installDir,project);
|
|
581
568
|
const results=checks.map(c=>{let s;try{const r=c.auto();s=r===true||r==='PASS'?'PASS':(r==='MANUAL'?'MANUAL':'FAIL');}catch{s='MANUAL';}return{...c,status:s,guide:c.guide||''};});
|
|
582
569
|
showResults(results);
|
|
583
|
-
const rd=join(
|
|
570
|
+
const rd=join(installDir,'checklist_report');mkdirSync(rd,{recursive:true});
|
|
584
571
|
writeFileSync(join(rd,`assessment_${project}_${Date.now()}.json`),JSON.stringify({project,date:new Date().toISOString(),results},null,2));
|
|
585
572
|
log(chalk.dim(` Report: ${join(rd)}\n`));
|
|
586
573
|
|
|
587
574
|
// ── MERMAID DIAGRAMS ──
|
|
588
|
-
const diagPath=join(
|
|
575
|
+
const diagPath=join(installDir,`${project}_ERD_DFD.html`);
|
|
589
576
|
initMermaidFile(diagPath,project);
|
|
590
577
|
log(chalk.green(` ✓ Real ERD & DFD diagrams saved to:`));
|
|
591
578
|
log(` ${chalk.bold(diagPath)}`);
|
|
592
579
|
log(chalk.dim(' Open the .html file in a browser to see actual diagrams\n'));
|
|
593
580
|
|
|
594
581
|
// ── NEXT STEPS ──
|
|
595
|
-
showNextSteps(project,
|
|
582
|
+
showNextSteps(project, installDir);
|
|
596
583
|
|
|
597
584
|
log(chalk.bold.green('\n ✓ All done! Follow the steps above to run your project.\n'));
|
|
598
585
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npms-exam-kit",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "NESA National Practical Exam Projects Installer - SIMS & CRPMS",
|
|
5
5
|
"bin": {
|
|
6
6
|
"npms-exam-kit": "bin/exam-kit.js"
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"chalk": "^5.3.0",
|
|
19
|
-
"inquirer": "^9.2.0"
|
|
20
|
-
"fs-extra": "^11.2.0"
|
|
19
|
+
"inquirer": "^9.2.0"
|
|
21
20
|
},
|
|
22
21
|
"type": "module",
|
|
23
22
|
"engines": {
|