auth0-deploy-cli 7.4.0 → 7.5.2
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/.circleci/config.yml +15 -0
- package/.eslintrc +66 -17
- package/.github/CODEOWNERS +1 -0
- package/.husky/pre-commit +2 -0
- package/CHANGELOG.md +27 -2
- package/lib/args.js +94 -81
- package/lib/commands/export.js +54 -78
- package/lib/commands/import.js +46 -70
- package/lib/commands/index.js +11 -20
- package/lib/configFactory.js +19 -27
- package/lib/context/defaults.js +18 -41
- package/lib/context/directory/handlers/actions.js +77 -107
- package/lib/context/directory/handlers/attackProtection.js +59 -0
- package/lib/context/directory/handlers/clientGrants.js +45 -54
- package/lib/context/directory/handlers/clients.js +60 -79
- package/lib/context/directory/handlers/connections.js +65 -89
- package/lib/context/directory/handlers/databases.js +91 -123
- package/lib/context/directory/handlers/emailProvider.js +46 -57
- package/lib/context/directory/handlers/emailTemplates.js +67 -80
- package/lib/context/directory/handlers/guardianFactorProviders.js +41 -49
- package/lib/context/directory/handlers/guardianFactorTemplates.js +41 -49
- package/lib/context/directory/handlers/guardianFactors.js +41 -49
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +40 -50
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +40 -50
- package/lib/context/directory/handlers/guardianPolicies.js +40 -50
- package/lib/context/directory/handlers/hooks.js +55 -70
- package/lib/context/directory/handlers/index.js +53 -123
- package/lib/context/directory/handlers/migrations.js +36 -41
- package/lib/context/directory/handlers/organizations.js +54 -69
- package/lib/context/directory/handlers/pages.js +72 -86
- package/lib/context/directory/handlers/resourceServers.js +41 -49
- package/lib/context/directory/handlers/roles.js +49 -62
- package/lib/context/directory/handlers/rules.js +52 -68
- package/lib/context/directory/handlers/rulesConfigs.js +33 -32
- package/lib/context/directory/handlers/tenant.js +52 -47
- package/lib/context/directory/handlers/triggers.js +39 -54
- package/lib/context/directory/index.js +113 -101
- package/lib/context/index.js +96 -105
- package/lib/context/yaml/handlers/actions.js +71 -88
- package/lib/context/yaml/handlers/attackProtection.js +29 -0
- package/lib/context/yaml/handlers/clientGrants.js +36 -29
- package/lib/context/yaml/handlers/clients.js +61 -76
- package/lib/context/yaml/handlers/connections.js +76 -103
- package/lib/context/yaml/handlers/databases.js +64 -79
- package/lib/context/yaml/handlers/emailProvider.js +33 -30
- package/lib/context/yaml/handlers/emailTemplates.js +45 -54
- package/lib/context/yaml/handlers/guardianFactorProviders.js +27 -18
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +27 -18
- package/lib/context/yaml/handlers/guardianFactors.js +27 -18
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +27 -20
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +27 -20
- package/lib/context/yaml/handlers/guardianPolicies.js +27 -20
- package/lib/context/yaml/handlers/hooks.js +57 -67
- package/lib/context/yaml/handlers/index.js +53 -123
- package/lib/context/yaml/handlers/migrations.js +23 -24
- package/lib/context/yaml/handlers/organizations.js +40 -38
- package/lib/context/yaml/handlers/pages.js +49 -58
- package/lib/context/yaml/handlers/resourceServers.js +27 -18
- package/lib/context/yaml/handlers/roles.js +34 -24
- package/lib/context/yaml/handlers/rules.js +48 -58
- package/lib/context/yaml/handlers/rulesConfigs.js +27 -18
- package/lib/context/yaml/handlers/tenant.js +44 -30
- package/lib/context/yaml/handlers/triggers.js +32 -23
- package/lib/context/yaml/index.js +127 -142
- package/lib/index.js +73 -79
- package/lib/logger.js +18 -22
- package/lib/readonly.js +74 -66
- package/lib/tools/ValidationError.js +8 -13
- package/lib/tools/auth0/client.js +143 -133
- package/lib/tools/auth0/handlers/actions.js +231 -243
- package/lib/tools/auth0/handlers/attackProtection.js +86 -0
- package/lib/tools/auth0/handlers/branding.js +47 -46
- package/lib/tools/auth0/handlers/clientGrants.js +118 -116
- package/lib/tools/auth0/handlers/clients.js +72 -90
- package/lib/tools/auth0/handlers/connections.js +150 -118
- package/lib/tools/auth0/handlers/databases.js +127 -124
- package/lib/tools/auth0/handlers/default.js +186 -189
- package/lib/tools/auth0/handlers/emailProvider.js +67 -78
- package/lib/tools/auth0/handlers/emailTemplates.js +116 -92
- package/lib/tools/auth0/handlers/guardianFactorProviders.js +66 -81
- package/lib/tools/auth0/handlers/guardianFactorTemplates.js +60 -71
- package/lib/tools/auth0/handlers/guardianFactors.js +56 -63
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +80 -79
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +77 -76
- package/lib/tools/auth0/handlers/guardianPolicies.js +59 -62
- package/lib/tools/auth0/handlers/hooks.js +201 -227
- package/lib/tools/auth0/handlers/index.js +53 -111
- package/lib/tools/auth0/handlers/migrations.js +99 -79
- package/lib/tools/auth0/handlers/organizations.js +225 -247
- package/lib/tools/auth0/handlers/pages.js +116 -154
- package/lib/tools/auth0/handlers/prompts.js +47 -46
- package/lib/tools/auth0/handlers/resourceServers.js +88 -112
- package/lib/tools/auth0/handlers/roles.js +203 -220
- package/lib/tools/auth0/handlers/rules.js +168 -189
- package/lib/tools/auth0/handlers/rulesConfigs.js +54 -63
- package/lib/tools/auth0/handlers/tenant.js +88 -64
- package/lib/tools/auth0/handlers/triggers.js +126 -126
- package/lib/tools/auth0/index.js +92 -85
- package/lib/tools/auth0/schema.js +39 -31
- package/lib/tools/constants.js +111 -21
- package/lib/tools/deploy.js +35 -32
- package/lib/tools/index.js +19 -32
- package/lib/tools/logger.js +11 -12
- package/lib/tools/utils.js +255 -282
- package/lib/utils.js +167 -190
- package/package.json +10 -16
- package/tsconfig.json +17 -0
- package/typescript-migration-progress.sh +22 -0
- package/.babelrc +0 -17
- package/.nyc_output/597f412e-a239-4319-ad5b-ddb87fc39e67.json +0 -1
- package/.nyc_output/processinfo/597f412e-a239-4319-ad5b-ddb87fc39e67.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
|
@@ -1,77 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _logger2 = _interopRequireDefault(_logger);
|
|
22
|
-
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const tools_1 = require("../../../tools");
|
|
18
|
+
const utils_1 = require("../../../utils");
|
|
19
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
25
20
|
function parse(context) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
const hooksFolder = path_1.default.join(context.filePath, tools_1.constants.HOOKS_DIRECTORY);
|
|
22
|
+
if (!(0, utils_1.existsMustBeDir)(hooksFolder))
|
|
23
|
+
return { hooks: undefined }; // Skip
|
|
24
|
+
const files = (0, utils_1.getFiles)(hooksFolder, ['.json']);
|
|
25
|
+
const hooks = files.map((f) => {
|
|
26
|
+
const hook = Object.assign({}, (0, utils_1.loadJSON)(f, context.mappings));
|
|
27
|
+
if (hook.script) {
|
|
28
|
+
hook.script = context.loadFile(hook.script, tools_1.constants.HOOKS_DIRECTORY);
|
|
29
|
+
}
|
|
30
|
+
hook.name = hook.name.toLowerCase().replace(/\s/g, '-');
|
|
31
|
+
return hook;
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
hooks
|
|
34
35
|
};
|
|
35
|
-
|
|
36
|
-
if (hook.script) {
|
|
37
|
-
hook.script = context.loadFile(hook.script, _tools.constants.HOOKS_DIRECTORY);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
hook.name = hook.name.toLowerCase().replace(/\s/g, '-');
|
|
41
|
-
return hook;
|
|
42
|
-
});
|
|
43
|
-
return {
|
|
44
|
-
hooks
|
|
45
|
-
};
|
|
46
36
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
(0, _utils.dumpJSON)(hookFile, { ...hook,
|
|
69
|
-
script: `./${name}.js`
|
|
37
|
+
function dump(context) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const hooks = [...context.assets.hooks || []];
|
|
40
|
+
if (hooks.length < 1)
|
|
41
|
+
return;
|
|
42
|
+
// Create Hooks folder
|
|
43
|
+
const hooksFolder = path_1.default.join(context.filePath, tools_1.constants.HOOKS_DIRECTORY);
|
|
44
|
+
fs_extra_1.default.ensureDirSync(hooksFolder);
|
|
45
|
+
hooks.forEach((hook) => {
|
|
46
|
+
// Dump script to file
|
|
47
|
+
// For cases when hook does not have `meta['hook-name']`
|
|
48
|
+
hook.name = hook.name || hook.id;
|
|
49
|
+
const name = (0, utils_1.sanitize)(hook.name);
|
|
50
|
+
const hookCode = path_1.default.join(hooksFolder, `${name}.js`);
|
|
51
|
+
logger_1.default.info(`Writing ${hookCode}`);
|
|
52
|
+
fs_extra_1.default.writeFileSync(hookCode, hook.script);
|
|
53
|
+
// Dump template metadata
|
|
54
|
+
const hookFile = path_1.default.join(hooksFolder, `${name}.json`);
|
|
55
|
+
(0, utils_1.dumpJSON)(hookFile, Object.assign(Object.assign({}, hook), { script: `./${name}.js` }));
|
|
56
|
+
});
|
|
70
57
|
});
|
|
71
|
-
});
|
|
72
58
|
}
|
|
73
|
-
|
|
74
59
|
exports.default = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
60
|
+
parse,
|
|
61
|
+
dump
|
|
62
|
+
};
|
|
@@ -1,125 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var _connections = require("./connections");
|
|
32
|
-
|
|
33
|
-
var _connections2 = _interopRequireDefault(_connections);
|
|
34
|
-
|
|
35
|
-
var _databases = require("./databases");
|
|
36
|
-
|
|
37
|
-
var _databases2 = _interopRequireDefault(_databases);
|
|
38
|
-
|
|
39
|
-
var _emailTemplates = require("./emailTemplates");
|
|
40
|
-
|
|
41
|
-
var _emailTemplates2 = _interopRequireDefault(_emailTemplates);
|
|
42
|
-
|
|
43
|
-
var _clientGrants = require("./clientGrants");
|
|
44
|
-
|
|
45
|
-
var _clientGrants2 = _interopRequireDefault(_clientGrants);
|
|
46
|
-
|
|
47
|
-
var _rulesConfigs = require("./rulesConfigs");
|
|
48
|
-
|
|
49
|
-
var _rulesConfigs2 = _interopRequireDefault(_rulesConfigs);
|
|
50
|
-
|
|
51
|
-
var _resourceServers = require("./resourceServers");
|
|
52
|
-
|
|
53
|
-
var _resourceServers2 = _interopRequireDefault(_resourceServers);
|
|
54
|
-
|
|
55
|
-
var _guardianFactors = require("./guardianFactors");
|
|
56
|
-
|
|
57
|
-
var _guardianFactors2 = _interopRequireDefault(_guardianFactors);
|
|
58
|
-
|
|
59
|
-
var _guardianFactorProviders = require("./guardianFactorProviders");
|
|
60
|
-
|
|
61
|
-
var _guardianFactorProviders2 = _interopRequireDefault(_guardianFactorProviders);
|
|
62
|
-
|
|
63
|
-
var _guardianFactorTemplates = require("./guardianFactorTemplates");
|
|
64
|
-
|
|
65
|
-
var _guardianFactorTemplates2 = _interopRequireDefault(_guardianFactorTemplates);
|
|
66
|
-
|
|
67
|
-
var _guardianPhoneFactorMessageTypes = require("./guardianPhoneFactorMessageTypes");
|
|
68
|
-
|
|
69
|
-
var _guardianPhoneFactorMessageTypes2 = _interopRequireDefault(_guardianPhoneFactorMessageTypes);
|
|
70
|
-
|
|
71
|
-
var _guardianPhoneFactorSelectedProvider = require("./guardianPhoneFactorSelectedProvider");
|
|
72
|
-
|
|
73
|
-
var _guardianPhoneFactorSelectedProvider2 = _interopRequireDefault(_guardianPhoneFactorSelectedProvider);
|
|
74
|
-
|
|
75
|
-
var _guardianPolicies = require("./guardianPolicies");
|
|
76
|
-
|
|
77
|
-
var _guardianPolicies2 = _interopRequireDefault(_guardianPolicies);
|
|
78
|
-
|
|
79
|
-
var _roles = require("./roles");
|
|
80
|
-
|
|
81
|
-
var _roles2 = _interopRequireDefault(_roles);
|
|
82
|
-
|
|
83
|
-
var _migrations = require("./migrations");
|
|
84
|
-
|
|
85
|
-
var _migrations2 = _interopRequireDefault(_migrations);
|
|
86
|
-
|
|
87
|
-
var _actions = require("./actions");
|
|
88
|
-
|
|
89
|
-
var _actions2 = _interopRequireDefault(_actions);
|
|
90
|
-
|
|
91
|
-
var _organizations = require("./organizations");
|
|
92
|
-
|
|
93
|
-
var _organizations2 = _interopRequireDefault(_organizations);
|
|
94
|
-
|
|
95
|
-
var _triggers = require("./triggers");
|
|
96
|
-
|
|
97
|
-
var _triggers2 = _interopRequireDefault(_triggers);
|
|
98
|
-
|
|
99
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
100
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const pages_1 = __importDefault(require("./pages"));
|
|
7
|
+
const rules_1 = __importDefault(require("./rules"));
|
|
8
|
+
const hooks_1 = __importDefault(require("./hooks"));
|
|
9
|
+
const clients_1 = __importDefault(require("./clients"));
|
|
10
|
+
const tenant_1 = __importDefault(require("./tenant"));
|
|
11
|
+
const emailProvider_1 = __importDefault(require("./emailProvider"));
|
|
12
|
+
const connections_1 = __importDefault(require("./connections"));
|
|
13
|
+
const databases_1 = __importDefault(require("./databases"));
|
|
14
|
+
const emailTemplates_1 = __importDefault(require("./emailTemplates"));
|
|
15
|
+
const clientGrants_1 = __importDefault(require("./clientGrants"));
|
|
16
|
+
const rulesConfigs_1 = __importDefault(require("./rulesConfigs"));
|
|
17
|
+
const resourceServers_1 = __importDefault(require("./resourceServers"));
|
|
18
|
+
const guardianFactors_1 = __importDefault(require("./guardianFactors"));
|
|
19
|
+
const guardianFactorProviders_1 = __importDefault(require("./guardianFactorProviders"));
|
|
20
|
+
const guardianFactorTemplates_1 = __importDefault(require("./guardianFactorTemplates"));
|
|
21
|
+
const guardianPhoneFactorMessageTypes_1 = __importDefault(require("./guardianPhoneFactorMessageTypes"));
|
|
22
|
+
const guardianPhoneFactorSelectedProvider_1 = __importDefault(require("./guardianPhoneFactorSelectedProvider"));
|
|
23
|
+
const guardianPolicies_1 = __importDefault(require("./guardianPolicies"));
|
|
24
|
+
const roles_1 = __importDefault(require("./roles"));
|
|
25
|
+
const migrations_1 = __importDefault(require("./migrations"));
|
|
26
|
+
const actions_1 = __importDefault(require("./actions"));
|
|
27
|
+
const organizations_1 = __importDefault(require("./organizations"));
|
|
28
|
+
const triggers_1 = __importDefault(require("./triggers"));
|
|
29
|
+
const attackProtection_1 = __importDefault(require("./attackProtection"));
|
|
101
30
|
exports.default = {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
31
|
+
rules: rules_1.default,
|
|
32
|
+
rulesConfigs: rulesConfigs_1.default,
|
|
33
|
+
hooks: hooks_1.default,
|
|
34
|
+
pages: pages_1.default,
|
|
35
|
+
databases: databases_1.default,
|
|
36
|
+
clientGrants: clientGrants_1.default,
|
|
37
|
+
resourceServers: resourceServers_1.default,
|
|
38
|
+
clients: clients_1.default,
|
|
39
|
+
connections: connections_1.default,
|
|
40
|
+
tenant: tenant_1.default,
|
|
41
|
+
emailProvider: emailProvider_1.default,
|
|
42
|
+
emailTemplates: emailTemplates_1.default,
|
|
43
|
+
guardianFactors: guardianFactors_1.default,
|
|
44
|
+
guardianFactorProviders: guardianFactorProviders_1.default,
|
|
45
|
+
guardianFactorTemplates: guardianFactorTemplates_1.default,
|
|
46
|
+
migrations: migrations_1.default,
|
|
47
|
+
guardianPhoneFactorMessageTypes: guardianPhoneFactorMessageTypes_1.default,
|
|
48
|
+
guardianPhoneFactorSelectedProvider: guardianPhoneFactorSelectedProvider_1.default,
|
|
49
|
+
guardianPolicies: guardianPolicies_1.default,
|
|
50
|
+
roles: roles_1.default,
|
|
51
|
+
actions: actions_1.default,
|
|
52
|
+
organizations: organizations_1.default,
|
|
53
|
+
triggers: triggers_1.default,
|
|
54
|
+
attackProtection: attackProtection_1.default
|
|
55
|
+
};
|
|
@@ -1,46 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const utils_1 = require("../../../utils");
|
|
15
17
|
function parse(context) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return {};
|
|
18
|
+
const baseFolder = path_1.default.join(context.filePath);
|
|
19
|
+
if (!(0, utils_1.existsMustBeDir)(baseFolder))
|
|
20
|
+
return {}; // Skip
|
|
21
|
+
const migrationsFile = path_1.default.join(baseFolder, 'migrations.json');
|
|
22
|
+
if ((0, utils_1.isFile)(migrationsFile)) {
|
|
23
|
+
/* eslint-disable camelcase */
|
|
24
|
+
const migrations = (0, utils_1.loadJSON)(migrationsFile, context.mappings);
|
|
25
|
+
return { migrations };
|
|
26
|
+
}
|
|
27
|
+
return {};
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(0, _utils.dumpJSON)(migrationsFile, migrations);
|
|
29
|
+
function dump(context) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const { migrations } = context.assets;
|
|
32
|
+
if (!migrations || Object.keys(migrations).length === 0)
|
|
33
|
+
return; // Skip, nothing to dump
|
|
34
|
+
const migrationsFile = path_1.default.join(context.filePath, 'migrations.json');
|
|
35
|
+
(0, utils_1.dumpJSON)(migrationsFile, migrations);
|
|
36
|
+
});
|
|
41
37
|
}
|
|
42
|
-
|
|
43
38
|
exports.default = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
39
|
+
parse,
|
|
40
|
+
dump
|
|
41
|
+
};
|
|
@@ -1,75 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _utils = require("../../../utils");
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
18
|
+
const utils_1 = require("../../../utils");
|
|
23
19
|
function parse(context) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
const organizationsFolder = path_1.default.join(context.filePath, 'organizations');
|
|
21
|
+
if (!(0, utils_1.existsMustBeDir)(organizationsFolder))
|
|
22
|
+
return { organizations: undefined }; // Skip
|
|
23
|
+
const files = (0, utils_1.getFiles)(organizationsFolder, ['.json']);
|
|
24
|
+
const organizations = files.map((f) => {
|
|
25
|
+
const org = Object.assign({}, (0, utils_1.loadJSON)(f, context.mappings));
|
|
26
|
+
return org;
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
organizations
|
|
32
30
|
};
|
|
33
|
-
return org;
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
organizations
|
|
37
|
-
};
|
|
38
31
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
delete conn.connection;
|
|
64
|
-
return conn;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
(0, _utils.dumpJSON)(organizationFile, organization);
|
|
69
|
-
});
|
|
32
|
+
function dump(context) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const { organizations } = context.assets;
|
|
35
|
+
// API returns an empty object if no grants are present
|
|
36
|
+
if (!organizations || organizations.constructor === Object)
|
|
37
|
+
return; // Skip, nothing to dump
|
|
38
|
+
const organizationsFolder = path_1.default.join(context.filePath, 'organizations');
|
|
39
|
+
fs_extra_1.default.ensureDirSync(organizationsFolder);
|
|
40
|
+
organizations.forEach((organization) => {
|
|
41
|
+
const organizationFile = path_1.default.join(organizationsFolder, (0, utils_1.sanitize)(`${organization.name}.json`));
|
|
42
|
+
logger_1.default.info(`Writing ${organizationFile}`);
|
|
43
|
+
if (organization.connections.length > 0) {
|
|
44
|
+
organization.connections = organization.connections.map((c) => {
|
|
45
|
+
// connection is a computed field
|
|
46
|
+
const name = c.connection && c.connection.name;
|
|
47
|
+
const conn = Object.assign({ name }, c);
|
|
48
|
+
delete conn.connection_id;
|
|
49
|
+
delete conn.connection;
|
|
50
|
+
return conn;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
(0, utils_1.dumpJSON)(organizationFile, organization);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
70
56
|
}
|
|
71
|
-
|
|
72
57
|
exports.default = {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
58
|
+
parse,
|
|
59
|
+
dump
|
|
60
|
+
};
|