@pnp/cli-microsoft365 5.9.0-beta.7a142b7 → 5.9.0-beta.86c5624

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 (47) hide show
  1. package/.eslintrc.js +13 -0
  2. package/README.md +5 -0
  3. package/dist/appInsights.js +2 -0
  4. package/dist/m365/pp/commands/dataverse/dataverse-table-list.js +75 -0
  5. package/dist/m365/pp/commands/solution/Solution.js +3 -0
  6. package/dist/m365/pp/commands/solution/solution-list.js +87 -0
  7. package/dist/m365/pp/commands/tenant/tenant-settings-list.js +45 -0
  8. package/dist/m365/pp/commands.js +4 -1
  9. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.14.0.js +0 -2
  10. package/dist/m365/spfx/commands/spfx-doctor.js +52 -7
  11. package/dist/m365/spo/commands/eventreceiver/EventReceiver.js +3 -0
  12. package/dist/m365/spo/commands/eventreceiver/eventreceiver-remove.js +182 -0
  13. package/dist/m365/spo/commands/file/file-copy.js +25 -39
  14. package/dist/m365/spo/commands/file/file-move.js +24 -37
  15. package/dist/m365/spo/commands/file/file-rename.js +19 -16
  16. package/dist/m365/spo/commands/file/file-roleassignment-add.js +231 -0
  17. package/dist/m365/spo/commands/file/file-roleassignment-remove.js +180 -0
  18. package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +1 -1
  19. package/dist/m365/spo/commands/folder/folder-roleinheritance-break.js +94 -0
  20. package/dist/m365/spo/commands/folder/folder-roleinheritance-reset.js +89 -0
  21. package/dist/m365/spo/commands/group/AssociatedGroupPropertiesCollection.js +3 -0
  22. package/dist/m365/spo/commands/group/group-list.js +49 -10
  23. package/dist/m365/spo/commands/list/list-roleassignment-add.js +10 -10
  24. package/dist/m365/spo/commands/list/list-roleassignment-remove.js +8 -8
  25. package/dist/m365/spo/commands/listitem/listitem-roleassignment-remove.js +8 -8
  26. package/dist/m365/spo/commands/web/web-roleassignment-add.js +10 -10
  27. package/dist/m365/spo/commands/web/web-roleassignment-remove.js +8 -8
  28. package/dist/m365/spo/commands.js +5 -0
  29. package/dist/utils/cache.js +81 -0
  30. package/dist/utils/pid.js +57 -0
  31. package/dist/utils/powerPlatform.js +42 -0
  32. package/docs/docs/cmd/pp/dataverse/dataverse-table-list.md +33 -0
  33. package/docs/docs/cmd/pp/environment/environment-list.md +1 -1
  34. package/docs/docs/cmd/pp/solution/solution-list.md +33 -0
  35. package/docs/docs/cmd/pp/tenant/tenant-settings-list.md +26 -0
  36. package/docs/docs/cmd/spfx/spfx-doctor.md +10 -1
  37. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-remove.md +69 -0
  38. package/docs/docs/cmd/spo/file/file-roleassignment-add.md +57 -0
  39. package/docs/docs/cmd/spo/file/file-roleassignment-remove.md +54 -0
  40. package/docs/docs/cmd/spo/folder/folder-roleinheritance-break.md +39 -0
  41. package/docs/docs/cmd/spo/folder/folder-roleinheritance-reset.md +36 -0
  42. package/docs/docs/cmd/spo/group/group-list.md +10 -1
  43. package/docs/docs/cmd/spo/hubsite/hubsite-disconnect.md +1 -1
  44. package/docs/docs/cmd/spo/hubsite/hubsite-get.md +3 -3
  45. package/npm-shrinkwrap.json +342 -357
  46. package/package.json +22 -18
  47. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006006_CFG_PS_features.js +0 -60
package/.eslintrc.js CHANGED
@@ -17,6 +17,7 @@ const dictionary = [
17
17
  'content',
18
18
  'conversation',
19
19
  'custom',
20
+ 'dataverse',
20
21
  'default',
21
22
  'external',
22
23
  'externalize',
@@ -61,6 +62,7 @@ const dictionary = [
61
62
  'site',
62
63
  'status',
63
64
  'storage',
65
+ 'table',
64
66
  'teams',
65
67
  'token',
66
68
  'type',
@@ -172,6 +174,17 @@ module.exports = {
172
174
  "eqeqeq": [
173
175
  "error",
174
176
  "always"
177
+ ],
178
+ "@typescript-eslint/naming-convention": [
179
+ "error",
180
+ {
181
+ "selector": [
182
+ "method"
183
+ ],
184
+ "format": [
185
+ "camelCase"
186
+ ]
187
+ }
175
188
  ]
176
189
  },
177
190
  "overrides": [
package/README.md CHANGED
@@ -15,6 +15,11 @@
15
15
  alt="GitHub" />
16
16
  </a>
17
17
 
18
+ <a href="https://discord.com/invite/7rfW4kg6B5">
19
+ <img src="https://img.shields.io/badge/Discord-Join-7289da?style=flat-square"
20
+ alt="Discord" />
21
+ </a>
22
+
18
23
  <a href="https://twitter.com/climicrosoft365">
19
24
  <img src="https://img.shields.io/badge/Twitter-%40climicrosoft365-blue?style=flat-square"
20
25
  alt="Twitter" />
@@ -10,6 +10,7 @@ const appInsights = require("applicationinsights");
10
10
  const crypto = require("crypto");
11
11
  const fs = require("fs");
12
12
  const path = require("path");
13
+ const pid_1 = require("./utils/pid");
13
14
  const config = appInsights.setup('6b908c80-d09f-4cf6-8274-e54349a0149a');
14
15
  config.setInternalLogging(false, false);
15
16
  // append -dev to the version number when ran locally
@@ -20,6 +21,7 @@ const env = process.env.CLIMICROSOFT365_ENV !== undefined ? process.env.CLIMICRO
20
21
  appInsights.defaultClient.commonProperties = {
21
22
  version: version,
22
23
  node: process.version,
24
+ shell: pid_1.pid.getProcessName(process.ppid) || '',
23
25
  env: env,
24
26
  ci: Boolean(process.env.CI).toString()
25
27
  };
@@ -0,0 +1,75 @@
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 _PpDataverseTableListCommand_instances, _PpDataverseTableListCommand_initTelemetry, _PpDataverseTableListCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const powerPlatform_1 = require("../../../../utils/powerPlatform");
20
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
21
+ const commands_1 = require("../../commands");
22
+ class PpDataverseTableListCommand extends PowerPlatformCommand_1.default {
23
+ constructor() {
24
+ super();
25
+ _PpDataverseTableListCommand_instances.add(this);
26
+ __classPrivateFieldGet(this, _PpDataverseTableListCommand_instances, "m", _PpDataverseTableListCommand_initTelemetry).call(this);
27
+ __classPrivateFieldGet(this, _PpDataverseTableListCommand_instances, "m", _PpDataverseTableListCommand_initOptions).call(this);
28
+ }
29
+ get name() {
30
+ return commands_1.default.DATAVERSE_TABLE_LIST;
31
+ }
32
+ get description() {
33
+ return 'Lists dataverse tables in a given environment';
34
+ }
35
+ defaultProperties() {
36
+ return ['SchemaName', 'EntitySetName', 'IsManaged'];
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Retrieving list of tables for which the user is an admin...`);
42
+ }
43
+ const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
44
+ const requestOptions = {
45
+ url: `${dynamicsApiUrl}/api/data/v9.0/EntityDefinitions?$select=MetadataId,IsCustomEntity,IsManaged,SchemaName,IconVectorName,LogicalName,EntitySetName,IsActivity,DataProviderId,IsRenameable,IsCustomizable,CanCreateForms,CanCreateViews,CanCreateCharts,CanCreateAttributes,CanChangeTrackingBeEnabled,CanModifyAdditionalSettings,CanChangeHierarchicalRelationship,CanEnableSyncToExternalSearchIndex&$filter=(IsIntersect eq false and IsLogicalEntity eq false and%0APrimaryNameAttribute ne null and PrimaryNameAttribute ne %27%27 and ObjectTypeCode gt 0 and%0AObjectTypeCode ne 4712 and ObjectTypeCode ne 4724 and ObjectTypeCode ne 9933 and ObjectTypeCode ne 9934 and%0AObjectTypeCode ne 9935 and ObjectTypeCode ne 9947 and ObjectTypeCode ne 9945 and ObjectTypeCode ne 9944 and%0AObjectTypeCode ne 9942 and ObjectTypeCode ne 9951 and ObjectTypeCode ne 2016 and ObjectTypeCode ne 9949 and%0AObjectTypeCode ne 9866 and ObjectTypeCode ne 9867 and ObjectTypeCode ne 9868) and (IsCustomizable/Value eq true or IsCustomEntity eq true or IsManaged eq false or IsMappable/Value eq true or IsRenameable/Value eq true)&api-version=9.1`,
46
+ headers: {
47
+ accept: 'application/json;odata.metadata=none'
48
+ },
49
+ responseType: 'json'
50
+ };
51
+ try {
52
+ const res = yield request_1.default.get(requestOptions);
53
+ logger.log(res.value);
54
+ }
55
+ catch (err) {
56
+ this.handleRejectedODataJsonPromise(err);
57
+ }
58
+ });
59
+ }
60
+ }
61
+ _PpDataverseTableListCommand_instances = new WeakSet(), _PpDataverseTableListCommand_initTelemetry = function _PpDataverseTableListCommand_initTelemetry() {
62
+ this.telemetry.push((args) => {
63
+ Object.assign(this.telemetryProperties, {
64
+ asAdmin: !!args.options.asAdmin
65
+ });
66
+ });
67
+ }, _PpDataverseTableListCommand_initOptions = function _PpDataverseTableListCommand_initOptions() {
68
+ this.options.unshift({
69
+ option: '-e, --environment <environment>'
70
+ }, {
71
+ option: '-a, --asAdmin'
72
+ });
73
+ };
74
+ module.exports = new PpDataverseTableListCommand();
75
+ //# sourceMappingURL=dataverse-table-list.js.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Solution.js.map
@@ -0,0 +1,87 @@
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 _PpSolutionListCommand_instances, _PpSolutionListCommand_initTelemetry, _PpSolutionListCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const powerPlatform_1 = require("../../../../utils/powerPlatform");
20
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
21
+ const commands_1 = require("../../commands");
22
+ class PpSolutionListCommand extends PowerPlatformCommand_1.default {
23
+ constructor() {
24
+ super();
25
+ _PpSolutionListCommand_instances.add(this);
26
+ __classPrivateFieldGet(this, _PpSolutionListCommand_instances, "m", _PpSolutionListCommand_initTelemetry).call(this);
27
+ __classPrivateFieldGet(this, _PpSolutionListCommand_instances, "m", _PpSolutionListCommand_initOptions).call(this);
28
+ }
29
+ get name() {
30
+ return commands_1.default.SOLUTION_LIST;
31
+ }
32
+ get description() {
33
+ return 'Lists solutions in a given environment.';
34
+ }
35
+ defaultProperties() {
36
+ return ['uniquename', 'version', 'publisher'];
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Retrieving list of solutions for which the user is an admin...`);
42
+ }
43
+ try {
44
+ const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
45
+ const requestOptions = {
46
+ url: `${dynamicsApiUrl}/api/data/v9.0/solutions?$filter=isvisible eq true&$expand=publisherid($select=friendlyname)&$select=solutionid,uniquename,version,publisherid,installedon,solutionpackageversion,friendlyname,versionnumber&api-version=9.1`,
47
+ headers: {
48
+ accept: 'application/json;odata.metadata=none'
49
+ },
50
+ responseType: 'json'
51
+ };
52
+ const res = yield request_1.default.get(requestOptions);
53
+ if (!args.options.output || args.options.output === 'json') {
54
+ logger.log(res.value);
55
+ }
56
+ else {
57
+ //converted to text friendly output
58
+ logger.log(res.value.map(i => {
59
+ return {
60
+ uniquename: i.uniquename,
61
+ version: i.version,
62
+ publisher: i.publisherid.friendlyname
63
+ };
64
+ }));
65
+ }
66
+ }
67
+ catch (err) {
68
+ this.handleRejectedODataJsonPromise(err);
69
+ }
70
+ });
71
+ }
72
+ }
73
+ _PpSolutionListCommand_instances = new WeakSet(), _PpSolutionListCommand_initTelemetry = function _PpSolutionListCommand_initTelemetry() {
74
+ this.telemetry.push((args) => {
75
+ Object.assign(this.telemetryProperties, {
76
+ asAdmin: !!args.options.asAdmin
77
+ });
78
+ });
79
+ }, _PpSolutionListCommand_initOptions = function _PpSolutionListCommand_initOptions() {
80
+ this.options.unshift({
81
+ option: '-e, --environment <environment>'
82
+ }, {
83
+ option: '-a, --asAdmin'
84
+ });
85
+ };
86
+ module.exports = new PpSolutionListCommand();
87
+ //# sourceMappingURL=solution-list.js.map
@@ -0,0 +1,45 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const request_1 = require("../../../../request");
13
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
14
+ const commands_1 = require("../../commands");
15
+ class PpTenantSettingsListCommand extends PowerPlatformCommand_1.default {
16
+ get name() {
17
+ return commands_1.default.TENANT_SETTINGS_LIST;
18
+ }
19
+ get description() {
20
+ return 'Lists the global Power Platform tenant settings';
21
+ }
22
+ defaultProperties() {
23
+ return ['disableCapacityAllocationByEnvironmentAdmins', 'disableEnvironmentCreationByNonAdminUsers', 'disableNPSCommentsReachout', 'disablePortalsCreationByNonAdminUsers', 'disableSupportTicketsVisibleByAllUsers', 'disableSurveyFeedback', 'disableTrialEnvironmentCreationByNonAdminUsers', 'walkMeOptOut'];
24
+ }
25
+ commandAction(logger) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const requestOptions = {
28
+ url: `${this.resource}/providers/Microsoft.BusinessAppPlatform/listtenantsettings?api-version=2020-10-01`,
29
+ headers: {
30
+ accept: 'application/json'
31
+ },
32
+ responseType: 'json'
33
+ };
34
+ try {
35
+ const res = yield request_1.default.post(requestOptions);
36
+ logger.log(res);
37
+ }
38
+ catch (err) {
39
+ this.handleRejectedODataJsonPromise(err);
40
+ }
41
+ });
42
+ }
43
+ }
44
+ module.exports = new PpTenantSettingsListCommand();
45
+ //# sourceMappingURL=tenant-settings-list.js.map
@@ -2,9 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'pp';
4
4
  exports.default = {
5
+ DATAVERSE_TABLE_LIST: `${prefix} dataverse table list`,
5
6
  ENVIRONMENT_LIST: `${prefix} environment list`,
6
7
  GATEWAY_LIST: `${prefix} gateway list`,
7
8
  MANAGEMENTAPP_ADD: `${prefix} managementapp add`,
8
- MANAGEMENTAPP_LIST: `${prefix} managementapp list`
9
+ MANAGEMENTAPP_LIST: `${prefix} managementapp list`,
10
+ SOLUTION_LIST: `${prefix} solution list`,
11
+ TENANT_SETTINGS_LIST: `${prefix} tenant settings list`
9
12
  };
10
13
  //# sourceMappingURL=commands.js.map
@@ -25,7 +25,6 @@ const FN002009_DEVDEP_microsoft_sp_tslint_rules_1 = require("./rules/FN002009_DE
25
25
  const FN002019_DEVDEP_spfx_fast_serve_helpers_1 = require("./rules/FN002019_DEVDEP_spfx_fast_serve_helpers");
26
26
  const FN006004_CFG_PS_developer_1 = require("./rules/FN006004_CFG_PS_developer");
27
27
  const FN006005_CFG_PS_metadata_1 = require("./rules/FN006005_CFG_PS_metadata");
28
- const FN006006_CFG_PS_features_1 = require("./rules/FN006006_CFG_PS_features");
29
28
  const FN010001_YORC_version_1 = require("./rules/FN010001_YORC_version");
30
29
  const FN014008_CODE_launch_hostedWorkbench_type_1 = require("./rules/FN014008_CODE_launch_hostedWorkbench_type");
31
30
  module.exports = [
@@ -54,7 +53,6 @@ module.exports = [
54
53
  new FN002019_DEVDEP_spfx_fast_serve_helpers_1.FN002019_DEVDEP_spfx_fast_serve_helpers('1.14.0'),
55
54
  new FN006004_CFG_PS_developer_1.FN006004_CFG_PS_developer('1.14.0'),
56
55
  new FN006005_CFG_PS_metadata_1.FN006005_CFG_PS_metadata(),
57
- new FN006006_CFG_PS_features_1.FN006006_CFG_PS_features(),
58
56
  new FN010001_YORC_version_1.FN010001_YORC_version('1.14.0'),
59
57
  new FN014008_CODE_launch_hostedWorkbench_type_1.FN014008_CODE_launch_hostedWorkbench_type('pwa-chrome')
60
58
  ];
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
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
14
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
15
  };
16
- var _SpfxDoctorCommand_instances, _SpfxDoctorCommand_initTelemetry, _SpfxDoctorCommand_initOptions, _SpfxDoctorCommand_initValidators, _SpfxDoctorCommand_initTypes;
16
+ var _SpfxDoctorCommand_instances, _SpfxDoctorCommand_initTelemetry, _SpfxDoctorCommand_initOptions, _SpfxDoctorCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const chalk = require("chalk");
19
19
  const child_process = require("child_process");
@@ -428,12 +428,26 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
428
428
  range: '^4',
429
429
  fix: 'npm i -g yo@4'
430
430
  }
431
+ },
432
+ '1.16.0-beta.1': {
433
+ gulpCli: {
434
+ range: '^1 || ^2',
435
+ fix: 'npm i -g gulp-cli@2'
436
+ },
437
+ node: {
438
+ range: '^16.13',
439
+ fix: 'Install Node.js v16.13 or higher'
440
+ },
441
+ sp: SharePointVersion.SPO,
442
+ yo: {
443
+ range: '^4',
444
+ fix: 'npm i -g yo@4'
445
+ }
431
446
  }
432
447
  };
433
448
  __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initTelemetry).call(this);
434
449
  __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initOptions).call(this);
435
450
  __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initValidators).call(this);
436
- __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initTypes).call(this);
437
451
  }
438
452
  get name() {
439
453
  return commands_1.default.DOCTOR;
@@ -442,6 +456,7 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
442
456
  return 'Verifies environment configuration for using the specific version of the SharePoint Framework';
443
457
  }
444
458
  commandAction(logger, args) {
459
+ var _a;
445
460
  return __awaiter(this, void 0, void 0, function* () {
446
461
  if (!args.options.output) {
447
462
  args.options.output = 'text';
@@ -454,7 +469,7 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
454
469
  let prerequisites;
455
470
  const fixes = [];
456
471
  try {
457
- spfxVersion = yield this.getSharePointFrameworkVersion(logger);
472
+ spfxVersion = (_a = args.options.spfxVersion) !== null && _a !== void 0 ? _a : yield this.getSharePointFrameworkVersion(logger);
458
473
  if (!spfxVersion) {
459
474
  logger.log(this.getStatus(CheckStatus.Failure, `SharePoint Framework`));
460
475
  throw `SharePoint Framework not found`;
@@ -464,7 +479,13 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
464
479
  logger.log(this.getStatus(CheckStatus.Failure, `SharePoint Framework v${spfxVersion}`));
465
480
  throw `spfx doctor doesn't support SPFx v${spfxVersion} at this moment`;
466
481
  }
467
- logger.log(this.getStatus(CheckStatus.Success, `SharePoint Framework v${spfxVersion}`));
482
+ if (args.options.spfxVersion) {
483
+ yield this.checkSharePointFrameworkVersion(args.options.spfxVersion, fixes, logger);
484
+ }
485
+ else {
486
+ // spfx was detected and if we are here, it means that we support it
487
+ logger.log(this.getStatus(CheckStatus.Success, `SharePoint Framework v${spfxVersion}`));
488
+ }
468
489
  yield this.checkSharePointCompatibility(spfxVersion, prerequisites, args, fixes, logger);
469
490
  yield this.checkNodeVersion(prerequisites, fixes, logger);
470
491
  yield this.checkYo(prerequisites, fixes, logger);
@@ -517,6 +538,23 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
517
538
  this.checkStatus('Node', nodeVersion, prerequisites.node, OptionalOrRequired.Required, fixes, logger);
518
539
  });
519
540
  }
541
+ checkSharePointFrameworkVersion(spfxVersionRequested, fixes, logger) {
542
+ return this
543
+ .getPackageVersion('@microsoft/generator-sharepoint', PackageSearchMode.GlobalOnly, HandlePromise.Continue, logger)
544
+ .then((spfxVersionDetected) => {
545
+ const versionCheck = {
546
+ range: spfxVersionRequested,
547
+ fix: `npm i -g @microsoft/generator-sharepoint@${spfxVersionRequested}`
548
+ };
549
+ if (spfxVersionDetected) {
550
+ this.checkStatus(`SharePoint Framework`, spfxVersionDetected, versionCheck, OptionalOrRequired.Required, fixes, logger);
551
+ }
552
+ else {
553
+ logger.log(this.getStatus(CheckStatus.Failure, `SharePoint Framework v${spfxVersionRequested} not found`));
554
+ fixes.push(versionCheck.fix);
555
+ }
556
+ });
557
+ }
520
558
  checkYo(prerequisites, fixes, logger) {
521
559
  return this
522
560
  .getPackageVersion('yo', PackageSearchMode.GlobalOnly, HandlePromise.Continue, logger)
@@ -695,13 +733,17 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
695
733
  _SpfxDoctorCommand_instances = new WeakSet(), _SpfxDoctorCommand_initTelemetry = function _SpfxDoctorCommand_initTelemetry() {
696
734
  this.telemetry.push((args) => {
697
735
  Object.assign(this.telemetryProperties, {
698
- env: args.options.env
736
+ env: args.options.env,
737
+ spfxVersion: args.options.spfxVersion
699
738
  });
700
739
  });
701
740
  }, _SpfxDoctorCommand_initOptions = function _SpfxDoctorCommand_initOptions() {
702
741
  this.options.unshift({
703
742
  option: '-e, --env [env]',
704
743
  autocomplete: ['sp2016', 'sp2019', 'spo']
744
+ }, {
745
+ option: '-v, --spfxVersion [spfxVersion]',
746
+ autocomplete: Object.keys(this.versions)
705
747
  });
706
748
  }, _SpfxDoctorCommand_initValidators = function _SpfxDoctorCommand_initValidators() {
707
749
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -711,13 +753,16 @@ _SpfxDoctorCommand_instances = new WeakSet(), _SpfxDoctorCommand_initTelemetry =
711
753
  return `${args.options.env} is not a valid SharePoint version. Valid versions are sp2016, sp2019 or spo`;
712
754
  }
713
755
  }
756
+ if (args.options.spfxVersion) {
757
+ if (!this.versions[args.options.spfxVersion]) {
758
+ return `${args.options.spfxVersion} is not a supported SharePoint Framework version. Supported versions are ${Object.keys(this.versions).join(', ')}`;
759
+ }
760
+ }
714
761
  if (args.options.output && args.options.output !== 'text') {
715
762
  return `The output option only accepts the type 'text'`;
716
763
  }
717
764
  return true;
718
765
  }));
719
- }, _SpfxDoctorCommand_initTypes = function _SpfxDoctorCommand_initTypes() {
720
- this.types.string.push('e', 'env');
721
766
  };
722
767
  module.exports = new SpfxDoctorCommand();
723
768
  //# sourceMappingURL=spfx-doctor.js.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=EventReceiver.js.map
@@ -0,0 +1,182 @@
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 _SpoEventreceiverRemoveCommand_instances, _SpoEventreceiverRemoveCommand_initTelemetry, _SpoEventreceiverRemoveCommand_initOptions, _SpoEventreceiverRemoveCommand_initValidators, _SpoEventreceiverRemoveCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const formatting_1 = require("../../../../utils/formatting");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
21
+ const validation_1 = require("../../../../utils/validation");
22
+ const SpoCommand_1 = require("../../../base/SpoCommand");
23
+ const commands_1 = require("../../commands");
24
+ const request_1 = require("../../../../request");
25
+ const getCommand = require('./eventreceiver-get');
26
+ class SpoEventreceiverRemoveCommand extends SpoCommand_1.default {
27
+ constructor() {
28
+ super();
29
+ _SpoEventreceiverRemoveCommand_instances.add(this);
30
+ __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initTelemetry).call(this);
31
+ __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initOptions).call(this);
32
+ __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initValidators).call(this);
33
+ __classPrivateFieldGet(this, _SpoEventreceiverRemoveCommand_instances, "m", _SpoEventreceiverRemoveCommand_initOptionSets).call(this);
34
+ }
35
+ get name() {
36
+ return commands_1.default.EVENTRECEIVER_REMOVE;
37
+ }
38
+ get description() {
39
+ return 'Removes event receivers for the specified web, site, or list.';
40
+ }
41
+ commandAction(logger, args) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ try {
44
+ const getEventReceiversOutput = yield this.getEventReceivers(args.options);
45
+ const eventReceivers = JSON.parse(getEventReceiversOutput.stdout);
46
+ if (!eventReceivers.length) {
47
+ throw Error(`Specified event receiver with ${args.options.id !== undefined ? `id ${args.options.id}` : `name ${args.options.name}`} cannot be found`);
48
+ }
49
+ if (eventReceivers.length > 1) {
50
+ throw Error(`Multiple eventreceivers with ${args.options.id !== undefined ? `id ${args.options.id} found` : `name ${args.options.name}, ids: ${eventReceivers.map(x => x.ReceiverId)} found`}`);
51
+ }
52
+ if (args.options.confirm) {
53
+ yield this.removeEventReceiver(args.options);
54
+ }
55
+ else {
56
+ const result = yield Cli_1.Cli.prompt({
57
+ type: 'confirm',
58
+ name: 'continue',
59
+ default: false,
60
+ message: `Are you sure you want to remove event receiver with ${args.options.id !== undefined ? `id ${args.options.id}` : `name ${args.options.name}`}?`
61
+ });
62
+ if (result.continue) {
63
+ yield this.removeEventReceiver(args.options);
64
+ }
65
+ }
66
+ }
67
+ catch (err) {
68
+ this.handleRejectedODataJsonPromise(err);
69
+ }
70
+ });
71
+ }
72
+ removeEventReceiver(options) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ let requestUrl = `${options.webUrl}/_api/`;
75
+ let listUrl = '';
76
+ let filter = '?$filter=';
77
+ if (options.listId) {
78
+ listUrl = `lists(guid'${formatting_1.formatting.encodeQueryParameter(options.listId)}')/`;
79
+ }
80
+ else if (options.listTitle) {
81
+ listUrl = `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(options.listTitle)}')/`;
82
+ }
83
+ else if (options.listUrl) {
84
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(options.webUrl, options.listUrl);
85
+ listUrl = `GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
86
+ }
87
+ if (!options.scope || options.scope === 'web') {
88
+ requestUrl += `web/${listUrl}eventreceivers`;
89
+ }
90
+ else {
91
+ requestUrl += 'site/eventreceivers';
92
+ }
93
+ if (options.id) {
94
+ filter += `receiverid eq (guid'${options.id}')`;
95
+ }
96
+ else {
97
+ filter += `receivername eq '${options.name}'`;
98
+ }
99
+ const requestOptions = {
100
+ url: requestUrl + filter,
101
+ headers: {
102
+ 'accept': 'application/json;odata=nometadata'
103
+ },
104
+ responseType: 'json'
105
+ };
106
+ yield request_1.default.delete(requestOptions);
107
+ });
108
+ }
109
+ getEventReceivers(options) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ const getOptions = {
112
+ webUrl: options.webUrl,
113
+ listId: options.listId,
114
+ listTitle: options.listTitle,
115
+ listUrl: options.listUrl,
116
+ scope: options.scope,
117
+ id: options.id,
118
+ name: options.name,
119
+ debug: this.debug,
120
+ verbose: this.verbose
121
+ };
122
+ return yield Cli_1.Cli.executeCommandWithOutput(getCommand, { options: Object.assign(Object.assign({}, getOptions), { _: [] }) });
123
+ });
124
+ }
125
+ }
126
+ _SpoEventreceiverRemoveCommand_instances = new WeakSet(), _SpoEventreceiverRemoveCommand_initTelemetry = function _SpoEventreceiverRemoveCommand_initTelemetry() {
127
+ this.telemetry.push((args) => {
128
+ Object.assign(this.telemetryProperties, {
129
+ listId: typeof args.options.listId !== 'undefined',
130
+ listTitle: typeof args.options.listTitle !== 'undefined',
131
+ listUrl: typeof args.options.listUrl !== 'undefined',
132
+ scope: typeof args.options.scope !== 'undefined',
133
+ id: typeof args.options.id !== 'undefined',
134
+ name: typeof args.options.name !== 'undefined',
135
+ confirm: (!(!args.options.confirm)).toString()
136
+ });
137
+ });
138
+ }, _SpoEventreceiverRemoveCommand_initOptions = function _SpoEventreceiverRemoveCommand_initOptions() {
139
+ this.options.unshift({
140
+ option: '-u, --webUrl <webUrl>'
141
+ }, {
142
+ option: '--listTitle [listTitle]'
143
+ }, {
144
+ option: '--listId [listId]'
145
+ }, {
146
+ option: '--listUrl [listUrl]'
147
+ }, {
148
+ option: '-n, --name [name]'
149
+ }, {
150
+ option: '-i, --id [id]'
151
+ }, {
152
+ option: '-s, --scope [scope]',
153
+ autocomplete: ['web', 'site']
154
+ }, {
155
+ option: '--confirm'
156
+ });
157
+ }, _SpoEventreceiverRemoveCommand_initValidators = function _SpoEventreceiverRemoveCommand_initValidators() {
158
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
159
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
160
+ if (isValidSharePointUrl !== true) {
161
+ return isValidSharePointUrl;
162
+ }
163
+ const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
164
+ if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
165
+ return `Specify either list id or title or list url`;
166
+ }
167
+ if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
168
+ return `${args.options.listId} is not a valid GUID`;
169
+ }
170
+ if (args.options.scope && ['web', 'site'].indexOf(args.options.scope) === -1) {
171
+ return `${args.options.scope} is not a valid type value. Allowed values web|site.`;
172
+ }
173
+ if (args.options.scope && args.options.scope === 'site' && (args.options.listId || args.options.listUrl || args.options.listTitle)) {
174
+ return 'Scope cannot be set to site when retrieving list event receivers.';
175
+ }
176
+ return true;
177
+ }));
178
+ }, _SpoEventreceiverRemoveCommand_initOptionSets = function _SpoEventreceiverRemoveCommand_initOptionSets() {
179
+ this.optionSets.push(['name', 'id']);
180
+ };
181
+ module.exports = new SpoEventreceiverRemoveCommand();
182
+ //# sourceMappingURL=eventreceiver-remove.js.map