@pnp/cli-microsoft365 10.10.0-beta.3dc1bcf → 10.10.0-beta.eb74779
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/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/cli/cli.js +1 -1
- package/dist/m365/app/commands/permission/permission-add.js +8 -1
- package/dist/m365/base/SpoCommand.js +1 -0
- package/dist/m365/entra/commands/app/app-permission-add.js +5 -18
- package/dist/m365/spo/commands/site/site-set.js +2 -2
- package/dist/utils/entraServicePrincipal.js +21 -0
- package/npm-shrinkwrap.json +2322 -534
- package/package.json +12 -12
package/dist/cli/cli.js
CHANGED
|
@@ -791,7 +791,7 @@ async function closeWithError(error, args, showHelpIfEnabled = false) {
|
|
|
791
791
|
}
|
|
792
792
|
let errorMessage = error instanceof CommandError ? error.message : error;
|
|
793
793
|
if (error instanceof ZodError) {
|
|
794
|
-
errorMessage = error.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(os.EOL);
|
|
794
|
+
errorMessage = error.errors.map(e => (e.path.length > 0 ? `${e.path.join('.')}: ${e.message}` : e.message)).join(os.EOL);
|
|
795
795
|
}
|
|
796
796
|
if ((!args.options.output || args.options.output === 'json') &&
|
|
797
797
|
!cli.getSettingWithDefaultValue(settingsNames.printErrorsAsPlainText, true)) {
|
|
@@ -4,6 +4,7 @@ import { formatting } from '../../../../utils/formatting.js';
|
|
|
4
4
|
import { odata } from '../../../../utils/odata.js';
|
|
5
5
|
import AppCommand, { appCommandOptions } from '../../../base/AppCommand.js';
|
|
6
6
|
import commands from '../../commands.js';
|
|
7
|
+
import { entraServicePrincipal } from '../../../../utils/entraServicePrincipal.js';
|
|
7
8
|
const options = appCommandOptions
|
|
8
9
|
.extend({
|
|
9
10
|
applicationPermissions: z.string().optional(),
|
|
@@ -58,7 +59,13 @@ class AppPermissionAddCommand extends AppCommand {
|
|
|
58
59
|
};
|
|
59
60
|
await request.patch(addPermissionsRequestOptions);
|
|
60
61
|
if (args.options.grantAdminConsent) {
|
|
61
|
-
|
|
62
|
+
let appServicePrincipal = servicePrincipals.find(sp => sp.appId === this.appId);
|
|
63
|
+
if (!appServicePrincipal) {
|
|
64
|
+
if (this.verbose) {
|
|
65
|
+
await logger.logToStderr(`Creating service principal for app ${this.appId}...`);
|
|
66
|
+
}
|
|
67
|
+
appServicePrincipal = await entraServicePrincipal.createServicePrincipal(this.appId);
|
|
68
|
+
}
|
|
62
69
|
await this.grantAdminConsent(appServicePrincipal, appPermissions, logger);
|
|
63
70
|
}
|
|
64
71
|
}
|
|
@@ -11,6 +11,7 @@ import request from "../../../../request.js";
|
|
|
11
11
|
import { validation } from "../../../../utils/validation.js";
|
|
12
12
|
import { formatting } from "../../../../utils/formatting.js";
|
|
13
13
|
import { cli } from "../../../../cli/cli.js";
|
|
14
|
+
import { entraServicePrincipal } from "../../../../utils/entraServicePrincipal.js";
|
|
14
15
|
var ScopeType;
|
|
15
16
|
(function (ScopeType) {
|
|
16
17
|
ScopeType["Role"] = "Role";
|
|
@@ -58,7 +59,10 @@ class EntraAppPermissionAddCommand extends GraphCommand {
|
|
|
58
59
|
if (args.options.grantAdminConsent) {
|
|
59
60
|
let appServicePrincipal = servicePrincipals.find(sp => sp.appId === appObject.appId);
|
|
60
61
|
if (!appServicePrincipal) {
|
|
61
|
-
|
|
62
|
+
if (this.verbose) {
|
|
63
|
+
await logger.logToStderr(`Creating service principal for app ${appObject.appId}...`);
|
|
64
|
+
}
|
|
65
|
+
appServicePrincipal = await entraServicePrincipal.createServicePrincipal(appObject.appId);
|
|
62
66
|
}
|
|
63
67
|
await this.grantAdminConsent(appServicePrincipal, appPermissions, logger);
|
|
64
68
|
}
|
|
@@ -67,23 +71,6 @@ class EntraAppPermissionAddCommand extends GraphCommand {
|
|
|
67
71
|
this.handleRejectedODataJsonPromise(err);
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
|
-
async createServicePrincipal(appId, logger) {
|
|
71
|
-
if (this.verbose) {
|
|
72
|
-
await logger.logToStderr(`Creating service principal for app ${appId}...`);
|
|
73
|
-
}
|
|
74
|
-
const requestOptions = {
|
|
75
|
-
url: `${this.resource}/v1.0/servicePrincipals`,
|
|
76
|
-
headers: {
|
|
77
|
-
accept: 'application/json;odata.metadata=none',
|
|
78
|
-
'content-type': 'application/json;odata=nometadata'
|
|
79
|
-
},
|
|
80
|
-
data: {
|
|
81
|
-
appId
|
|
82
|
-
},
|
|
83
|
-
responseType: 'json'
|
|
84
|
-
};
|
|
85
|
-
return await request.post(requestOptions);
|
|
86
|
-
}
|
|
87
74
|
async getAppObject(options) {
|
|
88
75
|
let appNotFoundMessage = '';
|
|
89
76
|
let apps = [];
|
|
@@ -62,7 +62,7 @@ class SpoSiteSetCommand extends SpoCommand {
|
|
|
62
62
|
if (this.debug) {
|
|
63
63
|
await logger.logToStderr(`Setting the site its logo...`);
|
|
64
64
|
}
|
|
65
|
-
const logoUrl = args.options.siteLogoUrl ? urlUtil.
|
|
65
|
+
const logoUrl = args.options.siteLogoUrl ? urlUtil.getUrlRelativePath(args.options.siteLogoUrl) : "";
|
|
66
66
|
const requestOptions = {
|
|
67
67
|
url: `${args.options.url}/_api/siteiconmanager/setsitelogo`,
|
|
68
68
|
headers: {
|
|
@@ -84,7 +84,7 @@ class SpoSiteSetCommand extends SpoCommand {
|
|
|
84
84
|
if (this.debug) {
|
|
85
85
|
await logger.logToStderr(`Setting the site thumbnail...`);
|
|
86
86
|
}
|
|
87
|
-
const thumbnailUrl = args.options.siteThumbnailUrl ? urlUtil.
|
|
87
|
+
const thumbnailUrl = args.options.siteThumbnailUrl ? urlUtil.getUrlRelativePath(args.options.siteThumbnailUrl) : "";
|
|
88
88
|
const requestOptions = {
|
|
89
89
|
url: `${args.options.url}/_api/siteiconmanager/setsitelogo`,
|
|
90
90
|
headers: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { odata } from './odata.js';
|
|
2
2
|
import { formatting } from './formatting.js';
|
|
3
3
|
import { cli } from '../cli/cli.js';
|
|
4
|
+
import request from '../request.js';
|
|
4
5
|
export const entraServicePrincipal = {
|
|
5
6
|
/**
|
|
6
7
|
* Get service principal by its appId
|
|
@@ -52,6 +53,26 @@ export const entraServicePrincipal = {
|
|
|
52
53
|
url += `?$select=${properties}`;
|
|
53
54
|
}
|
|
54
55
|
return odata.getAllItems(url);
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* Create a new service principal for the specified application.
|
|
59
|
+
* @param appId Application ID of the application for which to create a service principal.
|
|
60
|
+
* @returns The created service principal.
|
|
61
|
+
*/
|
|
62
|
+
async createServicePrincipal(appId) {
|
|
63
|
+
const url = `https://graph.microsoft.com/v1.0/servicePrincipals`;
|
|
64
|
+
const requestOptions = {
|
|
65
|
+
url: url,
|
|
66
|
+
headers: {
|
|
67
|
+
accept: 'application/json;odata.metadata=none',
|
|
68
|
+
'content-type': 'application/json;odata=nometadata'
|
|
69
|
+
},
|
|
70
|
+
data: {
|
|
71
|
+
appId
|
|
72
|
+
},
|
|
73
|
+
responseType: 'json'
|
|
74
|
+
};
|
|
75
|
+
return await request.post(requestOptions);
|
|
55
76
|
}
|
|
56
77
|
};
|
|
57
78
|
//# sourceMappingURL=entraServicePrincipal.js.map
|