@eide/foir-cli 0.3.1 → 0.3.2

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/cli.js +26 -7
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -345,12 +345,14 @@ async function loginAction(globalOpts) {
345
345
  const port = await findAvailablePort(9876, 9900);
346
346
  const redirectUri = `http://localhost:${port}/callback`;
347
347
  const authCode = await new Promise((resolve7, reject) => {
348
+ let timeoutId;
348
349
  const server = http.createServer((req, res) => {
349
350
  const url = new URL(req.url, `http://localhost:${port}`);
350
351
  if (url.pathname === "/callback") {
351
352
  const code = url.searchParams.get("code");
352
353
  const returnedState = url.searchParams.get("state");
353
354
  const error = url.searchParams.get("error");
355
+ clearTimeout(timeoutId);
354
356
  if (error) {
355
357
  res.writeHead(400, { "Content-Type": "text/html" });
356
358
  res.end(
@@ -372,16 +374,20 @@ async function loginAction(globalOpts) {
372
374
  const apiHost = new URL(apiUrl).host;
373
375
  const mainHost = apiHost.replace(/^api\./, "");
374
376
  const mainUrl = `https://${mainHost}`;
375
- res.writeHead(200, { "Content-Type": "text/html" });
377
+ res.writeHead(200, {
378
+ "Content-Type": "text/html",
379
+ "Connection": "close"
380
+ });
376
381
  res.end(
377
382
  `<html><head><meta http-equiv="refresh" content="2;url=${mainUrl}"></head><body style="font-family:system-ui;text-align:center;padding:50px"><h1>Authentication successful!</h1><p>You can close this window.</p></body></html>`
378
383
  );
384
+ server.closeAllConnections();
379
385
  server.close();
380
386
  resolve7(code);
381
387
  }
382
388
  });
383
389
  server.listen(port);
384
- setTimeout(
390
+ timeoutId = setTimeout(
385
391
  () => {
386
392
  server.close();
387
393
  reject(new Error("Authentication timed out after 5 minutes"));
@@ -2833,11 +2839,24 @@ function registerSelectProjectCommand(program2, globalOpts) {
2833
2839
  name: t.name
2834
2840
  })
2835
2841
  );
2836
- const projects = (sessionContext.availableProjects ?? []).map((p) => ({
2837
- id: p.id,
2838
- name: p.name,
2839
- tenantId: p.tenantId
2840
- }));
2842
+ if (tenants.length === 0) {
2843
+ console.log(
2844
+ "No workspaces found. Create one in the platform first."
2845
+ );
2846
+ throw new Error("No workspaces available");
2847
+ }
2848
+ const projects = [];
2849
+ for (const tenant of tenants) {
2850
+ const { items } = await client.identity.listProjects({
2851
+ tenantId: tenant.id,
2852
+ status: 1,
2853
+ // PROJECT_STATUS_ACTIVE
2854
+ limit: 100
2855
+ });
2856
+ for (const p of items) {
2857
+ projects.push({ id: p.id, name: p.name, tenantId: p.tenantId });
2858
+ }
2859
+ }
2841
2860
  if (projects.length === 0) {
2842
2861
  console.log("No projects found. Create one in the platform first.");
2843
2862
  throw new Error("No projects available");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Universal platform CLI for Foir platform",
5
5
  "type": "module",
6
6
  "publishConfig": {