@embeddable.com/sdk-core 3.9.0 → 3.9.2
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/defineConfig.d.ts +3 -3
- package/lib/index.esm.js +30 -44
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +27 -41
- package/lib/index.js.map +1 -1
- package/lib/push.d.ts +1 -2
- package/package.json +1 -1
- package/src/defineConfig.test.ts +1 -1
- package/src/defineConfig.ts +3 -6
- package/src/dev.test.ts +1 -1
- package/src/dev.ts +17 -25
- package/src/push.ts +6 -30
package/lib/push.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export declare const YAML_OR_JS_FILES: RegExp;
|
|
2
|
-
export declare const SELF_SERVE_CUSTOM_FILES: RegExp;
|
|
3
2
|
declare const _default: () => Promise<void>;
|
|
4
3
|
export default _default;
|
|
5
|
-
export declare function archive(ctx: any, yamlFiles: [string, string][],
|
|
4
|
+
export declare function archive(ctx: any, yamlFiles: [string, string][], isDev?: boolean): Promise<unknown>;
|
|
6
5
|
export declare function sendBuildByApiKey(ctx: any, { apiKey, email, message }: any): Promise<{
|
|
7
6
|
bundleId: any;
|
|
8
7
|
email: any;
|
package/package.json
CHANGED
package/src/defineConfig.test.ts
CHANGED
|
@@ -53,10 +53,10 @@ describe("defineConfig", () => {
|
|
|
53
53
|
"bundleHash": undefined,
|
|
54
54
|
"componentDir": "/embeddable-sdk/packages/core-sdk",
|
|
55
55
|
"errorFallbackComponent": "/embeddable-sdk/packages/core-sdk",
|
|
56
|
+
"globalCss": "/embeddable-sdk/packages/core-sdk",
|
|
56
57
|
"modelsSrc": "/embeddable-sdk/packages/core-sdk",
|
|
57
58
|
"rollupOptions": {},
|
|
58
59
|
"rootDir": "/embeddable-sdk/packages/core-sdk",
|
|
59
|
-
"selfServeCustomizationDir": "/embeddable-sdk/packages/core-sdk",
|
|
60
60
|
"srcDir": "/embeddable-sdk/packages/core-sdk",
|
|
61
61
|
"stencilBuild": "/embeddable-sdk/packages/core-sdk",
|
|
62
62
|
"tmpDir": "/embeddable-sdk/packages/core-sdk",
|
package/src/defineConfig.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type EmbeddableConfig = {
|
|
|
19
19
|
previewBaseUrl?: string;
|
|
20
20
|
componentsSrc?: string;
|
|
21
21
|
modelsSrc?: string;
|
|
22
|
-
|
|
22
|
+
globalCss?: string;
|
|
23
23
|
viteConfig?: {
|
|
24
24
|
resolve?: {
|
|
25
25
|
alias?: Record<string, string>;
|
|
@@ -40,7 +40,7 @@ export default ({
|
|
|
40
40
|
previewBaseUrl,
|
|
41
41
|
modelsSrc = "src",
|
|
42
42
|
componentsSrc = "src",
|
|
43
|
-
|
|
43
|
+
globalCss = "src/global.css",
|
|
44
44
|
viteConfig = {},
|
|
45
45
|
rollupOptions = {},
|
|
46
46
|
}: EmbeddableConfig) => {
|
|
@@ -77,10 +77,7 @@ export default ({
|
|
|
77
77
|
modelsSrc: modelsSrc ? path.resolve(clientRoot, modelsSrc) : undefined,
|
|
78
78
|
buildDir: path.resolve(clientRoot, ".embeddable-build"),
|
|
79
79
|
tmpDir: path.resolve(clientRoot, ".embeddable-tmp"),
|
|
80
|
-
|
|
81
|
-
clientRoot,
|
|
82
|
-
selfServeCustomizationSrc,
|
|
83
|
-
),
|
|
80
|
+
globalCss: path.resolve(clientRoot, globalCss),
|
|
84
81
|
componentDir: path.resolve(clientRoot, ".embeddable-build", "component"),
|
|
85
82
|
stencilBuild: path.resolve(
|
|
86
83
|
clientRoot,
|
package/src/dev.test.ts
CHANGED
|
@@ -39,7 +39,7 @@ const mockConfig = {
|
|
|
39
39
|
componentDir: "/mock/root/.embeddable-dev-build/component",
|
|
40
40
|
stencilBuild: "/mock/root/.embeddable-dev-build/dist/embeddable-wrapper",
|
|
41
41
|
tmpDir: "/mock/root/.embeddable-dev-tmp",
|
|
42
|
-
|
|
42
|
+
globalCss: "/mock/root/global.css",
|
|
43
43
|
modelsSrc: "/mock/root/models",
|
|
44
44
|
},
|
|
45
45
|
plugins: [],
|
package/src/dev.ts
CHANGED
|
@@ -26,6 +26,7 @@ import validate from "./validate";
|
|
|
26
26
|
import { checkNodeVersion } from "./utils";
|
|
27
27
|
import { createManifest } from "./cleanup";
|
|
28
28
|
import { selectWorkspace } from "./workspaceUtils";
|
|
29
|
+
import * as fs from "fs";
|
|
29
30
|
const minimist = require("minimist");
|
|
30
31
|
|
|
31
32
|
const oraP = import("ora");
|
|
@@ -38,7 +39,7 @@ let previewWorkspace: string;
|
|
|
38
39
|
|
|
39
40
|
const SERVER_PORT = 8926;
|
|
40
41
|
const BUILD_DEV_DIR = ".embeddable-dev-build";
|
|
41
|
-
const
|
|
42
|
+
const GLOBAL_CSS = "/global.css";
|
|
42
43
|
|
|
43
44
|
const buildWebComponent = async (config: any) => {
|
|
44
45
|
await generate(config, "sdk-react");
|
|
@@ -104,7 +105,6 @@ export default async () => {
|
|
|
104
105
|
const serveStatic = require("serve-static");
|
|
105
106
|
|
|
106
107
|
const serve = serveStatic(config.client.buildDir);
|
|
107
|
-
const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
|
|
108
108
|
|
|
109
109
|
const workspacePreparation = ora("Preparing workspace...").start();
|
|
110
110
|
|
|
@@ -140,20 +140,18 @@ export default async () => {
|
|
|
140
140
|
|
|
141
141
|
const done = finalhandler(request, res);
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
try {
|
|
144
|
+
if (request.url?.endsWith(GLOBAL_CSS)) {
|
|
145
|
+
res.writeHead(200, { "Content-Type": "text/css" });
|
|
146
|
+
res.end(fs.readFileSync(config.client.globalCss));
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
} catch {}
|
|
148
150
|
|
|
149
|
-
request
|
|
150
|
-
SELF_SERVE_CUSTOMIZATION_REQUEST_URL,
|
|
151
|
-
"",
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
selectedServe(request, res, done);
|
|
151
|
+
serve(request, res, done);
|
|
155
152
|
},
|
|
156
153
|
);
|
|
154
|
+
|
|
157
155
|
wss = new WebSocketServer({ server });
|
|
158
156
|
|
|
159
157
|
server.listen(SERVER_PORT, async () => {
|
|
@@ -193,9 +191,9 @@ export default async () => {
|
|
|
193
191
|
const dataModelAndSecurityContextWatch =
|
|
194
192
|
dataModelAndSecurityContextWatcher(config);
|
|
195
193
|
|
|
196
|
-
const
|
|
194
|
+
const customGlobalCssWatch = globalCssWatcher(config);
|
|
197
195
|
watchers.push(dataModelAndSecurityContextWatch);
|
|
198
|
-
watchers.push(
|
|
196
|
+
watchers.push(customGlobalCssWatch);
|
|
199
197
|
});
|
|
200
198
|
};
|
|
201
199
|
|
|
@@ -265,17 +263,11 @@ const dataModelAndSecurityContextWatcher = (ctx: any): FSWatcher => {
|
|
|
265
263
|
return fsWatcher;
|
|
266
264
|
};
|
|
267
265
|
|
|
268
|
-
const
|
|
269
|
-
const fsWatcher = chokidar.watch(
|
|
270
|
-
[
|
|
271
|
-
path.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
|
|
272
|
-
path.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
|
|
273
|
-
],
|
|
274
|
-
chokidarWatchOptions,
|
|
275
|
-
);
|
|
266
|
+
const globalCssWatcher = (ctx: any): FSWatcher => {
|
|
267
|
+
const fsWatcher = chokidar.watch(ctx.client.globalCss, chokidarWatchOptions);
|
|
276
268
|
|
|
277
269
|
fsWatcher.on("all", async () => {
|
|
278
|
-
sendMessage("
|
|
270
|
+
sendMessage("globalCssUpdateSuccess");
|
|
279
271
|
});
|
|
280
272
|
|
|
281
273
|
return fsWatcher;
|
|
@@ -297,7 +289,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx: any) => {
|
|
|
297
289
|
path.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
|
|
298
290
|
]);
|
|
299
291
|
|
|
300
|
-
await archive(ctx, filesList,
|
|
292
|
+
await archive(ctx, filesList, true);
|
|
301
293
|
await sendBuild(ctx, { workspaceId: previewWorkspace, token });
|
|
302
294
|
sending.succeed(`Data models and/or security context synchronized`);
|
|
303
295
|
sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
|
package/src/push.ts
CHANGED
|
@@ -16,11 +16,6 @@ import { selectWorkspace } from "./workspaceUtils";
|
|
|
16
16
|
// grab .cube.yml|js and .sc.yml|js files
|
|
17
17
|
export const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
|
|
18
18
|
|
|
19
|
-
// grab all files in self-serve-customization folder
|
|
20
|
-
export const SELF_SERVE_CUSTOM_FILES = /^(style\.css|.*\.svg)$/;
|
|
21
|
-
|
|
22
|
-
const customSelfServeFolder = "self-serve-customization/";
|
|
23
|
-
|
|
24
19
|
let ora: any;
|
|
25
20
|
export default async () => {
|
|
26
21
|
let spinnerPushing;
|
|
@@ -139,26 +134,14 @@ async function buildArchive(config: any) {
|
|
|
139
134
|
YAML_OR_JS_FILES,
|
|
140
135
|
);
|
|
141
136
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// check existance of self-serve-customization folder
|
|
145
|
-
try {
|
|
146
|
-
await fs.access(config.client.selfServeCustomizationDir);
|
|
147
|
-
selfServeFiles = await findFiles(
|
|
148
|
-
`${config.client.selfServeCustomizationDir}`,
|
|
149
|
-
SELF_SERVE_CUSTOM_FILES,
|
|
150
|
-
);
|
|
151
|
-
} catch (e: any) {}
|
|
152
|
-
|
|
153
|
-
await archive(config, filesList, selfServeFiles);
|
|
137
|
+
await archive(config, filesList);
|
|
154
138
|
return spinnerArchive.succeed("Bundling completed");
|
|
155
139
|
}
|
|
156
140
|
|
|
157
141
|
export async function archive(
|
|
158
142
|
ctx: any,
|
|
159
143
|
yamlFiles: [string, string][],
|
|
160
|
-
|
|
161
|
-
includeBuild: boolean = true,
|
|
144
|
+
isDev: boolean = false,
|
|
162
145
|
) {
|
|
163
146
|
const output = fsSync.createWriteStream(ctx.client.archiveFile);
|
|
164
147
|
|
|
@@ -167,8 +150,11 @@ export async function archive(
|
|
|
167
150
|
});
|
|
168
151
|
|
|
169
152
|
_archiver.pipe(output);
|
|
170
|
-
if (
|
|
153
|
+
if (!isDev) {
|
|
171
154
|
_archiver.directory(ctx.client.buildDir, false);
|
|
155
|
+
_archiver.file(ctx.client.globalCss, {
|
|
156
|
+
name: "global.css",
|
|
157
|
+
});
|
|
172
158
|
}
|
|
173
159
|
|
|
174
160
|
for (const fileData of yamlFiles) {
|
|
@@ -179,16 +165,6 @@ export async function archive(
|
|
|
179
165
|
});
|
|
180
166
|
}
|
|
181
167
|
|
|
182
|
-
if (selfServeFiles.length > 0) {
|
|
183
|
-
for (const fileData of selfServeFiles) {
|
|
184
|
-
const fileName = fileData[1].split("/").pop();
|
|
185
|
-
|
|
186
|
-
_archiver.file(fileData[1], {
|
|
187
|
-
name: `${customSelfServeFolder}${fileName!}`,
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
168
|
await _archiver.finalize();
|
|
193
169
|
|
|
194
170
|
return new Promise((resolve, _reject) => {
|