@embeddable.com/sdk-core 3.14.2-next.0 → 3.14.2-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 +19 -31
- package/lib/index.esm.js.map +1 -1
- package/lib/push.d.ts +4 -2
- package/package.json +2 -2
- package/src/buildGlobalHooks.int.test.ts +3 -0
- package/src/buildGlobalHooks.ts +2 -1
- package/src/buildGlobalHooks.unit.test.ts +4 -0
- package/src/cleanup.ts +5 -0
- package/src/push.test.ts +10 -3
- package/src/push.ts +12 -6
- package/src/validate.ts +3 -24
package/lib/push.d.ts
CHANGED
|
@@ -12,13 +12,15 @@ export declare function archive(args: {
|
|
|
12
12
|
isDev: boolean;
|
|
13
13
|
}): Promise<void>;
|
|
14
14
|
export declare function createFormData(filePath: string, metadata: Record<string, any>): Promise<import("formdata-node").FormData>;
|
|
15
|
-
export declare function sendBuildByApiKey(ctx: ResolvedEmbeddableConfig, { apiKey, email, message, }: {
|
|
15
|
+
export declare function sendBuildByApiKey(ctx: ResolvedEmbeddableConfig, { apiKey, email, message, cubeVersion, }: {
|
|
16
16
|
apiKey: string;
|
|
17
17
|
email: string;
|
|
18
18
|
message?: string;
|
|
19
|
+
cubeVersion?: string;
|
|
19
20
|
}): Promise<any>;
|
|
20
|
-
export declare function sendBuild(ctx: ResolvedEmbeddableConfig, { workspaceId, token, message, }: {
|
|
21
|
+
export declare function sendBuild(ctx: ResolvedEmbeddableConfig, { workspaceId, token, message, cubeVersion, }: {
|
|
21
22
|
workspaceId: string;
|
|
22
23
|
token: string;
|
|
23
24
|
message?: string;
|
|
25
|
+
cubeVersion?: string;
|
|
24
26
|
}): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embeddable.com/sdk-core",
|
|
3
|
-
"version": "3.14.2-next.
|
|
3
|
+
"version": "3.14.2-next.2",
|
|
4
4
|
"description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"embeddable",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@embeddable.com/core": "2.10.
|
|
43
|
+
"@embeddable.com/core": "2.10.2-next.0",
|
|
44
44
|
"@embeddable.com/sdk-utils": "0.8.0",
|
|
45
45
|
"@inquirer/prompts": "^7.2.1",
|
|
46
46
|
"@stencil/core": "^4.23.0",
|
|
@@ -15,6 +15,7 @@ import path from "node:path";
|
|
|
15
15
|
|
|
16
16
|
const rootDir = path.resolve("fake", "root");
|
|
17
17
|
const buildDir = path.resolve("fake", "build");
|
|
18
|
+
const tmpDir = path.resolve("fake", "tmp");
|
|
18
19
|
const srcDir = path.resolve("fake", "src");
|
|
19
20
|
const lifecycleFile = path.resolve("fake", "root", "embeddable.lifecycle.ts");
|
|
20
21
|
const themFile = path.resolve("fake", "root", "embeddable.theme.ts");
|
|
@@ -91,6 +92,7 @@ describe("buildGlobalHooks (Integration Tests)", () => {
|
|
|
91
92
|
client: {
|
|
92
93
|
srcDir,
|
|
93
94
|
buildDir,
|
|
95
|
+
tmpDir,
|
|
94
96
|
rootDir,
|
|
95
97
|
lifecycleHooksFile: lifecycleFile,
|
|
96
98
|
customizationFile: themFile,
|
|
@@ -188,6 +190,7 @@ describe("buildGlobalHooks (Integration Tests)", () => {
|
|
|
188
190
|
client: {
|
|
189
191
|
srcDir,
|
|
190
192
|
buildDir,
|
|
193
|
+
tmpDir,
|
|
191
194
|
rootDir,
|
|
192
195
|
lifecycleHooksFile: lifecycleFile,
|
|
193
196
|
customizationFile: themFile,
|
package/src/buildGlobalHooks.ts
CHANGED
|
@@ -23,6 +23,7 @@ export default async (ctx: ResolvedEmbeddableConfig) => {
|
|
|
23
23
|
const progress = watch ? undefined : ora("Building global hooks...").start();
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
|
+
await fs.mkdir(ctx.client.tmpDir, { recursive: true });
|
|
26
27
|
const { fileName: themeProvider, watcher: themeWatcher } =
|
|
27
28
|
await buildThemeHook(ctx);
|
|
28
29
|
const { lifecycleHooks, watcher: lifecycleWatcher } =
|
|
@@ -232,7 +233,7 @@ async function cleanupTemporaryHookFile(ctx: ResolvedEmbeddableConfig) {
|
|
|
232
233
|
* Get the path to the temporary hook file in the build directory.
|
|
233
234
|
*/
|
|
234
235
|
function getTempHookFilePath(ctx: ResolvedEmbeddableConfig): string {
|
|
235
|
-
return path.resolve(ctx.client.
|
|
236
|
+
return path.resolve(ctx.client.tmpDir, TEMP_JS_HOOK_FILE);
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
function waitForInitialBuild(watcher: RollupWatcher): Promise<void> {
|
|
@@ -70,6 +70,7 @@ describe("buildGlobalHooks (Unit Tests)", () => {
|
|
|
70
70
|
client: {
|
|
71
71
|
srcDir: path.resolve(process.cwd(), "fake", "src"),
|
|
72
72
|
buildDir: path.resolve(process.cwd(), "fake", "build"),
|
|
73
|
+
tmpDir: path.resolve(process.cwd(), "fake", "tmp"),
|
|
73
74
|
rootDir: path.resolve(process.cwd(), "fake", "root"),
|
|
74
75
|
lifecycleHooksFile: lifecyclePath,
|
|
75
76
|
componentLibraries: [],
|
|
@@ -113,6 +114,7 @@ describe("buildGlobalHooks (Unit Tests)", () => {
|
|
|
113
114
|
client: {
|
|
114
115
|
srcDir: path.resolve(process.cwd(), "fake", "src"),
|
|
115
116
|
buildDir: path.resolve(process.cwd(), "fake", "build"),
|
|
117
|
+
tmpDir: path.resolve(process.cwd(), "fake", "tmp"),
|
|
116
118
|
rootDir: path.resolve(process.cwd(), "fake", "root"),
|
|
117
119
|
lifecycleHooksFile: lifecyclePath,
|
|
118
120
|
customizationFile: themePath,
|
|
@@ -190,6 +192,7 @@ describe("buildGlobalHooks (Unit Tests)", () => {
|
|
|
190
192
|
client: {
|
|
191
193
|
srcDir: path.resolve(process.cwd(), "fake", "src"),
|
|
192
194
|
buildDir: path.resolve(process.cwd(), "fake", "build"),
|
|
195
|
+
tmpDir: path.resolve(process.cwd(), "fake", "tmp"),
|
|
193
196
|
rootDir: path.resolve(process.cwd(), "fake", "root"),
|
|
194
197
|
lifecycleHooksFile: lifecyclePath,
|
|
195
198
|
customizationFile: themePath,
|
|
@@ -242,6 +245,7 @@ describe("buildGlobalHooks (Unit Tests)", () => {
|
|
|
242
245
|
client: {
|
|
243
246
|
srcDir: path.resolve(process.cwd(), "fake", "src"),
|
|
244
247
|
buildDir: path.resolve(process.cwd(), "fake", "build"),
|
|
248
|
+
tmpDir: path.resolve(process.cwd(), "fake", "tmp"),
|
|
245
249
|
rootDir: path.resolve(process.cwd(), "fake", "root"),
|
|
246
250
|
lifecycleHooksFile: lifecyclePath,
|
|
247
251
|
customizationFile: themePath,
|
package/src/cleanup.ts
CHANGED
|
@@ -75,6 +75,11 @@ export async function createManifest({
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
async function extractBuild(ctx: ResolvedEmbeddableConfig) {
|
|
78
|
+
// Ensure tmpDir is removed before attempting to rename a directory to it.
|
|
79
|
+
// This helps prevent EPERM errors on Windows if tmpDir already exists and is non-empty
|
|
80
|
+
// from a previous failed run or other reasons.
|
|
81
|
+
await fs.rm(ctx.client.tmpDir, { recursive: true, force: true });
|
|
82
|
+
|
|
78
83
|
const stencilBuildFiles = await findFiles(
|
|
79
84
|
ctx.client.stencilBuild,
|
|
80
85
|
/embeddable-wrapper.esm-[a-z0-9]+\.js/,
|
package/src/push.test.ts
CHANGED
|
@@ -320,13 +320,20 @@ describe("push", () => {
|
|
|
320
320
|
"valid@email.com",
|
|
321
321
|
"--message",
|
|
322
322
|
"test message",
|
|
323
|
+
"--cube-version",
|
|
324
|
+
"v1.34",
|
|
323
325
|
],
|
|
324
326
|
},
|
|
325
327
|
});
|
|
326
328
|
vi.mocked(getArgumentByKey)
|
|
327
|
-
.
|
|
328
|
-
|
|
329
|
-
|
|
329
|
+
.mockImplementation((keysArg) => {
|
|
330
|
+
const key = Array.isArray(keysArg) ? keysArg[0] : keysArg;
|
|
331
|
+
if (key === '--api-key') return 'some-key';
|
|
332
|
+
if (key === '--email') return 'valid@email.com';
|
|
333
|
+
if (key === '--message') return 'test message';
|
|
334
|
+
if (key === '--cube-version') return 'v1.34';
|
|
335
|
+
return undefined;
|
|
336
|
+
});
|
|
330
337
|
|
|
331
338
|
await push();
|
|
332
339
|
|
package/src/push.ts
CHANGED
|
@@ -32,6 +32,7 @@ export default async () => {
|
|
|
32
32
|
breadcrumbs.push("checkNodeVersion");
|
|
33
33
|
const isBuildSuccess = await checkBuildSuccess();
|
|
34
34
|
const config = await provideConfig();
|
|
35
|
+
const cubeVersion = getArgumentByKey(["--cube-version"]);
|
|
35
36
|
|
|
36
37
|
if (!isBuildSuccess && config.pushComponents) {
|
|
37
38
|
console.error(
|
|
@@ -44,7 +45,7 @@ export default async () => {
|
|
|
44
45
|
spinnerPushing = ora("Using API key...").start();
|
|
45
46
|
breadcrumbs.push("push by api key");
|
|
46
47
|
try {
|
|
47
|
-
await pushByApiKey(config, spinnerPushing);
|
|
48
|
+
await pushByApiKey(config, spinnerPushing, cubeVersion);
|
|
48
49
|
} catch (error: any) {
|
|
49
50
|
if (error.response?.data?.errorCode === "BUILDER-998") {
|
|
50
51
|
spinnerPushing.fail(
|
|
@@ -88,7 +89,7 @@ Read more about deployment regions at https://docs.embeddable.com/deployment/dep
|
|
|
88
89
|
);
|
|
89
90
|
|
|
90
91
|
breadcrumbs.push("send build");
|
|
91
|
-
await sendBuild(config, { workspaceId, token, message });
|
|
92
|
+
await sendBuild(config, { workspaceId, token, message, cubeVersion });
|
|
92
93
|
|
|
93
94
|
publishedSectionFeedback(config, spinnerPushing);
|
|
94
95
|
spinnerPushing.succeed(
|
|
@@ -111,7 +112,7 @@ const publishedSectionFeedback = (
|
|
|
111
112
|
config.pushComponents && spinnerPushing.succeed("Components published");
|
|
112
113
|
};
|
|
113
114
|
|
|
114
|
-
async function pushByApiKey(config: ResolvedEmbeddableConfig, spinner: any) {
|
|
115
|
+
async function pushByApiKey(config: ResolvedEmbeddableConfig, spinner: any, cubeVersion?: string) {
|
|
115
116
|
const apiKey = getArgumentByKey(["--api-key", "-k"]);
|
|
116
117
|
|
|
117
118
|
if (!apiKey) {
|
|
@@ -137,6 +138,7 @@ async function pushByApiKey(config: ResolvedEmbeddableConfig, spinner: any) {
|
|
|
137
138
|
apiKey,
|
|
138
139
|
email,
|
|
139
140
|
message,
|
|
141
|
+
cubeVersion,
|
|
140
142
|
});
|
|
141
143
|
}
|
|
142
144
|
|
|
@@ -277,13 +279,15 @@ export async function sendBuildByApiKey(
|
|
|
277
279
|
apiKey,
|
|
278
280
|
email,
|
|
279
281
|
message,
|
|
280
|
-
|
|
282
|
+
cubeVersion,
|
|
283
|
+
}: { apiKey: string; email: string; message?: string; cubeVersion?: string },
|
|
281
284
|
) {
|
|
282
285
|
const form = await createFormData(ctx.client.archiveFile, {
|
|
283
286
|
pushModels: ctx.pushModels,
|
|
284
287
|
pushComponents: ctx.pushComponents,
|
|
285
288
|
authorEmail: email,
|
|
286
289
|
description: message,
|
|
290
|
+
...(cubeVersion ? { cubeVersion } : {}),
|
|
287
291
|
});
|
|
288
292
|
|
|
289
293
|
const response = await uploadFile(
|
|
@@ -293,7 +297,7 @@ export async function sendBuildByApiKey(
|
|
|
293
297
|
);
|
|
294
298
|
await fs.rm(ctx.client.archiveFile);
|
|
295
299
|
|
|
296
|
-
return { ...response.data, message };
|
|
300
|
+
return { ...response.data, message, cubeVersion };
|
|
297
301
|
}
|
|
298
302
|
|
|
299
303
|
export async function sendBuild(
|
|
@@ -302,13 +306,15 @@ export async function sendBuild(
|
|
|
302
306
|
workspaceId,
|
|
303
307
|
token,
|
|
304
308
|
message,
|
|
305
|
-
|
|
309
|
+
cubeVersion,
|
|
310
|
+
}: { workspaceId: string; token: string; message?: string; cubeVersion?: string },
|
|
306
311
|
) {
|
|
307
312
|
const form = await createFormData(ctx.client.archiveFile, {
|
|
308
313
|
pushModels: ctx.pushModels,
|
|
309
314
|
pushComponents: ctx.pushComponents,
|
|
310
315
|
authorEmail: "",
|
|
311
316
|
description: message,
|
|
317
|
+
...(cubeVersion ? { cubeVersion } : {}),
|
|
312
318
|
});
|
|
313
319
|
|
|
314
320
|
await uploadFile(
|
package/src/validate.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as YAML from "yaml";
|
|
3
3
|
import { errorFormatter, findFiles } from "@embeddable.com/sdk-utils";
|
|
4
|
+
import { DIMENSION_TYPES, MEASURE_TYPES } from "@embeddable.com/core";
|
|
4
5
|
import { z } from "zod";
|
|
5
6
|
import ora from "ora";
|
|
6
7
|
import { checkNodeVersion } from "./utils";
|
|
@@ -170,28 +171,6 @@ export async function clientContextValidation(filesList: [string, string][]) {
|
|
|
170
171
|
return errors;
|
|
171
172
|
}
|
|
172
173
|
|
|
173
|
-
enum MeasureTypeEnum {
|
|
174
|
-
string = "string",
|
|
175
|
-
time = "time",
|
|
176
|
-
boolean = "boolean",
|
|
177
|
-
number = "number",
|
|
178
|
-
count = "count",
|
|
179
|
-
count_distinct = "count_distinct",
|
|
180
|
-
count_distinct_approx = "count_distinct_approx",
|
|
181
|
-
sum = "sum",
|
|
182
|
-
avg = "avg",
|
|
183
|
-
min = "min",
|
|
184
|
-
max = "max",
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
enum DimensionTypeEnum {
|
|
188
|
-
string = "string",
|
|
189
|
-
time = "time",
|
|
190
|
-
boolean = "boolean",
|
|
191
|
-
number = "number",
|
|
192
|
-
geo = "geo",
|
|
193
|
-
}
|
|
194
|
-
|
|
195
174
|
const cubeModelSchema = z
|
|
196
175
|
.object({
|
|
197
176
|
cubes: z
|
|
@@ -200,14 +179,14 @@ const cubeModelSchema = z
|
|
|
200
179
|
dimensions: z
|
|
201
180
|
.object({
|
|
202
181
|
name: z.string(),
|
|
203
|
-
type: z.
|
|
182
|
+
type: z.enum(DIMENSION_TYPES),
|
|
204
183
|
})
|
|
205
184
|
.array()
|
|
206
185
|
.optional(),
|
|
207
186
|
measures: z
|
|
208
187
|
.object({
|
|
209
188
|
name: z.string(),
|
|
210
|
-
type: z.
|
|
189
|
+
type: z.enum(MEASURE_TYPES),
|
|
211
190
|
})
|
|
212
191
|
.array()
|
|
213
192
|
.optional(),
|