aethel 0.3.0 → 0.3.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/CHANGELOG.md +4 -0
- package/README.md +31 -7
- package/package.json +1 -1
- package/src/core/auth.js +17 -5
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -33,14 +33,38 @@ npm run install:cli # symlinks `aethel` into ~/.local/bin
|
|
|
33
33
|
|
|
34
34
|
## Setup
|
|
35
35
|
|
|
36
|
-
1.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
### 1. Get Google OAuth Credentials
|
|
37
|
+
|
|
38
|
+
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
|
|
39
|
+
2. Create a project (or select an existing one)
|
|
40
|
+
3. Enable the **Google Drive API** (APIs & Services → Library)
|
|
41
|
+
4. Go to **APIs & Services → Credentials**
|
|
42
|
+
5. Click **Create Credentials → OAuth 2.0 Client ID**
|
|
43
|
+
6. Application type: **Desktop application**
|
|
44
|
+
7. Download the JSON file
|
|
45
|
+
|
|
46
|
+
### 2. Save Credentials
|
|
47
|
+
|
|
48
|
+
Save the downloaded JSON as `~/.config/aethel/credentials.json`:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
mkdir -p ~/.config/aethel
|
|
52
|
+
mv ~/Downloads/client_secret_*.json ~/.config/aethel/credentials.json
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
You can also place `credentials.json` in the current directory, or pass a custom path with `--credentials`.
|
|
56
|
+
|
|
57
|
+
### 3. Authenticate
|
|
40
58
|
|
|
41
59
|
```bash
|
|
42
60
|
aethel auth # opens browser, saves token.json
|
|
43
|
-
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 4. Initialize a Workspace
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
aethel init --local-path ./my-drive # sync entire My Drive
|
|
67
|
+
aethel init --local-path ./workspace --drive-folder <folder-id> # sync specific folder
|
|
44
68
|
```
|
|
45
69
|
|
|
46
70
|
> `credentials.json` and `token.json` are local secrets — never commit them.
|
|
@@ -143,8 +167,8 @@ build/
|
|
|
143
167
|
|
|
144
168
|
| Variable | Default | Description |
|
|
145
169
|
|----------|---------|-------------|
|
|
146
|
-
| `GOOGLE_DRIVE_CREDENTIALS_PATH` |
|
|
147
|
-
| `GOOGLE_DRIVE_TOKEN_PATH` |
|
|
170
|
+
| `GOOGLE_DRIVE_CREDENTIALS_PATH` | `~/.config/aethel/credentials.json` | Path to OAuth credentials |
|
|
171
|
+
| `GOOGLE_DRIVE_TOKEN_PATH` | `~/.config/aethel/token.json` | Path to cached OAuth token |
|
|
148
172
|
| `AETHEL_DRIVE_CONCURRENCY` | `40` | Max concurrent Drive API requests |
|
|
149
173
|
|
|
150
174
|
## Architecture
|
package/package.json
CHANGED
package/src/core/auth.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import fsSyncFallback from "node:fs";
|
|
3
3
|
import http from "node:http";
|
|
4
|
+
import os from "node:os";
|
|
4
5
|
import path from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { URL } from "node:url";
|
|
7
7
|
import { google } from "googleapis";
|
|
8
8
|
import open from "open";
|
|
@@ -10,8 +10,7 @@ import open from "open";
|
|
|
10
10
|
const SCOPES = ["https://www.googleapis.com/auth/drive"];
|
|
11
11
|
const DEFAULT_CREDENTIALS_PATH = "credentials.json";
|
|
12
12
|
const DEFAULT_TOKEN_PATH = "token.json";
|
|
13
|
-
const
|
|
14
|
-
const PROJECT_ROOT = path.resolve(MODULE_DIR, "..", "..");
|
|
13
|
+
const CONFIG_DIR = path.join(os.homedir(), ".config", "aethel");
|
|
15
14
|
const AUTH_TIMEOUT_MS = 120_000;
|
|
16
15
|
|
|
17
16
|
// ── Path resolution ─────────────────────────────────────────────────
|
|
@@ -22,7 +21,12 @@ function resolvePath(candidatePath, fallbackFileName) {
|
|
|
22
21
|
? candidatePath
|
|
23
22
|
: path.resolve(process.cwd(), candidatePath);
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
// Also check cwd before falling back to ~/.config/aethel/
|
|
25
|
+
const cwdPath = path.resolve(process.cwd(), fallbackFileName);
|
|
26
|
+
if (fsSyncFallback.existsSync(cwdPath)) {
|
|
27
|
+
return cwdPath;
|
|
28
|
+
}
|
|
29
|
+
return path.join(CONFIG_DIR, fallbackFileName);
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
export function resolveCredentialsPath(customPath) {
|
|
@@ -47,7 +51,15 @@ async function loadClientConfig(credentialsPath) {
|
|
|
47
51
|
raw = await fs.readFile(credentialsPath, "utf8");
|
|
48
52
|
} catch {
|
|
49
53
|
throw new Error(
|
|
50
|
-
`OAuth credentials file
|
|
54
|
+
`OAuth credentials file not found: ${credentialsPath}\n\n` +
|
|
55
|
+
"Setup steps:\n" +
|
|
56
|
+
" 1. Go to https://console.cloud.google.com/\n" +
|
|
57
|
+
" 2. Create a project and enable the Google Drive API\n" +
|
|
58
|
+
" 3. Create an OAuth 2.0 Client ID (Desktop application)\n" +
|
|
59
|
+
" 4. Download the credentials JSON and save it as:\n" +
|
|
60
|
+
` ${path.join(CONFIG_DIR, DEFAULT_CREDENTIALS_PATH)}\n\n` +
|
|
61
|
+
"Or pass a custom path:\n" +
|
|
62
|
+
" aethel auth --credentials /path/to/credentials.json"
|
|
51
63
|
);
|
|
52
64
|
}
|
|
53
65
|
|