@pnp/cli-microsoft365 7.3.0-beta.16c6462 → 7.3.0-beta.1c23854

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 (427) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Auth.js +4 -5
  4. package/dist/Command.js +10 -13
  5. package/dist/api.js +2 -3
  6. package/dist/autocomplete.js +4 -6
  7. package/dist/chili/chili.js +1 -2
  8. package/dist/cli/cli.js +880 -0
  9. package/dist/index.js +2 -2
  10. package/dist/m365/aad/commands/administrativeunit/administrativeunit-member-add.js +137 -0
  11. package/dist/m365/aad/commands/administrativeunit/administrativeunit-member-get.js +112 -0
  12. package/dist/m365/aad/commands/administrativeunit/administrativeunit-member-list.js +138 -0
  13. package/dist/m365/aad/commands/administrativeunit/administrativeunit-remove.js +2 -2
  14. package/dist/m365/aad/commands/app/app-get.js +2 -2
  15. package/dist/m365/aad/commands/app/app-permission-add.js +237 -0
  16. package/dist/m365/aad/commands/app/app-remove.js +3 -3
  17. package/dist/m365/aad/commands/app/app-role-add.js +2 -2
  18. package/dist/m365/aad/commands/app/app-role-list.js +2 -2
  19. package/dist/m365/aad/commands/app/app-role-remove.js +4 -4
  20. package/dist/m365/aad/commands/app/app-set.js +2 -2
  21. package/dist/m365/aad/commands/approleassignment/approleassignment-add.js +2 -2
  22. package/dist/m365/aad/commands/approleassignment/approleassignment-remove.js +2 -2
  23. package/dist/m365/aad/commands/group/group-list.js +71 -3
  24. package/dist/m365/aad/commands/group/group-remove.js +2 -2
  25. package/dist/m365/aad/commands/groupsetting/groupsetting-remove.js +2 -2
  26. package/dist/m365/aad/commands/m365group/m365group-recyclebinitem-clear.js +2 -2
  27. package/dist/m365/aad/commands/m365group/m365group-recyclebinitem-remove.js +3 -3
  28. package/dist/m365/aad/commands/m365group/m365group-recyclebinitem-restore.js +2 -2
  29. package/dist/m365/aad/commands/m365group/m365group-remove.js +2 -2
  30. package/dist/m365/aad/commands/m365group/m365group-teamify.js +2 -2
  31. package/dist/m365/aad/commands/m365group/m365group-user-remove.js +2 -2
  32. package/dist/m365/aad/commands/oauth2grant/oauth2grant-remove.js +2 -2
  33. package/dist/m365/aad/commands/siteclassification/siteclassification-disable.js +2 -2
  34. package/dist/m365/aad/commands/sp/sp-add.js +2 -2
  35. package/dist/m365/aad/commands/sp/sp-get.js +2 -2
  36. package/dist/m365/aad/commands/user/user-get.js +2 -2
  37. package/dist/m365/aad/commands/user/user-license-remove.js +2 -2
  38. package/dist/m365/aad/commands/user/user-recyclebinitem-clear.js +2 -2
  39. package/dist/m365/aad/commands/user/user-recyclebinitem-remove.js +2 -2
  40. package/dist/m365/aad/commands/user/user-remove.js +2 -2
  41. package/dist/m365/aad/commands.js +5 -1
  42. package/dist/m365/app/commands/app-get.js +2 -2
  43. package/dist/m365/app/commands/app-open.js +2 -2
  44. package/dist/m365/app/commands/permission/permission-list.js +2 -2
  45. package/dist/m365/base/AppCommand.js +2 -2
  46. package/dist/m365/booking/commands/business/business-get.js +2 -2
  47. package/dist/m365/cli/commands/cli-doctor.js +2 -2
  48. package/dist/m365/cli/commands/cli-reconsent.js +2 -2
  49. package/dist/m365/cli/commands/config/config-get.js +2 -2
  50. package/dist/m365/cli/commands/config/config-list.js +2 -2
  51. package/dist/m365/cli/commands/config/config-reset.js +3 -3
  52. package/dist/m365/cli/commands/config/config-set.js +4 -4
  53. package/dist/m365/commands/docs.js +2 -2
  54. package/dist/m365/commands/login.js +4 -4
  55. package/dist/m365/commands/setup.js +8 -8
  56. package/dist/m365/context/commands/context-remove.js +2 -2
  57. package/dist/m365/context/commands/option/option-remove.js +2 -2
  58. package/dist/m365/external/commands/connection/connection-doctor.js +1 -2
  59. package/dist/m365/external/commands/connection/connection-remove.js +3 -3
  60. package/dist/m365/flow/commands/flow-remove.js +2 -2
  61. package/dist/m365/flow/commands/owner/owner-list.js +2 -2
  62. package/dist/m365/flow/commands/owner/owner-remove.js +2 -2
  63. package/dist/m365/flow/commands/run/run-cancel.js +2 -2
  64. package/dist/m365/flow/commands/run/run-resubmit.js +2 -2
  65. package/dist/m365/graph/commands/changelog/changelog-list.js +3 -3
  66. package/dist/m365/graph/commands/schemaextension/schemaextension-remove.js +2 -2
  67. package/dist/m365/outlook/commands/message/message-list.js +2 -2
  68. package/dist/m365/outlook/commands/message/message-move.js +2 -2
  69. package/dist/m365/pa/commands/app/app-consent-set.js +2 -2
  70. package/dist/m365/pa/commands/app/app-get.js +2 -2
  71. package/dist/m365/pa/commands/app/app-permission-remove.js +2 -2
  72. package/dist/m365/pa/commands/app/app-remove.js +2 -2
  73. package/dist/m365/planner/commands/bucket/bucket-get.js +2 -2
  74. package/dist/m365/planner/commands/bucket/bucket-remove.js +3 -3
  75. package/dist/m365/planner/commands/bucket/bucket-set.js +2 -2
  76. package/dist/m365/planner/commands/plan/plan-remove.js +2 -2
  77. package/dist/m365/planner/commands/roster/roster-member-remove.js +3 -3
  78. package/dist/m365/planner/commands/roster/roster-remove.js +2 -2
  79. package/dist/m365/planner/commands/task/task-checklistitem-add.js +2 -2
  80. package/dist/m365/planner/commands/task/task-checklistitem-list.js +2 -2
  81. package/dist/m365/planner/commands/task/task-checklistitem-remove.js +2 -2
  82. package/dist/m365/planner/commands/task/task-get.js +3 -3
  83. package/dist/m365/planner/commands/task/task-reference-remove.js +2 -2
  84. package/dist/m365/planner/commands/task/task-remove.js +4 -4
  85. package/dist/m365/pp/commands/aibuildermodel/aibuildermodel-get.js +2 -2
  86. package/dist/m365/pp/commands/aibuildermodel/aibuildermodel-remove.js +3 -3
  87. package/dist/m365/pp/commands/card/card-clone.js +2 -2
  88. package/dist/m365/pp/commands/card/card-get.js +2 -2
  89. package/dist/m365/pp/commands/card/card-remove.js +3 -3
  90. package/dist/m365/pp/commands/chatbot/chatbot-get.js +2 -2
  91. package/dist/m365/pp/commands/chatbot/chatbot-remove.js +3 -3
  92. package/dist/m365/pp/commands/dataverse/dataverse-table-remove.js +2 -2
  93. package/dist/m365/pp/commands/dataverse/dataverse-table-row-remove.js +2 -2
  94. package/dist/m365/pp/commands/managementapp/managementapp-add.js +2 -2
  95. package/dist/m365/pp/commands/solution/solution-get.js +2 -2
  96. package/dist/m365/pp/commands/solution/solution-list.js +2 -2
  97. package/dist/m365/pp/commands/solution/solution-publish.js +2 -2
  98. package/dist/m365/pp/commands/solution/solution-publisher-remove.js +3 -3
  99. package/dist/m365/pp/commands/solution/solution-remove.js +3 -3
  100. package/dist/m365/purview/commands/retentionevent/retentionevent-remove.js +2 -2
  101. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-remove.js +2 -2
  102. package/dist/m365/purview/commands/retentionlabel/retentionlabel-remove.js +2 -2
  103. package/dist/m365/spfx/commands/project/project-permissions-grant.js +2 -2
  104. package/dist/m365/spo/commands/app/app-add.js +2 -2
  105. package/dist/m365/spo/commands/app/app-remove.js +2 -2
  106. package/dist/m365/spo/commands/app/app-retract.js +2 -2
  107. package/dist/m365/spo/commands/app/app-uninstall.js +2 -2
  108. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +2 -2
  109. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-remove.js +3 -3
  110. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-set.js +2 -2
  111. package/dist/m365/spo/commands/cdn/cdn-origin-remove.js +2 -2
  112. package/dist/m365/spo/commands/commandset/commandset-get.js +2 -2
  113. package/dist/m365/spo/commands/commandset/commandset-remove.js +3 -3
  114. package/dist/m365/spo/commands/commandset/commandset-set.js +2 -2
  115. package/dist/m365/spo/commands/contenttype/contenttype-add.js +2 -2
  116. package/dist/m365/spo/commands/contenttype/contenttype-field-remove.js +2 -2
  117. package/dist/m365/spo/commands/contenttype/contenttype-remove.js +2 -2
  118. package/dist/m365/spo/commands/customaction/customaction-add.js +1 -1
  119. package/dist/m365/spo/commands/customaction/customaction-clear.js +2 -2
  120. package/dist/m365/spo/commands/customaction/customaction-get.js +3 -3
  121. package/dist/m365/spo/commands/customaction/customaction-remove.js +3 -3
  122. package/dist/m365/spo/commands/eventreceiver/eventreceiver-get.js +2 -2
  123. package/dist/m365/spo/commands/eventreceiver/eventreceiver-remove.js +3 -3
  124. package/dist/m365/spo/commands/field/field-remove.js +2 -2
  125. package/dist/m365/spo/commands/file/file-add.js +1 -1
  126. package/dist/m365/spo/commands/file/file-checkout-undo.js +2 -2
  127. package/dist/m365/spo/commands/file/file-remove.js +2 -2
  128. package/dist/m365/spo/commands/file/file-rename.js +2 -2
  129. package/dist/m365/spo/commands/file/file-retentionlabel-remove.js +2 -2
  130. package/dist/m365/spo/commands/file/file-roleassignment-add.js +5 -5
  131. package/dist/m365/spo/commands/file/file-roleassignment-remove.js +5 -5
  132. package/dist/m365/spo/commands/file/file-roleinheritance-break.js +3 -3
  133. package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +3 -3
  134. package/dist/m365/spo/commands/file/file-sharinginfo-get.js +2 -2
  135. package/dist/m365/spo/commands/file/file-sharinglink-clear.js +3 -3
  136. package/dist/m365/spo/commands/file/file-sharinglink-list.js +2 -2
  137. package/dist/m365/spo/commands/file/file-sharinglink-remove.js +2 -2
  138. package/dist/m365/spo/commands/file/file-version-clear.js +2 -2
  139. package/dist/m365/spo/commands/file/file-version-remove.js +2 -2
  140. package/dist/m365/spo/commands/file/file-version-restore.js +2 -2
  141. package/dist/m365/spo/commands/folder/folder-remove.js +2 -2
  142. package/dist/m365/spo/commands/folder/folder-retentionlabel-remove.js +2 -2
  143. package/dist/m365/spo/commands/folder/folder-roleassignment-add.js +4 -4
  144. package/dist/m365/spo/commands/folder/folder-roleassignment-remove.js +4 -4
  145. package/dist/m365/spo/commands/folder/folder-roleinheritance-break.js +2 -2
  146. package/dist/m365/spo/commands/folder/folder-roleinheritance-reset.js +2 -2
  147. package/dist/m365/spo/commands/group/group-list.js +2 -2
  148. package/dist/m365/spo/commands/group/group-member-remove.js +9 -9
  149. package/dist/m365/spo/commands/group/group-remove.js +2 -2
  150. package/dist/m365/spo/commands/group/group-set.js +2 -2
  151. package/dist/m365/spo/commands/homesite/homesite-remove.js +2 -2
  152. package/dist/m365/spo/commands/hubsite/hubsite-connect.js +2 -2
  153. package/dist/m365/spo/commands/hubsite/hubsite-disconnect.js +3 -3
  154. package/dist/m365/spo/commands/hubsite/hubsite-get.js +4 -4
  155. package/dist/m365/spo/commands/hubsite/hubsite-rights-revoke.js +2 -2
  156. package/dist/m365/spo/commands/hubsite/hubsite-unregister.js +2 -2
  157. package/dist/m365/spo/commands/knowledgehub/knowledgehub-remove.js +2 -2
  158. package/dist/m365/spo/commands/list/list-contenttype-remove.js +2 -2
  159. package/dist/m365/spo/commands/list/list-remove.js +2 -2
  160. package/dist/m365/spo/commands/list/list-retentionlabel-remove.js +2 -2
  161. package/dist/m365/spo/commands/list/list-roleassignment-remove.js +4 -4
  162. package/dist/m365/spo/commands/list/list-roleinheritance-break.js +2 -2
  163. package/dist/m365/spo/commands/list/list-roleinheritance-reset.js +2 -2
  164. package/dist/m365/spo/commands/list/list-view-field-remove.js +2 -2
  165. package/dist/m365/spo/commands/list/list-view-remove.js +2 -2
  166. package/dist/m365/spo/commands/list/list-webhook-remove.js +2 -2
  167. package/dist/m365/spo/commands/listitem/listitem-attachment-remove.js +2 -2
  168. package/dist/m365/spo/commands/listitem/listitem-list.js +2 -2
  169. package/dist/m365/spo/commands/listitem/listitem-remove.js +2 -2
  170. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-remove.js +2 -2
  171. package/dist/m365/spo/commands/listitem/listitem-roleassignment-add.js +4 -4
  172. package/dist/m365/spo/commands/listitem/listitem-roleassignment-remove.js +4 -4
  173. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-break.js +2 -2
  174. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-reset.js +2 -2
  175. package/dist/m365/spo/commands/navigation/navigation-node-remove.js +2 -2
  176. package/dist/m365/spo/commands/orgassetslibrary/orgassetslibrary-remove.js +2 -2
  177. package/dist/m365/spo/commands/orgnewssite/orgnewssite-remove.js +2 -2
  178. package/dist/m365/spo/commands/page/page-add.js +4 -4
  179. package/dist/m365/spo/commands/page/page-column-get.js +2 -2
  180. package/dist/m365/spo/commands/page/page-column-list.js +2 -2
  181. package/dist/m365/spo/commands/page/page-remove.js +2 -2
  182. package/dist/m365/spo/commands/page/page-section-get.js +2 -2
  183. package/dist/m365/spo/commands/page/page-section-list.js +2 -2
  184. package/dist/m365/spo/commands/page/page-set.js +5 -5
  185. package/dist/m365/spo/commands/propertybag/propertybag-remove.js +2 -2
  186. package/dist/m365/spo/commands/roledefinition/roledefinition-remove.js +2 -2
  187. package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-permissionrequest-approve.js +2 -2
  188. package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-set.js +2 -2
  189. package/dist/m365/spo/commands/site/site-apppermission-remove.js +2 -2
  190. package/dist/m365/spo/commands/site/site-hubsite-disconnect.js +2 -2
  191. package/dist/m365/spo/commands/site/site-recyclebinitem-clear.js +2 -2
  192. package/dist/m365/spo/commands/site/site-recyclebinitem-move.js +2 -2
  193. package/dist/m365/spo/commands/site/site-recyclebinitem-remove.js +2 -2
  194. package/dist/m365/spo/commands/site/site-remove.js +2 -2
  195. package/dist/m365/spo/commands/site/site-set.js +3 -3
  196. package/dist/m365/spo/commands/sitedesign/sitedesign-get.js +2 -2
  197. package/dist/m365/spo/commands/sitedesign/sitedesign-remove.js +2 -2
  198. package/dist/m365/spo/commands/sitedesign/sitedesign-rights-revoke.js +2 -2
  199. package/dist/m365/spo/commands/sitedesign/sitedesign-task-remove.js +2 -2
  200. package/dist/m365/spo/commands/sitescript/sitescript-remove.js +2 -2
  201. package/dist/m365/spo/commands/spo-search.js +2 -2
  202. package/dist/m365/spo/commands/storageentity/storageentity-remove.js +2 -2
  203. package/dist/m365/spo/commands/tenant/tenant-appcatalog-add.js +5 -5
  204. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-add.js +5 -5
  205. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +2 -2
  206. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-remove.js +3 -3
  207. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-set.js +4 -4
  208. package/dist/m365/spo/commands/tenant/tenant-commandset-add.js +5 -5
  209. package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +2 -2
  210. package/dist/m365/spo/commands/tenant/tenant-commandset-remove.js +3 -3
  211. package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-remove.js +2 -2
  212. package/dist/m365/spo/commands/term/term-get.js +2 -2
  213. package/dist/m365/spo/commands/term/term-list.js +2 -2
  214. package/dist/m365/spo/commands/theme/theme-remove.js +2 -2
  215. package/dist/m365/spo/commands/user/user-remove.js +2 -2
  216. package/dist/m365/spo/commands/userprofile/userprofile-get.js +2 -2
  217. package/dist/m365/spo/commands/web/web-remove.js +2 -2
  218. package/dist/m365/spo/commands/web/web-roleassignment-add.js +4 -4
  219. package/dist/m365/spo/commands/web/web-roleassignment-remove.js +4 -4
  220. package/dist/m365/spo/commands/web/web-roleinheritance-break.js +2 -2
  221. package/dist/m365/spo/commands/web/web-roleinheritance-reset.js +2 -2
  222. package/dist/m365/teams/commands/app/app-install.js +32 -5
  223. package/dist/m365/teams/commands/app/app-remove.js +3 -3
  224. package/dist/m365/teams/commands/app/app-uninstall.js +2 -2
  225. package/dist/m365/teams/commands/app/app-update.js +2 -2
  226. package/dist/m365/teams/commands/cache/cache-remove.js +2 -2
  227. package/dist/m365/teams/commands/channel/channel-add.js +2 -2
  228. package/dist/m365/teams/commands/channel/channel-member-add.js +2 -2
  229. package/dist/m365/teams/commands/channel/channel-member-remove.js +3 -3
  230. package/dist/m365/teams/commands/channel/channel-member-set.js +2 -2
  231. package/dist/m365/teams/commands/channel/channel-remove.js +2 -2
  232. package/dist/m365/teams/commands/chat/chat-get.js +3 -3
  233. package/dist/m365/teams/commands/chat/chat-member-remove.js +2 -2
  234. package/dist/m365/teams/commands/chat/chat-message-send.js +3 -3
  235. package/dist/m365/teams/commands/meeting/meeting-add.js +151 -0
  236. package/dist/m365/teams/commands/meeting/meeting-attendancereport-list.js +2 -2
  237. package/dist/m365/teams/commands/tab/tab-remove.js +2 -2
  238. package/dist/m365/teams/commands/team/team-app-list.js +3 -3
  239. package/dist/m365/teams/commands/team/team-remove.js +2 -2
  240. package/dist/m365/teams/commands/user/user-app-add.js +23 -5
  241. package/dist/m365/teams/commands/user/user-app-list.js +2 -2
  242. package/dist/m365/teams/commands/user/user-app-remove.js +3 -3
  243. package/dist/m365/teams/commands.js +2 -1
  244. package/dist/m365/tenant/commands/people/people-profilecardproperty-remove.js +2 -2
  245. package/dist/m365/todo/commands/list/list-remove.js +2 -2
  246. package/dist/m365/todo/commands/task/task-get.js +2 -2
  247. package/dist/m365/todo/commands/task/task-list.js +2 -2
  248. package/dist/m365/todo/commands/task/task-remove.js +2 -2
  249. package/dist/m365/viva/commands/connections/connections-app-create.js +2 -2
  250. package/dist/m365/yammer/commands/group/group-user-remove.js +2 -2
  251. package/dist/m365/yammer/commands/message/message-like-set.js +2 -2
  252. package/dist/m365/yammer/commands/message/message-remove.js +2 -2
  253. package/dist/m365/yammer/commands/yammer-search.js +2 -2
  254. package/dist/telemetry.js +2 -2
  255. package/dist/utils/aadAdministrativeUnit.js +5 -5
  256. package/dist/utils/aadDevice.js +25 -0
  257. package/dist/utils/aadGroup.js +3 -3
  258. package/dist/utils/prompt.js +4 -7
  259. package/dist/utils/validation.js +5 -2
  260. package/docs/docs/cmd/aad/administrativeunit/administrativeunit-member-add.mdx +93 -0
  261. package/docs/docs/cmd/aad/administrativeunit/administrativeunit-member-get.mdx +130 -0
  262. package/docs/docs/cmd/aad/administrativeunit/administrativeunit-member-list.mdx +312 -0
  263. package/docs/docs/cmd/aad/app/app-permission-add.mdx +62 -0
  264. package/docs/docs/cmd/aad/group/group-list.mdx +11 -0
  265. package/docs/docs/cmd/aad/user/user-password-validate.mdx +2 -2
  266. package/docs/docs/cmd/adaptivecard/adaptivecard-send.mdx +1 -1
  267. package/docs/docs/cmd/external/connection/connection-doctor.mdx +3 -0
  268. package/docs/docs/cmd/flow/environment/environment-get.mdx +1 -1
  269. package/docs/docs/cmd/flow/environment/environment-list.mdx +1 -1
  270. package/docs/docs/cmd/flow/flow-disable.mdx +1 -1
  271. package/docs/docs/cmd/flow/flow-enable.mdx +1 -1
  272. package/docs/docs/cmd/flow/flow-export.mdx +1 -1
  273. package/docs/docs/cmd/flow/flow-get.mdx +1 -1
  274. package/docs/docs/cmd/flow/flow-list.mdx +1 -1
  275. package/docs/docs/cmd/flow/run/run-cancel.mdx +1 -1
  276. package/docs/docs/cmd/flow/run/run-get.mdx +1 -1
  277. package/docs/docs/cmd/flow/run/run-list.mdx +1 -1
  278. package/docs/docs/cmd/flow/run/run-resubmit.mdx +1 -1
  279. package/docs/docs/cmd/graph/changelog/changelog-list.mdx +1 -1
  280. package/docs/docs/cmd/graph/schemaextension/schemaextension-add.mdx +1 -1
  281. package/docs/docs/cmd/graph/schemaextension/schemaextension-set.mdx +1 -1
  282. package/docs/docs/cmd/onedrive/report/report-activityfilecounts.mdx +0 -3
  283. package/docs/docs/cmd/onedrive/report/report-activityusercounts.mdx +0 -3
  284. package/docs/docs/cmd/onedrive/report/report-activityuserdetail.mdx +0 -3
  285. package/docs/docs/cmd/onedrive/report/report-usageaccountcounts.mdx +0 -3
  286. package/docs/docs/cmd/onedrive/report/report-usageaccountdetail.mdx +0 -3
  287. package/docs/docs/cmd/onedrive/report/report-usagefilecounts.mdx +0 -3
  288. package/docs/docs/cmd/onedrive/report/report-usagestorage.mdx +0 -3
  289. package/docs/docs/cmd/outlook/report/report-mailactivitycounts.mdx +0 -3
  290. package/docs/docs/cmd/outlook/report/report-mailactivityusercounts.mdx +0 -3
  291. package/docs/docs/cmd/outlook/report/report-mailactivityuserdetail.mdx +0 -3
  292. package/docs/docs/cmd/outlook/report/report-mailappusageappsusercounts.mdx +0 -3
  293. package/docs/docs/cmd/outlook/report/report-mailappusageusercounts.mdx +0 -3
  294. package/docs/docs/cmd/outlook/report/report-mailappusageuserdetail.mdx +0 -3
  295. package/docs/docs/cmd/outlook/report/report-mailappusageversionsusercounts.mdx +0 -3
  296. package/docs/docs/cmd/outlook/report/report-mailboxusagedetail.mdx +0 -3
  297. package/docs/docs/cmd/outlook/report/report-mailboxusagemailboxcount.mdx +0 -3
  298. package/docs/docs/cmd/outlook/report/report-mailboxusagequotastatusmailboxcounts.mdx +0 -3
  299. package/docs/docs/cmd/outlook/report/report-mailboxusagestorage.mdx +0 -3
  300. package/docs/docs/cmd/pa/app/app-get.mdx +1 -1
  301. package/docs/docs/cmd/pa/app/app-list.mdx +1 -1
  302. package/docs/docs/cmd/pa/connector/connector-export.mdx +1 -1
  303. package/docs/docs/cmd/pa/connector/connector-list.mdx +1 -1
  304. package/docs/docs/cmd/pa/environment/environment-get.mdx +1 -1
  305. package/docs/docs/cmd/pa/environment/environment-list.mdx +1 -1
  306. package/docs/docs/cmd/planner/bucket/bucket-add.mdx +1 -1
  307. package/docs/docs/cmd/planner/bucket/bucket-get.mdx +1 -1
  308. package/docs/docs/cmd/planner/bucket/bucket-list.mdx +1 -1
  309. package/docs/docs/cmd/planner/bucket/bucket-remove.mdx +1 -1
  310. package/docs/docs/cmd/planner/bucket/bucket-set.mdx +1 -1
  311. package/docs/docs/cmd/planner/plan/plan-get.mdx +1 -1
  312. package/docs/docs/cmd/planner/plan/plan-list.mdx +1 -1
  313. package/docs/docs/cmd/planner/plan/plan-set.mdx +1 -1
  314. package/docs/docs/cmd/planner/roster/roster-add.mdx +2 -2
  315. package/docs/docs/cmd/planner/roster/roster-get.mdx +1 -1
  316. package/docs/docs/cmd/planner/roster/roster-member-add.mdx +1 -1
  317. package/docs/docs/cmd/planner/roster/roster-member-get.mdx +1 -1
  318. package/docs/docs/cmd/planner/roster/roster-member-list.mdx +1 -1
  319. package/docs/docs/cmd/planner/roster/roster-member-remove.mdx +2 -2
  320. package/docs/docs/cmd/planner/roster/roster-plan-list.mdx +1 -1
  321. package/docs/docs/cmd/planner/roster/roster-remove.mdx +2 -2
  322. package/docs/docs/cmd/planner/task/task-add.mdx +1 -1
  323. package/docs/docs/cmd/planner/task/task-list.mdx +2 -2
  324. package/docs/docs/cmd/planner/task/task-remove.mdx +1 -1
  325. package/docs/docs/cmd/planner/task/task-set.mdx +1 -1
  326. package/docs/docs/cmd/pp/environment/environment-get.mdx +1 -1
  327. package/docs/docs/cmd/pp/environment/environment-list.mdx +1 -1
  328. package/docs/docs/cmd/pp/tenant/tenant-settings-list.mdx +1 -1
  329. package/docs/docs/cmd/pp/tenant/tenant-settings-set.mdx +1 -1
  330. package/docs/docs/cmd/purview/retentionevent/retentionevent-add.mdx +1 -1
  331. package/docs/docs/cmd/purview/retentionevent/retentionevent-get.mdx +1 -1
  332. package/docs/docs/cmd/purview/retentionevent/retentionevent-list.mdx +1 -1
  333. package/docs/docs/cmd/purview/retentionevent/retentionevent-remove.mdx +1 -1
  334. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.mdx +1 -1
  335. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-get.mdx +1 -1
  336. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-list.mdx +1 -1
  337. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-remove.mdx +1 -1
  338. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-set.mdx +1 -1
  339. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.mdx +1 -1
  340. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-get.mdx +1 -1
  341. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-list.mdx +1 -1
  342. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-remove.mdx +1 -1
  343. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-set.mdx +1 -1
  344. package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-get.mdx +2 -2
  345. package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-list.mdx +2 -2
  346. package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-policysettings-list.mdx +2 -2
  347. package/docs/docs/cmd/skype/report/report-activitycounts.mdx +0 -2
  348. package/docs/docs/cmd/skype/report/report-activityusercounts.mdx +0 -3
  349. package/docs/docs/cmd/skype/report/report-activityuserdetail.mdx +0 -3
  350. package/docs/docs/cmd/spfx/project/project-externalize.mdx +1 -1
  351. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.mdx +1 -1
  352. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-set.mdx +1 -1
  353. package/docs/docs/cmd/spo/commandset/commandset-add.mdx +1 -1
  354. package/docs/docs/cmd/spo/commandset/commandset-set.mdx +1 -1
  355. package/docs/docs/cmd/spo/contenttype/contenttype-set.mdx +1 -1
  356. package/docs/docs/cmd/spo/customaction/customaction-add.mdx +1 -1
  357. package/docs/docs/cmd/spo/customaction/customaction-set.mdx +1 -1
  358. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-remove.mdx +1 -1
  359. package/docs/docs/cmd/spo/field/field-set.mdx +1 -1
  360. package/docs/docs/cmd/spo/list/list-sensitivitylabel-ensure.mdx +1 -1
  361. package/docs/docs/cmd/spo/list/list-view-set.mdx +1 -1
  362. package/docs/docs/cmd/spo/listitem/listitem-add.mdx +1 -1
  363. package/docs/docs/cmd/spo/listitem/listitem-batch-add.mdx +1 -1
  364. package/docs/docs/cmd/spo/listitem/listitem-set.mdx +1 -1
  365. package/docs/docs/cmd/spo/page/page-clientsidewebpart-add.mdx +1 -1
  366. package/docs/docs/cmd/spo/page/page-control-set.mdx +1 -1
  367. package/docs/docs/cmd/spo/page/page-set.mdx +1 -1
  368. package/docs/docs/cmd/spo/report/report-activityfilecounts.mdx +0 -3
  369. package/docs/docs/cmd/spo/report/report-activitypages.mdx +0 -3
  370. package/docs/docs/cmd/spo/report/report-activityusercounts.mdx +0 -3
  371. package/docs/docs/cmd/spo/report/report-activityuserdetail.mdx +0 -3
  372. package/docs/docs/cmd/spo/report/report-siteusagedetail.mdx +0 -3
  373. package/docs/docs/cmd/spo/report/report-siteusagefilecounts.mdx +0 -3
  374. package/docs/docs/cmd/spo/report/report-siteusagepages.mdx +0 -3
  375. package/docs/docs/cmd/spo/report/report-siteusagesitecounts.mdx +0 -3
  376. package/docs/docs/cmd/spo/report/report-siteusagestorage.mdx +0 -3
  377. package/docs/docs/cmd/spo/site/site-groupify.mdx +1 -1
  378. package/docs/docs/cmd/spo/site/site-recyclebinitem-clear.mdx +1 -1
  379. package/docs/docs/cmd/spo/site/site-recyclebinitem-remove.mdx +1 -1
  380. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.mdx +1 -1
  381. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-set.mdx +1 -1
  382. package/docs/docs/cmd/spo/tenant/tenant-commandset-add.mdx +1 -1
  383. package/docs/docs/cmd/spo/tenant/tenant-commandset-set.mdx +1 -1
  384. package/docs/docs/cmd/spo/term/term-add.mdx +1 -1
  385. package/docs/docs/cmd/spo/term/term-group-add.mdx +1 -1
  386. package/docs/docs/cmd/spo/term/term-set-add.mdx +1 -1
  387. package/docs/docs/cmd/teams/app/app-install.mdx +11 -2
  388. package/docs/docs/cmd/teams/meeting/meeting-add.mdx +283 -0
  389. package/docs/docs/cmd/teams/meeting/meeting-transcript-list.mdx +2 -2
  390. package/docs/docs/cmd/teams/report/report-deviceusagedistributionusercounts.mdx +0 -3
  391. package/docs/docs/cmd/teams/report/report-deviceusageusercounts.mdx +0 -3
  392. package/docs/docs/cmd/teams/report/report-deviceusageuserdetail.mdx +0 -3
  393. package/docs/docs/cmd/teams/report/report-useractivitycounts.mdx +0 -3
  394. package/docs/docs/cmd/teams/report/report-useractivityusercounts.mdx +0 -3
  395. package/docs/docs/cmd/teams/report/report-useractivityuserdetail.mdx +0 -3
  396. package/docs/docs/cmd/teams/user/user-app-add.mdx +12 -3
  397. package/docs/docs/cmd/teams/user/user-app-remove.mdx +2 -2
  398. package/docs/docs/cmd/tenant/people/people-profilecardproperty-add.mdx +1 -1
  399. package/docs/docs/cmd/tenant/people/people-profilecardproperty-remove.mdx +1 -1
  400. package/docs/docs/cmd/tenant/people/people-profilecardproperty-set.mdx +1 -1
  401. package/docs/docs/cmd/tenant/report/report-activeusercounts.mdx +0 -3
  402. package/docs/docs/cmd/tenant/report/report-activeuserdetail.mdx +0 -3
  403. package/docs/docs/cmd/tenant/report/report-servicesusercounts.mdx +0 -3
  404. package/docs/docs/cmd/yammer/group/group-list.mdx +1 -1
  405. package/docs/docs/cmd/yammer/group/group-user-add.mdx +1 -1
  406. package/docs/docs/cmd/yammer/group/group-user-remove.mdx +1 -1
  407. package/docs/docs/cmd/yammer/message/message-add.mdx +1 -1
  408. package/docs/docs/cmd/yammer/message/message-get.mdx +1 -1
  409. package/docs/docs/cmd/yammer/message/message-like-set.mdx +1 -1
  410. package/docs/docs/cmd/yammer/message/message-list.mdx +1 -1
  411. package/docs/docs/cmd/yammer/message/message-remove.mdx +1 -1
  412. package/docs/docs/cmd/yammer/network/network-list.mdx +1 -1
  413. package/docs/docs/cmd/yammer/report/report-activitycounts.mdx +0 -3
  414. package/docs/docs/cmd/yammer/report/report-activityusercounts.mdx +0 -3
  415. package/docs/docs/cmd/yammer/report/report-activityuserdetail.mdx +0 -3
  416. package/docs/docs/cmd/yammer/report/report-deviceusagedistributionusercounts.mdx +0 -3
  417. package/docs/docs/cmd/yammer/report/report-deviceusageusercounts.mdx +0 -3
  418. package/docs/docs/cmd/yammer/report/report-deviceusageuserdetail.mdx +0 -3
  419. package/docs/docs/cmd/yammer/report/report-groupsactivitycounts.mdx +0 -3
  420. package/docs/docs/cmd/yammer/report/report-groupsactivitydetail.mdx +0 -3
  421. package/docs/docs/cmd/yammer/report/report-groupsactivitygroupcounts.mdx +0 -3
  422. package/docs/docs/cmd/yammer/user/user-get.mdx +1 -1
  423. package/docs/docs/cmd/yammer/user/user-list.mdx +1 -1
  424. package/docs/docs/cmd/yammer/yammer-search.mdx +1 -1
  425. package/npm-shrinkwrap.json +1008 -406
  426. package/package.json +25 -24
  427. package/dist/cli/Cli.js +0 -857
package/dist/cli/Cli.js DELETED
@@ -1,857 +0,0 @@
1
- import Configstore from 'configstore';
2
- import fs from 'fs';
3
- import minimist from 'minimist';
4
- import { createRequire } from 'module';
5
- import ora from 'ora';
6
- import os from 'os';
7
- import path from 'path';
8
- import { fileURLToPath, pathToFileURL } from 'url';
9
- import Command, { CommandError } from '../Command.js';
10
- import config from '../config.js';
11
- import request from '../request.js';
12
- import { settingsNames } from '../settingsNames.js';
13
- import { telemetry } from '../telemetry.js';
14
- import { app } from '../utils/app.js';
15
- import { formatting } from '../utils/formatting.js';
16
- import { md } from '../utils/md.js';
17
- import { validation } from '../utils/validation.js';
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));
22
- export class Cli {
23
- get config() {
24
- if (!this._config) {
25
- this._config = new Configstore(config.configstoreName);
26
- }
27
- return this._config;
28
- }
29
- getSettingWithDefaultValue(settingName, defaultValue) {
30
- const configuredValue = this.config.get(settingName);
31
- if (typeof configuredValue === 'undefined') {
32
- return defaultValue;
33
- }
34
- else {
35
- return configuredValue;
36
- }
37
- }
38
- constructor() {
39
- this.commands = [];
40
- const options = {
41
- text: 'Running command...',
42
- /* c8 ignore next 1 */
43
- stream: this.getSettingWithDefaultValue('errorOutput', 'stderr') === 'stderr' ? process.stderr : process.stdout
44
- };
45
- this.spinner = ora(options);
46
- }
47
- static getInstance() {
48
- if (!Cli.instance) {
49
- Cli.instance = new Cli();
50
- }
51
- return Cli.instance;
52
- }
53
- async execute(rawArgs) {
54
- const start = process.hrtime.bigint();
55
- // for completion commands we also need information about commands' options
56
- const loadAllCommandInfo = rawArgs.indexOf('completion') > -1;
57
- this.loadAllCommandsInfo(loadAllCommandInfo);
58
- // check if help for a specific command has been requested using the
59
- // 'm365 help xyz' format. If so, remove 'help' from the array of words
60
- // to use lazy loading commands but keep track of the fact that help should
61
- // be displayed
62
- let showHelp = false;
63
- if (rawArgs.length > 0 && rawArgs[0] === 'help') {
64
- showHelp = true;
65
- rawArgs.shift();
66
- }
67
- // parse args to see if a command has been specified
68
- const parsedArgs = minimist(rawArgs);
69
- // load command
70
- await this.loadCommandFromArgs(parsedArgs._);
71
- if (this.commandToExecute) {
72
- // we have found a command to execute. Parse args again taking into
73
- // account short and long options, option types and whether the command
74
- // supports known and unknown options or not
75
- try {
76
- this.optionsFromArgs = {
77
- options: this.getCommandOptionsFromArgs(rawArgs, this.commandToExecute)
78
- };
79
- }
80
- catch (e) {
81
- const optionsWithoutShorts = Cli.removeShortOptions({ options: parsedArgs });
82
- return this.closeWithError(e.message, optionsWithoutShorts, false);
83
- }
84
- }
85
- else {
86
- // we need this to properly support displaying commands
87
- // from the current group
88
- this.optionsFromArgs = {
89
- options: parsedArgs
90
- };
91
- }
92
- // show help if no match found, help explicitly requested or
93
- // no command specified
94
- if (!this.commandToExecute ||
95
- showHelp ||
96
- parsedArgs.h ||
97
- parsedArgs.help) {
98
- if (parsedArgs.output !== 'none') {
99
- this.printHelp(await this.getHelpMode(parsedArgs));
100
- }
101
- return Promise.resolve();
102
- }
103
- const optionsWithoutShorts = Cli.removeShortOptions(this.optionsFromArgs);
104
- try {
105
- // replace values staring with @ with file contents
106
- Cli.loadOptionValuesFromFiles(optionsWithoutShorts);
107
- }
108
- catch (e) {
109
- return this.closeWithError(e, optionsWithoutShorts);
110
- }
111
- const startProcessing = process.hrtime.bigint();
112
- try {
113
- // process options before passing them on to validation stage
114
- const contextCommandOptions = await this.loadOptionsFromContext(this.commandToExecute.options, optionsWithoutShorts.options.debug);
115
- optionsWithoutShorts.options = { ...contextCommandOptions, ...optionsWithoutShorts.options };
116
- await this.commandToExecute.command.processOptions(optionsWithoutShorts.options);
117
- const endProcessing = process.hrtime.bigint();
118
- timings.options.push(Number(endProcessing - startProcessing));
119
- }
120
- catch (e) {
121
- const endProcessing = process.hrtime.bigint();
122
- timings.options.push(Number(endProcessing - startProcessing));
123
- return this.closeWithError(e.message, optionsWithoutShorts, false);
124
- }
125
- // if output not specified, set the configured output value (if any)
126
- if (optionsWithoutShorts.options.output === undefined) {
127
- optionsWithoutShorts.options.output = this.getSettingWithDefaultValue(settingsNames.output, 'json');
128
- }
129
- const startValidation = process.hrtime.bigint();
130
- const validationResult = await this.commandToExecute.command.validate(optionsWithoutShorts, this.commandToExecute);
131
- const endValidation = process.hrtime.bigint();
132
- timings.validation.push(Number(endValidation - startValidation));
133
- if (validationResult !== true) {
134
- return this.closeWithError(validationResult, optionsWithoutShorts, true);
135
- }
136
- const end = process.hrtime.bigint();
137
- timings.core.push(Number(end - start));
138
- try {
139
- await Cli.executeCommand(this.commandToExecute.command, optionsWithoutShorts);
140
- const endTotal = process.hrtime.bigint();
141
- timings.total.push(Number(endTotal - start));
142
- this.printTimings(rawArgs);
143
- process.exit(0);
144
- }
145
- catch (err) {
146
- const endTotal = process.hrtime.bigint();
147
- timings.total.push(Number(endTotal - start));
148
- this.printTimings(rawArgs);
149
- await this.closeWithError(err, optionsWithoutShorts);
150
- /* c8 ignore next */
151
- }
152
- }
153
- printTimings(rawArgs) {
154
- if (rawArgs.some(arg => arg === '--debug')) {
155
- Cli.error('');
156
- Cli.error('Timings:');
157
- Object.getOwnPropertyNames(timings).forEach(key => {
158
- Cli.error(`${key}: ${timings[key].reduce((a, b) => a + b, 0) / 1e6}ms`);
159
- });
160
- }
161
- }
162
- static async executeCommand(command, args) {
163
- const logger = {
164
- log: async (message) => {
165
- if (args.options.output !== 'none') {
166
- const output = await Cli.formatOutput(command, message, args.options);
167
- Cli.log(output);
168
- }
169
- },
170
- logRaw: async (message) => {
171
- if (args.options.output !== 'none') {
172
- Cli.log(message);
173
- }
174
- },
175
- logToStderr: async (message) => {
176
- if (args.options.output !== 'none') {
177
- Cli.error(message);
178
- }
179
- }
180
- };
181
- if (args.options.debug) {
182
- await logger.logToStderr(`Executing command ${command.name} with options ${JSON.stringify(args)}`);
183
- }
184
- // store the current command name, if any and set the name to the name of
185
- // the command to execute
186
- const cli = Cli.getInstance();
187
- const parentCommandName = cli.currentCommandName;
188
- cli.currentCommandName = command.getCommandName(cli.currentCommandName);
189
- const showSpinner = cli.getSettingWithDefaultValue(settingsNames.showSpinner, true) && args.options.output !== 'none';
190
- // don't show spinner if running tests
191
- /* c8 ignore next 3 */
192
- if (showSpinner && typeof global.it === 'undefined') {
193
- cli.spinner.start();
194
- }
195
- const startCommand = process.hrtime.bigint();
196
- try {
197
- await command.action(logger, args);
198
- if (args.options.debug || args.options.verbose) {
199
- const chalk = (await import('chalk')).default;
200
- await logger.logToStderr(chalk.green('DONE'));
201
- }
202
- }
203
- finally {
204
- // restore the original command name
205
- cli.currentCommandName = parentCommandName;
206
- /* c8 ignore next 3 */
207
- if (cli.spinner.isSpinning) {
208
- cli.spinner.stop();
209
- }
210
- const endCommand = process.hrtime.bigint();
211
- timings.command.push(Number(endCommand - startCommand));
212
- }
213
- }
214
- static async executeCommandWithOutput(command, args, listener) {
215
- const log = [];
216
- const logErr = [];
217
- const logger = {
218
- log: async (message) => {
219
- const formattedMessage = await Cli.formatOutput(command, message, args.options);
220
- if (listener && listener.stdout) {
221
- listener.stdout(formattedMessage);
222
- }
223
- log.push(formattedMessage);
224
- },
225
- logRaw: async (message) => {
226
- const formattedMessage = await Cli.formatOutput(command, message, args.options);
227
- if (listener && listener.stdout) {
228
- listener.stdout(formattedMessage);
229
- }
230
- log.push(formattedMessage);
231
- },
232
- logToStderr: async (message) => {
233
- if (listener && listener.stderr) {
234
- listener.stderr(message);
235
- }
236
- logErr.push(message);
237
- }
238
- };
239
- if (args.options.debug && args.options.output !== 'none') {
240
- const message = `Executing command ${command.name} with options ${JSON.stringify(args)}`;
241
- if (listener && listener.stderr) {
242
- listener.stderr(message);
243
- }
244
- logErr.push(message);
245
- }
246
- // store the current command name, if any and set the name to the name of
247
- // the command to execute
248
- const cli = Cli.getInstance();
249
- const parentCommandName = cli.currentCommandName;
250
- cli.currentCommandName = command.getCommandName();
251
- // store the current logger if any
252
- const currentLogger = request.logger;
253
- try {
254
- await command.action(logger, args);
255
- return ({
256
- stdout: log.join(os.EOL),
257
- stderr: logErr.join(os.EOL)
258
- });
259
- }
260
- catch (err) {
261
- // restoring the command and logger is done here instead of in a 'finally' because there were issues with the code coverage tool
262
- // restore the original command name
263
- cli.currentCommandName = parentCommandName;
264
- // restore the original logger
265
- request.logger = currentLogger;
266
- throw {
267
- error: err,
268
- stderr: logErr.join(os.EOL)
269
- };
270
- }
271
- /* c8 ignore next */
272
- finally {
273
- // restore the original command name
274
- cli.currentCommandName = parentCommandName;
275
- // restore the original logger
276
- request.logger = currentLogger;
277
- }
278
- }
279
- loadAllCommandsInfo(loadFull = false) {
280
- const commandsInfoFileName = loadFull ? 'allCommandsFull.json' : 'allCommands.json';
281
- this.commands = require(path.join(__dirname, '..', '..', commandsInfoFileName));
282
- }
283
- /**
284
- * Loads command files into CLI based on the specified arguments.
285
- *
286
- * @param commandNameWords Array of words specified as args
287
- */
288
- async loadCommandFromArgs(commandNameWords) {
289
- if (commandNameWords.length === 0) {
290
- return;
291
- }
292
- this.currentCommandName = commandNameWords.join(' ');
293
- const commandFilePath = this.commands
294
- .find(c => c.name === this.currentCommandName ||
295
- c.aliases?.find(a => a === this.currentCommandName))?.file ?? '';
296
- if (commandFilePath) {
297
- await this.loadCommandFromFile(commandFilePath);
298
- }
299
- }
300
- async loadOptionsFromContext(commandOptions, debug) {
301
- const filePath = '.m365rc.json';
302
- let m365rc = {};
303
- if (!fs.existsSync(filePath)) {
304
- return;
305
- }
306
- if (debug) {
307
- await Cli.error('found .m365rc.json file');
308
- }
309
- try {
310
- const fileContents = fs.readFileSync(filePath, 'utf8');
311
- if (fileContents) {
312
- m365rc = JSON.parse(fileContents);
313
- }
314
- }
315
- catch (e) {
316
- await this.closeWithError(`Error parsing ${filePath}`, { options: {} });
317
- /* c8 ignore next */
318
- }
319
- if (!m365rc.context) {
320
- return;
321
- }
322
- if (debug) {
323
- await Cli.error('found context in .m365rc.json file');
324
- }
325
- const context = m365rc.context;
326
- const foundOptions = {};
327
- await commandOptions.forEach(async (option) => {
328
- if (context[option.name]) {
329
- foundOptions[option.name] = context[option.name];
330
- if (debug) {
331
- await Cli.error(`returning ${option.name} option from context`);
332
- }
333
- }
334
- });
335
- return foundOptions;
336
- }
337
- /**
338
- * Loads command from the specified file into CLI. If can't find the file
339
- * or the file doesn't contain a command, loads all available commands.
340
- *
341
- * @param commandFilePathUrl File path of the file with command to load
342
- */
343
- async loadCommandFromFile(commandFileUrl) {
344
- const commandsFolder = path.join(__dirname, '../m365');
345
- const filePath = path.join(commandsFolder, commandFileUrl);
346
- if (!fs.existsSync(filePath)) {
347
- // reset command name
348
- this.currentCommandName = undefined;
349
- return;
350
- }
351
- try {
352
- const command = await import(pathToFileURL(filePath).toString());
353
- if (command.default instanceof Command) {
354
- const commandInfo = this.commands.find(c => c.file === commandFileUrl);
355
- this.commandToExecute = Cli.getCommandInfo(command.default, commandFileUrl, commandInfo?.help);
356
- }
357
- }
358
- catch { }
359
- }
360
- static getCommandInfo(command, filePath = '', helpFilePath = '') {
361
- return {
362
- aliases: command.alias(),
363
- name: command.name,
364
- description: command.description,
365
- command: command,
366
- options: this.getCommandOptions(command),
367
- defaultProperties: command.defaultProperties(),
368
- file: filePath,
369
- help: helpFilePath
370
- };
371
- }
372
- static getCommandOptions(command) {
373
- const options = [];
374
- command.options.forEach(option => {
375
- const required = option.option.indexOf('<') > -1;
376
- const optionArgs = option.option.split(/[ ,|]+/);
377
- let short;
378
- let long;
379
- let name = '';
380
- optionArgs.forEach(o => {
381
- if (o.startsWith('--')) {
382
- long = o.replace('--', '');
383
- name = long;
384
- }
385
- else if (o.startsWith('-')) {
386
- short = o.replace('-', '');
387
- name = short;
388
- }
389
- });
390
- options.push({
391
- autocomplete: option.autocomplete,
392
- long: long,
393
- name: name,
394
- required: required,
395
- short: short
396
- });
397
- });
398
- return options;
399
- }
400
- getCommandOptionsFromArgs(args, commandInfo) {
401
- const minimistOptions = {
402
- alias: {}
403
- };
404
- let argsToParse = args;
405
- if (commandInfo) {
406
- const commandTypes = commandInfo.command.types;
407
- if (commandTypes) {
408
- minimistOptions.string = commandTypes.string;
409
- // minimist will parse unused boolean options to 'false' (unused options => options that are not included in the args)
410
- // But in the CLI booleans are nullable. They can can be true, false or undefined.
411
- // For this reason we only pass boolean types that are actually used as arg.
412
- minimistOptions.boolean = commandTypes.boolean.filter(optionName => args.some(arg => `--${optionName}` === arg || `-${optionName}` === arg));
413
- }
414
- minimistOptions.alias = {};
415
- commandInfo.options.forEach(option => {
416
- if (option.short && option.long) {
417
- minimistOptions.alias[option.short] = option.long;
418
- }
419
- });
420
- argsToParse = this.getRewrittenArgs(args, commandTypes);
421
- }
422
- return minimist(argsToParse, minimistOptions);
423
- }
424
- /**
425
- * Rewrites arguments (if necessary) before passing them into minimist.
426
- * Currently only boolean values are checked and fixed.
427
- * Args are only checked and rewritten if the option has been added to the 'types.boolean' array.
428
- */
429
- getRewrittenArgs(args, commandTypes) {
430
- const booleanTypes = commandTypes.boolean;
431
- if (booleanTypes.length === 0) {
432
- return args;
433
- }
434
- return args.map((arg, index, array) => {
435
- if (arg.startsWith('-') || index === 0) {
436
- return arg;
437
- }
438
- // This line checks if the current arg is a value that belongs to a boolean option.
439
- if (booleanTypes.some(t => `--${t}` === array[index - 1] || `-${t}` === array[index - 1])) {
440
- const rewrittenBoolean = formatting.rewriteBooleanValue(arg);
441
- if (!validation.isValidBoolean(rewrittenBoolean)) {
442
- const optionName = array[index - 1];
443
- throw new Error(`The value '${arg}' for option '${optionName}' is not a valid boolean`);
444
- }
445
- return rewrittenBoolean;
446
- }
447
- return arg;
448
- });
449
- }
450
- static async formatOutput(command, logStatement, options) {
451
- if (logStatement instanceof Date) {
452
- return logStatement.toString();
453
- }
454
- let logStatementType = typeof logStatement;
455
- if (logStatementType === 'undefined') {
456
- return logStatement;
457
- }
458
- // we need to get the list of object's properties to see if the specified
459
- // JMESPath query (if any) filters object's properties or not. We need to
460
- // know this in order to decide if we should use default command's
461
- // properties or custom ones from JMESPath
462
- const originalObject = Array.isArray(logStatement) ? Cli.getFirstNonUndefinedArrayItem(logStatement) : logStatement;
463
- const originalProperties = originalObject && typeof originalObject !== 'string' ? Object.getOwnPropertyNames(originalObject) : [];
464
- if (options.query &&
465
- !options.help) {
466
- const jmespath = await import('jmespath');
467
- try {
468
- logStatement = jmespath.search(logStatement, options.query);
469
- }
470
- catch (e) {
471
- const message = `JMESPath query error. ${e.message}. See https://jmespath.org/specification.html for more information`;
472
- await Cli.getInstance().closeWithError(message, { options }, false);
473
- /* c8 ignore next */
474
- }
475
- // we need to update the statement type in case the JMESPath query
476
- // returns an object of different shape than the original message to log
477
- // #2095
478
- logStatementType = typeof logStatement;
479
- }
480
- if (!options.output || options.output === 'json') {
481
- return command.getJsonOutput(logStatement);
482
- }
483
- if (logStatement instanceof CommandError) {
484
- const chalk = (await import('chalk')).default;
485
- return chalk.red(`Error: ${logStatement.message}`);
486
- }
487
- let arrayType = '';
488
- if (!Array.isArray(logStatement)) {
489
- logStatement = [logStatement];
490
- arrayType = logStatementType;
491
- }
492
- else {
493
- for (let i = 0; i < logStatement.length; i++) {
494
- if (Array.isArray(logStatement[i])) {
495
- arrayType = 'array';
496
- break;
497
- }
498
- const t = typeof logStatement[i];
499
- if (t !== 'undefined') {
500
- arrayType = t;
501
- break;
502
- }
503
- }
504
- }
505
- if (arrayType !== 'object') {
506
- return logStatement.join(os.EOL);
507
- }
508
- // if output type has been set to 'text', process the retrieved
509
- // data so that returned objects contain only default properties specified
510
- // on the current command. If there is no current command or the
511
- // command doesn't specify default properties, return original data
512
- if (this.shouldTrimOutput(options.output)) {
513
- const cli = Cli.getInstance();
514
- const currentCommand = cli.commandToExecute;
515
- if (arrayType === 'object' &&
516
- currentCommand && currentCommand.defaultProperties) {
517
- // the log statement contains the same properties as the original object
518
- // so it can be filtered following the default properties specified on
519
- // the command
520
- if (JSON.stringify(originalProperties) === JSON.stringify(Object.getOwnPropertyNames(logStatement[0]))) {
521
- // in some cases we return properties wrapped in `value` array
522
- // returned by the API. We'll remove it in the future, but for now
523
- // we'll use a workaround to drop the `value` array here
524
- if (logStatement[0].value &&
525
- Array.isArray(logStatement[0].value)) {
526
- logStatement = logStatement[0].value;
527
- }
528
- logStatement = logStatement.map((s) => formatting.filterObject(s, currentCommand.defaultProperties));
529
- }
530
- }
531
- }
532
- switch (options.output) {
533
- case 'csv':
534
- return command.getCsvOutput(logStatement, options);
535
- case 'md':
536
- return command.getMdOutput(logStatement, command, options);
537
- default:
538
- return command.getTextOutput(logStatement);
539
- }
540
- }
541
- static getFirstNonUndefinedArrayItem(arr) {
542
- for (let i = 0; i < arr.length; i++) {
543
- const a = arr[i];
544
- if (typeof a !== 'undefined') {
545
- return a;
546
- }
547
- }
548
- return undefined;
549
- }
550
- printHelp(helpMode, exitCode = 0) {
551
- const properties = {};
552
- if (this.commandToExecute) {
553
- properties.command = this.commandToExecute.name;
554
- this.printCommandHelp(helpMode);
555
- }
556
- else {
557
- Cli.log();
558
- Cli.log(`CLI for Microsoft 365 v${app.packageJson().version}`);
559
- Cli.log(`${app.packageJson().description}`);
560
- Cli.log();
561
- properties.command = 'commandList';
562
- this.printAvailableCommands();
563
- }
564
- telemetry.trackEvent('help', properties);
565
- process.exit(exitCode);
566
- }
567
- printCommandHelp(helpMode) {
568
- const docsRootDir = path.join(__dirname, '..', '..', 'docs');
569
- const helpFilePath = path.join(docsRootDir, 'docs', 'cmd', this.commandToExecute.help);
570
- if (fs.existsSync(helpFilePath)) {
571
- let helpContents = fs.readFileSync(helpFilePath, 'utf8');
572
- helpContents = this.getHelpSection(helpMode, helpContents);
573
- helpContents = md.md2plain(helpContents, docsRootDir);
574
- Cli.log();
575
- Cli.log(helpContents);
576
- }
577
- }
578
- async getHelpMode(options) {
579
- const { h, help } = options;
580
- if (!h && !help) {
581
- return this.getSettingWithDefaultValue(settingsNames.helpMode, Cli.defaultHelpMode);
582
- }
583
- // user passed -h or --help, let's see if they passed a specific mode
584
- // or requested the default
585
- const helpMode = h ?? help;
586
- if (typeof helpMode === 'boolean' || typeof helpMode !== 'string') {
587
- // requested default mode or passed a number, let's use default
588
- return this.getSettingWithDefaultValue(settingsNames.helpMode, Cli.defaultHelpMode);
589
- }
590
- else {
591
- const lowerCaseHelpMode = helpMode.toLowerCase();
592
- if (Cli.helpModes.indexOf(lowerCaseHelpMode) < 0) {
593
- await Cli.getInstance().closeWithError(`Unknown help mode ${helpMode}. Allowed values are ${Cli.helpModes.join(', ')}`, { options }, false);
594
- /* c8 ignore next 2 */
595
- return ''; // noop
596
- }
597
- else {
598
- return lowerCaseHelpMode;
599
- }
600
- }
601
- }
602
- getHelpSection(helpMode, helpContents) {
603
- if (helpMode === 'full') {
604
- return helpContents;
605
- }
606
- // options is the first section, so get help up to options
607
- const titleAndUsage = helpContents.substring(0, helpContents.indexOf('## Options'));
608
- // find the requested section
609
- const sectionLines = [];
610
- const sectionName = helpMode[0].toUpperCase() + helpMode.substring(1);
611
- const lines = helpContents.split('\n');
612
- for (let i = 0; i < lines.length; i++) {
613
- const line = lines[i];
614
- if (line.indexOf(`## ${sectionName}`) === 0) {
615
- sectionLines.push(line);
616
- }
617
- else if (sectionLines.length > 0) {
618
- if (line.indexOf('## ') === 0) {
619
- // we've reached the next section, stop
620
- break;
621
- }
622
- else {
623
- sectionLines.push(line);
624
- }
625
- }
626
- }
627
- return titleAndUsage + sectionLines.join('\n');
628
- }
629
- printAvailableCommands() {
630
- // commands that match the current group
631
- const commandsToPrint = {};
632
- // sub-commands in the current group
633
- const commandGroupsToPrint = {};
634
- // current command group, eg. 'spo', 'spo site'
635
- let currentGroup = '';
636
- const addToList = (commandName, command) => {
637
- const pos = commandName.indexOf(' ', currentGroup.length + 1);
638
- if (pos === -1) {
639
- commandsToPrint[commandName] = command;
640
- }
641
- else {
642
- const subCommandsGroup = commandName.substr(0, pos);
643
- if (!commandGroupsToPrint[subCommandsGroup]) {
644
- commandGroupsToPrint[subCommandsGroup] = 0;
645
- }
646
- commandGroupsToPrint[subCommandsGroup]++;
647
- }
648
- };
649
- // get current command group
650
- if (this.optionsFromArgs &&
651
- this.optionsFromArgs.options &&
652
- this.optionsFromArgs.options._ &&
653
- this.optionsFromArgs.options._.length > 0) {
654
- currentGroup = this.optionsFromArgs.options._.join(' ');
655
- if (currentGroup) {
656
- currentGroup += ' ';
657
- }
658
- }
659
- const getCommandsForGroup = () => {
660
- for (let i = 0; i < this.commands.length; i++) {
661
- const command = this.commands[i];
662
- if (command.name.startsWith(currentGroup)) {
663
- addToList(command.name, command);
664
- }
665
- if (command.aliases) {
666
- for (let j = 0; j < command.aliases.length; j++) {
667
- const alias = command.aliases[j];
668
- if (alias.startsWith(currentGroup)) {
669
- addToList(alias, command);
670
- }
671
- }
672
- }
673
- }
674
- };
675
- getCommandsForGroup();
676
- if (Object.keys(commandsToPrint).length === 0 &&
677
- Object.keys(commandGroupsToPrint).length === 0) {
678
- // specified string didn't match any commands. Reset group and try again
679
- currentGroup = '';
680
- getCommandsForGroup();
681
- }
682
- const namesOfCommandsToPrint = Object.keys(commandsToPrint);
683
- if (namesOfCommandsToPrint.length > 0) {
684
- // determine the length of the longest command name to pad strings + ' [options]'
685
- const maxLength = Math.max(...namesOfCommandsToPrint.map(s => s.length)) + 10;
686
- Cli.log(`Commands:`);
687
- Cli.log();
688
- const sortedCommandNamesToPrint = Object.getOwnPropertyNames(commandsToPrint).sort();
689
- sortedCommandNamesToPrint.forEach(commandName => {
690
- Cli.log(` ${`${commandName} [options]`.padEnd(maxLength, ' ')} ${commandsToPrint[commandName].description}`);
691
- });
692
- }
693
- const namesOfCommandGroupsToPrint = Object.keys(commandGroupsToPrint);
694
- if (namesOfCommandGroupsToPrint.length > 0) {
695
- if (namesOfCommandsToPrint.length > 0) {
696
- Cli.log();
697
- }
698
- // determine the longest command group name to pad strings + ' *'
699
- const maxLength = Math.max(...namesOfCommandGroupsToPrint.map(s => s.length)) + 2;
700
- Cli.log(`Commands groups:`);
701
- Cli.log();
702
- // sort commands groups (because of aliased commands)
703
- const sortedCommandGroupsToPrint = Object
704
- .keys(commandGroupsToPrint)
705
- .sort()
706
- .reduce((object, key) => {
707
- object[key] = commandGroupsToPrint[key];
708
- return object;
709
- }, {});
710
- for (const commandGroup in sortedCommandGroupsToPrint) {
711
- Cli.log(` ${`${commandGroup} *`.padEnd(maxLength, ' ')} ${commandGroupsToPrint[commandGroup]} command${commandGroupsToPrint[commandGroup] === 1 ? '' : 's'}`);
712
- }
713
- }
714
- Cli.log();
715
- }
716
- async closeWithError(error, args, showHelpIfEnabled = false) {
717
- let exitCode = 1;
718
- if (args.options.output === 'none') {
719
- return process.exit(exitCode);
720
- }
721
- const chalk = (await import('chalk')).default;
722
- let errorMessage = error instanceof CommandError ? error.message : error;
723
- if ((!args.options.output || args.options.output === 'json') &&
724
- !this.getSettingWithDefaultValue(settingsNames.printErrorsAsPlainText, true)) {
725
- errorMessage = JSON.stringify({ error: errorMessage });
726
- }
727
- else {
728
- errorMessage = chalk.red(`Error: ${errorMessage}`);
729
- }
730
- if (error instanceof CommandError && error.code) {
731
- exitCode = error.code;
732
- }
733
- await Cli.error(errorMessage);
734
- if (showHelpIfEnabled &&
735
- await this.getSettingWithDefaultValue(settingsNames.showHelpOnFailure, showHelpIfEnabled)) {
736
- this.printHelp(await this.getHelpMode(args.options), exitCode);
737
- }
738
- else {
739
- process.exit(exitCode);
740
- }
741
- // will never be run. Required for testing where we're stubbing process.exit
742
- /* c8 ignore next */
743
- throw new Error(errorMessage);
744
- /* c8 ignore next */
745
- }
746
- static log(message, ...optionalParams) {
747
- const cli = Cli.getInstance();
748
- const spinnerSpinning = cli.spinner.isSpinning;
749
- /* c8 ignore next 3 */
750
- if (spinnerSpinning) {
751
- cli.spinner.stop();
752
- }
753
- if (message) {
754
- console.log(message, ...optionalParams);
755
- }
756
- else {
757
- console.log();
758
- }
759
- // Restart the spinner if it was running before the log
760
- /* c8 ignore next 3 */
761
- if (spinnerSpinning) {
762
- cli.spinner.start();
763
- }
764
- }
765
- static async error(message, ...optionalParams) {
766
- const cli = Cli.getInstance();
767
- const spinnerSpinning = cli.spinner.isSpinning;
768
- /* c8 ignore next 3 */
769
- if (spinnerSpinning) {
770
- cli.spinner.stop();
771
- }
772
- const errorOutput = cli.getSettingWithDefaultValue(settingsNames.errorOutput, 'stderr');
773
- if (errorOutput === 'stdout') {
774
- console.log(message, ...optionalParams);
775
- }
776
- else {
777
- console.error(message, ...optionalParams);
778
- }
779
- // Restart the spinner if it was running before the log
780
- /* c8 ignore next 3 */
781
- if (spinnerSpinning) {
782
- cli.spinner.start();
783
- }
784
- }
785
- static async promptForSelection(config) {
786
- const cli = Cli.getInstance();
787
- const spinnerSpinning = cli.spinner.isSpinning;
788
- /* c8 ignore next 3 */
789
- if (spinnerSpinning) {
790
- cli.spinner.stop();
791
- }
792
- const answer = await prompt.forSelection(config);
793
- Cli.error('');
794
- // Restart the spinner if it was running before the prompt
795
- /* c8 ignore next 3 */
796
- if (spinnerSpinning) {
797
- cli.spinner.start();
798
- }
799
- return answer;
800
- }
801
- static async promptForConfirmation(config) {
802
- const cli = Cli.getInstance();
803
- const spinnerSpinning = cli.spinner.isSpinning;
804
- /* c8 ignore next 3 */
805
- if (spinnerSpinning) {
806
- cli.spinner.stop();
807
- }
808
- const answer = await prompt.forConfirmation(config);
809
- Cli.error('');
810
- // Restart the spinner if it was running before the prompt
811
- /* c8 ignore next 3 */
812
- if (spinnerSpinning) {
813
- cli.spinner.start();
814
- }
815
- return answer;
816
- }
817
- static async handleMultipleResultsFound(message, values) {
818
- const prompt = Cli.getInstance().getSettingWithDefaultValue(settingsNames.prompt, true);
819
- if (!prompt) {
820
- throw new Error(`${message} Found: ${Object.keys(values).join(', ')}.`);
821
- }
822
- Cli.error(`🌶️ ${message}`);
823
- const choices = Object.keys(values).map((choice) => { return { name: choice, value: choice }; });
824
- const response = await Cli.promptForSelection({ message: `Please choose one:`, choices });
825
- return values[response];
826
- }
827
- static removeShortOptions(args) {
828
- const filteredArgs = JSON.parse(JSON.stringify(args));
829
- const optionsToRemove = Object.getOwnPropertyNames(args.options)
830
- .filter(option => option.length === 1 || option === '--');
831
- optionsToRemove.forEach(option => delete filteredArgs.options[option]);
832
- return filteredArgs;
833
- }
834
- static loadOptionValuesFromFiles(args) {
835
- const optionNames = Object.getOwnPropertyNames(args.options);
836
- optionNames.forEach(option => {
837
- const value = args.options[option];
838
- if (!value ||
839
- typeof value !== 'string' ||
840
- !value.startsWith('@')) {
841
- return;
842
- }
843
- const filePath = value.substr(1);
844
- // if the file doesn't exist, leave as-is, if it exists replace with
845
- // contents from the file
846
- if (fs.existsSync(filePath)) {
847
- args.options[option] = fs.readFileSync(filePath, 'utf-8');
848
- }
849
- });
850
- }
851
- static shouldTrimOutput(output) {
852
- return output === 'text';
853
- }
854
- }
855
- Cli.defaultHelpMode = 'options';
856
- Cli.helpModes = ['options', 'examples', 'remarks', 'response', 'full'];
857
- //# sourceMappingURL=Cli.js.map