@pnp/cli-microsoft365 6.1.0-beta.c68d208 → 6.1.0-beta.d86ff3a

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.
@@ -0,0 +1,103 @@
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 _ContextRemoveCommand_instances, _ContextRemoveCommand_initTelemetry, _ContextRemoveCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const fs = require("fs");
19
+ const Cli_1 = require("../../../cli/Cli");
20
+ const Command_1 = require("../../../Command");
21
+ const AnonymousCommand_1 = require("../../base/AnonymousCommand");
22
+ const commands_1 = require("../commands");
23
+ class ContextRemoveCommand extends AnonymousCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.REMOVE;
26
+ }
27
+ get description() {
28
+ return 'Removes the CLI for Microsoft 365 context in the current working folder';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _ContextRemoveCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _ContextRemoveCommand_instances, "m", _ContextRemoveCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _ContextRemoveCommand_instances, "m", _ContextRemoveCommand_initOptions).call(this);
35
+ }
36
+ commandAction(logger, args) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ if (args.options.confirm) {
39
+ yield this.removeContext();
40
+ }
41
+ else {
42
+ const result = yield Cli_1.Cli.prompt({
43
+ type: 'confirm',
44
+ name: 'continue',
45
+ default: false,
46
+ message: `Are you sure you want to remove the context?`
47
+ });
48
+ if (result.continue) {
49
+ yield this.removeContext();
50
+ }
51
+ }
52
+ });
53
+ }
54
+ removeContext() {
55
+ const filePath = '.m365rc.json';
56
+ let m365rc = {};
57
+ if (fs.existsSync(filePath)) {
58
+ try {
59
+ const fileContents = fs.readFileSync(filePath, 'utf8');
60
+ if (fileContents) {
61
+ m365rc = JSON.parse(fileContents);
62
+ }
63
+ }
64
+ catch (e) {
65
+ throw new Command_1.CommandError(`Error reading ${filePath}: ${e}. Please remove context info from ${filePath} manually.`);
66
+ }
67
+ }
68
+ if (!m365rc.context) {
69
+ return;
70
+ }
71
+ const keys = Object.keys(m365rc);
72
+ if (keys.length === 1 && keys.indexOf('context') > -1) {
73
+ try {
74
+ fs.unlinkSync(filePath);
75
+ }
76
+ catch (e) {
77
+ throw new Command_1.CommandError(`Error removing ${filePath}: ${e}. Please remove ${filePath} manually.`);
78
+ }
79
+ }
80
+ else {
81
+ try {
82
+ delete m365rc.context;
83
+ fs.writeFileSync(filePath, JSON.stringify(m365rc, null, 2));
84
+ }
85
+ catch (e) {
86
+ throw new Command_1.CommandError(`Error writing ${filePath}: ${e}. Please remove context info from ${filePath} manually.`);
87
+ }
88
+ }
89
+ }
90
+ }
91
+ _ContextRemoveCommand_instances = new WeakSet(), _ContextRemoveCommand_initTelemetry = function _ContextRemoveCommand_initTelemetry() {
92
+ this.telemetry.push((args) => {
93
+ Object.assign(this.telemetryProperties, {
94
+ confirm: !!args.options.confirm
95
+ });
96
+ });
97
+ }, _ContextRemoveCommand_initOptions = function _ContextRemoveCommand_initOptions() {
98
+ this.options.unshift({
99
+ option: '--confirm'
100
+ });
101
+ };
102
+ module.exports = new ContextRemoveCommand();
103
+ //# sourceMappingURL=context-remove.js.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'context';
4
4
  exports.default = {
5
- INIT: `${prefix} init`
5
+ INIT: `${prefix} init`,
6
+ REMOVE: `${prefix} remove`
6
7
  };
7
8
  //# sourceMappingURL=commands.js.map
@@ -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 _SpoListRetentionLabelSetCommand_instances, _SpoListRetentionLabelSetCommand_initTelemetry, _SpoListRetentionLabelSetCommand_initOptions, _SpoListRetentionLabelSetCommand_initValidators, _SpoListRetentionLabelSetCommand_initOptionSets;
16
+ var _SpoListRetentionLabelEnsureCommand_instances, _SpoListRetentionLabelEnsureCommand_initTelemetry, _SpoListRetentionLabelEnsureCommand_initOptions, _SpoListRetentionLabelEnsureCommand_initValidators, _SpoListRetentionLabelEnsureCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
@@ -21,9 +21,9 @@ const urlUtil_1 = require("../../../../utils/urlUtil");
21
21
  const validation_1 = require("../../../../utils/validation");
22
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
23
23
  const commands_1 = require("../../commands");
24
- class SpoListRetentionLabelSetCommand extends SpoCommand_1.default {
24
+ class SpoListRetentionLabelEnsureCommand extends SpoCommand_1.default {
25
25
  get name() {
26
- return commands_1.default.LIST_RETENTIONLABEL_SET;
26
+ return commands_1.default.LIST_RETENTIONLABEL_ENSURE;
27
27
  }
28
28
  alias() {
29
29
  return [commands_1.default.LIST_LABEL_SET];
@@ -33,15 +33,15 @@ class SpoListRetentionLabelSetCommand extends SpoCommand_1.default {
33
33
  }
34
34
  constructor() {
35
35
  super();
36
- _SpoListRetentionLabelSetCommand_instances.add(this);
37
- __classPrivateFieldGet(this, _SpoListRetentionLabelSetCommand_instances, "m", _SpoListRetentionLabelSetCommand_initTelemetry).call(this);
38
- __classPrivateFieldGet(this, _SpoListRetentionLabelSetCommand_instances, "m", _SpoListRetentionLabelSetCommand_initOptions).call(this);
39
- __classPrivateFieldGet(this, _SpoListRetentionLabelSetCommand_instances, "m", _SpoListRetentionLabelSetCommand_initValidators).call(this);
40
- __classPrivateFieldGet(this, _SpoListRetentionLabelSetCommand_instances, "m", _SpoListRetentionLabelSetCommand_initOptionSets).call(this);
36
+ _SpoListRetentionLabelEnsureCommand_instances.add(this);
37
+ __classPrivateFieldGet(this, _SpoListRetentionLabelEnsureCommand_instances, "m", _SpoListRetentionLabelEnsureCommand_initTelemetry).call(this);
38
+ __classPrivateFieldGet(this, _SpoListRetentionLabelEnsureCommand_instances, "m", _SpoListRetentionLabelEnsureCommand_initOptions).call(this);
39
+ __classPrivateFieldGet(this, _SpoListRetentionLabelEnsureCommand_instances, "m", _SpoListRetentionLabelEnsureCommand_initValidators).call(this);
40
+ __classPrivateFieldGet(this, _SpoListRetentionLabelEnsureCommand_instances, "m", _SpoListRetentionLabelEnsureCommand_initOptionSets).call(this);
41
41
  }
42
42
  commandAction(logger, args) {
43
43
  return __awaiter(this, void 0, void 0, function* () {
44
- this.showDeprecationWarning(logger, commands_1.default.LIST_LABEL_SET, commands_1.default.LIST_RETENTIONLABEL_SET);
44
+ this.showDeprecationWarning(logger, commands_1.default.LIST_LABEL_SET, commands_1.default.LIST_RETENTIONLABEL_ENSURE);
45
45
  try {
46
46
  let listRestUrl = '';
47
47
  let listServerRelativeUrl = '';
@@ -90,7 +90,7 @@ class SpoListRetentionLabelSetCommand extends SpoCommand_1.default {
90
90
  });
91
91
  }
92
92
  }
93
- _SpoListRetentionLabelSetCommand_instances = new WeakSet(), _SpoListRetentionLabelSetCommand_initTelemetry = function _SpoListRetentionLabelSetCommand_initTelemetry() {
93
+ _SpoListRetentionLabelEnsureCommand_instances = new WeakSet(), _SpoListRetentionLabelEnsureCommand_initTelemetry = function _SpoListRetentionLabelEnsureCommand_initTelemetry() {
94
94
  this.telemetry.push((args) => {
95
95
  Object.assign(this.telemetryProperties, {
96
96
  listId: (!(!args.options.listId)).toString(),
@@ -101,7 +101,7 @@ _SpoListRetentionLabelSetCommand_instances = new WeakSet(), _SpoListRetentionLab
101
101
  blockEdit: args.options.blockEdit || false
102
102
  });
103
103
  });
104
- }, _SpoListRetentionLabelSetCommand_initOptions = function _SpoListRetentionLabelSetCommand_initOptions() {
104
+ }, _SpoListRetentionLabelEnsureCommand_initOptions = function _SpoListRetentionLabelEnsureCommand_initOptions() {
105
105
  this.options.unshift({
106
106
  option: '-u, --webUrl <webUrl>'
107
107
  }, {
@@ -119,15 +119,15 @@ _SpoListRetentionLabelSetCommand_instances = new WeakSet(), _SpoListRetentionLab
119
119
  }, {
120
120
  option: '--blockEdit'
121
121
  });
122
- }, _SpoListRetentionLabelSetCommand_initValidators = function _SpoListRetentionLabelSetCommand_initValidators() {
122
+ }, _SpoListRetentionLabelEnsureCommand_initValidators = function _SpoListRetentionLabelEnsureCommand_initValidators() {
123
123
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
124
124
  if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
125
125
  return `${args.options.listId} is not a valid GUID`;
126
126
  }
127
127
  return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
128
128
  }));
129
- }, _SpoListRetentionLabelSetCommand_initOptionSets = function _SpoListRetentionLabelSetCommand_initOptionSets() {
129
+ }, _SpoListRetentionLabelEnsureCommand_initOptionSets = function _SpoListRetentionLabelEnsureCommand_initOptionSets() {
130
130
  this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] });
131
131
  };
132
- module.exports = new SpoListRetentionLabelSetCommand();
133
- //# sourceMappingURL=list-retentionlabel-set.js.map
132
+ module.exports = new SpoListRetentionLabelEnsureCommand();
133
+ //# sourceMappingURL=list-retentionlabel-ensure.js.map
@@ -115,8 +115,8 @@ exports.default = {
115
115
  LIST_LABEL_SET: `${prefix} list label set`,
116
116
  LIST_LIST: `${prefix} list list`,
117
117
  LIST_REMOVE: `${prefix} list remove`,
118
+ LIST_RETENTIONLABEL_ENSURE: `${prefix} list retentionlabel ensure`,
118
119
  LIST_RETENTIONLABEL_GET: `${prefix} list retentionlabel get`,
119
- LIST_RETENTIONLABEL_SET: `${prefix} list retentionlabel set`,
120
120
  LIST_ROLEASSIGNMENT_REMOVE: `${prefix} list roleassignment remove`,
121
121
  LIST_ROLEASSIGNMENT_ADD: `${prefix} list roleassignment add`,
122
122
  LIST_ROLEINHERITANCE_BREAK: `${prefix} list roleinheritance break`,
package/dist/request.js CHANGED
@@ -61,7 +61,8 @@ class Request {
61
61
  this.req = axios_1.default.create({
62
62
  headers: {
63
63
  'user-agent': `NONISV|SharePointPnP|CLIMicrosoft365/${packageJSON.version}`,
64
- 'accept-encoding': 'gzip, deflate'
64
+ 'accept-encoding': 'gzip, deflate',
65
+ 'X-ClientService-ClientTag': `M365CLI:${packageJSON.version}`
65
66
  },
66
67
  decompress: true,
67
68
  responseType: 'text',
@@ -0,0 +1,34 @@
1
+ # context remove
2
+
3
+ Removes the CLI for Microsoft 365 context in the current working folder
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 context remove [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `--confirm`
14
+ : Don't prompt for confirmation to remove the context
15
+
16
+ --8<-- "docs/cmd/_global.md"
17
+
18
+ ## Examples
19
+
20
+ Removes the CLI for Microsoft 365 context in the current working folder
21
+
22
+ ```sh
23
+ m365 context remove
24
+ ```
25
+
26
+ Removes the CLI for Microsoft 365 context in the current working folder and does not prompt for confirmation before deleting.
27
+
28
+ ```sh
29
+ m365 context remove --confirm
30
+ ```
31
+
32
+ ## Response
33
+
34
+ The command won't return a response on success.
@@ -1,11 +1,11 @@
1
- # spo list retentionlabel set
1
+ # spo list retentionlabel ensure
2
2
 
3
3
  Sets a default retention label on the specified list or library.
4
4
 
5
5
  ## Usage
6
6
 
7
7
  ```sh
8
- m365 spo list retentionlabel set [options]
8
+ m365 spo list retentionlabel ensure [options]
9
9
  ```
10
10
 
11
11
  ## Alias
@@ -51,13 +51,13 @@ A list retention label is a default label that will be applied to all new items
51
51
  Sets retention label "Some label" on the list _Shared Documents_ located in site _https://contoso.sharepoint.com/sites/project-x_
52
52
 
53
53
  ```sh
54
- m365 spo list retentionlabel set --webUrl https://contoso.sharepoint.com/sites/project-x --listUrl 'Shared Documents' --label 'Some label'
54
+ m365 spo list retentionlabel ensure --webUrl https://contoso.sharepoint.com/sites/project-x --listUrl 'Shared Documents' --label 'Some label'
55
55
  ```
56
56
 
57
57
  Sets retention label "Some label" and disables editing and deleting items on the list and all existing items for list for list _Documents_ located in site _https://contoso.sharepoint.com/sites/project-x_
58
58
 
59
59
  ```sh
60
- m365 spo list retentionlabel set --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle 'Documents' --label 'Some label' --blockEdit --blockDelete --syncToItems
60
+ m365 spo list retentionlabel ensure --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle 'Documents' --label 'Some label' --blockEdit --blockDelete --syncToItems
61
61
  ```
62
62
 
63
63
  ## Response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "6.1.0-beta.c68d208",
3
+ "version": "6.1.0-beta.d86ff3a",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",