auth0-deploy-cli 7.5.2 → 7.6.0
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/CHANGELOG.md +11 -1
- package/lib/args.js +0 -2
- package/lib/commands/import.js +1 -0
- package/lib/context/directory/handlers/actions.js +3 -2
- package/lib/context/directory/handlers/attackProtection.js +3 -2
- package/lib/context/directory/handlers/branding.js +59 -0
- package/lib/context/directory/handlers/clientGrants.js +3 -2
- package/lib/context/directory/handlers/clients.js +3 -2
- package/lib/context/directory/handlers/connections.js +3 -2
- package/lib/context/directory/handlers/databases.js +18 -16
- package/lib/context/directory/handlers/emailProvider.js +3 -2
- package/lib/context/directory/handlers/emailTemplates.js +11 -9
- package/lib/context/directory/handlers/guardianFactorProviders.js +3 -2
- package/lib/context/directory/handlers/guardianFactorTemplates.js +3 -2
- package/lib/context/directory/handlers/guardianFactors.js +3 -2
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +3 -2
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +3 -2
- package/lib/context/directory/handlers/guardianPolicies.js +3 -2
- package/lib/context/directory/handlers/hooks.js +3 -2
- package/lib/context/directory/handlers/index.js +3 -1
- package/lib/context/directory/handlers/migrations.js +8 -8
- package/lib/context/directory/handlers/organizations.js +3 -2
- package/lib/context/directory/handlers/pages.js +18 -18
- package/lib/context/directory/handlers/resourceServers.js +3 -2
- package/lib/context/directory/handlers/roles.js +3 -2
- package/lib/context/directory/handlers/rules.js +3 -2
- package/lib/context/directory/handlers/rulesConfigs.js +4 -3
- package/lib/context/directory/handlers/tenant.js +5 -3
- package/lib/context/directory/handlers/triggers.js +3 -2
- package/lib/context/directory/index.js +2 -4
- package/lib/context/yaml/handlers/actions.js +4 -3
- package/lib/context/yaml/handlers/attackProtection.js +5 -11
- package/lib/context/yaml/handlers/branding.js +65 -0
- package/lib/context/yaml/handlers/clientGrants.js +3 -2
- package/lib/context/yaml/handlers/clients.js +3 -2
- package/lib/context/yaml/handlers/connections.js +3 -2
- package/lib/context/yaml/handlers/databases.js +3 -2
- package/lib/context/yaml/handlers/emailProvider.js +3 -2
- package/lib/context/yaml/handlers/emailTemplates.js +3 -2
- package/lib/context/yaml/handlers/guardianFactorProviders.js +5 -12
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +5 -12
- package/lib/context/yaml/handlers/guardianFactors.js +5 -12
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +5 -12
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +5 -12
- package/lib/context/yaml/handlers/guardianPolicies.js +5 -12
- package/lib/context/yaml/handlers/hooks.js +3 -2
- package/lib/context/yaml/handlers/index.js +3 -1
- package/lib/context/yaml/handlers/migrations.js +3 -2
- package/lib/context/yaml/handlers/organizations.js +3 -2
- package/lib/context/yaml/handlers/pages.js +3 -2
- package/lib/context/yaml/handlers/resourceServers.js +3 -2
- package/lib/context/yaml/handlers/roles.js +3 -2
- package/lib/context/yaml/handlers/rules.js +3 -2
- package/lib/context/yaml/handlers/rulesConfigs.js +4 -3
- package/lib/context/yaml/handlers/tenant.js +3 -2
- package/lib/context/yaml/handlers/triggers.js +3 -2
- package/lib/context/yaml/index.js +2 -1
- package/lib/tools/auth0/handlers/branding.js +67 -13
- package/lib/tools/auth0/handlers/default.js +7 -1
- package/lib/tools/auth0/handlers/organizations.js +7 -2
- package/lib/tools/auth0/handlers/resourceServers.js +7 -2
- package/lib/tools/auth0/handlers/roles.js +7 -2
- package/lib/tools/auth0/handlers/rules.js +7 -1
- package/lib/tools/calculateChanges.js +144 -0
- package/lib/tools/constants.js +7 -0
- package/lib/tools/utils.js +1 -142
- package/package.json +2 -2
- package/tsconfig.json +1 -0
|
@@ -43,7 +43,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
44
|
exports.schema = void 0;
|
|
45
45
|
const default_1 = __importStar(require("./default"));
|
|
46
|
-
const
|
|
46
|
+
const calculateChanges_1 = require("../../calculateChanges");
|
|
47
47
|
const logger_1 = __importDefault(require("../../logger"));
|
|
48
48
|
exports.schema = {
|
|
49
49
|
type: 'array',
|
|
@@ -188,7 +188,12 @@ class RoleHandler extends default_1.default {
|
|
|
188
188
|
return;
|
|
189
189
|
// Gets roles from destination tenant
|
|
190
190
|
const existing = yield this.getType();
|
|
191
|
-
const changes = (0,
|
|
191
|
+
const changes = (0, calculateChanges_1.calculateChanges)({
|
|
192
|
+
handler: this,
|
|
193
|
+
assets: roles,
|
|
194
|
+
existing,
|
|
195
|
+
identifiers: ['id', 'name']
|
|
196
|
+
});
|
|
192
197
|
logger_1.default.debug(`Start processChanges for roles [delete:${changes.del.length}] [update:${changes.update.length}], [create:${changes.create.length}]`);
|
|
193
198
|
const myChanges = [{ del: changes.del }, { create: changes.create }, { update: changes.update }];
|
|
194
199
|
yield Promise.all(myChanges.map((change) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -17,6 +17,7 @@ const ValidationError_1 = __importDefault(require("../../ValidationError"));
|
|
|
17
17
|
const utils_1 = require("../../utils");
|
|
18
18
|
const default_1 = __importDefault(require("./default"));
|
|
19
19
|
const logger_1 = __importDefault(require("../../logger"));
|
|
20
|
+
const calculateChanges_1 = require("../../calculateChanges");
|
|
20
21
|
exports.excludeSchema = {
|
|
21
22
|
type: 'array',
|
|
22
23
|
items: { type: 'string' }
|
|
@@ -84,7 +85,12 @@ class RulesHandler extends default_1.default {
|
|
|
84
85
|
existing = existing.filter((r) => !excludedRules.includes(r.name));
|
|
85
86
|
}
|
|
86
87
|
// Figure out what needs to be updated vs created
|
|
87
|
-
const { del, update, create, conflicts } = (0,
|
|
88
|
+
const { del, update, create, conflicts } = (0, calculateChanges_1.calculateChanges)({
|
|
89
|
+
handler: this,
|
|
90
|
+
assets: rules,
|
|
91
|
+
existing,
|
|
92
|
+
identifiers: ['id', 'name']
|
|
93
|
+
});
|
|
88
94
|
// Figure out the rules that need to be re-ordered
|
|
89
95
|
const futureRules = [...create, ...update];
|
|
90
96
|
const futureMaxOrder = Math.max(...futureRules.map((r) => r.order));
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
exports.calculateChanges = exports.processChangedObjectFields = void 0;
|
|
7
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
8
|
+
/**
|
|
9
|
+
* @template T
|
|
10
|
+
* @param {typeof import('./auth0/handlers/default').default} handler
|
|
11
|
+
* @param {T} desiredAssetState
|
|
12
|
+
* @param {T} currentAssetState
|
|
13
|
+
* @param {string[]} [objectFields=[]]
|
|
14
|
+
* @param {boolean} [allowDelete=false]
|
|
15
|
+
* @returns T
|
|
16
|
+
*/
|
|
17
|
+
function processChangedObjectFields({ handler, desiredAssetState, currentAssetState, allowDelete = false }) {
|
|
18
|
+
const desiredAssetStateWithChanges = Object.assign({}, desiredAssetState);
|
|
19
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
20
|
+
for (const fieldName of handler.objectFields) {
|
|
21
|
+
const areDesiredStateAndCurrentStateEmpty = Object.keys(desiredAssetState[fieldName] || {}).length === 0 && Object.keys(currentAssetState[fieldName] || {}).length === 0;
|
|
22
|
+
if (areDesiredStateAndCurrentStateEmpty) {
|
|
23
|
+
// If both the desired state and current state for a given object is empty, it is a no-op and can skip
|
|
24
|
+
// eslint-disable-next-line no-continue
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
// A desired state that omits the objectField OR that has it as an empty object should
|
|
28
|
+
// signal that all fields should be removed (subject to ALLOW_DELETE).
|
|
29
|
+
if (desiredAssetState[fieldName] && Object.keys(desiredAssetState[fieldName]).length) {
|
|
30
|
+
// Both the current and desired state have the object field. Here's where we need to map
|
|
31
|
+
// to the APIv2 protocol of setting `null` values for deleted fields.
|
|
32
|
+
// For new and modified properties of the object field, we can just pass them through to
|
|
33
|
+
// APIv2.
|
|
34
|
+
if (currentAssetState[fieldName]) {
|
|
35
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
36
|
+
for (const currentObjectFieldPropertyName of Object.keys(currentAssetState[fieldName])) {
|
|
37
|
+
// Loop through each object property that exists currently
|
|
38
|
+
if (desiredAssetState[fieldName][currentObjectFieldPropertyName] === undefined) {
|
|
39
|
+
// If the object has a property that exists now but doesn't exist in the proposed state
|
|
40
|
+
if (allowDelete) {
|
|
41
|
+
desiredAssetStateWithChanges[fieldName][currentObjectFieldPropertyName] = null;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// If deletes aren't allowed, do outright delete the property within the object
|
|
45
|
+
logger_1.default.warn(`Detected that the ${fieldName} of the following ${handler.name || handler.id || ''} should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config\n${handler.objString(currentAssetState)}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (allowDelete) {
|
|
52
|
+
// If the desired state does not have the object field and the current state does, we
|
|
53
|
+
// should mark *all* properties for deletion by specifying an empty object.
|
|
54
|
+
//
|
|
55
|
+
// See: https://auth0.com/docs/users/metadata/manage-metadata-api#delete-user-metadata
|
|
56
|
+
desiredAssetStateWithChanges[fieldName] = {};
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
delete desiredAssetStateWithChanges[fieldName];
|
|
60
|
+
logger_1.default.warn(`Detected that the ${fieldName} of the following ${handler.name || handler.id || ''} should be emptied. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config\n${handler.objString(currentAssetState)}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return desiredAssetStateWithChanges;
|
|
64
|
+
}
|
|
65
|
+
exports.processChangedObjectFields = processChangedObjectFields;
|
|
66
|
+
function calculateChanges({ handler, assets, existing, identifiers = ['id', 'name'], allowDelete }) {
|
|
67
|
+
// Calculate the changes required between two sets of assets.
|
|
68
|
+
const update = [];
|
|
69
|
+
let del = [...existing];
|
|
70
|
+
let create = [...assets];
|
|
71
|
+
const conflicts = [];
|
|
72
|
+
const findByKeyValue = (key, value, arr) => arr.find((e) => {
|
|
73
|
+
if (Array.isArray(key)) {
|
|
74
|
+
const values = key.map((k) => e[k]);
|
|
75
|
+
if (values.every((v) => v)) {
|
|
76
|
+
return value === values.join('-');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return e[key] === value;
|
|
80
|
+
});
|
|
81
|
+
const processAssets = (id, arr) => {
|
|
82
|
+
arr.forEach((asset) => {
|
|
83
|
+
const assetIdValue = (() => {
|
|
84
|
+
if (Array.isArray(id)) {
|
|
85
|
+
const values = id.map((i) => asset[i]);
|
|
86
|
+
if (values.every((v) => v)) {
|
|
87
|
+
return values.join('-');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return asset[id];
|
|
91
|
+
})();
|
|
92
|
+
if (assetIdValue !== undefined) {
|
|
93
|
+
const found = findByKeyValue(id, assetIdValue, del);
|
|
94
|
+
if (found !== undefined) {
|
|
95
|
+
// Delete from existing
|
|
96
|
+
del = del.filter((e) => e !== found);
|
|
97
|
+
// Delete from create as it's an update
|
|
98
|
+
create = create.filter((e) => e !== asset);
|
|
99
|
+
// Append identifiers to asset
|
|
100
|
+
update.push(Object.assign(Object.assign({}, identifiers.reduce((obj, i) => {
|
|
101
|
+
if (found[i])
|
|
102
|
+
obj[i] = found[i];
|
|
103
|
+
return obj;
|
|
104
|
+
}, {})), (handler.objectFields.length
|
|
105
|
+
? processChangedObjectFields({
|
|
106
|
+
handler, desiredAssetState: asset, currentAssetState: found, allowDelete
|
|
107
|
+
})
|
|
108
|
+
: asset)));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
// Loop through identifiers (in order) to try match assets to existing
|
|
114
|
+
// If existing then update if not create
|
|
115
|
+
// The remainder will be deleted
|
|
116
|
+
for (const id of identifiers) { // eslint-disable-line
|
|
117
|
+
processAssets(id, [...create]);
|
|
118
|
+
}
|
|
119
|
+
// Check if there are assets with names that will conflict with existing names during the update process
|
|
120
|
+
// This will rename those assets to a temp random name first
|
|
121
|
+
// This assumes the first identifiers is the unique identifier
|
|
122
|
+
if (identifiers.includes('name')) {
|
|
123
|
+
const uniqueID = identifiers[0];
|
|
124
|
+
const futureAssets = [...create, ...update];
|
|
125
|
+
futureAssets.forEach((a) => {
|
|
126
|
+
// If the conflicting item is going to be deleted then skip
|
|
127
|
+
const inDeleted = del.filter((e) => e.name === a.name && e[uniqueID] !== a[uniqueID])[0];
|
|
128
|
+
if (!inDeleted) {
|
|
129
|
+
const conflict = existing.filter((e) => e.name === a.name && e[uniqueID] !== a[uniqueID])[0];
|
|
130
|
+
if (conflict) {
|
|
131
|
+
const temp = Math.random().toString(36).substr(2, 5);
|
|
132
|
+
conflicts.push(Object.assign(Object.assign({}, conflict), { name: `${conflict.name}-${temp}` }));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
del,
|
|
139
|
+
update,
|
|
140
|
+
conflicts,
|
|
141
|
+
create
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
exports.calculateChanges = calculateChanges;
|
package/lib/tools/constants.js
CHANGED
|
@@ -141,12 +141,19 @@ constants.GUARDIAN_FACTOR_PROVIDERS = {
|
|
|
141
141
|
sms: ['twilio'],
|
|
142
142
|
'push-notification': ['sns']
|
|
143
143
|
};
|
|
144
|
+
constants.UNIVERSAL_LOGIN_TEMPLATE = 'universal_login';
|
|
145
|
+
constants.SUPPORTED_BRANDING_TEMPLATES = [
|
|
146
|
+
constants.UNIVERSAL_LOGIN_TEMPLATE
|
|
147
|
+
];
|
|
144
148
|
constants.RESOURCE_SERVERS_DIRECTORY = 'resource-servers';
|
|
145
149
|
constants.RESOURCE_SERVERS_CLIENT_NAME = 'resourceServers';
|
|
146
150
|
constants.RESOURCE_SERVERS_MANAGEMENT_API_NAME = 'Auth0 Management API';
|
|
147
151
|
constants.RESOURCE_SERVERS_ID_NAME = 'id';
|
|
148
152
|
constants.CLIENTS_DIRECTORY = 'clients';
|
|
149
153
|
constants.CLIENTS_GRANTS_DIRECTORY = 'grants';
|
|
154
|
+
constants.BRANDING_DIRECTORY = 'branding';
|
|
155
|
+
constants.BRANDING_TEMPLATES_DIRECTORY = 'templates';
|
|
156
|
+
constants.BRANDING_TEMPLATES_YAML_DIRECTORY = 'branding_templates';
|
|
150
157
|
constants.CLIENTS_CLIENT_NAME = 'clients';
|
|
151
158
|
constants.CLIENTS_CLIENT_ID_NAME = 'client_id';
|
|
152
159
|
constants.CONNECTIONS_DIRECTORY = 'connections';
|
package/lib/tools/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.areArraysEquals = exports.filterExcluded = exports.duplicateItems = exports.getEnabledClients = exports.stripFields = exports.
|
|
6
|
+
exports.areArraysEquals = exports.filterExcluded = exports.duplicateItems = exports.getEnabledClients = exports.stripFields = exports.dumpJSON = exports.flatten = exports.loadFileAndReplaceKeywords = exports.convertClientNamesToIds = exports.convertClientNameToId = exports.keywordReplace = exports.keywordStringReplace = exports.keywordArrayReplace = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const dot_prop_1 = __importDefault(require("dot-prop"));
|
|
@@ -80,147 +80,6 @@ function dumpJSON(obj, spacing = 0) {
|
|
|
80
80
|
return JSON.stringify(obj, null, spacing);
|
|
81
81
|
}
|
|
82
82
|
exports.dumpJSON = dumpJSON;
|
|
83
|
-
/**
|
|
84
|
-
* @template T
|
|
85
|
-
* @param {typeof import('./auth0/handlers/default').default} handler
|
|
86
|
-
* @param {T} desiredAssetState
|
|
87
|
-
* @param {T} currentAssetState
|
|
88
|
-
* @param {string[]} [objectFields=[]]
|
|
89
|
-
* @param {boolean} [allowDelete=false]
|
|
90
|
-
* @returns T
|
|
91
|
-
*/
|
|
92
|
-
function processChangedObjectFields({ handler, desiredAssetState, currentAssetState, allowDelete = false }) {
|
|
93
|
-
const desiredAssetStateWithChanges = Object.assign({}, desiredAssetState);
|
|
94
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
95
|
-
for (const fieldName of handler.objectFields) {
|
|
96
|
-
const areDesiredStateAndCurrentStateEmpty = Object.keys(desiredAssetState[fieldName] || {}).length === 0 && Object.keys(currentAssetState[fieldName] || {}).length === 0;
|
|
97
|
-
if (areDesiredStateAndCurrentStateEmpty) {
|
|
98
|
-
// If both the desired state and current state for a given object is empty, it is a no-op and can skip
|
|
99
|
-
// eslint-disable-next-line no-continue
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
// A desired state that omits the objectField OR that has it as an empty object should
|
|
103
|
-
// signal that all fields should be removed (subject to ALLOW_DELETE).
|
|
104
|
-
if (desiredAssetState[fieldName] && Object.keys(desiredAssetState[fieldName]).length) {
|
|
105
|
-
// Both the current and desired state have the object field. Here's where we need to map
|
|
106
|
-
// to the APIv2 protocol of setting `null` values for deleted fields.
|
|
107
|
-
// For new and modified properties of the object field, we can just pass them through to
|
|
108
|
-
// APIv2.
|
|
109
|
-
if (currentAssetState[fieldName]) {
|
|
110
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
111
|
-
for (const currentObjectFieldPropertyName of Object.keys(currentAssetState[fieldName])) {
|
|
112
|
-
// Loop through each object property that exists currently
|
|
113
|
-
if (desiredAssetState[fieldName][currentObjectFieldPropertyName] === undefined) {
|
|
114
|
-
// If the object has a property that exists now but doesn't exist in the proposed state
|
|
115
|
-
if (allowDelete) {
|
|
116
|
-
desiredAssetStateWithChanges[fieldName][currentObjectFieldPropertyName] = null;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
// If deletes aren't allowed, do outright delete the property within the object
|
|
120
|
-
logger_1.default.warn(`Detected that the ${fieldName} of the following ${handler.name || handler.id || ''} should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config\n${handler.objString(currentAssetState)}`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
else if (allowDelete) {
|
|
127
|
-
// If the desired state does not have the object field and the current state does, we
|
|
128
|
-
// should mark *all* properties for deletion by specifying an empty object.
|
|
129
|
-
//
|
|
130
|
-
// See: https://auth0.com/docs/users/metadata/manage-metadata-api#delete-user-metadata
|
|
131
|
-
desiredAssetStateWithChanges[fieldName] = {};
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
delete desiredAssetStateWithChanges[fieldName];
|
|
135
|
-
logger_1.default.warn(`Detected that the ${fieldName} of the following ${handler.name || handler.id || ''} should be emptied. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config\n${handler.objString(currentAssetState)}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return desiredAssetStateWithChanges;
|
|
139
|
-
}
|
|
140
|
-
exports.processChangedObjectFields = processChangedObjectFields;
|
|
141
|
-
function calcChanges(handler, assets, existing, identifiers = ['id', 'name'], allowDelete = false) {
|
|
142
|
-
// Calculate the changes required between two sets of assets.
|
|
143
|
-
const update = [];
|
|
144
|
-
let del = [...existing];
|
|
145
|
-
let create = [...assets];
|
|
146
|
-
const conflicts = [];
|
|
147
|
-
const findByKeyValue = (key, value, arr) => arr.find((e) => {
|
|
148
|
-
if (Array.isArray(key)) {
|
|
149
|
-
const values = key.map((k) => e[k]);
|
|
150
|
-
if (values.every((v) => v)) {
|
|
151
|
-
return value === values.join('-');
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
return e[key] === value;
|
|
156
|
-
}
|
|
157
|
-
return false;
|
|
158
|
-
});
|
|
159
|
-
const processAssets = (id, arr) => {
|
|
160
|
-
arr.forEach((asset) => {
|
|
161
|
-
let assetIdValue;
|
|
162
|
-
if (Array.isArray(id)) {
|
|
163
|
-
const values = id.map((i) => asset[i]);
|
|
164
|
-
if (values.every((v) => v)) {
|
|
165
|
-
assetIdValue = values.join('-');
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
assetIdValue = asset[id];
|
|
170
|
-
}
|
|
171
|
-
if (assetIdValue) {
|
|
172
|
-
const found = findByKeyValue(id, assetIdValue, del);
|
|
173
|
-
if (found) {
|
|
174
|
-
// Delete from existing
|
|
175
|
-
del = del.filter((e) => e !== found);
|
|
176
|
-
// Delete from create as it's an update
|
|
177
|
-
create = create.filter((e) => e !== asset);
|
|
178
|
-
// Append identifiers to asset
|
|
179
|
-
update.push(Object.assign(Object.assign({}, identifiers.reduce((obj, i) => {
|
|
180
|
-
if (found[i])
|
|
181
|
-
obj[i] = found[i];
|
|
182
|
-
return obj;
|
|
183
|
-
}, {})), (handler.objectFields.length
|
|
184
|
-
? processChangedObjectFields({
|
|
185
|
-
handler, desiredAssetState: asset, currentAssetState: found, allowDelete
|
|
186
|
-
})
|
|
187
|
-
: asset)));
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
// Loop through identifiers (in order) to try match assets to existing
|
|
193
|
-
// If existing then update if not create
|
|
194
|
-
// The remainder will be deleted
|
|
195
|
-
for (const id of identifiers) { // eslint-disable-line
|
|
196
|
-
processAssets(id, [...create]);
|
|
197
|
-
}
|
|
198
|
-
// Check if there are assets with names that will conflict with existing names during the update process
|
|
199
|
-
// This will rename those assets to a temp random name first
|
|
200
|
-
// This assumes the first identifiers is the unique identifier
|
|
201
|
-
if (identifiers.includes('name')) {
|
|
202
|
-
const uniqueID = identifiers[0];
|
|
203
|
-
const futureAssets = [...create, ...update];
|
|
204
|
-
futureAssets.forEach((a) => {
|
|
205
|
-
// If the conflicting item is going to be deleted then skip
|
|
206
|
-
const inDeleted = del.filter((e) => e.name === a.name && e[uniqueID] !== a[uniqueID])[0];
|
|
207
|
-
if (!inDeleted) {
|
|
208
|
-
const conflict = existing.filter((e) => e.name === a.name && e[uniqueID] !== a[uniqueID])[0];
|
|
209
|
-
if (conflict) {
|
|
210
|
-
const temp = Math.random().toString(36).substr(2, 5);
|
|
211
|
-
conflicts.push(Object.assign(Object.assign({}, conflict), { name: `${conflict.name}-${temp}` }));
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
return {
|
|
217
|
-
del,
|
|
218
|
-
update,
|
|
219
|
-
conflicts,
|
|
220
|
-
create
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
exports.calcChanges = calcChanges;
|
|
224
83
|
function stripFields(obj, fields) {
|
|
225
84
|
// Strip object fields supporting dot notation (ie: a.deep.field)
|
|
226
85
|
const stripped = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auth0-deploy-cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0",
|
|
4
4
|
"description": "A command line tool for deploying updates to your Auth0 tenant",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"lint:fix": "eslint --fix --ignore-path .eslintignore --ignore-pattern webpack . && kacl lint",
|
|
11
11
|
"lint": "eslint --ignore-path .eslintignore --ignore-pattern webpack . && kacl lint",
|
|
12
12
|
"pretest": "rimraf ./.nyc_output",
|
|
13
|
-
"test": "ts-mocha -p tsconfig.json --recursive 'test/**/*.test
|
|
13
|
+
"test": "ts-mocha -p tsconfig.json --recursive 'test/**/*.test*'",
|
|
14
14
|
"build": "rimraf ./lib && npx tsc",
|
|
15
15
|
"dev": "npx tsc --watch",
|
|
16
16
|
"prepare": "npm run build",
|