@embeddable.com/sdk-core 3.7.0 → 3.7.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 -1
- package/lib/index.esm.js +46 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +46 -6
- package/lib/index.js.map +1 -1
- package/lib/push.d.ts +2 -1
- package/package.json +1 -1
- package/src/defineConfig.test.ts +1 -0
- package/src/defineConfig.ts +6 -0
- package/src/dev.ts +37 -2
- package/src/push.ts +28 -1
package/lib/push.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare const YAML_OR_JS_FILES: RegExp;
|
|
2
|
+
export declare const SELF_SERVE_CUSTOM_FILES: RegExp;
|
|
2
3
|
declare const _default: () => Promise<void>;
|
|
3
4
|
export default _default;
|
|
4
|
-
export declare function archive(ctx: any, yamlFiles: [string, string][], includeBuild?: boolean): Promise<unknown>;
|
|
5
|
+
export declare function archive(ctx: any, yamlFiles: [string, string][], selfServeFiles?: [string, string][], includeBuild?: boolean): Promise<unknown>;
|
|
5
6
|
export declare function sendBuildByApiKey(ctx: any, { apiKey, email, message }: any): Promise<{
|
|
6
7
|
bundleId: any;
|
|
7
8
|
email: any;
|
package/package.json
CHANGED
package/src/defineConfig.test.ts
CHANGED
|
@@ -56,6 +56,7 @@ describe("defineConfig", () => {
|
|
|
56
56
|
"modelsSrc": "/embeddable-sdk/packages/core-sdk",
|
|
57
57
|
"rollupOptions": {},
|
|
58
58
|
"rootDir": "/embeddable-sdk/packages/core-sdk",
|
|
59
|
+
"selfServeCustomizationDir": "/embeddable-sdk/packages/core-sdk",
|
|
59
60
|
"srcDir": "/embeddable-sdk/packages/core-sdk",
|
|
60
61
|
"stencilBuild": "/embeddable-sdk/packages/core-sdk",
|
|
61
62
|
"tmpDir": "/embeddable-sdk/packages/core-sdk",
|
package/src/defineConfig.ts
CHANGED
|
@@ -19,6 +19,7 @@ export type EmbeddableConfig = {
|
|
|
19
19
|
previewBaseUrl?: string;
|
|
20
20
|
componentsSrc?: string;
|
|
21
21
|
modelsSrc?: string;
|
|
22
|
+
selfServeCustomizationSrc?: string;
|
|
22
23
|
viteConfig?: {
|
|
23
24
|
resolve?: {
|
|
24
25
|
alias?: Record<string, string>;
|
|
@@ -39,6 +40,7 @@ export default ({
|
|
|
39
40
|
previewBaseUrl,
|
|
40
41
|
modelsSrc = "src",
|
|
41
42
|
componentsSrc = "src",
|
|
43
|
+
selfServeCustomizationSrc = "src/self-serve-customization",
|
|
42
44
|
viteConfig = {},
|
|
43
45
|
rollupOptions = {},
|
|
44
46
|
}: EmbeddableConfig) => {
|
|
@@ -75,6 +77,10 @@ export default ({
|
|
|
75
77
|
modelsSrc: modelsSrc ? path.resolve(clientRoot, modelsSrc) : undefined,
|
|
76
78
|
buildDir: path.resolve(clientRoot, ".embeddable-build"),
|
|
77
79
|
tmpDir: path.resolve(clientRoot, ".embeddable-tmp"),
|
|
80
|
+
selfServeCustomizationDir: path.resolve(
|
|
81
|
+
clientRoot,
|
|
82
|
+
selfServeCustomizationSrc,
|
|
83
|
+
),
|
|
78
84
|
componentDir: path.resolve(clientRoot, ".embeddable-build", "component"),
|
|
79
85
|
stencilBuild: path.resolve(
|
|
80
86
|
clientRoot,
|
package/src/dev.ts
CHANGED
|
@@ -36,6 +36,7 @@ let previewWorkspace: string;
|
|
|
36
36
|
|
|
37
37
|
const SERVER_PORT = 8926;
|
|
38
38
|
const BUILD_DEV_DIR = ".embeddable-dev-build";
|
|
39
|
+
const SELF_SERVE_CUSTOMIZATION_REQUEST_URL = "/self-serve-customization";
|
|
39
40
|
|
|
40
41
|
const buildWebComponent = async (config: any) => {
|
|
41
42
|
await generate(config, "sdk-react");
|
|
@@ -93,6 +94,7 @@ export default async () => {
|
|
|
93
94
|
const serveStatic = require("serve-static");
|
|
94
95
|
|
|
95
96
|
const serve = serveStatic(config.client.buildDir);
|
|
97
|
+
const serveSelfeServe = serveStatic(config.client.selfServeCustomizationDir);
|
|
96
98
|
|
|
97
99
|
const workspacePreparation = ora("Preparing workspace...").start();
|
|
98
100
|
|
|
@@ -125,7 +127,19 @@ export default async () => {
|
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
const done = finalhandler(request, res);
|
|
128
|
-
|
|
130
|
+
|
|
131
|
+
const selectedServe = request.url?.startsWith(
|
|
132
|
+
SELF_SERVE_CUSTOMIZATION_REQUEST_URL,
|
|
133
|
+
)
|
|
134
|
+
? serveSelfeServe
|
|
135
|
+
: serve;
|
|
136
|
+
|
|
137
|
+
request.url = request.url?.replace(
|
|
138
|
+
SELF_SERVE_CUSTOMIZATION_REQUEST_URL,
|
|
139
|
+
"",
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
selectedServe(request, res, done);
|
|
129
143
|
},
|
|
130
144
|
);
|
|
131
145
|
wss = new WebSocketServer({ server });
|
|
@@ -165,7 +179,10 @@ export default async () => {
|
|
|
165
179
|
|
|
166
180
|
const dataModelAndSecurityContextWatch =
|
|
167
181
|
dataModelAndSecurityContextWatcher(config);
|
|
182
|
+
|
|
183
|
+
const customSelfServeWatch = customSelfServeWatcher(config);
|
|
168
184
|
watchers.push(dataModelAndSecurityContextWatch);
|
|
185
|
+
watchers.push(customSelfServeWatch);
|
|
169
186
|
});
|
|
170
187
|
};
|
|
171
188
|
|
|
@@ -237,6 +254,24 @@ const dataModelAndSecurityContextWatcher = (ctx: any): FSWatcher => {
|
|
|
237
254
|
return fsWatcher;
|
|
238
255
|
};
|
|
239
256
|
|
|
257
|
+
const customSelfServeWatcher = (ctx: any): FSWatcher => {
|
|
258
|
+
const fsWatcher = chokidar.watch(
|
|
259
|
+
[
|
|
260
|
+
path.resolve(ctx.client.selfServeCustomizationDir, "style.css"),
|
|
261
|
+
path.resolve(ctx.client.selfServeCustomizationDir, "*.svg"),
|
|
262
|
+
],
|
|
263
|
+
{
|
|
264
|
+
ignoreInitial: true,
|
|
265
|
+
},
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
fsWatcher.on("all", async () => {
|
|
269
|
+
sendMessage("customSelfServeUpdateSuccess");
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
return fsWatcher;
|
|
273
|
+
};
|
|
274
|
+
|
|
240
275
|
const sendDataModelsAndSecurityContextsChanges = async (ctx: any) => {
|
|
241
276
|
sendMessage("dataModelsAndOrSecurityContextUpdateStart");
|
|
242
277
|
const isValid = await validate(ctx, false);
|
|
@@ -253,7 +288,7 @@ const sendDataModelsAndSecurityContextsChanges = async (ctx: any) => {
|
|
|
253
288
|
path.resolve(ctx.client.buildDir, "embeddable-manifest.json"),
|
|
254
289
|
]);
|
|
255
290
|
|
|
256
|
-
await archive(ctx, filesList, false);
|
|
291
|
+
await archive(ctx, filesList, [], false);
|
|
257
292
|
await sendBuild(ctx, { workspaceId: previewWorkspace, token });
|
|
258
293
|
sending.succeed(`Data models and/or security context synchronized`);
|
|
259
294
|
sendMessage("dataModelsAndOrSecurityContextUpdateSuccess");
|
package/src/push.ts
CHANGED
|
@@ -15,6 +15,11 @@ import { checkBuildSuccess, checkNodeVersion, getArgumentByKey } from "./utils";
|
|
|
15
15
|
// grab .cube.yml|js and .sc.yml|js files
|
|
16
16
|
export const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
|
|
17
17
|
|
|
18
|
+
// grab all files in self-serve-customization folder
|
|
19
|
+
export const SELF_SERVE_CUSTOM_FILES = /^(style\.css|.*\.svg)$/;
|
|
20
|
+
|
|
21
|
+
const customSelfServeFolder = "self-serve-customization/";
|
|
22
|
+
|
|
18
23
|
let ora: any;
|
|
19
24
|
export default async () => {
|
|
20
25
|
let spinnerPushing;
|
|
@@ -170,13 +175,25 @@ async function buildArchive(config: any) {
|
|
|
170
175
|
YAML_OR_JS_FILES,
|
|
171
176
|
);
|
|
172
177
|
|
|
173
|
-
|
|
178
|
+
let selfServeFiles: [string, string][] = [];
|
|
179
|
+
|
|
180
|
+
// check existance of self-serve-customization folder
|
|
181
|
+
try {
|
|
182
|
+
await fs.access(config.client.selfServeCustomizationDir);
|
|
183
|
+
selfServeFiles = await findFiles(
|
|
184
|
+
`${config.client.selfServeCustomizationDir}`,
|
|
185
|
+
SELF_SERVE_CUSTOM_FILES,
|
|
186
|
+
);
|
|
187
|
+
} catch (e: any) {}
|
|
188
|
+
|
|
189
|
+
await archive(config, filesList, selfServeFiles);
|
|
174
190
|
return spinnerArchive.succeed("Bundling completed");
|
|
175
191
|
}
|
|
176
192
|
|
|
177
193
|
export async function archive(
|
|
178
194
|
ctx: any,
|
|
179
195
|
yamlFiles: [string, string][],
|
|
196
|
+
selfServeFiles: [string, string][] = [],
|
|
180
197
|
includeBuild: boolean = true,
|
|
181
198
|
) {
|
|
182
199
|
const output = fsSync.createWriteStream(ctx.client.archiveFile);
|
|
@@ -198,6 +215,16 @@ export async function archive(
|
|
|
198
215
|
});
|
|
199
216
|
}
|
|
200
217
|
|
|
218
|
+
if (selfServeFiles.length > 0) {
|
|
219
|
+
for (const fileData of selfServeFiles) {
|
|
220
|
+
const fileName = fileData[1].split("/").pop();
|
|
221
|
+
|
|
222
|
+
_archiver.file(fileData[1], {
|
|
223
|
+
name: `${customSelfServeFolder}${fileName!}`,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
201
228
|
await _archiver.finalize();
|
|
202
229
|
|
|
203
230
|
return new Promise((resolve, _reject) => {
|