@pnp/cli-microsoft365 5.0.0-beta.fe151d6 → 5.0.0
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/.devcontainer/devcontainer.json +13 -2
- package/.eslintrc.js +3 -0
- package/.mocharc.json +9 -0
- package/README.md +3 -3
- package/dist/Auth.js +22 -9
- package/dist/Command.js +1 -1
- package/dist/Utils.js +7 -0
- package/dist/api.d.ts +13 -0
- package/dist/api.js +17 -0
- package/dist/appInsights.js +3 -2
- package/dist/cli/Cli.js +38 -6
- package/dist/m365/aad/commands/app/app-add.js +43 -7
- package/dist/m365/aad/commands/app/app-delete.js +123 -0
- package/dist/m365/aad/commands/app/app-get.js +142 -0
- package/dist/m365/aad/commands/app/app-set.js +98 -3
- package/dist/m365/aad/commands/group/group-list.js +54 -0
- package/dist/m365/aad/commands/o365group/{Group.js → GroupExtended.js} +1 -1
- package/dist/m365/aad/commands/o365group/o365group-conversation-list.js +41 -0
- package/dist/m365/aad/commands/o365group/o365group-user-set.js +3 -3
- package/dist/m365/aad/commands/user/user-get.js +33 -6
- package/dist/m365/aad/commands/user/user-hibp.js +67 -0
- package/dist/m365/aad/commands/user/user-list.js +7 -4
- package/dist/m365/aad/commands/user/user-password-validate.js +42 -0
- package/dist/m365/aad/commands.js +6 -0
- package/dist/m365/app/commands/permission/permission-list.js +266 -0
- package/dist/m365/app/commands.js +7 -0
- package/dist/m365/base/AppCommand.js +76 -0
- package/dist/m365/cli/commands/cli-doctor.js +2 -0
- package/dist/m365/cli/commands/config/config-set.js +5 -1
- package/dist/m365/flow/commands/flow-get.js +2 -2
- package/dist/m365/outlook/commands/room/room-list.js +43 -0
- package/dist/m365/outlook/commands/roomlist/roomlist-list.js +25 -0
- package/dist/m365/outlook/commands.js +2 -0
- package/dist/m365/pa/cds-project-mutator.js +1 -1
- package/dist/m365/pa/commands/app/app-list.js +28 -1
- package/dist/m365/{aad/commands/o365group/GroupUser.js → planner/AppliedCategories.js} +1 -1
- package/dist/m365/planner/commands/task/task-add.js +288 -0
- package/dist/m365/planner/commands/task/task-details-get.js +39 -0
- package/dist/m365/planner/commands/task/task-get.js +37 -0
- package/dist/m365/planner/commands/task/task-list.js +37 -7
- package/dist/m365/planner/commands/task/task-set.js +357 -0
- package/dist/m365/planner/commands.js +5 -1
- package/dist/m365/search/commands/externalconnection/externalconnection-add.js +99 -0
- package/dist/m365/search/commands.js +7 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006005_CFG_PS_metadata.js +63 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006006_CFG_PS_features.js +60 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN014008_CODE_launch_hostedWorkbench_type.js +62 -0
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.14.0.js +59 -0
- package/dist/m365/spfx/commands/project/project-upgrade.js +2 -1
- package/dist/m365/spfx/commands/spfx-doctor.js +25 -6
- package/dist/m365/spo/commands/group/group-user-add.js +74 -16
- package/dist/m365/spo/commands/group/group-user-remove.js +100 -0
- package/dist/m365/spo/commands/site/site-ensure.js +1 -1
- package/dist/m365/spo/commands/site/site-recyclebinitem-list.js +76 -0
- package/dist/m365/spo/commands/web/web-installedlanguage-list.js +48 -0
- package/dist/m365/spo/commands.js +3 -0
- package/dist/m365/teams/commands/app/app-install.js +75 -21
- package/dist/m365/teams/commands/app/app-list.js +9 -6
- package/dist/m365/teams/commands/app/app-update.js +54 -12
- package/dist/m365/teams/commands/channel/channel-get.js +29 -7
- package/dist/m365/teams/commands/chat/chat-list.js +43 -0
- package/dist/m365/teams/commands/chat/chat-member-list.js +42 -0
- package/dist/m365/teams/commands/chat/chat-message-list.js +60 -0
- package/dist/m365/teams/commands/chat/chat-message-send.js +225 -0
- package/dist/m365/teams/commands/message/message-get.js +1 -1
- package/dist/m365/teams/commands/tab/tab-get.js +9 -6
- package/dist/m365/teams/commands.js +4 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-get.js +57 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-list.js +56 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-get.js +39 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-list.js +38 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-get.js +51 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-list.js +38 -0
- package/dist/m365/tenant/commands.js +6 -0
- package/dist/request.js +9 -4
- package/dist/settingsNames.js +6 -0
- package/docs/docs/cmd/_global.md +2 -2
- package/docs/docs/cmd/aad/app/app-delete.md +51 -0
- package/docs/docs/cmd/aad/app/app-get.md +59 -0
- package/docs/docs/cmd/aad/app/app-set.md +21 -0
- package/docs/docs/cmd/aad/group/group-list.md +30 -0
- package/docs/docs/cmd/aad/o365group/o365group-conversation-list.md +24 -0
- package/docs/docs/cmd/aad/user/user-get.md +13 -4
- package/docs/docs/cmd/aad/user/user-hibp.md +46 -0
- package/docs/docs/cmd/aad/user/user-list.md +9 -0
- package/docs/docs/cmd/aad/user/user-password-validate.md +29 -0
- package/docs/docs/cmd/app/permission/permission-list.md +36 -0
- package/docs/docs/cmd/outlook/room/room-list.md +30 -0
- package/docs/docs/cmd/outlook/roomlist/roomlist-list.md +21 -0
- package/docs/docs/cmd/pa/app/app-list.md +17 -1
- package/docs/docs/cmd/planner/task/task-add.md +78 -0
- package/docs/docs/cmd/planner/task/task-details-get.md +24 -0
- package/docs/docs/cmd/planner/task/task-get.md +29 -0
- package/docs/docs/cmd/planner/task/task-list.md +5 -0
- package/docs/docs/cmd/planner/task/task-set.md +99 -0
- package/docs/docs/cmd/search/externalconnection/externalconnection-add.md +43 -0
- package/docs/docs/cmd/spfx/project/project-externalize.md +1 -1
- package/docs/docs/cmd/spfx/project/project-rename.md +1 -1
- package/docs/docs/cmd/spfx/project/project-upgrade.md +8 -8
- package/docs/docs/cmd/spfx/spfx-doctor.md +1 -1
- package/docs/docs/cmd/spo/group/group-user-add.md +28 -6
- package/docs/docs/cmd/spo/group/group-user-remove.md +39 -0
- package/docs/docs/cmd/spo/site/site-recyclebinitem-list.md +40 -0
- package/docs/docs/cmd/spo/web/web-installedlanguage-list.md +24 -0
- package/docs/docs/cmd/teams/app/app-install.md +22 -4
- package/docs/docs/cmd/teams/app/app-update.md +12 -3
- package/docs/docs/cmd/teams/channel/channel-get.md +11 -2
- package/docs/docs/cmd/teams/chat/chat-list.md +30 -0
- package/docs/docs/cmd/teams/chat/chat-member-list.md +24 -0
- package/docs/docs/cmd/teams/chat/chat-message-list.md +24 -0
- package/docs/docs/cmd/teams/chat/chat-message-send.md +55 -0
- package/docs/docs/cmd/teams/message/message-get.md +0 -3
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +33 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +30 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +24 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +34 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +28 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +34 -0
- package/npm-shrinkwrap.json +1327 -1497
- package/package.json +40 -28
- package/dist/m365/base/AadCommand.js +0 -10
|
@@ -2,10 +2,21 @@
|
|
|
2
2
|
"name": "CLI for Microsoft 365",
|
|
3
3
|
"dockerFile": "Dockerfile",
|
|
4
4
|
"settings": {
|
|
5
|
-
"terminal.integrated.
|
|
5
|
+
"terminal.integrated.profiles.linux": {
|
|
6
|
+
"zsh": {
|
|
7
|
+
"path": "/bin/zsh",
|
|
8
|
+
"args": [
|
|
9
|
+
"-l"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"terminal.integrated.defaultProfile.linux": "zsh"
|
|
6
14
|
},
|
|
7
15
|
"postCreateCommand": "npm i && npm run clean && npm run build && npm link",
|
|
8
16
|
"extensions": [
|
|
9
|
-
"dbaeumer.vscode-eslint"
|
|
17
|
+
"dbaeumer.vscode-eslint",
|
|
18
|
+
"hbenl.vscode-test-explorer",
|
|
19
|
+
"hbenl.vscode-mocha-test-adapter",
|
|
20
|
+
"eamodio.gitlens"
|
|
10
21
|
]
|
|
11
22
|
}
|
package/.eslintrc.js
CHANGED
|
@@ -23,6 +23,7 @@ const dictionary = [
|
|
|
23
23
|
'group',
|
|
24
24
|
'groupify',
|
|
25
25
|
'guest',
|
|
26
|
+
'health',
|
|
26
27
|
'hide',
|
|
27
28
|
'historical',
|
|
28
29
|
'home',
|
|
@@ -30,6 +31,7 @@ const dictionary = [
|
|
|
30
31
|
'in',
|
|
31
32
|
'init',
|
|
32
33
|
'install',
|
|
34
|
+
'installed',
|
|
33
35
|
'is',
|
|
34
36
|
'issue',
|
|
35
37
|
'list',
|
|
@@ -47,6 +49,7 @@ const dictionary = [
|
|
|
47
49
|
'records',
|
|
48
50
|
'recycle',
|
|
49
51
|
'role',
|
|
52
|
+
'room',
|
|
50
53
|
'schema',
|
|
51
54
|
'service',
|
|
52
55
|
'setting',
|
package/.mocharc.json
ADDED
package/README.md
CHANGED
|
@@ -179,7 +179,7 @@ m365 spo site get --url https://contoso.sharepoint.com --output text
|
|
|
179
179
|
|
|
180
180
|
## Build
|
|
181
181
|
|
|
182
|
-
To build and run this CLI locally, you will need [`node`](https://nodejs.org) `>=
|
|
182
|
+
To build and run this CLI locally, you will need [`node`](https://nodejs.org) `>= 16.0.0` installed.
|
|
183
183
|
|
|
184
184
|
```sh
|
|
185
185
|
# Clone this repository
|
|
@@ -208,9 +208,9 @@ If you want to get involved with helping us grow the CLI, whether that is sugges
|
|
|
208
208
|
|
|
209
209
|
Checkout our [Wiki](https://github.com/pnp/cli-microsoft365/wiki) for guides on how to contribute to this project.
|
|
210
210
|
|
|
211
|
-
##
|
|
211
|
+
## Microsoft 365 Platform Community
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
CLI for Microsoft 365 is a [Microsoft 365 Platform Community](https://pnp.github.io) (PnP) project. Microsoft 365 Platform Community is a virtual team consisting of Microsoft employees and community members focused on helping the community make the best use of Microsoft products. CLI for Microsoft 365 is an open-source project not affiliated with Microsoft and not covered by Microsoft support. If you experience any issues using the CLI, please submit an issue in the [issues list](https://github.com/pnp/cli-microsoft365/issues).
|
|
214
214
|
|
|
215
215
|
## Disclaimer
|
|
216
216
|
|
package/dist/Auth.js
CHANGED
|
@@ -12,9 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.Auth = exports.CertificateType = exports.AuthType = exports.Service = void 0;
|
|
13
13
|
const FileTokenStorage_1 = require("./auth/FileTokenStorage");
|
|
14
14
|
const msalCachePlugin_1 = require("./auth/msalCachePlugin");
|
|
15
|
+
const cli_1 = require("./cli");
|
|
15
16
|
const Command_1 = require("./Command");
|
|
16
17
|
const config_1 = require("./config");
|
|
17
18
|
const request_1 = require("./request");
|
|
19
|
+
const settingsNames_1 = require("./settingsNames");
|
|
18
20
|
class Service {
|
|
19
21
|
constructor() {
|
|
20
22
|
this.connected = false;
|
|
@@ -285,20 +287,31 @@ class Auth {
|
|
|
285
287
|
}
|
|
286
288
|
this.deviceCodeRequest = {
|
|
287
289
|
// deviceCodeCallback is called by MSAL which we're not testing
|
|
288
|
-
/* c8 ignore next
|
|
289
|
-
deviceCodeCallback: response =>
|
|
290
|
-
if (debug) {
|
|
291
|
-
logger.logToStderr('Response:');
|
|
292
|
-
logger.logToStderr(response);
|
|
293
|
-
logger.logToStderr('');
|
|
294
|
-
}
|
|
295
|
-
logger.log(response.message);
|
|
296
|
-
},
|
|
290
|
+
/* c8 ignore next 1 */
|
|
291
|
+
deviceCodeCallback: response => this.processDeviceCodeCallback(response, logger, debug),
|
|
297
292
|
scopes: [`${resource}/.default`]
|
|
298
293
|
};
|
|
299
294
|
return this.clientApplication.acquireTokenByDeviceCode(this.deviceCodeRequest);
|
|
300
295
|
});
|
|
301
296
|
}
|
|
297
|
+
processDeviceCodeCallback(response, logger, debug) {
|
|
298
|
+
if (debug) {
|
|
299
|
+
logger.logToStderr('Response:');
|
|
300
|
+
logger.logToStderr(response);
|
|
301
|
+
logger.logToStderr('');
|
|
302
|
+
}
|
|
303
|
+
logger.log(response.message);
|
|
304
|
+
if (cli_1.Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.autoOpenBrowserOnLogin, false)) {
|
|
305
|
+
// _open is never set before hitting this line, but this check
|
|
306
|
+
// is implemented so that we can support lazy loading
|
|
307
|
+
// but also stub it for testing
|
|
308
|
+
/* c8 ignore next 3 */
|
|
309
|
+
if (!this._open) {
|
|
310
|
+
this._open = require('open');
|
|
311
|
+
}
|
|
312
|
+
this._open(response.verificationUri);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
302
315
|
ensureAccessTokenWithPassword(resource, logger, debug) {
|
|
303
316
|
return __awaiter(this, void 0, void 0, function* () {
|
|
304
317
|
if (debug) {
|
package/dist/Command.js
CHANGED
package/dist/Utils.js
CHANGED
|
@@ -40,6 +40,9 @@ class Utils {
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
+
static isValidGuidArray(guids) {
|
|
44
|
+
return guids.every(guid => this.isValidGuid(guid));
|
|
45
|
+
}
|
|
43
46
|
static isValidGuid(guid) {
|
|
44
47
|
const guidRegEx = new RegExp(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
|
|
45
48
|
return guidRegEx.test(guid);
|
|
@@ -48,6 +51,10 @@ class Utils {
|
|
|
48
51
|
const guidRegEx = new RegExp(/^19:[0-9a-zA-Z-_]+@thread\.(skype|tacv2)$/i);
|
|
49
52
|
return guidRegEx.test(guid);
|
|
50
53
|
}
|
|
54
|
+
static isValidTeamsChatId(guid) {
|
|
55
|
+
const guidRegEx = new RegExp(/^19:[0-9a-zA-Z-_]+(@thread\.v2|@unq\.gbl\.spaces)$/i);
|
|
56
|
+
return guidRegEx.test(guid);
|
|
57
|
+
}
|
|
51
58
|
static isValidUserPrincipalName(upn) {
|
|
52
59
|
const upnRegEx = new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/i);
|
|
53
60
|
return upnRegEx.test(upn);
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CommandOutput {
|
|
2
|
+
error?: {
|
|
3
|
+
message: string;
|
|
4
|
+
code?: number;
|
|
5
|
+
}
|
|
6
|
+
stdout: string;
|
|
7
|
+
stderr: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare function executeCommand(commandName: string, options: any, listener?: {
|
|
11
|
+
stdout: (message: any) => void,
|
|
12
|
+
stderr: (message: any) => void,
|
|
13
|
+
}): Promise<CommandOutput>;
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeCommand = void 0;
|
|
4
|
+
const cli_1 = require("./cli");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
function executeCommand(commandName, options, listener) {
|
|
7
|
+
const cli = cli_1.Cli.getInstance();
|
|
8
|
+
cli.commandsFolder = path.join(__dirname, 'm365');
|
|
9
|
+
cli.commands = [];
|
|
10
|
+
cli.loadCommandFromArgs(commandName.split(' '));
|
|
11
|
+
if (cli.commands.length !== 1) {
|
|
12
|
+
return Promise.reject(`Command not found: ${commandName}`);
|
|
13
|
+
}
|
|
14
|
+
return cli_1.Cli.executeCommandWithOutput(cli.commands[0].command, { options: options !== null && options !== void 0 ? options : {} }, listener);
|
|
15
|
+
}
|
|
16
|
+
exports.executeCommand = executeCommand;
|
|
17
|
+
//# sourceMappingURL=api.js.map
|
package/dist/appInsights.js
CHANGED
|
@@ -20,10 +20,11 @@ const env = process.env.CLIMICROSOFT365_ENV !== undefined ? process.env.CLIMICRO
|
|
|
20
20
|
appInsights.defaultClient.commonProperties = {
|
|
21
21
|
version: version,
|
|
22
22
|
node: process.version,
|
|
23
|
-
env: env
|
|
23
|
+
env: env,
|
|
24
|
+
ci: Boolean(process.env.CI).toString()
|
|
24
25
|
};
|
|
25
26
|
appInsights.defaultClient.context.tags['ai.session.id'] = crypto.randomBytes(24).toString('base64');
|
|
26
|
-
|
|
27
|
+
appInsights.defaultClient.context.tags['ai.cloud.roleInstance'] = crypto.createHash('sha256').update(appInsights.defaultClient.context.tags['ai.cloud.roleInstance']).digest('hex');
|
|
27
28
|
delete appInsights.defaultClient.context.tags['ai.cloud.role'];
|
|
28
29
|
exports.default = appInsights.defaultClient;
|
|
29
30
|
//# sourceMappingURL=appInsights.js.map
|
package/dist/cli/Cli.js
CHANGED
|
@@ -17,6 +17,7 @@ const path = require("path");
|
|
|
17
17
|
const appInsights_1 = require("../appInsights");
|
|
18
18
|
const Command_1 = require("../Command");
|
|
19
19
|
const config_1 = require("../config");
|
|
20
|
+
const request_1 = require("../request");
|
|
20
21
|
const settingsNames_1 = require("../settingsNames");
|
|
21
22
|
const Utils_1 = require("../Utils");
|
|
22
23
|
const packageJSON = require('../../package.json');
|
|
@@ -188,32 +189,51 @@ class Cli {
|
|
|
188
189
|
});
|
|
189
190
|
});
|
|
190
191
|
}
|
|
191
|
-
static executeCommandWithOutput(command, args) {
|
|
192
|
+
static executeCommandWithOutput(command, args, listener) {
|
|
192
193
|
return new Promise((resolve, reject) => {
|
|
193
194
|
const log = [];
|
|
194
195
|
const logErr = [];
|
|
195
196
|
const logger = {
|
|
196
197
|
log: (message) => {
|
|
197
|
-
|
|
198
|
+
const formattedMessage = Cli.formatOutput(message, args.options);
|
|
199
|
+
if (listener && listener.stdout) {
|
|
200
|
+
listener.stdout(formattedMessage);
|
|
201
|
+
}
|
|
202
|
+
log.push(formattedMessage);
|
|
198
203
|
},
|
|
199
204
|
logRaw: (message) => {
|
|
200
|
-
|
|
205
|
+
const formattedMessage = Cli.formatOutput(message, args.options);
|
|
206
|
+
if (listener && listener.stdout) {
|
|
207
|
+
listener.stdout(formattedMessage);
|
|
208
|
+
}
|
|
209
|
+
log.push(formattedMessage);
|
|
201
210
|
},
|
|
202
211
|
logToStderr: (message) => {
|
|
212
|
+
if (listener && listener.stderr) {
|
|
213
|
+
listener.stderr(message);
|
|
214
|
+
}
|
|
203
215
|
logErr.push(message);
|
|
204
216
|
}
|
|
205
217
|
};
|
|
206
218
|
if (args.options.debug) {
|
|
207
|
-
|
|
219
|
+
const message = `Executing command ${command.name} with options ${JSON.stringify(args)}`;
|
|
220
|
+
if (listener && listener.stderr) {
|
|
221
|
+
listener.stderr(message);
|
|
222
|
+
}
|
|
223
|
+
logErr.push(message);
|
|
208
224
|
}
|
|
209
225
|
// store the current command name, if any and set the name to the name of
|
|
210
226
|
// the command to execute
|
|
211
227
|
const cli = Cli.getInstance();
|
|
212
228
|
const parentCommandName = cli.currentCommandName;
|
|
213
229
|
cli.currentCommandName = command.getCommandName();
|
|
230
|
+
// store the current logger if any
|
|
231
|
+
const currentLogger = request_1.default.logger;
|
|
214
232
|
command.action(logger, args, (err) => {
|
|
215
233
|
// restore the original command name
|
|
216
234
|
cli.currentCommandName = parentCommandName;
|
|
235
|
+
// restore the original logger
|
|
236
|
+
request_1.default.logger = currentLogger;
|
|
217
237
|
if (err) {
|
|
218
238
|
return reject({
|
|
219
239
|
error: err,
|
|
@@ -416,11 +436,11 @@ class Cli {
|
|
|
416
436
|
if (arrayType !== 'object') {
|
|
417
437
|
return logStatement.join(os.EOL);
|
|
418
438
|
}
|
|
419
|
-
// if output type has been set to 'text', process the retrieved
|
|
439
|
+
// if output type has been set to 'text' or 'csv', process the retrieved
|
|
420
440
|
// data so that returned objects contain only default properties specified
|
|
421
441
|
// on the current command. If there is no current command or the
|
|
422
442
|
// command doesn't specify default properties, return original data
|
|
423
|
-
if (options.output === 'text') {
|
|
443
|
+
if (options.output === 'text' || options.output === 'csv') {
|
|
424
444
|
const cli = Cli.getInstance();
|
|
425
445
|
const currentCommand = cli.commandToExecute;
|
|
426
446
|
if (arrayType === 'object' &&
|
|
@@ -440,6 +460,18 @@ class Cli {
|
|
|
440
460
|
}
|
|
441
461
|
}
|
|
442
462
|
}
|
|
463
|
+
if (options.output === 'csv') {
|
|
464
|
+
const { stringify } = require('csv-stringify/sync');
|
|
465
|
+
const cli = Cli.getInstance();
|
|
466
|
+
// https://csv.js.org/stringify/options/
|
|
467
|
+
return stringify(logStatement, {
|
|
468
|
+
header: cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.csvHeader, true),
|
|
469
|
+
escape: cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.csvEscape, '"'),
|
|
470
|
+
quote: cli.config.get(settingsNames_1.settingsNames.csvQuote),
|
|
471
|
+
quoted: cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.csvQuoted, false),
|
|
472
|
+
quotedEmpty: cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.csvQuotedEmpty, false)
|
|
473
|
+
});
|
|
474
|
+
}
|
|
443
475
|
// display object as a list of key-value pairs
|
|
444
476
|
if (logStatement.length === 1) {
|
|
445
477
|
const obj = logStatement[0];
|
|
@@ -105,21 +105,49 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
105
105
|
if (!args.options.manifest) {
|
|
106
106
|
return Promise.resolve(appInfo);
|
|
107
107
|
}
|
|
108
|
-
const
|
|
108
|
+
const v2Manifest = JSON.parse(args.options.manifest);
|
|
109
109
|
// remove properties that might be coming from the original app that was
|
|
110
110
|
// used to create the manifest and which can't be updated
|
|
111
|
-
delete
|
|
112
|
-
delete
|
|
113
|
-
delete
|
|
111
|
+
delete v2Manifest.id;
|
|
112
|
+
delete v2Manifest.appId;
|
|
113
|
+
delete v2Manifest.publisherDomain;
|
|
114
114
|
// Azure Portal returns v2 manifest whereas the Graph API expects a v1.6
|
|
115
|
-
const
|
|
115
|
+
const graphManifest = this.transformManifest(v2Manifest);
|
|
116
116
|
const updateAppRequestOptions = {
|
|
117
117
|
url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
|
|
118
118
|
headers: {
|
|
119
119
|
'content-type': 'application/json'
|
|
120
120
|
},
|
|
121
121
|
responseType: 'json',
|
|
122
|
-
data:
|
|
122
|
+
data: graphManifest
|
|
123
|
+
};
|
|
124
|
+
return request_1.default
|
|
125
|
+
.patch(updateAppRequestOptions)
|
|
126
|
+
.then(_ => this.updatePreAuthorizedAppsFromManifest(v2Manifest, appInfo))
|
|
127
|
+
.then(_ => Promise.resolve(appInfo));
|
|
128
|
+
}
|
|
129
|
+
updatePreAuthorizedAppsFromManifest(manifest, appInfo) {
|
|
130
|
+
if (!manifest ||
|
|
131
|
+
!manifest.preAuthorizedApplications ||
|
|
132
|
+
manifest.preAuthorizedApplications.length === 0) {
|
|
133
|
+
return Promise.resolve(appInfo);
|
|
134
|
+
}
|
|
135
|
+
const graphManifest = {
|
|
136
|
+
api: {
|
|
137
|
+
preAuthorizedApplications: manifest.preAuthorizedApplications
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
graphManifest.api.preAuthorizedApplications.forEach((p) => {
|
|
141
|
+
p.delegatedPermissionIds = p.permissionIds;
|
|
142
|
+
delete p.permissionIds;
|
|
143
|
+
});
|
|
144
|
+
const updateAppRequestOptions = {
|
|
145
|
+
url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
|
|
146
|
+
headers: {
|
|
147
|
+
'content-type': 'application/json'
|
|
148
|
+
},
|
|
149
|
+
responseType: 'json',
|
|
150
|
+
data: graphManifest
|
|
123
151
|
};
|
|
124
152
|
return request_1.default
|
|
125
153
|
.patch(updateAppRequestOptions)
|
|
@@ -180,8 +208,16 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
180
208
|
delete graphManifest.oauth2AllowIdTokenImplicitFlow;
|
|
181
209
|
graphManifest.api.oauth2PermissionScopes = v2Manifest.oauth2Permissions;
|
|
182
210
|
delete graphManifest.oauth2Permissions;
|
|
211
|
+
if (graphManifest.api.oauth2PermissionScopes) {
|
|
212
|
+
graphManifest.api.oauth2PermissionScopes.forEach((scope) => {
|
|
213
|
+
delete scope.lang;
|
|
214
|
+
delete scope.origin;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
183
217
|
delete graphManifest.oauth2RequiredPostResponse;
|
|
184
|
-
|
|
218
|
+
// MS Graph doesn't support creating OAuth2 permissions and pre-authorized
|
|
219
|
+
// apps in one request. This is why we need to remove it here and do it in
|
|
220
|
+
// the next request
|
|
185
221
|
delete graphManifest.preAuthorizedApplications;
|
|
186
222
|
if (v2Manifest.replyUrlsWithType) {
|
|
187
223
|
v2Manifest.replyUrlsWithType.forEach((urlWithType) => {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cli_1 = require("../../../../cli");
|
|
4
|
+
const request_1 = require("../../../../request");
|
|
5
|
+
const Utils_1 = require("../../../../Utils");
|
|
6
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
7
|
+
const commands_1 = require("../../commands");
|
|
8
|
+
class AadAppDeleteCommand extends GraphCommand_1.default {
|
|
9
|
+
get name() {
|
|
10
|
+
return commands_1.default.APP_DELETE;
|
|
11
|
+
}
|
|
12
|
+
get description() {
|
|
13
|
+
return 'Removes an Azure AD app registration';
|
|
14
|
+
}
|
|
15
|
+
getTelemetryProperties(args) {
|
|
16
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
17
|
+
telemetryProps.appId = typeof args.options.appId !== 'undefined';
|
|
18
|
+
telemetryProps.objectId = typeof args.options.objectId !== 'undefined';
|
|
19
|
+
telemetryProps.name = typeof args.options.name !== 'undefined';
|
|
20
|
+
telemetryProps.confirm = (!(!args.options.confirm)).toString();
|
|
21
|
+
return telemetryProps;
|
|
22
|
+
}
|
|
23
|
+
commandAction(logger, args, cb) {
|
|
24
|
+
const deleteApp = () => {
|
|
25
|
+
this
|
|
26
|
+
.getObjectId(args, logger)
|
|
27
|
+
.then((objectId) => {
|
|
28
|
+
if (this.verbose) {
|
|
29
|
+
logger.logToStderr(`Deleting Azure AD app ${objectId}...`);
|
|
30
|
+
}
|
|
31
|
+
const requestOptions = {
|
|
32
|
+
url: `${this.resource}/v1.0/myorganization/applications/${objectId}`,
|
|
33
|
+
headers: {
|
|
34
|
+
accept: 'application/json;odata.metadata=none'
|
|
35
|
+
},
|
|
36
|
+
responseType: 'json'
|
|
37
|
+
};
|
|
38
|
+
return request_1.default.delete(requestOptions);
|
|
39
|
+
})
|
|
40
|
+
.then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
|
|
41
|
+
};
|
|
42
|
+
if (args.options.confirm) {
|
|
43
|
+
deleteApp();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
cli_1.Cli.prompt({
|
|
47
|
+
type: 'confirm',
|
|
48
|
+
name: 'continue',
|
|
49
|
+
default: false,
|
|
50
|
+
message: `Are you sure you want to delete the App?`
|
|
51
|
+
}, (result) => {
|
|
52
|
+
if (!result.continue) {
|
|
53
|
+
cb();
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
deleteApp();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
getObjectId(args, logger) {
|
|
62
|
+
if (args.options.objectId) {
|
|
63
|
+
return Promise.resolve(args.options.objectId);
|
|
64
|
+
}
|
|
65
|
+
const { appId, name } = args.options;
|
|
66
|
+
if (this.verbose) {
|
|
67
|
+
logger.logToStderr(`Retrieving information about Azure AD app ${appId ? appId : name}...`);
|
|
68
|
+
}
|
|
69
|
+
const filter = appId ?
|
|
70
|
+
`appId eq '${encodeURIComponent(appId)}'` :
|
|
71
|
+
`displayName eq '${encodeURIComponent(name)}'`;
|
|
72
|
+
const requestOptions = {
|
|
73
|
+
url: `${this.resource}/v1.0/myorganization/applications?$filter=${filter}&$select=id`,
|
|
74
|
+
headers: {
|
|
75
|
+
accept: 'application/json;odata.metadata=none'
|
|
76
|
+
},
|
|
77
|
+
responseType: 'json'
|
|
78
|
+
};
|
|
79
|
+
return request_1.default
|
|
80
|
+
.get(requestOptions)
|
|
81
|
+
.then((res) => {
|
|
82
|
+
if (res.value.length === 1) {
|
|
83
|
+
return Promise.resolve(res.value[0].id);
|
|
84
|
+
}
|
|
85
|
+
if (res.value.length === 0) {
|
|
86
|
+
const applicationIdentifier = appId ? `ID ${appId}` : `name ${name}`;
|
|
87
|
+
return Promise.reject(`No Azure AD application registration with ${applicationIdentifier} found`);
|
|
88
|
+
}
|
|
89
|
+
return Promise.reject(`Multiple Azure AD application registration with name ${name} found. Please choose one of the object IDs: ${res.value.map(a => a.id).join(', ')}`);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
options() {
|
|
93
|
+
const options = [
|
|
94
|
+
{ option: '--appId [appId]' },
|
|
95
|
+
{ option: '--objectId [objectId]' },
|
|
96
|
+
{ option: '--name [name]' },
|
|
97
|
+
{ option: '--confirm' }
|
|
98
|
+
];
|
|
99
|
+
const parentOptions = super.options();
|
|
100
|
+
return options.concat(parentOptions);
|
|
101
|
+
}
|
|
102
|
+
validate(args) {
|
|
103
|
+
if (!args.options.appId &&
|
|
104
|
+
!args.options.objectId &&
|
|
105
|
+
!args.options.name) {
|
|
106
|
+
return 'Specify either appId, objectId, or name';
|
|
107
|
+
}
|
|
108
|
+
if ((args.options.appId && args.options.objectId) ||
|
|
109
|
+
(args.options.appId && args.options.name) ||
|
|
110
|
+
(args.options.objectId && args.options.name)) {
|
|
111
|
+
return 'Specify either appId, objectId, or name';
|
|
112
|
+
}
|
|
113
|
+
if (args.options.appId && !Utils_1.default.isValidGuid(args.options.appId)) {
|
|
114
|
+
return `${args.options.appId} is not a valid GUID`;
|
|
115
|
+
}
|
|
116
|
+
if (args.options.objectId && !Utils_1.default.isValidGuid(args.options.objectId)) {
|
|
117
|
+
return `${args.options.objectId} is not a valid GUID`;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
module.exports = new AadAppDeleteCommand();
|
|
123
|
+
//# sourceMappingURL=app-delete.js.map
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const request_1 = require("../../../../request");
|
|
5
|
+
const Utils_1 = require("../../../../Utils");
|
|
6
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
7
|
+
const commands_1 = require("../../commands");
|
|
8
|
+
class AadAppGetCommand extends GraphCommand_1.default {
|
|
9
|
+
get name() {
|
|
10
|
+
return commands_1.default.APP_GET;
|
|
11
|
+
}
|
|
12
|
+
get description() {
|
|
13
|
+
return 'Gets an Azure AD app registration';
|
|
14
|
+
}
|
|
15
|
+
getTelemetryProperties(args) {
|
|
16
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
17
|
+
telemetryProps.appId = typeof args.options.appId !== 'undefined';
|
|
18
|
+
telemetryProps.objectId = typeof args.options.objectId !== 'undefined';
|
|
19
|
+
telemetryProps.name = typeof args.options.name !== 'undefined';
|
|
20
|
+
return telemetryProps;
|
|
21
|
+
}
|
|
22
|
+
commandAction(logger, args, cb) {
|
|
23
|
+
this
|
|
24
|
+
.getAppObjectId(args)
|
|
25
|
+
.then(appObjectId => this.getAppInfo(appObjectId))
|
|
26
|
+
.then(appInfo => this.saveAppInfo(args, appInfo, logger))
|
|
27
|
+
.then((res) => {
|
|
28
|
+
logger.log(res);
|
|
29
|
+
cb();
|
|
30
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
31
|
+
}
|
|
32
|
+
getAppObjectId(args) {
|
|
33
|
+
if (args.options.objectId) {
|
|
34
|
+
return Promise.resolve(args.options.objectId);
|
|
35
|
+
}
|
|
36
|
+
const { appId, name } = args.options;
|
|
37
|
+
const filter = appId ?
|
|
38
|
+
`appId eq '${encodeURIComponent(appId)}'` :
|
|
39
|
+
`displayName eq '${encodeURIComponent(name)}'`;
|
|
40
|
+
const requestOptions = {
|
|
41
|
+
url: `${this.resource}/v1.0/myorganization/applications?$filter=${filter}&$select=id`,
|
|
42
|
+
headers: {
|
|
43
|
+
accept: 'application/json;odata.metadata=none'
|
|
44
|
+
},
|
|
45
|
+
responseType: 'json'
|
|
46
|
+
};
|
|
47
|
+
return request_1.default
|
|
48
|
+
.get(requestOptions)
|
|
49
|
+
.then((res) => {
|
|
50
|
+
if (res.value.length === 1) {
|
|
51
|
+
return Promise.resolve(res.value[0].id);
|
|
52
|
+
}
|
|
53
|
+
if (res.value.length === 0) {
|
|
54
|
+
const applicationIdentifier = appId ? `ID ${appId}` : `name ${name}`;
|
|
55
|
+
return Promise.reject(`No Azure AD application registration with ${applicationIdentifier} found`);
|
|
56
|
+
}
|
|
57
|
+
return Promise.reject(`Multiple Azure AD application registration with name ${name} found. Please disambiguate (app object IDs): ${res.value.map(a => a.id).join(', ')}`);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
getAppInfo(appObjectId) {
|
|
61
|
+
const requestOptions = {
|
|
62
|
+
url: `${this.resource}/v1.0/myorganization/applications/${appObjectId}`,
|
|
63
|
+
headers: {
|
|
64
|
+
accept: 'application/json;odata.metadata=none'
|
|
65
|
+
},
|
|
66
|
+
responseType: 'json'
|
|
67
|
+
};
|
|
68
|
+
return request_1.default.get(requestOptions);
|
|
69
|
+
}
|
|
70
|
+
saveAppInfo(args, appInfo, logger) {
|
|
71
|
+
if (!args.options.save) {
|
|
72
|
+
return Promise.resolve(appInfo);
|
|
73
|
+
}
|
|
74
|
+
const filePath = '.m365rc.json';
|
|
75
|
+
if (this.verbose) {
|
|
76
|
+
logger.logToStderr(`Saving Azure AD app registration information to the ${filePath} file...`);
|
|
77
|
+
}
|
|
78
|
+
let m365rc = {};
|
|
79
|
+
if (fs.existsSync(filePath)) {
|
|
80
|
+
if (this.debug) {
|
|
81
|
+
logger.logToStderr(`Reading existing ${filePath}...`);
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const fileContents = fs.readFileSync(filePath, 'utf8');
|
|
85
|
+
if (fileContents) {
|
|
86
|
+
m365rc = JSON.parse(fileContents);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
logger.logToStderr(`Error reading ${filePath}: ${e}. Please add app info to ${filePath} manually.`);
|
|
91
|
+
return Promise.resolve(appInfo);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (!m365rc.apps) {
|
|
95
|
+
m365rc.apps = [];
|
|
96
|
+
}
|
|
97
|
+
if (!m365rc.apps.some(a => a.appId === appInfo.appId)) {
|
|
98
|
+
m365rc.apps.push({
|
|
99
|
+
appId: appInfo.appId,
|
|
100
|
+
name: appInfo.displayName
|
|
101
|
+
});
|
|
102
|
+
try {
|
|
103
|
+
fs.writeFileSync(filePath, JSON.stringify(m365rc, null, 2));
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
logger.logToStderr(`Error writing ${filePath}: ${e}. Please add app info to ${filePath} manually.`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return Promise.resolve(appInfo);
|
|
110
|
+
}
|
|
111
|
+
options() {
|
|
112
|
+
const options = [
|
|
113
|
+
{ option: '--appId [appId]' },
|
|
114
|
+
{ option: '--objectId [objectId]' },
|
|
115
|
+
{ option: '--name [name]' },
|
|
116
|
+
{ option: '--save' }
|
|
117
|
+
];
|
|
118
|
+
const parentOptions = super.options();
|
|
119
|
+
return options.concat(parentOptions);
|
|
120
|
+
}
|
|
121
|
+
validate(args) {
|
|
122
|
+
if (!args.options.appId &&
|
|
123
|
+
!args.options.objectId &&
|
|
124
|
+
!args.options.name) {
|
|
125
|
+
return 'Specify either appId, objectId, or name';
|
|
126
|
+
}
|
|
127
|
+
if ((args.options.appId && args.options.objectId) ||
|
|
128
|
+
(args.options.appId && args.options.name) ||
|
|
129
|
+
(args.options.objectId && args.options.name)) {
|
|
130
|
+
return 'Specify either appId, objectId, or name but not both';
|
|
131
|
+
}
|
|
132
|
+
if (args.options.appId && !Utils_1.default.isValidGuid(args.options.appId)) {
|
|
133
|
+
return `${args.options.appId} is not a valid GUID`;
|
|
134
|
+
}
|
|
135
|
+
if (args.options.objectId && !Utils_1.default.isValidGuid(args.options.objectId)) {
|
|
136
|
+
return `${args.options.objectId} is not a valid GUID`;
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
module.exports = new AadAppGetCommand();
|
|
142
|
+
//# sourceMappingURL=app-get.js.map
|