@pnp/cli-microsoft365 7.3.0-beta.01256d2 → 7.3.0-beta.6062919

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