@overscore/cli 0.11.3 → 0.11.5
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/dist/index.js +26 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30,11 +30,34 @@ async function loadEnv() {
|
|
|
30
30
|
const env = parseEnv(fs.readFileSync(envPath, "utf-8"));
|
|
31
31
|
const apiUrl = env.VITE_OVERSCORE_API_URL;
|
|
32
32
|
const apiKey = env.VITE_OVERSCORE_API_KEY;
|
|
33
|
+
const dashboardSlug = env.VITE_OVERSCORE_DASHBOARD_SLUG || path.basename(process.cwd());
|
|
34
|
+
const projectSlug = env.VITE_OVERSCORE_PROJECT_SLUG || "";
|
|
33
35
|
if (apiUrl && apiKey) {
|
|
34
|
-
const dashboardSlug = env.VITE_OVERSCORE_DASHBOARD_SLUG || path.basename(process.cwd());
|
|
35
|
-
const projectSlug = env.VITE_OVERSCORE_PROJECT_SLUG || "";
|
|
36
36
|
return { apiUrl, apiKey, dashboardSlug, projectSlug };
|
|
37
37
|
}
|
|
38
|
+
// .env has project context but no API key — generate one via device token
|
|
39
|
+
if (projectSlug) {
|
|
40
|
+
const globalCfgPath = path.join(process.env.HOME || "", ".overscore", "config");
|
|
41
|
+
const globalCfg = fs.existsSync(globalCfgPath)
|
|
42
|
+
? parseEnv(fs.readFileSync(globalCfgPath, "utf-8"))
|
|
43
|
+
: {};
|
|
44
|
+
if (globalCfg.OVERSCORE_DEVICE_TOKEN) {
|
|
45
|
+
const newKey = await refreshApiKey(projectSlug);
|
|
46
|
+
if (newKey) {
|
|
47
|
+
const envContent = fs.readFileSync(envPath, "utf-8");
|
|
48
|
+
const updated = envContent.includes("VITE_OVERSCORE_API_KEY=")
|
|
49
|
+
? envContent.replace(/^VITE_OVERSCORE_API_KEY=.*/m, `VITE_OVERSCORE_API_KEY=${newKey}`)
|
|
50
|
+
: envContent + `VITE_OVERSCORE_API_KEY=${newKey}\n`;
|
|
51
|
+
fs.writeFileSync(envPath, updated);
|
|
52
|
+
return {
|
|
53
|
+
apiUrl: apiUrl || `${HUB_URL}/api`,
|
|
54
|
+
apiKey: newKey,
|
|
55
|
+
dashboardSlug,
|
|
56
|
+
projectSlug,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
38
61
|
}
|
|
39
62
|
// (2) Global config (works from analysis folders or anywhere)
|
|
40
63
|
const configPath = path.join(process.env.HOME || "", ".overscore", "config");
|
|
@@ -2070,7 +2093,7 @@ async function authLogin() {
|
|
|
2070
2093
|
resolveCallback({ token, project });
|
|
2071
2094
|
});
|
|
2072
2095
|
server.listen(chosenPort, "127.0.0.1");
|
|
2073
|
-
const loginUrl = `${HUB_URL}/login?next=${encodeURIComponent(`/api/cli/auth/finalize?port=${chosenPort}&state=${state}`)}&mode=signin`;
|
|
2096
|
+
const loginUrl = `${HUB_URL}/login?next=${encodeURIComponent(`/api/cli/auth/finalize?port=${chosenPort}&state=${state}`)}&mode=signin&switch=1`;
|
|
2074
2097
|
console.log(`\n Opening browser to authenticate...`);
|
|
2075
2098
|
console.log(`\n If your browser doesn't open automatically, visit:\n ${loginUrl}\n`);
|
|
2076
2099
|
try {
|