d-drive-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/README.md +0 -22
- package/dist/commands/config.js +6 -3
- package/package.json +1 -1
- package/src/commands/config.ts +8 -4
package/README.md
CHANGED
|
@@ -4,32 +4,10 @@ Command-line tool for D-Drive cloud storage.
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
### Option 1: NPM (Coming Soon)
|
|
8
7
|
```bash
|
|
9
8
|
npm install -g d-drive-cli
|
|
10
9
|
```
|
|
11
10
|
|
|
12
|
-
### Option 2: Local Installation (Current)
|
|
13
|
-
```bash
|
|
14
|
-
# Clone the repository
|
|
15
|
-
git clone https://github.com/jasonzli-DEV/D-Drive.git
|
|
16
|
-
cd D-Drive/cli
|
|
17
|
-
|
|
18
|
-
# Build and install globally
|
|
19
|
-
npm install
|
|
20
|
-
npm run build
|
|
21
|
-
npm install -g .
|
|
22
|
-
|
|
23
|
-
# Verify installation
|
|
24
|
-
d-drive --version
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Option 3: Direct from Repository
|
|
28
|
-
```bash
|
|
29
|
-
# Install directly from GitHub (once published)
|
|
30
|
-
npm install -g jasonzli-DEV/D-Drive/cli
|
|
31
|
-
```
|
|
32
|
-
|
|
33
11
|
## Configuration
|
|
34
12
|
|
|
35
13
|
First, configure your API key:
|
package/dist/commands/config.js
CHANGED
|
@@ -20,17 +20,20 @@ async function configCommand(options) {
|
|
|
20
20
|
if (options.key) {
|
|
21
21
|
const spinner = (0, ora_1.default)('Validating API key...').start();
|
|
22
22
|
try {
|
|
23
|
-
//
|
|
23
|
+
// Normalize and test the API key by calling the /auth/me endpoint
|
|
24
24
|
const config = (0, config_1.getConfig)();
|
|
25
25
|
const apiUrl = options.url || config.apiUrl || 'http://localhost:5000/api';
|
|
26
|
+
// Accept keys entered with or without the `dd_` prefix, and strip any accidental "Bearer " prefix
|
|
27
|
+
const rawKey = options.key.replace(/^Bearer\s+/i, '').trim();
|
|
28
|
+
const normalizedKey = rawKey.startsWith('dd_') ? rawKey : `dd_${rawKey}`;
|
|
26
29
|
const response = await axios_1.default.get(`${apiUrl}/auth/me`, {
|
|
27
30
|
headers: {
|
|
28
|
-
Authorization: `Bearer ${
|
|
31
|
+
Authorization: `Bearer ${normalizedKey}`,
|
|
29
32
|
},
|
|
30
33
|
timeout: 10000,
|
|
31
34
|
});
|
|
32
35
|
if (response.status === 200 && response.data) {
|
|
33
|
-
(0, config_1.setConfig)('apiKey',
|
|
36
|
+
(0, config_1.setConfig)('apiKey', normalizedKey);
|
|
34
37
|
if (options.url) {
|
|
35
38
|
(0, config_1.setConfig)('apiUrl', options.url);
|
|
36
39
|
}
|
package/package.json
CHANGED
package/src/commands/config.ts
CHANGED
|
@@ -23,19 +23,23 @@ export async function configCommand(options: ConfigOptions) {
|
|
|
23
23
|
const spinner = ora('Validating API key...').start();
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
|
-
//
|
|
26
|
+
// Normalize and test the API key by calling the /auth/me endpoint
|
|
27
27
|
const config = getConfig();
|
|
28
28
|
const apiUrl = options.url || config.apiUrl || 'http://localhost:5000/api';
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
// Accept keys entered with or without the `dd_` prefix, and strip any accidental "Bearer " prefix
|
|
31
|
+
const rawKey = options.key.replace(/^Bearer\s+/i, '').trim();
|
|
32
|
+
const normalizedKey = rawKey.startsWith('dd_') ? rawKey : `dd_${rawKey}`;
|
|
33
|
+
|
|
30
34
|
const response = await axios.get(`${apiUrl}/auth/me`, {
|
|
31
35
|
headers: {
|
|
32
|
-
Authorization: `Bearer ${
|
|
36
|
+
Authorization: `Bearer ${normalizedKey}`,
|
|
33
37
|
},
|
|
34
38
|
timeout: 10000,
|
|
35
39
|
});
|
|
36
40
|
|
|
37
41
|
if (response.status === 200 && response.data) {
|
|
38
|
-
setConfig('apiKey',
|
|
42
|
+
setConfig('apiKey', normalizedKey);
|
|
39
43
|
if (options.url) {
|
|
40
44
|
setConfig('apiUrl', options.url);
|
|
41
45
|
}
|