@embeddable.com/sdk-core 3.2.1 → 3.3.0

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
@@ -378,11 +378,11 @@ async function generate$1(ctx) {
378
378
  const optionsFiles = await findFiles(ctx.client.srcDir, EMB_OPTIONS_FILE_REGEX);
379
379
  const typeImports = typeFiles
380
380
  .concat(optionsFiles)
381
- .map(([_fileName, filePath]) => `import './${path$1
381
+ .map(([_fileName, filePath]) => `import '../${path$1
382
382
  .relative(ctx.client.rootDir, filePath)
383
383
  .replaceAll("\\", "/")}';`)
384
384
  .join("\n");
385
- await fs$1.writeFile(path$1.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename), typeImports);
385
+ await fs$1.writeFile(path$1.resolve(ctx.client.buildDir, ctx.outputOptions.typesEntryPointFilename), typeImports);
386
386
  }
387
387
  async function build$1(ctx) {
388
388
  var _a;
@@ -391,7 +391,7 @@ async function build$1(ctx) {
391
391
  build: {
392
392
  emptyOutDir: false,
393
393
  lib: {
394
- entry: path$1.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename),
394
+ entry: path$1.resolve(ctx.client.buildDir, ctx.outputOptions.typesEntryPointFilename),
395
395
  formats: ["es"],
396
396
  fileName: "embeddable-types",
397
397
  },
@@ -407,7 +407,7 @@ async function build$1(ctx) {
407
407
  });
408
408
  }
409
409
  async function cleanup$1(ctx) {
410
- await fs$1.rm(path$1.resolve(ctx.client.rootDir, "embeddable-types-entry-point.js"));
410
+ await fs$1.rm(path$1.resolve(ctx.client.buildDir, "embeddable-types-entry-point.js"));
411
411
  }
412
412
 
413
413
  var prepare = async (ctx) => {
@@ -20299,10 +20299,46 @@ const getArgumentByKey = (key) => {
20299
20299
  const index = process.argv.indexOf(key);
20300
20300
  return index !== -1 ? process.argv[index + 1] : undefined;
20301
20301
  };
20302
+ const SUCCESS_FLAG_FILE = `${CREDENTIALS_DIR}/success`;
20303
+ /**
20304
+ * Store a flag in the credentials directory to indicate a successful build
20305
+ * This is used to determine if the build was successful or not
20306
+ */
20307
+ const storeBuildSuccessFlag = async () => {
20308
+ try {
20309
+ await fs$1.access(CREDENTIALS_DIR);
20310
+ }
20311
+ catch (_e) {
20312
+ await fs$1.mkdir(CREDENTIALS_DIR);
20313
+ }
20314
+ await fs$1.writeFile(SUCCESS_FLAG_FILE, "true");
20315
+ };
20316
+ /**
20317
+ * Remove the success flag from the credentials directory
20318
+ */
20319
+ const removeBuildSuccessFlag = async () => {
20320
+ try {
20321
+ await fs$1.unlink(SUCCESS_FLAG_FILE);
20322
+ }
20323
+ catch (_e) { }
20324
+ };
20325
+ /**
20326
+ * Check if the build was successful
20327
+ */
20328
+ const checkBuildSuccess = async () => {
20329
+ try {
20330
+ await fs$1.access(SUCCESS_FLAG_FILE);
20331
+ return true;
20332
+ }
20333
+ catch (_e) {
20334
+ return false;
20335
+ }
20336
+ };
20302
20337
 
20303
20338
  var build = async () => {
20304
20339
  try {
20305
20340
  checkNodeVersion();
20341
+ removeBuildSuccessFlag();
20306
20342
  const config = await provideConfig();
20307
20343
  await validate(config);
20308
20344
  await prepare(config);
@@ -20316,6 +20352,7 @@ var build = async () => {
20316
20352
  // NOTE: likely this will be called inside the loop above if we decide to support clients with mixed frameworks simultaneously.
20317
20353
  await generate(config, "sdk-react");
20318
20354
  await cleanup(config);
20355
+ await storeBuildSuccessFlag();
20319
20356
  }
20320
20357
  catch (error) {
20321
20358
  await reportErrorToRollbar(error);
@@ -20413,6 +20450,11 @@ var push = async () => {
20413
20450
  let spinnerPushing;
20414
20451
  try {
20415
20452
  checkNodeVersion();
20453
+ const isBuildSuccess = await checkBuildSuccess();
20454
+ if (!isBuildSuccess) {
20455
+ console.error("Build failed or not completed. Please run `embeddable:build` first.");
20456
+ process.exit(1);
20457
+ }
20416
20458
  ora$1 = (await oraP$1).default;
20417
20459
  const config = await provideConfig();
20418
20460
  if (process.argv.includes("--api-key") || process.argv.includes("-k")) {
@@ -20593,24 +20635,48 @@ let browserWindow = null;
20593
20635
  let ora;
20594
20636
  let previewWorkspace;
20595
20637
  const SERVER_PORT = 8926;
20638
+ const BUILD_DEV_DIR = ".embeddable-dev-build";
20596
20639
  const buildWebComponent = async (config) => {
20597
20640
  await generate(config, "sdk-react");
20598
20641
  };
20642
+ const addToGitingore = async () => {
20643
+ try {
20644
+ const fs = require("fs").promises;
20645
+ const gitignorePath = path$2.resolve(process.cwd(), ".gitignore");
20646
+ const gitignoreContent = await fs.readFile(gitignorePath, "utf8");
20647
+ if (!gitignoreContent.includes(BUILD_DEV_DIR)) {
20648
+ await fs.appendFile(gitignorePath, `\n${BUILD_DEV_DIR}\n`);
20649
+ }
20650
+ }
20651
+ catch (e) {
20652
+ // ignore
20653
+ }
20654
+ };
20599
20655
  var dev = async () => {
20600
20656
  var _a;
20601
20657
  checkNodeVersion();
20658
+ addToGitingore();
20602
20659
  const http = require("http");
20603
20660
  ora = (await oraP).default;
20604
20661
  process.on("warning", (e) => console.warn(e.stack));
20605
20662
  const logger = createNodeLogger({ process });
20606
20663
  const sys = createNodeSys({ process });
20664
+ const defaultConfig = await provideConfig();
20665
+ const buildDir = path$2.resolve(defaultConfig.client.rootDir, ".embeddable-dev-build");
20607
20666
  const config = {
20667
+ ...defaultConfig,
20608
20668
  dev: {
20609
20669
  watch: true,
20610
20670
  logger,
20611
20671
  sys,
20612
20672
  },
20613
- ...(await provideConfig()),
20673
+ client: {
20674
+ ...defaultConfig.client,
20675
+ buildDir: buildDir,
20676
+ componentDir: path$2.resolve(buildDir, "component"),
20677
+ stencilBuild: path$2.resolve(buildDir, "dist", "embeddable-wrapper"),
20678
+ tmpDir: path$2.resolve(defaultConfig.client.rootDir, ".embeddable-dev-tmp"),
20679
+ },
20614
20680
  };
20615
20681
  await prepare(config);
20616
20682
  const finalhandler = require("finalhandler");