@embeddable.com/sdk-core 3.12.0 → 3.12.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/bin/embeddable +8 -5
- package/lib/index.esm.js +25 -16
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +25 -16
- package/lib/index.js.map +1 -1
- package/lib/src/build.d.ts +2 -0
- package/lib/src/build.test.d.ts +1 -0
- package/lib/src/buildTypes.d.ts +4 -0
- package/lib/src/buildTypes.test.d.ts +1 -0
- package/lib/src/cleanup.d.ts +16 -0
- package/lib/src/cleanup.test.d.ts +1 -0
- package/lib/src/createContext.d.ts +23 -0
- package/lib/src/credentials.d.ts +2 -0
- package/lib/src/defineConfig.d.ts +65 -0
- package/lib/src/dev.d.ts +2 -0
- package/lib/src/generate.d.ts +2 -0
- package/lib/src/globalCleanup.d.ts +2 -0
- package/lib/src/index.d.ts +5 -0
- package/lib/src/login.d.ts +4 -0
- package/lib/src/prepare.d.ts +3 -0
- package/lib/src/provideConfig.d.ts +2 -0
- package/lib/src/provideConfig.test.d.ts +1 -0
- package/lib/src/push.d.ts +26 -0
- package/lib/src/utils.d.ts +25 -0
- package/lib/src/utils.test.d.ts +1 -0
- package/lib/src/validate.d.ts +8 -0
- package/lib/src/validate.test.d.ts +1 -0
- package/lib/validate.d.ts +1 -1
- package/loader/custom-esm-loader.mjs +53 -10
- package/loader/entryPoint.js +37 -13
- package/loader/entryPoint.test.js +6 -5
- package/package.json +2 -2
- package/src/dev.ts +2 -1
- package/src/logger.ts +2 -6
- package/src/login.ts +14 -2
- package/src/push.ts +1 -0
- package/src/validate.ts +4 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const _default: (ctx: any) => Promise<void>;
|
|
2
|
+
export default _default;
|
|
3
|
+
type ManifestArgs = {
|
|
4
|
+
ctx: any;
|
|
5
|
+
typesFileName: string;
|
|
6
|
+
metaFileName: string;
|
|
7
|
+
editorsMetaFileName: string;
|
|
8
|
+
stencilWrapperFileName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function createManifest({
|
|
11
|
+
ctx,
|
|
12
|
+
typesFileName,
|
|
13
|
+
metaFileName,
|
|
14
|
+
editorsMetaFileName,
|
|
15
|
+
stencilWrapperFileName,
|
|
16
|
+
}: ManifestArgs): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare const _default: (
|
|
2
|
+
coreRoot: string,
|
|
3
|
+
clientRoot: string,
|
|
4
|
+
) => {
|
|
5
|
+
core: {
|
|
6
|
+
rootDir: string;
|
|
7
|
+
templatesDir: string;
|
|
8
|
+
configsDir: string;
|
|
9
|
+
};
|
|
10
|
+
client: {
|
|
11
|
+
rootDir: string;
|
|
12
|
+
buildDir: string;
|
|
13
|
+
srcDir: string;
|
|
14
|
+
tmpDir: string;
|
|
15
|
+
componentDir: string;
|
|
16
|
+
stencilBuild: string;
|
|
17
|
+
archiveFile: string;
|
|
18
|
+
};
|
|
19
|
+
outputOptions: {
|
|
20
|
+
typesEntryPointFilename: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type EmbeddableConfig = {
|
|
2
|
+
plugins: (() => {
|
|
3
|
+
pluginName: string;
|
|
4
|
+
build: (config: EmbeddableConfig) => Promise<unknown>;
|
|
5
|
+
cleanup: (config: EmbeddableConfig) => Promise<unknown>;
|
|
6
|
+
validate: (config: EmbeddableConfig) => Promise<unknown>;
|
|
7
|
+
})[];
|
|
8
|
+
pushBaseUrl?: string;
|
|
9
|
+
audienceUrl?: string;
|
|
10
|
+
authDomain?: string;
|
|
11
|
+
authClientId?: string;
|
|
12
|
+
errorFallbackComponent?: string;
|
|
13
|
+
applicationEnvironment?: string;
|
|
14
|
+
rollbarAccessToken?: string;
|
|
15
|
+
previewBaseUrl?: string;
|
|
16
|
+
componentsSrc?: string;
|
|
17
|
+
modelsSrc?: string;
|
|
18
|
+
};
|
|
19
|
+
declare const _default: ({
|
|
20
|
+
plugins,
|
|
21
|
+
pushBaseUrl,
|
|
22
|
+
audienceUrl,
|
|
23
|
+
authDomain,
|
|
24
|
+
authClientId,
|
|
25
|
+
errorFallbackComponent,
|
|
26
|
+
applicationEnvironment,
|
|
27
|
+
rollbarAccessToken,
|
|
28
|
+
previewBaseUrl,
|
|
29
|
+
modelsSrc,
|
|
30
|
+
componentsSrc,
|
|
31
|
+
}: EmbeddableConfig) => {
|
|
32
|
+
core: {
|
|
33
|
+
rootDir: string;
|
|
34
|
+
templatesDir: string;
|
|
35
|
+
configsDir: string;
|
|
36
|
+
};
|
|
37
|
+
client: {
|
|
38
|
+
rootDir: string;
|
|
39
|
+
srcDir: string;
|
|
40
|
+
modelsSrc: string | undefined;
|
|
41
|
+
buildDir: string;
|
|
42
|
+
tmpDir: string;
|
|
43
|
+
componentDir: string;
|
|
44
|
+
stencilBuild: string;
|
|
45
|
+
archiveFile: string;
|
|
46
|
+
errorFallbackComponent: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
outputOptions: {
|
|
49
|
+
typesEntryPointFilename: string;
|
|
50
|
+
};
|
|
51
|
+
pushBaseUrl: string;
|
|
52
|
+
audienceUrl: string;
|
|
53
|
+
previewBaseUrl: string;
|
|
54
|
+
authDomain: string;
|
|
55
|
+
authClientId: string;
|
|
56
|
+
applicationEnvironment: string;
|
|
57
|
+
rollbarAccessToken: string;
|
|
58
|
+
plugins: (() => {
|
|
59
|
+
pluginName: string;
|
|
60
|
+
build: (config: EmbeddableConfig) => Promise<unknown>;
|
|
61
|
+
cleanup: (config: EmbeddableConfig) => Promise<unknown>;
|
|
62
|
+
validate: (config: EmbeddableConfig) => Promise<unknown>;
|
|
63
|
+
})[];
|
|
64
|
+
};
|
|
65
|
+
export default _default;
|
package/lib/src/dev.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const YAML_OR_JS_FILES: RegExp;
|
|
2
|
+
declare const _default: () => Promise<void>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare function archive(
|
|
5
|
+
ctx: any,
|
|
6
|
+
yamlFiles: [string, string][],
|
|
7
|
+
includeBuild?: boolean,
|
|
8
|
+
): Promise<unknown>;
|
|
9
|
+
export declare function sendBuildByApiKey(
|
|
10
|
+
ctx: any,
|
|
11
|
+
{ apiKey, email, message }: any,
|
|
12
|
+
): Promise<{
|
|
13
|
+
bundleId: any;
|
|
14
|
+
email: any;
|
|
15
|
+
message: any;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function sendBuild(
|
|
18
|
+
ctx: any,
|
|
19
|
+
{
|
|
20
|
+
workspaceId,
|
|
21
|
+
token,
|
|
22
|
+
}: {
|
|
23
|
+
workspaceId: string;
|
|
24
|
+
token: string;
|
|
25
|
+
},
|
|
26
|
+
): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const checkNodeVersion: () => Promise<boolean>;
|
|
2
|
+
/**
|
|
3
|
+
* Get the value of a process argument by key
|
|
4
|
+
* Example: getArgumentByKey("--email") or getArgumentByKey(["--email", "-e"])
|
|
5
|
+
* @param key The key to search for in the process arguments
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const getArgumentByKey: (
|
|
9
|
+
key: string | string[],
|
|
10
|
+
) => string | undefined;
|
|
11
|
+
export declare const SUCCESS_FLAG_FILE: string;
|
|
12
|
+
/**
|
|
13
|
+
* Store a flag in the credentials directory to indicate a successful build
|
|
14
|
+
* This is used to determine if the build was successful or not
|
|
15
|
+
*/
|
|
16
|
+
export declare const storeBuildSuccessFlag: () => Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Remove the success flag from the credentials directory
|
|
19
|
+
*/
|
|
20
|
+
export declare const removeBuildSuccessFlag: () => Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if the build was successful
|
|
23
|
+
*/
|
|
24
|
+
export declare const checkBuildSuccess: () => Promise<boolean>;
|
|
25
|
+
export declare const getPackageVersion: (packageName: string) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: (ctx: any, exitIfInvalid?: boolean) => Promise<boolean>;
|
|
2
|
+
export default _default;
|
|
3
|
+
export declare function dataModelsValidation(
|
|
4
|
+
filesList: [string, string][],
|
|
5
|
+
): Promise<string[]>;
|
|
6
|
+
export declare function securityContextValidation(
|
|
7
|
+
filesList: [string, string][],
|
|
8
|
+
): Promise<string[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/validate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const _default: (ctx: any
|
|
1
|
+
declare const _default: (ctx: any) => Promise<boolean>;
|
|
2
2
|
export default _default;
|
|
3
3
|
export declare function dataModelsValidation(filesList: [string, string][]): Promise<string[]>;
|
|
4
4
|
export declare function securityContextValidation(filesList: [string, string][]): Promise<string[]>;
|
|
@@ -12,6 +12,7 @@ import ts from "typescript";
|
|
|
12
12
|
import { readDefaultTsConfig } from "@swc-node/register/read-default-tsconfig";
|
|
13
13
|
import { compile } from "./custom-esm-register.cjs";
|
|
14
14
|
import fs from "fs";
|
|
15
|
+
import path from "path";
|
|
15
16
|
|
|
16
17
|
// Find the tsconfig.json in the customer's project directory
|
|
17
18
|
const tsconfigPath = ts.findConfigFile(
|
|
@@ -59,6 +60,13 @@ const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
|
59
60
|
|
|
60
61
|
const isWindows = process.platform === "win32";
|
|
61
62
|
|
|
63
|
+
function cleanWindowsFileURL(url) {
|
|
64
|
+
// Remove any duplicate file:/ prefixes and normalize slashes
|
|
65
|
+
return url.replace(/file:\/+/g, 'file:///')
|
|
66
|
+
.replace(/\\/g, '/')
|
|
67
|
+
.replace(/file:\/+([A-Za-z]:)/, 'file:///$1');
|
|
68
|
+
}
|
|
69
|
+
|
|
62
70
|
export const resolve = async (specifier, context, nextResolve) => {
|
|
63
71
|
if (NON_JS_TS_EXTENSIONS.test(specifier)) {
|
|
64
72
|
const mockModulePath = pathToFileURL(
|
|
@@ -76,19 +84,54 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
76
84
|
|
|
77
85
|
// Entry point
|
|
78
86
|
if (!context.parentURL) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
if (isWindows) {
|
|
88
|
+
// Handle the case where the specifier contains both the cwd and the actual path
|
|
89
|
+
const parts = specifier.split('file:/');
|
|
90
|
+
const lastPart = parts[parts.length - 1];
|
|
91
|
+
|
|
92
|
+
// Convert the path to a proper file URL
|
|
93
|
+
const cleanPath = lastPart.replace(/^\/+/, '');
|
|
94
|
+
const entryPointPath = pathToFileURL(cleanPath).href;
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
format: isTS ? "ts" : undefined,
|
|
98
|
+
url: cleanWindowsFileURL(entryPointPath),
|
|
99
|
+
shortCircuit: true,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
84
102
|
|
|
85
|
-
|
|
103
|
+
return {
|
|
86
104
|
format: isTS ? "ts" : undefined,
|
|
87
|
-
url:
|
|
105
|
+
url: specifier,
|
|
88
106
|
shortCircuit: true,
|
|
89
107
|
};
|
|
108
|
+
}
|
|
90
109
|
|
|
91
|
-
|
|
110
|
+
// Handle SDK relative imports
|
|
111
|
+
if (isWindows && specifier.startsWith('.') && context.parentURL?.includes('embeddable-sdk')) {
|
|
112
|
+
const parentPath = fileURLToPath(context.parentURL);
|
|
113
|
+
const parentDir = dirname(parentPath);
|
|
114
|
+
let resolvedPath = join(parentDir, specifier);
|
|
115
|
+
|
|
116
|
+
// If no extension is provided, try common extensions
|
|
117
|
+
if (!path.extname(resolvedPath)) {
|
|
118
|
+
const extensions = ['.js', '.mjs', '.cjs', '.ts', '.mts'];
|
|
119
|
+
for (const ext of extensions) {
|
|
120
|
+
const pathWithExt = resolvedPath + ext;
|
|
121
|
+
if (fs.existsSync(pathWithExt) && fs.statSync(pathWithExt).isFile()) {
|
|
122
|
+
resolvedPath = pathWithExt;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Check if the resolved path exists and is a file
|
|
129
|
+
if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {
|
|
130
|
+
return {
|
|
131
|
+
url: pathToFileURL(resolvedPath).href,
|
|
132
|
+
shortCircuit: true
|
|
133
|
+
};
|
|
134
|
+
}
|
|
92
135
|
}
|
|
93
136
|
|
|
94
137
|
// Determine if this is a package import
|
|
@@ -99,14 +142,14 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
99
142
|
|
|
100
143
|
// External library import
|
|
101
144
|
if (
|
|
102
|
-
(context.parentURL
|
|
145
|
+
(context.parentURL?.includes("/node_modules/") || isPackageImport) &&
|
|
103
146
|
!isTS
|
|
104
147
|
) {
|
|
105
148
|
return nextResolve(specifier);
|
|
106
149
|
}
|
|
107
150
|
|
|
108
151
|
const isFileUrl = specifier.startsWith("file://");
|
|
109
|
-
const isParentFileUrl = context.parentURL
|
|
152
|
+
const isParentFileUrl = context.parentURL?.startsWith("file://");
|
|
110
153
|
|
|
111
154
|
// Resolve the module using TypeScript's module resolution
|
|
112
155
|
const { resolvedModule } = ts.resolveModuleName(
|
package/loader/entryPoint.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { build, defineConfig, dev, login, push } from "../lib/index.js";
|
|
2
2
|
import { spawn } from "child_process";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
|
|
6
|
+
const COMMANDS_MAP = {
|
|
7
|
+
build,
|
|
8
|
+
login,
|
|
9
|
+
push,
|
|
10
|
+
dev,
|
|
11
|
+
defineConfig,
|
|
12
|
+
};
|
|
13
|
+
|
|
6
14
|
export async function main() {
|
|
7
15
|
const command = process.argv[2];
|
|
8
16
|
const runScript = COMMANDS_MAP[command];
|
|
@@ -40,11 +48,13 @@ async function runTypeScriptCheck(skipTypeCheck = false) {
|
|
|
40
48
|
return;
|
|
41
49
|
}
|
|
42
50
|
|
|
51
|
+
const isWindows = process.platform === "win32";
|
|
52
|
+
const tscBinary = isWindows ? "tsc.cmd" : "tsc";
|
|
43
53
|
const tscPath = path.join(
|
|
44
54
|
customerProjectDir,
|
|
45
55
|
"node_modules",
|
|
46
56
|
".bin",
|
|
47
|
-
|
|
57
|
+
tscBinary,
|
|
48
58
|
);
|
|
49
59
|
|
|
50
60
|
if (!fs.existsSync(tscPath) && !skipTypeCheck) {
|
|
@@ -55,20 +65,34 @@ async function runTypeScriptCheck(skipTypeCheck = false) {
|
|
|
55
65
|
process.exit(1);
|
|
56
66
|
}
|
|
57
67
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
try {
|
|
69
|
+
const tsc = spawn(tscPath, ["--noEmit", "--pretty"], {
|
|
70
|
+
cwd: customerProjectDir,
|
|
71
|
+
stdio: "inherit",
|
|
72
|
+
env: { ...process.env, FORCE_COLOR: "true" },
|
|
73
|
+
shell: isWindows, // Use shell on Windows
|
|
74
|
+
windowsVerbatimArguments: isWindows, // Preserve argument quoting on Windows
|
|
75
|
+
});
|
|
63
76
|
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
tsc.on("error", (err) => {
|
|
78
|
+
outputWarning(`Failed to start TypeScript compiler: ${err.message}`);
|
|
66
79
|
outputWarning(skipTypeCheckWarning);
|
|
67
80
|
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
tsc.on("exit", (code) => {
|
|
84
|
+
if (code !== 0) {
|
|
85
|
+
outputWarning(skipTypeCheckWarning);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
} else {
|
|
88
|
+
resolve();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
} catch (err) {
|
|
92
|
+
outputWarning(`Failed to start TypeScript compiler: ${err.message}`);
|
|
93
|
+
outputWarning(skipTypeCheckWarning);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
72
96
|
});
|
|
73
97
|
}
|
|
74
98
|
|
|
@@ -8,10 +8,11 @@ vi.mock("child_process");
|
|
|
8
8
|
vi.mock("fs");
|
|
9
9
|
vi.mock("path");
|
|
10
10
|
vi.mock("../lib/index.js", () => ({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
build: vi.fn().mockResolvedValue(undefined),
|
|
12
|
+
login: vi.fn().mockResolvedValue(undefined),
|
|
13
|
+
push: vi.fn().mockResolvedValue(undefined),
|
|
14
|
+
dev: vi.fn().mockResolvedValue(undefined),
|
|
15
|
+
defineConfig: vi.fn().mockResolvedValue(undefined),
|
|
15
16
|
}));
|
|
16
17
|
|
|
17
18
|
describe("entryPoint", () => {
|
|
@@ -44,7 +45,7 @@ describe("entryPoint", () => {
|
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
// Set up process.argv for the test
|
|
47
|
-
process.argv = ["node", "script.js", "
|
|
48
|
+
process.argv = ["node", "script.js", "defineConfig"];
|
|
48
49
|
|
|
49
50
|
// Dynamically import main after mocking process.exit
|
|
50
51
|
const entryPoint = await import("./entryPoint.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embeddable.com/sdk-core",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.1",
|
|
4
4
|
"description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"embeddable",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@embeddable.com/sdk-utils": "0.6.
|
|
41
|
+
"@embeddable.com/sdk-utils": "0.6.1",
|
|
42
42
|
"@inquirer/prompts": "^7.1.0",
|
|
43
43
|
"@stencil/core": "^4.22.3",
|
|
44
44
|
"@swc-node/register": "^1.10.9",
|
package/src/dev.ts
CHANGED
|
@@ -215,6 +215,7 @@ export default async () => {
|
|
|
215
215
|
});
|
|
216
216
|
} catch (error: any) {
|
|
217
217
|
await logError({ command: "dev", breadcrumbs, error });
|
|
218
|
+
console.log(error);
|
|
218
219
|
process.exit(1);
|
|
219
220
|
}
|
|
220
221
|
};
|
|
@@ -309,7 +310,7 @@ const globalCssWatcher = (ctx: any): FSWatcher => {
|
|
|
309
310
|
|
|
310
311
|
const sendDataModelsAndContextsChanges = async (ctx: any) => {
|
|
311
312
|
sendMessage("dataModelsAndOrSecurityContextUpdateStart");
|
|
312
|
-
const isValid = await validate(ctx
|
|
313
|
+
const isValid = await validate(ctx);
|
|
313
314
|
if (isValid) {
|
|
314
315
|
const token = await getToken();
|
|
315
316
|
const sending = ora(
|
package/src/logger.ts
CHANGED
|
@@ -96,9 +96,7 @@ async function rotateLogIfNeeded() {
|
|
|
96
96
|
function setupGlobalErrorHandlers(command: string) {
|
|
97
97
|
process.on("uncaughtException", async (error) => {
|
|
98
98
|
await logError({ command, breadcrumbs: ["uncaughtException"], error });
|
|
99
|
-
console.error(
|
|
100
|
-
"An uncaught error occurred. Check the log file for details.",
|
|
101
|
-
);
|
|
99
|
+
console.error(error);
|
|
102
100
|
process.exit(1);
|
|
103
101
|
});
|
|
104
102
|
|
|
@@ -108,9 +106,7 @@ function setupGlobalErrorHandlers(command: string) {
|
|
|
108
106
|
breadcrumbs: ["unhandledRejection"],
|
|
109
107
|
error: reason as Error | string,
|
|
110
108
|
});
|
|
111
|
-
console.error(
|
|
112
|
-
"An unhandled rejection occurred. Check the log file for details.",
|
|
113
|
-
);
|
|
109
|
+
console.error(reason);
|
|
114
110
|
process.exit(1);
|
|
115
111
|
});
|
|
116
112
|
}
|
package/src/login.ts
CHANGED
|
@@ -46,11 +46,20 @@ export default async () => {
|
|
|
46
46
|
|
|
47
47
|
await open(deviceCodeResponse.data["verification_uri_complete"]);
|
|
48
48
|
|
|
49
|
+
let isTerminated = false;
|
|
50
|
+
const signalHandler = () => {
|
|
51
|
+
isTerminated = true;
|
|
52
|
+
authenticationSpinner.fail("Authentication process interrupted");
|
|
53
|
+
process.exit(0);
|
|
54
|
+
};
|
|
55
|
+
process.on("SIGTERM", signalHandler);
|
|
56
|
+
process.on("SIGINT", signalHandler);
|
|
57
|
+
|
|
49
58
|
/**
|
|
50
59
|
* This is a recommended way to poll, since it take some time for a user to enter a `user_code` in a browser.
|
|
51
60
|
* deviceCodeResponse.data['interval'] is a recommended/calculated polling interval specified in seconds.
|
|
52
61
|
*/
|
|
53
|
-
while (
|
|
62
|
+
while (!isTerminated) {
|
|
54
63
|
try {
|
|
55
64
|
const tokenResponse = await axios.post(
|
|
56
65
|
`https://${config.authDomain}/oauth/token`,
|
|
@@ -75,12 +84,15 @@ export default async () => {
|
|
|
75
84
|
await sleep(deviceCodeResponse.data["interval"] * 1000);
|
|
76
85
|
}
|
|
77
86
|
}
|
|
87
|
+
|
|
88
|
+
// Clean up signal handlers
|
|
89
|
+
process.off("SIGTERM", signalHandler);
|
|
90
|
+
process.off("SIGINT", signalHandler);
|
|
78
91
|
} catch (error: unknown) {
|
|
79
92
|
authenticationSpinner.fail("Authentication failed. Please try again.");
|
|
80
93
|
await logError({ command: "login", breadcrumbs, error });
|
|
81
94
|
await reportErrorToRollbar(error);
|
|
82
95
|
console.log(error);
|
|
83
|
-
|
|
84
96
|
process.exit(1);
|
|
85
97
|
}
|
|
86
98
|
};
|
package/src/push.ts
CHANGED
package/src/validate.ts
CHANGED
|
@@ -8,7 +8,7 @@ const CUBE_YAML_FILE_REGEX = /^(.*)\.cube\.ya?ml$/;
|
|
|
8
8
|
const SECURITY_CONTEXT_FILE_REGEX = /^(.*)\.sc\.ya?ml$/;
|
|
9
9
|
const CLIENT_CONTEXT_FILE_REGEX = /^(.*)\.cc\.ya?ml$/;
|
|
10
10
|
|
|
11
|
-
export default async (ctx: any
|
|
11
|
+
export default async (ctx: any) => {
|
|
12
12
|
checkNodeVersion();
|
|
13
13
|
const ora = (await import("ora")).default;
|
|
14
14
|
|
|
@@ -36,9 +36,7 @@ export default async (ctx: any, exitIfInvalid = true) => {
|
|
|
36
36
|
spinnerValidate.info(errorMessage),
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
39
|
+
process.exit(1);
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
spinnerValidate.succeed("Data model validation completed");
|
|
@@ -58,9 +56,7 @@ export default async (ctx: any, exitIfInvalid = true) => {
|
|
|
58
56
|
spinnerValidate.info(errorMessage),
|
|
59
57
|
);
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
59
|
+
process.exit(1);
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
if (clientContextErrors.length) {
|
|
@@ -70,9 +66,7 @@ export default async (ctx: any, exitIfInvalid = true) => {
|
|
|
70
66
|
spinnerValidate.info(errorMessage),
|
|
71
67
|
);
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
69
|
+
process.exit(1);
|
|
76
70
|
}
|
|
77
71
|
|
|
78
72
|
return (
|