@pnp/cli-microsoft365 7.0.0-beta.c0afb7b → 7.0.0-beta.c2db9df
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/README.md +4 -4
- package/dist/cli/Cli.js +3 -3
- package/dist/m365/aad/commands/app/app-add.js +8 -8
- package/dist/m365/aad/commands/app/app-get.js +4 -1
- package/dist/m365/aad/commands/app/app-remove.js +3 -1
- package/dist/m365/aad/commands/app/app-role-add.js +9 -6
- package/dist/m365/aad/commands/app/app-role-list.js +4 -1
- package/dist/m365/aad/commands/app/app-role-remove.js +5 -2
- package/dist/m365/aad/commands/app/app-set.js +9 -6
- package/dist/m365/aad/commands/approleassignment/approleassignment-add.js +7 -2
- package/dist/m365/aad/commands/group/group-get.js +4 -4
- package/dist/m365/aad/commands/group/group-list.js +1 -23
- package/dist/m365/aad/commands/m365group/m365group-add.js +12 -9
- package/dist/m365/aad/commands/m365group/m365group-recyclebinitem-remove.js +3 -1
- package/dist/m365/aad/commands/m365group/m365group-recyclebinitem-restore.js +4 -1
- package/dist/m365/aad/commands/m365group/m365group-teamify.js +4 -1
- package/dist/m365/aad/commands/policy/policy-list.js +5 -5
- package/dist/m365/aad/commands/sp/sp-add.js +4 -1
- package/dist/m365/aad/commands/sp/sp-get.js +4 -1
- package/dist/m365/aad/commands/user/user-get.js +7 -2
- package/dist/m365/booking/commands/business/business-get.js +4 -1
- package/dist/m365/cli/commands/cli-issue.js +5 -5
- package/dist/m365/cli/commands/config/config-get.js +5 -5
- package/dist/m365/cli/commands/config/config-reset.js +5 -5
- package/dist/m365/cli/commands/config/config-set.js +5 -5
- package/dist/m365/commands/login.js +5 -5
- package/dist/m365/commands/request.js +1 -1
- package/dist/m365/flow/commands/owner/owner-ensure.js +5 -5
- package/dist/m365/outlook/commands/message/message-list.js +4 -2
- package/dist/m365/outlook/commands/message/message-move.js +4 -2
- package/dist/m365/pa/commands/app/app-export.js +7 -7
- package/dist/m365/pa/commands/app/app-owner-set.js +5 -5
- package/dist/m365/pa/commands/app/app-permission-ensure.js +5 -5
- package/dist/m365/planner/commands/bucket/bucket-get.js +5 -1
- package/dist/m365/planner/commands/bucket/bucket-remove.js +3 -1
- package/dist/m365/planner/commands/bucket/bucket-set.js +4 -1
- package/dist/m365/planner/commands/task/task-add.js +17 -11
- package/dist/m365/planner/commands/task/task-get.js +42 -27
- package/dist/m365/planner/commands/task/task-list.js +26 -19
- package/dist/m365/planner/commands/task/task-remove.js +45 -37
- package/dist/m365/planner/commands/task/task-set.js +35 -23
- package/dist/m365/pp/commands/aibuildermodel/aibuildermodel-get.js +4 -1
- package/dist/m365/pp/commands/card/card-get.js +3 -5
- package/dist/m365/pp/commands/chatbot/chatbot-get.js +3 -1
- package/dist/m365/pp/commands/managementapp/managementapp-add.js +4 -1
- package/dist/m365/purview/commands/retentionlabel/retentionlabel-add.js +14 -14
- package/dist/m365/search/commands/externalconnection/externalconnection-remove.js +3 -1
- package/dist/m365/spfx/commands/package/package-generate.js +15 -15
- package/dist/m365/spfx/commands/project/DeployWorkflow.js +55 -0
- package/dist/m365/spfx/commands/project/project-doctor/{doctor-1.18.0-beta.5.js → doctor-1.18.0-rc.1.js} +2 -2
- package/dist/m365/spfx/commands/project/project-doctor.js +9 -9
- package/dist/m365/spfx/commands/project/project-github-workflow-add.js +157 -0
- package/dist/m365/spfx/commands/project/project-github-workflow-model.js +2 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002028_DEVDEP_microsoft_rush_stack_compiler_4_7.js +13 -0
- package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.18.0-beta.5.js → upgrade-1.18.0-rc.1.js} +35 -27
- package/dist/m365/spfx/commands/project/project-upgrade.js +14 -14
- package/dist/m365/spfx/commands/spfx-doctor.js +3 -3
- package/dist/m365/spfx/commands.js +1 -0
- package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-add.js +5 -5
- package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +5 -3
- package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-list.js +5 -5
- package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-remove.js +2 -2
- package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-set.js +3 -2
- package/dist/m365/spo/commands/commandset/commandset-add.js +11 -11
- package/dist/m365/spo/commands/commandset/commandset-get.js +12 -10
- package/dist/m365/spo/commands/commandset/commandset-list.js +5 -5
- package/dist/m365/spo/commands/commandset/commandset-remove.js +7 -6
- package/dist/m365/spo/commands/commandset/commandset-set.js +14 -12
- package/dist/m365/spo/commands/customaction/customaction-get.js +5 -2
- package/dist/m365/spo/commands/customaction/customaction-remove.js +3 -1
- package/dist/m365/spo/commands/eventreceiver/eventreceiver-get.js +3 -1
- package/dist/m365/spo/commands/file/file-get.js +9 -6
- package/dist/m365/spo/commands/file/file-sharinglink-add.js +8 -8
- package/dist/m365/spo/commands/file/file-sharinglink-list.js +5 -5
- package/dist/m365/spo/commands/hubsite/hubsite-connect.js +7 -4
- package/dist/m365/spo/commands/hubsite/hubsite-disconnect.js +4 -1
- package/dist/m365/spo/commands/hubsite/hubsite-get.js +3 -1
- package/dist/m365/spo/commands/list/list-add.js +4 -4
- package/dist/m365/spo/commands/list/list-set.js +4 -4
- package/dist/m365/spo/commands/listitem/listitem-add.js +1 -0
- package/dist/m365/spo/commands/listitem/listitem-set.js +3 -2
- package/dist/m365/spo/commands/orgassetslibrary/orgassetslibrary-add.js +8 -8
- package/dist/m365/spo/commands/page/clientsidepages.js +18 -0
- package/dist/m365/spo/commands/page/page-get.js +1 -0
- package/dist/m365/spo/commands/page/page-list.js +4 -3
- package/dist/m365/spo/commands/page/page-section-add.js +56 -21
- package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-set.js +30 -32
- package/dist/m365/spo/commands/site/site-add.js +114 -161
- package/dist/m365/spo/commands/site/site-apppermission-add.js +15 -18
- package/dist/m365/spo/commands/site/site-apppermission-remove.js +34 -38
- package/dist/m365/spo/commands/site/site-apppermission-set.js +11 -14
- package/dist/m365/spo/commands/site/site-ensure.js +13 -66
- package/dist/m365/spo/commands/site/site-list.js +5 -7
- package/dist/m365/spo/commands/site/site-recyclebinitem-list.js +6 -6
- package/dist/m365/spo/commands/site/site-remove.js +166 -210
- package/dist/m365/spo/commands/site/site-set.js +121 -153
- package/dist/m365/spo/commands/tenant/tenant-appcatalog-add.js +1 -1
- package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +8 -3
- package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-list.js +3 -2
- package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-remove.js +2 -1
- package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-set.js +3 -2
- package/dist/m365/spo/commands/tenant/tenant-commandset-add.js +8 -8
- package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +8 -3
- package/dist/m365/spo/commands/tenant/tenant-commandset-list.js +3 -2
- package/dist/m365/spo/commands/tenant/tenant-commandset-remove.js +3 -1
- package/dist/m365/spo/commands/tenant/tenant-commandset-set.js +8 -8
- package/dist/m365/spo/commands/tenant/tenant-settings-set.js +4 -4
- package/dist/m365/spo/commands/term/term-get.js +6 -6
- package/dist/m365/spo/commands/web/web-roleinheritance-break.js +3 -3
- package/dist/m365/spo/commands/web/web-set.js +5 -5
- package/dist/m365/teams/commands/app/app-list.js +5 -5
- package/dist/m365/teams/commands/channel/channel-add.js +5 -1
- package/dist/m365/teams/commands/channel/channel-member-add.js +4 -2
- package/dist/m365/teams/commands/channel/channel-member-remove.js +3 -1
- package/dist/m365/teams/commands/channel/channel-member-set.js +4 -1
- package/dist/m365/teams/commands/chat/chat-get.js +7 -10
- package/dist/m365/teams/commands/chat/chat-member-add.js +5 -5
- package/dist/m365/teams/commands/chat/chat-message-send.js +8 -10
- package/dist/m365/teams/commands/funsettings/funsettings-set.js +4 -4
- package/dist/m365/teams/commands/guestsettings/guestsettings-set.js +4 -4
- package/dist/m365/teams/commands/membersettings/membersettings-set.js +4 -4
- package/dist/m365/teams/commands/messagingsettings/messagingsettings-set.js +5 -5
- package/dist/m365/teams/commands/team/team-clone.js +5 -10
- package/dist/m365/teams/commands/team/team-list.js +94 -30
- package/dist/m365/teams/commands/team/team-set.js +3 -3
- package/dist/m365/tenant/commands/info/info-get.js +83 -0
- package/dist/m365/tenant/commands.js +1 -0
- package/dist/m365/todo/commands/task/task-add.js +6 -6
- package/dist/m365/yammer/commands/message/message-list.js +5 -5
- package/dist/m365/yammer/commands/yammer-search.js +5 -5
- package/dist/utils/aadGroup.js +23 -3
- package/dist/utils/formatting.js +7 -0
- package/dist/utils/fsUtil.js +5 -0
- package/dist/utils/powerPlatform.js +1 -1
- package/dist/utils/spo.js +582 -0
- package/docs/docs/cmd/aad/group/group-get.mdx +5 -5
- package/docs/docs/cmd/aad/group/group-list.mdx +0 -11
- package/docs/docs/cmd/aad/policy/policy-list.mdx +5 -5
- package/docs/docs/cmd/cli/config/config-list.mdx +1 -1
- package/docs/docs/cmd/pa/app/app-export.mdx +5 -5
- package/docs/docs/cmd/planner/task/task-add.mdx +22 -7
- package/docs/docs/cmd/planner/task/task-get.mdx +13 -4
- package/docs/docs/cmd/planner/task/task-list.mdx +22 -7
- package/docs/docs/cmd/planner/task/task-remove.mdx +25 -8
- package/docs/docs/cmd/planner/task/task-set.mdx +22 -7
- package/docs/docs/cmd/spfx/project/project-github-workflow-add.mdx +94 -0
- package/docs/docs/cmd/spo/listitem/listitem-add.mdx +2 -5
- package/docs/docs/cmd/spo/listitem/listitem-set.mdx +2 -5
- package/docs/docs/cmd/spo/page/page-get.mdx +0 -1
- package/docs/docs/cmd/spo/page/page-list.mdx +0 -1
- package/docs/docs/cmd/spo/page/page-section-add.mdx +25 -1
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.mdx +2 -4
- package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +2 -4
- package/docs/docs/cmd/teams/team/team-clone.mdx +3 -3
- package/docs/docs/cmd/teams/team/team-list.mdx +47 -22
- package/docs/docs/cmd/tenant/info/info-get.mdx +101 -0
- package/npm-shrinkwrap.json +196 -193
- package/package.json +8 -12
|
@@ -5,14 +5,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _SpoSiteEnsureCommand_instances, _SpoSiteEnsureCommand_initOptions, _SpoSiteEnsureCommand_initTypes, _SpoSiteEnsureCommand_initValidators;
|
|
7
7
|
import chalk from 'chalk';
|
|
8
|
-
import {
|
|
8
|
+
import { spo } from '../../../../utils/spo.js';
|
|
9
9
|
import { validation } from '../../../../utils/validation.js';
|
|
10
10
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
11
11
|
import commands from '../../commands.js';
|
|
12
|
-
import spoWebGetCommand from '../web/web-get.js';
|
|
13
12
|
import { SharingCapabilities } from './SharingCapabilities.js';
|
|
14
|
-
import spoSiteAddCommand from './site-add.js';
|
|
15
|
-
import spoSiteSetCommand from './site-set.js';
|
|
16
13
|
class SpoSiteEnsureCommand extends SpoCommand {
|
|
17
14
|
get name() {
|
|
18
15
|
return commands.SITE_ENSURE;
|
|
@@ -30,10 +27,7 @@ class SpoSiteEnsureCommand extends SpoCommand {
|
|
|
30
27
|
async commandAction(logger, args) {
|
|
31
28
|
try {
|
|
32
29
|
const res = await this.ensureSite(logger, args);
|
|
33
|
-
|
|
34
|
-
await logger.logToStderr(res.stderr);
|
|
35
|
-
}
|
|
36
|
-
await logger.log(res.stdout);
|
|
30
|
+
await logger.log(res);
|
|
37
31
|
if (this.verbose) {
|
|
38
32
|
await logger.logToStderr(chalk.green('DONE'));
|
|
39
33
|
}
|
|
@@ -49,9 +43,9 @@ class SpoSiteEnsureCommand extends SpoCommand {
|
|
|
49
43
|
}
|
|
50
44
|
catch (err) {
|
|
51
45
|
if (this.debug) {
|
|
52
|
-
await logger.logToStderr(err
|
|
46
|
+
await logger.logToStderr(err);
|
|
53
47
|
}
|
|
54
|
-
if (err.error
|
|
48
|
+
if (err.error !== '404 FILE NOT FOUND') {
|
|
55
49
|
throw err;
|
|
56
50
|
}
|
|
57
51
|
if (this.verbose) {
|
|
@@ -60,12 +54,15 @@ class SpoSiteEnsureCommand extends SpoCommand {
|
|
|
60
54
|
return this.createSite(args, logger);
|
|
61
55
|
}
|
|
62
56
|
if (this.debug) {
|
|
63
|
-
await logger.logToStderr(getWebOutput
|
|
57
|
+
await logger.logToStderr(getWebOutput);
|
|
64
58
|
}
|
|
65
59
|
if (this.verbose) {
|
|
66
60
|
await logger.logToStderr(`Site found at ${args.options.url}. Checking if site matches conditions...`);
|
|
67
61
|
}
|
|
68
|
-
const web =
|
|
62
|
+
const web = {
|
|
63
|
+
Configuration: getWebOutput.Configuration,
|
|
64
|
+
WebTemplate: getWebOutput.WebTemplate
|
|
65
|
+
};
|
|
69
66
|
if (args.options.type) {
|
|
70
67
|
// type was specified so we need to check if the existing site matches
|
|
71
68
|
// it. If not, we throw an error and stop
|
|
@@ -100,70 +97,20 @@ class SpoSiteEnsureCommand extends SpoCommand {
|
|
|
100
97
|
if (this.verbose) {
|
|
101
98
|
await logger.logToStderr(`Checking if site ${args.options.url} exists...`);
|
|
102
99
|
}
|
|
103
|
-
|
|
104
|
-
url: args.options.url,
|
|
105
|
-
output: 'json',
|
|
106
|
-
debug: this.debug,
|
|
107
|
-
verbose: this.verbose
|
|
108
|
-
};
|
|
109
|
-
return Cli.executeCommandWithOutput(spoWebGetCommand, { options: { ...options, _: [] } });
|
|
100
|
+
return await spo.getWeb(args.options.url, logger, this.verbose);
|
|
110
101
|
}
|
|
111
102
|
async createSite(args, logger) {
|
|
112
103
|
if (this.verbose) {
|
|
113
104
|
await logger.logToStderr(`Creating site...`);
|
|
114
105
|
}
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
title: args.options.title,
|
|
118
|
-
alias: args.options.alias,
|
|
119
|
-
description: args.options.description,
|
|
120
|
-
classification: args.options.classification,
|
|
121
|
-
isPublic: args.options.isPublic,
|
|
122
|
-
lcid: args.options.lcid,
|
|
123
|
-
url: typeof args.options.type === 'undefined' || args.options.type === 'TeamSite' ? undefined : args.options.url,
|
|
124
|
-
owners: args.options.owners,
|
|
125
|
-
shareByEmailEnabled: args.options.shareByEmailEnabled,
|
|
126
|
-
siteDesign: args.options.siteDesign,
|
|
127
|
-
siteDesignId: args.options.siteDesignId,
|
|
128
|
-
timeZone: args.options.timeZone,
|
|
129
|
-
webTemplate: args.options.webTemplate,
|
|
130
|
-
resourceQuota: args.options.resourceQuota,
|
|
131
|
-
resourceQuotaWarningLevel: args.options.resourceQuotaWarningLevel,
|
|
132
|
-
storageQuota: args.options.storageQuota,
|
|
133
|
-
storageQuotaWarningLevel: args.options.storageQuotaWarningLevel,
|
|
134
|
-
removeDeletedSite: args.options.removeDeletedSite,
|
|
135
|
-
wait: args.options.wait,
|
|
136
|
-
verbose: this.verbose,
|
|
137
|
-
debug: this.debug
|
|
138
|
-
};
|
|
139
|
-
const validationResult = await spoSiteAddCommand.validate({ options: options }, Cli.getCommandInfo(spoSiteAddCommand));
|
|
140
|
-
if (validationResult !== true) {
|
|
141
|
-
throw validationResult;
|
|
142
|
-
}
|
|
143
|
-
return Cli.executeCommandWithOutput(spoSiteAddCommand, { options: { ...options, _: [] } });
|
|
106
|
+
const url = typeof args.options.type === 'undefined' || args.options.type === 'TeamSite' ? undefined : args.options.url;
|
|
107
|
+
return await spo.addSite(args.options.title, logger, this.verbose, args.options.wait, args.options.type, args.options.alias, args.options.description, args.options.owners, args.options.shareByEmailEnabled, args.options.removeDeletedSite, args.options.classification, args.options.isPublic, args.options.lcid, url, args.options.siteDesign, args.options.siteDesignId, args.options.timeZone, args.options.webTemplate, args.options.resourceQuota, args.options.resourceQuotaWarningLevel, args.options.storageQuota, args.options.storageQuotaWarningLevel);
|
|
144
108
|
}
|
|
145
109
|
async updateSite(args, logger) {
|
|
146
110
|
if (this.verbose) {
|
|
147
111
|
await logger.logToStderr(`Updating site...`);
|
|
148
112
|
}
|
|
149
|
-
|
|
150
|
-
classification: args.options.classification,
|
|
151
|
-
disableFlows: args.options.disableFlows,
|
|
152
|
-
isPublic: args.options.isPublic,
|
|
153
|
-
owners: args.options.owners,
|
|
154
|
-
shareByEmailEnabled: args.options.shareByEmailEnabled,
|
|
155
|
-
siteDesignId: args.options.siteDesignId,
|
|
156
|
-
title: args.options.title,
|
|
157
|
-
url: args.options.url,
|
|
158
|
-
sharingCapability: args.options.sharingCapability,
|
|
159
|
-
verbose: this.verbose,
|
|
160
|
-
debug: this.debug
|
|
161
|
-
};
|
|
162
|
-
const validationResult = await spoSiteSetCommand.validate({ options: options }, Cli.getCommandInfo(spoSiteSetCommand));
|
|
163
|
-
if (validationResult !== true) {
|
|
164
|
-
throw validationResult;
|
|
165
|
-
}
|
|
166
|
-
return Cli.executeCommandWithOutput(spoSiteSetCommand, { options: { ...options, _: [] } });
|
|
113
|
+
return await spo.updateSite(args.options.url, logger, this.verbose, args.options.title, args.options.classification, args.options.disableFlows, args.options.isPublic, args.options.owners, args.options.shareByEmailEnabled, args.options.siteDesignId, args.options.sharingCapability);
|
|
167
114
|
}
|
|
168
115
|
/**
|
|
169
116
|
* Maps the base sharingCapability enum to string array so it can
|
|
@@ -54,16 +54,14 @@ class SpoSiteListCommand extends SpoCommand {
|
|
|
54
54
|
},
|
|
55
55
|
data: requestBody
|
|
56
56
|
};
|
|
57
|
-
const
|
|
58
|
-
const json = JSON.parse(
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
throw response.ErrorInfo.ErrorMessage;
|
|
57
|
+
const response = await request.post(requestOptions);
|
|
58
|
+
const json = JSON.parse(response);
|
|
59
|
+
const responseContent = json[0];
|
|
60
|
+
if (responseContent.ErrorInfo) {
|
|
61
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
63
62
|
}
|
|
64
63
|
else {
|
|
65
64
|
const sites = json[json.length - 1];
|
|
66
|
-
logger.log(sites);
|
|
67
65
|
this.allSites.push(...sites._Child_Items_);
|
|
68
66
|
if (sites.NextStartIndexFromSharePoint) {
|
|
69
67
|
await this.getAllSites(spoAdminUrl, filter, sites.NextStartIndexFromSharePoint, personalSite, webTemplate, formDigest, logger);
|
|
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
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
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var _SpoSiteRecycleBinItemListCommand_instances, _SpoSiteRecycleBinItemListCommand_initTelemetry, _SpoSiteRecycleBinItemListCommand_initOptions, _SpoSiteRecycleBinItemListCommand_initValidators;
|
|
6
|
+
var _SpoSiteRecycleBinItemListCommand_instances, _a, _SpoSiteRecycleBinItemListCommand_initTelemetry, _SpoSiteRecycleBinItemListCommand_initOptions, _SpoSiteRecycleBinItemListCommand_initValidators;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
8
|
import { validation } from '../../../../utils/validation.js';
|
|
9
9
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
@@ -32,7 +32,7 @@ class SpoSiteRecycleBinItemListCommand extends SpoCommand {
|
|
|
32
32
|
const state = args.options.secondary ? '2' : '1';
|
|
33
33
|
let requestUrl = `${args.options.siteUrl}/_api/site/RecycleBin?$filter=(ItemState eq ${state})`;
|
|
34
34
|
if (typeof args.options.type !== 'undefined') {
|
|
35
|
-
const type =
|
|
35
|
+
const type = _a.recycleBinItemType.find(item => item.value === args.options.type);
|
|
36
36
|
if (typeof type !== 'undefined') {
|
|
37
37
|
requestUrl += ` and (ItemType eq ${type.id})`;
|
|
38
38
|
}
|
|
@@ -53,7 +53,7 @@ class SpoSiteRecycleBinItemListCommand extends SpoCommand {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
_SpoSiteRecycleBinItemListCommand_instances = new WeakSet(), _SpoSiteRecycleBinItemListCommand_initTelemetry = function _SpoSiteRecycleBinItemListCommand_initTelemetry() {
|
|
56
|
+
_a = SpoSiteRecycleBinItemListCommand, _SpoSiteRecycleBinItemListCommand_instances = new WeakSet(), _SpoSiteRecycleBinItemListCommand_initTelemetry = function _SpoSiteRecycleBinItemListCommand_initTelemetry() {
|
|
57
57
|
this.telemetry.push((args) => {
|
|
58
58
|
Object.assign(this.telemetryProperties, {
|
|
59
59
|
type: args.options.type,
|
|
@@ -65,7 +65,7 @@ _SpoSiteRecycleBinItemListCommand_instances = new WeakSet(), _SpoSiteRecycleBinI
|
|
|
65
65
|
option: '-u, --siteUrl <siteUrl>'
|
|
66
66
|
}, {
|
|
67
67
|
option: '-t, --type [type]',
|
|
68
|
-
autocomplete:
|
|
68
|
+
autocomplete: _a.recycleBinItemType.map(item => item.value)
|
|
69
69
|
}, {
|
|
70
70
|
option: '-s, --secondary'
|
|
71
71
|
});
|
|
@@ -76,8 +76,8 @@ _SpoSiteRecycleBinItemListCommand_instances = new WeakSet(), _SpoSiteRecycleBinI
|
|
|
76
76
|
return isValidSharePointUrl;
|
|
77
77
|
}
|
|
78
78
|
if (typeof args.options.type !== 'undefined' &&
|
|
79
|
-
!
|
|
80
|
-
return `${args.options.type} is not a valid value. Allowed values are ${
|
|
79
|
+
!_a.recycleBinItemType.some(item => item.value === args.options.type)) {
|
|
80
|
+
return `${args.options.type} is not a valid value. Allowed values are ${_a.recycleBinItemType.map(item => item.value).join(', ')}`;
|
|
81
81
|
}
|
|
82
82
|
return true;
|
|
83
83
|
});
|
|
@@ -29,69 +29,69 @@ class SpoSiteRemoveCommand extends SpoCommand {
|
|
|
29
29
|
__classPrivateFieldGet(this, _SpoSiteRemoveCommand_instances, "m", _SpoSiteRemoveCommand_initValidators).call(this);
|
|
30
30
|
}
|
|
31
31
|
async commandAction(logger, args) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if (args.options.force) {
|
|
33
|
+
await this.removeSite(logger, args);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const result = await Cli.prompt({
|
|
37
|
+
type: 'confirm',
|
|
38
|
+
name: 'continue',
|
|
39
|
+
default: false,
|
|
40
|
+
message: `Are you sure you want to remove the site ${args.options.url}?`
|
|
41
|
+
});
|
|
42
|
+
if (result.continue) {
|
|
43
|
+
await this.removeSite(logger, args);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async removeSite(logger, args) {
|
|
48
|
+
try {
|
|
49
|
+
if (args.options.fromRecycleBin) {
|
|
50
|
+
await this.deleteSiteWithoutGroup(logger, args);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const groupId = await this.getSiteGroupId(args.options.url, logger);
|
|
54
|
+
if (groupId === '00000000-0000-0000-0000-000000000000') {
|
|
55
|
+
if (this.debug) {
|
|
56
|
+
await logger.logToStderr('Site is not groupified. Going ahead with the conventional site deletion options');
|
|
57
|
+
}
|
|
35
58
|
await this.deleteSiteWithoutGroup(logger, args);
|
|
36
59
|
}
|
|
37
60
|
else {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (this.debug) {
|
|
41
|
-
await logger.logToStderr('Site is not groupified. Going ahead with the conventional site deletion options');
|
|
42
|
-
}
|
|
43
|
-
await this.deleteSiteWithoutGroup(logger, args);
|
|
61
|
+
if (this.debug) {
|
|
62
|
+
await logger.logToStderr(`Site attached to group ${groupId}. Initiating group delete operation via Graph API`);
|
|
44
63
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
64
|
+
try {
|
|
65
|
+
const group = await aadGroup.getGroupById(groupId);
|
|
66
|
+
if (args.options.skipRecycleBin || args.options.wait) {
|
|
67
|
+
await logger.logToStderr(chalk.yellow(`Entered site is a groupified site. Hence, the parameters 'skipRecycleBin' and 'wait' will not be applicable.`));
|
|
48
68
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
await
|
|
55
|
-
await this.deleteSite(args.options.url, args.options.wait, logger);
|
|
69
|
+
await this.deleteGroup(group.id, logger);
|
|
70
|
+
await this.deleteSite(args.options.url, args.options.wait, logger);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
if (this.verbose) {
|
|
74
|
+
await logger.logToStderr(`Site group doesn't exist. Searching in the Microsoft 365 deleted groups.`);
|
|
56
75
|
}
|
|
57
|
-
|
|
76
|
+
const deletedGroups = await this.isSiteGroupDeleted(groupId);
|
|
77
|
+
if (deletedGroups.value.length === 0) {
|
|
58
78
|
if (this.verbose) {
|
|
59
|
-
await logger.logToStderr(
|
|
60
|
-
}
|
|
61
|
-
const deletedGroups = await this.isSiteGroupDeleted(groupId);
|
|
62
|
-
if (deletedGroups.value.length === 0) {
|
|
63
|
-
if (this.verbose) {
|
|
64
|
-
await logger.logToStderr("Site group doesn't exist anymore. Deleting the site.");
|
|
65
|
-
}
|
|
66
|
-
if (args.options.wait) {
|
|
67
|
-
await logger.logToStderr(chalk.yellow(`Entered site is a groupified site. Hence, the parameter 'wait' will not be applicable.`));
|
|
68
|
-
}
|
|
69
|
-
await this.deleteOrphanedSite(logger, args.options.url);
|
|
79
|
+
await logger.logToStderr("Site group doesn't exist anymore. Deleting the site.");
|
|
70
80
|
}
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
if (args.options.wait) {
|
|
82
|
+
await logger.logToStderr(chalk.yellow(`Entered site is a groupified site. Hence, the parameter 'wait' will not be applicable.`));
|
|
73
83
|
}
|
|
84
|
+
await this.deleteOrphanedSite(logger, args.options.url);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw `Site group still exists in the deleted groups. The site won't be removed.`;
|
|
74
88
|
}
|
|
75
89
|
}
|
|
76
90
|
}
|
|
77
91
|
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
this.handleRejectedPromise(err);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
if (args.options.force) {
|
|
83
|
-
await removeSite();
|
|
84
92
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
type: 'confirm',
|
|
88
|
-
name: 'continue',
|
|
89
|
-
default: false,
|
|
90
|
-
message: `Are you sure you want to remove the site ${args.options.url}?`
|
|
91
|
-
});
|
|
92
|
-
if (result.continue) {
|
|
93
|
-
await removeSite();
|
|
94
|
-
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
this.handleRejectedPromise(err);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
isSiteGroupDeleted(groupId) {
|
|
@@ -104,175 +104,131 @@ class SpoSiteRemoveCommand extends SpoCommand {
|
|
|
104
104
|
};
|
|
105
105
|
return request.get(requestOptions);
|
|
106
106
|
}
|
|
107
|
-
deleteOrphanedSite(logger, url) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
};
|
|
119
|
-
return request.post(requestOptions);
|
|
120
|
-
});
|
|
107
|
+
async deleteOrphanedSite(logger, url) {
|
|
108
|
+
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
109
|
+
const requestOptions = {
|
|
110
|
+
url: `${spoAdminUrl}/_api/GroupSiteManager/Delete?siteUrl='${url}'`,
|
|
111
|
+
headers: {
|
|
112
|
+
'content-type': 'application/json;odata=nometadata',
|
|
113
|
+
accept: 'application/json;odata=nometadata'
|
|
114
|
+
},
|
|
115
|
+
responseType: 'json'
|
|
116
|
+
};
|
|
117
|
+
return await request.post(requestOptions);
|
|
121
118
|
}
|
|
122
|
-
deleteSiteWithoutGroup(logger, args) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
-
.then(async (res) => {
|
|
130
|
-
this.context = res;
|
|
131
|
-
if (args.options.fromRecycleBin) {
|
|
132
|
-
if (this.verbose) {
|
|
133
|
-
await logger.logToStderr(`Deleting site from recycle bin ${args.options.url}...`);
|
|
134
|
-
}
|
|
135
|
-
return this.deleteSiteFromTheRecycleBin(args.options.url, args.options.wait, logger);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
return this.deleteSite(args.options.url, args.options.wait, logger);
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
.then(async () => {
|
|
142
|
-
if (args.options.skipRecycleBin) {
|
|
143
|
-
if (this.verbose) {
|
|
144
|
-
await logger.logToStderr(`Also deleting site from tenant recycle bin ${args.options.url}...`);
|
|
145
|
-
}
|
|
146
|
-
return this.deleteSiteFromTheRecycleBin(args.options.url, args.options.wait, logger);
|
|
119
|
+
async deleteSiteWithoutGroup(logger, args) {
|
|
120
|
+
this.spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
121
|
+
this.context = await spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
122
|
+
if (args.options.fromRecycleBin) {
|
|
123
|
+
if (this.verbose) {
|
|
124
|
+
await logger.logToStderr(`Deleting site from recycle bin ${args.options.url}...`);
|
|
147
125
|
}
|
|
148
|
-
|
|
149
|
-
|
|
126
|
+
await this.deleteSiteFromTheRecycleBin(args.options.url, args.options.wait, logger);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
await this.deleteSite(args.options.url, args.options.wait, logger);
|
|
130
|
+
}
|
|
131
|
+
if (args.options.skipRecycleBin) {
|
|
132
|
+
if (this.verbose) {
|
|
133
|
+
await logger.logToStderr(`Also deleting site from tenant recycle bin ${args.options.url}...`);
|
|
150
134
|
}
|
|
151
|
-
|
|
135
|
+
await this.deleteSiteFromTheRecycleBin(args.options.url, args.options.wait, logger);
|
|
136
|
+
}
|
|
152
137
|
}
|
|
153
|
-
deleteSite(url, wait, logger) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
reject,
|
|
190
|
-
logger,
|
|
191
|
-
currentContext: this.context,
|
|
192
|
-
debug: this.debug,
|
|
193
|
-
verbose: this.verbose
|
|
194
|
-
});
|
|
195
|
-
}, operation.PollingInterval);
|
|
196
|
-
}
|
|
197
|
-
});
|
|
138
|
+
async deleteSite(url, wait, logger) {
|
|
139
|
+
this.context = await spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
140
|
+
if (this.verbose) {
|
|
141
|
+
await logger.logToStderr(`Deleting site ${url}...`);
|
|
142
|
+
}
|
|
143
|
+
const requestOptions = {
|
|
144
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
145
|
+
headers: {
|
|
146
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
147
|
+
},
|
|
148
|
+
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="55" ObjectPathId="54"/><ObjectPath Id="57" ObjectPathId="56"/><Query Id="58" ObjectPathId="54"><Query SelectAllProperties="true"><Properties/></Query></Query><Query Id="59" ObjectPathId="56"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true"/><Property Name="PollingInterval" ScalarProperty="true"/></Properties></Query></Query></Actions><ObjectPaths><Constructor Id="54" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}"/><Method Id="56" ParentId="54" Name="RemoveSite"><Parameters><Parameter Type="String">${formatting.escapeXml(url)}</Parameter></Parameters></Method></ObjectPaths></Request>`
|
|
149
|
+
};
|
|
150
|
+
const response = await request.post(requestOptions);
|
|
151
|
+
const json = JSON.parse(response);
|
|
152
|
+
const responseContent = json[0];
|
|
153
|
+
if (responseContent.ErrorInfo) {
|
|
154
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
155
|
+
}
|
|
156
|
+
const operation = json[json.length - 1];
|
|
157
|
+
const isComplete = operation.IsComplete;
|
|
158
|
+
if (!wait || isComplete) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
await new Promise((resolve, reject) => {
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
spo.waitUntilFinished({
|
|
164
|
+
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
165
|
+
siteUrl: this.spoAdminUrl,
|
|
166
|
+
resolve,
|
|
167
|
+
reject,
|
|
168
|
+
logger,
|
|
169
|
+
currentContext: this.context,
|
|
170
|
+
debug: this.debug,
|
|
171
|
+
verbose: this.verbose
|
|
172
|
+
});
|
|
173
|
+
}, operation.PollingInterval);
|
|
198
174
|
});
|
|
199
175
|
}
|
|
200
|
-
deleteSiteFromTheRecycleBin(url, wait, logger) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
this.context
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
reject,
|
|
234
|
-
logger,
|
|
235
|
-
currentContext: this.context,
|
|
236
|
-
debug: this.debug,
|
|
237
|
-
verbose: this.verbose
|
|
238
|
-
});
|
|
239
|
-
}, operation.PollingInterval);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
176
|
+
async deleteSiteFromTheRecycleBin(url, wait, logger) {
|
|
177
|
+
this.context = await spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
178
|
+
const requestOptions = {
|
|
179
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
180
|
+
headers: {
|
|
181
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
182
|
+
},
|
|
183
|
+
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>`
|
|
184
|
+
};
|
|
185
|
+
const response = await request.post(requestOptions);
|
|
186
|
+
const json = JSON.parse(response);
|
|
187
|
+
const responseContent = json[0];
|
|
188
|
+
if (responseContent.ErrorInfo) {
|
|
189
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
190
|
+
}
|
|
191
|
+
const operation = json[json.length - 1];
|
|
192
|
+
const isComplete = operation.IsComplete;
|
|
193
|
+
if (!wait || isComplete) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
await new Promise((resolve, reject) => {
|
|
197
|
+
setTimeout(() => {
|
|
198
|
+
spo.waitUntilFinished({
|
|
199
|
+
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
200
|
+
siteUrl: this.spoAdminUrl,
|
|
201
|
+
resolve,
|
|
202
|
+
reject,
|
|
203
|
+
logger,
|
|
204
|
+
currentContext: this.context,
|
|
205
|
+
debug: this.debug,
|
|
206
|
+
verbose: this.verbose
|
|
207
|
+
});
|
|
208
|
+
}, operation.PollingInterval);
|
|
242
209
|
});
|
|
243
210
|
}
|
|
244
|
-
getSiteGroupId(url, logger) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
.then((res) => {
|
|
266
|
-
const json = JSON.parse(res);
|
|
267
|
-
const response = json[0];
|
|
268
|
-
if (response.ErrorInfo) {
|
|
269
|
-
return Promise.reject(response.ErrorInfo.ErrorMessage);
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
const groupId = json[json.length - 1].GroupId.replace('/Guid(', '').replace(')/', '');
|
|
273
|
-
return Promise.resolve(groupId);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
211
|
+
async getSiteGroupId(url, logger) {
|
|
212
|
+
this.spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
213
|
+
this.context = await spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
214
|
+
if (this.verbose) {
|
|
215
|
+
await logger.logToStderr(`Retrieving the group Id of the site ${url}`);
|
|
216
|
+
}
|
|
217
|
+
const requestOptions = {
|
|
218
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
219
|
+
headers: {
|
|
220
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
221
|
+
},
|
|
222
|
+
data: `<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}"><Actions><ObjectPath Id="4" ObjectPathId="3"/><Query Id="5" ObjectPathId="3"><Query SelectAllProperties="false"><Properties><Property Name="GroupId" ScalarProperty="true"/></Properties></Query></Query></Actions><ObjectPaths><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}"/><Method Id="3" ParentId="1" Name="GetSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting.escapeXml(url)}</Parameter></Parameters></Method></ObjectPaths></Request>`
|
|
223
|
+
};
|
|
224
|
+
const response = await request.post(requestOptions);
|
|
225
|
+
const json = JSON.parse(response);
|
|
226
|
+
const responseContent = json[0];
|
|
227
|
+
if (responseContent.ErrorInfo) {
|
|
228
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
229
|
+
}
|
|
230
|
+
const groupId = json[json.length - 1].GroupId.replace('/Guid(', '').replace(')/', '');
|
|
231
|
+
return groupId;
|
|
276
232
|
}
|
|
277
233
|
async deleteGroup(groupId, logger) {
|
|
278
234
|
if (this.verbose) {
|