@pnp/cli-microsoft365 10.10.0-beta.1bb5ba0 → 10.10.0-beta.2cb88d5
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.
|
@@ -1,48 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
var _SpoHomeSiteRemoveCommand_instances, _SpoHomeSiteRemoveCommand_initTelemetry, _SpoHomeSiteRemoveCommand_initOptions;
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { zod } from '../../../../utils/zod.js';
|
|
3
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
4
|
+
import { validation } from '../../../../utils/validation.js';
|
|
7
5
|
import { cli } from '../../../../cli/cli.js';
|
|
8
6
|
import config from '../../../../config.js';
|
|
9
7
|
import request from '../../../../request.js';
|
|
10
8
|
import { spo } from '../../../../utils/spo.js';
|
|
11
9
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
12
10
|
import commands from '../../commands.js';
|
|
11
|
+
const options = globalOptionsZod
|
|
12
|
+
.extend({
|
|
13
|
+
url: zod.alias('u', z.string()
|
|
14
|
+
.refine(url => validation.isValidSharePointUrl(url) === true, url => ({
|
|
15
|
+
message: `'${url}' is not a valid SharePoint Online site URL.`
|
|
16
|
+
})).optional()),
|
|
17
|
+
force: zod.alias('f', z.boolean().optional())
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
13
20
|
class SpoHomeSiteRemoveCommand extends SpoCommand {
|
|
14
21
|
get name() {
|
|
15
22
|
return commands.HOMESITE_REMOVE;
|
|
16
23
|
}
|
|
17
24
|
get description() {
|
|
18
|
-
return 'Removes
|
|
25
|
+
return 'Removes a Home Site';
|
|
19
26
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
_SpoHomeSiteRemoveCommand_instances.add(this);
|
|
23
|
-
__classPrivateFieldGet(this, _SpoHomeSiteRemoveCommand_instances, "m", _SpoHomeSiteRemoveCommand_initTelemetry).call(this);
|
|
24
|
-
__classPrivateFieldGet(this, _SpoHomeSiteRemoveCommand_instances, "m", _SpoHomeSiteRemoveCommand_initOptions).call(this);
|
|
27
|
+
get schema() {
|
|
28
|
+
return options;
|
|
25
29
|
}
|
|
26
30
|
async commandAction(logger, args) {
|
|
27
31
|
const removeHomeSite = async () => {
|
|
28
32
|
try {
|
|
33
|
+
if (this.verbose) {
|
|
34
|
+
await logger.logToStderr(`Removing ${args.options.url ? `'${args.options.url}' as home site` : 'the current home site'}...`);
|
|
35
|
+
}
|
|
29
36
|
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
30
37
|
const reqDigest = await spo.getRequestDigest(spoAdminUrl);
|
|
31
|
-
|
|
32
|
-
url
|
|
33
|
-
|
|
34
|
-
'X-RequestDigest': reqDigest.FormDigestValue
|
|
35
|
-
},
|
|
36
|
-
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="28" ObjectPathId="27" /><Method Name="RemoveSPHSite" Id="29" ObjectPathId="27" /></Actions><ObjectPaths><Constructor Id="27" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
37
|
-
};
|
|
38
|
-
const res = await request.post(requestOptions);
|
|
39
|
-
const json = JSON.parse(res);
|
|
40
|
-
const response = json[0];
|
|
41
|
-
if (response.ErrorInfo) {
|
|
42
|
-
throw response.ErrorInfo.ErrorMessage;
|
|
38
|
+
if (args.options.url) {
|
|
39
|
+
await this.removeHomeSiteByUrl(args.options.url, spoAdminUrl, logger);
|
|
40
|
+
await logger.log(`${args.options.url} has been removed as a Home Site. It may take some time for the change to apply. Check aka.ms/homesites for details.`);
|
|
43
41
|
}
|
|
44
42
|
else {
|
|
45
|
-
await
|
|
43
|
+
await this.warn(logger, `The current way this command works is deprecated and will change in the next major release. The '--url' option will become required.`);
|
|
44
|
+
const requestOptions = {
|
|
45
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
46
|
+
headers: {
|
|
47
|
+
'X-RequestDigest': reqDigest.FormDigestValue
|
|
48
|
+
},
|
|
49
|
+
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="28" ObjectPathId="27" /><Method Name="RemoveSPHSite" Id="29" ObjectPathId="27" /></Actions><ObjectPaths><Constructor Id="27" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
50
|
+
};
|
|
51
|
+
const res = await request.post(requestOptions);
|
|
52
|
+
const json = JSON.parse(res);
|
|
53
|
+
const response = json[0];
|
|
54
|
+
if (response.ErrorInfo) {
|
|
55
|
+
throw response.ErrorInfo.ErrorMessage;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
await logger.log(json[json.length - 1]);
|
|
59
|
+
}
|
|
46
60
|
}
|
|
47
61
|
}
|
|
48
62
|
catch (err) {
|
|
@@ -53,23 +67,29 @@ class SpoHomeSiteRemoveCommand extends SpoCommand {
|
|
|
53
67
|
await removeHomeSite();
|
|
54
68
|
}
|
|
55
69
|
else {
|
|
56
|
-
const result = await cli.promptForConfirmation({
|
|
70
|
+
const result = await cli.promptForConfirmation({
|
|
71
|
+
message: args.options.url
|
|
72
|
+
? `Are you sure you want to remove '${args.options.url}' as home site?`
|
|
73
|
+
: `Are you sure you want to remove the current home site?`
|
|
74
|
+
});
|
|
57
75
|
if (result) {
|
|
58
76
|
await removeHomeSite();
|
|
59
77
|
}
|
|
60
78
|
}
|
|
61
79
|
}
|
|
80
|
+
async removeHomeSiteByUrl(siteUrl, spoAdminUrl, logger) {
|
|
81
|
+
const siteAdminProperties = await spo.getSiteAdminPropertiesByUrl(siteUrl, false, logger, this.verbose);
|
|
82
|
+
const requestOptions = {
|
|
83
|
+
url: `${spoAdminUrl}/_api/SPO.Tenant/RemoveTargetedSite`,
|
|
84
|
+
headers: {
|
|
85
|
+
accept: 'application/json;odata=nometadata'
|
|
86
|
+
},
|
|
87
|
+
data: {
|
|
88
|
+
siteId: siteAdminProperties.SiteId
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
await request.post(requestOptions);
|
|
92
|
+
}
|
|
62
93
|
}
|
|
63
|
-
_SpoHomeSiteRemoveCommand_instances = new WeakSet(), _SpoHomeSiteRemoveCommand_initTelemetry = function _SpoHomeSiteRemoveCommand_initTelemetry() {
|
|
64
|
-
this.telemetry.push((args) => {
|
|
65
|
-
Object.assign(this.telemetryProperties, {
|
|
66
|
-
force: args.options.force || false
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}, _SpoHomeSiteRemoveCommand_initOptions = function _SpoHomeSiteRemoveCommand_initOptions() {
|
|
70
|
-
this.options.unshift({
|
|
71
|
-
option: '-f, --force'
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
94
|
export default new SpoHomeSiteRemoveCommand();
|
|
75
95
|
//# sourceMappingURL=homesite-remove.js.map
|
|
@@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
|
|
|
4
4
|
|
|
5
5
|
# spo homesite remove
|
|
6
6
|
|
|
7
|
-
Removes
|
|
7
|
+
Removes a Home Site
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
@@ -15,6 +15,9 @@ m365 spo homesite remove [options]
|
|
|
15
15
|
## Options
|
|
16
16
|
|
|
17
17
|
```md definition-list
|
|
18
|
+
`-u, --url [url]`
|
|
19
|
+
: URL of the home site to remove.
|
|
20
|
+
|
|
18
21
|
`-f, --force`
|
|
19
22
|
: Do not prompt for confirmation before removing the Home Site.
|
|
20
23
|
```
|
|
@@ -31,10 +34,10 @@ To use this command you must be either **SharePoint Administrator** or **Global
|
|
|
31
34
|
|
|
32
35
|
## Examples
|
|
33
36
|
|
|
34
|
-
Removes
|
|
37
|
+
Removes a Home site specified by URL without prompting for confirmation.
|
|
35
38
|
|
|
36
39
|
```sh
|
|
37
|
-
m365 spo homesite remove --force
|
|
40
|
+
m365 spo homesite remove --url "https://contoso.sharepoint.com/sites/testcomms" --force
|
|
38
41
|
```
|
|
39
42
|
|
|
40
43
|
## Response
|
package/package.json
CHANGED