@contrail/cli 3.5.5-alpha.a73fd77 → 3.5.5-alpha.cb68c04
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/README.md +1 -1
- package/dist/auth/login.d.ts +1 -0
- package/dist/auth/login.js +23 -7
- package/dist/auth/login.spec.js +17 -0
- package/dist/commands/app/upgrade.js +0 -4
- package/dist/interfaces.d.ts +0 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/dist/commands/app/upgrade.spec.d.ts +0 -1
- package/dist/commands/app/upgrade.spec.js +0 -36
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ $ npm install -g @contrail/cli
|
|
|
17
17
|
$ contrail COMMAND
|
|
18
18
|
running command...
|
|
19
19
|
$ contrail (--version)
|
|
20
|
-
@contrail/cli/3.5.5-alpha.
|
|
20
|
+
@contrail/cli/3.5.5-alpha.cb68c04 linux-x64 node-v24.21.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
package/dist/auth/login.d.ts
CHANGED
package/dist/auth/login.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getVersionFromPackageJson = exports.authUser = void 0;
|
|
3
|
+
exports.parseNetworkFailureReason = exports.getVersionFromPackageJson = exports.authUser = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const amazon_cognito_identity_js_1 = require("amazon-cognito-identity-js");
|
|
6
6
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
@@ -15,6 +15,20 @@ const CONFIGURATION = {
|
|
|
15
15
|
apiGateway: 'https://api.vibeiq.com/prod/api',
|
|
16
16
|
};
|
|
17
17
|
async function authUser() {
|
|
18
|
+
try {
|
|
19
|
+
return await resolveAuthContext();
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
const reason = parseNetworkFailureReason(e);
|
|
23
|
+
if (!reason) {
|
|
24
|
+
throw e;
|
|
25
|
+
}
|
|
26
|
+
logger_1.default.error(`Could not reach the VibeIQ API: ${reason}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.authUser = authUser;
|
|
31
|
+
async function resolveAuthContext() {
|
|
18
32
|
logger_1.default.debug('authorizing user...');
|
|
19
33
|
const config = await (0, config_1.getConfig)();
|
|
20
34
|
if (process.env.CONTRAIL_CLI_API_KEY) {
|
|
@@ -40,16 +54,14 @@ async function authUser() {
|
|
|
40
54
|
return await refreshCurrentUserOrg();
|
|
41
55
|
}
|
|
42
56
|
catch (e) {
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
process.exit(1);
|
|
57
|
+
if (parseNetworkFailureReason(e)) {
|
|
58
|
+
throw e;
|
|
46
59
|
}
|
|
47
60
|
logger_1.default.info('Token expired. Requesting auth credentials...');
|
|
48
61
|
}
|
|
49
62
|
}
|
|
50
63
|
return await authenticateWithUsernamePassword(config);
|
|
51
64
|
}
|
|
52
|
-
exports.authUser = authUser;
|
|
53
65
|
async function getOrgSlug(config) {
|
|
54
66
|
const orgSlug = config?.orgSlug || process.env.CONTRAIL_CLI_ORG_SLUG;
|
|
55
67
|
if (!orgSlug) {
|
|
@@ -215,7 +227,11 @@ async function returnAndStoreConfig(config) {
|
|
|
215
227
|
await (0, config_1.storeConfig)(configCopy);
|
|
216
228
|
return configCopy;
|
|
217
229
|
}
|
|
218
|
-
function
|
|
230
|
+
function parseNetworkFailureReason(e) {
|
|
219
231
|
const cause = e?.cause;
|
|
220
|
-
|
|
232
|
+
if (!cause) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
return cause.code ? `${cause.code}: ${cause.message}` : cause.message;
|
|
221
236
|
}
|
|
237
|
+
exports.parseNetworkFailureReason = parseNetworkFailureReason;
|
package/dist/auth/login.spec.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const login_1 = require("./login");
|
|
4
|
+
describe('parseNetworkFailureReason', () => {
|
|
5
|
+
it('reports the cause behind a fetch failure', () => {
|
|
6
|
+
const e = Object.assign(new TypeError('fetch failed'), {
|
|
7
|
+
cause: Object.assign(new Error('unable to get local issuer certificate'), {
|
|
8
|
+
code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
|
|
9
|
+
}),
|
|
10
|
+
});
|
|
11
|
+
expect((0, login_1.parseNetworkFailureReason)(e)).toBe('UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate');
|
|
12
|
+
});
|
|
13
|
+
it('falls back to the message when the cause carries no code', () => {
|
|
14
|
+
const e = Object.assign(new TypeError('fetch failed'), { cause: new Error('bad port') });
|
|
15
|
+
expect((0, login_1.parseNetworkFailureReason)(e)).toBe('bad port');
|
|
16
|
+
});
|
|
17
|
+
it('returns null for an API error so the caller still treats it as an expired token', () => {
|
|
18
|
+
expect((0, login_1.parseNetworkFailureReason)(new Error('Token expired'))).toBeNull();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
4
21
|
describe('getVersionFromPackageJson', () => {
|
|
5
22
|
it('should return the version value from package.json', () => {
|
|
6
23
|
const version = (0, login_1.getVersionFromPackageJson)();
|
|
@@ -95,10 +95,6 @@ async function upgradeAndWait(appOrgToUpgrade, versionToUpgrade) {
|
|
|
95
95
|
entityName: 'app-org',
|
|
96
96
|
id: appOrgToUpgrade.id,
|
|
97
97
|
});
|
|
98
|
-
if (appStillUpgrading.status === 'READY' && appStillUpgrading.lastInstallError) {
|
|
99
|
-
logger_1.default.info(`${chalk_1.default.red.bold('APP UPGRADE')} ${appStillUpgrading.lastInstallError}`);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
98
|
if (appStillUpgrading.status === 'READY') {
|
|
103
99
|
logger_1.default.info(`${chalk_1.default.green.bold('APP UPGRADE')} App Upgraded`);
|
|
104
100
|
return;
|
package/dist/interfaces.d.ts
CHANGED
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const get = jest.fn();
|
|
4
|
-
const update = jest.fn();
|
|
5
|
-
const info = jest.fn();
|
|
6
|
-
jest.mock('@contrail/sdk', () => ({
|
|
7
|
-
Auth: jest.fn(),
|
|
8
|
-
Entities: jest.fn(() => ({
|
|
9
|
-
get: (...args) => get(...args),
|
|
10
|
-
update: (...args) => update(...args),
|
|
11
|
-
})),
|
|
12
|
-
}));
|
|
13
|
-
jest.mock('../../common', () => ({ delay: () => Promise.resolve() }));
|
|
14
|
-
jest.mock('../../logger', () => ({ info: (...args) => info(...args) }));
|
|
15
|
-
const upgrade_1 = require("./upgrade");
|
|
16
|
-
describe('upgradeAndWait', () => {
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
get.mockReset();
|
|
19
|
-
update.mockReset().mockResolvedValue({});
|
|
20
|
-
info.mockReset();
|
|
21
|
-
});
|
|
22
|
-
it('should report success once the app is ready', async () => {
|
|
23
|
-
get.mockResolvedValue({ status: 'READY' });
|
|
24
|
-
await (0, upgrade_1.upgradeAndWait)({ id: 'app-org-1' }, 'version-2');
|
|
25
|
-
expect(info).toHaveBeenLastCalledWith(expect.stringContaining('App Upgraded'));
|
|
26
|
-
});
|
|
27
|
-
it('should report why the upgrade was reverted instead of calling it upgraded', async () => {
|
|
28
|
-
get.mockResolvedValue({
|
|
29
|
-
status: 'READY',
|
|
30
|
-
lastInstallError: '1.0.1 could not finish installing (template write failed); reverted to 1.0.0',
|
|
31
|
-
});
|
|
32
|
-
await (0, upgrade_1.upgradeAndWait)({ id: 'app-org-1' }, 'version-2');
|
|
33
|
-
expect(info).toHaveBeenLastCalledWith(expect.stringContaining('reverted to 1.0.0'));
|
|
34
|
-
expect(info).not.toHaveBeenCalledWith(expect.stringContaining('App Upgraded'));
|
|
35
|
-
});
|
|
36
|
-
});
|