@pnp/cli-microsoft365 6.11.0-beta.259c884 → 6.11.0-beta.2d03676
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.
- package/dist/m365/spfx/commands/project/DeployWorkflow.js +58 -0
- package/dist/m365/spfx/commands/project/project-github-workflow-add.js +171 -0
- package/dist/m365/spfx/commands/project/project-github-workflow-model.js +3 -0
- package/dist/m365/spfx/commands.js +1 -0
- package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-set.js +32 -32
- package/dist/m365/spo/commands/site/site-add.js +113 -154
- package/dist/m365/spo/commands/site/site-apppermission-add.js +26 -27
- package/dist/m365/spo/commands/site/site-apppermission-remove.js +37 -37
- package/dist/m365/spo/commands/site/site-apppermission-set.js +15 -16
- package/dist/m365/spo/commands/site/site-ensure.js +18 -69
- package/dist/m365/spo/commands/site/site-remove.js +139 -171
- package/dist/m365/spo/commands/site/site-set.js +134 -146
- package/dist/utils/aadGroup.js +20 -0
- package/dist/utils/fsUtil.js +5 -0
- package/dist/utils/spo.js +600 -0
- package/docs/docs/cmd/spfx/project/project-github-workflow-add.mdx +94 -0
- package/npm-shrinkwrap.json +15 -1
- package/package.json +3 -2
|
@@ -39,40 +39,39 @@ class SpoSiteAppPermissionAddCommand extends GraphCommand_1.default {
|
|
|
39
39
|
__classPrivateFieldGet(this, _SpoSiteAppPermissionAddCommand_instances, "m", _SpoSiteAppPermissionAddCommand_initOptionSets).call(this);
|
|
40
40
|
}
|
|
41
41
|
getAppInfo(args) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
.get(appRequestOptions)
|
|
64
|
-
.then(response => {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (args.options.appId && args.options.appDisplayName) {
|
|
44
|
+
return {
|
|
45
|
+
appId: args.options.appId,
|
|
46
|
+
displayName: args.options.appDisplayName
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
let endpoint = "";
|
|
50
|
+
if (args.options.appId) {
|
|
51
|
+
endpoint = `${this.resource}/v1.0/myorganization/servicePrincipals?$select=appId,displayName&$filter=appId eq '${formatting_1.formatting.encodeQueryParameter(args.options.appId)}'`;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
endpoint = `${this.resource}/v1.0/myorganization/servicePrincipals?$select=appId,displayName&$filter=displayName eq '${formatting_1.formatting.encodeQueryParameter(args.options.appDisplayName)}'`;
|
|
55
|
+
}
|
|
56
|
+
const appRequestOptions = {
|
|
57
|
+
url: endpoint,
|
|
58
|
+
headers: {
|
|
59
|
+
accept: 'application/json;odata.metadata=none'
|
|
60
|
+
},
|
|
61
|
+
responseType: 'json'
|
|
62
|
+
};
|
|
63
|
+
const response = yield request_1.default.get(appRequestOptions);
|
|
65
64
|
const appItem = response.value[0];
|
|
66
65
|
if (!appItem) {
|
|
67
|
-
|
|
66
|
+
throw "The specified Azure AD app does not exist";
|
|
68
67
|
}
|
|
69
68
|
if (response.value.length > 1) {
|
|
70
|
-
|
|
69
|
+
throw `Multiple Azure AD app with displayName ${args.options.appDisplayName} found: ${response.value.map(x => x.appId)}`;
|
|
71
70
|
}
|
|
72
|
-
return
|
|
71
|
+
return {
|
|
73
72
|
appId: appItem.appId,
|
|
74
73
|
displayName: appItem.displayName
|
|
75
|
-
}
|
|
74
|
+
};
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
77
|
/**
|
|
@@ -31,15 +31,14 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand_1.default {
|
|
|
31
31
|
constructor() {
|
|
32
32
|
super();
|
|
33
33
|
_SpoSiteAppPermissionRemoveCommand_instances.add(this);
|
|
34
|
-
this.siteId = '';
|
|
35
34
|
__classPrivateFieldGet(this, _SpoSiteAppPermissionRemoveCommand_instances, "m", _SpoSiteAppPermissionRemoveCommand_initTelemetry).call(this);
|
|
36
35
|
__classPrivateFieldGet(this, _SpoSiteAppPermissionRemoveCommand_instances, "m", _SpoSiteAppPermissionRemoveCommand_initOptions).call(this);
|
|
37
36
|
__classPrivateFieldGet(this, _SpoSiteAppPermissionRemoveCommand_instances, "m", _SpoSiteAppPermissionRemoveCommand_initValidators).call(this);
|
|
38
37
|
__classPrivateFieldGet(this, _SpoSiteAppPermissionRemoveCommand_instances, "m", _SpoSiteAppPermissionRemoveCommand_initOptionSets).call(this);
|
|
39
38
|
}
|
|
40
|
-
getPermissions() {
|
|
39
|
+
getPermissions(siteId) {
|
|
41
40
|
const requestOptions = {
|
|
42
|
-
url: `${this.resource}/v1.0/sites/${
|
|
41
|
+
url: `${this.resource}/v1.0/sites/${siteId}/permissions`,
|
|
43
42
|
headers: {
|
|
44
43
|
accept: 'application/json;odata.metadata=none'
|
|
45
44
|
},
|
|
@@ -47,34 +46,33 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand_1.default {
|
|
|
47
46
|
};
|
|
48
47
|
return request_1.default.get(requestOptions);
|
|
49
48
|
}
|
|
50
|
-
getFilteredPermissions(
|
|
49
|
+
getFilteredPermissions(options, permissions) {
|
|
51
50
|
let filterProperty = 'displayName';
|
|
52
|
-
let filterValue =
|
|
53
|
-
if (
|
|
51
|
+
let filterValue = options.appDisplayName;
|
|
52
|
+
if (options.appId) {
|
|
54
53
|
filterProperty = 'id';
|
|
55
|
-
filterValue =
|
|
54
|
+
filterValue = options.appId;
|
|
56
55
|
}
|
|
57
56
|
return permissions.filter((p) => {
|
|
58
57
|
return p.grantedToIdentities.some(({ application }) => application[filterProperty] === filterValue);
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
|
-
getPermissionIds(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
.getPermissions()
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
permissions = this.getFilteredPermissions(args, res.value);
|
|
60
|
+
getPermissionIds(siteId, options) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
if (options.id) {
|
|
63
|
+
return Promise.resolve([options.id]);
|
|
64
|
+
}
|
|
65
|
+
const permissionsObject = yield this.getPermissions(siteId);
|
|
66
|
+
let permissions = permissionsObject.value;
|
|
67
|
+
if (options.appId || options.appDisplayName) {
|
|
68
|
+
permissions = this.getFilteredPermissions(options, permissionsObject.value);
|
|
71
69
|
}
|
|
72
|
-
return
|
|
70
|
+
return permissions.map(x => x.id);
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
|
-
removePermissions(permissionId) {
|
|
73
|
+
removePermissions(siteId, permissionId) {
|
|
76
74
|
const spRequestOptions = {
|
|
77
|
-
url: `${this.resource}/v1.0/sites/${
|
|
75
|
+
url: `${this.resource}/v1.0/sites/${siteId}/permissions/${permissionId}`,
|
|
78
76
|
headers: {
|
|
79
77
|
'accept': 'application/json;odata.metadata=none'
|
|
80
78
|
},
|
|
@@ -84,23 +82,8 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand_1.default {
|
|
|
84
82
|
}
|
|
85
83
|
commandAction(logger, args) {
|
|
86
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
const removeSiteAppPermission = () => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
try {
|
|
89
|
-
this.siteId = yield spo_1.spo.getSpoGraphSiteId(args.options.siteUrl);
|
|
90
|
-
const permissionIdsToRemove = yield this.getPermissionIds(args);
|
|
91
|
-
const tasks = [];
|
|
92
|
-
for (const permissionId of permissionIdsToRemove) {
|
|
93
|
-
tasks.push(this.removePermissions(permissionId));
|
|
94
|
-
}
|
|
95
|
-
const res = yield Promise.all(tasks);
|
|
96
|
-
logger.log(res);
|
|
97
|
-
}
|
|
98
|
-
catch (err) {
|
|
99
|
-
this.handleRejectedODataJsonPromise(err);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
85
|
if (args.options.confirm) {
|
|
103
|
-
yield removeSiteAppPermission();
|
|
86
|
+
yield this.removeSiteAppPermission(logger, args.options);
|
|
104
87
|
}
|
|
105
88
|
else {
|
|
106
89
|
const result = yield Cli_1.Cli.prompt({
|
|
@@ -110,11 +93,28 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand_1.default {
|
|
|
110
93
|
message: `Are you sure you want to remove the specified application permission from site ${args.options.siteUrl}?`
|
|
111
94
|
});
|
|
112
95
|
if (result.continue) {
|
|
113
|
-
yield removeSiteAppPermission();
|
|
96
|
+
yield this.removeSiteAppPermission(logger, args.options);
|
|
114
97
|
}
|
|
115
98
|
}
|
|
116
99
|
});
|
|
117
100
|
}
|
|
101
|
+
removeSiteAppPermission(logger, options) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
try {
|
|
104
|
+
const siteId = yield spo_1.spo.getSpoGraphSiteId(options.siteUrl);
|
|
105
|
+
const permissionIdsToRemove = yield this.getPermissionIds(siteId, options);
|
|
106
|
+
const tasks = [];
|
|
107
|
+
for (const permissionId of permissionIdsToRemove) {
|
|
108
|
+
tasks.push(this.removePermissions(siteId, permissionId));
|
|
109
|
+
}
|
|
110
|
+
const response = yield Promise.all(tasks);
|
|
111
|
+
logger.log(response);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
this.handleRejectedODataJsonPromise(err);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
118
|
}
|
|
119
119
|
_SpoSiteAppPermissionRemoveCommand_instances = new WeakSet(), _SpoSiteAppPermissionRemoveCommand_initTelemetry = function _SpoSiteAppPermissionRemoveCommand_initTelemetry() {
|
|
120
120
|
this.telemetry.push((args) => {
|
|
@@ -47,27 +47,26 @@ class SpoSiteAppPermissionSetCommand extends GraphCommand_1.default {
|
|
|
47
47
|
return permissions.filter((p) => p.grantedToIdentities.some(({ application }) => application[filterProperty] === filterValue));
|
|
48
48
|
}
|
|
49
49
|
getPermission(args) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.get(permissionRequestOptions)
|
|
62
|
-
.then(response => {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
if (args.options.id) {
|
|
52
|
+
return args.options.id;
|
|
53
|
+
}
|
|
54
|
+
const permissionRequestOptions = {
|
|
55
|
+
url: `${this.resource}/v1.0/sites/${this.siteId}/permissions`,
|
|
56
|
+
headers: {
|
|
57
|
+
accept: 'application/json;odata.metadata=none'
|
|
58
|
+
},
|
|
59
|
+
responseType: 'json'
|
|
60
|
+
};
|
|
61
|
+
const response = yield request_1.default.get(permissionRequestOptions);
|
|
63
62
|
const sitePermissionItems = this.getFilteredPermissions(args, response.value);
|
|
64
63
|
if (sitePermissionItems.length === 0) {
|
|
65
|
-
|
|
64
|
+
throw 'The specified app permission does not exist';
|
|
66
65
|
}
|
|
67
66
|
if (sitePermissionItems.length > 1) {
|
|
68
|
-
|
|
67
|
+
throw `Multiple app permissions with displayName ${args.options.appDisplayName} found: ${response.value.map(x => x.grantedToIdentities.map(y => y.application.id))}`;
|
|
69
68
|
}
|
|
70
|
-
return
|
|
69
|
+
return sitePermissionItems[0].id;
|
|
71
70
|
});
|
|
72
71
|
}
|
|
73
72
|
commandAction(logger, args) {
|
|
@@ -16,14 +16,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
16
16
|
var _SpoSiteEnsureCommand_instances, _SpoSiteEnsureCommand_initOptions, _SpoSiteEnsureCommand_initTypes, _SpoSiteEnsureCommand_initValidators;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const chalk = require("chalk");
|
|
19
|
-
const Cli_1 = require("../../../../cli/Cli");
|
|
20
19
|
const validation_1 = require("../../../../utils/validation");
|
|
21
20
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
22
21
|
const commands_1 = require("../../commands");
|
|
23
|
-
const spoWebGetCommand = require("../web/web-get");
|
|
24
22
|
const SharingCapabilities_1 = require("./SharingCapabilities");
|
|
25
|
-
const
|
|
26
|
-
const spoSiteSetCommand = require("./site-set");
|
|
23
|
+
const spo_1 = require("../../../../utils/spo");
|
|
27
24
|
class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
28
25
|
get name() {
|
|
29
26
|
return commands_1.default.SITE_ENSURE;
|
|
@@ -42,10 +39,7 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
|
42
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
40
|
try {
|
|
44
41
|
const res = yield this.ensureSite(logger, args);
|
|
45
|
-
|
|
46
|
-
logger.logToStderr(res.stderr);
|
|
47
|
-
}
|
|
48
|
-
logger.log(res.stdout);
|
|
42
|
+
logger.log(res);
|
|
49
43
|
if (this.verbose) {
|
|
50
44
|
logger.logToStderr(chalk.green('DONE'));
|
|
51
45
|
}
|
|
@@ -63,9 +57,9 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
|
63
57
|
}
|
|
64
58
|
catch (err) {
|
|
65
59
|
if (this.debug) {
|
|
66
|
-
logger.logToStderr(err
|
|
60
|
+
logger.logToStderr(err);
|
|
67
61
|
}
|
|
68
|
-
if (err.error
|
|
62
|
+
if (err.error !== '404 FILE NOT FOUND') {
|
|
69
63
|
throw err;
|
|
70
64
|
}
|
|
71
65
|
if (this.verbose) {
|
|
@@ -74,12 +68,15 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
|
74
68
|
return this.createSite(args, logger);
|
|
75
69
|
}
|
|
76
70
|
if (this.debug) {
|
|
77
|
-
logger.logToStderr(getWebOutput
|
|
71
|
+
logger.logToStderr(getWebOutput);
|
|
78
72
|
}
|
|
79
73
|
if (this.verbose) {
|
|
80
74
|
logger.logToStderr(`Site found at ${args.options.url}. Checking if site matches conditions...`);
|
|
81
75
|
}
|
|
82
|
-
const web =
|
|
76
|
+
const web = {
|
|
77
|
+
Configuration: getWebOutput.Configuration,
|
|
78
|
+
WebTemplate: getWebOutput.WebTemplate
|
|
79
|
+
};
|
|
83
80
|
if (args.options.type) {
|
|
84
81
|
// type was specified so we need to check if the existing site matches
|
|
85
82
|
// it. If not, we throw an error and stop
|
|
@@ -112,51 +109,20 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
|
112
109
|
});
|
|
113
110
|
}
|
|
114
111
|
getWeb(args, logger) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
debug: this.debug,
|
|
122
|
-
verbose: this.verbose
|
|
123
|
-
};
|
|
124
|
-
return Cli_1.Cli.executeCommandWithOutput(spoWebGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
if (this.verbose) {
|
|
114
|
+
logger.logToStderr(`Checking if site ${args.options.url} exists...`);
|
|
115
|
+
}
|
|
116
|
+
return yield spo_1.spo.getWeb(args.options.url, logger, this.verbose);
|
|
117
|
+
});
|
|
125
118
|
}
|
|
126
119
|
createSite(args, logger) {
|
|
127
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
121
|
if (this.verbose) {
|
|
129
122
|
logger.logToStderr(`Creating site...`);
|
|
130
123
|
}
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
title: args.options.title,
|
|
134
|
-
alias: args.options.alias,
|
|
135
|
-
description: args.options.description,
|
|
136
|
-
classification: args.options.classification,
|
|
137
|
-
isPublic: args.options.isPublic,
|
|
138
|
-
lcid: args.options.lcid,
|
|
139
|
-
url: typeof args.options.type === 'undefined' || args.options.type === 'TeamSite' ? undefined : args.options.url,
|
|
140
|
-
owners: args.options.owners,
|
|
141
|
-
shareByEmailEnabled: args.options.shareByEmailEnabled,
|
|
142
|
-
siteDesign: args.options.siteDesign,
|
|
143
|
-
siteDesignId: args.options.siteDesignId,
|
|
144
|
-
timeZone: args.options.timeZone,
|
|
145
|
-
webTemplate: args.options.webTemplate,
|
|
146
|
-
resourceQuota: args.options.resourceQuota,
|
|
147
|
-
resourceQuotaWarningLevel: args.options.resourceQuotaWarningLevel,
|
|
148
|
-
storageQuota: args.options.storageQuota,
|
|
149
|
-
storageQuotaWarningLevel: args.options.storageQuotaWarningLevel,
|
|
150
|
-
removeDeletedSite: args.options.removeDeletedSite,
|
|
151
|
-
wait: args.options.wait,
|
|
152
|
-
verbose: this.verbose,
|
|
153
|
-
debug: this.debug
|
|
154
|
-
};
|
|
155
|
-
const validationResult = yield spoSiteAddCommand.validate({ options: options }, Cli_1.Cli.getCommandInfo(spoSiteAddCommand));
|
|
156
|
-
if (validationResult !== true) {
|
|
157
|
-
throw validationResult;
|
|
158
|
-
}
|
|
159
|
-
return Cli_1.Cli.executeCommandWithOutput(spoSiteAddCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
124
|
+
const url = typeof args.options.type === 'undefined' || args.options.type === 'TeamSite' ? undefined : args.options.url;
|
|
125
|
+
return yield spo_1.spo.addSite(args.options.title, logger, this.verbose, args.options.wait, args.options.type, args.options.alias, args.options.description, args.options.owners, args.options.shareByEmailEnabled, args.options.removeDeletedSite, args.options.classification, args.options.isPublic, args.options.lcid, url, args.options.siteDesign, args.options.siteDesignId, args.options.timeZone, args.options.webTemplate, args.options.resourceQuota, args.options.resourceQuotaWarningLevel, args.options.storageQuota, args.options.storageQuotaWarningLevel);
|
|
160
126
|
});
|
|
161
127
|
}
|
|
162
128
|
updateSite(args, logger) {
|
|
@@ -164,24 +130,7 @@ class SpoSiteEnsureCommand extends SpoCommand_1.default {
|
|
|
164
130
|
if (this.verbose) {
|
|
165
131
|
logger.logToStderr(`Updating site...`);
|
|
166
132
|
}
|
|
167
|
-
|
|
168
|
-
classification: args.options.classification,
|
|
169
|
-
disableFlows: args.options.disableFlows,
|
|
170
|
-
isPublic: args.options.isPublic,
|
|
171
|
-
owners: args.options.owners,
|
|
172
|
-
shareByEmailEnabled: args.options.shareByEmailEnabled,
|
|
173
|
-
siteDesignId: args.options.siteDesignId,
|
|
174
|
-
title: args.options.title,
|
|
175
|
-
url: args.options.url,
|
|
176
|
-
sharingCapability: args.options.sharingCapability,
|
|
177
|
-
verbose: this.verbose,
|
|
178
|
-
debug: this.debug
|
|
179
|
-
};
|
|
180
|
-
const validationResult = yield spoSiteSetCommand.validate({ options: options }, Cli_1.Cli.getCommandInfo(spoSiteSetCommand));
|
|
181
|
-
if (validationResult !== true) {
|
|
182
|
-
throw validationResult;
|
|
183
|
-
}
|
|
184
|
-
return Cli_1.Cli.executeCommandWithOutput(spoSiteSetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
133
|
+
return yield spo_1.spo.updateSite(args.options.url, logger, this.verbose, args.options.title, args.options.classification, args.options.disableFlows, args.options.isPublic, args.options.owners, args.options.shareByEmailEnabled, args.options.siteDesignId, args.options.sharingCapability);
|
|
185
134
|
});
|
|
186
135
|
}
|
|
187
136
|
/**
|