@overscore/cli 0.13.17 → 0.13.18

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 })) {
@@ -3052,6 +3112,9 @@ else if (command === "versions") {
3052
3112
  else if (command === "list") {
3053
3113
  listDashboards();
3054
3114
  }
3115
+ else if (command === "projects") {
3116
+ listProjects();
3117
+ }
3055
3118
  else if (command === "install-skills") {
3056
3119
  installSkills();
3057
3120
  }
@@ -3216,6 +3279,7 @@ else {
3216
3279
  auth logout Remove saved credentials
3217
3280
  dev Start the dev server (injects auth automatically)
3218
3281
  list List all dashboards in the project
3282
+ projects List every project on your account
3219
3283
  deploy Build and deploy the dashboard
3220
3284
  pull <slug> Pull source code from the hub
3221
3285
  versions List deploy history
@@ -3228,6 +3292,7 @@ else {
3228
3292
  npx @overscore/cli auth login
3229
3293
  npx @overscore/cli dev
3230
3294
  npx @overscore/cli list
3295
+ npx @overscore/cli projects
3231
3296
  npx @overscore/cli deploy --message "description"
3232
3297
  npx @overscore/cli pull <slug>
3233
3298
  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.17",
3
+ "version": "0.13.18",
4
4
  "description": "CLI for deploying Overscore dashboards and publishing analyses",
5
5
  "bin": {
6
6
  "overscore": "dist/index.js"