@pnp/cli-microsoft365 7.3.0 → 7.4.0-beta.ae3d33b

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.
@@ -32,8 +32,13 @@ class PaAppGetCommand extends PowerAppsCommand {
32
32
  async commandAction(logger, args) {
33
33
  try {
34
34
  if (args.options.name) {
35
+ let endpoint = `${this.resource}/providers/Microsoft.PowerApps`;
36
+ if (args.options.asAdmin) {
37
+ endpoint += `/scopes/admin/environments/${formatting.encodeQueryParameter(args.options.environmentName)}`;
38
+ }
39
+ endpoint += `/apps/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01`;
35
40
  const requestOptions = {
36
- url: `${this.resource}/providers/Microsoft.PowerApps/apps/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01`,
41
+ url: endpoint,
37
42
  headers: {
38
43
  accept: 'application/json'
39
44
  },
@@ -50,8 +55,8 @@ class PaAppGetCommand extends PowerAppsCommand {
50
55
  await logger.logToStderr(`Retrieving information about Microsoft Power App with displayName '${args.options.displayName}'...`);
51
56
  }
52
57
  const getAppsOutput = await this.getApps(args, logger);
53
- const allApps = JSON.parse(getAppsOutput.stdout);
54
- if (allApps.length > 0) {
58
+ if (getAppsOutput.stdout && JSON.parse(getAppsOutput.stdout).length > 0) {
59
+ const allApps = JSON.parse(getAppsOutput.stdout);
55
60
  const app = allApps.find((a) => {
56
61
  return a.properties.displayName.toLowerCase() === `${args.options.displayName}`.toLowerCase();
57
62
  });
@@ -59,15 +64,11 @@ class PaAppGetCommand extends PowerAppsCommand {
59
64
  await logger.log(this.setProperties(app));
60
65
  }
61
66
  else {
62
- if (this.verbose) {
63
- await logger.logToStderr(`No app found with displayName '${args.options.displayName}'`);
64
- }
67
+ throw `No app found with displayName '${args.options.displayName}'.`;
65
68
  }
66
69
  }
67
70
  else {
68
- if (this.verbose) {
69
- await logger.logToStderr('No apps found');
70
- }
71
+ throw 'No apps found.';
71
72
  }
72
73
  }
73
74
  }
@@ -82,7 +83,9 @@ class PaAppGetCommand extends PowerAppsCommand {
82
83
  const options = {
83
84
  output: 'json',
84
85
  debug: this.debug,
85
- verbose: this.verbose
86
+ verbose: this.verbose,
87
+ environmentName: args.options.environmentName,
88
+ asAdmin: args.options.asAdmin
86
89
  };
87
90
  return await cli.executeCommandWithOutput(paAppListCommand, { options: { ...options, _: [] } });
88
91
  }
@@ -98,7 +101,9 @@ _PaAppGetCommand_instances = new WeakSet(), _PaAppGetCommand_initTelemetry = fun
98
101
  this.telemetry.push((args) => {
99
102
  Object.assign(this.telemetryProperties, {
100
103
  name: typeof args.options.name !== 'undefined',
101
- displayName: typeof args.options.displayName !== 'undefined'
104
+ displayName: typeof args.options.displayName !== 'undefined',
105
+ asAdmin: !!args.options.asAdmin,
106
+ environmentName: typeof args.options.environmentName !== 'undefined'
102
107
  });
103
108
  });
104
109
  }, _PaAppGetCommand_initOptions = function _PaAppGetCommand_initOptions() {
@@ -106,12 +111,22 @@ _PaAppGetCommand_instances = new WeakSet(), _PaAppGetCommand_initTelemetry = fun
106
111
  option: '-n, --name [name]'
107
112
  }, {
108
113
  option: '-d, --displayName [displayName]'
114
+ }, {
115
+ option: '-e, --environmentName [environmentName]'
116
+ }, {
117
+ option: '--asAdmin'
109
118
  });
110
119
  }, _PaAppGetCommand_initValidators = function _PaAppGetCommand_initValidators() {
111
120
  this.validators.push(async (args) => {
112
121
  if (args.options.name && !validation.isValidGuid(args.options.name)) {
113
122
  return `${args.options.name} is not a valid GUID`;
114
123
  }
124
+ if (args.options.asAdmin && !args.options.environmentName) {
125
+ return 'When specifying the asAdmin option, the environment option is required as well.';
126
+ }
127
+ if (args.options.environmentName && !args.options.asAdmin) {
128
+ return 'When specifying the environment option, the asAdmin option is required as well.';
129
+ }
115
130
  return true;
116
131
  });
117
132
  }, _PaAppGetCommand_initOptionSets = function _PaAppGetCommand_initOptionSets() {
@@ -30,8 +30,13 @@ class PaAppRemoveCommand extends PowerAppsCommand {
30
30
  await logger.logToStderr(`Removing Microsoft Power App ${args.options.name}...`);
31
31
  }
32
32
  const removePaApp = async () => {
33
+ let endpoint = `${this.resource}/providers/Microsoft.PowerApps`;
34
+ if (args.options.asAdmin) {
35
+ endpoint += `/scopes/admin/environments/${formatting.encodeQueryParameter(args.options.environmentName)}`;
36
+ }
37
+ endpoint += `/apps/${formatting.encodeQueryParameter(args.options.name)}?api-version=2017-08-01`;
33
38
  const requestOptions = {
34
- url: `${this.resource}/providers/Microsoft.PowerApps/apps/${formatting.encodeQueryParameter(args.options.name)}?api-version=2017-08-01`,
39
+ url: endpoint,
35
40
  fullResponse: true,
36
41
  headers: {
37
42
  accept: 'application/json'
@@ -64,7 +69,9 @@ class PaAppRemoveCommand extends PowerAppsCommand {
64
69
  _PaAppRemoveCommand_instances = new WeakSet(), _PaAppRemoveCommand_initTelemetry = function _PaAppRemoveCommand_initTelemetry() {
65
70
  this.telemetry.push((args) => {
66
71
  Object.assign(this.telemetryProperties, {
67
- force: typeof args.options.force !== 'undefined'
72
+ force: typeof args.options.force !== 'undefined',
73
+ asAdmin: !!args.options.asAdmin,
74
+ environmentName: typeof args.options.environmentName !== 'undefined'
68
75
  });
69
76
  });
70
77
  }, _PaAppRemoveCommand_initOptions = function _PaAppRemoveCommand_initOptions() {
@@ -72,12 +79,22 @@ _PaAppRemoveCommand_instances = new WeakSet(), _PaAppRemoveCommand_initTelemetry
72
79
  option: '-n, --name <name>'
73
80
  }, {
74
81
  option: '-f, --force'
82
+ }, {
83
+ option: '--asAdmin'
84
+ }, {
85
+ option: '-e, --environmentName [environmentName]'
75
86
  });
76
87
  }, _PaAppRemoveCommand_initValidators = function _PaAppRemoveCommand_initValidators() {
77
88
  this.validators.push(async (args) => {
78
89
  if (!validation.isValidGuid(args.options.name)) {
79
90
  return `${args.options.name} is not a valid GUID`;
80
91
  }
92
+ if (args.options.asAdmin && !args.options.environmentName) {
93
+ return 'When specifying the asAdmin option, the environment option is required as well.';
94
+ }
95
+ if (args.options.environmentName && !args.options.asAdmin) {
96
+ return 'When specifying the environment option, the asAdmin option is required as well.';
97
+ }
81
98
  return true;
82
99
  });
83
100
  };
@@ -20,6 +20,12 @@ m365 pa app get [options]
20
20
 
21
21
  `-d, --displayName [displayName]`
22
22
  : The display name of the Microsoft Power App to get information about.
23
+
24
+ `--asAdmin`
25
+ : Run the command as admin for apps you don't have permission to.
26
+
27
+ `-e, --environmentName [environmentName]`
28
+ : The name of the environment. Required when using `asAdmin`.
23
29
  ```
24
30
 
25
31
  <Global />
@@ -32,6 +38,9 @@ This command is based on an API that is currently in preview and is subject to c
32
38
 
33
39
  :::
34
40
 
41
+ As a maker, you are able to retrieve the Power Apps you have permission to. As an administrator, you are also able to retrieve Power Apps from other users you don't have permission to. To get the app from another user, use the `asAdmin` option and make sure to specify the `environment` option as well.
42
+
43
+
35
44
  If you try to retrieve a non-existing Microsoft Power App, you will get the `Request failed with status code 404` error.
36
45
 
37
46
  ## Examples
@@ -48,6 +57,12 @@ Get information about the specified Microsoft Power App by the app's display nam
48
57
  m365 pa app get --displayName App
49
58
  ```
50
59
 
60
+ Get information about the specific app you do not have access to.
61
+
62
+ ```sh
63
+ m365 pa app get --name 3989cb59-ce1a-4a5c-bb78-257c5c39381d --environmentName Default-d87a7535-dd31-4437-bfe1-95340acd55c5 --asAdmin
64
+ ```
65
+
51
66
  ## Response
52
67
 
53
68
  <Tabs>
@@ -18,6 +18,12 @@ m365 pa app remove [options]
18
18
 
19
19
  `-f, --force`
20
20
  : Don't prompt for confirmation
21
+
22
+ `--asAdmin`
23
+ : Run the command as admin for apps you don't own.
24
+
25
+ `-e, --environmentName [environmentName]`
26
+ : The name of the environment. Required when using `asAdmin`.
21
27
  ```
22
28
 
23
29
  <Global />
@@ -26,6 +32,8 @@ m365 pa app remove [options]
26
32
 
27
33
  By default, the command will try to remove a Power App. As maker, you are able to delete the Power Apps you own. As administrator, you are also able to delete Power Apps from other users.
28
34
 
35
+ To remove an app you do not own, use the `asAdmin` option and make sure to specify the `environmentName` option as well.
36
+
29
37
  To remove a model-driven Power App you need administrator permissions.
30
38
 
31
39
  If the Power App with the name you specified doesn't exist, you will get the `Error: App 'abc' does not exist` error.
@@ -44,6 +52,12 @@ Removes the specified Power App without confirmation
44
52
  m365 pa app remove --name 3989cb59-ce1a-4a5c-bb78-257c5c39381d --force
45
53
  ```
46
54
 
55
+ Removes the specified Power App you don't own
56
+
57
+ ```sh
58
+ m365 pa app remove --name 3989cb59-ce1a-4a5c-bb78-257c5c39381d --environmentName Default-d87a7535-dd31-4437-bfe1-95340acd55c5 --asAdmin
59
+ ```
60
+
47
61
  ## Response
48
62
 
49
63
  The command won't return a response on success.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@pnp/cli-microsoft365",
9
- "version": "7.3.0",
9
+ "version": "7.4.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@azure/msal-common": "^14.5.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "7.3.0",
3
+ "version": "7.4.0-beta.ae3d33b",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",
@@ -301,4 +301,4 @@
301
301
  "sinon": "^17.0.0",
302
302
  "source-map-support": "^0.5.21"
303
303
  }
304
- }
304
+ }