forcedotcom/sf-skills / plugins/builder/consumer-goods/skills/consumer-goods-accruals-datakit-deploy
consumer-goods-accruals-datakit-deploy
VerifiedUse this skill to deploy the TPM Liability Accruals data kit end to end to a Salesforce org. Invoke when a customer or teammate wants to install the accrual engine, verify the Data Cloud connection, deploy the Data Kit components, and schedule the export and accrual calculation chain. Trigger phrases include: 'deploy the accrual data kit', 'set up liability accruals', 'install TPM accruals', 'headless accruals setup', 'configure the Data Cloud export connector', 'schedule the accrual chain'. Do NOT use for creating a Data Space alone (use platform-dataspace-access-configure), for generic Salesforce metadata deployment (use platform-metadata-deploy), for querying org data only (use platform-soql-query), or when setting up the data kit for the Trade Promotion Effectiveness (TPE) feature (use consumer-goods-tpe-datakit-deploy instead).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 18.9 KB |
| scripts/setup.jsexecutable | script | 10.9 KB |
| scripts/steps/00-check-prerequisites.js | script | 1.9 KB |
| scripts/steps/01-download-static-resource.js | script | 3.5 KB |
| scripts/steps/02-replace-org-id.js | script | 1.6 KB |
| scripts/steps/03-deploy-metadata.js | script | 1.1 KB |
| scripts/steps/04-deploy-engine.js | script | 6.7 KB |
| scripts/steps/05-deploy-tpm-accruals.js | script | 8.9 KB |
| scripts/steps/06-create-dataspace.js | script | 2.0 KB |
| scripts/steps/07-deploy-accruals-reports.js | script | 8.5 KB |
| scripts/steps/08-deploy-ui.js | script | 8.1 KB |
| scripts/steps/09-completion.js | script | 2.5 KB |
| scripts/steps/utils.js | script | 15.8 KB |
scripts/steps/08-deploy-ui.js
View on GitHubconst { execFileSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const { exec, execDeployJson, getSfBin } = require('./utils');
/**
* Step 8: Deploy UI components (TPMAccrualTacticSummary) with Data Space replacements
* @param {string} orgAlias - The Salesforce org alias
* @param {string} setupDir - The setup directory path
* @param {boolean} skipDataSpace - Whether to skip data space configuration
* @param {string} configuredDataSpaceName - The data space name from config
* @param {string} configuredDataSpacePrefix - The data space prefix from config
* @param {string} salesOrg - The sales org identifier
* @param {string} namespace - Org namespace prefix WITH trailing "__" (e.g. "cgcloud_dev__"), or '' for unmanaged
* @param {boolean} dryRun - If true, skip deployment but keep temp files
*/
async function deployUI(orgAlias, setupDir, skipDataSpace, configuredDataSpaceName, configuredDataSpacePrefix, salesOrg = '0001', namespace = '', dryRun = false) {
console.log('\n=== Step 8: Deploying UI Components ===');
// Use "default" and empty prefix if skipping data space, otherwise use configured values
const dataSpaceName = skipDataSpace ? 'default' : configuredDataSpaceName;
const dataSpacePrefix = skipDataSpace ? '' : configuredDataSpacePrefix;
console.log(`Data Space Name: ${dataSpaceName}`);
console.log(`Data Space Prefix: ${dataSpacePrefix || '(empty)'}`);
console.log(`Sales Org: ${salesOrg}`);
console.log(`Namespace: ${namespace || '(none)'}`);
const sourceDir = path.join(setupDir, 'CGCloudAddons', 'TPM', 'Accruals', 'UI');
const tempDir = path.join(setupDir, 'temp-ui');
// Clean up temp directory if it exists
if (fs.existsSync(tempDir)) {
console.log('Cleaning up existing temp directory...');
fs.rmSync(tempDir, { recursive: true });
}
console.log('Copying UI components to temp directory...');
copyDirectory(sourceDir, tempDir);
console.log('Replacing Data Space placeholders, namespace, and sales org in file names and contents...');
replaceDataSpacePlaceholders(tempDir, dataSpaceName, dataSpacePrefix, salesOrg, namespace);
const deployPath = path.join(tempDir, 'force-app');
if (dryRun) {
console.log('[DRY RUN] Skipping deployment - files prepared at:');
console.log(` ${tempDir}`);
console.log('[DRY RUN] Temp directory preserved for inspection');
console.log('[OK] Step 8 completed (dry run)\n');
return;
}
console.log('Deploying UI components metadata...');
execDeployJson(['project', 'deploy', 'start', '--source-dir', deployPath, '--target-org', orgAlias]);
// Clean up temp directory
console.log('Cleaning up temp directory...');
fs.rmSync(tempDir, { recursive: true });
console.log('[OK] UI Components deployed successfully\n');
// Show manual step instructions
console.log('+============================================================================+');
console.log('| MANUAL STEP REQUIRED |');
console.log('+============================================================================+');
console.log('');
console.log(' Please manually add the TPMAccrualTacticSummary component to the');
console.log(' Promotion page in your Salesforce org.');
console.log('');
console.log(' Steps:');
console.log(' 1. Navigate to the Promotion page layout editor');
console.log(' 2. Add the TPMAccrualTacticSummary Lightning component to the page');
console.log(' 3. Save and activate the page');
console.log('');
console.log('============================================================================');
console.log('');
}
/**
* Recursively copy a directory
*/
function copyDirectory(src, dest) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
const entries = fs.readdirSync(src, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
copyDirectory(srcPath, destPath);
} else {
fs.copyFileSync(srcPath, destPath);
}
}
}
/**
* Replace placeholders in a name (file or directory)
* Handles double underscore pattern to avoid DS2__ becoming DS2___
*/
function replaceNamePlaceholders(name, dataSpaceName, dataSpacePrefix) {
let newName = name;
if (dataSpacePrefix === '') {
newName = newName.replace(/_DATASPACE_PREFIX__/g, '');
} else {
newName = newName.replace(/_DATASPACE_PREFIX__/g, dataSpacePrefix);
}
newName = newName
.replace(/_DATASPACE_PREFIX_/g, dataSpacePrefix)
.replace(/_DATASPACE_NAME_/g, dataSpaceName);
return newName;
}
/**
* Replace Data Space placeholders in both file names and file contents
*/
function replaceDataSpacePlaceholders(dir, dataSpaceName, dataSpacePrefix, salesOrg, namespace) {
const entries = fs.readdirSync(dir, { withFileTypes: true });
for (const entry of entries) {
const oldPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
// Recursively process subdirectories first
replaceDataSpacePlaceholders(oldPath, dataSpaceName, dataSpacePrefix, salesOrg, namespace);
// Rename directory if it contains placeholders
if (entry.name.includes('_DATASPACE_PREFIX_') || entry.name.includes('_DATASPACE_NAME_')) {
const newName = replaceNamePlaceholders(entry.name, dataSpaceName, dataSpacePrefix);
const newPath = path.join(dir, newName);
fs.renameSync(oldPath, newPath);
}
} else {
// Process file contents
replaceInFile(oldPath, dataSpaceName, dataSpacePrefix, salesOrg, namespace);
// Rename file if it contains placeholders
if (entry.name.includes('_DATASPACE_PREFIX_') || entry.name.includes('_DATASPACE_NAME_')) {
const newName = replaceNamePlaceholders(entry.name, dataSpaceName, dataSpacePrefix);
const newPath = path.join(dir, newName);
fs.renameSync(oldPath, newPath);
}
}
}
}
/**
* Replace placeholders in file contents
*/
function replaceInFile(filePath, dataSpaceName, dataSpacePrefix, salesOrg, namespace) {
try {
let content = fs.readFileSync(filePath, 'utf8');
// Check if file contains placeholders or hardcoded sales org
const hasPlaceholders = content.includes('_DATASPACE_PREFIX_') || content.includes('_DATASPACE_NAME_') || content.includes('_ORG_NS_');
const hasSalesOrgKey = content.includes("'0001':") && filePath.endsWith('Controller.js');
if (hasPlaceholders || hasSalesOrgKey) {
if (dataSpacePrefix === '') {
// If dataspace prefix is empty, remove double underscore pattern entirely
content = content.replace(/_DATASPACE_PREFIX__/g, '');
} else {
// Replace double underscore pattern first to avoid double underscores in output
// _DATASPACE_PREFIX__ with DS2_ results in DS2_ (not DS2__)
content = content.replace(/_DATASPACE_PREFIX__/g, dataSpacePrefix);
}
content = content
.replace(/_DATASPACE_PREFIX_/g, dataSpacePrefix)
.replace(/_DATASPACE_NAME_/g, dataSpaceName)
.replace(/_ORG_NS_/g, namespace || '');
// Replace the hardcoded '0001' sales org key in the CONFIGURATION_BY_SALESORG map
if (hasSalesOrgKey) {
// Belt-and-suspenders: salesOrg must be validated before splicing into JS source
if (!/^[A-Za-z0-9]{4}$/.test(salesOrg)) {
throw new Error(
`Error: Invalid sales org. Expected a 4-character alphanumeric identifier.`
);
}
content = content.replace(/'0001':/g, `'${salesOrg}':`);
}
fs.writeFileSync(filePath, content, 'utf8');
}
} catch (error) {
if (error.code === 'EISDIR') {
// Directory entry -- skip silently, expected when walking mixed trees
return;
}
// Unexpected I/O failure (missing file, permission error, write error)
throw new Error(`Failed to process UI template file ${filePath}: ${error.message}`, { cause: error });
}
}
module.exports = deployUI;
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |