@pnp/cli-microsoft365 5.8.0-beta.bc15f2b → 5.8.0-beta.c222170

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  LOGIN: `login`,
5
5
  LOGOUT: `logout`,
6
+ REQUEST: `request`,
6
7
  STATUS: `status`,
7
8
  VERSION: 'version'
8
9
  };
@@ -0,0 +1,153 @@
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 _RequestCommand_instances, _RequestCommand_initTelemetry, _RequestCommand_initOptions, _RequestCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const fs = require("fs");
19
+ const Command_1 = require("../../Command");
20
+ const request_1 = require("../../request");
21
+ const commands_1 = require("./commands");
22
+ const path = require("path");
23
+ class RequestCommand extends Command_1.default {
24
+ constructor() {
25
+ super();
26
+ _RequestCommand_instances.add(this);
27
+ this.allowedMethods = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options'];
28
+ __classPrivateFieldGet(this, _RequestCommand_instances, "m", _RequestCommand_initTelemetry).call(this);
29
+ __classPrivateFieldGet(this, _RequestCommand_instances, "m", _RequestCommand_initOptions).call(this);
30
+ __classPrivateFieldGet(this, _RequestCommand_instances, "m", _RequestCommand_initValidators).call(this);
31
+ }
32
+ get name() {
33
+ return commands_1.default.REQUEST;
34
+ }
35
+ get description() {
36
+ return 'Executes the specified web request using CLI for Microsoft 365';
37
+ }
38
+ allowUnknownOptions() {
39
+ return true;
40
+ }
41
+ commandAction(logger, args, cb) {
42
+ if (this.debug) {
43
+ logger.logToStderr(`Preparing request...`);
44
+ }
45
+ const method = (args.options.method || 'get').toUpperCase();
46
+ const headers = {};
47
+ const unknownOptions = this.getUnknownOptions(args.options);
48
+ const unknownOptionsNames = Object.getOwnPropertyNames(unknownOptions);
49
+ unknownOptionsNames.forEach(o => {
50
+ headers[o] = unknownOptions[o];
51
+ });
52
+ if (!headers.accept) {
53
+ headers.accept = 'application/json';
54
+ }
55
+ if (args.options.resource) {
56
+ headers['x-resource'] = args.options.resource;
57
+ }
58
+ const config = {
59
+ url: args.options.url,
60
+ headers,
61
+ method,
62
+ data: args.options.body
63
+ };
64
+ if (headers.accept.toString().startsWith('application/json')) {
65
+ config.responseType = 'json';
66
+ }
67
+ if (args.options.filePath) {
68
+ config.responseType = 'stream';
69
+ }
70
+ if (this.verbose) {
71
+ logger.logToStderr(`Executing request...`);
72
+ }
73
+ if (args.options.filePath) {
74
+ request_1.default
75
+ .execute(config)
76
+ .then((file) => {
77
+ return new Promise((resolve, reject) => {
78
+ const writer = fs.createWriteStream(args.options.filePath);
79
+ file.data.pipe(writer);
80
+ writer.on('error', err => {
81
+ reject(err);
82
+ });
83
+ writer.on('close', () => {
84
+ resolve(args.options.filePath);
85
+ });
86
+ });
87
+ })
88
+ .then((file) => {
89
+ if (this.verbose) {
90
+ logger.logToStderr(`File saved to path ${file}`);
91
+ }
92
+ cb();
93
+ }, (err) => this.handleError(err, logger, cb));
94
+ }
95
+ else {
96
+ request_1.default
97
+ .execute(config)
98
+ .then(response => {
99
+ logger.log(response);
100
+ cb();
101
+ }, (rawRes) => this.handleError(rawRes, logger, cb));
102
+ }
103
+ }
104
+ }
105
+ _RequestCommand_instances = new WeakSet(), _RequestCommand_initTelemetry = function _RequestCommand_initTelemetry() {
106
+ this.telemetry.push((args) => {
107
+ const properties = {
108
+ method: args.options.method || 'get',
109
+ resource: typeof args.options.resource !== 'undefined',
110
+ accept: args.options.accept || 'application/json',
111
+ body: typeof args.options.body !== 'undefined',
112
+ filePath: typeof args.options.filePath !== 'undefined'
113
+ };
114
+ const unknownOptions = this.getUnknownOptions(args.options);
115
+ const unknownOptionsNames = Object.getOwnPropertyNames(unknownOptions);
116
+ unknownOptionsNames.forEach(o => {
117
+ properties[o] = typeof unknownOptions[o] !== 'undefined';
118
+ });
119
+ Object.assign(this.telemetryProperties, properties);
120
+ });
121
+ }, _RequestCommand_initOptions = function _RequestCommand_initOptions() {
122
+ this.options.unshift({
123
+ option: '-u, --url <url>'
124
+ }, {
125
+ option: '-m, --method [method]',
126
+ autocomplete: this.allowedMethods
127
+ }, {
128
+ option: '-r, --resource [resource]'
129
+ }, {
130
+ option: '-b, --body [body]'
131
+ }, {
132
+ option: '-p, --filePath [filePath]'
133
+ });
134
+ }, _RequestCommand_initValidators = function _RequestCommand_initValidators() {
135
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
136
+ const currentMethod = args.options.method || 'get';
137
+ if (this.allowedMethods.indexOf(currentMethod) === -1) {
138
+ return `${currentMethod} is not a valid value for method. Allowed values: ${this.allowedMethods.join(', ')}`;
139
+ }
140
+ if (args.options.body && (!args.options.method || args.options.method === 'get')) {
141
+ return 'Specify a different method when using body';
142
+ }
143
+ if (args.options.body && !args.options['content-type']) {
144
+ return 'Specify the content-type when using body';
145
+ }
146
+ if (args.options.filePath && !fs.existsSync(path.dirname(args.options.filePath))) {
147
+ return 'The location specified in the filePath does not exist';
148
+ }
149
+ return true;
150
+ }));
151
+ };
152
+ module.exports = new RequestCommand();
153
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const FN001008_DEP_react_1 = require("./rules/FN001008_DEP_react");
4
+ const FN001009_DEP_react_dom_1 = require("./rules/FN001009_DEP_react_dom");
5
+ const FN001022_DEP_office_ui_fabric_react_1 = require("./rules/FN001022_DEP_office_ui_fabric_react");
6
+ const FN002004_DEVDEP_gulp_1 = require("./rules/FN002004_DEVDEP_gulp");
7
+ const FN002007_DEVDEP_ajv_1 = require("./rules/FN002007_DEVDEP_ajv");
8
+ const FN002013_DEVDEP_types_webpack_env_1 = require("./rules/FN002013_DEVDEP_types_webpack_env");
9
+ const FN002015_DEVDEP_types_react_1 = require("./rules/FN002015_DEVDEP_types_react");
10
+ const FN002016_DEVDEP_types_react_dom_1 = require("./rules/FN002016_DEVDEP_types_react_dom");
11
+ const FN002019_DEVDEP_microsoft_rush_stack_compiler_1 = require("./rules/FN002019_DEVDEP_microsoft_rush_stack_compiler");
12
+ module.exports = [
13
+ new FN001008_DEP_react_1.FN001008_DEP_react('16'),
14
+ new FN001009_DEP_react_dom_1.FN001009_DEP_react_dom('16'),
15
+ new FN001022_DEP_office_ui_fabric_react_1.FN001022_DEP_office_ui_fabric_react('7.192.0'),
16
+ new FN002004_DEVDEP_gulp_1.FN002004_DEVDEP_gulp('4.0.2'),
17
+ new FN002007_DEVDEP_ajv_1.FN002007_DEVDEP_ajv('^6.12.5'),
18
+ new FN002013_DEVDEP_types_webpack_env_1.FN002013_DEVDEP_types_webpack_env('~1.15.2'),
19
+ new FN002015_DEVDEP_types_react_1.FN002015_DEVDEP_types_react('16'),
20
+ new FN002016_DEVDEP_types_react_dom_1.FN002016_DEVDEP_types_react_dom('16'),
21
+ new FN002019_DEVDEP_microsoft_rush_stack_compiler_1.FN002019_DEVDEP_microsoft_rush_stack_compiler(['4.5'])
22
+ ];
23
+ //# sourceMappingURL=doctor-1.16.0-beta.1.js.map
@@ -61,7 +61,8 @@ class SpfxProjectDoctorCommand extends base_project_command_1.BaseProjectCommand
61
61
  '1.13.1',
62
62
  '1.14.0',
63
63
  '1.15.0',
64
- '1.15.2'
64
+ '1.15.2',
65
+ '1.16.0-beta.1'
65
66
  ];
66
67
  __classPrivateFieldGet(this, _SpfxProjectDoctorCommand_instances, "m", _SpfxProjectDoctorCommand_initTelemetry).call(this);
67
68
  __classPrivateFieldGet(this, _SpfxProjectDoctorCommand_instances, "m", _SpfxProjectDoctorCommand_initOptions).call(this);
@@ -71,9 +71,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
71
71
  _SpfxDoctorCommand_instances.add(this);
72
72
  this.versions = {
73
73
  '1.0.0': {
74
- gulp: {
75
- range: '^3',
76
- fix: 'npm i -g gulp@3'
74
+ gulpCli: {
75
+ range: '^1 || ^2',
76
+ fix: 'npm i -g gulp-cli@2'
77
77
  },
78
78
  node: {
79
79
  range: '^6',
@@ -86,9 +86,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
86
86
  }
87
87
  },
88
88
  '1.1.0': {
89
- gulp: {
90
- range: '^3',
91
- fix: 'npm i -g gulp@3'
89
+ gulpCli: {
90
+ range: '^1 || ^2',
91
+ fix: 'npm i -g gulp-cli@2'
92
92
  },
93
93
  node: {
94
94
  range: '^6',
@@ -101,9 +101,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
101
101
  }
102
102
  },
103
103
  '1.2.0': {
104
- gulp: {
105
- range: '^3',
106
- fix: 'npm i -g gulp@3'
104
+ gulpCli: {
105
+ range: '^1 || ^2',
106
+ fix: 'npm i -g gulp-cli@2'
107
107
  },
108
108
  node: {
109
109
  range: '^6',
@@ -116,9 +116,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
116
116
  }
117
117
  },
118
118
  '1.4.0': {
119
- gulp: {
120
- range: '^3',
121
- fix: 'npm i -g gulp@3'
119
+ gulpCli: {
120
+ range: '^1 || ^2',
121
+ fix: 'npm i -g gulp-cli@2'
122
122
  },
123
123
  node: {
124
124
  range: '^6',
@@ -131,9 +131,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
131
131
  }
132
132
  },
133
133
  '1.4.1': {
134
- gulp: {
135
- range: '^3',
136
- fix: 'npm i -g gulp@3'
134
+ gulpCli: {
135
+ range: '^1 || ^2',
136
+ fix: 'npm i -g gulp-cli@2'
137
137
  },
138
138
  node: {
139
139
  range: '^6 || ^8',
@@ -146,9 +146,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
146
146
  }
147
147
  },
148
148
  '1.5.0': {
149
- gulp: {
150
- range: '^3',
151
- fix: 'npm i -g gulp@3'
149
+ gulpCli: {
150
+ range: '^1 || ^2',
151
+ fix: 'npm i -g gulp-cli@2'
152
152
  },
153
153
  node: {
154
154
  range: '^6 || ^8',
@@ -161,9 +161,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
161
161
  }
162
162
  },
163
163
  '1.5.1': {
164
- gulp: {
165
- range: '^3',
166
- fix: 'npm i -g gulp@3'
164
+ gulpCli: {
165
+ range: '^1 || ^2',
166
+ fix: 'npm i -g gulp-cli@2'
167
167
  },
168
168
  node: {
169
169
  range: '^6 || ^8',
@@ -176,9 +176,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
176
176
  }
177
177
  },
178
178
  '1.6.0': {
179
- gulp: {
180
- range: '^3',
181
- fix: 'npm i -g gulp@3'
179
+ gulpCli: {
180
+ range: '^1 || ^2',
181
+ fix: 'npm i -g gulp-cli@2'
182
182
  },
183
183
  node: {
184
184
  range: '^6 || ^8',
@@ -191,9 +191,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
191
191
  }
192
192
  },
193
193
  '1.7.0': {
194
- gulp: {
195
- range: '^3',
196
- fix: 'npm i -g gulp@3'
194
+ gulpCli: {
195
+ range: '^1 || ^2',
196
+ fix: 'npm i -g gulp-cli@2'
197
197
  },
198
198
  node: {
199
199
  range: '^8',
@@ -206,9 +206,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
206
206
  }
207
207
  },
208
208
  '1.7.1': {
209
- gulp: {
210
- range: '^3',
211
- fix: 'npm i -g gulp@3'
209
+ gulpCli: {
210
+ range: '^1 || ^2',
211
+ fix: 'npm i -g gulp-cli@2'
212
212
  },
213
213
  node: {
214
214
  range: '^8',
@@ -221,9 +221,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
221
221
  }
222
222
  },
223
223
  '1.8.0': {
224
- gulp: {
225
- range: '^3',
226
- fix: 'npm i -g gulp@3'
224
+ gulpCli: {
225
+ range: '^1 || ^2',
226
+ fix: 'npm i -g gulp-cli@2'
227
227
  },
228
228
  node: {
229
229
  range: '^8',
@@ -236,9 +236,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
236
236
  }
237
237
  },
238
238
  '1.8.1': {
239
- gulp: {
240
- range: '^3',
241
- fix: 'npm i -g gulp@3'
239
+ gulpCli: {
240
+ range: '^1 || ^2',
241
+ fix: 'npm i -g gulp-cli@2'
242
242
  },
243
243
  node: {
244
244
  range: '^8',
@@ -251,9 +251,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
251
251
  }
252
252
  },
253
253
  '1.8.2': {
254
- gulp: {
255
- range: '^3',
256
- fix: 'npm i -g gulp@3'
254
+ gulpCli: {
255
+ range: '^1 || ^2',
256
+ fix: 'npm i -g gulp-cli@2'
257
257
  },
258
258
  node: {
259
259
  range: '^8 || ^10',
@@ -266,9 +266,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
266
266
  }
267
267
  },
268
268
  '1.9.0': {
269
- gulp: {
270
- range: '^3',
271
- fix: 'npm i -g gulp@3'
269
+ gulpCli: {
270
+ range: '^1 || ^2',
271
+ fix: 'npm i -g gulp-cli@2'
272
272
  },
273
273
  node: {
274
274
  range: '^8 || ^10',
@@ -281,9 +281,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
281
281
  }
282
282
  },
283
283
  '1.9.1': {
284
- gulp: {
285
- range: '^3',
286
- fix: 'npm i -g gulp@3'
284
+ gulpCli: {
285
+ range: '^1 || ^2',
286
+ fix: 'npm i -g gulp-cli@2'
287
287
  },
288
288
  node: {
289
289
  range: '^10',
@@ -296,9 +296,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
296
296
  }
297
297
  },
298
298
  '1.10.0': {
299
- gulp: {
300
- range: '^3',
301
- fix: 'npm i -g gulp@3'
299
+ gulpCli: {
300
+ range: '^1 || ^2',
301
+ fix: 'npm i -g gulp-cli@2'
302
302
  },
303
303
  node: {
304
304
  range: '^10',
@@ -311,9 +311,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
311
311
  }
312
312
  },
313
313
  '1.11.0': {
314
- gulp: {
315
- range: '^3',
316
- fix: 'npm i -g gulp@3'
314
+ gulpCli: {
315
+ range: '^1 || ^2',
316
+ fix: 'npm i -g gulp-cli@2'
317
317
  },
318
318
  node: {
319
319
  range: '^10',
@@ -326,9 +326,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
326
326
  }
327
327
  },
328
328
  '1.12.0': {
329
- gulp: {
330
- range: '^4',
331
- fix: 'npm i -g gulp@4'
329
+ gulpCli: {
330
+ range: '^1 || ^2',
331
+ fix: 'npm i -g gulp-cli@2'
332
332
  },
333
333
  node: {
334
334
  range: '^12',
@@ -341,9 +341,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
341
341
  }
342
342
  },
343
343
  '1.12.1': {
344
- gulp: {
345
- range: '^4',
346
- fix: 'npm i -g gulp@4'
344
+ gulpCli: {
345
+ range: '^1 || ^2',
346
+ fix: 'npm i -g gulp-cli@2'
347
347
  },
348
348
  node: {
349
349
  range: '^12 || ^14',
@@ -356,9 +356,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
356
356
  }
357
357
  },
358
358
  '1.13.0': {
359
- gulp: {
360
- range: '^4',
361
- fix: 'npm i -g gulp@4'
359
+ gulpCli: {
360
+ range: '^1 || ^2',
361
+ fix: 'npm i -g gulp-cli@2'
362
362
  },
363
363
  node: {
364
364
  range: '^12 || ^14',
@@ -371,9 +371,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
371
371
  }
372
372
  },
373
373
  '1.13.1': {
374
- gulp: {
375
- range: '^4',
376
- fix: 'npm i -g gulp@4'
374
+ gulpCli: {
375
+ range: '^1 || ^2',
376
+ fix: 'npm i -g gulp-cli@2'
377
377
  },
378
378
  node: {
379
379
  range: '^12 || ^14',
@@ -386,9 +386,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
386
386
  }
387
387
  },
388
388
  '1.14.0': {
389
- gulp: {
390
- range: '^4',
391
- fix: 'npm i -g gulp@4'
389
+ gulpCli: {
390
+ range: '^1 || ^2',
391
+ fix: 'npm i -g gulp-cli@2'
392
392
  },
393
393
  node: {
394
394
  range: '^12 || ^14',
@@ -401,9 +401,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
401
401
  }
402
402
  },
403
403
  '1.15.0': {
404
- gulp: {
405
- range: '^4',
406
- fix: 'npm i -g gulp@4'
404
+ gulpCli: {
405
+ range: '^1 || ^2',
406
+ fix: 'npm i -g gulp-cli@2'
407
407
  },
408
408
  node: {
409
409
  range: '^12.13 || ^14.15 || ^16.13',
@@ -416,9 +416,9 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
416
416
  }
417
417
  },
418
418
  '1.15.2': {
419
- gulp: {
420
- range: '^4',
421
- fix: 'npm i -g gulp@4'
419
+ gulpCli: {
420
+ range: '^1 || ^2',
421
+ fix: 'npm i -g gulp-cli@2'
422
422
  },
423
423
  node: {
424
424
  range: '^12.13 || ^14.15 || ^16.13',
@@ -472,7 +472,8 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
472
472
  .then(_ => this.checkSharePointCompatibility(spfxVersion, prerequisites, args, fixes, logger))
473
473
  .then(_ => this.checkNodeVersion(prerequisites, fixes, logger))
474
474
  .then(_ => this.checkYo(prerequisites, fixes, logger))
475
- .then(_ => this.checkGulp(prerequisites, fixes, logger))
475
+ .then(_ => this.checkGulp(fixes, logger))
476
+ .then(_ => this.checkGulpCli(prerequisites, fixes, logger))
476
477
  .then(_ => this.checkTypeScript(fixes, logger))
477
478
  .then(_ => {
478
479
  if (fixes.length > 0) {
@@ -534,16 +535,26 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
534
535
  }
535
536
  });
536
537
  }
537
- checkGulp(prerequisites, fixes, logger) {
538
+ checkGulpCli(prerequisites, fixes, logger) {
539
+ return this
540
+ .getPackageVersion('gulp-cli', PackageSearchMode.GlobalOnly, HandlePromise.Continue, logger)
541
+ .then((gulpCliVersion) => {
542
+ if (gulpCliVersion) {
543
+ this.checkStatus('gulp-cli', gulpCliVersion, prerequisites.gulpCli, OptionalOrRequired.Required, fixes, logger);
544
+ }
545
+ else {
546
+ logger.log(this.getStatus(CheckStatus.Failure, `gulp-cli not found`));
547
+ fixes.push(prerequisites.gulpCli.fix);
548
+ }
549
+ });
550
+ }
551
+ checkGulp(fixes, logger) {
538
552
  return this
539
553
  .getPackageVersion('gulp', PackageSearchMode.GlobalOnly, HandlePromise.Continue, logger)
540
554
  .then((gulpVersion) => {
541
555
  if (gulpVersion) {
542
- this.checkStatus('gulp', gulpVersion, prerequisites.gulp, OptionalOrRequired.Required, fixes, logger);
543
- }
544
- else {
545
- logger.log(this.getStatus(CheckStatus.Failure, `gulp not found`));
546
- fixes.push(prerequisites.gulp.fix);
556
+ logger.log(this.getStatus(CheckStatus.Failure, `gulp should be removed`));
557
+ fixes.push('npm un -g gulp');
547
558
  }
548
559
  });
549
560
  }
package/dist/request.js CHANGED
@@ -128,7 +128,8 @@ class Request {
128
128
  return Promise.resolve('');
129
129
  }
130
130
  else {
131
- const resource = Auth_1.Auth.getResourceFromUrl(options.url);
131
+ const url = options.headers && options.headers['x-resource'] ? options.headers['x-resource'] : options.url;
132
+ const resource = Auth_1.Auth.getResourceFromUrl(url);
132
133
  return Auth_1.default.ensureAccessToken(resource, this._logger, this._debug);
133
134
  }
134
135
  })()
@@ -137,7 +138,10 @@ class Request {
137
138
  if (options.headers['x-anonymous']) {
138
139
  delete options.headers['x-anonymous'];
139
140
  }
140
- else {
141
+ if (options.headers['x-resource']) {
142
+ delete options.headers['x-resource'];
143
+ }
144
+ if (accessToken !== '') {
141
145
  options.headers.authorization = `Bearer ${accessToken}`;
142
146
  }
143
147
  }
@@ -0,0 +1,76 @@
1
+ # request
2
+
3
+ Executes the specified web request using CLI for Microsoft 365
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 request [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --url <url>`
14
+ : The request URL.
15
+
16
+ `-m, --method [method]`
17
+ : The HTTP request method. Accepted values are `get, post, put, patch, delete, head, options`. The default value is `get`.
18
+
19
+ `-r, --resource [resource]`
20
+ : The resource uri for which the CLI should acquire a token from AAD in order to access
21
+ the service.
22
+
23
+ `-b, --body [body]`
24
+ : The request body. Optionally use `@example.json` to load the body from a file.
25
+
26
+ `-p, --filePath [filePath]`
27
+ : The file path to save the response to. This option can be used when downloading files.
28
+
29
+ --8<-- "docs/cmd/_global.md"
30
+
31
+ ## Remarks
32
+
33
+ When executing a request, CLI will take care of the very basic configuration, and you'll need to specify all additional information, such as headers, method and body. CLI will take care for you of:
34
+
35
+ - applying compression and handling throttling,
36
+ - setting the `accept` to `application/json` if you don't specify it yourself,
37
+ - setting the `authorization` header to the bearer token obtained for the resource determined from the request URL
38
+
39
+ If you specify the `resource` option, the CLI will try to retrieve a valid token for the resource instead of determining the resource based on the url. The value doesn't have to be a URL. It can be also a URI like `app://<guid>`.
40
+
41
+ Specify additional headers by typing them as options, for example: `--content-type "application/json"`, `--if-match "*"`, `--x-requestdigest "somedigest"`.
42
+
43
+ !!! important
44
+ When building the request, depending on the shell you use, you might need to escape all `$` characters in the URL, request headers, and the body. If you don't do it, the shell will treat it as a variable and will remove the following word from the request, breaking the request.
45
+
46
+ ## Examples
47
+
48
+ Call the SharePoint Rest API using a GET request with a constructed URL containing expands, filters and selects.
49
+
50
+ ```sh
51
+ m365 request --url "https://contoso.sharepoint.com/sites/project-x/_api/web/siteusers?\$filter=IsShareByEmailGuestUser eq true&\$expand=Groups&\$select=Title,LoginName,Email,Groups/LoginName" --accept "application/json;odata=nometadata"
52
+ ```
53
+
54
+ Call the Microsoft Graph beta endpoint using a GET request.
55
+
56
+ ```sh
57
+ m365 request --url "https://graph.microsoft.com/beta/me"
58
+ ```
59
+
60
+ Call the SharePoint API to retrieve a form digest.
61
+
62
+ ```sh
63
+ m365 request --method post --url "https://contoso.sharepoint.com/sites/project-x/_api/contextinfo"
64
+ ```
65
+
66
+ Call the SharePoint API to update a site title.
67
+
68
+ ```sh
69
+ m365 request --method post --url "https://contoso.sharepoint.com/sites/project-x/_api/web" --body '{ "Title": "New title" }' --content-type "application/json" --x-http-method "PATCH"
70
+ ```
71
+
72
+ Call the Microsoft Graph to get a profile photo.
73
+
74
+ ```sh
75
+ m365 request --url "https://graph.microsoft.com/beta/me/photo/\$value" --filePath ./profile-pic.jpg
76
+ ```
@@ -37,7 +37,7 @@ This commands helps you to verify if your environment meets all prerequisites fo
37
37
 
38
38
  The command starts by detecting the version of SharePoint Framework that you want to use. First, it looks at the current project. If you didn't run the command in the context of a SharePoint Framework project, the command will try to determine the SharePoint Framework version based on the SharePoint Framework Yeoman generator that you have installed either in the current directory or globally.
39
39
 
40
- Based on the determined version of the SharePoint Framework, the command will look at other dependencies such as Node.js, npm, Yeoman, Gulp and TypeScript to verify if their meet the requirements of that particular version of the SharePoint Framework.
40
+ Based on the determined version of the SharePoint Framework, the command will look at other dependencies such as Node.js, npm, Yeoman, Gulp CLI and TypeScript to verify if their meet the requirements of that particular version of the SharePoint Framework.
41
41
 
42
42
  If you miss any required tools or use a version that doesn't meet the SharePoint Framework requirements, the command will give you a list of recommendation how to address these issues.
43
43
 
@@ -51,11 +51,11 @@ Next to verifying the readiness of your environment to use a particular version
51
51
  Verify if your environment meets the requirements to work with the SharePoint Framework
52
52
 
53
53
  ```sh
54
- m365 spfx doctor
54
+ m365 spfx doctor --output text
55
55
  ```
56
56
 
57
57
  Verify if your environment meets the requirements to work with the SharePoint Framework and also if the version of the SharePoint Framework that you're using is compatible with SharePoint 2019
58
58
 
59
59
  ```sh
60
- m365 spfx doctor --env sp2019
60
+ m365 spfx doctor --env sp2019 --output text
61
61
  ```
@@ -1,6 +1,6 @@
1
1
  # spo listitem roleassignment remove
2
2
 
3
- Removes a role assignment to a listitem.
3
+ Removes a role assignment from a listitem.
4
4
 
5
5
  ## Usage
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "5.8.0-beta.bc15f2b",
3
+ "version": "5.8.0-beta.c222170",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",
@@ -138,6 +138,7 @@
138
138
  "Kelkar, Vipul <vipul.kelkar@outlook.com>",
139
139
  "Kesavanarayanan, Sudharsan <10280385+sudharsank@users.noreply.github.com>",
140
140
  "Khalil, Bassem <bk@bassems-air.home>",
141
+ "Kirkham, Don <donkirkham@live.com>",
141
142
  "Kumar, Shantha <34408892+ktskumar@users.noreply.github.com>",
142
143
  "Lamber, Patrick <patrick@nubo.eu>",
143
144
  "Laskewitz, Daniel <daniel@laskewitz.nl>",