@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.esm.js
CHANGED
|
@@ -385,6 +385,7 @@ async function generate$1(ctx) {
|
|
|
385
385
|
await fs$1.writeFile(path$1.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename), typeImports);
|
|
386
386
|
}
|
|
387
387
|
async function build$1(ctx) {
|
|
388
|
+
var _a;
|
|
388
389
|
await vite.build({
|
|
389
390
|
logLevel: "error",
|
|
390
391
|
build: {
|
|
@@ -394,11 +395,13 @@ async function build$1(ctx) {
|
|
|
394
395
|
formats: ["es"],
|
|
395
396
|
fileName: "embeddable-types",
|
|
396
397
|
},
|
|
397
|
-
rollupOptions:
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
rollupOptions: ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.watch)
|
|
399
|
+
? undefined
|
|
400
|
+
: {
|
|
401
|
+
output: {
|
|
402
|
+
entryFileNames: "embeddable-types-[hash].js",
|
|
403
|
+
},
|
|
400
404
|
},
|
|
401
|
-
},
|
|
402
405
|
outDir: ctx.client.buildDir,
|
|
403
406
|
},
|
|
404
407
|
});
|
|
@@ -450,7 +453,7 @@ async function injectBundleRender(ctx, pluginName) {
|
|
|
450
453
|
await fs$1.writeFile(path$1.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, importStr));
|
|
451
454
|
}
|
|
452
455
|
async function runStencil(ctx) {
|
|
453
|
-
var _a, _b;
|
|
456
|
+
var _a, _b, _c;
|
|
454
457
|
const logger = ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.logger) || createNodeLogger({ process });
|
|
455
458
|
const sys = ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.sys) || createNodeSys({ process });
|
|
456
459
|
const devMode = !!ctx.dev;
|
|
@@ -477,10 +480,13 @@ async function runStencil(ctx) {
|
|
|
477
480
|
const compiler = await createCompiler(validated.config);
|
|
478
481
|
await compiler.build();
|
|
479
482
|
const entryFilePath = path$1.resolve(ctx.client.stencilBuild, "embeddable-wrapper.esm.js");
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
483
|
+
let fileName = "embeddable-wrapper.esm.js";
|
|
484
|
+
if (!((_c = ctx.dev) === null || _c === void 0 ? void 0 : _c.watch)) {
|
|
485
|
+
const entryFileContent = await fs$1.readFile(entryFilePath, "utf8");
|
|
486
|
+
const fileHash = getContentHash(entryFileContent);
|
|
487
|
+
fileName = `embeddable-wrapper.esm-${fileHash}.js`;
|
|
488
|
+
}
|
|
489
|
+
await fs$1.rename(entryFilePath, path$1.resolve(ctx.client.stencilBuild, fileName));
|
|
484
490
|
await compiler.destroy();
|
|
485
491
|
process.chdir(ctx.client.rootDir);
|
|
486
492
|
}
|
|
@@ -20293,10 +20299,46 @@ const getArgumentByKey = (key) => {
|
|
|
20293
20299
|
const index = process.argv.indexOf(key);
|
|
20294
20300
|
return index !== -1 ? process.argv[index + 1] : undefined;
|
|
20295
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
|
+
};
|
|
20296
20337
|
|
|
20297
20338
|
var build = async () => {
|
|
20298
20339
|
try {
|
|
20299
20340
|
checkNodeVersion();
|
|
20341
|
+
removeBuildSuccessFlag();
|
|
20300
20342
|
const config = await provideConfig();
|
|
20301
20343
|
await validate(config);
|
|
20302
20344
|
await prepare(config);
|
|
@@ -20310,6 +20352,7 @@ var build = async () => {
|
|
|
20310
20352
|
// NOTE: likely this will be called inside the loop above if we decide to support clients with mixed frameworks simultaneously.
|
|
20311
20353
|
await generate(config, "sdk-react");
|
|
20312
20354
|
await cleanup(config);
|
|
20355
|
+
await storeBuildSuccessFlag();
|
|
20313
20356
|
}
|
|
20314
20357
|
catch (error) {
|
|
20315
20358
|
await reportErrorToRollbar(error);
|
|
@@ -20407,6 +20450,11 @@ var push = async () => {
|
|
|
20407
20450
|
let spinnerPushing;
|
|
20408
20451
|
try {
|
|
20409
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
|
+
}
|
|
20410
20458
|
ora$1 = (await oraP$1).default;
|
|
20411
20459
|
const config = await provideConfig();
|
|
20412
20460
|
if (process.argv.includes("--api-key") || process.argv.includes("-k")) {
|