@contrail/cli 1.0.2 → 1.0.3
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/.vscode/settings.json +5 -5
- package/bin/init +3 -3
- package/lib/auth/auth.d.ts +9 -9
- package/lib/auth/auth.js +2 -2
- package/lib/auth/login.d.ts +1 -1
- package/lib/auth/login.js +112 -96
- package/lib/cli.d.ts +5 -5
- package/lib/cli.js +30 -30
- package/lib/create-app/create.d.ts +1 -1
- package/lib/create-app/create.js +63 -48
- package/lib/create-app/setup-template.d.ts +1 -1
- package/lib/create-app/setup-template.js +34 -48
- package/lib/deploy-app/actions-deployer.d.ts +10 -10
- package/lib/deploy-app/actions-deployer.js +86 -75
- package/lib/deploy-app/app-deployer.d.ts +8 -10
- package/lib/deploy-app/app-deployer.js +79 -84
- package/lib/deploy-app/app-template-parsers.d.ts +7 -0
- package/lib/deploy-app/app-template-parsers.js +37 -0
- package/lib/deploy-app/deploy.d.ts +2 -2
- package/lib/deploy-app/deploy.js +56 -30
- package/lib/deploy-app/interfaces.d.ts +74 -43
- package/lib/deploy-app/interfaces.js +4 -0
- package/package.json +63 -63
- package/publish.sh +5 -0
- package/src/auth/auth.ts +9 -9
- package/src/auth/login.ts +124 -107
- package/src/cli.ts +32 -33
- package/src/create-app/create.ts +73 -58
- package/src/create-app/setup-template.ts +37 -56
- package/src/deploy-app/actions-deployer.ts +109 -84
- package/src/deploy-app/app-deployer.ts +86 -89
- package/src/deploy-app/app-template-parsers.ts +43 -0
- package/src/deploy-app/deploy.ts +64 -33
- package/src/deploy-app/interfaces.ts +78 -43
- package/templates/javascript/actions/example/action.js +37 -37
- package/templates/javascript/app.yml +54 -42
- package/templates/javascript/package.json +23 -23
- package/templates/javascript/set_auth.bat +3 -0
- package/templates/javascript/set_auth.sh +3 -0
- package/templates/typescript/actions/exampleAction.ts +38 -0
- package/templates/typescript/app.yml +56 -0
- package/templates/typescript/package.json +24 -0
- package/templates/typescript/set_auth.bat +3 -0
- package/templates/typescript/set_auth.sh +3 -0
- package/templates/typescript/tsconfig.json +31 -0
- package/tsconfig.json +22 -22
- package/tslint.json +57 -57
- package/lib/deploy-app/actions.d.ts +0 -5
- package/lib/deploy-app/actions.js +0 -17
- package/lib/deploy-app/app-declaration.d.ts +0 -20
- package/lib/deploy-app/app-declaration.js +0 -0
- package/lib/deploy-app/app.d.ts +0 -8
- package/lib/deploy-app/app.js +0 -56
|
@@ -1,57 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import ncp from 'ncp';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { promisify } from 'util';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const TARGET_DIR = process.cwd();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
title: 'Copy template files',
|
|
39
|
-
task: () => copyTemplate(),
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
title: 'Install dependencies',
|
|
43
|
-
task: () =>
|
|
44
|
-
projectInstall({
|
|
45
|
-
cwd: TARGET_DIR,
|
|
46
|
-
}),
|
|
47
|
-
// skip: () =>
|
|
48
|
-
// !options.runInstall
|
|
49
|
-
// ? 'Pass --install to automatically install dependencies'
|
|
50
|
-
// : undefined,
|
|
51
|
-
},
|
|
52
|
-
]);
|
|
53
|
-
await tasks.run();
|
|
54
|
-
} catch (e) {
|
|
55
|
-
console.log('Error copying template: ', e);
|
|
56
|
-
}
|
|
1
|
+
|
|
2
|
+
import ncp from 'ncp';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { promisify } from 'util';
|
|
5
|
+
const Listr = require('listr');
|
|
6
|
+
import { projectInstall } from 'pkg-install';
|
|
7
|
+
const copy = promisify(ncp);
|
|
8
|
+
|
|
9
|
+
const TARGET_DIR = process.cwd();
|
|
10
|
+
const currentFileUrl = import .meta.url;
|
|
11
|
+
|
|
12
|
+
function copyTemplate(templateDir){
|
|
13
|
+
return copy(templateDir, TARGET_DIR, {
|
|
14
|
+
clobber: false,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function setUpTemplate(options) {
|
|
19
|
+
const templateDir = path.resolve(new URL(currentFileUrl).pathname, `../../../templates/${options.template.toLocaleLowerCase()}`).replace(/\\/g, '\\').replace(/(.):\\(.):/g, '').replace(/%20/g, ' ');
|
|
20
|
+
try {
|
|
21
|
+
const tasks = new Listr([
|
|
22
|
+
{
|
|
23
|
+
title: 'Copy template files',
|
|
24
|
+
task: () => copyTemplate(templateDir),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
title: 'Install dependencies',
|
|
28
|
+
task: () =>
|
|
29
|
+
projectInstall({
|
|
30
|
+
cwd: TARGET_DIR,
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
]);
|
|
34
|
+
await tasks.run();
|
|
35
|
+
} catch (e) {
|
|
36
|
+
throw new Error(`Error copying template: ${e}`);
|
|
37
|
+
}
|
|
57
38
|
}
|
|
@@ -1,84 +1,109 @@
|
|
|
1
|
-
import { Entities } from '@contrail/sdk';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { App,
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
1
|
+
import { Entities } from '@contrail/sdk';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { App, AppDeclaration, AppActionDeclaration, EventWorkflowActionDefinition } from './interfaces';
|
|
4
|
+
import { ConfigPropertiesParser } from './app-template-parsers';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
|
|
7
|
+
export class ActionsDeployer {
|
|
8
|
+
async deployActions(appDeclaration: AppDeclaration, app: App) {
|
|
9
|
+
|
|
10
|
+
// FETCH ALL ACTIONS FROM THE API.
|
|
11
|
+
const existingActions = await this.getActionsForApp(app);
|
|
12
|
+
|
|
13
|
+
// UPSERT / DELETE BASED ON ACTION IDENTIFIER
|
|
14
|
+
console.log('%s \tDeploying actions.', chalk.yellow.bold('ACTION'));
|
|
15
|
+
|
|
16
|
+
for (const actionKey of Object.keys(appDeclaration.actions)) {
|
|
17
|
+
await this.deployAction(actionKey, appDeclaration.actions[actionKey], app, existingActions);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async getActionsForApp(app: App) {
|
|
22
|
+
return await new Entities().get({
|
|
23
|
+
entityName: 'event-workflow-action-definition',
|
|
24
|
+
criteria: { ownerKey: `app:${app.id}` },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async deployAction(actionKey: string, actionDeclaration: AppActionDeclaration, app: App, existingActions: Array<any>) {
|
|
29
|
+
console.log(`%s \tDeploying action: ${actionKey}`, chalk.yellow.bold('ACTION'));
|
|
30
|
+
|
|
31
|
+
const identifier = this.getActionDeclarationIdentifier(actionKey, app);
|
|
32
|
+
const existingDefinition = existingActions.find(ad => ad.identifier === identifier);
|
|
33
|
+
|
|
34
|
+
if (!existingDefinition) {
|
|
35
|
+
await this.createNewActionDefinition(actionKey, actionDeclaration, app);
|
|
36
|
+
} else {
|
|
37
|
+
await this.updateActionDefinition(existingDefinition, actionDeclaration);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private async createNewActionDefinition(actionKey: string, actionDeclaration: AppActionDeclaration, app: App) {
|
|
42
|
+
const newObject: EventWorkflowActionDefinition = {
|
|
43
|
+
identifier: this.getActionDeclarationIdentifier(actionKey, app),
|
|
44
|
+
name: actionDeclaration.name,
|
|
45
|
+
ownerKey: `app:${app.id}`,
|
|
46
|
+
public: app.public, // TODO - an actions visibility is not tied to the visibility of the app
|
|
47
|
+
configProperties: ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const functionString = await this.getFunction(actionDeclaration);
|
|
51
|
+
if (functionString) {
|
|
52
|
+
newObject.executeFunctionString = functionString;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const actionDefinition = await new Entities().create({
|
|
56
|
+
entityName: 'event-workflow-action-definition',
|
|
57
|
+
object: newObject,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
console.log(`%s Created new action definition: ${actionKey}`, chalk.yellow.bold('APP'));
|
|
61
|
+
|
|
62
|
+
return actionDefinition;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private async updateActionDefinition(existingActionDefinition: EventWorkflowActionDefinition,
|
|
66
|
+
actionDeclaration: AppActionDeclaration) {
|
|
67
|
+
const updates: EventWorkflowActionDefinition = {
|
|
68
|
+
name: actionDeclaration.name,
|
|
69
|
+
// public: actionDeclaration.public, // TODO - an actions visibility is allowed to change
|
|
70
|
+
configProperties: ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration),
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const functionString = await this.getFunction(actionDeclaration);
|
|
74
|
+
if (functionString) {
|
|
75
|
+
updates.executeFunctionString = functionString;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const actionDefinition = await new Entities().update({
|
|
79
|
+
entityName: 'event-workflow-action-definition',
|
|
80
|
+
id: existingActionDefinition.id,
|
|
81
|
+
object: updates,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
console.log(`%s Updated existingaction defintion: ${actionDefinition.identifier}`, chalk.yellow.bold('APP'));
|
|
85
|
+
|
|
86
|
+
return actionDefinition;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
getActionDeclarationIdentifier(actionKey, app: App) {
|
|
90
|
+
return app.identifier + ':' + actionKey;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async getFunction(actionDeclaration: AppActionDeclaration): Promise<string> {
|
|
94
|
+
if (!actionDeclaration.handler) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!actionDeclaration.handler.endsWith('.js')) {
|
|
99
|
+
throw new Error('Action handler must be a .js file.');
|
|
100
|
+
}
|
|
101
|
+
const CURRENT_DIR = process.cwd();
|
|
102
|
+
const isWin = process.platform === 'win32';
|
|
103
|
+
const separator = isWin ? '\\' : '/';
|
|
104
|
+
|
|
105
|
+
const functionLocaiton = CURRENT_DIR + separator + actionDeclaration.handler;
|
|
106
|
+
const content = fs.readFileSync(functionLocaiton);
|
|
107
|
+
return content.toString();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -1,89 +1,86 @@
|
|
|
1
|
-
import { Entities } from '@contrail/sdk';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export class AppDeployer {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return apps.find(app => app.identifier === appDeclaration.appIdentifier);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
}
|
|
1
|
+
import { Entities } from '@contrail/sdk';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { Auth } from '../auth/auth';
|
|
4
|
+
import { ActionsDeployer } from './actions-deployer';
|
|
5
|
+
import { App, AppDeclaration } from './interfaces';
|
|
6
|
+
import { TriggerKeyDefinitionParser, ConfigPropertiesParser } from './app-template-parsers';
|
|
7
|
+
|
|
8
|
+
export class AppDeployer {
|
|
9
|
+
public async deploy(appDeclaration: AppDeclaration) {
|
|
10
|
+
let app = await this.getExistingApp(appDeclaration);
|
|
11
|
+
if (!app) {
|
|
12
|
+
app = await this.createNewApp(appDeclaration);
|
|
13
|
+
} else {
|
|
14
|
+
app = await this.updateExistingApp(appDeclaration, app);
|
|
15
|
+
}
|
|
16
|
+
await new ActionsDeployer().deployActions(appDeclaration, app);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public async getExistingApp(appDeclaration: AppDeclaration): Promise<App> {
|
|
20
|
+
const orgId = Auth.config.orgId;
|
|
21
|
+
const apps = [];
|
|
22
|
+
|
|
23
|
+
apps.push(...await new Entities().get({
|
|
24
|
+
entityName: 'app',
|
|
25
|
+
criteria: {
|
|
26
|
+
orgId,
|
|
27
|
+
private: true,
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
apps.push(...await new Entities().get({
|
|
31
|
+
entityName: 'app',
|
|
32
|
+
criteria: {
|
|
33
|
+
orgId,
|
|
34
|
+
private: false,
|
|
35
|
+
},
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
return apps.find(app => app.identifier === appDeclaration.appIdentifier);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private async createNewApp(appDeclaration: AppDeclaration) {
|
|
42
|
+
const newApp = {
|
|
43
|
+
identifier: appDeclaration.appIdentifier,
|
|
44
|
+
name: appDeclaration.appName,
|
|
45
|
+
public: appDeclaration.visibility === 'public',
|
|
46
|
+
description: appDeclaration.appDescription,
|
|
47
|
+
publisher: appDeclaration.publisher,
|
|
48
|
+
thumbnail: appDeclaration.thumbnail,
|
|
49
|
+
eventWorkflowTriggerKeyMapping: appDeclaration.eventWorkflowTriggerKeyMapping,
|
|
50
|
+
keywords: appDeclaration.keywords,
|
|
51
|
+
configProperties: ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration),
|
|
52
|
+
triggerKeyDefinitions: TriggerKeyDefinitionParser.buildTriggersArray(appDeclaration),
|
|
53
|
+
};
|
|
54
|
+
const app = await new Entities().create({ entityName: 'app', object: newApp });
|
|
55
|
+
console.log(`%s Created new app: ${app.name}`, chalk.yellow.bold('APP'));
|
|
56
|
+
return app;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public async updateExistingApp(appDeclaration: AppDeclaration, existingApp) {
|
|
60
|
+
const updates = {
|
|
61
|
+
name: appDeclaration.appName,
|
|
62
|
+
public: appDeclaration.visibility === 'public',
|
|
63
|
+
description: appDeclaration.appDescription,
|
|
64
|
+
publisher: appDeclaration.publisher,
|
|
65
|
+
thumbnail: appDeclaration.thumbnail,
|
|
66
|
+
eventWorkflowTriggerKeyMapping: appDeclaration.eventWorkflowTriggerKeyMapping,
|
|
67
|
+
keywords: appDeclaration.keywords,
|
|
68
|
+
configProperties: ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration),
|
|
69
|
+
triggerKeyDefinitions: TriggerKeyDefinitionParser.buildTriggersArray(appDeclaration),
|
|
70
|
+
};
|
|
71
|
+
const app = await new Entities().update({ entityName: 'app', id: existingApp.id, object: updates });
|
|
72
|
+
console.log(`%s Updated app: ${app.name}`, chalk.yellow.bold('APP'));
|
|
73
|
+
return app;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public async remove(appDeclaration: AppDeclaration) {
|
|
77
|
+
let app = await this.getExistingApp(appDeclaration);
|
|
78
|
+
if (app) {
|
|
79
|
+
app = await new Entities().delete({ entityName: 'app', id: app.id });
|
|
80
|
+
console.log(`%s Deleted app: ${app.name}`, chalk.yellow.bold('APP'));
|
|
81
|
+
} else {
|
|
82
|
+
throw new Error('App not found.');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AppDeclaration, TriggerKeyDefinition, ConfigPropertyElements } from './interfaces';
|
|
2
|
+
|
|
3
|
+
export class TriggerKeyDefinitionParser {
|
|
4
|
+
public static buildTriggersArray(appDeclaration: AppDeclaration): Array<TriggerKeyDefinition> {
|
|
5
|
+
const triggers: Array<TriggerKeyDefinition> = [];
|
|
6
|
+
|
|
7
|
+
for (const triggerName of Object.keys(appDeclaration.triggers)) {
|
|
8
|
+
const triggerDeclaration = appDeclaration.triggers[triggerName];
|
|
9
|
+
|
|
10
|
+
const triggerDefinition = {
|
|
11
|
+
triggerKey: triggerDeclaration.external ? `${appDeclaration.appIdentifier}:${triggerDeclaration.key}` : triggerDeclaration.key,
|
|
12
|
+
name: triggerDeclaration.name,
|
|
13
|
+
external: triggerDeclaration.external,
|
|
14
|
+
description: triggerDeclaration.description,
|
|
15
|
+
};
|
|
16
|
+
if (!triggerDefinition.triggerKey || !triggerDefinition.name) {
|
|
17
|
+
throw new Error('Illegal trigger declaration: must have key and name');
|
|
18
|
+
}
|
|
19
|
+
triggers.push(triggerDefinition);
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
return triggers;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class ConfigPropertiesParser {
|
|
27
|
+
public static getConfigProperties(configPropertyElements: ConfigPropertyElements) {
|
|
28
|
+
const appConfiguration = [];
|
|
29
|
+
for (const configKey of Object.keys(configPropertyElements)) {
|
|
30
|
+
const declaration = configPropertyElements[configKey];
|
|
31
|
+
const config: any = {
|
|
32
|
+
label: declaration.label,
|
|
33
|
+
slug: configKey,
|
|
34
|
+
propertyType: declaration.propertyType, // TODO should support options
|
|
35
|
+
};
|
|
36
|
+
if (declaration.options) {
|
|
37
|
+
config.options = declaration.options;
|
|
38
|
+
}
|
|
39
|
+
appConfiguration.push(config);
|
|
40
|
+
}
|
|
41
|
+
return appConfiguration;
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/deploy-app/deploy.ts
CHANGED
|
@@ -1,34 +1,65 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import { authUser } from '../auth/login';
|
|
4
|
-
import { AppDeployer } from './app-deployer';
|
|
5
|
-
import {
|
|
6
|
-
const yaml = require('js-yaml');
|
|
7
|
-
|
|
8
|
-
function loadAppConfig(){
|
|
9
|
-
const TARGET_DIR = process.cwd();
|
|
10
|
-
try {
|
|
11
|
-
const doc = yaml.load(fs.readFileSync(TARGET_DIR + '/app.yml', 'utf8'));
|
|
12
|
-
console.log(doc);
|
|
13
|
-
return doc;
|
|
14
|
-
} catch (e) {
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export async function deployApp(args) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { authUser } from '../auth/login';
|
|
4
|
+
import { AppDeployer } from './app-deployer';
|
|
5
|
+
import { AppDeclaration } from './interfaces';
|
|
6
|
+
const yaml = require('js-yaml');
|
|
7
|
+
|
|
8
|
+
function loadAppConfig(){
|
|
9
|
+
const TARGET_DIR = process.cwd();
|
|
10
|
+
try {
|
|
11
|
+
const doc = yaml.load(fs.readFileSync(TARGET_DIR + '/app.yml', 'utf8'));
|
|
12
|
+
console.log(doc);
|
|
13
|
+
return doc;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function deployApp(args) {
|
|
20
|
+
let appDeclaration: AppDeclaration;
|
|
21
|
+
try {
|
|
22
|
+
appDeclaration = loadAppConfig();
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
console.log(`%s Application Deployment Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log(`%s Deploying Application. ${appDeclaration.appIdentifier}`, chalk.blue.bold('START'));
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
await authUser();
|
|
33
|
+
await new AppDeployer().deploy(appDeclaration);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
console.log(`%s Application Deployment Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
console.log('%s Deployment Complete.', chalk.green.bold('COMPLETE'));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function removeApp(args) {
|
|
44
|
+
let appDeclaration: AppDeclaration;
|
|
45
|
+
try {
|
|
46
|
+
appDeclaration = loadAppConfig();
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
console.log(`%s Application Removal Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log(`%s Removing Application. ${appDeclaration.appIdentifier}`, chalk.blue.bold('START'));
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
await authUser();
|
|
57
|
+
await new AppDeployer().remove(appDeclaration);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
console.log(`%s Application Removal Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log('%s Application Removal Complete.', chalk.green.bold('COMPLETE'));
|
|
34
65
|
}
|