@contrail/cli 1.0.30 → 1.0.32
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/.eslintrc.js +53 -0
- package/lib/apps/deploy-app/actions-deployer.js +12 -3
- package/lib/apps/deploy-app/app-deployer.js +2 -3
- package/lib/apps/deploy-app/app-template-parsers.js +1 -1
- package/lib/apps/deploy-app/docker-action-builder.d.ts +7 -7
- package/lib/apps/deploy-app/docker-action-builder.js +83 -83
- package/lib/apps/deploy-app/interfaces.d.ts +8 -8
- package/lib/apps/deploy-app/workflow-definition-deployer.js +1 -1
- package/lib/apps/deploy-app/workflow-deployer.d.ts +7 -7
- package/lib/apps/deploy-app/workflow-deployer.js +77 -77
- package/lib/auth/login.js +5 -5
- package/lib/cli.js +9 -2
- package/lib/colors/color-loader.js +8 -8
- package/lib/config/config.js +2 -2
- package/lib/interfaces.d.ts +2 -2
- package/lib/types/interfaces.js +1 -0
- package/lib/types/option-set-merger.js +2 -2
- package/lib/types/option-set-parser.js +2 -2
- package/lib/types/option-set-uploader.js +2 -2
- package/lib/types/parse-types.d.ts +1 -0
- package/lib/types/parse-types.js +47 -6
- package/lib/types/types-extractor.js +4 -4
- package/lib/types/types-properties-merger.js +2 -2
- package/lib/types/types-uploader.d.ts +1 -1
- package/lib/types/types-uploader.js +6 -6
- package/package.json +8 -6
- package/src/apps/deploy-app/actions-deployer.ts +17 -10
- package/src/apps/deploy-app/app-deployer.ts +3 -4
- package/src/apps/deploy-app/workflow-definition-deployer.ts +3 -3
- package/src/auth/login.ts +125 -125
- package/src/cli.ts +126 -120
- package/src/colors/color-loader.ts +16 -16
- package/src/config/config.ts +9 -11
- package/src/config/configCommands.ts +1 -1
- package/src/interfaces.ts +9 -10
- package/src/types/csv-parser.ts +1 -1
- package/src/types/option-set-merger.ts +9 -9
- package/src/types/option-set-parser.ts +5 -6
- package/src/types/option-set-uploader.ts +2 -2
- package/src/types/parse-types.ts +61 -12
- package/src/types/types-extractor.ts +5 -5
- package/src/types/types-properties-merger.ts +6 -6
- package/src/types/types-uploader.ts +31 -31
- package/src/workflows/workflow-template-deployer.ts +2 -4
- package/src/workflows/workflowCommands.ts +0 -1
- package/templates/javascript/actions/example/action.js +37 -37
- package/templates/typescript/actions/exampleAction.ts +1 -1
- package/templates/typescript/app.yml +1 -1
package/src/auth/login.ts
CHANGED
|
@@ -5,151 +5,151 @@ import { Auth, AuthContext } from './auth';
|
|
|
5
5
|
import { getConfig, storeConfig } from '../config/config';
|
|
6
6
|
|
|
7
7
|
const CONFIGURATION = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
userPoolId: 'us-east-1_x8hXZUsL6',
|
|
9
|
+
clientId: process.env.CONTRAIL_COGNITO_CLIENT_ID || '2oubek96sue5rsncovtqhs3scm',
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export async function authUser(): Promise<AuthContext> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
console.debug('authorizing user');
|
|
14
|
+
const config = await getConfig();
|
|
15
|
+
if (
|
|
16
|
+
config &&
|
|
17
17
|
config.apiUserToken &&
|
|
18
18
|
config.apiGateway &&
|
|
19
19
|
config.orgSlug
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
setSdkConfig(Auth.config);
|
|
28
|
-
try {
|
|
29
|
-
return await refreshCurrentUserOrg();
|
|
30
|
-
} catch (e) {
|
|
31
|
-
console.log("Token expired. Requesting auth credentials...")
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
const questions = [];
|
|
36
|
-
if (!process.env.CONTRAIL_CLI_EMAIL) {
|
|
37
|
-
questions.push({
|
|
38
|
-
type: 'input',
|
|
39
|
-
name: 'email',
|
|
40
|
-
validate: (val) => !!val,
|
|
41
|
-
message: 'Email',
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
if (!process.env.CONTRAIL_CLI_PASSWORD) {
|
|
45
|
-
questions.push({
|
|
46
|
-
type: 'password',
|
|
47
|
-
name: 'password',
|
|
48
|
-
validate: (val) => !!val,
|
|
49
|
-
message: 'Password',
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (!process.env.CONTRAIL_CLI_ORGSLUG) {
|
|
53
|
-
questions.push({
|
|
54
|
-
type: 'input',
|
|
55
|
-
name: 'orgSlug',
|
|
56
|
-
validate: (val) => !!val,
|
|
57
|
-
message: 'Org (slug)',
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const answers = await inquirer.prompt(questions);
|
|
62
|
-
const params = {
|
|
63
|
-
email: process.env.CONTRAIL_CLI_EMAIL || answers.email,
|
|
64
|
-
password: process.env.CONTRAIL_CLI_PASSWORD || answers.password,
|
|
65
|
-
orgSlug: process.env.CONTRAIL_CLI_ORGSLUG || answers.orgSlug,
|
|
20
|
+
) {
|
|
21
|
+
console.debug('populating auth config from fs config');
|
|
22
|
+
Auth.config = {
|
|
23
|
+
apiUserToken: config.apiUserToken,
|
|
24
|
+
apiGateway: config.apiGateway,
|
|
25
|
+
orgSlug: config.orgSlug,
|
|
66
26
|
};
|
|
67
|
-
|
|
68
|
-
|
|
27
|
+
setSdkConfig(Auth.config);
|
|
28
|
+
try {
|
|
29
|
+
return await refreshCurrentUserOrg();
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.log('Token expired. Requesting auth credentials...');
|
|
69
32
|
}
|
|
70
33
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
34
|
+
}
|
|
35
|
+
const questions = [];
|
|
36
|
+
if (!process.env.CONTRAIL_CLI_EMAIL) {
|
|
37
|
+
questions.push({
|
|
38
|
+
type: 'input',
|
|
39
|
+
name: 'email',
|
|
40
|
+
validate: (val) => !!val,
|
|
41
|
+
message: 'Email',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (!process.env.CONTRAIL_CLI_PASSWORD) {
|
|
45
|
+
questions.push({
|
|
46
|
+
type: 'password',
|
|
47
|
+
name: 'password',
|
|
48
|
+
validate: (val) => !!val,
|
|
49
|
+
message: 'Password',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!process.env.CONTRAIL_CLI_ORGSLUG) {
|
|
53
|
+
questions.push({
|
|
54
|
+
type: 'input',
|
|
55
|
+
name: 'orgSlug',
|
|
56
|
+
validate: (val) => !!val,
|
|
57
|
+
message: 'Org (slug)',
|
|
58
|
+
});
|
|
59
|
+
}
|
|
75
60
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
61
|
+
const answers = await inquirer.prompt(questions);
|
|
62
|
+
const params = {
|
|
63
|
+
email: process.env.CONTRAIL_CLI_EMAIL || answers.email,
|
|
64
|
+
password: process.env.CONTRAIL_CLI_PASSWORD || answers.password,
|
|
65
|
+
orgSlug: process.env.CONTRAIL_CLI_ORGSLUG || answers.orgSlug,
|
|
66
|
+
};
|
|
67
|
+
if (!params.email || !params.password) {
|
|
68
|
+
throw new Error('Email and Password required');
|
|
69
|
+
}
|
|
81
70
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
71
|
+
const poolData = {
|
|
72
|
+
UserPoolId: CONFIGURATION.userPoolId,
|
|
73
|
+
ClientId: CONFIGURATION.clientId,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
|
|
77
|
+
const authData = {
|
|
78
|
+
Username: params.email,
|
|
79
|
+
Password: params.password,
|
|
80
|
+
};
|
|
87
81
|
|
|
88
|
-
|
|
82
|
+
const authDetails = new AmazonCognitoIdentity.AuthenticationDetails(authData);
|
|
83
|
+
const userData = {
|
|
84
|
+
Username: params.email,
|
|
85
|
+
Pool: userPool,
|
|
86
|
+
};
|
|
89
87
|
|
|
90
|
-
|
|
91
|
-
cognitoUser.authenticateUser(authDetails, {
|
|
92
|
-
onSuccess: async (result) => {
|
|
93
|
-
const user = result;
|
|
94
|
-
const config = await setAuthContext(user, params);
|
|
88
|
+
const cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
|
|
95
89
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
cognitoUser.authenticateUser(authDetails, {
|
|
92
|
+
onSuccess: async (result) => {
|
|
93
|
+
const user = result;
|
|
94
|
+
const config = await setAuthContext(user, params);
|
|
95
|
+
|
|
96
|
+
resolve(config);
|
|
97
|
+
},
|
|
98
|
+
onFailure: (err) => {
|
|
99
|
+
reject(err);
|
|
100
|
+
},
|
|
102
101
|
});
|
|
102
|
+
});
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
async function setAuthContext(user, params): Promise<AuthContext> {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
106
|
+
const config = await getConfig();
|
|
107
|
+
let apiGateway;
|
|
108
|
+
console.log(config.environments);
|
|
109
|
+
if(config.environments) {
|
|
110
|
+
const questions = [];
|
|
111
|
+
questions.push({
|
|
112
|
+
type: 'list',
|
|
113
|
+
name: 'environment',
|
|
114
|
+
message: 'Which environment would you like to use?',
|
|
115
|
+
choices: Object.keys(config.environments),
|
|
116
|
+
default: Object.keys(config.environments)[0],
|
|
117
|
+
});
|
|
118
|
+
const answers = await inquirer.prompt(questions);
|
|
119
|
+
apiGateway = config.environments[answers.environment];
|
|
120
|
+
} else {
|
|
121
|
+
apiGateway = 'https://api.vibeiq.com/prod/api';
|
|
122
|
+
}
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
// Set Auth Config
|
|
125
|
+
Auth.config = {
|
|
126
|
+
apiUserToken: user.idToken.jwtToken,
|
|
127
|
+
apiGateway,
|
|
128
|
+
orgSlug: params.orgSlug,
|
|
129
|
+
};
|
|
130
|
+
// SET SDK CONFIG
|
|
131
|
+
setSdkConfig(Auth.config);
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
return refreshCurrentUserOrg();
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
async function refreshCurrentUserOrg() {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
137
|
+
console.debug('refreshing current user org');
|
|
138
|
+
const currentUser = await Request.request('/users/current', {
|
|
139
|
+
method: 'GET',
|
|
140
|
+
headers: {
|
|
141
|
+
Accept: 'application/json',
|
|
142
|
+
'Content-Type': 'application/json',
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
if (!currentUser) {
|
|
146
|
+
throw Error('Could not get current user');
|
|
147
|
+
}
|
|
148
|
+
const org = currentUser.orgs.find(o => o.orgSlug === Auth.config.orgSlug);
|
|
149
|
+
if (org) {
|
|
150
|
+
Auth.config.orgId = org.orgId || org.id;
|
|
151
|
+
}
|
|
152
|
+
// cache config in the fs
|
|
153
|
+
storeConfig(Object.assign({}, Auth.config));
|
|
154
|
+
return Object.assign({}, Auth.config);
|
|
155
|
+
}
|
package/src/cli.ts
CHANGED
|
@@ -7,9 +7,9 @@ import { UploadOptionSets } from './types/option-set-uploader';
|
|
|
7
7
|
import { ParseOptionSetsLocalFiles } from './types/option-set-parser';
|
|
8
8
|
import { MergeOptionSets } from './types/option-set-merger';
|
|
9
9
|
import { MergeTypeProperties } from './types/types-properties-merger';
|
|
10
|
-
import { ParseTypesFromFiles, ParseTypesFromLocalFiles } from './types/parse-types';
|
|
10
|
+
import { ParseTypesFromFiles, ParseTypesFromLocalFiles, ParseTypesFromTemplateFromLocalFiles } from './types/parse-types';
|
|
11
11
|
import { loadColors, deleteColors } from './colors/color-loader';
|
|
12
|
-
import {listConfig, removeConfig} from './config/configCommands'
|
|
12
|
+
import {listConfig, removeConfig} from './config/configCommands';
|
|
13
13
|
import {deleteWorkflowTemplate, deployWorkflowTemplate, listWorkflowTemplate} from './workflows/workflowCommands';
|
|
14
14
|
const cliUsage = require('command-line-usage');
|
|
15
15
|
|
|
@@ -42,128 +42,132 @@ export async function cli(args) {
|
|
|
42
42
|
command = commandParts[1];
|
|
43
43
|
|
|
44
44
|
switch (domain) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
case 'deploy': {
|
|
52
|
-
deployApp(args);
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
case 'remove': {
|
|
56
|
-
removeApp(args);
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
default: {
|
|
60
|
-
printIllegalCommand();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
case 'types': {
|
|
66
|
-
switch (command) {
|
|
67
|
-
case 'getAll': {
|
|
68
|
-
getTypes(args);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case 'uploadTypes': {
|
|
72
|
-
uploadTypes(args);
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
case 'uploadOptionSets': {
|
|
76
|
-
UploadOptionSets(args);
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
case 'parseOptionSetsLocalFiles': {
|
|
80
|
-
ParseOptionSetsLocalFiles(args);
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case 'parseTypesFromLocalFiles': {
|
|
84
|
-
ParseTypesFromLocalFiles(args);
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
case 'parseTypesFromFiles': {
|
|
88
|
-
ParseTypesFromFiles(args);
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case 'mergeOptionSets': {
|
|
92
|
-
MergeOptionSets(args);
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case 'mergeTypeProperties': {
|
|
96
|
-
MergeTypeProperties(args);
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
default: {
|
|
100
|
-
printIllegalCommand();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
45
|
+
case 'app': {
|
|
46
|
+
switch (command) {
|
|
47
|
+
case 'create': {
|
|
48
|
+
create(args);
|
|
103
49
|
break;
|
|
104
50
|
}
|
|
51
|
+
case 'deploy': {
|
|
52
|
+
deployApp(args);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case 'remove': {
|
|
56
|
+
removeApp(args);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
default: {
|
|
60
|
+
printIllegalCommand();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case 'types': {
|
|
66
|
+
switch (command) {
|
|
67
|
+
case 'getAll': {
|
|
68
|
+
getTypes(args);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case 'uploadTypes': {
|
|
72
|
+
uploadTypes();
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case 'uploadOptionSets': {
|
|
76
|
+
UploadOptionSets(args);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case 'parseOptionSetsLocalFiles': {
|
|
80
|
+
ParseOptionSetsLocalFiles(args);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case 'parseTypesFromLocalFiles': {
|
|
84
|
+
ParseTypesFromLocalFiles(args);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case 'parseTypesFromTemplateFromLocalFiles': {
|
|
88
|
+
ParseTypesFromTemplateFromLocalFiles(args);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 'parseTypesFromFiles': {
|
|
92
|
+
ParseTypesFromFiles(args);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case 'mergeOptionSets': {
|
|
96
|
+
MergeOptionSets(args);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case 'mergeTypeProperties': {
|
|
100
|
+
MergeTypeProperties(args);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
default: {
|
|
104
|
+
printIllegalCommand();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
105
109
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
default: {
|
|
137
|
-
printIllegalCommand();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
case 'config': {
|
|
143
|
-
switch (command) {
|
|
144
|
-
case 'list': {
|
|
145
|
-
await listConfig();
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
case 'remove': {
|
|
149
|
-
await removeConfig(args);
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
default: {
|
|
153
|
-
printIllegalCommand();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
case 'help':
|
|
159
|
-
case '-help':
|
|
160
|
-
case '--help': {
|
|
161
|
-
printHelp();
|
|
110
|
+
case 'colors': {
|
|
111
|
+
switch (command) {
|
|
112
|
+
case 'load': {
|
|
113
|
+
await loadColors();
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case 'delete': {
|
|
117
|
+
await deleteColors();
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
default: {
|
|
121
|
+
printIllegalCommand();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case 'workflow-templates': {
|
|
127
|
+
switch (command) {
|
|
128
|
+
case 'load': {
|
|
129
|
+
await deployWorkflowTemplate();
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case 'delete': {
|
|
133
|
+
await deleteWorkflowTemplate();
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case 'list': {
|
|
137
|
+
await listWorkflowTemplate();
|
|
162
138
|
break;
|
|
163
139
|
}
|
|
164
140
|
default: {
|
|
165
141
|
printIllegalCommand();
|
|
166
142
|
}
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case 'config': {
|
|
147
|
+
switch (command) {
|
|
148
|
+
case 'list': {
|
|
149
|
+
await listConfig();
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case 'remove': {
|
|
153
|
+
await removeConfig(args);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
default: {
|
|
157
|
+
printIllegalCommand();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case 'help':
|
|
163
|
+
case '-help':
|
|
164
|
+
case '--help': {
|
|
165
|
+
printHelp();
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
default: {
|
|
169
|
+
printIllegalCommand();
|
|
170
|
+
}
|
|
167
171
|
}
|
|
168
172
|
}
|
|
169
173
|
|
|
@@ -235,16 +239,18 @@ const helpSections = [
|
|
|
235
239
|
'parseOptionSetsLocalFiles <File Paths> Parse CSV files into OptionSets',
|
|
236
240
|
'parseTypesFromLocalFiles <File Paths> Parse CSV files into Types and ',
|
|
237
241
|
'. OptionSets from local files.\n',
|
|
242
|
+
'parseTypesFromTemplateFromLocalFiles <File Paths> Parse CSV files into ',
|
|
243
|
+
'. Types and OptionSets from local files.\n',
|
|
238
244
|
'parseTypesFromFiles <fileIds> Parse CSV files into Types and ',
|
|
239
245
|
'. OptionSets from VibeIQ Files.\n',
|
|
240
246
|
'mergeOptionSets <File Path> Merge the OptionSets from an existing',
|
|
241
|
-
'. org and the OptionSets passed in.',
|
|
247
|
+
'. org and the OptionSets passed in.',
|
|
242
248
|
'. File must be .yml\n',
|
|
243
|
-
'mergeTypeProperties <File Path> <TypePaths> ',
|
|
249
|
+
'mergeTypeProperties <File Path> <TypePaths> ',
|
|
244
250
|
'. Merge the TypeProperties from an existing',
|
|
245
251
|
'. org and the TypeProperties passed in.',
|
|
246
|
-
'. Add to Types via TypePath',
|
|
252
|
+
'. Add to Types via TypePath',
|
|
247
253
|
'. File must be .yml\n',
|
|
248
254
|
],
|
|
249
255
|
},
|
|
250
|
-
];
|
|
256
|
+
];
|
|
@@ -3,7 +3,7 @@ import chalk from 'chalk';
|
|
|
3
3
|
import { authUser } from '../auth/login';
|
|
4
4
|
import { getSeparatorByPlatform } from '../common';
|
|
5
5
|
|
|
6
|
-
const csv = require('csvtojson')
|
|
6
|
+
const csv = require('csvtojson');
|
|
7
7
|
|
|
8
8
|
interface Color {
|
|
9
9
|
name: string;
|
|
@@ -17,7 +17,7 @@ export async function deleteColors() {
|
|
|
17
17
|
try {
|
|
18
18
|
await authUser();
|
|
19
19
|
const colors = await getExistingColors();
|
|
20
|
-
console.log(
|
|
20
|
+
console.log('Deleting %s colors', colors.length);
|
|
21
21
|
for (const color of colors) {
|
|
22
22
|
await deleteColor(color);
|
|
23
23
|
}
|
|
@@ -32,10 +32,10 @@ export async function deleteColors() {
|
|
|
32
32
|
export async function loadColors() {
|
|
33
33
|
try {
|
|
34
34
|
await authUser();
|
|
35
|
-
console.log(
|
|
36
|
-
console.log(
|
|
35
|
+
console.log('%s Getting Existing Colors', chalk.yellow.bold('COLORS'));
|
|
36
|
+
console.log('%s Uploading', chalk.yellow.bold('COLORS'));
|
|
37
37
|
await uploadColors();
|
|
38
|
-
console.log(
|
|
38
|
+
console.log('%s Uploaded', chalk.yellow.bold('COLORS'));
|
|
39
39
|
|
|
40
40
|
}
|
|
41
41
|
catch (e) {
|
|
@@ -47,23 +47,23 @@ export async function loadColors() {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async function getLocalColors() {
|
|
50
|
-
console.log(
|
|
50
|
+
console.log('loading colors from local file');
|
|
51
51
|
const TARGET_DIR = process.cwd();
|
|
52
52
|
try {
|
|
53
53
|
const separator = getSeparatorByPlatform();
|
|
54
54
|
|
|
55
|
-
const csvFilePath = TARGET_DIR + separator + 'colors.csv'
|
|
56
|
-
return await csv().fromFile(csvFilePath)
|
|
55
|
+
const csvFilePath = TARGET_DIR + separator + 'colors.csv';
|
|
56
|
+
return await csv().fromFile(csvFilePath);
|
|
57
57
|
} catch (e) {
|
|
58
58
|
throw new Error(`ERROR PARSING COLORS CSV: ${e}`);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
async function getExistingColors() {
|
|
63
|
-
console.log(
|
|
63
|
+
console.log('%s Getting Existing Colors', chalk.yellow.bold('COLORS'));
|
|
64
64
|
try {
|
|
65
65
|
const result = await new Entities().get({ entityName: 'color', take: 3000}); //, useSearch: false }); Not in EntitiesClientGetOptions yet
|
|
66
|
-
console.log(
|
|
66
|
+
console.log('Found %s existing colors', result.length);
|
|
67
67
|
return result;
|
|
68
68
|
} catch (e) {
|
|
69
69
|
throw new Error(`ERROR DOWNLOADING COLORS: ${e}`);
|
|
@@ -81,10 +81,10 @@ async function deleteColor(color) {
|
|
|
81
81
|
async function uploadColors() {
|
|
82
82
|
const colors: Color[] = await getLocalColors();
|
|
83
83
|
const existingColors = await getExistingColors();
|
|
84
|
-
const existingNamesValues = existingColors.filter(x => x.name).map(x => x.name)
|
|
84
|
+
const existingNamesValues = existingColors.filter(x => x.name).map(x => x.name);
|
|
85
85
|
for (const color of colors) {
|
|
86
86
|
if (existingNamesValues.includes(color.name)) {
|
|
87
|
-
console.log(
|
|
87
|
+
console.log('%s SKIPPING %s (%s)', chalk.yellow.bold('COLORS'), color.hex, color.name);
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
90
|
if (color.hex.length > 1 && color.hex[0] === '#') {
|
|
@@ -93,15 +93,15 @@ async function uploadColors() {
|
|
|
93
93
|
const o: any = {
|
|
94
94
|
hex: color.hex,
|
|
95
95
|
name: color.name
|
|
96
|
-
}
|
|
96
|
+
};
|
|
97
97
|
if (color.red) {
|
|
98
|
-
o.red = color.red
|
|
98
|
+
o.red = color.red;
|
|
99
99
|
}
|
|
100
100
|
if (color.green) {
|
|
101
|
-
o.green = color.green
|
|
101
|
+
o.green = color.green;
|
|
102
102
|
}
|
|
103
103
|
if (color.blue) {
|
|
104
|
-
o.blue = color.blue
|
|
104
|
+
o.blue = color.blue;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
await new Entities().create({
|