@pnp/cli-microsoft365 4.1.0-beta.7fbe6cd → 4.1.0-beta.85537cc

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 CHANGED
@@ -82,6 +82,7 @@
82
82
  - Supported authentication methods
83
83
  - Azure Managed Identity
84
84
  - Certificate
85
+ - Client Secret
85
86
  - Device Code
86
87
  - Username and Password
87
88
  - Manage your SharePoint Framework projects
@@ -156,22 +157,22 @@ Get command information and example usage using the global `--help` option.
156
157
  m365 spo site get --help
157
158
  ```
158
159
 
159
- Execute a command and output response as text.
160
+ Execute a command and output response as JSON.
160
161
 
161
162
  ```sh
162
163
  m365 spo site get --url https://contoso.sharepoint.com
163
164
  ```
164
165
 
165
- Execute a command and output response as JSON using the global `--output` option.
166
+ Filter responses and return custom objects using [JMESPath](https://jmespath.org/) queries using the global `--query` option.
166
167
 
167
168
  ```sh
168
- m365 spo site get --url https://contoso.sharepoint.com --output json
169
+ m365 spo site list --query '[?Template==`GROUP#0`].{Title:Title, Url:Url}'
169
170
  ```
170
171
 
171
- Filter responses and return custom objects using [JMESPath](https://jmespath.org/) queries using the global `--query` option.
172
+ Execute a command and output response as text using the global `--output` option.
172
173
 
173
174
  ```sh
174
- m365 spo site list --output json --query '[?Template==`GROUP#0`].{Title:Title, Url:Url}'
175
+ m365 spo site get --url https://contoso.sharepoint.com --output text
175
176
  ```
176
177
 
177
178
  > For more examples and usage, refer to the [command](https://pnp.github.io/cli-microsoft365/cmd/login/) and [sample scripts](https://pnp.github.io/cli-microsoft365/sample-scripts/) documentation.
package/dist/cli/Cli.js CHANGED
@@ -369,7 +369,7 @@ class Cli {
369
369
  // know this in order to decide if we should use default command's
370
370
  // properties or custom ones from JMESPath
371
371
  const originalObject = Array.isArray(logStatement) ? Cli.getFirstNonUndefinedArrayItem(logStatement) : logStatement;
372
- const originalProperties = originalObject ? Object.getOwnPropertyNames(originalObject) : [];
372
+ const originalProperties = originalObject && typeof originalObject !== 'string' ? Object.getOwnPropertyNames(originalObject) : [];
373
373
  if (options.query &&
374
374
  !options.help) {
375
375
  const jmespath = require('jmespath');
@@ -42,7 +42,6 @@ exports.default = {
42
42
  OAUTH2GRANT_REMOVE: `${prefix} oauth2grant remove`,
43
43
  OAUTH2GRANT_SET: `${prefix} oauth2grant set`,
44
44
  POLICY_LIST: `${prefix} policy list`,
45
- SERVICEPRINCIPAL_GET: `${prefix} serviceprincipal get`,
46
45
  SITECLASSIFICATION_DISABLE: `${prefix} siteclassification disable`,
47
46
  SITECLASSIFICATION_ENABLE: `${prefix} siteclassification enable`,
48
47
  SITECLASSIFICATION_GET: `${prefix} siteclassification get`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "4.1.0-beta.7fbe6cd",
3
+ "version": "4.1.0-beta.85537cc",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -1,116 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const request_1 = require("../../../../request");
4
- const Utils_1 = require("../../../../Utils");
5
- const GraphCommand_1 = require("../../../base/GraphCommand");
6
- const commands_1 = require("../../commands");
7
- class AadServicePrincipalGetCommand extends GraphCommand_1.default {
8
- get name() {
9
- return commands_1.default.SERVICEPRINCIPAL_GET;
10
- }
11
- get description() {
12
- return 'Retrieves a service principal from Azure AD directory';
13
- }
14
- getTelemetryProperties(args) {
15
- const telemetryProps = super.getTelemetryProperties(args);
16
- telemetryProps.id = typeof args.options.id !== 'undefined';
17
- telemetryProps.appId = typeof args.options.appId !== 'undefined';
18
- telemetryProps.name = typeof args.options.name !== 'undefined';
19
- return telemetryProps;
20
- }
21
- getServicePrincipalId(args) {
22
- if (args.options.id) {
23
- return Promise.resolve(args.options.id);
24
- }
25
- let requestURL = '';
26
- if (args.options.appId) {
27
- requestURL = `${this.resource}/v1.0/serviceprincipals?$filter=appId eq '${encodeURIComponent(args.options.appId)}'&$select=id`;
28
- }
29
- else {
30
- requestURL = `${this.resource}/v1.0/serviceprincipals?$filter=displayName eq '${encodeURIComponent(args.options.name)}'&$select=id`;
31
- }
32
- const requestOptions = {
33
- url: requestURL,
34
- headers: {
35
- accept: 'application/json;odata.metadata=none',
36
- ConsistencyLevel: 'eventual'
37
- },
38
- responseType: 'json'
39
- };
40
- return request_1.default
41
- .get(requestOptions)
42
- .then(response => {
43
- const servicePrincipalItem = response.value[0];
44
- if (!servicePrincipalItem) {
45
- return Promise.reject(`The specified service principal doesn't exist in Azure AD`);
46
- }
47
- if (response.value.length > 1 && args.options.name) {
48
- return Promise.reject(`Multiple service principals with name ${args.options.name} found: ${response.value.map(x => x.id)}`);
49
- }
50
- if (response.value.length > 1 && args.options.appId) {
51
- return Promise.reject(`Multiple service principals with appId ${args.options.appId} found: ${response.value.map(x => x.id)}`);
52
- }
53
- return Promise.resolve(servicePrincipalItem.id);
54
- });
55
- }
56
- commandAction(logger, args, cb) {
57
- this
58
- .getServicePrincipalId(args)
59
- .then((servicePrincipalId) => {
60
- const requestOptions = {
61
- url: `${this.resource}/v1.0/serviceprincipals/${encodeURIComponent(servicePrincipalId)}`,
62
- headers: {
63
- accept: 'application/json;odata.metadata=none',
64
- ConsistencyLevel: 'eventual'
65
- },
66
- responseType: 'json'
67
- };
68
- return request_1.default.get(requestOptions);
69
- })
70
- .then((res) => {
71
- logger.log(res);
72
- cb();
73
- }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
74
- }
75
- options() {
76
- const options = [
77
- {
78
- option: '-i, --id [id]'
79
- },
80
- {
81
- option: '--appId [appId]'
82
- },
83
- {
84
- option: '--n, --name [name]'
85
- }
86
- ];
87
- const parentOptions = super.options();
88
- return options.concat(parentOptions);
89
- }
90
- validate(args) {
91
- if (args.options.id && args.options.appId && args.options.name) {
92
- return 'Specify either id, appId or name, but not all.';
93
- }
94
- if (args.options.id && args.options.appId) {
95
- return 'Specify either id or appId, but not both.';
96
- }
97
- if (args.options.appId && args.options.name) {
98
- return 'Specify either appId or name, but not both.';
99
- }
100
- if (args.options.name && args.options.id) {
101
- return 'Specify either id or name, but not both.';
102
- }
103
- if (!args.options.id && !args.options.appId && !args.options.name) {
104
- return 'Specify id, appId or name, one is required';
105
- }
106
- if (args.options.id && !Utils_1.default.isValidGuid(args.options.id)) {
107
- return `${args.options.id} is not a valid GUID`;
108
- }
109
- if (args.options.appId && !Utils_1.default.isValidGuid(args.options.appId)) {
110
- return `${args.options.appId} is not a valid GUID`;
111
- }
112
- return true;
113
- }
114
- }
115
- module.exports = new AadServicePrincipalGetCommand();
116
- //# sourceMappingURL=serviceprincipal-get.js.map
@@ -1,42 +0,0 @@
1
- # aad serviceprincipal get
2
-
3
- Retrieves a service principal from Azure AD directory
4
-
5
- ## Usage
6
-
7
- ```sh
8
- m365 aad serviceprincipal get
9
- ```
10
-
11
- ## Options
12
-
13
- `-i, --id [id]`
14
- : The ID of the service principal to retrieve information for. Specify either `id`, `appId` or `name`
15
-
16
- `-n, --name [name]`
17
- : The display name of the service principal to retrieve information for. Specify either `id`, `appId` or `name`
18
-
19
- `--appId [appId]`
20
- : The appId of the service principal to retrieve information for. Specify either `id` or `appId` or `name`
21
-
22
- --8<-- "docs/cmd/_global.md"
23
-
24
- ## Examples
25
-
26
- Get information about the service principal with id _1caf7dcd-7e83-4c3a-94f7-932a1299c843_
27
-
28
- ```sh
29
- m365 aad serviceprincipal get --id 1caf7dcd-7e83-4c3a-94f7-932a1299c843
30
- ```
31
-
32
- Get information about service principal with name _ServicePrincipal App_
33
-
34
- ```sh
35
- m365 aad serviceprincipal get --name "ServicePrincipal App"
36
- ```
37
-
38
- Get information about service principal with appId _8a2a376d-5f57-4c14-9639-692f841c00bc_
39
-
40
- ```sh
41
- m365 aad serviceprincipal get --appId "8a2a376d-5f57-4c14-9639-692f841c00bc"
42
- ```