@embeddable.com/sdk-core 3.2.0 → 3.2.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.esm.js +57 -9
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +57 -9
- 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 -5
- package/src/generate.ts +9 -4
- package/src/push.ts +9 -1
- package/src/utils.ts +38 -0
package/lib/index.js
CHANGED
|
@@ -412,6 +412,7 @@ async function generate$1(ctx) {
|
|
|
412
412
|
await fs__namespace.writeFile(path__namespace.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename), typeImports);
|
|
413
413
|
}
|
|
414
414
|
async function build$1(ctx) {
|
|
415
|
+
var _a;
|
|
415
416
|
await vite__namespace.build({
|
|
416
417
|
logLevel: "error",
|
|
417
418
|
build: {
|
|
@@ -421,11 +422,13 @@ async function build$1(ctx) {
|
|
|
421
422
|
formats: ["es"],
|
|
422
423
|
fileName: "embeddable-types",
|
|
423
424
|
},
|
|
424
|
-
rollupOptions:
|
|
425
|
-
|
|
426
|
-
|
|
425
|
+
rollupOptions: ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch)
|
|
426
|
+
? undefined
|
|
427
|
+
: {
|
|
428
|
+
output: {
|
|
429
|
+
entryFileNames: "embeddable-types-[hash].js",
|
|
430
|
+
},
|
|
427
431
|
},
|
|
428
|
-
},
|
|
429
432
|
outDir: ctx.client.buildDir,
|
|
430
433
|
},
|
|
431
434
|
});
|
|
@@ -477,7 +480,7 @@ async function injectBundleRender(ctx, pluginName) {
|
|
|
477
480
|
await fs__namespace.writeFile(path__namespace.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, importStr));
|
|
478
481
|
}
|
|
479
482
|
async function runStencil(ctx) {
|
|
480
|
-
var _a, _b;
|
|
483
|
+
var _a, _b, _c;
|
|
481
484
|
const logger = ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.logger) || node.createNodeLogger({ process });
|
|
482
485
|
const sys = ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.sys) || node.createNodeSys({ process });
|
|
483
486
|
const devMode = !!ctx.dev;
|
|
@@ -504,10 +507,13 @@ async function runStencil(ctx) {
|
|
|
504
507
|
const compiler$1 = await compiler.createCompiler(validated.config);
|
|
505
508
|
await compiler$1.build();
|
|
506
509
|
const entryFilePath = path__namespace.resolve(ctx.client.stencilBuild, "embeddable-wrapper.esm.js");
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
510
|
+
let fileName = "embeddable-wrapper.esm.js";
|
|
511
|
+
if (!((_c = ctx.dev) === null || _c === void 0 ? void 0 : _c.watch)) {
|
|
512
|
+
const entryFileContent = await fs__namespace.readFile(entryFilePath, "utf8");
|
|
513
|
+
const fileHash = getContentHash(entryFileContent);
|
|
514
|
+
fileName = `embeddable-wrapper.esm-${fileHash}.js`;
|
|
515
|
+
}
|
|
516
|
+
await fs__namespace.rename(entryFilePath, path__namespace.resolve(ctx.client.stencilBuild, fileName));
|
|
511
517
|
await compiler$1.destroy();
|
|
512
518
|
process.chdir(ctx.client.rootDir);
|
|
513
519
|
}
|
|
@@ -20320,10 +20326,46 @@ const getArgumentByKey = (key) => {
|
|
|
20320
20326
|
const index = process.argv.indexOf(key);
|
|
20321
20327
|
return index !== -1 ? process.argv[index + 1] : undefined;
|
|
20322
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
|
+
};
|
|
20323
20364
|
|
|
20324
20365
|
var build = async () => {
|
|
20325
20366
|
try {
|
|
20326
20367
|
checkNodeVersion();
|
|
20368
|
+
removeBuildSuccessFlag();
|
|
20327
20369
|
const config = await provideConfig();
|
|
20328
20370
|
await validate(config);
|
|
20329
20371
|
await prepare(config);
|
|
@@ -20337,6 +20379,7 @@ var build = async () => {
|
|
|
20337
20379
|
// NOTE: likely this will be called inside the loop above if we decide to support clients with mixed frameworks simultaneously.
|
|
20338
20380
|
await generate(config, "sdk-react");
|
|
20339
20381
|
await cleanup(config);
|
|
20382
|
+
await storeBuildSuccessFlag();
|
|
20340
20383
|
}
|
|
20341
20384
|
catch (error) {
|
|
20342
20385
|
await reportErrorToRollbar(error);
|
|
@@ -20434,6 +20477,11 @@ var push = async () => {
|
|
|
20434
20477
|
let spinnerPushing;
|
|
20435
20478
|
try {
|
|
20436
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
|
+
}
|
|
20437
20485
|
ora$1 = (await oraP$1).default;
|
|
20438
20486
|
const config = await provideConfig();
|
|
20439
20487
|
if (process.argv.includes("--api-key") || process.argv.includes("-k")) {
|