@contrail/cli 2.4.0 → 3.0.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/README.md +550 -196
- package/dist/auth/login.d.ts +1 -0
- package/dist/auth/login.js +119 -48
- package/dist/auth/login.spec.d.ts +1 -0
- package/dist/auth/login.spec.js +10 -0
- package/dist/baseFlags.d.ts +10 -0
- package/dist/baseFlags.js +25 -0
- package/dist/basecommand.d.ts +5 -2
- package/dist/basecommand.js +51 -47
- package/dist/commands/app/create.d.ts +2 -2
- package/dist/commands/app/create.js +1 -1
- package/dist/commands/app/delete.d.ts +4 -0
- package/dist/commands/app/delete.js +3 -0
- package/dist/commands/app/getApiKey.d.ts +2 -0
- package/dist/commands/app/getApiKey.js +3 -3
- package/dist/commands/app/init.d.ts +5 -1
- package/dist/commands/app/init.js +6 -3
- package/dist/commands/app/install.d.ts +1 -1
- package/dist/commands/app/install.js +10 -11
- package/dist/commands/app/publish.d.ts +2 -0
- package/dist/commands/app/publish.js +3 -3
- package/dist/commands/app/uninstall.d.ts +2 -0
- package/dist/commands/app/uninstall.js +5 -5
- package/dist/commands/app/upgrade.d.ts +2 -0
- package/dist/commands/app/upgrade.js +8 -8
- package/dist/commands/app/version/major.d.ts +4 -0
- package/dist/commands/app/version/major.js +3 -0
- package/dist/commands/app/version/minor.d.ts +4 -0
- package/dist/commands/app/version/minor.js +3 -0
- package/dist/commands/app/version/patch.d.ts +4 -0
- package/dist/commands/app/version/patch.js +3 -0
- package/dist/commands/config/create.d.ts +12 -0
- package/dist/commands/config/create.js +27 -0
- package/dist/commands/config/describe.d.ts +14 -0
- package/dist/commands/config/describe.js +46 -0
- package/dist/commands/config/list.d.ts +4 -0
- package/dist/commands/config/list.js +5 -1
- package/dist/commands/config/set.d.ts +3 -2
- package/dist/commands/config/set.js +17 -13
- package/dist/commands/config/use.d.ts +14 -0
- package/dist/commands/config/use.js +47 -0
- package/dist/commands/file/upload.d.ts +15 -0
- package/dist/commands/file/upload.js +69 -0
- package/dist/commands/groups/export.d.ts +2 -0
- package/dist/commands/groups/export.js +2 -2
- package/dist/commands/groups/{upload.d.ts → import.d.ts} +4 -0
- package/dist/commands/groups/{upload.js → import.js} +60 -23
- package/dist/commands/instance/export.d.ts +2 -0
- package/dist/commands/instance/export.js +4 -4
- package/dist/commands/instance/import.d.ts +2 -0
- package/dist/commands/instance/import.js +8 -8
- package/dist/commands/load/colors.d.ts +14 -0
- package/dist/commands/load/colors.js +53 -0
- package/dist/commands/load/custom-entity.d.ts +14 -0
- package/dist/commands/load/custom-entity.js +55 -0
- package/dist/commands/load/line-sheet.d.ts +14 -0
- package/dist/commands/load/line-sheet.js +55 -0
- package/dist/commands/{loader-process → load}/upload-and-load.d.ts +4 -0
- package/dist/commands/{loader-process → load}/upload-and-load.js +6 -4
- package/dist/commands/projects/export.d.ts +4 -1
- package/dist/commands/projects/export.js +4 -3
- package/dist/commands/projects/list.d.ts +4 -0
- package/dist/commands/projects/list.js +3 -0
- package/dist/commands/projects/load.d.ts +4 -0
- package/dist/commands/projects/load.js +5 -3
- package/dist/commands/types/exportOptionSetHierarchies.d.ts +4 -0
- package/dist/commands/types/exportOptionSetHierarchies.js +3 -0
- package/dist/commands/types/getAll.d.ts +9 -27
- package/dist/commands/types/getAll.js +6 -313
- package/dist/commands/types/getOptionSets.d.ts +16 -0
- package/dist/commands/types/getOptionSets.js +171 -0
- package/dist/commands/types/loadAll.d.ts +2 -0
- package/dist/commands/types/loadAll.js +2 -2
- package/dist/commands/types/mergeOptionSets.d.ts +4 -0
- package/dist/commands/types/mergeOptionSets.js +5 -3
- package/dist/commands/types/mergeTypeProperties.d.ts +4 -0
- package/dist/commands/types/mergeTypeProperties.js +11 -9
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +4 -0
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.js +4 -2
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.d.ts +4 -0
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.js +4 -2
- package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +2 -0
- package/dist/commands/types/parseOptionSetsLocalFiles.js +4 -4
- package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +4 -0
- package/dist/commands/types/parseOptionSetsToFolderStructure.js +6 -4
- package/dist/commands/types/parseTypesFromFiles.d.ts +4 -0
- package/dist/commands/types/parseTypesFromFiles.js +4 -2
- package/dist/commands/types/parseTypesFromLocalFiles.d.ts +4 -0
- package/dist/commands/types/parseTypesFromLocalFiles.js +4 -2
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +4 -0
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.js +5 -3
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +4 -0
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.js +5 -3
- package/dist/commands/types/uploadOptionSetHierarchies.d.ts +2 -0
- package/dist/commands/types/uploadOptionSetHierarchies.js +2 -2
- package/dist/commands/types/uploadOptionSets.d.ts +2 -0
- package/dist/commands/types/uploadOptionSets.js +2 -2
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +4 -0
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.js +4 -2
- package/dist/commands/types/uploadRuleSets.d.ts +2 -0
- package/dist/commands/types/uploadRuleSets.js +2 -2
- package/dist/commands/types/uploadTypePolicies.d.ts +2 -0
- package/dist/commands/types/uploadTypePolicies.js +2 -2
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +2 -0
- package/dist/commands/types/uploadTypePropertyPolicies.js +2 -2
- package/dist/commands/types/uploadTypes.d.ts +2 -0
- package/dist/commands/types/uploadTypes.js +2 -2
- package/dist/commands/types/uploadUsageInfo.d.ts +2 -0
- package/dist/commands/types/uploadUsageInfo.js +2 -2
- package/dist/commands/users/export.d.ts +2 -0
- package/dist/commands/users/export.js +2 -2
- package/dist/commands/users/{upload.d.ts → import.d.ts} +4 -0
- package/dist/commands/users/{upload.js → import.js} +4 -2
- package/dist/commands/webhooks/create.d.ts +2 -0
- package/dist/commands/webhooks/create.js +2 -2
- package/dist/commands/webhooks/delete.d.ts +2 -0
- package/dist/commands/webhooks/delete.js +5 -5
- package/dist/commands/webhooks/getWebhookTrigger.d.ts +4 -0
- package/dist/commands/webhooks/getWebhookTrigger.js +6 -4
- package/dist/commands/webhooks/list.d.ts +2 -0
- package/dist/commands/webhooks/list.js +2 -2
- package/dist/commands/workflow-template-definitions/install.d.ts +4 -0
- package/dist/commands/workflow-template-definitions/install.js +3 -0
- package/dist/commands/workflow-template-definitions/list.d.ts +4 -0
- package/dist/commands/workflow-template-definitions/list.js +3 -0
- package/dist/commands/workflow-templates/delete.d.ts +4 -0
- package/dist/commands/workflow-templates/delete.js +3 -0
- package/dist/commands/workflow-templates/export.d.ts +2 -0
- package/dist/commands/workflow-templates/export.js +4 -2
- package/dist/commands/workflow-templates/list.d.ts +4 -0
- package/dist/commands/workflow-templates/list.js +3 -0
- package/dist/commands/workflow-templates/load.d.ts +4 -0
- package/dist/commands/workflow-templates/load.js +4 -2
- package/dist/helpers/app/app-template-parsers.d.ts +1 -1
- package/dist/helpers/app/app-template-parsers.js +3 -4
- package/dist/helpers/config/config.d.ts +12 -2
- package/dist/helpers/config/config.js +158 -16
- package/dist/helpers/file-helpers.d.ts +1 -0
- package/dist/helpers/file-helpers.js +11 -1
- package/dist/helpers/load/helpers.d.ts +20 -0
- package/dist/helpers/load/helpers.js +141 -0
- package/dist/helpers/load/helpers.spec.d.ts +1 -0
- package/dist/helpers/load/helpers.spec.js +62 -0
- package/dist/helpers/load/validators.d.ts +14 -0
- package/dist/helpers/load/validators.js +182 -0
- package/dist/helpers/load/validators.spec.d.ts +1 -0
- package/dist/helpers/load/validators.spec.js +450 -0
- package/dist/helpers/types/type-uploader.js +11 -3
- package/dist/helpers/workflow-template-definitions/workflow-template-definition-deployer.js +1 -1
- package/dist/helpers/workflow-templates/helper.js +0 -4
- package/dist/interfaces.d.ts +1 -0
- package/dist/templates/typescript/app.yml +17 -19
- package/dist/templates/typescript/package.json +14 -0
- package/dist/templates/typescript/src/actions/logItem.ts +1 -2
- package/oclif.manifest.json +1955 -250
- package/package.json +4 -2
- package/dist/commands/colors/deleteAll.d.ts +0 -6
- package/dist/commands/colors/deleteAll.js +0 -31
- package/dist/commands/colors/load.d.ts +0 -6
- package/dist/commands/colors/load.js +0 -30
- package/dist/commands/config/environments/list.d.ts +0 -7
- package/dist/commands/config/environments/list.js +0 -19
- package/dist/commands/config/environments/remove.d.ts +0 -12
- package/dist/commands/config/environments/remove.js +0 -36
- package/dist/commands/config/environments/set.d.ts +0 -12
- package/dist/commands/config/environments/set.js +0 -29
- package/dist/commands/config/remove.d.ts +0 -15
- package/dist/commands/config/remove.js +0 -28
- package/dist/commands/loader-process/load.d.ts +0 -9
- package/dist/commands/loader-process/load.js +0 -39
- package/dist/helpers/loader-process/helpers.d.ts +0 -2
- package/dist/helpers/loader-process/helpers.js +0 -99
package/dist/auth/login.d.ts
CHANGED
package/dist/auth/login.js
CHANGED
|
@@ -1,27 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.authUser = void 0;
|
|
3
|
+
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"));
|
|
7
7
|
const sdk_1 = require("@contrail/sdk");
|
|
8
8
|
const config_1 = require("../helpers/config/config");
|
|
9
9
|
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
10
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
10
12
|
const CONFIGURATION = {
|
|
11
13
|
userPoolId: 'us-east-1_qIaNZdUfm',
|
|
12
14
|
clientId: process.env.CONTRAIL_COGNITO_CLIENT_ID || '7knkt34gfacbgd0ghnuspefdfg',
|
|
15
|
+
apiGateway: 'https://api.vibeiq.com/prod/api',
|
|
13
16
|
};
|
|
14
17
|
async function authUser() {
|
|
15
18
|
logger_1.default.debug('authorizing user...');
|
|
16
19
|
const config = await (0, config_1.getConfig)();
|
|
17
|
-
if (
|
|
20
|
+
if (process.env.CONTRAIL_CLI_API_KEY) {
|
|
21
|
+
const apiKey = process.env.CONTRAIL_CLI_API_KEY;
|
|
22
|
+
const orgSlug = await getOrgSlug(config);
|
|
23
|
+
logger_1.default.debug('Using API key for authentication...');
|
|
24
|
+
return await authenticateWithApiKey(config, apiKey, orgSlug);
|
|
25
|
+
}
|
|
26
|
+
if (config &&
|
|
27
|
+
config.apiUserToken &&
|
|
28
|
+
config.apiRefreshToken &&
|
|
29
|
+
config.apiGateway &&
|
|
30
|
+
config.orgSlug) {
|
|
18
31
|
logger_1.default.debug('populating auth config from fs config...');
|
|
19
|
-
|
|
32
|
+
sdk_1.Auth.config = {
|
|
20
33
|
apiUserToken: config.apiUserToken,
|
|
34
|
+
apiRefreshToken: config.apiRefreshToken,
|
|
21
35
|
apiGateway: config.apiGateway,
|
|
22
36
|
orgSlug: config.orgSlug,
|
|
23
37
|
};
|
|
24
|
-
(0, sdk_1.setConfig)(
|
|
38
|
+
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
25
39
|
try {
|
|
26
40
|
return await refreshCurrentUserOrg();
|
|
27
41
|
}
|
|
@@ -29,6 +43,37 @@ async function authUser() {
|
|
|
29
43
|
logger_1.default.info('Token expired. Requesting auth credentials...');
|
|
30
44
|
}
|
|
31
45
|
}
|
|
46
|
+
return await authenticateWithUsernamePassword(config);
|
|
47
|
+
}
|
|
48
|
+
exports.authUser = authUser;
|
|
49
|
+
async function getOrgSlug(config) {
|
|
50
|
+
const orgSlug = config?.orgSlug || process.env.CONTRAIL_CLI_ORG_SLUG;
|
|
51
|
+
if (!orgSlug) {
|
|
52
|
+
const answers = await inquirer_1.default.prompt([
|
|
53
|
+
{
|
|
54
|
+
type: 'input',
|
|
55
|
+
name: 'orgSlug',
|
|
56
|
+
validate: (val) => !!val,
|
|
57
|
+
message: 'Org (slug)',
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
return answers.orgSlug;
|
|
61
|
+
}
|
|
62
|
+
return orgSlug;
|
|
63
|
+
}
|
|
64
|
+
async function authenticateWithApiKey(config, apiKey, orgSlug) {
|
|
65
|
+
const apiGateway = config?.apiGateway ?? CONFIGURATION.apiGateway;
|
|
66
|
+
sdk_1.Auth.config = {
|
|
67
|
+
apiUserToken: apiKey,
|
|
68
|
+
apiRefreshToken: null,
|
|
69
|
+
apiGateway,
|
|
70
|
+
orgSlug,
|
|
71
|
+
};
|
|
72
|
+
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
73
|
+
await (0, sdk_1.getCurrentUser)();
|
|
74
|
+
return returnAndStoreConfig(sdk_1.Auth.config);
|
|
75
|
+
}
|
|
76
|
+
async function authenticateWithUsernamePassword(config) {
|
|
32
77
|
const questions = [];
|
|
33
78
|
if (!process.env.CONTRAIL_CLI_EMAIL) {
|
|
34
79
|
questions.push({
|
|
@@ -46,19 +91,12 @@ async function authUser() {
|
|
|
46
91
|
message: 'Password',
|
|
47
92
|
});
|
|
48
93
|
}
|
|
49
|
-
if (!process.env.CONTRAIL_CLI_ORGSLUG) {
|
|
50
|
-
questions.push({
|
|
51
|
-
type: 'input',
|
|
52
|
-
name: 'orgSlug',
|
|
53
|
-
validate: (val) => !!val,
|
|
54
|
-
message: 'Org (slug)',
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
94
|
const answers = await inquirer_1.default.prompt(questions);
|
|
58
95
|
const params = {
|
|
59
96
|
email: process.env.CONTRAIL_CLI_EMAIL || answers.email,
|
|
60
97
|
password: process.env.CONTRAIL_CLI_PASSWORD || answers.password,
|
|
61
|
-
orgSlug:
|
|
98
|
+
orgSlug: await getOrgSlug(config),
|
|
99
|
+
...(config?.apiGateway && { apiGateway: config.apiGateway }),
|
|
62
100
|
};
|
|
63
101
|
if (!params.email || !params.password) {
|
|
64
102
|
throw new Error('Email and Password required');
|
|
@@ -91,52 +129,85 @@ async function authUser() {
|
|
|
91
129
|
});
|
|
92
130
|
});
|
|
93
131
|
}
|
|
94
|
-
exports.authUser = authUser;
|
|
95
132
|
async function setAuthContext(user, params) {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
if (config.environments) {
|
|
99
|
-
const questions = [];
|
|
100
|
-
questions.push({
|
|
101
|
-
type: 'list',
|
|
102
|
-
name: 'environment',
|
|
103
|
-
message: 'Which environment would you like to use?',
|
|
104
|
-
choices: Object.keys(config.environments),
|
|
105
|
-
default: Object.keys(config.environments)[0],
|
|
106
|
-
});
|
|
107
|
-
const answers = await inquirer_1.default.prompt(questions);
|
|
108
|
-
apiGateway = config.environments[answers.environment];
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
apiGateway = 'https://api.vibeiq.com/prod/api';
|
|
112
|
-
}
|
|
133
|
+
const apiGateway = params?.apiGateway ?? CONFIGURATION.apiGateway;
|
|
134
|
+
const { vibeAccessToken, vibeRefreshToken } = await getVibeAccessTokenFromCognitoAccessToken(user.idToken.jwtToken, apiGateway);
|
|
113
135
|
// Set Auth Config
|
|
114
|
-
|
|
115
|
-
apiUserToken:
|
|
136
|
+
sdk_1.Auth.config = {
|
|
137
|
+
apiUserToken: vibeAccessToken,
|
|
138
|
+
apiRefreshToken: vibeRefreshToken,
|
|
116
139
|
apiGateway,
|
|
117
140
|
orgSlug: params.orgSlug,
|
|
118
141
|
};
|
|
119
142
|
// SET SDK CONFIG
|
|
120
|
-
(0, sdk_1.setConfig)(
|
|
143
|
+
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
121
144
|
return refreshCurrentUserOrg();
|
|
122
145
|
}
|
|
123
146
|
async function refreshCurrentUserOrg() {
|
|
124
147
|
logger_1.default.debug('refreshing current user org...');
|
|
125
148
|
const currentUser = await (0, sdk_1.getCurrentUser)();
|
|
126
|
-
const sdkConfig = await (0, sdk_1.getConfig)();
|
|
127
149
|
if (!currentUser) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
150
|
+
const config = await (0, config_1.getConfig)();
|
|
151
|
+
try {
|
|
152
|
+
const newVibeAccessToken = await requestRefreshedAccessToken(config.apiRefreshToken, config.apiGateway);
|
|
153
|
+
sdk_1.Auth.config = {
|
|
154
|
+
apiUserToken: newVibeAccessToken,
|
|
155
|
+
apiRefreshToken: config.apiRefreshToken,
|
|
156
|
+
apiGateway: config.apiGateway,
|
|
157
|
+
orgSlug: config.orgSlug,
|
|
158
|
+
};
|
|
159
|
+
console.log('fetched new access token from refresh token', newVibeAccessToken);
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
throw Error('Could not get refresh token');
|
|
163
|
+
}
|
|
133
164
|
}
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
165
|
+
// TODO: To uncomment when telemetry backend is developed.
|
|
166
|
+
// const current_Version = getVersionFromPackageJson();
|
|
167
|
+
// await checkTelemetry(current_Version);
|
|
168
|
+
return returnAndStoreConfig(sdk_1.Auth.config);
|
|
169
|
+
}
|
|
170
|
+
async function getVibeAccessTokenFromCognitoAccessToken(cognitoAccessToken, apiGateway) {
|
|
171
|
+
const url = `${apiGateway}/auth/cognito/`;
|
|
172
|
+
const response = await fetch(url, {
|
|
173
|
+
method: 'POST',
|
|
174
|
+
headers: {
|
|
175
|
+
Accept: 'application/json',
|
|
176
|
+
'Content-Type': 'application/json',
|
|
177
|
+
},
|
|
178
|
+
body: JSON.stringify({ accessToken: cognitoAccessToken }),
|
|
179
|
+
});
|
|
180
|
+
return await response.json().then((data) => {
|
|
181
|
+
return { vibeAccessToken: data.accessToken, vibeRefreshToken: data.refreshToken };
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
async function requestRefreshedAccessToken(vibeRefreshToken, apiGateway) {
|
|
185
|
+
const url = `${apiGateway}/auth/jwt_refresh/`;
|
|
186
|
+
const response = await fetch(url, {
|
|
187
|
+
method: 'POST',
|
|
188
|
+
headers: {
|
|
189
|
+
Accept: 'application/json',
|
|
190
|
+
'Content-Type': 'application/json',
|
|
191
|
+
},
|
|
192
|
+
body: JSON.stringify({ refreshToken: vibeRefreshToken }),
|
|
193
|
+
});
|
|
194
|
+
return await response.json().then((data) => {
|
|
195
|
+
return data.accessToken;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function getVersionFromPackageJson() {
|
|
199
|
+
// Get the path to the package.json file
|
|
200
|
+
const packageJsonPath = path_1.default.resolve(process.cwd(), 'package.json');
|
|
201
|
+
// Read the package.json file
|
|
202
|
+
const packageJsonContent = fs_1.default.readFileSync(packageJsonPath, 'utf8');
|
|
203
|
+
// Parse the package.json content
|
|
204
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
205
|
+
// Return the version value
|
|
206
|
+
return packageJson.version;
|
|
207
|
+
}
|
|
208
|
+
exports.getVersionFromPackageJson = getVersionFromPackageJson;
|
|
209
|
+
async function returnAndStoreConfig(config) {
|
|
210
|
+
const configCopy = Object.assign({}, config);
|
|
211
|
+
await (0, config_1.storeConfig)(configCopy);
|
|
212
|
+
return configCopy;
|
|
142
213
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const login_1 = require("./login");
|
|
4
|
+
describe('getVersionFromPackageJson', () => {
|
|
5
|
+
it('should return the version value from package.json', () => {
|
|
6
|
+
const version = (0, login_1.getVersionFromPackageJson)();
|
|
7
|
+
expect(version).toBeDefined();
|
|
8
|
+
expect(typeof version).toBe('string');
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const LogLevelFlag: {
|
|
2
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
3
|
+
};
|
|
4
|
+
export declare const AlwaysConfirmEnvFlag: {
|
|
5
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
|
+
};
|
|
7
|
+
export declare const baseFlags: {
|
|
8
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.baseFlags = exports.AlwaysConfirmEnvFlag = exports.LogLevelFlag = void 0;
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
exports.LogLevelFlag = {
|
|
6
|
+
logLevel: core_1.Flags.string({
|
|
7
|
+
description: 'The Log Level',
|
|
8
|
+
required: false,
|
|
9
|
+
char: 'l',
|
|
10
|
+
options: ['error', 'warn', 'info', 'debug'],
|
|
11
|
+
}),
|
|
12
|
+
};
|
|
13
|
+
exports.AlwaysConfirmEnvFlag = {
|
|
14
|
+
alwaysConfirmEnv: core_1.Flags.string({
|
|
15
|
+
description: 'The Environment variables',
|
|
16
|
+
required: false,
|
|
17
|
+
char: 'e',
|
|
18
|
+
default: 'true',
|
|
19
|
+
options: ['true', 'false'],
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
exports.baseFlags = {
|
|
23
|
+
...exports.LogLevelFlag,
|
|
24
|
+
...exports.AlwaysConfirmEnvFlag,
|
|
25
|
+
};
|
package/dist/basecommand.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
export declare abstract class BaseCommand extends Command {
|
|
3
3
|
static description: string;
|
|
4
|
+
skipValidateEnv: boolean;
|
|
4
5
|
skipConfirmEnv: boolean;
|
|
5
6
|
static baseFlags: {
|
|
7
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
-
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
9
|
};
|
|
10
|
+
protected flags: any;
|
|
11
|
+
protected args: any;
|
|
9
12
|
init(): Promise<void>;
|
|
10
|
-
setLogLevel(logLevel: string):
|
|
13
|
+
setLogLevel(logLevel: string, config?: any): void;
|
|
11
14
|
private confirmEnv;
|
|
12
15
|
}
|
package/dist/basecommand.js
CHANGED
|
@@ -6,73 +6,77 @@ const core_1 = require("@oclif/core");
|
|
|
6
6
|
const logger_1 = tslib_1.__importDefault(require("./logger"));
|
|
7
7
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
8
|
const config_1 = require("./helpers/config/config");
|
|
9
|
-
const lodash_1 =
|
|
10
|
-
const
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
const login_1 = require("./auth/login");
|
|
11
|
+
const baseFlags_1 = require("./baseFlags");
|
|
11
12
|
class BaseCommand extends core_1.Command {
|
|
12
13
|
static description = 'Global Flags';
|
|
14
|
+
skipValidateEnv = true;
|
|
13
15
|
skipConfirmEnv = false;
|
|
14
16
|
static baseFlags = {
|
|
15
|
-
|
|
16
|
-
description: 'The Log Level',
|
|
17
|
-
required: false,
|
|
18
|
-
char: 'l',
|
|
19
|
-
options: ['error', 'warn', 'info', 'debug'],
|
|
20
|
-
}),
|
|
21
|
-
alwaysConfirmEnv: core_1.Flags.boolean({
|
|
22
|
-
description: 'The Environment variables',
|
|
23
|
-
required: false,
|
|
24
|
-
char: 'e',
|
|
25
|
-
default: true,
|
|
26
|
-
}),
|
|
17
|
+
...baseFlags_1.baseFlags,
|
|
27
18
|
};
|
|
19
|
+
flags;
|
|
20
|
+
args;
|
|
28
21
|
async init() {
|
|
29
22
|
await super.init();
|
|
30
|
-
|
|
23
|
+
if (!this.ctor?.flags)
|
|
24
|
+
this.ctor.flags = {};
|
|
25
|
+
const { args, flags } = await this.parse({
|
|
31
26
|
flags: this.ctor.flags,
|
|
32
27
|
baseFlags: super.ctor.baseFlags,
|
|
33
28
|
args: this.ctor.args,
|
|
34
29
|
strict: this.ctor.strict,
|
|
35
30
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
this.flags = flags;
|
|
32
|
+
this.args = args;
|
|
33
|
+
const config = await (0, config_1.readVibeIQConfig)();
|
|
34
|
+
if (!this.skipValidateEnv) {
|
|
35
|
+
await (0, config_1.validateEnvironments)();
|
|
36
|
+
}
|
|
37
|
+
this.setLogLevel(flags.logLevel, config);
|
|
38
|
+
flags.alwaysConfirmEnv = (flags?.alwaysConfirmEnv === 'false' ? false : true);
|
|
39
|
+
if (!this.skipConfirmEnv && flags.alwaysConfirmEnv) {
|
|
40
|
+
await this.confirmEnv();
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
|
|
43
|
+
setLogLevel(logLevel, config) {
|
|
42
44
|
if (logLevel) {
|
|
43
45
|
logger_1.default.level = logLevel;
|
|
44
46
|
}
|
|
45
|
-
else {
|
|
46
|
-
|
|
47
|
-
if (config.logLevel) {
|
|
48
|
-
logger_1.default.level = config.logLevel;
|
|
49
|
-
}
|
|
47
|
+
else if (config?.logLevel) {
|
|
48
|
+
logger_1.default.level = config.logLevel;
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
|
-
async confirmEnv(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
env = Object.keys(config.environments).find((key) => config.environments[key] === data.apiGateway);
|
|
59
|
-
}
|
|
60
|
-
data.apiGateway = env;
|
|
61
|
-
console.table(data);
|
|
62
|
-
const questions = [];
|
|
63
|
-
questions.push({
|
|
64
|
-
type: 'list',
|
|
65
|
-
name: 'confirm',
|
|
66
|
-
message: 'Please confirm if the provided configuration is correct',
|
|
67
|
-
choices: ['yes', 'no'],
|
|
68
|
-
default: 'no',
|
|
51
|
+
async confirmEnv() {
|
|
52
|
+
let config = await (0, config_1.getConfig)();
|
|
53
|
+
if ((0, lodash_1.keys)(config).length === 0) {
|
|
54
|
+
await (0, login_1.authUser)().catch((e) => {
|
|
55
|
+
console.log(`Error: ${e.message}\n\nCheck if you are using the correct environment configuration and credentials.`);
|
|
56
|
+
this.exit(1);
|
|
69
57
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
config = await (0, config_1.getConfig)();
|
|
59
|
+
}
|
|
60
|
+
const data = (0, lodash_1.pick)(config, ['orgSlug', 'apiGateway']);
|
|
61
|
+
let env = '';
|
|
62
|
+
if (data.apiGateway) {
|
|
63
|
+
env = Object.keys(config_1.ENVIRONMENTS).find((key) => config_1.ENVIRONMENTS[key] === data.apiGateway);
|
|
64
|
+
}
|
|
65
|
+
data.environment = env;
|
|
66
|
+
delete data.apiGateway;
|
|
67
|
+
console.table(data);
|
|
68
|
+
const questions = [];
|
|
69
|
+
questions.push({
|
|
70
|
+
type: 'list',
|
|
71
|
+
name: 'confirm',
|
|
72
|
+
message: 'Please confirm if the provided configuration is correct',
|
|
73
|
+
choices: ['yes', 'no'],
|
|
74
|
+
default: 'no',
|
|
75
|
+
});
|
|
76
|
+
const { confirm } = await inquirer_1.default.prompt(questions);
|
|
77
|
+
if (confirm === 'no') {
|
|
78
|
+
logger_1.default.info('Please use `contrail config use` command to choose the configuration or `contrail config set --environment=prod` to set different environment.');
|
|
79
|
+
this.exit(1);
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
}
|
|
@@ -2,9 +2,9 @@ import { BaseCommand } from '../../basecommand';
|
|
|
2
2
|
export default class CreateApp extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
-
static
|
|
5
|
+
static flags: {
|
|
6
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
-
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
8
|
};
|
|
9
9
|
run(): Promise<void>;
|
|
10
10
|
}
|
|
@@ -3,5 +3,9 @@ export default class DeleteApp extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static strict: boolean;
|
|
6
|
+
static flags: {
|
|
7
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
};
|
|
6
10
|
run(): Promise<void>;
|
|
7
11
|
}
|
|
@@ -4,6 +4,8 @@ export default class GetAPIKeyApp extends BaseCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
appIdentifier: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
9
|
};
|
|
8
10
|
run(): Promise<void>;
|
|
9
11
|
}
|
|
@@ -14,13 +14,13 @@ class GetAPIKeyApp extends basecommand_1.BaseCommand {
|
|
|
14
14
|
`,
|
|
15
15
|
];
|
|
16
16
|
static flags = {
|
|
17
|
+
...basecommand_1.BaseCommand.baseFlags,
|
|
17
18
|
appIdentifier: core_1.Flags.string({ char: 'a', description: 'The app identifier', required: false }),
|
|
18
19
|
};
|
|
19
20
|
async run() {
|
|
20
|
-
const { flags } = await this.parse(GetAPIKeyApp);
|
|
21
21
|
await (0, login_1.authUser)();
|
|
22
22
|
const installedApps = await (0, apps_1.getInstalledApps)();
|
|
23
|
-
if (!flags.appIdentifier) {
|
|
23
|
+
if (!this.flags.appIdentifier) {
|
|
24
24
|
const questions = [
|
|
25
25
|
{
|
|
26
26
|
type: 'list',
|
|
@@ -38,7 +38,7 @@ class GetAPIKeyApp extends basecommand_1.BaseCommand {
|
|
|
38
38
|
logger_1.default.info(`App API key: (app:${answers.appApiKey})`);
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
const appFound = installedApps.find((x) => x.app.identifier === flags.appIdentifier);
|
|
41
|
+
const appFound = installedApps.find((x) => x.app.identifier === this.flags.appIdentifier);
|
|
42
42
|
if (!appFound) {
|
|
43
43
|
logger_1.default.info('You do not have such an app installed');
|
|
44
44
|
return;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { BaseCommand } from '../../basecommand';
|
|
2
|
-
export default class
|
|
2
|
+
export default class InitApp extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
};
|
|
5
9
|
run(): Promise<void>;
|
|
6
10
|
}
|
|
@@ -6,12 +6,15 @@ const login_1 = require("../../auth/login");
|
|
|
6
6
|
const basecommand_1 = require("../../basecommand");
|
|
7
7
|
const setup_template_1 = require("../../helpers/app/setup-template");
|
|
8
8
|
const sdk_1 = require("@contrail/sdk");
|
|
9
|
-
class
|
|
10
|
-
static description = '
|
|
9
|
+
class InitApp extends basecommand_1.BaseCommand {
|
|
10
|
+
static description = 'Initialize an app directory from a template';
|
|
11
11
|
static examples = [
|
|
12
12
|
`$ contrail app init
|
|
13
13
|
`,
|
|
14
14
|
];
|
|
15
|
+
static flags = {
|
|
16
|
+
...basecommand_1.BaseCommand.baseFlags,
|
|
17
|
+
};
|
|
15
18
|
async run() {
|
|
16
19
|
await (0, login_1.authUser)();
|
|
17
20
|
const currentUser = await (0, sdk_1.getCurrentUser)();
|
|
@@ -62,4 +65,4 @@ class CreateApp extends basecommand_1.BaseCommand {
|
|
|
62
65
|
});
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
|
-
exports.default =
|
|
68
|
+
exports.default = InitApp;
|
|
@@ -6,8 +6,8 @@ export default class InstallApp extends BaseCommand {
|
|
|
6
6
|
static flags: {
|
|
7
7
|
appIdentifier: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
8
|
installWorkflowTemplates: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
-
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
11
|
};
|
|
12
12
|
run(): Promise<void>;
|
|
13
13
|
}
|
|
@@ -33,7 +33,6 @@ class InstallApp extends basecommand_1.BaseCommand {
|
|
|
33
33
|
}),
|
|
34
34
|
};
|
|
35
35
|
async run() {
|
|
36
|
-
const { flags } = await this.parse(InstallApp);
|
|
37
36
|
await (0, login_1.authUser)();
|
|
38
37
|
const apps = await (0, apps_1.getAvailableApps)();
|
|
39
38
|
if (!apps.length) {
|
|
@@ -42,7 +41,7 @@ class InstallApp extends basecommand_1.BaseCommand {
|
|
|
42
41
|
const installedApps = await (0, apps_1.getInstalledApps)();
|
|
43
42
|
const installedAppsIds = installedApps.map((x) => x.app.id);
|
|
44
43
|
const installableApps = apps.filter((x) => !installedAppsIds.includes(x.id));
|
|
45
|
-
if (!flags.appIdentifier) {
|
|
44
|
+
if (!this.flags.appIdentifier) {
|
|
46
45
|
logger_1.default.info(chalk_1.default.yellow.bold('Installed Apps:'));
|
|
47
46
|
for (const appOrg of installedApps) {
|
|
48
47
|
logger_1.default.info(chalk_1.default.yellow.bold(`${appOrg.app.name}: ${appOrg.app.identifier}`));
|
|
@@ -55,18 +54,18 @@ class InstallApp extends basecommand_1.BaseCommand {
|
|
|
55
54
|
choices: installableApps.map((x) => x.identifier),
|
|
56
55
|
});
|
|
57
56
|
const answers = await inquirer_1.default.prompt(questions);
|
|
58
|
-
flags.appIdentifier = answers.appIdentifier;
|
|
57
|
+
this.flags.appIdentifier = answers.appIdentifier;
|
|
59
58
|
}
|
|
60
|
-
const app = installableApps.find((x) => x.identifier === flags.appIdentifier);
|
|
59
|
+
const app = installableApps.find((x) => x.identifier === this.flags.appIdentifier);
|
|
61
60
|
if (!app) {
|
|
62
|
-
logger_1.default.error(chalk_1.default.red.bold(`App ${flags.appIdentifier} not found`));
|
|
63
|
-
throw new Error(`App ${flags.appIdentifier} not found`);
|
|
61
|
+
logger_1.default.error(chalk_1.default.red.bold(`App ${this.flags.appIdentifier} not found`));
|
|
62
|
+
throw new Error(`App ${this.flags.appIdentifier} not found`);
|
|
64
63
|
}
|
|
65
64
|
let configProperties;
|
|
66
65
|
if (app.configProperties) {
|
|
67
66
|
configProperties = await getConfigProperties(app);
|
|
68
67
|
}
|
|
69
|
-
logger_1.default.info('%s Installing
|
|
68
|
+
logger_1.default.info('%s Installing app', chalk_1.default.green.bold('APP INSTALLATION'));
|
|
70
69
|
const appOrg = await (0, apps_1.installAppToOrg)(app, configProperties);
|
|
71
70
|
// eslint-disable-next-line no-constant-condition
|
|
72
71
|
while (true) {
|
|
@@ -89,7 +88,7 @@ class InstallApp extends basecommand_1.BaseCommand {
|
|
|
89
88
|
return;
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
|
-
if (!flags.installWorkflowTemplates) {
|
|
91
|
+
if (!this.flags.installWorkflowTemplates) {
|
|
93
92
|
const answers = await inquirer_1.default.prompt([
|
|
94
93
|
{
|
|
95
94
|
type: 'confirm',
|
|
@@ -100,13 +99,13 @@ class InstallApp extends basecommand_1.BaseCommand {
|
|
|
100
99
|
]);
|
|
101
100
|
if (!answers.shouldInstallWorkflows) {
|
|
102
101
|
logger_1.default.info('%s Not installing associated app workflows', chalk_1.default.yellow.bold('APP INSTALLATION'));
|
|
103
|
-
flags.installWorkflowTemplates = false;
|
|
102
|
+
this.flags.installWorkflowTemplates = false;
|
|
104
103
|
}
|
|
105
104
|
else {
|
|
106
|
-
flags.installWorkflowTemplates = true;
|
|
105
|
+
this.flags.installWorkflowTemplates = true;
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
|
-
if (flags.installWorkflowTemplates) {
|
|
108
|
+
if (this.flags.installWorkflowTemplates) {
|
|
110
109
|
const workflowTemplateDefinitions = await (0, apps_1.getWorkflowTemplateDefinitionsForAppVersion)({
|
|
111
110
|
appVersionId: appOrg.appVersionId,
|
|
112
111
|
});
|
|
@@ -7,6 +7,8 @@ export default class PublishApp extends BaseCommand {
|
|
|
7
7
|
upgrade: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
8
|
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
9
|
dryRun: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
12
|
};
|
|
11
13
|
run(): Promise<void>;
|
|
12
14
|
}
|