@rockcarver/frodo-cli 0.18.2-8 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +119 -1
- package/esm/app.js +4 -1
- package/esm/app.js.map +1 -1
- package/esm/cli/FrodoCommand.js +133 -0
- package/esm/cli/FrodoCommand.js.map +1 -0
- package/esm/cli/_template/something-delete.js +9 -15
- package/esm/cli/_template/something-delete.js.map +1 -1
- package/esm/cli/_template/something-describe.js +9 -15
- package/esm/cli/_template/something-describe.js.map +1 -1
- package/esm/cli/_template/something-else-delete.js +9 -15
- package/esm/cli/_template/something-else-delete.js.map +1 -1
- package/esm/cli/_template/something-else-describe.js +9 -15
- package/esm/cli/_template/something-else-describe.js.map +1 -1
- package/esm/cli/_template/something-else-export.js +9 -15
- package/esm/cli/_template/something-else-export.js.map +1 -1
- package/esm/cli/_template/something-else-import.js +9 -15
- package/esm/cli/_template/something-else-import.js.map +1 -1
- package/esm/cli/_template/something-else-list.js +9 -15
- package/esm/cli/_template/something-else-list.js.map +1 -1
- package/esm/cli/_template/something-else.js +8 -8
- package/esm/cli/_template/something-else.js.map +1 -1
- package/esm/cli/_template/something-export.js +9 -15
- package/esm/cli/_template/something-export.js.map +1 -1
- package/esm/cli/_template/something-import.js +9 -15
- package/esm/cli/_template/something-import.js.map +1 -1
- package/esm/cli/_template/something-list.js +9 -15
- package/esm/cli/_template/something-list.js.map +1 -1
- package/esm/cli/_template/something-other-delete.js +9 -15
- package/esm/cli/_template/something-other-delete.js.map +1 -1
- package/esm/cli/_template/something-other-describe.js +9 -15
- package/esm/cli/_template/something-other-describe.js.map +1 -1
- package/esm/cli/_template/something-other-export.js +9 -15
- package/esm/cli/_template/something-other-export.js.map +1 -1
- package/esm/cli/_template/something-other-import.js +9 -15
- package/esm/cli/_template/something-other-import.js.map +1 -1
- package/esm/cli/_template/something-other-list.js +9 -15
- package/esm/cli/_template/something-other-list.js.map +1 -1
- package/esm/cli/_template/something-other.js +8 -8
- package/esm/cli/_template/something-other.js.map +1 -1
- package/esm/cli/_template/something.js +9 -10
- package/esm/cli/_template/something.js.map +1 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +8 -15
- 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 +9 -15
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-get-access-token.js +9 -15
- package/esm/cli/admin/admin-get-access-token.js.map +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +9 -15
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js +9 -15
- 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 -15
- 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 -15
- 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 +9 -15
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js +8 -15
- package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-repair-org-model.js +9 -15
- package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +9 -15
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js +9 -15
- package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
- package/esm/cli/admin/admin.js +14 -15
- package/esm/cli/admin/admin.js.map +1 -1
- package/esm/cli/agent/agent-delete.js +8 -15
- package/esm/cli/agent/agent-delete.js.map +1 -1
- package/esm/cli/agent/agent-describe.js +9 -15
- package/esm/cli/agent/agent-describe.js.map +1 -1
- package/esm/cli/agent/agent-export.js +8 -15
- package/esm/cli/agent/agent-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-delete.js +8 -15
- package/esm/cli/agent/agent-gateway-delete.js.map +1 -1
- package/esm/cli/agent/agent-gateway-describe.js +9 -15
- package/esm/cli/agent/agent-gateway-describe.js.map +1 -1
- package/esm/cli/agent/agent-gateway-export.js +8 -15
- package/esm/cli/agent/agent-gateway-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-import.js +8 -15
- package/esm/cli/agent/agent-gateway-import.js.map +1 -1
- package/esm/cli/agent/agent-gateway-list.js +9 -15
- package/esm/cli/agent/agent-gateway-list.js.map +1 -1
- package/esm/cli/agent/agent-gateway.js +8 -8
- package/esm/cli/agent/agent-gateway.js.map +1 -1
- package/esm/cli/agent/agent-import.js +8 -15
- package/esm/cli/agent/agent-import.js.map +1 -1
- package/esm/cli/agent/agent-java-delete.js +8 -15
- package/esm/cli/agent/agent-java-delete.js.map +1 -1
- package/esm/cli/agent/agent-java-describe.js +9 -15
- package/esm/cli/agent/agent-java-describe.js.map +1 -1
- package/esm/cli/agent/agent-java-export.js +8 -15
- package/esm/cli/agent/agent-java-export.js.map +1 -1
- package/esm/cli/agent/agent-java-import.js +8 -15
- package/esm/cli/agent/agent-java-import.js.map +1 -1
- package/esm/cli/agent/agent-java-list.js +9 -15
- package/esm/cli/agent/agent-java-list.js.map +1 -1
- package/esm/cli/agent/agent-java.js +8 -8
- package/esm/cli/agent/agent-java.js.map +1 -1
- package/esm/cli/agent/agent-list.js +9 -15
- package/esm/cli/agent/agent-list.js.map +1 -1
- package/esm/cli/agent/agent-web-delete.js +8 -15
- package/esm/cli/agent/agent-web-delete.js.map +1 -1
- package/esm/cli/agent/agent-web-describe.js +9 -15
- package/esm/cli/agent/agent-web-describe.js.map +1 -1
- package/esm/cli/agent/agent-web-export.js +8 -15
- package/esm/cli/agent/agent-web-export.js.map +1 -1
- package/esm/cli/agent/agent-web-import.js +8 -15
- package/esm/cli/agent/agent-web-import.js.map +1 -1
- package/esm/cli/agent/agent-web-list.js +9 -15
- package/esm/cli/agent/agent-web-list.js.map +1 -1
- package/esm/cli/agent/agent-web.js +8 -8
- package/esm/cli/agent/agent-web.js.map +1 -1
- package/esm/cli/agent/agent.js +10 -11
- package/esm/cli/agent/agent.js.map +1 -1
- package/esm/cli/app/app-delete.js +9 -12
- package/esm/cli/app/app-delete.js.map +1 -1
- package/esm/cli/app/app-describe.js +9 -12
- package/esm/cli/app/app-describe.js.map +1 -1
- package/esm/cli/app/app-export.js +28 -34
- package/esm/cli/app/app-export.js.map +1 -1
- package/esm/cli/app/app-import.js +11 -14
- package/esm/cli/app/app-import.js.map +1 -1
- package/esm/cli/app/app-list.js +11 -14
- package/esm/cli/app/app-list.js.map +1 -1
- package/esm/cli/app/app.js +8 -10
- package/esm/cli/app/app.js.map +1 -1
- package/esm/cli/conn/conn-delete.js +5 -5
- package/esm/cli/conn/conn-delete.js.map +1 -1
- package/esm/cli/conn/conn-describe.js +6 -5
- package/esm/cli/conn/conn-describe.js.map +1 -1
- package/esm/cli/conn/conn-list.js +6 -8
- package/esm/cli/conn/conn-list.js.map +1 -1
- package/esm/cli/conn/conn-save.js +72 -0
- package/esm/cli/conn/conn-save.js.map +1 -0
- package/esm/cli/conn/conn.js +10 -8
- package/esm/cli/conn/conn.js.map +1 -1
- package/esm/cli/email/email-template-export.js +29 -39
- package/esm/cli/email/email-template-export.js.map +1 -1
- package/esm/cli/email/email-template-import.js +34 -45
- package/esm/cli/email/email-template-import.js.map +1 -1
- package/esm/cli/email/email-template-list.js +12 -17
- package/esm/cli/email/email-template-list.js.map +1 -1
- package/esm/cli/email/email-template.js +6 -6
- package/esm/cli/email/email-template.js.map +1 -1
- package/esm/cli/email/email.js +2 -2
- package/esm/cli/email/email.js.map +1 -1
- package/esm/cli/esv/esv-apply.js +9 -12
- package/esm/cli/esv/esv-apply.js.map +1 -1
- package/esm/cli/esv/esv-secret-create.js +11 -14
- package/esm/cli/esv/esv-secret-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-delete.js +23 -29
- package/esm/cli/esv/esv-secret-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-describe.js +11 -14
- package/esm/cli/esv/esv-secret-describe.js.map +1 -1
- package/esm/cli/esv/esv-secret-export.js +9 -12
- package/esm/cli/esv/esv-secret-export.js.map +1 -1
- package/esm/cli/esv/esv-secret-import.js +9 -12
- package/esm/cli/esv/esv-secret-import.js.map +1 -1
- package/esm/cli/esv/esv-secret-list.js +11 -14
- package/esm/cli/esv/esv-secret-list.js.map +1 -1
- package/esm/cli/esv/esv-secret-set.js +11 -14
- package/esm/cli/esv/esv-secret-set.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-activate.js +18 -24
- package/esm/cli/esv/esv-secret-version-activate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-create.js +11 -14
- package/esm/cli/esv/esv-secret-version-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js +18 -24
- package/esm/cli/esv/esv-secret-version-deactivate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-delete.js +23 -29
- package/esm/cli/esv/esv-secret-version-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-list.js +11 -14
- package/esm/cli/esv/esv-secret-version-list.js.map +1 -1
- package/esm/cli/esv/esv-secret-version.js +8 -8
- package/esm/cli/esv/esv-secret-version.js.map +1 -1
- package/esm/cli/esv/esv-secret.js +11 -11
- package/esm/cli/esv/esv-secret.js.map +1 -1
- package/esm/cli/esv/esv-variable-create.js +10 -14
- package/esm/cli/esv/esv-variable-create.js.map +1 -1
- package/esm/cli/esv/esv-variable-delete.js +23 -29
- package/esm/cli/esv/esv-variable-delete.js.map +1 -1
- package/esm/cli/esv/esv-variable-describe.js +11 -14
- package/esm/cli/esv/esv-variable-describe.js.map +1 -1
- package/esm/cli/esv/esv-variable-export.js +9 -12
- package/esm/cli/esv/esv-variable-export.js.map +1 -1
- package/esm/cli/esv/esv-variable-import.js +9 -12
- package/esm/cli/esv/esv-variable-import.js.map +1 -1
- package/esm/cli/esv/esv-variable-list.js +11 -14
- package/esm/cli/esv/esv-variable-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-set.js +19 -26
- package/esm/cli/esv/esv-variable-set.js.map +1 -1
- package/esm/cli/esv/esv-variable.js +10 -10
- package/esm/cli/esv/esv-variable.js.map +1 -1
- package/esm/cli/esv/esv.js +5 -6
- package/esm/cli/esv/esv.js.map +1 -1
- package/esm/cli/idm/idm-count.js +12 -17
- package/esm/cli/idm/idm-count.js.map +1 -1
- package/esm/cli/idm/idm-export.js +29 -39
- package/esm/cli/idm/idm-export.js.map +1 -1
- package/esm/cli/idm/idm-import.js +29 -39
- package/esm/cli/idm/idm-import.js.map +1 -1
- package/esm/cli/idm/idm-list.js +11 -17
- package/esm/cli/idm/idm-list.js.map +1 -1
- package/esm/cli/idm/idm.js +6 -9
- package/esm/cli/idm/idm.js.map +1 -1
- package/esm/cli/idp/idp-export.js +11 -15
- package/esm/cli/idp/idp-export.js.map +1 -1
- package/esm/cli/idp/idp-import.js +32 -38
- package/esm/cli/idp/idp-import.js.map +1 -1
- package/esm/cli/idp/idp-list.js +9 -13
- package/esm/cli/idp/idp-list.js.map +1 -1
- package/esm/cli/idp/idp.js +5 -6
- package/esm/cli/idp/idp.js.map +1 -1
- package/esm/cli/info/info.js +19 -20
- package/esm/cli/info/info.js.map +1 -1
- package/esm/cli/journey/journey-delete.js +22 -28
- package/esm/cli/journey/journey-delete.js.map +1 -1
- package/esm/cli/journey/journey-describe.js +12 -19
- package/esm/cli/journey/journey-describe.js.map +1 -1
- package/esm/cli/journey/journey-disable.js +20 -26
- package/esm/cli/journey/journey-disable.js.map +1 -1
- package/esm/cli/journey/journey-enable.js +20 -26
- package/esm/cli/journey/journey-enable.js.map +1 -1
- package/esm/cli/journey/journey-export.js +37 -45
- package/esm/cli/journey/journey-export.js.map +1 -1
- package/esm/cli/journey/journey-import.js +44 -52
- package/esm/cli/journey/journey-import.js.map +1 -1
- package/esm/cli/journey/journey-list.js +10 -13
- package/esm/cli/journey/journey-list.js.map +1 -1
- package/esm/cli/journey/journey-prune.js +9 -13
- package/esm/cli/journey/journey-prune.js.map +1 -1
- package/esm/cli/journey/journey.js +10 -11
- package/esm/cli/journey/journey.js.map +1 -1
- package/esm/cli/logging/logs-fetch.js +17 -19
- package/esm/cli/logging/logs-fetch.js.map +1 -1
- package/esm/cli/logging/logs-list.js +19 -25
- package/esm/cli/logging/logs-list.js.map +1 -1
- package/esm/cli/logging/logs-tail.js +17 -19
- package/esm/cli/logging/logs-tail.js.map +1 -1
- package/esm/cli/logging/logs.js +7 -6
- package/esm/cli/logging/logs.js.map +1 -1
- package/esm/cli/realm/realm-add-custom-domain.js +11 -14
- package/esm/cli/realm/realm-add-custom-domain.js.map +1 -1
- package/esm/cli/realm/realm-describe.js +10 -14
- package/esm/cli/realm/realm-describe.js.map +1 -1
- package/esm/cli/realm/realm-list.js +11 -14
- package/esm/cli/realm/realm-list.js.map +1 -1
- package/esm/cli/realm/realm-remove-custom-domain.js +11 -14
- package/esm/cli/realm/realm-remove-custom-domain.js.map +1 -1
- package/esm/cli/realm/realm.js +7 -8
- package/esm/cli/realm/realm.js.map +1 -1
- package/esm/cli/saml/saml-cot-export.js +27 -36
- package/esm/cli/saml/saml-cot-export.js.map +1 -1
- package/esm/cli/saml/saml-cot-import.js +32 -41
- package/esm/cli/saml/saml-cot-import.js.map +1 -1
- package/esm/cli/saml/saml-cot-list.js +10 -16
- package/esm/cli/saml/saml-cot-list.js.map +1 -1
- package/esm/cli/saml/saml-cot.js +6 -6
- package/esm/cli/saml/saml-cot.js.map +1 -1
- package/esm/cli/saml/saml-delete.js +8 -15
- package/esm/cli/saml/saml-delete.js.map +1 -1
- package/esm/cli/saml/saml-describe.js +10 -16
- package/esm/cli/saml/saml-describe.js.map +1 -1
- package/esm/cli/saml/saml-export.js +9 -16
- package/esm/cli/saml/saml-export.js.map +1 -1
- package/esm/cli/saml/saml-import.js +45 -54
- package/esm/cli/saml/saml-import.js.map +1 -1
- package/esm/cli/saml/saml-list.js +11 -17
- package/esm/cli/saml/saml-list.js.map +1 -1
- package/esm/cli/saml/saml-metadata-export.js +21 -30
- package/esm/cli/saml/saml-metadata-export.js.map +1 -1
- package/esm/cli/saml/saml-metadata.js +4 -4
- package/esm/cli/saml/saml-metadata.js.map +1 -1
- package/esm/cli/saml/saml.js +9 -10
- package/esm/cli/saml/saml.js.map +1 -1
- package/esm/cli/script/script-delete.js +9 -12
- package/esm/cli/script/script-delete.js.map +1 -1
- package/esm/cli/script/script-describe.js +9 -12
- package/esm/cli/script/script-describe.js.map +1 -1
- package/esm/cli/script/script-export.js +28 -34
- package/esm/cli/script/script-export.js.map +1 -1
- package/esm/cli/script/script-import.js +10 -13
- package/esm/cli/script/script-import.js.map +1 -1
- package/esm/cli/script/script-list.js +10 -13
- package/esm/cli/script/script-list.js.map +1 -1
- package/esm/cli/script/script.js +7 -8
- package/esm/cli/script/script.js.map +1 -1
- package/esm/cli/service/service-delete.js +10 -16
- package/esm/cli/service/service-delete.js.map +1 -1
- package/esm/cli/service/service-export.js +12 -17
- package/esm/cli/service/service-export.js.map +1 -1
- package/esm/cli/service/service-import.js +12 -18
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/cli/service/service-list.js +9 -15
- package/esm/cli/service/service-list.js.map +1 -1
- package/esm/cli/service/service.js +6 -7
- package/esm/cli/service/service.js.map +1 -1
- package/esm/cli/theme/theme-delete.js +15 -26
- package/esm/cli/theme/theme-delete.js.map +1 -1
- package/esm/cli/theme/theme-export.js +14 -26
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/cli/theme/theme-import.js +16 -29
- package/esm/cli/theme/theme-import.js.map +1 -1
- package/esm/cli/theme/theme-list.js +12 -20
- package/esm/cli/theme/theme-list.js.map +1 -1
- package/esm/cli/theme/theme.js +6 -7
- package/esm/cli/theme/theme.js.map +1 -1
- package/esm/ops/ConnectionProfileOps.js +30 -0
- package/esm/ops/ConnectionProfileOps.js.map +1 -0
- package/esm/ops/EmailTemplateOps.js +267 -2
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +317 -0
- package/esm/ops/IdmOps.js.map +1 -0
- package/esm/ops/JourneyOps.js +2 -1
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/ServiceOps.js +20 -20
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +329 -0
- package/esm/ops/ThemeOps.js.map +1 -1
- package/esm/utils/Console.js +15 -25
- package/esm/utils/Console.js.map +1 -1
- package/esm/utils/ExportImportUtils.js +46 -0
- package/esm/utils/ExportImportUtils.js.map +1 -0
- package/package.json +6 -5
- package/esm/cli/cmd_common.js +0 -79
- package/esm/cli/cmd_common.js.map +0 -1
- package/esm/cli/conn/conn-add.js +0 -37
- package/esm/cli/conn/conn-add.js.map +0 -1
- package/esm/cli/journey/journey-delete.e2e.test_.js.map +0 -1
- package/esm/cli/journey/journey-list.e2e.test_.js.map +0 -1
package/esm/ops/ThemeOps.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { Theme, ExportImportUtils } from '@rockcarver/frodo-lib';
|
|
3
|
+
import { printMessage, createTable, createProgressIndicator, updateProgressIndicator, stopProgressIndicator } from '../utils/Console';
|
|
4
|
+
import { saveToFile, getTypedFilename } from '../utils/ExportImportUtils';
|
|
5
|
+
const {
|
|
6
|
+
getTheme,
|
|
7
|
+
getThemes,
|
|
8
|
+
getThemeByName,
|
|
9
|
+
putThemeByName,
|
|
10
|
+
putTheme,
|
|
11
|
+
putThemes,
|
|
12
|
+
deleteTheme,
|
|
13
|
+
deleteThemeByName,
|
|
14
|
+
deleteThemes
|
|
15
|
+
} = Theme;
|
|
16
|
+
const {
|
|
17
|
+
getRealmString,
|
|
18
|
+
validateImport
|
|
19
|
+
} = ExportImportUtils;
|
|
1
20
|
/**
|
|
2
21
|
* Get a one-line description of the theme
|
|
3
22
|
* @param {ThemeSkeleton} themeObj theme object to describe
|
|
@@ -28,4 +47,314 @@ export function getTableRowMd(themeObj) {
|
|
|
28
47
|
const row = `| ${themeObj.name} | ${themeObj.linkedTrees ? themeObj.linkedTrees.join(', ') : ''} | \`${themeObj._id}\` |`;
|
|
29
48
|
return row;
|
|
30
49
|
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* List all the themes
|
|
53
|
+
* @param {boolean} long Long version, more fields
|
|
54
|
+
*/
|
|
55
|
+
export async function listThemes(long = false) {
|
|
56
|
+
const themeList = await getThemes();
|
|
57
|
+
themeList.sort((a, b) => a.name.localeCompare(b.name));
|
|
58
|
+
if (!long) {
|
|
59
|
+
themeList.forEach(theme => {
|
|
60
|
+
printMessage(`${theme.isDefault ? theme.name['brightCyan'] : theme.name}`, 'data');
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
const table = createTable(['Name'['brightCyan'], 'Id'['brightCyan'], 'Default'['brightCyan']]);
|
|
64
|
+
themeList.forEach(theme => {
|
|
65
|
+
table.push([`${theme.name}`, `${theme._id}`, `${theme.isDefault ? 'Yes'['brightGreen'] : ''}`]);
|
|
66
|
+
});
|
|
67
|
+
printMessage(table.toString(), 'data');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Export theme by name to file
|
|
73
|
+
* @param {String} name theme name
|
|
74
|
+
* @param {String} file optional export file name
|
|
75
|
+
*/
|
|
76
|
+
export async function exportThemeByName(name, file) {
|
|
77
|
+
let fileName = getTypedFilename(name, 'theme');
|
|
78
|
+
if (file) {
|
|
79
|
+
fileName = file;
|
|
80
|
+
}
|
|
81
|
+
createProgressIndicator('determinate', 1, `Exporting ${name}`);
|
|
82
|
+
try {
|
|
83
|
+
const themeData = await getThemeByName(name);
|
|
84
|
+
updateProgressIndicator(`Writing file ${fileName}`);
|
|
85
|
+
saveToFile('theme', [themeData], '_id', fileName);
|
|
86
|
+
stopProgressIndicator(`Successfully exported theme ${name}.`);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
stopProgressIndicator(`${error.message}`);
|
|
89
|
+
printMessage(`${error.message}`, 'error');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Export theme by uuid to file
|
|
95
|
+
* @param {String} id theme uuid
|
|
96
|
+
* @param {String} file optional export file name
|
|
97
|
+
*/
|
|
98
|
+
export async function exportThemeById(id, file) {
|
|
99
|
+
let fileName = getTypedFilename(id, 'theme');
|
|
100
|
+
if (file) {
|
|
101
|
+
fileName = file;
|
|
102
|
+
}
|
|
103
|
+
createProgressIndicator('determinate', 1, `Exporting ${id}`);
|
|
104
|
+
try {
|
|
105
|
+
const themeData = await getTheme(id);
|
|
106
|
+
updateProgressIndicator(`Writing file ${fileName}`);
|
|
107
|
+
saveToFile('theme', [themeData], '_id', fileName);
|
|
108
|
+
stopProgressIndicator(`Successfully exported theme ${id}.`);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
stopProgressIndicator(`${error.message}`);
|
|
111
|
+
printMessage(`${error.message}`, 'error');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Export all themes to file
|
|
117
|
+
* @param {String} file optional export file name
|
|
118
|
+
*/
|
|
119
|
+
export async function exportThemesToFile(file) {
|
|
120
|
+
let fileName = getTypedFilename(`all${getRealmString()}Themes`, 'theme');
|
|
121
|
+
if (file) {
|
|
122
|
+
fileName = file;
|
|
123
|
+
}
|
|
124
|
+
const allThemesData = await getThemes();
|
|
125
|
+
createProgressIndicator('determinate', allThemesData.length, 'Exporting themes');
|
|
126
|
+
for (const themeData of allThemesData) {
|
|
127
|
+
updateProgressIndicator(`Exporting theme ${themeData.name}`);
|
|
128
|
+
}
|
|
129
|
+
saveToFile('theme', allThemesData, '_id', fileName);
|
|
130
|
+
stopProgressIndicator(`${allThemesData.length} themes exported to ${fileName}.`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Export all themes to separate files
|
|
135
|
+
*/
|
|
136
|
+
export async function exportThemesToFiles() {
|
|
137
|
+
const allThemesData = await getThemes();
|
|
138
|
+
createProgressIndicator('determinate', allThemesData.length, 'Exporting themes');
|
|
139
|
+
for (const themeData of allThemesData) {
|
|
140
|
+
updateProgressIndicator(`Writing theme ${themeData.name}`);
|
|
141
|
+
const fileName = getTypedFilename(themeData.name, 'theme');
|
|
142
|
+
saveToFile('theme', themeData, '_id', fileName);
|
|
143
|
+
}
|
|
144
|
+
stopProgressIndicator(`${allThemesData.length} themes exported.`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Import theme by name from file
|
|
149
|
+
* @param {String} name theme name
|
|
150
|
+
* @param {String} file import file name
|
|
151
|
+
*/
|
|
152
|
+
export async function importThemeByName(name, file) {
|
|
153
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
154
|
+
if (err) throw err;
|
|
155
|
+
const themeData = JSON.parse(data);
|
|
156
|
+
if (validateImport(themeData.meta)) {
|
|
157
|
+
createProgressIndicator('determinate', 1, 'Importing theme...');
|
|
158
|
+
let found = false;
|
|
159
|
+
for (const id in themeData.theme) {
|
|
160
|
+
if ({}.hasOwnProperty.call(themeData.theme, id)) {
|
|
161
|
+
if (themeData.theme[id].name === name) {
|
|
162
|
+
found = true;
|
|
163
|
+
updateProgressIndicator(`Importing ${themeData.theme[id].name}`);
|
|
164
|
+
try {
|
|
165
|
+
await putThemeByName(name, themeData.theme[id]);
|
|
166
|
+
stopProgressIndicator(`Successfully imported theme ${name}.`);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
stopProgressIndicator(`Error importing theme ${themeData.theme[id].name}: ${error.message}`);
|
|
169
|
+
printMessage(`Error importing theme ${themeData.theme[id].name}: ${error.message}`, 'error');
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (!found) {
|
|
176
|
+
stopProgressIndicator(`Theme ${name} not found!`);
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
printMessage('Import validation failed...', 'error');
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Import theme by uuid from file
|
|
186
|
+
* @param {String} id theme uuid
|
|
187
|
+
* @param {String} file import file name
|
|
188
|
+
*/
|
|
189
|
+
export async function importThemeById(id, file) {
|
|
190
|
+
fs.readFile(file, 'utf8', async (err, data) => {
|
|
191
|
+
if (err) throw err;
|
|
192
|
+
const themeData = JSON.parse(data);
|
|
193
|
+
if (validateImport(themeData.meta)) {
|
|
194
|
+
createProgressIndicator('determinate', 1, 'Importing theme...');
|
|
195
|
+
let found = false;
|
|
196
|
+
for (const themeId in themeData.theme) {
|
|
197
|
+
if ({}.hasOwnProperty.call(themeData.theme, themeId)) {
|
|
198
|
+
if (themeId === id) {
|
|
199
|
+
found = true;
|
|
200
|
+
updateProgressIndicator(`Importing ${themeData.theme[themeId]._id}`);
|
|
201
|
+
try {
|
|
202
|
+
await putTheme(themeId, themeData.theme[themeId]);
|
|
203
|
+
stopProgressIndicator(`Successfully imported theme ${id}.`);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
stopProgressIndicator(`Error importing theme ${themeData.theme[themeId]._id}: ${error.message}`);
|
|
206
|
+
printMessage(`Error importing theme ${themeData.theme[themeId]._id}: ${error.message}`, 'error');
|
|
207
|
+
}
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (!found) {
|
|
213
|
+
stopProgressIndicator(`Theme ${id} not found!`);
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
printMessage('Import validation failed...', 'error');
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Import all themes from single file
|
|
223
|
+
* @param {String} file import file name
|
|
224
|
+
*/
|
|
225
|
+
export async function importThemesFromFile(file) {
|
|
226
|
+
fs.readFile(file, 'utf8', (err, data) => {
|
|
227
|
+
if (err) throw err;
|
|
228
|
+
const fileData = JSON.parse(data);
|
|
229
|
+
if (validateImport(fileData.meta)) {
|
|
230
|
+
createProgressIndicator('determinate', Object.keys(fileData.theme).length, 'Importing themes...');
|
|
231
|
+
for (const id in fileData.theme) {
|
|
232
|
+
if ({}.hasOwnProperty.call(fileData.theme, id)) {
|
|
233
|
+
updateProgressIndicator(`Importing ${fileData.theme[id].name}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
putThemes(fileData.theme).then(result => {
|
|
237
|
+
if (result == null) {
|
|
238
|
+
stopProgressIndicator(`Error importing ${Object.keys(fileData.theme).length} themes!`);
|
|
239
|
+
printMessage(`Error importing ${Object.keys(fileData.theme).length} themes from ${file}`, 'error');
|
|
240
|
+
} else {
|
|
241
|
+
stopProgressIndicator(`Successfully imported ${Object.keys(fileData.theme).length} themes.`);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
} else {
|
|
245
|
+
printMessage('Import validation failed...', 'error');
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Import themes from separate files
|
|
252
|
+
*/
|
|
253
|
+
export async function importThemesFromFiles() {
|
|
254
|
+
const names = fs.readdirSync('.');
|
|
255
|
+
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.theme.json'));
|
|
256
|
+
createProgressIndicator('determinate', jsonFiles.length, 'Importing themes...');
|
|
257
|
+
let fileData = null;
|
|
258
|
+
let count = 0;
|
|
259
|
+
let total = 0;
|
|
260
|
+
let files = 0;
|
|
261
|
+
for (const file of jsonFiles) {
|
|
262
|
+
const data = fs.readFileSync(file, 'utf8');
|
|
263
|
+
fileData = JSON.parse(data);
|
|
264
|
+
if (validateImport(fileData.meta)) {
|
|
265
|
+
count = Object.keys(fileData.theme).length;
|
|
266
|
+
// eslint-disable-next-line no-await-in-loop
|
|
267
|
+
const result = await putThemes(fileData.theme);
|
|
268
|
+
if (result == null) {
|
|
269
|
+
printMessage(`Error importing ${count} themes from ${file}`, 'error');
|
|
270
|
+
} else {
|
|
271
|
+
files += 1;
|
|
272
|
+
total += count;
|
|
273
|
+
updateProgressIndicator(`Imported ${count} theme(s) from ${file}`);
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
printMessage(`Validation of ${file} failed!`, 'error');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
stopProgressIndicator(`Finished importing ${total} theme(s) from ${files} file(s).`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Import first theme from file
|
|
284
|
+
* @param {String} file import file name
|
|
285
|
+
*/
|
|
286
|
+
export async function importFirstThemeFromFile(file) {
|
|
287
|
+
fs.readFile(file, 'utf8', (err, data) => {
|
|
288
|
+
if (err) throw err;
|
|
289
|
+
const themeData = JSON.parse(data);
|
|
290
|
+
if (validateImport(themeData.meta)) {
|
|
291
|
+
createProgressIndicator('determinate', 1, 'Importing theme...');
|
|
292
|
+
for (const id in themeData.theme) {
|
|
293
|
+
if ({}.hasOwnProperty.call(themeData.theme, id)) {
|
|
294
|
+
updateProgressIndicator(`Importing ${themeData.theme[id].name}`);
|
|
295
|
+
putTheme(id, themeData.theme[id]).then(result => {
|
|
296
|
+
if (result == null) {
|
|
297
|
+
stopProgressIndicator(`Error importing theme ${themeData.theme[id].name}`);
|
|
298
|
+
printMessage(`Error importing theme ${themeData.theme[id].name}`, 'error');
|
|
299
|
+
} else {
|
|
300
|
+
stopProgressIndicator(`Successfully imported theme ${themeData.theme[id].name}`);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
printMessage('Import validation failed...', 'error');
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Delete theme by id
|
|
314
|
+
* @param {String} id theme id
|
|
315
|
+
*/
|
|
316
|
+
export async function deleteThemeCmd(id) {
|
|
317
|
+
createProgressIndicator('indeterminate', undefined, `Deleting ${id}...`);
|
|
318
|
+
try {
|
|
319
|
+
await deleteTheme(id);
|
|
320
|
+
stopProgressIndicator(`Deleted ${id}.`, 'success');
|
|
321
|
+
} catch (error) {
|
|
322
|
+
stopProgressIndicator(`Error: ${error.message}`, 'fail');
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Delete theme by name
|
|
328
|
+
* @param {String} name theme name
|
|
329
|
+
*/
|
|
330
|
+
export async function deleteThemeByNameCmd(name) {
|
|
331
|
+
createProgressIndicator('indeterminate', undefined, `Deleting ${name}...`);
|
|
332
|
+
try {
|
|
333
|
+
await deleteThemeByName(name);
|
|
334
|
+
stopProgressIndicator(`Deleted ${name}.`, 'success');
|
|
335
|
+
} catch (error) {
|
|
336
|
+
stopProgressIndicator(`Error: ${error.message}`, 'fail');
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Delete all themes
|
|
342
|
+
*/
|
|
343
|
+
export async function deleteAllThemes() {
|
|
344
|
+
createProgressIndicator('indeterminate', undefined, `Deleting all realm themes...`);
|
|
345
|
+
try {
|
|
346
|
+
await deleteThemes();
|
|
347
|
+
stopProgressIndicator(`Deleted all realm themes.`, 'success');
|
|
348
|
+
} catch (error) {
|
|
349
|
+
stopProgressIndicator(`Error: ${error.message}`, 'fail');
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Delete all themes
|
|
355
|
+
* @deprecated since version 0.14.0
|
|
356
|
+
*/
|
|
357
|
+
export async function deleteThemesCmd() {
|
|
358
|
+
return deleteAllThemes();
|
|
359
|
+
}
|
|
31
360
|
//# sourceMappingURL=ThemeOps.js.map
|
package/esm/ops/ThemeOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeOps.js","names":["getOneLineDescription","themeObj","description","_id","name","linkedTrees","join","getTableHeaderMd","markdown","getTableRowMd","row"],"sources":["ops/ThemeOps.ts"],"sourcesContent":["import { ThemeSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\n\n/**\n * Get a one-line description of the theme\n * @param {ThemeSkeleton} themeObj theme object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(themeObj: ThemeSkeleton): string {\n const description = `[${themeObj._id['brightCyan']}] ${themeObj.name}${\n themeObj.linkedTrees\n ? ' (' + themeObj.linkedTrees.join(', ')['brightCyan'] + ')'\n : ''\n }`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name | Linked Journey(s) | Id |\\n';\n markdown += '| ---- | ----------------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the theme in markdown\n * @param {ThemeSkeleton} themeObj theme object to describe\n * @returns {string} a table-row of the theme in markdown\n */\nexport function getTableRowMd(themeObj: ThemeSkeleton): string {\n const row = `| ${themeObj.name} | ${\n themeObj.linkedTrees ? themeObj.linkedTrees.join(', ') : ''\n } | \\`${themeObj._id}\\` |`;\n return row;\n}\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,qBAAqB,CAACC,QAAuB,EAAU;EACrE,MAAMC,WAAW,GAAI,IAAGD,QAAQ,CAACE,GAAG,CAAC,YAAY,CAAE,KAAIF,QAAQ,CAACG,IAAK,GACnEH,QAAQ,CAACI,WAAW,GAChB,IAAI,GAAGJ,QAAQ,CAACI,WAAW,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,GAAG,GAC1D,EACL,EAAC;EACF,OAAOJ,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASK,gBAAgB,GAAW;EACzC,IAAIC,QAAQ,GAAG,EAAE;EACjBA,QAAQ,IAAI,qCAAqC;EACjDA,QAAQ,IAAI,mCAAmC;EAC/C,OAAOA,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAa,CAACR,QAAuB,EAAU;EAC7D,MAAMS,GAAG,GAAI,KAAIT,QAAQ,CAACG,IAAK,MAC7BH,QAAQ,CAACI,WAAW,GAAGJ,QAAQ,CAACI,WAAW,CAACC,IAAI,CAAC,IAAI,CAAC,GAAG,EAC1D,QAAOL,QAAQ,CAACE,GAAI,MAAK;EAC1B,OAAOO,GAAG;AACZ"}
|
|
1
|
+
{"version":3,"file":"ThemeOps.js","names":["fs","Theme","ExportImportUtils","printMessage","createTable","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","saveToFile","getTypedFilename","getTheme","getThemes","getThemeByName","putThemeByName","putTheme","putThemes","deleteTheme","deleteThemeByName","deleteThemes","getRealmString","validateImport","getOneLineDescription","themeObj","description","_id","name","linkedTrees","join","getTableHeaderMd","markdown","getTableRowMd","row","listThemes","long","themeList","sort","a","b","localeCompare","forEach","theme","isDefault","table","push","toString","exportThemeByName","file","fileName","themeData","error","message","exportThemeById","id","exportThemesToFile","allThemesData","length","exportThemesToFiles","importThemeByName","readFile","err","data","JSON","parse","meta","found","hasOwnProperty","call","importThemeById","themeId","importThemesFromFile","fileData","Object","keys","then","result","importThemesFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","count","total","files","readFileSync","importFirstThemeFromFile","deleteThemeCmd","undefined","deleteThemeByNameCmd","deleteAllThemes","deleteThemesCmd"],"sources":["ops/ThemeOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { Theme, ExportImportUtils } from '@rockcarver/frodo-lib';\nimport { ThemeSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n printMessage,\n createTable,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { saveToFile, getTypedFilename } from '../utils/ExportImportUtils';\n\nconst {\n getTheme,\n getThemes,\n getThemeByName,\n putThemeByName,\n putTheme,\n putThemes,\n deleteTheme,\n deleteThemeByName,\n deleteThemes,\n} = Theme;\nconst { getRealmString, validateImport } = ExportImportUtils;\n/**\n * Get a one-line description of the theme\n * @param {ThemeSkeleton} themeObj theme object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(themeObj: ThemeSkeleton): string {\n const description = `[${themeObj._id['brightCyan']}] ${themeObj.name}${\n themeObj.linkedTrees\n ? ' (' + themeObj.linkedTrees.join(', ')['brightCyan'] + ')'\n : ''\n }`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name | Linked Journey(s) | Id |\\n';\n markdown += '| ---- | ----------------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the theme in markdown\n * @param {ThemeSkeleton} themeObj theme object to describe\n * @returns {string} a table-row of the theme in markdown\n */\nexport function getTableRowMd(themeObj: ThemeSkeleton): string {\n const row = `| ${themeObj.name} | ${\n themeObj.linkedTrees ? themeObj.linkedTrees.join(', ') : ''\n } | \\`${themeObj._id}\\` |`;\n return row;\n}\n\n/**\n * List all the themes\n * @param {boolean} long Long version, more fields\n */\nexport async function listThemes(long = false) {\n const themeList = await getThemes();\n themeList.sort((a, b) => a.name.localeCompare(b.name));\n if (!long) {\n themeList.forEach((theme) => {\n printMessage(\n `${theme.isDefault ? theme.name['brightCyan'] : theme.name}`,\n 'data'\n );\n });\n } else {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Id'['brightCyan'],\n 'Default'['brightCyan'],\n ]);\n themeList.forEach((theme) => {\n table.push([\n `${theme.name}`,\n `${theme._id}`,\n `${theme.isDefault ? 'Yes'['brightGreen'] : ''}`,\n ]);\n });\n printMessage(table.toString(), 'data');\n }\n}\n\n/**\n * Export theme by name to file\n * @param {String} name theme name\n * @param {String} file optional export file name\n */\nexport async function exportThemeByName(name, file) {\n let fileName = getTypedFilename(name, 'theme');\n if (file) {\n fileName = file;\n }\n createProgressIndicator('determinate', 1, `Exporting ${name}`);\n try {\n const themeData = await getThemeByName(name);\n updateProgressIndicator(`Writing file ${fileName}`);\n saveToFile('theme', [themeData], '_id', fileName);\n stopProgressIndicator(`Successfully exported theme ${name}.`);\n } catch (error) {\n stopProgressIndicator(`${error.message}`);\n printMessage(`${error.message}`, 'error');\n }\n}\n\n/**\n * Export theme by uuid to file\n * @param {String} id theme uuid\n * @param {String} file optional export file name\n */\nexport async function exportThemeById(id, file) {\n let fileName = getTypedFilename(id, 'theme');\n if (file) {\n fileName = file;\n }\n createProgressIndicator('determinate', 1, `Exporting ${id}`);\n try {\n const themeData = await getTheme(id);\n updateProgressIndicator(`Writing file ${fileName}`);\n saveToFile('theme', [themeData], '_id', fileName);\n stopProgressIndicator(`Successfully exported theme ${id}.`);\n } catch (error) {\n stopProgressIndicator(`${error.message}`);\n printMessage(`${error.message}`, 'error');\n }\n}\n\n/**\n * Export all themes to file\n * @param {String} file optional export file name\n */\nexport async function exportThemesToFile(file) {\n let fileName = getTypedFilename(`all${getRealmString()}Themes`, 'theme');\n if (file) {\n fileName = file;\n }\n const allThemesData = await getThemes();\n createProgressIndicator(\n 'determinate',\n allThemesData.length,\n 'Exporting themes'\n );\n for (const themeData of allThemesData) {\n updateProgressIndicator(`Exporting theme ${themeData.name}`);\n }\n saveToFile('theme', allThemesData, '_id', fileName);\n stopProgressIndicator(\n `${allThemesData.length} themes exported to ${fileName}.`\n );\n}\n\n/**\n * Export all themes to separate files\n */\nexport async function exportThemesToFiles() {\n const allThemesData = await getThemes();\n createProgressIndicator(\n 'determinate',\n allThemesData.length,\n 'Exporting themes'\n );\n for (const themeData of allThemesData) {\n updateProgressIndicator(`Writing theme ${themeData.name}`);\n const fileName = getTypedFilename(themeData.name, 'theme');\n saveToFile('theme', themeData, '_id', fileName);\n }\n stopProgressIndicator(`${allThemesData.length} themes exported.`);\n}\n\n/**\n * Import theme by name from file\n * @param {String} name theme name\n * @param {String} file import file name\n */\nexport async function importThemeByName(name, file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const themeData = JSON.parse(data);\n if (validateImport(themeData.meta)) {\n createProgressIndicator('determinate', 1, 'Importing theme...');\n let found = false;\n for (const id in themeData.theme) {\n if ({}.hasOwnProperty.call(themeData.theme, id)) {\n if (themeData.theme[id].name === name) {\n found = true;\n updateProgressIndicator(`Importing ${themeData.theme[id].name}`);\n try {\n await putThemeByName(name, themeData.theme[id]);\n stopProgressIndicator(`Successfully imported theme ${name}.`);\n } catch (error) {\n stopProgressIndicator(\n `Error importing theme ${themeData.theme[id].name}: ${error.message}`\n );\n printMessage(\n `Error importing theme ${themeData.theme[id].name}: ${error.message}`,\n 'error'\n );\n }\n break;\n }\n }\n }\n if (!found) {\n stopProgressIndicator(`Theme ${name} not found!`);\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import theme by uuid from file\n * @param {String} id theme uuid\n * @param {String} file import file name\n */\nexport async function importThemeById(id, file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const themeData = JSON.parse(data);\n if (validateImport(themeData.meta)) {\n createProgressIndicator('determinate', 1, 'Importing theme...');\n let found = false;\n for (const themeId in themeData.theme) {\n if ({}.hasOwnProperty.call(themeData.theme, themeId)) {\n if (themeId === id) {\n found = true;\n updateProgressIndicator(\n `Importing ${themeData.theme[themeId]._id}`\n );\n try {\n await putTheme(themeId, themeData.theme[themeId]);\n stopProgressIndicator(`Successfully imported theme ${id}.`);\n } catch (error) {\n stopProgressIndicator(\n `Error importing theme ${themeData.theme[themeId]._id}: ${error.message}`\n );\n printMessage(\n `Error importing theme ${themeData.theme[themeId]._id}: ${error.message}`,\n 'error'\n );\n }\n break;\n }\n }\n }\n if (!found) {\n stopProgressIndicator(`Theme ${id} not found!`);\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all themes from single file\n * @param {String} file import file name\n */\nexport async function importThemesFromFile(file) {\n fs.readFile(file, 'utf8', (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n Object.keys(fileData.theme).length,\n 'Importing themes...'\n );\n for (const id in fileData.theme) {\n if ({}.hasOwnProperty.call(fileData.theme, id)) {\n updateProgressIndicator(`Importing ${fileData.theme[id].name}`);\n }\n }\n putThemes(fileData.theme).then((result) => {\n if (result == null) {\n stopProgressIndicator(\n `Error importing ${Object.keys(fileData.theme).length} themes!`\n );\n printMessage(\n `Error importing ${\n Object.keys(fileData.theme).length\n } themes from ${file}`,\n 'error'\n );\n } else {\n stopProgressIndicator(\n `Successfully imported ${\n Object.keys(fileData.theme).length\n } themes.`\n );\n }\n });\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import themes from separate files\n */\nexport async function importThemesFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.theme.json')\n );\n\n createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing themes...'\n );\n let fileData = null;\n let count = 0;\n let total = 0;\n let files = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n count = Object.keys(fileData.theme).length;\n // eslint-disable-next-line no-await-in-loop\n const result = await putThemes(fileData.theme);\n if (result == null) {\n printMessage(`Error importing ${count} themes from ${file}`, 'error');\n } else {\n files += 1;\n total += count;\n updateProgressIndicator(`Imported ${count} theme(s) from ${file}`);\n }\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Finished importing ${total} theme(s) from ${files} file(s).`\n );\n}\n\n/**\n * Import first theme from file\n * @param {String} file import file name\n */\nexport async function importFirstThemeFromFile(file) {\n fs.readFile(file, 'utf8', (err, data) => {\n if (err) throw err;\n const themeData = JSON.parse(data);\n if (validateImport(themeData.meta)) {\n createProgressIndicator('determinate', 1, 'Importing theme...');\n for (const id in themeData.theme) {\n if ({}.hasOwnProperty.call(themeData.theme, id)) {\n updateProgressIndicator(`Importing ${themeData.theme[id].name}`);\n putTheme(id, themeData.theme[id]).then((result) => {\n if (result == null) {\n stopProgressIndicator(\n `Error importing theme ${themeData.theme[id].name}`\n );\n printMessage(\n `Error importing theme ${themeData.theme[id].name}`,\n 'error'\n );\n } else {\n stopProgressIndicator(\n `Successfully imported theme ${themeData.theme[id].name}`\n );\n }\n });\n break;\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Delete theme by id\n * @param {String} id theme id\n */\nexport async function deleteThemeCmd(id) {\n createProgressIndicator('indeterminate', undefined, `Deleting ${id}...`);\n try {\n await deleteTheme(id);\n stopProgressIndicator(`Deleted ${id}.`, 'success');\n } catch (error) {\n stopProgressIndicator(`Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete theme by name\n * @param {String} name theme name\n */\nexport async function deleteThemeByNameCmd(name) {\n createProgressIndicator('indeterminate', undefined, `Deleting ${name}...`);\n try {\n await deleteThemeByName(name);\n stopProgressIndicator(`Deleted ${name}.`, 'success');\n } catch (error) {\n stopProgressIndicator(`Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete all themes\n */\nexport async function deleteAllThemes() {\n createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting all realm themes...`\n );\n try {\n await deleteThemes();\n stopProgressIndicator(`Deleted all realm themes.`, 'success');\n } catch (error) {\n stopProgressIndicator(`Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete all themes\n * @deprecated since version 0.14.0\n */\nexport async function deleteThemesCmd() {\n return deleteAllThemes();\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,SAASC,KAAK,EAAEC,iBAAiB,QAAQ,uBAAuB;AAEhE,SACEC,YAAY,EACZC,WAAW,EACXC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,UAAU,EAAEC,gBAAgB,QAAQ,4BAA4B;AAEzE,MAAM;EACJC,QAAQ;EACRC,SAAS;EACTC,cAAc;EACdC,cAAc;EACdC,QAAQ;EACRC,SAAS;EACTC,WAAW;EACXC,iBAAiB;EACjBC;AACF,CAAC,GAAGjB,KAAK;AACT,MAAM;EAAEkB,cAAc;EAAEC;AAAe,CAAC,GAAGlB,iBAAiB;AAC5D;AACA;AACA;AACA;AACA;AACA,OAAO,SAASmB,qBAAqB,CAACC,QAAuB,EAAU;EACrE,MAAMC,WAAW,GAAI,IAAGD,QAAQ,CAACE,GAAG,CAAC,YAAY,CAAE,KAAIF,QAAQ,CAACG,IAAK,GACnEH,QAAQ,CAACI,WAAW,GAChB,IAAI,GAAGJ,QAAQ,CAACI,WAAW,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,GAAG,GAC1D,EACL,EAAC;EACF,OAAOJ,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASK,gBAAgB,GAAW;EACzC,IAAIC,QAAQ,GAAG,EAAE;EACjBA,QAAQ,IAAI,qCAAqC;EACjDA,QAAQ,IAAI,mCAAmC;EAC/C,OAAOA,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAa,CAACR,QAAuB,EAAU;EAC7D,MAAMS,GAAG,GAAI,KAAIT,QAAQ,CAACG,IAAK,MAC7BH,QAAQ,CAACI,WAAW,GAAGJ,QAAQ,CAACI,WAAW,CAACC,IAAI,CAAC,IAAI,CAAC,GAAG,EAC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,SAAS,EACR,8BAA6B,CAC/B;EACD,IAAI;IACF,MAAMtE,YAAY,EAAE;IACpBX,qBAAqB,CAAE,2BAA0B,EAAE,SAAS,CAAC;EAC/D,CAAC,CAAC,OAAO0C,KAAK,EAAE;IACd1C,qBAAqB,CAAE,UAAS0C,KAAK,CAACC,OAAQ,EAAC,EAAE,MAAM,CAAC;EAC1D;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAeyC,eAAe,GAAG;EACtC,OAAOD,eAAe,EAAE;AAC1B"}
|
package/esm/utils/Console.js
CHANGED
|
@@ -8,21 +8,23 @@ Color.enable();
|
|
|
8
8
|
const {
|
|
9
9
|
appendTextToFile
|
|
10
10
|
} = ExportImportUtils;
|
|
11
|
+
let progressBar = null;
|
|
12
|
+
let spinner = null;
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
|
-
* Output a message in default color to stdout or append to `state.
|
|
15
|
+
* Output a message in default color to stdout or append to `state.getOutputFile()`
|
|
14
16
|
* @param {string | object} message the message
|
|
15
17
|
*/
|
|
16
18
|
function data(message, newline = true) {
|
|
17
19
|
if (!message) return;
|
|
18
|
-
if (state.
|
|
20
|
+
if (state.getOutputFile()) {
|
|
19
21
|
if (typeof message === 'object') {
|
|
20
22
|
message = JSON.stringify(message, null, 2);
|
|
21
23
|
}
|
|
22
24
|
if (newline) {
|
|
23
25
|
message += '\n';
|
|
24
26
|
}
|
|
25
|
-
appendTextToFile(message, state.
|
|
27
|
+
appendTextToFile(message, state.getOutputFile());
|
|
26
28
|
} else if (typeof message === 'object') {
|
|
27
29
|
console.dir(message, {
|
|
28
30
|
depth: 3
|
|
@@ -134,7 +136,7 @@ function curlirize(message) {
|
|
|
134
136
|
*/
|
|
135
137
|
export function verboseMessage(message) {
|
|
136
138
|
if (!message) return;
|
|
137
|
-
if (state.
|
|
139
|
+
if (state.getVerbose()) {
|
|
138
140
|
text(message);
|
|
139
141
|
}
|
|
140
142
|
}
|
|
@@ -145,7 +147,7 @@ export function verboseMessage(message) {
|
|
|
145
147
|
*/
|
|
146
148
|
export function debugMessage(message) {
|
|
147
149
|
if (!message) return;
|
|
148
|
-
if (state.
|
|
150
|
+
if (state.getDebug()) {
|
|
149
151
|
debug(message);
|
|
150
152
|
}
|
|
151
153
|
}
|
|
@@ -156,7 +158,7 @@ export function debugMessage(message) {
|
|
|
156
158
|
*/
|
|
157
159
|
export function curlirizeMessage(message) {
|
|
158
160
|
if (!message) return;
|
|
159
|
-
if (state.
|
|
161
|
+
if (state.getCurlirize()) {
|
|
160
162
|
curlirize(message);
|
|
161
163
|
}
|
|
162
164
|
}
|
|
@@ -214,12 +216,10 @@ export function createProgressBar(total, message = null, options = {
|
|
|
214
216
|
noTTYOutput: true
|
|
215
217
|
};
|
|
216
218
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
pBar.start(total, 0, {
|
|
219
|
+
progressBar = new SingleBar(opt, Presets.legacy); // create only when needed
|
|
220
|
+
progressBar.start(total, 0, {
|
|
220
221
|
data: message
|
|
221
222
|
});
|
|
222
|
-
state.default.session.setItem('progressBar', pBar);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/**
|
|
@@ -228,10 +228,9 @@ export function createProgressBar(total, message = null, options = {
|
|
|
228
228
|
*
|
|
229
229
|
*/
|
|
230
230
|
export function updateProgressBar(message = null) {
|
|
231
|
-
|
|
232
|
-
if (message) pBar.increment({
|
|
231
|
+
if (message) progressBar.increment({
|
|
233
232
|
data: message
|
|
234
|
-
});else
|
|
233
|
+
});else progressBar.increment();
|
|
235
234
|
}
|
|
236
235
|
|
|
237
236
|
/**
|
|
@@ -239,11 +238,10 @@ export function updateProgressBar(message = null) {
|
|
|
239
238
|
* @param {*} message optional message to update the progress bar
|
|
240
239
|
*/
|
|
241
240
|
export function stopProgressBar(message = null) {
|
|
242
|
-
|
|
243
|
-
if (message) pBar.update({
|
|
241
|
+
if (message) progressBar.update({
|
|
244
242
|
data: message
|
|
245
243
|
});
|
|
246
|
-
|
|
244
|
+
progressBar.stop();
|
|
247
245
|
}
|
|
248
246
|
|
|
249
247
|
/**
|
|
@@ -251,8 +249,7 @@ export function stopProgressBar(message = null) {
|
|
|
251
249
|
* @param {String} message optional spinner message
|
|
252
250
|
*/
|
|
253
251
|
export function showSpinner(message) {
|
|
254
|
-
|
|
255
|
-
state.default.session.setItem('Spinner', spinner);
|
|
252
|
+
spinner = createSpinner(message).start();
|
|
256
253
|
}
|
|
257
254
|
|
|
258
255
|
/**
|
|
@@ -260,7 +257,6 @@ export function showSpinner(message) {
|
|
|
260
257
|
* @param {String} message optional message to update the spinner
|
|
261
258
|
*/
|
|
262
259
|
export function stopSpinner(message = null) {
|
|
263
|
-
const spinner = state.default.session.getItem('Spinner');
|
|
264
260
|
if (spinner) {
|
|
265
261
|
let options = {};
|
|
266
262
|
if (message) options = {
|
|
@@ -275,7 +271,6 @@ export function stopSpinner(message = null) {
|
|
|
275
271
|
* @param {String} message optional message to update the spinner
|
|
276
272
|
*/
|
|
277
273
|
export function succeedSpinner(message = null) {
|
|
278
|
-
const spinner = state.default.session.getItem('Spinner');
|
|
279
274
|
if (spinner) {
|
|
280
275
|
let options = {};
|
|
281
276
|
if (message) options = {
|
|
@@ -290,7 +285,6 @@ export function succeedSpinner(message = null) {
|
|
|
290
285
|
* @param {String} message optional message to update the spinner
|
|
291
286
|
*/
|
|
292
287
|
export function warnSpinner(message = null) {
|
|
293
|
-
const spinner = state.default.session.getItem('Spinner');
|
|
294
288
|
if (spinner) {
|
|
295
289
|
let options = {};
|
|
296
290
|
if (message) options = {
|
|
@@ -305,7 +299,6 @@ export function warnSpinner(message = null) {
|
|
|
305
299
|
* @param {String} message optional message to update the spinner
|
|
306
300
|
*/
|
|
307
301
|
export function failSpinner(message = null) {
|
|
308
|
-
const spinner = state.default.session.getItem('Spinner');
|
|
309
302
|
if (spinner) {
|
|
310
303
|
let options = {};
|
|
311
304
|
if (message) options = {
|
|
@@ -320,7 +313,6 @@ export function failSpinner(message = null) {
|
|
|
320
313
|
* @param {String} message optional message to update the spinner
|
|
321
314
|
*/
|
|
322
315
|
export function spinSpinner(message = null) {
|
|
323
|
-
const spinner = state.default.session.getItem('Spinner');
|
|
324
316
|
if (spinner) {
|
|
325
317
|
let options = {};
|
|
326
318
|
if (message) options = {
|
|
@@ -338,7 +330,6 @@ export function createProgressIndicator(type = 'determinate', total = 0, message
|
|
|
338
330
|
}
|
|
339
331
|
}
|
|
340
332
|
export function updateProgressIndicator(message) {
|
|
341
|
-
const progressBar = state.default.session.getItem('progressBar');
|
|
342
333
|
if (!progressBar) {
|
|
343
334
|
spinSpinner(message);
|
|
344
335
|
} else {
|
|
@@ -346,7 +337,6 @@ export function updateProgressIndicator(message) {
|
|
|
346
337
|
}
|
|
347
338
|
}
|
|
348
339
|
export function stopProgressIndicator(message, status = 'none') {
|
|
349
|
-
const progressBar = state.default.session.getItem('progressBar');
|
|
350
340
|
if (!progressBar) {
|
|
351
341
|
switch (status) {
|
|
352
342
|
case 'none':
|