@embeddable.com/sdk-core 3.7.1 → 3.7.3
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 +73 -64
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +73 -64
- package/lib/index.js.map +1 -1
- package/lib/workspaceUtils.d.ts +2 -0
- package/package.json +1 -1
- package/src/dev.ts +15 -4
- package/src/push.ts +13 -64
- package/src/utils.test.ts +3 -5
- package/src/utils.ts +5 -7
- package/src/workspaceUtils.test.ts +131 -0
- package/src/workspaceUtils.ts +65 -0
package/lib/index.esm.js
CHANGED
|
@@ -539,10 +539,9 @@ const CREDENTIALS_DIR = path$1.resolve(os$1.homedir(), ".embeddable");
|
|
|
539
539
|
const CREDENTIALS_FILE = path$1.resolve(CREDENTIALS_DIR, "credentials");
|
|
540
540
|
|
|
541
541
|
const oraP$3 = import('ora');
|
|
542
|
-
let ora$2;
|
|
543
542
|
const checkNodeVersion = async () => {
|
|
544
|
-
ora
|
|
545
|
-
const spinner = ora
|
|
543
|
+
const ora = (await oraP$3).default;
|
|
544
|
+
const spinner = ora("Checking node version...").start();
|
|
546
545
|
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
547
546
|
const packageJson = await Promise.resolve().then(function () { return _package$1; });
|
|
548
547
|
const { engines: { node }, } = packageJson;
|
|
@@ -551,10 +550,7 @@ const checkNodeVersion = async () => {
|
|
|
551
550
|
.map((v) => v.replace(/[^\d]/g, ""))
|
|
552
551
|
.map(Number);
|
|
553
552
|
if (major < minMajor || (major === minMajor && minor < minMinor)) {
|
|
554
|
-
spinner.fail({
|
|
555
|
-
text: `Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`,
|
|
556
|
-
color: "red",
|
|
557
|
-
});
|
|
553
|
+
spinner.fail(`Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`);
|
|
558
554
|
process.exit(1);
|
|
559
555
|
}
|
|
560
556
|
else {
|
|
@@ -20537,8 +20533,58 @@ async function resolveFiles() {
|
|
|
20537
20533
|
}
|
|
20538
20534
|
}
|
|
20539
20535
|
|
|
20540
|
-
const oraP$1 = import('ora');
|
|
20541
20536
|
const inquirerSelect = import('@inquirer/select');
|
|
20537
|
+
async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
20538
|
+
var _a;
|
|
20539
|
+
try {
|
|
20540
|
+
const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
|
|
20541
|
+
headers: {
|
|
20542
|
+
Authorization: `Bearer ${token}`,
|
|
20543
|
+
},
|
|
20544
|
+
});
|
|
20545
|
+
return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
|
|
20546
|
+
}
|
|
20547
|
+
catch (e) {
|
|
20548
|
+
if (e.response.status === 401) {
|
|
20549
|
+
workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
|
|
20550
|
+
}
|
|
20551
|
+
else {
|
|
20552
|
+
workspaceSpinner.fail("Failed to fetch workspaces");
|
|
20553
|
+
}
|
|
20554
|
+
process.exit(1);
|
|
20555
|
+
}
|
|
20556
|
+
}
|
|
20557
|
+
async function selectWorkspace(ora, ctx, token) {
|
|
20558
|
+
const workspaceSpinner = ora({
|
|
20559
|
+
text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
|
|
20560
|
+
color: "green",
|
|
20561
|
+
discardStdin: false,
|
|
20562
|
+
}).start();
|
|
20563
|
+
const availableWorkspaces = await getWorkspaces(ctx, token, workspaceSpinner);
|
|
20564
|
+
let selectedWorkspace;
|
|
20565
|
+
if (availableWorkspaces.length === 0) {
|
|
20566
|
+
workspaceSpinner.fail("No workspaces found");
|
|
20567
|
+
process.exit(1);
|
|
20568
|
+
}
|
|
20569
|
+
workspaceSpinner.info(`Found ${availableWorkspaces.length} workspace(s)`);
|
|
20570
|
+
if (availableWorkspaces.length === 1) {
|
|
20571
|
+
selectedWorkspace = availableWorkspaces[0];
|
|
20572
|
+
}
|
|
20573
|
+
else {
|
|
20574
|
+
const select = (await inquirerSelect).default;
|
|
20575
|
+
selectedWorkspace = await select({
|
|
20576
|
+
message: "Select workspace to push changes",
|
|
20577
|
+
choices: availableWorkspaces.map((workspace) => ({
|
|
20578
|
+
name: `${workspace.name} (${workspace.workspaceId})`,
|
|
20579
|
+
value: workspace,
|
|
20580
|
+
})),
|
|
20581
|
+
});
|
|
20582
|
+
}
|
|
20583
|
+
workspaceSpinner.succeed(`Workspace: ${selectedWorkspace.name} (${selectedWorkspace.workspaceId})`);
|
|
20584
|
+
return selectedWorkspace;
|
|
20585
|
+
}
|
|
20586
|
+
|
|
20587
|
+
const oraP$1 = import('ora');
|
|
20542
20588
|
// grab .cube.yml|js and .sc.yml|js files
|
|
20543
20589
|
const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
|
|
20544
20590
|
// grab all files in self-serve-customization folder
|
|
@@ -20567,7 +20613,7 @@ var push = async () => {
|
|
|
20567
20613
|
spinnerPushing = ora$1()
|
|
20568
20614
|
.start()
|
|
20569
20615
|
.info("No API Key provided. Standard login will be used.");
|
|
20570
|
-
const { workspaceId, name: workspaceName } = await selectWorkspace(config, token);
|
|
20616
|
+
const { workspaceId, name: workspaceName } = await selectWorkspace(ora$1, config, token);
|
|
20571
20617
|
const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`;
|
|
20572
20618
|
await buildArchive(config);
|
|
20573
20619
|
spinnerPushing.info(`Publishing to ${workspaceName} using ${workspacePreviewUrl}...`);
|
|
@@ -20606,35 +20652,6 @@ async function pushByApiKey(config, spinner) {
|
|
|
20606
20652
|
message,
|
|
20607
20653
|
});
|
|
20608
20654
|
}
|
|
20609
|
-
async function selectWorkspace(ctx, token) {
|
|
20610
|
-
const workspaceSpinner = ora$1({
|
|
20611
|
-
text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
|
|
20612
|
-
color: "green",
|
|
20613
|
-
discardStdin: false,
|
|
20614
|
-
}).start();
|
|
20615
|
-
const availableWorkspaces = await getWorkspaces(ctx, token, workspaceSpinner);
|
|
20616
|
-
let selectedWorkspace;
|
|
20617
|
-
if (availableWorkspaces.length === 0) {
|
|
20618
|
-
workspaceSpinner.fail("No workspaces found");
|
|
20619
|
-
process.exit(1);
|
|
20620
|
-
}
|
|
20621
|
-
workspaceSpinner.info(`Found ${availableWorkspaces.length} workspace(s)`);
|
|
20622
|
-
if (availableWorkspaces.length === 1) {
|
|
20623
|
-
selectedWorkspace = availableWorkspaces[0];
|
|
20624
|
-
}
|
|
20625
|
-
else {
|
|
20626
|
-
const select = (await inquirerSelect).default;
|
|
20627
|
-
selectedWorkspace = await select({
|
|
20628
|
-
message: "Select workspace to push changes",
|
|
20629
|
-
choices: availableWorkspaces.map((workspace) => ({
|
|
20630
|
-
name: `${workspace.name} (${workspace.workspaceId})`,
|
|
20631
|
-
value: workspace,
|
|
20632
|
-
})),
|
|
20633
|
-
});
|
|
20634
|
-
}
|
|
20635
|
-
workspaceSpinner.succeed(`Workspace: ${selectedWorkspace.name} (${selectedWorkspace.workspaceId})`);
|
|
20636
|
-
return selectedWorkspace;
|
|
20637
|
-
}
|
|
20638
20655
|
async function verify(ctx) {
|
|
20639
20656
|
try {
|
|
20640
20657
|
await fs$1.access(ctx.client.buildDir);
|
|
@@ -20654,7 +20671,13 @@ async function verify(ctx) {
|
|
|
20654
20671
|
async function buildArchive(config) {
|
|
20655
20672
|
const spinnerArchive = ora$1("Building...").start();
|
|
20656
20673
|
const filesList = await findFiles(config.client.modelsSrc || config.client.srcDir, YAML_OR_JS_FILES);
|
|
20657
|
-
|
|
20674
|
+
let selfServeFiles = [];
|
|
20675
|
+
// check existance of self-serve-customization folder
|
|
20676
|
+
try {
|
|
20677
|
+
await fs$1.access(config.client.selfServeCustomizationDir);
|
|
20678
|
+
selfServeFiles = await findFiles(`${config.client.selfServeCustomizationDir}`, SELF_SERVE_CUSTOM_FILES);
|
|
20679
|
+
}
|
|
20680
|
+
catch (e) { }
|
|
20658
20681
|
await archive(config, filesList, selfServeFiles);
|
|
20659
20682
|
return spinnerArchive.succeed("Bundling completed");
|
|
20660
20683
|
}
|
|
@@ -20718,26 +20741,6 @@ async function uploadFile(formData, url, token) {
|
|
|
20718
20741
|
maxBodyLength: Infinity,
|
|
20719
20742
|
});
|
|
20720
20743
|
}
|
|
20721
|
-
async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
20722
|
-
var _a;
|
|
20723
|
-
try {
|
|
20724
|
-
const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
|
|
20725
|
-
headers: {
|
|
20726
|
-
Authorization: `Bearer ${token}`,
|
|
20727
|
-
},
|
|
20728
|
-
});
|
|
20729
|
-
return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
|
|
20730
|
-
}
|
|
20731
|
-
catch (e) {
|
|
20732
|
-
if (e.response.status === 401) {
|
|
20733
|
-
workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
|
|
20734
|
-
}
|
|
20735
|
-
else {
|
|
20736
|
-
workspaceSpinner.fail("Failed to fetch workspaces");
|
|
20737
|
-
}
|
|
20738
|
-
process.exit(1);
|
|
20739
|
-
}
|
|
20740
|
-
}
|
|
20741
20744
|
|
|
20742
20745
|
const minimist = require("minimist");
|
|
20743
20746
|
const oraP = import('ora');
|
|
@@ -20798,7 +20801,7 @@ var dev = async () => {
|
|
|
20798
20801
|
const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
|
|
20799
20802
|
const workspacePreparation = ora("Preparing workspace...").start();
|
|
20800
20803
|
try {
|
|
20801
|
-
previewWorkspace = await getPreviewWorkspace(config);
|
|
20804
|
+
previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
|
|
20802
20805
|
}
|
|
20803
20806
|
catch (e) {
|
|
20804
20807
|
workspacePreparation.fail((_a = e.response.data) === null || _a === void 0 ? void 0 : _a.errorMessage);
|
|
@@ -20961,10 +20964,16 @@ const onClose = async (server, sys, watchers, config) => {
|
|
|
20961
20964
|
await sys.destroy();
|
|
20962
20965
|
process.exit(0);
|
|
20963
20966
|
};
|
|
20964
|
-
const getPreviewWorkspace = async (ctx) => {
|
|
20967
|
+
const getPreviewWorkspace = async (startedOra, ctx) => {
|
|
20965
20968
|
const token = await getToken();
|
|
20966
20969
|
const params = minimist(process.argv.slice(2));
|
|
20967
|
-
|
|
20970
|
+
let primaryWorkspace = params.w || params.workspace;
|
|
20971
|
+
if (!primaryWorkspace) {
|
|
20972
|
+
startedOra.stop(); // Stop current Ora, otherwise the last option will get hidden by it.
|
|
20973
|
+
const { workspaceId } = await selectWorkspace(ora, ctx, token);
|
|
20974
|
+
primaryWorkspace = workspaceId;
|
|
20975
|
+
startedOra.start();
|
|
20976
|
+
}
|
|
20968
20977
|
try {
|
|
20969
20978
|
const response = await axios.get(`${ctx.pushBaseUrl}/workspace/dev-workspace`, {
|
|
20970
20979
|
params: { primaryWorkspace },
|
|
@@ -20978,7 +20987,7 @@ const getPreviewWorkspace = async (ctx) => {
|
|
|
20978
20987
|
if (e.response.status === 401) {
|
|
20979
20988
|
// login and retry
|
|
20980
20989
|
await login();
|
|
20981
|
-
return await getPreviewWorkspace(ctx);
|
|
20990
|
+
return await getPreviewWorkspace(startedOra, ctx);
|
|
20982
20991
|
}
|
|
20983
20992
|
else {
|
|
20984
20993
|
throw e;
|
|
@@ -21039,7 +21048,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21039
21048
|
};
|
|
21040
21049
|
|
|
21041
21050
|
var name = "@embeddable.com/sdk-core";
|
|
21042
|
-
var version = "3.7.
|
|
21051
|
+
var version = "3.7.3";
|
|
21043
21052
|
var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
|
|
21044
21053
|
var keywords = [
|
|
21045
21054
|
"embeddable",
|