@contrail/cli 3.5.2-alpha.fcd3386 → 3.5.3-alpha.0dcc977
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 +50 -1
- package/dist/api/org-config.d.ts +3 -0
- package/dist/api/org-config.js +26 -0
- package/dist/commands/groups/export.js +1 -13
- package/dist/commands/instance/export.js +2 -0
- package/dist/commands/instance/import.js +2 -0
- package/dist/commands/org-config/export.d.ts +13 -0
- package/dist/commands/org-config/export.js +71 -0
- package/dist/commands/org-config/import.d.ts +12 -0
- package/dist/commands/org-config/import.js +70 -0
- package/dist/commands/users/export.js +1 -13
- package/dist/helpers/file-helpers.d.ts +1 -0
- package/dist/helpers/file-helpers.js +15 -1
- package/node_modules/@contrail/org-config-migration/.github/workflows/publish-to-npm.yml +117 -0
- package/node_modules/@contrail/org-config-migration/.husky/pre-commit +0 -0
- package/node_modules/@contrail/org-config-migration/lib/index.d.ts +3 -3
- package/node_modules/@contrail/org-config-migration/lib/index.js +19 -19
- package/node_modules/@contrail/org-config-migration/lib/interfaces.d.ts +87 -97
- package/node_modules/@contrail/org-config-migration/lib/interfaces.js +2 -2
- package/node_modules/@contrail/org-config-migration/lib/services/index.d.ts +1 -1
- package/node_modules/@contrail/org-config-migration/lib/services/index.js +17 -17
- package/node_modules/@contrail/org-config-migration/lib/services/types.d.ts +12 -17
- package/node_modules/@contrail/org-config-migration/lib/services/types.js +115 -155
- package/node_modules/@contrail/org-config-migration/lib/types/exportAll.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportAll.js +34 -40
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.js +20 -20
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.js +16 -47
- package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.js +8 -8
- package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.js +14 -39
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.js +44 -56
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.js +44 -71
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.js +85 -85
- package/node_modules/@contrail/org-config-migration/lib/types/importAll.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/importAll.js +386 -451
- package/node_modules/@contrail/org-config-migration/lib/types/index.d.ts +8 -9
- package/node_modules/@contrail/org-config-migration/lib/types/index.js +24 -25
- package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.d.ts +3 -3
- package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.js +210 -210
- package/node_modules/@contrail/org-config-migration/lib/users/export.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/export.js +40 -40
- package/node_modules/@contrail/org-config-migration/lib/users/import.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/import.js +41 -41
- package/node_modules/@contrail/org-config-migration/lib/users/index.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/index.js +18 -18
- package/node_modules/@contrail/org-config-migration/package.json +1 -1
- package/oclif.manifest.json +111 -1
- package/package.json +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.d.ts +0 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.js +0 -39
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ $ npm install -g @contrail/cli
|
|
|
17
17
|
$ contrail COMMAND
|
|
18
18
|
running command...
|
|
19
19
|
$ contrail (--version)
|
|
20
|
-
@contrail/cli/3.5.
|
|
20
|
+
@contrail/cli/3.5.3-alpha.0dcc977 linux-x64 node-v24.19.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -61,6 +61,8 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
|
|
|
61
61
|
* [`contrail load custom-entity DATAFILE CONFIGFILE`](#contrail-load-custom-entity-datafile-configfile)
|
|
62
62
|
* [`contrail load line-sheet DATAFILE CONFIGFILE`](#contrail-load-line-sheet-datafile-configfile)
|
|
63
63
|
* [`contrail load upload-and-load INCOMINGFILE CONFIGFILENAME`](#contrail-load-upload-and-load-incomingfile-configfilename)
|
|
64
|
+
* [`contrail org-config export`](#contrail-org-config-export)
|
|
65
|
+
* [`contrail org-config import`](#contrail-org-config-import)
|
|
64
66
|
* [`contrail projects export PROJECTNAME`](#contrail-projects-export-projectname)
|
|
65
67
|
* [`contrail projects list`](#contrail-projects-list)
|
|
66
68
|
* [`contrail projects load TEMPLATEFILELOCATION`](#contrail-projects-load-templatefilelocation)
|
|
@@ -777,6 +779,53 @@ EXAMPLES
|
|
|
777
779
|
$ contrail load-processor upload-and-load <File Path> <Config Path>
|
|
778
780
|
```
|
|
779
781
|
|
|
782
|
+
## `contrail org-config export`
|
|
783
|
+
|
|
784
|
+
Export the org config for your Org
|
|
785
|
+
|
|
786
|
+
```
|
|
787
|
+
USAGE
|
|
788
|
+
$ contrail org-config export [-l error|warn|info|debug] [-e true|false] [-d <value>] [-f]
|
|
789
|
+
|
|
790
|
+
FLAGS
|
|
791
|
+
-d, --outDir=<value> [default: .] The directory to which to export the org config data. Defaults to the
|
|
792
|
+
current directory
|
|
793
|
+
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
794
|
+
<options: true|false>
|
|
795
|
+
-f, --overwrite Replaces any existing export files in outDir
|
|
796
|
+
-l, --logLevel=<option> The Log Level
|
|
797
|
+
<options: error|warn|info|debug>
|
|
798
|
+
|
|
799
|
+
DESCRIPTION
|
|
800
|
+
Export the org config for your Org
|
|
801
|
+
|
|
802
|
+
EXAMPLES
|
|
803
|
+
$ contrail org-config export
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
## `contrail org-config import`
|
|
807
|
+
|
|
808
|
+
Upload an extracted org config
|
|
809
|
+
|
|
810
|
+
```
|
|
811
|
+
USAGE
|
|
812
|
+
$ contrail org-config import [-l error|warn|info|debug] [-e true|false] [-d <value>]
|
|
813
|
+
|
|
814
|
+
FLAGS
|
|
815
|
+
-d, --dir=<value> [default: .] The directory from which to import the org config data. Defaults to the
|
|
816
|
+
current directory. The org config data will be loaded from $dir/org-config.yml
|
|
817
|
+
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
818
|
+
<options: true|false>
|
|
819
|
+
-l, --logLevel=<option> The Log Level
|
|
820
|
+
<options: error|warn|info|debug>
|
|
821
|
+
|
|
822
|
+
DESCRIPTION
|
|
823
|
+
Upload an extracted org config
|
|
824
|
+
|
|
825
|
+
EXAMPLES
|
|
826
|
+
$ contrail org-config import
|
|
827
|
+
```
|
|
828
|
+
|
|
780
829
|
## `contrail projects export PROJECTNAME`
|
|
781
830
|
|
|
782
831
|
Export a project.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOrgConfig = exports.updateOrgConfig = exports.getOrgConfigs = void 0;
|
|
4
|
+
const sdk_1 = require("@contrail/sdk");
|
|
5
|
+
async function getOrgConfigs(options) {
|
|
6
|
+
return new sdk_1.Entities().get({
|
|
7
|
+
entityName: 'org-config',
|
|
8
|
+
...options,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.getOrgConfigs = getOrgConfigs;
|
|
12
|
+
async function updateOrgConfig(id, changes) {
|
|
13
|
+
return new sdk_1.Entities().update({
|
|
14
|
+
entityName: 'org-config',
|
|
15
|
+
id,
|
|
16
|
+
object: changes,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.updateOrgConfig = updateOrgConfig;
|
|
20
|
+
async function createOrgConfig(orgConfig) {
|
|
21
|
+
return new sdk_1.Entities().create({
|
|
22
|
+
entityName: 'org-config',
|
|
23
|
+
object: orgConfig,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.createOrgConfig = createOrgConfig;
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.exportGroups = exports.DEFAULT_FILE_LOCATION = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path = tslib_1.__importStar(require("path"));
|
|
6
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
6
|
const login_1 = require("../../auth/login");
|
|
9
|
-
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
10
7
|
const core_1 = require("@oclif/core");
|
|
11
8
|
const file_helpers_1 = require("../../helpers/file-helpers");
|
|
12
9
|
const users_1 = require("../../api/users");
|
|
@@ -61,18 +58,9 @@ async function exportGroups(fileLocation, overwrite) {
|
|
|
61
58
|
});
|
|
62
59
|
}
|
|
63
60
|
groups = groups.sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
64
|
-
await saveData(groups, fileLocation, overwrite);
|
|
61
|
+
await (0, file_helpers_1.saveData)(groups, fileLocation, overwrite);
|
|
65
62
|
}
|
|
66
63
|
exports.exportGroups = exportGroups;
|
|
67
|
-
async function saveData(data, fileLocation, overwrite) {
|
|
68
|
-
const yamlStr = js_yaml_1.default.dump(data);
|
|
69
|
-
const CURRENT_DIR = process.cwd();
|
|
70
|
-
const pathToWrite = path.join(CURRENT_DIR, fileLocation);
|
|
71
|
-
if (fs_1.default.existsSync(pathToWrite)) {
|
|
72
|
-
await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
|
|
73
|
-
}
|
|
74
|
-
fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
|
|
75
|
-
}
|
|
76
64
|
function getGroupPrincipals(group, allGroups, orgUsers) {
|
|
77
65
|
if (!group?.groupPrincipals) {
|
|
78
66
|
return [];
|
|
@@ -6,6 +6,7 @@ const core_1 = require("@oclif/core");
|
|
|
6
6
|
const getAll_1 = require("../types/getAll");
|
|
7
7
|
const export_1 = require("../users/export");
|
|
8
8
|
const export_2 = require("../groups/export");
|
|
9
|
+
const export_3 = require("../org-config/export");
|
|
9
10
|
const basecommand_1 = require("../../basecommand");
|
|
10
11
|
class ExportInstance extends basecommand_1.BaseCommand {
|
|
11
12
|
static description = 'Exports an data of an instance including types and users';
|
|
@@ -32,6 +33,7 @@ class ExportInstance extends basecommand_1.BaseCommand {
|
|
|
32
33
|
await (0, getAll_1.getAll)(this.flags.outDir, this.flags.overwrite);
|
|
33
34
|
await (0, export_1.exportUsers)(path.join(this.flags.outDir, 'users.yml'), this.flags.overwrite);
|
|
34
35
|
await (0, export_2.exportGroups)(path.join(this.flags.outDir, 'groups.yml'), this.flags.overwrite);
|
|
36
|
+
await (0, export_3.exportOrgConfig)(this.flags.outDir, this.flags.overwrite);
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
exports.default = ExportInstance;
|
|
@@ -8,6 +8,7 @@ const import_1 = require("../users/import");
|
|
|
8
8
|
const import_2 = require("../groups/import");
|
|
9
9
|
const uploadTypePropertyPolicies_1 = require("../types/uploadTypePropertyPolicies");
|
|
10
10
|
const uploadTypePolicies_1 = require("../types/uploadTypePolicies");
|
|
11
|
+
const import_3 = require("../org-config/import");
|
|
11
12
|
const basecommand_1 = require("../../basecommand");
|
|
12
13
|
class ImportInstance extends basecommand_1.BaseCommand {
|
|
13
14
|
static description = 'Import the data to an instance, including types and users';
|
|
@@ -30,6 +31,7 @@ class ImportInstance extends basecommand_1.BaseCommand {
|
|
|
30
31
|
await (0, import_2.uploadGroups)(path.join(this.flags.dir, 'groups.yml'));
|
|
31
32
|
await (0, uploadTypePropertyPolicies_1.uploadTypePropertyPolicies)(this.flags.dir);
|
|
32
33
|
await (0, uploadTypePolicies_1.uploadTypePolicies)(this.flags.dir);
|
|
34
|
+
await (0, import_3.uploadOrgConfig)(this.flags.dir);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
exports.default = ImportInstance;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../basecommand';
|
|
2
|
+
export default class ExportOrgConfig extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
outDir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function exportOrgConfig(outDir: string, overwrite: boolean): Promise<void>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exportOrgConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
const login_1 = require("../../auth/login");
|
|
8
|
+
const core_1 = require("@oclif/core");
|
|
9
|
+
const file_helpers_1 = require("../../helpers/file-helpers");
|
|
10
|
+
const org_config_1 = require("../../api/org-config");
|
|
11
|
+
const basecommand_1 = require("../../basecommand");
|
|
12
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
13
|
+
const ORG_SPECIFIC_FIELDS = [
|
|
14
|
+
'id',
|
|
15
|
+
'orgId',
|
|
16
|
+
'createdOn',
|
|
17
|
+
'updatedOn',
|
|
18
|
+
'createdById',
|
|
19
|
+
'updatedById',
|
|
20
|
+
'createdBy',
|
|
21
|
+
'updatedBy',
|
|
22
|
+
];
|
|
23
|
+
class ExportOrgConfig extends basecommand_1.BaseCommand {
|
|
24
|
+
static description = 'Export the org config for your Org';
|
|
25
|
+
static examples = [
|
|
26
|
+
`$ contrail org-config export
|
|
27
|
+
`,
|
|
28
|
+
];
|
|
29
|
+
static flags = {
|
|
30
|
+
...basecommand_1.BaseCommand.baseFlags,
|
|
31
|
+
outDir: core_1.Flags.string({
|
|
32
|
+
char: 'd',
|
|
33
|
+
description: 'The directory to which to export the org config data. Defaults to the current directory',
|
|
34
|
+
required: false,
|
|
35
|
+
default: '.',
|
|
36
|
+
}),
|
|
37
|
+
overwrite: core_1.Flags.boolean({
|
|
38
|
+
char: 'f',
|
|
39
|
+
description: 'Replaces any existing export files in outDir',
|
|
40
|
+
required: false,
|
|
41
|
+
default: false,
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
44
|
+
async run() {
|
|
45
|
+
await exportOrgConfig(this.flags.outDir, this.flags.overwrite);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.default = ExportOrgConfig;
|
|
49
|
+
async function exportOrgConfig(outDir, overwrite) {
|
|
50
|
+
try {
|
|
51
|
+
await (0, login_1.authUser)();
|
|
52
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} Exporting`);
|
|
53
|
+
const orgConfigs = await (0, org_config_1.getOrgConfigs)();
|
|
54
|
+
if (!Array.isArray(orgConfigs) || orgConfigs.length === 0) {
|
|
55
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} No org config found. Skipping.`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const orgConfig = { ...orgConfigs[0] };
|
|
59
|
+
for (const field of ORG_SPECIFIC_FIELDS) {
|
|
60
|
+
delete orgConfig[field];
|
|
61
|
+
}
|
|
62
|
+
await (0, file_helpers_1.saveData)(orgConfig, path.join(outDir, 'org-config.yml'), overwrite);
|
|
63
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} Exported`);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
logger_1.default.info(`${chalk_1.default.red.bold('FAIL')} Org Config Export Failed. ${e}`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
logger_1.default.info(`${chalk_1.default.green.bold('COMPLETE')} Org Config Export Complete.`);
|
|
70
|
+
}
|
|
71
|
+
exports.exportOrgConfig = exportOrgConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../basecommand';
|
|
2
|
+
export default class ImportOrgConfig extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare function uploadOrgConfig(dir: string): Promise<void>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadOrgConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
|
+
const login_1 = require("../../auth/login");
|
|
9
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
10
|
+
const core_1 = require("@oclif/core");
|
|
11
|
+
const org_config_1 = require("../../api/org-config");
|
|
12
|
+
const basecommand_1 = require("../../basecommand");
|
|
13
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
14
|
+
class ImportOrgConfig extends basecommand_1.BaseCommand {
|
|
15
|
+
static description = 'Upload an extracted org config';
|
|
16
|
+
static examples = [
|
|
17
|
+
`$ contrail org-config import
|
|
18
|
+
`,
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
...basecommand_1.BaseCommand.baseFlags,
|
|
22
|
+
dir: core_1.Flags.string({
|
|
23
|
+
char: 'd',
|
|
24
|
+
description: 'The directory from which to import the org config data. Defaults to the current directory. The org config data will be loaded from $dir/org-config.yml',
|
|
25
|
+
required: false,
|
|
26
|
+
default: '.',
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
async run() {
|
|
30
|
+
await uploadOrgConfig(this.flags.dir);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = ImportOrgConfig;
|
|
34
|
+
async function uploadOrgConfig(dir) {
|
|
35
|
+
try {
|
|
36
|
+
await (0, login_1.authUser)();
|
|
37
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} Uploading`);
|
|
38
|
+
const orgConfig = loadOrgConfig(dir);
|
|
39
|
+
if (!orgConfig || typeof orgConfig !== 'object') {
|
|
40
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} No org config found in ${dir}. Skipping.`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const existingOrgConfigs = await (0, org_config_1.getOrgConfigs)();
|
|
44
|
+
if (Array.isArray(existingOrgConfigs) && existingOrgConfigs.length > 0) {
|
|
45
|
+
await (0, org_config_1.updateOrgConfig)(existingOrgConfigs[0].id, orgConfig);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
await (0, org_config_1.createOrgConfig)(orgConfig);
|
|
49
|
+
}
|
|
50
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('ORG CONFIG')} Uploaded`);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
logger_1.default.info(`${chalk_1.default.red.bold('FAIL')} Org Config Upload Failed. ${e}`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
logger_1.default.info(`${chalk_1.default.green.bold('COMPLETE')} Org Config Upload Complete.`);
|
|
57
|
+
}
|
|
58
|
+
exports.uploadOrgConfig = uploadOrgConfig;
|
|
59
|
+
function loadOrgConfig(fromDir) {
|
|
60
|
+
const filePath = path.join(fromDir, 'org-config.yml');
|
|
61
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
return js_yaml_1.default.load(fs_1.default.readFileSync(filePath, 'utf8'));
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.exportUsers = exports.DEFAULT_FILE_LOCATION = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path = tslib_1.__importStar(require("path"));
|
|
6
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
6
|
const login_1 = require("../../auth/login");
|
|
9
|
-
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
10
7
|
const core_1 = require("@oclif/core");
|
|
11
8
|
const file_helpers_1 = require("../../helpers/file-helpers");
|
|
12
9
|
const users_1 = require("../../api/users");
|
|
@@ -63,15 +60,6 @@ async function exportUsers(fileLocation, overwrite) {
|
|
|
63
60
|
});
|
|
64
61
|
}
|
|
65
62
|
users = users.sort((one, two) => (one.email < two.email ? -1 : 1));
|
|
66
|
-
await saveData(users, fileLocation, overwrite);
|
|
63
|
+
await (0, file_helpers_1.saveData)(users, fileLocation, overwrite);
|
|
67
64
|
}
|
|
68
65
|
exports.exportUsers = exportUsers;
|
|
69
|
-
async function saveData(data, fileLocation, overwrite) {
|
|
70
|
-
const yamlStr = js_yaml_1.default.dump(data);
|
|
71
|
-
const CURRENT_DIR = process.cwd();
|
|
72
|
-
const pathToWrite = path.resolve(path.join(CURRENT_DIR, fileLocation));
|
|
73
|
-
if (fs_1.default.existsSync(pathToWrite)) {
|
|
74
|
-
await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
|
|
75
|
-
}
|
|
76
|
-
fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
|
|
77
|
-
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCSVData = exports.safeFileOverwrite = void 0;
|
|
3
|
+
exports.saveData = exports.parseCSVData = exports.safeFileOverwrite = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
7
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
6
9
|
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
7
10
|
const sync_1 = require("csv-parse/sync");
|
|
8
11
|
const PASS_FORCE_TO_OVERWRITE = 'Pass --overwrite to overwrite without prompting';
|
|
@@ -34,3 +37,14 @@ function parseCSVData(data) {
|
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
exports.parseCSVData = parseCSVData;
|
|
40
|
+
//saves data as yaml to fileLocation (relative to the current directory), prompting before overwriting unless overwrite is passed
|
|
41
|
+
async function saveData(data, fileLocation, overwrite) {
|
|
42
|
+
const yamlStr = js_yaml_1.default.dump(data);
|
|
43
|
+
const CURRENT_DIR = process.cwd();
|
|
44
|
+
const pathToWrite = path.resolve(path.join(CURRENT_DIR, fileLocation));
|
|
45
|
+
if (fs_1.default.existsSync(pathToWrite)) {
|
|
46
|
+
await safeFileOverwrite(pathToWrite, overwrite);
|
|
47
|
+
}
|
|
48
|
+
fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
|
|
49
|
+
}
|
|
50
|
+
exports.saveData = saveData;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
name: Publish to NPM
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ['**']
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
check-version:
|
|
11
|
+
name: Verify version is available on npm
|
|
12
|
+
if: github.event_name == 'pull_request'
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Check version not already published
|
|
18
|
+
run: |
|
|
19
|
+
PACKAGE_NAME=$(node -p "require('./package.json').name")
|
|
20
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
21
|
+
echo "Checking if ${PACKAGE_NAME}@${VERSION} exists on npm..."
|
|
22
|
+
if npm view "${PACKAGE_NAME}@${VERSION}" version 2>/dev/null; then
|
|
23
|
+
echo "::error::Version ${VERSION} is already published on npm. Bump the version in package.json before merging."
|
|
24
|
+
exit 1
|
|
25
|
+
else
|
|
26
|
+
echo "Version ${VERSION} is available."
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
check-dependencies:
|
|
30
|
+
name: Verify no private dependencies
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v4
|
|
34
|
+
|
|
35
|
+
- name: Verify no private dependencies
|
|
36
|
+
run: |
|
|
37
|
+
node -e "
|
|
38
|
+
const deps = require('./package.json').dependencies || {};
|
|
39
|
+
const { execSync } = require('child_process');
|
|
40
|
+
let failed = false;
|
|
41
|
+
for (const pkg of Object.keys(deps)) {
|
|
42
|
+
try {
|
|
43
|
+
execSync('npm view ' + pkg, { stdio: 'pipe' });
|
|
44
|
+
} catch {
|
|
45
|
+
console.error('::error::Dependency ' + pkg + ' is not publicly accessible on npm');
|
|
46
|
+
failed = true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (failed) process.exit(1);
|
|
50
|
+
console.log('All ' + Object.keys(deps).length + ' dependencies are public.');
|
|
51
|
+
"
|
|
52
|
+
|
|
53
|
+
publish-alpha:
|
|
54
|
+
name: Publish alpha
|
|
55
|
+
needs: check-dependencies
|
|
56
|
+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
permissions:
|
|
59
|
+
id-token: write
|
|
60
|
+
contents: read
|
|
61
|
+
outputs:
|
|
62
|
+
version: ${{ steps.publish.outputs.version }}
|
|
63
|
+
steps:
|
|
64
|
+
- uses: actions/checkout@v4
|
|
65
|
+
|
|
66
|
+
- uses: actions/setup-node@v4
|
|
67
|
+
with:
|
|
68
|
+
node-version: '24'
|
|
69
|
+
registry-url: 'https://registry.npmjs.org'
|
|
70
|
+
|
|
71
|
+
- name: Install and build
|
|
72
|
+
run: npm ci && npm run build
|
|
73
|
+
|
|
74
|
+
- name: Publish alpha
|
|
75
|
+
id: publish
|
|
76
|
+
run: |
|
|
77
|
+
SHORT_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-7)
|
|
78
|
+
VERSION=$(node -p "require('./package.json').version")-alpha.${SHORT_SHA}
|
|
79
|
+
npm version $VERSION --no-git-tag-version
|
|
80
|
+
OUTPUT=$(npm publish --tag alpha 2>&1) && {
|
|
81
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
82
|
+
} || {
|
|
83
|
+
if echo "$OUTPUT" | grep -q "You cannot publish over the previously published versions"; then
|
|
84
|
+
echo "::warning::Alpha ${VERSION} already published, skipping."
|
|
85
|
+
else
|
|
86
|
+
echo "::error::Failed to publish alpha ${VERSION}"
|
|
87
|
+
echo "$OUTPUT"
|
|
88
|
+
exit 1
|
|
89
|
+
fi
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
publish-release:
|
|
93
|
+
name: Publish release
|
|
94
|
+
needs: check-dependencies
|
|
95
|
+
if: github.event_name == 'push'
|
|
96
|
+
runs-on: ubuntu-latest
|
|
97
|
+
permissions:
|
|
98
|
+
id-token: write
|
|
99
|
+
contents: read
|
|
100
|
+
outputs:
|
|
101
|
+
version: ${{ steps.publish.outputs.version }}
|
|
102
|
+
steps:
|
|
103
|
+
- uses: actions/checkout@v4
|
|
104
|
+
|
|
105
|
+
- uses: actions/setup-node@v4
|
|
106
|
+
with:
|
|
107
|
+
node-version: '24'
|
|
108
|
+
registry-url: 'https://registry.npmjs.org'
|
|
109
|
+
|
|
110
|
+
- name: Install and build
|
|
111
|
+
run: npm ci && npm run build
|
|
112
|
+
|
|
113
|
+
- name: Publish release
|
|
114
|
+
id: publish
|
|
115
|
+
run: |
|
|
116
|
+
npm publish
|
|
117
|
+
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
|
|
File without changes
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './services';
|
|
3
|
-
export * from './users';
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './services';
|
|
3
|
+
export * from './users';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./services"), exports);
|
|
19
|
-
__exportStar(require("./users"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./services"), exports);
|
|
19
|
+
__exportStar(require("./users"), exports);
|