@pnp/cli-microsoft365
Version:
Manage Microsoft 365 and SharePoint Framework projects on any platform
79 lines • 4.15 kB
JavaScript
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _SpoHomeSiteSetCommand_instances, _SpoHomeSiteSetCommand_initTelemetry, _SpoHomeSiteSetCommand_initOptions, _SpoHomeSiteSetCommand_initValidators, _SpoHomeSiteSetCommand_initTypes;
import request from '../../../../request.js';
import { spo } from '../../../../utils/spo.js';
import { validation } from '../../../../utils/validation.js';
import SpoCommand from '../../../base/SpoCommand.js';
import commands from '../../commands.js';
class SpoHomeSiteSetCommand extends SpoCommand {
get name() {
return commands.HOMESITE_SET;
}
get description() {
return 'Sets the specified site as the Home Site';
}
constructor() {
super();
_SpoHomeSiteSetCommand_instances.add(this);
__classPrivateFieldGet(this, _SpoHomeSiteSetCommand_instances, "m", _SpoHomeSiteSetCommand_initTelemetry).call(this);
__classPrivateFieldGet(this, _SpoHomeSiteSetCommand_instances, "m", _SpoHomeSiteSetCommand_initOptions).call(this);
__classPrivateFieldGet(this, _SpoHomeSiteSetCommand_instances, "m", _SpoHomeSiteSetCommand_initValidators).call(this);
__classPrivateFieldGet(this, _SpoHomeSiteSetCommand_instances, "m", _SpoHomeSiteSetCommand_initTypes).call(this);
}
async commandAction(logger, args) {
try {
if (this.verbose) {
await logger.logToStderr(`Setting the SharePoint home site to: ${args.options.siteUrl}...`);
await logger.logToStderr('Attempting to retrieve the SharePoint admin URL.');
}
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
const requestOptions = {
url: `${spoAdminUrl}/_api/SPO.Tenant`,
headers: {
accept: 'application/json;odata=nometadata',
'content-Type': 'application/json'
},
responseType: 'json',
data: {
sphSiteUrl: args.options.siteUrl
}
};
if (args.options.vivaConnectionsDefaultStart !== undefined) {
requestOptions.url += '/SetSPHSiteWithConfiguration';
requestOptions.data.configuration = { vivaConnectionsDefaultStart: args.options.vivaConnectionsDefaultStart };
}
else {
requestOptions.url += '/SetSPHSite';
}
const res = await request.post(requestOptions);
await logger.log(res.value);
}
catch (err) {
this.handleRejectedODataJsonPromise(err);
}
}
}
_SpoHomeSiteSetCommand_instances = new WeakSet(), _SpoHomeSiteSetCommand_initTelemetry = function _SpoHomeSiteSetCommand_initTelemetry() {
this.telemetry.push((args) => {
Object.assign(this.telemetryProperties, {
vivaConnectionsDefaultStart: typeof args.options.vivaConnectionsDefaultStart !== 'undefined'
});
});
}, _SpoHomeSiteSetCommand_initOptions = function _SpoHomeSiteSetCommand_initOptions() {
this.options.unshift({
option: '-u, --siteUrl <siteUrl>'
}, {
option: '--vivaConnectionsDefaultStart [vivaConnectionsDefaultStart]',
autocomplete: ['true', 'false']
});
}, _SpoHomeSiteSetCommand_initValidators = function _SpoHomeSiteSetCommand_initValidators() {
this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.siteUrl));
}, _SpoHomeSiteSetCommand_initTypes = function _SpoHomeSiteSetCommand_initTypes() {
this.types.boolean.push('vivaConnectionsDefaultStart');
};
export default new SpoHomeSiteSetCommand();
//# sourceMappingURL=homesite-set.js.map