@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/index.esm.js +147 -96
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +145 -94
- package/lib/index.js.map +1 -1
- package/lib/utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/cleanup.ts +77 -14
- package/src/utils.ts +16 -0
package/lib/utils.d.ts
CHANGED
package/package.json
CHANGED
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
};
|