@contrail/cli 1.0.71 → 2.0.1
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/LICENSE +21 -0
- package/README.md +1034 -5
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/{lib → dist}/api/apps.d.ts +13 -13
- package/dist/api/apps.js +96 -0
- package/{lib → dist}/api/event-workflow-action-definition.d.ts +1 -1
- package/dist/api/event-workflow-action-definition.js +11 -0
- package/{lib → dist}/api/event-workflow-template-definition.d.ts +6 -6
- package/dist/api/event-workflow-template-definition.js +26 -0
- package/{lib → dist}/api/event-workflow-templates.d.ts +7 -7
- package/dist/api/event-workflow-templates.js +32 -0
- package/dist/api/types.d.ts +7 -0
- package/dist/api/types.js +52 -0
- package/{lib → dist}/auth/auth.d.ts +9 -9
- package/dist/auth/auth.js +6 -0
- package/{lib → dist}/auth/login.d.ts +2 -2
- package/{lib → dist}/auth/login.js +146 -141
- package/dist/commands/app/create.d.ts +6 -0
- package/dist/commands/app/create.js +15 -0
- package/dist/commands/app/delete.d.ts +7 -0
- package/dist/commands/app/delete.js +38 -0
- package/dist/commands/app/install.d.ts +11 -0
- package/dist/commands/app/install.js +117 -0
- package/dist/commands/app/publish.d.ts +7 -0
- package/dist/commands/app/publish.js +45 -0
- package/dist/commands/app/uninstall.d.ts +10 -0
- package/dist/commands/app/uninstall.js +58 -0
- package/dist/commands/app/upgrade.d.ts +11 -0
- package/dist/commands/app/upgrade.js +79 -0
- package/dist/commands/colors/deleteAll.d.ts +6 -0
- package/dist/commands/colors/deleteAll.js +30 -0
- package/dist/commands/colors/load.d.ts +6 -0
- package/dist/commands/colors/load.js +29 -0
- package/dist/commands/config/list.d.ts +6 -0
- package/dist/commands/config/list.js +15 -0
- package/dist/commands/config/remove.d.ts +14 -0
- package/dist/commands/config/remove.js +26 -0
- package/dist/commands/config/set.d.ts +13 -0
- package/dist/commands/config/set.js +29 -0
- package/dist/commands/loader-process/load.d.ts +9 -0
- package/dist/commands/loader-process/load.js +33 -0
- package/dist/commands/loader-process/upload-and-load.d.ts +10 -0
- package/dist/commands/loader-process/upload-and-load.js +35 -0
- package/dist/commands/projects/export.d.ts +10 -0
- package/dist/commands/projects/export.js +34 -0
- package/dist/commands/projects/list.d.ts +6 -0
- package/dist/commands/projects/list.js +34 -0
- package/dist/commands/projects/load.d.ts +9 -0
- package/{lib/projects/project-uploader.js → dist/commands/projects/load.js} +106 -105
- package/dist/commands/types/exportOptionSetHierarchies.d.ts +7 -0
- package/{lib/types/option-set-hierarchy-exporter.js → dist/commands/types/exportOptionSetHierarchies.js} +130 -113
- package/{lib/types/types-extractor.d.ts → dist/commands/types/getAll.d.ts} +29 -27
- package/{lib/types/types-extractor.js → dist/commands/types/getAll.js} +267 -318
- package/dist/commands/types/loadAll.d.ts +7 -0
- package/dist/commands/types/loadAll.js +41 -0
- package/dist/commands/types/mergeOptionSets.d.ts +9 -0
- package/{lib/types/option-set-merger.js → dist/commands/types/mergeOptionSets.js} +114 -105
- package/dist/commands/types/mergeTypeProperties.d.ts +11 -0
- package/dist/commands/types/mergeTypeProperties.js +89 -0
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +10 -0
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.js +112 -0
- package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +14 -0
- package/dist/commands/types/parseOptionSetsLocalFiles.js +153 -0
- package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +10 -0
- package/dist/commands/types/parseOptionSetsToFolderStructure.js +104 -0
- package/dist/commands/types/parseTypesFromFiles.d.ts +10 -0
- package/dist/commands/types/parseTypesFromFiles.js +34 -0
- package/dist/commands/types/parseTypesFromLocalFiles.d.ts +10 -0
- package/dist/commands/types/parseTypesFromLocalFiles.js +34 -0
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +11 -0
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.js +36 -0
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +10 -0
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.js +35 -0
- package/dist/commands/types/uploadOptionSetHierarchies.d.ts +7 -0
- package/{lib/types/option-set-hierarchy-uploader.js → dist/commands/types/uploadOptionSetHierarchies.js} +130 -113
- package/dist/commands/types/uploadOptionSets.d.ts +7 -0
- package/{lib/types/option-set-uploader.js → dist/commands/types/uploadOptionSets.js} +115 -98
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +11 -0
- package/{lib/types/option-set-hierarchy-parser.js → dist/commands/types/uploadOptionSetsHierarchyLocalFile.js} +128 -140
- package/dist/commands/types/uploadRuleSets.d.ts +7 -0
- package/{lib/types/rule-set-uploader.js → dist/commands/types/uploadRuleSets.js} +189 -172
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +7 -0
- package/{lib/types/type-property-policy-uploader.js → dist/commands/types/uploadTypePropertyPolicies.js} +195 -178
- package/dist/commands/types/uploadUsageInfo.d.ts +7 -0
- package/{lib/types/usage-info-uploader.js → dist/commands/types/uploadUsageInfo.js} +149 -132
- package/dist/commands/users/export.d.ts +9 -0
- package/dist/commands/users/export.js +60 -0
- package/dist/commands/users/upload.d.ts +9 -0
- package/dist/commands/users/upload.js +65 -0
- package/dist/commands/workflow-template-definitions/install.d.ts +6 -0
- package/dist/commands/workflow-template-definitions/install.js +17 -0
- package/dist/commands/workflow-template-definitions/list.d.ts +6 -0
- package/dist/commands/workflow-template-definitions/list.js +17 -0
- package/dist/commands/workflow-templates/delete.d.ts +6 -0
- package/dist/commands/workflow-templates/delete.js +17 -0
- package/dist/commands/workflow-templates/list.d.ts +6 -0
- package/dist/commands/workflow-templates/list.js +17 -0
- package/dist/commands/workflow-templates/load.d.ts +9 -0
- package/dist/commands/workflow-templates/load.js +21 -0
- package/{lib → dist}/common.d.ts +1 -1
- package/dist/common.js +9 -0
- package/{lib/apps/deploy-app → dist/helpers/app}/actions-deployer.d.ts +11 -11
- package/{lib/apps/deploy-app → dist/helpers/app}/actions-deployer.js +122 -114
- package/{lib/apps/deploy-app → dist/helpers/app}/app-deployer.d.ts +8 -8
- package/{lib/apps/deploy-app → dist/helpers/app}/app-deployer.js +98 -93
- package/{lib/apps/deploy-app → dist/helpers/app}/app-template-parsers.d.ts +7 -7
- package/{lib/apps/deploy-app → dist/helpers/app}/app-template-parsers.js +43 -38
- package/dist/helpers/app/load-app-config.d.ts +1 -0
- package/dist/helpers/app/load-app-config.js +18 -0
- package/dist/helpers/app/setup-template.d.ts +1 -0
- package/dist/helpers/app/setup-template.js +38 -0
- package/dist/helpers/colors/helpers.d.ts +4 -0
- package/dist/helpers/colors/helpers.js +74 -0
- package/{lib → dist/helpers}/config/config.d.ts +6 -6
- package/dist/helpers/config/config.js +76 -0
- package/dist/helpers/loader-process/helpers.d.ts +2 -0
- package/{lib/loader-process/loader-process.js → dist/helpers/loader-process/helpers.js} +98 -120
- package/dist/helpers/projects/helpers.d.ts +2 -0
- package/{lib/projects/project-exporter.js → dist/helpers/projects/helpers.js} +165 -187
- package/{lib → dist/helpers}/types/csv-parser.d.ts +1 -1
- package/{lib → dist/helpers}/types/csv-parser.js +56 -51
- package/dist/helpers/types/type-extractor.d.ts +1 -0
- package/dist/helpers/types/type-extractor.js +32 -0
- package/dist/helpers/types/type-parser.d.ts +4 -0
- package/dist/helpers/types/type-parser.js +118 -0
- package/{lib/types/types-uploader.d.ts → dist/helpers/types/type-uploader.d.ts} +1 -1
- package/{lib/types/types-uploader.js → dist/helpers/types/type-uploader.js} +244 -239
- package/{lib → dist/helpers}/workflow-template-definitions/workflow-template-definition-deployer.d.ts +12 -12
- package/{lib → dist/helpers}/workflow-template-definitions/workflow-template-definition-deployer.js +156 -151
- package/{lib/workflow-templates/local-workflow-template-deployer.d.ts → dist/helpers/workflow-templates/helper.d.ts} +17 -11
- package/dist/helpers/workflow-templates/helper.js +166 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/{lib → dist}/interfaces.d.ts +323 -191
- package/dist/interfaces.js +63 -0
- package/{templates → dist/templates}/typescript/Dockerfile +15 -15
- package/{templates → dist/templates}/typescript/README.md +10 -10
- package/{templates → dist/templates}/typescript/app.yml +49 -49
- package/{templates → dist/templates}/typescript/docker_deploy.bat +1 -1
- package/{templates → dist/templates}/typescript/package.json +54 -54
- package/{templates → dist/templates}/typescript/src/actions/logItem.ts +25 -25
- package/{templates → dist/templates}/typescript/src/framework/action-dispatcher.ts +89 -89
- package/{templates → dist/templates}/typescript/src/framework/app-config.ts +26 -26
- package/{templates → dist/templates}/typescript/src/framework/handler.ts +11 -11
- package/{templates → dist/templates}/typescript/src/framework/index.ts +2 -2
- package/{templates → dist/templates}/typescript/src/framework/interfaces.ts +32 -32
- package/{templates → dist/templates}/typescript/src/framework/logger.ts +21 -21
- package/{templates → dist/templates}/typescript/src/framework/mock-server.ts +31 -31
- package/{templates → dist/templates}/typescript/tsconfig.json +28 -28
- package/oclif.manifest.json +821 -0
- package/package.json +116 -72
- package/.eslintrc.js +0 -53
- package/.vscode/settings.json +0 -6
- package/bin/init +0 -4
- package/lib/api/apps.js +0 -85
- package/lib/api/event-workflow-action-definition.js +0 -7
- package/lib/api/event-workflow-template-definition.js +0 -20
- package/lib/api/event-workflow-templates.js +0 -25
- package/lib/apps/create-app/create.d.ts +0 -1
- package/lib/apps/create-app/create.js +0 -60
- package/lib/apps/create-app/setup-template.d.ts +0 -1
- package/lib/apps/create-app/setup-template.js +0 -34
- package/lib/apps/deploy-app/deploy.d.ts +0 -2
- package/lib/apps/deploy-app/deploy.js +0 -58
- package/lib/apps/install-app/app-installer.d.ts +0 -2
- package/lib/apps/install-app/app-installer.js +0 -120
- package/lib/apps/upgrade-app/app-upgrader.d.ts +0 -3
- package/lib/apps/upgrade-app/app-upgrader.js +0 -126
- package/lib/auth/auth.js +0 -2
- package/lib/cli.d.ts +0 -5
- package/lib/cli.js +0 -524
- package/lib/colors/color-loader.d.ts +0 -2
- package/lib/colors/color-loader.js +0 -96
- package/lib/common.js +0 -5
- package/lib/config/config.js +0 -70
- package/lib/config/configCommands.d.ts +0 -3
- package/lib/config/configCommands.js +0 -34
- package/lib/interfaces.js +0 -25
- package/lib/loader-process/loader-process.d.ts +0 -2
- package/lib/projects/interfaces.d.ts +0 -77
- package/lib/projects/interfaces.js +0 -23
- package/lib/projects/project-exporter.d.ts +0 -2
- package/lib/projects/project-uploader.d.ts +0 -1
- package/lib/types/allUploader.d.ts +0 -1
- package/lib/types/allUploader.js +0 -24
- package/lib/types/interfaces.d.ts +0 -55
- package/lib/types/interfaces.js +0 -1
- package/lib/types/option-set-hierarchy-exporter.d.ts +0 -1
- package/lib/types/option-set-hierarchy-parser.d.ts +0 -2
- package/lib/types/option-set-hierarchy-uploader.d.ts +0 -1
- package/lib/types/option-set-merger.d.ts +0 -1
- package/lib/types/option-set-parser.d.ts +0 -3
- package/lib/types/option-set-parser.js +0 -140
- package/lib/types/option-set-uploader.d.ts +0 -1
- package/lib/types/parse-types.d.ts +0 -4
- package/lib/types/parse-types.js +0 -189
- package/lib/types/rule-set-uploader.d.ts +0 -1
- package/lib/types/type-property-policy-uploader.d.ts +0 -1
- package/lib/types/types-properties-merger.d.ts +0 -1
- package/lib/types/types-properties-merger.js +0 -75
- package/lib/types/usage-info-uploader.d.ts +0 -1
- package/lib/users/user-exporter.d.ts +0 -1
- package/lib/users/user-exporter.js +0 -41
- package/lib/users/user-uploader.d.ts +0 -1
- package/lib/users/user-uploader.js +0 -45
- package/lib/workflow-template-definitions/workflow-template-definition-commands.d.ts +0 -2
- package/lib/workflow-template-definitions/workflow-template-definition-commands.js +0 -10
- package/lib/workflow-templates/local-workflow-template-deployer.js +0 -102
- package/lib/workflow-templates/workflow-template-commands.d.ts +0 -4
- package/lib/workflow-templates/workflow-template-commands.js +0 -51
- package/lib/workflow-templates/workflow-template-deployer.d.ts +0 -4
- package/lib/workflow-templates/workflow-template-deployer.js +0 -26
- package/publish.bat +0 -5
- package/publish.sh +0 -5
- package/src/api/apps.ts +0 -97
- package/src/api/event-workflow-action-definition.ts +0 -8
- package/src/api/event-workflow-template-definition.ts +0 -23
- package/src/api/event-workflow-templates.ts +0 -29
- package/src/apps/create-app/create.ts +0 -74
- package/src/apps/create-app/setup-template.ts +0 -38
- package/src/apps/deploy-app/actions-deployer.ts +0 -140
- package/src/apps/deploy-app/app-deployer.ts +0 -105
- package/src/apps/deploy-app/app-template-parsers.ts +0 -44
- package/src/apps/deploy-app/deploy.ts +0 -66
- package/src/apps/install-app/app-installer.ts +0 -126
- package/src/apps/upgrade-app/app-upgrader.ts +0 -132
- package/src/auth/auth.ts +0 -10
- package/src/auth/login.ts +0 -155
- package/src/cli.ts +0 -540
- package/src/colors/color-loader.ts +0 -112
- package/src/colors/colors.csv +0 -866
- package/src/common.ts +0 -5
- package/src/config/config.ts +0 -74
- package/src/config/configCommands.ts +0 -38
- package/src/interfaces.ts +0 -200
- package/src/loader-process/loader-process.ts +0 -152
- package/src/projects/interfaces.ts +0 -73
- package/src/projects/project-exporter.ts +0 -225
- package/src/projects/project-uploader.ts +0 -131
- package/src/types/allUploader.ts +0 -28
- package/src/types/csv-parser.ts +0 -59
- package/src/types/interfaces.ts +0 -58
- package/src/types/option-set-hierarchy-exporter.ts +0 -125
- package/src/types/option-set-hierarchy-parser.ts +0 -169
- package/src/types/option-set-hierarchy-uploader.ts +0 -122
- package/src/types/option-set-merger.ts +0 -124
- package/src/types/option-set-parser.ts +0 -166
- package/src/types/option-set-uploader.ts +0 -108
- package/src/types/parse-types.ts +0 -227
- package/src/types/rule-set-uploader.ts +0 -187
- package/src/types/type-property-policy-uploader.ts +0 -192
- package/src/types/types-extractor.ts +0 -369
- package/src/types/types-properties-merger.ts +0 -90
- package/src/types/types-uploader.ts +0 -271
- package/src/types/usage-info-uploader.ts +0 -139
- package/src/users/user-exporter.ts +0 -52
- package/src/users/user-uploader.ts +0 -58
- package/src/workflow-template-definitions/workflow-template-definition-commands.ts +0 -13
- package/src/workflow-template-definitions/workflow-template-definition-deployer.ts +0 -184
- package/src/workflow-templates/local-workflow-template-deployer.ts +0 -126
- package/src/workflow-templates/workflow-template-commands.ts +0 -59
- package/src/workflow-templates/workflow-template-deployer.ts +0 -30
- package/templates/javascript/actions/example/action.js +0 -38
- package/templates/javascript/app.yml +0 -53
- package/templates/javascript/package.json +0 -23
- package/templates/typescript/package-lock.json +0 -14
- package/tsconfig.json +0 -32
package/lib/cli.js
DELETED
|
@@ -1,524 +0,0 @@
|
|
|
1
|
-
import { create } from './apps/create-app/create';
|
|
2
|
-
import { deployApp, removeApp } from './apps/deploy-app/deploy';
|
|
3
|
-
import { getAll } from './types/types-extractor';
|
|
4
|
-
import { uploadTypes } from './types/types-uploader';
|
|
5
|
-
import { UploadOptionSets } from './types/option-set-uploader';
|
|
6
|
-
import { ParseOptionSetsLocalFiles, ParseOptionSetsToFolderStructure } from './types/option-set-parser';
|
|
7
|
-
import { ParseOptionSetsHierarchyLocalFile, UploadOptionSetsHierarchyLocalFile } from './types/option-set-hierarchy-parser';
|
|
8
|
-
import { ExportOptionSetsHierarchies } from './types/option-set-hierarchy-exporter';
|
|
9
|
-
import { MergeOptionSets } from './types/option-set-merger';
|
|
10
|
-
import { MergeTypeProperties } from './types/types-properties-merger';
|
|
11
|
-
import { ParseTypesFromFiles, ParseTypesFromLocalFiles, ParseTypesFromTemplateFromLocalFiles, ParseTypesFromTemplateAndDataFromLocalFiles } from './types/parse-types';
|
|
12
|
-
import { loadColors, deleteColors } from './colors/color-loader';
|
|
13
|
-
import { listConfig, removeConfig, setConfig } from './config/configCommands';
|
|
14
|
-
import { deleteWorkflowTemplates, localDeployWorkflowTemplate, listWorkflowTemplate } from './workflow-templates/workflow-template-commands';
|
|
15
|
-
import { installApp, uninstallApp } from './apps/install-app/app-installer';
|
|
16
|
-
import { upgradeApp } from './apps/upgrade-app/app-upgrader';
|
|
17
|
-
import { cliInstallWorkflowTemplateDefinitions, listWorkflowTemplateDefinitions } from './workflow-template-definitions/workflow-template-definition-commands';
|
|
18
|
-
import { configureProject } from './projects/project-uploader';
|
|
19
|
-
import { ListProjects, ExportProject } from './projects/project-exporter';
|
|
20
|
-
import { Load, UploadAndLoad } from './loader-process/loader-process';
|
|
21
|
-
import { uploadUsageInfo } from './types/usage-info-uploader';
|
|
22
|
-
import { uploadRuleSets } from './types/rule-set-uploader';
|
|
23
|
-
import { UploadOptionSetHierarchies } from './types/option-set-hierarchy-uploader';
|
|
24
|
-
import { uploadTypePropertyPolicies } from './types/type-property-policy-uploader';
|
|
25
|
-
import { uploadAll } from './types/allUploader';
|
|
26
|
-
import { ExportUsers } from './users/user-exporter';
|
|
27
|
-
import { UploadUsers } from './users/user-uploader';
|
|
28
|
-
const cliUsage = require('command-line-usage');
|
|
29
|
-
/**
|
|
30
|
-
* Built using documentation here:
|
|
31
|
-
* https://www.twilio.com/blog/how-to-build-a-cli-with-node-js
|
|
32
|
-
*/
|
|
33
|
-
export async function cli(args) {
|
|
34
|
-
const fullCommand = args[2];
|
|
35
|
-
if (!fullCommand) {
|
|
36
|
-
printIllegalCommand();
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const commandParts = fullCommand.split('.');
|
|
40
|
-
if (!(commandParts === null || commandParts === void 0 ? void 0 : commandParts.length)) {
|
|
41
|
-
printIllegalCommand();
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if ((commandParts === null || commandParts === void 0 ? void 0 : commandParts.length) < 2 &&
|
|
45
|
-
commandParts[0].toLowerCase() !== 'help' &&
|
|
46
|
-
commandParts[0].toLowerCase() !== '-help' &&
|
|
47
|
-
commandParts[0].toLowerCase() !== '--help') {
|
|
48
|
-
printIllegalCommand();
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const domain = commandParts[0];
|
|
52
|
-
const command = commandParts[1];
|
|
53
|
-
switch (domain) {
|
|
54
|
-
case 'app': {
|
|
55
|
-
switch (command) {
|
|
56
|
-
case 'create': {
|
|
57
|
-
create(args);
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
case 'deploy': {
|
|
61
|
-
deployApp(args);
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
case 'remove': {
|
|
65
|
-
removeApp(args);
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
case 'install': {
|
|
69
|
-
installApp();
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
case 'uninstall': {
|
|
73
|
-
uninstallApp();
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
case 'upgrade': {
|
|
77
|
-
upgradeApp();
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
default: {
|
|
81
|
-
printIllegalCommand();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
case 'types': {
|
|
87
|
-
switch (command) {
|
|
88
|
-
case 'getAll': {
|
|
89
|
-
getAll(args);
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
case 'uploadAll': {
|
|
93
|
-
uploadAll();
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
case 'uploadTypes': {
|
|
97
|
-
uploadTypes();
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
case 'uploadOptionSets': {
|
|
101
|
-
UploadOptionSets(args);
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
case 'parseOptionSetsLocalFiles': {
|
|
105
|
-
ParseOptionSetsLocalFiles(args);
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
case 'parseOptionSetsToFolderStructure': {
|
|
109
|
-
ParseOptionSetsToFolderStructure(args);
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
case 'parseOptionSetsHierarchyLocalFile': {
|
|
113
|
-
ParseOptionSetsHierarchyLocalFile(args);
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
case 'uploadOptionSetsHierarchyLocalFile': {
|
|
117
|
-
UploadOptionSetsHierarchyLocalFile(args);
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
case 'exportOptionSetsHierarchies': {
|
|
121
|
-
ExportOptionSetsHierarchies();
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
case 'uploadOptionSetsHierarchies': {
|
|
125
|
-
UploadOptionSetHierarchies(args);
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
case 'uploadRuleSets': {
|
|
129
|
-
uploadRuleSets(args);
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
case 'uploadUsageInfo': {
|
|
133
|
-
uploadUsageInfo(args);
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
case 'uploadTypePropertyPolicies': {
|
|
137
|
-
uploadTypePropertyPolicies(args);
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case 'parseTypesFromLocalFiles': {
|
|
141
|
-
ParseTypesFromLocalFiles(args);
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
case 'parseTypesFromTemplateFromLocalFiles': {
|
|
145
|
-
ParseTypesFromTemplateFromLocalFiles(args);
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
case 'parseTypesFromTemplateAndDataFromLocalFiles': {
|
|
149
|
-
ParseTypesFromTemplateAndDataFromLocalFiles(args);
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
case 'parseTypesFromFiles': {
|
|
153
|
-
ParseTypesFromFiles(args);
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
case 'mergeOptionSets': {
|
|
157
|
-
MergeOptionSets(args);
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
case 'mergeTypeProperties': {
|
|
161
|
-
MergeTypeProperties(args);
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
default: {
|
|
165
|
-
printIllegalCommand();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
case 'colors': {
|
|
171
|
-
switch (command) {
|
|
172
|
-
case 'load': {
|
|
173
|
-
await loadColors();
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
case 'delete': {
|
|
177
|
-
await deleteColors();
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
default: {
|
|
181
|
-
printIllegalCommand();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
case 'loader': {
|
|
187
|
-
switch (command) {
|
|
188
|
-
case 'uploadAndLoad': {
|
|
189
|
-
await UploadAndLoad(args);
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
case 'load': {
|
|
193
|
-
await Load(args);
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
default: {
|
|
197
|
-
printIllegalCommand();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
case 'projects': {
|
|
203
|
-
switch (command) {
|
|
204
|
-
case 'load': {
|
|
205
|
-
await configureProject(args);
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
case 'list': {
|
|
209
|
-
await ListProjects();
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
case 'export': {
|
|
213
|
-
await ExportProject(args);
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
default: {
|
|
217
|
-
printIllegalCommand();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
case 'users': {
|
|
223
|
-
switch (command) {
|
|
224
|
-
case 'export': {
|
|
225
|
-
await ExportUsers();
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
case 'import': {
|
|
229
|
-
await UploadUsers();
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
default: {
|
|
233
|
-
printIllegalCommand();
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
case 'workflow-templates': {
|
|
239
|
-
switch (command) {
|
|
240
|
-
case 'load': {
|
|
241
|
-
await localDeployWorkflowTemplate();
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
case 'delete': {
|
|
245
|
-
await deleteWorkflowTemplates();
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
case 'list': {
|
|
249
|
-
await listWorkflowTemplate();
|
|
250
|
-
break;
|
|
251
|
-
}
|
|
252
|
-
default: {
|
|
253
|
-
printIllegalCommand();
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
case 'workflow-template-definitions': {
|
|
259
|
-
switch (command) {
|
|
260
|
-
case 'install': {
|
|
261
|
-
await cliInstallWorkflowTemplateDefinitions();
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
case 'list': {
|
|
265
|
-
await listWorkflowTemplateDefinitions();
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
default: {
|
|
269
|
-
printIllegalCommand();
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
case 'config': {
|
|
275
|
-
switch (command) {
|
|
276
|
-
case 'list': {
|
|
277
|
-
await listConfig();
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
case 'set': {
|
|
281
|
-
await setConfig(args);
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
case 'remove': {
|
|
285
|
-
await removeConfig(args);
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
default: {
|
|
289
|
-
printIllegalCommand();
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
case 'help':
|
|
295
|
-
case '-help':
|
|
296
|
-
case '--help': {
|
|
297
|
-
printHelp();
|
|
298
|
-
break;
|
|
299
|
-
}
|
|
300
|
-
default: {
|
|
301
|
-
printIllegalCommand();
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function printHelp() {
|
|
306
|
-
const sections = [
|
|
307
|
-
{
|
|
308
|
-
header: 'VibeIQ CLI',
|
|
309
|
-
content: 'From your friends at VibeIQ!',
|
|
310
|
-
},
|
|
311
|
-
...helpSections,
|
|
312
|
-
];
|
|
313
|
-
const usage = cliUsage(sections);
|
|
314
|
-
console.log(usage);
|
|
315
|
-
}
|
|
316
|
-
function printIllegalCommand() {
|
|
317
|
-
console.log('Illegal command.');
|
|
318
|
-
const usage = cliUsage(helpSections);
|
|
319
|
-
console.log(usage);
|
|
320
|
-
}
|
|
321
|
-
const helpSections = [
|
|
322
|
-
{
|
|
323
|
-
header: 'General Usage',
|
|
324
|
-
content: [
|
|
325
|
-
'Commands are run by pairing a domain with a command, joining them using a "."',
|
|
326
|
-
'e.g. app.create',
|
|
327
|
-
'',
|
|
328
|
-
'All <File Path> options should use the file path relative to the folder the command is being run in and include the file ext.',
|
|
329
|
-
],
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
header: 'App Commands - Domain: app',
|
|
333
|
-
content: [
|
|
334
|
-
{
|
|
335
|
-
name: 'create',
|
|
336
|
-
summary: 'Create a new app workspace.'
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
name: 'deploy [--template-only]',
|
|
340
|
-
summary: 'Deploy your app. --template-only can be used to deploy event workflow as a template directly to the org'
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
name: 'remove',
|
|
344
|
-
summary: 'Remove your app.'
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
name: 'install',
|
|
348
|
-
summary: 'Install an app to your org.'
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
name: 'upgrade',
|
|
352
|
-
summary: 'Upgrades or downgrades an existing app in your org.'
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
name: 'uninstall',
|
|
356
|
-
summary: 'Uninstall an app from your org.'
|
|
357
|
-
},
|
|
358
|
-
],
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
header: 'Colors Commands - Domain: colors',
|
|
362
|
-
content: [{
|
|
363
|
-
name: 'load',
|
|
364
|
-
summary: 'Load colors from a CSV. Headers (name, hex, red, green, blue) are required'
|
|
365
|
-
}
|
|
366
|
-
// , {name: 'delete', summary: 'Delete all colors.'}
|
|
367
|
-
],
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
header: 'Loader Commands - Domain: loader',
|
|
371
|
-
content: [{
|
|
372
|
-
name: 'uploadAndLoad <File Path> <Config Path>',
|
|
373
|
-
summary: 'Upload a csv file and kick off a load job for the uploaded file. The file path must be a reference to a .csv file and the config path must be a reference to a .json or a .yml file.'
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
name: 'load <Config Path>',
|
|
377
|
-
summary: 'Upload a csv file and kick off a load job for the uploaded file. The config path must be a reference to a .json or a .yml file.'
|
|
378
|
-
}
|
|
379
|
-
],
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
header: 'Project Commands - Domain: projects',
|
|
383
|
-
content: [{
|
|
384
|
-
name: 'load <File Path>',
|
|
385
|
-
summary: 'Configure a project from a yml file.'
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
name: 'list',
|
|
389
|
-
summary: 'Get a list of all projects.'
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
name: 'export <Project Name>',
|
|
393
|
-
summary: 'Export a project.'
|
|
394
|
-
}
|
|
395
|
-
],
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
header: 'Users Commands - Domain: users',
|
|
399
|
-
content: [
|
|
400
|
-
{
|
|
401
|
-
name: 'export',
|
|
402
|
-
summary: 'Export all users in the org.'
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
name: 'import',
|
|
406
|
-
summary: 'Import all users in the users.yml file.'
|
|
407
|
-
}
|
|
408
|
-
],
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
header: 'Workflow Template Commands - Domain: workflow-templates',
|
|
412
|
-
content: [
|
|
413
|
-
{
|
|
414
|
-
name: 'deploy',
|
|
415
|
-
summary: 'Deploy your workflow. Assumes a workflow.yml file.'
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
name: 'delete',
|
|
419
|
-
summary: 'Removes the workflows in the workflow.yml file.'
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
name: 'list',
|
|
423
|
-
summary: 'Lists the workflow templates in the org'
|
|
424
|
-
},
|
|
425
|
-
],
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
header: 'Workflow Template Definition Commands - Domain: workflow-template-definitions',
|
|
429
|
-
content: [{
|
|
430
|
-
name: 'install',
|
|
431
|
-
summary: 'Install the template definitions of an app to your org'
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
name: 'list',
|
|
435
|
-
summary: 'Lists the workflow templates in the org'
|
|
436
|
-
}
|
|
437
|
-
],
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
header: 'Type Commands - Domain: types',
|
|
441
|
-
content: [
|
|
442
|
-
{
|
|
443
|
-
name: 'getAll',
|
|
444
|
-
summary: 'Get all OptionSets and Types for your Org.'
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
name: 'uploadTypes',
|
|
448
|
-
summary: 'Upload Types for your Org. Types are uploaded from types.yml\n'
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
name: 'uploadOptionSets',
|
|
452
|
-
summary: 'Upload OptionSets for your Org. OptionSets are loaded from .yml files in the option-sets directory.\n'
|
|
453
|
-
},
|
|
454
|
-
{
|
|
455
|
-
name: 'parseOptionSetsLocalFiles <File Paths> <style>',
|
|
456
|
-
summary: 'Parse CSV files into OptionSets. Style denotes the format the csv is in. If the csv file has a column for name and label, use "NameAndLabel". If the file has one column for each option set with the rows being the label value use "LabelsInColumn"\n'
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
name: 'parseOptionSetsToFolderStructure <File Path>',
|
|
460
|
-
summary: 'Parse single yml file into a folder with separate files per option set.\n'
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
name: 'parseOptionSetsHierarchyLocalFile <File Path>',
|
|
464
|
-
summary: 'Parse CSV file into OptionSetHierarchy.'
|
|
465
|
-
},
|
|
466
|
-
{
|
|
467
|
-
name: 'uploadOptionSetsHierarchyLocalFile <File Path> <name>',
|
|
468
|
-
summary: 'upload CSV file into OptionSetHierarchy.'
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
name: 'exportOptionSetsHierarchies',
|
|
472
|
-
summary: 'export OptionSetHierarchies into CSVs.\n'
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
name: 'uploadAll',
|
|
476
|
-
summary: 'Upload an extracted archive of types:getAll.'
|
|
477
|
-
},
|
|
478
|
-
{
|
|
479
|
-
name: 'uploadOptionSetsHierarchies',
|
|
480
|
-
summary: 'Upload an extracted option set hierarchies.'
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
name: 'uploadRuleSets',
|
|
484
|
-
summary: 'Upload an extracted rule set.'
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
name: 'uploadUsageInfo',
|
|
488
|
-
summary: 'Upload extracted usage info.'
|
|
489
|
-
},
|
|
490
|
-
{
|
|
491
|
-
name: 'uploadTypePropertyPolicies',
|
|
492
|
-
summary: 'Upload type property policies.'
|
|
493
|
-
},
|
|
494
|
-
{
|
|
495
|
-
name: 'uploadOptionSetsHierarchyLocalFiles <File Paths> <name>',
|
|
496
|
-
summary: 'upload CSV files into OptionSetHierarchies.'
|
|
497
|
-
},
|
|
498
|
-
{
|
|
499
|
-
name: 'parseTypesFromLocalFiles <File Paths>',
|
|
500
|
-
summary: 'Parse CSV files into Types and OptionSets from local files.\n'
|
|
501
|
-
},
|
|
502
|
-
{
|
|
503
|
-
name: 'parseTypesFromTemplateFromLocalFiles <File Paths>',
|
|
504
|
-
summary: 'Parse CSV files into Types and OptionSets from local type template files.\n'
|
|
505
|
-
},
|
|
506
|
-
{
|
|
507
|
-
name: 'parseTypesFromTemplateAndDataFromLocalFiles <File Paths>',
|
|
508
|
-
summary: 'Parse CSV files into Types and OptionSets from local type template and data files.\n'
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
name: 'parseTypesFromFiles <fileIds>',
|
|
512
|
-
summary: 'Parse CSV files into Types and OptionSets from VibeIQ Files.\n File must be .yml\n'
|
|
513
|
-
},
|
|
514
|
-
{
|
|
515
|
-
name: 'mergeTypeProperties <File Path> <TypePaths>',
|
|
516
|
-
summary: 'Merge the TypeProperties from an existing org and the TypeProperties passed in. Add to Types via TypePath File must be .yml\n'
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
name: 'mergeOptionSets <File Path>',
|
|
520
|
-
summary: 'Merge the OptionSets from an existing org and the OptionSets passed in. OptionSets File must be .yml.',
|
|
521
|
-
},
|
|
522
|
-
],
|
|
523
|
-
},
|
|
524
|
-
];
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Entities } from '@contrail/sdk';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { authUser } from '../auth/login';
|
|
4
|
-
import { getSeparatorByPlatform } from '../common';
|
|
5
|
-
const csv = require('csvtojson');
|
|
6
|
-
export async function deleteColors() {
|
|
7
|
-
try {
|
|
8
|
-
await authUser();
|
|
9
|
-
const colors = await getExistingColors();
|
|
10
|
-
console.log('Deleting %s colors', colors.length);
|
|
11
|
-
for (const color of colors) {
|
|
12
|
-
await deleteColor(color);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
console.log(`%s Loading Colors Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
console.log('%s Deleting Colors Complete.', chalk.green.bold('COMPLETE'));
|
|
20
|
-
}
|
|
21
|
-
export async function loadColors() {
|
|
22
|
-
try {
|
|
23
|
-
await authUser();
|
|
24
|
-
console.log('%s Getting Existing Colors', chalk.yellow.bold('COLORS'));
|
|
25
|
-
console.log('%s Uploading', chalk.yellow.bold('COLORS'));
|
|
26
|
-
await uploadColors();
|
|
27
|
-
console.log('%s Uploaded', chalk.yellow.bold('COLORS'));
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
console.log(`%s Loading Colors Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
console.log('%s Loading Colors Complete.', chalk.green.bold('COMPLETE'));
|
|
34
|
-
}
|
|
35
|
-
async function getLocalColors() {
|
|
36
|
-
console.log('loading colors from local file');
|
|
37
|
-
const TARGET_DIR = process.cwd();
|
|
38
|
-
try {
|
|
39
|
-
const separator = getSeparatorByPlatform();
|
|
40
|
-
const csvFilePath = TARGET_DIR + separator + 'colors.csv';
|
|
41
|
-
return await csv().fromFile(csvFilePath);
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
throw new Error(`ERROR PARSING COLORS CSV: ${e}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async function getExistingColors() {
|
|
48
|
-
console.log('%s Getting Existing Colors', chalk.yellow.bold('COLORS'));
|
|
49
|
-
try {
|
|
50
|
-
const result = await new Entities().get({ entityName: 'color', take: 3000 }); //, useSearch: false }); Not in EntitiesClientGetOptions yet
|
|
51
|
-
console.log('Found %s existing colors', result.length);
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
throw new Error(`ERROR DOWNLOADING COLORS: ${e}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
async function deleteColor(color) {
|
|
59
|
-
try {
|
|
60
|
-
await new Entities().delete({ entityName: 'color', id: color.id });
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
throw new Error(`ERROR DOWNLOADING COLORS: ${e}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
async function uploadColors() {
|
|
67
|
-
const colors = await getLocalColors();
|
|
68
|
-
const existingColors = await getExistingColors();
|
|
69
|
-
const existingNamesValues = existingColors.filter(x => x.name).map(x => x.name);
|
|
70
|
-
for (const color of colors) {
|
|
71
|
-
if (existingNamesValues.includes(color.name)) {
|
|
72
|
-
console.log('%s SKIPPING %s (%s)', chalk.yellow.bold('COLORS'), color.hex, color.name);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (color.hex.length > 1 && color.hex[0] === '#') {
|
|
76
|
-
color.hex = color.hex.substring(1);
|
|
77
|
-
}
|
|
78
|
-
const o = {
|
|
79
|
-
hex: color.hex,
|
|
80
|
-
name: color.name
|
|
81
|
-
};
|
|
82
|
-
if (color.red) {
|
|
83
|
-
o.red = color.red;
|
|
84
|
-
}
|
|
85
|
-
if (color.green) {
|
|
86
|
-
o.green = color.green;
|
|
87
|
-
}
|
|
88
|
-
if (color.blue) {
|
|
89
|
-
o.blue = color.blue;
|
|
90
|
-
}
|
|
91
|
-
await new Entities().create({
|
|
92
|
-
entityName: 'color',
|
|
93
|
-
object: o
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
package/lib/common.js
DELETED
package/lib/config/config.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { promises as fsPromises } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { homedir } from 'os';
|
|
4
|
-
const userHomeDir = homedir();
|
|
5
|
-
const configDirectoryLocation = join(userHomeDir, '.vibeiq');
|
|
6
|
-
const configFileLocation = join(configDirectoryLocation, 'config.json');
|
|
7
|
-
export async function initializeVibeIQConfig() {
|
|
8
|
-
try {
|
|
9
|
-
await fsPromises.mkdir(configDirectoryLocation, { recursive: true });
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
console.error('could not initialize vibeiq directory');
|
|
13
|
-
throw e;
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
await fsPromises.writeFile(configFileLocation, '{}');
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
console.error(`could not initialize config file (${configFileLocation}).`);
|
|
20
|
-
throw e;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export async function readVibeIQConfig() {
|
|
24
|
-
let fileContent;
|
|
25
|
-
try {
|
|
26
|
-
fileContent = await fsPromises.readFile(configFileLocation);
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
console.debug(`failed to open config file (${configFileLocation}) for reading.`);
|
|
30
|
-
console.debug('trying to initialize config file');
|
|
31
|
-
await initializeVibeIQConfig();
|
|
32
|
-
fileContent = await fsPromises.readFile(configFileLocation);
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
return JSON.parse(fileContent);
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
console.error(`Could not parse local vibeiq config. The file (${configFileLocation}) might be malformed`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export async function writeVibeIQConfig(config) {
|
|
42
|
-
try {
|
|
43
|
-
await fsPromises.writeFile(configFileLocation, JSON.stringify(config, null, 2));
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
console.error(`Could not open config file (${configFileLocation}) for writing.`);
|
|
47
|
-
throw e;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export async function getConfig() {
|
|
51
|
-
console.debug('getting config from file system');
|
|
52
|
-
return await readVibeIQConfig();
|
|
53
|
-
}
|
|
54
|
-
export async function deleteConfigs(configNames) {
|
|
55
|
-
const currentConfig = await readVibeIQConfig();
|
|
56
|
-
for (const configName of configNames) {
|
|
57
|
-
delete currentConfig[configName];
|
|
58
|
-
}
|
|
59
|
-
await storeConfig(currentConfig, false);
|
|
60
|
-
}
|
|
61
|
-
export async function storeConfig(incomingConfig, merge = true) {
|
|
62
|
-
let config;
|
|
63
|
-
if (merge) {
|
|
64
|
-
config = Object.assign(Object.assign({}, await readVibeIQConfig()), incomingConfig);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
config = incomingConfig;
|
|
68
|
-
}
|
|
69
|
-
await writeVibeIQConfig(config);
|
|
70
|
-
}
|