@contrail/cli 2.1.20 → 2.1.22
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 +311 -105
- package/dist/api/apps.js +15 -15
- package/dist/api/event-workflow-action-definition.d.ts +1 -1
- package/dist/api/event-workflow-action-definition.js +1 -1
- package/dist/api/event-workflow-template-definition.d.ts +4 -3
- package/dist/api/event-workflow-templates.d.ts +5 -4
- package/dist/api/event-workflow-templates.js +2 -2
- package/dist/api/types.d.ts +10 -10
- package/dist/api/users.js +4 -2
- package/dist/auth/login.js +12 -14
- package/dist/commands/app/create.d.ts +2 -2
- package/dist/commands/app/create.js +15 -10
- package/dist/commands/app/delete.d.ts +2 -2
- package/dist/commands/app/delete.js +4 -2
- package/dist/commands/app/getApiKey.d.ts +2 -2
- package/dist/commands/app/getApiKey.js +17 -11
- package/dist/commands/app/install.d.ts +2 -2
- package/dist/commands/app/install.js +42 -25
- package/dist/commands/app/publish.d.ts +2 -2
- package/dist/commands/app/publish.js +26 -11
- package/dist/commands/app/uninstall.d.ts +2 -2
- package/dist/commands/app/uninstall.js +20 -11
- package/dist/commands/app/upgrade.d.ts +2 -2
- package/dist/commands/app/upgrade.js +46 -23
- package/dist/commands/basecommand.d.ts +7 -0
- package/dist/commands/basecommand.js +29 -0
- package/dist/commands/colors/deleteAll.d.ts +2 -2
- package/dist/commands/colors/deleteAll.js +8 -5
- package/dist/commands/colors/load.d.ts +2 -2
- package/dist/commands/colors/load.js +10 -7
- package/dist/commands/config/list.d.ts +2 -2
- package/dist/commands/config/list.js +4 -2
- package/dist/commands/config/remove.d.ts +2 -2
- package/dist/commands/config/remove.js +4 -2
- package/dist/commands/config/set.d.ts +3 -2
- package/dist/commands/config/set.js +21 -7
- package/dist/commands/groups/export.d.ts +2 -2
- package/dist/commands/groups/export.js +20 -8
- package/dist/commands/groups/upload.d.ts +3 -3
- package/dist/commands/groups/upload.js +44 -32
- package/dist/commands/instance/export.d.ts +2 -2
- package/dist/commands/instance/export.js +15 -3
- package/dist/commands/instance/import.d.ts +2 -2
- package/dist/commands/instance/import.js +9 -2
- package/dist/commands/loader-process/load.d.ts +2 -2
- package/dist/commands/loader-process/load.js +13 -6
- package/dist/commands/loader-process/upload-and-load.d.ts +2 -2
- package/dist/commands/loader-process/upload-and-load.js +18 -7
- package/dist/commands/projects/export.d.ts +2 -2
- package/dist/commands/projects/export.js +4 -2
- package/dist/commands/projects/list.d.ts +2 -2
- package/dist/commands/projects/list.js +6 -4
- package/dist/commands/projects/load.d.ts +2 -2
- package/dist/commands/projects/load.js +16 -8
- package/dist/commands/types/exportOptionSetHierarchies.d.ts +2 -2
- package/dist/commands/types/exportOptionSetHierarchies.js +15 -12
- package/dist/commands/types/getAll.d.ts +2 -2
- package/dist/commands/types/getAll.js +107 -76
- package/dist/commands/types/loadAll.d.ts +2 -2
- package/dist/commands/types/loadAll.js +12 -4
- package/dist/commands/types/mergeOptionSets.d.ts +2 -2
- package/dist/commands/types/mergeOptionSets.js +13 -10
- package/dist/commands/types/mergeTypeProperties.d.ts +2 -2
- package/dist/commands/types/mergeTypeProperties.js +12 -9
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +2 -2
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.js +19 -15
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.d.ts +10 -0
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.js +102 -0
- package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseOptionSetsLocalFiles.js +21 -21
- package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +2 -2
- package/dist/commands/types/parseOptionSetsToFolderStructure.js +17 -18
- package/dist/commands/types/parseTypesFromFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromFiles.js +14 -8
- package/dist/commands/types/parseTypesFromLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromLocalFiles.js +10 -7
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.js +11 -8
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.js +11 -8
- package/dist/commands/types/uploadOptionSetHierarchies.d.ts +2 -2
- package/dist/commands/types/uploadOptionSetHierarchies.js +44 -32
- package/dist/commands/types/uploadOptionSets.d.ts +2 -2
- package/dist/commands/types/uploadOptionSets.js +21 -13
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +2 -2
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.js +26 -19
- package/dist/commands/types/uploadRuleSets.d.ts +2 -2
- package/dist/commands/types/uploadRuleSets.js +34 -26
- package/dist/commands/types/uploadTypePolicies.d.ts +2 -2
- package/dist/commands/types/uploadTypePolicies.js +37 -29
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +2 -2
- package/dist/commands/types/uploadTypePropertyPolicies.js +38 -30
- package/dist/commands/types/uploadTypes.d.ts +2 -2
- package/dist/commands/types/uploadTypes.js +10 -4
- package/dist/commands/types/uploadUsageInfo.d.ts +2 -2
- package/dist/commands/types/uploadUsageInfo.js +32 -24
- package/dist/commands/users/export.d.ts +2 -2
- package/dist/commands/users/export.js +15 -4
- package/dist/commands/users/upload.d.ts +2 -2
- package/dist/commands/users/upload.js +6 -4
- package/dist/commands/webhooks/create.d.ts +2 -2
- package/dist/commands/webhooks/create.js +8 -6
- package/dist/commands/webhooks/delete.d.ts +2 -2
- package/dist/commands/webhooks/delete.js +8 -5
- package/dist/commands/webhooks/getWebhookTrigger.d.ts +2 -2
- package/dist/commands/webhooks/getWebhookTrigger.js +10 -9
- package/dist/commands/webhooks/list.d.ts +2 -2
- package/dist/commands/webhooks/list.js +8 -6
- package/dist/commands/workflow-template-definitions/install.d.ts +2 -2
- package/dist/commands/workflow-template-definitions/install.js +4 -2
- package/dist/commands/workflow-template-definitions/list.d.ts +2 -2
- package/dist/commands/workflow-template-definitions/list.js +4 -2
- package/dist/commands/workflow-templates/delete.d.ts +2 -2
- package/dist/commands/workflow-templates/delete.js +4 -2
- package/dist/commands/workflow-templates/export.d.ts +2 -2
- package/dist/commands/workflow-templates/export.js +19 -17
- package/dist/commands/workflow-templates/list.d.ts +2 -2
- package/dist/commands/workflow-templates/list.js +4 -2
- package/dist/commands/workflow-templates/load.d.ts +2 -2
- package/dist/commands/workflow-templates/load.js +8 -3
- package/dist/common.d.ts +4 -1
- package/dist/common.js +10 -1
- package/dist/helpers/app/actions-deployer.d.ts +2 -2
- package/dist/helpers/app/actions-deployer.js +12 -7
- package/dist/helpers/app/app-deployer.d.ts +1 -1
- package/dist/helpers/app/app-deployer.js +70 -52
- package/dist/helpers/app/app-template-parsers.js +3 -1
- package/dist/helpers/app/load-app-config.d.ts +2 -1
- package/dist/helpers/app/load-app-config.js +2 -2
- package/dist/helpers/app/setup-template.js +4 -3
- package/dist/helpers/colors/helpers.d.ts +10 -2
- package/dist/helpers/colors/helpers.js +11 -10
- package/dist/helpers/config/config.js +15 -10
- package/dist/helpers/file-helpers.js +7 -4
- package/dist/helpers/loader-process/helpers.js +14 -13
- package/dist/helpers/projects/helpers.d.ts +2 -1
- package/dist/helpers/projects/helpers.js +16 -15
- package/dist/helpers/types/csv-parser.js +17 -14
- package/dist/helpers/types/type-extractor.d.ts +1 -1
- package/dist/helpers/types/type-extractor.js +3 -2
- package/dist/helpers/types/type-parser.js +22 -21
- package/dist/helpers/types/type-uploader.js +19 -15
- package/dist/helpers/workflow-template-definitions/workflow-template-definition-deployer.d.ts +1 -1
- package/dist/helpers/workflow-template-definitions/workflow-template-definition-deployer.js +47 -28
- package/dist/helpers/workflow-templates/helper.d.ts +3 -3
- package/dist/helpers/workflow-templates/helper.js +33 -23
- package/dist/interface-converters.spec.js +15 -15
- package/dist/interfaces.d.ts +6 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.js +32 -0
- package/dist/templates/typescript/src/actions/logItem.ts +9 -4
- package/dist/templates/typescript/src/main.ts +13 -8
- package/oclif.manifest.json +861 -31
- package/package.json +10 -7
|
@@ -9,9 +9,11 @@ const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
|
9
9
|
const login_1 = require("../../auth/login");
|
|
10
10
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
11
11
|
const core_1 = require("@oclif/core");
|
|
12
|
-
|
|
12
|
+
const basecommand_1 = require("../basecommand");
|
|
13
|
+
class ImportUsers extends basecommand_1.BaseCommand {
|
|
13
14
|
async run() {
|
|
14
|
-
const { args } = await this.parse(ImportUsers);
|
|
15
|
+
const { args, flags } = await this.parse(ImportUsers);
|
|
16
|
+
await super.setLogLevel(flags.logLevel);
|
|
15
17
|
try {
|
|
16
18
|
await (0, login_1.authUser)();
|
|
17
19
|
this.log('%s Uploading Users.', chalk_1.default.blue.bold('START'));
|
|
@@ -58,8 +60,8 @@ async function uploadUsers(fileLocation) {
|
|
|
58
60
|
object: {
|
|
59
61
|
role: role,
|
|
60
62
|
userEmail: email,
|
|
61
|
-
...user
|
|
62
|
-
}
|
|
63
|
+
...user,
|
|
64
|
+
},
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class CreateWebhooks extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class CreateWebhooks extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
3
4
|
const core_1 = require("@oclif/core");
|
|
4
5
|
const login_1 = require("../../auth/login");
|
|
5
6
|
const webhooks_1 = require("../../api/webhooks");
|
|
6
|
-
|
|
7
|
+
const basecommand_1 = require("../basecommand");
|
|
8
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
9
|
+
class CreateWebhooks extends basecommand_1.BaseCommand {
|
|
7
10
|
async run() {
|
|
8
11
|
const { flags } = await this.parse(CreateWebhooks);
|
|
12
|
+
await super.setLogLevel(flags.logLevel);
|
|
9
13
|
await (0, login_1.authUser)();
|
|
10
14
|
const webhook = await (0, webhooks_1.createWebhook)({});
|
|
11
15
|
if (flags.json) {
|
|
12
|
-
|
|
16
|
+
logger_1.default.info(JSON.stringify(webhook, null, 2));
|
|
13
17
|
}
|
|
14
18
|
else {
|
|
15
|
-
|
|
19
|
+
logger_1.default.info(webhook.id);
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
23
|
exports.default = CreateWebhooks;
|
|
20
24
|
CreateWebhooks.description = 'Create a new webhook';
|
|
21
|
-
CreateWebhooks.examples = [
|
|
22
|
-
'contrail webhooks create',
|
|
23
|
-
];
|
|
25
|
+
CreateWebhooks.examples = ['contrail webhooks create'];
|
|
24
26
|
CreateWebhooks.flags = {
|
|
25
27
|
json: core_1.Flags.boolean({ char: 'j', description: 'output in json format', default: false }),
|
|
26
28
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DeleteWebhooks extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class DeleteWebhooks extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -5,14 +5,17 @@ const core_1 = require("@oclif/core");
|
|
|
5
5
|
const login_1 = require("../../auth/login");
|
|
6
6
|
const webhooks_1 = require("../../api/webhooks");
|
|
7
7
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
|
-
|
|
8
|
+
const basecommand_1 = require("../basecommand");
|
|
9
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
10
|
+
class DeleteWebhooks extends basecommand_1.BaseCommand {
|
|
9
11
|
async run() {
|
|
10
12
|
const { flags, args } = await this.parse(DeleteWebhooks);
|
|
13
|
+
await super.setLogLevel(flags.logLevel);
|
|
11
14
|
await (0, login_1.authUser)();
|
|
12
15
|
const webhooks = await (0, webhooks_1.getWebhooks)();
|
|
13
16
|
const deletedWebhooks = [];
|
|
14
17
|
if (args.webhookId) {
|
|
15
|
-
const toDelete = webhooks.find(x => x.id === args.webhookId);
|
|
18
|
+
const toDelete = webhooks.find((x) => x.id === args.webhookId);
|
|
16
19
|
if (!toDelete) {
|
|
17
20
|
throw new Error(`No webhook found with id ${args.webhookId}`);
|
|
18
21
|
}
|
|
@@ -23,17 +26,17 @@ class DeleteWebhooks extends core_1.Command {
|
|
|
23
26
|
type: 'checkbox',
|
|
24
27
|
name: 'webhookIds',
|
|
25
28
|
message: 'which webhook(s) would you like to delete?',
|
|
26
|
-
choices: webhooks.map(x => ({ name: x.id, value: x.id })),
|
|
29
|
+
choices: webhooks.map((x) => ({ name: x.id, value: x.id })),
|
|
27
30
|
});
|
|
28
31
|
for (const id of answer.webhookIds) {
|
|
29
32
|
deletedWebhooks.push(await (0, webhooks_1.deleteWebhook)(id));
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
if (flags.json) {
|
|
33
|
-
|
|
36
|
+
logger_1.default.info(JSON.stringify(deletedWebhooks, null, 2));
|
|
34
37
|
}
|
|
35
38
|
else {
|
|
36
|
-
|
|
39
|
+
logger_1.default.info(deletedWebhooks.map((x) => x.id).join('\n'));
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class GetWebhookTrigger extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class GetWebhookTrigger extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static args: {
|
|
@@ -5,34 +5,35 @@ const core_1 = require("@oclif/core");
|
|
|
5
5
|
const login_1 = require("../../auth/login");
|
|
6
6
|
const webhooks_1 = require("../../api/webhooks");
|
|
7
7
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
|
-
|
|
8
|
+
const basecommand_1 = require("../basecommand");
|
|
9
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
10
|
+
class GetWebhookTrigger extends basecommand_1.BaseCommand {
|
|
9
11
|
async run() {
|
|
10
|
-
const { args } = await this.parse(GetWebhookTrigger);
|
|
12
|
+
const { args, flags } = await this.parse(GetWebhookTrigger);
|
|
13
|
+
await super.setLogLevel(flags.logLevel);
|
|
11
14
|
await (0, login_1.authUser)();
|
|
12
15
|
const webhooks = await (0, webhooks_1.getWebhooks)();
|
|
13
16
|
if (args.webhookId) {
|
|
14
|
-
const foundWebhook = webhooks.find(x => x.id === args.webhookId);
|
|
17
|
+
const foundWebhook = webhooks.find((x) => x.id === args.webhookId);
|
|
15
18
|
if (!foundWebhook) {
|
|
16
19
|
throw new Error(`No webhook found with id ${args.webhookId}`);
|
|
17
20
|
}
|
|
18
|
-
|
|
21
|
+
logger_1.default.info(`webhookId:${foundWebhook.id}`);
|
|
19
22
|
}
|
|
20
23
|
else {
|
|
21
24
|
const answer = await inquirer_1.default.prompt({
|
|
22
25
|
type: 'list',
|
|
23
26
|
name: 'webhookId',
|
|
24
27
|
message: 'For which webhook would you like ot generate an event tirgger?',
|
|
25
|
-
choices: webhooks.map(x => ({ name: x.id, value: x.id })),
|
|
28
|
+
choices: webhooks.map((x) => ({ name: x.id, value: x.id })),
|
|
26
29
|
});
|
|
27
|
-
|
|
30
|
+
logger_1.default.info(`webhookId:${answer.webhookId}`);
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
exports.default = GetWebhookTrigger;
|
|
32
35
|
GetWebhookTrigger.description = 'Crafts a webhook trigger that can be used for event workflows. This command does not alter the state of any webhook or event workflow. It is only a utility for generating a webhook trigger.';
|
|
33
|
-
GetWebhookTrigger.examples = [
|
|
34
|
-
'contrail webhooks getWebhookTrigger 1234-abcd-1234-abcd-1234abcd',
|
|
35
|
-
];
|
|
36
|
+
GetWebhookTrigger.examples = ['contrail webhooks getWebhookTrigger 1234-abcd-1234-abcd-1234abcd'];
|
|
36
37
|
GetWebhookTrigger.args = {
|
|
37
38
|
webhookId: core_1.Args.string({ description: 'The id of the webhook to delete', required: false }),
|
|
38
39
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class ListWebhooks extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class ListWebhooks extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
3
4
|
const core_1 = require("@oclif/core");
|
|
4
5
|
const login_1 = require("../../auth/login");
|
|
5
6
|
const webhooks_1 = require("../../api/webhooks");
|
|
6
|
-
|
|
7
|
+
const basecommand_1 = require("../basecommand");
|
|
8
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
9
|
+
class ListWebhooks extends basecommand_1.BaseCommand {
|
|
7
10
|
async run() {
|
|
8
11
|
const { flags } = await this.parse(ListWebhooks);
|
|
12
|
+
await super.setLogLevel(flags.logLevel);
|
|
9
13
|
await (0, login_1.authUser)();
|
|
10
14
|
const webhooks = await (0, webhooks_1.getWebhooks)();
|
|
11
15
|
if (flags.json) {
|
|
12
|
-
|
|
16
|
+
logger_1.default.info(JSON.stringify(webhooks, null, 2));
|
|
13
17
|
}
|
|
14
18
|
else {
|
|
15
|
-
|
|
19
|
+
logger_1.default.info(webhooks.map((x) => x.id).join('\n'));
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
23
|
exports.default = ListWebhooks;
|
|
20
24
|
ListWebhooks.description = 'List current webhooks';
|
|
21
|
-
ListWebhooks.examples = [
|
|
22
|
-
'contrail webhooks list',
|
|
23
|
-
];
|
|
25
|
+
ListWebhooks.examples = ['contrail webhooks list'];
|
|
24
26
|
ListWebhooks.flags = {
|
|
25
27
|
// // flag with a value (-n, --name=VALUE)
|
|
26
28
|
// name: Flags.string({char: 'n', description: 'name to print'}),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class InstallWorkflowTemplateDefinitions extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class InstallWorkflowTemplateDefinitions extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
run(): Promise<void>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
3
|
const login_1 = require("../../auth/login");
|
|
5
4
|
const workflow_template_definition_deployer_1 = require("../../helpers/workflow-template-definitions/workflow-template-definition-deployer");
|
|
6
|
-
|
|
5
|
+
const basecommand_1 = require("../basecommand");
|
|
6
|
+
class InstallWorkflowTemplateDefinitions extends basecommand_1.BaseCommand {
|
|
7
7
|
async run() {
|
|
8
|
+
const { flags } = await this.parse(InstallWorkflowTemplateDefinitions);
|
|
9
|
+
await super.setLogLevel(flags.logLevel);
|
|
8
10
|
await (0, login_1.authUser)();
|
|
9
11
|
await new workflow_template_definition_deployer_1.WorkflowTemplateDefinitionDeployer().cliInstallWorkflowTemplateDefinitions();
|
|
10
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class ListWorkflowTemplateDefinitions extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class ListWorkflowTemplateDefinitions extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
run(): Promise<void>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
3
|
const login_1 = require("../../auth/login");
|
|
5
4
|
const workflow_template_definition_deployer_1 = require("../../helpers/workflow-template-definitions/workflow-template-definition-deployer");
|
|
6
|
-
|
|
5
|
+
const basecommand_1 = require("../basecommand");
|
|
6
|
+
class ListWorkflowTemplateDefinitions extends basecommand_1.BaseCommand {
|
|
7
7
|
async run() {
|
|
8
|
+
const { flags } = await this.parse(ListWorkflowTemplateDefinitions);
|
|
9
|
+
await super.setLogLevel(flags.logLevel);
|
|
8
10
|
await (0, login_1.authUser)();
|
|
9
11
|
await new workflow_template_definition_deployer_1.WorkflowTemplateDefinitionDeployer().listWorkflowTemplateDefinitions();
|
|
10
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DeleteWorkflowTemplates extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class DeleteWorkflowTemplates extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
run(): Promise<void>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
3
|
const login_1 = require("../../auth/login");
|
|
5
4
|
const helper_1 = require("../../helpers/workflow-templates/helper");
|
|
6
|
-
|
|
5
|
+
const basecommand_1 = require("../basecommand");
|
|
6
|
+
class DeleteWorkflowTemplates extends basecommand_1.BaseCommand {
|
|
7
7
|
async run() {
|
|
8
|
+
const { flags } = await this.parse(DeleteWorkflowTemplates);
|
|
9
|
+
await super.setLogLevel(flags.logLevel);
|
|
8
10
|
await (0, login_1.authUser)();
|
|
9
11
|
await new helper_1.WorkflowTemplateDeployer().deleteWorkflowTemplates();
|
|
10
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
2
|
export declare const DEFAULT_FILE_LOCATION = "workflows.yml";
|
|
3
|
-
export default class ExportWorkflows extends
|
|
3
|
+
export default class ExportWorkflows extends BaseCommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
@@ -12,53 +12,55 @@ const core_1 = require("@oclif/core");
|
|
|
12
12
|
const file_helpers_1 = require("../../helpers/file-helpers");
|
|
13
13
|
const event_workflow_templates_1 = require("../../api/event-workflow-templates");
|
|
14
14
|
const helper_1 = require("../../helpers/workflow-templates/helper");
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const basecommand_1 = require("../basecommand");
|
|
16
|
+
exports.DEFAULT_FILE_LOCATION = 'workflows.yml';
|
|
17
|
+
class ExportWorkflows extends basecommand_1.BaseCommand {
|
|
17
18
|
async run() {
|
|
18
19
|
var _a;
|
|
19
20
|
const { flags } = await this.parse(ExportWorkflows);
|
|
21
|
+
await super.setLogLevel(flags.logLevel);
|
|
20
22
|
try {
|
|
21
23
|
await (0, login_1.authUser)();
|
|
22
|
-
this.log(
|
|
24
|
+
this.log('%s Getting Workflows.', chalk_1.default.blue.bold('START'));
|
|
23
25
|
await exportWorkflows((_a = flags.outFile) !== null && _a !== void 0 ? _a : exports.DEFAULT_FILE_LOCATION, flags.overwrite);
|
|
24
|
-
this.log(
|
|
26
|
+
this.log('%s Done', chalk_1.default.yellow.bold('WORKFLOWS'));
|
|
25
27
|
}
|
|
26
28
|
catch (e) {
|
|
27
|
-
this.log(`%s Workflows download Failed. ${e}`, chalk_1.default.red.bold(
|
|
29
|
+
this.log(`%s Workflows download Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
30
|
-
this.log(
|
|
32
|
+
this.log('%s Workflows download Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
exports.default = ExportWorkflows;
|
|
34
|
-
ExportWorkflows.description =
|
|
36
|
+
ExportWorkflows.description = 'Export all workflows in the org.';
|
|
35
37
|
ExportWorkflows.examples = [
|
|
36
38
|
`$ contrail workflow-templates export
|
|
37
39
|
`,
|
|
38
40
|
];
|
|
39
41
|
ExportWorkflows.flags = {
|
|
40
42
|
outFile: core_1.Flags.string({
|
|
41
|
-
char:
|
|
42
|
-
description:
|
|
43
|
+
char: 'f',
|
|
44
|
+
description: 'The location for the file to be saved',
|
|
43
45
|
required: false,
|
|
44
46
|
default: exports.DEFAULT_FILE_LOCATION,
|
|
45
47
|
}),
|
|
46
48
|
overwrite: core_1.Flags.boolean({
|
|
47
|
-
description:
|
|
49
|
+
description: 'Replaces existing files if they exist',
|
|
48
50
|
required: false,
|
|
49
51
|
default: false,
|
|
50
52
|
}),
|
|
51
53
|
};
|
|
52
54
|
async function exportWorkflows(fileLocation, overwrite) {
|
|
53
55
|
const allWorkflowsInOrg = await (0, event_workflow_templates_1.getExistingWorkflowTemplates)();
|
|
54
|
-
|
|
56
|
+
const workflowsObj = { workflows: [] };
|
|
55
57
|
for (const workflow of allWorkflowsInOrg) {
|
|
56
58
|
const exportWorkflow = lodash_1.default.pick(workflow, [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
'triggerKey',
|
|
60
|
+
'workflowDefinition',
|
|
61
|
+
'name',
|
|
62
|
+
'isActive',
|
|
63
|
+
'identifier',
|
|
62
64
|
]);
|
|
63
65
|
await (0, helper_1.populateActionIdentifiers)(exportWorkflow);
|
|
64
66
|
workflowsObj.workflows.push(exportWorkflow);
|
|
@@ -73,5 +75,5 @@ async function saveData(data, fileLocation, overwrite) {
|
|
|
73
75
|
if (fs_1.default.existsSync(pathToWrite)) {
|
|
74
76
|
await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
|
|
75
77
|
}
|
|
76
|
-
fs_1.default.writeFileSync(pathToWrite, yamlStr,
|
|
78
|
+
fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
|
|
77
79
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class ListWorkflowTemplates extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class ListWorkflowTemplates extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
run(): Promise<void>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
3
|
const login_1 = require("../../auth/login");
|
|
5
4
|
const helper_1 = require("../../helpers/workflow-templates/helper");
|
|
6
|
-
|
|
5
|
+
const basecommand_1 = require("../basecommand");
|
|
6
|
+
class ListWorkflowTemplates extends basecommand_1.BaseCommand {
|
|
7
7
|
async run() {
|
|
8
|
+
const { flags } = await this.parse(ListWorkflowTemplates);
|
|
9
|
+
await super.setLogLevel(flags.logLevel);
|
|
8
10
|
await (0, login_1.authUser)();
|
|
9
11
|
return await new helper_1.WorkflowTemplateDeployer().listExistingWorkflowTemplates();
|
|
10
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class LoadWorkflowTemplates extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class LoadWorkflowTemplates extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static args: {
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const login_1 = require("../../auth/login");
|
|
5
5
|
const helper_1 = require("../../helpers/workflow-templates/helper");
|
|
6
|
-
|
|
6
|
+
const basecommand_1 = require("../basecommand");
|
|
7
|
+
class LoadWorkflowTemplates extends basecommand_1.BaseCommand {
|
|
7
8
|
async run() {
|
|
8
|
-
const { args } = await this.parse(LoadWorkflowTemplates);
|
|
9
|
+
const { args, flags } = await this.parse(LoadWorkflowTemplates);
|
|
10
|
+
await super.setLogLevel(flags.logLevel);
|
|
9
11
|
await (0, login_1.authUser)();
|
|
10
12
|
await (0, helper_1.localDeployWorkflowTemplate)(args.fileLocation);
|
|
11
13
|
}
|
|
@@ -17,5 +19,8 @@ LoadWorkflowTemplates.examples = [
|
|
|
17
19
|
`,
|
|
18
20
|
];
|
|
19
21
|
LoadWorkflowTemplates.args = {
|
|
20
|
-
fileLocation: core_1.Args.string({
|
|
22
|
+
fileLocation: core_1.Args.string({
|
|
23
|
+
description: 'The workflow template file to load',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
21
26
|
};
|
package/dist/common.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare function getSeparatorByPlatform(): string;
|
|
3
|
+
export declare function delay(ms: number): Promise<NodeJS.Timeout>;
|
|
4
|
+
export declare function removeSlash(string: any): string;
|
package/dist/common.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSeparatorByPlatform = void 0;
|
|
3
|
+
exports.removeSlash = exports.delay = exports.getSeparatorByPlatform = void 0;
|
|
4
4
|
function getSeparatorByPlatform() {
|
|
5
5
|
const isWin = process.platform === 'win32';
|
|
6
6
|
const separator = isWin ? '\\' : '/';
|
|
7
7
|
return separator;
|
|
8
8
|
}
|
|
9
9
|
exports.getSeparatorByPlatform = getSeparatorByPlatform;
|
|
10
|
+
function delay(ms) {
|
|
11
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
12
|
+
}
|
|
13
|
+
exports.delay = delay;
|
|
14
|
+
function removeSlash(string) {
|
|
15
|
+
const re = /\//gi;
|
|
16
|
+
return string.replace(re, '-');
|
|
17
|
+
}
|
|
18
|
+
exports.removeSlash = removeSlash;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { App, AppDeclaration, AppActionDeclaration } from '../../interfaces';
|
|
2
|
-
export declare function getActionsForAppVersion(app: App): Promise<
|
|
1
|
+
import { App, AppDeclaration, AppActionDeclaration, EventWorkflowActionDefinition } from '../../interfaces';
|
|
2
|
+
export declare function getActionsForAppVersion(app: App): Promise<EventWorkflowActionDefinition[]>;
|
|
3
3
|
export declare function getActionDeclarationIdentifier(actionKey: any, app: App): string;
|
|
4
4
|
export declare function deleteAction(actionId: any): Promise<any>;
|
|
5
5
|
export declare class ActionsDeployer {
|
|
@@ -7,6 +7,7 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
|
7
7
|
const app_template_parsers_1 = require("./app-template-parsers");
|
|
8
8
|
const common_1 = require("../../common");
|
|
9
9
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
10
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
10
11
|
async function getActionsForAppVersion(app) {
|
|
11
12
|
return await new sdk_1.Entities().get({
|
|
12
13
|
entityName: 'event-workflow-action-definition',
|
|
@@ -19,7 +20,10 @@ function getActionDeclarationIdentifier(actionKey, app) {
|
|
|
19
20
|
}
|
|
20
21
|
exports.getActionDeclarationIdentifier = getActionDeclarationIdentifier;
|
|
21
22
|
async function deleteAction(actionId) {
|
|
22
|
-
return await new sdk_1.Entities().delete({
|
|
23
|
+
return await new sdk_1.Entities().delete({
|
|
24
|
+
entityName: 'event-workflow-action-definition',
|
|
25
|
+
id: actionId,
|
|
26
|
+
});
|
|
23
27
|
}
|
|
24
28
|
exports.deleteAction = deleteAction;
|
|
25
29
|
class ActionsDeployer {
|
|
@@ -27,7 +31,7 @@ class ActionsDeployer {
|
|
|
27
31
|
// FETCH ALL ACTIONS FROM THE API.
|
|
28
32
|
const existingActions = await getActionsForAppVersion(app);
|
|
29
33
|
// UPSERT / DELETE BASED ON ACTION IDENTIFIER
|
|
30
|
-
|
|
34
|
+
logger_1.default.info('%s \tDeploying actions.', chalk_1.default.yellow.bold('ACTION'));
|
|
31
35
|
if (appDeclaration.actions) {
|
|
32
36
|
const localActionKeys = Object.keys(appDeclaration.actions);
|
|
33
37
|
if ((localActionKeys === null || localActionKeys === void 0 ? void 0 : localActionKeys.length) > 0) {
|
|
@@ -38,9 +42,9 @@ class ActionsDeployer {
|
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
async deployAction(actionKey, actionDeclaration, app, existingActions) {
|
|
41
|
-
|
|
45
|
+
logger_1.default.info(`%s \tDeploying action: ${actionKey}`, chalk_1.default.yellow.bold('ACTION'));
|
|
42
46
|
const identifier = getActionDeclarationIdentifier(actionKey, app);
|
|
43
|
-
const existingDefinition = existingActions.find(ad => ad.identifier === identifier);
|
|
47
|
+
const existingDefinition = existingActions.find((ad) => ad.identifier === identifier);
|
|
44
48
|
if (!existingDefinition) {
|
|
45
49
|
await this.createNewActionDefinition(actionKey, actionDeclaration, app);
|
|
46
50
|
}
|
|
@@ -70,7 +74,7 @@ class ActionsDeployer {
|
|
|
70
74
|
entityName: 'event-workflow-action-definition',
|
|
71
75
|
object: newObject,
|
|
72
76
|
});
|
|
73
|
-
|
|
77
|
+
logger_1.default.info(`%s Created new action definition: ${actionKey}`, chalk_1.default.yellow.bold('APP'));
|
|
74
78
|
return actionDefinition;
|
|
75
79
|
}
|
|
76
80
|
async updateActionDefinition(existingActionDefinition, actionDeclaration, app) {
|
|
@@ -78,7 +82,8 @@ class ActionsDeployer {
|
|
|
78
82
|
if (actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) {
|
|
79
83
|
configProperties = app_template_parsers_1.ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration);
|
|
80
84
|
}
|
|
81
|
-
else if (!(actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) &&
|
|
85
|
+
else if (!(actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) &&
|
|
86
|
+
existingActionDefinition.configProperties) {
|
|
82
87
|
configProperties = null;
|
|
83
88
|
}
|
|
84
89
|
const updates = {
|
|
@@ -98,7 +103,7 @@ class ActionsDeployer {
|
|
|
98
103
|
id: existingActionDefinition.id,
|
|
99
104
|
object: updates,
|
|
100
105
|
});
|
|
101
|
-
|
|
106
|
+
logger_1.default.info(`%s Updated existing action definition: ${actionDefinition.identifier}`, chalk_1.default.yellow.bold('APP'));
|
|
102
107
|
return actionDefinition;
|
|
103
108
|
}
|
|
104
109
|
async getFunction(actionDeclaration) {
|
|
@@ -6,7 +6,7 @@ export declare class AppDeployer {
|
|
|
6
6
|
deploy(appDeclaration: AppDeclaration): Promise<App>;
|
|
7
7
|
getExistingApp(appDeclaration: AppDeclaration): Promise<App>;
|
|
8
8
|
private createNewApp;
|
|
9
|
-
updateExistingApp(appDeclaration: AppDeclaration, existingApp: any): Promise<
|
|
9
|
+
updateExistingApp(appDeclaration: AppDeclaration, existingApp: any): Promise<App>;
|
|
10
10
|
remove(appDeclaration: AppDeclaration): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare function createNodePackage(appIdentifier: string, debug: boolean, dryRun: boolean): Promise<AppCodePackage>;
|