@pnp/cli-microsoft365 5.2.0-beta.90d2227 → 5.2.0-beta.a814a27

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.js CHANGED
@@ -37,6 +37,7 @@ const dictionary = [
37
37
  'list',
38
38
  'management',
39
39
  'member',
40
+ 'membership',
40
41
  'messaging',
41
42
  'news',
42
43
  'oauth2',
package/.mocharc.json CHANGED
@@ -5,5 +5,6 @@
5
5
  "spec": "dist/**/*.spec.js",
6
6
  "require": "source-map-support/register",
7
7
  "watch": "dist/**/*.js",
8
+ "timeout": 10000,
8
9
  "logpanel": true
9
10
  }
package/dist/Auth.js CHANGED
@@ -301,7 +301,8 @@ class Auth {
301
301
  logger.logToStderr('');
302
302
  }
303
303
  logger.log(response.message);
304
- if (cli_1.Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.autoOpenBrowserOnLogin, false)) {
304
+ if (cli_1.Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.autoOpenBrowserOnLogin, false)
305
+ || cli_1.Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.autoOpenLinksInBrowser, false)) {
305
306
  // _open is never set before hitting this line, but this check
306
307
  // is implemented so that we can support lazy loading
307
308
  // but also stub it for testing
package/dist/Command.js CHANGED
@@ -144,7 +144,12 @@ class Command {
144
144
  return __awaiter(this, void 0, void 0, function* () {
145
145
  });
146
146
  }
147
- getCommandName() {
147
+ getCommandName(alias) {
148
+ var _a;
149
+ if (alias &&
150
+ ((_a = this.alias()) === null || _a === void 0 ? void 0 : _a.includes(alias))) {
151
+ return alias;
152
+ }
148
153
  let commandName = this.name;
149
154
  let pos = commandName.indexOf('<');
150
155
  const pos1 = commandName.indexOf('[');
package/dist/cli/Cli.js CHANGED
@@ -202,7 +202,7 @@ class Cli {
202
202
  // the command to execute
203
203
  const cli = Cli.getInstance();
204
204
  const parentCommandName = cli.currentCommandName;
205
- cli.currentCommandName = command.getCommandName();
205
+ cli.currentCommandName = command.getCommandName(cli.currentCommandName);
206
206
  command.action(logger, args, (err) => {
207
207
  // restore the original command name
208
208
  cli.currentCommandName = parentCommandName;
@@ -21,6 +21,9 @@ class AppGetCommand extends AppCommand_1.default {
21
21
  cli_1.Cli
22
22
  .executeCommandWithOutput(AadAppGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) })
23
23
  .then((appGetOutput) => {
24
+ if (this.verbose) {
25
+ logger.logToStderr(appGetOutput.stderr);
26
+ }
24
27
  logger.log(JSON.parse(appGetOutput.stdout));
25
28
  cb();
26
29
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("../../../cli");
3
4
  const config_1 = require("../../../config");
5
+ const settingsNames_1 = require("../../../settingsNames");
4
6
  const AnonymousCommand_1 = require("../../base/AnonymousCommand");
5
7
  const commands_1 = require("../commands");
6
8
  class CliReconsentCommand extends AnonymousCommand_1.default {
@@ -11,8 +13,24 @@ class CliReconsentCommand extends AnonymousCommand_1.default {
11
13
  return 'Returns Azure AD URL to open in the browser to re-consent CLI for Microsoft 365 permissions';
12
14
  }
13
15
  commandAction(logger, args, cb) {
14
- logger.log(`To re-consent the PnP Microsoft 365 Management Shell Azure AD application navigate in your web browser to https://login.microsoftonline.com/${config_1.default.tenant}/oauth2/authorize?client_id=${config_1.default.cliAadAppId}&response_type=code&prompt=admin_consent`);
15
- cb();
16
+ const url = `https://login.microsoftonline.com/${config_1.default.tenant}/oauth2/authorize?client_id=${config_1.default.cliAadAppId}&response_type=code&prompt=admin_consent`;
17
+ if (cli_1.Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.autoOpenLinksInBrowser, false) === false) {
18
+ logger.log(`To re-consent the PnP Microsoft 365 Management Shell Azure AD application navigate in your web browser to ${url}`);
19
+ return cb();
20
+ }
21
+ logger.log(`Opening the following page in your browser: ${url}`);
22
+ // _open is never set before hitting this line, but this check
23
+ // is implemented so that we can support lazy loading
24
+ // but also stub it for testing
25
+ /* c8 ignore next 3 */
26
+ if (!this._open) {
27
+ this._open = require('open');
28
+ }
29
+ this._open(url).then(() => {
30
+ cb();
31
+ }, (error) => {
32
+ this.handleRejectedODataJsonPromise(error, logger, cb);
33
+ });
16
34
  }
17
35
  }
18
36
  module.exports = new CliReconsentCommand();
@@ -20,6 +20,7 @@ class CliConfigSetCommand extends AnonymousCommand_1.default {
20
20
  let value = undefined;
21
21
  switch (args.options.key) {
22
22
  case settingsNames_1.settingsNames.autoOpenBrowserOnLogin:
23
+ case settingsNames_1.settingsNames.autoOpenLinksInBrowser:
23
24
  case settingsNames_1.settingsNames.copyDeviceCodeToClipboard:
24
25
  case settingsNames_1.settingsNames.csvHeader:
25
26
  case settingsNames_1.settingsNames.csvQuoted:
@@ -242,6 +242,9 @@ class SpfxProjectUpgradeCommand extends base_project_command_1.BaseProjectComman
242
242
  }
243
243
  });
244
244
  switch (args.options.output) {
245
+ case 'text':
246
+ logger.log(this.getTextReport(findingsToReport));
247
+ break;
245
248
  case 'json':
246
249
  logger.log(findingsToReport);
247
250
  break;
@@ -252,7 +255,7 @@ class SpfxProjectUpgradeCommand extends base_project_command_1.BaseProjectComman
252
255
  logger.log(this.getMdReport(findingsToReport));
253
256
  break;
254
257
  default:
255
- logger.log(this.getTextReport(findingsToReport));
258
+ logger.log(findingsToReport);
256
259
  }
257
260
  cb();
258
261
  }
@@ -50,7 +50,7 @@ class SpoSiteRemoveCommand extends SpoCommand_1.default {
50
50
  if (args.options.skipRecycleBin || args.options.wait) {
51
51
  logger.logToStderr(chalk.yellow(`Entered site is a groupified site. Hence, the parameters 'skipRecycleBin' and 'wait' will not be applicable.`));
52
52
  }
53
- return this.deleteGroupifiedSite(group.id, logger);
53
+ return this.deleteGroup(group.id, logger);
54
54
  })
55
55
  .catch((err) => {
56
56
  if (err.response.status === 404) {
@@ -79,7 +79,8 @@ class SpoSiteRemoveCommand extends SpoCommand_1.default {
79
79
  else {
80
80
  return Promise.reject(err);
81
81
  }
82
- });
82
+ })
83
+ .then(_ => this.deleteSite(args.options.url, args.options.wait, logger));
83
84
  }
84
85
  })
85
86
  .then(_ => cb(), (err) => this.handleRejectedPromise(err, logger, cb));
@@ -296,7 +297,7 @@ class SpoSiteRemoveCommand extends SpoCommand_1.default {
296
297
  }
297
298
  });
298
299
  }
299
- deleteGroupifiedSite(groupId, logger) {
300
+ deleteGroup(groupId, logger) {
300
301
  if (this.verbose) {
301
302
  logger.logToStderr(`Removing Microsoft 365 Group: ${groupId}...`);
302
303
  }
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../../../../utils");
4
+ const GraphCommand_1 = require("../../../base/GraphCommand");
5
+ const commands_1 = require("../../commands");
6
+ const request_1 = require("../../../../request");
7
+ class TeamsChannelMembershipListCommand extends GraphCommand_1.default {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.teamId = '';
11
+ }
12
+ get name() {
13
+ return commands_1.default.CHANNEL_MEMBERSHIP_LIST;
14
+ }
15
+ get description() {
16
+ return 'Lists memberships in the specified Microsoft Teams team channel';
17
+ }
18
+ defaultProperties() {
19
+ return ['id', 'roles', 'displayName', 'userId', 'email'];
20
+ }
21
+ getTelemetryProperties(args) {
22
+ const telemetryProps = super.getTelemetryProperties(args);
23
+ telemetryProps.teamId = typeof args.options.teamId !== 'undefined';
24
+ telemetryProps.teamName = typeof args.options.teamName !== 'undefined';
25
+ telemetryProps.channelId = typeof args.options.channelId !== 'undefined';
26
+ telemetryProps.channelName = typeof args.options.channelName !== 'undefined';
27
+ telemetryProps.role = typeof args.options.role;
28
+ return telemetryProps;
29
+ }
30
+ commandAction(logger, args, cb) {
31
+ this
32
+ .getTeamId(args)
33
+ .then((teamId) => {
34
+ this.teamId = teamId;
35
+ return this.getChannelId(args);
36
+ })
37
+ .then((channelId) => {
38
+ const endpoint = `${this.resource}/v1.0/teams/${this.teamId}/channels/${channelId}/members`;
39
+ return utils_1.odata.getAllItems(endpoint, logger);
40
+ })
41
+ .then((memberships) => {
42
+ if (args.options.role) {
43
+ if (args.options.role === 'member') {
44
+ // Members have no role value
45
+ memberships = memberships.filter(i => i.roles.length === 0);
46
+ }
47
+ else {
48
+ memberships = memberships.filter(i => i.roles.indexOf(args.options.role) !== -1);
49
+ }
50
+ }
51
+ logger.log(memberships);
52
+ cb();
53
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
54
+ }
55
+ getTeamId(args) {
56
+ if (args.options.teamId) {
57
+ return Promise.resolve(args.options.teamId);
58
+ }
59
+ const requestOptions = {
60
+ url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(args.options.teamName)}'`,
61
+ headers: {
62
+ accept: 'application/json;odata.metadata=none'
63
+ },
64
+ responseType: 'json'
65
+ };
66
+ return request_1.default
67
+ .get(requestOptions)
68
+ .then(response => {
69
+ const groupItem = response.value[0];
70
+ if (!groupItem) {
71
+ return Promise.reject(`The specified team does not exist in the Microsoft Teams`);
72
+ }
73
+ if (groupItem.resourceProvisioningOptions.indexOf('Team') === -1) {
74
+ return Promise.reject(`The specified team does not exist in the Microsoft Teams`);
75
+ }
76
+ if (response.value.length > 1) {
77
+ return Promise.reject(`Multiple Microsoft Teams teams with name ${args.options.teamName} found: ${response.value.map(x => x.id)}`);
78
+ }
79
+ return Promise.resolve(groupItem.id);
80
+ });
81
+ }
82
+ getChannelId(args) {
83
+ if (args.options.channelId) {
84
+ return Promise.resolve(args.options.channelId);
85
+ }
86
+ const channelRequestOptions = {
87
+ url: `${this.resource}/v1.0/teams/${encodeURIComponent(this.teamId)}/channels?$filter=displayName eq '${encodeURIComponent(args.options.channelName)}'`,
88
+ headers: {
89
+ accept: 'application/json;odata.metadata=none'
90
+ },
91
+ responseType: 'json'
92
+ };
93
+ return request_1.default
94
+ .get(channelRequestOptions)
95
+ .then(response => {
96
+ const channelItem = response.value[0];
97
+ if (!channelItem) {
98
+ return Promise.reject(`The specified channel does not exist in the Microsoft Teams team`);
99
+ }
100
+ return Promise.resolve(channelItem.id);
101
+ });
102
+ }
103
+ options() {
104
+ const options = [
105
+ {
106
+ option: '--teamId [teamId]'
107
+ },
108
+ {
109
+ option: '--teamName [teamName]'
110
+ },
111
+ {
112
+ option: '--channelId [channelId]'
113
+ },
114
+ {
115
+ option: '--channelName [channelName]'
116
+ },
117
+ {
118
+ option: '-r, --role [role]',
119
+ autocomplete: ['owner', 'member', 'guest']
120
+ }
121
+ ];
122
+ const parentOptions = super.options();
123
+ return options.concat(parentOptions);
124
+ }
125
+ validate(args) {
126
+ if (args.options.teamId && args.options.teamName) {
127
+ return 'Specify either teamId or teamName, but not both';
128
+ }
129
+ if (!args.options.teamId && !args.options.teamName) {
130
+ return 'Specify teamId or teamName, one is required';
131
+ }
132
+ if (args.options.teamId && !utils_1.validation.isValidGuid(args.options.teamId)) {
133
+ return `${args.options.teamId} is not a valid GUID`;
134
+ }
135
+ if (args.options.channelId && args.options.channelName) {
136
+ return 'Specify either channelId or channelName, but not both';
137
+ }
138
+ if (!args.options.channelId && !args.options.channelName) {
139
+ return 'Specify channelId or channelName, one is required';
140
+ }
141
+ if (args.options.role) {
142
+ if (['owner', 'member', 'guest'].indexOf(args.options.role) === -1) {
143
+ return `${args.options.role} is not a valid role value. Allowed values owner|member|guest`;
144
+ }
145
+ }
146
+ return true;
147
+ }
148
+ }
149
+ module.exports = new TeamsChannelMembershipListCommand();
150
+ //# sourceMappingURL=channel-membership-list.js.map
@@ -11,6 +11,7 @@ exports.default = {
11
11
  CHANNEL_ADD: `${prefix} channel add`,
12
12
  CHANNEL_GET: `${prefix} channel get`,
13
13
  CHANNEL_LIST: `${prefix} channel list`,
14
+ CHANNEL_MEMBERSHIP_LIST: `${prefix} channel membership list`,
14
15
  CHANNEL_REMOVE: `${prefix} channel remove`,
15
16
  CHANNEL_SET: `${prefix} channel set`,
16
17
  CHAT_GET: `${prefix} chat get`,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.settingsNames = void 0;
4
4
  const settingsNames = {
5
5
  autoOpenBrowserOnLogin: 'autoOpenBrowserOnLogin',
6
+ autoOpenLinksInBrowser: 'autoOpenLinksInBrowser',
6
7
  copyDeviceCodeToClipboard: 'copyDeviceCodeToClipboard',
7
8
  csvEscape: 'csvEscape',
8
9
  csvHeader: 'csvHeader',
@@ -0,0 +1,48 @@
1
+ # teams channel membership list
2
+
3
+ Lists memberships in the specified Microsoft Teams team channel
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 teams channel membership list [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `--teamId [teamId]`
14
+ : The Id of the Microsoft Teams team. Specify either `teamId` or `teamName` but not both
15
+
16
+ `--teamName [teamName]`
17
+ : The display name of the Microsoft Teams team. Specify either `teamId` or `teamName` but not both
18
+
19
+ `--channelId [channelId]`
20
+ : The Id of the Microsoft Teams team channel. Specify either `channelId` or `channelName` but not both
21
+
22
+ `channelName [channelName]`
23
+ : The display name of the Microsoft Teams team channel. Specify either `channelId` or `channelName` but not both
24
+
25
+ `-r, --role [role]`
26
+ : Filter the results to only users with the given role: owner, member, guest
27
+
28
+ --8<-- "docs/cmd/_global.md"
29
+
30
+ ## Examples
31
+
32
+ List the memberships in a specified Microsoft Teams team with id 00000000-0000-0000-0000-000000000000 and channel id 00:00000000000000000000000000000000@thread.skype
33
+
34
+ ```sh
35
+ m365 teams channel membership list --teamId 00000000-0000-0000-0000-000000000000 --channelId 00:00000000000000000000000000000000@thread.skype
36
+ ```
37
+
38
+ List the memberships in a specified Microsoft Teams team with name _Team Name_ and channel with name _Channel Name_
39
+
40
+ ```sh
41
+ m365 teams channel membership list --teamName "Team Name" --channelName "Channel Name"
42
+ ```
43
+
44
+ List all owner memberships in the specified Microsoft Teams team with id 00000000-0000-0000-0000-000000000000 and channel id 00:00000000000000000000000000000000@thread.skype
45
+
46
+ ```sh
47
+ m365 teams channel membership list --teamId 00000000-0000-0000-0000-000000000000 --channelId 00:00000000000000000000000000000000@thread.skype --role owner
48
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "5.2.0-beta.90d2227",
3
+ "version": "5.2.0-beta.a814a27",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",
@@ -25,7 +25,7 @@
25
25
  "test": "npm run test:version && npm run lint && npm run test:cov",
26
26
  "test:version": "node scripts/check-version.js",
27
27
  "test:cov": "c8 npm run test:test",
28
- "test:test": "mocha \"dist/**/*.spec.js\" --timeout 10000",
28
+ "test:test": "mocha",
29
29
  "lint": "eslint --ext .ts src"
30
30
  },
31
31
  "keywords": [