@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.js
CHANGED
|
@@ -566,10 +566,9 @@ const CREDENTIALS_DIR = path__namespace.resolve(os__namespace.homedir(), ".embed
|
|
|
566
566
|
const CREDENTIALS_FILE = path__namespace.resolve(CREDENTIALS_DIR, "credentials");
|
|
567
567
|
|
|
568
568
|
const oraP$3 = import('ora');
|
|
569
|
-
let ora$2;
|
|
570
569
|
const checkNodeVersion = async () => {
|
|
571
|
-
ora
|
|
572
|
-
const spinner = ora
|
|
570
|
+
const ora = (await oraP$3).default;
|
|
571
|
+
const spinner = ora("Checking node version...").start();
|
|
573
572
|
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
574
573
|
const packageJson = await Promise.resolve().then(function () { return _package$1; });
|
|
575
574
|
const { engines: { node }, } = packageJson;
|
|
@@ -578,13 +577,11 @@ const checkNodeVersion = async () => {
|
|
|
578
577
|
.map((v) => v.replace(/[^\d]/g, ""))
|
|
579
578
|
.map(Number);
|
|
580
579
|
if (major < minMajor || (major === minMajor && minor < minMinor)) {
|
|
581
|
-
spinner.fail({
|
|
582
|
-
text: `Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`,
|
|
583
|
-
color: "red",
|
|
584
|
-
});
|
|
580
|
+
spinner.fail(`Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`);
|
|
585
581
|
process.exit(1);
|
|
586
582
|
}
|
|
587
583
|
else {
|
|
584
|
+
spinner.stop();
|
|
588
585
|
return true;
|
|
589
586
|
}
|
|
590
587
|
};
|
|
@@ -20564,8 +20561,58 @@ async function resolveFiles() {
|
|
|
20564
20561
|
}
|
|
20565
20562
|
}
|
|
20566
20563
|
|
|
20567
|
-
const oraP$1 = import('ora');
|
|
20568
20564
|
const inquirerSelect = import('@inquirer/select');
|
|
20565
|
+
async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
20566
|
+
var _a;
|
|
20567
|
+
try {
|
|
20568
|
+
const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
|
|
20569
|
+
headers: {
|
|
20570
|
+
Authorization: `Bearer ${token}`,
|
|
20571
|
+
},
|
|
20572
|
+
});
|
|
20573
|
+
return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
|
|
20574
|
+
}
|
|
20575
|
+
catch (e) {
|
|
20576
|
+
if (e.response.status === 401) {
|
|
20577
|
+
workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
|
|
20578
|
+
}
|
|
20579
|
+
else {
|
|
20580
|
+
workspaceSpinner.fail("Failed to fetch workspaces");
|
|
20581
|
+
}
|
|
20582
|
+
process.exit(1);
|
|
20583
|
+
}
|
|
20584
|
+
}
|
|
20585
|
+
async function selectWorkspace(ora, ctx, token) {
|
|
20586
|
+
const workspaceSpinner = ora({
|
|
20587
|
+
text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
|
|
20588
|
+
color: "green",
|
|
20589
|
+
discardStdin: false,
|
|
20590
|
+
}).start();
|
|
20591
|
+
const availableWorkspaces = await getWorkspaces(ctx, token, workspaceSpinner);
|
|
20592
|
+
let selectedWorkspace;
|
|
20593
|
+
if (availableWorkspaces.length === 0) {
|
|
20594
|
+
workspaceSpinner.fail("No workspaces found");
|
|
20595
|
+
process.exit(1);
|
|
20596
|
+
}
|
|
20597
|
+
workspaceSpinner.info(`Found ${availableWorkspaces.length} workspace(s)`);
|
|
20598
|
+
if (availableWorkspaces.length === 1) {
|
|
20599
|
+
selectedWorkspace = availableWorkspaces[0];
|
|
20600
|
+
}
|
|
20601
|
+
else {
|
|
20602
|
+
const select = (await inquirerSelect).default;
|
|
20603
|
+
selectedWorkspace = await select({
|
|
20604
|
+
message: "Select workspace to push changes",
|
|
20605
|
+
choices: availableWorkspaces.map((workspace) => ({
|
|
20606
|
+
name: `${workspace.name} (${workspace.workspaceId})`,
|
|
20607
|
+
value: workspace,
|
|
20608
|
+
})),
|
|
20609
|
+
});
|
|
20610
|
+
}
|
|
20611
|
+
workspaceSpinner.succeed(`Workspace: ${selectedWorkspace.name} (${selectedWorkspace.workspaceId})`);
|
|
20612
|
+
return selectedWorkspace;
|
|
20613
|
+
}
|
|
20614
|
+
|
|
20615
|
+
const oraP$1 = import('ora');
|
|
20569
20616
|
// grab .cube.yml|js and .sc.yml|js files
|
|
20570
20617
|
const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
|
|
20571
20618
|
// grab all files in self-serve-customization folder
|
|
@@ -20594,7 +20641,7 @@ var push = async () => {
|
|
|
20594
20641
|
spinnerPushing = ora$1()
|
|
20595
20642
|
.start()
|
|
20596
20643
|
.info("No API Key provided. Standard login will be used.");
|
|
20597
|
-
const { workspaceId, name: workspaceName } = await selectWorkspace(config, token);
|
|
20644
|
+
const { workspaceId, name: workspaceName } = await selectWorkspace(ora$1, config, token);
|
|
20598
20645
|
const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`;
|
|
20599
20646
|
await buildArchive(config);
|
|
20600
20647
|
spinnerPushing.info(`Publishing to ${workspaceName} using ${workspacePreviewUrl}...`);
|
|
@@ -20633,35 +20680,6 @@ async function pushByApiKey(config, spinner) {
|
|
|
20633
20680
|
message,
|
|
20634
20681
|
});
|
|
20635
20682
|
}
|
|
20636
|
-
async function selectWorkspace(ctx, token) {
|
|
20637
|
-
const workspaceSpinner = ora$1({
|
|
20638
|
-
text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
|
|
20639
|
-
color: "green",
|
|
20640
|
-
discardStdin: false,
|
|
20641
|
-
}).start();
|
|
20642
|
-
const availableWorkspaces = await getWorkspaces(ctx, token, workspaceSpinner);
|
|
20643
|
-
let selectedWorkspace;
|
|
20644
|
-
if (availableWorkspaces.length === 0) {
|
|
20645
|
-
workspaceSpinner.fail("No workspaces found");
|
|
20646
|
-
process.exit(1);
|
|
20647
|
-
}
|
|
20648
|
-
workspaceSpinner.info(`Found ${availableWorkspaces.length} workspace(s)`);
|
|
20649
|
-
if (availableWorkspaces.length === 1) {
|
|
20650
|
-
selectedWorkspace = availableWorkspaces[0];
|
|
20651
|
-
}
|
|
20652
|
-
else {
|
|
20653
|
-
const select = (await inquirerSelect).default;
|
|
20654
|
-
selectedWorkspace = await select({
|
|
20655
|
-
message: "Select workspace to push changes",
|
|
20656
|
-
choices: availableWorkspaces.map((workspace) => ({
|
|
20657
|
-
name: `${workspace.name} (${workspace.workspaceId})`,
|
|
20658
|
-
value: workspace,
|
|
20659
|
-
})),
|
|
20660
|
-
});
|
|
20661
|
-
}
|
|
20662
|
-
workspaceSpinner.succeed(`Workspace: ${selectedWorkspace.name} (${selectedWorkspace.workspaceId})`);
|
|
20663
|
-
return selectedWorkspace;
|
|
20664
|
-
}
|
|
20665
20683
|
async function verify(ctx) {
|
|
20666
20684
|
try {
|
|
20667
20685
|
await fs__namespace.access(ctx.client.buildDir);
|
|
@@ -20751,26 +20769,6 @@ async function uploadFile(formData, url, token) {
|
|
|
20751
20769
|
maxBodyLength: Infinity,
|
|
20752
20770
|
});
|
|
20753
20771
|
}
|
|
20754
|
-
async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
20755
|
-
var _a;
|
|
20756
|
-
try {
|
|
20757
|
-
const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
|
|
20758
|
-
headers: {
|
|
20759
|
-
Authorization: `Bearer ${token}`,
|
|
20760
|
-
},
|
|
20761
|
-
});
|
|
20762
|
-
return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
|
|
20763
|
-
}
|
|
20764
|
-
catch (e) {
|
|
20765
|
-
if (e.response.status === 401) {
|
|
20766
|
-
workspaceSpinner.fail('Unauthorized. Please login using "embeddable login" command.');
|
|
20767
|
-
}
|
|
20768
|
-
else {
|
|
20769
|
-
workspaceSpinner.fail("Failed to fetch workspaces");
|
|
20770
|
-
}
|
|
20771
|
-
process.exit(1);
|
|
20772
|
-
}
|
|
20773
|
-
}
|
|
20774
20772
|
|
|
20775
20773
|
const minimist = require("minimist");
|
|
20776
20774
|
const oraP = import('ora');
|
|
@@ -20831,7 +20829,7 @@ var dev = async () => {
|
|
|
20831
20829
|
const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
|
|
20832
20830
|
const workspacePreparation = ora("Preparing workspace...").start();
|
|
20833
20831
|
try {
|
|
20834
|
-
previewWorkspace = await getPreviewWorkspace(config);
|
|
20832
|
+
previewWorkspace = await getPreviewWorkspace(workspacePreparation, config);
|
|
20835
20833
|
}
|
|
20836
20834
|
catch (e) {
|
|
20837
20835
|
workspacePreparation.fail((_a = e.response.data) === null || _a === void 0 ? void 0 : _a.errorMessage);
|
|
@@ -20994,10 +20992,16 @@ const onClose = async (server, sys, watchers, config) => {
|
|
|
20994
20992
|
await sys.destroy();
|
|
20995
20993
|
process.exit(0);
|
|
20996
20994
|
};
|
|
20997
|
-
const getPreviewWorkspace = async (ctx) => {
|
|
20995
|
+
const getPreviewWorkspace = async (startedOra, ctx) => {
|
|
20998
20996
|
const token = await getToken();
|
|
20999
20997
|
const params = minimist(process.argv.slice(2));
|
|
21000
|
-
|
|
20998
|
+
let primaryWorkspace = params.w || params.workspace;
|
|
20999
|
+
if (!primaryWorkspace) {
|
|
21000
|
+
startedOra.stop(); // Stop current Ora, otherwise the last option will get hidden by it.
|
|
21001
|
+
const { workspaceId } = await selectWorkspace(ora, ctx, token);
|
|
21002
|
+
primaryWorkspace = workspaceId;
|
|
21003
|
+
startedOra.start();
|
|
21004
|
+
}
|
|
21001
21005
|
try {
|
|
21002
21006
|
const response = await axios.get(`${ctx.pushBaseUrl}/workspace/dev-workspace`, {
|
|
21003
21007
|
params: { primaryWorkspace },
|
|
@@ -21011,7 +21015,7 @@ const getPreviewWorkspace = async (ctx) => {
|
|
|
21011
21015
|
if (e.response.status === 401) {
|
|
21012
21016
|
// login and retry
|
|
21013
21017
|
await login();
|
|
21014
|
-
return await getPreviewWorkspace(ctx);
|
|
21018
|
+
return await getPreviewWorkspace(startedOra, ctx);
|
|
21015
21019
|
}
|
|
21016
21020
|
else {
|
|
21017
21021
|
throw e;
|
|
@@ -21072,7 +21076,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
21072
21076
|
};
|
|
21073
21077
|
|
|
21074
21078
|
var name = "@embeddable.com/sdk-core";
|
|
21075
|
-
var version = "3.7.
|
|
21079
|
+
var version = "3.7.4";
|
|
21076
21080
|
var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
|
|
21077
21081
|
var keywords = [
|
|
21078
21082
|
"embeddable",
|