@pnp/cli-microsoft365 7.3.0-beta.a98760b → 7.3.0-beta.d293309
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/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/Auth.js +4 -5
- package/dist/Command.js +10 -13
- package/dist/api.js +2 -3
- package/dist/appInsights.js +2 -1
- package/dist/autocomplete.js +4 -6
- package/dist/chili/chili.js +1 -2
- package/dist/cli/cli.js +880 -0
- package/dist/index.js +2 -10
- package/dist/m365/aad/commands/administrativeunit/administrativeunit-member-list.js +138 -0
- package/dist/m365/aad/commands/administrativeunit/administrativeunit-remove.js +2 -2
- package/dist/m365/aad/commands/app/app-get.js +2 -2
- package/dist/m365/aad/commands/app/app-remove.js +3 -3
- package/dist/m365/aad/commands/app/app-role-add.js +2 -2
- package/dist/m365/aad/commands/app/app-role-list.js +2 -2
- package/dist/m365/aad/commands/app/app-role-remove.js +4 -4
- package/dist/m365/aad/commands/app/app-set.js +2 -2
- package/dist/m365/aad/commands/approleassignment/approleassignment-add.js +2 -2
- package/dist/m365/aad/commands/approleassignment/approleassignment-remove.js +2 -2
- package/dist/m365/aad/commands/group/group-list.js +71 -3
- package/dist/m365/aad/commands/group/group-remove.js +2 -2
- package/dist/m365/aad/commands/groupsetting/groupsetting-remove.js +2 -2
- package/dist/m365/aad/commands/m365group/m365group-recyclebinitem-clear.js +2 -2
- package/dist/m365/aad/commands/m365group/m365group-recyclebinitem-remove.js +3 -3
- package/dist/m365/aad/commands/m365group/m365group-recyclebinitem-restore.js +2 -2
- package/dist/m365/aad/commands/m365group/m365group-remove.js +2 -2
- package/dist/m365/aad/commands/m365group/m365group-teamify.js +2 -2
- package/dist/m365/aad/commands/m365group/m365group-user-remove.js +2 -2
- package/dist/m365/aad/commands/oauth2grant/oauth2grant-remove.js +2 -2
- package/dist/m365/aad/commands/siteclassification/siteclassification-disable.js +2 -2
- package/dist/m365/aad/commands/sp/sp-add.js +2 -2
- package/dist/m365/aad/commands/sp/sp-get.js +2 -2
- package/dist/m365/aad/commands/user/user-get.js +2 -2
- package/dist/m365/aad/commands/user/user-license-remove.js +2 -2
- package/dist/m365/aad/commands/user/user-recyclebinitem-clear.js +2 -2
- package/dist/m365/aad/commands/user/user-recyclebinitem-remove.js +2 -2
- package/dist/m365/aad/commands/user/user-remove.js +2 -2
- package/dist/m365/aad/commands.js +1 -0
- package/dist/m365/app/commands/app-get.js +2 -2
- package/dist/m365/app/commands/app-open.js +2 -2
- package/dist/m365/app/commands/permission/permission-list.js +2 -2
- package/dist/m365/base/AppCommand.js +2 -2
- package/dist/m365/booking/commands/business/business-get.js +2 -2
- package/dist/m365/cli/commands/cli-doctor.js +2 -2
- package/dist/m365/cli/commands/cli-reconsent.js +2 -2
- package/dist/m365/cli/commands/config/config-get.js +2 -2
- package/dist/m365/cli/commands/config/config-list.js +2 -2
- package/dist/m365/cli/commands/config/config-reset.js +3 -3
- package/dist/m365/cli/commands/config/config-set.js +4 -4
- package/dist/m365/commands/docs.js +2 -2
- package/dist/m365/commands/login.js +4 -4
- package/dist/m365/commands/setup.js +8 -8
- package/dist/m365/context/commands/context-remove.js +2 -2
- package/dist/m365/context/commands/option/option-remove.js +2 -2
- package/dist/m365/external/commands/connection/connection-doctor.js +423 -0
- package/dist/m365/external/commands/connection/connection-remove.js +3 -3
- package/dist/m365/external/commands/item/item-add.js +144 -0
- package/dist/m365/external/commands.js +3 -1
- package/dist/m365/flow/commands/flow-remove.js +2 -2
- package/dist/m365/flow/commands/owner/owner-list.js +2 -2
- package/dist/m365/flow/commands/owner/owner-remove.js +2 -2
- package/dist/m365/flow/commands/run/run-cancel.js +2 -2
- package/dist/m365/flow/commands/run/run-resubmit.js +2 -2
- package/dist/m365/graph/commands/changelog/changelog-list.js +3 -3
- package/dist/m365/graph/commands/schemaextension/schemaextension-remove.js +2 -2
- package/dist/m365/outlook/commands/message/message-list.js +2 -2
- package/dist/m365/outlook/commands/message/message-move.js +2 -2
- package/dist/m365/pa/commands/app/app-consent-set.js +2 -2
- package/dist/m365/pa/commands/app/app-get.js +2 -2
- package/dist/m365/pa/commands/app/app-permission-remove.js +2 -2
- package/dist/m365/pa/commands/app/app-remove.js +2 -2
- package/dist/m365/planner/commands/bucket/bucket-get.js +2 -2
- package/dist/m365/planner/commands/bucket/bucket-remove.js +3 -3
- package/dist/m365/planner/commands/bucket/bucket-set.js +2 -2
- package/dist/m365/planner/commands/plan/plan-remove.js +2 -2
- package/dist/m365/planner/commands/roster/roster-member-remove.js +3 -3
- package/dist/m365/planner/commands/roster/roster-remove.js +2 -2
- package/dist/m365/planner/commands/task/task-checklistitem-add.js +2 -2
- package/dist/m365/planner/commands/task/task-checklistitem-list.js +2 -2
- package/dist/m365/planner/commands/task/task-checklistitem-remove.js +2 -2
- package/dist/m365/planner/commands/task/task-get.js +3 -3
- package/dist/m365/planner/commands/task/task-reference-remove.js +2 -2
- package/dist/m365/planner/commands/task/task-remove.js +4 -4
- package/dist/m365/pp/commands/aibuildermodel/aibuildermodel-get.js +2 -2
- package/dist/m365/pp/commands/aibuildermodel/aibuildermodel-remove.js +3 -3
- package/dist/m365/pp/commands/card/card-clone.js +2 -2
- package/dist/m365/pp/commands/card/card-get.js +2 -2
- package/dist/m365/pp/commands/card/card-remove.js +3 -3
- package/dist/m365/pp/commands/chatbot/chatbot-get.js +2 -2
- package/dist/m365/pp/commands/chatbot/chatbot-remove.js +3 -3
- package/dist/m365/pp/commands/dataverse/dataverse-table-remove.js +2 -2
- package/dist/m365/pp/commands/dataverse/dataverse-table-row-remove.js +2 -2
- package/dist/m365/pp/commands/managementapp/managementapp-add.js +2 -2
- package/dist/m365/pp/commands/solution/solution-get.js +2 -2
- package/dist/m365/pp/commands/solution/solution-list.js +2 -2
- package/dist/m365/pp/commands/solution/solution-publish.js +2 -2
- package/dist/m365/pp/commands/solution/solution-publisher-remove.js +3 -3
- package/dist/m365/pp/commands/solution/solution-remove.js +3 -3
- package/dist/m365/purview/commands/retentionevent/retentionevent-remove.js +2 -2
- package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-remove.js +2 -2
- package/dist/m365/purview/commands/retentionlabel/retentionlabel-remove.js +2 -2
- package/dist/m365/spfx/commands/project/project-permissions-grant.js +2 -2
- package/dist/m365/spo/commands/app/app-add.js +2 -2
- package/dist/m365/spo/commands/app/app-remove.js +2 -2
- package/dist/m365/spo/commands/app/app-retract.js +2 -2
- package/dist/m365/spo/commands/app/app-uninstall.js +2 -2
- package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +2 -2
- package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-remove.js +3 -3
- package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-set.js +2 -2
- package/dist/m365/spo/commands/cdn/cdn-origin-remove.js +2 -2
- package/dist/m365/spo/commands/commandset/commandset-get.js +2 -2
- package/dist/m365/spo/commands/commandset/commandset-remove.js +3 -3
- package/dist/m365/spo/commands/commandset/commandset-set.js +2 -2
- package/dist/m365/spo/commands/contenttype/contenttype-add.js +2 -2
- package/dist/m365/spo/commands/contenttype/contenttype-field-remove.js +2 -2
- package/dist/m365/spo/commands/contenttype/contenttype-remove.js +2 -2
- package/dist/m365/spo/commands/customaction/customaction-add.js +1 -1
- package/dist/m365/spo/commands/customaction/customaction-clear.js +2 -2
- package/dist/m365/spo/commands/customaction/customaction-get.js +3 -3
- package/dist/m365/spo/commands/customaction/customaction-remove.js +3 -3
- package/dist/m365/spo/commands/eventreceiver/eventreceiver-get.js +2 -2
- package/dist/m365/spo/commands/eventreceiver/eventreceiver-remove.js +3 -3
- package/dist/m365/spo/commands/field/field-remove.js +2 -2
- package/dist/m365/spo/commands/file/file-add.js +1 -1
- package/dist/m365/spo/commands/file/file-checkout-undo.js +2 -2
- package/dist/m365/spo/commands/file/file-remove.js +2 -2
- package/dist/m365/spo/commands/file/file-rename.js +2 -2
- package/dist/m365/spo/commands/file/file-retentionlabel-remove.js +2 -2
- package/dist/m365/spo/commands/file/file-roleassignment-add.js +5 -5
- package/dist/m365/spo/commands/file/file-roleassignment-remove.js +5 -5
- package/dist/m365/spo/commands/file/file-roleinheritance-break.js +3 -3
- package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +3 -3
- package/dist/m365/spo/commands/file/file-sharinginfo-get.js +2 -2
- package/dist/m365/spo/commands/file/file-sharinglink-clear.js +3 -3
- package/dist/m365/spo/commands/file/file-sharinglink-list.js +2 -2
- package/dist/m365/spo/commands/file/file-sharinglink-remove.js +2 -2
- package/dist/m365/spo/commands/file/file-version-clear.js +2 -2
- package/dist/m365/spo/commands/file/file-version-remove.js +2 -2
- package/dist/m365/spo/commands/file/file-version-restore.js +2 -2
- package/dist/m365/spo/commands/folder/folder-remove.js +2 -2
- package/dist/m365/spo/commands/folder/folder-retentionlabel-remove.js +2 -2
- package/dist/m365/spo/commands/folder/folder-roleassignment-add.js +4 -4
- package/dist/m365/spo/commands/folder/folder-roleassignment-remove.js +4 -4
- package/dist/m365/spo/commands/folder/folder-roleinheritance-break.js +2 -2
- package/dist/m365/spo/commands/folder/folder-roleinheritance-reset.js +2 -2
- package/dist/m365/spo/commands/group/group-list.js +2 -2
- package/dist/m365/spo/commands/group/group-member-remove.js +9 -9
- package/dist/m365/spo/commands/group/group-remove.js +2 -2
- package/dist/m365/spo/commands/group/group-set.js +2 -2
- package/dist/m365/spo/commands/homesite/homesite-remove.js +2 -2
- package/dist/m365/spo/commands/hubsite/hubsite-connect.js +2 -2
- package/dist/m365/spo/commands/hubsite/hubsite-disconnect.js +3 -3
- package/dist/m365/spo/commands/hubsite/hubsite-get.js +4 -4
- package/dist/m365/spo/commands/hubsite/hubsite-rights-revoke.js +2 -2
- package/dist/m365/spo/commands/hubsite/hubsite-unregister.js +2 -2
- package/dist/m365/spo/commands/knowledgehub/knowledgehub-remove.js +2 -2
- package/dist/m365/spo/commands/list/list-contenttype-remove.js +2 -2
- package/dist/m365/spo/commands/list/list-remove.js +2 -2
- package/dist/m365/spo/commands/list/list-retentionlabel-remove.js +2 -2
- package/dist/m365/spo/commands/list/list-roleassignment-remove.js +4 -4
- package/dist/m365/spo/commands/list/list-roleinheritance-break.js +2 -2
- package/dist/m365/spo/commands/list/list-roleinheritance-reset.js +2 -2
- package/dist/m365/spo/commands/list/list-view-field-remove.js +2 -2
- package/dist/m365/spo/commands/list/list-view-remove.js +2 -2
- package/dist/m365/spo/commands/list/list-webhook-remove.js +2 -2
- package/dist/m365/spo/commands/listitem/listitem-attachment-remove.js +2 -2
- package/dist/m365/spo/commands/listitem/listitem-list.js +2 -2
- package/dist/m365/spo/commands/listitem/listitem-remove.js +2 -2
- package/dist/m365/spo/commands/listitem/listitem-retentionlabel-remove.js +2 -2
- package/dist/m365/spo/commands/listitem/listitem-roleassignment-add.js +4 -4
- package/dist/m365/spo/commands/listitem/listitem-roleassignment-remove.js +4 -4
- package/dist/m365/spo/commands/listitem/listitem-roleinheritance-break.js +2 -2
- package/dist/m365/spo/commands/listitem/listitem-roleinheritance-reset.js +2 -2
- package/dist/m365/spo/commands/navigation/navigation-node-remove.js +2 -2
- package/dist/m365/spo/commands/orgassetslibrary/orgassetslibrary-remove.js +2 -2
- package/dist/m365/spo/commands/orgnewssite/orgnewssite-remove.js +2 -2
- package/dist/m365/spo/commands/page/page-add.js +4 -4
- package/dist/m365/spo/commands/page/page-column-get.js +2 -2
- package/dist/m365/spo/commands/page/page-column-list.js +2 -2
- package/dist/m365/spo/commands/page/page-remove.js +2 -2
- package/dist/m365/spo/commands/page/page-section-get.js +2 -2
- package/dist/m365/spo/commands/page/page-section-list.js +2 -2
- package/dist/m365/spo/commands/page/page-set.js +5 -5
- package/dist/m365/spo/commands/propertybag/propertybag-remove.js +2 -2
- package/dist/m365/spo/commands/roledefinition/roledefinition-remove.js +2 -2
- package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-permissionrequest-approve.js +2 -2
- package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-set.js +2 -2
- package/dist/m365/spo/commands/site/site-apppermission-remove.js +2 -2
- package/dist/m365/spo/commands/site/site-hubsite-disconnect.js +2 -2
- package/dist/m365/spo/commands/site/site-recyclebinitem-clear.js +2 -2
- package/dist/m365/spo/commands/site/site-recyclebinitem-move.js +2 -2
- package/dist/m365/spo/commands/site/site-recyclebinitem-remove.js +2 -2
- package/dist/m365/spo/commands/site/site-remove.js +2 -2
- package/dist/m365/spo/commands/site/site-set.js +3 -3
- package/dist/m365/spo/commands/sitedesign/sitedesign-get.js +2 -2
- package/dist/m365/spo/commands/sitedesign/sitedesign-remove.js +2 -2
- package/dist/m365/spo/commands/sitedesign/sitedesign-rights-revoke.js +2 -2
- package/dist/m365/spo/commands/sitedesign/sitedesign-task-remove.js +2 -2
- package/dist/m365/spo/commands/sitescript/sitescript-remove.js +2 -2
- package/dist/m365/spo/commands/spo-search.js +2 -2
- package/dist/m365/spo/commands/storageentity/storageentity-remove.js +2 -2
- package/dist/m365/spo/commands/tenant/tenant-appcatalog-add.js +5 -5
- package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-add.js +5 -5
- package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +2 -2
- package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-remove.js +3 -3
- package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-set.js +4 -4
- package/dist/m365/spo/commands/tenant/tenant-commandset-add.js +5 -5
- package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +2 -2
- package/dist/m365/spo/commands/tenant/tenant-commandset-remove.js +3 -3
- package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-remove.js +2 -2
- package/dist/m365/spo/commands/term/term-get.js +2 -2
- package/dist/m365/spo/commands/term/term-list.js +2 -2
- package/dist/m365/spo/commands/theme/theme-remove.js +2 -2
- package/dist/m365/spo/commands/user/user-remove.js +2 -2
- package/dist/m365/spo/commands/userprofile/userprofile-get.js +2 -2
- package/dist/m365/spo/commands/web/web-remove.js +2 -2
- package/dist/m365/spo/commands/web/web-roleassignment-add.js +4 -4
- package/dist/m365/spo/commands/web/web-roleassignment-remove.js +4 -4
- package/dist/m365/spo/commands/web/web-roleinheritance-break.js +2 -2
- package/dist/m365/spo/commands/web/web-roleinheritance-reset.js +2 -2
- package/dist/m365/teams/commands/app/app-install.js +32 -5
- package/dist/m365/teams/commands/app/app-remove.js +3 -3
- package/dist/m365/teams/commands/app/app-uninstall.js +2 -2
- package/dist/m365/teams/commands/app/app-update.js +2 -2
- package/dist/m365/teams/commands/cache/cache-remove.js +2 -2
- package/dist/m365/teams/commands/channel/channel-add.js +2 -2
- package/dist/m365/teams/commands/channel/channel-member-add.js +2 -2
- package/dist/m365/teams/commands/channel/channel-member-remove.js +3 -3
- package/dist/m365/teams/commands/channel/channel-member-set.js +2 -2
- package/dist/m365/teams/commands/channel/channel-remove.js +2 -2
- package/dist/m365/teams/commands/chat/chat-get.js +3 -3
- package/dist/m365/teams/commands/chat/chat-member-remove.js +2 -2
- package/dist/m365/teams/commands/chat/chat-message-send.js +3 -3
- package/dist/m365/teams/commands/meeting/meeting-add.js +151 -0
- package/dist/m365/teams/commands/meeting/meeting-attendancereport-list.js +2 -2
- package/dist/m365/teams/commands/tab/tab-remove.js +2 -2
- package/dist/m365/teams/commands/team/team-app-list.js +3 -3
- package/dist/m365/teams/commands/team/team-remove.js +2 -2
- package/dist/m365/teams/commands/user/user-app-list.js +2 -2
- package/dist/m365/teams/commands/user/user-app-remove.js +35 -4
- package/dist/m365/teams/commands.js +2 -1
- package/dist/m365/tenant/commands/people/people-profilecardproperty-remove.js +2 -2
- package/dist/m365/todo/commands/list/list-remove.js +2 -2
- package/dist/m365/todo/commands/task/task-get.js +2 -2
- package/dist/m365/todo/commands/task/task-list.js +2 -2
- package/dist/m365/todo/commands/task/task-remove.js +2 -2
- package/dist/m365/viva/commands/connections/connections-app-create.js +2 -2
- package/dist/m365/yammer/commands/group/group-user-remove.js +2 -2
- package/dist/m365/yammer/commands/message/message-like-set.js +2 -2
- package/dist/m365/yammer/commands/message/message-remove.js +2 -2
- package/dist/m365/yammer/commands/yammer-search.js +2 -2
- package/dist/telemetry.js +2 -10
- package/dist/utils/aadAdministrativeUnit.js +2 -2
- package/dist/utils/aadGroup.js +3 -3
- package/dist/utils/prompt.js +4 -7
- package/dist/utils/validation.js +5 -2
- package/docs/docs/cmd/aad/administrativeunit/administrativeunit-member-list.mdx +312 -0
- package/docs/docs/cmd/aad/group/group-list.mdx +11 -0
- package/docs/docs/cmd/aad/user/user-password-validate.mdx +2 -2
- package/docs/docs/cmd/adaptivecard/adaptivecard-send.mdx +1 -1
- package/docs/docs/cmd/external/connection/connection-doctor.mdx +182 -0
- package/docs/docs/cmd/external/item/item-add.mdx +145 -0
- package/docs/docs/cmd/flow/environment/environment-get.mdx +1 -1
- package/docs/docs/cmd/flow/environment/environment-list.mdx +1 -1
- package/docs/docs/cmd/flow/flow-disable.mdx +1 -1
- package/docs/docs/cmd/flow/flow-enable.mdx +1 -1
- package/docs/docs/cmd/flow/flow-export.mdx +1 -1
- package/docs/docs/cmd/flow/flow-get.mdx +1 -1
- package/docs/docs/cmd/flow/flow-list.mdx +1 -1
- package/docs/docs/cmd/flow/run/run-cancel.mdx +1 -1
- package/docs/docs/cmd/flow/run/run-get.mdx +1 -1
- package/docs/docs/cmd/flow/run/run-list.mdx +1 -1
- package/docs/docs/cmd/flow/run/run-resubmit.mdx +1 -1
- package/docs/docs/cmd/graph/changelog/changelog-list.mdx +1 -1
- package/docs/docs/cmd/graph/schemaextension/schemaextension-add.mdx +1 -1
- package/docs/docs/cmd/graph/schemaextension/schemaextension-set.mdx +1 -1
- package/docs/docs/cmd/onedrive/report/report-activityfilecounts.mdx +0 -3
- package/docs/docs/cmd/onedrive/report/report-activityusercounts.mdx +0 -3
- package/docs/docs/cmd/onedrive/report/report-activityuserdetail.mdx +0 -3
- package/docs/docs/cmd/onedrive/report/report-usageaccountcounts.mdx +0 -3
- package/docs/docs/cmd/onedrive/report/report-usageaccountdetail.mdx +0 -3
- package/docs/docs/cmd/onedrive/report/report-usagefilecounts.mdx +0 -3
- package/docs/docs/cmd/onedrive/report/report-usagestorage.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailactivitycounts.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailactivityusercounts.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailactivityuserdetail.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailappusageappsusercounts.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailappusageusercounts.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailappusageuserdetail.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailappusageversionsusercounts.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailboxusagedetail.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailboxusagemailboxcount.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailboxusagequotastatusmailboxcounts.mdx +0 -3
- package/docs/docs/cmd/outlook/report/report-mailboxusagestorage.mdx +0 -3
- package/docs/docs/cmd/pa/app/app-get.mdx +1 -1
- package/docs/docs/cmd/pa/app/app-list.mdx +1 -1
- package/docs/docs/cmd/pa/connector/connector-export.mdx +1 -1
- package/docs/docs/cmd/pa/connector/connector-list.mdx +1 -1
- package/docs/docs/cmd/pa/environment/environment-get.mdx +1 -1
- package/docs/docs/cmd/pa/environment/environment-list.mdx +1 -1
- package/docs/docs/cmd/planner/bucket/bucket-add.mdx +1 -1
- package/docs/docs/cmd/planner/bucket/bucket-get.mdx +1 -1
- package/docs/docs/cmd/planner/bucket/bucket-list.mdx +1 -1
- package/docs/docs/cmd/planner/bucket/bucket-remove.mdx +1 -1
- package/docs/docs/cmd/planner/bucket/bucket-set.mdx +1 -1
- package/docs/docs/cmd/planner/plan/plan-get.mdx +1 -1
- package/docs/docs/cmd/planner/plan/plan-list.mdx +1 -1
- package/docs/docs/cmd/planner/plan/plan-set.mdx +1 -1
- package/docs/docs/cmd/planner/roster/roster-add.mdx +2 -2
- package/docs/docs/cmd/planner/roster/roster-get.mdx +1 -1
- package/docs/docs/cmd/planner/roster/roster-member-add.mdx +1 -1
- package/docs/docs/cmd/planner/roster/roster-member-get.mdx +1 -1
- package/docs/docs/cmd/planner/roster/roster-member-list.mdx +1 -1
- package/docs/docs/cmd/planner/roster/roster-member-remove.mdx +2 -2
- package/docs/docs/cmd/planner/roster/roster-plan-list.mdx +1 -1
- package/docs/docs/cmd/planner/roster/roster-remove.mdx +2 -2
- package/docs/docs/cmd/planner/task/task-add.mdx +1 -1
- package/docs/docs/cmd/planner/task/task-list.mdx +2 -2
- package/docs/docs/cmd/planner/task/task-remove.mdx +1 -1
- package/docs/docs/cmd/planner/task/task-set.mdx +1 -1
- package/docs/docs/cmd/pp/environment/environment-get.mdx +1 -1
- package/docs/docs/cmd/pp/environment/environment-list.mdx +1 -1
- package/docs/docs/cmd/pp/tenant/tenant-settings-list.mdx +1 -1
- package/docs/docs/cmd/pp/tenant/tenant-settings-set.mdx +1 -1
- package/docs/docs/cmd/purview/retentionevent/retentionevent-add.mdx +1 -1
- package/docs/docs/cmd/purview/retentionevent/retentionevent-get.mdx +1 -1
- package/docs/docs/cmd/purview/retentionevent/retentionevent-list.mdx +1 -1
- package/docs/docs/cmd/purview/retentionevent/retentionevent-remove.mdx +1 -1
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.mdx +1 -1
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-get.mdx +1 -1
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-list.mdx +1 -1
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-remove.mdx +1 -1
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-set.mdx +1 -1
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.mdx +1 -1
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-get.mdx +1 -1
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-list.mdx +1 -1
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-remove.mdx +1 -1
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-set.mdx +1 -1
- package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-get.mdx +2 -2
- package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-list.mdx +2 -2
- package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-policysettings-list.mdx +2 -2
- package/docs/docs/cmd/skype/report/report-activitycounts.mdx +0 -2
- package/docs/docs/cmd/skype/report/report-activityusercounts.mdx +0 -3
- package/docs/docs/cmd/skype/report/report-activityuserdetail.mdx +0 -3
- package/docs/docs/cmd/spfx/project/project-externalize.mdx +1 -1
- package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.mdx +1 -1
- package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-set.mdx +1 -1
- package/docs/docs/cmd/spo/commandset/commandset-add.mdx +1 -1
- package/docs/docs/cmd/spo/commandset/commandset-set.mdx +1 -1
- package/docs/docs/cmd/spo/contenttype/contenttype-set.mdx +1 -1
- package/docs/docs/cmd/spo/customaction/customaction-add.mdx +1 -1
- package/docs/docs/cmd/spo/customaction/customaction-set.mdx +1 -1
- package/docs/docs/cmd/spo/eventreceiver/eventreceiver-remove.mdx +1 -1
- package/docs/docs/cmd/spo/field/field-set.mdx +1 -1
- package/docs/docs/cmd/spo/list/list-sensitivitylabel-ensure.mdx +1 -1
- package/docs/docs/cmd/spo/list/list-view-set.mdx +1 -1
- package/docs/docs/cmd/spo/listitem/listitem-add.mdx +1 -1
- package/docs/docs/cmd/spo/listitem/listitem-batch-add.mdx +1 -1
- package/docs/docs/cmd/spo/listitem/listitem-set.mdx +1 -1
- package/docs/docs/cmd/spo/page/page-clientsidewebpart-add.mdx +1 -1
- package/docs/docs/cmd/spo/page/page-control-set.mdx +1 -1
- package/docs/docs/cmd/spo/page/page-set.mdx +1 -1
- package/docs/docs/cmd/spo/report/report-activityfilecounts.mdx +0 -3
- package/docs/docs/cmd/spo/report/report-activitypages.mdx +0 -3
- package/docs/docs/cmd/spo/report/report-activityusercounts.mdx +0 -3
- package/docs/docs/cmd/spo/report/report-activityuserdetail.mdx +0 -3
- package/docs/docs/cmd/spo/report/report-siteusagedetail.mdx +0 -3
- package/docs/docs/cmd/spo/report/report-siteusagefilecounts.mdx +0 -3
- package/docs/docs/cmd/spo/report/report-siteusagepages.mdx +0 -3
- package/docs/docs/cmd/spo/report/report-siteusagesitecounts.mdx +0 -3
- package/docs/docs/cmd/spo/report/report-siteusagestorage.mdx +0 -3
- package/docs/docs/cmd/spo/site/site-groupify.mdx +1 -1
- package/docs/docs/cmd/spo/site/site-recyclebinitem-clear.mdx +1 -1
- package/docs/docs/cmd/spo/site/site-recyclebinitem-remove.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-set.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-commandset-add.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-commandset-set.mdx +1 -1
- package/docs/docs/cmd/spo/term/term-add.mdx +1 -1
- package/docs/docs/cmd/spo/term/term-group-add.mdx +1 -1
- package/docs/docs/cmd/spo/term/term-set-add.mdx +1 -1
- package/docs/docs/cmd/teams/app/app-install.mdx +11 -2
- package/docs/docs/cmd/teams/meeting/meeting-add.mdx +283 -0
- package/docs/docs/cmd/teams/meeting/meeting-transcript-list.mdx +2 -2
- package/docs/docs/cmd/teams/report/report-deviceusagedistributionusercounts.mdx +0 -3
- package/docs/docs/cmd/teams/report/report-deviceusageusercounts.mdx +0 -3
- package/docs/docs/cmd/teams/report/report-deviceusageuserdetail.mdx +0 -3
- package/docs/docs/cmd/teams/report/report-useractivitycounts.mdx +0 -3
- package/docs/docs/cmd/teams/report/report-useractivityusercounts.mdx +0 -3
- package/docs/docs/cmd/teams/report/report-useractivityuserdetail.mdx +0 -3
- package/docs/docs/cmd/teams/user/user-app-remove.mdx +13 -4
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-add.mdx +1 -1
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-remove.mdx +1 -1
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-set.mdx +1 -1
- package/docs/docs/cmd/tenant/report/report-activeusercounts.mdx +0 -3
- package/docs/docs/cmd/tenant/report/report-activeuserdetail.mdx +0 -3
- package/docs/docs/cmd/tenant/report/report-servicesusercounts.mdx +0 -3
- package/docs/docs/cmd/yammer/group/group-list.mdx +1 -1
- package/docs/docs/cmd/yammer/group/group-user-add.mdx +1 -1
- package/docs/docs/cmd/yammer/group/group-user-remove.mdx +1 -1
- package/docs/docs/cmd/yammer/message/message-add.mdx +1 -1
- package/docs/docs/cmd/yammer/message/message-get.mdx +1 -1
- package/docs/docs/cmd/yammer/message/message-like-set.mdx +1 -1
- package/docs/docs/cmd/yammer/message/message-list.mdx +1 -1
- package/docs/docs/cmd/yammer/message/message-remove.mdx +1 -1
- package/docs/docs/cmd/yammer/network/network-list.mdx +1 -1
- package/docs/docs/cmd/yammer/report/report-activitycounts.mdx +0 -3
- package/docs/docs/cmd/yammer/report/report-activityusercounts.mdx +0 -3
- package/docs/docs/cmd/yammer/report/report-activityuserdetail.mdx +0 -3
- package/docs/docs/cmd/yammer/report/report-deviceusagedistributionusercounts.mdx +0 -3
- package/docs/docs/cmd/yammer/report/report-deviceusageusercounts.mdx +0 -3
- package/docs/docs/cmd/yammer/report/report-deviceusageuserdetail.mdx +0 -3
- package/docs/docs/cmd/yammer/report/report-groupsactivitycounts.mdx +0 -3
- package/docs/docs/cmd/yammer/report/report-groupsactivitydetail.mdx +0 -3
- package/docs/docs/cmd/yammer/report/report-groupsactivitygroupcounts.mdx +0 -3
- package/docs/docs/cmd/yammer/user/user-get.mdx +1 -1
- package/docs/docs/cmd/yammer/user/user-list.mdx +1 -1
- package/docs/docs/cmd/yammer/yammer-search.mdx +1 -1
- package/npm-shrinkwrap.json +1012 -410
- package/package.json +26 -25
- package/dist/cli/Cli.js +0 -857
package/dist/cli/Cli.js
DELETED
|
@@ -1,857 +0,0 @@
|
|
|
1
|
-
import Configstore from 'configstore';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import minimist from 'minimist';
|
|
4
|
-
import { createRequire } from 'module';
|
|
5
|
-
import ora from 'ora';
|
|
6
|
-
import os from 'os';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import { fileURLToPath, pathToFileURL } from 'url';
|
|
9
|
-
import Command, { CommandError } from '../Command.js';
|
|
10
|
-
import config from '../config.js';
|
|
11
|
-
import request from '../request.js';
|
|
12
|
-
import { settingsNames } from '../settingsNames.js';
|
|
13
|
-
import { telemetry } from '../telemetry.js';
|
|
14
|
-
import { app } from '../utils/app.js';
|
|
15
|
-
import { formatting } from '../utils/formatting.js';
|
|
16
|
-
import { md } from '../utils/md.js';
|
|
17
|
-
import { validation } from '../utils/validation.js';
|
|
18
|
-
import { prompt } from '../utils/prompt.js';
|
|
19
|
-
import { timings } from './timings.js';
|
|
20
|
-
const require = createRequire(import.meta.url);
|
|
21
|
-
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
22
|
-
export class Cli {
|
|
23
|
-
get config() {
|
|
24
|
-
if (!this._config) {
|
|
25
|
-
this._config = new Configstore(config.configstoreName);
|
|
26
|
-
}
|
|
27
|
-
return this._config;
|
|
28
|
-
}
|
|
29
|
-
getSettingWithDefaultValue(settingName, defaultValue) {
|
|
30
|
-
const configuredValue = this.config.get(settingName);
|
|
31
|
-
if (typeof configuredValue === 'undefined') {
|
|
32
|
-
return defaultValue;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return configuredValue;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
constructor() {
|
|
39
|
-
this.commands = [];
|
|
40
|
-
const options = {
|
|
41
|
-
text: 'Running command...',
|
|
42
|
-
/* c8 ignore next 1 */
|
|
43
|
-
stream: this.getSettingWithDefaultValue('errorOutput', 'stderr') === 'stderr' ? process.stderr : process.stdout
|
|
44
|
-
};
|
|
45
|
-
this.spinner = ora(options);
|
|
46
|
-
}
|
|
47
|
-
static getInstance() {
|
|
48
|
-
if (!Cli.instance) {
|
|
49
|
-
Cli.instance = new Cli();
|
|
50
|
-
}
|
|
51
|
-
return Cli.instance;
|
|
52
|
-
}
|
|
53
|
-
async execute(rawArgs) {
|
|
54
|
-
const start = process.hrtime.bigint();
|
|
55
|
-
// for completion commands we also need information about commands' options
|
|
56
|
-
const loadAllCommandInfo = rawArgs.indexOf('completion') > -1;
|
|
57
|
-
this.loadAllCommandsInfo(loadAllCommandInfo);
|
|
58
|
-
// check if help for a specific command has been requested using the
|
|
59
|
-
// 'm365 help xyz' format. If so, remove 'help' from the array of words
|
|
60
|
-
// to use lazy loading commands but keep track of the fact that help should
|
|
61
|
-
// be displayed
|
|
62
|
-
let showHelp = false;
|
|
63
|
-
if (rawArgs.length > 0 && rawArgs[0] === 'help') {
|
|
64
|
-
showHelp = true;
|
|
65
|
-
rawArgs.shift();
|
|
66
|
-
}
|
|
67
|
-
// parse args to see if a command has been specified
|
|
68
|
-
const parsedArgs = minimist(rawArgs);
|
|
69
|
-
// load command
|
|
70
|
-
await this.loadCommandFromArgs(parsedArgs._);
|
|
71
|
-
if (this.commandToExecute) {
|
|
72
|
-
// we have found a command to execute. Parse args again taking into
|
|
73
|
-
// account short and long options, option types and whether the command
|
|
74
|
-
// supports known and unknown options or not
|
|
75
|
-
try {
|
|
76
|
-
this.optionsFromArgs = {
|
|
77
|
-
options: this.getCommandOptionsFromArgs(rawArgs, this.commandToExecute)
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
const optionsWithoutShorts = Cli.removeShortOptions({ options: parsedArgs });
|
|
82
|
-
return this.closeWithError(e.message, optionsWithoutShorts, false);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// we need this to properly support displaying commands
|
|
87
|
-
// from the current group
|
|
88
|
-
this.optionsFromArgs = {
|
|
89
|
-
options: parsedArgs
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
// show help if no match found, help explicitly requested or
|
|
93
|
-
// no command specified
|
|
94
|
-
if (!this.commandToExecute ||
|
|
95
|
-
showHelp ||
|
|
96
|
-
parsedArgs.h ||
|
|
97
|
-
parsedArgs.help) {
|
|
98
|
-
if (parsedArgs.output !== 'none') {
|
|
99
|
-
this.printHelp(await this.getHelpMode(parsedArgs));
|
|
100
|
-
}
|
|
101
|
-
return Promise.resolve();
|
|
102
|
-
}
|
|
103
|
-
const optionsWithoutShorts = Cli.removeShortOptions(this.optionsFromArgs);
|
|
104
|
-
try {
|
|
105
|
-
// replace values staring with @ with file contents
|
|
106
|
-
Cli.loadOptionValuesFromFiles(optionsWithoutShorts);
|
|
107
|
-
}
|
|
108
|
-
catch (e) {
|
|
109
|
-
return this.closeWithError(e, optionsWithoutShorts);
|
|
110
|
-
}
|
|
111
|
-
const startProcessing = process.hrtime.bigint();
|
|
112
|
-
try {
|
|
113
|
-
// process options before passing them on to validation stage
|
|
114
|
-
const contextCommandOptions = await this.loadOptionsFromContext(this.commandToExecute.options, optionsWithoutShorts.options.debug);
|
|
115
|
-
optionsWithoutShorts.options = { ...contextCommandOptions, ...optionsWithoutShorts.options };
|
|
116
|
-
await this.commandToExecute.command.processOptions(optionsWithoutShorts.options);
|
|
117
|
-
const endProcessing = process.hrtime.bigint();
|
|
118
|
-
timings.options.push(Number(endProcessing - startProcessing));
|
|
119
|
-
}
|
|
120
|
-
catch (e) {
|
|
121
|
-
const endProcessing = process.hrtime.bigint();
|
|
122
|
-
timings.options.push(Number(endProcessing - startProcessing));
|
|
123
|
-
return this.closeWithError(e.message, optionsWithoutShorts, false);
|
|
124
|
-
}
|
|
125
|
-
// if output not specified, set the configured output value (if any)
|
|
126
|
-
if (optionsWithoutShorts.options.output === undefined) {
|
|
127
|
-
optionsWithoutShorts.options.output = this.getSettingWithDefaultValue(settingsNames.output, 'json');
|
|
128
|
-
}
|
|
129
|
-
const startValidation = process.hrtime.bigint();
|
|
130
|
-
const validationResult = await this.commandToExecute.command.validate(optionsWithoutShorts, this.commandToExecute);
|
|
131
|
-
const endValidation = process.hrtime.bigint();
|
|
132
|
-
timings.validation.push(Number(endValidation - startValidation));
|
|
133
|
-
if (validationResult !== true) {
|
|
134
|
-
return this.closeWithError(validationResult, optionsWithoutShorts, true);
|
|
135
|
-
}
|
|
136
|
-
const end = process.hrtime.bigint();
|
|
137
|
-
timings.core.push(Number(end - start));
|
|
138
|
-
try {
|
|
139
|
-
await Cli.executeCommand(this.commandToExecute.command, optionsWithoutShorts);
|
|
140
|
-
const endTotal = process.hrtime.bigint();
|
|
141
|
-
timings.total.push(Number(endTotal - start));
|
|
142
|
-
this.printTimings(rawArgs);
|
|
143
|
-
process.exit(0);
|
|
144
|
-
}
|
|
145
|
-
catch (err) {
|
|
146
|
-
const endTotal = process.hrtime.bigint();
|
|
147
|
-
timings.total.push(Number(endTotal - start));
|
|
148
|
-
this.printTimings(rawArgs);
|
|
149
|
-
await this.closeWithError(err, optionsWithoutShorts);
|
|
150
|
-
/* c8 ignore next */
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
printTimings(rawArgs) {
|
|
154
|
-
if (rawArgs.some(arg => arg === '--debug')) {
|
|
155
|
-
Cli.error('');
|
|
156
|
-
Cli.error('Timings:');
|
|
157
|
-
Object.getOwnPropertyNames(timings).forEach(key => {
|
|
158
|
-
Cli.error(`${key}: ${timings[key].reduce((a, b) => a + b, 0) / 1e6}ms`);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
static async executeCommand(command, args) {
|
|
163
|
-
const logger = {
|
|
164
|
-
log: async (message) => {
|
|
165
|
-
if (args.options.output !== 'none') {
|
|
166
|
-
const output = await Cli.formatOutput(command, message, args.options);
|
|
167
|
-
Cli.log(output);
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
logRaw: async (message) => {
|
|
171
|
-
if (args.options.output !== 'none') {
|
|
172
|
-
Cli.log(message);
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
logToStderr: async (message) => {
|
|
176
|
-
if (args.options.output !== 'none') {
|
|
177
|
-
Cli.error(message);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
if (args.options.debug) {
|
|
182
|
-
await logger.logToStderr(`Executing command ${command.name} with options ${JSON.stringify(args)}`);
|
|
183
|
-
}
|
|
184
|
-
// store the current command name, if any and set the name to the name of
|
|
185
|
-
// the command to execute
|
|
186
|
-
const cli = Cli.getInstance();
|
|
187
|
-
const parentCommandName = cli.currentCommandName;
|
|
188
|
-
cli.currentCommandName = command.getCommandName(cli.currentCommandName);
|
|
189
|
-
const showSpinner = cli.getSettingWithDefaultValue(settingsNames.showSpinner, true) && args.options.output !== 'none';
|
|
190
|
-
// don't show spinner if running tests
|
|
191
|
-
/* c8 ignore next 3 */
|
|
192
|
-
if (showSpinner && typeof global.it === 'undefined') {
|
|
193
|
-
cli.spinner.start();
|
|
194
|
-
}
|
|
195
|
-
const startCommand = process.hrtime.bigint();
|
|
196
|
-
try {
|
|
197
|
-
await command.action(logger, args);
|
|
198
|
-
if (args.options.debug || args.options.verbose) {
|
|
199
|
-
const chalk = (await import('chalk')).default;
|
|
200
|
-
await logger.logToStderr(chalk.green('DONE'));
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
finally {
|
|
204
|
-
// restore the original command name
|
|
205
|
-
cli.currentCommandName = parentCommandName;
|
|
206
|
-
/* c8 ignore next 3 */
|
|
207
|
-
if (cli.spinner.isSpinning) {
|
|
208
|
-
cli.spinner.stop();
|
|
209
|
-
}
|
|
210
|
-
const endCommand = process.hrtime.bigint();
|
|
211
|
-
timings.command.push(Number(endCommand - startCommand));
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
static async executeCommandWithOutput(command, args, listener) {
|
|
215
|
-
const log = [];
|
|
216
|
-
const logErr = [];
|
|
217
|
-
const logger = {
|
|
218
|
-
log: async (message) => {
|
|
219
|
-
const formattedMessage = await Cli.formatOutput(command, message, args.options);
|
|
220
|
-
if (listener && listener.stdout) {
|
|
221
|
-
listener.stdout(formattedMessage);
|
|
222
|
-
}
|
|
223
|
-
log.push(formattedMessage);
|
|
224
|
-
},
|
|
225
|
-
logRaw: async (message) => {
|
|
226
|
-
const formattedMessage = await Cli.formatOutput(command, message, args.options);
|
|
227
|
-
if (listener && listener.stdout) {
|
|
228
|
-
listener.stdout(formattedMessage);
|
|
229
|
-
}
|
|
230
|
-
log.push(formattedMessage);
|
|
231
|
-
},
|
|
232
|
-
logToStderr: async (message) => {
|
|
233
|
-
if (listener && listener.stderr) {
|
|
234
|
-
listener.stderr(message);
|
|
235
|
-
}
|
|
236
|
-
logErr.push(message);
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
if (args.options.debug && args.options.output !== 'none') {
|
|
240
|
-
const message = `Executing command ${command.name} with options ${JSON.stringify(args)}`;
|
|
241
|
-
if (listener && listener.stderr) {
|
|
242
|
-
listener.stderr(message);
|
|
243
|
-
}
|
|
244
|
-
logErr.push(message);
|
|
245
|
-
}
|
|
246
|
-
// store the current command name, if any and set the name to the name of
|
|
247
|
-
// the command to execute
|
|
248
|
-
const cli = Cli.getInstance();
|
|
249
|
-
const parentCommandName = cli.currentCommandName;
|
|
250
|
-
cli.currentCommandName = command.getCommandName();
|
|
251
|
-
// store the current logger if any
|
|
252
|
-
const currentLogger = request.logger;
|
|
253
|
-
try {
|
|
254
|
-
await command.action(logger, args);
|
|
255
|
-
return ({
|
|
256
|
-
stdout: log.join(os.EOL),
|
|
257
|
-
stderr: logErr.join(os.EOL)
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
catch (err) {
|
|
261
|
-
// restoring the command and logger is done here instead of in a 'finally' because there were issues with the code coverage tool
|
|
262
|
-
// restore the original command name
|
|
263
|
-
cli.currentCommandName = parentCommandName;
|
|
264
|
-
// restore the original logger
|
|
265
|
-
request.logger = currentLogger;
|
|
266
|
-
throw {
|
|
267
|
-
error: err,
|
|
268
|
-
stderr: logErr.join(os.EOL)
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
/* c8 ignore next */
|
|
272
|
-
finally {
|
|
273
|
-
// restore the original command name
|
|
274
|
-
cli.currentCommandName = parentCommandName;
|
|
275
|
-
// restore the original logger
|
|
276
|
-
request.logger = currentLogger;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
loadAllCommandsInfo(loadFull = false) {
|
|
280
|
-
const commandsInfoFileName = loadFull ? 'allCommandsFull.json' : 'allCommands.json';
|
|
281
|
-
this.commands = require(path.join(__dirname, '..', '..', commandsInfoFileName));
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Loads command files into CLI based on the specified arguments.
|
|
285
|
-
*
|
|
286
|
-
* @param commandNameWords Array of words specified as args
|
|
287
|
-
*/
|
|
288
|
-
async loadCommandFromArgs(commandNameWords) {
|
|
289
|
-
if (commandNameWords.length === 0) {
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
this.currentCommandName = commandNameWords.join(' ');
|
|
293
|
-
const commandFilePath = this.commands
|
|
294
|
-
.find(c => c.name === this.currentCommandName ||
|
|
295
|
-
c.aliases?.find(a => a === this.currentCommandName))?.file ?? '';
|
|
296
|
-
if (commandFilePath) {
|
|
297
|
-
await this.loadCommandFromFile(commandFilePath);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
async loadOptionsFromContext(commandOptions, debug) {
|
|
301
|
-
const filePath = '.m365rc.json';
|
|
302
|
-
let m365rc = {};
|
|
303
|
-
if (!fs.existsSync(filePath)) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
if (debug) {
|
|
307
|
-
await Cli.error('found .m365rc.json file');
|
|
308
|
-
}
|
|
309
|
-
try {
|
|
310
|
-
const fileContents = fs.readFileSync(filePath, 'utf8');
|
|
311
|
-
if (fileContents) {
|
|
312
|
-
m365rc = JSON.parse(fileContents);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
catch (e) {
|
|
316
|
-
await this.closeWithError(`Error parsing ${filePath}`, { options: {} });
|
|
317
|
-
/* c8 ignore next */
|
|
318
|
-
}
|
|
319
|
-
if (!m365rc.context) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
if (debug) {
|
|
323
|
-
await Cli.error('found context in .m365rc.json file');
|
|
324
|
-
}
|
|
325
|
-
const context = m365rc.context;
|
|
326
|
-
const foundOptions = {};
|
|
327
|
-
await commandOptions.forEach(async (option) => {
|
|
328
|
-
if (context[option.name]) {
|
|
329
|
-
foundOptions[option.name] = context[option.name];
|
|
330
|
-
if (debug) {
|
|
331
|
-
await Cli.error(`returning ${option.name} option from context`);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
return foundOptions;
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Loads command from the specified file into CLI. If can't find the file
|
|
339
|
-
* or the file doesn't contain a command, loads all available commands.
|
|
340
|
-
*
|
|
341
|
-
* @param commandFilePathUrl File path of the file with command to load
|
|
342
|
-
*/
|
|
343
|
-
async loadCommandFromFile(commandFileUrl) {
|
|
344
|
-
const commandsFolder = path.join(__dirname, '../m365');
|
|
345
|
-
const filePath = path.join(commandsFolder, commandFileUrl);
|
|
346
|
-
if (!fs.existsSync(filePath)) {
|
|
347
|
-
// reset command name
|
|
348
|
-
this.currentCommandName = undefined;
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
try {
|
|
352
|
-
const command = await import(pathToFileURL(filePath).toString());
|
|
353
|
-
if (command.default instanceof Command) {
|
|
354
|
-
const commandInfo = this.commands.find(c => c.file === commandFileUrl);
|
|
355
|
-
this.commandToExecute = Cli.getCommandInfo(command.default, commandFileUrl, commandInfo?.help);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
catch { }
|
|
359
|
-
}
|
|
360
|
-
static getCommandInfo(command, filePath = '', helpFilePath = '') {
|
|
361
|
-
return {
|
|
362
|
-
aliases: command.alias(),
|
|
363
|
-
name: command.name,
|
|
364
|
-
description: command.description,
|
|
365
|
-
command: command,
|
|
366
|
-
options: this.getCommandOptions(command),
|
|
367
|
-
defaultProperties: command.defaultProperties(),
|
|
368
|
-
file: filePath,
|
|
369
|
-
help: helpFilePath
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
static getCommandOptions(command) {
|
|
373
|
-
const options = [];
|
|
374
|
-
command.options.forEach(option => {
|
|
375
|
-
const required = option.option.indexOf('<') > -1;
|
|
376
|
-
const optionArgs = option.option.split(/[ ,|]+/);
|
|
377
|
-
let short;
|
|
378
|
-
let long;
|
|
379
|
-
let name = '';
|
|
380
|
-
optionArgs.forEach(o => {
|
|
381
|
-
if (o.startsWith('--')) {
|
|
382
|
-
long = o.replace('--', '');
|
|
383
|
-
name = long;
|
|
384
|
-
}
|
|
385
|
-
else if (o.startsWith('-')) {
|
|
386
|
-
short = o.replace('-', '');
|
|
387
|
-
name = short;
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
options.push({
|
|
391
|
-
autocomplete: option.autocomplete,
|
|
392
|
-
long: long,
|
|
393
|
-
name: name,
|
|
394
|
-
required: required,
|
|
395
|
-
short: short
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
return options;
|
|
399
|
-
}
|
|
400
|
-
getCommandOptionsFromArgs(args, commandInfo) {
|
|
401
|
-
const minimistOptions = {
|
|
402
|
-
alias: {}
|
|
403
|
-
};
|
|
404
|
-
let argsToParse = args;
|
|
405
|
-
if (commandInfo) {
|
|
406
|
-
const commandTypes = commandInfo.command.types;
|
|
407
|
-
if (commandTypes) {
|
|
408
|
-
minimistOptions.string = commandTypes.string;
|
|
409
|
-
// minimist will parse unused boolean options to 'false' (unused options => options that are not included in the args)
|
|
410
|
-
// But in the CLI booleans are nullable. They can can be true, false or undefined.
|
|
411
|
-
// For this reason we only pass boolean types that are actually used as arg.
|
|
412
|
-
minimistOptions.boolean = commandTypes.boolean.filter(optionName => args.some(arg => `--${optionName}` === arg || `-${optionName}` === arg));
|
|
413
|
-
}
|
|
414
|
-
minimistOptions.alias = {};
|
|
415
|
-
commandInfo.options.forEach(option => {
|
|
416
|
-
if (option.short && option.long) {
|
|
417
|
-
minimistOptions.alias[option.short] = option.long;
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
argsToParse = this.getRewrittenArgs(args, commandTypes);
|
|
421
|
-
}
|
|
422
|
-
return minimist(argsToParse, minimistOptions);
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Rewrites arguments (if necessary) before passing them into minimist.
|
|
426
|
-
* Currently only boolean values are checked and fixed.
|
|
427
|
-
* Args are only checked and rewritten if the option has been added to the 'types.boolean' array.
|
|
428
|
-
*/
|
|
429
|
-
getRewrittenArgs(args, commandTypes) {
|
|
430
|
-
const booleanTypes = commandTypes.boolean;
|
|
431
|
-
if (booleanTypes.length === 0) {
|
|
432
|
-
return args;
|
|
433
|
-
}
|
|
434
|
-
return args.map((arg, index, array) => {
|
|
435
|
-
if (arg.startsWith('-') || index === 0) {
|
|
436
|
-
return arg;
|
|
437
|
-
}
|
|
438
|
-
// This line checks if the current arg is a value that belongs to a boolean option.
|
|
439
|
-
if (booleanTypes.some(t => `--${t}` === array[index - 1] || `-${t}` === array[index - 1])) {
|
|
440
|
-
const rewrittenBoolean = formatting.rewriteBooleanValue(arg);
|
|
441
|
-
if (!validation.isValidBoolean(rewrittenBoolean)) {
|
|
442
|
-
const optionName = array[index - 1];
|
|
443
|
-
throw new Error(`The value '${arg}' for option '${optionName}' is not a valid boolean`);
|
|
444
|
-
}
|
|
445
|
-
return rewrittenBoolean;
|
|
446
|
-
}
|
|
447
|
-
return arg;
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
static async formatOutput(command, logStatement, options) {
|
|
451
|
-
if (logStatement instanceof Date) {
|
|
452
|
-
return logStatement.toString();
|
|
453
|
-
}
|
|
454
|
-
let logStatementType = typeof logStatement;
|
|
455
|
-
if (logStatementType === 'undefined') {
|
|
456
|
-
return logStatement;
|
|
457
|
-
}
|
|
458
|
-
// we need to get the list of object's properties to see if the specified
|
|
459
|
-
// JMESPath query (if any) filters object's properties or not. We need to
|
|
460
|
-
// know this in order to decide if we should use default command's
|
|
461
|
-
// properties or custom ones from JMESPath
|
|
462
|
-
const originalObject = Array.isArray(logStatement) ? Cli.getFirstNonUndefinedArrayItem(logStatement) : logStatement;
|
|
463
|
-
const originalProperties = originalObject && typeof originalObject !== 'string' ? Object.getOwnPropertyNames(originalObject) : [];
|
|
464
|
-
if (options.query &&
|
|
465
|
-
!options.help) {
|
|
466
|
-
const jmespath = await import('jmespath');
|
|
467
|
-
try {
|
|
468
|
-
logStatement = jmespath.search(logStatement, options.query);
|
|
469
|
-
}
|
|
470
|
-
catch (e) {
|
|
471
|
-
const message = `JMESPath query error. ${e.message}. See https://jmespath.org/specification.html for more information`;
|
|
472
|
-
await Cli.getInstance().closeWithError(message, { options }, false);
|
|
473
|
-
/* c8 ignore next */
|
|
474
|
-
}
|
|
475
|
-
// we need to update the statement type in case the JMESPath query
|
|
476
|
-
// returns an object of different shape than the original message to log
|
|
477
|
-
// #2095
|
|
478
|
-
logStatementType = typeof logStatement;
|
|
479
|
-
}
|
|
480
|
-
if (!options.output || options.output === 'json') {
|
|
481
|
-
return command.getJsonOutput(logStatement);
|
|
482
|
-
}
|
|
483
|
-
if (logStatement instanceof CommandError) {
|
|
484
|
-
const chalk = (await import('chalk')).default;
|
|
485
|
-
return chalk.red(`Error: ${logStatement.message}`);
|
|
486
|
-
}
|
|
487
|
-
let arrayType = '';
|
|
488
|
-
if (!Array.isArray(logStatement)) {
|
|
489
|
-
logStatement = [logStatement];
|
|
490
|
-
arrayType = logStatementType;
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
for (let i = 0; i < logStatement.length; i++) {
|
|
494
|
-
if (Array.isArray(logStatement[i])) {
|
|
495
|
-
arrayType = 'array';
|
|
496
|
-
break;
|
|
497
|
-
}
|
|
498
|
-
const t = typeof logStatement[i];
|
|
499
|
-
if (t !== 'undefined') {
|
|
500
|
-
arrayType = t;
|
|
501
|
-
break;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
if (arrayType !== 'object') {
|
|
506
|
-
return logStatement.join(os.EOL);
|
|
507
|
-
}
|
|
508
|
-
// if output type has been set to 'text', process the retrieved
|
|
509
|
-
// data so that returned objects contain only default properties specified
|
|
510
|
-
// on the current command. If there is no current command or the
|
|
511
|
-
// command doesn't specify default properties, return original data
|
|
512
|
-
if (this.shouldTrimOutput(options.output)) {
|
|
513
|
-
const cli = Cli.getInstance();
|
|
514
|
-
const currentCommand = cli.commandToExecute;
|
|
515
|
-
if (arrayType === 'object' &&
|
|
516
|
-
currentCommand && currentCommand.defaultProperties) {
|
|
517
|
-
// the log statement contains the same properties as the original object
|
|
518
|
-
// so it can be filtered following the default properties specified on
|
|
519
|
-
// the command
|
|
520
|
-
if (JSON.stringify(originalProperties) === JSON.stringify(Object.getOwnPropertyNames(logStatement[0]))) {
|
|
521
|
-
// in some cases we return properties wrapped in `value` array
|
|
522
|
-
// returned by the API. We'll remove it in the future, but for now
|
|
523
|
-
// we'll use a workaround to drop the `value` array here
|
|
524
|
-
if (logStatement[0].value &&
|
|
525
|
-
Array.isArray(logStatement[0].value)) {
|
|
526
|
-
logStatement = logStatement[0].value;
|
|
527
|
-
}
|
|
528
|
-
logStatement = logStatement.map((s) => formatting.filterObject(s, currentCommand.defaultProperties));
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
switch (options.output) {
|
|
533
|
-
case 'csv':
|
|
534
|
-
return command.getCsvOutput(logStatement, options);
|
|
535
|
-
case 'md':
|
|
536
|
-
return command.getMdOutput(logStatement, command, options);
|
|
537
|
-
default:
|
|
538
|
-
return command.getTextOutput(logStatement);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
static getFirstNonUndefinedArrayItem(arr) {
|
|
542
|
-
for (let i = 0; i < arr.length; i++) {
|
|
543
|
-
const a = arr[i];
|
|
544
|
-
if (typeof a !== 'undefined') {
|
|
545
|
-
return a;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
return undefined;
|
|
549
|
-
}
|
|
550
|
-
printHelp(helpMode, exitCode = 0) {
|
|
551
|
-
const properties = {};
|
|
552
|
-
if (this.commandToExecute) {
|
|
553
|
-
properties.command = this.commandToExecute.name;
|
|
554
|
-
this.printCommandHelp(helpMode);
|
|
555
|
-
}
|
|
556
|
-
else {
|
|
557
|
-
Cli.log();
|
|
558
|
-
Cli.log(`CLI for Microsoft 365 v${app.packageJson().version}`);
|
|
559
|
-
Cli.log(`${app.packageJson().description}`);
|
|
560
|
-
Cli.log();
|
|
561
|
-
properties.command = 'commandList';
|
|
562
|
-
this.printAvailableCommands();
|
|
563
|
-
}
|
|
564
|
-
telemetry.trackEvent('help', properties);
|
|
565
|
-
process.exit(exitCode);
|
|
566
|
-
}
|
|
567
|
-
printCommandHelp(helpMode) {
|
|
568
|
-
const docsRootDir = path.join(__dirname, '..', '..', 'docs');
|
|
569
|
-
const helpFilePath = path.join(docsRootDir, 'docs', 'cmd', this.commandToExecute.help);
|
|
570
|
-
if (fs.existsSync(helpFilePath)) {
|
|
571
|
-
let helpContents = fs.readFileSync(helpFilePath, 'utf8');
|
|
572
|
-
helpContents = this.getHelpSection(helpMode, helpContents);
|
|
573
|
-
helpContents = md.md2plain(helpContents, docsRootDir);
|
|
574
|
-
Cli.log();
|
|
575
|
-
Cli.log(helpContents);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
async getHelpMode(options) {
|
|
579
|
-
const { h, help } = options;
|
|
580
|
-
if (!h && !help) {
|
|
581
|
-
return this.getSettingWithDefaultValue(settingsNames.helpMode, Cli.defaultHelpMode);
|
|
582
|
-
}
|
|
583
|
-
// user passed -h or --help, let's see if they passed a specific mode
|
|
584
|
-
// or requested the default
|
|
585
|
-
const helpMode = h ?? help;
|
|
586
|
-
if (typeof helpMode === 'boolean' || typeof helpMode !== 'string') {
|
|
587
|
-
// requested default mode or passed a number, let's use default
|
|
588
|
-
return this.getSettingWithDefaultValue(settingsNames.helpMode, Cli.defaultHelpMode);
|
|
589
|
-
}
|
|
590
|
-
else {
|
|
591
|
-
const lowerCaseHelpMode = helpMode.toLowerCase();
|
|
592
|
-
if (Cli.helpModes.indexOf(lowerCaseHelpMode) < 0) {
|
|
593
|
-
await Cli.getInstance().closeWithError(`Unknown help mode ${helpMode}. Allowed values are ${Cli.helpModes.join(', ')}`, { options }, false);
|
|
594
|
-
/* c8 ignore next 2 */
|
|
595
|
-
return ''; // noop
|
|
596
|
-
}
|
|
597
|
-
else {
|
|
598
|
-
return lowerCaseHelpMode;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
getHelpSection(helpMode, helpContents) {
|
|
603
|
-
if (helpMode === 'full') {
|
|
604
|
-
return helpContents;
|
|
605
|
-
}
|
|
606
|
-
// options is the first section, so get help up to options
|
|
607
|
-
const titleAndUsage = helpContents.substring(0, helpContents.indexOf('## Options'));
|
|
608
|
-
// find the requested section
|
|
609
|
-
const sectionLines = [];
|
|
610
|
-
const sectionName = helpMode[0].toUpperCase() + helpMode.substring(1);
|
|
611
|
-
const lines = helpContents.split('\n');
|
|
612
|
-
for (let i = 0; i < lines.length; i++) {
|
|
613
|
-
const line = lines[i];
|
|
614
|
-
if (line.indexOf(`## ${sectionName}`) === 0) {
|
|
615
|
-
sectionLines.push(line);
|
|
616
|
-
}
|
|
617
|
-
else if (sectionLines.length > 0) {
|
|
618
|
-
if (line.indexOf('## ') === 0) {
|
|
619
|
-
// we've reached the next section, stop
|
|
620
|
-
break;
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
sectionLines.push(line);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
return titleAndUsage + sectionLines.join('\n');
|
|
628
|
-
}
|
|
629
|
-
printAvailableCommands() {
|
|
630
|
-
// commands that match the current group
|
|
631
|
-
const commandsToPrint = {};
|
|
632
|
-
// sub-commands in the current group
|
|
633
|
-
const commandGroupsToPrint = {};
|
|
634
|
-
// current command group, eg. 'spo', 'spo site'
|
|
635
|
-
let currentGroup = '';
|
|
636
|
-
const addToList = (commandName, command) => {
|
|
637
|
-
const pos = commandName.indexOf(' ', currentGroup.length + 1);
|
|
638
|
-
if (pos === -1) {
|
|
639
|
-
commandsToPrint[commandName] = command;
|
|
640
|
-
}
|
|
641
|
-
else {
|
|
642
|
-
const subCommandsGroup = commandName.substr(0, pos);
|
|
643
|
-
if (!commandGroupsToPrint[subCommandsGroup]) {
|
|
644
|
-
commandGroupsToPrint[subCommandsGroup] = 0;
|
|
645
|
-
}
|
|
646
|
-
commandGroupsToPrint[subCommandsGroup]++;
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
// get current command group
|
|
650
|
-
if (this.optionsFromArgs &&
|
|
651
|
-
this.optionsFromArgs.options &&
|
|
652
|
-
this.optionsFromArgs.options._ &&
|
|
653
|
-
this.optionsFromArgs.options._.length > 0) {
|
|
654
|
-
currentGroup = this.optionsFromArgs.options._.join(' ');
|
|
655
|
-
if (currentGroup) {
|
|
656
|
-
currentGroup += ' ';
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
const getCommandsForGroup = () => {
|
|
660
|
-
for (let i = 0; i < this.commands.length; i++) {
|
|
661
|
-
const command = this.commands[i];
|
|
662
|
-
if (command.name.startsWith(currentGroup)) {
|
|
663
|
-
addToList(command.name, command);
|
|
664
|
-
}
|
|
665
|
-
if (command.aliases) {
|
|
666
|
-
for (let j = 0; j < command.aliases.length; j++) {
|
|
667
|
-
const alias = command.aliases[j];
|
|
668
|
-
if (alias.startsWith(currentGroup)) {
|
|
669
|
-
addToList(alias, command);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
};
|
|
675
|
-
getCommandsForGroup();
|
|
676
|
-
if (Object.keys(commandsToPrint).length === 0 &&
|
|
677
|
-
Object.keys(commandGroupsToPrint).length === 0) {
|
|
678
|
-
// specified string didn't match any commands. Reset group and try again
|
|
679
|
-
currentGroup = '';
|
|
680
|
-
getCommandsForGroup();
|
|
681
|
-
}
|
|
682
|
-
const namesOfCommandsToPrint = Object.keys(commandsToPrint);
|
|
683
|
-
if (namesOfCommandsToPrint.length > 0) {
|
|
684
|
-
// determine the length of the longest command name to pad strings + ' [options]'
|
|
685
|
-
const maxLength = Math.max(...namesOfCommandsToPrint.map(s => s.length)) + 10;
|
|
686
|
-
Cli.log(`Commands:`);
|
|
687
|
-
Cli.log();
|
|
688
|
-
const sortedCommandNamesToPrint = Object.getOwnPropertyNames(commandsToPrint).sort();
|
|
689
|
-
sortedCommandNamesToPrint.forEach(commandName => {
|
|
690
|
-
Cli.log(` ${`${commandName} [options]`.padEnd(maxLength, ' ')} ${commandsToPrint[commandName].description}`);
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
const namesOfCommandGroupsToPrint = Object.keys(commandGroupsToPrint);
|
|
694
|
-
if (namesOfCommandGroupsToPrint.length > 0) {
|
|
695
|
-
if (namesOfCommandsToPrint.length > 0) {
|
|
696
|
-
Cli.log();
|
|
697
|
-
}
|
|
698
|
-
// determine the longest command group name to pad strings + ' *'
|
|
699
|
-
const maxLength = Math.max(...namesOfCommandGroupsToPrint.map(s => s.length)) + 2;
|
|
700
|
-
Cli.log(`Commands groups:`);
|
|
701
|
-
Cli.log();
|
|
702
|
-
// sort commands groups (because of aliased commands)
|
|
703
|
-
const sortedCommandGroupsToPrint = Object
|
|
704
|
-
.keys(commandGroupsToPrint)
|
|
705
|
-
.sort()
|
|
706
|
-
.reduce((object, key) => {
|
|
707
|
-
object[key] = commandGroupsToPrint[key];
|
|
708
|
-
return object;
|
|
709
|
-
}, {});
|
|
710
|
-
for (const commandGroup in sortedCommandGroupsToPrint) {
|
|
711
|
-
Cli.log(` ${`${commandGroup} *`.padEnd(maxLength, ' ')} ${commandGroupsToPrint[commandGroup]} command${commandGroupsToPrint[commandGroup] === 1 ? '' : 's'}`);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
Cli.log();
|
|
715
|
-
}
|
|
716
|
-
async closeWithError(error, args, showHelpIfEnabled = false) {
|
|
717
|
-
let exitCode = 1;
|
|
718
|
-
if (args.options.output === 'none') {
|
|
719
|
-
return process.exit(exitCode);
|
|
720
|
-
}
|
|
721
|
-
const chalk = (await import('chalk')).default;
|
|
722
|
-
let errorMessage = error instanceof CommandError ? error.message : error;
|
|
723
|
-
if ((!args.options.output || args.options.output === 'json') &&
|
|
724
|
-
!this.getSettingWithDefaultValue(settingsNames.printErrorsAsPlainText, true)) {
|
|
725
|
-
errorMessage = JSON.stringify({ error: errorMessage });
|
|
726
|
-
}
|
|
727
|
-
else {
|
|
728
|
-
errorMessage = chalk.red(`Error: ${errorMessage}`);
|
|
729
|
-
}
|
|
730
|
-
if (error instanceof CommandError && error.code) {
|
|
731
|
-
exitCode = error.code;
|
|
732
|
-
}
|
|
733
|
-
await Cli.error(errorMessage);
|
|
734
|
-
if (showHelpIfEnabled &&
|
|
735
|
-
await this.getSettingWithDefaultValue(settingsNames.showHelpOnFailure, showHelpIfEnabled)) {
|
|
736
|
-
this.printHelp(await this.getHelpMode(args.options), exitCode);
|
|
737
|
-
}
|
|
738
|
-
else {
|
|
739
|
-
process.exit(exitCode);
|
|
740
|
-
}
|
|
741
|
-
// will never be run. Required for testing where we're stubbing process.exit
|
|
742
|
-
/* c8 ignore next */
|
|
743
|
-
throw new Error(errorMessage);
|
|
744
|
-
/* c8 ignore next */
|
|
745
|
-
}
|
|
746
|
-
static log(message, ...optionalParams) {
|
|
747
|
-
const cli = Cli.getInstance();
|
|
748
|
-
const spinnerSpinning = cli.spinner.isSpinning;
|
|
749
|
-
/* c8 ignore next 3 */
|
|
750
|
-
if (spinnerSpinning) {
|
|
751
|
-
cli.spinner.stop();
|
|
752
|
-
}
|
|
753
|
-
if (message) {
|
|
754
|
-
console.log(message, ...optionalParams);
|
|
755
|
-
}
|
|
756
|
-
else {
|
|
757
|
-
console.log();
|
|
758
|
-
}
|
|
759
|
-
// Restart the spinner if it was running before the log
|
|
760
|
-
/* c8 ignore next 3 */
|
|
761
|
-
if (spinnerSpinning) {
|
|
762
|
-
cli.spinner.start();
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
static async error(message, ...optionalParams) {
|
|
766
|
-
const cli = Cli.getInstance();
|
|
767
|
-
const spinnerSpinning = cli.spinner.isSpinning;
|
|
768
|
-
/* c8 ignore next 3 */
|
|
769
|
-
if (spinnerSpinning) {
|
|
770
|
-
cli.spinner.stop();
|
|
771
|
-
}
|
|
772
|
-
const errorOutput = cli.getSettingWithDefaultValue(settingsNames.errorOutput, 'stderr');
|
|
773
|
-
if (errorOutput === 'stdout') {
|
|
774
|
-
console.log(message, ...optionalParams);
|
|
775
|
-
}
|
|
776
|
-
else {
|
|
777
|
-
console.error(message, ...optionalParams);
|
|
778
|
-
}
|
|
779
|
-
// Restart the spinner if it was running before the log
|
|
780
|
-
/* c8 ignore next 3 */
|
|
781
|
-
if (spinnerSpinning) {
|
|
782
|
-
cli.spinner.start();
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
static async promptForSelection(config) {
|
|
786
|
-
const cli = Cli.getInstance();
|
|
787
|
-
const spinnerSpinning = cli.spinner.isSpinning;
|
|
788
|
-
/* c8 ignore next 3 */
|
|
789
|
-
if (spinnerSpinning) {
|
|
790
|
-
cli.spinner.stop();
|
|
791
|
-
}
|
|
792
|
-
const answer = await prompt.forSelection(config);
|
|
793
|
-
Cli.error('');
|
|
794
|
-
// Restart the spinner if it was running before the prompt
|
|
795
|
-
/* c8 ignore next 3 */
|
|
796
|
-
if (spinnerSpinning) {
|
|
797
|
-
cli.spinner.start();
|
|
798
|
-
}
|
|
799
|
-
return answer;
|
|
800
|
-
}
|
|
801
|
-
static async promptForConfirmation(config) {
|
|
802
|
-
const cli = Cli.getInstance();
|
|
803
|
-
const spinnerSpinning = cli.spinner.isSpinning;
|
|
804
|
-
/* c8 ignore next 3 */
|
|
805
|
-
if (spinnerSpinning) {
|
|
806
|
-
cli.spinner.stop();
|
|
807
|
-
}
|
|
808
|
-
const answer = await prompt.forConfirmation(config);
|
|
809
|
-
Cli.error('');
|
|
810
|
-
// Restart the spinner if it was running before the prompt
|
|
811
|
-
/* c8 ignore next 3 */
|
|
812
|
-
if (spinnerSpinning) {
|
|
813
|
-
cli.spinner.start();
|
|
814
|
-
}
|
|
815
|
-
return answer;
|
|
816
|
-
}
|
|
817
|
-
static async handleMultipleResultsFound(message, values) {
|
|
818
|
-
const prompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt, true);
|
|
819
|
-
if (!prompt) {
|
|
820
|
-
throw new Error(`${message} Found: ${Object.keys(values).join(', ')}.`);
|
|
821
|
-
}
|
|
822
|
-
Cli.error(`🌶️ ${message}`);
|
|
823
|
-
const choices = Object.keys(values).map((choice) => { return { name: choice, value: choice }; });
|
|
824
|
-
const response = await Cli.promptForSelection({ message: `Please choose one:`, choices });
|
|
825
|
-
return values[response];
|
|
826
|
-
}
|
|
827
|
-
static removeShortOptions(args) {
|
|
828
|
-
const filteredArgs = JSON.parse(JSON.stringify(args));
|
|
829
|
-
const optionsToRemove = Object.getOwnPropertyNames(args.options)
|
|
830
|
-
.filter(option => option.length === 1 || option === '--');
|
|
831
|
-
optionsToRemove.forEach(option => delete filteredArgs.options[option]);
|
|
832
|
-
return filteredArgs;
|
|
833
|
-
}
|
|
834
|
-
static loadOptionValuesFromFiles(args) {
|
|
835
|
-
const optionNames = Object.getOwnPropertyNames(args.options);
|
|
836
|
-
optionNames.forEach(option => {
|
|
837
|
-
const value = args.options[option];
|
|
838
|
-
if (!value ||
|
|
839
|
-
typeof value !== 'string' ||
|
|
840
|
-
!value.startsWith('@')) {
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
|
-
const filePath = value.substr(1);
|
|
844
|
-
// if the file doesn't exist, leave as-is, if it exists replace with
|
|
845
|
-
// contents from the file
|
|
846
|
-
if (fs.existsSync(filePath)) {
|
|
847
|
-
args.options[option] = fs.readFileSync(filePath, 'utf-8');
|
|
848
|
-
}
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
static shouldTrimOutput(output) {
|
|
852
|
-
return output === 'text';
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
Cli.defaultHelpMode = 'options';
|
|
856
|
-
Cli.helpModes = ['options', 'examples', 'remarks', 'response', 'full'];
|
|
857
|
-
//# sourceMappingURL=Cli.js.map
|