-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy path_sfRemoteSitesCreate.js
More file actions
43 lines (35 loc) · 1.95 KB
/
_sfRemoteSitesCreate.js
File metadata and controls
43 lines (35 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
// Initialize constants
const config = require('config');
const fs = require('fs');
// Include the helper library to retrieve the environment details
const sfTemplateCreator = require('./_sfTemplateCreator');
const commonFs = require('../_common/fs');
/**
* @function _sfRemoteSitesCreate
* @description Attempts to create a version of the RemoteSites SFDX metadata template
* leveraging environment data provided.
*
* @param {Object} environmentDef Represents the already-validated environment details to use when performing the actions
* @returns {Promise} Returns the result of the remoteSites creation request
*/
module.exports = async environmentDef => {
// Define the basepath where the remoteSites template should be rendered
const basePath = `${config.get('paths.source.dx.base')}${config.get('paths.source.dx.deployPath')}`;
await commonFs.verifyAndCreateFolder(`${basePath}remoteSiteSettings`);
// Default the file-extension to use
const fileExt = config.get('paths.source.dx.meta-ext').toString();
// Initialize the template folder
const templateFolder = 'remoteSiteSettings/';
// Build out the suffix to the template file
const templateSuffix = 'template.remoteSite' + fileExt;
// Create the destination file's filename and suffix; personalized with the B2C Instance Name
const fileSuffix = `${environmentDef.b2cInstanceName}.remoteSite${fileExt}`;
// Copy the Account Manager remoteSiteSetting meta-data definition
const amTemplate = `${config.get('paths.source.dx.templates')}${templateFolder}B2CAM.remoteSite-meta.xml`;
fs.copyFileSync(amTemplate, `${basePath}remoteSiteSettings/B2CAM.remoteSite-meta.xml`);
// Replace the placeholder with the templateUrl
return sfTemplateCreator(environmentDef, templateFolder, templateSuffix, fileSuffix, templateFileAsString => {
return templateFileAsString.replace('{{B2C_HOSTNAME}}', `https://${environmentDef.b2cHostName}`);
});
};