@pnp/cli-microsoft365 7.1.0-beta.aca68bd → 7.1.0-beta.bcf9db3
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/.devcontainer/Dockerfile +0 -1
- package/.eslintrc.cjs +1 -0
- package/Dockerfile +0 -1
- package/dist/Auth.js +1 -1
- package/dist/Command.js +18 -28
- package/dist/appInsights.js +5 -9
- package/dist/cli/Cli.js +9 -4
- package/dist/m365/aad/commands/group/group-user-list.js +146 -0
- package/dist/m365/aad/commands/m365group/m365group-remove.js +109 -15
- package/dist/m365/aad/commands.js +1 -0
- package/dist/m365/cli/commands/cli-doctor.js +11 -6
- package/dist/m365/commands/setup.js +2 -1
- package/dist/m365/spo/commands/app/app-deploy.js +1 -1
- package/dist/m365/spo/commands/app/app-get.js +1 -1
- package/dist/m365/spo/commands/app/app-teamspackage-download.js +1 -1
- package/dist/m365/spo/commands/apppage/apppage-add.js +1 -1
- package/dist/m365/spo/commands/feature/feature-disable.js +8 -6
- package/dist/m365/spo/commands/feature/feature-enable.js +6 -5
- package/dist/m365/spo/commands/page/Page.js +1 -1
- package/dist/m365/spo/commands/page/page-add.js +1 -1
- package/dist/m365/spo/commands/page/page-get.js +1 -1
- package/dist/m365/spo/commands/page/page-header-set.js +1 -1
- package/dist/m365/spo/commands/page/page-remove.js +1 -1
- package/dist/m365/spo/commands/page/page-set.js +2 -2
- package/dist/m365/spo/commands/page/page-text-add.js +1 -1
- package/dist/m365/spo/commands/sitedesign/sitedesign-get.js +15 -14
- package/dist/m365/spo/commands/sitedesign/sitedesign-remove.js +22 -22
- package/dist/m365/spo/commands/user/user-get.js +7 -1
- package/dist/m365/todo/commands/task/task-list.js +8 -10
- package/dist/m365/todo/commands/task/task-remove.js +36 -36
- package/dist/m365/todo/commands/task/task-set.js +11 -13
- package/dist/m365/yammer/commands/group/group-user-remove.js +22 -23
- package/dist/telemetry.js +30 -14
- package/dist/telemetryRunner.js +26 -0
- package/dist/utils/odata.js +20 -19
- package/dist/utils/prompt.js +16 -0
- package/docs/docs/cmd/aad/group/group-user-list.mdx +135 -0
- package/docs/docs/cmd/aad/license/license-list.mdx +21 -16
- package/docs/docs/cmd/aad/m365group/m365group-add.mdx +1 -1
- package/docs/docs/cmd/aad/m365group/m365group-remove.mdx +11 -1
- package/docs/docs/cmd/aad/user/user-add.mdx +2 -4
- package/docs/docs/cmd/aad/user/user-license-add.mdx +2 -4
- package/docs/docs/cmd/aad/user/user-license-list.mdx +3 -5
- package/docs/docs/cmd/aad/user/user-recyclebinitem-list.mdx +1 -3
- package/docs/docs/cmd/aad/user/user-recyclebinitem-restore.mdx +1 -3
- package/docs/docs/cmd/flow/environment/environment-get.mdx +3 -4
- package/docs/docs/cmd/flow/environment/environment-list.mdx +3 -4
- package/docs/docs/cmd/flow/owner/owner-list.mdx +2 -3
- package/docs/docs/cmd/flow/run/run-list.mdx +6 -8
- package/docs/docs/cmd/graph/schemaextension/schemaextension-list.mdx +2 -3
- package/docs/docs/cmd/onenote/page/page-list.mdx +6 -9
- package/docs/docs/cmd/outlook/message/message-get.mdx +5 -15
- package/docs/docs/cmd/outlook/message/message-list.mdx +5 -14
- package/docs/docs/cmd/outlook/room/room-list.mdx +3 -6
- package/docs/docs/cmd/outlook/roomlist/roomlist-list.mdx +1 -3
- package/docs/docs/cmd/pa/app/app-get.mdx +4 -7
- package/docs/docs/cmd/pa/app/app-list.mdx +4 -7
- package/docs/docs/cmd/pa/connector/connector-list.mdx +2 -4
- package/docs/docs/cmd/pa/environment/environment-get.mdx +2 -4
- package/docs/docs/cmd/pa/environment/environment-list.mdx +1 -3
- package/docs/docs/cmd/planner/plan/plan-add.mdx +4 -11
- package/docs/docs/cmd/planner/plan/plan-get.mdx +4 -9
- package/docs/docs/cmd/planner/plan/plan-list.mdx +3 -6
- package/docs/docs/cmd/planner/plan/plan-set.mdx +3 -9
- package/docs/docs/cmd/planner/roster/roster-member-add.mdx +2 -4
- package/docs/docs/cmd/planner/roster/roster-member-get.mdx +2 -4
- package/docs/docs/cmd/planner/roster/roster-member-list.mdx +1 -3
- package/docs/docs/cmd/planner/task/task-add.mdx +4 -14
- package/docs/docs/cmd/planner/task/task-checklistitem-add.mdx +2 -4
- package/docs/docs/cmd/planner/task/task-checklistitem-list.mdx +1 -3
- package/docs/docs/cmd/planner/task/task-get.mdx +0 -7
- package/docs/docs/cmd/planner/task/task-list.mdx +1 -5
- package/docs/docs/cmd/planner/task/task-reference-add.mdx +0 -2
- package/docs/docs/cmd/planner/task/task-reference-list.mdx +0 -2
- package/docs/docs/cmd/planner/task/task-set.mdx +4 -13
- package/docs/docs/cmd/planner/tenant/tenant-settings-list.mdx +1 -3
- package/docs/docs/cmd/planner/tenant/tenant-settings-set.mdx +3 -5
- package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-get.mdx +6 -8
- package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-list.mdx +4 -7
- package/docs/docs/cmd/pp/card/card-get.mdx +4 -8
- package/docs/docs/cmd/pp/card/card-list.mdx +0 -4
- package/docs/docs/cmd/pp/chatbot/chatbot-get.mdx +4 -6
- package/docs/docs/cmd/pp/dataverse/dataverse-table-get.mdx +3 -14
- package/docs/docs/cmd/pp/dataverse/dataverse-table-list.mdx +3 -14
- package/docs/docs/cmd/pp/environment/environment-get.mdx +3 -5
- package/docs/docs/cmd/pp/environment/environment-list.mdx +2 -4
- package/docs/docs/cmd/pp/gateway/gateway-get.mdx +0 -3
- package/docs/docs/cmd/pp/gateway/gateway-list.mdx +1 -4
- package/docs/docs/cmd/purview/auditlog/auditlog-list.mdx +4 -0
- package/docs/docs/cmd/purview/retentionevent/retentionevent-add.mdx +3 -8
- package/docs/docs/cmd/purview/retentionevent/retentionevent-get.mdx +1 -3
- package/docs/docs/cmd/purview/retentionevent/retentionevent-list.mdx +1 -5
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.mdx +0 -2
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-get.mdx +1 -3
- package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-list.mdx +1 -3
- package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-get.mdx +3 -6
- package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-list.mdx +3 -5
- package/docs/docs/cmd/purview/threatassessment/threatassessment-get.mdx +4 -8
- package/docs/docs/cmd/spo/app/app-add.mdx +94 -7
- package/docs/docs/cmd/spo/app/app-deploy.mdx +11 -7
- package/docs/docs/cmd/spo/app/app-get.mdx +117 -8
- package/docs/docs/cmd/spo/app/app-install.mdx +9 -5
- package/docs/docs/cmd/spo/app/app-instance-list.mdx +85 -2
- package/docs/docs/cmd/spo/app/app-list.mdx +95 -3
- package/docs/docs/cmd/spo/app/app-remove.mdx +11 -7
- package/docs/docs/cmd/spo/app/app-retract.mdx +9 -5
- package/docs/docs/cmd/spo/app/app-teamspackage-download.mdx +12 -8
- package/docs/docs/cmd/spo/app/app-uninstall.mdx +11 -7
- package/docs/docs/cmd/spo/app/app-upgrade.mdx +9 -5
- package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.mdx +4 -2
- package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +9 -7
- package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-list.mdx +6 -6
- package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-remove.mdx +12 -6
- package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-set.mdx +4 -2
- package/docs/docs/cmd/spo/apppage/apppage-add.mdx +54 -5
- package/docs/docs/cmd/spo/apppage/apppage-set.mdx +8 -4
- package/docs/docs/cmd/spo/cdn/cdn-get.mdx +36 -1
- package/docs/docs/cmd/spo/cdn/cdn-origin-add.mdx +7 -3
- package/docs/docs/cmd/spo/cdn/cdn-origin-list.mdx +48 -3
- package/docs/docs/cmd/spo/cdn/cdn-origin-remove.mdx +8 -4
- package/docs/docs/cmd/spo/cdn/cdn-policy-list.mdx +53 -3
- package/docs/docs/cmd/spo/cdn/cdn-policy-set.mdx +7 -3
- package/docs/docs/cmd/spo/cdn/cdn-set.mdx +7 -3
- package/docs/docs/cmd/spo/commandset/commandset-add.mdx +6 -6
- package/docs/docs/cmd/spo/commandset/commandset-get.mdx +3 -5
- package/docs/docs/cmd/spo/commandset/commandset-list.mdx +6 -5
- package/docs/docs/cmd/spo/commandset/commandset-remove.mdx +7 -3
- package/docs/docs/cmd/spo/commandset/commandset-set.mdx +6 -4
- package/docs/docs/cmd/spo/contenttype/contenttype-add.mdx +148 -9
- package/docs/docs/cmd/spo/contenttype/contenttype-field-remove.mdx +19 -15
- package/docs/docs/cmd/spo/contenttype/contenttype-field-set.mdx +12 -8
- package/docs/docs/cmd/spo/contenttype/contenttype-get.mdx +147 -8
- package/docs/docs/cmd/spo/contenttype/contenttype-list.mdx +115 -4
- package/docs/docs/cmd/spo/contenttype/contenttype-remove.mdx +8 -4
- package/docs/docs/cmd/spo/contenttype/contenttype-set.mdx +8 -4
- package/docs/docs/cmd/spo/contenttypehub/contenttypehub-get.mdx +44 -0
- package/docs/docs/cmd/spo/customaction/customaction-add.mdx +12 -8
- package/docs/docs/cmd/spo/customaction/customaction-clear.mdx +10 -7
- package/docs/docs/cmd/spo/customaction/customaction-get.mdx +11 -15
- package/docs/docs/cmd/spo/customaction/customaction-list.mdx +87 -5
- package/docs/docs/cmd/spo/customaction/customaction-remove.mdx +17 -13
- package/docs/docs/cmd/spo/customaction/customaction-set.mdx +27 -23
- package/docs/docs/cmd/spo/eventreceiver/eventreceiver-get.mdx +29 -14
- package/docs/docs/cmd/spo/eventreceiver/eventreceiver-list.mdx +66 -5
- package/docs/docs/cmd/spo/eventreceiver/eventreceiver-remove.mdx +4 -0
- package/docs/docs/cmd/spo/externaluser/externaluser-list.mdx +78 -7
- package/docs/docs/cmd/spo/feature/feature-disable.mdx +10 -6
- package/docs/docs/cmd/spo/feature/feature-enable.mdx +9 -5
- package/docs/docs/cmd/spo/feature/feature-list.mdx +52 -0
- package/docs/docs/cmd/spo/field/field-add.mdx +177 -11
- package/docs/docs/cmd/spo/field/field-get.mdx +175 -9
- package/docs/docs/cmd/spo/field/field-list.mdx +135 -8
- package/docs/docs/cmd/spo/field/field-remove.mdx +16 -12
- package/docs/docs/cmd/spo/field/field-set.mdx +15 -11
- package/docs/docs/cmd/spo/file/file-add.mdx +31 -27
- package/docs/docs/cmd/spo/file/file-checkin.mdx +13 -9
- package/docs/docs/cmd/spo/file/file-checkout.mdx +9 -5
- package/docs/docs/cmd/spo/file/file-copy.mdx +5 -5
- package/docs/docs/cmd/spo/file/file-get.mdx +89 -18
- package/docs/docs/cmd/spo/file/file-list.mdx +5 -5
- package/docs/docs/cmd/spo/file/file-move.mdx +5 -5
- package/docs/docs/cmd/spo/file/file-remove.mdx +13 -9
- package/docs/docs/cmd/spo/file/file-rename.mdx +63 -5
- package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.mdx +3 -3
- package/docs/docs/cmd/spo/file/file-retentionlabel-remove.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-roleassignment-add.mdx +4 -0
- package/docs/docs/cmd/spo/file/file-roleassignment-remove.mdx +7 -3
- package/docs/docs/cmd/spo/file/file-roleinheritance-break.mdx +9 -5
- package/docs/docs/cmd/spo/file/file-roleinheritance-reset.mdx +10 -6
- package/docs/docs/cmd/spo/file/file-sharinginfo-get.mdx +133 -5
- package/docs/docs/cmd/spo/file/file-sharinglink-add.mdx +21 -3
- package/docs/docs/cmd/spo/file/file-sharinglink-clear.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-sharinglink-get.mdx +18 -0
- package/docs/docs/cmd/spo/file/file-sharinglink-list.mdx +20 -3
- package/docs/docs/cmd/spo/file/file-sharinglink-set.mdx +2 -7
- package/docs/docs/cmd/spo/file/file-version-clear.mdx +7 -7
- package/docs/docs/cmd/spo/file/file-version-get.mdx +28 -6
- package/docs/docs/cmd/spo/file/file-version-list.mdx +28 -6
- package/docs/docs/cmd/spo/file/file-version-remove.mdx +8 -8
- package/docs/docs/cmd/spo/file/file-version-restore.mdx +8 -8
- package/docs/docs/cmd/spo/folder/folder-add.mdx +3 -3
- package/docs/docs/cmd/spo/folder/folder-copy.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-get.mdx +257 -3
- package/docs/docs/cmd/spo/folder/folder-list.mdx +3 -4
- package/docs/docs/cmd/spo/folder/folder-move.mdx +5 -5
- package/docs/docs/cmd/spo/folder/folder-remove.mdx +6 -2
- package/docs/docs/cmd/spo/folder/folder-rename.mdx +2 -2
- package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.mdx +3 -3
- package/docs/docs/cmd/spo/folder/folder-retentionlabel-remove.mdx +2 -2
- package/docs/docs/cmd/spo/folder/folder-roleassignment-add.mdx +13 -8
- package/docs/docs/cmd/spo/folder/folder-roleassignment-remove.mdx +8 -4
- package/docs/docs/cmd/spo/folder/folder-roleinheritance-break.mdx +4 -0
- package/docs/docs/cmd/spo/folder/folder-roleinheritance-reset.mdx +5 -1
- package/docs/docs/cmd/spo/group/group-add.mdx +78 -0
- package/docs/docs/cmd/spo/group/group-get.mdx +81 -3
- package/docs/docs/cmd/spo/group/group-list.mdx +74 -3
- package/docs/docs/cmd/spo/group/group-member-add.mdx +13 -21
- package/docs/docs/cmd/spo/group/group-member-list.mdx +80 -5
- package/docs/docs/cmd/spo/group/group-member-remove.mdx +4 -4
- package/docs/docs/cmd/spo/group/group-remove.mdx +10 -6
- package/docs/docs/cmd/spo/group/group-set.mdx +9 -5
- package/docs/docs/cmd/spo/hidedefaultthemes/hidedefaultthemes-get.mdx +36 -1
- package/docs/docs/cmd/spo/hidedefaultthemes/hidedefaultthemes-set.mdx +6 -2
- package/docs/docs/cmd/spo/hubsite/hubsite-data-get.mdx +0 -2
- package/docs/docs/cmd/spo/list/list-add.mdx +0 -3
- package/docs/docs/cmd/spo/list/list-contenttype-add.mdx +0 -2
- package/docs/docs/cmd/spo/list/list-contenttype-list.mdx +0 -2
- package/docs/docs/cmd/spo/list/list-get.mdx +1 -4
- package/docs/docs/cmd/spo/list/list-list.mdx +0 -4
- package/docs/docs/cmd/spo/list/list-view-add.mdx +0 -3
- package/docs/docs/cmd/spo/list/list-view-get.mdx +9 -12
- package/docs/docs/cmd/spo/list/list-view-list.mdx +4 -7
- package/docs/docs/cmd/spo/listitem/listitem-attachment-list.mdx +8 -11
- package/docs/docs/cmd/spo/listitem/listitem-get.mdx +0 -2
- package/docs/docs/cmd/spo/navigation/navigation-node-add.mdx +4 -6
- package/docs/docs/cmd/spo/navigation/navigation-node-get.mdx +0 -2
- package/docs/docs/cmd/spo/navigation/navigation-node-list.mdx +4 -6
- package/docs/docs/cmd/spo/page/page-copy.mdx +4 -8
- package/docs/docs/cmd/spo/page/page-get.mdx +2 -5
- package/docs/docs/cmd/spo/page/page-list.mdx +1 -5
- package/docs/docs/cmd/spo/sitescript/sitescript-get.mdx +4 -4
- package/docs/docs/cmd/spo/sitescript/sitescript-set.mdx +6 -7
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.mdx +3 -1
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-get.mdx +5 -3
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.mdx +4 -2
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-remove.mdx +5 -1
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-set.mdx +2 -0
- package/docs/docs/cmd/spo/tenant/tenant-commandset-add.mdx +2 -1
- package/docs/docs/cmd/spo/tenant/tenant-commandset-get.mdx +5 -2
- package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +4 -1
- package/docs/docs/cmd/spo/tenant/tenant-commandset-remove.mdx +5 -1
- package/docs/docs/cmd/spo/tenant/tenant-commandset-set.mdx +3 -1
- package/docs/docs/cmd/spo/user/user-get.mdx +6 -0
- package/docs/docs/cmd/teams/channel/channel-member-list.mdx +3 -5
- package/docs/docs/cmd/teams/channel/channel-member-set.mdx +0 -2
- package/docs/docs/cmd/teams/chat/chat-get.mdx +2 -4
- package/docs/docs/cmd/teams/chat/chat-list.mdx +1 -3
- package/docs/docs/cmd/teams/chat/chat-member-list.mdx +2 -4
- package/docs/docs/cmd/teams/message/message-get.mdx +0 -7
- package/docs/docs/cmd/teams/message/message-list.mdx +0 -6
- package/docs/docs/cmd/teams/message/message-reply-list.mdx +0 -6
- package/docs/docs/cmd/teams/tab/tab-add.mdx +10 -12
- package/docs/docs/cmd/teams/tab/tab-get.mdx +8 -10
- package/docs/docs/cmd/teams/tab/tab-list.mdx +4 -7
- package/docs/docs/cmd/teams/team/team-add.mdx +0 -7
- package/docs/docs/cmd/teams/team/team-get.mdx +0 -6
- package/docs/docs/cmd/tenant/security/security-alerts-list.mdx +1 -1
- package/docs/docs/cmd/todo/task/task-add.mdx +9 -13
- package/docs/docs/cmd/todo/task/task-set.mdx +10 -14
- package/eslint-rules/lib/index.js +2 -1
- package/eslint-rules/lib/rules/no-by-server-relative-url-usage.js +55 -0
- package/npm-shrinkwrap.json +86 -82
- package/package.json +52 -31
package/.devcontainer/Dockerfile
CHANGED
|
@@ -6,7 +6,6 @@ LABEL name="CLI for Microsoft 365 Development" \
|
|
|
6
6
|
maintainers="Waldek Mastykarz <waldek@mastykarz.nl>, \
|
|
7
7
|
Garry Trinder <garry.trinder@live.com>, \
|
|
8
8
|
Albert-Jan Schot <appie@digiwijs.nl>, \
|
|
9
|
-
Rabia Williams <rabiawilliams@gmail.com>, \
|
|
10
9
|
Patrick Lamber <patrick@nubo.eu>, \
|
|
11
10
|
Arjun Menon <arjun.umenon@gmail.com>, \
|
|
12
11
|
Adam Wojcik <adam.wojcik.it@gmail.com>, \
|
package/.eslintrc.cjs
CHANGED
|
@@ -136,6 +136,7 @@ module.exports = {
|
|
|
136
136
|
"rules": {
|
|
137
137
|
"cli-microsoft365/correct-command-class-name": ["error", sortedDictionary, capitalized],
|
|
138
138
|
"cli-microsoft365/correct-command-name": "error",
|
|
139
|
+
"cli-microsoft365/no-by-server-relative-url-usage": "error",
|
|
139
140
|
"indent": "off",
|
|
140
141
|
"@typescript-eslint/indent": [
|
|
141
142
|
"error",
|
package/Dockerfile
CHANGED
|
@@ -8,7 +8,6 @@ LABEL name="m365pnp/cli-microsoft365:${CLI_VERSION}" \
|
|
|
8
8
|
maintainers="Waldek Mastykarz <waldek@mastykarz.nl>, \
|
|
9
9
|
Garry Trinder <garry.trinder@live.com>, \
|
|
10
10
|
Albert-Jan Schot <appie@digiwijs.nl>, \
|
|
11
|
-
Rabia Williams <rabiawilliams@gmail.com>, \
|
|
12
11
|
Patrick Lamber <patrick@nubo.eu>, \
|
|
13
12
|
Arjun Menon <arjun.umenon@gmail.com>, \
|
|
14
13
|
Adam Wojcik <adam.wojcik.it@gmail.com>, \
|
package/dist/Auth.js
CHANGED
package/dist/Command.js
CHANGED
|
@@ -12,6 +12,7 @@ import { settingsNames } from './settingsNames.js';
|
|
|
12
12
|
import { telemetry } from './telemetry.js';
|
|
13
13
|
import { accessToken } from './utils/accessToken.js';
|
|
14
14
|
import { md } from './utils/md.js';
|
|
15
|
+
import { prompt } from './utils/prompt.js';
|
|
15
16
|
export class CommandError {
|
|
16
17
|
constructor(message, code) {
|
|
17
18
|
this.message = message;
|
|
@@ -75,7 +76,6 @@ class Command {
|
|
|
75
76
|
}
|
|
76
77
|
async validateRequiredOptions(args, command) {
|
|
77
78
|
const shouldPrompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt, true);
|
|
78
|
-
let inquirer;
|
|
79
79
|
let prompted = false;
|
|
80
80
|
for (let i = 0; i < command.options.length; i++) {
|
|
81
81
|
if (!command.options[i].required ||
|
|
@@ -87,19 +87,17 @@ class Command {
|
|
|
87
87
|
}
|
|
88
88
|
if (!prompted) {
|
|
89
89
|
prompted = true;
|
|
90
|
-
Cli.
|
|
90
|
+
Cli.error('🌶️ Provide values for the following parameters:');
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
inquirer = await import('inquirer');
|
|
94
|
-
}
|
|
95
|
-
const missingRequireOptionValue = await inquirer.default
|
|
96
|
-
.prompt({
|
|
92
|
+
const missingRequireOptionValue = await prompt.forInput({
|
|
97
93
|
name: 'missingRequireOptionValue',
|
|
98
94
|
message: `${command.options[i].name}: `
|
|
99
|
-
})
|
|
100
|
-
.then(result => result.missingRequireOptionValue);
|
|
95
|
+
}).then(result => result.missingRequireOptionValue);
|
|
101
96
|
args.options[command.options[i].name] = missingRequireOptionValue;
|
|
102
97
|
}
|
|
98
|
+
if (prompted) {
|
|
99
|
+
Cli.error('');
|
|
100
|
+
}
|
|
103
101
|
this.processOptions(args.options);
|
|
104
102
|
return true;
|
|
105
103
|
}
|
|
@@ -108,7 +106,6 @@ class Command {
|
|
|
108
106
|
if (!optionsSets || optionsSets.length === 0) {
|
|
109
107
|
return true;
|
|
110
108
|
}
|
|
111
|
-
let inquirer;
|
|
112
109
|
const shouldPrompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt, true);
|
|
113
110
|
const argsOptions = Object.keys(args.options);
|
|
114
111
|
for (const optionSet of optionsSets.sort(opt => opt.runsWhen ? 0 : 1)) {
|
|
@@ -120,50 +117,43 @@ class Command {
|
|
|
120
117
|
if (!shouldPrompt) {
|
|
121
118
|
return `Specify one of the following options: ${optionSet.options.join(', ')}.`;
|
|
122
119
|
}
|
|
123
|
-
await this.promptForOptionSetNameAndValue(args, optionSet
|
|
120
|
+
await this.promptForOptionSetNameAndValue(args, optionSet);
|
|
124
121
|
}
|
|
125
122
|
if (commonOptions.length > 1) {
|
|
126
123
|
if (!shouldPrompt) {
|
|
127
124
|
return `Specify one of the following options: ${optionSet.options.join(', ')}, but not multiple.`;
|
|
128
125
|
}
|
|
129
|
-
await this.promptForSpecificOption(args, commonOptions
|
|
126
|
+
await this.promptForSpecificOption(args, commonOptions);
|
|
130
127
|
}
|
|
131
128
|
}
|
|
132
129
|
return true;
|
|
133
130
|
}
|
|
134
|
-
async promptForOptionSetNameAndValue(args, optionSet
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
Cli.log(`Please specify one of the following options:`);
|
|
139
|
-
const resultOptionName = await inquirer.default.prompt({
|
|
131
|
+
async promptForOptionSetNameAndValue(args, optionSet) {
|
|
132
|
+
Cli.error(`🌶️ Please specify one of the following options:`);
|
|
133
|
+
const resultOptionName = await prompt.forInput({
|
|
140
134
|
type: 'list',
|
|
141
135
|
name: 'missingRequiredOptionName',
|
|
142
136
|
message: `Option to use:`,
|
|
143
137
|
choices: optionSet.options
|
|
144
138
|
});
|
|
145
139
|
const missingRequiredOptionName = resultOptionName.missingRequiredOptionName;
|
|
146
|
-
const resultOptionValue = await
|
|
147
|
-
.prompt({
|
|
140
|
+
const resultOptionValue = await prompt.forInput({
|
|
148
141
|
name: 'missingRequiredOptionValue',
|
|
149
142
|
message: `${missingRequiredOptionName}:`
|
|
150
143
|
});
|
|
151
144
|
args.options[missingRequiredOptionName] = resultOptionValue.missingRequiredOptionValue;
|
|
152
|
-
Cli.
|
|
145
|
+
Cli.error('');
|
|
153
146
|
}
|
|
154
|
-
async promptForSpecificOption(args, commonOptions
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
Cli.log(`Multiple options for an option set specified. Please specify the correct option that you wish to use.`);
|
|
159
|
-
const requiredOptionNameResult = await inquirer.default.prompt({
|
|
147
|
+
async promptForSpecificOption(args, commonOptions) {
|
|
148
|
+
Cli.error(`🌶️ Multiple options for an option set specified. Please specify the correct option that you wish to use.`);
|
|
149
|
+
const requiredOptionNameResult = await prompt.forInput({
|
|
160
150
|
type: 'list',
|
|
161
151
|
name: 'missingRequiredOptionName',
|
|
162
152
|
message: `Option to use:`,
|
|
163
153
|
choices: commonOptions
|
|
164
154
|
});
|
|
165
155
|
commonOptions.filter(y => y !== requiredOptionNameResult.missingRequiredOptionName).map(optionName => args.options[optionName] = undefined);
|
|
166
|
-
Cli.
|
|
156
|
+
Cli.error('');
|
|
167
157
|
}
|
|
168
158
|
async validateOutput(args) {
|
|
169
159
|
if (args.options.output &&
|
package/dist/appInsights.js
CHANGED
|
@@ -9,7 +9,6 @@ import fs from 'fs';
|
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import url from 'url';
|
|
11
11
|
import { app } from './utils/app.js';
|
|
12
|
-
import { pid } from './utils/pid.js';
|
|
13
12
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
14
13
|
const config = appInsights.setup('6b908c80-d09f-4cf6-8274-e54349a0149a');
|
|
15
14
|
config.setInternalLogging(false, false);
|
|
@@ -18,17 +17,14 @@ config.setInternalLogging(false, false);
|
|
|
18
17
|
// in the telemetry
|
|
19
18
|
const version = `${app.packageJson().version}${fs.existsSync(path.join(__dirname, `..${path.sep}src`)) ? '-dev' : ''}`;
|
|
20
19
|
const env = process.env.CLIMICROSOFT365_ENV !== undefined ? process.env.CLIMICROSOFT365_ENV : '';
|
|
21
|
-
appInsights.default.defaultClient
|
|
20
|
+
const appInsightsClient = appInsights.default.defaultClient;
|
|
21
|
+
appInsightsClient.commonProperties = {
|
|
22
22
|
version: version,
|
|
23
23
|
node: process.version,
|
|
24
|
-
shell: pid.getProcessName(process.ppid) || '',
|
|
25
24
|
env: env,
|
|
26
25
|
ci: Boolean(process.env.CI).toString()
|
|
27
26
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
crypto.createHash('sha256').update(appInsights.default.defaultClient.context.tags['ai.cloud.roleInstance']).digest('hex');
|
|
32
|
-
delete appInsights.default.defaultClient.context.tags['ai.cloud.role'];
|
|
33
|
-
export default appInsights.default.defaultClient;
|
|
27
|
+
appInsightsClient.context.tags['ai.cloud.roleInstance'] = crypto.createHash('sha256').update(appInsightsClient.context.tags['ai.cloud.roleInstance']).digest('hex');
|
|
28
|
+
appInsightsClient.context.tags['ai.cloud.role'];
|
|
29
|
+
export default appInsightsClient;
|
|
34
30
|
//# sourceMappingURL=appInsights.js.map
|
package/dist/cli/Cli.js
CHANGED
|
@@ -15,6 +15,7 @@ import { formatting } from '../utils/formatting.js';
|
|
|
15
15
|
import { fsUtil } from '../utils/fsUtil.js';
|
|
16
16
|
import { md } from '../utils/md.js';
|
|
17
17
|
import { validation } from '../utils/validation.js';
|
|
18
|
+
import { prompt } from '../utils/prompt.js';
|
|
18
19
|
export class Cli {
|
|
19
20
|
get config() {
|
|
20
21
|
if (!this._config) {
|
|
@@ -31,11 +32,15 @@ export class Cli {
|
|
|
31
32
|
return configuredValue;
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
35
35
|
constructor() {
|
|
36
36
|
this.commands = [];
|
|
37
37
|
this.commandsFolder = '';
|
|
38
|
-
|
|
38
|
+
const options = {
|
|
39
|
+
text: 'Running command...',
|
|
40
|
+
/* c8 ignore next 1 */
|
|
41
|
+
stream: this.getSettingWithDefaultValue('errorOutput', 'stderr') === 'stderr' ? process.stderr : process.stdout
|
|
42
|
+
};
|
|
43
|
+
this.spinner = ora(options);
|
|
39
44
|
}
|
|
40
45
|
static getInstance() {
|
|
41
46
|
if (!Cli.instance) {
|
|
@@ -799,14 +804,13 @@ export class Cli {
|
|
|
799
804
|
}
|
|
800
805
|
}
|
|
801
806
|
static async prompt(options, answers) {
|
|
802
|
-
const inquirer = await import('inquirer');
|
|
803
807
|
const cli = Cli.getInstance();
|
|
804
808
|
const spinnerSpinning = cli.spinner.isSpinning;
|
|
805
809
|
/* c8 ignore next 3 */
|
|
806
810
|
if (spinnerSpinning) {
|
|
807
811
|
cli.spinner.stop();
|
|
808
812
|
}
|
|
809
|
-
const response = await
|
|
813
|
+
const response = await prompt.forInput(options, answers);
|
|
810
814
|
// Restart the spinner if it was running before the prompt
|
|
811
815
|
/* c8 ignore next 3 */
|
|
812
816
|
if (spinnerSpinning) {
|
|
@@ -823,6 +827,7 @@ export class Cli {
|
|
|
823
827
|
type: 'list',
|
|
824
828
|
name: 'select',
|
|
825
829
|
default: 0,
|
|
830
|
+
prefix: '🌶️ ',
|
|
826
831
|
message: `${message} Please choose one:`,
|
|
827
832
|
choices: Object.keys(values)
|
|
828
833
|
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _AadGroupUserListCommand_instances, _AadGroupUserListCommand_initTelemetry, _AadGroupUserListCommand_initOptions, _AadGroupUserListCommand_initOptionSets, _AadGroupUserListCommand_initValidators;
|
|
7
|
+
import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
8
|
+
import { odata } from '../../../../utils/odata.js';
|
|
9
|
+
import { validation } from '../../../../utils/validation.js';
|
|
10
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
|
+
import commands from '../../commands.js';
|
|
12
|
+
class AadGroupUserListCommand extends GraphCommand {
|
|
13
|
+
get name() {
|
|
14
|
+
return commands.GROUP_USER_LIST;
|
|
15
|
+
}
|
|
16
|
+
get description() {
|
|
17
|
+
return 'Lists users of a specific Azure AD group';
|
|
18
|
+
}
|
|
19
|
+
defaultProperties() {
|
|
20
|
+
return ['id', 'displayName', 'userPrincipalName', 'roles'];
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
_AadGroupUserListCommand_instances.add(this);
|
|
25
|
+
__classPrivateFieldGet(this, _AadGroupUserListCommand_instances, "m", _AadGroupUserListCommand_initTelemetry).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _AadGroupUserListCommand_instances, "m", _AadGroupUserListCommand_initOptions).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _AadGroupUserListCommand_instances, "m", _AadGroupUserListCommand_initOptionSets).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _AadGroupUserListCommand_instances, "m", _AadGroupUserListCommand_initValidators).call(this);
|
|
29
|
+
}
|
|
30
|
+
async commandAction(logger, args) {
|
|
31
|
+
try {
|
|
32
|
+
const groupId = await this.getGroupId(args.options, logger);
|
|
33
|
+
const users = [];
|
|
34
|
+
if (!args.options.role || args.options.role === 'Owner') {
|
|
35
|
+
const owners = await this.getUsers(args.options, 'Owners', groupId, logger);
|
|
36
|
+
owners.forEach(owner => users.push({ ...owner, roles: ['Owner'] }));
|
|
37
|
+
}
|
|
38
|
+
if (!args.options.role || args.options.role === 'Member') {
|
|
39
|
+
const members = await this.getUsers(args.options, 'Members', groupId, logger);
|
|
40
|
+
members.forEach((member) => {
|
|
41
|
+
const user = users.find((u) => u.id === member.id);
|
|
42
|
+
if (user !== undefined) {
|
|
43
|
+
user.roles.push('Member');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
users.push({ ...member, roles: ['Member'] });
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
await logger.log(users);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
this.handleRejectedODataJsonPromise(err);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async getGroupId(options, logger) {
|
|
57
|
+
if (options.groupId) {
|
|
58
|
+
return options.groupId;
|
|
59
|
+
}
|
|
60
|
+
if (this.verbose) {
|
|
61
|
+
await logger.logToStderr('Retrieving Group Id...');
|
|
62
|
+
}
|
|
63
|
+
return await aadGroup.getGroupIdByDisplayName(options.groupDisplayName);
|
|
64
|
+
}
|
|
65
|
+
async getUsers(options, role, groupId, logger) {
|
|
66
|
+
const { properties, filter } = options;
|
|
67
|
+
if (this.verbose) {
|
|
68
|
+
await logger.logToStderr(`Retrieving ${role} of the group with id ${groupId}`);
|
|
69
|
+
}
|
|
70
|
+
const selectProperties = properties ?
|
|
71
|
+
`${properties.split(',').filter(f => f.toLowerCase() !== 'id').concat('id').map(p => p.trim()).join(',')}` :
|
|
72
|
+
'id,displayName,userPrincipalName,givenName,surname';
|
|
73
|
+
const allSelectProperties = selectProperties.split(',');
|
|
74
|
+
const propertiesWithSlash = allSelectProperties.filter(item => item.includes('/'));
|
|
75
|
+
let fieldExpand = '';
|
|
76
|
+
propertiesWithSlash.forEach(p => {
|
|
77
|
+
if (fieldExpand.length > 0) {
|
|
78
|
+
fieldExpand += ',';
|
|
79
|
+
}
|
|
80
|
+
fieldExpand += `${p.split('/')[0]}($select=${p.split('/')[1]})`;
|
|
81
|
+
});
|
|
82
|
+
const expandParam = fieldExpand.length > 0 ? `&$expand=${fieldExpand}` : '';
|
|
83
|
+
const selectParam = allSelectProperties.filter(item => !item.includes('/'));
|
|
84
|
+
const endpoint = `${this.resource}/v1.0/groups/${groupId}/${role}/microsoft.graph.user?$select=${selectParam}${expandParam}`;
|
|
85
|
+
let users = [];
|
|
86
|
+
if (filter) {
|
|
87
|
+
// While using the filter, we need to specify the ConsistencyLevel header.
|
|
88
|
+
// Can be refactored when the header is no longer necessary.
|
|
89
|
+
const requestOptions = {
|
|
90
|
+
url: `${endpoint}&$filter=${encodeURIComponent(filter)}&$count=true`,
|
|
91
|
+
headers: {
|
|
92
|
+
accept: 'application/json;odata.metadata=none',
|
|
93
|
+
ConsistencyLevel: 'eventual'
|
|
94
|
+
},
|
|
95
|
+
responseType: 'json'
|
|
96
|
+
};
|
|
97
|
+
users = await odata.getAllItems(requestOptions);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
users = await odata.getAllItems(endpoint);
|
|
101
|
+
}
|
|
102
|
+
return users;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_AadGroupUserListCommand_instances = new WeakSet(), _AadGroupUserListCommand_initTelemetry = function _AadGroupUserListCommand_initTelemetry() {
|
|
106
|
+
this.telemetry.push((args) => {
|
|
107
|
+
Object.assign(this.telemetryProperties, {
|
|
108
|
+
groupId: typeof args.options.groupId !== 'undefined',
|
|
109
|
+
groupDisplayName: typeof args.options.groupDisplayName !== 'undefined',
|
|
110
|
+
role: typeof args.options.role !== 'undefined',
|
|
111
|
+
properties: typeof args.options.properties !== 'undefined',
|
|
112
|
+
filter: typeof args.options.filter !== 'undefined'
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}, _AadGroupUserListCommand_initOptions = function _AadGroupUserListCommand_initOptions() {
|
|
116
|
+
this.options.unshift({
|
|
117
|
+
option: "-i, --groupId [groupId]"
|
|
118
|
+
}, {
|
|
119
|
+
option: "-n, --groupDisplayName [groupDisplayName]"
|
|
120
|
+
}, {
|
|
121
|
+
option: "-r, --role [role]",
|
|
122
|
+
autocomplete: ["Owner", "Member"]
|
|
123
|
+
}, {
|
|
124
|
+
option: "-p, --properties [properties]"
|
|
125
|
+
}, {
|
|
126
|
+
option: "-f, --filter [filter]"
|
|
127
|
+
});
|
|
128
|
+
}, _AadGroupUserListCommand_initOptionSets = function _AadGroupUserListCommand_initOptionSets() {
|
|
129
|
+
this.optionSets.push({
|
|
130
|
+
options: ['groupId', 'groupDisplayName']
|
|
131
|
+
});
|
|
132
|
+
}, _AadGroupUserListCommand_initValidators = function _AadGroupUserListCommand_initValidators() {
|
|
133
|
+
this.validators.push(async (args) => {
|
|
134
|
+
if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
|
|
135
|
+
return `${args.options.groupId} is not a valid GUID`;
|
|
136
|
+
}
|
|
137
|
+
if (args.options.role) {
|
|
138
|
+
if (['Owner', 'Member'].indexOf(args.options.role) === -1) {
|
|
139
|
+
return `${args.options.role} is not a valid role value. Allowed values Owner|Member`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
export default new AadGroupUserListCommand();
|
|
146
|
+
//# sourceMappingURL=group-user-list.js.map
|
|
@@ -10,16 +10,21 @@ import { aadGroup } from '../../../../utils/aadGroup.js';
|
|
|
10
10
|
import { validation } from '../../../../utils/validation.js';
|
|
11
11
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
12
12
|
import commands from '../../commands.js';
|
|
13
|
+
import config from '../../../../config.js';
|
|
14
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
15
|
+
import { spo } from '../../../../utils/spo.js';
|
|
16
|
+
import { setTimeout } from 'timers/promises';
|
|
13
17
|
class AadM365GroupRemoveCommand extends GraphCommand {
|
|
14
18
|
get name() {
|
|
15
19
|
return commands.M365GROUP_REMOVE;
|
|
16
20
|
}
|
|
17
21
|
get description() {
|
|
18
|
-
return 'Removes
|
|
22
|
+
return 'Removes a Microsoft 365 Group';
|
|
19
23
|
}
|
|
20
24
|
constructor() {
|
|
21
25
|
super();
|
|
22
26
|
_AadM365GroupRemoveCommand_instances.add(this);
|
|
27
|
+
this.intervalInMs = 5000;
|
|
23
28
|
__classPrivateFieldGet(this, _AadM365GroupRemoveCommand_instances, "m", _AadM365GroupRemoveCommand_initTelemetry).call(this);
|
|
24
29
|
__classPrivateFieldGet(this, _AadM365GroupRemoveCommand_instances, "m", _AadM365GroupRemoveCommand_initOptions).call(this);
|
|
25
30
|
__classPrivateFieldGet(this, _AadM365GroupRemoveCommand_instances, "m", _AadM365GroupRemoveCommand_initValidators).call(this);
|
|
@@ -34,21 +39,13 @@ class AadM365GroupRemoveCommand extends GraphCommand {
|
|
|
34
39
|
if (!isUnifiedGroup) {
|
|
35
40
|
throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
|
|
36
41
|
}
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
await request.delete(requestOptions);
|
|
42
|
+
const siteUrl = await this.getM365GroupSiteUrl(logger, args.options.id);
|
|
43
|
+
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
44
|
+
// Delete the Microsoft 365 group site. This operation will also delete the group.
|
|
45
|
+
await this.deleteM365GroupSite(logger, siteUrl, spoAdminUrl);
|
|
44
46
|
if (args.options.skipRecycleBin) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
headers: {
|
|
48
|
-
'accept': 'application/json;odata.metadata=none'
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
await request.delete(requestOptions2);
|
|
47
|
+
await this.deleteM365GroupFromRecycleBin(logger, args.options.id);
|
|
48
|
+
await this.deleteSiteFromRecycleBin(logger, siteUrl, spoAdminUrl);
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
catch (err) {
|
|
@@ -70,6 +67,102 @@ class AadM365GroupRemoveCommand extends GraphCommand {
|
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
}
|
|
70
|
+
async getM365GroupSiteUrl(logger, id) {
|
|
71
|
+
if (this.verbose) {
|
|
72
|
+
await logger.logToStderr(`Getting the site URL of Microsoft 365 Group: ${id}...`);
|
|
73
|
+
}
|
|
74
|
+
const requestOptions = {
|
|
75
|
+
url: `${this.resource}/v1.0/groups/${id}/drive?$select=webUrl`,
|
|
76
|
+
headers: {
|
|
77
|
+
accept: 'application/json;odata.metadata=none'
|
|
78
|
+
},
|
|
79
|
+
responseType: 'json'
|
|
80
|
+
};
|
|
81
|
+
const res = await request.get(requestOptions);
|
|
82
|
+
// Extract the base URL by removing everything after the last '/' character in the URL.
|
|
83
|
+
const baseUrl = res.webUrl.substring(0, res.webUrl.lastIndexOf('/'));
|
|
84
|
+
return baseUrl;
|
|
85
|
+
}
|
|
86
|
+
async deleteM365GroupSite(logger, url, spoAdminUrl) {
|
|
87
|
+
if (this.verbose) {
|
|
88
|
+
await logger.logToStderr(`Deleting the group site: '${url}'...`);
|
|
89
|
+
}
|
|
90
|
+
const requestOptions = {
|
|
91
|
+
url: `${spoAdminUrl}/_api/GroupSiteManager/Delete?siteUrl='${url}'`,
|
|
92
|
+
headers: {
|
|
93
|
+
accept: 'application/json;odata=nometadata'
|
|
94
|
+
},
|
|
95
|
+
responseType: 'json'
|
|
96
|
+
};
|
|
97
|
+
await request.post(requestOptions);
|
|
98
|
+
}
|
|
99
|
+
async deleteM365GroupFromRecycleBin(logger, id) {
|
|
100
|
+
for (let retries = 0; retries < AadM365GroupRemoveCommand.maxRetries; retries++) {
|
|
101
|
+
if (await this.isM365GroupInDeletedItemsList(id)) {
|
|
102
|
+
await this.removeM365GroupPermanently(logger, id);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
if (this.verbose) {
|
|
107
|
+
await logger.logToStderr(`Group has not been deleted yet. Waiting for ${this.intervalInMs / 1000} seconds before the next attempt. ${AadM365GroupRemoveCommand.maxRetries - retries} attempts remaining...`);
|
|
108
|
+
}
|
|
109
|
+
await setTimeout(this.intervalInMs);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
await logger.logToStderr(`Group has been successfully deleted, but it couldn't be permanently removed from the recycle bin after all retries. It will still appear in the deleted groups list.`);
|
|
113
|
+
}
|
|
114
|
+
async removeM365GroupPermanently(logger, id) {
|
|
115
|
+
if (this.verbose) {
|
|
116
|
+
await logger.logToStderr(`Group has been deleted and is now available in the deleted groups list. Removing permanently...`);
|
|
117
|
+
}
|
|
118
|
+
const requestOptions = {
|
|
119
|
+
url: `${this.resource}/v1.0/directory/deletedItems/${id}`,
|
|
120
|
+
headers: {
|
|
121
|
+
accept: 'application/json;odata.metadata=none'
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
await request.delete(requestOptions);
|
|
125
|
+
}
|
|
126
|
+
async isM365GroupInDeletedItemsList(id) {
|
|
127
|
+
const requestOptions = {
|
|
128
|
+
url: `${this.resource}/v1.0/directory/deletedItems/${id}`,
|
|
129
|
+
headers: {
|
|
130
|
+
accept: 'application/json;odata.metadata=none'
|
|
131
|
+
},
|
|
132
|
+
responseType: 'json'
|
|
133
|
+
};
|
|
134
|
+
try {
|
|
135
|
+
const response = await request.get(requestOptions);
|
|
136
|
+
return Boolean(response && response.id);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (error.response && error.response.status === 404) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async deleteSiteFromRecycleBin(logger, url, spoAdminUrl) {
|
|
148
|
+
if (this.verbose) {
|
|
149
|
+
await logger.logToStderr(`Deleting the M365 group site '${url}' from the recycle bin...`);
|
|
150
|
+
}
|
|
151
|
+
const res = await spo.ensureFormDigest(spoAdminUrl, logger, undefined, this.debug);
|
|
152
|
+
const requestOptions = {
|
|
153
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
154
|
+
headers: {
|
|
155
|
+
'X-RequestDigest': res.FormDigestValue
|
|
156
|
+
},
|
|
157
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="185" ObjectPathId="184" /><Query Id="186" ObjectPathId="184"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Method Id="184" ParentId="175" Name="RemoveDeletedSite"><Parameters><Parameter Type="String">${formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
158
|
+
};
|
|
159
|
+
const processQuery = await request.post(requestOptions);
|
|
160
|
+
const json = JSON.parse(processQuery);
|
|
161
|
+
const response = json[0];
|
|
162
|
+
if (response.ErrorInfo) {
|
|
163
|
+
throw response.ErrorInfo.ErrorMessage;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
73
166
|
}
|
|
74
167
|
_AadM365GroupRemoveCommand_instances = new WeakSet(), _AadM365GroupRemoveCommand_initTelemetry = function _AadM365GroupRemoveCommand_initTelemetry() {
|
|
75
168
|
this.telemetry.push((args) => {
|
|
@@ -94,5 +187,6 @@ _AadM365GroupRemoveCommand_instances = new WeakSet(), _AadM365GroupRemoveCommand
|
|
|
94
187
|
return true;
|
|
95
188
|
});
|
|
96
189
|
};
|
|
190
|
+
AadM365GroupRemoveCommand.maxRetries = 10;
|
|
97
191
|
export default new AadM365GroupRemoveCommand();
|
|
98
192
|
//# sourceMappingURL=m365group-remove.js.map
|
|
@@ -14,6 +14,7 @@ export default {
|
|
|
14
14
|
GROUP_GET: `${prefix} group get`,
|
|
15
15
|
GROUP_LIST: `${prefix} group list`,
|
|
16
16
|
GROUP_REMOVE: `${prefix} group remove`,
|
|
17
|
+
GROUP_USER_LIST: `${prefix} group user list`,
|
|
17
18
|
GROUPSETTING_ADD: `${prefix} groupsetting add`,
|
|
18
19
|
GROUPSETTING_GET: `${prefix} groupsetting get`,
|
|
19
20
|
GROUPSETTING_LIST: `${prefix} groupsetting list`,
|
|
@@ -14,11 +14,14 @@ class CliDoctorCommand extends Command {
|
|
|
14
14
|
}
|
|
15
15
|
async commandAction(logger) {
|
|
16
16
|
const roles = [];
|
|
17
|
-
const scopes =
|
|
17
|
+
const scopes = new Map();
|
|
18
18
|
Object.keys(auth.service.accessTokens).forEach(resource => {
|
|
19
19
|
const accessToken = auth.service.accessTokens[resource].accessToken;
|
|
20
20
|
this.getRolesFromAccessToken(accessToken).forEach(role => roles.push(role));
|
|
21
|
-
this.getScopesFromAccessToken(accessToken)
|
|
21
|
+
const [res, scp] = this.getScopesFromAccessToken(accessToken);
|
|
22
|
+
if (res !== "") {
|
|
23
|
+
scopes.set(res, scp);
|
|
24
|
+
}
|
|
22
25
|
});
|
|
23
26
|
const diagnosticInfo = {
|
|
24
27
|
os: {
|
|
@@ -34,7 +37,7 @@ class CliDoctorCommand extends Command {
|
|
|
34
37
|
cliEnvironment: process.env.CLIMICROSOFT365_ENV ? process.env.CLIMICROSOFT365_ENV : '',
|
|
35
38
|
cliConfig: Cli.getInstance().config.all,
|
|
36
39
|
roles: roles,
|
|
37
|
-
scopes: scopes
|
|
40
|
+
scopes: Object.fromEntries(scopes)
|
|
38
41
|
};
|
|
39
42
|
await logger.log(diagnosticInfo);
|
|
40
43
|
}
|
|
@@ -55,20 +58,22 @@ class CliDoctorCommand extends Command {
|
|
|
55
58
|
return roles;
|
|
56
59
|
}
|
|
57
60
|
getScopesFromAccessToken(accessToken) {
|
|
61
|
+
let resource = "";
|
|
58
62
|
let scopes = [];
|
|
59
63
|
if (!accessToken || accessToken.length === 0) {
|
|
60
|
-
return scopes;
|
|
64
|
+
return [resource, scopes];
|
|
61
65
|
}
|
|
62
66
|
const chunks = accessToken.split('.');
|
|
63
67
|
if (chunks.length !== 3) {
|
|
64
|
-
return scopes;
|
|
68
|
+
return [resource, scopes];
|
|
65
69
|
}
|
|
66
70
|
const tokenString = Buffer.from(chunks[1], 'base64').toString();
|
|
67
71
|
const token = JSON.parse(tokenString);
|
|
68
72
|
if (token.scp?.length > 0) {
|
|
73
|
+
resource = token.aud.replace(/(-my|-admin).sharepoint.com/, '.sharepoint.com');
|
|
69
74
|
scopes = token.scp.split(' ');
|
|
70
75
|
}
|
|
71
|
-
return scopes;
|
|
76
|
+
return [resource, scopes];
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
79
|
export default new CliDoctorCommand();
|
|
@@ -12,6 +12,7 @@ import { pid } from '../../utils/pid.js';
|
|
|
12
12
|
import AnonymousCommand from '../base/AnonymousCommand.js';
|
|
13
13
|
import commands from './commands.js';
|
|
14
14
|
import { interactivePreset, powerShellPreset, scriptingPreset } from './setupPresets.js';
|
|
15
|
+
import { prompt } from '../../utils/prompt.js';
|
|
15
16
|
class SetupCommand extends AnonymousCommand {
|
|
16
17
|
get name() {
|
|
17
18
|
return commands.SETUP;
|
|
@@ -48,7 +49,7 @@ class SetupCommand extends AnonymousCommand {
|
|
|
48
49
|
await logger.logToStderr(`This command will guide you through the process of configuring the CLI for your needs.`);
|
|
49
50
|
await logger.logToStderr(`Please, answer the following questions and we'll define a set of settings to best match how you intend to use the CLI.`);
|
|
50
51
|
await logger.logToStderr('');
|
|
51
|
-
const preferences = await
|
|
52
|
+
const preferences = await prompt.forInput([
|
|
52
53
|
{
|
|
53
54
|
type: 'list',
|
|
54
55
|
name: 'usageMode',
|
|
@@ -43,7 +43,7 @@ class SpoAppDeployCommand extends SpoAppBaseCommand {
|
|
|
43
43
|
await logger.logToStderr(`Looking up app id for app named ${args.options.name}...`);
|
|
44
44
|
}
|
|
45
45
|
const requestOptions = {
|
|
46
|
-
url: `${appCatalogUrl}/_api/web/
|
|
46
|
+
url: `${appCatalogUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='AppCatalog')/files('${args.options.name}')?$select=UniqueId`,
|
|
47
47
|
headers: {
|
|
48
48
|
accept: 'application/json;odata=nometadata'
|
|
49
49
|
},
|
|
@@ -39,7 +39,7 @@ class SpoAppGetCommand extends SpoAppBaseCommand {
|
|
|
39
39
|
await logger.logToStderr(`Looking up app id for app named ${args.options.name}...`);
|
|
40
40
|
}
|
|
41
41
|
const requestOptions = {
|
|
42
|
-
url: `${appCatalogSiteUrl}/_api/web/
|
|
42
|
+
url: `${appCatalogSiteUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='AppCatalog')/files('${args.options.name}')?$select=UniqueId`,
|
|
43
43
|
headers: {
|
|
44
44
|
accept: 'application/json;odata=nometadata'
|
|
45
45
|
},
|
|
@@ -88,7 +88,7 @@ class SpoAppTeamsPackageDownloadCommand extends SpoAppBaseCommand {
|
|
|
88
88
|
url += `GetList('${serverRelativeAppCatalogListUrl}')/GetItemById(${args.options.appItemId})?$expand=File&$select=File/Name`;
|
|
89
89
|
}
|
|
90
90
|
else if (args.options.appName) {
|
|
91
|
-
url += `
|
|
91
|
+
url += `GetFolderByServerRelativePath(DecodedUrl='${appCatalogListName}')/files('${formatting.encodeQueryParameter(args.options.appName)}')/ListItemAllFields?$select=Id`;
|
|
92
92
|
}
|
|
93
93
|
const requestOptions = {
|
|
94
94
|
url,
|
|
@@ -38,7 +38,7 @@ class SpoAppPageAddCommand extends SpoCommand {
|
|
|
38
38
|
const page = await request.post(createPageRequestOptions);
|
|
39
39
|
const pageUrl = page.value;
|
|
40
40
|
let requestOptions = {
|
|
41
|
-
url: `${args.options.webUrl}/_api/web/
|
|
41
|
+
url: `${args.options.webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${urlUtil.getServerRelativeSiteUrl(args.options.webUrl)}/${pageUrl}')?$expand=ListItemAllFields`,
|
|
42
42
|
headers: {
|
|
43
43
|
'content-type': 'application/json;charset=utf-8',
|
|
44
44
|
accept: 'application/json;odata=nometadata'
|