@embeddable.com/sdk-core 3.13.0 → 3.13.2-next.0

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/push.d.ts CHANGED
@@ -1,14 +1,25 @@
1
+ import { ResolvedEmbeddableConfig } from "./defineConfig";
1
2
  export declare const CUBE_FILES: RegExp;
2
3
  export declare const PRESET_FILES: RegExp;
3
4
  declare const _default: () => Promise<void>;
4
5
  export default _default;
5
- export declare function archive(ctx: any, yamlFiles: [string, string][], isDev?: boolean): Promise<unknown>;
6
- export declare function sendBuildByApiKey(ctx: any, { apiKey, email, message }: any): Promise<{
6
+ export declare function buildArchive(config: ResolvedEmbeddableConfig): Promise<import("ora").Ora>;
7
+ export declare function archive(args: {
8
+ ctx: ResolvedEmbeddableConfig;
9
+ filesList: [string, string][];
10
+ isDev: boolean;
11
+ includeComponents: boolean;
12
+ }): Promise<unknown>;
13
+ export declare function sendBuildByApiKey(ctx: ResolvedEmbeddableConfig, { apiKey, email, message, }: {
14
+ apiKey: string;
15
+ email: string;
16
+ message?: string;
17
+ }): Promise<{
7
18
  bundleId: any;
8
- email: any;
9
- message: any;
19
+ email: string;
20
+ message: string | undefined;
10
21
  }>;
11
- export declare function sendBuild(ctx: any, { workspaceId, token }: {
22
+ export declare function sendBuild(ctx: ResolvedEmbeddableConfig, { workspaceId, token }: {
12
23
  workspaceId: string;
13
24
  token: string;
14
25
  }): Promise<void>;
package/lib/utils.d.ts CHANGED
@@ -20,5 +20,5 @@ export declare const removeBuildSuccessFlag: () => Promise<void>;
20
20
  * Check if the build was successful
21
21
  */
22
22
  export declare const checkBuildSuccess: () => Promise<boolean>;
23
- export declare const getSDKVersions: () => Record<string, string>;
23
+ export declare const getSDKVersions: () => Promise<Record<string, string>>;
24
24
  export declare const hrtimeToISO8601: (hrtime: number[] | null | undefined) => String;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "3.13.0",
3
+ "version": "3.13.2-next.0",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "license": "MIT",
41
41
  "dependencies": {
42
- "@embeddable.com/sdk-utils": "0.7.0",
42
+ "@embeddable.com/sdk-utils": "0.7.1",
43
43
  "@inquirer/prompts": "^7.2.1",
44
44
  "@stencil/core": "^4.23.0",
45
45
  "@swc-node/register": "^1.10.9",
package/src/cleanup.ts CHANGED
@@ -26,7 +26,7 @@ export async function createManifest({
26
26
  editorsMetaFileName,
27
27
  stencilWrapperFileName,
28
28
  }: ManifestArgs) {
29
- const sdkVersions = getSDKVersions();
29
+ const sdkVersions = await getSDKVersions();
30
30
  // identify user's package manager and its version
31
31
  let packageManager = "npm";
32
32
  if (process.env.npm_config_user_agent?.includes("yarn")) {
@@ -35,7 +35,7 @@ describe("defineConfig", () => {
35
35
  vi.mocked(path.resolve).mockReturnValue(coreRoot);
36
36
 
37
37
  vi.spyOn(process, "cwd").mockReturnValue(
38
- "/embeddable-sdk/packages/core-sdk"
38
+ "/embeddable-sdk/packages/core-sdk",
39
39
  );
40
40
  });
41
41
 
@@ -84,17 +84,17 @@ describe("defineConfig", () => {
84
84
 
85
85
  it("throws error for invalid property", () => {
86
86
  expect(() =>
87
- defineConfig({ plugins: [], invalidProp: "INVALID" as any } as any)
87
+ defineConfig({ plugins: [], invalidProp: "INVALID" as any } as any),
88
88
  ).toThrow(
89
- `Invalid Embeddable Configuration: "": Unrecognized key(s) in object: 'invalidProp'}`
89
+ `Invalid Embeddable Configuration: "": Unrecognized key(s) in object: 'invalidProp'}`,
90
90
  );
91
91
  });
92
92
 
93
93
  it("throws error for invalid property value", () => {
94
94
  expect(() =>
95
- defineConfig({ plugins: [], pushBaseUrl: 123 as any } as any)
95
+ defineConfig({ plugins: [], pushBaseUrl: 123 as any } as any),
96
96
  ).toThrow(
97
- `Invalid Embeddable Configuration: "pushBaseUrl": Expected string, received number}`
97
+ `Invalid Embeddable Configuration: "pushBaseUrl": Expected string, received number}`,
98
98
  );
99
99
  });
100
100
 
@@ -147,9 +147,9 @@ describe("defineConfig", () => {
147
147
 
148
148
  it("throws error for invalid region", () => {
149
149
  expect(() =>
150
- defineConfig({ plugins: [], region: "INVALID" as any })
150
+ defineConfig({ plugins: [], region: "INVALID" as any }),
151
151
  ).toThrow(
152
- `Invalid Embeddable Configuration: "region": Invalid literal value, expected "legacy-US"}`
152
+ `Invalid Embeddable Configuration: "region": Invalid literal value, expected "legacy-US"}`,
153
153
  );
154
154
  });
155
155
  });
package/src/utils.ts CHANGED
@@ -98,22 +98,24 @@ export const checkBuildSuccess = async () => {
98
98
  }
99
99
  };
100
100
 
101
- const getPackageVersion = (packageName: string) => {
101
+ const getPackageVersion = async (packageName: string) => {
102
102
  const packageJsonPath = path.join(
103
103
  process.cwd(),
104
104
  "node_modules",
105
105
  packageName,
106
106
  "package.json",
107
107
  );
108
+
109
+ let packageJson;
108
110
  try {
109
- const packageJson = require(packageJsonPath);
111
+ packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
110
112
  return packageJson.version;
111
113
  } catch (e) {
112
114
  return undefined;
113
115
  }
114
116
  };
115
117
 
116
- export const getSDKVersions = () => {
118
+ export const getSDKVersions = async () => {
117
119
  const packageNames = [
118
120
  "@embeddable.com/core",
119
121
  "@embeddable.com/react",
@@ -122,15 +124,18 @@ export const getSDKVersions = () => {
122
124
  "@embeddable.com/sdk-utils",
123
125
  ];
124
126
 
125
- const sdkVersions = packageNames.reduce<Record<string, string>>(
126
- (acc, packageName) => {
127
- const version = getPackageVersion(packageName);
127
+ const sdkVersions = await packageNames.reduce<
128
+ Promise<Record<string, string>>
129
+ >(
130
+ async (accPromise, packageName) => {
131
+ const acc = await accPromise; // Wait for the previous accumulator to resolve
132
+ const version = await getPackageVersion(packageName);
128
133
  if (version) {
129
134
  acc[packageName] = version;
130
135
  }
131
136
  return acc;
132
137
  },
133
- {},
138
+ Promise.resolve({}), // Start with a resolved promise containing an empty object
134
139
  );
135
140
 
136
141
  return sdkVersions;