@rockcarver/frodo-cli 2.0.0-32 → 2.0.0-33
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 +5 -1
- package/esm/cli/FrodoCommand.js +8 -1
- package/esm/cli/FrodoCommand.js.map +1 -1
- package/esm/cli/admin/admin-export-full-cloud-config.js +44 -0
- package/esm/cli/admin/admin-export-full-cloud-config.js.map +1 -0
- package/esm/cli/admin/admin.js +1 -0
- package/esm/cli/admin/admin.js.map +1 -1
- package/esm/cli/authz/authz-policy-export.js +1 -1
- package/esm/cli/authz/authz-policy-export.js.map +1 -1
- package/esm/cli/authz/authz-policy-import.js +1 -1
- package/esm/cli/authz/authz-policy-import.js.map +1 -1
- package/esm/cli/authz/authz-policy-list.js +2 -2
- package/esm/cli/authz/authz-policy-list.js.map +1 -1
- package/esm/cli/authz/authz-set-delete.js +2 -2
- package/esm/cli/authz/authz-set-delete.js.map +1 -1
- package/esm/cli/authz/authz-set-export.js +1 -1
- package/esm/cli/authz/authz-set-export.js.map +1 -1
- package/esm/cli/authz/authz-set-import.js +1 -1
- package/esm/cli/authz/authz-set-import.js.map +1 -1
- package/esm/cli/authz/authz-set-list.js +1 -1
- package/esm/cli/authz/authz-set-list.js.map +1 -1
- package/esm/cli/authz/authz-type-delete.js +3 -3
- package/esm/cli/authz/authz-type-delete.js.map +1 -1
- package/esm/cli/authz/authz-type-export.js +2 -2
- package/esm/cli/authz/authz-type-export.js.map +1 -1
- package/esm/cli/authz/authz-type-import.js +2 -2
- package/esm/cli/authz/authz-type-import.js.map +1 -1
- package/esm/cli/authz/authz-type-list.js +1 -1
- package/esm/cli/authz/authz-type-list.js.map +1 -1
- package/esm/cli/email/email-template-export.js +3 -3
- package/esm/cli/email/email-template-export.js.map +1 -1
- package/esm/cli/email/email-template-import.js +4 -4
- package/esm/cli/email/email-template-import.js.map +1 -1
- package/esm/cli/email/email-template-list.js +1 -1
- package/esm/cli/email/email-template-list.js.map +1 -1
- package/esm/cli/idm/idm-count.js +1 -1
- package/esm/cli/idm/idm-count.js.map +1 -1
- package/esm/cli/idm/idm-export.js +3 -3
- package/esm/cli/idm/idm-export.js.map +1 -1
- package/esm/cli/idm/idm-list.js +2 -2
- package/esm/cli/idm/idm-list.js.map +1 -1
- package/esm/cli/idp/idp-export.js +3 -3
- package/esm/cli/idp/idp-export.js.map +1 -1
- package/esm/cli/idp/idp-import.js +4 -4
- package/esm/cli/idp/idp-import.js.map +1 -1
- package/esm/cli/idp/idp-list.js +1 -1
- package/esm/cli/idp/idp-list.js.map +1 -1
- package/esm/cli/journey/journey-delete.js +6 -2
- package/esm/cli/journey/journey-delete.js.map +1 -1
- package/esm/cli/journey/journey-disable.js +4 -10
- package/esm/cli/journey/journey-disable.js.map +1 -1
- package/esm/cli/journey/journey-enable.js +4 -10
- package/esm/cli/journey/journey-enable.js.map +1 -1
- package/esm/cli/journey/journey-import.js +4 -4
- package/esm/cli/journey/journey-import.js.map +1 -1
- package/esm/cli/journey/journey-list.js +1 -1
- package/esm/cli/journey/journey-list.js.map +1 -1
- package/esm/cli/saml/saml-cot-export.js +3 -3
- package/esm/cli/saml/saml-cot-export.js.map +1 -1
- package/esm/cli/saml/saml-cot-list.js +1 -1
- package/esm/cli/saml/saml-cot-list.js.map +1 -1
- package/esm/cli/saml/saml-describe.js +1 -1
- package/esm/cli/saml/saml-describe.js.map +1 -1
- package/esm/cli/saml/saml-import.js +4 -4
- package/esm/cli/saml/saml-import.js.map +1 -1
- package/esm/cli/saml/saml-list.js +1 -1
- package/esm/cli/saml/saml-list.js.map +1 -1
- package/esm/cli/saml/saml-metadata-export.js +1 -1
- package/esm/cli/saml/saml-metadata-export.js.map +1 -1
- package/esm/cli/script/script-export.js +2 -6
- package/esm/cli/script/script-export.js.map +1 -1
- package/esm/cli/theme/theme-delete.js +3 -3
- package/esm/cli/theme/theme-delete.js.map +1 -1
- package/esm/cli/theme/theme-export.js +4 -4
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/cli/theme/theme-import.js +4 -4
- package/esm/cli/theme/theme-import.js.map +1 -1
- package/esm/cli/theme/theme-list.js +1 -1
- package/esm/cli/theme/theme-list.js.map +1 -1
- package/esm/ops/AdminFederationOps.js +28 -26
- package/esm/ops/AdminFederationOps.js.map +1 -1
- package/esm/ops/AdminOps.js +112 -0
- package/esm/ops/AdminOps.js.map +1 -0
- package/esm/ops/AgentOps.js +59 -51
- package/esm/ops/AgentOps.js.map +1 -1
- package/esm/ops/ApplicationOps.js +19 -13
- package/esm/ops/ApplicationOps.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +28 -26
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +78 -94
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +8 -31
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/IdpOps.js +49 -54
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +91 -70
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +13 -11
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/PolicyOps.js +31 -26
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/PolicySetOps.js +42 -39
- package/esm/ops/PolicySetOps.js.map +1 -1
- package/esm/ops/ResourceTypeOps.js +19 -16
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +49 -45
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ScriptOps.js +36 -55
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/ops/SecretsOps.js +13 -11
- package/esm/ops/SecretsOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +111 -130
- package/esm/ops/ThemeOps.js.map +1 -1
- package/esm/ops/VariablesOps.js +14 -12
- package/esm/ops/VariablesOps.js.map +1 -1
- package/esm/utils/Console.js +68 -30
- package/esm/utils/Console.js.map +1 -1
- package/esm/utils/ExportImportUtils.js +4 -12
- package/esm/utils/ExportImportUtils.js.map +1 -1
- package/package.json +2 -2
package/esm/ops/PolicyOps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import { createObjectTable,
|
|
3
|
+
import { createObjectTable, createProgressIndicator, createTable, debugMessage, failSpinner, printMessage, showSpinner, stopProgressIndicator, succeedSpinner, updateProgressIndicator } from '../utils/Console';
|
|
4
4
|
import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
|
|
5
5
|
const {
|
|
6
6
|
getRealmName,
|
|
@@ -128,6 +128,7 @@ export async function deletePolicies() {
|
|
|
128
128
|
let outcome = false;
|
|
129
129
|
const errors = [];
|
|
130
130
|
let policies = [];
|
|
131
|
+
let indicatorId;
|
|
131
132
|
try {
|
|
132
133
|
showSpinner(`Retrieving all policies...`);
|
|
133
134
|
try {
|
|
@@ -138,16 +139,16 @@ export async function deletePolicies() {
|
|
|
138
139
|
failSpinner(error.message);
|
|
139
140
|
throw error;
|
|
140
141
|
}
|
|
141
|
-
if (policies.length)
|
|
142
|
+
if (policies.length) indicatorId = createProgressIndicator('determinate', policies.length, `Deleting ${policies.length} policies...`);
|
|
142
143
|
for (const policy of policies) {
|
|
143
144
|
const policyId = policy._id;
|
|
144
145
|
try {
|
|
145
146
|
debugMessage(`Deleting policy ${policyId}`);
|
|
146
147
|
await deletePolicy(policyId);
|
|
147
|
-
|
|
148
|
+
updateProgressIndicator(indicatorId, `Deleted ${policyId}`);
|
|
148
149
|
} catch (error) {
|
|
149
150
|
error.message = `Error deleting policy ${policyId}: ${error}`;
|
|
150
|
-
|
|
151
|
+
updateProgressIndicator(indicatorId, error.message);
|
|
151
152
|
errors.push(error);
|
|
152
153
|
}
|
|
153
154
|
}
|
|
@@ -157,9 +158,9 @@ export async function deletePolicies() {
|
|
|
157
158
|
} finally {
|
|
158
159
|
if (errors.length) {
|
|
159
160
|
const errorMessages = errors.map(error => error.message).join('\n');
|
|
160
|
-
if (policies.length)
|
|
161
|
+
if (policies.length) stopProgressIndicator(indicatorId, `Error deleting all policies: ${errorMessages}`);
|
|
161
162
|
} else {
|
|
162
|
-
if (policies.length)
|
|
163
|
+
if (policies.length) stopProgressIndicator(indicatorId, `Deleted ${policies.length} policies.`);
|
|
163
164
|
outcome = true;
|
|
164
165
|
}
|
|
165
166
|
}
|
|
@@ -177,6 +178,7 @@ export async function deletePoliciesByPolicySet(policySetId) {
|
|
|
177
178
|
let outcome = false;
|
|
178
179
|
const errors = [];
|
|
179
180
|
let policies = [];
|
|
181
|
+
let indicatorId;
|
|
180
182
|
try {
|
|
181
183
|
showSpinner(`Retrieving all policies from policy set ${policySetId}...`);
|
|
182
184
|
try {
|
|
@@ -187,16 +189,16 @@ export async function deletePoliciesByPolicySet(policySetId) {
|
|
|
187
189
|
failSpinner(error.message);
|
|
188
190
|
throw error;
|
|
189
191
|
}
|
|
190
|
-
if (policies.length)
|
|
192
|
+
if (policies.length) indicatorId = createProgressIndicator('determinate', policies.length, `Deleting ${policies.length} policies from policy set ${policySetId}...`);
|
|
191
193
|
for (const policy of policies) {
|
|
192
194
|
const policyId = policy._id;
|
|
193
195
|
try {
|
|
194
196
|
debugMessage(`Deleting policy ${policyId}`);
|
|
195
197
|
await deletePolicy(policyId);
|
|
196
|
-
|
|
198
|
+
updateProgressIndicator(indicatorId, `Deleted ${policyId}`);
|
|
197
199
|
} catch (error) {
|
|
198
200
|
error.message = `Error deleting policy ${policyId} from policy set ${policySetId}: ${error}`;
|
|
199
|
-
|
|
201
|
+
updateProgressIndicator(indicatorId, error.message);
|
|
200
202
|
errors.push(error);
|
|
201
203
|
}
|
|
202
204
|
}
|
|
@@ -206,9 +208,9 @@ export async function deletePoliciesByPolicySet(policySetId) {
|
|
|
206
208
|
} finally {
|
|
207
209
|
if (errors.length) {
|
|
208
210
|
const errorMessages = errors.map(error => error.message).join('\n');
|
|
209
|
-
if (policies.length)
|
|
211
|
+
if (policies.length) stopProgressIndicator(indicatorId, `Error deleting all policies from policy set ${policySetId}: ${errorMessages}`);
|
|
210
212
|
} else {
|
|
211
|
-
if (policies.length)
|
|
213
|
+
if (policies.length) stopProgressIndicator(indicatorId, `Deleted ${policies.length} policies.`);
|
|
212
214
|
outcome = true;
|
|
213
215
|
}
|
|
214
216
|
}
|
|
@@ -323,24 +325,25 @@ export async function exportPoliciesToFiles(options = {
|
|
|
323
325
|
}) {
|
|
324
326
|
debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);
|
|
325
327
|
const errors = [];
|
|
328
|
+
let indicatorId;
|
|
326
329
|
try {
|
|
327
330
|
const policies = await readPolicies();
|
|
328
|
-
|
|
331
|
+
indicatorId = createProgressIndicator('determinate', policies.length, 'Exporting policy sets...');
|
|
329
332
|
for (const policy of policies) {
|
|
330
333
|
const file = getTypedFilename(policy._id, 'policy.authz');
|
|
331
334
|
try {
|
|
332
335
|
const exportData = await exportPolicy(policy._id, options);
|
|
333
336
|
saveJsonToFile(exportData, getFilePath(file, true));
|
|
334
|
-
|
|
337
|
+
updateProgressIndicator(indicatorId, `Exported ${policy._id}.`);
|
|
335
338
|
} catch (error) {
|
|
336
339
|
errors.push(error);
|
|
337
|
-
|
|
340
|
+
updateProgressIndicator(indicatorId, `Error exporting ${policy._id}.`);
|
|
338
341
|
}
|
|
339
342
|
}
|
|
340
|
-
|
|
343
|
+
stopProgressIndicator(indicatorId, `Export complete.`);
|
|
341
344
|
} catch (error) {
|
|
342
345
|
errors.push(error);
|
|
343
|
-
|
|
346
|
+
stopProgressIndicator(indicatorId, `Error exporting policy sets to files`);
|
|
344
347
|
}
|
|
345
348
|
debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);
|
|
346
349
|
return 0 === errors.length;
|
|
@@ -358,24 +361,25 @@ export async function exportPoliciesByPolicySetToFiles(policySetId, options = {
|
|
|
358
361
|
}) {
|
|
359
362
|
debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);
|
|
360
363
|
const errors = [];
|
|
364
|
+
let indicatorId;
|
|
361
365
|
try {
|
|
362
366
|
const policies = await readPoliciesByPolicySet(policySetId);
|
|
363
|
-
|
|
367
|
+
indicatorId = createProgressIndicator('determinate', policies.length, `Exporting policies in policy set ${policySetId}...`);
|
|
364
368
|
for (const policy of policies) {
|
|
365
369
|
const file = getTypedFilename(policy._id, 'policy.authz');
|
|
366
370
|
try {
|
|
367
371
|
const exportData = await exportPolicy(policy._id, options);
|
|
368
372
|
saveJsonToFile(exportData, getFilePath(file, true));
|
|
369
|
-
|
|
373
|
+
updateProgressIndicator(indicatorId, `Exported ${policy._id}.`);
|
|
370
374
|
} catch (error) {
|
|
371
375
|
errors.push(error);
|
|
372
|
-
|
|
376
|
+
updateProgressIndicator(indicatorId, `Error exporting ${policy._id}.`);
|
|
373
377
|
}
|
|
374
378
|
}
|
|
375
|
-
|
|
379
|
+
stopProgressIndicator(indicatorId, `Export complete.`);
|
|
376
380
|
} catch (error) {
|
|
377
381
|
errors.push(error);
|
|
378
|
-
|
|
382
|
+
stopProgressIndicator(indicatorId, `Error exporting policy sets to files`);
|
|
379
383
|
}
|
|
380
384
|
debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);
|
|
381
385
|
return 0 === errors.length;
|
|
@@ -475,11 +479,12 @@ export async function importPoliciesFromFiles(options = {
|
|
|
475
479
|
prereqs: false
|
|
476
480
|
}) {
|
|
477
481
|
const errors = [];
|
|
482
|
+
let indicatorId;
|
|
478
483
|
try {
|
|
479
484
|
debugMessage(`cli.PolicyOps.importPoliciesFromFiles: begin`);
|
|
480
485
|
const names = fs.readdirSync(getWorkingDirectory());
|
|
481
486
|
const files = names.filter(name => name.toLowerCase().endsWith('.policy.authz.json')).map(name => getFilePath(name));
|
|
482
|
-
|
|
487
|
+
indicatorId = createProgressIndicator('determinate', files.length, 'Importing policies...');
|
|
483
488
|
let total = 0;
|
|
484
489
|
for (const file of files) {
|
|
485
490
|
try {
|
|
@@ -488,17 +493,17 @@ export async function importPoliciesFromFiles(options = {
|
|
|
488
493
|
const count = Object.keys(fileData.policyset).length;
|
|
489
494
|
total += count;
|
|
490
495
|
await importPolicies(fileData, options);
|
|
491
|
-
|
|
496
|
+
updateProgressIndicator(indicatorId, `Imported ${count} policies from ${file}`);
|
|
492
497
|
} catch (error) {
|
|
493
498
|
errors.push(error);
|
|
494
|
-
|
|
499
|
+
updateProgressIndicator(indicatorId, `Error importing policies from ${file}`);
|
|
495
500
|
printMessage(error, 'error');
|
|
496
501
|
}
|
|
497
502
|
}
|
|
498
|
-
|
|
503
|
+
stopProgressIndicator(indicatorId, `Finished importing ${total} policies from ${files.length} files.`);
|
|
499
504
|
} catch (error) {
|
|
500
505
|
errors.push(error);
|
|
501
|
-
|
|
506
|
+
stopProgressIndicator(indicatorId, `Error importing policies from files.`);
|
|
502
507
|
printMessage(error, 'error');
|
|
503
508
|
}
|
|
504
509
|
debugMessage(`cli.PolicyOps.importPoliciesFromFiles: end`);
|
package/esm/ops/PolicyOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolicyOps.js","names":["frodo","state","fs","createObjectTable","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readPolicies","readPoliciesByPolicySet","readPolicy","exportPolicy","exportPolicies","exportPoliciesByPolicySet","importPolicy","importFirstPolicy","importPolicies","deletePolicy","authz","policy","listPolicies","long","outcome","policies","sort","a","b","_id","localeCompare","table","push","description","active","toString","err","message","listPoliciesByPolicySet","policySetId","describePolicy","policyId","json","policySet","deletePolicyById","error","deletePolicies","errors","length","errorMessages","map","join","deletePoliciesByPolicySet","exportPolicyToFile","file","options","deps","prereqs","useStringArrays","fileName","filePath","exportData","exportPoliciesToFile","getRealm","exportPoliciesByPolicySetToFile","exportPoliciesToFiles","exportPoliciesByPolicySetToFiles","importPolicyFromFile","data","readFileSync","fileData","JSON","parse","importFirstPolicyFromFile","importPoliciesFromFile","policySetName","importPoliciesFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","policyset"],"sources":["../../src/ops/PolicyOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type PolicySkeleton } from '@rockcarver/frodo-lib/types/api/PoliciesApi';\nimport type {\n PolicyExportInterface,\n PolicyExportOptions,\n PolicyImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/PolicyOps';\nimport fs from 'fs';\n\nimport {\n createObjectTable,\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\n\nconst { getRealmName, getFilePath, getWorkingDirectory } = frodo.utils;\nconst {\n readPolicies,\n readPoliciesByPolicySet,\n readPolicy,\n exportPolicy,\n exportPolicies,\n exportPoliciesByPolicySet,\n importPolicy,\n importFirstPolicy,\n importPolicies,\n deletePolicy,\n} = frodo.authz.policy;\n\n/**\n * List policies\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPolicies(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await readPolicies();\n policies.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Id', 'Description', 'Status']);\n for (const policy of policies) {\n table.push([\n `${policy._id}`,\n `${policy.description}`,\n policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const policy of policies) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * List policies by policy set\n * @param {string} policySetId policy set id/name\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPoliciesByPolicySet(\n policySetId: string,\n long = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await readPoliciesByPolicySet(policySetId);\n policies.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Id', 'Description', 'Status']);\n for (const policy of policies) {\n table.push([\n `${policy._id}`,\n `${policy.description}`,\n policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const policy of policies) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe policy\n * @param {string} policyId policy id/name\n * @param {Object} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describePolicy(\n policyId: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n const policySet = await readPolicy(policyId);\n outcome = true;\n if (json) {\n printMessage(policySet, 'data');\n } else {\n const table = createObjectTable(policySet);\n printMessage(table.toString(), 'data');\n }\n return outcome;\n}\n\n/**\n * Delete policy\n * @param {string} policyId policy id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicyById(policyId: string): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicy: begin`);\n showSpinner(`Deleting ${policyId}...`);\n let outcome = false;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n succeedSpinner(`Deleted ${policyId}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error deleting policy ${policyId}: ${error}`);\n }\n debugMessage(`cli.PolicyOps.deletePolicy: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicies(): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicies: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n try {\n showSpinner(`Retrieving all policies...`);\n try {\n policies = await readPolicies();\n succeedSpinner(`Found ${policies.length} policies.`);\n } catch (error) {\n error.message = `Error retrieving all policies: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n createProgressBar(\n policies.length,\n `Deleting ${policies.length} policies...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n updateProgressBar(`Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressBar(`Error deleting all policies: ${errorMessages}`);\n } else {\n if (policies.length)\n stopProgressBar(`Deleted ${policies.length} policies.`);\n outcome = true;\n }\n }\n debugMessage(`cli.PolicyOps.deletePolicies: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies in policy set\n * @param {string} policySetId policy set id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePoliciesByPolicySet(\n policySetId: string\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePoliciesByPolicySet: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n try {\n showSpinner(`Retrieving all policies from policy set ${policySetId}...`);\n try {\n policies = await readPoliciesByPolicySet(policySetId);\n succeedSpinner(\n `Found ${policies.length} policies in policy set ${policySetId}.`\n );\n } catch (error) {\n error.message = `Error retrieving all policies from policy set ${policySetId}: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n createProgressBar(\n policies.length,\n `Deleting ${policies.length} policies from policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n updateProgressBar(`Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId} from policy set ${policySetId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies from policy set ${policySetId}: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressBar(\n `Error deleting all policies from policy set ${policySetId}: ${errorMessages}`\n );\n } else {\n if (policies.length)\n stopProgressBar(`Deleted ${policies.length} policies.`);\n outcome = true;\n }\n }\n debugMessage(\n `cli.PolicyOps.deletePoliciesByPolicySet: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export policy to file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {ApplicationExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicyToFile(\n policyId: string,\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPolicyToFile: begin`);\n showSpinner(`Exporting ${policyId}...`);\n try {\n let fileName = getTypedFilename(policyId, 'policy.authz');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPolicy(policyId, options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${policyId} to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${policyId}: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPolicyToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFile(\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPolicies(options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all policy sets to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} policySetId policy set id/name\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFile(\n policySetId: string,\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${\n titleCase(getRealmName(state.getRealm())) + titleCase(policySetId)\n }Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPoliciesByPolicySet(policySetId, options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all policy sets to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFiles(\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n try {\n const policies: PolicySkeleton[] = await readPolicies();\n createProgressBar(policies.length, 'Exporting policy sets...');\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policy._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFiles(\n policySetId: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n try {\n const policies: PolicySkeleton[] =\n await readPoliciesByPolicySet(policySetId);\n createProgressBar(\n policies.length,\n `Exporting policies in policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policy._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import policy from file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicyFromFile(\n policyId: string,\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPolicyFromFile: begin`);\n showSpinner(`Importing ${policyId}...`);\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n await importPolicy(policyId, fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${policyId}.`);\n } catch (error) {\n failSpinner(`Error importing ${policyId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first policy from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstPolicyFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing first policy from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n const policy = await importFirstPolicy(fileData, options);\n outcome = true;\n succeedSpinner(\n `Imported first policy with id '${policy._id}' from ${filePath}.`\n );\n } catch (error) {\n failSpinner(`Error importing first policy from ${filePath}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPoliciesFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importPolicies(fileData, options);\n outcome = true;\n succeedSpinner(\n `Imported ${filePath}${\n options.policySetName\n ? ' into policy set ' + options.policySetName\n : '.'\n }`\n );\n } catch (error) {\n failSpinner(\n `Error importing ${filePath}${\n options.policySetName\n ? ' into policy set ' + options.policySetName\n : '.'\n }`\n );\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPoliciesFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from files\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFiles(\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.PolicyOps.importPoliciesFromFiles: begin`);\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.policy.authz.json'))\n .map((name) => getFilePath(name));\n createProgressBar(files.length, 'Importing policies...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: PolicyExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.policyset).length;\n total += count;\n await importPolicies(fileData, options);\n updateProgressBar(`Imported ${count} policies from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing policies from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} policies from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing policies from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPoliciesFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAOpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,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CAAC,CAAC,OAAOT,KAAK,EAAE;QACdE,MAAM,CAACf,IAAI,CAACa,KAAK,CAAC;QAClB3C,iBAAiB,CAAE,iCAAgCoD,IAAK,EAAC,CAAC;QAC1DxD,YAAY,CAAC+C,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACA7C,eAAe,CACZ,sBAAqBoF,KAAM,kBAAiBL,KAAK,CAAC/B,MAAO,SAC5D,CAAC;EACH,CAAC,CAAC,OAAOH,KAAK,EAAE;IACdE,MAAM,CAACf,IAAI,CAACa,KAAK,CAAC;IAClB7C,eAAe,CAAE,sCAAqC,CAAC;IACvDF,YAAY,CAAC+C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAjD,YAAY,CAAE,4CAA2C,CAAC;EAC1D,OAAO,CAAC,KAAKmD,MAAM,CAACC,MAAM;AAC5B"}
|
|
1
|
+
{"version":3,"file":"PolicyOps.js","names":["frodo","state","fs","createObjectTable","createProgressIndicator","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressIndicator","succeedSpinner","updateProgressIndicator","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readPolicies","readPoliciesByPolicySet","readPolicy","exportPolicy","exportPolicies","exportPoliciesByPolicySet","importPolicy","importFirstPolicy","importPolicies","deletePolicy","authz","policy","listPolicies","long","outcome","policies","sort","a","b","_id","localeCompare","table","push","description","active","toString","err","message","listPoliciesByPolicySet","policySetId","describePolicy","policyId","json","policySet","deletePolicyById","error","deletePolicies","errors","indicatorId","length","errorMessages","map","join","deletePoliciesByPolicySet","exportPolicyToFile","file","options","deps","prereqs","useStringArrays","fileName","filePath","exportData","exportPoliciesToFile","getRealm","exportPoliciesByPolicySetToFile","exportPoliciesToFiles","exportPoliciesByPolicySetToFiles","importPolicyFromFile","data","readFileSync","fileData","JSON","parse","importFirstPolicyFromFile","importPoliciesFromFile","policySetName","importPoliciesFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","policyset"],"sources":["../../src/ops/PolicyOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type PolicySkeleton } from '@rockcarver/frodo-lib/types/api/PoliciesApi';\nimport type {\n PolicyExportInterface,\n PolicyExportOptions,\n PolicyImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/PolicyOps';\nimport fs from 'fs';\n\nimport {\n createObjectTable,\n createProgressIndicator,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressIndicator,\n succeedSpinner,\n updateProgressIndicator,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\n\nconst { getRealmName, getFilePath, getWorkingDirectory } = frodo.utils;\nconst {\n readPolicies,\n readPoliciesByPolicySet,\n readPolicy,\n exportPolicy,\n exportPolicies,\n exportPoliciesByPolicySet,\n importPolicy,\n importFirstPolicy,\n importPolicies,\n deletePolicy,\n} = frodo.authz.policy;\n\n/**\n * List policies\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPolicies(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await readPolicies();\n policies.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Id', 'Description', 'Status']);\n for (const policy of policies) {\n table.push([\n `${policy._id}`,\n `${policy.description}`,\n policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const policy of policies) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * List policies by policy set\n * @param {string} policySetId policy set id/name\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPoliciesByPolicySet(\n policySetId: string,\n long = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await readPoliciesByPolicySet(policySetId);\n policies.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Id', 'Description', 'Status']);\n for (const policy of policies) {\n table.push([\n `${policy._id}`,\n `${policy.description}`,\n policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const policy of policies) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe policy\n * @param {string} policyId policy id/name\n * @param {Object} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describePolicy(\n policyId: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n const policySet = await readPolicy(policyId);\n outcome = true;\n if (json) {\n printMessage(policySet, 'data');\n } else {\n const table = createObjectTable(policySet);\n printMessage(table.toString(), 'data');\n }\n return outcome;\n}\n\n/**\n * Delete policy\n * @param {string} policyId policy id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicyById(policyId: string): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicy: begin`);\n showSpinner(`Deleting ${policyId}...`);\n let outcome = false;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n succeedSpinner(`Deleted ${policyId}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error deleting policy ${policyId}: ${error}`);\n }\n debugMessage(`cli.PolicyOps.deletePolicy: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicies(): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicies: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n let indicatorId: string;\n try {\n showSpinner(`Retrieving all policies...`);\n try {\n policies = await readPolicies();\n succeedSpinner(`Found ${policies.length} policies.`);\n } catch (error) {\n error.message = `Error retrieving all policies: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n indicatorId = createProgressIndicator(\n 'determinate',\n policies.length,\n `Deleting ${policies.length} policies...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n updateProgressIndicator(indicatorId, `Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId}: ${error}`;\n updateProgressIndicator(indicatorId, error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressIndicator(\n indicatorId,\n `Error deleting all policies: ${errorMessages}`\n );\n } else {\n if (policies.length)\n stopProgressIndicator(\n indicatorId,\n `Deleted ${policies.length} policies.`\n );\n outcome = true;\n }\n }\n debugMessage(`cli.PolicyOps.deletePolicies: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies in policy set\n * @param {string} policySetId policy set id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePoliciesByPolicySet(\n policySetId: string\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePoliciesByPolicySet: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n let indicatorId: string;\n try {\n showSpinner(`Retrieving all policies from policy set ${policySetId}...`);\n try {\n policies = await readPoliciesByPolicySet(policySetId);\n succeedSpinner(\n `Found ${policies.length} policies in policy set ${policySetId}.`\n );\n } catch (error) {\n error.message = `Error retrieving all policies from policy set ${policySetId}: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n indicatorId = createProgressIndicator(\n 'determinate',\n policies.length,\n `Deleting ${policies.length} policies from policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n updateProgressIndicator(indicatorId, `Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId} from policy set ${policySetId}: ${error}`;\n updateProgressIndicator(indicatorId, error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies from policy set ${policySetId}: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressIndicator(\n indicatorId,\n `Error deleting all policies from policy set ${policySetId}: ${errorMessages}`\n );\n } else {\n if (policies.length)\n stopProgressIndicator(\n indicatorId,\n `Deleted ${policies.length} policies.`\n );\n outcome = true;\n }\n }\n debugMessage(\n `cli.PolicyOps.deletePoliciesByPolicySet: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export policy to file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {ApplicationExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicyToFile(\n policyId: string,\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPolicyToFile: begin`);\n showSpinner(`Exporting ${policyId}...`);\n try {\n let fileName = getTypedFilename(policyId, 'policy.authz');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPolicy(policyId, options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${policyId} to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${policyId}: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPolicyToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFile(\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPolicies(options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all policy sets to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} policySetId policy set id/name\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFile(\n policySetId: string,\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${\n titleCase(getRealmName(state.getRealm())) + titleCase(policySetId)\n }Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPoliciesByPolicySet(policySetId, options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all policy sets to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFiles(\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n let indicatorId: string;\n try {\n const policies: PolicySkeleton[] = await readPolicies();\n indicatorId = createProgressIndicator(\n 'determinate',\n policies.length,\n 'Exporting policy sets...'\n );\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressIndicator(indicatorId, `Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressIndicator(indicatorId, `Error exporting ${policy._id}.`);\n }\n }\n stopProgressIndicator(indicatorId, `Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressIndicator(indicatorId, `Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFiles(\n policySetId: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n let indicatorId: string;\n try {\n const policies: PolicySkeleton[] =\n await readPoliciesByPolicySet(policySetId);\n indicatorId = createProgressIndicator(\n 'determinate',\n policies.length,\n `Exporting policies in policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressIndicator(indicatorId, `Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressIndicator(indicatorId, `Error exporting ${policy._id}.`);\n }\n }\n stopProgressIndicator(indicatorId, `Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressIndicator(indicatorId, `Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import policy from file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicyFromFile(\n policyId: string,\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPolicyFromFile: begin`);\n showSpinner(`Importing ${policyId}...`);\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n await importPolicy(policyId, fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${policyId}.`);\n } catch (error) {\n failSpinner(`Error importing ${policyId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first policy from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstPolicyFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing first policy from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n const policy = await importFirstPolicy(fileData, options);\n outcome = true;\n succeedSpinner(\n `Imported first policy with id '${policy._id}' from ${filePath}.`\n );\n } catch (error) {\n failSpinner(`Error importing first policy from ${filePath}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPoliciesFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importPolicies(fileData, options);\n outcome = true;\n succeedSpinner(\n `Imported ${filePath}${\n options.policySetName\n ? ' into policy set ' + options.policySetName\n : '.'\n }`\n );\n } catch (error) {\n failSpinner(\n `Error importing ${filePath}${\n options.policySetName\n ? ' into policy set ' + options.policySetName\n : '.'\n }`\n );\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPoliciesFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from files\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFiles(\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n const errors = [];\n let indicatorId: string;\n try {\n debugMessage(`cli.PolicyOps.importPoliciesFromFiles: begin`);\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.policy.authz.json'))\n .map((name) => getFilePath(name));\n indicatorId = createProgressIndicator(\n 'determinate',\n files.length,\n 'Importing policies...'\n );\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: PolicyExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.policyset).length;\n total += count;\n await importPolicies(fileData, options);\n updateProgressIndicator(\n indicatorId,\n `Imported ${count} policies from ${file}`\n );\n } catch (error) {\n errors.push(error);\n updateProgressIndicator(\n indicatorId,\n `Error importing policies from ${file}`\n );\n printMessage(error, 'error');\n }\n }\n stopProgressIndicator(\n indicatorId,\n `Finished importing ${total} policies from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressIndicator(indicatorId, `Error importing policies from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPoliciesFromFiles: end`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,CAACE,MAAM;AAC5B"}
|
package/esm/ops/PolicySetOps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import { createObjectTable,
|
|
3
|
+
import { createObjectTable, createProgressIndicator, debugMessage, printMessage, stopProgressIndicator, updateProgressIndicator } from '../utils/Console';
|
|
4
4
|
import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
|
|
5
5
|
const {
|
|
6
6
|
getRealmName,
|
|
@@ -68,7 +68,7 @@ export async function describePolicySet(policySetId, json = false) {
|
|
|
68
68
|
*/
|
|
69
69
|
export async function deletePolicySetById(policySetId) {
|
|
70
70
|
debugMessage(`cli.PolicySetOps.deletePolicySet: begin`);
|
|
71
|
-
|
|
71
|
+
const indicatorId = createProgressIndicator('indeterminate', 0, `Deleting ${policySetId}...`);
|
|
72
72
|
let outcome = false;
|
|
73
73
|
const errors = [];
|
|
74
74
|
const policies = await readPoliciesByPolicySet(policySetId);
|
|
@@ -78,21 +78,20 @@ export async function deletePolicySetById(policySetId) {
|
|
|
78
78
|
await deletePolicy(policy._id);
|
|
79
79
|
} catch (error) {
|
|
80
80
|
error.message = `Error deleting policy ${policy._id} in policy set ${policySetId}: ${error}`;
|
|
81
|
-
printMessage(error.message, 'error');
|
|
82
81
|
errors.push(error);
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
if (errors.length) {
|
|
86
85
|
const errorMessages = errors.map(error => error.message).join('\n');
|
|
87
|
-
|
|
86
|
+
stopProgressIndicator(indicatorId, `Error deleting policies in policy set ${policySetId}: ${errorMessages}`, 'fail');
|
|
88
87
|
} else {
|
|
89
88
|
try {
|
|
90
89
|
debugMessage(`Deleting policy set ${policySetId}`);
|
|
91
90
|
await deletePolicySet(policySetId);
|
|
92
|
-
|
|
91
|
+
stopProgressIndicator(indicatorId, `Deleted ${policySetId}.`, 'success');
|
|
93
92
|
outcome = true;
|
|
94
93
|
} catch (error) {
|
|
95
|
-
|
|
94
|
+
stopProgressIndicator(indicatorId, `Error deleting policy set ${policySetId}: ${error}`, 'fail');
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
debugMessage(`cli.PolicySetOps.deletePolicySet: end [outcome=${outcome}]`);
|
|
@@ -108,17 +107,19 @@ export async function deletePolicySets() {
|
|
|
108
107
|
let outcome = false;
|
|
109
108
|
const errors = [];
|
|
110
109
|
let policySets = [];
|
|
110
|
+
let indicatorId;
|
|
111
|
+
let indicatorId2;
|
|
111
112
|
try {
|
|
112
|
-
|
|
113
|
+
indicatorId = createProgressIndicator('indeterminate', 0, `Retrieving all policy sets...`);
|
|
113
114
|
try {
|
|
114
115
|
policySets = await readPolicySets();
|
|
115
|
-
|
|
116
|
+
stopProgressIndicator(indicatorId, `Found ${policySets.length} policy sets.`, 'success');
|
|
116
117
|
} catch (error) {
|
|
117
118
|
error.message = `Error retrieving all policy sets: ${error.message}`;
|
|
118
|
-
|
|
119
|
+
stopProgressIndicator(indicatorId, error.message, 'fail');
|
|
119
120
|
throw error;
|
|
120
121
|
}
|
|
121
|
-
if (policySets.length)
|
|
122
|
+
if (policySets.length) indicatorId2 = createProgressIndicator('determinate', policySets.length, `Deleting ${policySets.length} policy sets...`);
|
|
122
123
|
for (const policySet of policySets) {
|
|
123
124
|
const policySetId = policySet.name;
|
|
124
125
|
try {
|
|
@@ -139,10 +140,10 @@ export async function deletePolicySets() {
|
|
|
139
140
|
try {
|
|
140
141
|
debugMessage(`Deleting policy set ${policySetId}`);
|
|
141
142
|
await deletePolicySet(policySetId);
|
|
142
|
-
|
|
143
|
+
updateProgressIndicator(indicatorId2, `Deleted ${policySetId}`);
|
|
143
144
|
} catch (error) {
|
|
144
145
|
error.message = `Error deleting policy set ${policySetId}: ${error}`;
|
|
145
|
-
|
|
146
|
+
updateProgressIndicator(indicatorId2, error.message);
|
|
146
147
|
errors.push(error);
|
|
147
148
|
}
|
|
148
149
|
}
|
|
@@ -152,9 +153,9 @@ export async function deletePolicySets() {
|
|
|
152
153
|
} finally {
|
|
153
154
|
if (errors.length) {
|
|
154
155
|
const errorMessages = errors.map(error => error.message).join('\n');
|
|
155
|
-
if (policySets.length)
|
|
156
|
+
if (policySets.length) stopProgressIndicator(indicatorId2, `Error deleting all policy sets: ${errorMessages}`);
|
|
156
157
|
} else {
|
|
157
|
-
if (policySets.length)
|
|
158
|
+
if (policySets.length) stopProgressIndicator(indicatorId2, `Deleted ${policySets.length} policy sets.`);
|
|
158
159
|
outcome = true;
|
|
159
160
|
}
|
|
160
161
|
}
|
|
@@ -176,7 +177,7 @@ export async function exportPolicySetToFile(policySetId, file, options = {
|
|
|
176
177
|
}) {
|
|
177
178
|
let outcome = false;
|
|
178
179
|
debugMessage(`cli.PolicySetOps.exportPolicySetToFile: begin`);
|
|
179
|
-
|
|
180
|
+
const indicatorId = createProgressIndicator('indeterminate', 0, `Exporting ${policySetId}...`);
|
|
180
181
|
try {
|
|
181
182
|
let fileName = getTypedFilename(policySetId, 'policyset.authz');
|
|
182
183
|
if (file) {
|
|
@@ -185,10 +186,10 @@ export async function exportPolicySetToFile(policySetId, file, options = {
|
|
|
185
186
|
const filePath = getFilePath(fileName, true);
|
|
186
187
|
const exportData = await exportPolicySet(policySetId, options);
|
|
187
188
|
saveJsonToFile(exportData, filePath);
|
|
188
|
-
|
|
189
|
+
stopProgressIndicator(indicatorId, `Exported ${policySetId} to ${filePath}.`, 'success');
|
|
189
190
|
outcome = true;
|
|
190
191
|
} catch (error) {
|
|
191
|
-
|
|
192
|
+
stopProgressIndicator(indicatorId, `Error exporting ${policySetId}: ${error.message}`, 'fail');
|
|
192
193
|
}
|
|
193
194
|
debugMessage(`cli.PolicySetOps.exportPolicySetToFile: end`);
|
|
194
195
|
return outcome;
|
|
@@ -207,7 +208,7 @@ export async function exportPolicySetsToFile(file, options = {
|
|
|
207
208
|
}) {
|
|
208
209
|
let outcome = false;
|
|
209
210
|
debugMessage(`cli.PolicySetOps.exportPolicySetsToFile: begin`);
|
|
210
|
-
|
|
211
|
+
const indicatorId = createProgressIndicator('indeterminate', 0, `Exporting all policy sets...`);
|
|
211
212
|
try {
|
|
212
213
|
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}PolicySets`, 'policyset.authz');
|
|
213
214
|
if (file) {
|
|
@@ -216,10 +217,10 @@ export async function exportPolicySetsToFile(file, options = {
|
|
|
216
217
|
const filePath = getFilePath(fileName, true);
|
|
217
218
|
const exportData = await exportPolicySets(options);
|
|
218
219
|
saveJsonToFile(exportData, filePath);
|
|
219
|
-
|
|
220
|
+
stopProgressIndicator(indicatorId, `Exported all policy sets to ${filePath}.`, 'success');
|
|
220
221
|
outcome = true;
|
|
221
222
|
} catch (error) {
|
|
222
|
-
|
|
223
|
+
stopProgressIndicator(indicatorId, `Error exporting policy sets: ${error.message}`, 'fail');
|
|
223
224
|
}
|
|
224
225
|
debugMessage(`cli.PolicySetOps.exportPolicySetsToFile: end`);
|
|
225
226
|
return outcome;
|
|
@@ -237,24 +238,25 @@ export async function exportPolicySetsToFiles(options = {
|
|
|
237
238
|
}) {
|
|
238
239
|
debugMessage(`cli.PolicySetOps.exportPolicySetsToFiles: begin`);
|
|
239
240
|
const errors = [];
|
|
241
|
+
let indicatorId;
|
|
240
242
|
try {
|
|
241
243
|
const policySets = await readPolicySets();
|
|
242
|
-
|
|
244
|
+
indicatorId = createProgressIndicator('determinate', policySets.length, 'Exporting policy sets...');
|
|
243
245
|
for (const policySet of policySets) {
|
|
244
246
|
const file = getTypedFilename(policySet.name, 'policyset.authz');
|
|
245
247
|
try {
|
|
246
248
|
const exportData = await exportPolicySet(policySet.name, options);
|
|
247
249
|
saveJsonToFile(exportData, getFilePath(file, true));
|
|
248
|
-
|
|
250
|
+
updateProgressIndicator(indicatorId, `Exported ${policySet.name}.`);
|
|
249
251
|
} catch (error) {
|
|
250
252
|
errors.push(error);
|
|
251
|
-
|
|
253
|
+
updateProgressIndicator(indicatorId, `Error exporting ${policySet.name}.`);
|
|
252
254
|
}
|
|
253
255
|
}
|
|
254
|
-
|
|
256
|
+
stopProgressIndicator(indicatorId, `Export complete.`);
|
|
255
257
|
} catch (error) {
|
|
256
258
|
errors.push(error);
|
|
257
|
-
|
|
259
|
+
stopProgressIndicator(indicatorId, `Error exporting policy sets to files`);
|
|
258
260
|
}
|
|
259
261
|
debugMessage(`cli.PolicySetOps.exportPolicySetsToFiles: end`);
|
|
260
262
|
return 0 === errors.length;
|
|
@@ -273,15 +275,15 @@ export async function importPolicySetFromFile(policySetId, file, options = {
|
|
|
273
275
|
}) {
|
|
274
276
|
let outcome = false;
|
|
275
277
|
debugMessage(`cli.PolicySetOps.importPolicySetFromFile: begin`);
|
|
276
|
-
|
|
278
|
+
const indicatorId = createProgressIndicator('indeterminate', 0, `Importing ${policySetId}...`);
|
|
277
279
|
try {
|
|
278
280
|
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
279
281
|
const fileData = JSON.parse(data);
|
|
280
282
|
await importPolicySet(policySetId, fileData, options);
|
|
281
283
|
outcome = true;
|
|
282
|
-
|
|
284
|
+
stopProgressIndicator(indicatorId, `Imported ${policySetId}.`, 'success');
|
|
283
285
|
} catch (error) {
|
|
284
|
-
|
|
286
|
+
stopProgressIndicator(indicatorId, `Error importing ${policySetId}.`, 'fail');
|
|
285
287
|
printMessage(error, 'error');
|
|
286
288
|
}
|
|
287
289
|
debugMessage(`cli.PolicySetOps.importPolicySetFromFile: end`);
|
|
@@ -301,15 +303,15 @@ export async function importFirstPolicySetFromFile(file, options = {
|
|
|
301
303
|
let outcome = false;
|
|
302
304
|
debugMessage(`cli.PolicySetOps.importFirstPolicySetFromFile: begin`);
|
|
303
305
|
const filePath = getFilePath(file);
|
|
304
|
-
|
|
306
|
+
const indicatorId = createProgressIndicator('indeterminate', 0, `Importing first policy set from ${filePath}...`);
|
|
305
307
|
try {
|
|
306
308
|
const data = fs.readFileSync(filePath, 'utf8');
|
|
307
309
|
const fileData = JSON.parse(data);
|
|
308
310
|
const policySet = await importFirstPolicySet(fileData, options);
|
|
309
311
|
outcome = true;
|
|
310
|
-
|
|
312
|
+
stopProgressIndicator(indicatorId, `Imported first policy set with name '${policySet.name}' from ${filePath}.`, 'success');
|
|
311
313
|
} catch (error) {
|
|
312
|
-
|
|
314
|
+
stopProgressIndicator(indicatorId, `Error importing first policy set from ${filePath}.`, 'fail');
|
|
313
315
|
printMessage(error, 'error');
|
|
314
316
|
}
|
|
315
317
|
debugMessage(`cli.PolicySetOps.importFirstPolicySetFromFile: end`);
|
|
@@ -329,15 +331,15 @@ export async function importPolicySetsFromFile(file, options = {
|
|
|
329
331
|
let outcome = false;
|
|
330
332
|
debugMessage(`cli.PolicySetOps.importPolicySetsFromFile: begin`);
|
|
331
333
|
const filePath = getFilePath(file);
|
|
332
|
-
|
|
334
|
+
const indicatorId = createProgressIndicator('indeterminate', 0, `Importing ${filePath}...`);
|
|
333
335
|
try {
|
|
334
336
|
const data = fs.readFileSync(filePath, 'utf8');
|
|
335
337
|
const fileData = JSON.parse(data);
|
|
336
338
|
await importPolicySets(fileData, options);
|
|
337
339
|
outcome = true;
|
|
338
|
-
|
|
340
|
+
stopProgressIndicator(indicatorId, `Imported ${filePath}.`, 'success');
|
|
339
341
|
} catch (error) {
|
|
340
|
-
|
|
342
|
+
stopProgressIndicator(indicatorId, `Error importing ${filePath}.`, 'fail');
|
|
341
343
|
printMessage(error, 'error');
|
|
342
344
|
}
|
|
343
345
|
debugMessage(`cli.PolicySetOps.importPolicySetsFromFile: end`);
|
|
@@ -354,11 +356,12 @@ export async function importPolicySetsFromFiles(options = {
|
|
|
354
356
|
prereqs: false
|
|
355
357
|
}) {
|
|
356
358
|
const errors = [];
|
|
359
|
+
let indicatorId;
|
|
357
360
|
try {
|
|
358
361
|
debugMessage(`cli.PolicySetOps.importPolicySetsFromFiles: begin`);
|
|
359
362
|
const names = fs.readdirSync(getWorkingDirectory());
|
|
360
363
|
const files = names.filter(name => name.toLowerCase().endsWith('.policyset.authz.json')).map(name => getFilePath(name));
|
|
361
|
-
|
|
364
|
+
indicatorId = createProgressIndicator('determinate', files.length, 'Importing policy sets...');
|
|
362
365
|
let total = 0;
|
|
363
366
|
for (const file of files) {
|
|
364
367
|
try {
|
|
@@ -367,17 +370,17 @@ export async function importPolicySetsFromFiles(options = {
|
|
|
367
370
|
const count = Object.keys(fileData.policyset).length;
|
|
368
371
|
total += count;
|
|
369
372
|
await importPolicySets(fileData, options);
|
|
370
|
-
|
|
373
|
+
updateProgressIndicator(indicatorId, `Imported ${count} policy sets from ${file}`);
|
|
371
374
|
} catch (error) {
|
|
372
375
|
errors.push(error);
|
|
373
|
-
|
|
376
|
+
updateProgressIndicator(indicatorId, `Error importing policy sets from ${file}`);
|
|
374
377
|
printMessage(error, 'error');
|
|
375
378
|
}
|
|
376
379
|
}
|
|
377
|
-
|
|
380
|
+
stopProgressIndicator(indicatorId, `Finished importing ${total} policy sets from ${files.length} files.`);
|
|
378
381
|
} catch (error) {
|
|
379
382
|
errors.push(error);
|
|
380
|
-
|
|
383
|
+
stopProgressIndicator(indicatorId, `Error importing policy sets from files.`);
|
|
381
384
|
printMessage(error, 'error');
|
|
382
385
|
}
|
|
383
386
|
debugMessage(`cli.PolicySetOps.importPolicySetsFromFiles: end`);
|