@pnp/cli-microsoft365 7.2.0-beta.c7e1c03 → 7.2.0-beta.d785eb6

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 (109) hide show
  1. package/allCommands.json +1 -0
  2. package/dist/api.js +5 -7
  3. package/dist/cli/Cli.js +93 -118
  4. package/dist/cli/timings.js +9 -0
  5. package/dist/index.js +8 -14
  6. package/dist/m365/flow/commands/environment/environment-list.js +6 -4
  7. package/dist/m365/spfx/commands/project/DeployWorkflow.js +4 -4
  8. package/dist/m365/spfx/commands/project/project-doctor/{doctor-1.18.1-rc.0.js → doctor-1.18.1.js} +1 -1
  9. package/dist/m365/spfx/commands/project/project-doctor.js +1 -1
  10. package/dist/m365/spfx/commands/project/project-github-workflow-add.js +17 -0
  11. package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.18.1-rc.0.js → upgrade-1.18.1.js} +26 -26
  12. package/dist/m365/spfx/commands/project/project-upgrade.js +13 -15
  13. package/dist/m365/spfx/commands/spfx-doctor.js +1 -1
  14. package/dist/m365/spo/commands/site/site-add.js +45 -12
  15. package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-restore.js +19 -2
  16. package/dist/request.js +6 -0
  17. package/docs/docs/cmd/aad/approleassignment/approleassignment-add.mdx +1 -1
  18. package/docs/docs/cmd/aad/approleassignment/approleassignment-list.mdx +2 -2
  19. package/docs/docs/cmd/aad/approleassignment/approleassignment-remove.mdx +1 -1
  20. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-add.mdx +1 -1
  21. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-list.mdx +2 -2
  22. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-remove.mdx +2 -2
  23. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-set.mdx +2 -2
  24. package/docs/docs/cmd/aad/policy/policy-list.mdx +1 -1
  25. package/docs/docs/cmd/aad/siteclassification/siteclassification-disable.mdx +1 -1
  26. package/docs/docs/cmd/aad/siteclassification/siteclassification-enable.mdx +1 -1
  27. package/docs/docs/cmd/aad/siteclassification/siteclassification-get.mdx +1 -1
  28. package/docs/docs/cmd/aad/siteclassification/siteclassification-set.mdx +1 -1
  29. package/docs/docs/cmd/aad/sp/sp-add.mdx +2 -2
  30. package/docs/docs/cmd/aad/sp/sp-get.mdx +2 -2
  31. package/docs/docs/cmd/aad/user/user-add.mdx +3 -3
  32. package/docs/docs/cmd/aad/user/user-guest-add.mdx +1 -1
  33. package/docs/docs/cmd/aad/user/user-set.mdx +3 -3
  34. package/docs/docs/cmd/graph/changelog/changelog-list.mdx +5 -5
  35. package/docs/docs/cmd/onenote/notebook/notebook-list.mdx +1 -1
  36. package/docs/docs/cmd/outlook/message/message-list.mdx +1 -1
  37. package/docs/docs/cmd/outlook/message/message-move.mdx +1 -1
  38. package/docs/docs/cmd/planner/bucket/bucket-add.mdx +1 -1
  39. package/docs/docs/cmd/planner/bucket/bucket-set.mdx +1 -1
  40. package/docs/docs/cmd/planner/plan/plan-set.mdx +3 -3
  41. package/docs/docs/cmd/planner/task/task-set.mdx +1 -1
  42. package/docs/docs/cmd/purview/auditlog/auditlog-list.mdx +3 -3
  43. package/docs/docs/cmd/purview/retentionevent/retentionevent-add.mdx +1 -1
  44. package/docs/docs/cmd/purview/retentionevent/retentionevent-get.mdx +1 -1
  45. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.mdx +1 -1
  46. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-get.mdx +1 -1
  47. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-remove.mdx +1 -1
  48. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-set.mdx +1 -1
  49. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.mdx +1 -1
  50. package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-policysettings-list.mdx +4 -4
  51. package/docs/docs/cmd/spfx/project/project-upgrade.mdx +1 -1
  52. package/docs/docs/cmd/spo/app/app-add.mdx +1 -1
  53. package/docs/docs/cmd/spo/app/app-deploy.mdx +1 -1
  54. package/docs/docs/cmd/spo/app/app-get.mdx +1 -1
  55. package/docs/docs/cmd/spo/app/app-install.mdx +1 -1
  56. package/docs/docs/cmd/spo/app/app-list.mdx +1 -1
  57. package/docs/docs/cmd/spo/app/app-remove.mdx +1 -1
  58. package/docs/docs/cmd/spo/app/app-retract.mdx +1 -1
  59. package/docs/docs/cmd/spo/app/app-uninstall.mdx +1 -1
  60. package/docs/docs/cmd/spo/app/app-upgrade.mdx +1 -1
  61. package/docs/docs/cmd/spo/contenttype/contenttype-add.mdx +1 -1
  62. package/docs/docs/cmd/spo/contenttype/contenttype-set.mdx +1 -1
  63. package/docs/docs/cmd/spo/hidedefaultthemes/hidedefaultthemes-get.mdx +1 -1
  64. package/docs/docs/cmd/spo/hidedefaultthemes/hidedefaultthemes-set.mdx +1 -1
  65. package/docs/docs/cmd/spo/site/site-add.mdx +25 -4
  66. package/docs/docs/cmd/spo/site/site-appcatalog-add.mdx +1 -1
  67. package/docs/docs/cmd/spo/site/site-appcatalog-remove.mdx +1 -1
  68. package/docs/docs/cmd/spo/site/site-groupify.mdx +1 -1
  69. package/docs/docs/cmd/spo/sitedesign/sitedesign-add.mdx +3 -3
  70. package/docs/docs/cmd/spo/sitedesign/sitedesign-apply.mdx +1 -1
  71. package/docs/docs/cmd/spo/sitedesign/sitedesign-get.mdx +1 -1
  72. package/docs/docs/cmd/spo/sitedesign/sitedesign-list.mdx +1 -1
  73. package/docs/docs/cmd/spo/sitedesign/sitedesign-remove.mdx +1 -1
  74. package/docs/docs/cmd/spo/sitedesign/sitedesign-rights-grant.mdx +1 -1
  75. package/docs/docs/cmd/spo/sitedesign/sitedesign-rights-list.mdx +1 -1
  76. package/docs/docs/cmd/spo/sitedesign/sitedesign-rights-revoke.mdx +1 -1
  77. package/docs/docs/cmd/spo/sitedesign/sitedesign-run-list.mdx +1 -1
  78. package/docs/docs/cmd/spo/sitedesign/sitedesign-run-status-get.mdx +1 -1
  79. package/docs/docs/cmd/spo/sitedesign/sitedesign-set.mdx +3 -3
  80. package/docs/docs/cmd/spo/sitedesign/sitedesign-task-get.mdx +1 -1
  81. package/docs/docs/cmd/spo/sitedesign/sitedesign-task-list.mdx +1 -1
  82. package/docs/docs/cmd/spo/sitedesign/sitedesign-task-remove.mdx +1 -1
  83. package/docs/docs/cmd/spo/sitescript/sitescript-add.mdx +1 -1
  84. package/docs/docs/cmd/spo/sitescript/sitescript-get.mdx +1 -1
  85. package/docs/docs/cmd/spo/sitescript/sitescript-list.mdx +1 -1
  86. package/docs/docs/cmd/spo/sitescript/sitescript-remove.mdx +1 -1
  87. package/docs/docs/cmd/spo/sitescript/sitescript-set.mdx +1 -1
  88. package/docs/docs/cmd/spo/storageentity/storageentity-get.mdx +1 -1
  89. package/docs/docs/cmd/spo/storageentity/storageentity-list.mdx +1 -1
  90. package/docs/docs/cmd/spo/storageentity/storageentity-remove.mdx +1 -1
  91. package/docs/docs/cmd/spo/storageentity/storageentity-set.mdx +1 -1
  92. package/docs/docs/cmd/spo/theme/theme-apply.mdx +1 -1
  93. package/docs/docs/cmd/spo/theme/theme-get.mdx +1 -1
  94. package/docs/docs/cmd/spo/theme/theme-list.mdx +1 -1
  95. package/docs/docs/cmd/spo/theme/theme-remove.mdx +1 -1
  96. package/docs/docs/cmd/spo/user/user-remove.mdx +1 -1
  97. package/docs/docs/cmd/spo/web/web-set.mdx +1 -1
  98. package/docs/docs/cmd/teams/channel/channel-remove.mdx +1 -1
  99. package/docs/docs/cmd/teams/meeting/meeting-get.mdx +1 -1
  100. package/docs/docs/cmd/teams/meeting/meeting-transcript-list.mdx +1 -1
  101. package/docs/docs/cmd/teams/report/report-pstncalls.mdx +1 -1
  102. package/docs/docs/cmd/teams/tab/tab-remove.mdx +1 -1
  103. package/docs/docs/cmd/teams/team/team-remove.mdx +1 -1
  104. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.mdx +1 -1
  105. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.mdx +1 -1
  106. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.mdx +1 -1
  107. package/docs/docs/cmd/todo/task/task-set.mdx +1 -1
  108. package/npm-shrinkwrap.json +480 -516
  109. package/package.json +28 -28
package/dist/cli/Cli.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import Configstore from 'configstore';
2
2
  import fs from 'fs';
3
3
  import minimist from 'minimist';
4
+ import { createRequire } from 'module';
4
5
  import ora from 'ora';
5
6
  import os from 'os';
6
7
  import path from 'path';
7
- import { pathToFileURL } from 'url';
8
+ import { fileURLToPath, pathToFileURL } from 'url';
8
9
  import Command, { CommandError } from '../Command.js';
9
10
  import config from '../config.js';
10
11
  import request from '../request.js';
@@ -12,10 +13,12 @@ import { settingsNames } from '../settingsNames.js';
12
13
  import { telemetry } from '../telemetry.js';
13
14
  import { app } from '../utils/app.js';
14
15
  import { formatting } from '../utils/formatting.js';
15
- import { fsUtil } from '../utils/fsUtil.js';
16
16
  import { md } from '../utils/md.js';
17
17
  import { validation } from '../utils/validation.js';
18
18
  import { prompt } from '../utils/prompt.js';
19
+ import { timings } from './timings.js';
20
+ const require = createRequire(import.meta.url);
21
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
19
22
  export class Cli {
20
23
  get config() {
21
24
  if (!this._config) {
@@ -34,7 +37,6 @@ export class Cli {
34
37
  }
35
38
  constructor() {
36
39
  this.commands = [];
37
- this.commandsFolder = '';
38
40
  const options = {
39
41
  text: 'Running command...',
40
42
  /* c8 ignore next 1 */
@@ -48,8 +50,9 @@ export class Cli {
48
50
  }
49
51
  return Cli.instance;
50
52
  }
51
- async execute(commandsFolder, rawArgs) {
52
- this.commandsFolder = commandsFolder;
53
+ async execute(rawArgs) {
54
+ const start = process.hrtime.bigint();
55
+ this.loadAllCommandsInfo();
53
56
  // check if help for a specific command has been requested using the
54
57
  // 'm365 help xyz' format. If so, remove 'help' from the array of words
55
58
  // to use lazy loading commands but keep track of the fact that help should
@@ -59,22 +62,10 @@ export class Cli {
59
62
  showHelp = true;
60
63
  rawArgs.shift();
61
64
  }
62
- // parse args to see if a command has been specified and can be loaded
63
- // rather than loading all commands
65
+ // parse args to see if a command has been specified
64
66
  const parsedArgs = minimist(rawArgs);
65
- // load commands
67
+ // load command
66
68
  await this.loadCommandFromArgs(parsedArgs._);
67
- if (this.currentCommandName) {
68
- for (let i = 0; i < this.commands.length; i++) {
69
- const command = this.commands[i];
70
- if (command.name === this.currentCommandName ||
71
- (command.aliases &&
72
- command.aliases.indexOf(this.currentCommandName) > -1)) {
73
- this.commandToExecute = command;
74
- break;
75
- }
76
- }
77
- }
78
69
  if (this.commandToExecute) {
79
70
  // we have found a command to execute. Parse args again taking into
80
71
  // account short and long options, option types and whether the command
@@ -90,6 +81,8 @@ export class Cli {
90
81
  }
91
82
  }
92
83
  else {
84
+ // we need this to properly support displaying commands
85
+ // from the current group
93
86
  this.optionsFromArgs = {
94
87
  options: parsedArgs
95
88
  };
@@ -113,26 +106,56 @@ export class Cli {
113
106
  catch (e) {
114
107
  return this.closeWithError(e, optionsWithoutShorts);
115
108
  }
109
+ const startProcessing = process.hrtime.bigint();
116
110
  try {
117
111
  // process options before passing them on to validation stage
118
112
  const contextCommandOptions = await this.loadOptionsFromContext(this.commandToExecute.options, optionsWithoutShorts.options.debug);
119
113
  optionsWithoutShorts.options = { ...contextCommandOptions, ...optionsWithoutShorts.options };
120
114
  await this.commandToExecute.command.processOptions(optionsWithoutShorts.options);
115
+ const endProcessing = process.hrtime.bigint();
116
+ timings.options.push(Number(endProcessing - startProcessing));
121
117
  }
122
118
  catch (e) {
119
+ const endProcessing = process.hrtime.bigint();
120
+ timings.options.push(Number(endProcessing - startProcessing));
123
121
  return this.closeWithError(e.message, optionsWithoutShorts, false);
124
122
  }
125
123
  // if output not specified, set the configured output value (if any)
126
124
  if (optionsWithoutShorts.options.output === undefined) {
127
125
  optionsWithoutShorts.options.output = this.getSettingWithDefaultValue(settingsNames.output, 'json');
128
126
  }
127
+ const startValidation = process.hrtime.bigint();
129
128
  const validationResult = await this.commandToExecute.command.validate(optionsWithoutShorts, this.commandToExecute);
129
+ const endValidation = process.hrtime.bigint();
130
+ timings.validation.push(Number(endValidation - startValidation));
130
131
  if (validationResult !== true) {
131
132
  return this.closeWithError(validationResult, optionsWithoutShorts, true);
132
133
  }
133
- return Cli
134
- .executeCommand(this.commandToExecute.command, optionsWithoutShorts)
135
- .then(_ => process.exit(0), err => this.closeWithError(err, optionsWithoutShorts));
134
+ const end = process.hrtime.bigint();
135
+ timings.core.push(Number(end - start));
136
+ try {
137
+ await Cli.executeCommand(this.commandToExecute.command, optionsWithoutShorts);
138
+ const endTotal = process.hrtime.bigint();
139
+ timings.total.push(Number(endTotal - start));
140
+ this.printTimings(rawArgs);
141
+ process.exit(0);
142
+ }
143
+ catch (err) {
144
+ const endTotal = process.hrtime.bigint();
145
+ timings.total.push(Number(endTotal - start));
146
+ this.printTimings(rawArgs);
147
+ await this.closeWithError(err, optionsWithoutShorts);
148
+ /* c8 ignore next */
149
+ }
150
+ }
151
+ printTimings(rawArgs) {
152
+ if (rawArgs.some(arg => arg === '--debug')) {
153
+ Cli.error('');
154
+ Cli.error('Timings:');
155
+ Object.getOwnPropertyNames(timings).forEach(key => {
156
+ Cli.error(`${key}: ${timings[key].reduce((a, b) => a + b, 0) / 1e6}ms`);
157
+ });
158
+ }
136
159
  }
137
160
  static async executeCommand(command, args) {
138
161
  const logger = {
@@ -167,6 +190,7 @@ export class Cli {
167
190
  if (showSpinner && typeof global.it === 'undefined') {
168
191
  cli.spinner.start();
169
192
  }
193
+ const startCommand = process.hrtime.bigint();
170
194
  try {
171
195
  await command.action(logger, args);
172
196
  if (args.options.debug || args.options.verbose) {
@@ -181,6 +205,8 @@ export class Cli {
181
205
  if (cli.spinner.isSpinning) {
182
206
  cli.spinner.stop();
183
207
  }
208
+ const endCommand = process.hrtime.bigint();
209
+ timings.command.push(Number(endCommand - startCommand));
184
210
  }
185
211
  }
186
212
  static async executeCommandWithOutput(command, args, listener) {
@@ -248,55 +274,25 @@ export class Cli {
248
274
  request.logger = currentLogger;
249
275
  }
250
276
  }
251
- async loadAllCommands() {
252
- const files = fsUtil.readdirR(this.commandsFolder);
253
- await Promise.all(files.map(async (filePath) => {
254
- const file = pathToFileURL(filePath).toString();
255
- if (file.indexOf(`/commands/`) > -1 &&
256
- file.indexOf(`/assets/`) < 0 &&
257
- file.endsWith('.js') &&
258
- !file.endsWith('.spec.js')) {
259
- try {
260
- const command = await import(file);
261
- if (command.default instanceof Command) {
262
- this.loadCommand(command.default);
263
- }
264
- }
265
- catch (e) {
266
- this.closeWithError(e, { options: {} });
267
- }
268
- }
269
- }));
277
+ loadAllCommandsInfo() {
278
+ this.commands = require(path.join(__dirname, '../../allCommands.json'));
270
279
  }
271
280
  /**
272
281
  * Loads command files into CLI based on the specified arguments.
273
282
  *
274
283
  * @param commandNameWords Array of words specified as args
275
- */
284
+ */
276
285
  async loadCommandFromArgs(commandNameWords) {
277
- this.currentCommandName = commandNameWords.join(' ');
278
286
  if (commandNameWords.length === 0) {
279
- await this.loadAllCommands();
280
287
  return;
281
288
  }
282
- const isCompletionCommand = commandNameWords.indexOf('completion') > -1;
283
- if (isCompletionCommand) {
284
- await this.loadAllCommands();
285
- return;
286
- }
287
- let commandFilePath = '';
288
- if (commandNameWords.length === 1) {
289
- commandFilePath = path.join(this.commandsFolder, 'commands', `${commandNameWords[0]}.js`);
290
- }
291
- else {
292
- if (commandNameWords.length === 2) {
293
- commandFilePath = path.join(this.commandsFolder, commandNameWords[0], 'commands', `${commandNameWords.join('-')}.js`);
294
- }
295
- else {
296
- commandFilePath = path.join(this.commandsFolder, commandNameWords[0], 'commands', commandNameWords[1], commandNameWords.slice(1).join('-') + '.js');
297
- }
289
+ this.currentCommandName = commandNameWords.join(' ');
290
+ const commandFilePath = this.commands
291
+ .find(c => c.name === this.currentCommandName ||
292
+ c.aliases?.find(a => a === this.currentCommandName))?.file ?? '';
293
+ if (commandFilePath) {
294
+ await this.loadCommandFromFile(commandFilePath);
298
295
  }
299
- await this.loadCommandFromFile(commandFilePath);
300
296
  }
301
297
  async loadOptionsFromContext(commandOptions, debug) {
302
298
  const filePath = '.m365rc.json';
@@ -339,39 +335,37 @@ export class Cli {
339
335
  * Loads command from the specified file into CLI. If can't find the file
340
336
  * or the file doesn't contain a command, loads all available commands.
341
337
  *
342
- * @param commandFilePath File path of the file with command to load
338
+ * @param commandFilePathUrl File path of the file with command to load
343
339
  */
344
- async loadCommandFromFile(commandFilePath) {
345
- if (!fs.existsSync(commandFilePath)) {
346
- await this.loadAllCommands();
340
+ async loadCommandFromFile(commandFileUrl) {
341
+ const commandsFolder = path.join(__dirname, '../m365');
342
+ const filePath = path.join(commandsFolder, commandFileUrl);
343
+ if (!fs.existsSync(filePath)) {
344
+ // reset command name
345
+ this.currentCommandName = undefined;
347
346
  return;
348
347
  }
349
348
  try {
350
- const commandFileUrl = pathToFileURL(commandFilePath).toString();
351
- const command = await import(commandFileUrl);
349
+ const command = await import(pathToFileURL(filePath).toString());
352
350
  if (command.default instanceof Command) {
353
- this.loadCommand(command.default);
351
+ const commandInfo = this.commands.find(c => c.file === commandFileUrl);
352
+ this.commandToExecute = Cli.getCommandInfo(command.default, commandFileUrl, commandInfo?.help);
354
353
  }
355
- else {
356
- await this.loadAllCommands();
357
- }
358
- }
359
- catch {
360
- await this.loadAllCommands();
361
354
  }
355
+ catch { }
362
356
  }
363
- static getCommandInfo(command) {
357
+ static getCommandInfo(command, filePath = '', helpFilePath = '') {
364
358
  return {
365
359
  aliases: command.alias(),
366
360
  name: command.name,
361
+ description: command.description,
367
362
  command: command,
368
363
  options: this.getCommandOptions(command),
369
- defaultProperties: command.defaultProperties()
364
+ defaultProperties: command.defaultProperties(),
365
+ file: filePath,
366
+ help: helpFilePath
370
367
  };
371
368
  }
372
- loadCommand(command) {
373
- this.commands.push(Cli.getCommandInfo(command));
374
- }
375
369
  static getCommandOptions(command) {
376
370
  const options = [];
377
371
  command.options.forEach(option => {
@@ -568,58 +562,39 @@ export class Cli {
568
562
  process.exit(exitCode);
569
563
  }
570
564
  printCommandHelp(helpMode) {
571
- let helpFilePath = '';
572
- let commandNameWords = [];
573
- if (this.commandToExecute) {
574
- commandNameWords = (this.commandToExecute.name).split(' ');
575
- }
576
- const pathChunks = [this.commandsFolder, '..', '..', 'docs', 'docs', 'cmd'];
577
- if (commandNameWords.length === 1) {
578
- pathChunks.push(`${commandNameWords[0]}.mdx`);
579
- }
580
- else {
581
- if (commandNameWords.length === 2) {
582
- pathChunks.push(commandNameWords[0], `${commandNameWords.join('-')}.mdx`);
583
- }
584
- else {
585
- pathChunks.push(commandNameWords[0], commandNameWords[1], commandNameWords.slice(1).join('-') + '.mdx');
586
- }
587
- }
588
- helpFilePath = path.join(...pathChunks);
565
+ const docsRootDir = path.join(__dirname, '..', '..', 'docs');
566
+ const helpFilePath = path.join(docsRootDir, 'docs', 'cmd', this.commandToExecute.help);
589
567
  if (fs.existsSync(helpFilePath)) {
590
568
  let helpContents = fs.readFileSync(helpFilePath, 'utf8');
591
569
  helpContents = this.getHelpSection(helpMode, helpContents);
592
- helpContents = md.md2plain(helpContents, path.join(this.commandsFolder, '..', '..', 'docs'));
570
+ helpContents = md.md2plain(helpContents, docsRootDir);
593
571
  Cli.log();
594
572
  Cli.log(helpContents);
595
573
  }
596
574
  }
597
575
  async getHelpMode(options) {
598
- const h = options.h;
599
- const help = options.help;
576
+ const { h, help } = options;
577
+ if (!h && !help) {
578
+ return this.getSettingWithDefaultValue(settingsNames.helpMode, Cli.defaultHelpMode);
579
+ }
600
580
  // user passed -h or --help, let's see if they passed a specific mode
601
581
  // or requested the default
602
- if (h || help) {
603
- const helpMode = h ?? help;
604
- if (typeof helpMode === 'boolean' || typeof helpMode !== 'string') {
605
- // requested default mode or passed a number, let's use default
606
- return this.getSettingWithDefaultValue(settingsNames.helpMode, Cli.defaultHelpMode);
582
+ const helpMode = h ?? help;
583
+ if (typeof helpMode === 'boolean' || typeof helpMode !== 'string') {
584
+ // requested default mode or passed a number, let's use default
585
+ return this.getSettingWithDefaultValue(settingsNames.helpMode, Cli.defaultHelpMode);
586
+ }
587
+ else {
588
+ const lowerCaseHelpMode = helpMode.toLowerCase();
589
+ if (Cli.helpModes.indexOf(lowerCaseHelpMode) < 0) {
590
+ await Cli.getInstance().closeWithError(`Unknown help mode ${helpMode}. Allowed values are ${Cli.helpModes.join(', ')}`, { options }, false);
591
+ /* c8 ignore next 2 */
592
+ return ''; // noop
607
593
  }
608
594
  else {
609
- const lowerCaseHelpMode = helpMode.toLowerCase();
610
- if (Cli.helpModes.indexOf(lowerCaseHelpMode) < 0) {
611
- await Cli.getInstance().closeWithError(`Unknown help mode ${helpMode}. Allowed values are ${Cli.helpModes.join(', ')}`, { options }, false);
612
- /* c8 ignore next 2 */
613
- return ''; // noop
614
- }
615
- else {
616
- return lowerCaseHelpMode;
617
- }
595
+ return lowerCaseHelpMode;
618
596
  }
619
597
  }
620
- else {
621
- return this.getSettingWithDefaultValue(settingsNames.helpMode, Cli.defaultHelpMode);
622
- }
623
598
  }
624
599
  getHelpSection(helpMode, helpContents) {
625
600
  if (helpMode === 'full') {
@@ -709,7 +684,7 @@ export class Cli {
709
684
  Cli.log();
710
685
  const sortedCommandNamesToPrint = Object.getOwnPropertyNames(commandsToPrint).sort();
711
686
  sortedCommandNamesToPrint.forEach(commandName => {
712
- Cli.log(` ${`${commandName} [options]`.padEnd(maxLength, ' ')} ${commandsToPrint[commandName].command.description}`);
687
+ Cli.log(` ${`${commandName} [options]`.padEnd(maxLength, ' ')} ${commandsToPrint[commandName].description}`);
713
688
  });
714
689
  }
715
690
  const namesOfCommandGroupsToPrint = Object.keys(commandGroupsToPrint);
@@ -0,0 +1,9 @@
1
+ export const timings = {
2
+ api: [],
3
+ core: [],
4
+ command: [],
5
+ options: [],
6
+ total: [],
7
+ validation: []
8
+ };
9
+ //# sourceMappingURL=timings.js.map
package/dist/index.js CHANGED
@@ -1,11 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import fs from 'fs';
3
- import path from 'path';
4
- import url from 'url';
5
2
  import { Cli } from './cli/Cli.js';
6
3
  import { telemetry } from './telemetry.js';
7
4
  import { app } from './utils/app.js';
8
- const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
9
5
  // required to make console.log() in combination with piped output synchronous
10
6
  // on Windows/in PowerShell so that the output is not trimmed by calling
11
7
  // process.exit() after executing the command, while the output is still
@@ -18,14 +14,12 @@ if (!process.env.CLIMICROSOFT365_NOUPDATE) {
18
14
  updateNotifier.default({ pkg: app.packageJson() }).notify({ defer: false });
19
15
  });
20
16
  }
21
- fs.realpath(__dirname, async (err, resolvedPath) => {
22
- try {
23
- const cli = Cli.getInstance();
24
- await cli.execute(path.join(resolvedPath, 'm365'), process.argv.slice(2));
25
- }
26
- catch (e) {
27
- telemetry.trackException(e);
28
- process.exit(1);
29
- }
30
- });
17
+ try {
18
+ const cli = Cli.getInstance();
19
+ cli.execute(process.argv.slice(2));
20
+ }
21
+ catch (e) {
22
+ telemetry.trackException(e);
23
+ process.exit(1);
24
+ }
31
25
  //# sourceMappingURL=index.js.map
@@ -17,10 +17,12 @@ class FlowEnvironmentListCommand extends AzmgmtCommand {
17
17
  }
18
18
  try {
19
19
  const res = await odata.getAllItems(`${this.resource}providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01`);
20
- if (args.options.output !== 'json' && res.length > 0) {
21
- res.forEach(e => {
22
- e.displayName = e.properties.displayName;
23
- });
20
+ if (res.length > 0) {
21
+ if (args.options.output !== 'json') {
22
+ res.forEach(e => {
23
+ e.displayName = e.properties.displayName;
24
+ });
25
+ }
24
26
  await logger.log(res);
25
27
  }
26
28
  }
@@ -16,10 +16,10 @@ export const workflow = {
16
16
  uses: "actions/checkout@v3.5.3"
17
17
  },
18
18
  {
19
- name: "Use Node.js 16.x",
19
+ name: "Use Node.js",
20
20
  uses: "actions/setup-node@v3.7.0",
21
21
  with: {
22
- "node-version": "16.x"
22
+ "node-version": "18.x"
23
23
  }
24
24
  },
25
25
  {
@@ -32,7 +32,7 @@ export const workflow = {
32
32
  },
33
33
  {
34
34
  name: "CLI for Microsoft 365 Login",
35
- uses: "pnp/action-cli-login@v2.2.2",
35
+ uses: "pnp/action-cli-login@v2.2.4",
36
36
  with: {
37
37
  "CERTIFICATE_ENCODED": "${{ secrets.CERTIFICATE_ENCODED }}",
38
38
  "CERTIFICATE_PASSWORD": "${{ secrets.CERTIFICATE_PASSWORD }}",
@@ -41,7 +41,7 @@ export const workflow = {
41
41
  },
42
42
  {
43
43
  name: "CLI for Microsoft 365 Deploy App",
44
- uses: "pnp/action-cli-deploy@v3.0.1",
44
+ uses: "pnp/action-cli-deploy@v4.0.0",
45
45
  with: {
46
46
  "APP_FILE_PATH": "sharepoint/solution/{{ solutionName }}.sppkg",
47
47
  "SKIP_FEATURE_DEPLOYMENT": false,
@@ -18,4 +18,4 @@ export default [
18
18
  new FN002016_DEVDEP_types_react_dom('17'),
19
19
  new FN002019_DEVDEP_microsoft_rush_stack_compiler(['4.7'])
20
20
  ];
21
- //# sourceMappingURL=doctor-1.18.1-rc.0.js.map
21
+ //# sourceMappingURL=doctor-1.18.1.js.map
@@ -68,7 +68,7 @@ class SpfxProjectDoctorCommand extends BaseProjectCommand {
68
68
  '1.17.3',
69
69
  '1.17.4',
70
70
  '1.18.0',
71
- '1.18.1-rc.0'
71
+ '1.18.1'
72
72
  ];
73
73
  __classPrivateFieldGet(this, _SpfxProjectDoctorCommand_instances, "m", _SpfxProjectDoctorCommand_initTelemetry).call(this);
74
74
  __classPrivateFieldGet(this, _SpfxProjectDoctorCommand_instances, "m", _SpfxProjectDoctorCommand_initOptions).call(this);
@@ -63,6 +63,19 @@ class SpfxProjectGithubWorkflowAddCommand extends BaseProjectCommand {
63
63
  // eslint-disable-next-line camelcase
64
64
  workflow.on.workflow_dispatch = null;
65
65
  }
66
+ const version = this.getProjectVersion();
67
+ if (!version) {
68
+ throw `Unable to determine the version of the current SharePoint Framework project`;
69
+ }
70
+ const match = version.match(/^(\d+)\.(\d+)\.(\d+)$/);
71
+ const minorVersionString = match ? match[2] : null;
72
+ const minorVersion = minorVersionString ? Number(minorVersionString) : null;
73
+ if (minorVersion === null || isNaN(minorVersion)) {
74
+ throw `Unable to determine the minor version of the current SharePoint Framework project`;
75
+ }
76
+ if (minorVersion < 18) {
77
+ this.getNodeAction(workflow).with['node-version'] = '16.x';
78
+ }
66
79
  if (options.skipFeatureDeployment) {
67
80
  this.getDeployAction(workflow).with.SKIP_FEATURE_DEPLOYMENT = true;
68
81
  }
@@ -94,6 +107,10 @@ class SpfxProjectGithubWorkflowAddCommand extends BaseProjectCommand {
94
107
  const steps = this.getWorkFlowSteps(workflow);
95
108
  return steps.find(step => step.uses && step.uses.indexOf('action-cli-deploy') >= 0);
96
109
  }
110
+ getNodeAction(workflow) {
111
+ const steps = this.getWorkFlowSteps(workflow);
112
+ return steps.find(step => step.uses && step.uses.indexOf('actions/setup-node@') >= 0);
113
+ }
97
114
  getWorkFlowSteps(workflow) {
98
115
  return workflow.jobs['build-and-deploy'].steps;
99
116
  }
@@ -26,32 +26,32 @@ import { FN002023_DEVDEP_microsoft_eslint_config_spfx } from './rules/FN002023_D
26
26
  import { FN010001_YORC_version } from './rules/FN010001_YORC_version.js';
27
27
  import { FN014010_CODE_settings_filesexclude_jest } from './rules/FN014010_CODE_settings_filesexclude_jest.js';
28
28
  export default [
29
- new FN001001_DEP_microsoft_sp_core_library('1.18.1-rc.0'),
30
- new FN001002_DEP_microsoft_sp_lodash_subset('1.18.1-rc.0'),
31
- new FN001003_DEP_microsoft_sp_office_ui_fabric_core('1.18.1-rc.0'),
32
- new FN001004_DEP_microsoft_sp_webpart_base('1.18.1-rc.0'),
33
- new FN001011_DEP_microsoft_sp_dialog('1.18.1-rc.0'),
34
- new FN001012_DEP_microsoft_sp_application_base('1.18.1-rc.0'),
35
- new FN001014_DEP_microsoft_sp_listview_extensibility('1.18.1-rc.0'),
36
- new FN001021_DEP_microsoft_sp_property_pane('1.18.1-rc.0'),
29
+ new FN001001_DEP_microsoft_sp_core_library('1.18.1'),
30
+ new FN001002_DEP_microsoft_sp_lodash_subset('1.18.1'),
31
+ new FN001003_DEP_microsoft_sp_office_ui_fabric_core('1.18.1'),
32
+ new FN001004_DEP_microsoft_sp_webpart_base('1.18.1'),
33
+ new FN001011_DEP_microsoft_sp_dialog('1.18.1'),
34
+ new FN001012_DEP_microsoft_sp_application_base('1.18.1'),
35
+ new FN001014_DEP_microsoft_sp_listview_extensibility('1.18.1'),
36
+ new FN001021_DEP_microsoft_sp_property_pane('1.18.1'),
37
37
  new FN001022_DEP_office_ui_fabric_react('', false),
38
- new FN001023_DEP_microsoft_sp_component_base('1.18.1-rc.0'),
39
- new FN001024_DEP_microsoft_sp_diagnostics('1.18.1-rc.0'),
40
- new FN001025_DEP_microsoft_sp_dynamic_data('1.18.1-rc.0'),
41
- new FN001026_DEP_microsoft_sp_extension_base('1.18.1-rc.0'),
42
- new FN001027_DEP_microsoft_sp_http('1.18.1-rc.0'),
43
- new FN001028_DEP_microsoft_sp_list_subscription('1.18.1-rc.0'),
44
- new FN001029_DEP_microsoft_sp_loader('1.18.1-rc.0'),
45
- new FN001030_DEP_microsoft_sp_module_interfaces('1.18.1-rc.0'),
46
- new FN001031_DEP_microsoft_sp_odata_types('1.18.1-rc.0'),
47
- new FN001032_DEP_microsoft_sp_page_context('1.18.1-rc.0'),
48
- new FN001013_DEP_microsoft_decorators('1.18.1-rc.0'),
49
- new FN001034_DEP_microsoft_sp_adaptive_card_extension_base('1.18.1-rc.0'),
50
- new FN002001_DEVDEP_microsoft_sp_build_web('1.18.1-rc.0'),
51
- new FN002002_DEVDEP_microsoft_sp_module_interfaces('1.18.1-rc.0'),
52
- new FN002022_DEVDEP_microsoft_eslint_plugin_spfx('1.18.1-rc.0'),
53
- new FN002023_DEVDEP_microsoft_eslint_config_spfx('1.18.1-rc.0'),
54
- new FN010001_YORC_version('1.18.1-rc.0'),
38
+ new FN001023_DEP_microsoft_sp_component_base('1.18.1'),
39
+ new FN001024_DEP_microsoft_sp_diagnostics('1.18.1'),
40
+ new FN001025_DEP_microsoft_sp_dynamic_data('1.18.1'),
41
+ new FN001026_DEP_microsoft_sp_extension_base('1.18.1'),
42
+ new FN001027_DEP_microsoft_sp_http('1.18.1'),
43
+ new FN001028_DEP_microsoft_sp_list_subscription('1.18.1'),
44
+ new FN001029_DEP_microsoft_sp_loader('1.18.1'),
45
+ new FN001030_DEP_microsoft_sp_module_interfaces('1.18.1'),
46
+ new FN001031_DEP_microsoft_sp_odata_types('1.18.1'),
47
+ new FN001032_DEP_microsoft_sp_page_context('1.18.1'),
48
+ new FN001013_DEP_microsoft_decorators('1.18.1'),
49
+ new FN001034_DEP_microsoft_sp_adaptive_card_extension_base('1.18.1'),
50
+ new FN002001_DEVDEP_microsoft_sp_build_web('1.18.1'),
51
+ new FN002002_DEVDEP_microsoft_sp_module_interfaces('1.18.1'),
52
+ new FN002022_DEVDEP_microsoft_eslint_plugin_spfx('1.18.1'),
53
+ new FN002023_DEVDEP_microsoft_eslint_config_spfx('1.18.1'),
54
+ new FN010001_YORC_version('1.18.1'),
55
55
  new FN014010_CODE_settings_filesexclude_jest()
56
56
  ];
57
- //# sourceMappingURL=upgrade-1.18.1-rc.0.js.map
57
+ //# sourceMappingURL=upgrade-1.18.1.js.map
@@ -7,8 +7,6 @@ var _SpfxProjectUpgradeCommand_instances, _a, _SpfxProjectUpgradeCommand_initTel
7
7
  import fs from 'fs';
8
8
  import os from 'os';
9
9
  import path from 'path';
10
- // uncomment to support upgrading to preview releases
11
- import { prerelease } from 'semver';
12
10
  import { CommandError } from '../../../../Command.js';
13
11
  import { fsUtil } from '../../../../utils/fsUtil.js';
14
12
  import { packageManager } from '../../../../utils/packageManager.js';
@@ -72,7 +70,7 @@ class SpfxProjectUpgradeCommand extends BaseProjectCommand {
72
70
  '1.17.3',
73
71
  '1.17.4',
74
72
  '1.18.0',
75
- '1.18.1-rc.0'
73
+ '1.18.1'
76
74
  ];
77
75
  __classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initTelemetry).call(this);
78
76
  __classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initOptions).call(this);
@@ -85,15 +83,15 @@ class SpfxProjectUpgradeCommand extends BaseProjectCommand {
85
83
  }
86
84
  this.toVersion = args.options.toVersion ? args.options.toVersion : this.supportedVersions[this.supportedVersions.length - 1];
87
85
  // uncomment to support upgrading to preview releases
88
- if (!args.options.toVersion &&
89
- !args.options.preview &&
90
- prerelease(this.toVersion)) {
91
- // no version and no preview specified while the current version to
92
- // upgrade to is a prerelease so let's grab the first non-preview version
93
- // since we're supporting only one preview version, it's sufficient for
94
- // us to take second to last version
95
- this.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
96
- }
86
+ // if (!args.options.toVersion &&
87
+ // !args.options.preview &&
88
+ // prerelease(this.toVersion)) {
89
+ // // no version and no preview specified while the current version to
90
+ // // upgrade to is a prerelease so let's grab the first non-preview version
91
+ // // since we're supporting only one preview version, it's sufficient for
92
+ // // us to take second to last version
93
+ // this.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
94
+ // }
97
95
  this.packageManager = args.options.packageManager || 'npm';
98
96
  this.shell = args.options.shell || 'bash';
99
97
  if (this.supportedVersions.indexOf(this.toVersion) < 0) {
@@ -480,9 +478,9 @@ _a = SpfxProjectUpgradeCommand, _SpfxProjectUpgradeCommand_instances = new WeakS
480
478
  preview: args.options.preview
481
479
  });
482
480
  // uncomment to support upgrading to preview releases
483
- if (prerelease(this.telemetryProperties.toVersion) && !args.options.preview) {
484
- this.telemetryProperties.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
485
- }
481
+ // if (prerelease(this.telemetryProperties.toVersion) && !args.options.preview) {
482
+ // this.telemetryProperties.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
483
+ // }
486
484
  });
487
485
  }, _SpfxProjectUpgradeCommand_initOptions = function _SpfxProjectUpgradeCommand_initOptions() {
488
486
  this.options.unshift({
@@ -539,7 +539,7 @@ class SpfxDoctorCommand extends BaseProjectCommand {
539
539
  fix: 'npm i -g yo@4'
540
540
  }
541
541
  },
542
- '1.18.1-rc.0': {
542
+ '1.18.1': {
543
543
  gulpCli: {
544
544
  range: '^1 || ^2',
545
545
  fix: 'npm i -g gulp-cli@2'