canvaslms-cli 1.1.0 → 1.1.1
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/lib/config.js +7 -22
- package/package.json +2 -1
- package/src/index.js +1 -1
package/lib/config.js
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const os = require('os');
|
|
8
|
-
require('dotenv').config();
|
|
9
8
|
|
|
10
9
|
// Configuration file path in user's home directory
|
|
11
|
-
const CONFIG_FILE = path.join(os.homedir(), '.
|
|
10
|
+
const CONFIG_FILE = path.join(os.homedir(), '.canvaslms-cli-config.json');
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Get default configuration structure
|
|
@@ -23,11 +22,11 @@ function getDefaultConfig() {
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
|
-
* Load configuration from file
|
|
25
|
+
* Load configuration from file
|
|
27
26
|
*/
|
|
28
27
|
function loadConfig() {
|
|
29
28
|
try {
|
|
30
|
-
//
|
|
29
|
+
// Load from config file
|
|
31
30
|
if (fs.existsSync(CONFIG_FILE)) {
|
|
32
31
|
const configData = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
33
32
|
if (configData.domain && configData.token) {
|
|
@@ -37,24 +36,10 @@ function loadConfig() {
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (!domain || !token) {
|
|
45
|
-
console.error('❌ No Canvas configuration found!');
|
|
46
|
-
console.error('\nPlease run "canvas config setup" to configure your Canvas credentials.');
|
|
47
|
-
console.error('Or set environment variables:');
|
|
48
|
-
console.error(' CANVAS_DOMAIN=your-canvas-domain.instructure.com');
|
|
49
|
-
console.error(' CANVAS_API_TOKEN=your-api-token');
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Clean up domain - remove https:// and trailing slashes
|
|
54
|
-
domain = domain.replace(/^https?:\/\//, '').replace(/\/$/, '');
|
|
55
|
-
|
|
56
|
-
return { domain, token };
|
|
57
|
-
} catch (error) {
|
|
39
|
+
// No configuration found
|
|
40
|
+
console.error('❌ No Canvas configuration found!');
|
|
41
|
+
console.error('\nPlease run "canvas config setup" to configure your Canvas credentials.');
|
|
42
|
+
process.exit(1); } catch (error) {
|
|
58
43
|
console.error(`❌ Error loading configuration: ${error.message}`);
|
|
59
44
|
process.exit(1);
|
|
60
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canvaslms-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A command line tool for interacting with Canvas LMS API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"canvas",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"type": "commonjs",
|
|
28
28
|
"main": "src/index.js",
|
|
29
29
|
"bin": {
|
|
30
|
+
"canvaslms-cli": "src/index.js",
|
|
30
31
|
"canvas": "src/index.js"
|
|
31
32
|
},
|
|
32
33
|
"files": [
|