@embeddable.com/sdk-core 2.4.14 → 2.4.16
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/configs/package.json +13 -0
- package/lib/buildTypes.d.ts +2 -0
- package/lib/defineConfig.d.ts +3 -1
- package/lib/dev.d.ts +2 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.esm.js +218 -38
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +220 -38
- package/lib/index.js.map +1 -1
- package/lib/prepare.d.ts +1 -0
- package/lib/push.d.ts +6 -0
- package/lib/validate.d.ts +2 -1
- package/package.json +7 -2
package/lib/index.js
CHANGED
|
@@ -8,9 +8,9 @@ var fsSync = require('node:fs');
|
|
|
8
8
|
var node = require('@stencil/core/sys/node');
|
|
9
9
|
var compiler = require('@stencil/core/compiler');
|
|
10
10
|
var YAML = require('yaml');
|
|
11
|
-
var
|
|
11
|
+
var path$2 = require('path');
|
|
12
12
|
var require$$4$1 = require('util');
|
|
13
|
-
var require$$1
|
|
13
|
+
var require$$1 = require('os');
|
|
14
14
|
var require$$3 = require('http');
|
|
15
15
|
var require$$4 = require('https');
|
|
16
16
|
var require$$0$1 = require('url');
|
|
@@ -18,6 +18,8 @@ var require$$2$1 = require('fs');
|
|
|
18
18
|
var os$1 = require('node:os');
|
|
19
19
|
var axios = require('axios');
|
|
20
20
|
var archiver = require('archiver');
|
|
21
|
+
var ws = require('ws');
|
|
22
|
+
var chokidar = require('chokidar');
|
|
21
23
|
var promises = require('fs/promises');
|
|
22
24
|
|
|
23
25
|
function _interopNamespaceDefault(e) {
|
|
@@ -42,9 +44,10 @@ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path$1);
|
|
|
42
44
|
var vite__namespace = /*#__PURE__*/_interopNamespaceDefault(vite);
|
|
43
45
|
var fsSync__namespace = /*#__PURE__*/_interopNamespaceDefault(fsSync);
|
|
44
46
|
var YAML__namespace = /*#__PURE__*/_interopNamespaceDefault(YAML);
|
|
45
|
-
var
|
|
47
|
+
var path__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(path$2);
|
|
46
48
|
var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os$1);
|
|
47
49
|
var archiver__namespace = /*#__PURE__*/_interopNamespaceDefault(archiver);
|
|
50
|
+
var chokidar__namespace = /*#__PURE__*/_interopNamespaceDefault(chokidar);
|
|
48
51
|
|
|
49
52
|
var findFiles = async (initialSrcDir, regex) => {
|
|
50
53
|
const filesList = [];
|
|
@@ -358,11 +361,11 @@ const formatErrorPath = (path) => {
|
|
|
358
361
|
return formatted;
|
|
359
362
|
};
|
|
360
363
|
|
|
361
|
-
const oraP$
|
|
364
|
+
const oraP$4 = import('ora');
|
|
362
365
|
const EMB_TYPE_FILE_REGEX = /^(.*)\.type\.emb\.[jt]s$/;
|
|
363
366
|
const EMB_OPTIONS_FILE_REGEX = /^(.*)\.options\.emb\.[jt]s$/;
|
|
364
367
|
var buildTypes = async (ctx) => {
|
|
365
|
-
const ora = (await oraP$
|
|
368
|
+
const ora = (await oraP$4).default;
|
|
366
369
|
const progress = ora("building types...").start();
|
|
367
370
|
await generate$1(ctx);
|
|
368
371
|
await build$1(ctx);
|
|
@@ -379,17 +382,16 @@ async function generate$1(ctx) {
|
|
|
379
382
|
await fs__namespace.writeFile(path__namespace.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename), typeImports);
|
|
380
383
|
}
|
|
381
384
|
async function build$1(ctx) {
|
|
382
|
-
process.chdir(ctx.client.rootDir);
|
|
383
385
|
await vite__namespace.build({
|
|
384
386
|
logLevel: "error",
|
|
385
387
|
build: {
|
|
386
388
|
emptyOutDir: false,
|
|
387
389
|
lib: {
|
|
388
|
-
entry:
|
|
390
|
+
entry: path__namespace.resolve(ctx.client.rootDir, ctx.outputOptions.typesEntryPointFilename),
|
|
389
391
|
formats: ["es"],
|
|
390
392
|
fileName: "embeddable-types",
|
|
391
393
|
},
|
|
392
|
-
outDir:
|
|
394
|
+
outDir: ctx.client.buildDir,
|
|
393
395
|
},
|
|
394
396
|
});
|
|
395
397
|
}
|
|
@@ -438,15 +440,21 @@ async function injectBundleRender(ctx, pluginName) {
|
|
|
438
440
|
await fs__namespace.writeFile(path__namespace.resolve(ctx.client.componentDir, "component.tsx"), content.replace(RENDER_IMPORT_TOKEN, importStr));
|
|
439
441
|
}
|
|
440
442
|
async function runStencil(ctx) {
|
|
441
|
-
|
|
442
|
-
const logger = node.createNodeLogger({ process });
|
|
443
|
-
const sys = node.createNodeSys({ process });
|
|
443
|
+
var _a, _b;
|
|
444
|
+
const logger = ((_a = ctx.dev) === null || _a === void 0 ? void 0 : _a.logger) || node.createNodeLogger({ process });
|
|
445
|
+
const sys = ((_b = ctx.dev) === null || _b === void 0 ? void 0 : _b.sys) || node.createNodeSys({ process });
|
|
446
|
+
const devMode = !!ctx.dev;
|
|
444
447
|
const validated = await compiler.loadConfig({
|
|
448
|
+
initTsConfig: true,
|
|
445
449
|
logger,
|
|
446
450
|
sys,
|
|
447
451
|
config: {
|
|
452
|
+
devMode,
|
|
453
|
+
rootDir: ctx.client.buildDir,
|
|
454
|
+
configPath: path__namespace.resolve(ctx.client.buildDir, "stencil.config.ts"),
|
|
455
|
+
tsconfig: path__namespace.resolve(ctx.client.buildDir, "tsconfig.json"),
|
|
448
456
|
namespace: "embeddable-wrapper",
|
|
449
|
-
srcDir: "component",
|
|
457
|
+
srcDir: path__namespace.resolve(ctx.client.buildDir, "component"),
|
|
450
458
|
outputTargets: [
|
|
451
459
|
{
|
|
452
460
|
type: "dist",
|
|
@@ -457,6 +465,7 @@ async function runStencil(ctx) {
|
|
|
457
465
|
const compiler$1 = await compiler.createCompiler(validated.config);
|
|
458
466
|
await compiler$1.build();
|
|
459
467
|
await compiler$1.destroy();
|
|
468
|
+
process.chdir(ctx.client.rootDir);
|
|
460
469
|
}
|
|
461
470
|
async function generateSourceMap(ctx, pluginName) {
|
|
462
471
|
const componentBuildDir = path__namespace.resolve(ctx.client.buildDir, ctx[pluginName].outputOptions.buildName);
|
|
@@ -4521,7 +4530,7 @@ const checkNodeVersion$1 = () => {
|
|
|
4521
4530
|
throw new Error(`Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`);
|
|
4522
4531
|
}
|
|
4523
4532
|
};
|
|
4524
|
-
var validate = async (ctx) => {
|
|
4533
|
+
var validate = async (ctx, exitIfInvalid = true) => {
|
|
4525
4534
|
checkNodeVersion$1();
|
|
4526
4535
|
const ora = (await import('ora')).default;
|
|
4527
4536
|
const spinnerValidate = ora("data model validation...").start();
|
|
@@ -4530,9 +4539,12 @@ var validate = async (ctx) => {
|
|
|
4530
4539
|
if (dataModelErrors.length) {
|
|
4531
4540
|
spinnerValidate.fail("One or more cube.yaml files are invalid:");
|
|
4532
4541
|
dataModelErrors.forEach((errorMessage) => spinnerValidate.info(errorMessage));
|
|
4533
|
-
|
|
4542
|
+
if (exitIfInvalid) {
|
|
4543
|
+
process.exit(1);
|
|
4544
|
+
}
|
|
4534
4545
|
}
|
|
4535
4546
|
spinnerValidate.succeed("data model validation completed");
|
|
4547
|
+
return dataModelErrors.length === 0;
|
|
4536
4548
|
};
|
|
4537
4549
|
async function dataModelsValidation(filesList) {
|
|
4538
4550
|
const errors = [];
|
|
@@ -16815,7 +16827,7 @@ sourceMap.SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
|
|
|
16815
16827
|
sourceMap.SourceNode = sourceNode.SourceNode;
|
|
16816
16828
|
|
|
16817
16829
|
var SourceMapConsumer = sourceMap.SourceMapConsumer;
|
|
16818
|
-
var path =
|
|
16830
|
+
var path = path$2;
|
|
16819
16831
|
var fs = require$$2$1;
|
|
16820
16832
|
|
|
16821
16833
|
/**
|
|
@@ -19082,7 +19094,7 @@ var setupCustomJSON = function(JSON) {
|
|
|
19082
19094
|
var json3 = setupCustomJSON;
|
|
19083
19095
|
|
|
19084
19096
|
var util = require$$4$1;
|
|
19085
|
-
var os = require$$1
|
|
19097
|
+
var os = require$$1;
|
|
19086
19098
|
|
|
19087
19099
|
var packageJson = require$$2;
|
|
19088
19100
|
var Client = rollbar$1;
|
|
@@ -19858,7 +19870,7 @@ const reportErrorToRollbar = async (error) => {
|
|
|
19858
19870
|
|
|
19859
19871
|
const getSdkPackageVersionInfo = (config) => {
|
|
19860
19872
|
try {
|
|
19861
|
-
const packageJsonFilePath =
|
|
19873
|
+
const packageJsonFilePath = path__namespace$1.resolve(
|
|
19862
19874
|
config.client.rootDir,
|
|
19863
19875
|
"package.json",
|
|
19864
19876
|
);
|
|
@@ -19902,11 +19914,11 @@ async function getUserData() {
|
|
|
19902
19914
|
}
|
|
19903
19915
|
}
|
|
19904
19916
|
|
|
19905
|
-
const oraP$
|
|
19906
|
-
let ora$
|
|
19917
|
+
const oraP$3 = import('ora');
|
|
19918
|
+
let ora$2;
|
|
19907
19919
|
const checkNodeVersion = async () => {
|
|
19908
|
-
ora$
|
|
19909
|
-
ora$
|
|
19920
|
+
ora$2 = (await oraP$3).default;
|
|
19921
|
+
ora$2("checking node version...");
|
|
19910
19922
|
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
19911
19923
|
const engines = require("../package.json").engines.node;
|
|
19912
19924
|
const [minMajor, minMinor] = engines
|
|
@@ -19914,7 +19926,7 @@ const checkNodeVersion = async () => {
|
|
|
19914
19926
|
.map((v) => v.replace(/[^\d]/g, ""))
|
|
19915
19927
|
.map(Number);
|
|
19916
19928
|
if (major < minMajor || (major === minMajor && minor < minMinor)) {
|
|
19917
|
-
ora$
|
|
19929
|
+
ora$2({
|
|
19918
19930
|
text: `Node version ${minMajor}.${minMinor} or higher is required. You are running ${major}.${minor}.`,
|
|
19919
19931
|
color: "red",
|
|
19920
19932
|
}).fail();
|
|
@@ -19942,16 +19954,17 @@ var build = async () => {
|
|
|
19942
19954
|
catch (error) {
|
|
19943
19955
|
await reportErrorToRollbar(error);
|
|
19944
19956
|
console.log(error);
|
|
19945
|
-
|
|
19957
|
+
process.exit(1);
|
|
19946
19958
|
}
|
|
19947
19959
|
};
|
|
19948
19960
|
|
|
19949
|
-
const oraP$
|
|
19961
|
+
const oraP$2 = import('ora');
|
|
19950
19962
|
const openP = import('open');
|
|
19951
19963
|
var login = async () => {
|
|
19952
19964
|
var _a;
|
|
19965
|
+
const ora = (await oraP$2).default;
|
|
19966
|
+
const authenticationSpinner = ora("waiting for code verification...").start();
|
|
19953
19967
|
try {
|
|
19954
|
-
const ora = (await oraP$1).default;
|
|
19955
19968
|
const open = (await openP).default;
|
|
19956
19969
|
const config = await provideConfig();
|
|
19957
19970
|
await resolveFiles();
|
|
@@ -19965,7 +19978,6 @@ var login = async () => {
|
|
|
19965
19978
|
device_code: deviceCodeResponse.data["device_code"],
|
|
19966
19979
|
client_id: config.authClientId,
|
|
19967
19980
|
};
|
|
19968
|
-
const authenticationSpinner = ora("waiting for code verification...").start();
|
|
19969
19981
|
await open(deviceCodeResponse.data["verification_uri_complete"]);
|
|
19970
19982
|
/**
|
|
19971
19983
|
* This is a recommended way to poll, since it take some time for a user to enter a `user_code` in a browser.
|
|
@@ -19988,9 +20000,10 @@ var login = async () => {
|
|
|
19988
20000
|
}
|
|
19989
20001
|
}
|
|
19990
20002
|
catch (error) {
|
|
20003
|
+
authenticationSpinner.fail("authentication failed. please try again.");
|
|
19991
20004
|
await reportErrorToRollbar(error);
|
|
19992
20005
|
console.log(error);
|
|
19993
|
-
|
|
20006
|
+
process.exit(1);
|
|
19994
20007
|
}
|
|
19995
20008
|
};
|
|
19996
20009
|
async function getToken() {
|
|
@@ -20022,22 +20035,22 @@ async function resolveFiles() {
|
|
|
20022
20035
|
}
|
|
20023
20036
|
}
|
|
20024
20037
|
|
|
20025
|
-
const oraP = import('ora');
|
|
20038
|
+
const oraP$1 = import('ora');
|
|
20026
20039
|
const inquirerSelect = import('@inquirer/select');
|
|
20027
20040
|
const CUBE_YAML_FILE_REGEX = /^(.*)\.cube\.ya?ml$/;
|
|
20028
|
-
let ora;
|
|
20041
|
+
let ora$1;
|
|
20029
20042
|
var push = async () => {
|
|
20030
20043
|
try {
|
|
20031
20044
|
checkNodeVersion();
|
|
20032
|
-
ora = (await oraP).default;
|
|
20045
|
+
ora$1 = (await oraP$1).default;
|
|
20033
20046
|
const config = await provideConfig();
|
|
20034
20047
|
const token = await verify(config);
|
|
20035
20048
|
const { workspaceId, name: workspaceName } = await selectWorkspace(config, token);
|
|
20036
|
-
const spinnerArchive = ora("archivation...").start();
|
|
20049
|
+
const spinnerArchive = ora$1("archivation...").start();
|
|
20037
20050
|
const filesList = await findFiles(config.client.srcDir, CUBE_YAML_FILE_REGEX);
|
|
20038
20051
|
await archive(config, filesList);
|
|
20039
20052
|
spinnerArchive.succeed("archivation competed");
|
|
20040
|
-
const spinnerPushing = ora(`publishing to ${workspaceName} using ${config.pushBaseUrl}...`).start();
|
|
20053
|
+
const spinnerPushing = ora$1(`publishing to ${workspaceName} using ${config.pushBaseUrl}...`).start();
|
|
20041
20054
|
await sendBuild(config, { workspaceId, token });
|
|
20042
20055
|
spinnerPushing.succeed(`published to ${workspaceName} using ${config.pushBaseUrl}`);
|
|
20043
20056
|
}
|
|
@@ -20048,7 +20061,7 @@ var push = async () => {
|
|
|
20048
20061
|
}
|
|
20049
20062
|
};
|
|
20050
20063
|
async function selectWorkspace(ctx, token) {
|
|
20051
|
-
const workspaceSpinner = ora({
|
|
20064
|
+
const workspaceSpinner = ora$1({
|
|
20052
20065
|
text: `Fetching workspaces using ${ctx.pushBaseUrl}...`,
|
|
20053
20066
|
color: "green",
|
|
20054
20067
|
discardStdin: false,
|
|
@@ -20092,13 +20105,15 @@ async function verify(ctx) {
|
|
|
20092
20105
|
}
|
|
20093
20106
|
return token;
|
|
20094
20107
|
}
|
|
20095
|
-
async function archive(ctx, yamlFiles) {
|
|
20108
|
+
async function archive(ctx, yamlFiles, includeBuild = true) {
|
|
20096
20109
|
const output = fsSync__namespace.createWriteStream(ctx.client.archiveFile);
|
|
20097
20110
|
const _archiver = archiver__namespace.create("zip", {
|
|
20098
20111
|
zlib: { level: 9 },
|
|
20099
20112
|
});
|
|
20100
20113
|
_archiver.pipe(output);
|
|
20101
|
-
|
|
20114
|
+
if (includeBuild) {
|
|
20115
|
+
_archiver.directory(ctx.client.buildDir, false);
|
|
20116
|
+
}
|
|
20102
20117
|
for (const fileData of yamlFiles) {
|
|
20103
20118
|
_archiver.file(fileData[1], { name: `${fileData[0]}.cube.yaml` });
|
|
20104
20119
|
}
|
|
@@ -20124,13 +20139,14 @@ async function sendBuild(ctx, { workspaceId, token }) {
|
|
|
20124
20139
|
await fs__namespace.rm(ctx.client.archiveFile);
|
|
20125
20140
|
}
|
|
20126
20141
|
async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
20142
|
+
var _a;
|
|
20127
20143
|
try {
|
|
20128
20144
|
const response = await axios.get(`${ctx.pushBaseUrl}/workspace`, {
|
|
20129
20145
|
headers: {
|
|
20130
20146
|
Authorization: `Bearer ${token}`,
|
|
20131
20147
|
},
|
|
20132
20148
|
});
|
|
20133
|
-
return response.data;
|
|
20149
|
+
return (_a = response.data) === null || _a === void 0 ? void 0 : _a.filter((w) => !w.devWorkspace);
|
|
20134
20150
|
}
|
|
20135
20151
|
catch (e) {
|
|
20136
20152
|
if (e.response.status === 401) {
|
|
@@ -20143,7 +20159,171 @@ async function getWorkspaces(ctx, token, workspaceSpinner) {
|
|
|
20143
20159
|
}
|
|
20144
20160
|
}
|
|
20145
20161
|
|
|
20146
|
-
|
|
20162
|
+
const oraP = import('ora');
|
|
20163
|
+
let wss;
|
|
20164
|
+
let changedFiles = [];
|
|
20165
|
+
let browserWindow = null;
|
|
20166
|
+
let ora;
|
|
20167
|
+
let previewWorkspace;
|
|
20168
|
+
const SERVER_PORT = 8926;
|
|
20169
|
+
const buildWebComponent = async (config) => {
|
|
20170
|
+
await generate(config, "sdk-react");
|
|
20171
|
+
};
|
|
20172
|
+
var dev = async () => {
|
|
20173
|
+
const http = require("http");
|
|
20174
|
+
ora = (await oraP).default;
|
|
20175
|
+
process.on("warning", (e) => console.warn(e.stack));
|
|
20176
|
+
const logger = node.createNodeLogger({ process });
|
|
20177
|
+
const sys = node.createNodeSys({ process });
|
|
20178
|
+
const config = {
|
|
20179
|
+
dev: {
|
|
20180
|
+
watch: true,
|
|
20181
|
+
logger,
|
|
20182
|
+
sys,
|
|
20183
|
+
},
|
|
20184
|
+
...(await provideConfig()),
|
|
20185
|
+
};
|
|
20186
|
+
await prepare(config);
|
|
20187
|
+
const finalhandler = require("finalhandler");
|
|
20188
|
+
const serveStatic = require("serve-static");
|
|
20189
|
+
const serve = serveStatic(config.client.buildDir);
|
|
20190
|
+
const workspacePreparation = ora("Preparing workspace...").start();
|
|
20191
|
+
previewWorkspace = await getPreviewWorkspace(config);
|
|
20192
|
+
workspacePreparation.succeed("Workspace is ready");
|
|
20193
|
+
const server = http.createServer((request, res) => {
|
|
20194
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
20195
|
+
const done = finalhandler(request, res);
|
|
20196
|
+
serve(request, res, done);
|
|
20197
|
+
});
|
|
20198
|
+
wss = new ws.WebSocketServer({ server });
|
|
20199
|
+
server.listen(SERVER_PORT, async () => {
|
|
20200
|
+
const watchers = [];
|
|
20201
|
+
if (sys === null || sys === void 0 ? void 0 : sys.onProcessInterrupt) {
|
|
20202
|
+
sys.onProcessInterrupt(async () => await onClose(server, sys, watchers, config));
|
|
20203
|
+
}
|
|
20204
|
+
await sendDataModels(config);
|
|
20205
|
+
for (const getPlugin of config.plugins) {
|
|
20206
|
+
const plugin = getPlugin();
|
|
20207
|
+
await plugin.validate(config);
|
|
20208
|
+
const watcher = await plugin.build(config);
|
|
20209
|
+
await configureWatcher(watcher, config);
|
|
20210
|
+
watchers.push(watcher);
|
|
20211
|
+
}
|
|
20212
|
+
const modelWatcher = dataModelWatcher(config);
|
|
20213
|
+
watchers.push(modelWatcher);
|
|
20214
|
+
});
|
|
20215
|
+
};
|
|
20216
|
+
const configureWatcher = async (watcher, ctx) => {
|
|
20217
|
+
watcher.on("change", (path) => {
|
|
20218
|
+
changedFiles.push(path);
|
|
20219
|
+
});
|
|
20220
|
+
watcher.on("event", async (e) => {
|
|
20221
|
+
var _a;
|
|
20222
|
+
if (e.code === "BUNDLE_START") {
|
|
20223
|
+
await onBuildStart(ctx);
|
|
20224
|
+
}
|
|
20225
|
+
if (e.code === "BUNDLE_END") {
|
|
20226
|
+
await onBundleBuildEnd(ctx);
|
|
20227
|
+
changedFiles = [];
|
|
20228
|
+
}
|
|
20229
|
+
if (e.code === "ERROR") {
|
|
20230
|
+
sendMessage("componentsBuildError", { error: (_a = e.error) === null || _a === void 0 ? void 0 : _a.message });
|
|
20231
|
+
changedFiles = [];
|
|
20232
|
+
}
|
|
20233
|
+
});
|
|
20234
|
+
};
|
|
20235
|
+
const sendMessage = (type, meta = {}) => {
|
|
20236
|
+
wss.clients.forEach((ws) => {
|
|
20237
|
+
ws.send(JSON.stringify({ type, ...meta }));
|
|
20238
|
+
});
|
|
20239
|
+
};
|
|
20240
|
+
const typeFilesFilter = (f) => EMB_OPTIONS_FILE_REGEX.test(f) || EMB_TYPE_FILE_REGEX.test(f);
|
|
20241
|
+
const onlyTypesChanged = () => changedFiles.length !== 0 &&
|
|
20242
|
+
changedFiles.filter(typeFilesFilter).length === changedFiles.length;
|
|
20243
|
+
const isTypeFileChanged = () => changedFiles.findIndex(typeFilesFilter) >= 0;
|
|
20244
|
+
const onBuildStart = async (ctx) => {
|
|
20245
|
+
if (changedFiles.length === 0 || isTypeFileChanged()) {
|
|
20246
|
+
await buildTypes(ctx);
|
|
20247
|
+
}
|
|
20248
|
+
sendMessage("componentsBuildStart", { changedFiles });
|
|
20249
|
+
};
|
|
20250
|
+
const onBundleBuildEnd = async (ctx) => {
|
|
20251
|
+
if (!onlyTypesChanged() || changedFiles.length === 0) {
|
|
20252
|
+
await buildWebComponent(ctx);
|
|
20253
|
+
}
|
|
20254
|
+
if (browserWindow == null) {
|
|
20255
|
+
const open = (await import('open')).default;
|
|
20256
|
+
browserWindow = await open(`${ctx.previewBaseUrl}/workspace/${previewWorkspace}`);
|
|
20257
|
+
}
|
|
20258
|
+
else {
|
|
20259
|
+
sendMessage("componentsBuildSuccess");
|
|
20260
|
+
}
|
|
20261
|
+
};
|
|
20262
|
+
const dataModelWatcher = (ctx) => {
|
|
20263
|
+
const fsWatcher = chokidar__namespace.watch([path__namespace$1.resolve(ctx.client.srcDir, "**/*.cube.{yaml,yml}")], {
|
|
20264
|
+
ignoreInitial: true,
|
|
20265
|
+
});
|
|
20266
|
+
fsWatcher.on("all", async () => {
|
|
20267
|
+
await sendDataModels(ctx);
|
|
20268
|
+
});
|
|
20269
|
+
return fsWatcher;
|
|
20270
|
+
};
|
|
20271
|
+
const sendDataModels = async (ctx) => {
|
|
20272
|
+
sendMessage("dataModelsUpdateStart");
|
|
20273
|
+
const isValid = await validate(ctx, false);
|
|
20274
|
+
if (isValid) {
|
|
20275
|
+
const token = await getToken();
|
|
20276
|
+
const sending = ora("synchronising data models...").start();
|
|
20277
|
+
const filesList = await findFiles(ctx.client.srcDir, CUBE_YAML_FILE_REGEX);
|
|
20278
|
+
await archive(ctx, filesList, false);
|
|
20279
|
+
await sendBuild(ctx, { workspaceId: previewWorkspace, token });
|
|
20280
|
+
sending.succeed(`data models synchronized`);
|
|
20281
|
+
sendMessage("dataModelsUpdateSuccess");
|
|
20282
|
+
}
|
|
20283
|
+
else {
|
|
20284
|
+
sendMessage("dataModelsUpdateError");
|
|
20285
|
+
}
|
|
20286
|
+
};
|
|
20287
|
+
const onClose = async (server, sys, watchers, config) => {
|
|
20288
|
+
server.close();
|
|
20289
|
+
wss.close();
|
|
20290
|
+
browserWindow === null || browserWindow === void 0 ? void 0 : browserWindow.unref();
|
|
20291
|
+
for (const watcher of watchers) {
|
|
20292
|
+
if (watcher.close) {
|
|
20293
|
+
await watcher.close();
|
|
20294
|
+
}
|
|
20295
|
+
}
|
|
20296
|
+
for (const getPlugin of config.plugins) {
|
|
20297
|
+
const plugin = getPlugin();
|
|
20298
|
+
await plugin.cleanup(config);
|
|
20299
|
+
}
|
|
20300
|
+
await removeIfExists(config);
|
|
20301
|
+
await sys.destroy();
|
|
20302
|
+
process.exit(0);
|
|
20303
|
+
};
|
|
20304
|
+
const getPreviewWorkspace = async (ctx) => {
|
|
20305
|
+
const token = await getToken();
|
|
20306
|
+
try {
|
|
20307
|
+
const response = await axios.get(`${ctx.pushBaseUrl}/workspace/dev-workspace`, {
|
|
20308
|
+
headers: {
|
|
20309
|
+
Authorization: `Bearer ${token}`,
|
|
20310
|
+
},
|
|
20311
|
+
});
|
|
20312
|
+
return response.data;
|
|
20313
|
+
}
|
|
20314
|
+
catch (e) {
|
|
20315
|
+
if (e.response.status === 401) {
|
|
20316
|
+
// login and retry
|
|
20317
|
+
await login();
|
|
20318
|
+
return await getPreviewWorkspace(ctx);
|
|
20319
|
+
}
|
|
20320
|
+
else {
|
|
20321
|
+
throw e;
|
|
20322
|
+
}
|
|
20323
|
+
}
|
|
20324
|
+
};
|
|
20325
|
+
|
|
20326
|
+
var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientId, errorFallbackComponent, applicationEnvironment, rollbarAccessToken, previewBaseUrl, }) => {
|
|
20147
20327
|
const coreRoot = path__namespace.resolve(__dirname, "..");
|
|
20148
20328
|
const clientRoot = process.cwd();
|
|
20149
20329
|
return {
|
|
@@ -20169,6 +20349,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
|
|
|
20169
20349
|
},
|
|
20170
20350
|
pushBaseUrl: pushBaseUrl !== null && pushBaseUrl !== void 0 ? pushBaseUrl : "https://api.embeddable.com",
|
|
20171
20351
|
audienceUrl: audienceUrl !== null && audienceUrl !== void 0 ? audienceUrl : "https://auth.embeddable.com",
|
|
20352
|
+
previewBaseUrl: previewBaseUrl !== null && previewBaseUrl !== void 0 ? previewBaseUrl : "https://app.embeddable.com",
|
|
20172
20353
|
authDomain: authDomain !== null && authDomain !== void 0 ? authDomain : "auth.embeddable.com",
|
|
20173
20354
|
authClientId: authClientId !== null && authClientId !== void 0 ? authClientId : "dygrSUmI6HmgY5ymVbEAoLDEBxIOyr1V",
|
|
20174
20355
|
applicationEnvironment: applicationEnvironment !== null && applicationEnvironment !== void 0 ? applicationEnvironment : "production",
|
|
@@ -20516,7 +20697,7 @@ var _FileFromPath = class _FileFromPath {
|
|
|
20516
20697
|
__privateAdd(this, _start, void 0);
|
|
20517
20698
|
__privateSet(this, _path, input.path);
|
|
20518
20699
|
__privateSet(this, _start, input.start || 0);
|
|
20519
|
-
this.name =
|
|
20700
|
+
this.name = path$2.basename(__privateGet(this, _path));
|
|
20520
20701
|
this.size = input.size;
|
|
20521
20702
|
this.lastModified = input.lastModified;
|
|
20522
20703
|
}
|
|
@@ -20579,6 +20760,7 @@ var fileFromPath$1 = /*#__PURE__*/Object.freeze({
|
|
|
20579
20760
|
|
|
20580
20761
|
exports.build = build;
|
|
20581
20762
|
exports.defineConfig = defineConfig;
|
|
20763
|
+
exports.dev = dev;
|
|
20582
20764
|
exports.login = login;
|
|
20583
20765
|
exports.push = push;
|
|
20584
20766
|
//# sourceMappingURL=index.js.map
|