@embeddable.com/sdk-core 3.12.0 → 3.12.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.
package/lib/index.js CHANGED
@@ -25,6 +25,7 @@ var http = require('node:http');
25
25
  var ws = require('ws');
26
26
  var chokidar = require('chokidar');
27
27
  var fg = require('fast-glob');
28
+ var dotenv = require('dotenv');
28
29
  var promises = require('fs/promises');
29
30
 
30
31
  function _interopNamespaceDefault(e) {
@@ -57,6 +58,7 @@ var path__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(path$1);
57
58
  var archiver__namespace = /*#__PURE__*/_interopNamespaceDefault(archiver);
58
59
  var http__namespace = /*#__PURE__*/_interopNamespaceDefault(http);
59
60
  var chokidar__namespace = /*#__PURE__*/_interopNamespaceDefault(chokidar);
61
+ var dotenv__namespace = /*#__PURE__*/_interopNamespaceDefault(dotenv);
60
62
 
61
63
  var findFiles = async (initialSrcDir, regex) => {
62
64
  const filesList = [];
@@ -5010,7 +5012,7 @@ var z = /*#__PURE__*/Object.freeze({
5010
5012
  const CUBE_YAML_FILE_REGEX = /^(.*)\.cube\.ya?ml$/;
5011
5013
  const SECURITY_CONTEXT_FILE_REGEX = /^(.*)\.sc\.ya?ml$/;
5012
5014
  const CLIENT_CONTEXT_FILE_REGEX = /^(.*)\.cc\.ya?ml$/;
5013
- var validate = async (ctx, exitIfInvalid = true) => {
5015
+ var validate = async (ctx) => {
5014
5016
  checkNodeVersion();
5015
5017
  const ora = (await import('ora')).default;
5016
5018
  const spinnerValidate = ora("Data model validation...").start();
@@ -5021,9 +5023,7 @@ var validate = async (ctx, exitIfInvalid = true) => {
5021
5023
  if (dataModelErrors.length) {
5022
5024
  spinnerValidate.fail("One or more cube.yaml files are invalid:");
5023
5025
  dataModelErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
5024
- if (exitIfInvalid) {
5025
- process.exit(1);
5026
- }
5026
+ process.exit(1);
5027
5027
  }
5028
5028
  spinnerValidate.succeed("Data model validation completed");
5029
5029
  const securityContextErrors = await securityContextValidation(securityContextFilesList);
@@ -5031,16 +5031,12 @@ var validate = async (ctx, exitIfInvalid = true) => {
5031
5031
  if (securityContextErrors.length) {
5032
5032
  spinnerValidate.fail("One or more security context files are invalid:");
5033
5033
  securityContextErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
5034
- if (exitIfInvalid) {
5035
- process.exit(1);
5036
- }
5034
+ process.exit(1);
5037
5035
  }
5038
5036
  if (clientContextErrors.length) {
5039
5037
  spinnerValidate.fail("One or more client context files are invalid:");
5040
5038
  clientContextErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
5041
- if (exitIfInvalid) {
5042
- process.exit(1);
5043
- }
5039
+ process.exit(1);
5044
5040
  }
5045
5041
  return (dataModelErrors.length === 0 &&
5046
5042
  securityContextErrors.length === 0 &&
@@ -21353,7 +21349,7 @@ async function rotateLogIfNeeded() {
21353
21349
  function setupGlobalErrorHandlers(command) {
21354
21350
  process.on("uncaughtException", async (error) => {
21355
21351
  await logError({ command, breadcrumbs: ["uncaughtException"], error });
21356
- console.error("An uncaught error occurred. Check the log file for details.");
21352
+ console.error(error);
21357
21353
  process.exit(1);
21358
21354
  });
21359
21355
  process.on("unhandledRejection", async (reason) => {
@@ -21362,7 +21358,7 @@ function setupGlobalErrorHandlers(command) {
21362
21358
  breadcrumbs: ["unhandledRejection"],
21363
21359
  error: reason,
21364
21360
  });
21365
- console.error("An unhandled rejection occurred. Check the log file for details.");
21361
+ console.error(reason);
21366
21362
  process.exit(1);
21367
21363
  });
21368
21364
  }
@@ -21432,11 +21428,19 @@ var login = async () => {
21432
21428
  client_id: config.authClientId,
21433
21429
  };
21434
21430
  await open(deviceCodeResponse.data["verification_uri_complete"]);
21431
+ let isTerminated = false;
21432
+ const signalHandler = () => {
21433
+ isTerminated = true;
21434
+ authenticationSpinner.fail("Authentication process interrupted");
21435
+ process.exit(0);
21436
+ };
21437
+ process.on("SIGTERM", signalHandler);
21438
+ process.on("SIGINT", signalHandler);
21435
21439
  /**
21436
21440
  * This is a recommended way to poll, since it take some time for a user to enter a `user_code` in a browser.
21437
21441
  * deviceCodeResponse.data['interval'] is a recommended/calculated polling interval specified in seconds.
21438
21442
  */
21439
- while (true) {
21443
+ while (!isTerminated) {
21440
21444
  try {
21441
21445
  const tokenResponse = await axios.post(`https://${config.authDomain}/oauth/token`, tokenPayload);
21442
21446
  await fs__namespace.writeFile(CREDENTIALS_FILE, JSON.stringify(tokenResponse.data));
@@ -21451,6 +21455,9 @@ var login = async () => {
21451
21455
  await sleep(deviceCodeResponse.data["interval"] * 1000);
21452
21456
  }
21453
21457
  }
21458
+ // Clean up signal handlers
21459
+ process.off("SIGTERM", signalHandler);
21460
+ process.off("SIGINT", signalHandler);
21454
21461
  }
21455
21462
  catch (error) {
21456
21463
  authenticationSpinner.fail("Authentication failed. Please try again.");
@@ -21584,6 +21591,7 @@ var push = async () => {
21584
21591
  spinnerPushing === null || spinnerPushing === void 0 ? void 0 : spinnerPushing.fail("Publishing failed");
21585
21592
  await logError({ command: "push", breadcrumbs, error });
21586
21593
  await reportErrorToRollbar(error);
21594
+ console.log(error);
21587
21595
  process.exit(1);
21588
21596
  }
21589
21597
  };
@@ -21687,6 +21695,7 @@ async function uploadFile(formData, url, token) {
21687
21695
  }
21688
21696
 
21689
21697
  const minimist = require("minimist");
21698
+ dotenv__namespace.config();
21690
21699
  const oraP = import('ora');
21691
21700
  let wss;
21692
21701
  let changedFiles = [];
@@ -21825,6 +21834,7 @@ var dev = async () => {
21825
21834
  }
21826
21835
  catch (error) {
21827
21836
  await logError({ command: "dev", breadcrumbs, error });
21837
+ console.log(error);
21828
21838
  process.exit(1);
21829
21839
  }
21830
21840
  };
@@ -21898,7 +21908,7 @@ const globalCssWatcher = (ctx) => {
21898
21908
  };
21899
21909
  const sendDataModelsAndContextsChanges = async (ctx) => {
21900
21910
  sendMessage("dataModelsAndOrSecurityContextUpdateStart");
21901
- const isValid = await validate(ctx, false);
21911
+ const isValid = await validate(ctx);
21902
21912
  if (isValid) {
21903
21913
  const token = await getToken();
21904
21914
  const sending = ora("Synchronising data models and/or security contexts...").start();
@@ -21947,8 +21957,12 @@ const getPreviewWorkspace = async (startedOra, ctx) => {
21947
21957
  startedOra.start();
21948
21958
  }
21949
21959
  try {
21960
+ const instanceUrl = process.env.CUBE_CLOUD_ENDPOINT;
21950
21961
  const response = await axios.get(`${ctx.pushBaseUrl}/workspace/dev-workspace`, {
21951
- params: { primaryWorkspace },
21962
+ params: {
21963
+ primaryWorkspace,
21964
+ instanceUrl,
21965
+ },
21952
21966
  headers: {
21953
21967
  Authorization: `Bearer ${token}`,
21954
21968
  },
@@ -22027,7 +22041,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
22027
22041
  };
22028
22042
 
22029
22043
  var name = "@embeddable.com/sdk-core";
22030
- var version = "3.12.0";
22044
+ var version = "3.12.2";
22031
22045
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
22032
22046
  var keywords = [
22033
22047
  "embeddable",
@@ -22065,13 +22079,14 @@ var engines = {
22065
22079
  };
22066
22080
  var license = "MIT";
22067
22081
  var dependencies = {
22068
- "@embeddable.com/sdk-utils": "0.6.0",
22069
- "@inquirer/prompts": "^7.1.0",
22070
- "@stencil/core": "^4.22.3",
22082
+ "@embeddable.com/sdk-utils": "0.6.1",
22083
+ "@inquirer/prompts": "^7.2.1",
22084
+ "@stencil/core": "^4.23.0",
22071
22085
  "@swc-node/register": "^1.10.9",
22072
22086
  archiver: "^5.3.2",
22073
- axios: "^1.7.8",
22074
- chokidar: "^4.0.1",
22087
+ axios: "^1.7.9",
22088
+ chokidar: "^4.0.3",
22089
+ dotenv: "^16.4.7",
22075
22090
  "fast-glob": "^3.3.2",
22076
22091
  finalhandler: "^1.3.1",
22077
22092
  "formdata-node": "^6.0.3",