Skip to content

forcedotcom/sf-skills / plugins/builder/consumer-goods/skills/consumer-goods-tpe-datakit-deploy

consumer-goods-tpe-datakit-deploy

Verified

Deploy the TPM Accruals Data Kit components specifically required for Trade Promotion Effectiveness (TPE) dashboards. Use when a customer or admin wants to install or deploy the TPM data kit for TPE dashboards, or as a delegated step from consumer-goods-tpe-dashboard-configure. Do not use this skill if the customer wants to deploy the TPM Accruals Data Kit for the Accruals feature.

FileKindSize
SKILL.mdskill md15.2 KB
scripts/detect-namespace.jsexecutablescript2.3 KB
scripts/download-static-resource.jsexecutablescript5.6 KB
scripts/extract-crm-field-permissions.jsexecutablescript3.9 KB
scripts/sf-rest.jsscript3.5 KB
scripts/update-field-permissions.jsexecutablescript17.0 KB

scripts/download-static-resource.js

View on GitHub
#!/usr/bin/env node
/**
 * Downloads and unzips a StaticResource from an authenticated org, reusing
 * the same contract as `downloadStaticResource` in
 * `packages/liability-accruals/setup/steps/01-download-static-resource.js`
 * (SOQL for the StaticResource Id, then an authenticated GET against
 * `<instanceUrl>/services/data/v<apiVersion>/sobjects/StaticResource/<id>/Body`,
 * then extract the zip) — reimplemented here with Node's built-in fetch
 * instead of `curl`, so this skill has no dependency on that script. Zip
 * extraction shells out to a platform-native tool rather than an npm
 * package (`adm-zip`, etc.) so this skill stays dependency-free and portable
 * across machines that clone/copy it standalone, per this repo's
 * self-contained-skills rule:
 *   - Windows: `tar -xf` — the `tar.exe` bundled with Windows 10 (1803+) and
 *     11 is bsdtar, which reads zip archives transparently.
 *   - macOS/Linux: `unzip` — preinstalled on macOS; on Linux it's a common
 *     but not universal package (missing ⇒ clear error telling the user to
 *     install it). GNU `tar` on Linux cannot read zip, so `tar` is not a
 *     safe cross-platform substitute there.
 *
 * One deliberate deviation from that reference: `getOrgDetails()` there
 * reads `sf org display --json`'s `result.accessToken` directly, which no
 * longer returns a real token on `sf` CLI >= 2.136.8 (that field becomes a
 * redacted hint string pointing at `sf org auth show-access-token` —
 * confirmed live against this repo's own dev org). `getAccessToken()` in
 * ``./sf-rest` is version-gated to handle both cases; the token is never
 * printed.
 *
 * Usage:
 *   node download-static-resource.js \
 *     --target-org <username> \
 *     --name CGCloudAddons \
 *     [--output-dir <dir>]   # defaults to a fresh dir under the OS temp dir
 *
 * Writes <output-dir>/<name>.zip and unzips it to <output-dir>/<name>/.
 * Prints STATIC_RESOURCE_PATH=<absolute unzipped dir> on success.
 *
 * Exit codes: 0 = success, 1 = resource not found, org not connected, or
 * download/unzip failure.
 */

const fs = require('fs');
const os = require('os');
const path = require('path');
const { execFileSync } = require('child_process');
const { sfJson, getAccessToken } = require('./sf-rest');

function parseArgs(argv) {
  const args = {};
  for (let i = 0; i < argv.length; i += 1) {
    const token = argv[i];
    if (!token.startsWith('--')) continue;
    args[token.slice(2)] = argv[i + 1];
    i += 1;
  }
  return args;
}

function requireArg(args, name) {
  if (!args[name]) {
    console.error(`Missing required --${name}`);
    process.exit(1);
  }
  return args[name];
}

function unzipTo(zipPath, destDir) {
  const [cmd, cmdArgs] = process.platform === 'win32'
    ? ['tar', ['-xf', zipPath, '-C', destDir]]
    : ['unzip', ['-o', '-q', zipPath, '-d', destDir]];
  const attemptedCommand = `${cmd} ${cmdArgs.join(' ')}`;
  try {
    execFileSync(cmd, cmdArgs, { stdio: 'pipe' });
  } catch (error) {
    if (error.code === 'ENOENT') {
      console.error(
        `download-static-resource: command failed — "${attemptedCommand}" — "${cmd}" is not installed or not on PATH — ${
          process.platform === 'win32'
            ? 'expected the tar.exe bundled with Windows 10 (1803+) / 11'
            : 'install it (e.g. `apt install unzip`) and retry'
        }. If a different extraction command is available on this machine, run it manually against "${zipPath}" -> "${destDir}" and re-invoke this script with the same --output-dir to skip re-downloading.`
      );
      process.exit(1);
    }
    console.error(
      `download-static-resource: command failed — "${attemptedCommand}" — ${error.message}`
    );
    process.exit(1);
  }
}

async function main() {
  const args = parseArgs(process.argv.slice(2));
  const targetOrg = requireArg(args, 'target-org');
  const name = requireArg(args, 'name');
  const outputDir =
    args['output-dir'] ||
    fs.mkdtempSync(path.join(os.tmpdir(), 'cgcloud-static-resource-'));

  const queryResult = sfJson([
    'data',
    'query',
    '--target-org',
    targetOrg,
    '--query',
    `SELECT Id, Name FROM StaticResource WHERE Name='${name}'`,
    '--json',
  ]);
  if (!queryResult.records || queryResult.records.length < 1) {
    console.error(
      `download-static-resource: no StaticResource named "${name}" found in ${targetOrg} — confirm the package version installed in this org includes it.`
    );
    process.exit(1);
  }
  const staticResourceId = queryResult.records[0].Id;

  const orgDetails = sfJson(['org', 'display', '--target-org', targetOrg, '--json']);
  const instanceUrl = orgDetails.instanceUrl;
  const apiVersion = orgDetails.apiVersion || '60.0';
  const accessToken = getAccessToken(targetOrg);

  const bodyUrl = `${instanceUrl}/services/data/v${apiVersion}/sobjects/StaticResource/${staticResourceId}/Body`;
  const response = await fetch(bodyUrl, {
    headers: { Authorization: `Bearer ${accessToken}` },
  });
  if (!response.ok) {
    console.error(
      `download-static-resource: download failed with HTTP ${response.status}`
    );
    process.exit(1);
  }
  const buffer = Buffer.from(await response.arrayBuffer());

  fs.mkdirSync(outputDir, { recursive: true });
  const zipPath = path.join(outputDir, `${name}.zip`);
  fs.writeFileSync(zipPath, buffer);

  const unzipDir = path.join(outputDir, name);
  if (fs.existsSync(unzipDir)) {
    fs.rmSync(unzipDir, { recursive: true, force: true });
  }
  fs.mkdirSync(unzipDir, { recursive: true });
  unzipTo(zipPath, unzipDir);

  console.log(`STATIC_RESOURCE_PATH=${path.resolve(unzipDir)}`);
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 119kUpdated Claude CodeCodexVerifiedInstall
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: 118kUpdated Claude CodeCodexVerifiedInstall