@pnp/cli-microsoft365 7.11.0-beta.c513557 → 8.0.0-beta.630e741

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 (81) hide show
  1. package/.eslintrc.cjs +5 -2
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/Auth.js +2 -10
  5. package/dist/AuthServer.js +10 -10
  6. package/dist/Command.js +10 -10
  7. package/dist/chili/chili.js +0 -23
  8. package/dist/chili/index.js +1 -1
  9. package/dist/cli/cli.js +12 -74
  10. package/dist/index.js +1 -1
  11. package/dist/m365/base/AnonymousCommand.js +1 -1
  12. package/dist/m365/base/DelegatedGraphCommand.js +2 -2
  13. package/dist/m365/base/PowerAppsCommand.js +2 -2
  14. package/dist/m365/base/PowerAutomateCommand.js +2 -2
  15. package/dist/m365/base/PowerBICommand.js +2 -2
  16. package/dist/m365/base/PowerPlatformCommand.js +2 -2
  17. package/dist/m365/base/VivaEngageCommand.js +2 -2
  18. package/dist/m365/cli/commands/cli-consent.js +1 -1
  19. package/dist/m365/commands/login.js +1 -1
  20. package/dist/m365/commands/logout.js +1 -1
  21. package/dist/m365/commands/setup.js +0 -4
  22. package/dist/m365/commands/status.js +1 -1
  23. package/dist/m365/connection/commands/connection-list.js +1 -1
  24. package/dist/m365/connection/commands/connection-remove.js +1 -1
  25. package/dist/m365/connection/commands/connection-set.js +1 -1
  26. package/dist/m365/connection/commands/connection-use.js +1 -1
  27. package/dist/m365/entra/commands/app/app-permission-add.js +21 -1
  28. package/dist/m365/entra/commands/app/app-permission-remove.js +17 -0
  29. package/dist/m365/entra/commands/m365group/m365group-add.js +1 -0
  30. package/dist/m365/entra/commands/m365group/m365group-user-list.js +1 -1
  31. package/dist/m365/external/commands/connection/connection-doctor.js +11 -25
  32. package/dist/m365/external/commands/connection/connection-schema-add.js +4 -4
  33. package/dist/m365/file/commands/file-copy.js +3 -3
  34. package/dist/m365/flow/commands/flow-list.js +21 -23
  35. package/dist/m365/pa/commands/app/app-export.js +1 -1
  36. package/dist/m365/pa/commands/app/app-owner-set.js +1 -1
  37. package/dist/m365/pp/commands/solution/solution-publish.js +1 -1
  38. package/dist/m365/purview/commands/threatassessment/threatassessment-list.js +1 -1
  39. package/dist/m365/spfx/commands/project/base-project-command.js +36 -126
  40. package/dist/m365/spfx/commands/project/project-azuredevops-pipeline-add.js +1 -1
  41. package/dist/m365/spfx/commands/project/project-externalize.js +1 -1
  42. package/dist/m365/spfx/commands/project/project-github-workflow-add.js +1 -1
  43. package/dist/m365/spfx/commands/spfx-doctor.js +4 -4
  44. package/dist/m365/spo/commands/cdn/cdn-get.js +12 -15
  45. package/dist/m365/spo/commands/cdn/cdn-set.js +6 -4
  46. package/dist/m365/spo/commands/commandset/commandset-get.js +1 -1
  47. package/dist/m365/spo/commands/contenttype/contenttype-field-list.js +124 -0
  48. package/dist/m365/spo/commands/field/field-list.js +1 -1
  49. package/dist/m365/spo/commands/file/file-retentionlabel-remove.js +1 -1
  50. package/dist/m365/spo/commands/group/group-member-add.js +103 -99
  51. package/dist/m365/spo/commands/group/group-member-remove.js +2 -2
  52. package/dist/m365/spo/commands/list/list-retentionlabel-ensure.js +1 -1
  53. package/dist/m365/spo/commands/listitem/listitem-batch-remove.js +1 -1
  54. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-ensure.js +2 -2
  55. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-remove.js +2 -2
  56. package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +2 -3
  57. package/dist/m365/spo/commands/page/page-text-add.js +2 -3
  58. package/dist/m365/spo/commands/site/site-commsite-enable.js +1 -1
  59. package/dist/m365/spo/commands/spo-search.js +4 -5
  60. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-set.js +4 -4
  61. package/dist/m365/spo/commands/tenant/tenant-commandset-set.js +2 -2
  62. package/dist/m365/spo/commands/user/user-ensure.js +1 -1
  63. package/dist/m365/spo/commands.js +1 -0
  64. package/dist/m365/teams/commands/chat/chat-member-add.js +1 -1
  65. package/dist/m365/teams/commands/meeting/meeting-attendancereport-get.js +119 -0
  66. package/dist/m365/teams/commands/meeting/meeting-list.js +1 -1
  67. package/dist/m365/teams/commands.js +1 -0
  68. package/dist/m365/viva/commands/engage/engage-community-get.js +1 -1
  69. package/dist/request.js +13 -14
  70. package/dist/utils/formatting.js +14 -1
  71. package/dist/utils/spo.js +5 -5
  72. package/dist/utils/validation.js +25 -0
  73. package/docs/docs/cmd/external/connection/connection-doctor.mdx +9 -9
  74. package/docs/docs/cmd/flow/flow-list.mdx +114 -56
  75. package/docs/docs/cmd/spo/cdn/cdn-set.mdx +3 -3
  76. package/docs/docs/cmd/spo/contenttype/contenttype-field-list.mdx +172 -0
  77. package/docs/docs/cmd/spo/field/field-list.mdx +3 -3
  78. package/docs/docs/cmd/spo/group/group-member-add.mdx +34 -27
  79. package/docs/docs/cmd/teams/meeting/meeting-attendancereport-get.mdx +138 -0
  80. package/npm-shrinkwrap.json +809 -803
  81. package/package.json +13 -13
@@ -32,7 +32,7 @@ class EntraM365GroupUserListCommand extends GraphCommand {
32
32
  await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_LIST, commands.M365GROUP_USER_LIST);
33
33
  try {
34
34
  if (args.options.role === 'Guest') {
35
- this.warn(logger, `Value 'Guest' for the option role is deprecated. Use --filter "userType eq 'Guest'" instead.`);
35
+ await this.warn(logger, `Value 'Guest' for the option role is deprecated. Use --filter "userType eq 'Guest'" instead.`);
36
36
  }
37
37
  const groupId = await this.getGroupId(args.options, logger);
38
38
  const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
@@ -5,11 +5,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
5
5
  };
6
6
  var _ExternalConnectionDoctorCommand_instances, _a, _ExternalConnectionDoctorCommand_initOptions, _ExternalConnectionDoctorCommand_initValidators;
7
7
  import os from 'os';
8
- import { cli } from '../../../../cli/cli.js';
9
8
  import request from '../../../../request.js';
10
- import { settingsNames } from '../../../../settingsNames.js';
11
9
  import GraphCommand from '../../../base/GraphCommand.js';
12
10
  import commands from '../../commands.js';
11
+ import { CheckStatus, formatting } from '../../../../utils/formatting.js';
13
12
  class ExternalConnectionDoctorCommand extends GraphCommand {
14
13
  get name() {
15
14
  return commands.CONNECTION_DOCTOR;
@@ -28,9 +27,7 @@ class ExternalConnectionDoctorCommand extends GraphCommand {
28
27
  const ux = args.options.ux ?? 'all';
29
28
  const output = args.options.output;
30
29
  this.checksStatus = [];
31
- const showSpinner = cli.getSettingWithDefaultValue(settingsNames.showSpinner, true) &&
32
- output === 'text' &&
33
- typeof global.it === 'undefined';
30
+ const show = output === 'text';
34
31
  let checks = [
35
32
  {
36
33
  id: 'loadExternalConnection',
@@ -112,19 +109,12 @@ class ExternalConnectionDoctorCommand extends GraphCommand {
112
109
  checks = checks.filter((check, index, self) => self.findIndex(c => c.id === check.id) === index);
113
110
  for (const check of checks) {
114
111
  if (this.debug) {
115
- logger.logToStderr(`Running check ${check.id}...`);
116
- }
117
- // don't show spinner if running tests
118
- /* c8 ignore next 3 */
119
- if (showSpinner) {
120
- cli.spinner.start(check.text);
112
+ await logger.logToStderr(`Running check ${check.id}...`);
121
113
  }
122
114
  // only automated checks have functions
123
115
  if (!check.fn) {
124
- // don't show spinner if running tests
125
- /* c8 ignore next 3 */
126
- if (showSpinner) {
127
- cli.spinner.info(`${check.text} (manual)`);
116
+ if (show) {
117
+ await logger.log(formatting.getStatus(CheckStatus.Information, `${check.text} (manual)`));
128
118
  }
129
119
  this.checksStatus.push({
130
120
  ...check,
@@ -135,23 +125,19 @@ class ExternalConnectionDoctorCommand extends GraphCommand {
135
125
  const result = await check.fn.bind(this)(check.id, args);
136
126
  this.checksStatus.push({ ...check, ...result });
137
127
  if (result.status === 'passed') {
138
- // don't show spinner if running tests
139
- /* c8 ignore next 3 */
140
- if (showSpinner) {
141
- cli.spinner.succeed();
128
+ if (show) {
129
+ await logger.log(formatting.getStatus(CheckStatus.Success, check.text));
142
130
  }
143
131
  continue;
144
132
  }
145
133
  if (result.status === 'failed') {
146
- // don't show spinner if running tests
147
- /* c8 ignore next 9 */
148
- if (showSpinner) {
134
+ if (show) {
149
135
  const message = `${check.text}: ${result.errorMessage}`;
150
136
  if (check.type === 'required') {
151
- cli.spinner.fail(message);
137
+ await logger.log(formatting.getStatus(CheckStatus.Failure, message));
152
138
  }
153
139
  else {
154
- cli.spinner.warn(message);
140
+ await logger.log(formatting.getStatus(CheckStatus.Warning, check.text));
155
141
  }
156
142
  }
157
143
  if (result.shouldStop) {
@@ -159,7 +145,7 @@ class ExternalConnectionDoctorCommand extends GraphCommand {
159
145
  }
160
146
  }
161
147
  }
162
- if (output === 'text' || output === 'none') {
148
+ if (show || output === 'none') {
163
149
  return;
164
150
  }
165
151
  this.checksStatus.forEach(s => {
@@ -39,19 +39,19 @@ class ExternalConnectionSchemaAddCommand extends GraphCommand {
39
39
  try {
40
40
  const res = await request.patch(requestOptions);
41
41
  const location = res.headers.location;
42
- logger.log(location);
42
+ await logger.log(location);
43
43
  if (!args.options.wait) {
44
44
  return;
45
45
  }
46
46
  let status;
47
47
  do {
48
48
  if (this.verbose) {
49
- logger.logToStderr(`Waiting 60 seconds...`);
49
+ await logger.logToStderr(`Waiting 60 seconds...`);
50
50
  }
51
51
  // waiting 60s before polling as recommended by Microsoft
52
52
  await new Promise(resolve => setTimeout(resolve, 60000));
53
53
  if (this.debug) {
54
- logger.logToStderr(`Checking schema operation status...`);
54
+ await logger.logToStderr(`Checking schema operation status...`);
55
55
  }
56
56
  const operation = await request.get({
57
57
  url: location,
@@ -62,7 +62,7 @@ class ExternalConnectionSchemaAddCommand extends GraphCommand {
62
62
  });
63
63
  status = operation.status;
64
64
  if (this.verbose) {
65
- logger.logToStderr(`Schema operation status: ${status}`);
65
+ await logger.logToStderr(`Schema operation status: ${status}`);
66
66
  }
67
67
  if (status === 'failed') {
68
68
  throw `Provisioning schema failed: ${operation.error?.message}`;
@@ -31,7 +31,7 @@ class FileCopyCommand extends GraphCommand {
31
31
  const sourcePath = this.getAbsoluteUrl(webUrl, sourceUrl);
32
32
  const destinationPath = this.getAbsoluteUrl(webUrl, targetUrl);
33
33
  if (this.verbose) {
34
- logger.logToStderr(`Copying file '${sourcePath}' to '${destinationPath}'...`);
34
+ await logger.logToStderr(`Copying file '${sourcePath}' to '${destinationPath}'...`);
35
35
  }
36
36
  const copyUrl = await this.getCopyUrl(args.options, sourcePath, logger);
37
37
  const { targetDriveId, targetItemId } = await this.getTargetDriveAndItemId(webUrl, targetUrl, logger, verbose);
@@ -83,7 +83,7 @@ class FileCopyCommand extends GraphCommand {
83
83
  }
84
84
  async getDocumentLibrary(siteId, folderUrl, folderUrlFromUser, logger) {
85
85
  if (this.verbose) {
86
- logger.logToStderr(`Getting document library...`);
86
+ await logger.logToStderr(`Getting document library...`);
87
87
  }
88
88
  const requestOptions = {
89
89
  url: `${this.resource}/v1.0/sites/${siteId}/drives?$select=webUrl,id`,
@@ -110,7 +110,7 @@ class FileCopyCommand extends GraphCommand {
110
110
  }
111
111
  async getStartingFolderId(documentLibrary, folderUrl, logger) {
112
112
  if (this.verbose) {
113
- logger.logToStderr(`Getting starting folder id...`);
113
+ await logger.logToStderr(`Getting starting folder id...`);
114
114
  }
115
115
  const documentLibraryRelativeFolderUrl = folderUrl.href.replace(new RegExp(`${documentLibrary.webUrl}`, 'i'), '').replace(/\/+$/, '');
116
116
  const requestOptions = {
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
3
  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");
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _FlowListCommand_instances, _FlowListCommand_initTelemetry, _FlowListCommand_initOptions, _FlowListCommand_initValidators;
6
+ var _FlowListCommand_instances, _FlowListCommand_initTelemetry, _FlowListCommand_initOptions, _FlowListCommand_initValidators, _FlowListCommand_initTypes;
7
7
  import { formatting } from '../../../utils/formatting.js';
8
8
  import { odata } from '../../../utils/odata.js';
9
9
  import PowerAutomateCommand from '../../base/PowerAutomateCommand.js';
@@ -13,7 +13,7 @@ class FlowListCommand extends PowerAutomateCommand {
13
13
  return commands.LIST;
14
14
  }
15
15
  get description() {
16
- return 'Lists Microsoft Flows in the given environment';
16
+ return 'Lists Power Automate flows in the given environment';
17
17
  }
18
18
  defaultProperties() {
19
19
  return ['name', 'displayName'];
@@ -25,8 +25,12 @@ class FlowListCommand extends PowerAutomateCommand {
25
25
  __classPrivateFieldGet(this, _FlowListCommand_instances, "m", _FlowListCommand_initTelemetry).call(this);
26
26
  __classPrivateFieldGet(this, _FlowListCommand_instances, "m", _FlowListCommand_initOptions).call(this);
27
27
  __classPrivateFieldGet(this, _FlowListCommand_instances, "m", _FlowListCommand_initValidators).call(this);
28
+ __classPrivateFieldGet(this, _FlowListCommand_instances, "m", _FlowListCommand_initTypes).call(this);
28
29
  }
29
30
  async commandAction(logger, args) {
31
+ if (this.verbose) {
32
+ await logger.logToStderr(`Getting Power Automate flows${args.options.asAdmin && ' as admin'} in environment '${args.options.environmentName}'...`);
33
+ }
30
34
  try {
31
35
  const { environmentName, asAdmin, sharingStatus, includeSolutions } = args.options;
32
36
  let items = [];
@@ -50,34 +54,25 @@ class FlowListCommand extends PowerAutomateCommand {
50
54
  }
51
55
  // Remove duplicates
52
56
  items = items.filter((flow, index, self) => index === self.findIndex(f => f.id === flow.id));
53
- if (items.length > 0) {
54
- items.forEach(i => {
55
- i.displayName = i.properties.displayName;
57
+ if (args.options.output && args.options.output !== 'json') {
58
+ items.forEach(flow => {
59
+ flow.displayName = flow.properties.displayName;
56
60
  });
57
- await logger.log(items);
58
- }
59
- else {
60
- if (this.verbose) {
61
- await logger.logToStderr('No Flows found');
62
- }
63
61
  }
62
+ await logger.log(items);
64
63
  }
65
64
  catch (err) {
66
65
  this.handleRejectedODataJsonPromise(err);
67
66
  }
68
67
  }
69
68
  getApiUrl(environmentName, asAdmin, includeSolutionFlows, filter) {
70
- let url = `${this.resource}/providers/Microsoft.ProcessSimple${asAdmin ? '/scopes/admin' : ''}/environments/${formatting.encodeQueryParameter(environmentName)}/flows?api-version=2016-11-01`;
71
- if (filter === 'personal') {
72
- url += `&$filter=search('personal')`;
73
- }
74
- else if (filter === 'team') {
75
- url += `&$filter=search('team')`;
76
- }
77
- if (includeSolutionFlows) {
78
- url += '&include=includeSolutionCloudFlows';
79
- }
80
- return url;
69
+ const baseEndpoint = `${this.resource}/providers/Microsoft.ProcessSimple`;
70
+ const environmentSegment = `/environments/${formatting.encodeQueryParameter(environmentName)}`;
71
+ const adminSegment = `/scopes/admin${environmentSegment}/v2`;
72
+ const flowsEndpoint = '/flows?api-version=2016-11-01';
73
+ const filterQuery = filter === 'personal' || filter === 'team' ? `&$filter=search('${filter}')` : '';
74
+ const includeQuery = includeSolutionFlows ? '&include=includeSolutionCloudFlows' : '';
75
+ return `${baseEndpoint}${asAdmin ? adminSegment : environmentSegment}${flowsEndpoint}${filterQuery}${includeQuery}`;
81
76
  }
82
77
  }
83
78
  _FlowListCommand_instances = new WeakSet(), _FlowListCommand_initTelemetry = function _FlowListCommand_initTelemetry() {
@@ -105,10 +100,13 @@ _FlowListCommand_instances = new WeakSet(), _FlowListCommand_initTelemetry = fun
105
100
  return `The options asAdmin and sharingStatus cannot be specified together.`;
106
101
  }
107
102
  if (args.options.sharingStatus && !this.allowedSharingStatuses.some(status => status === args.options.sharingStatus)) {
108
- return `${args.options.sharingStatus} is not a valid sharing status. Allowed values are: ${this.allowedSharingStatuses.join(',')}`;
103
+ return `${args.options.sharingStatus} is not a valid sharing status. Allowed values are: ${this.allowedSharingStatuses.join(', ')}`;
109
104
  }
110
105
  return true;
111
106
  });
107
+ }, _FlowListCommand_initTypes = function _FlowListCommand_initTypes() {
108
+ this.types.string.push('environmentName', 'sharingStatus');
109
+ this.types.boolean.push('includeSolutions', 'asAdmin');
112
110
  };
113
111
  export default new FlowListCommand();
114
112
  //# sourceMappingURL=flow-list.js.map
@@ -128,7 +128,7 @@ class PaAppExportCommand extends PowerPlatformCommand {
128
128
  link = response.properties.packageLink.value;
129
129
  }
130
130
  else {
131
- setTimeout(this.pollingInterval);
131
+ await setTimeout(this.pollingInterval);
132
132
  }
133
133
  if (this.verbose) {
134
134
  await logger.logToStderr(`Current status of the get package link: ${status}`);
@@ -26,7 +26,7 @@ class PaAppOwnerSetCommand extends PowerAppsCommand {
26
26
  }
27
27
  async commandAction(logger, args) {
28
28
  if (this.verbose) {
29
- logger.logToStderr(`Setting new owner ${args.options.userId || args.options.userName} for Power Apps app ${args.options.appName}...`);
29
+ await logger.logToStderr(`Setting new owner ${args.options.userId || args.options.userName} for Power Apps app ${args.options.appName}...`);
30
30
  }
31
31
  try {
32
32
  const userId = await this.getUserId(args.options);
@@ -50,7 +50,7 @@ class PpSolutionPublishCommand extends PowerPlatformCommand {
50
50
  await request.post(requestOptions);
51
51
  }
52
52
  else {
53
- request.post(requestOptions);
53
+ void request.post(requestOptions);
54
54
  }
55
55
  }
56
56
  catch (err) {
@@ -26,7 +26,7 @@ class PurviewThreatAssessmentListCommand extends GraphCommand {
26
26
  }
27
27
  async commandAction(logger, args) {
28
28
  if (this.verbose) {
29
- logger.logToStderr('Retrieving a list of threat assessments');
29
+ await logger.logToStderr('Retrieving a list of threat assessments');
30
30
  }
31
31
  try {
32
32
  const filter = this.getFilterQuery(args.options);
@@ -4,6 +4,7 @@ import { formatting } from '../../../../utils/formatting.js';
4
4
  import { fsUtil } from '../../../../utils/fsUtil.js';
5
5
  import AnonymousCommand from "../../../base/AnonymousCommand.js";
6
6
  import { ScssFile, TsFile } from "./project-model/index.js";
7
+ import { CommandError } from '../../../../Command.js';
7
8
  export class BaseProjectCommand extends AnonymousCommand {
8
9
  constructor() {
9
10
  super(...arguments);
@@ -31,105 +32,17 @@ export class BaseProjectCommand extends AnonymousCommand {
31
32
  }
32
33
  catch { }
33
34
  }
34
- const configJsonPath = path.join(projectRootPath, 'config/config.json');
35
- if (fs.existsSync(configJsonPath)) {
36
- try {
37
- const source = formatting.removeSingleLineComments(fs.readFileSync(configJsonPath, 'utf-8'));
38
- project.configJson = JSON.parse(source);
39
- project.configJson.source = source;
40
- }
41
- catch { }
42
- }
43
- const copyAssetsJsonPath = path.join(projectRootPath, 'config/copy-assets.json');
44
- if (fs.existsSync(copyAssetsJsonPath)) {
45
- try {
46
- const source = formatting.removeSingleLineComments(fs.readFileSync(copyAssetsJsonPath, 'utf-8'));
47
- project.copyAssetsJson = JSON.parse(source);
48
- project.copyAssetsJson.source = source;
49
- }
50
- catch { }
51
- }
52
- const deployAzureStorageJsonPath = path.join(projectRootPath, 'config/deploy-azure-storage.json');
53
- if (fs.existsSync(deployAzureStorageJsonPath)) {
54
- try {
55
- const source = formatting.removeSingleLineComments(fs.readFileSync(deployAzureStorageJsonPath, 'utf-8'));
56
- project.deployAzureStorageJson = JSON.parse(source);
57
- project.deployAzureStorageJson.source = source;
58
- }
59
- catch { }
60
- }
61
- const packageJsonPath = path.join(projectRootPath, 'package.json');
62
- if (fs.existsSync(packageJsonPath)) {
63
- try {
64
- const source = formatting.removeSingleLineComments(fs.readFileSync(packageJsonPath, 'utf-8'));
65
- project.packageJson = JSON.parse(source);
66
- project.packageJson.source = source;
67
- }
68
- catch { }
69
- }
70
- const packageSolutionJsonPath = path.join(projectRootPath, 'config/package-solution.json');
71
- if (fs.existsSync(packageSolutionJsonPath)) {
72
- try {
73
- const source = formatting.removeSingleLineComments(fs.readFileSync(packageSolutionJsonPath, 'utf-8'));
74
- project.packageSolutionJson = JSON.parse(source);
75
- project.packageSolutionJson.source = source;
76
- }
77
- catch { }
78
- }
79
- const serveJsonPath = path.join(projectRootPath, 'config/serve.json');
80
- if (fs.existsSync(serveJsonPath)) {
81
- try {
82
- const source = formatting.removeSingleLineComments(fs.readFileSync(serveJsonPath, 'utf-8'));
83
- project.serveJson = JSON.parse(source);
84
- project.serveJson.source = source;
85
- }
86
- catch { }
87
- }
88
- const tsConfigJsonPath = path.join(projectRootPath, 'tsconfig.json');
89
- if (fs.existsSync(tsConfigJsonPath)) {
90
- try {
91
- const source = formatting.removeSingleLineComments(fs.readFileSync(tsConfigJsonPath, 'utf-8'));
92
- project.tsConfigJson = JSON.parse(source);
93
- project.tsConfigJson.source = source;
94
- }
95
- catch { }
96
- }
97
- const tsLintJsonPath = path.join(projectRootPath, 'config/tslint.json');
98
- if (fs.existsSync(tsLintJsonPath)) {
99
- try {
100
- const source = formatting.removeSingleLineComments(fs.readFileSync(tsLintJsonPath, 'utf-8'));
101
- project.tsLintJson = JSON.parse(source);
102
- project.tsLintJson.source = source;
103
- }
104
- catch { }
105
- }
106
- const tsLintJsonRootPath = path.join(projectRootPath, 'tslint.json');
107
- if (fs.existsSync(tsLintJsonRootPath)) {
108
- try {
109
- const source = formatting.removeSingleLineComments(fs.readFileSync(tsLintJsonRootPath, 'utf-8'));
110
- project.tsLintJsonRoot = JSON.parse(source);
111
- project.tsLintJsonRoot.source = source;
112
- }
113
- catch { }
114
- }
115
- const writeManifestJsonPath = path.join(projectRootPath, 'config/write-manifests.json');
116
- if (fs.existsSync(writeManifestJsonPath)) {
117
- try {
118
- const source = formatting.removeSingleLineComments(fs.readFileSync(writeManifestJsonPath, 'utf-8'));
119
- project.writeManifestsJson = JSON.parse(source);
120
- project.writeManifestsJson.source = source;
121
- }
122
- catch { }
123
- }
124
- const yoRcJsonPath = path.join(projectRootPath, '.yo-rc.json');
125
- if (fs.existsSync(yoRcJsonPath)) {
126
- try {
127
- const source = formatting.removeSingleLineComments(fs.readFileSync(yoRcJsonPath, 'utf-8'));
128
- project.yoRcJson = JSON.parse(source);
129
- project.yoRcJson.source = source;
130
- }
131
- catch { }
132
- }
35
+ this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'config.json'), project, 'configJson');
36
+ this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'copy-assets.json'), project, 'copyAssetsJson');
37
+ this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'deploy-azure-storage.json'), project, 'deployAzureStorageJson');
38
+ this.readAndParseJsonFile(path.join(projectRootPath, 'package.json'), project, 'packageJson');
39
+ this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'package-solution.json'), project, 'packageSolutionJson');
40
+ this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'serve.json'), project, 'serveJson');
41
+ this.readAndParseJsonFile(path.join(projectRootPath, 'tsconfig.json'), project, 'tsConfigJson');
42
+ this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'tslint.json'), project, 'tsLintJson');
43
+ this.readAndParseJsonFile(path.join(projectRootPath, 'tslint.json'), project, 'tsLintJsonRoot');
44
+ this.readAndParseJsonFile(path.join(projectRootPath, 'config', 'write-manifests.json'), project, 'writeManifestsJson');
45
+ this.readAndParseJsonFile(path.join(projectRootPath, '.yo-rc.json'), project, 'yoRcJson');
133
46
  const gulpfileJsPath = path.join(projectRootPath, 'gulpfile.js');
134
47
  if (fs.existsSync(gulpfileJsPath)) {
135
48
  project.gulpfileJs = {
@@ -141,33 +54,9 @@ export class BaseProjectCommand extends AnonymousCommand {
141
54
  project.esLintRcJs = new TsFile(esLintRcJsPath);
142
55
  }
143
56
  project.vsCode = {};
144
- const vsCodeSettingsPath = path.join(projectRootPath, '.vscode', 'settings.json');
145
- if (fs.existsSync(vsCodeSettingsPath)) {
146
- try {
147
- const source = formatting.removeSingleLineComments(fs.readFileSync(vsCodeSettingsPath, 'utf-8'));
148
- project.vsCode.settingsJson = JSON.parse(source);
149
- project.vsCode.settingsJson.source = source;
150
- }
151
- catch { }
152
- }
153
- const vsCodeExtensionsPath = path.join(projectRootPath, '.vscode', 'extensions.json');
154
- if (fs.existsSync(vsCodeExtensionsPath)) {
155
- try {
156
- const source = formatting.removeSingleLineComments(fs.readFileSync(vsCodeExtensionsPath, 'utf-8'));
157
- project.vsCode.extensionsJson = JSON.parse(source);
158
- project.vsCode.extensionsJson.source = source;
159
- }
160
- catch { }
161
- }
162
- const vsCodeLaunchPath = path.join(projectRootPath, '.vscode', 'launch.json');
163
- if (fs.existsSync(vsCodeLaunchPath)) {
164
- try {
165
- const source = formatting.removeSingleLineComments(fs.readFileSync(vsCodeLaunchPath, 'utf-8'));
166
- project.vsCode.launchJson = JSON.parse(source);
167
- project.vsCode.launchJson.source = source;
168
- }
169
- catch { }
170
- }
57
+ this.readAndParseJsonFile(path.join(projectRootPath, '.vscode', 'settings.json'), project, 'vsCode.settingsJson');
58
+ this.readAndParseJsonFile(path.join(projectRootPath, '.vscode', 'extensions.json'), project, 'vsCode.extensionsJson');
59
+ this.readAndParseJsonFile(path.join(projectRootPath, '.vscode', 'launch.json'), project, 'vsCode.launchJson');
171
60
  const srcFiles = fsUtil.readdirR(path.join(projectRootPath, 'src'));
172
61
  const manifestFiles = srcFiles.filter(f => f.endsWith('.manifest.json'));
173
62
  const manifests = manifestFiles.map((f) => {
@@ -233,5 +122,26 @@ export class BaseProjectCommand extends AnonymousCommand {
233
122
  catch { }
234
123
  return undefined;
235
124
  }
125
+ readAndParseJsonFile(filePath, project, keyPath) {
126
+ if (fs.existsSync(filePath)) {
127
+ try {
128
+ const source = formatting.removeSingleLineComments(fs.readFileSync(filePath, 'utf-8'));
129
+ const keys = keyPath.split('.');
130
+ let current = project;
131
+ for (let i = 0; i < keys.length - 1; i++) {
132
+ current = current[keys[i]];
133
+ }
134
+ const finalKey = keys[keys.length - 1];
135
+ current[finalKey] = JSON.parse(source);
136
+ if (typeof current[finalKey] === 'object' && current[finalKey] !== null) {
137
+ current[finalKey].source = source;
138
+ }
139
+ }
140
+ catch (error) {
141
+ throw new CommandError(`The file ${filePath} is not a valid JSON file or is not utf-8 encoded. Error: ${error}`);
142
+ }
143
+ }
144
+ return project;
145
+ }
236
146
  }
237
147
  //# sourceMappingURL=base-project-command.js.map
@@ -37,7 +37,7 @@ class SpfxProjectAzureDevOpsPipelineAddCommand extends BaseProjectCommand {
37
37
  const packageJson = fs.readFileSync(solutionPackageJsonFile, 'utf-8');
38
38
  const solutionName = JSON.parse(packageJson).name;
39
39
  if (this.debug) {
40
- logger.logToStderr(`Adding Azure DevOps pipeline in the current SPFx project`);
40
+ await logger.logToStderr(`Adding Azure DevOps pipeline in the current SPFx project`);
41
41
  }
42
42
  try {
43
43
  this.updatePipeline(solutionName, pipeline, args.options);
@@ -81,7 +81,7 @@ class SpfxProjectExternalizeCommand extends BaseProjectCommand {
81
81
  this.allEditSuggestions.push(...rulesResults.map(x => x.suggestions).reduce((x, y) => [...x, ...y]));
82
82
  //removing duplicates
83
83
  this.allFindings = this.allFindings.filter((x, i) => this.allFindings.findIndex(y => y.key === x.key) === i);
84
- this.writeReport(this.allFindings, this.allEditSuggestions, logger, args.options);
84
+ await this.writeReport(this.allFindings, this.allEditSuggestions, logger, args.options);
85
85
  }
86
86
  catch (err) {
87
87
  throw new CommandError(err);
@@ -40,7 +40,7 @@ class SpfxProjectGithubWorkflowAddCommand extends BaseProjectCommand {
40
40
  const packageJson = fs.readFileSync(solutionPackageJsonFile, 'utf-8');
41
41
  const solutionName = JSON.parse(packageJson).name;
42
42
  if (this.debug) {
43
- logger.logToStderr(`Adding GitHub workflow in the current SPFx project`);
43
+ await logger.logToStderr(`Adding GitHub workflow in the current SPFx project`);
44
44
  }
45
45
  try {
46
46
  this.updateWorkflow(solutionName, workflow, args.options);
@@ -713,7 +713,7 @@ class SpfxDoctorCommand extends BaseProjectCommand {
713
713
  }
714
714
  async checkNodeVersion(prerequisites) {
715
715
  const nodeVersion = this.getNodeVersion();
716
- this.checkStatus('Node', nodeVersion, prerequisites.node);
716
+ await this.checkStatus('Node', nodeVersion, prerequisites.node);
717
717
  }
718
718
  async checkSharePointFrameworkVersion(spfxVersionRequested) {
719
719
  let spfxVersionDetected = await this.getSPFxVersionFromYoRcFile();
@@ -725,7 +725,7 @@ class SpfxDoctorCommand extends BaseProjectCommand {
725
725
  fix: `npm i -g @microsoft/generator-sharepoint@${spfxVersionRequested}`
726
726
  };
727
727
  if (spfxVersionDetected) {
728
- this.checkStatus(`SharePoint Framework`, spfxVersionDetected, versionCheck);
728
+ await this.checkStatus(`SharePoint Framework`, spfxVersionDetected, versionCheck);
729
729
  }
730
730
  else {
731
731
  const message = `SharePoint Framework v${spfxVersionRequested} not found`;
@@ -742,7 +742,7 @@ class SpfxDoctorCommand extends BaseProjectCommand {
742
742
  async checkYo(prerequisites) {
743
743
  const yoVersion = await this.getPackageVersion('yo', PackageSearchMode.GlobalOnly, HandlePromise.Continue);
744
744
  if (yoVersion) {
745
- this.checkStatus('yo', yoVersion, prerequisites.yo);
745
+ await this.checkStatus('yo', yoVersion, prerequisites.yo);
746
746
  }
747
747
  else {
748
748
  const message = 'yo not found';
@@ -758,7 +758,7 @@ class SpfxDoctorCommand extends BaseProjectCommand {
758
758
  async checkGulpCli(prerequisites) {
759
759
  const gulpCliVersion = await this.getPackageVersion('gulp-cli', PackageSearchMode.GlobalOnly, HandlePromise.Continue);
760
760
  if (gulpCliVersion) {
761
- this.checkStatus('gulp-cli', gulpCliVersion, prerequisites.gulpCli);
761
+ await this.checkStatus('gulp-cli', gulpCliVersion, prerequisites.gulpCli);
762
762
  }
763
763
  else {
764
764
  const message = 'gulp-cli not found';
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
3
  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");
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _SpoCdnGetCommand_instances, _SpoCdnGetCommand_initTelemetry, _SpoCdnGetCommand_initOptions, _SpoCdnGetCommand_initValidators;
6
+ var _SpoCdnGetCommand_instances, _SpoCdnGetCommand_initTelemetry, _SpoCdnGetCommand_initOptions, _SpoCdnGetCommand_initValidators, _SpoCdnGetCommand_initTypes;
7
7
  import config from '../../../../config.js';
8
8
  import request from '../../../../request.js';
9
9
  import { spo } from '../../../../utils/spo.js';
@@ -19,9 +19,11 @@ class SpoCdnGetCommand extends SpoCommand {
19
19
  constructor() {
20
20
  super();
21
21
  _SpoCdnGetCommand_instances.add(this);
22
+ this.validTypes = ['Public', 'Private'];
22
23
  __classPrivateFieldGet(this, _SpoCdnGetCommand_instances, "m", _SpoCdnGetCommand_initTelemetry).call(this);
23
24
  __classPrivateFieldGet(this, _SpoCdnGetCommand_instances, "m", _SpoCdnGetCommand_initOptions).call(this);
24
25
  __classPrivateFieldGet(this, _SpoCdnGetCommand_instances, "m", _SpoCdnGetCommand_initValidators).call(this);
26
+ __classPrivateFieldGet(this, _SpoCdnGetCommand_instances, "m", _SpoCdnGetCommand_initTypes).call(this);
25
27
  }
26
28
  async commandAction(logger, args) {
27
29
  const cdnTypeString = args.options.type || 'Public';
@@ -48,15 +50,11 @@ class SpoCdnGetCommand extends SpoCommand {
48
50
  if (response.ErrorInfo) {
49
51
  throw response.ErrorInfo.ErrorMessage;
50
52
  }
51
- else {
52
- const result = json[json.length - 1];
53
- if (this.verbose) {
54
- await logger.logToStderr(`${(cdnType === 0 ? 'Public' : 'Private')} CDN at ${spoAdminUrl} is ${(result === true ? 'enabled' : 'disabled')}`);
55
- }
56
- else {
57
- await logger.logToStderr(result);
58
- }
53
+ const result = json[json.length - 1];
54
+ if (this.verbose) {
55
+ await logger.logToStderr(`${cdnType === 0 ? 'Public' : 'Private'} CDN at ${spoAdminUrl} is ${result === true ? 'enabled' : 'disabled'}`);
59
56
  }
57
+ await logger.log(result);
60
58
  }
61
59
  catch (err) {
62
60
  this.handleRejectedPromise(err);
@@ -72,18 +70,17 @@ _SpoCdnGetCommand_instances = new WeakSet(), _SpoCdnGetCommand_initTelemetry = f
72
70
  }, _SpoCdnGetCommand_initOptions = function _SpoCdnGetCommand_initOptions() {
73
71
  this.options.unshift({
74
72
  option: '-t, --type [type]',
75
- autocomplete: ['Public', 'Private']
73
+ autocomplete: this.validTypes
76
74
  });
77
75
  }, _SpoCdnGetCommand_initValidators = function _SpoCdnGetCommand_initValidators() {
78
76
  this.validators.push(async (args) => {
79
- if (args.options.type) {
80
- if (args.options.type !== 'Public' &&
81
- args.options.type !== 'Private') {
82
- return `${args.options.type} is not a valid CDN type. Allowed values are Public|Private`;
83
- }
77
+ if (args.options.type && !this.validTypes.includes(args.options.type)) {
78
+ return `'${args.options.type}' is not a valid CDN type. Allowed values are: ${this.validTypes.join(', ')}.`;
84
79
  }
85
80
  return true;
86
81
  });
82
+ }, _SpoCdnGetCommand_initTypes = function _SpoCdnGetCommand_initTypes() {
83
+ this.types.string.push('type');
87
84
  };
88
85
  export default new SpoCdnGetCommand();
89
86
  //# sourceMappingURL=cdn-get.js.map