@embeddable.com/sdk-core 4.0.0-next.0 → 4.0.0-next.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/index.esm.js +6 -4
- package/lib/index.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/dev.ts +2 -1
- package/src/push.test.ts +7 -7
- package/src/push.ts +21 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embeddable.com/sdk-core",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.2",
|
|
4
4
|
"description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"embeddable",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@embeddable.com/core": "2.10.4",
|
|
44
|
-
"@embeddable.com/sdk-utils": "0.8.0",
|
|
44
|
+
"@embeddable.com/sdk-utils": "0.8.1-next.0",
|
|
45
45
|
"@inquirer/prompts": "^7.2.1",
|
|
46
46
|
"@stencil/core": "^4.23.0",
|
|
47
47
|
"@swc-node/register": "^1.10.9",
|
package/src/dev.ts
CHANGED
|
@@ -55,7 +55,8 @@ let previewWorkspace: string;
|
|
|
55
55
|
|
|
56
56
|
const SERVER_PORT = 8926;
|
|
57
57
|
const BUILD_DEV_DIR = ".embeddable-dev-build";
|
|
58
|
-
|
|
58
|
+
// NOTE: for backward compatibility, keep the file name as global.css
|
|
59
|
+
const CUSTOM_CANVAS_CSS = "/global.css";
|
|
59
60
|
|
|
60
61
|
export const buildWebComponent = async (config: any) => {
|
|
61
62
|
await generate(config, "sdk-react");
|
package/src/push.test.ts
CHANGED
|
@@ -151,7 +151,7 @@ describe("push", () => {
|
|
|
151
151
|
|
|
152
152
|
expect(archiveMock.pipe).toHaveBeenCalled();
|
|
153
153
|
expect(archiveMock.file).toHaveBeenCalledWith("src/custom-canvas.css", {
|
|
154
|
-
name: "
|
|
154
|
+
name: "global.css",
|
|
155
155
|
});
|
|
156
156
|
expect(archiveMock.directory).toHaveBeenCalledWith("buildDir", false);
|
|
157
157
|
expect(archiveMock.finalize).toHaveBeenCalled();
|
|
@@ -248,10 +248,10 @@ describe("push", () => {
|
|
|
248
248
|
|
|
249
249
|
// Should include component build directory
|
|
250
250
|
expect(mockArchiver.directory).toHaveBeenCalled();
|
|
251
|
-
// Should not include model files (except
|
|
251
|
+
// Should not include model files (except global.css which is part of components)
|
|
252
252
|
expect(mockArchiver.file).toHaveBeenCalledTimes(2);
|
|
253
253
|
expect(mockArchiver.file).toHaveBeenCalledWith(expect.anything(), {
|
|
254
|
-
name: "
|
|
254
|
+
name: "global.css",
|
|
255
255
|
});
|
|
256
256
|
});
|
|
257
257
|
});
|
|
@@ -452,11 +452,11 @@ describe("push", () => {
|
|
|
452
452
|
testConfig.client.buildDir,
|
|
453
453
|
false
|
|
454
454
|
);
|
|
455
|
-
// Should include
|
|
455
|
+
// Should include global.css
|
|
456
456
|
expect(mockArchiver.file).toHaveBeenCalledWith(
|
|
457
457
|
testConfig.client.customCanvasCss,
|
|
458
458
|
{
|
|
459
|
-
name: "
|
|
459
|
+
name: "global.css",
|
|
460
460
|
}
|
|
461
461
|
);
|
|
462
462
|
// Should include all model files
|
|
@@ -505,11 +505,11 @@ describe("push", () => {
|
|
|
505
505
|
testConfig.client.buildDir,
|
|
506
506
|
false
|
|
507
507
|
);
|
|
508
|
-
// Should include
|
|
508
|
+
// Should include global.css
|
|
509
509
|
expect(mockArchiver.file).toHaveBeenCalledWith(
|
|
510
510
|
testConfig.client.customCanvasCss,
|
|
511
511
|
{
|
|
512
|
-
name: "
|
|
512
|
+
name: "global.css",
|
|
513
513
|
}
|
|
514
514
|
);
|
|
515
515
|
// Should only find client context files
|
package/src/push.ts
CHANGED
|
@@ -36,7 +36,7 @@ export default async () => {
|
|
|
36
36
|
|
|
37
37
|
if (!isBuildSuccess && config.pushComponents) {
|
|
38
38
|
console.error(
|
|
39
|
-
"Build failed or not completed. Please run `embeddable:build` first."
|
|
39
|
+
"Build failed or not completed. Please run `embeddable:build` first.",
|
|
40
40
|
);
|
|
41
41
|
process.exit(1);
|
|
42
42
|
}
|
|
@@ -52,7 +52,7 @@ export default async () => {
|
|
|
52
52
|
`Authentication failure. Server responded with: "${error.response?.data?.errorMessage}".
|
|
53
53
|
Ensure that your API key is valid for the region specified in the embeddable.config.ts|js file.
|
|
54
54
|
You are using the following region: ${config.region.replace("legacy-", "")} (${config.previewBaseUrl.replace("https://", "")} via ${config.pushBaseUrl})
|
|
55
|
-
Read more about deployment regions at https://docs.embeddable.com/deployment/deployment-regions
|
|
55
|
+
Read more about deployment regions at https://docs.embeddable.com/deployment/deployment-regions`,
|
|
56
56
|
);
|
|
57
57
|
process.exit(1);
|
|
58
58
|
}
|
|
@@ -76,7 +76,7 @@ Read more about deployment regions at https://docs.embeddable.com/deployment/dep
|
|
|
76
76
|
const { workspaceId, name: workspaceName } = await selectWorkspace(
|
|
77
77
|
ora,
|
|
78
78
|
config,
|
|
79
|
-
token
|
|
79
|
+
token,
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`;
|
|
@@ -85,7 +85,7 @@ Read more about deployment regions at https://docs.embeddable.com/deployment/dep
|
|
|
85
85
|
breadcrumbs.push("build archive");
|
|
86
86
|
await buildArchive(config);
|
|
87
87
|
spinnerPushing.info(
|
|
88
|
-
`Publishing to ${workspaceName} using ${workspacePreviewUrl}
|
|
88
|
+
`Publishing to ${workspaceName} using ${workspacePreviewUrl}...`,
|
|
89
89
|
);
|
|
90
90
|
|
|
91
91
|
breadcrumbs.push("send build");
|
|
@@ -93,7 +93,7 @@ Read more about deployment regions at https://docs.embeddable.com/deployment/dep
|
|
|
93
93
|
|
|
94
94
|
publishedSectionFeedback(config, spinnerPushing);
|
|
95
95
|
spinnerPushing.succeed(
|
|
96
|
-
`Published to ${workspaceName} using ${workspacePreviewUrl}
|
|
96
|
+
`Published to ${workspaceName} using ${workspacePreviewUrl}`,
|
|
97
97
|
);
|
|
98
98
|
} catch (error: any) {
|
|
99
99
|
spinnerPushing?.fail("Publishing failed");
|
|
@@ -106,7 +106,7 @@ Read more about deployment regions at https://docs.embeddable.com/deployment/dep
|
|
|
106
106
|
|
|
107
107
|
const publishedSectionFeedback = (
|
|
108
108
|
config: ResolvedEmbeddableConfig,
|
|
109
|
-
spinnerPushing: Ora
|
|
109
|
+
spinnerPushing: Ora,
|
|
110
110
|
) => {
|
|
111
111
|
config.pushModels && spinnerPushing.succeed("Models published");
|
|
112
112
|
config.pushComponents && spinnerPushing.succeed("Components published");
|
|
@@ -115,7 +115,7 @@ const publishedSectionFeedback = (
|
|
|
115
115
|
async function pushByApiKey(
|
|
116
116
|
config: ResolvedEmbeddableConfig,
|
|
117
117
|
spinner: any,
|
|
118
|
-
cubeVersion?: string
|
|
118
|
+
cubeVersion?: string,
|
|
119
119
|
) {
|
|
120
120
|
const apiKey = getArgumentByKey(["--api-key", "-k"]);
|
|
121
121
|
|
|
@@ -128,7 +128,7 @@ async function pushByApiKey(
|
|
|
128
128
|
|
|
129
129
|
if (!email || !/\S+@\S+\.\S+/.test(email)) {
|
|
130
130
|
spinner.fail(
|
|
131
|
-
"Invalid email provided. Please provide a valid email using --email (-e) flag"
|
|
131
|
+
"Invalid email provided. Please provide a valid email using --email (-e) flag",
|
|
132
132
|
);
|
|
133
133
|
process.exit(1);
|
|
134
134
|
}
|
|
@@ -172,7 +172,7 @@ export async function buildArchive(config: ResolvedEmbeddableConfig) {
|
|
|
172
172
|
|
|
173
173
|
if (!config.pushModels && !config.pushComponents) {
|
|
174
174
|
spinnerArchive.fail(
|
|
175
|
-
"Cannot push: both pushModels and pushComponents are disabled"
|
|
175
|
+
"Cannot push: both pushModels and pushComponents are disabled",
|
|
176
176
|
);
|
|
177
177
|
process.exit(1);
|
|
178
178
|
}
|
|
@@ -182,12 +182,12 @@ export async function buildArchive(config: ResolvedEmbeddableConfig) {
|
|
|
182
182
|
if (config.pushModels) {
|
|
183
183
|
const cubeFilesList = await findFiles(
|
|
184
184
|
config.client.modelsSrc || config.client.srcDir,
|
|
185
|
-
CUBE_FILES
|
|
185
|
+
CUBE_FILES,
|
|
186
186
|
);
|
|
187
187
|
|
|
188
188
|
const securityContextFilesList = await findFiles(
|
|
189
189
|
config.client.presetsSrc || config.client.srcDir,
|
|
190
|
-
SECURITY_CONTEXT_FILES
|
|
190
|
+
SECURITY_CONTEXT_FILES,
|
|
191
191
|
);
|
|
192
192
|
|
|
193
193
|
filesList.push(
|
|
@@ -199,21 +199,21 @@ export async function buildArchive(config: ResolvedEmbeddableConfig) {
|
|
|
199
199
|
...securityContextFilesList.map((entry): [string, string] => [
|
|
200
200
|
path.basename(entry[1]),
|
|
201
201
|
entry[1],
|
|
202
|
-
])
|
|
202
|
+
]),
|
|
203
203
|
);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
if (config.pushComponents) {
|
|
207
207
|
const clientContextFilesList = await findFiles(
|
|
208
208
|
config.client.presetsSrc || config.client.srcDir,
|
|
209
|
-
CLIENT_CONTEXT_FILES
|
|
209
|
+
CLIENT_CONTEXT_FILES,
|
|
210
210
|
);
|
|
211
211
|
|
|
212
212
|
filesList.push(
|
|
213
213
|
...clientContextFilesList.map((entry): [string, string] => [
|
|
214
214
|
path.basename(entry[1]),
|
|
215
215
|
entry[1],
|
|
216
|
-
])
|
|
216
|
+
]),
|
|
217
217
|
);
|
|
218
218
|
}
|
|
219
219
|
|
|
@@ -240,8 +240,9 @@ export async function archive(args: {
|
|
|
240
240
|
archive.pipe(output);
|
|
241
241
|
if (!isDev) {
|
|
242
242
|
archive.directory(ctx.client.buildDir, false);
|
|
243
|
+
// NOTE: for backward compatibility, keep the file name as global.css
|
|
243
244
|
archive.file(ctx.client.customCanvasCss, {
|
|
244
|
-
name: "
|
|
245
|
+
name: "global.css",
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
248
|
|
|
@@ -260,7 +261,7 @@ export async function archive(args: {
|
|
|
260
261
|
|
|
261
262
|
export async function createFormData(
|
|
262
263
|
filePath: string,
|
|
263
|
-
metadata: Record<string, any
|
|
264
|
+
metadata: Record<string, any>,
|
|
264
265
|
) {
|
|
265
266
|
const { FormData, Blob } = await import("formdata-node");
|
|
266
267
|
const { fileFromPath } = await import("formdata-node/file-from-path");
|
|
@@ -284,7 +285,7 @@ export async function sendBuildByApiKey(
|
|
|
284
285
|
email,
|
|
285
286
|
message,
|
|
286
287
|
cubeVersion,
|
|
287
|
-
}: { apiKey: string; email: string; message?: string; cubeVersion?: string }
|
|
288
|
+
}: { apiKey: string; email: string; message?: string; cubeVersion?: string },
|
|
288
289
|
) {
|
|
289
290
|
const form = await createFormData(ctx.client.archiveFile, {
|
|
290
291
|
pushModels: ctx.pushModels,
|
|
@@ -297,7 +298,7 @@ export async function sendBuildByApiKey(
|
|
|
297
298
|
const response = await uploadFile(
|
|
298
299
|
form,
|
|
299
300
|
`${ctx.pushBaseUrl}/api/v1/bundle/upload`,
|
|
300
|
-
apiKey
|
|
301
|
+
apiKey,
|
|
301
302
|
);
|
|
302
303
|
await fs.rm(ctx.client.archiveFile);
|
|
303
304
|
|
|
@@ -316,7 +317,7 @@ export async function sendBuild(
|
|
|
316
317
|
token: string;
|
|
317
318
|
message?: string;
|
|
318
319
|
cubeVersion?: string;
|
|
319
|
-
}
|
|
320
|
+
},
|
|
320
321
|
) {
|
|
321
322
|
const form = await createFormData(ctx.client.archiveFile, {
|
|
322
323
|
pushModels: ctx.pushModels,
|
|
@@ -329,7 +330,7 @@ export async function sendBuild(
|
|
|
329
330
|
await uploadFile(
|
|
330
331
|
form,
|
|
331
332
|
`${ctx.pushBaseUrl}/bundle/${workspaceId}/upload`,
|
|
332
|
-
token
|
|
333
|
+
token,
|
|
333
334
|
);
|
|
334
335
|
|
|
335
336
|
await fs.rm(ctx.client.archiveFile);
|