@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
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseLabelsInColumn = exports.ParseOptionSetsToFolderStructure = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
|
+
const types_1 = require("@contrail/types");
|
|
8
|
+
const util_1 = require("@contrail/util");
|
|
9
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
|
+
const csv = require('csvtojson');
|
|
11
|
+
const yaml = require('js-yaml');
|
|
12
|
+
const core_1 = require("@oclif/core");
|
|
13
|
+
class ParseOptionSetsLocalFiles extends core_1.Command {
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(ParseOptionSetsLocalFiles);
|
|
16
|
+
try {
|
|
17
|
+
this.log('%s Importing local file', chalk_1.default.yellow.bold('OPTION SET PARSE'));
|
|
18
|
+
this.log('Using File: ', args.file);
|
|
19
|
+
await parseOptionSetsLocalFiles(args.file, flags.csvStyle);
|
|
20
|
+
this.log('%s Parsed', chalk_1.default.yellow.bold('OPTION SET PARSE'));
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
this.log(`%s PARSE Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.log('%s PARSE Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = ParseOptionSetsLocalFiles;
|
|
30
|
+
ParseOptionSetsLocalFiles.description = '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"';
|
|
31
|
+
ParseOptionSetsLocalFiles.examples = [
|
|
32
|
+
`$ contrail types parseOptionSetsLocalFiles <File Paths> <style>
|
|
33
|
+
`,
|
|
34
|
+
];
|
|
35
|
+
ParseOptionSetsLocalFiles.flags = {
|
|
36
|
+
csvStyle: core_1.Flags.string({ options: ['NameAndLabel', 'LabelsInColumn'], required: true })
|
|
37
|
+
};
|
|
38
|
+
ParseOptionSetsLocalFiles.args = {
|
|
39
|
+
file: core_1.Args.string({ description: 'File to parse', required: true }),
|
|
40
|
+
};
|
|
41
|
+
async function ParseOptionSetsToFolderStructure(args) {
|
|
42
|
+
try {
|
|
43
|
+
if ((args === null || args === void 0 ? void 0 : args.length) < 4) {
|
|
44
|
+
throw new Error('File name must be included.');
|
|
45
|
+
}
|
|
46
|
+
console.log('%s Importing local file', chalk_1.default.yellow.bold('OPTION SET PARSE'));
|
|
47
|
+
const fileLocation = args[3];
|
|
48
|
+
console.log('Using File: ', fileLocation);
|
|
49
|
+
await parseOptionSetsToFolderStructure(fileLocation);
|
|
50
|
+
console.log('%s Parsed', chalk_1.default.yellow.bold('OPTION SET PARSE'));
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
console.log(`%s PARSE Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
console.log('%s PARSE Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
57
|
+
}
|
|
58
|
+
exports.ParseOptionSetsToFolderStructure = ParseOptionSetsToFolderStructure;
|
|
59
|
+
async function loadOptionSetCSV(fileLocation) {
|
|
60
|
+
const TARGET_DIR = process.cwd();
|
|
61
|
+
try {
|
|
62
|
+
const fullPath = path.resolve(path.join(TARGET_DIR, fileLocation));
|
|
63
|
+
console.log('Getting file from path: ', fullPath);
|
|
64
|
+
return await csv().fromFile(fullPath);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
throw new Error(`ERROR PARSING CSV: ${e}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function loadOptionSets(fileLocation) {
|
|
71
|
+
const TARGET_DIR = process.cwd();
|
|
72
|
+
try {
|
|
73
|
+
const fullPath = path.resolve(path.join(TARGET_DIR, fileLocation));
|
|
74
|
+
console.log('Getting file from path: ', fullPath);
|
|
75
|
+
const doc = yaml.load(fs_1.default.readFileSync(fullPath, 'utf8'));
|
|
76
|
+
return doc;
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function parseOptionSetsLocalFiles(fileLocation, csvStyle) {
|
|
83
|
+
const uploadedOptionData = await loadOptionSetCSV(fileLocation);
|
|
84
|
+
if (csvStyle === 'NameAndLabel') {
|
|
85
|
+
const parsedOptionSets = (0, types_1.parseOptionSets)(uploadedOptionData);
|
|
86
|
+
saveData(parsedOptionSets);
|
|
87
|
+
}
|
|
88
|
+
if (csvStyle === 'LabelsInColumn') {
|
|
89
|
+
const parsedOptionSets = parseLabelsInColumn(uploadedOptionData);
|
|
90
|
+
saveData(parsedOptionSets);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function parseOptionSetsToFolderStructure(fileLocation) {
|
|
94
|
+
const uploadedOptionData = await loadOptionSets(fileLocation);
|
|
95
|
+
saveDataInFolders(uploadedOptionData);
|
|
96
|
+
}
|
|
97
|
+
function saveData(data) {
|
|
98
|
+
const yamlStr = yaml.dump(data);
|
|
99
|
+
const CURRENT_DIR = process.cwd();
|
|
100
|
+
fs_1.default.writeFileSync(path.resolve(path.join(CURRENT_DIR, 'parsed_local_optionSets.yml')), yamlStr, 'utf8');
|
|
101
|
+
}
|
|
102
|
+
function saveDataInFolders(data) {
|
|
103
|
+
const folder = { filename: 'option-sets', split: true, fileLabel: 'name' };
|
|
104
|
+
const dir = 'merged_option_sets';
|
|
105
|
+
const CURRENT_DIR = process.cwd();
|
|
106
|
+
const subDir = path.join(CURRENT_DIR, dir, folder.filename);
|
|
107
|
+
if (!fs_1.default.existsSync(subDir)) {
|
|
108
|
+
fs_1.default.mkdirSync(subDir, { recursive: true });
|
|
109
|
+
}
|
|
110
|
+
for (const item of data) {
|
|
111
|
+
const yamlStr = yaml.dump(item);
|
|
112
|
+
const fileLabel = item[folder.fileLabel];
|
|
113
|
+
if (!fileLabel) {
|
|
114
|
+
console.warn('skipping bad data:', item);
|
|
115
|
+
}
|
|
116
|
+
fs_1.default.writeFileSync(path.join(subDir, `${removeSlash(fileLabel)}.yml`), yamlStr, 'utf8');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function removeSlash(string) {
|
|
120
|
+
const re = /\//gi;
|
|
121
|
+
return string.replace(re, '-');
|
|
122
|
+
}
|
|
123
|
+
function parseLabelsInColumn(uploadedOptionData) {
|
|
124
|
+
const optionSets = [];
|
|
125
|
+
const optionSetNames = Object.keys(uploadedOptionData[0]);
|
|
126
|
+
for (const optionSetName of optionSetNames) {
|
|
127
|
+
const uniqueOptionSetValues = new Set();
|
|
128
|
+
for (const data of uploadedOptionData) {
|
|
129
|
+
const label = data[optionSetName];
|
|
130
|
+
uniqueOptionSetValues.add(label);
|
|
131
|
+
}
|
|
132
|
+
const optionSet = [];
|
|
133
|
+
if (uniqueOptionSetValues) {
|
|
134
|
+
for (const entry of uniqueOptionSetValues.values()) {
|
|
135
|
+
if (entry === '') {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
optionSet.push({
|
|
139
|
+
value: util_1.StringUtil.convertToCamelCase(entry),
|
|
140
|
+
display: entry,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const reducedOptionSet = {
|
|
145
|
+
name: optionSetName,
|
|
146
|
+
isArchived: false,
|
|
147
|
+
optionSet,
|
|
148
|
+
};
|
|
149
|
+
optionSets.push(reducedOptionSet);
|
|
150
|
+
}
|
|
151
|
+
return optionSets;
|
|
152
|
+
}
|
|
153
|
+
exports.parseLabelsInColumn = parseLabelsInColumn;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class ParseOptionSetsToFolderStructure extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
file: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare function parseLabelsInColumn(uploadedOptionData: any): any[];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseLabelsInColumn = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
|
+
const util_1 = require("@contrail/util");
|
|
8
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
9
|
+
const csv = require('csvtojson');
|
|
10
|
+
const yaml = require('js-yaml');
|
|
11
|
+
const core_1 = require("@oclif/core");
|
|
12
|
+
class ParseOptionSetsToFolderStructure extends core_1.Command {
|
|
13
|
+
async run() {
|
|
14
|
+
const { args } = await this.parse(ParseOptionSetsToFolderStructure);
|
|
15
|
+
try {
|
|
16
|
+
console.log('%s Importing local file', chalk_1.default.yellow.bold('OPTION SET PARSE'));
|
|
17
|
+
console.log('Using File: ', args.file);
|
|
18
|
+
await parseOptionSetsToFolderStructure(args.file);
|
|
19
|
+
console.log('%s Parsed', chalk_1.default.yellow.bold('OPTION SET PARSE'));
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.log(`%s PARSE Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.log('%s PARSE Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = ParseOptionSetsToFolderStructure;
|
|
29
|
+
ParseOptionSetsToFolderStructure.description = '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"';
|
|
30
|
+
ParseOptionSetsToFolderStructure.examples = [
|
|
31
|
+
`$ contrail types parseOptionSetsLocalFiles <File Paths> <style>
|
|
32
|
+
`,
|
|
33
|
+
];
|
|
34
|
+
ParseOptionSetsToFolderStructure.args = {
|
|
35
|
+
file: core_1.Args.string({ description: 'File to parse', required: true }),
|
|
36
|
+
};
|
|
37
|
+
function loadOptionSets(fileLocation) {
|
|
38
|
+
const TARGET_DIR = process.cwd();
|
|
39
|
+
try {
|
|
40
|
+
const fullPath = path.resolve(path.join(TARGET_DIR, fileLocation));
|
|
41
|
+
console.log('Getting file from path: ', fullPath);
|
|
42
|
+
const doc = yaml.load(fs_1.default.readFileSync(fullPath, 'utf8'));
|
|
43
|
+
return doc;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function parseOptionSetsToFolderStructure(fileLocation) {
|
|
50
|
+
const uploadedOptionData = await loadOptionSets(fileLocation);
|
|
51
|
+
saveDataInFolders(uploadedOptionData);
|
|
52
|
+
}
|
|
53
|
+
function saveDataInFolders(data) {
|
|
54
|
+
const folder = { filename: 'option-sets', split: true, fileLabel: 'name' };
|
|
55
|
+
const dir = 'merged_option_sets';
|
|
56
|
+
const CURRENT_DIR = process.cwd();
|
|
57
|
+
const subDir = path.join(CURRENT_DIR, dir, folder.filename);
|
|
58
|
+
if (!fs_1.default.existsSync(subDir)) {
|
|
59
|
+
fs_1.default.mkdirSync(subDir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
for (const item of data) {
|
|
62
|
+
const yamlStr = yaml.dump(item);
|
|
63
|
+
const fileLabel = item[folder.fileLabel];
|
|
64
|
+
if (!fileLabel) {
|
|
65
|
+
console.warn('skipping bad data:', item);
|
|
66
|
+
}
|
|
67
|
+
fs_1.default.writeFileSync(path.join(subDir, `${removeSlash(fileLabel)}.yml`), yamlStr, 'utf8');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function removeSlash(string) {
|
|
71
|
+
const re = /\//gi;
|
|
72
|
+
return string.replace(re, '-');
|
|
73
|
+
}
|
|
74
|
+
function parseLabelsInColumn(uploadedOptionData) {
|
|
75
|
+
const optionSets = [];
|
|
76
|
+
const optionSetNames = Object.keys(uploadedOptionData[0]);
|
|
77
|
+
for (const optionSetName of optionSetNames) {
|
|
78
|
+
const uniqueOptionSetValues = new Set();
|
|
79
|
+
for (const data of uploadedOptionData) {
|
|
80
|
+
const label = data[optionSetName];
|
|
81
|
+
uniqueOptionSetValues.add(label);
|
|
82
|
+
}
|
|
83
|
+
const optionSet = [];
|
|
84
|
+
if (uniqueOptionSetValues) {
|
|
85
|
+
for (const entry of uniqueOptionSetValues.values()) {
|
|
86
|
+
if (entry === '') {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
optionSet.push({
|
|
90
|
+
value: util_1.StringUtil.convertToCamelCase(entry),
|
|
91
|
+
display: entry,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const reducedOptionSet = {
|
|
96
|
+
name: optionSetName,
|
|
97
|
+
isArchived: false,
|
|
98
|
+
optionSet,
|
|
99
|
+
};
|
|
100
|
+
optionSets.push(reducedOptionSet);
|
|
101
|
+
}
|
|
102
|
+
return optionSets;
|
|
103
|
+
}
|
|
104
|
+
exports.parseLabelsInColumn = parseLabelsInColumn;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class ParseTypesFromFiles extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static strict: boolean;
|
|
6
|
+
static args: {
|
|
7
|
+
typePaths: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const type_parser_1 = require("../../helpers/types/type-parser");
|
|
7
|
+
class ParseTypesFromFiles extends core_1.Command {
|
|
8
|
+
async run() {
|
|
9
|
+
const { argv } = await this.parse(ParseTypesFromFiles);
|
|
10
|
+
try {
|
|
11
|
+
console.log('%s Parsing', chalk_1.default.yellow.bold('TYPES AND OPTION SETS'));
|
|
12
|
+
const fileIds = argv;
|
|
13
|
+
console.log('Using FileId(s): ', fileIds);
|
|
14
|
+
await (0, type_parser_1.parseTypesFromFiles)(fileIds);
|
|
15
|
+
console.log('%s Parsed', chalk_1.default.yellow.bold('TYPES AND OPTION SETS'));
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.log(`%s Parsing Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log('%s Parsing Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = ParseTypesFromFiles;
|
|
25
|
+
ParseTypesFromFiles.description = 'Parse CSV files into Types and OptionSets from VibeIQ Files.\n File must be .yml.';
|
|
26
|
+
ParseTypesFromFiles.examples = [
|
|
27
|
+
`$ contrail types parseTypesFromFiles <fileIds>
|
|
28
|
+
`,
|
|
29
|
+
];
|
|
30
|
+
// variable argument length
|
|
31
|
+
ParseTypesFromFiles.strict = false;
|
|
32
|
+
ParseTypesFromFiles.args = {
|
|
33
|
+
typePaths: core_1.Args.string({ description: 'A list of the VibeIQ file IDs to parse', required: true }),
|
|
34
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class ParseTypesFromLocalFiles extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static strict: boolean;
|
|
6
|
+
static args: {
|
|
7
|
+
typePaths: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const type_parser_1 = require("../../helpers/types/type-parser");
|
|
7
|
+
class ParseTypesFromLocalFiles extends core_1.Command {
|
|
8
|
+
async run() {
|
|
9
|
+
const { argv } = await this.parse(ParseTypesFromLocalFiles);
|
|
10
|
+
try {
|
|
11
|
+
console.log('%s Parsing', chalk_1.default.yellow.bold('TYPES AND OPTION SETS'));
|
|
12
|
+
const fileLocations = argv;
|
|
13
|
+
console.log('Using File Location(s): ', fileLocations);
|
|
14
|
+
await (0, type_parser_1.parseTypesFromLocalFiles)(fileLocations);
|
|
15
|
+
console.log('%s Parsed', chalk_1.default.yellow.bold('TYPES AND OPTION SETS'));
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.log(`%s Parsing Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log('%s Parsing Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = ParseTypesFromLocalFiles;
|
|
25
|
+
ParseTypesFromLocalFiles.description = 'Parse CSV files into Types and OptionSets from local files.';
|
|
26
|
+
ParseTypesFromLocalFiles.examples = [
|
|
27
|
+
`$ contrail types parseTypesFromLocalFiles <File Paths>
|
|
28
|
+
`,
|
|
29
|
+
];
|
|
30
|
+
// variable argument length
|
|
31
|
+
ParseTypesFromLocalFiles.strict = false;
|
|
32
|
+
ParseTypesFromLocalFiles.args = {
|
|
33
|
+
typePaths: core_1.Args.string({ description: 'A list of the files to parse', required: true }),
|
|
34
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class ParseTypesFromTemplateAndDataFromLocalFiles extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static strict: boolean;
|
|
6
|
+
static args: {
|
|
7
|
+
templateFile: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
8
|
+
filePaths: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const type_parser_1 = require("../../helpers/types/type-parser");
|
|
7
|
+
class ParseTypesFromTemplateAndDataFromLocalFiles extends core_1.Command {
|
|
8
|
+
async run() {
|
|
9
|
+
const { args, argv } = await this.parse(ParseTypesFromTemplateAndDataFromLocalFiles);
|
|
10
|
+
try {
|
|
11
|
+
console.log('%s Parsing', chalk_1.default.yellow.bold('TYPES AND OPTION SETS'));
|
|
12
|
+
const templateFileLocation = args.templateFile;
|
|
13
|
+
const dataFileLocations = argv.slice(1);
|
|
14
|
+
console.log('Using Template File Location: ', templateFileLocation);
|
|
15
|
+
console.log('Using Data File Location: ', dataFileLocations);
|
|
16
|
+
await (0, type_parser_1.parseTypesFromTemplateAndDataFromLocalFiles)(templateFileLocation, dataFileLocations);
|
|
17
|
+
console.log('%s Parsed', chalk_1.default.yellow.bold('TYPES AND OPTION SETS'));
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
console.log(`%s Parsing Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log('%s Parsing Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = ParseTypesFromTemplateAndDataFromLocalFiles;
|
|
27
|
+
ParseTypesFromTemplateAndDataFromLocalFiles.description = 'Parse CSV files into Types and OptionSets from local type template files.';
|
|
28
|
+
ParseTypesFromTemplateAndDataFromLocalFiles.examples = [
|
|
29
|
+
`$ contrail types parseTypesFromTemplateAndDataFromLocalFiles <Template Path> <File Paths>
|
|
30
|
+
`,
|
|
31
|
+
];
|
|
32
|
+
ParseTypesFromTemplateAndDataFromLocalFiles.strict = false;
|
|
33
|
+
ParseTypesFromTemplateAndDataFromLocalFiles.args = {
|
|
34
|
+
templateFile: core_1.Args.string({ description: 'The template file to use', required: true }),
|
|
35
|
+
filePaths: core_1.Args.string({ description: 'A list of data file to use', required: true }),
|
|
36
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class ParseTypesFromTemplateFromLocalFiles extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
templateFile: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
7
|
+
filePath: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const type_parser_1 = require("../../helpers/types/type-parser");
|
|
7
|
+
class ParseTypesFromTemplateFromLocalFiles extends core_1.Command {
|
|
8
|
+
async run() {
|
|
9
|
+
const { args, } = await this.parse(ParseTypesFromTemplateFromLocalFiles);
|
|
10
|
+
try {
|
|
11
|
+
console.log('%s Parsing', chalk_1.default.yellow.bold('TYPES AND OPTION SETS'));
|
|
12
|
+
const templateFileLocation = args.templateFile;
|
|
13
|
+
const dataFileLocation = args.filePath;
|
|
14
|
+
console.log('Using Template File Location: ', templateFileLocation);
|
|
15
|
+
console.log('Using Data File Location: ', dataFileLocation);
|
|
16
|
+
await (0, type_parser_1.parseTypesFromTemplateFromLocalFiles)(templateFileLocation, dataFileLocation);
|
|
17
|
+
console.log('%s Parsed', chalk_1.default.yellow.bold('TYPES AND OPTION SETS'));
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
console.log(`%s Parsing Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log('%s Parsing Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = ParseTypesFromTemplateFromLocalFiles;
|
|
27
|
+
ParseTypesFromTemplateFromLocalFiles.description = 'Parse CSV files into Types and OptionSets from local type template files.';
|
|
28
|
+
ParseTypesFromTemplateFromLocalFiles.examples = [
|
|
29
|
+
`$ contrail types parseTypesFromTemplateFromLocalFiles <Template File> <Data File>
|
|
30
|
+
`,
|
|
31
|
+
];
|
|
32
|
+
ParseTypesFromTemplateFromLocalFiles.args = {
|
|
33
|
+
templateFile: core_1.Args.string({ description: 'The template file to use', required: true }),
|
|
34
|
+
filePath: core_1.Args.string({ description: 'The data file to use', required: true }),
|
|
35
|
+
};
|