@pnp/cli-microsoft365 6.11.0-beta.b75e15f → 6.11.0-beta.cb74646
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/planner/commands/task/task-add.js +17 -11
- package/dist/m365/planner/commands/task/task-get.js +35 -25
- package/dist/m365/planner/commands/task/task-list.js +26 -19
- package/dist/m365/planner/commands/task/task-remove.js +40 -35
- package/dist/m365/planner/commands/task/task-set.js +35 -23
- 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-remove.js +139 -171
- package/dist/m365/spo/commands/site/site-set.js +134 -146
- package/dist/utils/fsUtil.js +5 -0
- package/docs/docs/cmd/planner/task/task-add.mdx +22 -7
- package/docs/docs/cmd/planner/task/task-get.mdx +13 -4
- package/docs/docs/cmd/planner/task/task-list.mdx +22 -7
- package/docs/docs/cmd/planner/task/task-remove.mdx +25 -8
- package/docs/docs/cmd/planner/task/task-set.mdx +22 -7
- package/docs/docs/cmd/spfx/project/project-github-workflow-add.mdx +94 -0
- package/npm-shrinkwrap.json +15 -1
- package/package.json +3 -2
|
@@ -0,0 +1,171 @@
|
|
|
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 _SpfxProjectGithubWorkflowAddCommand_instances, _SpfxProjectGithubWorkflowAddCommand_initTelemetry, _SpfxProjectGithubWorkflowAddCommand_initOptions, _SpfxProjectGithubWorkflowAddCommand_initValidators;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const fs = require("fs");
|
|
19
|
+
const path = require("path");
|
|
20
|
+
const yaml = require("yaml");
|
|
21
|
+
const Command_1 = require("../../../../Command");
|
|
22
|
+
const fsUtil_1 = require("../../../../utils/fsUtil");
|
|
23
|
+
const validation_1 = require("../../../../utils/validation");
|
|
24
|
+
const commands_1 = require("../../commands");
|
|
25
|
+
const DeployWorkflow_1 = require("./DeployWorkflow");
|
|
26
|
+
const base_project_command_1 = require("./base-project-command");
|
|
27
|
+
class SpfxProjectGithubWorkflowAddCommand extends base_project_command_1.BaseProjectCommand {
|
|
28
|
+
get name() {
|
|
29
|
+
return commands_1.default.PROJECT_GITHUB_WORKFLOW_ADD;
|
|
30
|
+
}
|
|
31
|
+
get description() {
|
|
32
|
+
return 'Adds a GitHub workflow for a SharePoint Framework project.';
|
|
33
|
+
}
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
_SpfxProjectGithubWorkflowAddCommand_instances.add(this);
|
|
37
|
+
__classPrivateFieldGet(this, _SpfxProjectGithubWorkflowAddCommand_instances, "m", _SpfxProjectGithubWorkflowAddCommand_initTelemetry).call(this);
|
|
38
|
+
__classPrivateFieldGet(this, _SpfxProjectGithubWorkflowAddCommand_instances, "m", _SpfxProjectGithubWorkflowAddCommand_initOptions).call(this);
|
|
39
|
+
__classPrivateFieldGet(this, _SpfxProjectGithubWorkflowAddCommand_instances, "m", _SpfxProjectGithubWorkflowAddCommand_initValidators).call(this);
|
|
40
|
+
}
|
|
41
|
+
commandAction(logger, args) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
this.projectRootPath = this.getProjectRoot(process.cwd());
|
|
44
|
+
if (this.projectRootPath === null) {
|
|
45
|
+
throw new Command_1.CommandError(`Couldn't find project root folder`, SpfxProjectGithubWorkflowAddCommand.ERROR_NO_PROJECT_ROOT_FOLDER);
|
|
46
|
+
}
|
|
47
|
+
const solutionPackageJsonFile = path.join(this.projectRootPath, 'package.json');
|
|
48
|
+
const packageJson = fs.readFileSync(solutionPackageJsonFile, 'utf-8');
|
|
49
|
+
const solutionName = JSON.parse(packageJson).name;
|
|
50
|
+
if (this.debug) {
|
|
51
|
+
logger.logToStderr(`Adding GitHub workflow in the current SPFx project`);
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
this.updateWorkflow(solutionName, DeployWorkflow_1.workflow, args.options);
|
|
55
|
+
this.saveWorkflow(DeployWorkflow_1.workflow);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
throw new Command_1.CommandError(error);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
saveWorkflow(workflow) {
|
|
63
|
+
const githubPath = path.join(this.projectRootPath, '.github');
|
|
64
|
+
fsUtil_1.fsUtil.ensureDirectory(githubPath);
|
|
65
|
+
const workflowPath = path.join(githubPath, 'workflows');
|
|
66
|
+
fsUtil_1.fsUtil.ensureDirectory(workflowPath);
|
|
67
|
+
const workflowFile = path.join(workflowPath, 'deploy-spfx-solution.yml');
|
|
68
|
+
fs.writeFileSync(path.resolve(workflowFile), yaml.stringify(workflow), 'utf-8');
|
|
69
|
+
}
|
|
70
|
+
updateWorkflow(solutionName, workflow, options) {
|
|
71
|
+
var _a;
|
|
72
|
+
workflow.name = workflow.name.replace('{{ name }}', (_a = options.name) !== null && _a !== void 0 ? _a : solutionName);
|
|
73
|
+
if (options.branchName) {
|
|
74
|
+
workflow.on.push.branches[0] = options.branchName;
|
|
75
|
+
}
|
|
76
|
+
if (options.manuallyTrigger) {
|
|
77
|
+
// eslint-disable-next-line camelcase
|
|
78
|
+
workflow.on.workflow_dispatch = null;
|
|
79
|
+
}
|
|
80
|
+
if (options.skipFeatureDeployment) {
|
|
81
|
+
this.getDeployAction(workflow).with.SKIP_FEATURE_DEPLOYMENT = true;
|
|
82
|
+
}
|
|
83
|
+
if (options.overwrite) {
|
|
84
|
+
this.getDeployAction(workflow).with.OVERWRITE = true;
|
|
85
|
+
}
|
|
86
|
+
if (options.loginMethod === 'user') {
|
|
87
|
+
const loginAction = this.getLoginAction(workflow);
|
|
88
|
+
loginAction.with = {
|
|
89
|
+
ADMIN_USERNAME: '${{ secrets.ADMIN_USERNAME }}',
|
|
90
|
+
ADMIN_PASSWORD: '${{ secrets.ADMIN_PASSWORD }}'
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (options.scope === 'sitecollection') {
|
|
94
|
+
const deployAction = this.getDeployAction(workflow);
|
|
95
|
+
deployAction.with.SCOPE = 'sitecollection';
|
|
96
|
+
deployAction.with.SITE_COLLECTION_URL = options.siteUrl;
|
|
97
|
+
}
|
|
98
|
+
if (solutionName) {
|
|
99
|
+
const deployAction = this.getDeployAction(workflow);
|
|
100
|
+
deployAction.with.APP_FILE_PATH = deployAction.with.APP_FILE_PATH.replace('{{ solutionName }}', solutionName);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
getLoginAction(workflow) {
|
|
104
|
+
const steps = this.getWorkFlowSteps(workflow);
|
|
105
|
+
return steps.find(step => step.uses && step.uses.indexOf('action-cli-login') >= 0);
|
|
106
|
+
}
|
|
107
|
+
getDeployAction(workflow) {
|
|
108
|
+
const steps = this.getWorkFlowSteps(workflow);
|
|
109
|
+
return steps.find(step => step.uses && step.uses.indexOf('action-cli-deploy') >= 0);
|
|
110
|
+
}
|
|
111
|
+
getWorkFlowSteps(workflow) {
|
|
112
|
+
return workflow.jobs['build-and-deploy'].steps;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_SpfxProjectGithubWorkflowAddCommand_instances = new WeakSet(), _SpfxProjectGithubWorkflowAddCommand_initTelemetry = function _SpfxProjectGithubWorkflowAddCommand_initTelemetry() {
|
|
116
|
+
this.telemetry.push((args) => {
|
|
117
|
+
Object.assign(this.telemetryProperties, {
|
|
118
|
+
name: typeof args.options.name !== 'undefined',
|
|
119
|
+
branchName: typeof args.options.branchName !== 'undefined',
|
|
120
|
+
manuallyTrigger: !!args.options.manuallyTrigger,
|
|
121
|
+
loginMethod: typeof args.options.loginMethod !== 'undefined',
|
|
122
|
+
scope: typeof args.options.scope !== 'undefined',
|
|
123
|
+
skipFeatureDeployment: !!args.options.skipFeatureDeployment,
|
|
124
|
+
overwrite: !!args.options.overwrite
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}, _SpfxProjectGithubWorkflowAddCommand_initOptions = function _SpfxProjectGithubWorkflowAddCommand_initOptions() {
|
|
128
|
+
this.options.unshift({
|
|
129
|
+
option: '-n, --name [name]'
|
|
130
|
+
}, {
|
|
131
|
+
option: '-b, --branchName [branchName]'
|
|
132
|
+
}, {
|
|
133
|
+
option: '-m, --manuallyTrigger'
|
|
134
|
+
}, {
|
|
135
|
+
option: '-l, --loginMethod [loginMethod]',
|
|
136
|
+
autocomplete: SpfxProjectGithubWorkflowAddCommand.loginMethod
|
|
137
|
+
}, {
|
|
138
|
+
option: '-s, --scope [scope]',
|
|
139
|
+
autocomplete: SpfxProjectGithubWorkflowAddCommand.scope
|
|
140
|
+
}, {
|
|
141
|
+
option: '-u, --siteUrl [siteUrl]'
|
|
142
|
+
}, {
|
|
143
|
+
option: '--skipFeatureDeployment'
|
|
144
|
+
}, {
|
|
145
|
+
option: '--overwrite'
|
|
146
|
+
});
|
|
147
|
+
}, _SpfxProjectGithubWorkflowAddCommand_initValidators = function _SpfxProjectGithubWorkflowAddCommand_initValidators() {
|
|
148
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
if (args.options.scope && args.options.scope === 'sitecollection') {
|
|
150
|
+
if (!args.options.siteUrl) {
|
|
151
|
+
return `siteUrl option has to be defined when scope set to ${args.options.scope}`;
|
|
152
|
+
}
|
|
153
|
+
const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.siteUrl);
|
|
154
|
+
if (isValidSharePointUrl !== true) {
|
|
155
|
+
return isValidSharePointUrl;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (args.options.loginMethod && SpfxProjectGithubWorkflowAddCommand.loginMethod.indexOf(args.options.loginMethod) < 0) {
|
|
159
|
+
return `${args.options.loginMethod} is not a valid login method. Allowed values are ${SpfxProjectGithubWorkflowAddCommand.loginMethod.join(', ')}`;
|
|
160
|
+
}
|
|
161
|
+
if (args.options.scope && SpfxProjectGithubWorkflowAddCommand.scope.indexOf(args.options.scope) < 0) {
|
|
162
|
+
return `${args.options.scope} is not a valid scope. Allowed values are ${SpfxProjectGithubWorkflowAddCommand.scope.join(', ')}`;
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}));
|
|
166
|
+
};
|
|
167
|
+
SpfxProjectGithubWorkflowAddCommand.loginMethod = ['application', 'user'];
|
|
168
|
+
SpfxProjectGithubWorkflowAddCommand.scope = ['tenant', 'sitecollection'];
|
|
169
|
+
SpfxProjectGithubWorkflowAddCommand.ERROR_NO_PROJECT_ROOT_FOLDER = 1;
|
|
170
|
+
module.exports = new SpfxProjectGithubWorkflowAddCommand();
|
|
171
|
+
//# sourceMappingURL=project-github-workflow-add.js.map
|
|
@@ -6,6 +6,7 @@ exports.default = {
|
|
|
6
6
|
PACKAGE_GENERATE: `${prefix} package generate`,
|
|
7
7
|
PROJECT_DOCTOR: `${prefix} project doctor`,
|
|
8
8
|
PROJECT_EXTERNALIZE: `${prefix} project externalize`,
|
|
9
|
+
PROJECT_GITHUB_WORKFLOW_ADD: `${prefix} project github workflow add`,
|
|
9
10
|
PROJECT_PERMISSIONS_GRANT: `${prefix} project permissions grant`,
|
|
10
11
|
PROJECT_RENAME: `${prefix} project rename`,
|
|
11
12
|
PROJECT_UPGRADE: `${prefix} project upgrade`
|
|
@@ -40,38 +40,8 @@ class SpoServicePrincipalSetCommand extends SpoCommand_1.default {
|
|
|
40
40
|
}
|
|
41
41
|
commandAction(logger, args) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const toggleServicePrincipal = () => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
try {
|
|
45
|
-
const spoAdminUrl = yield spo_1.spo.getSpoAdminUrl(logger, this.debug);
|
|
46
|
-
const reqDigest = yield spo_1.spo.getRequestDigest(spoAdminUrl);
|
|
47
|
-
if (this.verbose) {
|
|
48
|
-
logger.logToStderr(`${(args.options.enabled ? 'Enabling' : 'Disabling')} service principal...`);
|
|
49
|
-
}
|
|
50
|
-
const requestOptions = {
|
|
51
|
-
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
52
|
-
headers: {
|
|
53
|
-
'X-RequestDigest': reqDigest.FormDigestValue
|
|
54
|
-
},
|
|
55
|
-
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="28" ObjectPathId="27" /><SetProperty Id="29" ObjectPathId="27" Name="AccountEnabled"><Parameter Type="Boolean">${args.options.enabled}</Parameter></SetProperty><Method Name="Update" Id="30" ObjectPathId="27" /><Query Id="31" ObjectPathId="27"><Query SelectAllProperties="true"><Properties><Property Name="AccountEnabled" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Constructor Id="27" TypeId="{104e8f06-1e00-4675-99c6-1b9b504ed8d8}" /></ObjectPaths></Request>`
|
|
56
|
-
};
|
|
57
|
-
const res = yield request_1.default.post(requestOptions);
|
|
58
|
-
const json = JSON.parse(res);
|
|
59
|
-
const response = json[0];
|
|
60
|
-
if (response.ErrorInfo) {
|
|
61
|
-
throw response.ErrorInfo.ErrorMessage;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
const output = json[json.length - 1];
|
|
65
|
-
delete output._ObjectType_;
|
|
66
|
-
logger.log(output);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (err) {
|
|
70
|
-
this.handleRejectedPromise(err);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
43
|
if (args.options.confirm) {
|
|
74
|
-
yield toggleServicePrincipal();
|
|
44
|
+
yield this.toggleServicePrincipal(logger, args);
|
|
75
45
|
}
|
|
76
46
|
else {
|
|
77
47
|
const result = yield Cli_1.Cli.prompt({
|
|
@@ -81,11 +51,41 @@ class SpoServicePrincipalSetCommand extends SpoCommand_1.default {
|
|
|
81
51
|
message: `Are you sure you want to ${args.options.enabled ? 'enable' : 'disable'} the service principal?`
|
|
82
52
|
});
|
|
83
53
|
if (result.continue) {
|
|
84
|
-
yield toggleServicePrincipal();
|
|
54
|
+
yield this.toggleServicePrincipal(logger, args);
|
|
85
55
|
}
|
|
86
56
|
}
|
|
87
57
|
});
|
|
88
58
|
}
|
|
59
|
+
toggleServicePrincipal(logger, args) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
try {
|
|
62
|
+
const spoAdminUrl = yield spo_1.spo.getSpoAdminUrl(logger, this.debug);
|
|
63
|
+
const reqDigest = yield spo_1.spo.getRequestDigest(spoAdminUrl);
|
|
64
|
+
if (this.verbose) {
|
|
65
|
+
logger.logToStderr(`${(args.options.enabled ? 'Enabling' : 'Disabling')} service principal...`);
|
|
66
|
+
}
|
|
67
|
+
const requestOptions = {
|
|
68
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
69
|
+
headers: {
|
|
70
|
+
'X-RequestDigest': reqDigest.FormDigestValue
|
|
71
|
+
},
|
|
72
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="28" ObjectPathId="27" /><SetProperty Id="29" ObjectPathId="27" Name="AccountEnabled"><Parameter Type="Boolean">${args.options.enabled}</Parameter></SetProperty><Method Name="Update" Id="30" ObjectPathId="27" /><Query Id="31" ObjectPathId="27"><Query SelectAllProperties="true"><Properties><Property Name="AccountEnabled" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Constructor Id="27" TypeId="{104e8f06-1e00-4675-99c6-1b9b504ed8d8}" /></ObjectPaths></Request>`
|
|
73
|
+
};
|
|
74
|
+
const response = yield request_1.default.post(requestOptions);
|
|
75
|
+
const json = JSON.parse(response);
|
|
76
|
+
const responseContent = json[0];
|
|
77
|
+
if (responseContent.ErrorInfo) {
|
|
78
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
79
|
+
}
|
|
80
|
+
const output = json[json.length - 1];
|
|
81
|
+
delete output._ObjectType_;
|
|
82
|
+
logger.log(output);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
this.handleRejectedPromise(err);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
89
|
}
|
|
90
90
|
_SpoServicePrincipalSetCommand_instances = new WeakSet(), _SpoServicePrincipalSetCommand_initTelemetry = function _SpoServicePrincipalSetCommand_initTelemetry() {
|
|
91
91
|
this.telemetry.push((args) => {
|
|
@@ -141,18 +141,16 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
|
|
|
141
141
|
requestOptions.data.request.Owner = args.options.owners;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
const
|
|
144
|
+
const response = yield request_1.default.post(requestOptions);
|
|
145
145
|
if (isTeamSite) {
|
|
146
|
-
if (
|
|
147
|
-
throw
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
logger.log(res.SiteUrl);
|
|
146
|
+
if (response.ErrorMessage !== null) {
|
|
147
|
+
throw response.ErrorMessage;
|
|
151
148
|
}
|
|
149
|
+
logger.log(response.SiteUrl);
|
|
152
150
|
}
|
|
153
151
|
else {
|
|
154
|
-
if (
|
|
155
|
-
logger.log(
|
|
152
|
+
if (response.SiteStatus === 2) {
|
|
153
|
+
logger.log(response.SiteUrl);
|
|
156
154
|
}
|
|
157
155
|
else {
|
|
158
156
|
throw 'An error has occurred while creating the site';
|
|
@@ -171,7 +169,7 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
|
|
|
171
169
|
this.context = yield spo_1.spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
172
170
|
let exists;
|
|
173
171
|
if (args.options.removeDeletedSite) {
|
|
174
|
-
exists = yield this.
|
|
172
|
+
exists = yield this.siteExists(args.options.url, logger);
|
|
175
173
|
}
|
|
176
174
|
else {
|
|
177
175
|
// assume site doesn't exist
|
|
@@ -205,153 +203,18 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
|
|
|
205
203
|
},
|
|
206
204
|
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="4" ObjectPathId="3" /><ObjectPath Id="6" ObjectPathId="5" /><Query Id="7" ObjectPathId="3"><Query SelectAllProperties="true"><Properties /></Query></Query><Query Id="8" ObjectPathId="5"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Constructor Id="3" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="5" ParentId="3" Name="CreateSite"><Parameters><Parameter TypeId="{11f84fff-b8cf-47b6-8b50-34e692656606}"><Property Name="CompatibilityLevel" Type="Int32">0</Property><Property Name="Lcid" Type="UInt32">${lcid}</Property><Property Name="Owner" Type="String">${formatting_1.formatting.escapeXml(args.options.owners)}</Property><Property Name="StorageMaximumLevel" Type="Int64">${storageQuota}</Property><Property Name="StorageWarningLevel" Type="Int64">${storageQuotaWarningLevel}</Property><Property Name="Template" Type="String">${formatting_1.formatting.escapeXml(webTemplate)}</Property><Property Name="TimeZoneId" Type="Int32">${args.options.timeZone}</Property><Property Name="Title" Type="String">${formatting_1.formatting.escapeXml(args.options.title)}</Property><Property Name="Url" Type="String">${formatting_1.formatting.escapeXml(args.options.url)}</Property><Property Name="UserCodeMaximumLevel" Type="Double">${resourceQuota}</Property><Property Name="UserCodeWarningLevel" Type="Double">${resourceQuotaWarningLevel}</Property></Parameter></Parameters></Method></ObjectPaths></Request>`
|
|
207
205
|
};
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
reject(response.ErrorInfo.ErrorMessage);
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
const operation = json[json.length - 1];
|
|
217
|
-
const isComplete = operation.IsComplete;
|
|
218
|
-
if (!args.options.wait || isComplete) {
|
|
219
|
-
resolve();
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
setTimeout(() => {
|
|
223
|
-
spo_1.spo.waitUntilFinished({
|
|
224
|
-
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
225
|
-
siteUrl: this.spoAdminUrl,
|
|
226
|
-
resolve,
|
|
227
|
-
reject,
|
|
228
|
-
logger,
|
|
229
|
-
currentContext: this.context,
|
|
230
|
-
verbose: this.verbose,
|
|
231
|
-
debug: this.debug
|
|
232
|
-
});
|
|
233
|
-
}, operation.PollingInterval);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
catch (err) {
|
|
238
|
-
this.handleRejectedPromise(err);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
siteExistsInTheRecycleBin(url, logger) {
|
|
243
|
-
return new Promise((resolve, reject) => {
|
|
244
|
-
spo_1.spo
|
|
245
|
-
.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug)
|
|
246
|
-
.then((res) => {
|
|
247
|
-
this.context = res;
|
|
248
|
-
if (this.verbose) {
|
|
249
|
-
logger.logToStderr(`Checking if the site ${url} exists...`);
|
|
250
|
-
}
|
|
251
|
-
const requestOptions = {
|
|
252
|
-
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
253
|
-
headers: {
|
|
254
|
-
'X-RequestDigest': this.context.FormDigestValue
|
|
255
|
-
},
|
|
256
|
-
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="197" ObjectPathId="196" /><ObjectPath Id="199" ObjectPathId="198" /><Query Id="200" ObjectPathId="198"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Constructor Id="196" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="198" ParentId="196" Name="GetSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter><Parameter Type="Boolean">false</Parameter></Parameters></Method></ObjectPaths></Request>`
|
|
257
|
-
};
|
|
258
|
-
return request_1.default.post(requestOptions);
|
|
259
|
-
})
|
|
260
|
-
.then((res) => {
|
|
261
|
-
const json = JSON.parse(res);
|
|
262
|
-
const response = json[0];
|
|
263
|
-
if (response.ErrorInfo) {
|
|
264
|
-
if (response.ErrorInfo.ErrorTypeName === 'Microsoft.Online.SharePoint.Common.SpoNoSiteException') {
|
|
265
|
-
return Promise.resolve(false);
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
return Promise.reject(response.ErrorInfo.ErrorMessage);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
const site = json[json.length - 1];
|
|
273
|
-
if (site.Status === 'Recycled') {
|
|
274
|
-
return Promise.reject(true);
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
return Promise.resolve(false);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
})
|
|
281
|
-
.then(() => {
|
|
282
|
-
if (this.verbose) {
|
|
283
|
-
logger.logToStderr(`Site doesn't exist. Checking if the site ${url} exists in the recycle bin...`);
|
|
206
|
+
const response = yield request_1.default.post(requestOptions);
|
|
207
|
+
const json = JSON.parse(response);
|
|
208
|
+
const responseContent = json[0];
|
|
209
|
+
if (responseContent.ErrorInfo) {
|
|
210
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
284
211
|
}
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
},
|
|
290
|
-
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="181" ObjectPathId="180" /><Query Id="182" ObjectPathId="180"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Method Id="180" ParentId="175" Name="GetDeletedSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
291
|
-
};
|
|
292
|
-
return request_1.default.post(requestOptions);
|
|
293
|
-
})
|
|
294
|
-
.then((res) => {
|
|
295
|
-
const json = JSON.parse(res);
|
|
296
|
-
const response = json[0];
|
|
297
|
-
if (response.ErrorInfo) {
|
|
298
|
-
if (response.ErrorInfo.ErrorTypeName === 'Microsoft.SharePoint.Client.UnknownError') {
|
|
299
|
-
resolve(false);
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
reject(response.ErrorInfo.ErrorMessage);
|
|
303
|
-
}
|
|
212
|
+
const operation = json[json.length - 1];
|
|
213
|
+
const isComplete = operation.IsComplete;
|
|
214
|
+
if (!args.options.wait || isComplete) {
|
|
215
|
+
return;
|
|
304
216
|
}
|
|
305
|
-
|
|
306
|
-
const site = json[json.length - 1];
|
|
307
|
-
if (site.Status === 'Recycled') {
|
|
308
|
-
resolve(true);
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
resolve(false);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}, (error) => {
|
|
315
|
-
if (typeof error === 'boolean') {
|
|
316
|
-
resolve(error);
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
reject(error);
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
deleteSiteFromTheRecycleBin(url, wait, logger) {
|
|
325
|
-
return new Promise((resolve, reject) => {
|
|
326
|
-
spo_1.spo
|
|
327
|
-
.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug)
|
|
328
|
-
.then((res) => {
|
|
329
|
-
this.context = res;
|
|
330
|
-
if (this.verbose) {
|
|
331
|
-
logger.logToStderr(`Deleting site ${url} from the recycle bin...`);
|
|
332
|
-
}
|
|
333
|
-
const requestOptions = {
|
|
334
|
-
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
335
|
-
headers: {
|
|
336
|
-
'X-RequestDigest': this.context.FormDigestValue
|
|
337
|
-
},
|
|
338
|
-
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="185" ObjectPathId="184" /><Query Id="186" ObjectPathId="184"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Method Id="184" ParentId="175" Name="RemoveDeletedSite"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
339
|
-
};
|
|
340
|
-
return request_1.default.post(requestOptions);
|
|
341
|
-
})
|
|
342
|
-
.then((res) => {
|
|
343
|
-
const json = JSON.parse(res);
|
|
344
|
-
const response = json[0];
|
|
345
|
-
if (response.ErrorInfo) {
|
|
346
|
-
reject(response.ErrorInfo.ErrorMessage);
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
const operation = json[json.length - 1];
|
|
350
|
-
const isComplete = operation.IsComplete;
|
|
351
|
-
if (!wait || isComplete) {
|
|
352
|
-
resolve();
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
217
|
+
yield new Promise((resolve, reject) => {
|
|
355
218
|
setTimeout(() => {
|
|
356
219
|
spo_1.spo.waitUntilFinished({
|
|
357
220
|
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
@@ -364,7 +227,103 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
|
|
|
364
227
|
debug: this.debug
|
|
365
228
|
});
|
|
366
229
|
}, operation.PollingInterval);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
this.handleRejectedPromise(err);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
siteExists(url, logger) {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
+
this.context = yield spo_1.spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
240
|
+
if (this.verbose) {
|
|
241
|
+
logger.logToStderr(`Checking if the site ${url} exists...`);
|
|
242
|
+
}
|
|
243
|
+
const requestOptions = {
|
|
244
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
245
|
+
headers: {
|
|
246
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
247
|
+
},
|
|
248
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="197" ObjectPathId="196" /><ObjectPath Id="199" ObjectPathId="198" /><Query Id="200" ObjectPathId="198"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Constructor Id="196" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="198" ParentId="196" Name="GetSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter><Parameter Type="Boolean">false</Parameter></Parameters></Method></ObjectPaths></Request>`
|
|
249
|
+
};
|
|
250
|
+
const response = yield request_1.default.post(requestOptions);
|
|
251
|
+
const json = JSON.parse(response);
|
|
252
|
+
const responseContent = json[0];
|
|
253
|
+
if (responseContent.ErrorInfo) {
|
|
254
|
+
if (responseContent.ErrorInfo.ErrorTypeName === 'Microsoft.Online.SharePoint.Common.SpoNoSiteException') {
|
|
255
|
+
return yield this.siteExistsInTheRecycleBin(url, logger);
|
|
367
256
|
}
|
|
257
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
const site = json[json.length - 1];
|
|
261
|
+
return site.Status === 'Recycled';
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
siteExistsInTheRecycleBin(url, logger) {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
if (this.verbose) {
|
|
268
|
+
logger.logToStderr(`Site doesn't exist. Checking if the site ${url} exists in the recycle bin...`);
|
|
269
|
+
}
|
|
270
|
+
const requestOptions = {
|
|
271
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
272
|
+
headers: {
|
|
273
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
274
|
+
},
|
|
275
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="181" ObjectPathId="180" /><Query Id="182" ObjectPathId="180"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Method Id="180" ParentId="175" Name="GetDeletedSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
276
|
+
};
|
|
277
|
+
const res = yield request_1.default.post(requestOptions);
|
|
278
|
+
const json = JSON.parse(res);
|
|
279
|
+
const response = json[0];
|
|
280
|
+
if (response.ErrorInfo) {
|
|
281
|
+
if (response.ErrorInfo.ErrorTypeName === 'Microsoft.SharePoint.Client.UnknownError') {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
throw response.ErrorInfo.ErrorMessage;
|
|
285
|
+
}
|
|
286
|
+
const site = json[json.length - 1];
|
|
287
|
+
return site.Status === 'Recycled';
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
deleteSiteFromTheRecycleBin(url, wait, logger) {
|
|
291
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
this.context = yield spo_1.spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
293
|
+
if (this.verbose) {
|
|
294
|
+
logger.logToStderr(`Deleting site ${url} from the recycle bin...`);
|
|
295
|
+
}
|
|
296
|
+
const requestOptions = {
|
|
297
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
298
|
+
headers: {
|
|
299
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
300
|
+
},
|
|
301
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="185" ObjectPathId="184" /><Query Id="186" ObjectPathId="184"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Method Id="184" ParentId="175" Name="RemoveDeletedSite"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
302
|
+
};
|
|
303
|
+
const response = yield request_1.default.post(requestOptions);
|
|
304
|
+
const json = JSON.parse(response);
|
|
305
|
+
const responseContent = json[0];
|
|
306
|
+
if (responseContent.ErrorInfo) {
|
|
307
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
308
|
+
}
|
|
309
|
+
const operation = json[json.length - 1];
|
|
310
|
+
const isComplete = operation.IsComplete;
|
|
311
|
+
if (!wait || isComplete) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
yield new Promise((resolve, reject) => {
|
|
315
|
+
setTimeout(() => {
|
|
316
|
+
spo_1.spo.waitUntilFinished({
|
|
317
|
+
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
318
|
+
siteUrl: this.spoAdminUrl,
|
|
319
|
+
resolve,
|
|
320
|
+
reject,
|
|
321
|
+
logger,
|
|
322
|
+
currentContext: this.context,
|
|
323
|
+
verbose: this.verbose,
|
|
324
|
+
debug: this.debug
|
|
325
|
+
});
|
|
326
|
+
}, operation.PollingInterval);
|
|
368
327
|
});
|
|
369
328
|
});
|
|
370
329
|
}
|
|
@@ -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
|
/**
|