@embeddable.com/sdk-core 3.3.0 → 3.3.1
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 +147 -96
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +145 -94
- package/lib/index.js.map +1 -1
- package/lib/utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/cleanup.ts +77 -14
- package/src/utils.ts +16 -0
package/lib/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs$1 from 'node:fs/promises';
|
|
2
2
|
import fs__default, { readdir, lstat } from 'node:fs/promises';
|
|
3
3
|
import * as path$1 from 'node:path';
|
|
4
|
-
import { join } from 'node:path';
|
|
4
|
+
import path__default, { join } from 'node:path';
|
|
5
5
|
import * as vite from 'vite';
|
|
6
6
|
import 'node:child_process';
|
|
7
7
|
import * as crypto from 'node:crypto';
|
|
@@ -9,17 +9,17 @@ import * as fs$2 from 'node:fs';
|
|
|
9
9
|
import { existsSync } from 'node:fs';
|
|
10
10
|
import { createNodeLogger, createNodeSys } from '@stencil/core/sys/node';
|
|
11
11
|
import { loadConfig, createCompiler } from '@stencil/core/compiler';
|
|
12
|
+
import * as os$1 from 'node:os';
|
|
12
13
|
import * as YAML from 'yaml';
|
|
13
14
|
import * as url$2 from 'node:url';
|
|
14
15
|
import * as path$2 from 'path';
|
|
15
|
-
import path__default, { basename } from 'path';
|
|
16
|
+
import path__default$1, { basename } from 'path';
|
|
16
17
|
import require$$4$1 from 'util';
|
|
17
18
|
import require$$1 from 'os';
|
|
18
19
|
import require$$3 from 'http';
|
|
19
20
|
import require$$4 from 'https';
|
|
20
21
|
import require$$0$1 from 'url';
|
|
21
22
|
import require$$2$1, { createReadStream } from 'fs';
|
|
22
|
-
import * as os$1 from 'node:os';
|
|
23
23
|
import axios from 'axios';
|
|
24
24
|
import * as archiver from 'archiver';
|
|
25
25
|
import { WebSocketServer } from 'ws';
|
|
@@ -510,11 +510,142 @@ async function generateSourceMap(ctx, pluginName) {
|
|
|
510
510
|
await fs$1.rm(tmpComponentDir, { recursive: true });
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
+
const CREDENTIALS_DIR = path$1.resolve(os$1.homedir(), ".embeddable");
|
|
514
|
+
const CREDENTIALS_FILE = path$1.resolve(CREDENTIALS_DIR, "credentials");
|
|
515
|
+
|
|
516
|
+
const oraP$3 = import('ora');
|
|
517
|
+
let ora$2;
|
|
518
|
+
const checkNodeVersion$1 = async () => {
|
|
519
|
+
ora$2 = (await oraP$3).default;
|
|
520
|
+
ora$2("Checking node version...");
|
|
521
|
+
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
522
|
+
const engines = require("../package.json").engines.node;
|
|
523
|
+
const [minMajor, minMinor] = engines
|
|
524
|
+
.split(".")
|
|
525
|
+
.map((v) => v.replace(/[^\d]/g, ""))
|
|
526
|
+
.map(Number);
|
|
527
|
+
if (major < minMajor || (major === minMajor && minor < minMinor)) {
|
|
528
|
+
ora$2({
|
|
529
|
+
text: `Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`,
|
|
530
|
+
color: "red",
|
|
531
|
+
}).fail();
|
|
532
|
+
process.exit(1);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
/**
|
|
536
|
+
* Get the value of a process argument by key
|
|
537
|
+
* Example: getArgumentByKey("--email") or getArgumentByKey(["--email", "-e"])
|
|
538
|
+
* @param key The key to search for in the process arguments
|
|
539
|
+
* @returns
|
|
540
|
+
*/
|
|
541
|
+
const getArgumentByKey = (key) => {
|
|
542
|
+
if (Array.isArray(key)) {
|
|
543
|
+
for (const k of key) {
|
|
544
|
+
if (process.argv.includes(k)) {
|
|
545
|
+
const index = process.argv.indexOf(k);
|
|
546
|
+
return index !== -1 ? process.argv[index + 1] : undefined;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return undefined;
|
|
550
|
+
}
|
|
551
|
+
const index = process.argv.indexOf(key);
|
|
552
|
+
return index !== -1 ? process.argv[index + 1] : undefined;
|
|
553
|
+
};
|
|
554
|
+
const SUCCESS_FLAG_FILE = `${CREDENTIALS_DIR}/success`;
|
|
555
|
+
/**
|
|
556
|
+
* Store a flag in the credentials directory to indicate a successful build
|
|
557
|
+
* This is used to determine if the build was successful or not
|
|
558
|
+
*/
|
|
559
|
+
const storeBuildSuccessFlag = async () => {
|
|
560
|
+
try {
|
|
561
|
+
await fs$1.access(CREDENTIALS_DIR);
|
|
562
|
+
}
|
|
563
|
+
catch (_e) {
|
|
564
|
+
await fs$1.mkdir(CREDENTIALS_DIR);
|
|
565
|
+
}
|
|
566
|
+
await fs$1.writeFile(SUCCESS_FLAG_FILE, "true");
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* Remove the success flag from the credentials directory
|
|
570
|
+
*/
|
|
571
|
+
const removeBuildSuccessFlag = async () => {
|
|
572
|
+
try {
|
|
573
|
+
await fs$1.unlink(SUCCESS_FLAG_FILE);
|
|
574
|
+
}
|
|
575
|
+
catch (_e) { }
|
|
576
|
+
};
|
|
577
|
+
/**
|
|
578
|
+
* Check if the build was successful
|
|
579
|
+
*/
|
|
580
|
+
const checkBuildSuccess = async () => {
|
|
581
|
+
try {
|
|
582
|
+
await fs$1.access(SUCCESS_FLAG_FILE);
|
|
583
|
+
return true;
|
|
584
|
+
}
|
|
585
|
+
catch (_e) {
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
const getPackageVersion = (packageName) => {
|
|
590
|
+
const packageJsonPath = path__default.join(process.cwd(), "node_modules", packageName, "package.json");
|
|
591
|
+
try {
|
|
592
|
+
const packageJson = require(packageJsonPath);
|
|
593
|
+
return packageJson.version;
|
|
594
|
+
}
|
|
595
|
+
catch (e) {
|
|
596
|
+
return undefined;
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
|
|
513
600
|
var cleanup = async (ctx) => {
|
|
514
601
|
await extractBuild(ctx);
|
|
515
602
|
await removeObsoleteDir(ctx.client.buildDir);
|
|
516
603
|
await moveBuildTOBuildDir(ctx);
|
|
517
604
|
};
|
|
605
|
+
async function createManifest({ ctx, typesFileName, metaFileName, editorsMetaFileName, stencilWrapperFileName, }) {
|
|
606
|
+
var _a, _b, _c, _d;
|
|
607
|
+
const packageNames = [
|
|
608
|
+
"@embeddable.com/core",
|
|
609
|
+
"@embeddable.com/react",
|
|
610
|
+
"@embeddable.com/sdk-core",
|
|
611
|
+
"@embeddable.com/sdk-react",
|
|
612
|
+
"@embeddable.com/sdk-utils",
|
|
613
|
+
];
|
|
614
|
+
const sdkVersions = packageNames.reduce((acc, packageName) => {
|
|
615
|
+
const version = getPackageVersion(packageName);
|
|
616
|
+
if (version) {
|
|
617
|
+
acc[packageName] = version;
|
|
618
|
+
}
|
|
619
|
+
return acc;
|
|
620
|
+
}, {});
|
|
621
|
+
// identify user's package manager and its version
|
|
622
|
+
let packageManager = "npm";
|
|
623
|
+
if ((_a = process.env.npm_config_user_agent) === null || _a === void 0 ? void 0 : _a.includes("yarn")) {
|
|
624
|
+
packageManager = "yarn";
|
|
625
|
+
}
|
|
626
|
+
if ((_b = process.env.npm_config_user_agent) === null || _b === void 0 ? void 0 : _b.includes("pnpm")) {
|
|
627
|
+
packageManager = "pnpm";
|
|
628
|
+
}
|
|
629
|
+
const packageManagerVersion = ((_d = (_c = process.env.npm_config_user_agent) === null || _c === void 0 ? void 0 : _c.match(/(\d+\.\d+\.\d+)/)) === null || _d === void 0 ? void 0 : _d[0]) ||
|
|
630
|
+
"unknown";
|
|
631
|
+
// write manifest file with files with hash
|
|
632
|
+
const manifest = {
|
|
633
|
+
entryFiles: {
|
|
634
|
+
"embeddable-types.js": typesFileName,
|
|
635
|
+
"embeddable-components-meta.js": metaFileName,
|
|
636
|
+
"embeddable-editors-meta.js": editorsMetaFileName,
|
|
637
|
+
"embeddable-wrapper.esm.js": stencilWrapperFileName,
|
|
638
|
+
},
|
|
639
|
+
metadata: {
|
|
640
|
+
nodeVersion: process.version,
|
|
641
|
+
platform: process.platform,
|
|
642
|
+
sdkVersions,
|
|
643
|
+
packageManager,
|
|
644
|
+
packageManagerVersion,
|
|
645
|
+
},
|
|
646
|
+
};
|
|
647
|
+
await fs$1.writeFile(path$1.join(ctx.client.tmpDir, "embeddable-manifest.json"), JSON.stringify(manifest));
|
|
648
|
+
}
|
|
518
649
|
async function extractBuild(ctx) {
|
|
519
650
|
const [[, stencilWrapperFilePath]] = await findFiles(ctx.client.stencilBuild, /embeddable-wrapper.esm-[a-z0-9]+\.js/);
|
|
520
651
|
const stencilWrapperFileName = path$1.basename(stencilWrapperFilePath);
|
|
@@ -528,16 +659,13 @@ async function extractBuild(ctx) {
|
|
|
528
659
|
const [[, editorsMetaFilePath]] = await findFiles(ctx.client.buildDir, /embeddable-editors-meta-[a-z0-9]+\.js/);
|
|
529
660
|
const editorsMetaFileName = path$1.basename(editorsMetaFilePath);
|
|
530
661
|
await fs$1.rename(editorsMetaFilePath, path$1.join(ctx.client.tmpDir, editorsMetaFileName));
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
},
|
|
539
|
-
};
|
|
540
|
-
await fs$1.writeFile(path$1.join(ctx.client.tmpDir, "embeddable-manifest.json"), JSON.stringify(manifest));
|
|
662
|
+
await createManifest({
|
|
663
|
+
ctx,
|
|
664
|
+
typesFileName,
|
|
665
|
+
metaFileName,
|
|
666
|
+
editorsMetaFileName,
|
|
667
|
+
stencilWrapperFileName,
|
|
668
|
+
});
|
|
541
669
|
}
|
|
542
670
|
async function removeObsoleteDir(dir) {
|
|
543
671
|
await fs$1.rm(dir, { recursive: true });
|
|
@@ -4783,7 +4911,7 @@ var z = /*#__PURE__*/Object.freeze({
|
|
|
4783
4911
|
|
|
4784
4912
|
const CUBE_YAML_FILE_REGEX = /^(.*)\.cube\.ya?ml$/;
|
|
4785
4913
|
const SECURITY_CONTEXT_FILE_REGEX = /^(.*)\.sc\.ya?ml$/;
|
|
4786
|
-
const checkNodeVersion
|
|
4914
|
+
const checkNodeVersion = () => {
|
|
4787
4915
|
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
4788
4916
|
const engines = require("../package.json").engines.node;
|
|
4789
4917
|
const [minMajor, minMinor] = engines.split(".").map(Number);
|
|
@@ -4792,7 +4920,7 @@ const checkNodeVersion$1 = () => {
|
|
|
4792
4920
|
}
|
|
4793
4921
|
};
|
|
4794
4922
|
var validate = async (ctx, exitIfInvalid = true) => {
|
|
4795
|
-
checkNodeVersion
|
|
4923
|
+
checkNodeVersion();
|
|
4796
4924
|
const ora = (await import('ora')).default;
|
|
4797
4925
|
const spinnerValidate = ora("Data model validation...").start();
|
|
4798
4926
|
const filesList = await findFiles(ctx.client.srcDir, CUBE_YAML_FILE_REGEX);
|
|
@@ -17174,7 +17302,7 @@ sourceMap.SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
|
|
|
17174
17302
|
sourceMap.SourceNode = sourceNode.SourceNode;
|
|
17175
17303
|
|
|
17176
17304
|
var SourceMapConsumer = sourceMap.SourceMapConsumer;
|
|
17177
|
-
var path = path__default;
|
|
17305
|
+
var path = path__default$1;
|
|
17178
17306
|
var fs = require$$2$1;
|
|
17179
17307
|
|
|
17180
17308
|
/**
|
|
@@ -20124,9 +20252,6 @@ var rollbar = Rollbar;
|
|
|
20124
20252
|
|
|
20125
20253
|
var Rollbar$1 = /*@__PURE__*/getDefaultExportFromCjs(rollbar);
|
|
20126
20254
|
|
|
20127
|
-
const CREDENTIALS_DIR = path$1.resolve(os$1.homedir(), ".embeddable");
|
|
20128
|
-
const CREDENTIALS_FILE = path$1.resolve(CREDENTIALS_DIR, "credentials");
|
|
20129
|
-
|
|
20130
20255
|
class InvalidTokenError extends Error {
|
|
20131
20256
|
}
|
|
20132
20257
|
InvalidTokenError.prototype.name = "InvalidTokenError";
|
|
@@ -20261,83 +20386,9 @@ async function getUserData() {
|
|
|
20261
20386
|
}
|
|
20262
20387
|
}
|
|
20263
20388
|
|
|
20264
|
-
const oraP$3 = import('ora');
|
|
20265
|
-
let ora$2;
|
|
20266
|
-
const checkNodeVersion = async () => {
|
|
20267
|
-
ora$2 = (await oraP$3).default;
|
|
20268
|
-
ora$2("Checking node version...");
|
|
20269
|
-
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
20270
|
-
const engines = require("../package.json").engines.node;
|
|
20271
|
-
const [minMajor, minMinor] = engines
|
|
20272
|
-
.split(".")
|
|
20273
|
-
.map((v) => v.replace(/[^\d]/g, ""))
|
|
20274
|
-
.map(Number);
|
|
20275
|
-
if (major < minMajor || (major === minMajor && minor < minMinor)) {
|
|
20276
|
-
ora$2({
|
|
20277
|
-
text: `Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`,
|
|
20278
|
-
color: "red",
|
|
20279
|
-
}).fail();
|
|
20280
|
-
process.exit(1);
|
|
20281
|
-
}
|
|
20282
|
-
};
|
|
20283
|
-
/**
|
|
20284
|
-
* Get the value of a process argument by key
|
|
20285
|
-
* Example: getArgumentByKey("--email") or getArgumentByKey(["--email", "-e"])
|
|
20286
|
-
* @param key The key to search for in the process arguments
|
|
20287
|
-
* @returns
|
|
20288
|
-
*/
|
|
20289
|
-
const getArgumentByKey = (key) => {
|
|
20290
|
-
if (Array.isArray(key)) {
|
|
20291
|
-
for (const k of key) {
|
|
20292
|
-
if (process.argv.includes(k)) {
|
|
20293
|
-
const index = process.argv.indexOf(k);
|
|
20294
|
-
return index !== -1 ? process.argv[index + 1] : undefined;
|
|
20295
|
-
}
|
|
20296
|
-
}
|
|
20297
|
-
return undefined;
|
|
20298
|
-
}
|
|
20299
|
-
const index = process.argv.indexOf(key);
|
|
20300
|
-
return index !== -1 ? process.argv[index + 1] : undefined;
|
|
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
|
-
};
|
|
20337
|
-
|
|
20338
20389
|
var build = async () => {
|
|
20339
20390
|
try {
|
|
20340
|
-
checkNodeVersion();
|
|
20391
|
+
checkNodeVersion$1();
|
|
20341
20392
|
removeBuildSuccessFlag();
|
|
20342
20393
|
const config = await provideConfig();
|
|
20343
20394
|
await validate(config);
|
|
@@ -20449,7 +20500,7 @@ var push = async () => {
|
|
|
20449
20500
|
var _a, _b;
|
|
20450
20501
|
let spinnerPushing;
|
|
20451
20502
|
try {
|
|
20452
|
-
checkNodeVersion();
|
|
20503
|
+
checkNodeVersion$1();
|
|
20453
20504
|
const isBuildSuccess = await checkBuildSuccess();
|
|
20454
20505
|
if (!isBuildSuccess) {
|
|
20455
20506
|
console.error("Build failed or not completed. Please run `embeddable:build` first.");
|
|
@@ -20654,7 +20705,7 @@ const addToGitingore = async () => {
|
|
|
20654
20705
|
};
|
|
20655
20706
|
var dev = async () => {
|
|
20656
20707
|
var _a;
|
|
20657
|
-
checkNodeVersion();
|
|
20708
|
+
checkNodeVersion$1();
|
|
20658
20709
|
addToGitingore();
|
|
20659
20710
|
const http = require("http");
|
|
20660
20711
|
ora = (await oraP).default;
|