@embeddable.com/sdk-core 3.14.2-next.2 → 3.14.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/dev.d.ts +8 -0
- package/lib/index.esm.js +9 -8
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +22492 -0
- package/lib/index.js.map +1 -0
- package/package.json +3 -3
- package/src/dev.test.ts +177 -7
- package/src/dev.ts +38 -29
- package/src/push.test.ts +8 -9
- package/src/push.ts +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embeddable.com/sdk-core",
|
|
3
|
-
"version": "3.14.2
|
|
3
|
+
"version": "3.14.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.2
|
|
43
|
+
"@embeddable.com/core": "2.10.2",
|
|
44
44
|
"@embeddable.com/sdk-utils": "0.8.0",
|
|
45
45
|
"@inquirer/prompts": "^7.2.1",
|
|
46
46
|
"@stencil/core": "^4.23.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"finalhandler": "^1.3.1",
|
|
54
54
|
"formdata-node": "^6.0.3",
|
|
55
55
|
"minimist": "^1.2.8",
|
|
56
|
-
"open": "^
|
|
56
|
+
"open": "^10.1.2",
|
|
57
57
|
"ora": "^8.1.1",
|
|
58
58
|
"serve-static": "^1.16.2",
|
|
59
59
|
"sorcery": "^1.0.0",
|
package/src/dev.test.ts
CHANGED
|
@@ -5,7 +5,17 @@ import provideConfig from "./provideConfig";
|
|
|
5
5
|
import buildGlobalHooks from "./buildGlobalHooks";
|
|
6
6
|
import { getToken } from "./login";
|
|
7
7
|
import * as chokidar from "chokidar";
|
|
8
|
-
import
|
|
8
|
+
import generate from "./generate";
|
|
9
|
+
import buildTypes from "./buildTypes";
|
|
10
|
+
import validate from "./validate";
|
|
11
|
+
import { findFiles } from "@embeddable.com/sdk-utils";
|
|
12
|
+
import dev, {
|
|
13
|
+
configureWatcher,
|
|
14
|
+
buildWebComponent,
|
|
15
|
+
globalHookWatcher,
|
|
16
|
+
openDevWorkspacePage,
|
|
17
|
+
sendBuildChanges,
|
|
18
|
+
} from "./dev";
|
|
9
19
|
import { checkNodeVersion } from "./utils";
|
|
10
20
|
import { createManifest } from "./cleanup";
|
|
11
21
|
import prepare from "./prepare";
|
|
@@ -14,7 +24,9 @@ import * as open from "open";
|
|
|
14
24
|
import { logError } from "./logger";
|
|
15
25
|
import { ResolvedEmbeddableConfig } from "./defineConfig";
|
|
16
26
|
import { RollupWatcher } from "rollup";
|
|
17
|
-
import
|
|
27
|
+
import ora from "ora";
|
|
28
|
+
import push, { archive } from "./push";
|
|
29
|
+
|
|
18
30
|
// Mock dependencies
|
|
19
31
|
vi.mock("./buildTypes", () => ({ default: vi.fn() }));
|
|
20
32
|
vi.mock("./buildGlobalHooks", () => ({ default: vi.fn() }));
|
|
@@ -31,18 +43,46 @@ vi.mock("chokidar", () => ({ watch: vi.fn((_) => ({ on: vi.fn() })) }));
|
|
|
31
43
|
vi.mock("./login", () => ({ getToken: vi.fn(), default: vi.fn() }));
|
|
32
44
|
vi.mock("axios", () => ({ default: { get: vi.fn(), post: vi.fn() } }));
|
|
33
45
|
vi.mock("@embeddable.com/sdk-utils", () => ({ findFiles: vi.fn() }));
|
|
34
|
-
vi.mock("./push", () => ({ archive: vi.fn(), sendBuild: vi.fn() }));
|
|
35
46
|
vi.mock("./validate", () => ({ default: vi.fn() }));
|
|
36
47
|
vi.mock("./utils", () => ({ checkNodeVersion: vi.fn() }));
|
|
37
48
|
vi.mock("./cleanup", () => ({ createManifest: vi.fn() }));
|
|
38
49
|
vi.mock("node:http", () => ({
|
|
39
50
|
createServer: vi.fn(() => ({ listen: vi.fn() })),
|
|
40
51
|
}));
|
|
52
|
+
|
|
41
53
|
vi.mock("./logger", () => ({
|
|
42
54
|
initLogger: vi.fn(),
|
|
43
55
|
logError: vi.fn(),
|
|
44
56
|
}));
|
|
45
57
|
|
|
58
|
+
vi.mock("./push", async (importOriginal) => {
|
|
59
|
+
const actual = await importOriginal<typeof push>();
|
|
60
|
+
return {
|
|
61
|
+
...actual,
|
|
62
|
+
archive: vi.fn(),
|
|
63
|
+
sendBuild: vi.fn(),
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
vi.mock("open", () => ({ default: vi.fn() }));
|
|
68
|
+
vi.mock("ora", () => ({
|
|
69
|
+
default: vi.fn(() => ({
|
|
70
|
+
info: vi.fn(),
|
|
71
|
+
start: vi.fn(),
|
|
72
|
+
succeed: vi.fn(),
|
|
73
|
+
fail: vi.fn(),
|
|
74
|
+
stop: vi.fn(),
|
|
75
|
+
})),
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
vi.mock("./dev", async (importOriginal) => {
|
|
79
|
+
const actual = await importOriginal<typeof dev>();
|
|
80
|
+
return {
|
|
81
|
+
...actual,
|
|
82
|
+
buildWebComponent: vi.fn(),
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
|
|
46
86
|
const mockConfig = {
|
|
47
87
|
client: {
|
|
48
88
|
rootDir: "/mock/root",
|
|
@@ -58,31 +98,47 @@ const mockConfig = {
|
|
|
58
98
|
plugins: [],
|
|
59
99
|
previewBaseUrl: "http://preview.example.com",
|
|
60
100
|
pushBaseUrl: "http://push.example.com",
|
|
101
|
+
pushComponents: true,
|
|
102
|
+
pushModels: true,
|
|
61
103
|
};
|
|
62
104
|
|
|
63
105
|
describe("dev command", () => {
|
|
64
106
|
let listenMock: Mock;
|
|
107
|
+
let wsMock: any;
|
|
108
|
+
let oraMock: any;
|
|
65
109
|
beforeEach(() => {
|
|
66
110
|
listenMock = vi.fn();
|
|
111
|
+
wsMock = {
|
|
112
|
+
send: vi.fn(),
|
|
113
|
+
};
|
|
114
|
+
oraMock = {
|
|
115
|
+
info: vi.fn(),
|
|
116
|
+
start: vi.fn(() => oraMock),
|
|
117
|
+
succeed: vi.fn(),
|
|
118
|
+
fail: vi.fn(),
|
|
119
|
+
stop: vi.fn(),
|
|
120
|
+
};
|
|
67
121
|
vi.mocked(http.createServer).mockImplementation(
|
|
68
122
|
() =>
|
|
69
123
|
({
|
|
70
124
|
listen: listenMock,
|
|
71
|
-
}) as any
|
|
125
|
+
}) as any,
|
|
72
126
|
);
|
|
73
127
|
vi.mocked(WebSocketServer).mockImplementation(() => {
|
|
74
128
|
return {
|
|
75
|
-
clients: [],
|
|
129
|
+
clients: [wsMock],
|
|
76
130
|
on: vi.fn(),
|
|
77
131
|
} as any;
|
|
78
132
|
});
|
|
79
133
|
|
|
134
|
+
vi.mocked(ora).mockImplementation(() => oraMock);
|
|
135
|
+
|
|
80
136
|
// Mock process.on to avoid actually setting up process listeners
|
|
81
137
|
vi.spyOn(process, "on").mockImplementation(() => process);
|
|
82
138
|
vi.spyOn(process, "exit").mockImplementation(() => undefined as never);
|
|
83
139
|
|
|
84
140
|
vi.mocked(provideConfig).mockResolvedValue(
|
|
85
|
-
mockConfig as unknown as ResolvedEmbeddableConfig
|
|
141
|
+
mockConfig as unknown as ResolvedEmbeddableConfig,
|
|
86
142
|
);
|
|
87
143
|
vi.mocked(getToken).mockResolvedValue("mock-token");
|
|
88
144
|
vi.mocked(axios.get).mockResolvedValue({
|
|
@@ -98,6 +154,13 @@ describe("dev command", () => {
|
|
|
98
154
|
themeWatcher: watcherMock,
|
|
99
155
|
lifecycleWatcher: watcherMock,
|
|
100
156
|
});
|
|
157
|
+
|
|
158
|
+
vi.mocked(buildWebComponent).mockImplementation(() => Promise.resolve());
|
|
159
|
+
vi.mocked(validate).mockImplementation(() => Promise.resolve(true));
|
|
160
|
+
|
|
161
|
+
vi.mocked(findFiles).mockResolvedValue([
|
|
162
|
+
["mock-model.json", "/mock/root/models/mock-model.json"],
|
|
163
|
+
]);
|
|
101
164
|
});
|
|
102
165
|
|
|
103
166
|
afterEach(() => {
|
|
@@ -130,7 +193,7 @@ describe("dev command", () => {
|
|
|
130
193
|
await expect.poll(() => chokidar.watch).toBeCalledTimes(1);
|
|
131
194
|
|
|
132
195
|
expect(open.default).toHaveBeenCalledWith(
|
|
133
|
-
"http://preview.example.com/workspace/mock-workspace"
|
|
196
|
+
"http://preview.example.com/workspace/mock-workspace",
|
|
134
197
|
);
|
|
135
198
|
});
|
|
136
199
|
|
|
@@ -211,4 +274,111 @@ describe("dev command", () => {
|
|
|
211
274
|
|
|
212
275
|
console.log = originalConsoleLog;
|
|
213
276
|
});
|
|
277
|
+
|
|
278
|
+
describe("configureWatcher", () => {
|
|
279
|
+
it("should configure the watcher", () => {
|
|
280
|
+
const watcher = { on: vi.fn() } as unknown as RollupWatcher;
|
|
281
|
+
configureWatcher(
|
|
282
|
+
watcher,
|
|
283
|
+
mockConfig as unknown as ResolvedEmbeddableConfig,
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
expect(watcher.on).toHaveBeenCalledWith("change", expect.any(Function));
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("should call generate on BUNDLE_END", async () => {
|
|
290
|
+
let onHandler: ((event: any) => void) | undefined;
|
|
291
|
+
const watcher = {
|
|
292
|
+
on: (event: string, handler: (event: any) => void) => {
|
|
293
|
+
onHandler = handler;
|
|
294
|
+
},
|
|
295
|
+
} as unknown as RollupWatcher;
|
|
296
|
+
configureWatcher(
|
|
297
|
+
watcher,
|
|
298
|
+
mockConfig as unknown as ResolvedEmbeddableConfig,
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
await onHandler?.({
|
|
302
|
+
code: "BUNDLE_END",
|
|
303
|
+
} as any);
|
|
304
|
+
|
|
305
|
+
expect(generate).toHaveBeenCalledWith(mockConfig, "sdk-react");
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("should call buildTypes on BUNDLE_START", async () => {
|
|
309
|
+
let onHandler: ((event: any) => void) | undefined;
|
|
310
|
+
|
|
311
|
+
const watcher = {
|
|
312
|
+
on: (event: string, handler: (event: any) => void) => {
|
|
313
|
+
onHandler = handler;
|
|
314
|
+
},
|
|
315
|
+
} as unknown as RollupWatcher;
|
|
316
|
+
configureWatcher(
|
|
317
|
+
watcher,
|
|
318
|
+
mockConfig as unknown as ResolvedEmbeddableConfig,
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
await onHandler?.({
|
|
322
|
+
code: "BUNDLE_START",
|
|
323
|
+
} as any);
|
|
324
|
+
|
|
325
|
+
expect(buildTypes).toHaveBeenCalledWith(mockConfig);
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
describe("globalHookWatcher", () => {
|
|
330
|
+
it("should call watcher.on", async () => {
|
|
331
|
+
const watcher = { on: vi.fn() } as unknown as RollupWatcher;
|
|
332
|
+
globalHookWatcher(watcher);
|
|
333
|
+
|
|
334
|
+
await expect
|
|
335
|
+
.poll(() => watcher.on)
|
|
336
|
+
.toBeCalledWith("change", expect.any(Function));
|
|
337
|
+
|
|
338
|
+
expect(watcher.on).toHaveBeenCalledWith("event", expect.any(Function));
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
describe("openDevWorkspacePage", () => {
|
|
343
|
+
it("should open the dev workspace page", async () => {
|
|
344
|
+
await openDevWorkspacePage(
|
|
345
|
+
"http://preview.example.com",
|
|
346
|
+
"mock-workspace",
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
expect(open.default).toHaveBeenCalledWith(
|
|
350
|
+
"http://preview.example.com/workspace/mock-workspace",
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
expect(ora).toHaveBeenCalledWith(
|
|
354
|
+
"Preview workspace is available at http://preview.example.com/workspace/mock-workspace",
|
|
355
|
+
);
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
describe("sendBuildChanges", () => {
|
|
360
|
+
it("should send the build changes", async () => {
|
|
361
|
+
await sendBuildChanges(mockConfig as unknown as ResolvedEmbeddableConfig);
|
|
362
|
+
|
|
363
|
+
const filesList = [
|
|
364
|
+
...Array.from({ length: 3 }, () => [
|
|
365
|
+
"mock-model.json",
|
|
366
|
+
"/mock/root/models/mock-model.json",
|
|
367
|
+
]),
|
|
368
|
+
[
|
|
369
|
+
"embeddable-manifest.json",
|
|
370
|
+
process.platform === "win32"
|
|
371
|
+
? "D:\\mock\\root\\.embeddable-dev-build\\embeddable-manifest.json"
|
|
372
|
+
: "/mock/root/.embeddable-dev-build/embeddable-manifest.json",
|
|
373
|
+
],
|
|
374
|
+
];
|
|
375
|
+
|
|
376
|
+
expect(getToken).toHaveBeenCalled();
|
|
377
|
+
expect(archive).toHaveBeenCalledWith({
|
|
378
|
+
ctx: mockConfig,
|
|
379
|
+
filesList,
|
|
380
|
+
isDev: true,
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
});
|
|
214
384
|
});
|
package/src/dev.ts
CHANGED
|
@@ -4,6 +4,7 @@ import buildTypes, {
|
|
|
4
4
|
} from "./buildTypes";
|
|
5
5
|
import prepare, { removeIfExists } from "./prepare";
|
|
6
6
|
import generate from "./generate";
|
|
7
|
+
import open from "open";
|
|
7
8
|
import provideConfig from "./provideConfig";
|
|
8
9
|
import {
|
|
9
10
|
CompilerSystem,
|
|
@@ -56,7 +57,7 @@ const SERVER_PORT = 8926;
|
|
|
56
57
|
const BUILD_DEV_DIR = ".embeddable-dev-build";
|
|
57
58
|
const GLOBAL_CSS = "/global.css";
|
|
58
59
|
|
|
59
|
-
const buildWebComponent = async (config: any) => {
|
|
60
|
+
export const buildWebComponent = async (config: any) => {
|
|
60
61
|
await generate(config, "sdk-react");
|
|
61
62
|
};
|
|
62
63
|
|
|
@@ -114,7 +115,7 @@ export default async () => {
|
|
|
114
115
|
stencilBuild: path.resolve(buildDir, "dist", "embeddable-wrapper"),
|
|
115
116
|
tmpDir: path.resolve(
|
|
116
117
|
defaultConfig.client.rootDir,
|
|
117
|
-
".embeddable-dev-tmp"
|
|
118
|
+
".embeddable-dev-tmp",
|
|
118
119
|
),
|
|
119
120
|
},
|
|
120
121
|
};
|
|
@@ -130,7 +131,7 @@ export default async () => {
|
|
|
130
131
|
try {
|
|
131
132
|
previewWorkspace = await getPreviewWorkspace(
|
|
132
133
|
workspacePreparation,
|
|
133
|
-
config
|
|
134
|
+
config,
|
|
134
135
|
);
|
|
135
136
|
} catch (e: any) {
|
|
136
137
|
if (e.response?.status === 401) {
|
|
@@ -139,11 +140,11 @@ export default async () => {
|
|
|
139
140
|
workspacePreparation = ora("Preparing workspace...").start();
|
|
140
141
|
previewWorkspace = await getPreviewWorkspace(
|
|
141
142
|
workspacePreparation,
|
|
142
|
-
config
|
|
143
|
+
config,
|
|
143
144
|
);
|
|
144
145
|
} else {
|
|
145
146
|
workspacePreparation.fail(
|
|
146
|
-
e.response?.data?.errorMessage || "Unknown error: " + e.message
|
|
147
|
+
e.response?.data?.errorMessage || "Unknown error: " + e.message,
|
|
147
148
|
);
|
|
148
149
|
process.exit(1);
|
|
149
150
|
}
|
|
@@ -156,11 +157,11 @@ export default async () => {
|
|
|
156
157
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
157
158
|
res.setHeader(
|
|
158
159
|
"Access-Control-Allow-Methods",
|
|
159
|
-
"GET, POST, PUT, DELETE, OPTIONS"
|
|
160
|
+
"GET, POST, PUT, DELETE, OPTIONS",
|
|
160
161
|
);
|
|
161
162
|
res.setHeader(
|
|
162
163
|
"Access-Control-Allow-Headers",
|
|
163
|
-
"Content-Type, Authorization"
|
|
164
|
+
"Content-Type, Authorization",
|
|
164
165
|
);
|
|
165
166
|
|
|
166
167
|
if (request.method === "OPTIONS") {
|
|
@@ -181,7 +182,7 @@ export default async () => {
|
|
|
181
182
|
} catch {}
|
|
182
183
|
|
|
183
184
|
serve(request, res, done);
|
|
184
|
-
}
|
|
185
|
+
},
|
|
185
186
|
);
|
|
186
187
|
|
|
187
188
|
const { themeWatcher, lifecycleWatcher } = await buildGlobalHooks(config);
|
|
@@ -191,7 +192,7 @@ export default async () => {
|
|
|
191
192
|
const watchers: Array<RollupWatcher | FSWatcher> = [];
|
|
192
193
|
if (sys?.onProcessInterrupt) {
|
|
193
194
|
sys.onProcessInterrupt(
|
|
194
|
-
async () => await onClose(server, sys, watchers, config)
|
|
195
|
+
async () => await onClose(server, sys, watchers, config),
|
|
195
196
|
);
|
|
196
197
|
}
|
|
197
198
|
|
|
@@ -229,15 +230,15 @@ export default async () => {
|
|
|
229
230
|
watchers.push(customGlobalCssWatch);
|
|
230
231
|
|
|
231
232
|
if (themeWatcher) {
|
|
232
|
-
await globalHookWatcher(themeWatcher
|
|
233
|
+
await globalHookWatcher(themeWatcher);
|
|
233
234
|
watchers.push(themeWatcher);
|
|
234
235
|
}
|
|
235
236
|
if (lifecycleWatcher) {
|
|
236
|
-
await globalHookWatcher(lifecycleWatcher
|
|
237
|
+
await globalHookWatcher(lifecycleWatcher);
|
|
237
238
|
watchers.push(lifecycleWatcher);
|
|
238
239
|
}
|
|
239
240
|
} else {
|
|
240
|
-
await openDevWorkspacePage(config.previewBaseUrl);
|
|
241
|
+
await openDevWorkspacePage(config.previewBaseUrl, previewWorkspace);
|
|
241
242
|
}
|
|
242
243
|
|
|
243
244
|
const cubeSecurityContextAndClientContextWatch =
|
|
@@ -251,9 +252,9 @@ export default async () => {
|
|
|
251
252
|
}
|
|
252
253
|
};
|
|
253
254
|
|
|
254
|
-
const configureWatcher = async (
|
|
255
|
+
export const configureWatcher = async (
|
|
255
256
|
watcher: RollupWatcher,
|
|
256
|
-
ctx: ResolvedEmbeddableConfig
|
|
257
|
+
ctx: ResolvedEmbeddableConfig,
|
|
257
258
|
) => {
|
|
258
259
|
watcher.on("change", (path) => {
|
|
259
260
|
changedFiles.push(path);
|
|
@@ -274,7 +275,7 @@ const configureWatcher = async (
|
|
|
274
275
|
});
|
|
275
276
|
};
|
|
276
277
|
|
|
277
|
-
const globalHookWatcher = async (watcher: RollupWatcher
|
|
278
|
+
export const globalHookWatcher = async (watcher: RollupWatcher) => {
|
|
278
279
|
watcher.on("change", (path) => {
|
|
279
280
|
changedFiles.push(path);
|
|
280
281
|
});
|
|
@@ -314,9 +315,14 @@ const onBuildStart = async (ctx: ResolvedEmbeddableConfig) => {
|
|
|
314
315
|
sendMessage("componentsBuildStart", { changedFiles });
|
|
315
316
|
};
|
|
316
317
|
|
|
317
|
-
const openDevWorkspacePage = async (
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
export const openDevWorkspacePage = async (
|
|
319
|
+
previewBaseUrl: string,
|
|
320
|
+
workspaceId: string,
|
|
321
|
+
) => {
|
|
322
|
+
ora(
|
|
323
|
+
`Preview workspace is available at ${previewBaseUrl}/workspace/${workspaceId}`,
|
|
324
|
+
).info();
|
|
325
|
+
return await open(`${previewBaseUrl}/workspace/${workspaceId}`);
|
|
320
326
|
};
|
|
321
327
|
|
|
322
328
|
const onBundleBuildEnd = async (ctx: ResolvedEmbeddableConfig) => {
|
|
@@ -324,16 +330,19 @@ const onBundleBuildEnd = async (ctx: ResolvedEmbeddableConfig) => {
|
|
|
324
330
|
await buildWebComponent(ctx);
|
|
325
331
|
}
|
|
326
332
|
if (browserWindow == null) {
|
|
327
|
-
browserWindow = await openDevWorkspacePage(
|
|
333
|
+
browserWindow = await openDevWorkspacePage(
|
|
334
|
+
ctx.previewBaseUrl,
|
|
335
|
+
previewWorkspace,
|
|
336
|
+
);
|
|
328
337
|
} else {
|
|
329
338
|
sendMessage("componentsBuildSuccess");
|
|
330
339
|
}
|
|
331
340
|
};
|
|
332
341
|
|
|
333
342
|
const cubeSecurityContextAndClientContextWatcher = async (
|
|
334
|
-
ctx: ResolvedEmbeddableConfig
|
|
343
|
+
ctx: ResolvedEmbeddableConfig,
|
|
335
344
|
): Promise<FSWatcher> => {
|
|
336
|
-
let filesToWatch:
|
|
345
|
+
let filesToWatch: string[] = [];
|
|
337
346
|
|
|
338
347
|
if (ctx.pushComponents) {
|
|
339
348
|
const clientContextFiles = await fg("**/*.cc.{yaml,yml}", {
|
|
@@ -374,7 +383,7 @@ const globalCssWatcher = (ctx: ResolvedEmbeddableConfig): FSWatcher => {
|
|
|
374
383
|
return fsWatcher;
|
|
375
384
|
};
|
|
376
385
|
|
|
377
|
-
const sendBuildChanges = async (ctx: ResolvedEmbeddableConfig) => {
|
|
386
|
+
export const sendBuildChanges = async (ctx: ResolvedEmbeddableConfig) => {
|
|
378
387
|
const isValid = await validate(ctx);
|
|
379
388
|
|
|
380
389
|
if (!isValid) {
|
|
@@ -382,19 +391,19 @@ const sendBuildChanges = async (ctx: ResolvedEmbeddableConfig) => {
|
|
|
382
391
|
}
|
|
383
392
|
|
|
384
393
|
const sending = ora(
|
|
385
|
-
"Synchronising data models and/or security contexts..."
|
|
394
|
+
"Synchronising data models and/or security contexts...",
|
|
386
395
|
).start();
|
|
387
396
|
|
|
388
397
|
let filesList: [string, string][] = [];
|
|
389
398
|
if (ctx.pushComponents) {
|
|
390
399
|
const clientContextFilesList = await findFiles(
|
|
391
400
|
ctx.client.presetsSrc,
|
|
392
|
-
CLIENT_CONTEXT_FILES
|
|
401
|
+
CLIENT_CONTEXT_FILES,
|
|
393
402
|
);
|
|
394
403
|
|
|
395
404
|
// Map the files to include their full filenames
|
|
396
405
|
const clientContextFileList = [...clientContextFilesList].map(
|
|
397
|
-
(entry): [string, string] => [path.basename(entry[1]), entry[1]]
|
|
406
|
+
(entry): [string, string] => [path.basename(entry[1]), entry[1]],
|
|
398
407
|
);
|
|
399
408
|
|
|
400
409
|
filesList = [...clientContextFileList];
|
|
@@ -404,7 +413,7 @@ const sendBuildChanges = async (ctx: ResolvedEmbeddableConfig) => {
|
|
|
404
413
|
const cubeFilesList = await findFiles(ctx.client.modelsSrc, CUBE_FILES);
|
|
405
414
|
const securityContextFilesList = await findFiles(
|
|
406
415
|
ctx.client.presetsSrc,
|
|
407
|
-
SECURITY_CONTEXT_FILES
|
|
416
|
+
SECURITY_CONTEXT_FILES,
|
|
408
417
|
);
|
|
409
418
|
|
|
410
419
|
// Map the files to include their full filenames
|
|
@@ -439,7 +448,7 @@ const onClose = async (
|
|
|
439
448
|
server: Server,
|
|
440
449
|
sys: CompilerSystem,
|
|
441
450
|
watchers: Array<RollupWatcher | FSWatcher>,
|
|
442
|
-
config: ResolvedEmbeddableConfig
|
|
451
|
+
config: ResolvedEmbeddableConfig,
|
|
443
452
|
) => {
|
|
444
453
|
server.close();
|
|
445
454
|
wss.close();
|
|
@@ -460,7 +469,7 @@ const onClose = async (
|
|
|
460
469
|
|
|
461
470
|
const getPreviewWorkspace = async (
|
|
462
471
|
startedOra: Ora,
|
|
463
|
-
ctx: ResolvedEmbeddableConfig
|
|
472
|
+
ctx: ResolvedEmbeddableConfig,
|
|
464
473
|
): Promise<string> => {
|
|
465
474
|
const token = await getToken();
|
|
466
475
|
|
|
@@ -489,7 +498,7 @@ const getPreviewWorkspace = async (
|
|
|
489
498
|
headers: {
|
|
490
499
|
Authorization: `Bearer ${token}`,
|
|
491
500
|
},
|
|
492
|
-
}
|
|
501
|
+
},
|
|
493
502
|
);
|
|
494
503
|
return response.data;
|
|
495
504
|
} catch (e: any) {
|
package/src/push.test.ts
CHANGED
|
@@ -325,15 +325,14 @@ describe("push", () => {
|
|
|
325
325
|
],
|
|
326
326
|
},
|
|
327
327
|
});
|
|
328
|
-
vi.mocked(getArgumentByKey)
|
|
329
|
-
.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
});
|
|
328
|
+
vi.mocked(getArgumentByKey).mockImplementation((keysArg) => {
|
|
329
|
+
const key = Array.isArray(keysArg) ? keysArg[0] : keysArg;
|
|
330
|
+
if (key === "--api-key") return "some-key";
|
|
331
|
+
if (key === "--email") return "valid@email.com";
|
|
332
|
+
if (key === "--message") return "test message";
|
|
333
|
+
if (key === "--cube-version") return "v1.34";
|
|
334
|
+
return undefined;
|
|
335
|
+
});
|
|
337
336
|
|
|
338
337
|
await push();
|
|
339
338
|
|
package/src/push.ts
CHANGED
|
@@ -112,7 +112,11 @@ const publishedSectionFeedback = (
|
|
|
112
112
|
config.pushComponents && spinnerPushing.succeed("Components published");
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
-
async function pushByApiKey(
|
|
115
|
+
async function pushByApiKey(
|
|
116
|
+
config: ResolvedEmbeddableConfig,
|
|
117
|
+
spinner: any,
|
|
118
|
+
cubeVersion?: string,
|
|
119
|
+
) {
|
|
116
120
|
const apiKey = getArgumentByKey(["--api-key", "-k"]);
|
|
117
121
|
|
|
118
122
|
if (!apiKey) {
|
|
@@ -307,7 +311,12 @@ export async function sendBuild(
|
|
|
307
311
|
token,
|
|
308
312
|
message,
|
|
309
313
|
cubeVersion,
|
|
310
|
-
}: {
|
|
314
|
+
}: {
|
|
315
|
+
workspaceId: string;
|
|
316
|
+
token: string;
|
|
317
|
+
message?: string;
|
|
318
|
+
cubeVersion?: string;
|
|
319
|
+
},
|
|
311
320
|
) {
|
|
312
321
|
const form = await createFormData(ctx.client.archiveFile, {
|
|
313
322
|
pushModels: ctx.pushModels,
|