@embeddable.com/sdk-core 3.1.7 → 3.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
@@ -1,4 +1,5 @@
1
1
  import * as path from "node:path";
2
+ import { existsSync } from "node:fs";
2
3
 
3
4
  export type EmbeddableConfig = {
4
5
  plugins: (() => {
@@ -15,6 +16,8 @@ export type EmbeddableConfig = {
15
16
  applicationEnvironment?: string;
16
17
  rollbarAccessToken?: string;
17
18
  previewBaseUrl?: string;
19
+ componentsSrc?: string;
20
+ modelsSrc?: string;
18
21
  };
19
22
 
20
23
  export default ({
@@ -27,10 +30,30 @@ export default ({
27
30
  applicationEnvironment,
28
31
  rollbarAccessToken,
29
32
  previewBaseUrl,
33
+ modelsSrc,
34
+ componentsSrc = "src",
30
35
  }: EmbeddableConfig) => {
31
36
  const coreRoot = path.resolve(__dirname, "..");
32
37
  const clientRoot = process.cwd();
33
38
 
39
+ if (!path.isAbsolute(componentsSrc)) {
40
+ componentsSrc = path.resolve(clientRoot, componentsSrc);
41
+
42
+ if (!existsSync(componentsSrc)) {
43
+ throw new Error(
44
+ `componentsSrc directory ${componentsSrc} does not exist`,
45
+ );
46
+ }
47
+ }
48
+
49
+ if (modelsSrc && !path.isAbsolute(modelsSrc)) {
50
+ modelsSrc = path.resolve(clientRoot, modelsSrc);
51
+
52
+ if (!existsSync(modelsSrc)) {
53
+ throw new Error(`modelsSrc directory ${modelsSrc} does not exist`);
54
+ }
55
+ }
56
+
34
57
  return {
35
58
  core: {
36
59
  rootDir: coreRoot,
@@ -39,8 +62,9 @@ export default ({
39
62
  },
40
63
  client: {
41
64
  rootDir: clientRoot,
65
+ srcDir: path.resolve(clientRoot, componentsSrc),
66
+ modelsSrc: modelsSrc ? path.resolve(clientRoot, modelsSrc) : undefined,
42
67
  buildDir: path.resolve(clientRoot, ".embeddable-build"),
43
- srcDir: path.resolve(clientRoot, "src"),
44
68
  tmpDir: path.resolve(clientRoot, ".embeddable-tmp"),
45
69
  componentDir: path.resolve(clientRoot, ".embeddable-build", "component"),
46
70
  stencilBuild: path.resolve(
package/src/push.ts CHANGED
@@ -41,7 +41,7 @@ export default async () => {
41
41
  token,
42
42
  );
43
43
 
44
- const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`
44
+ const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`;
45
45
 
46
46
  await buildArchive(config);
47
47
  spinnerPushing = ora(
@@ -154,7 +154,10 @@ async function verify(ctx: any) {
154
154
  async function buildArchive(config: any) {
155
155
  const spinnerArchive = ora("Building...").start();
156
156
 
157
- const filesList = await findFiles(config.client.srcDir, YAML_OR_JS_FILES);
157
+ const filesList = await findFiles(
158
+ config.client.modelsSrc || config.client.srcDir,
159
+ YAML_OR_JS_FILES,
160
+ );
158
161
 
159
162
  await archive(config, filesList);
160
163
  return spinnerArchive.succeed("Bundling completed");
package/src/validate.ts CHANGED
@@ -28,7 +28,7 @@ export default async (ctx: any, exitIfInvalid = true) => {
28
28
 
29
29
  const filesList = await findFiles(ctx.client.srcDir, CUBE_YAML_FILE_REGEX);
30
30
  const securityContextFilesList = await findFiles(
31
- ctx.client.srcDir,
31
+ ctx.client.modelsSrc || ctx.client.srcDir,
32
32
  SECURITY_CONTEXT_FILE_REGEX,
33
33
  );
34
34
 
@@ -81,13 +81,13 @@ export async function dataModelsValidation(filesList: [string, string][]) {
81
81
 
82
82
  const cubeModelSafeParse = cubeModelSchema.safeParse(cube);
83
83
  const viewModelSafeParse = viewModelSchema.safeParse(cube);
84
-
84
+
85
85
  if (cube.cubes && !cubeModelSafeParse.success) {
86
86
  errorFormatter(cubeModelSafeParse.error.issues).forEach((error) => {
87
87
  errors.push(`${filePath}: ${error}`);
88
88
  });
89
89
  }
90
-
90
+
91
91
  if (cube.views && !viewModelSafeParse.success) {
92
92
  errorFormatter(viewModelSafeParse.error.issues).forEach((error) => {
93
93
  errors.push(`${filePath}: ${error}`);
@@ -185,14 +185,15 @@ const cubeModelSchema = z
185
185
  );
186
186
 
187
187
  const viewModelSchema = z.object({
188
- views: z.object({
189
- name: z.string(),
190
- cubes: z
191
- .object({
192
- join_path: z.string(),
193
- })
194
- .array()
195
- })
188
+ views: z
189
+ .object({
190
+ name: z.string(),
191
+ cubes: z
192
+ .object({
193
+ join_path: z.string(),
194
+ })
195
+ .array(),
196
+ })
196
197
  .array()
197
198
  .min(1),
198
199
  });