@pnp/cli-microsoft365 7.0.0 → 7.1.0-beta.8b56e1d
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/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/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/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 +2 -2
- package/package.json +2 -2
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>, \
|
|
@@ -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'
|
|
@@ -12,7 +12,7 @@ export class Page {
|
|
|
12
12
|
}
|
|
13
13
|
const pageName = this.getPageNameWithExtension(name);
|
|
14
14
|
const requestOptions = {
|
|
15
|
-
url: `${webUrl}/_api/web/
|
|
15
|
+
url: `${webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${urlUtil.getServerRelativeSiteUrl(webUrl)}/SitePages/${formatting.encodeQueryParameter(pageName)}')?$expand=ListItemAllFields/ClientSideApplicationId`,
|
|
16
16
|
headers: {
|
|
17
17
|
'content-type': 'application/json;charset=utf-8',
|
|
18
18
|
accept: 'application/json;odata=nometadata'
|
|
@@ -52,7 +52,7 @@ class SpoPageAddCommand extends SpoCommand {
|
|
|
52
52
|
const reqDigest = await spo.getRequestDigest(args.options.webUrl);
|
|
53
53
|
requestDigest = reqDigest.FormDigestValue;
|
|
54
54
|
let requestOptions = {
|
|
55
|
-
url: `${args.options.webUrl}/_api/web/
|
|
55
|
+
url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${serverRelativeSiteUrl}/sitepages')/files/AddTemplateFile`,
|
|
56
56
|
headers: {
|
|
57
57
|
'X-RequestDigest': requestDigest,
|
|
58
58
|
'content-type': 'application/json;odata=nometadata',
|
|
@@ -36,7 +36,7 @@ class SpoPageGetCommand extends SpoCommand {
|
|
|
36
36
|
}
|
|
37
37
|
try {
|
|
38
38
|
let requestOptions = {
|
|
39
|
-
url: `${args.options.webUrl}/_api/web/
|
|
39
|
+
url: `${args.options.webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${urlUtil.getServerRelativeSiteUrl(args.options.webUrl)}/SitePages/${formatting.encodeQueryParameter(pageName)}')?$expand=ListItemAllFields/ClientSideApplicationId,ListItemAllFields/PageLayoutType,ListItemAllFields/CommentsDisabled`,
|
|
40
40
|
headers: {
|
|
41
41
|
'content-type': 'application/json;charset=utf-8',
|
|
42
42
|
accept: 'application/json;odata=nometadata'
|
|
@@ -300,7 +300,7 @@ class SpoPageHeaderSetCommand extends SpoCommand {
|
|
|
300
300
|
await logger.logToStderr(`Retrieving information about the header image...`);
|
|
301
301
|
}
|
|
302
302
|
const requestOptions = {
|
|
303
|
-
url: `${siteUrl}/_api/web/
|
|
303
|
+
url: `${siteUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(imageUrl)}')?$select=ListId,UniqueId`,
|
|
304
304
|
headers: {
|
|
305
305
|
accept: 'application/json;odata=nometadata'
|
|
306
306
|
},
|
|
@@ -54,7 +54,7 @@ class SpoPageRemoveCommand extends SpoCommand {
|
|
|
54
54
|
}
|
|
55
55
|
const requestOptions = {
|
|
56
56
|
url: `${args.options
|
|
57
|
-
.webUrl}/_api/web/
|
|
57
|
+
.webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${urlUtil.getServerRelativeSiteUrl(args.options.webUrl)}/sitepages/${pageName}')`,
|
|
58
58
|
headers: {
|
|
59
59
|
'X-RequestDigest': requestDigest,
|
|
60
60
|
'X-HTTP-Method': 'DELETE',
|
|
@@ -199,7 +199,7 @@ class SpoPageSetCommand extends SpoCommand {
|
|
|
199
199
|
}
|
|
200
200
|
if (typeof args.options.commentsEnabled !== 'undefined') {
|
|
201
201
|
const requestOptions = {
|
|
202
|
-
url: `${args.options.webUrl}/_api/web/
|
|
202
|
+
url: `${args.options.webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${serverRelativeFileUrl}')/ListItemAllFields/SetCommentsDisabled(${args.options.commentsEnabled === false})`,
|
|
203
203
|
headers: {
|
|
204
204
|
'X-RequestDigest': requestDigest,
|
|
205
205
|
'content-type': 'application/json;odata=nometadata',
|
|
@@ -239,7 +239,7 @@ class SpoPageSetCommand extends SpoCommand {
|
|
|
239
239
|
}
|
|
240
240
|
else {
|
|
241
241
|
requestOptions = {
|
|
242
|
-
url: `${args.options.webUrl}/_api/web/
|
|
242
|
+
url: `${args.options.webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${serverRelativeFileUrl}')/CheckIn(comment=@a1,checkintype=@a2)?@a1='${formatting.encodeQueryParameter(args.options.publishMessage || '')}'&@a2=1`,
|
|
243
243
|
headers: {
|
|
244
244
|
'X-RequestDigest': requestDigest,
|
|
245
245
|
'content-type': 'application/json;odata=nometadata',
|
|
@@ -79,7 +79,7 @@ class SpoPageTextAddCommand extends SpoCommand {
|
|
|
79
79
|
}
|
|
80
80
|
const requestOptions = {
|
|
81
81
|
url: `${args.options
|
|
82
|
-
.webUrl}/_api/web/
|
|
82
|
+
.webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${urlUtil.getServerRelativeSiteUrl(args.options.webUrl)}/sitepages/${pageName}')/ListItemAllFields`,
|
|
83
83
|
headers: {
|
|
84
84
|
'X-RequestDigest': requestDigest,
|
|
85
85
|
'content-type': 'application/json;odata=nometadata',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
module.exports.rules = {
|
|
2
2
|
'correct-command-class-name': require('./rules/correct-command-class-name'),
|
|
3
|
-
'correct-command-name': require('./rules/correct-command-name')
|
|
3
|
+
'correct-command-name': require('./rules/correct-command-name'),
|
|
4
|
+
'no-by-server-relative-url-usage': require('./rules/no-by-server-relative-url-usage')
|
|
4
5
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function reportIncorrectEndpoint(context, node, urlEndpoint, pathEndpoint, updatedValue) {
|
|
2
|
+
context.report({
|
|
3
|
+
node,
|
|
4
|
+
messageId: 'incorrectEndpoint',
|
|
5
|
+
data: { urlEndpoint, pathEndpoint },
|
|
6
|
+
fix: fixer => fixer.replaceText(node, updatedValue),
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
meta: {
|
|
12
|
+
type: 'problem',
|
|
13
|
+
docs: {
|
|
14
|
+
description: "Prevent usage of 'ByServerRelativeUrl' endpoint",
|
|
15
|
+
recommended: true
|
|
16
|
+
},
|
|
17
|
+
fixable: 'code',
|
|
18
|
+
messages: {
|
|
19
|
+
incorrectEndpoint: `Avoid "{{ urlEndpoint }}" endpoint. Instead, use "{{ pathEndpoint }}". Reference issue #5333 for more information.`
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
create: context => {
|
|
23
|
+
return {
|
|
24
|
+
TemplateLiteral(node) {
|
|
25
|
+
const sourceCodeText = context.getSourceCode().getText(node);
|
|
26
|
+
const updatedValue = sourceCodeText
|
|
27
|
+
.replace(/GetFileByServerRelativeUrl\(/ig, 'GetFileByServerRelativePath(DecodedUrl=')
|
|
28
|
+
.replace(/GetFolderByServerRelativeUrl\(/ig, 'GetFolderByServerRelativePath(DecodedUrl=');
|
|
29
|
+
|
|
30
|
+
if (updatedValue !== sourceCodeText) {
|
|
31
|
+
const templateValue = node.quasis.map(quasi => quasi.value.raw).join('');
|
|
32
|
+
const urlEndpoint = templateValue.match(/GetFileByServerRelativeUrl\(/i) ? "GetFileByServerRelativeUrl('url')" : "GetFolderByServerRelativeUrl('url')";
|
|
33
|
+
const pathEndpoint = urlEndpoint.replace("Url('url')", "Path(DecodedUrl='url')");
|
|
34
|
+
|
|
35
|
+
reportIncorrectEndpoint(context, node, urlEndpoint, pathEndpoint, updatedValue);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
VariableDeclarator(node) {
|
|
39
|
+
const { init } = node;
|
|
40
|
+
if (
|
|
41
|
+
init && init.type === 'Literal' &&
|
|
42
|
+
(String(init.value).match(/GetFileByServerRelativeUrl\(/i) || String(init.value).match(/GetFolderByServerRelativeUrl\(/i))
|
|
43
|
+
) {
|
|
44
|
+
const urlEndpoint = String(init.value).match(/GetFileByServerRelativeUrl\(/i) ? "GetFileByServerRelativeUrl('url')" : "GetFolderByServerRelativeUrl('url')";
|
|
45
|
+
const pathEndpoint = urlEndpoint.replace("Url('url')", "Path(DecodedUrl='url')");
|
|
46
|
+
const updatedValue = String(init.value)
|
|
47
|
+
.replace(/GetFileByServerRelativeUrl\(/i, 'GetFileByServerRelativePath(DecodedUrl=')
|
|
48
|
+
.replace(/GetFolderByServerRelativeUrl\(/i, 'GetFolderByServerRelativePath(DecodedUrl=');
|
|
49
|
+
|
|
50
|
+
reportIncorrectEndpoint(context, init, urlEndpoint, pathEndpoint, `'${updatedValue}'`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
};
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnp/cli-microsoft365",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@pnp/cli-microsoft365",
|
|
9
|
-
"version": "7.
|
|
9
|
+
"version": "7.1.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@azure/msal-common": "^13.2.1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnp/cli-microsoft365",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-beta.8b56e1d",
|
|
4
4
|
"description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/api.js",
|
|
@@ -279,4 +279,4 @@
|
|
|
279
279
|
"sinon": "^15.2.0",
|
|
280
280
|
"source-map-support": "^0.5.21"
|
|
281
281
|
}
|
|
282
|
-
}
|
|
282
|
+
}
|