@contrail/cli 2.0.1 → 2.0.2
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 +24 -2
- package/dist/commands/app/getApiKey.d.ts +9 -0
- package/dist/commands/app/getApiKey.js +45 -0
- package/dist/commands/app/publish.d.ts +3 -0
- package/dist/commands/app/publish.js +17 -8
- package/dist/commands/app/upgrade.d.ts +1 -0
- package/dist/commands/app/upgrade.js +21 -16
- package/dist/helpers/app/app-deployer.d.ts +1 -1
- package/dist/helpers/app/app-deployer.js +1 -0
- package/dist/helpers/app/load-app-config.js +2 -2
- package/dist/interfaces.d.ts +1 -0
- package/oclif.manifest.json +33 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ $ npm install -g @contrail/cli
|
|
|
14
14
|
$ contrail-cli COMMAND
|
|
15
15
|
running command...
|
|
16
16
|
$ contrail-cli (--version)
|
|
17
|
-
@contrail/cli/2.0.
|
|
17
|
+
@contrail/cli/2.0.2 darwin-arm64 node-v18.13.0
|
|
18
18
|
$ contrail-cli --help [COMMAND]
|
|
19
19
|
USAGE
|
|
20
20
|
$ contrail-cli COMMAND
|
|
@@ -25,6 +25,7 @@ USAGE
|
|
|
25
25
|
<!-- commands -->
|
|
26
26
|
* [`contrail-cli app create`](#contrail-cli-app-create)
|
|
27
27
|
* [`contrail-cli app delete`](#contrail-cli-app-delete)
|
|
28
|
+
* [`contrail-cli app getApiKey`](#contrail-cli-app-getapikey)
|
|
28
29
|
* [`contrail-cli app install`](#contrail-cli-app-install)
|
|
29
30
|
* [`contrail-cli app publish`](#contrail-cli-app-publish)
|
|
30
31
|
* [`contrail-cli app uninstall`](#contrail-cli-app-uninstall)
|
|
@@ -105,6 +106,24 @@ EXAMPLES
|
|
|
105
106
|
$ contrail app delete
|
|
106
107
|
```
|
|
107
108
|
|
|
109
|
+
## `contrail-cli app getApiKey`
|
|
110
|
+
|
|
111
|
+
Get an api key for an app
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
USAGE
|
|
115
|
+
$ contrail-cli app getApiKey [--appIdentifier <value>]
|
|
116
|
+
|
|
117
|
+
FLAGS
|
|
118
|
+
--appIdentifier=<value> The app identifier
|
|
119
|
+
|
|
120
|
+
DESCRIPTION
|
|
121
|
+
Get an api key for an app
|
|
122
|
+
|
|
123
|
+
EXAMPLES
|
|
124
|
+
$ contrail app getApiKey
|
|
125
|
+
```
|
|
126
|
+
|
|
108
127
|
## `contrail-cli app install`
|
|
109
128
|
|
|
110
129
|
Install an app from the marketplace
|
|
@@ -130,7 +149,10 @@ Publish the app
|
|
|
130
149
|
|
|
131
150
|
```
|
|
132
151
|
USAGE
|
|
133
|
-
$ contrail-cli app publish
|
|
152
|
+
$ contrail-cli app publish [-u]
|
|
153
|
+
|
|
154
|
+
FLAGS
|
|
155
|
+
-u, --upgrade In addition to deploying, upgrade the installed version of the app in this org to the latest one.
|
|
134
156
|
|
|
135
157
|
DESCRIPTION
|
|
136
158
|
Publish the app
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class GetAPIKeyApp extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
appIdentifier: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const apps_1 = require("../../api/apps");
|
|
6
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
|
+
const login_1 = require("../../auth/login");
|
|
8
|
+
class GetAPIKeyApp extends core_1.Command {
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags } = await this.parse(GetAPIKeyApp);
|
|
11
|
+
await (0, login_1.authUser)();
|
|
12
|
+
const installedApps = await (0, apps_1.getInstalledApps)();
|
|
13
|
+
if (!flags.appIdentifier) {
|
|
14
|
+
const questions = [{
|
|
15
|
+
type: 'list',
|
|
16
|
+
name: 'appApiKey',
|
|
17
|
+
message: 'For which app would you like to retrieve the API key?',
|
|
18
|
+
choices: installedApps.map(x => {
|
|
19
|
+
return {
|
|
20
|
+
name: x.app.name, value: x.apiKey.apiKey
|
|
21
|
+
};
|
|
22
|
+
})
|
|
23
|
+
}];
|
|
24
|
+
const answers = await inquirer_1.default.prompt(questions);
|
|
25
|
+
console.log(`App API key: ${answers.appApiKey}`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const appFound = installedApps.find(x => x.app.identifier === flags.appIdentifier);
|
|
29
|
+
if (!appFound) {
|
|
30
|
+
console.log('You do not have such an app installed');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
console.log(`App API key: ${appFound.apiKey.apiKey}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.default = GetAPIKeyApp;
|
|
38
|
+
GetAPIKeyApp.description = 'Get an api key for an app';
|
|
39
|
+
GetAPIKeyApp.examples = [
|
|
40
|
+
`$ contrail app getApiKey
|
|
41
|
+
`,
|
|
42
|
+
];
|
|
43
|
+
GetAPIKeyApp.flags = {
|
|
44
|
+
appIdentifier: core_1.Flags.string({ description: 'The app identifier', required: false })
|
|
45
|
+
};
|
|
@@ -6,15 +6,11 @@ const login_1 = require("../../auth/login");
|
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
7
7
|
const load_app_config_1 = require("../../helpers/app/load-app-config");
|
|
8
8
|
const app_deployer_1 = require("../../helpers/app/app-deployer");
|
|
9
|
+
const apps_1 = require("../../api/apps");
|
|
10
|
+
const upgrade_1 = require("./upgrade");
|
|
9
11
|
class PublishApp extends core_1.Command {
|
|
10
|
-
// static flags = {
|
|
11
|
-
// list: Flags.string({char: 'f', description: 'Who is saying hello', required: true}),
|
|
12
|
-
// }
|
|
13
|
-
// static args = {
|
|
14
|
-
// AppName: Args.string({description: 'The app name', required: true}),
|
|
15
|
-
// }
|
|
16
12
|
async run() {
|
|
17
|
-
|
|
13
|
+
const { flags } = await this.parse(PublishApp);
|
|
18
14
|
let appDeclaration;
|
|
19
15
|
try {
|
|
20
16
|
appDeclaration = (0, load_app_config_1.loadAppConfig)();
|
|
@@ -26,7 +22,17 @@ class PublishApp extends core_1.Command {
|
|
|
26
22
|
console.log(`%s Deploying Application. ${appDeclaration.appIdentifier}`, chalk_1.default.blue.bold('START'));
|
|
27
23
|
try {
|
|
28
24
|
await (0, login_1.authUser)();
|
|
29
|
-
await new app_deployer_1.AppDeployer().deploy(appDeclaration);
|
|
25
|
+
const app = await new app_deployer_1.AppDeployer().deploy(appDeclaration);
|
|
26
|
+
if (flags.upgrade) {
|
|
27
|
+
const installedApps = await (0, apps_1.getInstalledApps)();
|
|
28
|
+
const installedAppOrg = installedApps.find(x => x.appId === app.id);
|
|
29
|
+
if (!installedAppOrg) {
|
|
30
|
+
console.log('The app you published is not installed in your org');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
await (0, upgrade_1.upgradeAndWait)(installedAppOrg, app.latestAppVersionId);
|
|
34
|
+
console.log('%s App upgraded.', chalk_1.default.green.bold('UPGRADED'));
|
|
35
|
+
}
|
|
30
36
|
}
|
|
31
37
|
catch (e) {
|
|
32
38
|
console.log(`%s Application Deployment Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
@@ -43,3 +49,6 @@ PublishApp.examples = [
|
|
|
43
49
|
];
|
|
44
50
|
// variable argument length
|
|
45
51
|
PublishApp.strict = true;
|
|
52
|
+
PublishApp.flags = {
|
|
53
|
+
upgrade: core_1.Flags.boolean({ char: 'u', description: 'In addition to deploying, upgrade the installed version of the app in this org to the latest one.', required: false }),
|
|
54
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upgradeAndWait = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
5
6
|
const login_1 = require("../../auth/login");
|
|
@@ -9,7 +10,7 @@ const sdk_1 = require("@contrail/sdk");
|
|
|
9
10
|
const apps_1 = require("../../api/apps");
|
|
10
11
|
class UpgradeApp extends core_1.Command {
|
|
11
12
|
async run() {
|
|
12
|
-
const {
|
|
13
|
+
const { flags } = await this.parse(UpgradeApp);
|
|
13
14
|
await (0, login_1.authUser)();
|
|
14
15
|
const allApps = await (0, apps_1.getAvailableApps)();
|
|
15
16
|
const installedApps = await (0, apps_1.getInstalledApps)();
|
|
@@ -45,21 +46,7 @@ class UpgradeApp extends core_1.Command {
|
|
|
45
46
|
versionToUpgrade = answers.appVersion;
|
|
46
47
|
}
|
|
47
48
|
this.log(`%s Upgrading app to version ${versionToUpgrade}`, chalk_1.default.green.bold('APP UPGRADE'));
|
|
48
|
-
await (
|
|
49
|
-
// eslint-disable-next-line no-constant-condition
|
|
50
|
-
while (true) {
|
|
51
|
-
await delay(1000);
|
|
52
|
-
const appStillUpgrading = await new sdk_1.Entities().get({ entityName: 'app-org', id: appOrgToUpgrade.id });
|
|
53
|
-
if (appStillUpgrading.status === 'READY') {
|
|
54
|
-
this.log('%s App Upgraded', chalk_1.default.green.bold('APP UPGRADE'));
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (appStillUpgrading.status === 'FAILED_INSTALLING') {
|
|
58
|
-
this.log('%s App Upgrade FAILED!', chalk_1.default.red.bold('APP UPGRADE'));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.log('checking app status...');
|
|
62
|
-
}
|
|
49
|
+
await upgradeAndWait(appOrgToUpgrade, versionToUpgrade);
|
|
63
50
|
}
|
|
64
51
|
}
|
|
65
52
|
exports.default = UpgradeApp;
|
|
@@ -74,6 +61,24 @@ UpgradeApp.flags = {
|
|
|
74
61
|
appIdentifier: core_1.Flags.string({ char: 'i', description: 'The appIdentifier of the app to install', required: false }),
|
|
75
62
|
latest: core_1.Flags.boolean({ char: 'l', description: 'Upgrade to the latest version of the app', required: false })
|
|
76
63
|
};
|
|
64
|
+
async function upgradeAndWait(appOrgToUpgrade, versionToUpgrade) {
|
|
65
|
+
await (0, apps_1.upgradeAppVersion)(appOrgToUpgrade, versionToUpgrade);
|
|
66
|
+
// eslint-disable-next-line no-constant-condition
|
|
67
|
+
while (true) {
|
|
68
|
+
await delay(1000);
|
|
69
|
+
const appStillUpgrading = await new sdk_1.Entities().get({ entityName: 'app-org', id: appOrgToUpgrade.id });
|
|
70
|
+
if (appStillUpgrading.status === 'READY') {
|
|
71
|
+
console.log('%s App Upgraded', chalk_1.default.green.bold('APP UPGRADE'));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (appStillUpgrading.status === 'FAILED_INSTALLING') {
|
|
75
|
+
console.log('%s App Upgrade FAILED!', chalk_1.default.red.bold('APP UPGRADE'));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
console.log('checking app status...');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.upgradeAndWait = upgradeAndWait;
|
|
77
82
|
function delay(ms) {
|
|
78
83
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
79
84
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { App, AppDeclaration } from '../../interfaces';
|
|
2
2
|
export declare class AppDeployer {
|
|
3
|
-
deploy(appDeclaration: AppDeclaration): Promise<
|
|
3
|
+
deploy(appDeclaration: AppDeclaration): Promise<App>;
|
|
4
4
|
getExistingApp(appDeclaration: AppDeclaration): Promise<App>;
|
|
5
5
|
private createNewApp;
|
|
6
6
|
updateExistingApp(appDeclaration: AppDeclaration, existingApp: any): Promise<any>;
|
|
@@ -22,6 +22,7 @@ class AppDeployer {
|
|
|
22
22
|
}
|
|
23
23
|
await new actions_deployer_1.ActionsDeployer().deployActions(appDeclaration, app);
|
|
24
24
|
await new workflow_template_definition_deployer_1.WorkflowTemplateDefinitionDeployer().deployWorkflowTemplateDefinitions(appDeclaration, app);
|
|
25
|
+
return app;
|
|
25
26
|
}
|
|
26
27
|
async getExistingApp(appDeclaration) {
|
|
27
28
|
const orgId = auth_1.Auth.config.orgId;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadAppConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
7
|
const yaml = require('js-yaml');
|
|
7
8
|
function loadAppConfig() {
|
|
8
9
|
const TARGET_DIR = process.cwd();
|
|
9
10
|
try {
|
|
10
|
-
const doc = yaml.load(path.join(TARGET_DIR, 'app.yml'), 'utf8');
|
|
11
|
-
console.log(doc);
|
|
11
|
+
const doc = yaml.load(fs_1.default.readFileSync(path.resolve(path.join(TARGET_DIR, 'app.yml')), 'utf8'));
|
|
12
12
|
return doc;
|
|
13
13
|
}
|
|
14
14
|
catch (e) {
|
package/dist/interfaces.d.ts
CHANGED
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.
|
|
2
|
+
"version": "2.0.2",
|
|
3
3
|
"commands": {
|
|
4
4
|
"app:create": {
|
|
5
5
|
"id": "app:create",
|
|
@@ -29,6 +29,28 @@
|
|
|
29
29
|
"flags": {},
|
|
30
30
|
"args": {}
|
|
31
31
|
},
|
|
32
|
+
"app:getApiKey": {
|
|
33
|
+
"id": "app:getApiKey",
|
|
34
|
+
"description": "Get an api key for an app",
|
|
35
|
+
"strict": true,
|
|
36
|
+
"pluginName": "@contrail/cli",
|
|
37
|
+
"pluginAlias": "@contrail/cli",
|
|
38
|
+
"pluginType": "core",
|
|
39
|
+
"aliases": [],
|
|
40
|
+
"examples": [
|
|
41
|
+
"$ contrail app getApiKey\n"
|
|
42
|
+
],
|
|
43
|
+
"flags": {
|
|
44
|
+
"appIdentifier": {
|
|
45
|
+
"name": "appIdentifier",
|
|
46
|
+
"type": "option",
|
|
47
|
+
"description": "The app identifier",
|
|
48
|
+
"required": false,
|
|
49
|
+
"multiple": false
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"args": {}
|
|
53
|
+
},
|
|
32
54
|
"app:install": {
|
|
33
55
|
"id": "app:install",
|
|
34
56
|
"description": "Install an app from the marketplace",
|
|
@@ -71,7 +93,16 @@
|
|
|
71
93
|
"examples": [
|
|
72
94
|
"$ contrail app publish\n"
|
|
73
95
|
],
|
|
74
|
-
"flags": {
|
|
96
|
+
"flags": {
|
|
97
|
+
"upgrade": {
|
|
98
|
+
"name": "upgrade",
|
|
99
|
+
"type": "boolean",
|
|
100
|
+
"char": "u",
|
|
101
|
+
"description": "In addition to deploying, upgrade the installed version of the app in this org to the latest one.",
|
|
102
|
+
"required": false,
|
|
103
|
+
"allowNo": false
|
|
104
|
+
}
|
|
105
|
+
},
|
|
75
106
|
"args": {}
|
|
76
107
|
},
|
|
77
108
|
"app:uninstall": {
|