@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.esm.js CHANGED
@@ -539,10 +539,9 @@ const CREDENTIALS_DIR = path$1.resolve(os$1.homedir(), ".embeddable");
539
539
  const CREDENTIALS_FILE = path$1.resolve(CREDENTIALS_DIR, "credentials");
540
540
 
541
541
  const oraP$3 = import('ora');
542
- let ora$2;
543
542
  const checkNodeVersion = async () => {
544
- ora$2 = (await oraP$3).default;
545
- const spinner = ora$2("Checking node version...");
543
+ const ora = (await oraP$3).default;
544
+ const spinner = ora("Checking node version...").start();
546
545
  const [major, minor] = process.versions.node.split(".").map(Number);
547
546
  const packageJson = await Promise.resolve().then(function () { return _package$1; });
548
547
  const { engines: { node }, } = packageJson;
@@ -551,10 +550,7 @@ const checkNodeVersion = async () => {
551
550
  .map((v) => v.replace(/[^\d]/g, ""))
552
551
  .map(Number);
553
552
  if (major < minMajor || (major === minMajor && minor < minMinor)) {
554
- spinner.fail({
555
- text: `Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`,
556
- color: "red",
557
- });
553
+ spinner.fail(`Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`);
558
554
  process.exit(1);
559
555
  }
560
556
  else {
@@ -20537,8 +20533,58 @@ async function resolveFiles() {
20537
20533
  }
20538
20534
  }
20539
20535
 
20540
- const oraP$1 = import('ora');
20541
20536
  const inquirerSelect = import('@inquirer/select');
20537
+ async function getWorkspaces(ctx, token, workspaceSpinner) {
20538
+ var _a;
20539
+ try {
20540
+ const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
20541
+ headers: {
20542
+ Authorization: `Bearer ${token}`,
20543
+ },
20544
+ });
20545
+ return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
20546
+ }
20547
+ catch (e) {
20548
+ if (e.response.status === 401) {
20549
+ workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
20550
+ }
20551
+ else {
20552
+ workspaceSpinner.fail("Failed to fetch workspaces");
20553
+ }
20554
+ process.exit(1);
20555
+ }
20556
+ }
20557
+ async function selectWorkspace(ora, ctx, token) {
20558
+ const workspaceSpinner = ora({
20559
+ text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
20560
+ color: "green",
20561
+ discardStdin: false,
20562
+ }).start();
20563
+ const availableWorkspaces = await getWorkspaces(ctx, token, workspaceSpinner);
20564
+ let selectedWorkspace;
20565
+ if (availableWorkspaces.length === 0) {
20566
+ workspaceSpinner.fail("No workspaces found");
20567
+ process.exit(1);
20568
+ }
20569
+ workspaceSpinner.info(`Found ${availableWorkspaces.length} workspace(s)`);
20570
+ if (availableWorkspaces.length === 1) {
20571
+ selectedWorkspace = availableWorkspaces[0];
20572
+ }
20573
+ else {
20574
+ const select = (await inquirerSelect).default;
20575
+ selectedWorkspace = await select({
20576
+ message: "Select workspace to push changes",
20577
+ choices: availableWorkspaces.map((workspace) => ({
20578
+ name: `${workspace.name} (${workspace.workspaceId})`,
20579
+ value: workspace,
20580
+ })),
20581
+ });
20582
+ }
20583
+ workspaceSpinner.succeed(`Workspace: ${selectedWorkspace.name} (${selectedWorkspace.workspaceId})`);
20584
+ return selectedWorkspace;
20585
+ }
20586
+
20587
+ const oraP$1 = import('ora');
20542
20588
  // grab .cube.yml|js and .sc.yml|js files
20543
20589
  const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
20544
20590
  // grab all files in self-serve-customization folder
@@ -20567,7 +20613,7 @@ var push = async () => {
20567
20613
  spinnerPushing = ora$1()
20568
20614
  .start()
20569
20615
  .info("No API Key provided. Standard login will be used.");
20570
- const { workspaceId, name: workspaceName } = await selectWorkspace(config, token);
20616
+ const { workspaceId, name: workspaceName } = await selectWorkspace(ora$1, config, token);
20571
20617
  const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`;
20572
20618
  await buildArchive(config);
20573
20619
  spinnerPushing.info(`Publishing to ${workspaceName} using ${workspacePreviewUrl}...`);
@@ -20606,35 +20652,6 @@ async function pushByApiKey(config, spinner) {
20606
20652
  message,
20607
20653
  });
20608
20654
  }
20609
- async function selectWorkspace(ctx, token) {
20610
- const workspaceSpinner = ora$1({
20611
- text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
20612
- color: "green",
20613
- discardStdin: false,
20614
- }).start();
20615
- const availableWorkspaces = await getWorkspaces(ctx, token, workspaceSpinner);
20616
- let selectedWorkspace;
20617
- if (availableWorkspaces.length === 0) {
20618
- workspaceSpinner.fail("No workspaces found");
20619
- process.exit(1);
20620
- }
20621
- workspaceSpinner.info(`Found ${availableWorkspaces.length} workspace(s)`);
20622
- if (availableWorkspaces.length === 1) {
20623
- selectedWorkspace = availableWorkspaces[0];
20624
- }
20625
- else {
20626
- const select = (await inquirerSelect).default;
20627
- selectedWorkspace = await select({
20628
- message: "Select workspace to push changes",
20629
- choices: availableWorkspaces.map((workspace) => ({
20630
- name: `${workspace.name} (${workspace.workspaceId})`,
20631
- value: workspace,
20632
- })),
20633
- });
20634
- }
20635
- workspaceSpinner.succeed(`Workspace: ${selectedWorkspace.name} (${selectedWorkspace.workspaceId})`);
20636
- return selectedWorkspace;
20637
- }
20638
20655
  async function verify(ctx) {
20639
20656
  try {
20640
20657
  await fs$1.access(ctx.client.buildDir);
@@ -20724,26 +20741,6 @@ async function uploadFile(formData, url, token) {
20724
20741
  maxBodyLength: Infinity,
20725
20742
  });
20726
20743
  }
20727
- async function getWorkspaces(ctx, token, workspaceSpinner) {
20728
- var _a;
20729
- try {
20730
- const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
20731
- headers: {
20732
- Authorization: `Bearer ${token}`,
20733
- },
20734
- });
20735
- return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
20736
- }
20737
- catch (e) {
20738
- if (e.response.status === 401) {
20739
- workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
20740
- }
20741
- else {
20742
- workspaceSpinner.fail("Failed to fetch workspaces");
20743
- }
20744
- process.exit(1);
20745
- }
20746
- }
20747
20744
 
20748
20745
  const minimist = require("minimist");
20749
20746
  const oraP = import('ora');
@@ -20804,7 +20801,7 @@ var dev = async () => {
20804
20801
  const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
20805
20802
  const workspacePreparation = ora("Preparing workspace...").start();
20806
20803
  try {
20807
- previewWorkspace = await getPreviewWorkspace(config);
20804
+ previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
20808
20805
  }
20809
20806
  catch (e) {
20810
20807
  workspacePreparation.fail((_a = e.response.data) === null || _a === void 0 ? void 0 : _a.errorMessage);
@@ -20967,10 +20964,16 @@ const onClose = async (server, sys, watchers, config) => {
20967
20964
  await sys.destroy();
20968
20965
  process.exit(0);
20969
20966
  };
20970
- const getPreviewWorkspace = async (ctx) => {
20967
+ const getPreviewWorkspace = async (startedOra, ctx) => {
20971
20968
  const token = await getToken();
20972
20969
  const params = minimist(process.argv.slice(2));
20973
- const primaryWorkspace = params.w || params.workspace;
20970
+ let primaryWorkspace = params.w || params.workspace;
20971
+ if (!primaryWorkspace) {
20972
+ startedOra.stop(); // Stop current Ora, otherwise the last option will get hidden by it.
20973
+ const { workspaceId } = await selectWorkspace(ora, ctx, token);
20974
+ primaryWorkspace = workspaceId;
20975
+ startedOra.start();
20976
+ }
20974
20977
  try {
20975
20978
  const response = await axios.get(`${ctx.pushBaseUrl}/workspace/dev-workspace`, {
20976
20979
  params: { primaryWorkspace },
@@ -20984,7 +20987,7 @@ const getPreviewWorkspace = async (ctx) => {
20984
20987
  if (e.response.status === 401) {
20985
20988
  // login and retry
20986
20989
  await login();
20987
- return await getPreviewWorkspace(ctx);
20990
+ return await getPreviewWorkspace(startedOra, ctx);
20988
20991
  }
20989
20992
  else {
20990
20993
  throw e;
@@ -21045,7 +21048,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21045
21048
  };
21046
21049
 
21047
21050
  var name = "@embeddable.com/sdk-core";
21048
- var version = "3.7.2";
21051
+ var version = "3.7.3";
21049
21052
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
21050
21053
  var keywords = [
21051
21054
  "embeddable",