aethel 0.3.2 → 0.3.3
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/package.json +1 -1
- package/src/cli.js +5 -2
- package/src/core/auth.js +15 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -20,7 +20,7 @@ function getGitHash() {
|
|
|
20
20
|
|
|
21
21
|
const gitHash = getGitHash();
|
|
22
22
|
const versionString = gitHash ? `${pkg.version} (${gitHash})` : pkg.version;
|
|
23
|
-
import { resolveCredentialsPath, resolveTokenPath } from "./core/auth.js";
|
|
23
|
+
import { persistCredentials, resolveCredentialsPath, resolveTokenPath } from "./core/auth.js";
|
|
24
24
|
import {
|
|
25
25
|
initWorkspace,
|
|
26
26
|
requireRoot,
|
|
@@ -119,8 +119,11 @@ async function handleAuth(options) {
|
|
|
119
119
|
const repo = await openRepo(options, { requireWorkspace: false });
|
|
120
120
|
const account = await repo.getAccountInfo();
|
|
121
121
|
|
|
122
|
+
const credentialsPath = resolveCredentialsPath(options.credentials);
|
|
123
|
+
await persistCredentials(credentialsPath);
|
|
124
|
+
|
|
122
125
|
console.log("OAuth initialization completed.");
|
|
123
|
-
console.log(`Credentials path: ${
|
|
126
|
+
console.log(`Credentials path: ${credentialsPath}`);
|
|
124
127
|
console.log(`Token path: ${resolveTokenPath(options.token)}`);
|
|
125
128
|
console.log(`Authenticated user: ${account.name}`);
|
|
126
129
|
console.log(`Authenticated email: ${account.email}`);
|
package/src/core/auth.js
CHANGED
|
@@ -29,6 +29,21 @@ function resolvePath(candidatePath, fallbackFileName) {
|
|
|
29
29
|
return path.join(CONFIG_DIR, fallbackFileName);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
export { CONFIG_DIR };
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Copy a credentials file into ~/.config/aethel/ so future commands
|
|
36
|
+
* work without --credentials. No-op if the file is already there.
|
|
37
|
+
*/
|
|
38
|
+
export async function persistCredentials(sourcePath) {
|
|
39
|
+
const dest = path.join(CONFIG_DIR, DEFAULT_CREDENTIALS_PATH);
|
|
40
|
+
const resolved = path.resolve(sourcePath);
|
|
41
|
+
if (resolved === dest) return;
|
|
42
|
+
if (fsSyncFallback.existsSync(dest)) return;
|
|
43
|
+
await fs.mkdir(CONFIG_DIR, { recursive: true });
|
|
44
|
+
await fs.copyFile(resolved, dest);
|
|
45
|
+
}
|
|
46
|
+
|
|
32
47
|
export function resolveCredentialsPath(customPath) {
|
|
33
48
|
return resolvePath(
|
|
34
49
|
customPath || process.env.GOOGLE_DRIVE_CREDENTIALS_PATH,
|