@rockcarver/frodo-cli 2.0.0-6 → 2.0.0-7
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/app.js +4 -1
- package/esm/app.js.map +1 -1
- package/esm/cli/_template/something-delete.js +4 -1
- package/esm/cli/_template/something-delete.js.map +1 -1
- package/esm/cli/_template/something-describe.js +4 -1
- package/esm/cli/_template/something-describe.js.map +1 -1
- package/esm/cli/_template/something-else-delete.js +4 -1
- package/esm/cli/_template/something-else-delete.js.map +1 -1
- package/esm/cli/_template/something-else-describe.js +4 -1
- package/esm/cli/_template/something-else-describe.js.map +1 -1
- package/esm/cli/_template/something-else-export.js +4 -1
- package/esm/cli/_template/something-else-export.js.map +1 -1
- package/esm/cli/_template/something-else-import.js +4 -1
- package/esm/cli/_template/something-else-import.js.map +1 -1
- package/esm/cli/_template/something-else-list.js +4 -1
- package/esm/cli/_template/something-else-list.js.map +1 -1
- package/esm/cli/_template/something-export.js +4 -1
- package/esm/cli/_template/something-export.js.map +1 -1
- package/esm/cli/_template/something-import.js +4 -1
- package/esm/cli/_template/something-import.js.map +1 -1
- package/esm/cli/_template/something-list.js +4 -1
- package/esm/cli/_template/something-list.js.map +1 -1
- package/esm/cli/_template/something-other-delete.js +4 -1
- package/esm/cli/_template/something-other-delete.js.map +1 -1
- package/esm/cli/_template/something-other-describe.js +4 -1
- package/esm/cli/_template/something-other-describe.js.map +1 -1
- package/esm/cli/_template/something-other-export.js +4 -1
- package/esm/cli/_template/something-other-export.js.map +1 -1
- package/esm/cli/_template/something-other-import.js +4 -1
- package/esm/cli/_template/something-other-import.js.map +1 -1
- package/esm/cli/_template/something-other-list.js +4 -1
- package/esm/cli/_template/something-other-list.js.map +1 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +8 -2
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +10 -3
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-federation-export.js +4 -1
- package/esm/cli/admin/admin-federation-export.js.map +1 -1
- package/esm/cli/admin/admin-federation-import.js +7 -4
- package/esm/cli/admin/admin-federation-import.js.map +1 -1
- package/esm/cli/admin/admin-federation-list.js +4 -1
- package/esm/cli/admin/admin-federation-list.js.map +1 -1
- package/esm/cli/admin/admin-get-access-token.js +8 -2
- package/esm/cli/admin/admin-get-access-token.js.map +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +8 -2
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js +8 -2
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +8 -2
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +8 -2
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js +8 -2
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js +8 -2
- package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-repair-org-model.js +8 -2
- package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +8 -2
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js +8 -2
- package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
- package/esm/cli/agent/agent-delete.js +10 -3
- package/esm/cli/agent/agent-delete.js.map +1 -1
- package/esm/cli/agent/agent-describe.js +4 -1
- package/esm/cli/agent/agent-describe.js.map +1 -1
- package/esm/cli/agent/agent-export.js +4 -1
- package/esm/cli/agent/agent-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-delete.js +10 -3
- package/esm/cli/agent/agent-gateway-delete.js.map +1 -1
- package/esm/cli/agent/agent-gateway-describe.js +4 -1
- package/esm/cli/agent/agent-gateway-describe.js.map +1 -1
- package/esm/cli/agent/agent-gateway-export.js +4 -1
- package/esm/cli/agent/agent-gateway-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-import.js +4 -1
- package/esm/cli/agent/agent-gateway-import.js.map +1 -1
- package/esm/cli/agent/agent-gateway-list.js +4 -1
- package/esm/cli/agent/agent-gateway-list.js.map +1 -1
- package/esm/cli/agent/agent-import.js +4 -1
- package/esm/cli/agent/agent-import.js.map +1 -1
- package/esm/cli/agent/agent-java-delete.js +10 -3
- package/esm/cli/agent/agent-java-delete.js.map +1 -1
- package/esm/cli/agent/agent-java-describe.js +4 -1
- package/esm/cli/agent/agent-java-describe.js.map +1 -1
- package/esm/cli/agent/agent-java-export.js +4 -1
- package/esm/cli/agent/agent-java-export.js.map +1 -1
- package/esm/cli/agent/agent-java-import.js +4 -1
- package/esm/cli/agent/agent-java-import.js.map +1 -1
- package/esm/cli/agent/agent-java-list.js +4 -1
- package/esm/cli/agent/agent-java-list.js.map +1 -1
- package/esm/cli/agent/agent-list.js +4 -1
- package/esm/cli/agent/agent-list.js.map +1 -1
- package/esm/cli/agent/agent-web-delete.js +10 -3
- package/esm/cli/agent/agent-web-delete.js.map +1 -1
- package/esm/cli/agent/agent-web-describe.js +4 -1
- package/esm/cli/agent/agent-web-describe.js.map +1 -1
- package/esm/cli/agent/agent-web-export.js +4 -1
- package/esm/cli/agent/agent-web-export.js.map +1 -1
- package/esm/cli/agent/agent-web-import.js +4 -1
- package/esm/cli/agent/agent-web-import.js.map +1 -1
- package/esm/cli/agent/agent-web-list.js +4 -1
- package/esm/cli/agent/agent-web-list.js.map +1 -1
- package/esm/cli/app/app-delete.js +4 -1
- package/esm/cli/app/app-delete.js.map +1 -1
- package/esm/cli/app/app-describe.js +4 -1
- package/esm/cli/app/app-describe.js.map +1 -1
- package/esm/cli/app/app-export.js +6 -3
- package/esm/cli/app/app-export.js.map +1 -1
- package/esm/cli/app/app-import.js +7 -4
- package/esm/cli/app/app-import.js.map +1 -1
- package/esm/cli/app/app-list.js +4 -1
- package/esm/cli/app/app-list.js.map +1 -1
- package/esm/cli/authz/authz-policy-delete.js +6 -3
- package/esm/cli/authz/authz-policy-delete.js.map +1 -1
- package/esm/cli/authz/authz-policy-describe.js +4 -1
- package/esm/cli/authz/authz-policy-describe.js.map +1 -1
- package/esm/cli/authz/authz-policy-export.js +8 -5
- package/esm/cli/authz/authz-policy-export.js.map +1 -1
- package/esm/cli/authz/authz-policy-import.js +7 -4
- package/esm/cli/authz/authz-policy-import.js.map +1 -1
- package/esm/cli/authz/authz-policy-list.js +5 -2
- package/esm/cli/authz/authz-policy-list.js.map +1 -1
- package/esm/cli/authz/authz-set-delete.js +5 -2
- package/esm/cli/authz/authz-set-delete.js.map +1 -1
- package/esm/cli/authz/authz-set-describe.js +4 -1
- package/esm/cli/authz/authz-set-describe.js.map +1 -1
- package/esm/cli/authz/authz-set-export.js +6 -3
- package/esm/cli/authz/authz-set-export.js.map +1 -1
- package/esm/cli/authz/authz-set-import.js +7 -4
- package/esm/cli/authz/authz-set-import.js.map +1 -1
- package/esm/cli/authz/authz-set-list.js +4 -1
- package/esm/cli/authz/authz-set-list.js.map +1 -1
- package/esm/cli/authz/authz-type-delete.js +6 -3
- package/esm/cli/authz/authz-type-delete.js.map +1 -1
- package/esm/cli/authz/authz-type-describe.js +5 -2
- package/esm/cli/authz/authz-type-describe.js.map +1 -1
- package/esm/cli/authz/authz-type-export.js +7 -4
- package/esm/cli/authz/authz-type-export.js.map +1 -1
- package/esm/cli/authz/authz-type-import.js +8 -5
- package/esm/cli/authz/authz-type-import.js.map +1 -1
- package/esm/cli/authz/authz-type-list.js +4 -1
- package/esm/cli/authz/authz-type-list.js.map +1 -1
- package/esm/cli/conn/conn-save.js +18 -5
- package/esm/cli/conn/conn-save.js.map +1 -1
- package/esm/cli/email/email-template-export.js +6 -3
- package/esm/cli/email/email-template-export.js.map +1 -1
- package/esm/cli/email/email-template-import.js +7 -4
- package/esm/cli/email/email-template-import.js.map +1 -1
- package/esm/cli/email/email-template-list.js +4 -1
- package/esm/cli/email/email-template-list.js.map +1 -1
- package/esm/cli/esv/esv-apply.js +15 -5
- package/esm/cli/esv/esv-apply.js.map +1 -1
- package/esm/cli/esv/esv-secret-create.js +4 -1
- package/esm/cli/esv/esv-secret-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-delete.js +5 -2
- package/esm/cli/esv/esv-secret-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-describe.js +4 -1
- package/esm/cli/esv/esv-secret-describe.js.map +1 -1
- package/esm/cli/esv/esv-secret-export.js +4 -1
- package/esm/cli/esv/esv-secret-export.js.map +1 -1
- package/esm/cli/esv/esv-secret-import.js +4 -1
- package/esm/cli/esv/esv-secret-import.js.map +1 -1
- package/esm/cli/esv/esv-secret-list.js +4 -1
- package/esm/cli/esv/esv-secret-list.js.map +1 -1
- package/esm/cli/esv/esv-secret-set.js +4 -1
- package/esm/cli/esv/esv-secret-set.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-activate.js +4 -1
- package/esm/cli/esv/esv-secret-version-activate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-create.js +4 -1
- package/esm/cli/esv/esv-secret-version-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js +4 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-delete.js +5 -2
- package/esm/cli/esv/esv-secret-version-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-list.js +4 -1
- package/esm/cli/esv/esv-secret-version-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-create.js +4 -1
- package/esm/cli/esv/esv-variable-create.js.map +1 -1
- package/esm/cli/esv/esv-variable-delete.js +5 -2
- package/esm/cli/esv/esv-variable-delete.js.map +1 -1
- package/esm/cli/esv/esv-variable-describe.js +4 -1
- package/esm/cli/esv/esv-variable-describe.js.map +1 -1
- package/esm/cli/esv/esv-variable-export.js +4 -1
- package/esm/cli/esv/esv-variable-export.js.map +1 -1
- package/esm/cli/esv/esv-variable-import.js +4 -1
- package/esm/cli/esv/esv-variable-import.js.map +1 -1
- package/esm/cli/esv/esv-variable-list.js +4 -1
- package/esm/cli/esv/esv-variable-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-set.js +5 -2
- package/esm/cli/esv/esv-variable-set.js.map +1 -1
- package/esm/cli/idm/idm-count.js +4 -1
- package/esm/cli/idm/idm-count.js.map +1 -1
- package/esm/cli/idm/idm-export.js +6 -3
- package/esm/cli/idm/idm-export.js.map +1 -1
- package/esm/cli/idm/idm-import.js +7 -4
- package/esm/cli/idm/idm-import.js.map +1 -1
- package/esm/cli/idm/idm-list.js +4 -1
- package/esm/cli/idm/idm-list.js.map +1 -1
- package/esm/cli/idp/idp-export.js +4 -1
- package/esm/cli/idp/idp-export.js.map +1 -1
- package/esm/cli/idp/idp-import.js +7 -4
- package/esm/cli/idp/idp-import.js.map +1 -1
- package/esm/cli/idp/idp-list.js +4 -1
- package/esm/cli/idp/idp-list.js.map +1 -1
- package/esm/cli/info/info.js +8 -2
- package/esm/cli/info/info.js.map +1 -1
- package/esm/cli/journey/journey-delete.js +5 -2
- package/esm/cli/journey/journey-delete.js.map +1 -1
- package/esm/cli/journey/journey-describe.js +14 -6
- package/esm/cli/journey/journey-describe.js.map +1 -1
- package/esm/cli/journey/journey-disable.js +8 -2
- package/esm/cli/journey/journey-disable.js.map +1 -1
- package/esm/cli/journey/journey-enable.js +8 -2
- package/esm/cli/journey/journey-enable.js.map +1 -1
- package/esm/cli/journey/journey-export.js +6 -3
- package/esm/cli/journey/journey-export.js.map +1 -1
- package/esm/cli/journey/journey-import.js +7 -4
- package/esm/cli/journey/journey-import.js.map +1 -1
- package/esm/cli/journey/journey-list.js +4 -1
- package/esm/cli/journey/journey-list.js.map +1 -1
- package/esm/cli/journey/journey-prune.js +10 -3
- package/esm/cli/journey/journey-prune.js.map +1 -1
- package/esm/cli/log/log-fetch.js +16 -6
- package/esm/cli/log/log-fetch.js.map +1 -1
- package/esm/cli/log/log-key-delete.js +5 -2
- package/esm/cli/log/log-key-delete.js.map +1 -1
- package/esm/cli/log/log-key-describe.js +4 -1
- package/esm/cli/log/log-key-describe.js.map +1 -1
- package/esm/cli/log/log-key-list.js +4 -1
- package/esm/cli/log/log-key-list.js.map +1 -1
- package/esm/cli/log/log-list.js +14 -4
- package/esm/cli/log/log-list.js.map +1 -1
- package/esm/cli/log/log-tail.js +16 -6
- package/esm/cli/log/log-tail.js.map +1 -1
- package/esm/cli/realm/realm-add-custom-domain.js +4 -1
- package/esm/cli/realm/realm-add-custom-domain.js.map +1 -1
- package/esm/cli/realm/realm-describe.js +4 -1
- package/esm/cli/realm/realm-describe.js.map +1 -1
- package/esm/cli/realm/realm-list.js +4 -1
- package/esm/cli/realm/realm-list.js.map +1 -1
- package/esm/cli/realm/realm-remove-custom-domain.js +8 -2
- package/esm/cli/realm/realm-remove-custom-domain.js.map +1 -1
- package/esm/cli/saml/saml-cot-export.js +6 -3
- package/esm/cli/saml/saml-cot-export.js.map +1 -1
- package/esm/cli/saml/saml-cot-import.js +7 -4
- package/esm/cli/saml/saml-cot-import.js.map +1 -1
- package/esm/cli/saml/saml-cot-list.js +4 -1
- package/esm/cli/saml/saml-cot-list.js.map +1 -1
- package/esm/cli/saml/saml-delete.js +11 -4
- package/esm/cli/saml/saml-delete.js.map +1 -1
- package/esm/cli/saml/saml-describe.js +4 -1
- package/esm/cli/saml/saml-describe.js.map +1 -1
- package/esm/cli/saml/saml-export.js +6 -3
- package/esm/cli/saml/saml-export.js.map +1 -1
- package/esm/cli/saml/saml-import.js +7 -4
- package/esm/cli/saml/saml-import.js.map +1 -1
- package/esm/cli/saml/saml-list.js +4 -1
- package/esm/cli/saml/saml-list.js.map +1 -1
- package/esm/cli/saml/saml-metadata-export.js +5 -2
- package/esm/cli/saml/saml-metadata-export.js.map +1 -1
- package/esm/cli/script/script-delete.js +4 -1
- package/esm/cli/script/script-delete.js.map +1 -1
- package/esm/cli/script/script-describe.js +4 -1
- package/esm/cli/script/script-describe.js.map +1 -1
- package/esm/cli/script/script-export.js +4 -1
- package/esm/cli/script/script-export.js.map +1 -1
- package/esm/cli/script/script-import.js +4 -1
- package/esm/cli/script/script-import.js.map +1 -1
- package/esm/cli/script/script-list.js +4 -1
- package/esm/cli/script/script-list.js.map +1 -1
- package/esm/cli/service/service-delete.js +5 -2
- package/esm/cli/service/service-delete.js.map +1 -1
- package/esm/cli/service/service-export.js +6 -3
- package/esm/cli/service/service-export.js.map +1 -1
- package/esm/cli/service/service-import.js +7 -4
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/cli/service/service-list.js +4 -1
- package/esm/cli/service/service-list.js.map +1 -1
- package/esm/cli/theme/theme-delete.js +6 -3
- package/esm/cli/theme/theme-delete.js.map +1 -1
- package/esm/cli/theme/theme-export.js +7 -4
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/cli/theme/theme-import.js +8 -5
- package/esm/cli/theme/theme-import.js.map +1 -1
- package/esm/cli/theme/theme-list.js +4 -1
- package/esm/cli/theme/theme-list.js.map +1 -1
- package/esm/ops/AdminFederationOps.js +17 -9
- package/esm/ops/AdminFederationOps.js.map +1 -1
- package/esm/ops/AgentOps.js +62 -36
- package/esm/ops/AgentOps.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +22 -10
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/ConnectionProfileOps.js +10 -3
- package/esm/ops/ConnectionProfileOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +23 -15
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +34 -21
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/IdpOps.js +17 -9
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +46 -30
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/LogOps.js +21 -11
- package/esm/ops/LogOps.js.map +1 -1
- package/esm/ops/NodeOps.js +5 -2
- package/esm/ops/NodeOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +25 -12
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/OrganizationOps.js +8 -2
- package/esm/ops/OrganizationOps.js.map +1 -1
- package/esm/ops/PolicyOps.js +36 -21
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/PolicySetOps.js +35 -18
- package/esm/ops/PolicySetOps.js.map +1 -1
- package/esm/ops/RealmOps.js +11 -6
- package/esm/ops/RealmOps.js.map +1 -1
- package/esm/ops/ResourceTypeOps.js +34 -18
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +43 -23
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ScriptOps.js +18 -10
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/ops/SecretsOps.js +28 -14
- package/esm/ops/SecretsOps.js.map +1 -1
- package/esm/ops/ServiceOps.js +38 -17
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +35 -19
- package/esm/ops/ThemeOps.js.map +1 -1
- package/esm/ops/VariablesOps.js +23 -12
- package/esm/ops/VariablesOps.js.map +1 -1
- package/esm/utils/Config.js +6 -3
- package/esm/utils/Config.js.map +1 -1
- package/esm/utils/Console.js +5 -2
- package/esm/utils/Console.js.map +1 -1
- package/esm/utils/ExportImportUtils.js +6 -3
- package/esm/utils/ExportImportUtils.js.map +1 -1
- package/esm/utils/Version.js +7 -3
- package/esm/utils/Version.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,33 +3,36 @@ import { Option } from 'commander';
|
|
|
3
3
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
4
4
|
import { printMessage, verboseMessage } from '../../utils/Console';
|
|
5
5
|
import { importFirstThemeFromFile, importThemeById, importThemeByName, importThemesFromFile, importThemesFromFiles } from '../../ops/ThemeOps';
|
|
6
|
+
const {
|
|
7
|
+
getTokens
|
|
8
|
+
} = frodo.login;
|
|
6
9
|
const program = new FrodoCommand('frodo theme import');
|
|
7
10
|
program.description('Import themes.').addOption(new Option('-n, --theme-name <name>', 'Name of the theme. If specified, -a and -A are ignored.')).addOption(new Option('-i, --theme-id <uuid>', 'Uuid of the theme. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import the theme(s) from.')).addOption(new Option('-a, --all', 'Import all the themes from single file. Ignored with -n or -i.')).addOption(new Option('-A, --all-separate', 'Import all the themes from separate files (*.json) in the current directory. Ignored with -n or -i or -a.')).action(
|
|
8
11
|
// implement command logic inside action handler
|
|
9
12
|
async (host, realm, user, password, options, command) => {
|
|
10
13
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
11
14
|
// import by name
|
|
12
|
-
if (options.file && options.themeName && (await
|
|
15
|
+
if (options.file && options.themeName && (await getTokens())) {
|
|
13
16
|
verboseMessage(`Importing theme with name "${options.themeName}" into realm "${state.getRealm()}"...`);
|
|
14
17
|
importThemeByName(options.themeName, options.file);
|
|
15
18
|
}
|
|
16
19
|
// import by id
|
|
17
|
-
else if (options.file && options.themeId && (await
|
|
20
|
+
else if (options.file && options.themeId && (await getTokens())) {
|
|
18
21
|
verboseMessage(`Importing theme with id "${options.themeId}" into realm "${state.getRealm()}"...`);
|
|
19
22
|
importThemeById(options.themeId, options.file);
|
|
20
23
|
}
|
|
21
24
|
// --all -a
|
|
22
|
-
else if (options.all && options.file && (await
|
|
25
|
+
else if (options.all && options.file && (await getTokens())) {
|
|
23
26
|
verboseMessage(`Importing all themes from a single file (${options.file})...`);
|
|
24
27
|
importThemesFromFile(options.file);
|
|
25
28
|
}
|
|
26
29
|
// --all-separate -A
|
|
27
|
-
else if (options.allSeparate && !options.file && (await
|
|
30
|
+
else if (options.allSeparate && !options.file && (await getTokens())) {
|
|
28
31
|
verboseMessage('Importing all themes from separate files in current directory...');
|
|
29
32
|
importThemesFromFiles();
|
|
30
33
|
}
|
|
31
34
|
// import single theme from file
|
|
32
|
-
else if (options.file && (await
|
|
35
|
+
else if (options.file && (await getTokens())) {
|
|
33
36
|
verboseMessage(`Importing first theme from file "${options.file}" into realm "${state.getRealm()}"...`);
|
|
34
37
|
importFirstThemeFromFile(options.file);
|
|
35
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-import.js","names":["FrodoCommand","Option","frodo","state","printMessage","verboseMessage","importFirstThemeFromFile","importThemeById","importThemeByName","importThemesFromFile","importThemesFromFiles","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","file","themeName","
|
|
1
|
+
{"version":3,"file":"theme-import.js","names":["FrodoCommand","Option","frodo","state","printMessage","verboseMessage","importFirstThemeFromFile","importThemeById","importThemeByName","importThemesFromFile","importThemesFromFiles","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","file","themeName","getRealm","themeId","all","allSeparate","help","process","exitCode","parse"],"sources":["cli/theme/theme-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n importFirstThemeFromFile,\n importThemeById,\n importThemeByName,\n importThemesFromFile,\n importThemesFromFiles,\n} from '../../ops/ThemeOps';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo theme import');\n\nprogram\n .description('Import themes.')\n .addOption(\n new Option(\n '-n, --theme-name <name>',\n 'Name of the theme. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-i, --theme-id <uuid>',\n 'Uuid of the theme. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the file to import the theme(s) from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all the themes from single file. Ignored with -n or -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all the themes from separate files (*.json) in the current directory. Ignored with -n or -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import by name\n if (options.file && options.themeName && (await getTokens())) {\n verboseMessage(\n `Importing theme with name \"${\n options.themeName\n }\" into realm \"${state.getRealm()}\"...`\n );\n importThemeByName(options.themeName, options.file);\n }\n // import by id\n else if (options.file && options.themeId && (await getTokens())) {\n verboseMessage(\n `Importing theme with id \"${\n options.themeId\n }\" into realm \"${state.getRealm()}\"...`\n );\n importThemeById(options.themeId, options.file);\n }\n // --all -a\n else if (options.all && options.file && (await getTokens())) {\n verboseMessage(\n `Importing all themes from a single file (${options.file})...`\n );\n importThemesFromFile(options.file);\n }\n // --all-separate -A\n else if (options.allSeparate && !options.file && (await getTokens())) {\n verboseMessage(\n 'Importing all themes from separate files in current directory...'\n );\n importThemesFromFiles();\n }\n // import single theme from file\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first theme from file \"${\n options.file\n }\" into realm \"${state.getRealm()}\"...`\n );\n importFirstThemeFromFile(options.file);\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,wBAAw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,CAACuB,QAAQ,CAAC,CAAE,MACpC,CAAC;IACDnB,eAAe,CAACc,OAAO,CAACM,OAAO,EAAEN,OAAO,CAACG,IAAI,CAAC;EAChD;EACA;EAAA,KACK,IAAIH,OAAO,CAACO,GAAG,IAAIP,OAAO,CAACG,IAAI,KAAK,MAAMb,SAAS,CAAC,CAAC,CAAC,EAAE;IAC3DN,cAAc,CACX,4CAA2CgB,OAAO,CAACG,IAAK,MAC3D,CAAC;IACDf,oBAAoB,CAACY,OAAO,CAACG,IAAI,CAAC;EACpC;EACA;EAAA,KACK,IAAIH,OAAO,CAACQ,WAAW,IAAI,CAACR,OAAO,CAACG,IAAI,KAAK,MAAMb,SAAS,CAAC,CAAC,CAAC,EAAE;IACpEN,cAAc,CACZ,kEACF,CAAC;IACDK,qBAAqB,CAAC,CAAC;EACzB;EACA;EAAA,KACK,IAAIW,OAAO,CAACG,IAAI,KAAK,MAAMb,SAAS,CAAC,CAAC,CAAC,EAAE;IAC5CN,cAAc,CACX,oCACCgB,OAAO,CAACG,IACT,iBAAgBrB,KAAK,CAACuB,QAAQ,CAAC,CAAE,MACpC,CAAC;IACDpB,wBAAwB,CAACe,OAAO,CAACG,IAAI,CAAC;EACxC;EACA;EAAA,KACK;IACHpB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;IACDS,OAAO,CAACiB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHnB,OAAO,CAACoB,KAAK,CAAC,CAAC"}
|
|
@@ -3,12 +3,15 @@ import { Option } from 'commander';
|
|
|
3
3
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
4
4
|
import { listThemes } from '../../ops/ThemeOps';
|
|
5
5
|
import { verboseMessage } from '../../utils/Console';
|
|
6
|
+
const {
|
|
7
|
+
getTokens
|
|
8
|
+
} = frodo.login;
|
|
6
9
|
const program = new FrodoCommand('frodo theme list');
|
|
7
10
|
program.description('List themes.').addOption(new Option('-l, --long', 'Long with more fields.').default(false, 'false')).action(
|
|
8
11
|
// implement command logic inside action handler
|
|
9
12
|
async (host, realm, user, password, options, command) => {
|
|
10
13
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
11
|
-
if (await
|
|
14
|
+
if (await getTokens()) {
|
|
12
15
|
verboseMessage(`Listing themes in realm "${state.getRealm()}"...`);
|
|
13
16
|
listThemes(options.long);
|
|
14
17
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-list.js","names":["FrodoCommand","Option","frodo","state","listThemes","verboseMessage","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","
|
|
1
|
+
{"version":3,"file":"theme-list.js","names":["FrodoCommand","Option","frodo","state","listThemes","verboseMessage","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","long","process","exitCode","parse"],"sources":["cli/theme/theme-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport { listThemes } from '../../ops/ThemeOps';\nimport { verboseMessage } from '../../utils/Console';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo theme list');\n\nprogram\n .description('List themes.')\n .addOption(\n new Option('-l, --long', 'Long with more fields.').default(false, 'false')\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n verboseMessage(`Listing themes in realm \"${state.getRealm()}\"...`);\n listThemes(options.long);\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,MAAM;EAAEC;AAAU,CAAC,GAAGJ,KAAK,CAACK,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIR,YAAY,CAAC,kBAAkB,CAAC;AAEpDQ,OAAO,CACJC,WAAW,CAAC,cAAc,CAAC,CAC3BC,SAAS,CACR,IAAIT,MAAM,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAACU,OAAO,CAAC,KAAK,EAAE,OAAO,CAC3E,CAAC,CACAC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAI,MAAMZ,SAAS,CAAC,CAAC,EAAE;IACrBD,cAAc,CAAE,4BAA2BF,KAAK,CAACiB,QAAQ,CAAC,CAAE,MAAK,CAAC;IAClEhB,UAAU,CAACa,OAAO,CAACI,IAAI,CAAC;EAC1B,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHf,OAAO,CAACgB,KAAK,CAAC,CAAC"}
|
|
@@ -2,6 +2,14 @@ import { frodo } from '@rockcarver/frodo-lib';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
4
4
|
import { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
|
|
5
|
+
const {
|
|
6
|
+
getAdminFederationProviders,
|
|
7
|
+
exportAdminFederationProvider,
|
|
8
|
+
exportAdminFederationProviders,
|
|
9
|
+
importAdminFederationProvider,
|
|
10
|
+
importAdminFederationProviders,
|
|
11
|
+
importFirstAdminFederationProvider
|
|
12
|
+
} = frodo.cloud.adminFed;
|
|
5
13
|
|
|
6
14
|
/**
|
|
7
15
|
* List providers
|
|
@@ -10,7 +18,7 @@ import { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
|
|
|
10
18
|
export async function listAdminFederationProviders() {
|
|
11
19
|
let outcome = false;
|
|
12
20
|
try {
|
|
13
|
-
const providers = await
|
|
21
|
+
const providers = await getAdminFederationProviders();
|
|
14
22
|
providers.sort((a, b) => a._id.localeCompare(b._id));
|
|
15
23
|
providers.forEach(socialIdentityProvider => {
|
|
16
24
|
printMessage(`${socialIdentityProvider._id}`, 'data');
|
|
@@ -38,7 +46,7 @@ export async function exportAdminFederationProviderToFile(providerId, file = '')
|
|
|
38
46
|
createProgressBar(1, `Exporting ${providerId}`);
|
|
39
47
|
try {
|
|
40
48
|
updateProgressBar(`Writing file ${fileName}`);
|
|
41
|
-
const fileData = await
|
|
49
|
+
const fileData = await exportAdminFederationProvider(providerId);
|
|
42
50
|
saveJsonToFile(fileData, fileName);
|
|
43
51
|
stopProgressBar(`Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`);
|
|
44
52
|
outcome = true;
|
|
@@ -62,7 +70,7 @@ export async function exportAdminFederationProvidersToFile(file = '') {
|
|
|
62
70
|
if (!fileName) {
|
|
63
71
|
fileName = getTypedFilename(`allProviders`, 'admin.federation');
|
|
64
72
|
}
|
|
65
|
-
const fileData = await
|
|
73
|
+
const fileData = await exportAdminFederationProviders();
|
|
66
74
|
saveJsonToFile(fileData, fileName);
|
|
67
75
|
succeedSpinner(`Exported all providers to ${fileName}`);
|
|
68
76
|
outcome = true;
|
|
@@ -81,12 +89,12 @@ export async function exportAdminFederationProvidersToFile(file = '') {
|
|
|
81
89
|
export async function exportAdminFederationProvidersToFiles() {
|
|
82
90
|
let outcome = false;
|
|
83
91
|
try {
|
|
84
|
-
const allIdpsData = await
|
|
92
|
+
const allIdpsData = await getAdminFederationProviders();
|
|
85
93
|
createProgressBar(allIdpsData.length, 'Exporting providers');
|
|
86
94
|
for (const idpData of allIdpsData) {
|
|
87
95
|
updateProgressBar(`Writing provider ${idpData._id}`);
|
|
88
96
|
const fileName = getTypedFilename(idpData._id, 'admin.federation');
|
|
89
|
-
const fileData = await
|
|
97
|
+
const fileData = await exportAdminFederationProvider(idpData._id);
|
|
90
98
|
saveJsonToFile(fileData, fileName);
|
|
91
99
|
}
|
|
92
100
|
stopProgressBar(`${allIdpsData.length} providers exported.`);
|
|
@@ -111,7 +119,7 @@ export async function importAdminFederationProviderFromFile(providerId, file) {
|
|
|
111
119
|
try {
|
|
112
120
|
const data = fs.readFileSync(file, 'utf8');
|
|
113
121
|
const fileData = JSON.parse(data);
|
|
114
|
-
await
|
|
122
|
+
await importAdminFederationProvider(providerId, fileData);
|
|
115
123
|
succeedSpinner(`Successfully imported provider ${providerId} from ${file}.`);
|
|
116
124
|
outcome = true;
|
|
117
125
|
} catch (error) {
|
|
@@ -134,7 +142,7 @@ export async function importFirstAdminFederationProviderFromFile(file) {
|
|
|
134
142
|
try {
|
|
135
143
|
const data = fs.readFileSync(file, 'utf8');
|
|
136
144
|
const fileData = JSON.parse(data);
|
|
137
|
-
await
|
|
145
|
+
await importFirstAdminFederationProvider(fileData);
|
|
138
146
|
succeedSpinner(`Successfully imported first provider from ${file}.`);
|
|
139
147
|
outcome = true;
|
|
140
148
|
} catch (error) {
|
|
@@ -158,7 +166,7 @@ export async function importAdminFederationProvidersFromFile(file) {
|
|
|
158
166
|
try {
|
|
159
167
|
const data = fs.readFileSync(file, 'utf8');
|
|
160
168
|
const fileData = JSON.parse(data);
|
|
161
|
-
await
|
|
169
|
+
await importAdminFederationProviders(fileData);
|
|
162
170
|
succeedSpinner(`Imported providers from ${file}.`);
|
|
163
171
|
outcome = true;
|
|
164
172
|
} catch (error) {
|
|
@@ -188,7 +196,7 @@ export async function importAdminFederationProvidersFromFiles() {
|
|
|
188
196
|
const fileData = JSON.parse(data);
|
|
189
197
|
const count = Object.keys(fileData.idp).length;
|
|
190
198
|
total += count;
|
|
191
|
-
await
|
|
199
|
+
await importAdminFederationProviders(fileData);
|
|
192
200
|
updateProgressBar(`Imported ${count} provider(s) from ${file}`);
|
|
193
201
|
} catch (error) {
|
|
194
202
|
errors.push(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminFederationOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","listAdminFederationProviders","outcome","providers","cloud","adminFed","getAdminFederationProviders","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","err","message","exportAdminFederationProviderToFile","providerId","file","fileName","fileData","exportAdminFederationProvider","exportAdminFederationProvidersToFile","exportAdminFederationProviders","error","_error$response","response","data","exportAdminFederationProvidersToFiles","allIdpsData","length","idpData","_error$response2","importAdminFederationProviderFromFile","readFileSync","JSON","parse","importAdminFederationProvider","_error$response3","importFirstAdminFederationProviderFromFile","importFirstAdminFederationProvider","_error$response4","importAdminFederationProvidersFromFile","importAdminFederationProviders","_error$response5","importAdminFederationProvidersFromFiles","errors","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","idp","push"],"sources":["ops/AdminFederationOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\n\n/**\n * List providers\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listAdminFederationProviders(): Promise<boolean> {\n let outcome = false;\n try {\n const providers = await frodo.cloud.adminFed.getAdminFederationProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n outcome = true;\n } catch (err) {\n printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProviderToFile(\n providerId: string,\n file = ''\n): Promise<boolean> {\n let outcome = false;\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'admin.federation');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await frodo.cloud.adminFed.exportAdminFederationProvider(\n providerId\n );\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n outcome = true;\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFile(\n file = ''\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Exporting all providers...`);\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allProviders`, 'admin.federation');\n }\n const fileData =\n await frodo.cloud.adminFed.exportAdminFederationProviders();\n saveJsonToFile(fileData, fileName);\n succeedSpinner(`Exported all providers to ${fileName}`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all providers.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers to individual files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFiles(): Promise<boolean> {\n let outcome = false;\n try {\n const allIdpsData =\n await frodo.cloud.adminFed.getAdminFederationProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressBar(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'admin.federation');\n const fileData = await frodo.cloud.adminFed.exportAdminFederationProvider(\n idpData._id\n );\n saveJsonToFile(fileData, fileName);\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all providers.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.cloud.adminFed.importAdminFederationProvider(\n providerId,\n fileData\n );\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstAdminFederationProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`\n );\n showSpinner(`Importing first provider from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.cloud.adminFed.importFirstAdminFederationProvider(fileData);\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`\n );\n showSpinner(`Importing providers from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.cloud.adminFed.importAdminFederationProviders(fileData);\n succeedSpinner(`Imported providers from ${file}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`\n );\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.admin.federation.json')\n );\n createProgressBar(files.length, 'Importing providers...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await frodo.cloud.adminFed.importAdminFederationProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing provider(s) from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing provider(s) from file(s).`);\n printMessage(error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`\n );\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBA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IACzD,IAAIwB,KAAK,GAAG,CAAC;IACb,KAAK,MAAMpC,IAAI,IAAI+B,KAAK,EAAE;MACxB,IAAI;QACF,MAAMtB,IAAI,GAAGrC,EAAE,CAAC4C,YAAY,CAAChB,IAAI,EAAE,MAAM,CAAC;QAC1C,MAAME,QAAQ,GAAGe,IAAI,CAACC,KAAK,CAACT,IAAI,CAAC;QACjC,MAAM4B,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACrC,QAAQ,CAACsC,GAAG,CAAC,CAAC5B,MAAM;QAC9CwB,KAAK,IAAIC,KAAK;QACd,MAAMlE,KAAK,CAACe,KAAK,CAACC,QAAQ,CAACsC,8BAA8B,CAACvB,QAAQ,CAAC;QACnEtB,iBAAiB,CAAE,YAAWyD,KAAM,qBAAoBrC,IAAK,EAAC,CAAC;MACjE,CAAC,CAAC,OAAOM,KAAK,EAAE;QACdsB,MAAM,CAACa,IAAI,CAACnC,KAAK,CAAC;QAClB1B,iBAAiB,CAAE,oCAAmCoB,IAAK,EAAC,CAAC;QAC7DxB,YAAY,CAAC8B,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACA5B,eAAe,CACZ,sBAAqB0D,KAAM,qBAAoBL,KAAK,CAACnB,MAAO,WAC/D,CAAC;EACH,CAAC,CAAC,OAAON,KAAK,EAAE;IACdsB,MAAM,CAACa,IAAI,CAACnC,KAAK,CAAC;IAClB5B,eAAe,CAAE,2CAA0C,CAAC;IAC5DF,YAAY,CAAC8B,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAhC,YAAY,CACT,qEACH,CAAC;EACD,OAAO,CAAC,KAAKsD,MAAM,CAAChB,MAAM;AAC5B"}
|
|
1
|
+
{"version":3,"file":"AdminFederationOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","getAdminFederationProviders","exportAdminFederationProvider","exportAdminFederationProviders","importAdminFederationProvider","importAdminFederationProviders","importFirstAdminFederationProvider","cloud","adminFed","listAdminFederationProviders","outcome","providers","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","err","message","exportAdminFederationProviderToFile","providerId","file","fileName","fileData","exportAdminFederationProvidersToFile","error","_error$response","response","data","exportAdminFederationProvidersToFiles","allIdpsData","length","idpData","_error$response2","importAdminFederationProviderFromFile","readFileSync","JSON","parse","_error$response3","importFirstAdminFederationProviderFromFile","_error$response4","importAdminFederationProvidersFromFile","_error$response5","importAdminFederationProvidersFromFiles","errors","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","idp","push"],"sources":["ops/AdminFederationOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\n\nconst {\n getAdminFederationProviders,\n exportAdminFederationProvider,\n exportAdminFederationProviders,\n importAdminFederationProvider,\n importAdminFederationProviders,\n importFirstAdminFederationProvider,\n} = frodo.cloud.adminFed;\n\n/**\n * List providers\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listAdminFederationProviders(): Promise<boolean> {\n let outcome = false;\n try {\n const providers = await getAdminFederationProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n outcome = true;\n } catch (err) {\n printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProviderToFile(\n providerId: string,\n file = ''\n): Promise<boolean> {\n let outcome = false;\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'admin.federation');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await exportAdminFederationProvider(providerId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n outcome = true;\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFile(\n file = ''\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Exporting all providers...`);\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allProviders`, 'admin.federation');\n }\n const fileData = await exportAdminFederationProviders();\n saveJsonToFile(fileData, fileName);\n succeedSpinner(`Exported all providers to ${fileName}`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all providers.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers to individual files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFiles(): Promise<boolean> {\n let outcome = false;\n try {\n const allIdpsData = await getAdminFederationProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressBar(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'admin.federation');\n const fileData = await exportAdminFederationProvider(idpData._id);\n saveJsonToFile(fileData, fileName);\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all providers.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProvider(providerId, fileData);\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstAdminFederationProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`\n );\n showSpinner(`Importing first provider from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstAdminFederationProvider(fileData);\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`\n );\n showSpinner(`Importing providers from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProviders(fileData);\n succeedSpinner(`Imported providers from ${file}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`\n );\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.admin.federation.json')\n );\n createProgressBar(files.length, 'Importing providers...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importAdminFederationProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing provider(s) from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing provider(s) from file(s).`);\n printMessage(error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`\n );\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAE7E,MAAM;EACJC,2BAA2B;EAC3BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC;AACF,CAAC,GAAGjB,KAAK,CAACkB,KAAK,CAACC,QAAQ;;AAExB;AACA;AACA;AACA;AACA,OAAO,eAAeC,4BAA4BA,CAAA,EAAqB;EACrE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,SAAS,GAAG,MAAMV,2BAA2B,CAAC,CAAC;IACrDU,SAAS,CAACC,IAAI,CAAC,CAAC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AAK,EAAC,CAAC;QAC7D7B,YAAY,CAACiC,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACA/B,eAAe,CACZ,sBAAqB0D,KAAM,qBAAoBL,KAAK,CAAChB,MAAO,WAC/D,CAAC;EACH,CAAC,CAAC,OAAON,KAAK,EAAE;IACdmB,MAAM,CAACa,IAAI,CAAChC,KAAK,CAAC;IAClB/B,eAAe,CAAE,2CAA0C,CAAC;IAC5DF,YAAY,CAACiC,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAnC,YAAY,CACT,qEACH,CAAC;EACD,OAAO,CAAC,KAAKsD,MAAM,CAACb,MAAM;AAC5B"}
|
package/esm/ops/AgentOps.js
CHANGED
|
@@ -2,6 +2,32 @@ import { frodo, state } from '@rockcarver/frodo-lib';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { printMessage, createTable, debugMessage, showSpinner, succeedSpinner, failSpinner } from '../utils/Console';
|
|
4
4
|
import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
|
|
5
|
+
const {
|
|
6
|
+
getRealmName
|
|
7
|
+
} = frodo.helper.utils;
|
|
8
|
+
const {
|
|
9
|
+
createAgentExportTemplate,
|
|
10
|
+
getAgents,
|
|
11
|
+
getIdentityGatewayAgents,
|
|
12
|
+
getJavaAgents,
|
|
13
|
+
getWebAgents,
|
|
14
|
+
exportAgents,
|
|
15
|
+
exportIdentityGatewayAgents,
|
|
16
|
+
exportJavaAgents,
|
|
17
|
+
exportWebAgents,
|
|
18
|
+
exportAgent,
|
|
19
|
+
exportIdentityGatewayAgent,
|
|
20
|
+
exportJavaAgent,
|
|
21
|
+
exportWebAgent,
|
|
22
|
+
importAgent,
|
|
23
|
+
importIdentityGatewayAgent,
|
|
24
|
+
importJavaAgent,
|
|
25
|
+
importWebAgent,
|
|
26
|
+
importAgents,
|
|
27
|
+
importIdentityGatewayAgents,
|
|
28
|
+
importJavaAgents,
|
|
29
|
+
importWebAgents
|
|
30
|
+
} = frodo.agent;
|
|
5
31
|
const agentTypeToFileIdMap = {
|
|
6
32
|
IdentityGatewayAgent: 'gateway.agent',
|
|
7
33
|
J2EEAgent: 'java.agent',
|
|
@@ -13,7 +39,7 @@ const agentTypeToFileIdMap = {
|
|
|
13
39
|
*/
|
|
14
40
|
export async function listAgents(long = false) {
|
|
15
41
|
try {
|
|
16
|
-
const agents = await
|
|
42
|
+
const agents = await getAgents();
|
|
17
43
|
if (long) {
|
|
18
44
|
const table = createTable(['Agent Id', 'Status', 'Agent Type']);
|
|
19
45
|
for (const agent of agents) {
|
|
@@ -48,7 +74,7 @@ export async function listAgents(long = false) {
|
|
|
48
74
|
*/
|
|
49
75
|
export async function listIdentityGatewayAgents(long = false) {
|
|
50
76
|
try {
|
|
51
|
-
const agents = await
|
|
77
|
+
const agents = await getIdentityGatewayAgents();
|
|
52
78
|
if (long) {
|
|
53
79
|
const table = createTable(['Gateway Agent Id', 'Status']);
|
|
54
80
|
for (const agent of agents) {
|
|
@@ -71,7 +97,7 @@ export async function listIdentityGatewayAgents(long = false) {
|
|
|
71
97
|
*/
|
|
72
98
|
export async function listJavaAgents(long = false) {
|
|
73
99
|
try {
|
|
74
|
-
const agents = await
|
|
100
|
+
const agents = await getJavaAgents();
|
|
75
101
|
if (long) {
|
|
76
102
|
const table = createTable(['Java Agent Id', 'Status']);
|
|
77
103
|
for (const agent of agents) {
|
|
@@ -94,7 +120,7 @@ export async function listJavaAgents(long = false) {
|
|
|
94
120
|
*/
|
|
95
121
|
export async function listWebAgents(long = false) {
|
|
96
122
|
try {
|
|
97
|
-
const agents = await
|
|
123
|
+
const agents = await getWebAgents();
|
|
98
124
|
if (long) {
|
|
99
125
|
const table = createTable(['Web Agent Id', 'Status']);
|
|
100
126
|
for (const agent of agents) {
|
|
@@ -117,8 +143,8 @@ export async function listWebAgents(long = false) {
|
|
|
117
143
|
* @param {string} file file name
|
|
118
144
|
*/
|
|
119
145
|
export async function exportAgentsToFile(file) {
|
|
120
|
-
const exportData = await
|
|
121
|
-
let fileName = getTypedFilename(`all${titleCase(
|
|
146
|
+
const exportData = await exportAgents();
|
|
147
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, 'agent');
|
|
122
148
|
if (file) {
|
|
123
149
|
fileName = file;
|
|
124
150
|
}
|
|
@@ -130,8 +156,8 @@ export async function exportAgentsToFile(file) {
|
|
|
130
156
|
* @param {string} file file name
|
|
131
157
|
*/
|
|
132
158
|
export async function exportIdentityGatewayAgentsToFile(file) {
|
|
133
|
-
const exportData = await
|
|
134
|
-
let fileName = getTypedFilename(`all${titleCase(
|
|
159
|
+
const exportData = await exportIdentityGatewayAgents();
|
|
160
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, agentTypeToFileIdMap['IdentityGatewayAgent']);
|
|
135
161
|
if (file) {
|
|
136
162
|
fileName = file;
|
|
137
163
|
}
|
|
@@ -143,8 +169,8 @@ export async function exportIdentityGatewayAgentsToFile(file) {
|
|
|
143
169
|
* @param {string} file file name
|
|
144
170
|
*/
|
|
145
171
|
export async function exportJavaAgentsToFile(file) {
|
|
146
|
-
const exportData = await
|
|
147
|
-
let fileName = getTypedFilename(`all${titleCase(
|
|
172
|
+
const exportData = await exportJavaAgents();
|
|
173
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, agentTypeToFileIdMap['J2EEAgent']);
|
|
148
174
|
if (file) {
|
|
149
175
|
fileName = file;
|
|
150
176
|
}
|
|
@@ -156,8 +182,8 @@ export async function exportJavaAgentsToFile(file) {
|
|
|
156
182
|
* @param {string} file file name
|
|
157
183
|
*/
|
|
158
184
|
export async function exportWebAgentsToFile(file) {
|
|
159
|
-
const exportData = await
|
|
160
|
-
let fileName = getTypedFilename(`all${titleCase(
|
|
185
|
+
const exportData = await exportWebAgents();
|
|
186
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, agentTypeToFileIdMap['WebAgent']);
|
|
161
187
|
if (file) {
|
|
162
188
|
fileName = file;
|
|
163
189
|
}
|
|
@@ -170,7 +196,7 @@ export async function exportWebAgentsToFile(file) {
|
|
|
170
196
|
* @param {string} file file name
|
|
171
197
|
*/
|
|
172
198
|
export async function exportAgentToFile(agentId, file) {
|
|
173
|
-
const exportData = await
|
|
199
|
+
const exportData = await exportAgent(agentId);
|
|
174
200
|
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
175
201
|
if (file) {
|
|
176
202
|
fileName = file;
|
|
@@ -184,7 +210,7 @@ export async function exportAgentToFile(agentId, file) {
|
|
|
184
210
|
* @param {string} file file name
|
|
185
211
|
*/
|
|
186
212
|
export async function exportIdentityGatewayAgentToFile(agentId, file) {
|
|
187
|
-
const exportData = await
|
|
213
|
+
const exportData = await exportIdentityGatewayAgent(agentId);
|
|
188
214
|
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
189
215
|
if (file) {
|
|
190
216
|
fileName = file;
|
|
@@ -198,7 +224,7 @@ export async function exportIdentityGatewayAgentToFile(agentId, file) {
|
|
|
198
224
|
* @param {string} file file name
|
|
199
225
|
*/
|
|
200
226
|
export async function exportJavaAgentToFile(agentId, file) {
|
|
201
|
-
const exportData = await
|
|
227
|
+
const exportData = await exportJavaAgent(agentId);
|
|
202
228
|
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
203
229
|
if (file) {
|
|
204
230
|
fileName = file;
|
|
@@ -212,7 +238,7 @@ export async function exportJavaAgentToFile(agentId, file) {
|
|
|
212
238
|
* @param {string} file file name
|
|
213
239
|
*/
|
|
214
240
|
export async function exportWebAgentToFile(agentId, file) {
|
|
215
|
-
const exportData = await
|
|
241
|
+
const exportData = await exportWebAgent(agentId);
|
|
216
242
|
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
217
243
|
if (file) {
|
|
218
244
|
fileName = file;
|
|
@@ -224,11 +250,11 @@ export async function exportWebAgentToFile(agentId, file) {
|
|
|
224
250
|
* Export all agents to separate files
|
|
225
251
|
*/
|
|
226
252
|
export async function exportAgentsToFiles() {
|
|
227
|
-
const agents = await
|
|
253
|
+
const agents = await getAgents();
|
|
228
254
|
debugMessage(`exportAgentsToFiles: ${agents.length} agents`);
|
|
229
255
|
for (const agent of agents) {
|
|
230
256
|
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
231
|
-
const exportData =
|
|
257
|
+
const exportData = createAgentExportTemplate();
|
|
232
258
|
exportData.agents[agent._id] = agent;
|
|
233
259
|
debugMessage(`exportAgentsToFiles: exporting ${agent._id} to ${fileName}`);
|
|
234
260
|
saveJsonToFile(exportData, fileName);
|
|
@@ -240,10 +266,10 @@ export async function exportAgentsToFiles() {
|
|
|
240
266
|
* Export all identity gateway agents to separate files
|
|
241
267
|
*/
|
|
242
268
|
export async function exportIdentityGatewayAgentsToFiles() {
|
|
243
|
-
const agents = await
|
|
269
|
+
const agents = await getIdentityGatewayAgents();
|
|
244
270
|
for (const agent of agents) {
|
|
245
271
|
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
246
|
-
const exportData =
|
|
272
|
+
const exportData = createAgentExportTemplate();
|
|
247
273
|
exportData.agents[agent._id] = agent;
|
|
248
274
|
saveJsonToFile(exportData, fileName);
|
|
249
275
|
}
|
|
@@ -253,10 +279,10 @@ export async function exportIdentityGatewayAgentsToFiles() {
|
|
|
253
279
|
* Export all java agents to separate files
|
|
254
280
|
*/
|
|
255
281
|
export async function exportJavaAgentsToFiles() {
|
|
256
|
-
const agents = await
|
|
282
|
+
const agents = await getJavaAgents();
|
|
257
283
|
for (const agent of agents) {
|
|
258
284
|
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
259
|
-
const exportData =
|
|
285
|
+
const exportData = createAgentExportTemplate();
|
|
260
286
|
exportData.agents[agent._id] = agent;
|
|
261
287
|
saveJsonToFile(exportData, fileName);
|
|
262
288
|
}
|
|
@@ -266,10 +292,10 @@ export async function exportJavaAgentsToFiles() {
|
|
|
266
292
|
* Export all web agents to separate files
|
|
267
293
|
*/
|
|
268
294
|
export async function exportWebAgentsToFiles() {
|
|
269
|
-
const agents = await
|
|
295
|
+
const agents = await getWebAgents();
|
|
270
296
|
for (const agent of agents) {
|
|
271
297
|
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
272
|
-
const exportData =
|
|
298
|
+
const exportData = createAgentExportTemplate();
|
|
273
299
|
exportData.agents[agent._id] = agent;
|
|
274
300
|
saveJsonToFile(exportData, fileName);
|
|
275
301
|
}
|
|
@@ -296,7 +322,7 @@ export async function importAgentFromFile(agentId, file) {
|
|
|
296
322
|
if (!verbose) showSpinner(`Importing ${agentId}...`);
|
|
297
323
|
try {
|
|
298
324
|
if (verbose) showSpinner(`Importing ${agentId}...`);
|
|
299
|
-
await
|
|
325
|
+
await importAgent(agentId, importData);
|
|
300
326
|
succeedSpinner(`Imported ${agentId}.`);
|
|
301
327
|
} catch (importError) {
|
|
302
328
|
if (verbose) showSpinner(`Importing ${agentId}...`);
|
|
@@ -323,7 +349,7 @@ export async function importFirstAgentFromFile(file) {
|
|
|
323
349
|
if (!verbose) showSpinner(`Importing ${agent['_id']}...`);
|
|
324
350
|
try {
|
|
325
351
|
if (verbose) showSpinner(`Importing ${agent['_id']}...`);
|
|
326
|
-
await
|
|
352
|
+
await importAgent(agent['_id'], importData);
|
|
327
353
|
succeedSpinner(`Imported ${agent['_id']}.`);
|
|
328
354
|
} catch (importError) {
|
|
329
355
|
if (verbose) showSpinner(`Importing ${agent['_id']}...`);
|
|
@@ -349,7 +375,7 @@ export async function importAgentsFromFile(file) {
|
|
|
349
375
|
debugMessage(`importAgentsFromFile: importing ${file}`);
|
|
350
376
|
const importData = JSON.parse(data);
|
|
351
377
|
try {
|
|
352
|
-
await
|
|
378
|
+
await importAgents(importData);
|
|
353
379
|
} catch (error) {
|
|
354
380
|
printMessage(`${error.message}`, 'error');
|
|
355
381
|
printMessage(error.response.status, 'error');
|
|
@@ -391,7 +417,7 @@ export async function importIdentityGatewayAgentFromFile(agentId, file) {
|
|
|
391
417
|
if (!verbose) showSpinner(`Importing ${agentId}...`);
|
|
392
418
|
try {
|
|
393
419
|
if (verbose) showSpinner(`Importing ${agentId}...`);
|
|
394
|
-
await
|
|
420
|
+
await importIdentityGatewayAgent(agentId, importData);
|
|
395
421
|
succeedSpinner(`Imported ${agentId}.`);
|
|
396
422
|
} catch (importError) {
|
|
397
423
|
failSpinner(`${importError}`);
|
|
@@ -419,7 +445,7 @@ export async function importFirstIdentityGatewayAgentFromFile(file) {
|
|
|
419
445
|
if (!verbose) showSpinner(`Importing ${agent['_id']}...`);
|
|
420
446
|
try {
|
|
421
447
|
if (verbose) showSpinner(`Importing ${agent['_id']}...`);
|
|
422
|
-
await
|
|
448
|
+
await importIdentityGatewayAgent(agent['_id'], importData);
|
|
423
449
|
succeedSpinner(`Imported ${agent['_id']}.`);
|
|
424
450
|
} catch (importError) {
|
|
425
451
|
failSpinner(`${importError}`);
|
|
@@ -445,7 +471,7 @@ export async function importIdentityGatewayAgentsFromFile(file) {
|
|
|
445
471
|
debugMessage(`cli.AgentOps.importIdentityGatewayAgentsFromFile: importing ${file}`);
|
|
446
472
|
const importData = JSON.parse(data);
|
|
447
473
|
try {
|
|
448
|
-
await
|
|
474
|
+
await importIdentityGatewayAgents(importData);
|
|
449
475
|
} catch (error) {
|
|
450
476
|
printMessage(`${error.message}`, 'error');
|
|
451
477
|
printMessage(error.response.status, 'error');
|
|
@@ -489,7 +515,7 @@ export async function importJavaAgentFromFile(agentId, file) {
|
|
|
489
515
|
if (!verbose) showSpinner(`Importing ${agentId}...`);
|
|
490
516
|
try {
|
|
491
517
|
if (verbose) showSpinner(`Importing ${agentId}...`);
|
|
492
|
-
await
|
|
518
|
+
await importJavaAgent(agentId, importData);
|
|
493
519
|
succeedSpinner(`Imported ${agentId}.`);
|
|
494
520
|
} catch (importError) {
|
|
495
521
|
failSpinner(`${importError}`);
|
|
@@ -517,7 +543,7 @@ export async function importFirstJavaAgentFromFile(file) {
|
|
|
517
543
|
if (!verbose) showSpinner(`Importing ${agent['_id']}...`);
|
|
518
544
|
try {
|
|
519
545
|
if (verbose) showSpinner(`Importing ${agent['_id']}...`);
|
|
520
|
-
await
|
|
546
|
+
await importJavaAgent(agent['_id'], importData);
|
|
521
547
|
succeedSpinner(`Imported ${agent['_id']}.`);
|
|
522
548
|
} catch (importError) {
|
|
523
549
|
failSpinner(`${importError}`);
|
|
@@ -543,7 +569,7 @@ export async function importJavaAgentsFromFile(file) {
|
|
|
543
569
|
debugMessage(`cli.AgentOps.importJavaAgentsFromFile: importing ${file}`);
|
|
544
570
|
const importData = JSON.parse(data);
|
|
545
571
|
try {
|
|
546
|
-
await
|
|
572
|
+
await importJavaAgents(importData);
|
|
547
573
|
} catch (error) {
|
|
548
574
|
printMessage(`${error.message}`, 'error');
|
|
549
575
|
printMessage(error.response.status, 'error');
|
|
@@ -587,7 +613,7 @@ export async function importWebAgentFromFile(agentId, file) {
|
|
|
587
613
|
if (!verbose) showSpinner(`Importing ${agentId}...`);
|
|
588
614
|
try {
|
|
589
615
|
if (verbose) showSpinner(`Importing ${agentId}...`);
|
|
590
|
-
await
|
|
616
|
+
await importWebAgent(agentId, importData);
|
|
591
617
|
succeedSpinner(`Imported ${agentId}.`);
|
|
592
618
|
} catch (importError) {
|
|
593
619
|
failSpinner(`${importError}`);
|
|
@@ -615,7 +641,7 @@ export async function importFirstWebAgentFromFile(file) {
|
|
|
615
641
|
if (!verbose) showSpinner(`Importing ${agent['_id']}...`);
|
|
616
642
|
try {
|
|
617
643
|
if (verbose) showSpinner(`Importing ${agent['_id']}...`);
|
|
618
|
-
await
|
|
644
|
+
await importWebAgent(agent['_id'], importData);
|
|
619
645
|
succeedSpinner(`Imported ${agent['_id']}.`);
|
|
620
646
|
} catch (importError) {
|
|
621
647
|
failSpinner(`caught it here ${importError}`);
|
|
@@ -641,7 +667,7 @@ export async function importWebAgentsFromFile(file) {
|
|
|
641
667
|
debugMessage(`cli.AgentOps.importWebAgentsFromFile: importing ${file}`);
|
|
642
668
|
const importData = JSON.parse(data);
|
|
643
669
|
try {
|
|
644
|
-
await
|
|
670
|
+
await importWebAgents(importData);
|
|
645
671
|
} catch (error) {
|
|
646
672
|
printMessage(`${error.message}`, 'error');
|
|
647
673
|
printMessage(error.response.status, 'error');
|