@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.
Files changed (53) hide show
  1. package/.vscode/settings.json +5 -5
  2. package/bin/init +3 -3
  3. package/lib/auth/auth.d.ts +9 -9
  4. package/lib/auth/auth.js +2 -2
  5. package/lib/auth/login.d.ts +1 -1
  6. package/lib/auth/login.js +112 -96
  7. package/lib/cli.d.ts +5 -5
  8. package/lib/cli.js +30 -30
  9. package/lib/create-app/create.d.ts +1 -1
  10. package/lib/create-app/create.js +63 -48
  11. package/lib/create-app/setup-template.d.ts +1 -1
  12. package/lib/create-app/setup-template.js +34 -48
  13. package/lib/deploy-app/actions-deployer.d.ts +10 -10
  14. package/lib/deploy-app/actions-deployer.js +86 -75
  15. package/lib/deploy-app/app-deployer.d.ts +8 -10
  16. package/lib/deploy-app/app-deployer.js +79 -84
  17. package/lib/deploy-app/app-template-parsers.d.ts +7 -0
  18. package/lib/deploy-app/app-template-parsers.js +37 -0
  19. package/lib/deploy-app/deploy.d.ts +2 -2
  20. package/lib/deploy-app/deploy.js +56 -30
  21. package/lib/deploy-app/interfaces.d.ts +74 -43
  22. package/lib/deploy-app/interfaces.js +4 -0
  23. package/package.json +63 -63
  24. package/publish.sh +5 -0
  25. package/src/auth/auth.ts +9 -9
  26. package/src/auth/login.ts +124 -107
  27. package/src/cli.ts +32 -33
  28. package/src/create-app/create.ts +73 -58
  29. package/src/create-app/setup-template.ts +37 -56
  30. package/src/deploy-app/actions-deployer.ts +109 -84
  31. package/src/deploy-app/app-deployer.ts +86 -89
  32. package/src/deploy-app/app-template-parsers.ts +43 -0
  33. package/src/deploy-app/deploy.ts +64 -33
  34. package/src/deploy-app/interfaces.ts +78 -43
  35. package/templates/javascript/actions/example/action.js +37 -37
  36. package/templates/javascript/app.yml +54 -42
  37. package/templates/javascript/package.json +23 -23
  38. package/templates/javascript/set_auth.bat +3 -0
  39. package/templates/javascript/set_auth.sh +3 -0
  40. package/templates/typescript/actions/exampleAction.ts +38 -0
  41. package/templates/typescript/app.yml +56 -0
  42. package/templates/typescript/package.json +24 -0
  43. package/templates/typescript/set_auth.bat +3 -0
  44. package/templates/typescript/set_auth.sh +3 -0
  45. package/templates/typescript/tsconfig.json +31 -0
  46. package/tsconfig.json +22 -22
  47. package/tslint.json +57 -57
  48. package/lib/deploy-app/actions.d.ts +0 -5
  49. package/lib/deploy-app/actions.js +0 -17
  50. package/lib/deploy-app/app-declaration.d.ts +0 -20
  51. package/lib/deploy-app/app-declaration.js +0 -0
  52. package/lib/deploy-app/app.d.ts +0 -8
  53. package/lib/deploy-app/app.js +0 -56
package/tslint.json CHANGED
@@ -1,57 +1,57 @@
1
- {
2
- "defaultSeverity": "error",
3
- "extends": [
4
- "tslint:recommended"
5
- ],
6
- "jsRules": {
7
- "no-unused-expression": true
8
- },
9
- "rules": {
10
- "eofline": false,
11
- "quotemark": [
12
- true,
13
- "single"
14
- ],
15
- "no-shadowed-variable": false,
16
- "indent": false,
17
- "member-access": [
18
- false
19
- ],
20
- "no-string-literal": false,
21
- "ordered-imports": [
22
- false
23
- ],
24
- "max-line-length": [
25
- false,
26
- 150
27
- ],
28
- "member-ordering": [
29
- false
30
- ],
31
- "curly": false,
32
- "interface-name": [
33
- false
34
- ],
35
- "array-type": [
36
- false
37
- ],
38
- "no-empty-interface": false,
39
- "no-empty": false,
40
- "arrow-parens": false,
41
- "object-literal-sort-keys": false,
42
- "no-unused-expression": false,
43
- "max-classes-per-file": [
44
- false
45
- ],
46
- "variable-name": [
47
- false
48
- ],
49
- "one-line": [
50
- false
51
- ],
52
- "one-variable-per-declaration": [
53
- false
54
- ]
55
- },
56
- "rulesDirectory": []
57
- }
1
+ {
2
+ "defaultSeverity": "error",
3
+ "extends": [
4
+ "tslint:recommended"
5
+ ],
6
+ "jsRules": {
7
+ "no-unused-expression": true
8
+ },
9
+ "rules": {
10
+ "eofline": false,
11
+ "quotemark": [
12
+ true,
13
+ "single"
14
+ ],
15
+ "no-shadowed-variable": false,
16
+ "indent": false,
17
+ "member-access": [
18
+ false
19
+ ],
20
+ "no-string-literal": false,
21
+ "ordered-imports": [
22
+ false
23
+ ],
24
+ "max-line-length": [
25
+ false,
26
+ 150
27
+ ],
28
+ "member-ordering": [
29
+ false
30
+ ],
31
+ "curly": false,
32
+ "interface-name": [
33
+ false
34
+ ],
35
+ "array-type": [
36
+ false
37
+ ],
38
+ "no-empty-interface": false,
39
+ "no-empty": false,
40
+ "arrow-parens": false,
41
+ "object-literal-sort-keys": false,
42
+ "no-unused-expression": false,
43
+ "max-classes-per-file": [
44
+ false
45
+ ],
46
+ "variable-name": [
47
+ false
48
+ ],
49
+ "one-line": [
50
+ false
51
+ ],
52
+ "one-variable-per-declaration": [
53
+ false
54
+ ]
55
+ },
56
+ "rulesDirectory": []
57
+ }
@@ -1,5 +0,0 @@
1
- import { AppDeclartion } from './app-declaration';
2
- export interface EventWorkflowActionDefinition {
3
- id?: string;
4
- }
5
- export declare function deployActions(appDeclaration: AppDeclartion): Promise<void>;
@@ -1,17 +0,0 @@
1
- import { Entities } from '@contrail/sdk';
2
- import chalk from 'chalk';
3
- export async function deployActions(appDeclaration) {
4
- // FETCH ALL ACTIONS FROM THE API.
5
- // UPSERT / DELETE BASED ON ACTION IDENTIFIER
6
- console.log('%s \tDeploying actions.', chalk.yellow.bold('ACTION'));
7
- for (const action of Object.keys(appDeclaration.actions)) {
8
- console.log(`%s \tDeploying action: ${action}`, chalk.yellow.bold('ACTION'));
9
- }
10
- }
11
- /**
12
- *
13
- */
14
- async function getActionsForApp() {
15
- const workspaces = await new Entities().get({ entityName: 'event-workflow-actions' });
16
- console.log('workspaces: ', workspaces);
17
- }
@@ -1,20 +0,0 @@
1
- /** Describes the derivative JSON / object represented
2
- * in app.yml file.
3
- */
4
- export interface AppDeclartion {
5
- appIdentifier: string;
6
- appName: string;
7
- appDescription?: string;
8
- visibility: 'private' | 'public';
9
- publisher: string;
10
- version: string;
11
- thumbnail?: string;
12
- actions?: {
13
- [key: string]: AppActionDeclaration;
14
- };
15
- }
16
- export interface AppActionDeclaration {
17
- handler: string;
18
- name: string;
19
- description?: string;
20
- }
File without changes
@@ -1,8 +0,0 @@
1
- import { AppDeclartion } from './app-declaration';
2
- export declare class AppDeployer {
3
- deploy(appDeclaration: AppDeclartion): Promise<void>;
4
- remove(appDeclaration: AppDeclartion): Promise<void>;
5
- getExistingApp(appDeclaration: AppDeclartion): Promise<any>;
6
- updateExistingApp(appDeclaration: AppDeclartion, existingApp: any): Promise<any>;
7
- private createNewApp;
8
- }
@@ -1,56 +0,0 @@
1
- import { Entities } from '@contrail/sdk';
2
- import chalk from 'chalk';
3
- export class AppDeployer {
4
- async deploy(appDeclaration) {
5
- let app = await this.getExistingApp(appDeclaration);
6
- if (!app) {
7
- app = await this.createNewApp(appDeclaration);
8
- }
9
- else {
10
- app = await this.updateExistingApp(appDeclaration, app);
11
- }
12
- }
13
- async remove(appDeclaration) {
14
- const app = await this.getExistingApp(appDeclaration);
15
- if (app) {
16
- await new Entities().delete({ entityName: 'app', id: app.id });
17
- console.log(`%s Deleted app: ${app.name}`, chalk.yellow.bold('APP'));
18
- }
19
- else {
20
- console.log(`%s App not found. Can not remove`, chalk.red.bold('APP'));
21
- }
22
- }
23
- async getExistingApp(appDeclaration) {
24
- const apps = await new Entities().get({ entityName: 'app', criteria: { orgId: '-VMrLJrt3clDKPi0', private: (appDeclaration.visibility === 'private') } });
25
- console.log('Existing: ', apps);
26
- const existing = apps.find(app => app.identifier === appDeclaration.appIdentifier);
27
- return existing;
28
- }
29
- async updateExistingApp(appDeclaration, existingApp) {
30
- const updates = {
31
- name: appDeclaration.appName,
32
- public: appDeclaration.visibility === 'public',
33
- description: appDeclaration.appDescription,
34
- publisher: appDeclaration.publisher,
35
- thumbnail: appDeclaration.thumbnail,
36
- eventWorkflowTriggerKeyMapping: 'NONE',
37
- };
38
- const app = await new Entities().update({ entityName: 'app', id: existingApp.id, object: updates });
39
- console.log(`%s Updated app: ${app.name}`, chalk.yellow.bold('APP'));
40
- return app;
41
- }
42
- async createNewApp(appDeclaration) {
43
- const newApp = {
44
- identifier: appDeclaration.appIdentifier,
45
- name: appDeclaration.appName,
46
- public: appDeclaration.visibility === 'public',
47
- description: appDeclaration.appDescription,
48
- publisher: appDeclaration.publisher,
49
- thumbnail: appDeclaration.thumbnail,
50
- eventWorkflowTriggerKeyMapping: 'NONE',
51
- };
52
- const app = await new Entities().create({ entityName: 'app', object: newApp });
53
- console.log(`%s Created new app: ${app.name}`, chalk.yellow.bold('APP'));
54
- return app;
55
- }
56
- }