@embeddable.com/sdk-core 3.13.1 → 3.13.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 +9 -7
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +198 -63
- package/lib/index.js.map +1 -1
- package/lib/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/cleanup.ts +1 -1
- package/src/defineConfig.test.ts +7 -7
- package/src/utils.ts +12 -7
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
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")) {
|
package/src/defineConfig.test.ts
CHANGED
|
@@ -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
|
-
|
|
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<
|
|
126
|
-
|
|
127
|
-
|
|
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;
|