@trayio/cdk-cli-commons 5.14.0 → 5.15.0
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/utils/check-env.js
CHANGED
|
@@ -29,13 +29,13 @@ const isValidApiToken = () => {
|
|
|
29
29
|
};
|
|
30
30
|
const checkMissingApiUrlEnv = () => {
|
|
31
31
|
if (!process.env.TRAY_API_URL) {
|
|
32
|
-
throw new Error('required env TRAY_API_URL is not set, or use the --us, --eu, or --
|
|
32
|
+
throw new Error('required env TRAY_API_URL is not set, or use the --us, --eu, --ap, or --ap2 region flags');
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
const isApiUrlValid = () => {
|
|
36
36
|
const apiUrl = process.env.TRAY_API_URL;
|
|
37
|
-
const validApiUrlRegex = /^https:\/\/api\.(?:ap1\.|eu1\.|staging\.)?tray\.io$/;
|
|
37
|
+
const validApiUrlRegex = /^https:\/\/api\.(?:ap1\.|ap2\.|eu1\.|staging\.)?tray\.io$/;
|
|
38
38
|
if (!validApiUrlRegex.test(apiUrl)) {
|
|
39
|
-
throw new Error(`TRAY_API_URL is invalid. It should be one of the following: https://api.tray.io, https://api.ap1.tray.io, https://api.eu1.tray.io. Or use the --us, --eu, or --
|
|
39
|
+
throw new Error(`TRAY_API_URL is invalid. It should be one of the following: https://api.tray.io, https://api.ap1.tray.io, https://api.ap2.tray.io, https://api.eu1.tray.io. Or use the --us, --eu, --ap, or --ap2 region flags`);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
@@ -51,7 +51,7 @@ describe('checkApiUrlEnv', () => {
|
|
|
51
51
|
TRAY_API_URL: 'https://api.tray.io/invalid',
|
|
52
52
|
TRAY_API_TOKEN: 'random',
|
|
53
53
|
};
|
|
54
|
-
expect(() => subject()).toThrowError('TRAY_API_URL is invalid. It should be one of the following: https://api.tray.io, https://api.ap1.tray.io, https://api.eu1.tray.io');
|
|
54
|
+
expect(() => subject()).toThrowError('TRAY_API_URL is invalid. It should be one of the following: https://api.tray.io, https://api.ap1.tray.io, https://api.ap2.tray.io, https://api.eu1.tray.io');
|
|
55
55
|
});
|
|
56
56
|
it('should not throw an error if TRAY_API_URL is valid', () => {
|
|
57
57
|
process.env = {
|
package/dist/utils/region.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const regionFlags: {
|
|
|
6
6
|
us: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
7
7
|
eu: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
8
8
|
ap: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
9
|
+
ap2: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
9
10
|
};
|
|
10
11
|
export interface HttpImplementation<T> {
|
|
11
12
|
new (httpConfig: HttpConfig, httpClient: HttpClient): T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"region.d.ts","sourceRoot":"","sources":["../../src/utils/region.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAGrE,eAAO,MAAM,UAAU,UAAW,WAAW,CAAC,OAAO,CAAC,KAAG,
|
|
1
|
+
{"version":3,"file":"region.d.ts","sourceRoot":"","sources":["../../src/utils/region.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAGrE,eAAO,MAAM,UAAU,UAAW,WAAW,CAAC,OAAO,CAAC,KAAG,MAexD,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;CAavB,CAAC;AAEF,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACpC,KAAK,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,CAAC,CAAC;CACxD;AAED,qBAAa,aAAa,CAAC,CAAC;IAE1B,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAC5D,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU;gBADtB,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC,EACzC,UAAU,EAAE,UAAU;IAGnC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC;CAIzC"}
|
package/dist/utils/region.js
CHANGED
|
@@ -13,6 +13,9 @@ const getBaseUrl = (flags) => {
|
|
|
13
13
|
if (flags.ap) {
|
|
14
14
|
return 'https://api.ap1.tray.io';
|
|
15
15
|
}
|
|
16
|
+
if (flags.ap2) {
|
|
17
|
+
return 'https://api.ap2.tray.io';
|
|
18
|
+
}
|
|
16
19
|
(0, check_env_1.checkApiUrlEnv)();
|
|
17
20
|
return process.env.TRAY_API_URL;
|
|
18
21
|
};
|
|
@@ -27,6 +30,9 @@ exports.regionFlags = {
|
|
|
27
30
|
ap: core_1.Flags.boolean({
|
|
28
31
|
description: 'Use the Tray APAC region',
|
|
29
32
|
}),
|
|
33
|
+
ap2: core_1.Flags.boolean({
|
|
34
|
+
description: 'Use the Tray APAC 2 region',
|
|
35
|
+
}),
|
|
30
36
|
};
|
|
31
37
|
class RegionHandler {
|
|
32
38
|
HttpImplementation;
|
|
@@ -27,7 +27,7 @@ describe('RegionHandler', () => {
|
|
|
27
27
|
TRAY_API_URL: '',
|
|
28
28
|
};
|
|
29
29
|
const regionHandler = new region_1.RegionHandler(HttpImplementationStub, new AxiosHttpClient_1.AxiosHttpClient());
|
|
30
|
-
expect(() => regionHandler.invoke({}).get()).toThrowError('required env TRAY_API_URL is not set, or use the --us, --eu, or --
|
|
30
|
+
expect(() => regionHandler.invoke({}).get()).toThrowError('required env TRAY_API_URL is not set, or use the --us, --eu, --ap, or --ap2 region flags');
|
|
31
31
|
});
|
|
32
32
|
it('should use US baseUrl when passed us flag', () => {
|
|
33
33
|
const regionHandler = new region_1.RegionHandler(HttpImplementationStub, new AxiosHttpClient_1.AxiosHttpClient());
|
|
@@ -47,4 +47,10 @@ describe('RegionHandler', () => {
|
|
|
47
47
|
const result = regionHandler.invoke(flags).get();
|
|
48
48
|
expect(result).toEqual('https://api.ap1.tray.io');
|
|
49
49
|
});
|
|
50
|
+
it('should use AP2 baseUrl when passed ap2 flag', () => {
|
|
51
|
+
const regionHandler = new region_1.RegionHandler(HttpImplementationStub, new AxiosHttpClient_1.AxiosHttpClient());
|
|
52
|
+
const flags = { ap2: true };
|
|
53
|
+
const result = regionHandler.invoke(flags).get();
|
|
54
|
+
expect(result).toEqual('https://api.ap2.tray.io');
|
|
55
|
+
});
|
|
50
56
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-cli-commons",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.15.0",
|
|
4
4
|
"description": "Shared utils between CDK ClIs",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@oclif/core": "3.18.1",
|
|
18
18
|
"@oclif/test": "3.1.12",
|
|
19
|
-
"@trayio/axios": "5.
|
|
20
|
-
"@trayio/commons": "5.
|
|
21
|
-
"@trayio/tray-client": "5.
|
|
19
|
+
"@trayio/axios": "5.15.0",
|
|
20
|
+
"@trayio/commons": "5.15.0",
|
|
21
|
+
"@trayio/tray-client": "5.15.0",
|
|
22
22
|
"chalk": "4.1.2"
|
|
23
23
|
},
|
|
24
24
|
"typesVersions": {
|