@pnp/cli-microsoft365 7.8.0-beta.5ca5055 → 7.8.0-beta.5f64790
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 +3 -3
- package/dist/index.js +13 -12
- package/dist/m365/commands/setup.js +3 -3
- package/dist/m365/entra/commands/m365group/m365group-add.js +4 -2
- package/dist/m365/outlook/commands/message/message-list.js +87 -17
- package/dist/m365/spo/commands/site/site-remove.js +128 -149
- package/dist/utils/urlUtil.js +8 -0
- package/docs/docs/cmd/entra/m365group/m365group-add.mdx +24 -24
- package/docs/docs/cmd/outlook/message/message-list.mdx +18 -6
- package/docs/docs/cmd/spo/site/site-remove.mdx +9 -19
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -18,7 +18,6 @@ import { validation } from '../utils/validation.js';
|
|
|
18
18
|
import { prompt } from '../utils/prompt.js';
|
|
19
19
|
import { timings } from './timings.js';
|
|
20
20
|
import { browserUtil } from '../utils/browserUtil.js';
|
|
21
|
-
import chalk from 'chalk';
|
|
22
21
|
const require = createRequire(import.meta.url);
|
|
23
22
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
24
23
|
let _config;
|
|
@@ -564,6 +563,7 @@ async function printHelp(helpMode, exitCode = 0) {
|
|
|
564
563
|
}
|
|
565
564
|
else {
|
|
566
565
|
if (cli.currentCommandName && !cli.commands.some(command => command.name.startsWith(cli.currentCommandName))) {
|
|
566
|
+
const chalk = (await import('chalk')).default;
|
|
567
567
|
await cli.error(chalk.red(`Command '${cli.currentCommandName}' was not found. Below you can find the commands and command groups you can use. For detailed information on a command group, use 'm365 [command group] --help'.`));
|
|
568
568
|
}
|
|
569
569
|
cli.log();
|
|
@@ -735,13 +735,13 @@ async function closeWithError(error, args, showHelpIfEnabled = false) {
|
|
|
735
735
|
if (args.options.output === 'none') {
|
|
736
736
|
return process.exit(exitCode);
|
|
737
737
|
}
|
|
738
|
-
const chalk = (await import('chalk')).default;
|
|
739
738
|
let errorMessage = error instanceof CommandError ? error.message : error;
|
|
740
739
|
if ((!args.options.output || args.options.output === 'json') &&
|
|
741
740
|
!cli.getSettingWithDefaultValue(settingsNames.printErrorsAsPlainText, true)) {
|
|
742
741
|
errorMessage = JSON.stringify({ error: errorMessage });
|
|
743
742
|
}
|
|
744
743
|
else {
|
|
744
|
+
const chalk = (await import('chalk')).default;
|
|
745
745
|
errorMessage = chalk.red(`Error: ${errorMessage}`);
|
|
746
746
|
}
|
|
747
747
|
if (error instanceof CommandError && error.code) {
|
|
@@ -749,7 +749,7 @@ async function closeWithError(error, args, showHelpIfEnabled = false) {
|
|
|
749
749
|
}
|
|
750
750
|
await cli.error(errorMessage);
|
|
751
751
|
if (showHelpIfEnabled &&
|
|
752
|
-
|
|
752
|
+
cli.getSettingWithDefaultValue(settingsNames.showHelpOnFailure, showHelpIfEnabled)) {
|
|
753
753
|
await printHelp(await getHelpMode(args.options), exitCode);
|
|
754
754
|
}
|
|
755
755
|
else {
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { cli } from './cli/cli.js';
|
|
3
3
|
import { app } from './utils/app.js';
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
process.stdout._handle
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
(async () => {
|
|
5
|
+
// required to make console.log() in combination with piped output synchronous
|
|
6
|
+
// on Windows/in PowerShell so that the output is not trimmed by calling
|
|
7
|
+
// process.exit() after executing the command, while the output is still
|
|
8
|
+
// being processed; https://github.com/pnp/cli-microsoft365/issues/1266
|
|
9
|
+
if (process.stdout._handle) {
|
|
10
|
+
process.stdout._handle.setBlocking(true);
|
|
11
|
+
}
|
|
12
|
+
if (!process.env.CLIMICROSOFT365_NOUPDATE) {
|
|
13
|
+
const updateNotifier = await import('update-notifier');
|
|
13
14
|
updateNotifier.default({ pkg: app.packageJson() }).notify({ defer: false });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
}
|
|
16
|
+
await cli.execute(process.argv.slice(2));
|
|
17
|
+
})();
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -35,9 +35,9 @@ class SetupCommand extends AnonymousCommand {
|
|
|
35
35
|
}
|
|
36
36
|
else if (args.options.scripting) {
|
|
37
37
|
Object.assign(settings, scriptingPreset);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
if (pid.isPowerShell()) {
|
|
39
|
+
Object.assign(settings, powerShellPreset);
|
|
40
|
+
}
|
|
41
41
|
}
|
|
42
42
|
await this.configureSettings(settings, true, logger);
|
|
43
43
|
return;
|
|
@@ -189,6 +189,7 @@ class EntraM365GroupAddCommand extends GraphCommand {
|
|
|
189
189
|
_EntraM365GroupAddCommand_instances = new WeakSet(), _EntraM365GroupAddCommand_initTelemetry = function _EntraM365GroupAddCommand_initTelemetry() {
|
|
190
190
|
this.telemetry.push((args) => {
|
|
191
191
|
Object.assign(this.telemetryProperties, {
|
|
192
|
+
description: typeof args.options.description !== 'undefined',
|
|
192
193
|
owners: typeof args.options.owners !== 'undefined',
|
|
193
194
|
members: typeof args.options.members !== 'undefined',
|
|
194
195
|
logoPath: typeof args.options.logoPath !== 'undefined',
|
|
@@ -202,10 +203,10 @@ _EntraM365GroupAddCommand_instances = new WeakSet(), _EntraM365GroupAddCommand_i
|
|
|
202
203
|
}, _EntraM365GroupAddCommand_initOptions = function _EntraM365GroupAddCommand_initOptions() {
|
|
203
204
|
this.options.unshift({
|
|
204
205
|
option: '-n, --displayName <displayName>'
|
|
205
|
-
}, {
|
|
206
|
-
option: '-d, --description <description>'
|
|
207
206
|
}, {
|
|
208
207
|
option: '-m, --mailNickname <mailNickname>'
|
|
208
|
+
}, {
|
|
209
|
+
option: '-d, --description [description]'
|
|
209
210
|
}, {
|
|
210
211
|
option: '--owners [owners]'
|
|
211
212
|
}, {
|
|
@@ -229,6 +230,7 @@ _EntraM365GroupAddCommand_instances = new WeakSet(), _EntraM365GroupAddCommand_i
|
|
|
229
230
|
option: '-l, --logoPath [logoPath]'
|
|
230
231
|
});
|
|
231
232
|
}, _EntraM365GroupAddCommand_initTypes = function _EntraM365GroupAddCommand_initTypes() {
|
|
233
|
+
this.types.string.push('displayName', 'mailNickname', 'description', 'owners', 'members', 'visibility', 'logoPath');
|
|
232
234
|
this.types.boolean.push('allowMembersToPost', 'hideGroupInOutlook', 'subscribeNewGroupMembers', 'welcomeEmailDisabled');
|
|
233
235
|
}, _EntraM365GroupAddCommand_initValidators = function _EntraM365GroupAddCommand_initValidators() {
|
|
234
236
|
this.validators.push(async (args) => {
|
|
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
3
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var _OutlookMessageListCommand_instances, _OutlookMessageListCommand_initTelemetry, _OutlookMessageListCommand_initOptions, _OutlookMessageListCommand_initOptionSets;
|
|
6
|
+
var _OutlookMessageListCommand_instances, _OutlookMessageListCommand_initTelemetry, _OutlookMessageListCommand_initOptions, _OutlookMessageListCommand_initValidators, _OutlookMessageListCommand_initTypes, _OutlookMessageListCommand_initOptionSets;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
8
|
import { formatting } from '../../../../utils/formatting.js';
|
|
9
9
|
import { odata } from '../../../../utils/odata.js';
|
|
@@ -11,6 +11,9 @@ import GraphCommand from '../../../base/GraphCommand.js';
|
|
|
11
11
|
import commands from '../../commands.js';
|
|
12
12
|
import { Outlook } from '../../Outlook.js';
|
|
13
13
|
import { cli } from '../../../../cli/cli.js';
|
|
14
|
+
import { validation } from '../../../../utils/validation.js';
|
|
15
|
+
import { accessToken } from '../../../../utils/accessToken.js';
|
|
16
|
+
import auth from '../../../../Auth.js';
|
|
14
17
|
class OutlookMessageListCommand extends GraphCommand {
|
|
15
18
|
get name() {
|
|
16
19
|
return commands.MESSAGE_LIST;
|
|
@@ -23,6 +26,8 @@ class OutlookMessageListCommand extends GraphCommand {
|
|
|
23
26
|
_OutlookMessageListCommand_instances.add(this);
|
|
24
27
|
__classPrivateFieldGet(this, _OutlookMessageListCommand_instances, "m", _OutlookMessageListCommand_initTelemetry).call(this);
|
|
25
28
|
__classPrivateFieldGet(this, _OutlookMessageListCommand_instances, "m", _OutlookMessageListCommand_initOptions).call(this);
|
|
29
|
+
__classPrivateFieldGet(this, _OutlookMessageListCommand_instances, "m", _OutlookMessageListCommand_initValidators).call(this);
|
|
30
|
+
__classPrivateFieldGet(this, _OutlookMessageListCommand_instances, "m", _OutlookMessageListCommand_initTypes).call(this);
|
|
26
31
|
__classPrivateFieldGet(this, _OutlookMessageListCommand_instances, "m", _OutlookMessageListCommand_initOptionSets).call(this);
|
|
27
32
|
}
|
|
28
33
|
defaultProperties() {
|
|
@@ -30,27 +35,44 @@ class OutlookMessageListCommand extends GraphCommand {
|
|
|
30
35
|
}
|
|
31
36
|
async commandAction(logger, args) {
|
|
32
37
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
if (!args.options.userId && !args.options.userName && accessToken.isAppOnlyAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken)) {
|
|
39
|
+
throw 'You must specify either the userId or userName option when using app-only permissions.';
|
|
40
|
+
}
|
|
41
|
+
const userUrl = args.options.userId || args.options.userName ? `users/${args.options.userId || formatting.encodeQueryParameter(args.options.userName)}` : 'me';
|
|
42
|
+
const folderId = await this.getFolderId(userUrl, args.options);
|
|
43
|
+
const folderUrl = folderId ? `/mailFolders/${folderId}` : '';
|
|
44
|
+
let requestUrl = `${this.resource}/v1.0/${userUrl}${folderUrl}/messages?$top=100`;
|
|
45
|
+
if (args.options.startTime || args.options.endTime) {
|
|
46
|
+
const filters = [];
|
|
47
|
+
if (args.options.startTime) {
|
|
48
|
+
filters.push(`receivedDateTime ge ${args.options.startTime}`);
|
|
49
|
+
}
|
|
50
|
+
if (args.options.endTime) {
|
|
51
|
+
filters.push(`receivedDateTime lt ${args.options.endTime}`);
|
|
52
|
+
}
|
|
53
|
+
if (filters.length > 0) {
|
|
54
|
+
requestUrl += `&$filter=${filters.join(' and ')}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const messages = await odata.getAllItems(requestUrl);
|
|
36
58
|
await logger.log(messages);
|
|
37
59
|
}
|
|
38
60
|
catch (err) {
|
|
39
61
|
this.handleRejectedODataJsonPromise(err);
|
|
40
62
|
}
|
|
41
63
|
}
|
|
42
|
-
async getFolderId(
|
|
43
|
-
if (!
|
|
64
|
+
async getFolderId(userUrl, options) {
|
|
65
|
+
if (!options.folderId && !options.folderName) {
|
|
44
66
|
return '';
|
|
45
67
|
}
|
|
46
|
-
if (
|
|
47
|
-
return
|
|
68
|
+
if (options.folderId) {
|
|
69
|
+
return options.folderId;
|
|
48
70
|
}
|
|
49
|
-
if (Outlook.wellKnownFolderNames.
|
|
50
|
-
return
|
|
71
|
+
if (Outlook.wellKnownFolderNames.includes(options.folderName.toLowerCase())) {
|
|
72
|
+
return options.folderName;
|
|
51
73
|
}
|
|
52
74
|
const requestOptions = {
|
|
53
|
-
url: `${this.resource}/v1.0/
|
|
75
|
+
url: `${this.resource}/v1.0/${userUrl}/mailFolders?$filter=displayName eq '${formatting.encodeQueryParameter(options.folderName)}'&$select=id`,
|
|
54
76
|
headers: {
|
|
55
77
|
accept: 'application/json;odata.metadata=none'
|
|
56
78
|
},
|
|
@@ -58,11 +80,11 @@ class OutlookMessageListCommand extends GraphCommand {
|
|
|
58
80
|
};
|
|
59
81
|
const response = await request.get(requestOptions);
|
|
60
82
|
if (response.value.length === 0) {
|
|
61
|
-
throw `Folder with name '${
|
|
83
|
+
throw `Folder with name '${options.folderName}' not found`;
|
|
62
84
|
}
|
|
63
85
|
if (response.value.length > 1) {
|
|
64
86
|
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', response.value);
|
|
65
|
-
const result = await cli.handleMultipleResultsFound(`Multiple folders with name '${
|
|
87
|
+
const result = await cli.handleMultipleResultsFound(`Multiple folders with name '${options.folderName}' found.`, resultAsKeyValuePair);
|
|
66
88
|
return result.id;
|
|
67
89
|
}
|
|
68
90
|
return response.value[0].id;
|
|
@@ -72,7 +94,11 @@ _OutlookMessageListCommand_instances = new WeakSet(), _OutlookMessageListCommand
|
|
|
72
94
|
this.telemetry.push((args) => {
|
|
73
95
|
Object.assign(this.telemetryProperties, {
|
|
74
96
|
folderId: typeof args.options.folderId !== 'undefined',
|
|
75
|
-
folderName: typeof args.options.folderName !== 'undefined'
|
|
97
|
+
folderName: typeof args.options.folderName !== 'undefined',
|
|
98
|
+
startTime: typeof args.options.startTime !== 'undefined',
|
|
99
|
+
endTime: typeof args.options.endTime !== 'undefined',
|
|
100
|
+
userId: typeof args.options.userId !== 'undefined',
|
|
101
|
+
userName: typeof args.options.userName !== 'undefined'
|
|
76
102
|
});
|
|
77
103
|
});
|
|
78
104
|
}, _OutlookMessageListCommand_initOptions = function _OutlookMessageListCommand_initOptions() {
|
|
@@ -80,11 +106,55 @@ _OutlookMessageListCommand_instances = new WeakSet(), _OutlookMessageListCommand
|
|
|
80
106
|
option: '--folderName [folderName]',
|
|
81
107
|
autocomplete: Outlook.wellKnownFolderNames
|
|
82
108
|
}, {
|
|
83
|
-
option: '--folderId [folderId]'
|
|
84
|
-
|
|
109
|
+
option: '--folderId [folderId]'
|
|
110
|
+
}, {
|
|
111
|
+
option: '--startTime [startTime]'
|
|
112
|
+
}, {
|
|
113
|
+
option: '--endTime [endTime]'
|
|
114
|
+
}, {
|
|
115
|
+
option: '--userId [userId]'
|
|
116
|
+
}, {
|
|
117
|
+
option: '--userName [userName]'
|
|
85
118
|
});
|
|
119
|
+
}, _OutlookMessageListCommand_initValidators = function _OutlookMessageListCommand_initValidators() {
|
|
120
|
+
this.validators.push(async (args) => {
|
|
121
|
+
if (args.options.startTime) {
|
|
122
|
+
if (!validation.isValidISODateTime(args.options.startTime)) {
|
|
123
|
+
return `'${args.options.startTime}' is not a valid ISO date string for option startTime.`;
|
|
124
|
+
}
|
|
125
|
+
if (new Date(args.options.startTime) > new Date()) {
|
|
126
|
+
return 'startTime value cannot be in the future.';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (args.options.endTime) {
|
|
130
|
+
if (!validation.isValidISODateTime(args.options.endTime)) {
|
|
131
|
+
return `'${args.options.endTime}' is not a valid ISO date string for option endTime.`;
|
|
132
|
+
}
|
|
133
|
+
if (new Date(args.options.endTime) > new Date()) {
|
|
134
|
+
return 'endTime value cannot be in the future.';
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (args.options.startTime && args.options.endTime && new Date(args.options.startTime) >= new Date(args.options.endTime)) {
|
|
138
|
+
return 'startTime must be before endTime.';
|
|
139
|
+
}
|
|
140
|
+
if (args.options.userId && !validation.isValidGuid(args.options.userId)) {
|
|
141
|
+
return `${args.options.userId} is not a valid GUID for option userId.`;
|
|
142
|
+
}
|
|
143
|
+
if (args.options.userName && !validation.isValidUserPrincipalName(args.options.userName)) {
|
|
144
|
+
return `${args.options.userName} is not a valid UPN for option userName.`;
|
|
145
|
+
}
|
|
146
|
+
return true;
|
|
147
|
+
});
|
|
148
|
+
}, _OutlookMessageListCommand_initTypes = function _OutlookMessageListCommand_initTypes() {
|
|
149
|
+
this.types.string.push('folderName', 'folderId', 'startTime', 'endTime', 'userId', 'userName');
|
|
86
150
|
}, _OutlookMessageListCommand_initOptionSets = function _OutlookMessageListCommand_initOptionSets() {
|
|
87
|
-
this.optionSets.push({
|
|
151
|
+
this.optionSets.push({
|
|
152
|
+
options: ['folderId', 'folderName'],
|
|
153
|
+
runsWhen: (args) => args.options.folderId || args.options.folderName
|
|
154
|
+
}, {
|
|
155
|
+
options: ['userId', 'userName'],
|
|
156
|
+
runsWhen: (args) => args.options.userId || args.options.userName
|
|
157
|
+
});
|
|
88
158
|
};
|
|
89
159
|
export default new OutlookMessageListCommand();
|
|
90
160
|
//# sourceMappingURL=message-list.js.map
|