@embeddable.com/sdk-core 3.3.0 → 3.3.1

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/utils.d.ts CHANGED
@@ -19,3 +19,4 @@ export declare const removeBuildSuccessFlag: () => Promise<void>;
19
19
  * Check if the build was successful
20
20
  */
21
21
  export declare const checkBuildSuccess: () => Promise<boolean>;
22
+ export declare const getPackageVersion: (packageName: string) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
package/src/cleanup.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { findFiles } from "@embeddable.com/sdk-utils";
2
2
  import * as fs from "node:fs/promises";
3
3
  import * as path from "node:path";
4
+ import { getPackageVersion } from "./utils";
4
5
 
5
6
  export default async (ctx: any) => {
6
7
  await extractBuild(ctx);
@@ -10,6 +11,75 @@ export default async (ctx: any) => {
10
11
  await moveBuildTOBuildDir(ctx);
11
12
  };
12
13
 
14
+ type ManifestArgs = {
15
+ ctx: any;
16
+ typesFileName: string;
17
+ metaFileName: string;
18
+ editorsMetaFileName: string;
19
+ stencilWrapperFileName: string;
20
+ };
21
+
22
+ async function createManifest({
23
+ ctx,
24
+ typesFileName,
25
+ metaFileName,
26
+ editorsMetaFileName,
27
+ stencilWrapperFileName,
28
+ }: ManifestArgs) {
29
+ const packageNames = [
30
+ "@embeddable.com/core",
31
+ "@embeddable.com/react",
32
+ "@embeddable.com/sdk-core",
33
+ "@embeddable.com/sdk-react",
34
+ "@embeddable.com/sdk-utils",
35
+ ];
36
+
37
+ const sdkVersions = packageNames.reduce<Record<string, string>>(
38
+ (acc, packageName) => {
39
+ const version = getPackageVersion(packageName);
40
+ if (version) {
41
+ acc[packageName] = version;
42
+ }
43
+ return acc;
44
+ },
45
+ {},
46
+ );
47
+ // identify user's package manager and its version
48
+ let packageManager = "npm";
49
+ if (process.env.npm_config_user_agent?.includes("yarn")) {
50
+ packageManager = "yarn";
51
+ }
52
+ if (process.env.npm_config_user_agent?.includes("pnpm")) {
53
+ packageManager = "pnpm";
54
+ }
55
+
56
+ const packageManagerVersion =
57
+ process.env.npm_config_user_agent?.match(/(\d+\.\d+\.\d+)/)?.[0] ||
58
+ "unknown";
59
+
60
+ // write manifest file with files with hash
61
+ const manifest = {
62
+ entryFiles: {
63
+ "embeddable-types.js": typesFileName,
64
+ "embeddable-components-meta.js": metaFileName,
65
+ "embeddable-editors-meta.js": editorsMetaFileName,
66
+ "embeddable-wrapper.esm.js": stencilWrapperFileName,
67
+ },
68
+ metadata: {
69
+ nodeVersion: process.version,
70
+ platform: process.platform,
71
+ sdkVersions,
72
+ packageManager,
73
+ packageManagerVersion,
74
+ },
75
+ };
76
+
77
+ await fs.writeFile(
78
+ path.join(ctx.client.tmpDir, "embeddable-manifest.json"),
79
+ JSON.stringify(manifest),
80
+ );
81
+ }
82
+
13
83
  async function extractBuild(ctx: any) {
14
84
  const [[, stencilWrapperFilePath]] = await findFiles(
15
85
  ctx.client.stencilBuild,
@@ -47,20 +117,13 @@ async function extractBuild(ctx: any) {
47
117
  path.join(ctx.client.tmpDir, editorsMetaFileName),
48
118
  );
49
119
 
50
- // write manifest file with files with hash
51
- const manifest = {
52
- entryFiles: {
53
- "embeddable-types.js": typesFileName,
54
- "embeddable-components-meta.js": metaFileName,
55
- "embeddable-editors-meta.js": editorsMetaFileName,
56
- "embeddable-wrapper.esm.js": stencilWrapperFileName,
57
- },
58
- };
59
-
60
- await fs.writeFile(
61
- path.join(ctx.client.tmpDir, "embeddable-manifest.json"),
62
- JSON.stringify(manifest),
63
- );
120
+ await createManifest({
121
+ ctx,
122
+ typesFileName,
123
+ metaFileName,
124
+ editorsMetaFileName,
125
+ stencilWrapperFileName,
126
+ });
64
127
  }
65
128
 
66
129
  async function removeObsoleteDir(dir: string) {
package/src/utils.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  const oraP = import("ora");
2
2
  import * as fs from "node:fs/promises";
3
3
  import { CREDENTIALS_DIR } from "./credentials";
4
+ import path from "node:path";
4
5
 
5
6
  let ora: any;
6
7
  export const checkNodeVersion = async () => {
@@ -82,3 +83,18 @@ export const checkBuildSuccess = async () => {
82
83
  return false;
83
84
  }
84
85
  };
86
+
87
+ export const getPackageVersion = (packageName: string) => {
88
+ const packageJsonPath = path.join(
89
+ process.cwd(),
90
+ "node_modules",
91
+ packageName,
92
+ "package.json",
93
+ );
94
+ try {
95
+ const packageJson = require(packageJsonPath);
96
+ return packageJson.version;
97
+ } catch (e) {
98
+ return undefined;
99
+ }
100
+ };