@pnp/cli-microsoft365 7.11.0-beta.c513557 → 8.0.0-beta.3c404b8

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.
Files changed (96) hide show
  1. package/.eslintrc.cjs +6 -2
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/Auth.js +2 -10
  5. package/dist/AuthServer.js +10 -10
  6. package/dist/Command.js +10 -10
  7. package/dist/chili/chili.js +0 -23
  8. package/dist/chili/index.js +1 -1
  9. package/dist/cli/cli.js +12 -74
  10. package/dist/index.js +1 -1
  11. package/dist/m365/base/AnonymousCommand.js +1 -1
  12. package/dist/m365/base/DelegatedGraphCommand.js +2 -2
  13. package/dist/m365/base/PowerAppsCommand.js +2 -2
  14. package/dist/m365/base/PowerAutomateCommand.js +2 -2
  15. package/dist/m365/base/PowerBICommand.js +2 -2
  16. package/dist/m365/base/PowerPlatformCommand.js +2 -2
  17. package/dist/m365/base/VivaEngageCommand.js +2 -2
  18. package/dist/m365/cli/commands/cli-consent.js +1 -1
  19. package/dist/m365/commands/login.js +1 -1
  20. package/dist/m365/commands/logout.js +1 -1
  21. package/dist/m365/commands/setup.js +0 -4
  22. package/dist/m365/commands/status.js +1 -1
  23. package/dist/m365/connection/commands/connection-list.js +1 -1
  24. package/dist/m365/connection/commands/connection-remove.js +1 -1
  25. package/dist/m365/connection/commands/connection-set.js +1 -1
  26. package/dist/m365/connection/commands/connection-use.js +1 -1
  27. package/dist/m365/entra/commands/app/app-permission-add.js +21 -1
  28. package/dist/m365/entra/commands/app/app-permission-remove.js +17 -0
  29. package/dist/m365/entra/commands/m365group/m365group-add.js +1 -0
  30. package/dist/m365/entra/commands/m365group/m365group-set.js +66 -29
  31. package/dist/m365/entra/commands/m365group/m365group-user-list.js +1 -1
  32. package/dist/m365/entra/commands/multitenant/MultitenantOrganization.js +2 -0
  33. package/dist/m365/entra/commands/multitenant/multitenant-get.js +32 -0
  34. package/dist/m365/entra/commands.js +1 -0
  35. package/dist/m365/external/commands/connection/connection-doctor.js +11 -25
  36. package/dist/m365/external/commands/connection/connection-schema-add.js +4 -4
  37. package/dist/m365/file/commands/file-copy.js +3 -3
  38. package/dist/m365/flow/commands/flow-list.js +23 -24
  39. package/dist/m365/graph/commands/subscription/subscription-add.js +4 -2
  40. package/dist/m365/pa/commands/app/app-export.js +1 -1
  41. package/dist/m365/pa/commands/app/app-owner-set.js +1 -1
  42. package/dist/m365/pp/commands/solution/solution-publish.js +1 -1
  43. package/dist/m365/purview/commands/threatassessment/threatassessment-list.js +1 -1
  44. package/dist/m365/spfx/commands/project/base-project-command.js +36 -126
  45. package/dist/m365/spfx/commands/project/project-azuredevops-pipeline-add.js +1 -1
  46. package/dist/m365/spfx/commands/project/project-externalize.js +1 -1
  47. package/dist/m365/spfx/commands/project/project-github-workflow-add.js +1 -1
  48. package/dist/m365/spfx/commands/spfx-doctor.js +4 -4
  49. package/dist/m365/spo/commands/cdn/cdn-get.js +12 -15
  50. package/dist/m365/spo/commands/cdn/cdn-set.js +6 -4
  51. package/dist/m365/spo/commands/commandset/commandset-get.js +1 -1
  52. package/dist/m365/spo/commands/contenttype/contenttype-field-list.js +124 -0
  53. package/dist/m365/spo/commands/field/field-list.js +1 -1
  54. package/dist/m365/spo/commands/file/file-retentionlabel-remove.js +1 -1
  55. package/dist/m365/spo/commands/group/group-member-add.js +103 -99
  56. package/dist/m365/spo/commands/group/group-member-remove.js +2 -2
  57. package/dist/m365/spo/commands/list/list-retentionlabel-ensure.js +1 -1
  58. package/dist/m365/spo/commands/listitem/listitem-batch-remove.js +1 -1
  59. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-ensure.js +2 -2
  60. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-remove.js +2 -2
  61. package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +2 -3
  62. package/dist/m365/spo/commands/page/page-text-add.js +2 -3
  63. package/dist/m365/spo/commands/site/site-commsite-enable.js +1 -1
  64. package/dist/m365/spo/commands/spo-search.js +4 -5
  65. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-set.js +4 -4
  66. package/dist/m365/spo/commands/tenant/tenant-commandset-set.js +2 -2
  67. package/dist/m365/spo/commands/user/user-ensure.js +1 -1
  68. package/dist/m365/spo/commands.js +1 -0
  69. package/dist/m365/teams/commands/chat/chat-member-add.js +1 -1
  70. package/dist/m365/teams/commands/meeting/meeting-attendancereport-get.js +119 -0
  71. package/dist/m365/teams/commands/meeting/meeting-list.js +1 -1
  72. package/dist/m365/teams/commands/message/message-remove.js +112 -0
  73. package/dist/m365/teams/commands.js +2 -0
  74. package/dist/m365/viva/commands/engage/engage-community-add.js +166 -0
  75. package/dist/m365/viva/commands/engage/engage-community-get.js +1 -1
  76. package/dist/m365/viva/commands.js +1 -0
  77. package/dist/request.js +13 -14
  78. package/dist/utils/formatting.js +14 -1
  79. package/dist/utils/spo.js +5 -5
  80. package/dist/utils/teams.js +49 -0
  81. package/dist/utils/validation.js +25 -0
  82. package/docs/docs/cmd/entra/m365group/m365group-set.mdx +37 -7
  83. package/docs/docs/cmd/entra/multitenant/multitenant-get.mdx +94 -0
  84. package/docs/docs/cmd/external/connection/connection-doctor.mdx +9 -9
  85. package/docs/docs/cmd/flow/flow-list.mdx +114 -56
  86. package/docs/docs/cmd/graph/subscription/subscription-add.mdx +18 -0
  87. package/docs/docs/cmd/spo/cdn/cdn-set.mdx +3 -3
  88. package/docs/docs/cmd/spo/contenttype/contenttype-field-list.mdx +172 -0
  89. package/docs/docs/cmd/spo/contenttype/contenttype-list.mdx +3 -3
  90. package/docs/docs/cmd/spo/field/field-list.mdx +3 -3
  91. package/docs/docs/cmd/spo/group/group-member-add.mdx +34 -27
  92. package/docs/docs/cmd/teams/meeting/meeting-attendancereport-get.mdx +138 -0
  93. package/docs/docs/cmd/teams/message/message-remove.mdx +63 -0
  94. package/docs/docs/cmd/viva/engage/engage-community-add.mdx +168 -0
  95. package/npm-shrinkwrap.json +809 -803
  96. package/package.json +13 -13
package/dist/Auth.js CHANGED
@@ -354,17 +354,9 @@ export class Auth {
354
354
  await logger.logToStderr(response);
355
355
  await logger.logToStderr('');
356
356
  }
357
- cli.spinner.text = response.message;
358
- cli.spinner.spinner = {
359
- frames: ['🌶️ ']
360
- };
361
- // don't show spinner if running tests
362
- /* c8 ignore next 3 */
363
- if (!cli.spinner.isSpinning && typeof global.it === 'undefined') {
364
- cli.spinner.start();
365
- }
357
+ await logger.logToStderr(`🌶️ ${response.message}`);
366
358
  if (cli.getSettingWithDefaultValue(settingsNames.autoOpenLinksInBrowser, false)) {
367
- browserUtil.open(response.verificationUri);
359
+ await browserUtil.open(response.verificationUri);
368
360
  }
369
361
  if (cli.getSettingWithDefaultValue(settingsNames.copyDeviceCodeToClipboard, false)) {
370
362
  // _clipboardy is never set before hitting this line, but this check
@@ -16,23 +16,23 @@ export class AuthServer {
16
16
  this.resource = resource;
17
17
  this.httpServer = http.createServer(this.httpRequest).listen(0, this.httpListener);
18
18
  };
19
- this.httpListener = () => {
19
+ this.httpListener = async () => {
20
20
  const requestState = Math.random().toString(16).substr(2, 20);
21
21
  const address = this.httpServer.address();
22
22
  this.generatedServerUrl = `http://localhost:${address.port}`;
23
23
  const url = `${Auth.getEndpointForResource('https://login.microsoftonline.com', this.connection.cloudType)}/${this.connection.tenant}/oauth2/authorize?response_type=code&client_id=${this.connection.appId}&redirect_uri=${this.generatedServerUrl}&state=${requestState}&resource=${this.resource}&prompt=select_account`;
24
24
  if (this.debug) {
25
- this.logger.logToStderr('Redirect URL:');
26
- this.logger.logToStderr(url);
27
- this.logger.logToStderr('');
25
+ await this.logger.logToStderr('Redirect URL:');
26
+ await this.logger.logToStderr(url);
27
+ await this.logger.logToStderr('');
28
28
  }
29
29
  this.openUrl(url);
30
30
  };
31
- this.httpRequest = (request, response) => {
31
+ this.httpRequest = async (request, response) => {
32
32
  if (this.debug) {
33
- this.logger.logToStderr('Response:');
34
- this.logger.logToStderr(request.url);
35
- this.logger.logToStderr('');
33
+ await this.logger.logToStderr('Response:');
34
+ await this.logger.logToStderr(request.url);
35
+ await this.logger.logToStderr('');
36
36
  }
37
37
  // url.parse is deprecated but we can't move to URL, because it doesn't
38
38
  // support server-relative URLs
@@ -82,8 +82,8 @@ export class AuthServer {
82
82
  }
83
83
  openUrl(url) {
84
84
  browserUtil.open(url)
85
- .then(_ => {
86
- this.logger.logToStderr("To sign in, use the web browser that just has been opened. Please sign-in there.");
85
+ .then(async (_) => {
86
+ await this.logger.logToStderr("To sign in, use the web browser that just has been opened. Please sign-in there.");
87
87
  })
88
88
  .catch(_ => {
89
89
  const errorResponse = {
package/dist/Command.js CHANGED
@@ -88,7 +88,7 @@ class Command {
88
88
  }
89
89
  if (!prompted) {
90
90
  prompted = true;
91
- cli.error('🌶️ Provide values for the following parameters:');
91
+ await cli.error('🌶️ Provide values for the following parameters:');
92
92
  }
93
93
  const answer = optionInfo.autocomplete !== undefined
94
94
  ? await prompt.forSelection({ message: `${optionInfo.name}: `, choices: optionInfo.autocomplete.map((choice) => { return { name: choice, value: choice }; }) })
@@ -96,9 +96,9 @@ class Command {
96
96
  args.options[optionInfo.name] = answer;
97
97
  }
98
98
  if (prompted) {
99
- cli.error('');
99
+ await cli.error('');
100
100
  }
101
- this.processOptions(args.options);
101
+ await this.processOptions(args.options);
102
102
  return true;
103
103
  }
104
104
  async validateOptionSets(args, command) {
@@ -129,17 +129,17 @@ class Command {
129
129
  return true;
130
130
  }
131
131
  async promptForOptionSetNameAndValue(args, optionSet) {
132
- cli.error(`🌶️ Please specify one of the following options:`);
132
+ await cli.error(`🌶️ Please specify one of the following options:`);
133
133
  const selectedOptionName = await prompt.forSelection({ message: `Option to use:`, choices: optionSet.options.map((choice) => { return { name: choice, value: choice }; }) });
134
134
  const optionValue = await prompt.forInput({ message: `${selectedOptionName}:` });
135
135
  args.options[selectedOptionName] = optionValue;
136
- cli.error('');
136
+ await cli.error('');
137
137
  }
138
138
  async promptForSpecificOption(args, commonOptions) {
139
- cli.error(`🌶️ Multiple options for an option set specified. Please specify the correct option that you wish to use.`);
139
+ await cli.error(`🌶️ Multiple options for an option set specified. Please specify the correct option that you wish to use.`);
140
140
  const selectedOptionName = await prompt.forSelection({ message: `Option to use:`, choices: commonOptions.map((choice) => { return { name: choice, value: choice }; }) });
141
141
  commonOptions.filter(y => y !== selectedOptionName).map(optionName => args.options[optionName] = undefined);
142
- cli.error('');
142
+ await cli.error('');
143
143
  }
144
144
  async validateOutput(args) {
145
145
  if (args.options.output &&
@@ -179,7 +179,7 @@ class Command {
179
179
  catch (error) {
180
180
  throw new CommandError(error);
181
181
  }
182
- this.initAction(args, logger);
182
+ await this.initAction(args, logger);
183
183
  if (!auth.connection.active) {
184
184
  throw new CommandError('Log in to Microsoft 365 first');
185
185
  }
@@ -308,13 +308,13 @@ class Command {
308
308
  handleRejectedPromise(rawResponse) {
309
309
  this.handleError(rawResponse);
310
310
  }
311
- initAction(args, logger) {
311
+ async initAction(args, logger) {
312
312
  this.debug = args.options.debug || process.env.CLIMICROSOFT365_DEBUG === '1';
313
313
  this.verbose = this.debug || args.options.verbose || process.env.CLIMICROSOFT365_VERBOSE === '1';
314
314
  request.debug = this.debug;
315
315
  request.logger = logger;
316
316
  if (this.debug && auth.connection.identityName !== undefined) {
317
- logger.logToStderr(`Executing command as '${auth.connection.identityName}', appId: ${auth.connection.appId}, tenantId: ${auth.connection.identityTenantId}`);
317
+ await logger.logToStderr(`Executing command as '${auth.connection.identityName}', appId: ${auth.connection.appId}, tenantId: ${auth.connection.identityTenantId}`);
318
318
  }
319
319
  telemetry.trackEvent(this.getUsedCommandName(), this.getTelemetryProperties(args));
320
320
  }
@@ -1,22 +1,17 @@
1
1
  import fs from 'fs';
2
- import ora from 'ora';
3
2
  import path from 'path';
4
3
  import url from 'url';
5
- import { cli } from '../cli/cli.js';
6
4
  import request from '../request.js';
7
- import { settingsNames } from '../settingsNames.js';
8
5
  import { md } from '../utils/md.js';
9
6
  import { prompt } from '../utils/prompt.js';
10
7
  const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
11
8
  const mendableBaseUrl = 'https://api.mendable.ai/v1';
12
9
  const mendableApiKey = 'd3313d54-6f8e-40e0-90d3-4095019d4be7';
13
- const spinner = ora({ discardStdin: false });
14
10
  let showHelp = false;
15
11
  let debug = false;
16
12
  let conversationId = 0;
17
13
  let initialPrompt = '';
18
14
  let history = [];
19
- const showSpinner = cli.getSettingWithDefaultValue(settingsNames.showSpinner, true) && typeof global.it === 'undefined';
20
15
  request.logger = {
21
16
  /* c8 ignore next 3 */
22
17
  log: async (msg) => console.log(msg),
@@ -74,20 +69,11 @@ async function promptForPrompt() {
74
69
  }
75
70
  async function runConversationTurn(conversationId, question) {
76
71
  console.log('');
77
- /* c8 ignore next 4 */
78
- if (showSpinner) {
79
- spinner.text = 'Searching documentation...';
80
- spinner.start();
81
- }
82
72
  const response = await runMendableChat(conversationId, question);
83
73
  history.push({
84
74
  prompt: question,
85
75
  response: response.answer.text
86
76
  });
87
- /* c8 ignore next 3 */
88
- if (showSpinner) {
89
- spinner.stop();
90
- }
91
77
  console.log(md.md2plain(response.answer.text, ''));
92
78
  console.log('');
93
79
  console.log('Source:');
@@ -141,16 +127,7 @@ async function endConversation(conversationId) {
141
127
  conversation_id: conversationId
142
128
  }
143
129
  };
144
- /* c8 ignore next 4 */
145
- if (showSpinner) {
146
- spinner.text = 'Ending conversation...';
147
- spinner.start();
148
- }
149
130
  await request.post(requestOptions);
150
- /* c8 ignore next 3 */
151
- if (showSpinner) {
152
- spinner.stop();
153
- }
154
131
  }
155
132
  async function runMendableChat(conversationId, question) {
156
133
  const requestOptions = {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { chili } from './chili.js';
3
3
  try {
4
- (async () => await chili.startConversation(process.argv.slice(2)))();
4
+ await (async () => await chili.startConversation(process.argv.slice(2)))();
5
5
  }
6
6
  catch (err) {
7
7
  console.error(`🛑 An error has occurred while searching documentation: ${err}`);
package/dist/cli/cli.js CHANGED
@@ -2,7 +2,6 @@ import Configstore from 'configstore';
2
2
  import fs from 'fs';
3
3
  import minimist from 'minimist';
4
4
  import { createRequire } from 'module';
5
- import ora from 'ora';
6
5
  import os from 'os';
7
6
  import path from 'path';
8
7
  import { fileURLToPath, pathToFileURL } from 'url';
@@ -21,9 +20,6 @@ import { browserUtil } from '../utils/browserUtil.js';
21
20
  const require = createRequire(import.meta.url);
22
21
  const __dirname = fileURLToPath(new URL('.', import.meta.url));
23
22
  let _config;
24
- // we assign it through exported function to support mocking
25
- // eslint-disable-next-line prefer-const
26
- let spinner = ora();
27
23
  const commands = [];
28
24
  /**
29
25
  * Command to execute
@@ -144,23 +140,23 @@ async function execute(rawArgs) {
144
140
  await cli.executeCommand(cli.commandToExecute.command, cli.optionsFromArgs);
145
141
  const endTotal = process.hrtime.bigint();
146
142
  timings.total.push(Number(endTotal - start));
147
- printTimings(rawArgs);
143
+ await printTimings(rawArgs);
148
144
  process.exit(0);
149
145
  }
150
146
  catch (err) {
151
147
  const endTotal = process.hrtime.bigint();
152
148
  timings.total.push(Number(endTotal - start));
153
- printTimings(rawArgs);
149
+ await printTimings(rawArgs);
154
150
  await cli.closeWithError(err, cli.optionsFromArgs);
155
151
  /* c8 ignore next */
156
152
  }
157
153
  }
158
- function printTimings(rawArgs) {
154
+ async function printTimings(rawArgs) {
159
155
  if (rawArgs.some(arg => arg === '--debug')) {
160
- cli.error('');
161
- cli.error('Timings:');
162
- Object.getOwnPropertyNames(timings).forEach(key => {
163
- cli.error(`${key}: ${timings[key].reduce((a, b) => a + b, 0) / 1e6}ms`);
156
+ await cli.error('');
157
+ await cli.error('Timings:');
158
+ Object.getOwnPropertyNames(timings).forEach(async (key) => {
159
+ await cli.error(`${key}: ${timings[key].reduce((a, b) => a + b, 0) / 1e6}ms`);
164
160
  });
165
161
  }
166
162
  }
@@ -179,7 +175,7 @@ async function executeCommand(command, args) {
179
175
  },
180
176
  logToStderr: async (message) => {
181
177
  if (args.options.output !== 'none') {
182
- cli.error(message);
178
+ await cli.error(message);
183
179
  }
184
180
  }
185
181
  };
@@ -190,12 +186,6 @@ async function executeCommand(command, args) {
190
186
  // the command to execute
191
187
  const parentCommandName = cli.currentCommandName;
192
188
  cli.currentCommandName = command.getCommandName(cli.currentCommandName);
193
- const showSpinner = cli.getSettingWithDefaultValue(settingsNames.showSpinner, true) && args.options.output !== 'none';
194
- // don't show spinner if running tests
195
- /* c8 ignore next 3 */
196
- if (showSpinner && typeof global.it === 'undefined') {
197
- cli.spinner.start();
198
- }
199
189
  const startCommand = process.hrtime.bigint();
200
190
  try {
201
191
  await command.action(logger, args);
@@ -207,10 +197,6 @@ async function executeCommand(command, args) {
207
197
  finally {
208
198
  // restore the original command name
209
199
  cli.currentCommandName = parentCommandName;
210
- /* c8 ignore next 3 */
211
- if (cli.spinner.isSpinning) {
212
- cli.spinner.stop();
213
- }
214
200
  const endCommand = process.hrtime.bigint();
215
201
  timings.command.push(Number(endCommand - startCommand));
216
202
  }
@@ -758,29 +744,14 @@ async function closeWithError(error, args, showHelpIfEnabled = false) {
758
744
  /* c8 ignore next */
759
745
  }
760
746
  function log(message, ...optionalParams) {
761
- const spinnerSpinning = cli.spinner.isSpinning;
762
- /* c8 ignore next 3 */
763
- if (spinnerSpinning) {
764
- cli.spinner.stop();
765
- }
766
747
  if (message) {
767
748
  console.log(message, ...optionalParams);
768
749
  }
769
750
  else {
770
751
  console.log();
771
752
  }
772
- // Restart the spinner if it was running before the log
773
- /* c8 ignore next 3 */
774
- if (spinnerSpinning) {
775
- cli.spinner.start();
776
- }
777
753
  }
778
754
  async function error(message, ...optionalParams) {
779
- const spinnerSpinning = cli.spinner.isSpinning;
780
- /* c8 ignore next 3 */
781
- if (spinnerSpinning) {
782
- cli.spinner.stop();
783
- }
784
755
  const errorOutput = cli.getSettingWithDefaultValue(settingsNames.errorOutput, 'stderr');
785
756
  if (errorOutput === 'stdout') {
786
757
  console.log(message, ...optionalParams);
@@ -788,40 +759,15 @@ async function error(message, ...optionalParams) {
788
759
  else {
789
760
  console.error(message, ...optionalParams);
790
761
  }
791
- // Restart the spinner if it was running before the log
792
- /* c8 ignore next 3 */
793
- if (spinnerSpinning) {
794
- cli.spinner.start();
795
- }
796
762
  }
797
763
  async function promptForSelection(config) {
798
- const spinnerSpinning = cli.spinner.isSpinning;
799
- /* c8 ignore next 3 */
800
- if (spinnerSpinning) {
801
- cli.spinner.stop();
802
- }
803
764
  const answer = await prompt.forSelection(config);
804
- cli.error('');
805
- // Restart the spinner if it was running before the prompt
806
- /* c8 ignore next 3 */
807
- if (spinnerSpinning) {
808
- cli.spinner.start();
809
- }
765
+ await cli.error('');
810
766
  return answer;
811
767
  }
812
768
  async function promptForConfirmation(config) {
813
- const spinnerSpinning = cli.spinner.isSpinning;
814
- /* c8 ignore next 3 */
815
- if (spinnerSpinning) {
816
- cli.spinner.stop();
817
- }
818
769
  const answer = await prompt.forConfirmation(config);
819
- cli.error('');
820
- // Restart the spinner if it was running before the prompt
821
- /* c8 ignore next 3 */
822
- if (spinnerSpinning) {
823
- cli.spinner.start();
824
- }
770
+ await cli.error('');
825
771
  return answer;
826
772
  }
827
773
  async function handleMultipleResultsFound(message, values) {
@@ -829,7 +775,7 @@ async function handleMultipleResultsFound(message, values) {
829
775
  if (!prompt) {
830
776
  throw new Error(`${message} Found: ${Object.keys(values).join(', ')}.`);
831
777
  }
832
- cli.error(`🌶️ ${message} `);
778
+ await cli.error(`🌶️ ${message} `);
833
779
  const choices = Object.keys(values).map((choice) => { return { name: choice, value: choice }; });
834
780
  const response = await cli.promptForSelection({ message: `Please choose one:`, choices });
835
781
  return values[response];
@@ -885,14 +831,6 @@ export const cli = {
885
831
  printAvailableCommands,
886
832
  promptForConfirmation,
887
833
  promptForSelection,
888
- shouldTrimOutput,
889
- spinner
890
- };
891
- const spinnerOptions = {
892
- text: 'Running command...',
893
- /* c8 ignore next 1 */
894
- stream: cli.getSettingWithDefaultValue('errorOutput', 'stderr') === 'stderr' ? process.stderr : process.stdout,
895
- discardStdin: false
834
+ shouldTrimOutput
896
835
  };
897
- cli.spinner = ora(spinnerOptions);
898
836
  //# sourceMappingURL=cli.js.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { cli } from './cli/cli.js';
3
3
  import { app } from './utils/app.js';
4
- (async () => {
4
+ await (async () => {
5
5
  // required to make console.log() in combination with piped output synchronous
6
6
  // on Windows/in PowerShell so that the output is not trimmed by calling
7
7
  // process.exit() after executing the command, while the output is still
@@ -1,7 +1,7 @@
1
1
  import Command from '../../Command.js';
2
2
  export default class AnonymousCommand extends Command {
3
3
  async action(logger, args) {
4
- this.initAction(args, logger);
4
+ await this.initAction(args, logger);
5
5
  await this.commandAction(logger, args);
6
6
  }
7
7
  }
@@ -5,8 +5,8 @@ import GraphCommand from './GraphCommand.js';
5
5
  * This command class is for delegated-only Graph commands.
6
6
  */
7
7
  export default class DelegatedGraphCommand extends GraphCommand {
8
- initAction(args, logger) {
9
- super.initAction(args, logger);
8
+ async initAction(args, logger) {
9
+ await super.initAction(args, logger);
10
10
  if (!auth.connection.active) {
11
11
  // we fail no login in the base command command class
12
12
  return;
@@ -5,8 +5,8 @@ export default class PowerAppsCommand extends Command {
5
5
  get resource() {
6
6
  return 'https://api.powerapps.com';
7
7
  }
8
- initAction(args, logger) {
9
- super.initAction(args, logger);
8
+ async initAction(args, logger) {
9
+ await super.initAction(args, logger);
10
10
  if (!auth.connection.active) {
11
11
  // we fail no login in the base command command class
12
12
  return;
@@ -5,8 +5,8 @@ export default class PowerAutomateCommand extends Command {
5
5
  get resource() {
6
6
  return 'https://api.flow.microsoft.com';
7
7
  }
8
- initAction(args, logger) {
9
- super.initAction(args, logger);
8
+ async initAction(args, logger) {
9
+ await super.initAction(args, logger);
10
10
  if (!auth.connection.active) {
11
11
  // we fail no login in the base command command class
12
12
  return;
@@ -5,8 +5,8 @@ export default class PowerBICommand extends Command {
5
5
  get resource() {
6
6
  return 'https://api.powerbi.com';
7
7
  }
8
- initAction(args, logger) {
9
- super.initAction(args, logger);
8
+ async initAction(args, logger) {
9
+ await super.initAction(args, logger);
10
10
  if (!auth.connection.active) {
11
11
  // we fail no login in the base command command class
12
12
  return;
@@ -5,8 +5,8 @@ export default class PowerPlatformCommand extends Command {
5
5
  get resource() {
6
6
  return 'https://api.bap.microsoft.com';
7
7
  }
8
- initAction(args, logger) {
9
- super.initAction(args, logger);
8
+ async initAction(args, logger) {
9
+ await super.initAction(args, logger);
10
10
  if (!auth.connection.active) {
11
11
  // we fail no login in the base command command class
12
12
  return;
@@ -5,8 +5,8 @@ export default class VivaEngageCommand extends Command {
5
5
  get resource() {
6
6
  return 'https://www.yammer.com/api';
7
7
  }
8
- initAction(args, logger) {
9
- super.initAction(args, logger);
8
+ async initAction(args, logger) {
9
+ await super.initAction(args, logger);
10
10
  if (!auth.connection.active) {
11
11
  // we fail no login in the base command command class
12
12
  return;
@@ -33,7 +33,7 @@ class CliConsentCommand extends AnonymousCommand {
33
33
  await logger.log(`To consent permissions for executing ${args.options.service} commands, navigate in your web browser to https://login.microsoftonline.com/${config.tenant}/oauth2/v2.0/authorize?client_id=${config.cliEntraAppId}&response_type=code&scope=${encodeURIComponent(scope)}`);
34
34
  }
35
35
  async action(logger, args) {
36
- this.initAction(args, logger);
36
+ await this.initAction(args, logger);
37
37
  await this.commandAction(logger, args);
38
38
  }
39
39
  }
@@ -98,7 +98,7 @@ class LoginCommand extends Command {
98
98
  catch (error) {
99
99
  throw new CommandError(error);
100
100
  }
101
- this.initAction(args, logger);
101
+ await this.initAction(args, logger);
102
102
  await this.commandAction(logger, args);
103
103
  }
104
104
  }
@@ -32,7 +32,7 @@ class LogoutCommand extends Command {
32
32
  catch (error) {
33
33
  throw new CommandError(error);
34
34
  }
35
- this.initAction(args, logger);
35
+ await this.initAction(args, logger);
36
36
  await this.commandAction(logger);
37
37
  }
38
38
  }
@@ -42,8 +42,6 @@ class SetupCommand extends AnonymousCommand {
42
42
  await this.configureSettings(settings, true, logger);
43
43
  return;
44
44
  }
45
- // stop the spinner. Fixes #5598
46
- cli.spinner.stop();
47
45
  await logger.logToStderr(`Welcome to the CLI for Microsoft 365 setup!`);
48
46
  await logger.logToStderr(`This command will guide you through the process of configuring the CLI for your needs.`);
49
47
  await logger.logToStderr(`Please, answer the following questions and we'll define a set of settings to best match how you intend to use the CLI.`);
@@ -85,8 +83,6 @@ class SetupCommand extends AnonymousCommand {
85
83
  await logger.logToStderr('');
86
84
  await logger.logToStderr('Configuring settings...');
87
85
  await logger.logToStderr('');
88
- // start the spinner. Fixes #5598
89
- cli.spinner.start();
90
86
  await this.configureSettings(settings, false, logger);
91
87
  if (!this.verbose) {
92
88
  await logger.logToStderr('');
@@ -49,7 +49,7 @@ class StatusCommand extends Command {
49
49
  catch (error) {
50
50
  throw new CommandError(error);
51
51
  }
52
- this.initAction(args, logger);
52
+ await this.initAction(args, logger);
53
53
  await this.commandAction(logger);
54
54
  }
55
55
  }
@@ -39,7 +39,7 @@ class ConnectionListCommand extends Command {
39
39
  catch (error) {
40
40
  throw new CommandError(error);
41
41
  }
42
- this.initAction(args, logger);
42
+ await this.initAction(args, logger);
43
43
  await this.commandAction(logger);
44
44
  }
45
45
  }
@@ -46,7 +46,7 @@ class ConnectionRemoveCommand extends Command {
46
46
  catch (error) {
47
47
  throw new CommandError(error);
48
48
  }
49
- this.initAction(args, logger);
49
+ await this.initAction(args, logger);
50
50
  await this.commandAction(logger, args);
51
51
  }
52
52
  }
@@ -34,7 +34,7 @@ class ConnectionSetCommand extends Command {
34
34
  catch (error) {
35
35
  throw new CommandError(error);
36
36
  }
37
- this.initAction(args, logger);
37
+ await this.initAction(args, logger);
38
38
  await this.commandAction(logger, args);
39
39
  }
40
40
  }
@@ -38,7 +38,7 @@ class ConnectionUseCommand extends Command {
38
38
  catch (error) {
39
39
  throw new CommandError(error);
40
40
  }
41
- this.initAction(args, logger);
41
+ await this.initAction(args, logger);
42
42
  await this.commandAction(logger, args);
43
43
  }
44
44
  }
@@ -61,7 +61,10 @@ class EntraAppPermissionAddCommand extends GraphCommand {
61
61
  };
62
62
  await request.patch(addPermissionsRequestOptions);
63
63
  if (args.options.grantAdminConsent) {
64
- const appServicePrincipal = servicePrincipals.find(sp => sp.appId === appObject.appId);
64
+ let appServicePrincipal = servicePrincipals.find(sp => sp.appId === appObject.appId);
65
+ if (!appServicePrincipal) {
66
+ appServicePrincipal = await this.createServicePrincipal(appObject.appId, logger);
67
+ }
65
68
  await this.grantAdminConsent(appServicePrincipal, appPermissions, logger);
66
69
  }
67
70
  }
@@ -69,6 +72,23 @@ class EntraAppPermissionAddCommand extends GraphCommand {
69
72
  this.handleRejectedODataJsonPromise(err);
70
73
  }
71
74
  }
75
+ async createServicePrincipal(appId, logger) {
76
+ if (this.verbose) {
77
+ await logger.logToStderr(`Creating service principal for app ${appId}...`);
78
+ }
79
+ const requestOptions = {
80
+ url: `${this.resource}/v1.0/servicePrincipals`,
81
+ headers: {
82
+ accept: 'application/json;odata.metadata=none',
83
+ 'content-type': 'application/json;odata=nometadata'
84
+ },
85
+ data: {
86
+ appId
87
+ },
88
+ responseType: 'json'
89
+ };
90
+ return await request.post(requestOptions);
91
+ }
72
92
  async getAppObject(options) {
73
93
  let appNotFoundMessage = '';
74
94
  let apps = [];
@@ -49,6 +49,11 @@ class EntraAppPermissionRemoveCommand extends GraphCommand {
49
49
  const applicationPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.applicationPermissions, ScopeType.Role, appPermissions, logger);
50
50
  this.removePermissionsFromResourceArray(applicationPermissions, appObject.requiredResourceAccess);
51
51
  }
52
+ for (let i = 0; i < appObject.requiredResourceAccess.length; i++) {
53
+ if (appObject.requiredResourceAccess[i].resourceAccess?.length === 0) {
54
+ appObject.requiredResourceAccess.splice(i, 1);
55
+ }
56
+ }
52
57
  const removePermissionRequestOptions = {
53
58
  url: `${this.resource}/v1.0/applications/${appObject.id}`,
54
59
  headers: {
@@ -270,6 +275,18 @@ _EntraAppPermissionRemoveCommand_instances = new WeakSet(), _EntraAppPermissionR
270
275
  if (args.options.appObjectId && !validation.isValidGuid(args.options.appObjectId)) {
271
276
  return `${args.options.appObjectId} is not a valid GUID`;
272
277
  }
278
+ if (args.options.delegatedPermissions) {
279
+ const invalidPermissions = validation.isValidPermission(args.options.delegatedPermissions);
280
+ if (Array.isArray(invalidPermissions)) {
281
+ return `Delegated permission(s) ${invalidPermissions.join(', ')} are not fully-qualified`;
282
+ }
283
+ }
284
+ if (args.options.applicationPermissions) {
285
+ const invalidPermissions = validation.isValidPermission(args.options.applicationPermissions);
286
+ if (Array.isArray(invalidPermissions)) {
287
+ return `Application permission(s) ${invalidPermissions.join(', ')} are not fully-qualified`;
288
+ }
289
+ }
273
290
  return true;
274
291
  });
275
292
  }, _EntraAppPermissionRemoveCommand_initOptionSets = function _EntraAppPermissionRemoveCommand_initOptionSets() {
@@ -139,6 +139,7 @@ class EntraM365GroupAddCommand extends GraphCommand {
139
139
  const userArr = users.split(',').map(o => o.trim());
140
140
  let promises = [];
141
141
  let userIds = [];
142
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
142
143
  promises = userArr.map(user => {
143
144
  const requestOptions = {
144
145
  url: `${this.resource}/v1.0/users?$filter=userPrincipalName eq '${formatting.encodeQueryParameter(user)}'&$select=id,userPrincipalName`,