@overscore/cli 0.11.4 → 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.
Files changed (2) hide show
  1. package/dist/index.js +25 -2
  2. 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");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overscore/cli",
3
- "version": "0.11.4",
3
+ "version": "0.11.5",
4
4
  "description": "CLI for deploying Overscore dashboards and publishing analyses",
5
5
  "bin": {
6
6
  "overscore": "dist/index.js"