@embeddable.com/sdk-core 3.7.2 → 3.7.4
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 +67 -63
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +67 -63
- 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 +3 -60
- package/src/utils.test.ts +4 -5
- package/src/utils.ts +6 -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,13 +550,11 @@ 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 {
|
|
557
|
+
spinner.stop();
|
|
561
558
|
return true;
|
|
562
559
|
}
|
|
563
560
|
};
|
|
@@ -20537,8 +20534,58 @@ async function resolveFiles() {
|
|
|
20537
20534
|
}
|
|
20538
20535
|
}
|
|
20539
20536
|
|
|
20540
|
-
const oraP$1 = import('ora');
|
|
20541
20537
|
const inquirerSelect = import('@inquirer/select');
|
|
20538
|
+
async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
20539
|
+
var _a;
|
|
20540
|
+
try {
|
|
20541
|
+
const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
|
|
20542
|
+
headers: {
|
|
20543
|
+
Authorization: `Bearer ${token}`,
|
|
20544
|
+
},
|
|
20545
|
+
});
|
|
20546
|
+
return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
|
|
20547
|
+
}
|
|
20548
|
+
catch (e) {
|
|
20549
|
+
if (e.response.status === 401) {
|
|
20550
|
+
workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
|
|
20551
|
+
}
|
|
20552
|
+
else {
|
|
20553
|
+
workspaceSpinner.fail("Failed to fetch workspaces");
|
|
20554
|
+
}
|
|
20555
|
+
process.exit(1);
|
|
20556
|
+
}
|
|
20557
|
+
}
|
|
20558
|
+
async function selectWorkspace(ora, ctx, token) {
|
|
20559
|
+
const workspaceSpinner = ora({
|
|
20560
|
+
text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
|
|
20561
|
+
color: "green",
|
|
20562
|
+
discardStdin: false,
|
|
20563
|
+
}).start();
|
|
20564
|
+
const availableWorkspaces = await getWorkspaces(ctx, token, workspaceSpinner);
|
|
20565
|
+
let selectedWorkspace;
|
|
20566
|
+
if (availableWorkspaces.length === 0) {
|
|
20567
|
+
workspaceSpinner.fail("No workspaces found");
|
|
20568
|
+
process.exit(1);
|
|
20569
|
+
}
|
|
20570
|
+
workspaceSpinner.info(`Found ${availableWorkspaces.length} workspace(s)`);
|
|
20571
|
+
if (availableWorkspaces.length === 1) {
|
|
20572
|
+
selectedWorkspace = availableWorkspaces[0];
|
|
20573
|
+
}
|
|
20574
|
+
else {
|
|
20575
|
+
const select = (await inquirerSelect).default;
|
|
20576
|
+
selectedWorkspace = await select({
|
|
20577
|
+
message: "Select workspace to push changes",
|
|
20578
|
+
choices: availableWorkspaces.map((workspace) => ({
|
|
20579
|
+
name: `${workspace.name} (${workspace.workspaceId})`,
|
|
20580
|
+
value: workspace,
|
|
20581
|
+
})),
|
|
20582
|
+
});
|
|
20583
|
+
}
|
|
20584
|
+
workspaceSpinner.succeed(`Workspace: ${selectedWorkspace.name} (${selectedWorkspace.workspaceId})`);
|
|
20585
|
+
return selectedWorkspace;
|
|
20586
|
+
}
|
|
20587
|
+
|
|
20588
|
+
const oraP$1 = import('ora');
|
|
20542
20589
|
// grab .cube.yml|js and .sc.yml|js files
|
|
20543
20590
|
const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
|
|
20544
20591
|
// grab all files in self-serve-customization folder
|
|
@@ -20567,7 +20614,7 @@ var push = async () => {
|
|
|
20567
20614
|
spinnerPushing = ora$1()
|
|
20568
20615
|
.start()
|
|
20569
20616
|
.info("No API Key provided. Standard login will be used.");
|
|
20570
|
-
const { workspaceId, name: workspaceName } = await selectWorkspace(config, token);
|
|
20617
|
+
const { workspaceId, name: workspaceName } = await selectWorkspace(ora$1, config, token);
|
|
20571
20618
|
const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`;
|
|
20572
20619
|
await buildArchive(config);
|
|
20573
20620
|
spinnerPushing.info(`Publishing to ${workspaceName} using ${workspacePreviewUrl}...`);
|
|
@@ -20606,35 +20653,6 @@ async function pushByApiKey(config, spinner) {
|
|
|
20606
20653
|
message,
|
|
20607
20654
|
});
|
|
20608
20655
|
}
|
|
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
20656
|
async function verify(ctx) {
|
|
20639
20657
|
try {
|
|
20640
20658
|
await fs$1.access(ctx.client.buildDir);
|
|
@@ -20724,26 +20742,6 @@ async function uploadFile(formData, url, token) {
|
|
|
20724
20742
|
maxBodyLength: Infinity,
|
|
20725
20743
|
});
|
|
20726
20744
|
}
|
|
20727
|
-
async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
20728
|
-
var _a;
|
|
20729
|
-
try {
|
|
20730
|
-
const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
|
|
20731
|
-
headers: {
|
|
20732
|
-
Authorization: `Bearer ${token}`,
|
|
20733
|
-
},
|
|
20734
|
-
});
|
|
20735
|
-
return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
|
|
20736
|
-
}
|
|
20737
|
-
catch (e) {
|
|
20738
|
-
if (e.response.status === 401) {
|
|
20739
|
-
workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
|
|
20740
|
-
}
|
|
20741
|
-
else {
|
|
20742
|
-
workspaceSpinner.fail("Failed to fetch workspaces");
|
|
20743
|
-
}
|
|
20744
|
-
process.exit(1);
|
|
20745
|
-
}
|
|
20746
|
-
}
|
|
20747
20745
|
|
|
20748
20746
|
const minimist = require("minimist");
|
|
20749
20747
|
const oraP = import('ora');
|
|
@@ -20804,7 +20802,7 @@ var dev = async () => {
|
|
|
20804
20802
|
const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
|
|
20805
20803
|
const workspacePreparation = ora("Preparing workspace...").start();
|
|
20806
20804
|
try {
|
|
20807
|
-
previewWorkspace = await getPreviewWorkspace(config);
|
|
20805
|
+
previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
|
|
20808
20806
|
}
|
|
20809
20807
|
catch (e) {
|
|
20810
20808
|
workspacePreparation.fail((_a = e.response.data) === null || _a === void 0 ? void 0 : _a.errorMessage);
|
|
@@ -20967,10 +20965,16 @@ const onClose = async (server, sys, watchers, config) => {
|
|
|
20967
20965
|
await sys.destroy();
|
|
20968
20966
|
process.exit(0);
|
|
20969
20967
|
};
|
|
20970
|
-
const getPreviewWorkspace = async (ctx) => {
|
|
20968
|
+
const getPreviewWorkspace = async (startedOra, ctx) => {
|
|
20971
20969
|
const token = await getToken();
|
|
20972
20970
|
const params = minimist(process.argv.slice(2));
|
|
20973
|
-
|
|
20971
|
+
let primaryWorkspace = params.w || params.workspace;
|
|
20972
|
+
if (!primaryWorkspace) {
|
|
20973
|
+
startedOra.stop(); // Stop current Ora, otherwise the last option will get hidden by it.
|
|
20974
|
+
const { workspaceId } = await selectWorkspace(ora, ctx, token);
|
|
20975
|
+
primaryWorkspace = workspaceId;
|
|
20976
|
+
startedOra.start();
|
|
20977
|
+
}
|
|
20974
20978
|
try {
|
|
20975
20979
|
const response = await axios.get(`${ctx.pushBaseUrl}/workspace/dev-workspace`, {
|
|
20976
20980
|
params: { primaryWorkspace },
|
|
@@ -20984,7 +20988,7 @@ const getPreviewWorkspace = async (ctx) => {
|
|
|
20984
20988
|
if (e.response.status === 401) {
|
|
20985
20989
|
// login and retry
|
|
20986
20990
|
await login();
|
|
20987
|
-
return await getPreviewWorkspace(ctx);
|
|
20991
|
+
return await getPreviewWorkspace(startedOra, ctx);
|
|
20988
20992
|
}
|
|
20989
20993
|
else {
|
|
20990
20994
|
throw e;
|
|
@@ -21045,7 +21049,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21045
21049
|
};
|
|
21046
21050
|
|
|
21047
21051
|
var name = "@embeddable.com/sdk-core";
|
|
21048
|
-
var version = "3.7.
|
|
21052
|
+
var version = "3.7.4";
|
|
21049
21053
|
var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
|
|
21050
21054
|
var keywords = [
|
|
21051
21055
|
"embeddable",
|