@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 +71 -5
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +71 -5
- package/lib/index.js.map +1 -1
- package/lib/utils.d.ts +13 -0
- package/package.json +2 -2
- package/src/build.ts +8 -1
- package/src/buildTypes.ts +7 -4
- package/src/dev.ts +31 -1
- package/src/globalCleanup.ts +0 -12
- package/src/push.ts +9 -1
- package/src/utils.ts +38 -0
package/lib/index.js
CHANGED
|
@@ -405,11 +405,11 @@ async function generate$1(ctx) {
|
|
|
405
405
|
const optionsFiles = await findFiles(ctx.client.srcDir, EMB_OPTIONS_FILE_REGEX);
|
|
406
406
|
const typeImports = typeFiles
|
|
407
407
|
.concat(optionsFiles)
|
|
408
|
-
.map(([_fileName, filePath]) => `import '
|
|
408
|
+
.map(([_fileName, filePath]) => `import '../${path__namespace
|
|
409
409
|
.relative(ctx.client.rootDir, filePath)
|
|
410
410
|
.replaceAll("\\", "/")}';`)
|
|
411
411
|
.join("\n");
|
|
412
|
-
await fs__namespace.writeFile(path__namespace.resolve(ctx.client.
|
|
412
|
+
await fs__namespace.writeFile(path__namespace.resolve(ctx.client.buildDir, ctx.outputOptions.typesEntryPointFilename), typeImports);
|
|
413
413
|
}
|
|
414
414
|
async function build$1(ctx) {
|
|
415
415
|
var _a;
|
|
@@ -418,7 +418,7 @@ async function build$1(ctx) {
|
|
|
418
418
|
build: {
|
|
419
419
|
emptyOutDir: false,
|
|
420
420
|
lib: {
|
|
421
|
-
entry: path__namespace.resolve(ctx.client.
|
|
421
|
+
entry: path__namespace.resolve(ctx.client.buildDir, ctx.outputOptions.typesEntryPointFilename),
|
|
422
422
|
formats: ["es"],
|
|
423
423
|
fileName: "embeddable-types",
|
|
424
424
|
},
|
|
@@ -434,7 +434,7 @@ async function build$1(ctx) {
|
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
436
|
async function cleanup$1(ctx) {
|
|
437
|
-
await fs__namespace.rm(path__namespace.resolve(ctx.client.
|
|
437
|
+
await fs__namespace.rm(path__namespace.resolve(ctx.client.buildDir, "embeddable-types-entry-point.js"));
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
var prepare = async (ctx) => {
|
|
@@ -20326,10 +20326,46 @@ const getArgumentByKey = (key) => {
|
|
|
20326
20326
|
const index = process.argv.indexOf(key);
|
|
20327
20327
|
return index !== -1 ? process.argv[index + 1] : undefined;
|
|
20328
20328
|
};
|
|
20329
|
+
const SUCCESS_FLAG_FILE = `${CREDENTIALS_DIR}/success`;
|
|
20330
|
+
/**
|
|
20331
|
+
* Store a flag in the credentials directory to indicate a successful build
|
|
20332
|
+
* This is used to determine if the build was successful or not
|
|
20333
|
+
*/
|
|
20334
|
+
const storeBuildSuccessFlag = async () => {
|
|
20335
|
+
try {
|
|
20336
|
+
await fs__namespace.access(CREDENTIALS_DIR);
|
|
20337
|
+
}
|
|
20338
|
+
catch (_e) {
|
|
20339
|
+
await fs__namespace.mkdir(CREDENTIALS_DIR);
|
|
20340
|
+
}
|
|
20341
|
+
await fs__namespace.writeFile(SUCCESS_FLAG_FILE, "true");
|
|
20342
|
+
};
|
|
20343
|
+
/**
|
|
20344
|
+
* Remove the success flag from the credentials directory
|
|
20345
|
+
*/
|
|
20346
|
+
const removeBuildSuccessFlag = async () => {
|
|
20347
|
+
try {
|
|
20348
|
+
await fs__namespace.unlink(SUCCESS_FLAG_FILE);
|
|
20349
|
+
}
|
|
20350
|
+
catch (_e) { }
|
|
20351
|
+
};
|
|
20352
|
+
/**
|
|
20353
|
+
* Check if the build was successful
|
|
20354
|
+
*/
|
|
20355
|
+
const checkBuildSuccess = async () => {
|
|
20356
|
+
try {
|
|
20357
|
+
await fs__namespace.access(SUCCESS_FLAG_FILE);
|
|
20358
|
+
return true;
|
|
20359
|
+
}
|
|
20360
|
+
catch (_e) {
|
|
20361
|
+
return false;
|
|
20362
|
+
}
|
|
20363
|
+
};
|
|
20329
20364
|
|
|
20330
20365
|
var build = async () => {
|
|
20331
20366
|
try {
|
|
20332
20367
|
checkNodeVersion();
|
|
20368
|
+
removeBuildSuccessFlag();
|
|
20333
20369
|
const config = await provideConfig();
|
|
20334
20370
|
await validate(config);
|
|
20335
20371
|
await prepare(config);
|
|
@@ -20343,6 +20379,7 @@ var build = async () => {
|
|
|
20343
20379
|
// NOTE: likely this will be called inside the loop above if we decide to support clients with mixed frameworks simultaneously.
|
|
20344
20380
|
await generate(config, "sdk-react");
|
|
20345
20381
|
await cleanup(config);
|
|
20382
|
+
await storeBuildSuccessFlag();
|
|
20346
20383
|
}
|
|
20347
20384
|
catch (error) {
|
|
20348
20385
|
await reportErrorToRollbar(error);
|
|
@@ -20440,6 +20477,11 @@ var push = async () => {
|
|
|
20440
20477
|
let spinnerPushing;
|
|
20441
20478
|
try {
|
|
20442
20479
|
checkNodeVersion();
|
|
20480
|
+
const isBuildSuccess = await checkBuildSuccess();
|
|
20481
|
+
if (!isBuildSuccess) {
|
|
20482
|
+
console.error("Build failed or not completed. Please run `embeddable:build` first.");
|
|
20483
|
+
process.exit(1);
|
|
20484
|
+
}
|
|
20443
20485
|
ora$1 = (await oraP$1).default;
|
|
20444
20486
|
const config = await provideConfig();
|
|
20445
20487
|
if (process.argv.includes("--api-key") || process.argv.includes("-k")) {
|
|
@@ -20620,24 +20662,48 @@ let browserWindow = null;
|
|
|
20620
20662
|
let ora;
|
|
20621
20663
|
let previewWorkspace;
|
|
20622
20664
|
const SERVER_PORT = 8926;
|
|
20665
|
+
const BUILD_DEV_DIR = ".embeddable-dev-build";
|
|
20623
20666
|
const buildWebComponent = async (config) => {
|
|
20624
20667
|
await generate(config, "sdk-react");
|
|
20625
20668
|
};
|
|
20669
|
+
const addToGitingore = async () => {
|
|
20670
|
+
try {
|
|
20671
|
+
const fs = require("fs").promises;
|
|
20672
|
+
const gitignorePath = path__namespace$1.resolve(process.cwd(), ".gitignore");
|
|
20673
|
+
const gitignoreContent = await fs.readFile(gitignorePath, "utf8");
|
|
20674
|
+
if (!gitignoreContent.includes(BUILD_DEV_DIR)) {
|
|
20675
|
+
await fs.appendFile(gitignorePath, `\n${BUILD_DEV_DIR}\n`);
|
|
20676
|
+
}
|
|
20677
|
+
}
|
|
20678
|
+
catch (e) {
|
|
20679
|
+
// ignore
|
|
20680
|
+
}
|
|
20681
|
+
};
|
|
20626
20682
|
var dev = async () => {
|
|
20627
20683
|
var _a;
|
|
20628
20684
|
checkNodeVersion();
|
|
20685
|
+
addToGitingore();
|
|
20629
20686
|
const http = require("http");
|
|
20630
20687
|
ora = (await oraP).default;
|
|
20631
20688
|
process.on("warning", (e) => console.warn(e.stack));
|
|
20632
20689
|
const logger = node.createNodeLogger({ process });
|
|
20633
20690
|
const sys = node.createNodeSys({ process });
|
|
20691
|
+
const defaultConfig = await provideConfig();
|
|
20692
|
+
const buildDir = path__namespace$1.resolve(defaultConfig.client.rootDir, ".embeddable-dev-build");
|
|
20634
20693
|
const config = {
|
|
20694
|
+
...defaultConfig,
|
|
20635
20695
|
dev: {
|
|
20636
20696
|
watch: true,
|
|
20637
20697
|
logger,
|
|
20638
20698
|
sys,
|
|
20639
20699
|
},
|
|
20640
|
-
|
|
20700
|
+
client: {
|
|
20701
|
+
...defaultConfig.client,
|
|
20702
|
+
buildDir: buildDir,
|
|
20703
|
+
componentDir: path__namespace$1.resolve(buildDir, "component"),
|
|
20704
|
+
stencilBuild: path__namespace$1.resolve(buildDir, "dist", "embeddable-wrapper"),
|
|
20705
|
+
tmpDir: path__namespace$1.resolve(defaultConfig.client.rootDir, ".embeddable-dev-tmp"),
|
|
20706
|
+
},
|
|
20641
20707
|
};
|
|
20642
20708
|
await prepare(config);
|
|
20643
20709
|
const finalhandler = require("finalhandler");
|