@overscore/cli 0.13.19 → 0.13.20

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 +65 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1155,6 +1155,7 @@ async function listDashboards() {
1155
1155
  }
1156
1156
  const data = (await res.json());
1157
1157
  console.log(`\n ${data.project} (${data.project_slug})\n`);
1158
+ console.log(" Showing one project — run 'overscore projects' to list them all.\n");
1158
1159
  if (data.dashboards.length === 0) {
1159
1160
  console.log(" No dashboards yet.\n");
1160
1161
  return;
@@ -1173,6 +1174,65 @@ async function listDashboards() {
1173
1174
  console.log();
1174
1175
  }
1175
1176
  }
1177
+ // Account-level project list. Uses the CLI DEVICE token (ocli_) rather than a
1178
+ // project-scoped API key, so it can enumerate EVERY project on the account —
1179
+ // including empty ones a project key could never see.
1180
+ async function listProjects() {
1181
+ const configPath = path.join(process.env.HOME || "", ".overscore", "config");
1182
+ const readToken = () => {
1183
+ const cfg = fs.existsSync(configPath)
1184
+ ? parseEnv(fs.readFileSync(configPath, "utf-8"))
1185
+ : {};
1186
+ return cfg.OVERSCORE_DEVICE_TOKEN;
1187
+ };
1188
+ let deviceToken = readToken();
1189
+ if (!deviceToken) {
1190
+ console.log("\n No session found. Launching browser login...\n");
1191
+ await authLogin();
1192
+ deviceToken = readToken();
1193
+ if (!deviceToken) {
1194
+ console.error("\n Could not authenticate.\n");
1195
+ process.exit(1);
1196
+ }
1197
+ }
1198
+ for (let attempt = 0; attempt < 2; attempt++) {
1199
+ const res = await fetch(`${HUB_URL}/api/projects`, {
1200
+ headers: { Authorization: `Bearer ${deviceToken}` },
1201
+ });
1202
+ if (res.ok) {
1203
+ const { projects } = (await res.json());
1204
+ printProjects(projects);
1205
+ return;
1206
+ }
1207
+ // Device token expired — re-auth once, then retry.
1208
+ if (res.status === 401 && attempt === 0) {
1209
+ console.log("\n Session expired. Launching browser login...\n");
1210
+ await authLogin();
1211
+ deviceToken = readToken();
1212
+ if (!deviceToken)
1213
+ break;
1214
+ continue;
1215
+ }
1216
+ const body = (await res.json().catch(() => ({})));
1217
+ console.error(`\n Error: ${body.error || `HTTP ${res.status}`}\n`);
1218
+ process.exit(1);
1219
+ }
1220
+ console.error("\n Could not authenticate.\n");
1221
+ process.exit(1);
1222
+ }
1223
+ function printProjects(projects) {
1224
+ if (!projects.length) {
1225
+ console.log("\n No projects yet.\n\n Create one: npx create-overscore --dashboard <name> --project <slug>\n");
1226
+ return;
1227
+ }
1228
+ console.log(`\n Your projects (${projects.length})\n`);
1229
+ for (const p of projects) {
1230
+ const count = p.dashboard_count === 1 ? "1 dashboard" : `${p.dashboard_count} dashboards`;
1231
+ console.log(` ${p.name}`);
1232
+ console.log(` slug: ${p.slug} · ${count} · ${p.role}`);
1233
+ console.log();
1234
+ }
1235
+ }
1176
1236
  function collectFiles(dir, prefix) {
1177
1237
  const files = [];
1178
1238
  for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
@@ -3056,6 +3116,9 @@ else if (command === "versions") {
3056
3116
  else if (command === "list") {
3057
3117
  listDashboards();
3058
3118
  }
3119
+ else if (command === "projects") {
3120
+ listProjects();
3121
+ }
3059
3122
  else if (command === "install-skills") {
3060
3123
  installSkills();
3061
3124
  }
@@ -3220,6 +3283,7 @@ else {
3220
3283
  auth logout Remove saved credentials
3221
3284
  dev Start the dev server (injects auth automatically)
3222
3285
  list List all dashboards in the project
3286
+ projects List every project on your account
3223
3287
  deploy Build and deploy the dashboard
3224
3288
  pull <slug> Pull source code from the hub
3225
3289
  versions List deploy history
@@ -3232,6 +3296,7 @@ else {
3232
3296
  npx @overscore/cli auth login
3233
3297
  npx @overscore/cli dev
3234
3298
  npx @overscore/cli list
3299
+ npx @overscore/cli projects
3235
3300
  npx @overscore/cli deploy --message "description"
3236
3301
  npx @overscore/cli pull <slug>
3237
3302
  npx @overscore/cli pull <slug> --version 3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overscore/cli",
3
- "version": "0.13.19",
3
+ "version": "0.13.20",
4
4
  "description": "CLI for deploying Overscore dashboards and publishing analyses",
5
5
  "bin": {
6
6
  "overscore": "dist/index.js"