@embeddable.com/sdk-core 3.9.0 → 3.9.1

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/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][], selfServeFiles?: [string, string][], includeBuild?: boolean): Promise<unknown>;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "3.9.0",
3
+ "version": "3.9.1",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
@@ -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",
@@ -19,7 +19,7 @@ export type EmbeddableConfig = {
19
19
  previewBaseUrl?: string;
20
20
  componentsSrc?: string;
21
21
  modelsSrc?: string;
22
- selfServeCustomizationSrc?: string;
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
- selfServeCustomizationSrc = "src/self-serve-customization",
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
- selfServeCustomizationDir: path.resolve(
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
- selfServeCustomizationDir: "/mock/root/self-serve",
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 SELF_SERVE_CUSTOMIZATION_REQUEST_URL = "/self-serve-customization";
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,16 @@ export default async () => {
140
140
 
141
141
  const done = finalhandler(request, res);
142
142
 
143
- const selectedServe = request.url?.startsWith(
144
- SELF_SERVE_CUSTOMIZATION_REQUEST_URL,
145
- )
146
- ? serveSelfeServe
147
- : serve;
148
-
149
- request.url = request.url?.replace(
150
- SELF_SERVE_CUSTOMIZATION_REQUEST_URL,
151
- "",
152
- );
143
+ if (request.url?.endsWith(GLOBAL_CSS)) {
144
+ res.writeHead(200, { "Content-Type": "text/css" });
145
+ res.end(fs.readFileSync(config.client.globalCss));
146
+ return;
147
+ }
153
148
 
154
- selectedServe(request, res, done);
149
+ serve(request, res, done);
155
150
  },
156
151
  );
152
+
157
153
  wss = new WebSocketServer({ server });
158
154
 
159
155
  server.listen(SERVER_PORT, async () => {
@@ -193,9 +189,9 @@ export default async () => {
193
189
  const dataModelAndSecurityContextWatch =
194
190
  dataModelAndSecurityContextWatcher(config);
195
191
 
196
- const customSelfServeWatch = customSelfServeWatcher(config);
192
+ const customGlobalCssWatch = globalCssWatcher(config);
197
193
  watchers.push(dataModelAndSecurityContextWatch);
198
- watchers.push(customSelfServeWatch);
194
+ watchers.push(customGlobalCssWatch);
199
195
  });
200
196
  };
201
197
 
@@ -265,17 +261,11 @@ const dataModelAndSecurityContextWatcher = (ctx: any): FSWatcher => {
265
261
  return fsWatcher;
266
262
  };
267
263
 
268
- const customSelfServeWatcher = (ctx: any): FSWatcher => {
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
- );
264
+ const globalCssWatcher = (ctx: any): FSWatcher => {
265
+ const fsWatcher = chokidar.watch(ctx.client.globalCss, chokidarWatchOptions);
276
266
 
277
267
  fsWatcher.on("all", async () => {
278
- sendMessage("customSelfServeUpdateSuccess");
268
+ sendMessage("globalCssUpdateSuccess");
279
269
  });
280
270
 
281
271
  return fsWatcher;
@@ -297,7 +287,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx: any) => {
297
287
  path.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
298
288
  ]);
299
289
 
300
- await archive(ctx, filesList, [], false);
290
+ await archive(ctx, filesList, true);
301
291
  await sendBuild(ctx, { workspaceId: previewWorkspace, token });
302
292
  sending.succeed(`Data models and/or security context synchronized`);
303
293
  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
- let selfServeFiles: [string, string][] = [];
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
- selfServeFiles: [string, string][] = [],
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 (includeBuild) {
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) => {