@mrselva/attendance 1.1.0 → 1.1.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/README.md +23 -42
- package/index.js +17 -34
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
[](https://nodejs.org)
|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> A fast and lightweight CLI tool to extract, normalize, and export multi-sheet attendance spreadsheets into organized Excel files and ZIP archives.
|
|
8
8
|
|
|
9
|
-
Run instantly with **`npx`** — no
|
|
9
|
+
Run instantly with **`npx`** — no installation required!
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
## ⚡ Quick Start
|
|
14
14
|
|
|
15
|
-
Open your terminal in any
|
|
15
|
+
Open your terminal in any directory and run:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
npx @mrselva/attendance
|
|
@@ -29,64 +29,51 @@ attendance
|
|
|
29
29
|
|
|
30
30
|
## ✨ Features
|
|
31
31
|
|
|
32
|
-
- **Zero Configuration & Auto-Import**: If no file is in `./input/`, an
|
|
33
|
-
- **Interactive CLI Wizard**: Clean, color-coded terminal prompts to pick
|
|
34
|
-
- **
|
|
35
|
-
- `AD`: AI & Data Science Lab
|
|
36
|
-
- `BW`: Blockchain and Web3.0 Lab
|
|
37
|
-
- `CD`: Cloud and DevOps Lab
|
|
38
|
-
- `CS`: Cyber Security Lab
|
|
39
|
-
- `DMA`: Data & Mobile Analytics Lab
|
|
40
|
-
- `EI`: Embedded & IoT Lab
|
|
41
|
-
- `FW`: Full Stack Web Lab
|
|
42
|
-
- `SOAL`: School of AI Learning
|
|
43
|
-
- `SOP`: School of Programming
|
|
32
|
+
- **Zero Configuration & Auto-Import**: If no file is in `./input/`, an interactive file picker window opens so you can select your spreadsheet directly from your computer, or drag & drop file paths into the terminal.
|
|
33
|
+
- **Interactive CLI Wizard**: Clean, color-coded terminal prompts to pick sheets and date filters.
|
|
34
|
+
- **Multi-Sheet Detection**: Automatically discovers all relevant sheets and rosters across the workbook.
|
|
44
35
|
- **Smart Date Filtering**:
|
|
45
|
-
- Export **All recorded dates**
|
|
46
|
-
- Export a **Single date** (e.g. `
|
|
36
|
+
- Export **All recorded dates**
|
|
37
|
+
- Export a **Single date** (e.g. `YYYY-MM-DD`)
|
|
47
38
|
- Export a **Date range** (from `YYYY-MM-DD` to `YYYY-MM-DD`)
|
|
48
39
|
- Export the **Latest date only**
|
|
49
|
-
- **
|
|
50
|
-
|
|
51
|
-
- `Registration Id`
|
|
52
|
-
- `Attendance *` (`PRESENT` or `ABSENT`)
|
|
53
|
-
- **Status Normalization**: Accurately normalizes marks (`P`, `1`, `OD`, `ELITE` → `PRESENT`; `A`, `0`, unrecorded → `ABSENT`).
|
|
54
|
-
- **Automatic ZIP Packaging**: Compresses generated files directly into `./output/<Vertical>_Attendance.zip`.
|
|
40
|
+
- **Status Normalization**: Accurately normalizes attendance status (`PRESENT`, `ABSENT`, etc.) and handles blanks cleanly.
|
|
41
|
+
- **Automatic ZIP Packaging**: Compresses generated export files directly into clean ZIP archives in `./output/`.
|
|
55
42
|
|
|
56
43
|
---
|
|
57
44
|
|
|
58
45
|
## 🚀 CLI Usage & Flags
|
|
59
46
|
|
|
60
|
-
|
|
47
|
+
Run the interactive wizard or pass flags for automation:
|
|
61
48
|
|
|
62
49
|
```bash
|
|
63
50
|
# Interactive mode
|
|
64
51
|
npx @mrselva/attendance
|
|
65
52
|
|
|
66
|
-
# Export
|
|
67
|
-
npx @mrselva/attendance -v
|
|
53
|
+
# Export all dates for a specific sheet
|
|
54
|
+
npx @mrselva/attendance -v SHEET_CODE -a
|
|
68
55
|
|
|
69
56
|
# Export a single date
|
|
70
|
-
npx @mrselva/attendance -v
|
|
57
|
+
npx @mrselva/attendance -v SHEET_CODE -d 2024-09-12
|
|
71
58
|
|
|
72
59
|
# Export the latest date recorded
|
|
73
|
-
npx @mrselva/attendance -v
|
|
60
|
+
npx @mrselva/attendance -v SHEET_CODE --latest
|
|
74
61
|
|
|
75
|
-
# Process ALL
|
|
62
|
+
# Process ALL sheets at once
|
|
76
63
|
npx @mrselva/attendance -v ALL -a
|
|
77
64
|
|
|
78
65
|
# Specify a custom input spreadsheet file
|
|
79
|
-
npx @mrselva/attendance -f "
|
|
66
|
+
npx @mrselva/attendance -f "attendance_sheet.xlsx" -v SHEET_CODE -a
|
|
80
67
|
```
|
|
81
68
|
|
|
82
69
|
### Options Reference
|
|
83
70
|
|
|
84
71
|
| Flag | Long Flag | Description |
|
|
85
72
|
| :--- | :--- | :--- |
|
|
86
|
-
| `-v <code
|
|
87
|
-
| `-a` | `--all` | Export all recorded
|
|
73
|
+
| `-v <code>` | `--vertical <code>` | Sheet code or name (or `ALL`) |
|
|
74
|
+
| `-a` | `--all` | Export all recorded dates |
|
|
88
75
|
| `-d <date>` | `--date <YYYY-MM-DD>` | Export a specific date |
|
|
89
|
-
| | `--latest` | Export the latest
|
|
76
|
+
| | `--latest` | Export the latest recorded date |
|
|
90
77
|
| `-f <file>` | `--file <path>` | Specify input Excel file path or filename |
|
|
91
78
|
| `-h` | `--help` | Display usage and help message |
|
|
92
79
|
|
|
@@ -96,24 +83,18 @@ npx @mrselva/attendance -f "2024-28_SoI_Attendance_Sheet.xlsx" -v FW -a
|
|
|
96
83
|
|
|
97
84
|
```text
|
|
98
85
|
your-folder/
|
|
99
|
-
├── input/ #
|
|
100
|
-
|
|
101
|
-
└── output/ # Automatically generated output
|
|
102
|
-
├── BW_Attendance.zip
|
|
103
|
-
└── CD_Attendance.zip
|
|
86
|
+
├── input/ # Place source spreadsheets here (or auto-import)
|
|
87
|
+
└── output/ # Automatically generated ZIP archives
|
|
104
88
|
```
|
|
105
89
|
|
|
106
|
-
> **Note:** If an `input/` folder is not found, the CLI will look for Excel files directly in your current working directory.
|
|
107
|
-
|
|
108
90
|
---
|
|
109
91
|
|
|
110
92
|
## 🛠 Requirements
|
|
111
93
|
|
|
112
94
|
- **Node.js**: `v16.0.0` or higher
|
|
113
|
-
- **npm**: `v7.0.0` or higher (included with Node.js)
|
|
114
95
|
|
|
115
96
|
---
|
|
116
97
|
|
|
117
98
|
## 📄 License
|
|
118
99
|
|
|
119
|
-
[ISC](LICENSE) © [mrselva
|
|
100
|
+
[ISC](LICENSE) © [mrselva](https://github.com/mrselva)
|
package/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Attendance
|
|
3
|
+
* Attendance Spreadsheet Converter & Exporter
|
|
4
4
|
* Single-file Node.js CLI script
|
|
5
5
|
*
|
|
6
6
|
* Features:
|
|
7
|
-
* - Scans ./input for attendance spreadsheets (.xlsx / .xls)
|
|
8
|
-
* - Interactively prompts for
|
|
7
|
+
* - Scans ./input or current directory for attendance spreadsheets (.xlsx / .xls)
|
|
8
|
+
* - Interactively prompts for sheet/category selection
|
|
9
9
|
* - Allows exporting all recorded dates, specific date, range, or latest date
|
|
10
|
-
* - Generates individual
|
|
11
|
-
* -
|
|
12
|
-
* - Works both interactively (in terminal) and with optional CLI flags (--vertical, --all, etc.)
|
|
10
|
+
* - Generates individual formatted Excel files with ZIP archive in ./output
|
|
11
|
+
* - Works both interactively (in terminal) and with CLI flags (--vertical, --all, etc.)
|
|
13
12
|
*/
|
|
14
13
|
|
|
15
14
|
const fs = require('fs');
|
|
@@ -23,18 +22,8 @@ const AdmZip = require('adm-zip');
|
|
|
23
22
|
const INPUT_DIR = path.resolve(process.cwd(), 'input');
|
|
24
23
|
const OUTPUT_DIR = path.resolve(process.cwd(), 'output');
|
|
25
24
|
|
|
26
|
-
//
|
|
27
|
-
const VERTICAL_NAMES = {
|
|
28
|
-
'AD': 'AI & Data Science Lab',
|
|
29
|
-
'BW': 'Blockchain and Web3.0 Lab',
|
|
30
|
-
'CD': 'Cloud and DevOps Lab',
|
|
31
|
-
'CS': 'Cyber Security Lab',
|
|
32
|
-
'DMA': 'Data & Mobile Analytics Lab',
|
|
33
|
-
'EI': 'Embedded & IoT Lab',
|
|
34
|
-
'FW': 'Full Stack Web Lab',
|
|
35
|
-
'SOAL': 'School of AI Learning',
|
|
36
|
-
'SOP': 'School of Programming'
|
|
37
|
-
};
|
|
25
|
+
// Optional category/sheet code to display name mapping
|
|
26
|
+
const VERTICAL_NAMES = {};
|
|
38
27
|
|
|
39
28
|
// ANSI color helpers
|
|
40
29
|
const colors = {
|
|
@@ -201,7 +190,6 @@ function parseVerticalSheet(ws, sheetName) {
|
|
|
201
190
|
let nameColIdx = -1;
|
|
202
191
|
let emailColIdx = -1;
|
|
203
192
|
let rollColIdx = -1;
|
|
204
|
-
let isKiteEmail = false;
|
|
205
193
|
const dateColumns = [];
|
|
206
194
|
|
|
207
195
|
// Analyze header row
|
|
@@ -215,13 +203,8 @@ function parseVerticalSheet(ws, sheetName) {
|
|
|
215
203
|
regColIdx = c;
|
|
216
204
|
} else if (hStr.includes('student name') || hStr === 'name') {
|
|
217
205
|
nameColIdx = c;
|
|
218
|
-
} else if (hStr.includes('
|
|
206
|
+
} else if (hStr.includes('email id') || hStr.includes('email') || hStr.includes('mail')) {
|
|
219
207
|
emailColIdx = c;
|
|
220
|
-
isKiteEmail = true;
|
|
221
|
-
} else if (!isKiteEmail && (hStr.includes('email id') || hStr.includes('email'))) {
|
|
222
|
-
if (!hStr.includes('soi')) {
|
|
223
|
-
emailColIdx = c;
|
|
224
|
-
}
|
|
225
208
|
} else if (hStr.includes('roll number') || hStr.includes('roll no')) {
|
|
226
209
|
rollColIdx = c;
|
|
227
210
|
} else {
|
|
@@ -270,7 +253,7 @@ function parseVerticalSheet(ws, sheetName) {
|
|
|
270
253
|
name: name,
|
|
271
254
|
regNo: regNo,
|
|
272
255
|
rollNo: rollNo,
|
|
273
|
-
email: email ||
|
|
256
|
+
email: email || ''
|
|
274
257
|
});
|
|
275
258
|
}
|
|
276
259
|
|
|
@@ -315,11 +298,11 @@ function parseVerticalSheet(ws, sheetName) {
|
|
|
315
298
|
};
|
|
316
299
|
}
|
|
317
300
|
|
|
318
|
-
// Generate
|
|
319
|
-
function
|
|
301
|
+
// Generate formatted Excel workbook for a single date
|
|
302
|
+
function generateExportWorkbook(verticalData, dateItem, rows) {
|
|
320
303
|
const wb = xlsx.utils.book_new();
|
|
321
304
|
|
|
322
|
-
//
|
|
305
|
+
// Export Sheet Header
|
|
323
306
|
const wsData = [
|
|
324
307
|
['Email Id', 'Registration Id', 'Attendance *']
|
|
325
308
|
];
|
|
@@ -542,7 +525,7 @@ Running without options launches the interactive CLI wizard.
|
|
|
542
525
|
}
|
|
543
526
|
|
|
544
527
|
console.log(`\n${colors.bold}${colors.magenta}╔═════════════════════════════════════════════════════════════════════╗`);
|
|
545
|
-
console.log(`║
|
|
528
|
+
console.log(`║ Attendance Sheet Exporter & Converter ║`);
|
|
546
529
|
console.log(`╚═════════════════════════════════════════════════════════════════════╝${colors.reset}`);
|
|
547
530
|
|
|
548
531
|
ensureDirs();
|
|
@@ -748,10 +731,10 @@ Running without options launches the interactive CLI wizard.
|
|
|
748
731
|
rl.close();
|
|
749
732
|
|
|
750
733
|
// Process selected verticals
|
|
751
|
-
logHeader('Processing & Generating
|
|
734
|
+
logHeader('Processing & Generating Export Files');
|
|
752
735
|
|
|
753
736
|
for (const vert of targets) {
|
|
754
|
-
console.log(`\n${colors.bold}
|
|
737
|
+
console.log(`\n${colors.bold}Sheet: ${vert.sheetName}${vert.verticalName !== vert.sheetName ? ' - ' + vert.verticalName : ''}${colors.reset}`);
|
|
755
738
|
console.log(` Students: ${colors.bold}${vert.students.length}${colors.reset}`);
|
|
756
739
|
|
|
757
740
|
let datesToExport = [...vert.dates];
|
|
@@ -789,7 +772,7 @@ Running without options launches the interactive CLI wizard.
|
|
|
789
772
|
|
|
790
773
|
for (const dateItem of datesToExport) {
|
|
791
774
|
const fileName = `Upload_Attendance_${vert.sheetName}_${dateItem.dateStr}.xlsx`;
|
|
792
|
-
const outWb =
|
|
775
|
+
const outWb = generateExportWorkbook(vert, dateItem, rows);
|
|
793
776
|
const fileBuffer = xlsx.write(outWb, { type: 'buffer', bookType: 'xlsx' });
|
|
794
777
|
zip.addFile(fileName, fileBuffer);
|
|
795
778
|
}
|
|
@@ -808,7 +791,7 @@ Running without options launches the interactive CLI wizard.
|
|
|
808
791
|
const zipStat = fs.statSync(zipFilePath);
|
|
809
792
|
const zipSizeKb = (zipStat.size / 1024).toFixed(1);
|
|
810
793
|
|
|
811
|
-
logSuccess(`Generated ZIP archive containing ${datesToExport.length}
|
|
794
|
+
logSuccess(`Generated ZIP archive containing ${datesToExport.length} export files:`);
|
|
812
795
|
console.log(` ${colors.bold}${colors.green}${zipFilePath}${colors.reset} (${zipSizeKb} KB)`);
|
|
813
796
|
}
|
|
814
797
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrselva/attendance",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "Extract
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Extract multi-sheet attendance data and export formatted Excel sheets with ZIP archives",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "node index.js"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [
|
|
10
10
|
"attendance",
|
|
11
|
-
"digicampus",
|
|
12
11
|
"excel",
|
|
12
|
+
"spreadsheet",
|
|
13
13
|
"cli",
|
|
14
14
|
"npx"
|
|
15
15
|
],
|