@contrail/cli 2.0.3 → 2.0.5
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/README.md +330 -187
- package/dist/api/apps.d.ts +1 -1
- package/dist/api/apps.js +2 -1
- package/dist/commands/app/install.d.ts +1 -0
- package/dist/commands/app/install.js +3 -2
- package/dist/commands/groups/export.d.ts +12 -0
- package/dist/commands/groups/export.js +93 -0
- package/dist/commands/groups/upload.d.ts +10 -0
- package/dist/commands/groups/upload.js +166 -0
- package/dist/commands/instance/export.d.ts +10 -0
- package/dist/commands/instance/export.js +24 -0
- package/dist/commands/instance/import.d.ts +9 -0
- package/dist/commands/instance/import.js +23 -0
- package/dist/commands/types/getAll.d.ts +5 -1
- package/dist/commands/types/getAll.js +31 -11
- package/dist/commands/types/loadAll.d.ts +5 -2
- package/dist/commands/types/loadAll.js +17 -13
- package/dist/commands/types/uploadOptionSetHierarchies.d.ts +4 -1
- package/dist/commands/types/uploadOptionSetHierarchies.js +13 -9
- package/dist/commands/types/uploadOptionSets.d.ts +4 -1
- package/dist/commands/types/uploadOptionSets.js +13 -9
- package/dist/commands/types/uploadRuleSets.d.ts +4 -1
- package/dist/commands/types/uploadRuleSets.js +12 -8
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +4 -1
- package/dist/commands/types/uploadTypePropertyPolicies.js +12 -8
- package/dist/commands/types/uploadUsageInfo.d.ts +4 -1
- package/dist/commands/types/uploadUsageInfo.js +9 -6
- package/dist/commands/users/export.d.ts +4 -1
- package/dist/commands/users/export.js +16 -7
- package/dist/commands/users/upload.d.ts +1 -0
- package/dist/commands/users/upload.js +5 -4
- package/dist/helpers/app/app-deployer.js +2 -0
- package/dist/helpers/file-helpers.d.ts +1 -0
- package/dist/helpers/file-helpers.js +23 -0
- package/dist/helpers/types/type-uploader.d.ts +1 -1
- package/dist/helpers/types/type-uploader.js +8 -8
- package/dist/interfaces.d.ts +1 -0
- package/dist/templates/typescript/app.yml +1 -0
- package/dist/templates/typescript/src/actions/logItem.ts +3 -8
- package/dist/templates/typescript/src/framework/app-config.ts +1 -4
- package/oclif.manifest.json +212 -15
- package/package.json +8 -3
|
@@ -2,6 +2,9 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class UploadOptionSets extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
};
|
|
5
8
|
run(): Promise<void>;
|
|
6
9
|
}
|
|
7
|
-
export declare function uploadOptionSets(): Promise<void>;
|
|
10
|
+
export declare function uploadOptionSets(dir: string): Promise<void>;
|
|
@@ -11,7 +11,8 @@ const core_1 = require("@oclif/core");
|
|
|
11
11
|
const yaml = require('js-yaml');
|
|
12
12
|
class UploadOptionSets extends core_1.Command {
|
|
13
13
|
async run() {
|
|
14
|
-
|
|
14
|
+
const { flags } = await this.parse(UploadOptionSets);
|
|
15
|
+
return await uploadOptionSets(flags.dir);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
exports.default = UploadOptionSets;
|
|
@@ -20,12 +21,15 @@ UploadOptionSets.examples = [
|
|
|
20
21
|
`$ contrail types uploadOptionSets
|
|
21
22
|
`,
|
|
22
23
|
];
|
|
23
|
-
|
|
24
|
+
UploadOptionSets.flags = {
|
|
25
|
+
dir: core_1.Flags.string({ char: 'd', description: 'The directory from which to export the option set data. Defaults to the current directory. The option set data will be loaded from $dir/option-sets', required: false, default: '.' }),
|
|
26
|
+
};
|
|
27
|
+
async function uploadOptionSets(dir) {
|
|
24
28
|
try {
|
|
25
29
|
const userConfig = await (0, login_1.authUser)();
|
|
26
30
|
console.log(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk_1.default.blue.bold('START'));
|
|
27
31
|
console.log('%s Uploading', chalk_1.default.yellow.bold('OPTION SETS'));
|
|
28
|
-
await uploadOS();
|
|
32
|
+
await uploadOS(dir);
|
|
29
33
|
console.log('%s Uploaded', chalk_1.default.yellow.bold('OPTION SETS'));
|
|
30
34
|
}
|
|
31
35
|
catch (e) {
|
|
@@ -35,13 +39,13 @@ async function uploadOptionSets() {
|
|
|
35
39
|
console.log('%s Types Upload Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
36
40
|
}
|
|
37
41
|
exports.uploadOptionSets = uploadOptionSets;
|
|
38
|
-
function loadOptionSets() {
|
|
39
|
-
const TARGET_DIR = process.cwd();
|
|
42
|
+
function loadOptionSets(fromDir) {
|
|
40
43
|
try {
|
|
41
|
-
const
|
|
44
|
+
const dir = path.resolve(path.join(fromDir, 'option-sets'));
|
|
45
|
+
const files = fs_1.default.readdirSync(dir);
|
|
42
46
|
const optionSets = [];
|
|
43
47
|
for (const file of files) {
|
|
44
|
-
optionSets.push(yaml.load(fs_1.default.readFileSync(path.join(
|
|
48
|
+
optionSets.push(yaml.load(fs_1.default.readFileSync(path.join(dir, file), 'utf8')));
|
|
45
49
|
}
|
|
46
50
|
return optionSets;
|
|
47
51
|
}
|
|
@@ -49,8 +53,8 @@ function loadOptionSets() {
|
|
|
49
53
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
|
-
async function uploadOS() {
|
|
53
|
-
const optionSets = loadOptionSets();
|
|
56
|
+
async function uploadOS(dir) {
|
|
57
|
+
const optionSets = loadOptionSets(dir);
|
|
54
58
|
const currentOptionSets = await new sdk_1.Entities().get({
|
|
55
59
|
entityName: 'type-property-option-set',
|
|
56
60
|
});
|
|
@@ -2,6 +2,9 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class UploadRuleSets extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
};
|
|
5
8
|
run(): Promise<void>;
|
|
6
9
|
}
|
|
7
|
-
export declare function uploadRuleSets(): Promise<void>;
|
|
10
|
+
export declare function uploadRuleSets(dir: string): Promise<void>;
|
|
@@ -11,7 +11,8 @@ const core_1 = require("@oclif/core");
|
|
|
11
11
|
const yaml = require('js-yaml');
|
|
12
12
|
class UploadRuleSets extends core_1.Command {
|
|
13
13
|
async run() {
|
|
14
|
-
await
|
|
14
|
+
const { flags } = await this.parse(UploadRuleSets);
|
|
15
|
+
await uploadRuleSets(flags.dir);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
exports.default = UploadRuleSets;
|
|
@@ -20,11 +21,14 @@ UploadRuleSets.examples = [
|
|
|
20
21
|
`$ contrail types uploadRuleSets
|
|
21
22
|
`,
|
|
22
23
|
];
|
|
23
|
-
|
|
24
|
+
UploadRuleSets.flags = {
|
|
25
|
+
dir: core_1.Flags.string({ char: 'd', description: 'The directory from which to export the rule set data. Defaults to the current directory. The rule set data will be loaded from $dir/rule-sets/*.yml', required: false, default: '.' }),
|
|
26
|
+
};
|
|
27
|
+
async function uploadRuleSets(dir) {
|
|
24
28
|
try {
|
|
25
29
|
await (0, login_1.authUser)();
|
|
26
30
|
console.log('%s Uploading', chalk_1.default.yellow.bold('RULE SET'));
|
|
27
|
-
const [reducedRuleSets, reducedRuleSetLinks] = await loadReducedRuleSets();
|
|
31
|
+
const [reducedRuleSets, reducedRuleSetLinks] = await loadReducedRuleSets(dir);
|
|
28
32
|
await uploadRuleSetObjects(reducedRuleSets);
|
|
29
33
|
await uploadRuleSetLinkObjects(reducedRuleSetLinks);
|
|
30
34
|
console.log('%s Uploaded', chalk_1.default.yellow.bold('RULE SET'));
|
|
@@ -36,16 +40,16 @@ async function uploadRuleSets() {
|
|
|
36
40
|
console.log('%s Rule set Upload Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
37
41
|
}
|
|
38
42
|
exports.uploadRuleSets = uploadRuleSets;
|
|
39
|
-
function loadReducedRuleSets() {
|
|
43
|
+
function loadReducedRuleSets(fromDir) {
|
|
40
44
|
const ruleSets = [];
|
|
41
45
|
let ruleSetLinks = [];
|
|
42
|
-
const
|
|
46
|
+
const dir = path.join(fromDir, 'rule-sets');
|
|
43
47
|
try {
|
|
44
|
-
const files = fs_1.default.readdirSync(
|
|
48
|
+
const files = fs_1.default.readdirSync(dir);
|
|
45
49
|
for (const file of files) {
|
|
46
|
-
ruleSets.push(yaml.load(fs_1.default.readFileSync(path.join(
|
|
50
|
+
ruleSets.push(yaml.load(fs_1.default.readFileSync(path.join(dir, file), 'utf8')));
|
|
47
51
|
}
|
|
48
|
-
ruleSetLinks = yaml.load(fs_1.default.readFileSync(path.join(
|
|
52
|
+
ruleSetLinks = yaml.load(fs_1.default.readFileSync(path.join(fromDir, 'rule-set-links.yml'), 'utf8'));
|
|
49
53
|
return [ruleSets, ruleSetLinks];
|
|
50
54
|
}
|
|
51
55
|
catch (e) {
|
|
@@ -2,6 +2,9 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class UploadTypePropertyPolicies extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
};
|
|
5
8
|
run(): Promise<void>;
|
|
6
9
|
}
|
|
7
|
-
export declare function uploadTypePropertyPolicies(): Promise<void>;
|
|
10
|
+
export declare function uploadTypePropertyPolicies(dir: string): Promise<void>;
|
|
@@ -12,7 +12,8 @@ const type_extractor_1 = require("../../helpers/types/type-extractor");
|
|
|
12
12
|
const yaml = require('js-yaml');
|
|
13
13
|
class UploadTypePropertyPolicies extends core_1.Command {
|
|
14
14
|
async run() {
|
|
15
|
-
|
|
15
|
+
const { flags } = await this.parse(UploadTypePropertyPolicies);
|
|
16
|
+
return await uploadTypePropertyPolicies(flags.dir);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
exports.default = UploadTypePropertyPolicies;
|
|
@@ -21,11 +22,14 @@ UploadTypePropertyPolicies.examples = [
|
|
|
21
22
|
`$ contrail types uploadTypePropertyPolicies
|
|
22
23
|
`,
|
|
23
24
|
];
|
|
24
|
-
|
|
25
|
+
UploadTypePropertyPolicies.flags = {
|
|
26
|
+
dir: core_1.Flags.string({ char: 'd', description: 'The directory from which to export the type property policy data. Defaults to the current directory. The type property policy data will be loaded from $dir/type-property-policies/*.yml', required: false, default: '.' }),
|
|
27
|
+
};
|
|
28
|
+
async function uploadTypePropertyPolicies(dir) {
|
|
25
29
|
try {
|
|
26
30
|
await (0, login_1.authUser)();
|
|
27
31
|
console.log('%s Uploading', chalk_1.default.yellow.bold('TYPE PROPERTY POLICY'));
|
|
28
|
-
const [reducedTypePropertyPolicies, reducedTypePropertyPolicyLinks] = await loadTPPolicies();
|
|
32
|
+
const [reducedTypePropertyPolicies, reducedTypePropertyPolicyLinks] = await loadTPPolicies(dir);
|
|
29
33
|
await uploadTPPolicyObjects(reducedTypePropertyPolicies);
|
|
30
34
|
await uploadTypePropertyPolicyLinks(reducedTypePropertyPolicyLinks);
|
|
31
35
|
console.log('%s Uploaded', chalk_1.default.yellow.bold('TYPE PROPERTY POLICY'));
|
|
@@ -37,16 +41,16 @@ async function uploadTypePropertyPolicies() {
|
|
|
37
41
|
console.log('%s Type Property Policy Upload Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
38
42
|
}
|
|
39
43
|
exports.uploadTypePropertyPolicies = uploadTypePropertyPolicies;
|
|
40
|
-
function loadTPPolicies() {
|
|
44
|
+
function loadTPPolicies(fromDir) {
|
|
41
45
|
const tpps = [];
|
|
42
46
|
let tppLinks = [];
|
|
43
|
-
const
|
|
47
|
+
const dir = path.join(fromDir, 'type-property-policies');
|
|
44
48
|
try {
|
|
45
|
-
const files = fs_1.default.readdirSync(
|
|
49
|
+
const files = fs_1.default.readdirSync(dir);
|
|
46
50
|
for (const file of files) {
|
|
47
|
-
tpps.push(yaml.load(fs_1.default.readFileSync(path.join(
|
|
51
|
+
tpps.push(yaml.load(fs_1.default.readFileSync(path.join(dir, file), 'utf8')));
|
|
48
52
|
}
|
|
49
|
-
tppLinks = yaml.load(fs_1.default.readFileSync(path.join(
|
|
53
|
+
tppLinks = yaml.load(fs_1.default.readFileSync(path.join(fromDir, 'type-property-policy-links.yml'), 'utf8'));
|
|
50
54
|
return [tpps, tppLinks];
|
|
51
55
|
}
|
|
52
56
|
catch (e) {
|
|
@@ -2,6 +2,9 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class UploadUsageInfo extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
};
|
|
5
8
|
run(): Promise<void>;
|
|
6
9
|
}
|
|
7
|
-
export declare function uploadUsageInfo(): Promise<void>;
|
|
10
|
+
export declare function uploadUsageInfo(dir: string): Promise<void>;
|
|
@@ -12,7 +12,8 @@ const type_extractor_1 = require("../../helpers/types/type-extractor");
|
|
|
12
12
|
const yaml = require('js-yaml');
|
|
13
13
|
class UploadUsageInfo extends core_1.Command {
|
|
14
14
|
async run() {
|
|
15
|
-
await
|
|
15
|
+
const { flags } = await this.parse(UploadUsageInfo);
|
|
16
|
+
await uploadUsageInfo(flags.dir);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
exports.default = UploadUsageInfo;
|
|
@@ -21,11 +22,14 @@ UploadUsageInfo.examples = [
|
|
|
21
22
|
`$ contrail types uploadUsageInfo
|
|
22
23
|
`,
|
|
23
24
|
];
|
|
24
|
-
|
|
25
|
+
UploadUsageInfo.flags = {
|
|
26
|
+
dir: core_1.Flags.string({ char: 'd', description: 'The directory from which to export the usage info data. Defaults to the current directory. The option set data will be loaded from $dir/usage-info.yml', required: false, default: '.' }),
|
|
27
|
+
};
|
|
28
|
+
async function uploadUsageInfo(dir) {
|
|
25
29
|
try {
|
|
26
30
|
await (0, login_1.authUser)();
|
|
27
31
|
console.log('%s Uploading', chalk_1.default.yellow.bold('USAGE INFO'));
|
|
28
|
-
const reducedUsageInfo = await loadUsageInfo();
|
|
32
|
+
const reducedUsageInfo = await loadUsageInfo(dir);
|
|
29
33
|
await uploadUsageInfoObjects(reducedUsageInfo);
|
|
30
34
|
console.log('%s Uploaded', chalk_1.default.yellow.bold('USAGE INFO'));
|
|
31
35
|
}
|
|
@@ -36,10 +40,9 @@ async function uploadUsageInfo() {
|
|
|
36
40
|
console.log('%s Usage Info Upload Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
37
41
|
}
|
|
38
42
|
exports.uploadUsageInfo = uploadUsageInfo;
|
|
39
|
-
function loadUsageInfo() {
|
|
40
|
-
const TARGET_DIR = process.cwd();
|
|
43
|
+
function loadUsageInfo(dir) {
|
|
41
44
|
try {
|
|
42
|
-
const doc = yaml.load(fs_1.default.readFileSync(path.join(
|
|
45
|
+
const doc = yaml.load(fs_1.default.readFileSync(path.join(dir, 'usage-info.yml'), 'utf8'));
|
|
43
46
|
return doc;
|
|
44
47
|
}
|
|
45
48
|
catch (e) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
+
export declare const DEFAULT_FILE_LOCATION = "users.yml";
|
|
2
3
|
export default class ExportUsers extends Command {
|
|
3
4
|
static description: string;
|
|
4
5
|
static examples: string[];
|
|
5
6
|
static flags: {
|
|
6
|
-
|
|
7
|
+
outDir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
9
|
};
|
|
8
10
|
run(): Promise<void>;
|
|
9
11
|
}
|
|
12
|
+
export declare function exportUsers(fileLocation: string, overwrite: boolean): Promise<void>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exportUsers = exports.DEFAULT_FILE_LOCATION = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const path = tslib_1.__importStar(require("path"));
|
|
5
6
|
const sdk_1 = require("@contrail/sdk");
|
|
@@ -8,14 +9,16 @@ const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
|
8
9
|
const login_1 = require("../../auth/login");
|
|
9
10
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
10
11
|
const core_1 = require("@oclif/core");
|
|
12
|
+
const file_helpers_1 = require("../../helpers/file-helpers");
|
|
13
|
+
exports.DEFAULT_FILE_LOCATION = 'users.yml';
|
|
11
14
|
class ExportUsers extends core_1.Command {
|
|
12
15
|
async run() {
|
|
13
16
|
var _a;
|
|
14
|
-
const {
|
|
17
|
+
const { flags } = await this.parse(ExportUsers);
|
|
15
18
|
try {
|
|
16
19
|
await (0, login_1.authUser)();
|
|
17
20
|
this.log('%s Getting Users.', chalk_1.default.blue.bold('START'));
|
|
18
|
-
await exportUsers((_a = flags.
|
|
21
|
+
await exportUsers((_a = flags.outDir) !== null && _a !== void 0 ? _a : exports.DEFAULT_FILE_LOCATION, flags.overwrite);
|
|
19
22
|
this.log('%s Done', chalk_1.default.yellow.bold('USERS'));
|
|
20
23
|
}
|
|
21
24
|
catch (e) {
|
|
@@ -32,9 +35,10 @@ ExportUsers.examples = [
|
|
|
32
35
|
`,
|
|
33
36
|
];
|
|
34
37
|
ExportUsers.flags = {
|
|
35
|
-
|
|
38
|
+
outDir: core_1.Flags.string({ char: 'd', description: 'The location for the file to be saved', required: false, default: exports.DEFAULT_FILE_LOCATION }),
|
|
39
|
+
overwrite: core_1.Flags.boolean({ description: 'Replaces existing files if they exist', required: false, default: false })
|
|
36
40
|
};
|
|
37
|
-
async function exportUsers(fileLocation) {
|
|
41
|
+
async function exportUsers(fileLocation, overwrite) {
|
|
38
42
|
const allUsersInOrg = await new sdk_1.Entities().get({
|
|
39
43
|
entityName: 'user-org',
|
|
40
44
|
});
|
|
@@ -51,10 +55,15 @@ async function exportUsers(fileLocation) {
|
|
|
51
55
|
...userInOrg.user
|
|
52
56
|
});
|
|
53
57
|
}
|
|
54
|
-
saveData(
|
|
58
|
+
await saveData(users, fileLocation, overwrite);
|
|
55
59
|
}
|
|
56
|
-
|
|
60
|
+
exports.exportUsers = exportUsers;
|
|
61
|
+
async function saveData(data, fileLocation, overwrite) {
|
|
57
62
|
const yamlStr = js_yaml_1.default.dump(data);
|
|
58
63
|
const CURRENT_DIR = process.cwd();
|
|
59
|
-
|
|
64
|
+
const pathToWrite = path.resolve(path.join(CURRENT_DIR, fileLocation));
|
|
65
|
+
if (fs_1.default.existsSync(pathToWrite)) {
|
|
66
|
+
await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
|
|
67
|
+
}
|
|
68
|
+
fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
|
|
60
69
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadUsers = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const path = tslib_1.__importStar(require("path"));
|
|
5
6
|
const sdk_1 = require("@contrail/sdk");
|
|
@@ -10,7 +11,7 @@ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
|
10
11
|
const core_1 = require("@oclif/core");
|
|
11
12
|
class ImportUsers extends core_1.Command {
|
|
12
13
|
async run() {
|
|
13
|
-
const { args
|
|
14
|
+
const { args } = await this.parse(ImportUsers);
|
|
14
15
|
try {
|
|
15
16
|
await (0, login_1.authUser)();
|
|
16
17
|
this.log('%s Uploading Users.', chalk_1.default.blue.bold('START'));
|
|
@@ -37,10 +38,9 @@ ImportUsers.args = {
|
|
|
37
38
|
function getUsersFile(fileLocation) {
|
|
38
39
|
const CURRENT_DIR = process.cwd();
|
|
39
40
|
try {
|
|
40
|
-
const fullPath = path.
|
|
41
|
-
console.log('Getting file from path: ', fullPath);
|
|
41
|
+
const fullPath = path.join(CURRENT_DIR, fileLocation);
|
|
42
42
|
const doc = js_yaml_1.default.load(fs_1.default.readFileSync(fullPath, 'utf8'));
|
|
43
|
-
return doc
|
|
43
|
+
return doc;
|
|
44
44
|
}
|
|
45
45
|
catch (e) {
|
|
46
46
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
@@ -63,3 +63,4 @@ async function uploadUsers(fileLocation) {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
exports.uploadUsers = uploadUsers;
|
|
@@ -42,6 +42,7 @@ class AppDeployer {
|
|
|
42
42
|
identifier: appDeclaration.appIdentifier,
|
|
43
43
|
name: appDeclaration.appName,
|
|
44
44
|
public: appDeclaration.visibility === 'public',
|
|
45
|
+
hidden: appDeclaration.hidden,
|
|
45
46
|
description: appDeclaration.appDescription,
|
|
46
47
|
publisher: appDeclaration.publisher,
|
|
47
48
|
thumbnail: appDeclaration.thumbnail,
|
|
@@ -67,6 +68,7 @@ class AppDeployer {
|
|
|
67
68
|
const updates = {
|
|
68
69
|
name: appDeclaration.appName,
|
|
69
70
|
public: appDeclaration.visibility === 'public',
|
|
71
|
+
hidden: appDeclaration.hidden,
|
|
70
72
|
description: appDeclaration.appDescription,
|
|
71
73
|
publisher: appDeclaration.publisher,
|
|
72
74
|
thumbnail: appDeclaration.thumbnail,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function safeFileOverwrite(fileLocation: string, overwrite: boolean): Promise<boolean>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safeFileOverwrite = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
|
+
const PASS_FORCE_TO_OVERWRITE = 'Pass --force to overwrite without prompting';
|
|
7
|
+
//throws an error if the user declines to overwrite the file
|
|
8
|
+
async function safeFileOverwrite(fileLocation, overwrite) {
|
|
9
|
+
if (overwrite) {
|
|
10
|
+
console.log(`overwriting ${fileLocation}`);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
const answers = await inquirer_1.default.prompt([{
|
|
14
|
+
type: 'confirm',
|
|
15
|
+
name: 'shouldOverwrite',
|
|
16
|
+
message: `The file ${fileLocation} already exists. Do you wish to overwrite it?\n${PASS_FORCE_TO_OVERWRITE}`,
|
|
17
|
+
default: false
|
|
18
|
+
}]);
|
|
19
|
+
if (!answers.shouldOverwrite) {
|
|
20
|
+
throw new Error('File was not overwritten. Cancelling process...');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.safeFileOverwrite = safeFileOverwrite;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function uploadTypes(): Promise<void>;
|
|
1
|
+
export declare function uploadTypes(dir: string): Promise<void>;
|
|
@@ -9,12 +9,12 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
9
9
|
const _ = tslib_1.__importStar(require("lodash"));
|
|
10
10
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
11
11
|
const login_1 = require("../../auth/login");
|
|
12
|
-
async function uploadTypes() {
|
|
12
|
+
async function uploadTypes(dir) {
|
|
13
13
|
try {
|
|
14
14
|
const userConfig = await (0, login_1.authUser)();
|
|
15
15
|
console.log(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk_1.default.blue.bold('START'));
|
|
16
16
|
console.log('%s Uploading', chalk_1.default.yellow.bold('TYPES'));
|
|
17
|
-
await uploadReducedTypes();
|
|
17
|
+
await uploadReducedTypes(dir);
|
|
18
18
|
console.log('%s Uploaded', chalk_1.default.yellow.bold('TYPES'));
|
|
19
19
|
}
|
|
20
20
|
catch (e) {
|
|
@@ -24,13 +24,13 @@ async function uploadTypes() {
|
|
|
24
24
|
console.log('%s Types Upload Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
25
25
|
}
|
|
26
26
|
exports.uploadTypes = uploadTypes;
|
|
27
|
-
function loadReducedTypes() {
|
|
28
|
-
const TARGET_DIR = process.cwd();
|
|
27
|
+
function loadReducedTypes(fromDir) {
|
|
29
28
|
try {
|
|
30
|
-
const
|
|
29
|
+
const dir = path.resolve(path.join(fromDir, 'types'));
|
|
30
|
+
const files = fs_1.default.readdirSync(dir);
|
|
31
31
|
const types = [];
|
|
32
32
|
for (const file of files) {
|
|
33
|
-
types.push(...js_yaml_1.default.load(fs_1.default.readFileSync(path.join(
|
|
33
|
+
types.push(...js_yaml_1.default.load(fs_1.default.readFileSync(path.join(dir, file), 'utf8')));
|
|
34
34
|
}
|
|
35
35
|
return types;
|
|
36
36
|
}
|
|
@@ -38,8 +38,8 @@ function loadReducedTypes() {
|
|
|
38
38
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
async function uploadReducedTypes() {
|
|
42
|
-
const types = loadReducedTypes();
|
|
41
|
+
async function uploadReducedTypes(dir) {
|
|
42
|
+
const types = loadReducedTypes(dir);
|
|
43
43
|
const currentTypesWithoutProperties = await new sdk_1.Entities().get({
|
|
44
44
|
entityName: 'type',
|
|
45
45
|
});
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ appIdentifier: "@your-co/app-name" # Change to be your company root domain and
|
|
|
2
2
|
appName: "Your App Name" # Give your app a name
|
|
3
3
|
appDescription: "Your app description." # Give your app a description
|
|
4
4
|
visibility: private # This should be private unless you want to develop an app for all VibeIQ customers to use
|
|
5
|
+
hidden: false # can be used with a public app to prevent it from showing on the marketplace, but still installable by other orgs
|
|
5
6
|
publisher: "Your company name" # Your company name, used for public apps
|
|
6
7
|
version: 1.0
|
|
7
8
|
dockerImageRef: CHANGE_ME # For VibeIQ Deployment... for use by VibeIQ employees only
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Entities } from "@contrail/sdk";
|
|
2
2
|
import { AppActionCallBack, AppActionCallbackStatus } from "../framework";
|
|
3
3
|
import { Logger } from "../framework/logger";
|
|
4
4
|
|
|
5
5
|
export async function execute(event, config: any, logger: Logger): Promise<AppActionCallBack> {
|
|
6
6
|
logger.log('Starting Example Action');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
logger.log('Loggin in');
|
|
10
|
-
// Fetch items from the SDK
|
|
11
|
-
await setAppCredentials(config.apiKey, config.orgSlug);
|
|
12
7
|
logger.log('Getting item from SDK');
|
|
13
8
|
|
|
14
9
|
const item = await new Entities().get({
|
|
15
10
|
entityName: 'item',
|
|
16
11
|
id: event.id,
|
|
17
|
-
})
|
|
18
|
-
logger.log('Got item: ', item);
|
|
12
|
+
});
|
|
13
|
+
logger.log('Got item: ', item);
|
|
19
14
|
|
|
20
15
|
return {
|
|
21
16
|
output: {
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
2
|
* WARNING: Do not modify this file, it is part of the generic runtime handling logic
|
|
3
3
|
* for VibeIQ app actions.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
import fs from 'fs';
|
|
8
7
|
const yaml = require('js-yaml');
|
|
9
8
|
|
|
10
9
|
export function loadAppConfig(){
|
|
11
10
|
const TARGET_DIR = process.cwd();
|
|
12
|
-
console.log("TARGET_DIR: ", TARGET_DIR)
|
|
13
11
|
try {
|
|
14
12
|
const separator = getSeparatorByPlatform();
|
|
15
13
|
const doc = yaml.load(fs.readFileSync(TARGET_DIR + separator + 'app.yml', 'utf8'));
|
|
16
|
-
console.log(doc);
|
|
17
14
|
return doc;
|
|
18
15
|
} catch (e) {
|
|
19
16
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|