@wilm-ai/wilma-cli 1.6.1 → 1.6.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.
Files changed (2) hide show
  1. package/dist/index.js +22 -9
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1777,28 +1777,41 @@ function formatContent(value) {
1777
1777
  }
1778
1778
  async function getStudentsForCommand(profile, config) {
1779
1779
  const stored = config.profiles.find((p) => p.id === config.lastProfileId);
1780
- const fresh = await WilmaClient.listStudents(profile);
1781
- if (stored) {
1780
+ const fresh = await WilmaClient.listStudents({ ...profile, studentNumber: null });
1781
+ if (stored && fresh.length > 0) {
1782
1782
  stored.students = fresh.map((s) => ({ studentNumber: s.studentNumber, name: s.name }));
1783
1783
  await saveConfig(config);
1784
1784
  }
1785
- return fresh;
1785
+ if (fresh.length > 0) {
1786
+ return fresh;
1787
+ }
1788
+ return (stored?.students ?? []).map((student) => ({
1789
+ ...student,
1790
+ href: `/!${student.studentNumber}/`,
1791
+ }));
1786
1792
  }
1787
1793
  async function resolveStudentForFlags(profile, config, student) {
1788
1794
  if (student) {
1795
+ const normalized = student.trim();
1796
+ if (/^\d+$/.test(normalized)) {
1797
+ const stored = config.profiles.find((p) => p.id === config.lastProfileId);
1798
+ const cached = stored?.students?.find((item) => item.studentNumber === normalized);
1799
+ return {
1800
+ studentNumber: normalized,
1801
+ name: cached?.name ?? normalized,
1802
+ href: `/!${normalized}/`,
1803
+ };
1804
+ }
1789
1805
  const students = await getStudentsForCommand(profile, config);
1790
- const exact = students.find((s) => s.studentNumber === student);
1791
- if (exact)
1792
- return exact;
1793
- const needle = student.toLowerCase();
1806
+ const needle = normalized.toLowerCase();
1794
1807
  const substring = students.find((s) => s.name.toLowerCase().includes(needle));
1795
1808
  if (substring)
1796
1809
  return substring;
1797
- const match = students.find((s) => fuzzyIncludes(s.name, student));
1810
+ const match = students.find((s) => fuzzyIncludes(s.name, normalized));
1798
1811
  if (match)
1799
1812
  return match;
1800
1813
  // No match found - show available students and exit
1801
- console.error(`Error: No student matching "${student}" found.`);
1814
+ console.error(`Error: No student matching "${normalized}" found.`);
1802
1815
  if (students.length > 0) {
1803
1816
  console.error("Available students:");
1804
1817
  students.forEach((s) => console.error(` ${s.studentNumber} ${s.name}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wilm-ai/wilma-cli",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@inquirer/prompts": "^5.3.8",
21
- "@wilm-ai/wilma-client": "^1.5.1"
21
+ "@wilm-ai/wilma-client": "^1.5.2"
22
22
  },
23
23
  "devDependencies": {
24
24
  "typescript": "^5.6.3"