@embeddable.com/sdk-core 3.7.2 → 3.7.3

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
@@ -566,10 +566,9 @@ const CREDENTIALS_DIR = path__namespace.resolve(os__namespace.homedir(), ".embed
566
566
  const CREDENTIALS_FILE = path__namespace.resolve(CREDENTIALS_DIR, "credentials");
567
567
 
568
568
  const oraP$3 = import('ora');
569
- let ora$2;
570
569
  const checkNodeVersion = async () => {
571
- ora$2 = (await oraP$3).default;
572
- const spinner = ora$2("Checking node version...");
570
+ const ora = (await oraP$3).default;
571
+ const spinner = ora("Checking node version...").start();
573
572
  const [major, minor] = process.versions.node.split(".").map(Number);
574
573
  const packageJson = await Promise.resolve().then(function () { return _package$1; });
575
574
  const { engines: { node }, } = packageJson;
@@ -578,10 +577,7 @@ const checkNodeVersion = async () => {
578
577
  .map((v) => v.replace(/[^\d]/g, ""))
579
578
  .map(Number);
580
579
  if (major < minMajor || (major === minMajor && minor < minMinor)) {
581
- spinner.fail({
582
- text: `Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`,
583
- color: "red",
584
- });
580
+ spinner.fail(`Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`);
585
581
  process.exit(1);
586
582
  }
587
583
  else {
@@ -20564,8 +20560,58 @@ async function resolveFiles() {
20564
20560
  }
20565
20561
  }
20566
20562
 
20567
- const oraP$1 = import('ora');
20568
20563
  const inquirerSelect = import('@inquirer/select');
20564
+ async function getWorkspaces(ctx, token, workspaceSpinner) {
20565
+ var _a;
20566
+ try {
20567
+ const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
20568
+ headers: {
20569
+ Authorization: `Bearer ${token}`,
20570
+ },
20571
+ });
20572
+ return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
20573
+ }
20574
+ catch (e) {
20575
+ if (e.response.status === 401) {
20576
+ workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
20577
+ }
20578
+ else {
20579
+ workspaceSpinner.fail("Failed to fetch workspaces");
20580
+ }
20581
+ process.exit(1);
20582
+ }
20583
+ }
20584
+ async function selectWorkspace(ora, ctx, token) {
20585
+ const workspaceSpinner = ora({
20586
+ text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
20587
+ color: "green",
20588
+ discardStdin: false,
20589
+ }).start();
20590
+ const availableWorkspaces = await getWorkspaces(ctx, token, workspaceSpinner);
20591
+ let selectedWorkspace;
20592
+ if (availableWorkspaces.length === 0) {
20593
+ workspaceSpinner.fail("No workspaces found");
20594
+ process.exit(1);
20595
+ }
20596
+ workspaceSpinner.info(`Found ${availableWorkspaces.length} workspace(s)`);
20597
+ if (availableWorkspaces.length === 1) {
20598
+ selectedWorkspace = availableWorkspaces[0];
20599
+ }
20600
+ else {
20601
+ const select = (await inquirerSelect).default;
20602
+ selectedWorkspace = await select({
20603
+ message: "Select workspace to push changes",
20604
+ choices: availableWorkspaces.map((workspace) => ({
20605
+ name: `${workspace.name} (${workspace.workspaceId})`,
20606
+ value: workspace,
20607
+ })),
20608
+ });
20609
+ }
20610
+ workspaceSpinner.succeed(`Workspace: ${selectedWorkspace.name} (${selectedWorkspace.workspaceId})`);
20611
+ return selectedWorkspace;
20612
+ }
20613
+
20614
+ const oraP$1 = import('ora');
20569
20615
  // grab .cube.yml|js and .sc.yml|js files
20570
20616
  const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
20571
20617
  // grab all files in self-serve-customization folder
@@ -20594,7 +20640,7 @@ var push = async () => {
20594
20640
  spinnerPushing = ora$1()
20595
20641
  .start()
20596
20642
  .info("No API Key provided. Standard login will be used.");
20597
- const { workspaceId, name: workspaceName } = await selectWorkspace(config, token);
20643
+ const { workspaceId, name: workspaceName } = await selectWorkspace(ora$1, config, token);
20598
20644
  const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`;
20599
20645
  await buildArchive(config);
20600
20646
  spinnerPushing.info(`Publishing to ${workspaceName} using ${workspacePreviewUrl}...`);
@@ -20633,35 +20679,6 @@ async function pushByApiKey(config, spinner) {
20633
20679
  message,
20634
20680
  });
20635
20681
  }
20636
- async function selectWorkspace(ctx, token) {
20637
- const workspaceSpinner = ora$1({
20638
- text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
20639
- color: "green",
20640
- discardStdin: false,
20641
- }).start();
20642
- const availableWorkspaces = await getWorkspaces(ctx, token, workspaceSpinner);
20643
- let selectedWorkspace;
20644
- if (availableWorkspaces.length === 0) {
20645
- workspaceSpinner.fail("No workspaces found");
20646
- process.exit(1);
20647
- }
20648
- workspaceSpinner.info(`Found ${availableWorkspaces.length} workspace(s)`);
20649
- if (availableWorkspaces.length === 1) {
20650
- selectedWorkspace = availableWorkspaces[0];
20651
- }
20652
- else {
20653
- const select = (await inquirerSelect).default;
20654
- selectedWorkspace = await select({
20655
- message: "Select workspace to push changes",
20656
- choices: availableWorkspaces.map((workspace) => ({
20657
- name: `${workspace.name} (${workspace.workspaceId})`,
20658
- value: workspace,
20659
- })),
20660
- });
20661
- }
20662
- workspaceSpinner.succeed(`Workspace: ${selectedWorkspace.name} (${selectedWorkspace.workspaceId})`);
20663
- return selectedWorkspace;
20664
- }
20665
20682
  async function verify(ctx) {
20666
20683
  try {
20667
20684
  await fs__namespace.access(ctx.client.buildDir);
@@ -20751,26 +20768,6 @@ async function uploadFile(formData, url, token) {
20751
20768
  maxBodyLength: Infinity,
20752
20769
  });
20753
20770
  }
20754
- async function getWorkspaces(ctx, token, workspaceSpinner) {
20755
- var _a;
20756
- try {
20757
- const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
20758
- headers: {
20759
- Authorization: `Bearer ${token}`,
20760
- },
20761
- });
20762
- return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
20763
- }
20764
- catch (e) {
20765
- if (e.response.status === 401) {
20766
- workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
20767
- }
20768
- else {
20769
- workspaceSpinner.fail("Failed to fetch workspaces");
20770
- }
20771
- process.exit(1);
20772
- }
20773
- }
20774
20771
 
20775
20772
  const minimist = require("minimist");
20776
20773
  const oraP = import('ora');
@@ -20831,7 +20828,7 @@ var dev = async () => {
20831
20828
  const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
20832
20829
  const workspacePreparation = ora("Preparing workspace...").start();
20833
20830
  try {
20834
- previewWorkspace = await getPreviewWorkspace(config);
20831
+ previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
20835
20832
  }
20836
20833
  catch (e) {
20837
20834
  workspacePreparation.fail((_a = e.response.data) === null || _a === void 0 ? void 0 : _a.errorMessage);
@@ -20994,10 +20991,16 @@ const onClose = async (server, sys, watchers, config) => {
20994
20991
  await sys.destroy();
20995
20992
  process.exit(0);
20996
20993
  };
20997
- const getPreviewWorkspace = async (ctx) => {
20994
+ const getPreviewWorkspace = async (startedOra, ctx) => {
20998
20995
  const token = await getToken();
20999
20996
  const params = minimist(process.argv.slice(2));
21000
- const primaryWorkspace = params.w || params.workspace;
20997
+ let primaryWorkspace = params.w || params.workspace;
20998
+ if (!primaryWorkspace) {
20999
+ startedOra.stop(); // Stop current Ora, otherwise the last option will get hidden by it.
21000
+ const { workspaceId } = await selectWorkspace(ora, ctx, token);
21001
+ primaryWorkspace = workspaceId;
21002
+ startedOra.start();
21003
+ }
21001
21004
  try {
21002
21005
  const response = await axios.get(`${ctx.pushBaseUrl}/workspace/dev-workspace`, {
21003
21006
  params: { primaryWorkspace },
@@ -21011,7 +21014,7 @@ const getPreviewWorkspace = async (ctx) => {
21011
21014
  if (e.response.status === 401) {
21012
21015
  // login and retry
21013
21016
  await login();
21014
- return await getPreviewWorkspace(ctx);
21017
+ return await getPreviewWorkspace(startedOra, ctx);
21015
21018
  }
21016
21019
  else {
21017
21020
  throw e;
@@ -21072,7 +21075,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21072
21075
  };
21073
21076
 
21074
21077
  var name = "@embeddable.com/sdk-core";
21075
- var version = "3.7.2";
21078
+ var version = "3.7.3";
21076
21079
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
21077
21080
  var keywords = [
21078
21081
  "embeddable",