zephyr-agent 0.0.15 → 0.0.17
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/dist/index.d.ts +5 -4
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/actions/ze-enable-snapshot-on-edge.d.ts +1 -1
- package/dist/lib/actions/ze-enable-snapshot-on-edge.js +1 -1
- package/dist/lib/actions/ze-enable-snapshot-on-edge.js.map +1 -1
- package/dist/lib/actions/ze-enable-snapshot-on-pages.js +2 -2
- package/dist/lib/actions/ze-enable-snapshot-on-pages.js.map +1 -1
- package/dist/lib/actions/ze-upload-assets.d.ts +1 -1
- package/dist/lib/actions/ze-upload-assets.js +38 -41
- package/dist/lib/actions/ze-upload-assets.js.map +1 -1
- package/dist/lib/actions/ze-upload-build-stats.d.ts +5 -4
- package/dist/lib/actions/ze-upload-build-stats.js +29 -19
- package/dist/lib/actions/ze-upload-build-stats.js.map +1 -1
- package/dist/lib/actions/ze-upload-snapshot.d.ts +1 -1
- package/dist/lib/actions/ze-upload-snapshot.js +11 -14
- package/dist/lib/actions/ze-upload-snapshot.js.map +1 -1
- package/dist/lib/application-configuration/get-application-configuration.d.ts +8 -1
- package/dist/lib/application-configuration/get-application-configuration.js +70 -34
- package/dist/lib/application-configuration/get-application-configuration.js.map +1 -1
- package/dist/lib/auth/login.d.ts +2 -12
- package/dist/lib/auth/login.js +82 -55
- package/dist/lib/auth/login.js.map +1 -1
- package/dist/lib/auth/websocket.d.ts +1 -2
- package/dist/lib/auth/websocket.js +1 -6
- package/dist/lib/auth/websocket.js.map +1 -1
- package/dist/lib/context-utils/ze-util-get-git-info.d.ts +3 -10
- package/dist/lib/context-utils/ze-util-get-git-info.js +5 -14
- package/dist/lib/context-utils/ze-util-get-git-info.js.map +1 -1
- package/dist/lib/custom-errors/configuration-error.js +1 -1
- package/dist/lib/custom-errors/configuration-error.js.map +1 -1
- package/dist/lib/custom-errors/could-not-get-build-id.d.ts +4 -0
- package/dist/lib/custom-errors/could-not-get-build-id.js +15 -0
- package/dist/lib/custom-errors/could-not-get-build-id.js.map +1 -0
- package/dist/lib/custom-errors/git-remote-configuration-error.js +4 -3
- package/dist/lib/custom-errors/git-remote-configuration-error.js.map +1 -1
- package/dist/lib/custom-errors/git-user-identity-error.js +4 -3
- package/dist/lib/custom-errors/git-user-identity-error.js.map +1 -1
- package/dist/lib/custom-errors/index.d.ts +7 -0
- package/dist/lib/custom-errors/index.js +18 -0
- package/dist/lib/custom-errors/index.js.map +1 -0
- package/dist/lib/custom-errors/package-json-not-valid-error.js +1 -2
- package/dist/lib/custom-errors/package-json-not-valid-error.js.map +1 -1
- package/dist/lib/custom-errors/snapshot-uploads.d.ts +7 -0
- package/dist/lib/custom-errors/snapshot-uploads.js +19 -0
- package/dist/lib/custom-errors/snapshot-uploads.js.map +1 -0
- package/dist/lib/dvcs/distributed-hash-control.js +6 -3
- package/dist/lib/dvcs/distributed-hash-control.js.map +1 -1
- package/dist/lib/dvcs/get-cache-key.d.ts +1 -0
- package/dist/lib/dvcs/get-cache-key.js +17 -0
- package/dist/lib/dvcs/get-cache-key.js.map +1 -0
- package/dist/lib/payload-builders/ze-get-dash-data.d.ts +5 -6
- package/dist/lib/payload-builders/ze-get-dash-data.js +2 -4
- package/dist/lib/payload-builders/ze-get-dash-data.js.map +1 -1
- package/dist/lib/remote-logs/ze-log-event.d.ts +5 -10
- package/dist/lib/remote-logs/ze-log-event.js +63 -40
- package/dist/lib/remote-logs/ze-log-event.js.map +1 -1
- package/dist/lib/upload/strategies/cloudflare/upload-build-stats-and-enable-envs.d.ts +1 -3
- package/dist/lib/upload/strategies/cloudflare/upload.d.ts +8 -1
- package/dist/lib/upload/strategies/cloudflare/upload.js +5 -4
- package/dist/lib/upload/strategies/cloudflare/upload.js.map +1 -1
- package/dist/lib/upload/strategies/cloudflare/upsert-assets-to-files.js +1 -1
- package/dist/lib/upload/strategies/cloudflare/upsert-assets-to-files.js.map +1 -1
- package/dist/lib/upload/strategies/cloudflare.strategy.d.ts +2 -3
- package/dist/lib/upload/strategies/cloudflare.strategy.js +6 -26
- package/dist/lib/upload/strategies/cloudflare.strategy.js.map +1 -1
- package/dist/lib/upload/strategies/netlify.strategy.d.ts +2 -3
- package/dist/lib/upload/strategies/netlify.strategy.js +6 -14
- package/dist/lib/upload/strategies/netlify.strategy.js.map +1 -1
- package/dist/lib/upload/upload-file.d.ts +4 -4
- package/dist/lib/upload/upload-file.js +2 -6
- package/dist/lib/upload/upload-file.js.map +1 -1
- package/dist/lib/upload/upload-snapshot.js +2 -2
- package/dist/lib/upload/upload-snapshot.js.map +1 -1
- package/dist/lib/upload/upload.d.ts +2 -3
- package/dist/lib/upload/upload.js +18 -14
- package/dist/lib/upload/upload.js.map +1 -1
- package/dist/lib/util/promise.d.ts +22 -0
- package/dist/lib/util/promise.js +59 -0
- package/dist/lib/util/promise.js.map +1 -0
- package/dist/lib/ze-api-requests/get-application-hash-list.js +2 -2
- package/dist/lib/ze-api-requests/get-application-hash-list.js.map +1 -1
- package/dist/lib/ze-api-requests/get-build-id.js +1 -1
- package/dist/lib/ze-api-requests/get-build-id.js.map +1 -1
- package/dist/package.json +2 -2
- package/package.json +3 -3
- package/dist/lib/upload/strategies/cloudflare/upload-to-pages.d.ts +0 -1
- package/dist/lib/upload/strategies/cloudflare/upload-to-pages.js +0 -20
- package/dist/lib/upload/strategies/cloudflare/upload-to-pages.js.map +0 -1
package/dist/lib/auth/login.js
CHANGED
|
@@ -1,39 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTokenStillValid = exports.checkAuth =
|
|
3
|
+
exports.isTokenStillValid = exports.checkAuth = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jose = tslib_1.__importStar(require("jose"));
|
|
6
|
-
const uuid_1 = require("uuid");
|
|
7
6
|
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
|
7
|
+
const ze_log_event_1 = require("../remote-logs/ze-log-event");
|
|
8
|
+
const promise_1 = require("../util/promise");
|
|
8
9
|
const websocket_1 = require("./websocket");
|
|
9
|
-
const open = (str) => new Function(`return import("open")`)().then(({ default: open }) => open(str));
|
|
10
|
-
function generateSessionKey() {
|
|
11
|
-
return (0, uuid_1.v4)().replace(/-/g, '');
|
|
12
|
-
}
|
|
13
|
-
exports.generateSessionKey = generateSessionKey;
|
|
14
|
-
function getPersonalAccessTokenFromWebsocket() {
|
|
15
|
-
return tslib_1.__awaiter(this, arguments, void 0, function* ({ openBrowser } = {
|
|
16
|
-
openBrowser: true,
|
|
17
|
-
}) {
|
|
18
|
-
const sessionKey = generateSessionKey();
|
|
19
|
-
if (openBrowser) {
|
|
20
|
-
const authUrl = yield getAuthenticationURL({ state: sessionKey });
|
|
21
|
-
yield open(authUrl);
|
|
22
|
-
}
|
|
23
|
-
return yield subscribeToWsEvents(sessionKey);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
exports.getPersonalAccessTokenFromWebsocket = getPersonalAccessTokenFromWebsocket;
|
|
27
|
-
function getAuthenticationURL(options) {
|
|
28
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const { state } = options;
|
|
30
|
-
// const loginUrl = new URL('/v2/authorize-link', ZEPHYR_API_ENDPOINT());
|
|
31
|
-
const loginUrl = new URL(zephyr_edge_contract_1.ze_api_gateway.auth_link, (0, zephyr_edge_contract_1.ZE_API_ENDPOINT)());
|
|
32
|
-
loginUrl.searchParams.append('state', state);
|
|
33
|
-
return (0, zephyr_edge_contract_1.request)(loginUrl);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
exports.getAuthenticationURL = getAuthenticationURL;
|
|
37
10
|
/**
|
|
38
11
|
* Check if the user is already authenticated. If not, open a browser window to authenticate.
|
|
39
12
|
* Display a message to the console.
|
|
@@ -41,14 +14,14 @@ exports.getAuthenticationURL = getAuthenticationURL;
|
|
|
41
14
|
*/
|
|
42
15
|
function checkAuth() {
|
|
43
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const secret_token =
|
|
17
|
+
const secret_token = (0, zephyr_edge_contract_1.getSecretToken)();
|
|
45
18
|
if (secret_token) {
|
|
46
19
|
return secret_token;
|
|
47
20
|
}
|
|
48
21
|
const token = yield (0, zephyr_edge_contract_1.getToken)();
|
|
49
22
|
if (token) {
|
|
50
23
|
// Check if the token has a valid expiration date.
|
|
51
|
-
if (isTokenStillValid(token)) {
|
|
24
|
+
if (isTokenStillValid(token, 60)) {
|
|
52
25
|
(0, zephyr_edge_contract_1.ze_log)('You are already logged in');
|
|
53
26
|
return token;
|
|
54
27
|
}
|
|
@@ -64,16 +37,69 @@ exports.checkAuth = checkAuth;
|
|
|
64
37
|
/**
|
|
65
38
|
* Decides whether the token is still valid based on its expiration time.
|
|
66
39
|
* @param token The token to check.
|
|
40
|
+
* @param gap in seconds
|
|
67
41
|
* @return boolean indicating if the token is still valid.
|
|
68
42
|
*/
|
|
69
|
-
function isTokenStillValid(token) {
|
|
70
|
-
|
|
71
|
-
|
|
43
|
+
function isTokenStillValid(token, gap = 0) {
|
|
44
|
+
// Attempts to decode the token
|
|
45
|
+
try {
|
|
46
|
+
const decodedToken = jose.decodeJwt(token);
|
|
47
|
+
if (decodedToken.exp) {
|
|
48
|
+
return new Date(decodedToken.exp * 1000) > new Date(Date.now() + gap * 1000);
|
|
49
|
+
}
|
|
50
|
+
// No expiration date found, invalid token.
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
catch (_a) {
|
|
54
|
+
// If the token is invalid, return false.
|
|
72
55
|
return false;
|
|
73
56
|
}
|
|
74
|
-
return new Date(decodedToken.exp * 1000) > new Date();
|
|
75
57
|
}
|
|
76
58
|
exports.isTokenStillValid = isTokenStillValid;
|
|
59
|
+
/**
|
|
60
|
+
* Opens the given URL in the default browser.
|
|
61
|
+
*/
|
|
62
|
+
function openUrl(url) {
|
|
63
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
// Lazy loads `open` module
|
|
65
|
+
const openModule = (yield eval(`import('open')`));
|
|
66
|
+
yield openModule.default(url);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Generates a URL-safe random string to use as a session key.
|
|
71
|
+
*/
|
|
72
|
+
function generateSessionKey() {
|
|
73
|
+
return encodeURIComponent(Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Tries to log in the user and get back the websocket reply containing the access token.
|
|
77
|
+
*/
|
|
78
|
+
function getPersonalAccessTokenFromWebsocket() {
|
|
79
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const sessionKey = generateSessionKey();
|
|
81
|
+
// Attempts to open the browser to authenticate the user.
|
|
82
|
+
const authUrl = yield getAuthenticationURL(sessionKey);
|
|
83
|
+
try {
|
|
84
|
+
yield openUrl(authUrl);
|
|
85
|
+
(0, ze_log_event_1.logFn)('debug', 'Opening browser for authentication...');
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
(0, ze_log_event_1.logFn)('debug', `Could not open browser to authenticate with ZephyrCloud. Please open the link below to authenticate:\n\n${(0, zephyr_edge_contract_1.white)(authUrl)}\n`);
|
|
89
|
+
}
|
|
90
|
+
return yield waitForAccessToken(sessionKey);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Generates the URL to authenticate the user.
|
|
95
|
+
*/
|
|
96
|
+
function getAuthenticationURL(state) {
|
|
97
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const loginUrl = new URL(zephyr_edge_contract_1.ze_api_gateway.auth_link, (0, zephyr_edge_contract_1.ZE_API_ENDPOINT)());
|
|
99
|
+
loginUrl.searchParams.append('state', state);
|
|
100
|
+
return (0, zephyr_edge_contract_1.request)(loginUrl);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
77
103
|
/**
|
|
78
104
|
* Initiates user authentication and handles token storage.
|
|
79
105
|
* @return The new token as a string.
|
|
@@ -85,26 +111,27 @@ function authenticateUser() {
|
|
|
85
111
|
return token;
|
|
86
112
|
});
|
|
87
113
|
}
|
|
88
|
-
|
|
89
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Waits for the access token to be received from the websocket.
|
|
116
|
+
*/
|
|
117
|
+
function waitForAccessToken(sessionKey) {
|
|
118
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const { promise, resolve, reject } = (0, promise_1.PromiseWithResolvers)();
|
|
90
120
|
const socket = (0, websocket_1.createSocket)((0, zephyr_edge_contract_1.ZEPHYR_API_ENDPOINT)());
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
state: sessionKey
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
cleanup();
|
|
106
|
-
reject(new Error(msg));
|
|
107
|
-
});
|
|
121
|
+
try {
|
|
122
|
+
socket.once('access-token', resolve);
|
|
123
|
+
// Creating errors outside of the listener closure makes the stack trace point
|
|
124
|
+
// to waitForAccessToken fn instead of socket.io internals event emitter code.
|
|
125
|
+
socket.once('access-token-error', reject.bind(new Error('Error getting access token')));
|
|
126
|
+
socket.once('connect_error', reject);
|
|
127
|
+
socket.emit('joinAccessTokenRoom', { state: sessionKey });
|
|
128
|
+
// The user has 60 seconds to log in through the browser.
|
|
129
|
+
setTimeout(reject, 60000, new Error('Login timeout.'));
|
|
130
|
+
return yield promise;
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
socket.close();
|
|
134
|
+
}
|
|
108
135
|
});
|
|
109
136
|
}
|
|
110
137
|
//# sourceMappingURL=login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/lib/auth/login.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,+
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/lib/auth/login.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,+DAW8B;AAC9B,8DAAoD;AACpD,6CAAuD;AACvD,2CAA2C;AAE3C;;;;GAIG;AACH,SAAsB,SAAS;;QAC7B,MAAM,YAAY,GAAG,IAAA,qCAAc,GAAE,CAAC;QAEtC,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAA,+BAAQ,GAAE,CAAC;QAE/B,IAAI,KAAK,EAAE,CAAC;YACV,kDAAkD;YAClD,IAAI,iBAAiB,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;gBACjC,IAAA,6BAAM,EAAC,2BAA2B,CAAC,CAAC;gBACpC,OAAO,KAAK,CAAC;YACf,CAAC;YAED,MAAM,IAAA,kCAAW,GAAE,CAAC;QACtB,CAAC;QAED,iDAAiD;QACjD,MAAM,QAAQ,GAAG,MAAM,gBAAgB,EAAE,CAAC;QAE1C,IAAA,6BAAM,EAAC,mBAAmB,CAAC,CAAC;QAE5B,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AAzBD,8BAyBC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,KAAa,EAAE,GAAG,GAAG,CAAC;IACtD,+BAA+B;IAC/B,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAE3C,IAAI,YAAY,CAAC,GAAG,EAAE,CAAC;YACrB,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,GAA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import { Socket } from 'socket.io-client';
|
|
1
|
+
import { type Socket } from 'socket.io-client';
|
|
2
2
|
interface ClientToServerEvents {
|
|
3
3
|
joinAccessTokenRoom: (props: {
|
|
4
4
|
state: string;
|
|
@@ -9,5 +9,4 @@ interface ServerToClientEvents {
|
|
|
9
9
|
'access-token-error': (msg: string) => void;
|
|
10
10
|
}
|
|
11
11
|
export declare function createSocket(endpoint: string): Socket<ServerToClientEvents, ClientToServerEvents>;
|
|
12
|
-
export declare function disposeSocket(socket: Socket): void;
|
|
13
12
|
export {};
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createSocket = void 0;
|
|
4
4
|
const socket_io_client_1 = require("socket.io-client");
|
|
5
5
|
function createSocket(endpoint) {
|
|
6
6
|
return (0, socket_io_client_1.io)(endpoint);
|
|
7
7
|
}
|
|
8
8
|
exports.createSocket = createSocket;
|
|
9
|
-
function disposeSocket(socket) {
|
|
10
|
-
socket.disconnect();
|
|
11
|
-
socket.close();
|
|
12
|
-
}
|
|
13
|
-
exports.disposeSocket = disposeSocket;
|
|
14
9
|
//# sourceMappingURL=websocket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/lib/auth/websocket.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/lib/auth/websocket.ts"],"names":[],"mappings":";;;AAAA,uDAA+D;AAW/D,SAAgB,YAAY,CAAC,QAAgB;IAC3C,OAAO,IAAA,qBAAQ,EAAC,QAAQ,CAAC,CAAC;AAC5B,CAAC;AAFD,oCAEC"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
+
import { type ZephyrPluginOptions } from 'zephyr-edge-contract';
|
|
1
2
|
export interface GitInfo {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
email?: string;
|
|
5
|
-
branch: string;
|
|
6
|
-
commit: string;
|
|
7
|
-
};
|
|
8
|
-
app: {
|
|
9
|
-
org: string;
|
|
10
|
-
project: string;
|
|
11
|
-
};
|
|
3
|
+
app: Pick<ZephyrPluginOptions['app'], 'org' | 'project'>;
|
|
4
|
+
git: ZephyrPluginOptions['git'];
|
|
12
5
|
}
|
|
13
6
|
export declare function getGitInfo(): Promise<GitInfo>;
|
|
@@ -34,16 +34,12 @@ function getGitInfo() {
|
|
|
34
34
|
.split(':')
|
|
35
35
|
// Take the last part, which is the path
|
|
36
36
|
.pop()) === null || _a === void 0 ? void 0 : _a.split('/');
|
|
37
|
-
const organization = urlParts && (urlParts === null || urlParts === void 0 ? void 0 : urlParts.length) > 1
|
|
38
|
-
|
|
39
|
-
: undefined;
|
|
40
|
-
const repositoryName = urlParts && urlParts.length > 0
|
|
41
|
-
? (_c = urlParts[urlParts.length - 1]) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()
|
|
42
|
-
: undefined;
|
|
37
|
+
const organization = urlParts && (urlParts === null || urlParts === void 0 ? void 0 : urlParts.length) > 1 ? (_b = urlParts[urlParts.length - 2]) === null || _b === void 0 ? void 0 : _b.toLocaleLowerCase() : undefined;
|
|
38
|
+
const repositoryName = urlParts && urlParts.length > 0 ? (_c = urlParts[urlParts.length - 1]) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase() : undefined;
|
|
43
39
|
if (!organization || !repositoryName) {
|
|
44
40
|
throw new git_remote_configuration_error_1.GitRemoteConfigurationError();
|
|
45
41
|
}
|
|
46
|
-
const has_secret_token = yield hasSecretToken();
|
|
42
|
+
const has_secret_token = yield (0, zephyr_edge_contract_1.hasSecretToken)();
|
|
47
43
|
if (!has_secret_token && (!username || !email)) {
|
|
48
44
|
throw new git_user_identity_error_1.GitUserIdentityError();
|
|
49
45
|
}
|
|
@@ -65,14 +61,9 @@ function getGitInfo() {
|
|
|
65
61
|
});
|
|
66
62
|
}
|
|
67
63
|
exports.getGitInfo = getGitInfo;
|
|
68
|
-
function hasSecretToken() {
|
|
69
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
return (0, zephyr_edge_contract_1.getSecretToken)().then((res) => !!res);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
64
|
function getGitUsername() {
|
|
74
65
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
const has_secret_token =
|
|
66
|
+
const has_secret_token = (0, zephyr_edge_contract_1.hasSecretToken)();
|
|
76
67
|
if (is_ci_1.default || has_secret_token) {
|
|
77
68
|
return exec("git log -1 --pretty=format:'%an'").then((res) => res.stdout.trim());
|
|
78
69
|
}
|
|
@@ -81,7 +72,7 @@ function getGitUsername() {
|
|
|
81
72
|
}
|
|
82
73
|
function getGitEmail() {
|
|
83
74
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const has_secret_token =
|
|
75
|
+
const has_secret_token = (0, zephyr_edge_contract_1.hasSecretToken)();
|
|
85
76
|
if (is_ci_1.default || has_secret_token) {
|
|
86
77
|
return exec("git log -1 --pretty=format:'%ae'").then((res) => res.stdout.trim());
|
|
87
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ze-util-get-git-info.js","sourceRoot":"","sources":["../../../src/lib/context-utils/ze-util-get-git-info.ts"],"names":[],"mappings":";;;;AAAA,yCAAsC;AACtC,2DAAoD;AACpD,0DAAyB;AACzB,+
|
|
1
|
+
{"version":3,"file":"ze-util-get-git-info.js","sourceRoot":"","sources":["../../../src/lib/context-utils/ze-util-get-git-info.ts"],"names":[],"mappings":";;;;AAAA,yCAAsC;AACtC,2DAAoD;AACpD,0DAAyB;AACzB,+DAAmG;AAEnG,oGAA8F;AAC9F,sFAAgF;AAEhF,MAAM,IAAI,GAAG,IAAA,qBAAS,EAAC,yBAAM,CAAC,CAAC;AAC/B,MAAM,YAAY,GAAG,UAAU,CAAC;AAOhC,SAAsB,UAAU;;;Q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CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,IAAI,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;CAAA;AAED,SAAe,kBAAkB;;QAC/B,OAAO,IAAI,CAAC,oCAAoC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACrF,CAAC;CAAA;AAED,SAAe,YAAY;;QACzB,OAAO,IAAI,CAAC,iCAAiC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAClF,CAAC;CAAA;AAED,SAAe,gBAAgB;;QAC7B,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;CAAA"}
|
|
@@ -6,7 +6,7 @@ class ConfigurationError extends Error {
|
|
|
6
6
|
// link to wherever documentation is
|
|
7
7
|
// docs usually locate at this address
|
|
8
8
|
constructor(code, message, level) {
|
|
9
|
-
super(`${zephyr_edge_contract_1.brightRedBgName} ${level === 'critical' ? `Critical error` : `Error`} [${code}]: ${message} \n ${code ? `See documentation on how to debug this error: https://docs.zephyr-cloud.io/
|
|
9
|
+
super(`${zephyr_edge_contract_1.brightRedBgName} ${level === 'critical' ? `Critical error` : `Error`} [${code}]: ${message} \n ${code ? `See documentation on how to debug this error: https://docs.zephyr-cloud.io/errors/${code.toLowerCase()}` : ''}`);
|
|
10
10
|
this.name = 'ConfigurationError';
|
|
11
11
|
// looks weird right? but vite build logger prints only stack trace,
|
|
12
12
|
// so this is how we ended up with this.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/configuration-error.ts"],"names":[],"mappings":";;;AAAA,+DAAuD;AAEvD,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,qCAAqC;IACrC,sCAAsC;IACtC,YAAY,IAAY,EAAE,OAAe,EAAE,KAA6B;QACtE,KAAK,CACH,GAAG,sCAAe,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,MAAM,OAAO,OAAO,IAAI,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"configuration-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/configuration-error.ts"],"names":[],"mappings":";;;AAAA,+DAAuD;AAEvD,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,qCAAqC;IACrC,sCAAsC;IACtC,YAAY,IAAY,EAAE,OAAe,EAAE,KAA6B;QACtE,KAAK,CACH,GAAG,sCAAe,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,MAAM,OAAO,OAAO,IAAI,CAAC,CAAC,CAAC,qFAAqF,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5N,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,oEAAoE;QACpE,wCAAwC;QACvC,IAA4B,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QAClD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC;IAC5B,CAAC;CACF;AAbD,gDAaC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CouldNotGetBuildIdError = void 0;
|
|
4
|
+
const configuration_error_1 = require("./configuration-error");
|
|
5
|
+
const noBuildIdErrMsg = `Could not get build id. Please make sure you have:
|
|
6
|
+
- a Zephyr account registered on https://app.zephyr-cloud.io
|
|
7
|
+
- git remote origin url is configured
|
|
8
|
+
- this repository has commit history`.trim();
|
|
9
|
+
class CouldNotGetBuildIdError extends configuration_error_1.ConfigurationError {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(`ZE10019`, noBuildIdErrMsg);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.CouldNotGetBuildIdError = CouldNotGetBuildIdError;
|
|
15
|
+
//# sourceMappingURL=could-not-get-build-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"could-not-get-build-id.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/could-not-get-build-id.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAM,eAAe,GAAG;;;qCAGa,CAAC,IAAI,EAAE,CAAC;AAE7C,MAAa,uBAAwB,SAAQ,wCAAkB;IAC7D;QACE,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IACpC,CAAC;CACF;AAJD,0DAIC"}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GitRemoteConfigurationError = void 0;
|
|
4
4
|
const configuration_error_1 = require("./configuration-error");
|
|
5
|
+
const gitRemoteErrMsg = `git remote origin is not configured properly
|
|
6
|
+
- please set valid 'git remote origin' by using commands below
|
|
7
|
+
- git init && git remote add origin <url>`.trim();
|
|
5
8
|
class GitRemoteConfigurationError extends configuration_error_1.ConfigurationError {
|
|
6
9
|
constructor() {
|
|
7
|
-
super(`ZE10014`,
|
|
8
|
-
- please set valid 'git remote origin' by using commands below\n
|
|
9
|
-
- git init && git remote add origin <url> \n`);
|
|
10
|
+
super(`ZE10014`, gitRemoteErrMsg);
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
exports.GitRemoteConfigurationError = GitRemoteConfigurationError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-remote-configuration-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/git-remote-configuration-error.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAa,2BAA4B,SAAQ,wCAAkB;IACjE;QACE,KAAK,
|
|
1
|
+
{"version":3,"file":"git-remote-configuration-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/git-remote-configuration-error.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAM,eAAe,GAAG;;0CAEkB,CAAC,IAAI,EAAE,CAAC;AAElD,MAAa,2BAA4B,SAAQ,wCAAkB;IACjE;QACE,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IACpC,CAAC;CACF;AAJD,kEAIC"}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GitUserIdentityError = void 0;
|
|
4
4
|
const configuration_error_1 = require("./configuration-error");
|
|
5
|
+
const gitUserErrMsg = `git username or email is not configured
|
|
6
|
+
- please set valid 'git config user.name' and 'git config user.email'
|
|
7
|
+
- or provide ZE_USER_TOKEN as environment variable`.trim();
|
|
5
8
|
class GitUserIdentityError extends configuration_error_1.ConfigurationError {
|
|
6
9
|
constructor() {
|
|
7
|
-
super(`ZE10015`,
|
|
8
|
-
- please set valid 'git config user.name' and 'git config user.email' \n
|
|
9
|
-
- or provide ZE_USER_TOKEN as environment variable \n`);
|
|
10
|
+
super(`ZE10015`, gitUserErrMsg);
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
exports.GitUserIdentityError = GitUserIdentityError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-user-identity-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/git-user-identity-error.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAa,oBAAqB,SAAQ,wCAAkB;IAC1D;QACE,KAAK,
|
|
1
|
+
{"version":3,"file":"git-user-identity-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/git-user-identity-error.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAM,aAAa,GAAG;;mDAE6B,CAAC,IAAI,EAAE,CAAC;AAE3D,MAAa,oBAAqB,SAAQ,wCAAkB;IAC1D;QACE,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IAClC,CAAC;CACF;AAJD,oDAIC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ConfigurationError } from './configuration-error';
|
|
2
|
+
export { GitRemoteConfigurationError } from './git-remote-configuration-error';
|
|
3
|
+
export { GitUserIdentityError } from './git-user-identity-error';
|
|
4
|
+
export { CouldNotGetBuildIdError } from './could-not-get-build-id';
|
|
5
|
+
export { PackageJsonNotFoundError } from './package-json-not-found-error';
|
|
6
|
+
export { PackageJsonNotValidError } from './package-json-not-valid-error';
|
|
7
|
+
export { PackageNotAJsonError } from './package-not-a-json-error';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PackageNotAJsonError = exports.PackageJsonNotValidError = exports.PackageJsonNotFoundError = exports.CouldNotGetBuildIdError = exports.GitUserIdentityError = exports.GitRemoteConfigurationError = exports.ConfigurationError = void 0;
|
|
4
|
+
var configuration_error_1 = require("./configuration-error");
|
|
5
|
+
Object.defineProperty(exports, "ConfigurationError", { enumerable: true, get: function () { return configuration_error_1.ConfigurationError; } });
|
|
6
|
+
var git_remote_configuration_error_1 = require("./git-remote-configuration-error");
|
|
7
|
+
Object.defineProperty(exports, "GitRemoteConfigurationError", { enumerable: true, get: function () { return git_remote_configuration_error_1.GitRemoteConfigurationError; } });
|
|
8
|
+
var git_user_identity_error_1 = require("./git-user-identity-error");
|
|
9
|
+
Object.defineProperty(exports, "GitUserIdentityError", { enumerable: true, get: function () { return git_user_identity_error_1.GitUserIdentityError; } });
|
|
10
|
+
var could_not_get_build_id_1 = require("./could-not-get-build-id");
|
|
11
|
+
Object.defineProperty(exports, "CouldNotGetBuildIdError", { enumerable: true, get: function () { return could_not_get_build_id_1.CouldNotGetBuildIdError; } });
|
|
12
|
+
var package_json_not_found_error_1 = require("./package-json-not-found-error");
|
|
13
|
+
Object.defineProperty(exports, "PackageJsonNotFoundError", { enumerable: true, get: function () { return package_json_not_found_error_1.PackageJsonNotFoundError; } });
|
|
14
|
+
var package_json_not_valid_error_1 = require("./package-json-not-valid-error");
|
|
15
|
+
Object.defineProperty(exports, "PackageJsonNotValidError", { enumerable: true, get: function () { return package_json_not_valid_error_1.PackageJsonNotValidError; } });
|
|
16
|
+
var package_not_a_json_error_1 = require("./package-not-a-json-error");
|
|
17
|
+
Object.defineProperty(exports, "PackageNotAJsonError", { enumerable: true, get: function () { return package_not_a_json_error_1.PackageNotAJsonError; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/index.ts"],"names":[],"mappings":";;;AAAA,6DAA2D;AAAlD,yHAAA,kBAAkB,OAAA;AAC3B,mFAA+E;AAAtE,6IAAA,2BAA2B,OAAA;AACpC,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,mEAAmE;AAA1D,iIAAA,uBAAuB,OAAA;AAChC,+EAA0E;AAAjE,wIAAA,wBAAwB,OAAA;AACjC,+EAA0E;AAAjE,wIAAA,wBAAwB,OAAA;AACjC,uEAAkE;AAAzD,gIAAA,oBAAoB,OAAA"}
|
|
@@ -4,8 +4,7 @@ exports.PackageJsonNotValidError = void 0;
|
|
|
4
4
|
const configuration_error_1 = require("./configuration-error");
|
|
5
5
|
class PackageJsonNotValidError extends configuration_error_1.ConfigurationError {
|
|
6
6
|
constructor(path) {
|
|
7
|
-
super(`ZE10013`, `package json ('${path}')
|
|
8
|
-
must have a 'name' and a 'version' properties`);
|
|
7
|
+
super(`ZE10013`, `package json in ('${path}') must have a 'name' and a 'version' properties`);
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
10
|
exports.PackageJsonNotValidError = PackageJsonNotValidError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-json-not-valid-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/package-json-not-valid-error.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAa,wBAAyB,SAAQ,wCAAkB;IAC9D,YAAY,IAAwB;QAClC,KAAK,
|
|
1
|
+
{"version":3,"file":"package-json-not-valid-error.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/package-json-not-valid-error.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAa,wBAAyB,SAAQ,wCAAkB;IAC9D,YAAY,IAAwB;QAClC,KAAK,CAAC,SAAS,EAAE,qBAAqB,IAAI,kDAAkD,CAAC,CAAC;IAChG,CAAC;CACF;AAJD,4DAIC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnapshotUploadNoResultError = exports.SnapshotUploadFailureError = void 0;
|
|
4
|
+
const configuration_error_1 = require("./configuration-error");
|
|
5
|
+
const snapshotUploadFailed = `Failed to upload snapshot.`.trim();
|
|
6
|
+
class SnapshotUploadFailureError extends configuration_error_1.ConfigurationError {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(`ZE20018`, snapshotUploadFailed);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.SnapshotUploadFailureError = SnapshotUploadFailureError;
|
|
12
|
+
const snapshotUploadNoResult = `Snapshot upload gave no result, exiting...`;
|
|
13
|
+
class SnapshotUploadNoResultError extends configuration_error_1.ConfigurationError {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(`ZE20019`, snapshotUploadNoResult);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.SnapshotUploadNoResultError = SnapshotUploadNoResultError;
|
|
19
|
+
//# sourceMappingURL=snapshot-uploads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-uploads.js","sourceRoot":"","sources":["../../../src/lib/custom-errors/snapshot-uploads.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,IAAI,EAAE,CAAC;AAEjE,MAAa,0BAA2B,SAAQ,wCAAkB;IAChE;QACE,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;IACzC,CAAC;CACF;AAJD,gEAIC;AAED,MAAM,sBAAsB,GAAG,4CAA4C,CAAC;AAE5E,MAAa,2BAA4B,SAAQ,wCAAkB;IACjE;QACE,KAAK,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;IAC3C,CAAC;CACF;AAJD,kEAIC"}
|
|
@@ -4,15 +4,17 @@ exports.update_hash_list = exports.get_hash_list = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
|
6
6
|
const get_application_hash_list_1 = require("../ze-api-requests/get-application-hash-list");
|
|
7
|
+
const get_cache_key_1 = require("./get-cache-key");
|
|
7
8
|
function get_hash_list(application_uid) {
|
|
8
9
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
const
|
|
10
|
+
const cacheKey = yield (0, get_cache_key_1.getCacheKey)(application_uid);
|
|
11
|
+
const local_hash_list = yield zephyr_edge_contract_1._hash_cache.getAppHashCache(cacheKey);
|
|
10
12
|
if (local_hash_list) {
|
|
11
13
|
return { hash_set: new Set(local_hash_list.hashes) };
|
|
12
14
|
}
|
|
13
15
|
const remote_hash_list = yield (0, get_application_hash_list_1.getApplicationHashList)({ application_uid });
|
|
14
16
|
if (remote_hash_list) {
|
|
15
|
-
yield zephyr_edge_contract_1._hash_cache.setAppHashCache(
|
|
17
|
+
yield zephyr_edge_contract_1._hash_cache.setAppHashCache(cacheKey, remote_hash_list);
|
|
16
18
|
return { hash_set: new Set(remote_hash_list.hashes) };
|
|
17
19
|
}
|
|
18
20
|
return { hash_set: new Set() };
|
|
@@ -21,8 +23,9 @@ function get_hash_list(application_uid) {
|
|
|
21
23
|
exports.get_hash_list = get_hash_list;
|
|
22
24
|
function update_hash_list(application_uid, assetsMap) {
|
|
23
25
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const cacheKey = yield (0, get_cache_key_1.getCacheKey)(application_uid);
|
|
24
27
|
const hashes = Object.values(assetsMap).map(({ hash }) => hash);
|
|
25
|
-
yield zephyr_edge_contract_1._hash_cache.setAppHashCache(
|
|
28
|
+
yield zephyr_edge_contract_1._hash_cache.setAppHashCache(cacheKey, { hashes });
|
|
26
29
|
});
|
|
27
30
|
}
|
|
28
31
|
exports.update_hash_list = update_hash_list;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distributed-hash-control.js","sourceRoot":"","sources":["../../../src/lib/dvcs/distributed-hash-control.ts"],"names":[],"mappings":";;;;AAAA,+DAA0E;AAC1E,4FAAsF;
|
|
1
|
+
{"version":3,"file":"distributed-hash-control.js","sourceRoot":"","sources":["../../../src/lib/dvcs/distributed-hash-control.ts"],"names":[],"mappings":";;;;AAAA,+DAA0E;AAC1E,4FAAsF;AACtF,mDAA8C;AAE9C,SAAsB,aAAa,CAAC,eAAuB;;QACzD,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAW,EAAC,eAAe,CAAC,CAAC;QACpD,MAAM,eAAe,GAAG,MAAM,kCAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACpE,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,EAAE,QAAQ,EAAE,IAAI,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,CAAC;QACD,MAAM,gBAAgB,GAAG,MAAM,IAAA,kDAAsB,EAAC,EAAE,eAAe,EAAE,CAAC,CAAC;QAC3E,IAAI,gBAAgB,EAAE,CAAC;YACrB,MAAM,kCAAW,CAAC,eAAe,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YAC9D,OAAO,EAAE,QAAQ,EAAE,IAAI,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QACxD,CAAC;QAED,OAAO,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;IACjC,CAAC;CAAA;AAbD,sCAaC;AAED,SAAsB,gBAAgB,CAAC,eAAuB,EAAE,SAA6C;;QAC3G,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAW,EAAC,eAAe,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QAChE,MAAM,kCAAW,CAAC,eAAe,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1D,CAAC;CAAA;AAJD,4CAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCacheKey(application_uid: string): Promise<string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCacheKey = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const get_application_configuration_1 = require("../application-configuration/get-application-configuration");
|
|
6
|
+
function getCacheKey(application_uid) {
|
|
7
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
var _a;
|
|
9
|
+
let edgeUrl = ((_a = (yield (0, get_application_configuration_1.getApplicationConfiguration)({ application_uid }))) === null || _a === void 0 ? void 0 : _a.EDGE_URL) || '';
|
|
10
|
+
if (edgeUrl) {
|
|
11
|
+
edgeUrl = new URL(edgeUrl).host;
|
|
12
|
+
}
|
|
13
|
+
return `${application_uid}-${edgeUrl}`;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.getCacheKey = getCacheKey;
|
|
17
|
+
//# sourceMappingURL=get-cache-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-cache-key.js","sourceRoot":"","sources":["../../../src/lib/dvcs/get-cache-key.ts"],"names":[],"mappings":";;;;AAAA,8GAAyG;AAEzG,SAAsB,WAAW,CAAC,eAAuB;;;QACvD,IAAI,OAAO,GAAG,CAAA,MAAA,CAAC,MAAM,IAAA,2DAA2B,EAAC,EAAE,eAAe,EAAE,CAAC,CAAC,0CAAE,QAAQ,KAAI,EAAE,CAAC;QACvF,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;QAClC,CAAC;QAED,OAAO,GAAG,eAAe,IAAI,OAAO,EAAE,CAAC;IACzC,CAAC;CAAA;AAPD,kCAOC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ZeApplicationConfig, ZephyrPluginOptions } from 'zephyr-edge-contract';
|
|
2
|
-
export declare function zeGetDashData({ pluginOptions, appConfig
|
|
2
|
+
export declare function zeGetDashData({ pluginOptions, appConfig }: GetDashDataOptions): {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
5
|
+
environment: string;
|
|
5
6
|
edge: {
|
|
6
7
|
url: string;
|
|
7
8
|
};
|
|
@@ -11,12 +12,12 @@ export declare function zeGetDashData({ pluginOptions, appConfig, }: GetDashData
|
|
|
11
12
|
name: string;
|
|
12
13
|
version: string;
|
|
13
14
|
} & {
|
|
14
|
-
buildId: string
|
|
15
|
+
buildId: string;
|
|
15
16
|
};
|
|
16
17
|
version: string;
|
|
17
18
|
git: {
|
|
18
|
-
name
|
|
19
|
-
email
|
|
19
|
+
name: string;
|
|
20
|
+
email: string;
|
|
20
21
|
branch: string;
|
|
21
22
|
commit: string;
|
|
22
23
|
};
|
|
@@ -30,8 +31,6 @@ export declare function zeGetDashData({ pluginOptions, appConfig, }: GetDashData
|
|
|
30
31
|
overrides: never[];
|
|
31
32
|
consumes: never[];
|
|
32
33
|
modules: never[];
|
|
33
|
-
sha: string;
|
|
34
|
-
buildHash: string;
|
|
35
34
|
};
|
|
36
35
|
export interface GetDashDataOptions {
|
|
37
36
|
appConfig: ZeApplicationConfig;
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.zeGetDashData = void 0;
|
|
4
4
|
const zephyr_edge_contract_1 = require("zephyr-edge-contract");
|
|
5
|
-
function zeGetDashData({ pluginOptions, appConfig
|
|
5
|
+
function zeGetDashData({ pluginOptions, appConfig }) {
|
|
6
6
|
const { EDGE_URL } = appConfig;
|
|
7
7
|
const version = (0, zephyr_edge_contract_1.createSnapshotId)(pluginOptions);
|
|
8
8
|
return {
|
|
9
9
|
id: pluginOptions.application_uid,
|
|
10
10
|
name: pluginOptions.app.name,
|
|
11
|
+
environment: '',
|
|
11
12
|
edge: { url: EDGE_URL },
|
|
12
13
|
app: Object.assign({}, pluginOptions.app, {
|
|
13
14
|
buildId: pluginOptions.zeConfig.buildId,
|
|
@@ -24,9 +25,6 @@ function zeGetDashData({ pluginOptions, appConfig, }) {
|
|
|
24
25
|
overrides: [],
|
|
25
26
|
consumes: [],
|
|
26
27
|
modules: [],
|
|
27
|
-
sha: pluginOptions.git.commit,
|
|
28
|
-
// todo: @deprecate
|
|
29
|
-
buildHash: pluginOptions.git.commit,
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
30
|
exports.zeGetDashData = zeGetDashData;
|