@embeddable.com/sdk-core 2.4.5 → 2.4.6

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/lib/index.js CHANGED
@@ -4680,7 +4680,7 @@ async function selectWorkspace(ctx, token) {
4680
4680
  color: "green",
4681
4681
  discardStdin: false,
4682
4682
  }).start();
4683
- const availableWorkspaces = await getWorkspaces(ctx, token);
4683
+ const availableWorkspaces = await getWorkspaces(ctx, token, workspaceSpinner);
4684
4684
  let selectedWorkspace;
4685
4685
  if (availableWorkspaces.length === 0) {
4686
4686
  workspaceSpinner.fail("No workspaces found");
@@ -4750,19 +4750,23 @@ async function sendBuild(ctx, { workspaceId, token }) {
4750
4750
  });
4751
4751
  await fs__namespace.rm(ctx.client.archiveFile);
4752
4752
  }
4753
- async function getWorkspaces(ctx, token) {
4753
+ async function getWorkspaces(ctx, token, workspaceSpinner) {
4754
4754
  try {
4755
- return axios
4756
- .get(`${ctx.pushBaseUrl}/workspace`, {
4755
+ const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
4757
4756
  headers: {
4758
4757
  Authorization: `Bearer ${token}`,
4759
4758
  },
4760
- })
4761
- .then((res) => res.data);
4759
+ });
4760
+ return response.data;
4762
4761
  }
4763
4762
  catch (e) {
4764
- console.error(e);
4765
- return [];
4763
+ if (e.response.status === 401) {
4764
+ workspaceSpinner.fail("Invalid token. Please login again.");
4765
+ }
4766
+ else {
4767
+ workspaceSpinner.fail("Failed to fetch workspaces");
4768
+ }
4769
+ process.exit(1);
4766
4770
  }
4767
4771
  }
4768
4772