canvaslms-cli 1.3.0 ā 1.3.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/commands/submit.js +0 -121
- package/package.json +1 -1
- package/src/index.js +1 -1
package/commands/submit.js
CHANGED
|
@@ -380,127 +380,6 @@ async function selectSingleFileFromList(rl, files) {
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
async function selectFilesImproved(rl) {
|
|
384
|
-
console.log('š Enhanced File Selection');
|
|
385
|
-
console.log('Choose files by entering their paths or browse current directory');
|
|
386
|
-
console.log('Press Enter with no input when done selecting files.\n');
|
|
387
|
-
|
|
388
|
-
const allFiles = [];
|
|
389
|
-
let fileIndex = 1;
|
|
390
|
-
|
|
391
|
-
while (true) {
|
|
392
|
-
console.log(`\nš File ${fileIndex} selection:`);
|
|
393
|
-
console.log('1. Enter file path directly');
|
|
394
|
-
console.log('2. Browse current directory');
|
|
395
|
-
console.log('3. Show currently selected files');
|
|
396
|
-
console.log('(Press Enter with no input to finish selection)');
|
|
397
|
-
|
|
398
|
-
const choice = await askQuestion(rl, '\nChoose option (1-3 or Enter to finish): ');
|
|
399
|
-
|
|
400
|
-
// Empty input means we're done selecting files
|
|
401
|
-
if (choice.trim() === '') {
|
|
402
|
-
if (allFiles.length === 0) {
|
|
403
|
-
console.log('ā ļø No files selected. Please select at least one file.');
|
|
404
|
-
continue;
|
|
405
|
-
}
|
|
406
|
-
break;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (choice === '1') {
|
|
410
|
-
// Direct file path entry
|
|
411
|
-
const filePath = await askQuestion(rl, 'Enter file path: ');
|
|
412
|
-
if (filePath.trim() !== '') {
|
|
413
|
-
if (fs.existsSync(filePath.trim())) {
|
|
414
|
-
if (!allFiles.includes(filePath.trim())) {
|
|
415
|
-
allFiles.push(filePath.trim());
|
|
416
|
-
const stats = fs.statSync(filePath.trim());
|
|
417
|
-
const size = (stats.size / 1024).toFixed(1) + ' KB';
|
|
418
|
-
console.log(`ā
Added: ${path.basename(filePath.trim())} (${size})`);
|
|
419
|
-
fileIndex++;
|
|
420
|
-
} else {
|
|
421
|
-
console.log('ā ļø File already selected.');
|
|
422
|
-
}
|
|
423
|
-
} else {
|
|
424
|
-
console.log('ā File not found. Please check the path.');
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
} else if (choice === '2') {
|
|
428
|
-
// Browse current directory
|
|
429
|
-
try {
|
|
430
|
-
const files = fs.readdirSync('.').filter(file => {
|
|
431
|
-
const stats = fs.statSync(file);
|
|
432
|
-
return stats.isFile() &&
|
|
433
|
-
!file.startsWith('.') &&
|
|
434
|
-
!['package.json', 'package-lock.json', 'node_modules'].includes(file);
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
if (files.length === 0) {
|
|
438
|
-
console.log('No suitable files found in current directory.');
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
console.log('\nš Files in current directory:');
|
|
443
|
-
files.forEach((file, index) => {
|
|
444
|
-
const stats = fs.statSync(file);
|
|
445
|
-
const size = (stats.size / 1024).toFixed(1) + ' KB';
|
|
446
|
-
const alreadySelected = allFiles.includes(file) ? ' ā
' : '';
|
|
447
|
-
console.log(`${index + 1}. ${file} (${size})${alreadySelected}`);
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
const fileChoice = await askQuestion(rl, '\nEnter file number (or Enter to go back): ');
|
|
451
|
-
if (fileChoice.trim() !== '') {
|
|
452
|
-
const fileIdx = parseInt(fileChoice) - 1;
|
|
453
|
-
if (fileIdx >= 0 && fileIdx < files.length) {
|
|
454
|
-
const selectedFile = files[fileIdx];
|
|
455
|
-
if (!allFiles.includes(selectedFile)) {
|
|
456
|
-
allFiles.push(selectedFile);
|
|
457
|
-
const stats = fs.statSync(selectedFile);
|
|
458
|
-
const size = (stats.size / 1024).toFixed(1) + ' KB';
|
|
459
|
-
console.log(`ā
Added: ${selectedFile} (${size})`);
|
|
460
|
-
fileIndex++;
|
|
461
|
-
} else {
|
|
462
|
-
console.log('ā ļø File already selected.');
|
|
463
|
-
}
|
|
464
|
-
} else {
|
|
465
|
-
console.log('ā Invalid file number.');
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
} catch (error) {
|
|
469
|
-
console.log('ā Error reading directory:', error.message);
|
|
470
|
-
}
|
|
471
|
-
} else if (choice === '3') {
|
|
472
|
-
// Show currently selected files
|
|
473
|
-
if (allFiles.length === 0) {
|
|
474
|
-
console.log('š No files selected yet.');
|
|
475
|
-
} else {
|
|
476
|
-
console.log(`\nš Currently selected files (${allFiles.length}):`);
|
|
477
|
-
allFiles.forEach((file, index) => {
|
|
478
|
-
const stats = fs.existsSync(file) ? fs.statSync(file) : null;
|
|
479
|
-
const size = stats ? (stats.size / 1024).toFixed(1) + ' KB' : 'File not found';
|
|
480
|
-
console.log(` ${index + 1}. ${path.basename(file)} (${size})`);
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
const removeFile = await askQuestion(rl, '\nRemove a file? Enter number or press Enter to continue: ');
|
|
484
|
-
if (removeFile.trim() !== '') {
|
|
485
|
-
const removeIdx = parseInt(removeFile) - 1;
|
|
486
|
-
if (removeIdx >= 0 && removeIdx < allFiles.length) {
|
|
487
|
-
const removedFile = allFiles.splice(removeIdx, 1)[0];
|
|
488
|
-
console.log(`šļø Removed: ${path.basename(removedFile)}`);
|
|
489
|
-
fileIndex--;
|
|
490
|
-
} else {
|
|
491
|
-
console.log('ā Invalid file number.');
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
} else {
|
|
496
|
-
console.log('ā Invalid option. Please choose 1, 2, 3, or press Enter to finish.');
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
console.log(`\nā
File selection complete! Selected ${allFiles.length} file(s).`);
|
|
501
|
-
return allFiles;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
383
|
module.exports = {
|
|
505
384
|
submitAssignment
|
|
506
385
|
};
|
package/package.json
CHANGED