canvaslms-cli 1.6.4 → 1.6.5

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/CHANGELOG.md CHANGED
@@ -1,221 +1,236 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [1.6.4] - 2025-12-14
9
-
10
- ### Changed
11
-
12
- - **Unified table rendering**: All commands (grades, list, assignments) now use the Table class with live resize support
13
- - **Grades command refactored**: Replaced 3 custom tables with Table class for consistent styling
14
-
15
- ### Fixed
16
-
17
- - **ESLint warnings**: Fixed `no-constant-condition` and `no-control-regex` warnings in interactive.ts
18
-
19
- ## [1.6.3] - 2025-12-14
20
-
21
- ### Added (1.6.3)
22
-
23
- - **Live table resize**: Tables re-render automatically when terminal is resized
24
- - **Adaptive truncation**: Text truncation updates dynamically based on terminal width
25
-
26
- ### Fixed (1.6.3)
27
-
28
- - **Submit table truncation**: Reduced excessive truncation in the submit table by compacting columns and shortening date format
29
- - **Table overflow**: Fixed tables overflowing terminal width on small screens
30
- - **Column width calculation**: Corrected border overhead calculation for accurate fitting
31
-
32
- ### Changed (1.6.3)
33
-
34
- - **Submit table columns**: Optimized and tightened column widths for compact display (Assignment Name max width set to 35, Type fixed at 8, Due fixed at 16 with MM/DD/YYYY formatting, Status fixed at 12)
35
-
36
- ## [1.6.2] - 2025-12-14
37
-
38
- - **Table display**: All table now have the same rounded corner format, text size adaptive to the terminal size
39
-
40
- ## [1.6.1] - 2025-12-13
41
-
42
- - **Dry Run Mode**: Submit command now supports `--dry-run` flag to test submission flow without actually uploading files or submitting assignments
43
- - **Assignment URL Display**: After successful submission, the direct link to the assignment is now displayed for easy access
44
-
45
- ## [1.6.0] - 2025-12-06
46
-
47
- ### Added (1.6.0)
48
-
49
- - **Boxed Table Displays**: All commands now display data in modern boxed tables with rounded corners (╭╮╰╯)
50
- - **Adaptive Column Widths**: Tables dynamically adjust column widths based on terminal size for optimal display
51
- - **Color-Coded Grades**: Assignment grades are now color-coded (green: ≥80%, yellow: ≥50%, red: <50%)
52
- - **Announcements Table**: Course selection and announcements list now displayed in formatted tables
53
- - **Profile Table**: User profile information displayed in clean field/value table format
54
-
55
- ### Changed (1.6.0)
56
-
57
- - **Grades Display**: Merged official grades and calculated statistics into a unified table
58
- - **CLI Descriptions**: Shortened command descriptions for cleaner help output
59
- - **Config Output**: Simplified config help by removing redundant command examples
60
- - **Submit Command**: Updated to use rounded corners and adaptive widths
61
- - **Line Endings**: Standardized all files to LF line endings
62
-
63
- ### Technical
64
-
65
- - Consistent use of box-drawing characters across all commands
66
- - Improved terminal width detection for responsive layouts
67
-
68
- ## [1.5.1] - 2025-11-05
69
-
70
- ## [1.4.7] - 2025-11-05
71
-
72
- ### Added (1.4.7)
73
-
74
- - Show allowed file extensions hint in the interactive file browser when an assignment restricts uploads (e.g. `*.pdf`, `*.docx`).
75
- - Add `r` keybinding to the file browser to reload the current directory listing without exiting the browser.
76
-
77
- - **Enhanced File Selection UX**: Implemented continuous file selection until empty input
78
- - Browse current directory with file size display
79
- - Add multiple files one by one
80
- - Remove files from selection
81
- - Show currently selected files
82
- - Smart file filtering (excludes hidden files, package files)
83
- - **Wildcard support**: Use patterns like `*.html`, `*.js`, `*.pdf` to select multiple files
84
- - File type icons for better visual identification
85
-
86
- - **Improved Grade Viewing**:
87
- - Interactive course selection for grade viewing
88
- - Assignment-level grade details with color coding
89
- - Overall course grade summary
90
- - Better grade formatting and status indicators
91
- - Support for letter grades, excused, and missing assignments
92
-
93
- ### Notes (1.4.7)
94
-
95
- - Bumped package version to 1.4.7.
96
- - Assignment-level grade details with color coding
97
- - Overall course grade summary
98
- - Better grade formatting and status indicators
99
- - Support for letter grades, excused, and missing assignments
100
-
101
- - **Enhanced Display Names**:
102
- - Show course names instead of IDs in all commands
103
- - Display assignment names prominently
104
- - Better labeling of IDs vs names throughout interface
105
-
106
- - **Interactive Utilities**:
107
- - Added validation and retry logic for user input
108
- - Confirmation helpers with default values
109
- - List selection utilities with cancel option
110
-
111
- ### Improved (1.4.7)
112
-
113
- - **Submit Command**: Complete redesign with better file selection workflow
114
- - **Grades Command**: Interactive course selection and detailed assignment grades
115
- - **Assignments Command**: Display course names prominently
116
- - **Announcements Command**: Show course names instead of IDs
117
- - **User Experience**: More consistent and intuitive interfaces across all commands
118
-
119
- ### Fixed (1.4.7)
120
-
121
- - Prevent the interactive file browser from permanently removing other stdin listeners: save and restore `process.stdin` 'data' listeners so `readline` and SIGINT (Ctrl+C) continue to work after browser exit.
122
- - Filter file browser listings by `allowed_extensions` when provided by the assignment so disallowed file types cannot be selected (prevents HTTP 400 "filetype not allowed").
123
- - Allow pressing Enter at the final "Proceed with submission? (Y/n)" prompt to accept the default (Yes) to match the shown prompt.
124
- - **Assignment Name Display**: Fixed "Unknown Assignment" issue in submission summary
125
- - **File Selection Flow**: Better error handling and user guidance during file selection
126
- - **Variable Scope**: Proper assignment variable handling throughout submission process
127
-
128
- ### Technical (1.4.7)
129
-
130
- - Enhanced interactive utilities in `lib/interactive.js`
131
- - Better error handling and user guidance
132
- - Improved code organization and modularity
133
-
134
- ## [1.1.1] - 2025-07-03
135
-
136
- ### Fixed (1.1.1)
137
-
138
- - Removed dotenv dependency that was causing module not found errors
139
- - Fixed configuration file path to use `.canvaslms-cli-config.json`
140
- - Resolved package publishing and global installation issues
141
-
142
- ### Added (1.1.1)
143
-
144
- - Dual binary support: both `canvaslms-cli` and `canvas` commands work
145
-
146
- ## [1.1.0] - 2025-07-03
147
-
148
- ### Major Changes (1.1.0)
149
-
150
- - Home directory configuration system (~/.canvaslms-cli-config.json)
151
- - Interactive configuration setup wizard (`canvas config setup`)
152
- - Configuration management subcommands:
153
- - `canvas config show` - Display current configuration
154
- - `canvas config edit` - Edit existing configuration
155
- - `canvas config path` - Show config file location
156
- - `canvas config delete` - Remove configuration file
157
- - Automatic configuration validation for all commands
158
- - Improved error handling and user guidance
159
-
160
- ### Changed (1.1.0)
161
-
162
- - **BREAKING**: Removed environment variable support (.env files)
163
- - Configuration now stored in user's home directory instead of project directory
164
- - Enhanced configuration validation with better error messages
165
- - Improved user onboarding with guided setup process
166
-
167
- ### Removed (1.1.0)
168
-
169
- - dotenv dependency (no longer needed)
170
- - Environment variable fallback support
171
-
172
- ## [1.0.0] - 2025-07-03
173
-
174
- ### Added (1.0.0)
175
-
176
- - Initial release of Canvas CLI Tool
177
- - Modular architecture with separate command handlers
178
- - Interactive assignment submission with file upload
179
- - Course management (list starred/all courses)
180
- - Assignment operations (view, filter by status)
181
- - Grade viewing for all courses or specific course
182
- - Announcements viewing
183
- - User profile management
184
- - Raw API access for all HTTP methods (GET, POST, PUT, DELETE)
185
- - Comprehensive configuration management
186
- - Color-coded output for better readability
187
- - Support for multiple file uploads
188
- - File selection from current directory
189
- - Detailed verbose modes for all commands
190
-
191
- ### Features (1.0.0)
192
-
193
- - 📚 Course listing with favorites support
194
- - 📝 Assignment management with status indicators
195
- - 🚀 Interactive file submission workflow
196
- - 📢 Announcement viewing
197
- - 👤 Profile information display
198
- - 🔧 Direct Canvas API access
199
- - Command aliases for faster usage
200
- - 🎨 Color-coded grade display
201
- - 📁 Smart file selection interface
202
-
203
- ### Technical (1.0.0)
204
-
205
- - Modular command structure in separate files
206
- - Reusable API client library
207
- - Interactive prompt utilities
208
- - File upload handling with progress indicators
209
- - Error handling and user-friendly messages
210
- - Cross-platform compatibility
211
-
212
- ## [Unreleased]
213
-
214
- ### Planned Features (Unreleased)
215
-
216
- - Assignment creation and editing
217
- - Bulk operations
218
- - Plugin system
219
- - Advanced filtering options
220
- - Export functionality
221
- - Offline mode support
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.6.5] - 2025-12-15
9
+
10
+ ### Removed (1.6.5)
11
+
12
+ - **Unused Command File**: Deleted `api.ts` - Raw API command handler that was never imported or used in the CLI
13
+ - **Unused Functions from interactive.ts**: `getSubfoldersRecursive()`, `getFilesMatchingWildcard()`, `selectFilesImproved()`
14
+ - **Unused Dependencies**: Removed `adm-zip` and `@types/adm-zip` packages
15
+
16
+ ## [1.6.4-fix] - 2025-12-15
17
+
18
+ ### Fix (1.6.4)
19
+
20
+ - **Remove Postinstall Command**: Change to prepare husky
21
+
22
+ ## [1.6.4] - 2025-12-15
23
+
24
+ ### Added (1.6.4)
25
+
26
+ - **Modules Command**: New `modules` command to view course modules and their items with progress tracking
27
+ - **Calendar Command**: New `calendar` command to view upcoming assignments and events with due dates
28
+
29
+ ### Changed (1.6.4)
30
+
31
+ - **Course Arguments**: Replaced course ID arguments with course name arguments across all commands (assignments, grades, announcements) for easier usage
32
+ - **Workflow Name**: Changed CI workflow name from "CI" to "Test & Build" for better clarity
33
+
34
+ ## [1.6.3] - 2025-12-14
35
+
36
+ ### Added (1.6.3)
37
+
38
+ - **Live table resize**: Tables re-render automatically when terminal is resized
39
+ - **Adaptive truncation**: Text truncation updates dynamically based on terminal width
40
+
41
+ ### Fixed (1.6.3)
42
+
43
+ - **Submit table truncation**: Reduced excessive truncation in the submit table by compacting columns and shortening date format
44
+ - **Table overflow**: Fixed tables overflowing terminal width on small screens
45
+ - **Column width calculation**: Corrected border overhead calculation for accurate fitting
46
+
47
+ ### Changed (1.6.3)
48
+
49
+ - **Submit table columns**: Optimized and tightened column widths for compact display (Assignment Name max width set to 35, Type fixed at 8, Due fixed at 16 with MM/DD/YYYY formatting, Status fixed at 12)
50
+
51
+ ## [1.6.2] - 2025-12-14
52
+
53
+ - **Table display**: All table now have the same rounded corner format, text size adaptive to the terminal size
54
+
55
+ ## [1.6.1] - 2025-12-13
56
+
57
+ - **Dry Run Mode**: Submit command now supports `--dry-run` flag to test submission flow without actually uploading files or submitting assignments
58
+ - **Assignment URL Display**: After successful submission, the direct link to the assignment is now displayed for easy access
59
+
60
+ ## [1.6.0] - 2025-12-06
61
+
62
+ ### Added (1.6.0)
63
+
64
+ - **Boxed Table Displays**: All commands now display data in modern boxed tables with rounded corners (╭╮╰╯)
65
+ - **Adaptive Column Widths**: Tables dynamically adjust column widths based on terminal size for optimal display
66
+ - **Color-Coded Grades**: Assignment grades are now color-coded (green: ≥80%, yellow: ≥50%, red: <50%)
67
+ - **Announcements Table**: Course selection and announcements list now displayed in formatted tables
68
+ - **Profile Table**: User profile information displayed in clean field/value table format
69
+
70
+ ### Changed (1.6.0)
71
+
72
+ - **Grades Display**: Merged official grades and calculated statistics into a unified table
73
+ - **CLI Descriptions**: Shortened command descriptions for cleaner help output
74
+ - **Config Output**: Simplified config help by removing redundant command examples
75
+ - **Submit Command**: Updated to use rounded corners and adaptive widths
76
+ - **Line Endings**: Standardized all files to LF line endings
77
+
78
+ ### Technical
79
+
80
+ - Consistent use of box-drawing characters across all commands
81
+ - Improved terminal width detection for responsive layouts
82
+
83
+ ## [1.5.1] - 2025-11-05
84
+
85
+ ## [1.4.7] - 2025-11-05
86
+
87
+ ### Added (1.4.7)
88
+
89
+ - Show allowed file extensions hint in the interactive file browser when an assignment restricts uploads (e.g. `*.pdf`, `*.docx`).
90
+ - Add `r` keybinding to the file browser to reload the current directory listing without exiting the browser.
91
+
92
+ - **Enhanced File Selection UX**: Implemented continuous file selection until empty input
93
+ - Browse current directory with file size display
94
+ - Add multiple files one by one
95
+ - Remove files from selection
96
+ - Show currently selected files
97
+ - Smart file filtering (excludes hidden files, package files)
98
+ - **Wildcard support**: Use patterns like `*.html`, `*.js`, `*.pdf` to select multiple files
99
+ - File type icons for better visual identification
100
+
101
+ - **Improved Grade Viewing**:
102
+ - Interactive course selection for grade viewing
103
+ - Assignment-level grade details with color coding
104
+ - Overall course grade summary
105
+ - Better grade formatting and status indicators
106
+ - Support for letter grades, excused, and missing assignments
107
+
108
+ ### Notes (1.4.7)
109
+
110
+ - Bumped package version to 1.4.7.
111
+ - Assignment-level grade details with color coding
112
+ - Overall course grade summary
113
+ - Better grade formatting and status indicators
114
+ - Support for letter grades, excused, and missing assignments
115
+
116
+ - **Enhanced Display Names**:
117
+ - Show course names instead of IDs in all commands
118
+ - Display assignment names prominently
119
+ - Better labeling of IDs vs names throughout interface
120
+
121
+ - **Interactive Utilities**:
122
+ - Added validation and retry logic for user input
123
+ - Confirmation helpers with default values
124
+ - List selection utilities with cancel option
125
+
126
+ ### Improved (1.4.7)
127
+
128
+ - **Submit Command**: Complete redesign with better file selection workflow
129
+ - **Grades Command**: Interactive course selection and detailed assignment grades
130
+ - **Assignments Command**: Display course names prominently
131
+ - **Announcements Command**: Show course names instead of IDs
132
+ - **User Experience**: More consistent and intuitive interfaces across all commands
133
+
134
+ ### Fixed (1.4.7)
135
+
136
+ - Prevent the interactive file browser from permanently removing other stdin listeners: save and restore `process.stdin` 'data' listeners so `readline` and SIGINT (Ctrl+C) continue to work after browser exit.
137
+ - Filter file browser listings by `allowed_extensions` when provided by the assignment so disallowed file types cannot be selected (prevents HTTP 400 "filetype not allowed").
138
+ - Allow pressing Enter at the final "Proceed with submission? (Y/n)" prompt to accept the default (Yes) to match the shown prompt.
139
+ - **Assignment Name Display**: Fixed "Unknown Assignment" issue in submission summary
140
+ - **File Selection Flow**: Better error handling and user guidance during file selection
141
+ - **Variable Scope**: Proper assignment variable handling throughout submission process
142
+
143
+ ### Technical (1.4.7)
144
+
145
+ - Enhanced interactive utilities in `lib/interactive.js`
146
+ - Better error handling and user guidance
147
+ - Improved code organization and modularity
148
+
149
+ ## [1.1.1] - 2025-07-03
150
+
151
+ ### Fixed (1.1.1)
152
+
153
+ - Removed dotenv dependency that was causing module not found errors
154
+ - Fixed configuration file path to use `.canvaslms-cli-config.json`
155
+ - Resolved package publishing and global installation issues
156
+
157
+ ### Added (1.1.1)
158
+
159
+ - Dual binary support: both `canvaslms-cli` and `canvas` commands work
160
+
161
+ ## [1.1.0] - 2025-07-03
162
+
163
+ ### Major Changes (1.1.0)
164
+
165
+ - Home directory configuration system (~/.canvaslms-cli-config.json)
166
+ - Interactive configuration setup wizard (`canvas config setup`)
167
+ - Configuration management subcommands:
168
+ - `canvas config show` - Display current configuration
169
+ - `canvas config edit` - Edit existing configuration
170
+ - `canvas config path` - Show config file location
171
+ - `canvas config delete` - Remove configuration file
172
+ - Automatic configuration validation for all commands
173
+ - Improved error handling and user guidance
174
+
175
+ ### Changed (1.1.0)
176
+
177
+ - **BREAKING**: Removed environment variable support (.env files)
178
+ - Configuration now stored in user's home directory instead of project directory
179
+ - Enhanced configuration validation with better error messages
180
+ - Improved user onboarding with guided setup process
181
+
182
+ ### Removed (1.1.0)
183
+
184
+ - dotenv dependency (no longer needed)
185
+ - Environment variable fallback support
186
+
187
+ ## [1.0.0] - 2025-07-03
188
+
189
+ ### Added (1.0.0)
190
+
191
+ - Initial release of Canvas CLI Tool
192
+ - Modular architecture with separate command handlers
193
+ - Interactive assignment submission with file upload
194
+ - Course management (list starred/all courses)
195
+ - Assignment operations (view, filter by status)
196
+ - Grade viewing for all courses or specific course
197
+ - Announcements viewing
198
+ - User profile management
199
+ - Raw API access for all HTTP methods (GET, POST, PUT, DELETE)
200
+ - Comprehensive configuration management
201
+ - Color-coded output for better readability
202
+ - Support for multiple file uploads
203
+ - File selection from current directory
204
+ - Detailed verbose modes for all commands
205
+
206
+ ### Features (1.0.0)
207
+
208
+ - 📚 Course listing with favorites support
209
+ - 📝 Assignment management with status indicators
210
+ - 🚀 Interactive file submission workflow
211
+ - 📢 Announcement viewing
212
+ - 👤 Profile information display
213
+ - 🔧 Direct Canvas API access
214
+ - Command aliases for faster usage
215
+ - 🎨 Color-coded grade display
216
+ - 📁 Smart file selection interface
217
+
218
+ ### Technical (1.0.0)
219
+
220
+ - Modular command structure in separate files
221
+ - Reusable API client library
222
+ - Interactive prompt utilities
223
+ - File upload handling with progress indicators
224
+ - Error handling and user-friendly messages
225
+ - Cross-platform compatibility
226
+
227
+ ## [Unreleased]
228
+
229
+ ### Planned Features (Unreleased)
230
+
231
+ - Assignment creation and editing
232
+ - Bulk operations
233
+ - Plugin system
234
+ - Advanced filtering options
235
+ - Export functionality
236
+ - Offline mode support
@@ -0,0 +1,7 @@
1
+ export interface CalendarOptions {
2
+ days?: string;
3
+ all?: boolean;
4
+ past?: boolean;
5
+ }
6
+ export declare function showCalendar(options?: CalendarOptions): Promise<void>;
7
+ //# sourceMappingURL=calendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../commands/calendar.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA8CD,wBAAsB,YAAY,CAChC,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC,CA+If"}
@@ -0,0 +1,150 @@
1
+ import { makeCanvasRequest } from "../lib/api-client.js";
2
+ import { Table, printInfo, printError, printSuccess } from "../lib/display.js";
3
+ import chalk from "chalk";
4
+ function formatTimeRemaining(dueDate) {
5
+ const now = new Date();
6
+ const diff = dueDate.getTime() - now.getTime();
7
+ const days = Math.floor(diff / (1000 * 60 * 60 * 24));
8
+ const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
9
+ if (diff < 0) {
10
+ const pastDays = Math.abs(days);
11
+ if (pastDays === 0)
12
+ return { text: "Today", color: chalk.red };
13
+ if (pastDays === 1)
14
+ return { text: "1d ago", color: chalk.red };
15
+ return { text: `${pastDays}d ago`, color: chalk.red };
16
+ }
17
+ if (days === 0) {
18
+ if (hours <= 1)
19
+ return { text: "< 1 hour", color: chalk.red };
20
+ return { text: `${hours} hours`, color: chalk.red };
21
+ }
22
+ if (days === 1)
23
+ return { text: "Tomorrow", color: chalk.yellow };
24
+ if (days <= 3)
25
+ return { text: `${days} days`, color: chalk.yellow };
26
+ if (days <= 7)
27
+ return { text: `${days} days`, color: chalk.cyan };
28
+ return { text: `${days} days`, color: chalk.green };
29
+ }
30
+ function formatDueDate(date) {
31
+ const month = (date.getMonth() + 1).toString().padStart(2, "0");
32
+ const day = date.getDate().toString().padStart(2, "0");
33
+ const hours = date.getHours().toString().padStart(2, "0");
34
+ const mins = date.getMinutes().toString().padStart(2, "0");
35
+ return `${month}/${day} ${hours}:${mins}`;
36
+ }
37
+ export async function showCalendar(options = {}) {
38
+ try {
39
+ const days = parseInt(options.days || "14", 10);
40
+ const showPast = options.past || false;
41
+ printInfo("\n" + "-".repeat(60));
42
+ printInfo("Loading upcoming due dates...");
43
+ const queryParams = ["enrollment_state=active", "include[]=favorites"];
44
+ const courses = await makeCanvasRequest("get", "courses", queryParams);
45
+ if (!courses || courses.length === 0) {
46
+ printError("No courses found.");
47
+ return;
48
+ }
49
+ let targetCourses = courses;
50
+ if (!options.all) {
51
+ const starred = courses.filter((c) => c.is_favorite);
52
+ if (starred.length > 0) {
53
+ targetCourses = starred;
54
+ }
55
+ }
56
+ const now = new Date();
57
+ const futureDate = new Date(now.getTime() + days * 24 * 60 * 60 * 1000);
58
+ const pastDate = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
59
+ const assignmentPromises = targetCourses.map(async (course) => {
60
+ try {
61
+ const assignments = await makeCanvasRequest("get", `courses/${course.id}/assignments`, ["include[]=submission", "per_page=100"]);
62
+ return { course, assignments: assignments || [] };
63
+ }
64
+ catch {
65
+ return { course, assignments: [] };
66
+ }
67
+ });
68
+ const results = await Promise.all(assignmentPromises);
69
+ const dueItems = [];
70
+ for (const { course, assignments } of results) {
71
+ for (const assignment of assignments) {
72
+ if (!assignment.due_at)
73
+ continue;
74
+ const dueAt = new Date(assignment.due_at);
75
+ const submission = assignment.submission;
76
+ const isSubmitted = !!(submission && submission.submitted_at);
77
+ if (showPast) {
78
+ if (dueAt < pastDate || dueAt > futureDate)
79
+ continue;
80
+ }
81
+ else {
82
+ if (dueAt < now || dueAt > futureDate)
83
+ continue;
84
+ }
85
+ dueItems.push({
86
+ courseName: course.name,
87
+ courseId: course.id,
88
+ assignmentName: assignment.name,
89
+ assignmentId: assignment.id,
90
+ dueAt,
91
+ submitted: isSubmitted,
92
+ pointsPossible: assignment.points_possible || 0,
93
+ });
94
+ }
95
+ }
96
+ dueItems.sort((a, b) => a.dueAt.getTime() - b.dueAt.getTime());
97
+ if (dueItems.length === 0) {
98
+ console.log(chalk.yellow(`\nNo upcoming assignments due in the next ${days} days.`));
99
+ if (!options.all) {
100
+ console.log(chalk.gray("Tip: Use --all to include all courses."));
101
+ }
102
+ return;
103
+ }
104
+ const courseLabel = options.all ? "all courses" : "starred courses";
105
+ console.log(chalk.cyan.bold(`\nUpcoming Due Dates (${courseLabel}, next ${days} days)`));
106
+ printSuccess(`Found ${dueItems.length} upcoming assignment(s).`);
107
+ const table = new Table([
108
+ { key: "course", header: "Course", flex: 1, minWidth: 10 },
109
+ { key: "assignment", header: "Assignment", flex: 1, minWidth: 15 },
110
+ { key: "due", header: "Due", width: 12 },
111
+ {
112
+ key: "remaining",
113
+ header: "Remaining",
114
+ width: 10,
115
+ color: (value, row) => {
116
+ const colorFn = row._remainingColor;
117
+ return colorFn ? colorFn(value) : chalk.white(value);
118
+ },
119
+ },
120
+ {
121
+ key: "status",
122
+ header: "Status",
123
+ width: 8,
124
+ color: (value, row) => row._submitted ? chalk.green(value) : chalk.yellow(value),
125
+ },
126
+ ], { showRowNumbers: true });
127
+ for (const item of dueItems) {
128
+ const remaining = formatTimeRemaining(item.dueAt);
129
+ table.addRow({
130
+ course: item.courseName,
131
+ assignment: item.assignmentName,
132
+ due: formatDueDate(item.dueAt),
133
+ remaining: remaining.text,
134
+ status: item.submitted ? "Done" : "Pending",
135
+ _submitted: item.submitted,
136
+ _remainingColor: remaining.color,
137
+ });
138
+ }
139
+ table.renderWithResize();
140
+ const pending = dueItems.filter((d) => !d.submitted).length;
141
+ const done = dueItems.filter((d) => d.submitted).length;
142
+ console.log(chalk.gray(`\n ${pending} pending, ${done} submitted`));
143
+ }
144
+ catch (error) {
145
+ const errorMessage = error instanceof Error ? error.message : String(error);
146
+ console.error(chalk.red("Error fetching calendar:"), errorMessage);
147
+ process.exit(1);
148
+ }
149
+ }
150
+ //# sourceMappingURL=calendar.js.map