npms-exam-kit 3.0.0 → 3.0.2
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 +63 -18
- 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 ''; } }
|
|
@@ -367,16 +367,52 @@ function generateMermaidDiagrams(projectType){
|
|
|
367
367
|
|
|
368
368
|
function initMermaidFile(fp, pt){
|
|
369
369
|
const d=generateMermaidDiagrams(pt);
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
370
|
+
const title=pt==='SIMS'?'Stock Inventory Management System (SIMS)':'Car Repair Payment Management System (CRPMS)';
|
|
371
|
+
const html=`<!DOCTYPE html>
|
|
372
|
+
<html lang="en">
|
|
373
|
+
<head>
|
|
374
|
+
<meta charset="UTF-8">
|
|
375
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
376
|
+
<title>${title} - ERD & DFD</title>
|
|
377
|
+
<script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"></script>
|
|
378
|
+
<style>
|
|
379
|
+
*{margin:0;padding:0;box-sizing:border-box}
|
|
380
|
+
body{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;padding:40px 20px;display:flex;flex-direction:column;align-items:center}
|
|
381
|
+
.container{max-width:1200px;width:100%}
|
|
382
|
+
h1{text-align:center;color:#1a1a2e;margin-bottom:8px;font-size:28px}
|
|
383
|
+
.subtitle{text-align:center;color:#666;margin-bottom:40px;font-size:14px}
|
|
384
|
+
.section{background:white;border-radius:16px;padding:32px;margin-bottom:32px;box-shadow:0 2px 12px rgba(0,0,0,0.08)}
|
|
385
|
+
.section h2{color:#1a1a2e;margin-bottom:20px;padding-bottom:12px;border-bottom:3px solid #00D2FF;font-size:20px}
|
|
386
|
+
.mermaid-wrapper{overflow-x:auto;padding:8px 0}
|
|
387
|
+
.mermaid svg{max-width:100%;height:auto}
|
|
388
|
+
.footer{text-align:center;color:#999;font-size:12px;margin-top:16px}
|
|
389
|
+
</style>
|
|
390
|
+
</head>
|
|
391
|
+
<body>
|
|
392
|
+
<div class="container">
|
|
393
|
+
<h1>${title}</h1>
|
|
394
|
+
<p class="subtitle">Entity Relationship Diagram & Data Flow Diagram — Generated by npms-exam-kit on ${new Date().toISOString().split('T')[0]}</p>
|
|
395
|
+
|
|
396
|
+
<div class="section">
|
|
397
|
+
<h2>Entity Relationship Diagram (ERD)</h2>
|
|
398
|
+
<div class="mermaid-wrapper">
|
|
399
|
+
<pre class="mermaid">${d.erd}</pre>
|
|
400
|
+
</div>
|
|
401
|
+
</div>
|
|
402
|
+
|
|
403
|
+
<div class="section">
|
|
404
|
+
<h2>Data Flow Diagram (DFD)</h2>
|
|
405
|
+
<div class="mermaid-wrapper">
|
|
406
|
+
<pre class="mermaid">${d.dfd}</pre>
|
|
407
|
+
</div>
|
|
408
|
+
</div>
|
|
409
|
+
|
|
410
|
+
<p class="footer">Open this file in a browser to view interactive diagrams. Generated by npms-exam-kit</p>
|
|
411
|
+
</div>
|
|
412
|
+
</body>
|
|
413
|
+
</html>`;
|
|
414
|
+
writeFileSync(fp.replace(/\.md$/,'.html'),html,'utf8');
|
|
415
|
+
return fp.replace(/\.md$/,'.html');
|
|
380
416
|
}
|
|
381
417
|
|
|
382
418
|
function showNextSteps(project, targetDir){
|
|
@@ -449,7 +485,7 @@ function showNextSteps(project, targetDir){
|
|
|
449
485
|
log(chalk.bold(` DATABASE: ${chalk.dim(dbName)}`));
|
|
450
486
|
log(chalk.bold(` FRONTEND: ${chalk.dim('http://localhost:5173')}`));
|
|
451
487
|
log(chalk.bold(` BACKEND: ${chalk.dim('http://localhost:5000')}`));
|
|
452
|
-
log(chalk.bold(`
|
|
488
|
+
log(chalk.bold(` Diagrams (ERD & DFD): ${chalk.dim(join(targetDir, project+'_ERD_DFD.html'))}`));
|
|
453
489
|
log(chalk.bold(` Assessment report saved: ${chalk.dim(join(targetDir, 'checklist_report'))}`));
|
|
454
490
|
log(chalk.bold('───────────────────────────────────────────────────────────────\n'));
|
|
455
491
|
|
|
@@ -485,10 +521,16 @@ async function main(){
|
|
|
485
521
|
}
|
|
486
522
|
|
|
487
523
|
const srcDir=join(PROJECTS_DIR,project==='SIMS'?'SIMS-master':'CRPMS-main');
|
|
488
|
-
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
|
+
}
|
|
489
531
|
|
|
490
|
-
|
|
491
|
-
log(chalk.bold(`\n Installing ${project}...`));
|
|
532
|
+
// ── INSTALL ──
|
|
533
|
+
log(chalk.bold(`\n Installing ${project} → ${targetDir} ...`));
|
|
492
534
|
const spinChars=['⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏'];
|
|
493
535
|
let si=0;
|
|
494
536
|
const spin=setInterval(()=>{process.stdout.write(`\r ${chalk.cyan(spinChars[si++%spinChars.length])} Installing...`);},80);
|
|
@@ -519,6 +561,8 @@ async function main(){
|
|
|
519
561
|
clearInterval(spin);
|
|
520
562
|
process.stdout.write('\r \r');
|
|
521
563
|
log(chalk.green(' ✓ Project files installed\n'));
|
|
564
|
+
log(chalk.dim(` Files created:`));
|
|
565
|
+
for(const f of readdirSync(targetDir).filter(f=>f!=='node_modules'&&f!=='package-lock.json')){log(chalk.dim(` ${f}`));}
|
|
522
566
|
|
|
523
567
|
// Create .env
|
|
524
568
|
if(existsSync(join(beDir,'.env.example'))&&!existsSync(join(beDir,'.env'))){
|
|
@@ -536,10 +580,11 @@ async function main(){
|
|
|
536
580
|
log(chalk.dim(` Report: ${join(rd)}\n`));
|
|
537
581
|
|
|
538
582
|
// ── MERMAID DIAGRAMS ──
|
|
539
|
-
const diagPath=join(targetDir,`${project}_ERD_DFD.
|
|
583
|
+
const diagPath=join(targetDir,`${project}_ERD_DFD.html`);
|
|
540
584
|
initMermaidFile(diagPath,project);
|
|
541
|
-
log(chalk.green(` ✓
|
|
542
|
-
log(` ${chalk.bold(diagPath)}
|
|
585
|
+
log(chalk.green(` ✓ Real ERD & DFD diagrams saved to:`));
|
|
586
|
+
log(` ${chalk.bold(diagPath)}`);
|
|
587
|
+
log(chalk.dim(' Open the .html file in a browser to see actual diagrams\n'));
|
|
543
588
|
|
|
544
589
|
// ── NEXT STEPS ──
|
|
545
590
|
showNextSteps(project, targetDir);
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npms-exam-kit",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
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",
|