@embeddable.com/sdk-core 3.2.1 → 3.2.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 +42 -0
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +42 -0
- package/lib/index.js.map +1 -1
- package/lib/utils.d.ts +13 -0
- package/package.json +1 -1
- package/src/build.ts +8 -1
- package/src/push.ts +9 -1
- package/src/utils.ts +38 -0
package/lib/utils.d.ts
CHANGED
|
@@ -6,3 +6,16 @@ export declare const checkNodeVersion: () => Promise<void>;
|
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
8
|
export declare const getArgumentByKey: (key: string | string[]) => string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Store a flag in the credentials directory to indicate a successful build
|
|
11
|
+
* This is used to determine if the build was successful or not
|
|
12
|
+
*/
|
|
13
|
+
export declare const storeBuildSuccessFlag: () => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Remove the success flag from the credentials directory
|
|
16
|
+
*/
|
|
17
|
+
export declare const removeBuildSuccessFlag: () => Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if the build was successful
|
|
20
|
+
*/
|
|
21
|
+
export declare const checkBuildSuccess: () => Promise<boolean>;
|
package/package.json
CHANGED
package/src/build.ts
CHANGED
|
@@ -6,11 +6,17 @@ import validate from "./validate";
|
|
|
6
6
|
import provideConfig from "./provideConfig";
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import reportErrorToRollbar from "./rollbar.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
checkNodeVersion,
|
|
11
|
+
removeBuildSuccessFlag,
|
|
12
|
+
storeBuildSuccessFlag,
|
|
13
|
+
} from "./utils";
|
|
10
14
|
|
|
11
15
|
export default async () => {
|
|
12
16
|
try {
|
|
13
17
|
checkNodeVersion();
|
|
18
|
+
removeBuildSuccessFlag();
|
|
19
|
+
|
|
14
20
|
const config = await provideConfig();
|
|
15
21
|
|
|
16
22
|
await validate(config);
|
|
@@ -30,6 +36,7 @@ export default async () => {
|
|
|
30
36
|
// NOTE: likely this will be called inside the loop above if we decide to support clients with mixed frameworks simultaneously.
|
|
31
37
|
await generate(config, "sdk-react");
|
|
32
38
|
await cleanup(config);
|
|
39
|
+
await storeBuildSuccessFlag();
|
|
33
40
|
} catch (error: any) {
|
|
34
41
|
await reportErrorToRollbar(error);
|
|
35
42
|
console.log(error);
|
package/src/push.ts
CHANGED
|
@@ -10,7 +10,7 @@ import reportErrorToRollbar from "./rollbar.mjs";
|
|
|
10
10
|
|
|
11
11
|
import { findFiles } from "@embeddable.com/sdk-utils";
|
|
12
12
|
import { getToken } from "./login";
|
|
13
|
-
import { checkNodeVersion, getArgumentByKey } from "./utils";
|
|
13
|
+
import { checkBuildSuccess, checkNodeVersion, getArgumentByKey } from "./utils";
|
|
14
14
|
|
|
15
15
|
// grab .cube.yml|js and .sc.yml|js files
|
|
16
16
|
export const YAML_OR_JS_FILES = /^(.*)\.(cube|sc)\.(ya?ml|js)$/;
|
|
@@ -21,6 +21,14 @@ export default async () => {
|
|
|
21
21
|
|
|
22
22
|
try {
|
|
23
23
|
checkNodeVersion();
|
|
24
|
+
const isBuildSuccess = await checkBuildSuccess();
|
|
25
|
+
if (!isBuildSuccess) {
|
|
26
|
+
console.error(
|
|
27
|
+
"Build failed or not completed. Please run `embeddable:build` first.",
|
|
28
|
+
);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
ora = (await oraP).default;
|
|
25
33
|
|
|
26
34
|
const config = await provideConfig();
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const oraP = import("ora");
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import { CREDENTIALS_DIR } from "./credentials";
|
|
2
4
|
|
|
3
5
|
let ora: any;
|
|
4
6
|
export const checkNodeVersion = async () => {
|
|
@@ -44,3 +46,39 @@ export const getArgumentByKey = (key: string | string[]) => {
|
|
|
44
46
|
const index = process.argv.indexOf(key);
|
|
45
47
|
return index !== -1 ? process.argv[index + 1] : undefined;
|
|
46
48
|
};
|
|
49
|
+
|
|
50
|
+
const SUCCESS_FLAG_FILE = `${CREDENTIALS_DIR}/success`;
|
|
51
|
+
/**
|
|
52
|
+
* Store a flag in the credentials directory to indicate a successful build
|
|
53
|
+
* This is used to determine if the build was successful or not
|
|
54
|
+
*/
|
|
55
|
+
export const storeBuildSuccessFlag = async () => {
|
|
56
|
+
try {
|
|
57
|
+
await fs.access(CREDENTIALS_DIR);
|
|
58
|
+
} catch (_e) {
|
|
59
|
+
await fs.mkdir(CREDENTIALS_DIR);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
await fs.writeFile(SUCCESS_FLAG_FILE, "true");
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Remove the success flag from the credentials directory
|
|
67
|
+
*/
|
|
68
|
+
export const removeBuildSuccessFlag = async () => {
|
|
69
|
+
try {
|
|
70
|
+
await fs.unlink(SUCCESS_FLAG_FILE);
|
|
71
|
+
} catch (_e) {}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Check if the build was successful
|
|
76
|
+
*/
|
|
77
|
+
export const checkBuildSuccess = async () => {
|
|
78
|
+
try {
|
|
79
|
+
await fs.access(SUCCESS_FLAG_FILE);
|
|
80
|
+
return true;
|
|
81
|
+
} catch (_e) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
};
|