@pnp/cli-microsoft365 6.5.0-beta.f8b8018 → 6.6.0-beta.2339ae2

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 (45) hide show
  1. package/.eslintrc.js +2 -0
  2. package/Dockerfile +1 -0
  3. package/dist/Command.js +17 -7
  4. package/dist/cli/Cli.js +15 -11
  5. package/dist/m365/cli/commands/config/config-set.js +1 -0
  6. package/dist/m365/commands/request.js +18 -1
  7. package/dist/m365/pa/commands/app/app-export.js +197 -0
  8. package/dist/m365/pa/commands.js +1 -0
  9. package/dist/m365/pp/commands/tenant/tenant-settings-set.js +261 -0
  10. package/dist/m365/pp/commands.js +2 -1
  11. package/dist/m365/purview/commands/threatassessment/threatassessment-get.js +79 -0
  12. package/dist/m365/purview/commands.js +2 -1
  13. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.0.js +23 -0
  14. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.1.js +23 -0
  15. package/dist/m365/spfx/commands/project/project-doctor.js +3 -1
  16. package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.17.0-rc.1.js → upgrade-1.17.0.js} +26 -26
  17. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.17.1.js +55 -0
  18. package/dist/m365/spfx/commands/project/project-upgrade.js +14 -15
  19. package/dist/m365/spfx/commands/spfx-doctor.js +30 -0
  20. package/dist/m365/spo/commands/file/file-move.js +1 -1
  21. package/dist/m365/spo/commands/file/file-retentionlabel-ensure.js +22 -1
  22. package/dist/m365/spo/commands/listitem/ListItemFieldValueResult.js +3 -0
  23. package/dist/m365/spo/commands/listitem/listitem-add.js +6 -5
  24. package/dist/m365/spo/commands/listitem/listitem-batch-add.js +18 -1
  25. package/dist/m365/spo/commands/listitem/listitem-get.js +21 -6
  26. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-ensure.js +35 -1
  27. package/dist/m365/spo/commands/listitem/listitem-set.js +5 -6
  28. package/dist/m365/spo/commands/web/web-set.js +33 -13
  29. package/dist/settingsNames.js +2 -1
  30. package/dist/utils/fsUtil.js +1 -1
  31. package/docs/docs/_clisettings.md +1 -0
  32. package/docs/docs/cmd/aad/o365group/o365group-add.md +3 -3
  33. package/docs/docs/cmd/pa/app/app-export.md +52 -0
  34. package/docs/docs/cmd/pp/tenant/tenant-settings-set.md +218 -0
  35. package/docs/docs/cmd/purview/threatassessment/threatassessment-get.md +191 -0
  36. package/docs/docs/cmd/request.md +10 -4
  37. package/docs/docs/cmd/spfx/project/project-upgrade.md +2 -2
  38. package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.md +12 -1
  39. package/docs/docs/cmd/spo/listitem/listitem-add.md +12 -1
  40. package/docs/docs/cmd/spo/listitem/listitem-batch-add.md +12 -9
  41. package/docs/docs/cmd/spo/listitem/listitem-get.md +14 -5
  42. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-ensure.md +15 -2
  43. package/docs/docs/cmd/spo/listitem/listitem-set.md +12 -1
  44. package/npm-shrinkwrap.json +460 -273
  45. package/package.json +14 -12
package/.eslintrc.js CHANGED
@@ -10,6 +10,7 @@ const dictionary = [
10
10
  'application',
11
11
  'apply',
12
12
  'approve',
13
+ 'assessment',
13
14
  'assets',
14
15
  'audit',
15
16
  'bin',
@@ -84,6 +85,7 @@ const dictionary = [
84
85
  'storage',
85
86
  'table',
86
87
  'teams',
88
+ 'threat',
87
89
  'token',
88
90
  'type',
89
91
  'user',
package/Dockerfile CHANGED
@@ -43,6 +43,7 @@ RUN bash -c 'echo "export PATH=$PATH:/home/cli-microsoft365/.npm-global/bin:/hom
43
43
  && bash -c 'echo "export CLIMICROSOFT365_ENV=\"docker\"" >> ~/.bash_profile' \
44
44
  && bash -c 'npm i -g @pnp/cli-microsoft365@${CLI_VERSION} --production --quiet --no-progress' \
45
45
  && bash -c 'echo "source /etc/profile.d/bash_completion.sh" >> ~/.bash_profile' \
46
+ && bash -c 'echo ". .bashrc" >> ~/.bash_profile' \
46
47
  && bash -c 'npm cache clean --force' \
47
48
  && bash -c 'm365 cli completion sh setup' \
48
49
  && pwsh -c 'm365 cli completion pwsh setup --profile $profile'
package/dist/Command.js CHANGED
@@ -458,9 +458,18 @@ class Command {
458
458
  // replace unescaped newlines with escaped newlines #2807
459
459
  .replace(/([^\\])\\n/g, '$1\\\\\\n');
460
460
  }
461
- getCsvOutput(logStatement) {
461
+ getCsvOutput(logStatement, options) {
462
462
  const { stringify } = require('csv-stringify/sync');
463
463
  const cli = Cli_1.Cli.getInstance();
464
+ if (logStatement && logStatement.length > 0 && !options.query) {
465
+ logStatement.map(l => {
466
+ for (const x of Object.keys(l)) {
467
+ if (typeof l[x] === 'object') {
468
+ delete l[x];
469
+ }
470
+ }
471
+ });
472
+ }
464
473
  // https://csv.js.org/stringify/options/
465
474
  return stringify(logStatement, {
466
475
  header: cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.csvHeader, true),
@@ -494,13 +503,14 @@ class Command {
494
503
  output.push(`## ${id}`, os.EOL, os.EOL);
495
504
  }
496
505
  output.push(`Property | Value`, os.EOL, `---------|-------`, os.EOL);
497
- output.push(Object.keys(l).map(k => {
498
- const value = l[k];
499
- let stringValue = value;
500
- if (typeof value === 'object') {
501
- stringValue = JSON.stringify(value);
506
+ output.push(Object.keys(l).filter(x => {
507
+ if (!options.query && typeof l[x] === 'object') {
508
+ return;
502
509
  }
503
- return `${md_1.md.escapeMd(k)} | ${md_1.md.escapeMd(stringValue)}`;
510
+ return x;
511
+ }).map(k => {
512
+ const value = l[k];
513
+ return `${md_1.md.escapeMd(k)} | ${md_1.md.escapeMd(value)}`;
504
514
  }).join(os.EOL), os.EOL);
505
515
  output.push(os.EOL);
506
516
  });
package/dist/cli/Cli.js CHANGED
@@ -158,9 +158,10 @@ class Cli {
158
158
  const cli = Cli.getInstance();
159
159
  const parentCommandName = cli.currentCommandName;
160
160
  cli.currentCommandName = command.getCommandName(cli.currentCommandName);
161
+ const showSpinner = cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.showSpinner, true);
161
162
  // don't show spinner if running tests
162
163
  /* c8 ignore next 3 */
163
- if (typeof global.it === 'undefined') {
164
+ if (showSpinner && typeof global.it === 'undefined') {
164
165
  cli.spinner.start();
165
166
  }
166
167
  try {
@@ -529,7 +530,7 @@ class Cli {
529
530
  }
530
531
  switch (options.output) {
531
532
  case 'csv':
532
- return command.getCsvOutput(logStatement);
533
+ return command.getCsvOutput(logStatement, options);
533
534
  case 'md':
534
535
  return command.getMdOutput(logStatement, command, options);
535
536
  default:
@@ -756,9 +757,10 @@ class Cli {
756
757
  /* c8 ignore next */
757
758
  }
758
759
  static log(message, ...optionalParams) {
760
+ const cli = Cli.getInstance();
759
761
  /* c8 ignore next 3 */
760
- if (Cli.getInstance().spinner.isSpinning) {
761
- Cli.getInstance().spinner.stop();
762
+ if (cli.spinner.isSpinning) {
763
+ cli.spinner.stop();
762
764
  }
763
765
  if (message) {
764
766
  console.log(message, ...optionalParams);
@@ -768,11 +770,12 @@ class Cli {
768
770
  }
769
771
  }
770
772
  static error(message, ...optionalParams) {
773
+ const cli = Cli.getInstance();
771
774
  /* c8 ignore next 3 */
772
- if (Cli.getInstance().spinner.isSpinning) {
773
- Cli.getInstance().spinner.stop();
775
+ if (cli.spinner.isSpinning) {
776
+ cli.spinner.stop();
774
777
  }
775
- const errorOutput = Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.errorOutput, 'stderr');
778
+ const errorOutput = cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.errorOutput, 'stderr');
776
779
  if (errorOutput === 'stdout') {
777
780
  console.log(message, ...optionalParams);
778
781
  }
@@ -783,16 +786,17 @@ class Cli {
783
786
  static prompt(options) {
784
787
  return __awaiter(this, void 0, void 0, function* () {
785
788
  const inquirer = require('inquirer');
786
- const spinnerSpinning = Cli.getInstance().spinner.isSpinning;
789
+ const cli = Cli.getInstance();
790
+ const spinnerSpinning = cli.spinner.isSpinning;
787
791
  /* c8 ignore next 3 */
788
792
  if (spinnerSpinning) {
789
- Cli.getInstance().spinner.stop();
793
+ cli.spinner.stop();
790
794
  }
791
795
  const response = yield inquirer.prompt(options);
792
796
  // Restart the spinner if it was running before the prompt
793
797
  /* c8 ignore next 3 */
794
798
  if (spinnerSpinning) {
795
- Cli.getInstance().spinner.start();
799
+ cli.spinner.start();
796
800
  }
797
801
  return response;
798
802
  });
@@ -822,7 +826,7 @@ class Cli {
822
826
  });
823
827
  }
824
828
  static shouldTrimOutput(output) {
825
- return output === 'text' || output === 'csv';
829
+ return output === 'text';
826
830
  }
827
831
  }
828
832
  exports.Cli = Cli;
@@ -46,6 +46,7 @@ class CliConfigSetCommand extends AnonymousCommand_1.default {
46
46
  case settingsNames_1.settingsNames.printErrorsAsPlainText:
47
47
  case settingsNames_1.settingsNames.prompt:
48
48
  case settingsNames_1.settingsNames.showHelpOnFailure:
49
+ case settingsNames_1.settingsNames.showSpinner:
49
50
  value = args.options.value === 'true';
50
51
  break;
51
52
  default:
@@ -20,6 +20,7 @@ const Command_1 = require("../../Command");
20
20
  const request_1 = require("../../request");
21
21
  const commands_1 = require("./commands");
22
22
  const path = require("path");
23
+ const Auth_1 = require("../../Auth");
23
24
  class RequestCommand extends Command_1.default {
24
25
  get name() {
25
26
  return commands_1.default.REQUEST;
@@ -44,6 +45,7 @@ class RequestCommand extends Command_1.default {
44
45
  logger.logToStderr(`Preparing request...`);
45
46
  }
46
47
  try {
48
+ const url = this.resolveUrlTokens(args.options.url);
47
49
  const method = (args.options.method || 'get').toUpperCase();
48
50
  const headers = {};
49
51
  const unknownOptions = this.getUnknownOptions(args.options);
@@ -58,7 +60,7 @@ class RequestCommand extends Command_1.default {
58
60
  headers['x-resource'] = args.options.resource;
59
61
  }
60
62
  const config = {
61
- url: args.options.url,
63
+ url: url,
62
64
  headers,
63
65
  method,
64
66
  data: args.options.body
@@ -98,6 +100,21 @@ class RequestCommand extends Command_1.default {
98
100
  }
99
101
  });
100
102
  }
103
+ resolveUrlTokens(url) {
104
+ if (url.startsWith('@graphbeta')) {
105
+ return url.replace('@graphbeta', 'https://graph.microsoft.com/beta');
106
+ }
107
+ if (url.startsWith('@graph')) {
108
+ return url.replace('@graph', 'https://graph.microsoft.com/v1.0');
109
+ }
110
+ if (url.startsWith('@spo')) {
111
+ if (Auth_1.default.service.spoUrl) {
112
+ return url.replace('@spo', Auth_1.default.service.spoUrl);
113
+ }
114
+ throw `SharePoint root site URL is unknown. Please set your SharePoint URL using command 'spo set'.`;
115
+ }
116
+ return url;
117
+ }
101
118
  }
102
119
  _RequestCommand_instances = new WeakSet(), _RequestCommand_initTelemetry = function _RequestCommand_initTelemetry() {
103
120
  this.telemetry.push((args) => {
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _PaAppExportCommand_instances, _PaAppExportCommand_initTelemetry, _PaAppExportCommand_initOptions, _PaAppExportCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const validation_1 = require("../../../../utils/validation");
19
+ const commands_1 = require("../../commands");
20
+ const fs = require("fs");
21
+ const path = require("path");
22
+ const formatting_1 = require("../../../../utils/formatting");
23
+ const request_1 = require("../../../../request");
24
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
25
+ class PaAppExportCommand extends PowerPlatformCommand_1.default {
26
+ get name() {
27
+ return commands_1.default.APP_EXPORT;
28
+ }
29
+ get description() {
30
+ return 'Exports the specified Power App';
31
+ }
32
+ constructor() {
33
+ super();
34
+ _PaAppExportCommand_instances.add(this);
35
+ __classPrivateFieldGet(this, _PaAppExportCommand_instances, "m", _PaAppExportCommand_initTelemetry).call(this);
36
+ __classPrivateFieldGet(this, _PaAppExportCommand_instances, "m", _PaAppExportCommand_initOptions).call(this);
37
+ __classPrivateFieldGet(this, _PaAppExportCommand_instances, "m", _PaAppExportCommand_initValidators).call(this);
38
+ }
39
+ commandAction(logger, args) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ try {
42
+ const location = yield this.exportPackage(args, logger);
43
+ const packageLink = yield this.getPackageLink(args, logger, location);
44
+ //Replace all illegal characters from the file name
45
+ const illegalCharsRegEx = /[\\\/:*?"<>|]/g;
46
+ const filename = args.options.packageDisplayName.replace(illegalCharsRegEx, '_');
47
+ const requestOptions = {
48
+ url: packageLink,
49
+ // Set responseType to arraybuffer, otherwise binary data will be encoded
50
+ // to utf8 and binary data is corrupt
51
+ responseType: 'arraybuffer',
52
+ headers: {
53
+ 'x-anonymous': true
54
+ }
55
+ };
56
+ const file = yield request_1.default.get(requestOptions);
57
+ let path = args.options.path || './';
58
+ if (!path.endsWith('/')) {
59
+ path += '/';
60
+ }
61
+ path += `${filename}.zip`;
62
+ fs.writeFileSync(path, file, 'binary');
63
+ if (this.verbose) {
64
+ logger.logToStderr(`File saved to path '${path}'`);
65
+ }
66
+ }
67
+ catch (err) {
68
+ this.handleRejectedODataJsonPromise(err);
69
+ }
70
+ });
71
+ }
72
+ getPackageResources(args, logger) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ if (this.verbose) {
75
+ logger.logToStderr('Getting the Microsoft Power App resources...');
76
+ }
77
+ const requestOptions = {
78
+ url: `${this.resource}/providers/Microsoft.BusinessAppPlatform/environments/${formatting_1.formatting.encodeQueryParameter(args.options.environment)}/listPackageResources?api-version=2016-11-01`,
79
+ headers: {
80
+ accept: 'application/json'
81
+ },
82
+ data: {
83
+ baseResourceIds: [
84
+ `/providers/Microsoft.PowerApps/apps/${args.options.id}`
85
+ ]
86
+ },
87
+ responseType: 'json'
88
+ };
89
+ const response = yield request_1.default.post(requestOptions);
90
+ Object.keys(response.resources).forEach((key) => {
91
+ response.resources[key].suggestedCreationType = 'Update';
92
+ });
93
+ return response.resources;
94
+ });
95
+ }
96
+ exportPackage(args, logger) {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ if (this.verbose) {
99
+ logger.logToStderr(`Initiating package export for Microsoft Power App ${args.options.id}...`);
100
+ }
101
+ const resources = yield this.getPackageResources(args, logger);
102
+ const requestOptions = {
103
+ url: `${this.resource}/providers/Microsoft.BusinessAppPlatform/environments/${formatting_1.formatting.encodeQueryParameter(args.options.environment)}/exportPackage?api-version=2016-11-01`,
104
+ headers: {
105
+ accept: 'application/json'
106
+ },
107
+ responseType: 'json',
108
+ data: {
109
+ includedResourceIds: [
110
+ `/providers/Microsoft.PowerApps/apps/${args.options.id}`
111
+ ],
112
+ details: {
113
+ creator: args.options.packageCreatedBy,
114
+ description: args.options.packageDescription,
115
+ displayName: args.options.packageDisplayName,
116
+ sourceEnvironment: args.options.packageSourceEnvironment
117
+ },
118
+ resources: resources
119
+ },
120
+ fullResponse: true
121
+ };
122
+ const response = yield request_1.default.post(requestOptions);
123
+ return response.headers.location;
124
+ });
125
+ }
126
+ getPackageLink(args, logger, location) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ if (this.verbose) {
129
+ logger.logToStderr('Retrieving the package link and waiting on the exported package.');
130
+ }
131
+ let status;
132
+ let link;
133
+ const requestOptions = {
134
+ url: location,
135
+ headers: {
136
+ accept: 'application/json'
137
+ },
138
+ responseType: 'json'
139
+ };
140
+ do {
141
+ const response = yield request_1.default.get(requestOptions);
142
+ status = response.properties.status;
143
+ if (status === "Succeeded") {
144
+ link = response.properties.packageLink.value;
145
+ }
146
+ else {
147
+ yield this.sleep(5000);
148
+ }
149
+ if (this.verbose) {
150
+ logger.logToStderr(`Current status of the get package link: ${status}`);
151
+ }
152
+ } while (status === 'Running');
153
+ return link;
154
+ });
155
+ }
156
+ sleep(ms) {
157
+ return new Promise(resolve => setTimeout(resolve, ms));
158
+ }
159
+ }
160
+ _PaAppExportCommand_instances = new WeakSet(), _PaAppExportCommand_initTelemetry = function _PaAppExportCommand_initTelemetry() {
161
+ this.telemetry.push((args) => {
162
+ Object.assign(this.telemetryProperties, {
163
+ packageDescription: typeof args.options.packageDescription !== 'undefined',
164
+ packageCreatedBy: typeof args.options.packageCreatedBy !== 'undefined',
165
+ packageSourceEnvironment: typeof args.options.packageSourceEnvironment !== 'undefined',
166
+ path: typeof args.options.path !== 'undefined'
167
+ });
168
+ });
169
+ }, _PaAppExportCommand_initOptions = function _PaAppExportCommand_initOptions() {
170
+ this.options.unshift({
171
+ option: '-i, --id <id>'
172
+ }, {
173
+ option: '-e, --environment <environment>'
174
+ }, {
175
+ option: '-n, --packageDisplayName [packageDisplayName]'
176
+ }, {
177
+ option: '-d, --packageDescription [packageDescription]'
178
+ }, {
179
+ option: '-c, --packageCreatedBy [packageCreatedBy]'
180
+ }, {
181
+ option: '-s, --packageSourceEnvironment [packageSourceEnvironment]'
182
+ }, {
183
+ option: '-p, --path [path]'
184
+ });
185
+ }, _PaAppExportCommand_initValidators = function _PaAppExportCommand_initValidators() {
186
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
187
+ if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
188
+ return `${args.options.id} is not a valid GUID`;
189
+ }
190
+ if (args.options.path && !fs.existsSync(path.dirname(args.options.path))) {
191
+ return 'Specified path where to save the file does not exist';
192
+ }
193
+ return true;
194
+ }));
195
+ };
196
+ module.exports = new PaAppExportCommand();
197
+ //# sourceMappingURL=app-export.js.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'pa';
4
4
  exports.default = {
5
+ APP_EXPORT: `${prefix} app export`,
5
6
  APP_GET: `${prefix} app get`,
6
7
  APP_LIST: `${prefix} app list`,
7
8
  APP_REMOVE: `${prefix} app remove`,