@wilm-ai/wilma-cli 1.5.0 → 1.5.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/dist/index.js +39 -30
- package/package.json +11 -10
- package/LICENSE +0 -21
package/dist/index.js
CHANGED
|
@@ -1008,37 +1008,52 @@ function currentWeekBounds() {
|
|
|
1008
1008
|
return [fmt(monday), fmt(friday)];
|
|
1009
1009
|
}
|
|
1010
1010
|
const DAY_NAMES = ["Su", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
1011
|
-
|
|
1012
|
-
const overview = await client.overview.get();
|
|
1011
|
+
function resolveScheduleDateSelection(opts) {
|
|
1013
1012
|
const when = opts.when || "week";
|
|
1014
|
-
let startDate;
|
|
1015
|
-
let endDate;
|
|
1016
1013
|
if (opts.date && opts.weekday) {
|
|
1017
1014
|
console.error("Use either --date or --weekday, not both.");
|
|
1018
1015
|
process.exit(1);
|
|
1019
1016
|
}
|
|
1020
1017
|
if (opts.date) {
|
|
1021
1018
|
const parsed = parseIsoDateOrExit(opts.date);
|
|
1022
|
-
|
|
1019
|
+
return {
|
|
1020
|
+
when,
|
|
1021
|
+
startDate: parsed,
|
|
1022
|
+
endDate: parsed,
|
|
1023
|
+
queryDate: parsed,
|
|
1024
|
+
outputWhen: "date",
|
|
1025
|
+
};
|
|
1023
1026
|
}
|
|
1024
|
-
|
|
1027
|
+
if (opts.weekday) {
|
|
1025
1028
|
const parsed = nextDateForWeekday(opts.weekday);
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1029
|
+
return {
|
|
1030
|
+
when,
|
|
1031
|
+
startDate: parsed,
|
|
1032
|
+
endDate: parsed,
|
|
1033
|
+
queryDate: parsed,
|
|
1034
|
+
outputWhen: "weekday",
|
|
1035
|
+
};
|
|
1030
1036
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1037
|
+
if (when === "today") {
|
|
1038
|
+
const date = todayString();
|
|
1039
|
+
return { when, startDate: date, endDate: date, outputWhen: when };
|
|
1033
1040
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1041
|
+
if (when === "tomorrow") {
|
|
1042
|
+
const date = nextSchoolDay();
|
|
1043
|
+
return { when, startDate: date, endDate: date, outputWhen: when };
|
|
1036
1044
|
}
|
|
1037
|
-
const
|
|
1045
|
+
const [startDate, endDate] = currentWeekBounds();
|
|
1046
|
+
return { when, startDate, endDate, outputWhen: when };
|
|
1047
|
+
}
|
|
1048
|
+
async function outputSchedule(client, opts) {
|
|
1049
|
+
const selection = resolveScheduleDateSelection(opts);
|
|
1050
|
+
const { when, startDate, endDate } = selection;
|
|
1051
|
+
const schedule = await client.schedule.list(selection.queryDate ? { date: selection.queryDate } : undefined);
|
|
1052
|
+
const lessons = schedule.filter((l) => l.date >= startDate && l.date <= endDate);
|
|
1038
1053
|
if (opts.json) {
|
|
1039
1054
|
const result = !opts.date && !opts.weekday && when === "week"
|
|
1040
1055
|
? { when, weekStart: startDate, weekEnd: endDate, lessons }
|
|
1041
|
-
: { when:
|
|
1056
|
+
: { when: selection.outputWhen, date: startDate, lessons };
|
|
1042
1057
|
console.log(JSON.stringify(result, null, 2));
|
|
1043
1058
|
return;
|
|
1044
1059
|
}
|
|
@@ -1673,31 +1688,25 @@ async function outputAllOverviewCommand(profile, config, command, flags, onMfa)
|
|
|
1673
1688
|
}
|
|
1674
1689
|
return;
|
|
1675
1690
|
}
|
|
1691
|
+
const scheduleSelection = command === "schedule"
|
|
1692
|
+
? resolveScheduleDateSelection(flags)
|
|
1693
|
+
: null;
|
|
1676
1694
|
const results = [];
|
|
1677
1695
|
for (const student of students) {
|
|
1678
1696
|
const client = await WilmaClient.login({ ...profile, studentNumber: student.studentNumber }, onMfa);
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
const when = flags.when || "week";
|
|
1682
|
-
let startDate, endDate;
|
|
1683
|
-
if (when === "today") {
|
|
1684
|
-
startDate = endDate = todayString();
|
|
1685
|
-
}
|
|
1686
|
-
else if (when === "tomorrow") {
|
|
1687
|
-
startDate = endDate = nextSchoolDay();
|
|
1688
|
-
}
|
|
1689
|
-
else {
|
|
1690
|
-
[startDate, endDate] = currentWeekBounds();
|
|
1691
|
-
}
|
|
1697
|
+
if (command === "schedule" && scheduleSelection) {
|
|
1698
|
+
const schedule = await client.schedule.list(scheduleSelection.queryDate ? { date: scheduleSelection.queryDate } : undefined);
|
|
1692
1699
|
results.push({
|
|
1693
1700
|
student,
|
|
1694
|
-
data:
|
|
1701
|
+
data: schedule.filter((l) => l.date >= scheduleSelection.startDate && l.date <= scheduleSelection.endDate),
|
|
1695
1702
|
});
|
|
1696
1703
|
}
|
|
1697
1704
|
else if (command === "homework") {
|
|
1705
|
+
const overview = await client.overview.get();
|
|
1698
1706
|
results.push({ student, data: overview.homework.slice(0, flags.limit ?? 10) });
|
|
1699
1707
|
}
|
|
1700
1708
|
else if (command === "grades") {
|
|
1709
|
+
const overview = await client.overview.get();
|
|
1701
1710
|
results.push({ student, data: overview.grades.slice(0, flags.limit ?? 20) });
|
|
1702
1711
|
}
|
|
1703
1712
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wilm-ai/wilma-cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,9 +8,17 @@
|
|
|
8
8
|
"wilmai": "dist/index.js",
|
|
9
9
|
"wilma": "dist/index.js"
|
|
10
10
|
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc -p tsconfig.json",
|
|
13
|
+
"lint": "echo 'add lint'",
|
|
14
|
+
"test": "echo 'add tests'",
|
|
15
|
+
"start": "node dist/index.js",
|
|
16
|
+
"prepack": "pnpm --filter @wilm-ai/wilma-client build && pnpm --filter @wilm-ai/wilma-cli build",
|
|
17
|
+
"test:live": "tsc -p tsconfig.json && node test/live.spec.mjs"
|
|
18
|
+
},
|
|
11
19
|
"dependencies": {
|
|
12
20
|
"@inquirer/prompts": "^5.3.8",
|
|
13
|
-
"@wilm-ai/wilma-client": "
|
|
21
|
+
"@wilm-ai/wilma-client": "workspace:^"
|
|
14
22
|
},
|
|
15
23
|
"devDependencies": {
|
|
16
24
|
"typescript": "^5.6.3"
|
|
@@ -21,12 +29,5 @@
|
|
|
21
29
|
],
|
|
22
30
|
"publishConfig": {
|
|
23
31
|
"access": "public"
|
|
24
|
-
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsc -p tsconfig.json",
|
|
27
|
-
"lint": "echo 'add lint'",
|
|
28
|
-
"test": "echo 'add tests'",
|
|
29
|
-
"start": "node dist/index.js",
|
|
30
|
-
"test:live": "tsc -p tsconfig.json && node test/live.spec.mjs"
|
|
31
32
|
}
|
|
32
|
-
}
|
|
33
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Wilm.ai
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|