@pnp/cli-microsoft365 7.7.0-beta.a12fb3e → 7.7.0-beta.cec4ca2
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/.eslintrc.cjs +1 -0
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/Command.js +1 -1
- package/dist/cli/cli.js +9 -4
- package/dist/m365/commands/setup.js +1 -7
- package/dist/m365/entra/commands/user/user-list.js +20 -7
- package/dist/m365/spe/commands/containertype/containertype-add.js +115 -0
- package/dist/m365/spe/commands.js +5 -0
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.0.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.0.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.0.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.1.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.1.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.1.3.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.10.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.11.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.12.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.12.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.13.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.13.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.14.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.15.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.15.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.16.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.16.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.3.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.4.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.18.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.18.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.18.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.19.0-beta.0.js +25 -0
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.2.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.4.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.4.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.4.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.5.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.5.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.6.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.7.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.7.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.8.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.8.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.8.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.9.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/generic-rules.js +0 -2
- package/dist/m365/spfx/commands/project/project-doctor/rules/FN021001_PKG_spfx_deps_versions_match_project_version.js +3 -2
- package/dist/m365/spfx/commands/project/project-doctor/rules/FN021013_PKG_spfx_devdeps_match_version.js +58 -0
- package/dist/m365/spfx/commands/project/project-doctor/spfx-deps.js +2 -0
- package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.19.0-beta.0.js +53 -0
- package/dist/m365/spfx/commands/project/project-upgrade.js +16 -13
- package/dist/m365/spfx/commands/spfx-doctor.js +212 -92
- package/dist/m365/spo/commands/listitem/listitem-set.js +9 -156
- package/dist/m365/spo/commands/page/page-add.js +6 -24
- package/dist/m365/spo/commands/page/page-set.js +19 -43
- package/dist/m365/spo/commands/site/site-apppermission-remove.js +8 -9
- package/dist/m365/spo/commands/site/site-hubsite-connect.js +3 -3
- package/dist/m365/spo/commands/site/site-hubsite-disconnect.js +2 -5
- package/dist/utils/prompt.js +2 -0
- package/dist/utils/spo.js +188 -0
- package/docs/docs/cmd/entra/user/user-list.mdx +36 -15
- package/docs/docs/cmd/spe/containertype/containertype-add.mdx +140 -0
- package/docs/docs/cmd/spfx/project/project-upgrade.mdx +1 -1
- package/docs/docs/cmd/spfx/spfx-doctor.mdx +108 -2
- package/docs/docs/cmd/spo/page/page-set.mdx +1 -1
- package/docs/docs/cmd/spo/site/site-apppermission-add.mdx +1 -1
- package/npm-shrinkwrap.json +138 -214
- package/package.json +14 -14
|
@@ -4,8 +4,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _SpoListItemSetCommand_instances, _SpoListItemSetCommand_initTelemetry, _SpoListItemSetCommand_initOptions, _SpoListItemSetCommand_initValidators, _SpoListItemSetCommand_initTypes, _SpoListItemSetCommand_initOptionSets;
|
|
7
|
-
import os from 'os';
|
|
8
|
-
import config from '../../../../config.js';
|
|
9
7
|
import request from '../../../../request.js';
|
|
10
8
|
import { basic } from '../../../../utils/basic.js';
|
|
11
9
|
import { formatting } from '../../../../utils/formatting.js';
|
|
@@ -35,11 +33,9 @@ class SpoListItemSetCommand extends SpoCommand {
|
|
|
35
33
|
}
|
|
36
34
|
async commandAction(logger, args) {
|
|
37
35
|
let contentTypeName = '';
|
|
38
|
-
let listId = '';
|
|
39
36
|
try {
|
|
40
37
|
let requestUrl = `${args.options.webUrl}/_api/web`;
|
|
41
38
|
if (args.options.listId) {
|
|
42
|
-
listId = args.options.listId;
|
|
43
39
|
requestUrl += `/lists(guid'${formatting.encodeQueryParameter(args.options.listId)}')`;
|
|
44
40
|
}
|
|
45
41
|
else if (args.options.listTitle) {
|
|
@@ -49,20 +45,6 @@ class SpoListItemSetCommand extends SpoCommand {
|
|
|
49
45
|
const listServerRelativeUrl = urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
|
|
50
46
|
requestUrl += `/GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
|
|
51
47
|
}
|
|
52
|
-
if (args.options.systemUpdate && !args.options.listId) {
|
|
53
|
-
if (this.verbose) {
|
|
54
|
-
await logger.logToStderr(`Getting list id...`);
|
|
55
|
-
}
|
|
56
|
-
const listRequestOptions = {
|
|
57
|
-
url: `${requestUrl}?$select=Id`,
|
|
58
|
-
headers: {
|
|
59
|
-
'accept': 'application/json;odata=nometadata'
|
|
60
|
-
},
|
|
61
|
-
responseType: 'json'
|
|
62
|
-
};
|
|
63
|
-
const list = await request.get(listRequestOptions);
|
|
64
|
-
listId = list.Id;
|
|
65
|
-
}
|
|
66
48
|
if (args.options.contentType) {
|
|
67
49
|
if (this.verbose) {
|
|
68
50
|
await logger.logToStderr(`Getting content types for list...`);
|
|
@@ -101,94 +83,10 @@ class SpoListItemSetCommand extends SpoCommand {
|
|
|
101
83
|
await logger.logToStderr(`using content type name: ${contentTypeName}`);
|
|
102
84
|
}
|
|
103
85
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
res = await spo.getRequestDigest(args.options.webUrl);
|
|
110
|
-
}
|
|
111
|
-
if (this.verbose) {
|
|
112
|
-
await logger.logToStderr(`Updating item in list ${args.options.listId || args.options.listTitle || args.options.listUrl} in site ${args.options.webUrl}...`);
|
|
113
|
-
}
|
|
114
|
-
const formDigestValue = args.options.systemUpdate ? res['FormDigestValue'] : '';
|
|
115
|
-
let objectIdentity = '';
|
|
116
|
-
if (args.options.systemUpdate) {
|
|
117
|
-
objectIdentity = await this.requestObjectIdentity(args.options.webUrl, logger, formDigestValue);
|
|
118
|
-
}
|
|
119
|
-
const additionalContentType = (args.options.systemUpdate && args.options.contentType && contentTypeName !== '') ? `
|
|
120
|
-
<Method Name="ParseAndSetFieldValue" Id="1" ObjectPathId="147">
|
|
121
|
-
<Parameters>
|
|
122
|
-
<Parameter Type="String">ContentType</Parameter>
|
|
123
|
-
<Parameter Type="String">${contentTypeName}</Parameter>
|
|
124
|
-
</Parameters>
|
|
125
|
-
</Method>`
|
|
126
|
-
: ``;
|
|
127
|
-
const requestBody = args.options.systemUpdate ?
|
|
128
|
-
`<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
|
|
129
|
-
<Actions>
|
|
130
|
-
${this.mapRequestBody(args.options).join('')}${additionalContentType}
|
|
131
|
-
<Method Name="SystemUpdate" Id="2" ObjectPathId="147" />
|
|
132
|
-
</Actions>
|
|
133
|
-
<ObjectPaths>
|
|
134
|
-
<Identity Id="147" Name="${objectIdentity}:list:${listId}:item:${args.options.id},1" />
|
|
135
|
-
</ObjectPaths>
|
|
136
|
-
</Request>`
|
|
137
|
-
: {
|
|
138
|
-
formValues: this.mapRequestBody(args.options)
|
|
139
|
-
};
|
|
140
|
-
if (args.options.contentType && contentTypeName !== '' && !args.options.systemUpdate) {
|
|
141
|
-
if (this.debug) {
|
|
142
|
-
await logger.logToStderr(`Specifying content type name [${contentTypeName}] in request body`);
|
|
143
|
-
}
|
|
144
|
-
requestBody.formValues.push({
|
|
145
|
-
FieldName: 'ContentType',
|
|
146
|
-
FieldValue: contentTypeName
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
const requestOptions = args.options.systemUpdate ?
|
|
150
|
-
{
|
|
151
|
-
url: `${args.options.webUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
152
|
-
headers: {
|
|
153
|
-
'Content-Type': 'text/xml',
|
|
154
|
-
'X-RequestDigest': formDigestValue
|
|
155
|
-
},
|
|
156
|
-
data: requestBody
|
|
157
|
-
} :
|
|
158
|
-
{
|
|
159
|
-
url: `${requestUrl}/items(${args.options.id})/ValidateUpdateListItem()`,
|
|
160
|
-
headers: {
|
|
161
|
-
'accept': 'application/json;odata=nometadata'
|
|
162
|
-
},
|
|
163
|
-
data: requestBody,
|
|
164
|
-
responseType: 'json'
|
|
165
|
-
};
|
|
166
|
-
const response = await request.post(requestOptions);
|
|
167
|
-
let itemId = 0;
|
|
168
|
-
if (args.options.systemUpdate) {
|
|
169
|
-
if (response.indexOf("ErrorMessage") > -1) {
|
|
170
|
-
throw `Error occurred in systemUpdate operation - ${response}`;
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
itemId = Number(args.options.id);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
// Response is from /ValidateUpdateListItem POST call, perform get on updated item to get all field values
|
|
178
|
-
const fieldValues = response.value;
|
|
179
|
-
if (fieldValues.some(f => f.HasException)) {
|
|
180
|
-
throw `Updating the items has failed with the following errors: ${os.EOL}${fieldValues.filter(f => f.HasException).map(f => { return `- ${f.FieldName} - ${f.ErrorMessage}`; }).join(os.EOL)}`;
|
|
181
|
-
}
|
|
182
|
-
itemId = fieldValues[0].ItemId;
|
|
183
|
-
}
|
|
184
|
-
const requestOptionsItems = {
|
|
185
|
-
url: `${requestUrl}/items(${itemId})`,
|
|
186
|
-
headers: {
|
|
187
|
-
'accept': 'application/json;odata=nometadata'
|
|
188
|
-
},
|
|
189
|
-
responseType: 'json'
|
|
190
|
-
};
|
|
191
|
-
const item = await request.get(requestOptionsItems);
|
|
86
|
+
const properties = this.mapRequestBody(args.options);
|
|
87
|
+
const item = args.options.systemUpdate ?
|
|
88
|
+
await spo.systemUpdateListItem(requestUrl, args.options.id, logger, this.verbose, properties, contentTypeName)
|
|
89
|
+
: await spo.updateListItem(requestUrl, args.options.id, properties, contentTypeName);
|
|
192
90
|
delete item.ID;
|
|
193
91
|
await logger.log(item);
|
|
194
92
|
}
|
|
@@ -197,7 +95,7 @@ class SpoListItemSetCommand extends SpoCommand {
|
|
|
197
95
|
}
|
|
198
96
|
}
|
|
199
97
|
mapRequestBody(options) {
|
|
200
|
-
const
|
|
98
|
+
const filteredData = {};
|
|
201
99
|
const excludeOptions = [
|
|
202
100
|
'listTitle',
|
|
203
101
|
'listId',
|
|
@@ -216,57 +114,12 @@ class SpoListItemSetCommand extends SpoCommand {
|
|
|
216
114
|
't',
|
|
217
115
|
'_'
|
|
218
116
|
];
|
|
219
|
-
Object.keys(options)
|
|
220
|
-
if (excludeOptions.
|
|
221
|
-
|
|
222
|
-
requestBody.push(`
|
|
223
|
-
<Method Name="ParseAndSetFieldValue" Id="1" ObjectPathId="147">
|
|
224
|
-
<Parameters>
|
|
225
|
-
<Parameter Type="String">${key}</Parameter>
|
|
226
|
-
<Parameter Type="String">${options[key].toString()}</Parameter>
|
|
227
|
-
</Parameters>
|
|
228
|
-
</Method>`);
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
requestBody.push({ FieldName: key, FieldValue: options[key].toString() });
|
|
232
|
-
}
|
|
117
|
+
for (const key of Object.keys(options)) {
|
|
118
|
+
if (!excludeOptions.includes(key)) {
|
|
119
|
+
filteredData[key] = options[key];
|
|
233
120
|
}
|
|
234
|
-
});
|
|
235
|
-
return requestBody;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Requests web object identity for the current web.
|
|
239
|
-
* This request has to be send before we can construct the property bag request.
|
|
240
|
-
* The response data looks like:
|
|
241
|
-
* _ObjectIdentity_=<GUID>|<GUID>:site:<GUID>:web:<GUID>
|
|
242
|
-
* _ObjectType_=SP.Web
|
|
243
|
-
* ServerRelativeUrl=/sites/contoso
|
|
244
|
-
* The ObjectIdentity is needed to create another request to retrieve the property bag or set property.
|
|
245
|
-
* @param webUrl web url
|
|
246
|
-
* @param cmd command cmd
|
|
247
|
-
*/
|
|
248
|
-
async requestObjectIdentity(webUrl, logger, formDigestValue) {
|
|
249
|
-
const requestOptions = {
|
|
250
|
-
url: `${webUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
251
|
-
headers: {
|
|
252
|
-
'X-RequestDigest': formDigestValue
|
|
253
|
-
},
|
|
254
|
-
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><Query Id="1" ObjectPathId="5"><Query SelectAllProperties="false"><Properties><Property Name="ServerRelativeUrl" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" /></ObjectPaths></Request>`
|
|
255
|
-
};
|
|
256
|
-
const response = await request.post(requestOptions);
|
|
257
|
-
if (this.debug) {
|
|
258
|
-
await logger.logToStderr('Attempt to get _ObjectIdentity_ key values');
|
|
259
|
-
}
|
|
260
|
-
const json = JSON.parse(response);
|
|
261
|
-
const contents = json.find(x => { return x['ErrorInfo']; });
|
|
262
|
-
if (contents && contents.ErrorInfo) {
|
|
263
|
-
throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
|
|
264
|
-
}
|
|
265
|
-
const identityObject = json.find(x => { return x['_ObjectIdentity_']; });
|
|
266
|
-
if (identityObject) {
|
|
267
|
-
return identityObject['_ObjectIdentity_'];
|
|
268
121
|
}
|
|
269
|
-
|
|
122
|
+
return filteredData;
|
|
270
123
|
}
|
|
271
124
|
}
|
|
272
125
|
_SpoListItemSetCommand_instances = new WeakSet(), _SpoListItemSetCommand_initTelemetry = function _SpoListItemSetCommand_initTelemetry() {
|
|
@@ -4,7 +4,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _SpoPageAddCommand_instances, _SpoPageAddCommand_initTelemetry, _SpoPageAddCommand_initOptions, _SpoPageAddCommand_initValidators;
|
|
7
|
-
import { cli } from '../../../../cli/cli.js';
|
|
8
7
|
import request from '../../../../request.js';
|
|
9
8
|
import { formatting } from '../../../../utils/formatting.js';
|
|
10
9
|
import { spo } from '../../../../utils/spo.js';
|
|
@@ -12,8 +11,6 @@ import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
|
12
11
|
import { validation } from '../../../../utils/validation.js';
|
|
13
12
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
14
13
|
import commands from '../../commands.js';
|
|
15
|
-
import spoFileGetCommand from '../file/file-get.js';
|
|
16
|
-
import spoListItemSetCommand from '../listitem/listitem-set.js';
|
|
17
14
|
import { Page, supportedPageLayouts, supportedPromoteAs } from './Page.js';
|
|
18
15
|
class SpoPageAddCommand extends SpoCommand {
|
|
19
16
|
get name() {
|
|
@@ -64,7 +61,8 @@ class SpoPageAddCommand extends SpoCommand {
|
|
|
64
61
|
};
|
|
65
62
|
const template = await request.post(requestOptions);
|
|
66
63
|
itemId = template.UniqueId;
|
|
67
|
-
const
|
|
64
|
+
const file = await spo.getFileAsListItemByUrl(args.options.webUrl, serverRelativeFileUrl, logger, this.verbose);
|
|
65
|
+
const listItemId = file.Id;
|
|
68
66
|
const pageProps = await Page.checkout(pageName, args.options.webUrl, logger, this.debug, this.verbose);
|
|
69
67
|
if (pageProps) {
|
|
70
68
|
pageId = pageProps.Id;
|
|
@@ -93,15 +91,11 @@ class SpoPageAddCommand extends SpoCommand {
|
|
|
93
91
|
break;
|
|
94
92
|
case 'NewsPage':
|
|
95
93
|
const listItemSetOptions = {
|
|
96
|
-
|
|
97
|
-
listUrl: listServerRelativeUrl,
|
|
98
|
-
id: listItemId,
|
|
99
|
-
systemUpdate: true,
|
|
100
|
-
FirstPublishedDate: new Date().toISOString(),
|
|
101
|
-
verbose: this.verbose,
|
|
102
|
-
debug: this.debug
|
|
94
|
+
FirstPublishedDate: new Date().toISOString()
|
|
103
95
|
};
|
|
104
|
-
|
|
96
|
+
const listUrl = urlUtil.getServerRelativePath(args.options.webUrl, listServerRelativeUrl);
|
|
97
|
+
const requestUrl = `${args.options.webUrl}/_api/web/GetList('${formatting.encodeQueryParameter(listUrl)}')`;
|
|
98
|
+
await spo.systemUpdateListItem(requestUrl, listItemId, logger, this.verbose, listItemSetOptions);
|
|
105
99
|
break;
|
|
106
100
|
case 'Template':
|
|
107
101
|
requestOptions.url = `${args.options.webUrl}/_api/SitePages/Pages(${listItemId})/SavePageAsTemplate`;
|
|
@@ -212,18 +206,6 @@ class SpoPageAddCommand extends SpoCommand {
|
|
|
212
206
|
this.handleRejectedODataJsonPromise(err);
|
|
213
207
|
}
|
|
214
208
|
}
|
|
215
|
-
async getFileListItemId(webUrl, serverRelativeFileUrl) {
|
|
216
|
-
const fileGetOptions = {
|
|
217
|
-
webUrl: webUrl,
|
|
218
|
-
url: serverRelativeFileUrl,
|
|
219
|
-
asListItem: true,
|
|
220
|
-
verbose: this.verbose,
|
|
221
|
-
debug: this.debug
|
|
222
|
-
};
|
|
223
|
-
const fileGetOutput = await cli.executeCommandWithOutput(spoFileGetCommand, { options: { ...fileGetOptions, _: [] } });
|
|
224
|
-
const fileGetOutputJson = JSON.parse(fileGetOutput.stdout);
|
|
225
|
-
return fileGetOutputJson.Id;
|
|
226
|
-
}
|
|
227
209
|
}
|
|
228
210
|
_SpoPageAddCommand_instances = new WeakSet(), _SpoPageAddCommand_initTelemetry = function _SpoPageAddCommand_initTelemetry() {
|
|
229
211
|
this.telemetry.push((args) => {
|
|
@@ -5,7 +5,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _SpoPageSetCommand_instances, _SpoPageSetCommand_initTelemetry, _SpoPageSetCommand_initOptions, _SpoPageSetCommand_initTypes, _SpoPageSetCommand_initValidators;
|
|
7
7
|
import { Auth } from '../../../../Auth.js';
|
|
8
|
-
import { cli } from '../../../../cli/cli.js';
|
|
9
8
|
import request from '../../../../request.js';
|
|
10
9
|
import { formatting } from '../../../../utils/formatting.js';
|
|
11
10
|
import { spo } from '../../../../utils/spo.js';
|
|
@@ -13,8 +12,6 @@ import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
|
13
12
|
import { validation } from '../../../../utils/validation.js';
|
|
14
13
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
15
14
|
import commands from '../../commands.js';
|
|
16
|
-
import spoFileGetCommand from '../file/file-get.js';
|
|
17
|
-
import spoListItemSetCommand from '../listitem/listitem-set.js';
|
|
18
15
|
import { Page, supportedPageLayouts, supportedPromoteAs } from './Page.js';
|
|
19
16
|
class SpoPageSetCommand extends SpoCommand {
|
|
20
17
|
get name() {
|
|
@@ -49,6 +46,8 @@ class SpoPageSetCommand extends SpoCommand {
|
|
|
49
46
|
}
|
|
50
47
|
const listServerRelativeUrl = `${urlUtil.getServerRelativeSiteUrl(args.options.webUrl)}/sitepages`;
|
|
51
48
|
const serverRelativeFileUrl = `${listServerRelativeUrl}/${pageName}`;
|
|
49
|
+
const listUrl = urlUtil.getServerRelativePath(args.options.webUrl, listServerRelativeUrl);
|
|
50
|
+
const requestUrl = `${args.options.webUrl}/_api/web/GetList('${formatting.encodeQueryParameter(listUrl)}')`;
|
|
52
51
|
const needsToSavePage = !!args.options.title || !!args.options.description;
|
|
53
52
|
try {
|
|
54
53
|
const requestDigestResult = await spo.getRequestDigest(args.options.webUrl);
|
|
@@ -65,21 +64,16 @@ class SpoPageSetCommand extends SpoCommand {
|
|
|
65
64
|
authorByline = page.AuthorByline;
|
|
66
65
|
}
|
|
67
66
|
if (args.options.layoutType) {
|
|
68
|
-
const
|
|
67
|
+
const file = await spo.getFileAsListItemByUrl(args.options.webUrl, serverRelativeFileUrl, logger, this.verbose);
|
|
68
|
+
const itemId = file.Id;
|
|
69
69
|
const listItemSetOptions = {
|
|
70
|
-
|
|
71
|
-
listUrl: listServerRelativeUrl,
|
|
72
|
-
id: itemId,
|
|
73
|
-
systemUpdate: true,
|
|
74
|
-
PageLayoutType: args.options.layoutType,
|
|
75
|
-
verbose: this.verbose,
|
|
76
|
-
debug: this.debug
|
|
70
|
+
PageLayoutType: args.options.layoutType
|
|
77
71
|
};
|
|
78
72
|
if (args.options.layoutType === 'Article') {
|
|
79
73
|
listItemSetOptions.PromotedState = 0;
|
|
80
74
|
listItemSetOptions.BannerImageUrl = `${resource}/_layouts/15/images/sitepagethumbnail.png, /_layouts/15/images/sitepagethumbnail.png`;
|
|
81
75
|
}
|
|
82
|
-
await
|
|
76
|
+
await spo.systemUpdateListItem(requestUrl, itemId, logger, this.verbose, listItemSetOptions);
|
|
83
77
|
}
|
|
84
78
|
if (args.options.promoteAs) {
|
|
85
79
|
const requestOptions = {
|
|
@@ -101,21 +95,17 @@ class SpoPageSetCommand extends SpoCommand {
|
|
|
101
95
|
await request.post(requestOptions);
|
|
102
96
|
break;
|
|
103
97
|
case 'NewsPage':
|
|
104
|
-
const
|
|
98
|
+
const newsPageItem = await spo.getFileAsListItemByUrl(args.options.webUrl, serverRelativeFileUrl, logger, this.verbose);
|
|
99
|
+
const newsPageItemId = newsPageItem.Id;
|
|
105
100
|
const listItemSetOptions = {
|
|
106
|
-
webUrl: args.options.webUrl,
|
|
107
|
-
listUrl: listServerRelativeUrl,
|
|
108
|
-
id: newsPageItemId,
|
|
109
|
-
systemUpdate: true,
|
|
110
101
|
PromotedState: 2,
|
|
111
|
-
FirstPublishedDate: new Date().toISOString()
|
|
112
|
-
verbose: this.verbose,
|
|
113
|
-
debug: this.debug
|
|
102
|
+
FirstPublishedDate: new Date().toISOString()
|
|
114
103
|
};
|
|
115
|
-
await
|
|
104
|
+
await spo.systemUpdateListItem(requestUrl, newsPageItemId, logger, this.verbose, listItemSetOptions);
|
|
116
105
|
break;
|
|
117
106
|
case 'Template':
|
|
118
|
-
const
|
|
107
|
+
const templateItem = await spo.getFileAsListItemByUrl(args.options.webUrl, serverRelativeFileUrl, logger, this.verbose);
|
|
108
|
+
const templateItemId = templateItem.Id;
|
|
119
109
|
requestOptions.headers = {
|
|
120
110
|
'X-RequestDigest': requestDigest,
|
|
121
111
|
'content-type': 'application/json;odata=nometadata',
|
|
@@ -210,17 +200,12 @@ class SpoPageSetCommand extends SpoCommand {
|
|
|
210
200
|
await request.post(requestOptions);
|
|
211
201
|
}
|
|
212
202
|
if (args.options.demoteFrom === 'NewsPage') {
|
|
213
|
-
const
|
|
203
|
+
const file = await spo.getFileAsListItemByUrl(args.options.webUrl, serverRelativeFileUrl, logger, this.verbose);
|
|
204
|
+
const fileId = file.Id;
|
|
214
205
|
const listItemSetOptions = {
|
|
215
|
-
|
|
216
|
-
listUrl: listServerRelativeUrl,
|
|
217
|
-
id: fileId,
|
|
218
|
-
systemUpdate: true,
|
|
219
|
-
PromotedState: 0,
|
|
220
|
-
verbose: this.verbose,
|
|
221
|
-
debug: this.debug
|
|
206
|
+
PromotedState: 0
|
|
222
207
|
};
|
|
223
|
-
await
|
|
208
|
+
await spo.systemUpdateListItem(requestUrl, fileId, logger, this.verbose, listItemSetOptions);
|
|
224
209
|
}
|
|
225
210
|
let requestOptions;
|
|
226
211
|
if (!args.options.publish) {
|
|
@@ -254,18 +239,6 @@ class SpoPageSetCommand extends SpoCommand {
|
|
|
254
239
|
this.handleRejectedODataJsonPromise(err);
|
|
255
240
|
}
|
|
256
241
|
}
|
|
257
|
-
async getFileListItemId(webUrl, serverRelativeFileUrl) {
|
|
258
|
-
const fileGetOptions = {
|
|
259
|
-
webUrl: webUrl,
|
|
260
|
-
url: serverRelativeFileUrl,
|
|
261
|
-
asListItem: true,
|
|
262
|
-
verbose: this.verbose,
|
|
263
|
-
debug: this.debug
|
|
264
|
-
};
|
|
265
|
-
const fileGetOutput = await cli.executeCommandWithOutput(spoFileGetCommand, { options: { ...fileGetOptions, _: [] } });
|
|
266
|
-
const fileGetOutputJson = JSON.parse(fileGetOutput.stdout);
|
|
267
|
-
return fileGetOutputJson.Id;
|
|
268
|
-
}
|
|
269
242
|
}
|
|
270
243
|
_SpoPageSetCommand_instances = new WeakSet(), _SpoPageSetCommand_initTelemetry = function _SpoPageSetCommand_initTelemetry() {
|
|
271
244
|
this.telemetry.push((args) => {
|
|
@@ -317,6 +290,9 @@ _SpoPageSetCommand_instances = new WeakSet(), _SpoPageSetCommand_initTelemetry =
|
|
|
317
290
|
if (isValidSharePointUrl !== true) {
|
|
318
291
|
return isValidSharePointUrl;
|
|
319
292
|
}
|
|
293
|
+
if (!args.options.layoutType && !args.options.promoteAs && !args.options.demoteFrom && args.options.commentsEnabled === undefined && !args.options.publish && !args.options.description && !args.options.title && !args.options.content) {
|
|
294
|
+
return 'Specify at least one option to update.';
|
|
295
|
+
}
|
|
320
296
|
if (args.options.layoutType &&
|
|
321
297
|
supportedPageLayouts.indexOf(args.options.layoutType) < 0) {
|
|
322
298
|
return `${args.options.layoutType} is not a valid option for layoutType. Allowed values ${supportedPageLayouts.join(', ')}`;
|
|
@@ -15,7 +15,7 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand {
|
|
|
15
15
|
return commands.SITE_APPPERMISSION_REMOVE;
|
|
16
16
|
}
|
|
17
17
|
get description() {
|
|
18
|
-
return 'Removes
|
|
18
|
+
return 'Removes a specific application permission from a site';
|
|
19
19
|
}
|
|
20
20
|
constructor() {
|
|
21
21
|
super();
|
|
@@ -48,7 +48,7 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand {
|
|
|
48
48
|
}
|
|
49
49
|
async getPermissionIds(siteId, options) {
|
|
50
50
|
if (options.id) {
|
|
51
|
-
return
|
|
51
|
+
return [options.id];
|
|
52
52
|
}
|
|
53
53
|
const permissionsObject = await this.getPermissions(siteId);
|
|
54
54
|
let permissions = permissionsObject.value;
|
|
@@ -61,7 +61,7 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand {
|
|
|
61
61
|
const spRequestOptions = {
|
|
62
62
|
url: `${this.resource}/v1.0/sites/${siteId}/permissions/${permissionId}`,
|
|
63
63
|
headers: {
|
|
64
|
-
|
|
64
|
+
accept: 'application/json;odata.metadata=none'
|
|
65
65
|
},
|
|
66
66
|
responseType: 'json'
|
|
67
67
|
};
|
|
@@ -69,16 +69,16 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand {
|
|
|
69
69
|
}
|
|
70
70
|
async commandAction(logger, args) {
|
|
71
71
|
if (args.options.force) {
|
|
72
|
-
await this.removeSiteAppPermission(
|
|
72
|
+
await this.removeSiteAppPermission(args.options);
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
75
|
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove the specified application permission from site ${args.options.siteUrl}?` });
|
|
76
76
|
if (result) {
|
|
77
|
-
await this.removeSiteAppPermission(
|
|
77
|
+
await this.removeSiteAppPermission(args.options);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
async removeSiteAppPermission(
|
|
81
|
+
async removeSiteAppPermission(options) {
|
|
82
82
|
try {
|
|
83
83
|
const siteId = await spo.getSpoGraphSiteId(options.siteUrl);
|
|
84
84
|
const permissionIdsToRemove = await this.getPermissionIds(siteId, options);
|
|
@@ -86,8 +86,7 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand {
|
|
|
86
86
|
for (const permissionId of permissionIdsToRemove) {
|
|
87
87
|
tasks.push(this.removePermissions(siteId, permissionId));
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
await logger.log(response);
|
|
89
|
+
await Promise.all(tasks);
|
|
91
90
|
}
|
|
92
91
|
catch (err) {
|
|
93
92
|
this.handleRejectedODataJsonPromise(err);
|
|
@@ -100,7 +99,7 @@ _SpoSiteAppPermissionRemoveCommand_instances = new WeakSet(), _SpoSiteAppPermiss
|
|
|
100
99
|
appId: typeof args.options.appId !== 'undefined',
|
|
101
100
|
appDisplayName: typeof args.options.appDisplayName !== 'undefined',
|
|
102
101
|
id: typeof args.options.id !== 'undefined',
|
|
103
|
-
force:
|
|
102
|
+
force: !!args.options.force
|
|
104
103
|
});
|
|
105
104
|
});
|
|
106
105
|
}, _SpoSiteAppPermissionRemoveCommand_initOptions = function _SpoSiteAppPermissionRemoveCommand_initOptions() {
|
|
@@ -6,7 +6,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _SpoSiteHubSiteConnectCommand_instances, _SpoSiteHubSiteConnectCommand_initOptions, _SpoSiteHubSiteConnectCommand_initValidators;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
8
|
import { formatting } from '../../../../utils/formatting.js';
|
|
9
|
-
import { spo } from '../../../../utils/spo.js';
|
|
10
9
|
import { validation } from '../../../../utils/validation.js';
|
|
11
10
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
12
11
|
import commands from '../../commands.js';
|
|
@@ -25,11 +24,12 @@ class SpoSiteHubSiteConnectCommand extends SpoCommand {
|
|
|
25
24
|
}
|
|
26
25
|
async commandAction(logger, args) {
|
|
27
26
|
try {
|
|
28
|
-
|
|
27
|
+
if (this.verbose) {
|
|
28
|
+
await logger.logToStderr(`Connecting site collection ${args.options.siteUrl} to hub site ${args.options.id}...`);
|
|
29
|
+
}
|
|
29
30
|
const requestOptions = {
|
|
30
31
|
url: `${args.options.siteUrl}/_api/site/JoinHubSite('${formatting.encodeQueryParameter(args.options.id)}')`,
|
|
31
32
|
headers: {
|
|
32
|
-
'X-RequestDigest': res.FormDigestValue,
|
|
33
33
|
accept: 'application/json;odata=nometadata'
|
|
34
34
|
},
|
|
35
35
|
responseType: 'json'
|
|
@@ -6,7 +6,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _SpoSiteHubSiteDisconnectCommand_instances, _SpoSiteHubSiteDisconnectCommand_initTelemetry, _SpoSiteHubSiteDisconnectCommand_initOptions, _SpoSiteHubSiteDisconnectCommand_initValidators;
|
|
7
7
|
import { cli } from '../../../../cli/cli.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
|
-
import { spo } from '../../../../utils/spo.js';
|
|
10
9
|
import { validation } from '../../../../utils/validation.js';
|
|
11
10
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
12
11
|
import commands from '../../commands.js';
|
|
@@ -15,7 +14,7 @@ class SpoSiteHubSiteDisconnectCommand extends SpoCommand {
|
|
|
15
14
|
return commands.SITE_HUBSITE_DISCONNECT;
|
|
16
15
|
}
|
|
17
16
|
get description() {
|
|
18
|
-
return 'Disconnects the
|
|
17
|
+
return 'Disconnects the specified site collection from its hub site';
|
|
19
18
|
}
|
|
20
19
|
constructor() {
|
|
21
20
|
super();
|
|
@@ -37,14 +36,12 @@ class SpoSiteHubSiteDisconnectCommand extends SpoCommand {
|
|
|
37
36
|
}
|
|
38
37
|
async disconnectHubSite(logger, args) {
|
|
39
38
|
try {
|
|
40
|
-
const res = await spo.getRequestDigest(args.options.siteUrl);
|
|
41
39
|
if (this.verbose) {
|
|
42
|
-
await logger.logToStderr(`Disconnecting site collection ${args.options.siteUrl} from its
|
|
40
|
+
await logger.logToStderr(`Disconnecting site collection ${args.options.siteUrl} from its hub site...`);
|
|
43
41
|
}
|
|
44
42
|
const requestOptions = {
|
|
45
43
|
url: `${args.options.siteUrl}/_api/site/JoinHubSite('00000000-0000-0000-0000-000000000000')`,
|
|
46
44
|
headers: {
|
|
47
|
-
'X-RequestDigest': res.FormDigestValue,
|
|
48
45
|
accept: 'application/json;odata=nometadata'
|
|
49
46
|
},
|
|
50
47
|
responseType: 'json'
|