@pnp/cli-microsoft365 8.0.0-beta.e6f9331 → 8.1.0-beta.3bc5759

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 (60) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/Auth.js +9 -17
  5. package/dist/Command.js +49 -2
  6. package/dist/chili/chili.js +0 -23
  7. package/dist/cli/cli.js +61 -101
  8. package/dist/m365/commands/login.js +44 -96
  9. package/dist/m365/commands/setup.js +0 -4
  10. package/dist/m365/entra/commands/m365group/m365group-set.js +66 -29
  11. package/dist/m365/entra/commands/multitenant/MultitenantOrganization.js +2 -0
  12. package/dist/m365/entra/commands/multitenant/multitenant-get.js +32 -0
  13. package/dist/m365/entra/commands.js +1 -0
  14. package/dist/m365/external/commands/connection/connection-doctor.js +10 -24
  15. package/dist/m365/flow/commands/flow-list.js +2 -1
  16. package/dist/m365/graph/commands/subscription/subscription-add.js +4 -2
  17. package/dist/m365/spe/ContainerTypeProperties.js +2 -0
  18. package/dist/m365/spe/commands/containertype/containertype-list.js +49 -0
  19. package/dist/m365/spe/commands.js +2 -1
  20. package/dist/m365/spfx/commands/project/base-project-command.js +36 -126
  21. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +16 -21
  22. package/dist/m365/spo/commands/commandset/commandset-get.js +31 -17
  23. package/dist/m365/spo/commands/contenttype/contenttype-field-list.js +124 -0
  24. package/dist/m365/spo/commands/field/field-list.js +1 -1
  25. package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +2 -3
  26. package/dist/m365/spo/commands/page/page-text-add.js +2 -3
  27. package/dist/m365/spo/commands/spo-search.js +3 -4
  28. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +19 -5
  29. package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +20 -6
  30. package/dist/m365/spo/commands.js +1 -0
  31. package/dist/m365/teams/commands/meeting/meeting-attendancereport-get.js +119 -0
  32. package/dist/m365/teams/commands/message/message-remove.js +112 -0
  33. package/dist/m365/teams/commands.js +2 -0
  34. package/dist/m365/viva/commands/engage/engage-community-add.js +166 -0
  35. package/dist/m365/viva/commands.js +1 -0
  36. package/dist/utils/formatting.js +30 -1
  37. package/dist/utils/teams.js +49 -0
  38. package/dist/utils/zod.js +124 -0
  39. package/docs/docs/cmd/entra/m365group/m365group-set.mdx +37 -7
  40. package/docs/docs/cmd/entra/multitenant/multitenant-get.mdx +94 -0
  41. package/docs/docs/cmd/external/connection/connection-doctor.mdx +9 -9
  42. package/docs/docs/cmd/graph/subscription/subscription-add.mdx +18 -0
  43. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +131 -0
  44. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +85 -36
  45. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-list.mdx +18 -24
  46. package/docs/docs/cmd/spo/commandset/commandset-get.mdx +75 -24
  47. package/docs/docs/cmd/spo/commandset/commandset-list.mdx +26 -32
  48. package/docs/docs/cmd/spo/contenttype/contenttype-field-list.mdx +172 -0
  49. package/docs/docs/cmd/spo/contenttype/contenttype-list.mdx +3 -3
  50. package/docs/docs/cmd/spo/field/field-list.mdx +3 -3
  51. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-get.mdx +79 -30
  52. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.mdx +20 -19
  53. package/docs/docs/cmd/spo/tenant/tenant-commandset-get.mdx +84 -38
  54. package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +20 -19
  55. package/docs/docs/cmd/teams/meeting/meeting-attendancereport-get.mdx +138 -0
  56. package/docs/docs/cmd/teams/meeting/meeting-list.mdx +7 -3
  57. package/docs/docs/cmd/teams/message/message-remove.mdx +63 -0
  58. package/docs/docs/cmd/viva/engage/engage-community-add.mdx +168 -0
  59. package/npm-shrinkwrap.json +590 -1024
  60. package/package.json +7 -3
@@ -42,8 +42,6 @@ class SetupCommand extends AnonymousCommand {
42
42
  await this.configureSettings(settings, true, logger);
43
43
  return;
44
44
  }
45
- // stop the spinner. Fixes #5598
46
- cli.spinner.stop();
47
45
  await logger.logToStderr(`Welcome to the CLI for Microsoft 365 setup!`);
48
46
  await logger.logToStderr(`This command will guide you through the process of configuring the CLI for your needs.`);
49
47
  await logger.logToStderr(`Please, answer the following questions and we'll define a set of settings to best match how you intend to use the CLI.`);
@@ -85,8 +83,6 @@ class SetupCommand extends AnonymousCommand {
85
83
  await logger.logToStderr('');
86
84
  await logger.logToStderr('Configuring settings...');
87
85
  await logger.logToStderr('');
88
- // start the spinner. Fixes #5598
89
- cli.spinner.start();
90
86
  await this.configureSettings(settings, false, logger);
91
87
  if (!this.verbose) {
92
88
  await logger.logToStderr('');
@@ -13,6 +13,8 @@ import GraphCommand from '../../../base/GraphCommand.js';
13
13
  import commands from '../../commands.js';
14
14
  import { entraGroup } from '../../../../utils/entraGroup.js';
15
15
  import aadCommands from '../../aadCommands.js';
16
+ import { accessToken } from '../../../../utils/accessToken.js';
17
+ import auth from '../../../../Auth.js';
16
18
  class EntraM365GroupSetCommand extends GraphCommand {
17
19
  get name() {
18
20
  return commands.M365GROUP_SET;
@@ -35,22 +37,22 @@ class EntraM365GroupSetCommand extends GraphCommand {
35
37
  async commandAction(logger, args) {
36
38
  await this.showDeprecationWarning(logger, aadCommands.M365GROUP_SET, commands.M365GROUP_SET);
37
39
  try {
40
+ if ((args.options.allowExternalSenders !== undefined || args.options.autoSubscribeNewMembers !== undefined) && accessToken.isAppOnlyAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken)) {
41
+ throw `Option 'allowExternalSenders' and 'autoSubscribeNewMembers' can only be used when using delegated permissions.`;
42
+ }
38
43
  const isUnifiedGroup = await entraGroup.isUnifiedGroup(args.options.id);
39
44
  if (!isUnifiedGroup) {
40
45
  throw Error(`Specified group with id '${args.options.id}' is not a Microsoft 365 group.`);
41
46
  }
42
- if (args.options.displayName || args.options.description || typeof args.options.isPrivate !== 'undefined') {
43
- if (this.verbose) {
44
- await logger.logToStderr(`Updating Microsoft 365 Group ${args.options.id}...`);
45
- }
46
- const update = {};
47
- if (args.options.displayName) {
48
- update.displayName = args.options.displayName;
49
- }
50
- if (args.options.description) {
51
- update.description = args.options.description;
52
- }
53
- if (typeof args.options.isPrivate !== 'undefined') {
47
+ if (this.verbose) {
48
+ await logger.logToStderr(`Updating Microsoft 365 Group ${args.options.id}...`);
49
+ }
50
+ if (args.options.displayName || args.options.description !== undefined || args.options.isPrivate !== undefined) {
51
+ const update = {
52
+ displayName: args.options.displayName,
53
+ description: args.options.description !== '' ? args.options.description : null
54
+ };
55
+ if (args.options.isPrivate !== undefined) {
54
56
  update.visibility = args.options.isPrivate ? 'Private' : 'Public';
55
57
  }
56
58
  const requestOptions = {
@@ -63,6 +65,24 @@ class EntraM365GroupSetCommand extends GraphCommand {
63
65
  };
64
66
  await request.patch(requestOptions);
65
67
  }
68
+ // This has to be a separate request due to some Graph API limitations. Otherwise it will throw an error.
69
+ if (args.options.allowExternalSenders !== undefined || args.options.autoSubscribeNewMembers !== undefined || args.options.hideFromAddressLists !== undefined || args.options.hideFromOutlookClients !== undefined) {
70
+ const requestBody = {
71
+ allowExternalSenders: args.options.allowExternalSenders,
72
+ autoSubscribeNewMembers: args.options.autoSubscribeNewMembers,
73
+ hideFromAddressLists: args.options.hideFromAddressLists,
74
+ hideFromOutlookClients: args.options.hideFromOutlookClients
75
+ };
76
+ const requestOptions = {
77
+ url: `${this.resource}/v1.0/groups/${args.options.id}`,
78
+ headers: {
79
+ accept: 'application/json;odata.metadata=none'
80
+ },
81
+ responseType: 'json',
82
+ data: requestBody
83
+ };
84
+ await request.patch(requestOptions);
85
+ }
66
86
  if (args.options.logoPath) {
67
87
  const fullPath = path.resolve(args.options.logoPath);
68
88
  if (this.verbose) {
@@ -172,8 +192,12 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
172
192
  description: typeof args.options.description !== 'undefined',
173
193
  owners: typeof args.options.owners !== 'undefined',
174
194
  members: typeof args.options.members !== 'undefined',
175
- isPrivate: args.options.isPrivate,
176
- logoPath: typeof args.options.logoPath !== 'undefined'
195
+ isPrivate: !!args.options.isPrivate,
196
+ logoPath: typeof args.options.logoPath !== 'undefined',
197
+ allowExternalSenders: !!args.options.allowExternalSenders,
198
+ autoSubscribeNewMembers: !!args.options.autoSubscribeNewMembers,
199
+ hideFromAddressLists: !!args.options.hideFromAddressLists,
200
+ hideFromOutlookClients: !!args.options.hideFromOutlookClients
177
201
  });
178
202
  });
179
203
  }, _EntraM365GroupSetCommand_initOptions = function _EntraM365GroupSetCommand_initOptions() {
@@ -192,36 +216,49 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
192
216
  autocomplete: ['true', 'false']
193
217
  }, {
194
218
  option: '-l, --logoPath [logoPath]'
219
+ }, {
220
+ option: '--allowExternalSenders [allowExternalSenders]',
221
+ autocomplete: ['true', 'false']
222
+ }, {
223
+ option: '--autoSubscribeNewMembers [autoSubscribeNewMembers]',
224
+ autocomplete: ['true', 'false']
225
+ }, {
226
+ option: '--hideFromAddressLists [hideFromAddressLists]',
227
+ autocomplete: ['true', 'false']
228
+ }, {
229
+ option: '--hideFromOutlookClients [hideFromOutlookClients]',
230
+ autocomplete: ['true', 'false']
195
231
  });
196
232
  }, _EntraM365GroupSetCommand_initTypes = function _EntraM365GroupSetCommand_initTypes() {
197
- this.types.boolean.push('isPrivate');
233
+ this.types.boolean.push('isPrivate', 'allowEternalSenders', 'autoSubscribeNewMembers', 'hideFromAddressLists', 'hideFromOutlookClients');
234
+ this.types.string.push('id', 'displayName', 'description', 'owners', 'members', 'logoPath');
198
235
  }, _EntraM365GroupSetCommand_initValidators = function _EntraM365GroupSetCommand_initValidators() {
199
236
  this.validators.push(async (args) => {
200
237
  if (!args.options.displayName &&
201
- !args.options.description &&
238
+ args.options.description === undefined &&
202
239
  !args.options.members &&
203
240
  !args.options.owners &&
204
- typeof args.options.isPrivate === 'undefined' &&
205
- !args.options.logoPath) {
206
- return 'Specify at least one property to update';
241
+ args.options.isPrivate === undefined &&
242
+ !args.options.logoPath &&
243
+ args.options.allowExternalSenders === undefined &&
244
+ args.options.autoSubscribeNewMembers === undefined &&
245
+ args.options.hideFromAddressLists === undefined &&
246
+ args.options.hideFromOutlookClients === undefined) {
247
+ return 'Specify at least one option to update.';
207
248
  }
208
249
  if (!validation.isValidGuid(args.options.id)) {
209
250
  return `${args.options.id} is not a valid GUID`;
210
251
  }
211
252
  if (args.options.owners) {
212
- const owners = args.options.owners.split(',').map(o => o.trim());
213
- for (let i = 0; i < owners.length; i++) {
214
- if (owners[i].indexOf('@') < 0) {
215
- return `${owners[i]} is not a valid userPrincipalName`;
216
- }
253
+ const isValidArray = validation.isValidUserPrincipalNameArray(args.options.owners);
254
+ if (isValidArray !== true) {
255
+ return `Option 'owners' contains one or more invalid UPNs: ${isValidArray}.`;
217
256
  }
218
257
  }
219
258
  if (args.options.members) {
220
- const members = args.options.members.split(',').map(m => m.trim());
221
- for (let i = 0; i < members.length; i++) {
222
- if (members[i].indexOf('@') < 0) {
223
- return `${members[i]} is not a valid userPrincipalName`;
224
- }
259
+ const isValidArray = validation.isValidUserPrincipalNameArray(args.options.members);
260
+ if (isValidArray !== true) {
261
+ return `Option 'members' contains one or more invalid UPNs: ${isValidArray}.`;
225
262
  }
226
263
  }
227
264
  if (args.options.logoPath) {
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MultitenantOrganization.js.map
@@ -0,0 +1,32 @@
1
+ import request from '../../../../request.js';
2
+ import GraphCommand from '../../../base/GraphCommand.js';
3
+ import commands from '../../commands.js';
4
+ class EntraMultitenantGetCommand extends GraphCommand {
5
+ get name() {
6
+ return commands.MULTITENANT_GET;
7
+ }
8
+ get description() {
9
+ return 'Gets properties of the multitenant organization';
10
+ }
11
+ async commandAction(logger) {
12
+ const requestOptions = {
13
+ url: `${this.resource}/v1.0/tenantRelationships/multiTenantOrganization`,
14
+ headers: {
15
+ accept: 'application/json;odata.metadata=none'
16
+ },
17
+ responseType: 'json'
18
+ };
19
+ try {
20
+ if (this.verbose) {
21
+ await logger.logToStderr('Retrieving multitenant organization...');
22
+ }
23
+ const multitenantOrg = await request.get(requestOptions);
24
+ await logger.log(multitenantOrg);
25
+ }
26
+ catch (err) {
27
+ this.handleRejectedODataJsonPromise(err);
28
+ }
29
+ }
30
+ }
31
+ export default new EntraMultitenantGetCommand();
32
+ //# sourceMappingURL=multitenant-get.js.map
@@ -72,6 +72,7 @@ export default {
72
72
  M365GROUP_USER_LIST: `${prefix} m365group user list`,
73
73
  M365GROUP_USER_REMOVE: `${prefix} m365group user remove`,
74
74
  M365GROUP_USER_SET: `${prefix} m365group user set`,
75
+ MULTITENANT_GET: `${prefix} multitenant get`,
75
76
  OAUTH2GRANT_ADD: `${prefix} oauth2grant add`,
76
77
  OAUTH2GRANT_LIST: `${prefix} oauth2grant list`,
77
78
  OAUTH2GRANT_REMOVE: `${prefix} oauth2grant remove`,
@@ -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',
@@ -114,17 +111,10 @@ class ExternalConnectionDoctorCommand extends GraphCommand {
114
111
  if (this.debug) {
115
112
  await logger.logToStderr(`Running check ${check.id}...`);
116
113
  }
117
- // don't show spinner if running tests
118
- /* c8 ignore next 3 */
119
- if (showSpinner) {
120
- cli.spinner.start(check.text);
121
- }
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 => {
@@ -46,7 +46,8 @@ class FlowListCommand extends PowerAutomateCommand {
46
46
  let url = this.getApiUrl(environmentName, asAdmin, includeSolutions, 'personal');
47
47
  items = await odata.getAllItems(url);
48
48
  url = this.getApiUrl(environmentName, asAdmin, includeSolutions, 'team');
49
- items = await odata.getAllItems(url);
49
+ const teamFlows = await odata.getAllItems(url);
50
+ items = items.concat(teamFlows);
50
51
  }
51
52
  else {
52
53
  const url = this.getApiUrl(environmentName, asAdmin, includeSolutions);
@@ -141,8 +141,10 @@ _GraphSubscriptionAddCommand_instances = new WeakSet(), _GraphSubscriptionAddCom
141
141
  });
142
142
  }, _GraphSubscriptionAddCommand_initValidators = function _GraphSubscriptionAddCommand_initValidators() {
143
143
  this.validators.push(async (args) => {
144
- if (args.options.notificationUrl.indexOf('https://') !== 0) {
145
- return `The specified notification URL '${args.options.notificationUrl}' does not start with 'https://'`;
144
+ if (!args.options.notificationUrl.toLowerCase().startsWith('https://')
145
+ && !args.options.notificationUrl.toLowerCase().startsWith('eventhub:https://')
146
+ && !args.options.notificationUrl.toLowerCase().startsWith('eventgrid:?azuresubscriptionid=')) {
147
+ return `The specified notification URL '${args.options.notificationUrl}' does not start with either 'https://' or 'EventHub:https://' or 'EventGrid:?azuresubscriptionid='`;
146
148
  }
147
149
  if (!this.isValidChangeTypes(args.options.changeTypes)) {
148
150
  return `The specified changeTypes are invalid. Valid options are 'created', 'updated' and 'deleted'`;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ContainerTypeProperties.js.map
@@ -0,0 +1,49 @@
1
+ import config from '../../../../config.js';
2
+ import request from '../../../../request.js';
3
+ import { spo } from '../../../../utils/spo.js';
4
+ import SpoCommand from '../../../base/SpoCommand.js';
5
+ import commands from '../../commands.js';
6
+ class SpeContainertypeListCommand extends SpoCommand {
7
+ get name() {
8
+ return commands.CONTAINERTYPE_LIST;
9
+ }
10
+ get description() {
11
+ return 'Lists all Container Types';
12
+ }
13
+ defaultProperties() {
14
+ return ['ContainerTypeId', 'DisplayName', 'OwningAppId'];
15
+ }
16
+ async commandAction(logger) {
17
+ try {
18
+ const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
19
+ if (this.verbose) {
20
+ await logger.logToStderr(`Retrieving list of Container types...`);
21
+ }
22
+ const allContainerTypes = await this.getAllContainerTypes(spoAdminUrl, logger);
23
+ await logger.log(allContainerTypes);
24
+ }
25
+ catch (err) {
26
+ this.handleRejectedPromise(err);
27
+ }
28
+ }
29
+ async getAllContainerTypes(spoAdminUrl, logger) {
30
+ const formDigestInfo = await spo.ensureFormDigest(spoAdminUrl, logger, undefined, this.debug);
31
+ const requestOptions = {
32
+ url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
33
+ headers: {
34
+ 'X-RequestDigest': formDigestInfo.FormDigestValue
35
+ },
36
+ data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="46" ObjectPathId="45" /><Method Name="GetSPOContainerTypes" Id="47" ObjectPathId="45"><Parameters><Parameter Type="Enum">1</Parameter></Parameters></Method></Actions><ObjectPaths><Constructor Id="45" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
37
+ };
38
+ const res = await request.post(requestOptions);
39
+ const json = JSON.parse(res);
40
+ const response = json[0];
41
+ if (response.ErrorInfo) {
42
+ throw response.ErrorInfo.ErrorMessage;
43
+ }
44
+ const containerTypes = json[json.length - 1];
45
+ return containerTypes;
46
+ }
47
+ }
48
+ export default new SpeContainertypeListCommand();
49
+ //# sourceMappingURL=containertype-list.js.map
@@ -1,5 +1,6 @@
1
1
  const prefix = 'spe';
2
2
  export default {
3
- CONTAINERTYPE_ADD: `${prefix} containertype add`
3
+ CONTAINERTYPE_ADD: `${prefix} containertype add`,
4
+ CONTAINERTYPE_LIST: `${prefix} containertype list`
4
5
  };
5
6
  //# sourceMappingURL=commands.js.map
@@ -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