forcedotcom/sf-skills / plugins/builder/experience-react/skills/experience-ui-bundle-metadata-generate
experience-ui-bundle-metadata-generate
VerifiedUse this skill when adding a front-end React or Angular UI bundle to an EXISTING SFDX project, or configuring UI bundle metadata and config files. TRIGGER when: adding or scaffolding a new UI bundle — including adding one more or another UI bundle — into a project that already exists; scaffolding a single bundle with the basic template (reactbasic or angularbasic) via sf template generate ui-bundle; editing ui-bundle.json routing, headers, or output directory; working with *.uibundle-meta.xml files; or registering CSP Trusted Sites, resolving blocked images or fonts or external API calls, or editing cspTrustedSites/*.cspTrustedSite-meta.xml files. DO NOT TRIGGER when: creating a brand-new Salesforce project entirely from scratch, where the whole SFDX starter project (UI bundle plus Experience Site metadata and toolchain) is generated together in one step (use experience-ui-bundle-project-generate).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.5 KB |
| references/angular-metadata-generate.md | markdown | 2.5 KB |
| references/csp-metadata-format.md | markdown | 12.3 KB |
| references/react-metadata-generate.md | markdown | 1.5 KB |
| scripts/check-api-version.mjsexecutable | script | 1.3 KB |
| scripts/detect-framework.mjsexecutable | script | 3.5 KB |
| scripts/verify-bundle-location.mjsexecutable | script | 5.6 KB |
scripts/detect-framework.mjs
View on GitHub#!/usr/bin/env node
//
// detect-framework.mjs — deterministic UI Bundle framework detector.
//
// Usage: node detect-framework.mjs [ROOT]
// ROOT app or uiBundle root to inspect (default: current directory)
//
// Always invoke via `node` (never as a bare executable) so this works on
// Windows cmd/PowerShell as well as macOS/Linux/Git Bash.
//
// Prints exactly one of the following tokens to stdout, nothing else, and sets
// a matching exit code so callers can branch without parsing:
// react (exit 0) — React signals only
// angular (exit 0) — Angular signals only
// ambiguous (exit 2) — both React and Angular signals present
// unknown (exit 3) — neither framework detected
//
// Step 0 of the skill acts on the result: a single framework (exit 0) proceeds;
// `ambiguous` asks the user to disambiguate; `unknown` TERMINATES the workflow
// (no supported framework found — do not guess).
import fs from "node:fs";
import path from "node:path";
const ROOT = process.argv[2] ?? ".";
let angular = false;
let react = false;
// Resolve ROOT to an absolute path when possible (for the angular.json walk-up).
let absRoot = "";
try {
if (fs.statSync(ROOT).isDirectory()) {
absRoot = fs.realpathSync(ROOT);
}
} catch {
absRoot = "";
}
// 1) angular.json at or above ROOT → Angular workspace.
if (absRoot) {
let dir = absRoot;
for (;;) {
if (fs.existsSync(path.join(dir, "angular.json"))) {
angular = true;
}
const parent = path.dirname(dir);
if (parent === dir) break;
dir = parent;
}
}
// Recursively collect file paths under `root`, skipping node_modules directories.
function walk(root) {
const results = [];
const stack = [root];
while (stack.length > 0) {
const current = stack.pop();
let entries;
try {
entries = fs.readdirSync(current, { withFileTypes: true });
} catch {
continue;
}
for (const entry of entries) {
if (entry.isDirectory()) {
if (entry.name === "node_modules") continue;
stack.push(path.join(current, entry.name));
} else if (entry.isFile()) {
results.push(path.join(current, entry.name));
}
}
}
return results;
}
const files = walk(ROOT);
// 2) package.json dependencies (excluding node_modules).
for (const file of files) {
if (path.basename(file) !== "package.json") continue;
let content = "";
try {
content = fs.readFileSync(file, "utf8");
} catch {
continue;
}
if (content.includes('"@angular/core"')) angular = true;
if (/"react"\s*:/.test(content)) react = true;
}
// 3) Source-file signatures (excluding node_modules).
function hasFile(matches) {
return files.some(matches);
}
// Angular: component files, routing module, or @Component-decorated classes.
if (hasFile((f) => f.endsWith(".component.ts"))) angular = true;
if (hasFile((f) => path.basename(f) === "app.routes.ts")) angular = true;
for (const file of files) {
if (!file.endsWith(".ts")) continue;
let content = "";
try {
content = fs.readFileSync(file, "utf8");
} catch {
continue;
}
if (content.includes("@Component")) {
angular = true;
break;
}
}
// React: JSX/TSX source files.
if (hasFile((f) => f.endsWith(".tsx"))) react = true;
if (hasFile((f) => f.endsWith(".jsx"))) react = true;
if (angular && react) {
console.log("ambiguous");
process.exit(2);
} else if (angular) {
console.log("angular");
process.exit(0);
} else if (react) {
console.log("react");
process.exit(0);
} else {
console.log("unknown");
process.exit(3);
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |