@embeddable.com/sdk-core 3.13.6-next.1 → 3.13.6-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 -0
- package/lib/index.esm.js.map +1 -1
- package/lib/push.d.ts +2 -1
- package/package.json +1 -1
- package/src/push.ts +26 -15
package/lib/push.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Ora } from "ora";
|
|
1
2
|
import { ResolvedEmbeddableConfig } from "./defineConfig";
|
|
2
3
|
export declare const CUBE_FILES: RegExp;
|
|
3
4
|
export declare const PRESET_FILES: RegExp;
|
|
4
5
|
declare const _default: () => Promise<void>;
|
|
5
6
|
export default _default;
|
|
6
|
-
export declare function buildArchive(config: ResolvedEmbeddableConfig): Promise<
|
|
7
|
+
export declare function buildArchive(config: ResolvedEmbeddableConfig): Promise<Ora>;
|
|
7
8
|
export declare function archive(args: {
|
|
8
9
|
ctx: ResolvedEmbeddableConfig;
|
|
9
10
|
filesList: [string, string][];
|
package/package.json
CHANGED
package/src/push.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as fs from "node:fs/promises";
|
|
|
2
2
|
import * as fsSync from "node:fs";
|
|
3
3
|
import archiver from "archiver";
|
|
4
4
|
import axios from "axios";
|
|
5
|
-
import ora from "ora";
|
|
5
|
+
import ora, { Ora } from "ora";
|
|
6
6
|
import { initLogger, logError } from "./logger";
|
|
7
7
|
import * as path from "path";
|
|
8
8
|
|
|
@@ -33,7 +33,7 @@ export default async () => {
|
|
|
33
33
|
const isBuildSuccess = await checkBuildSuccess();
|
|
34
34
|
if (!isBuildSuccess) {
|
|
35
35
|
console.error(
|
|
36
|
-
"Build failed or not completed. Please run `embeddable:build` first."
|
|
36
|
+
"Build failed or not completed. Please run `embeddable:build` first."
|
|
37
37
|
);
|
|
38
38
|
process.exit(1);
|
|
39
39
|
}
|
|
@@ -45,6 +45,7 @@ export default async () => {
|
|
|
45
45
|
breadcrumbs.push("push by api key");
|
|
46
46
|
await pushByApiKey(config, spinnerPushing);
|
|
47
47
|
|
|
48
|
+
publishedSectionFeedback(config, spinnerPushing);
|
|
48
49
|
spinnerPushing.succeed("Published using API key");
|
|
49
50
|
|
|
50
51
|
return;
|
|
@@ -60,7 +61,7 @@ export default async () => {
|
|
|
60
61
|
const { workspaceId, name: workspaceName } = await selectWorkspace(
|
|
61
62
|
ora,
|
|
62
63
|
config,
|
|
63
|
-
token
|
|
64
|
+
token
|
|
64
65
|
);
|
|
65
66
|
|
|
66
67
|
const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`;
|
|
@@ -69,13 +70,15 @@ export default async () => {
|
|
|
69
70
|
breadcrumbs.push("build archive");
|
|
70
71
|
await buildArchive(config);
|
|
71
72
|
spinnerPushing.info(
|
|
72
|
-
`Publishing to ${workspaceName} using ${workspacePreviewUrl}
|
|
73
|
+
`Publishing to ${workspaceName} using ${workspacePreviewUrl}...`
|
|
73
74
|
);
|
|
74
75
|
|
|
75
76
|
breadcrumbs.push("send build");
|
|
76
77
|
await sendBuild(config, { workspaceId, token, message });
|
|
78
|
+
|
|
79
|
+
publishedSectionFeedback(config, spinnerPushing);
|
|
77
80
|
spinnerPushing.succeed(
|
|
78
|
-
`Published to ${workspaceName} using ${workspacePreviewUrl}
|
|
81
|
+
`Published to ${workspaceName} using ${workspacePreviewUrl}`
|
|
79
82
|
);
|
|
80
83
|
} catch (error: any) {
|
|
81
84
|
spinnerPushing?.fail("Publishing failed");
|
|
@@ -86,6 +89,14 @@ export default async () => {
|
|
|
86
89
|
}
|
|
87
90
|
};
|
|
88
91
|
|
|
92
|
+
const publishedSectionFeedback = (
|
|
93
|
+
config: ResolvedEmbeddableConfig,
|
|
94
|
+
spinnerPushing: Ora
|
|
95
|
+
) => {
|
|
96
|
+
config.pushModels && spinnerPushing.succeed("Models published");
|
|
97
|
+
config.pushComponents && spinnerPushing.succeed("Components published");
|
|
98
|
+
};
|
|
99
|
+
|
|
89
100
|
async function pushByApiKey(config: ResolvedEmbeddableConfig, spinner: any) {
|
|
90
101
|
const apiKey = getArgumentByKey(["--api-key", "-k"]);
|
|
91
102
|
|
|
@@ -98,7 +109,7 @@ async function pushByApiKey(config: ResolvedEmbeddableConfig, spinner: any) {
|
|
|
98
109
|
|
|
99
110
|
if (!email || !/\S+@\S+\.\S+/.test(email)) {
|
|
100
111
|
spinner.fail(
|
|
101
|
-
"Invalid email provided. Please provide a valid email using --email (-e) flag"
|
|
112
|
+
"Invalid email provided. Please provide a valid email using --email (-e) flag"
|
|
102
113
|
);
|
|
103
114
|
process.exit(1);
|
|
104
115
|
}
|
|
@@ -139,7 +150,7 @@ export async function buildArchive(config: ResolvedEmbeddableConfig) {
|
|
|
139
150
|
|
|
140
151
|
if (!config.pushModels && !config.pushComponents) {
|
|
141
152
|
spinnerArchive.fail(
|
|
142
|
-
"Cannot push: both pushModels and pushComponents are disabled"
|
|
153
|
+
"Cannot push: both pushModels and pushComponents are disabled"
|
|
143
154
|
);
|
|
144
155
|
process.exit(1);
|
|
145
156
|
}
|
|
@@ -149,11 +160,11 @@ export async function buildArchive(config: ResolvedEmbeddableConfig) {
|
|
|
149
160
|
if (config.pushModels) {
|
|
150
161
|
const cubeFilesList = await findFiles(
|
|
151
162
|
config.client.modelsSrc || config.client.srcDir,
|
|
152
|
-
CUBE_FILES
|
|
163
|
+
CUBE_FILES
|
|
153
164
|
);
|
|
154
165
|
const contextFilesList = await findFiles(
|
|
155
166
|
config.client.presetsSrc || config.client.srcDir,
|
|
156
|
-
PRESET_FILES
|
|
167
|
+
PRESET_FILES
|
|
157
168
|
);
|
|
158
169
|
filesList.push(
|
|
159
170
|
...cubeFilesList.map((entry): [string, string] => [
|
|
@@ -163,7 +174,7 @@ export async function buildArchive(config: ResolvedEmbeddableConfig) {
|
|
|
163
174
|
...contextFilesList.map((entry): [string, string] => [
|
|
164
175
|
path.basename(entry[1]),
|
|
165
176
|
entry[1],
|
|
166
|
-
])
|
|
177
|
+
])
|
|
167
178
|
);
|
|
168
179
|
}
|
|
169
180
|
|
|
@@ -210,7 +221,7 @@ export async function archive(args: {
|
|
|
210
221
|
|
|
211
222
|
export async function createFormData(
|
|
212
223
|
filePath: string,
|
|
213
|
-
metadata: Record<string, any
|
|
224
|
+
metadata: Record<string, any>
|
|
214
225
|
) {
|
|
215
226
|
const { FormData, Blob } = await import("formdata-node");
|
|
216
227
|
const { fileFromPath } = await import("formdata-node/file-from-path");
|
|
@@ -233,7 +244,7 @@ export async function sendBuildByApiKey(
|
|
|
233
244
|
apiKey,
|
|
234
245
|
email,
|
|
235
246
|
message,
|
|
236
|
-
}: { apiKey: string; email: string; message?: string }
|
|
247
|
+
}: { apiKey: string; email: string; message?: string }
|
|
237
248
|
) {
|
|
238
249
|
const form = await createFormData(ctx.client.archiveFile, {
|
|
239
250
|
pushModels: ctx.pushModels,
|
|
@@ -245,7 +256,7 @@ export async function sendBuildByApiKey(
|
|
|
245
256
|
const response = await uploadFile(
|
|
246
257
|
form,
|
|
247
258
|
`${ctx.pushBaseUrl}/api/v1/bundle/upload`,
|
|
248
|
-
apiKey
|
|
259
|
+
apiKey
|
|
249
260
|
);
|
|
250
261
|
await fs.rm(ctx.client.archiveFile);
|
|
251
262
|
|
|
@@ -258,7 +269,7 @@ export async function sendBuild(
|
|
|
258
269
|
workspaceId,
|
|
259
270
|
token,
|
|
260
271
|
message,
|
|
261
|
-
}: { workspaceId: string; token: string; message?: string }
|
|
272
|
+
}: { workspaceId: string; token: string; message?: string }
|
|
262
273
|
) {
|
|
263
274
|
const form = await createFormData(ctx.client.archiveFile, {
|
|
264
275
|
pushModels: ctx.pushModels,
|
|
@@ -270,7 +281,7 @@ export async function sendBuild(
|
|
|
270
281
|
await uploadFile(
|
|
271
282
|
form,
|
|
272
283
|
`${ctx.pushBaseUrl}/bundle/${workspaceId}/upload`,
|
|
273
|
-
token
|
|
284
|
+
token
|
|
274
285
|
);
|
|
275
286
|
|
|
276
287
|
await fs.rm(ctx.client.archiveFile);
|