@contrail/cli 1.0.44 → 1.0.46
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/lib/cli.js +13 -0
- package/lib/projects/interfaces.d.ts +35 -0
- package/lib/projects/interfaces.js +15 -0
- package/lib/projects/project-uploader.d.ts +1 -0
- package/lib/projects/project-uploader.js +47 -0
- package/package.json +3 -3
- package/src/cli.ts +14 -0
- package/src/projects/interfaces.ts +35 -0
- package/src/projects/project-uploader.ts +59 -0
package/lib/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ import { deleteWorkflowTemplates, localDeployWorkflowTemplate, listWorkflowTempl
|
|
|
13
13
|
import { installApp, uninstallApp } from './apps/install-app/app-installer';
|
|
14
14
|
import { upgradeApp } from './apps/upgrade-app/app-upgrader';
|
|
15
15
|
import { cliInstallWorkflowTemplateDefinitions, listWorkflowTemplateDefinitions } from './workflow-template-definitions/workflow-template-definition-commands';
|
|
16
|
+
import { configureProject } from './projects/project-uploader';
|
|
16
17
|
const cliUsage = require('command-line-usage');
|
|
17
18
|
/**
|
|
18
19
|
* Built using documentation here:
|
|
@@ -135,6 +136,18 @@ export async function cli(args) {
|
|
|
135
136
|
}
|
|
136
137
|
break;
|
|
137
138
|
}
|
|
139
|
+
case 'projects': {
|
|
140
|
+
switch (command) {
|
|
141
|
+
case 'configure': {
|
|
142
|
+
await configureProject(args);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
default: {
|
|
146
|
+
printIllegalCommand();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
138
151
|
case 'workflow-templates': {
|
|
139
152
|
switch (command) {
|
|
140
153
|
case 'load': {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare class CommonConfiguration {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}
|
|
4
|
+
export declare enum AssortmentType {
|
|
5
|
+
ASSORTMENT = "ASSORTMENT",
|
|
6
|
+
BOARD = "BOARD",
|
|
7
|
+
PLAN = "PLAN",
|
|
8
|
+
SHOWCASE = "SHOWCASE"
|
|
9
|
+
}
|
|
10
|
+
export declare class AssortmentConfiguration {
|
|
11
|
+
identifier: string;
|
|
12
|
+
name: string;
|
|
13
|
+
type: AssortmentType;
|
|
14
|
+
sourceAssortmentIdentifier?: string;
|
|
15
|
+
composedFromAssortmentIdentifiers?: string[];
|
|
16
|
+
ownerAtts?: {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
assortmentAtts?: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare class Folder {
|
|
24
|
+
identifier: string;
|
|
25
|
+
name: string;
|
|
26
|
+
assortments: AssortmentConfiguration[];
|
|
27
|
+
subFolders: Folder[];
|
|
28
|
+
}
|
|
29
|
+
export declare class ProjectConfiguration {
|
|
30
|
+
projectName: string;
|
|
31
|
+
identifier: string;
|
|
32
|
+
commonConfig: CommonConfiguration;
|
|
33
|
+
assortments: AssortmentConfiguration[];
|
|
34
|
+
subFolders: Folder[];
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class CommonConfiguration {
|
|
2
|
+
}
|
|
3
|
+
export var AssortmentType;
|
|
4
|
+
(function (AssortmentType) {
|
|
5
|
+
AssortmentType["ASSORTMENT"] = "ASSORTMENT";
|
|
6
|
+
AssortmentType["BOARD"] = "BOARD";
|
|
7
|
+
AssortmentType["PLAN"] = "PLAN";
|
|
8
|
+
AssortmentType["SHOWCASE"] = "SHOWCASE";
|
|
9
|
+
})(AssortmentType || (AssortmentType = {}));
|
|
10
|
+
export class AssortmentConfiguration {
|
|
11
|
+
}
|
|
12
|
+
export class Folder {
|
|
13
|
+
}
|
|
14
|
+
export class ProjectConfiguration {
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function configureProject(args: any): Promise<void>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Request } from '@contrail/sdk';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { authUser } from '../auth/login';
|
|
5
|
+
import { getSeparatorByPlatform } from '../common';
|
|
6
|
+
import yaml from 'js-yaml';
|
|
7
|
+
export async function configureProject(args) {
|
|
8
|
+
try {
|
|
9
|
+
await authUser();
|
|
10
|
+
console.log('%s Parsing Template.', chalk.blue.bold('START'));
|
|
11
|
+
console.log('%s Uploading', chalk.yellow.bold('PROJECT'));
|
|
12
|
+
const templateFileLocation = args[3];
|
|
13
|
+
console.log('Using Template File Location: ', templateFileLocation);
|
|
14
|
+
await uploadProject(templateFileLocation);
|
|
15
|
+
console.log('%s Uploaded', chalk.yellow.bold('PROJECT'));
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.log(`%s Project Upload Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log('%s Project Upload Complete.', chalk.green.bold('COMPLETE'));
|
|
22
|
+
}
|
|
23
|
+
function getProjectFile(fileName) {
|
|
24
|
+
const CURRENT_DIR = process.cwd();
|
|
25
|
+
try {
|
|
26
|
+
const separator = getSeparatorByPlatform();
|
|
27
|
+
const fullPath = CURRENT_DIR + separator + fileName;
|
|
28
|
+
console.log('Getting file from path: ', fullPath);
|
|
29
|
+
const doc = yaml.load(fs.readFileSync(fullPath, 'utf8'));
|
|
30
|
+
return doc.projectConfiguration;
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function uploadProject(templateFileLocation) {
|
|
37
|
+
const projectConfiguration = getProjectFile(templateFileLocation);
|
|
38
|
+
console.log('Configuring Project.');
|
|
39
|
+
await Request.request('/project-configurator', {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
body: JSON.stringify(projectConfiguration),
|
|
42
|
+
headers: {
|
|
43
|
+
Accept: 'application/json',
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"description": "VibeIQ's Contrail Platform CLI.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@contrail/sdk": "^1.
|
|
27
|
-
"@contrail/types": "^
|
|
26
|
+
"@contrail/sdk": "^1.1.43",
|
|
27
|
+
"@contrail/types": "^3.0.20",
|
|
28
28
|
"@contrail/util": "^1.0.17",
|
|
29
29
|
"amazon-cognito-identity-js": "^5.2.3",
|
|
30
30
|
"arg": "^4.0.1",
|
package/src/cli.ts
CHANGED
|
@@ -14,6 +14,8 @@ import { deleteWorkflowTemplates, localDeployWorkflowTemplate, listWorkflowTempl
|
|
|
14
14
|
import { installApp, uninstallApp } from './apps/install-app/app-installer';
|
|
15
15
|
import { upgradeApp } from './apps/upgrade-app/app-upgrader';
|
|
16
16
|
import { cliInstallWorkflowTemplateDefinitions, listWorkflowTemplateDefinitions } from './workflow-template-definitions/workflow-template-definition-commands';
|
|
17
|
+
import { configureProject } from './projects/project-uploader';
|
|
18
|
+
|
|
17
19
|
const cliUsage = require('command-line-usage');
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -145,6 +147,18 @@ export async function cli(args) {
|
|
|
145
147
|
}
|
|
146
148
|
break;
|
|
147
149
|
}
|
|
150
|
+
case 'projects': {
|
|
151
|
+
switch (command) {
|
|
152
|
+
case 'configure': {
|
|
153
|
+
await configureProject(args);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
default: {
|
|
157
|
+
printIllegalCommand();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
148
162
|
case 'workflow-templates': {
|
|
149
163
|
switch (command) {
|
|
150
164
|
case 'load': {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export class CommonConfiguration {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export enum AssortmentType {
|
|
6
|
+
ASSORTMENT = 'ASSORTMENT',
|
|
7
|
+
BOARD = 'BOARD',
|
|
8
|
+
PLAN = 'PLAN',
|
|
9
|
+
SHOWCASE = 'SHOWCASE',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class AssortmentConfiguration {
|
|
13
|
+
identifier: string;
|
|
14
|
+
name: string;
|
|
15
|
+
type: AssortmentType;
|
|
16
|
+
sourceAssortmentIdentifier?: string;
|
|
17
|
+
composedFromAssortmentIdentifiers?: string[];
|
|
18
|
+
ownerAtts?: {[key: string]: any};
|
|
19
|
+
assortmentAtts?: {[key: string]: any};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class Folder {
|
|
23
|
+
identifier: string;
|
|
24
|
+
name: string;
|
|
25
|
+
assortments: AssortmentConfiguration[];
|
|
26
|
+
subFolders: Folder[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class ProjectConfiguration {
|
|
30
|
+
projectName: string;
|
|
31
|
+
identifier: string;
|
|
32
|
+
commonConfig: CommonConfiguration;
|
|
33
|
+
assortments: AssortmentConfiguration[];
|
|
34
|
+
subFolders: Folder[];
|
|
35
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Request } from '@contrail/sdk';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { authUser } from '../auth/login';
|
|
5
|
+
import { getSeparatorByPlatform } from '../common';
|
|
6
|
+
import { ProjectConfiguration } from './interfaces';
|
|
7
|
+
|
|
8
|
+
import yaml from 'js-yaml';
|
|
9
|
+
|
|
10
|
+
export async function configureProject(args) {
|
|
11
|
+
try {
|
|
12
|
+
await authUser();
|
|
13
|
+
console.log('%s Parsing Template.', chalk.blue.bold('START'));
|
|
14
|
+
|
|
15
|
+
console.log('%s Uploading', chalk.yellow.bold('PROJECT'));
|
|
16
|
+
const templateFileLocation = args[3];
|
|
17
|
+
console.log('Using Template File Location: ', templateFileLocation);
|
|
18
|
+
await uploadProject(templateFileLocation);
|
|
19
|
+
console.log('%s Uploaded', chalk.yellow.bold('PROJECT'));
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
console.log(`%s Project Upload Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
console.log('%s Project Upload Complete.', chalk.green.bold('COMPLETE'));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getProjectFile(fileName){
|
|
31
|
+
const CURRENT_DIR = process.cwd();
|
|
32
|
+
try {
|
|
33
|
+
const separator = getSeparatorByPlatform();
|
|
34
|
+
const fullPath = CURRENT_DIR + separator + fileName;
|
|
35
|
+
console.log('Getting file from path: ', fullPath);
|
|
36
|
+
|
|
37
|
+
const doc = yaml.load(fs.readFileSync(fullPath, 'utf8'));
|
|
38
|
+
return doc.projectConfiguration;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function uploadProject(templateFileLocation) {
|
|
45
|
+
const projectConfiguration: ProjectConfiguration[] = getProjectFile(templateFileLocation);
|
|
46
|
+
console.log('Configuring Project.');
|
|
47
|
+
|
|
48
|
+
await Request.request(
|
|
49
|
+
'/project-configurator',
|
|
50
|
+
{
|
|
51
|
+
method: 'POST',
|
|
52
|
+
body: JSON.stringify(projectConfiguration),
|
|
53
|
+
headers: {
|
|
54
|
+
Accept: 'application/json',
|
|
55
|
+
'Content-Type': 'application/json',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
}
|