Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | #!/usr/bin/env node
/**
* SCS (Static Content Service) Release Script
*
* Phase 0 – Seed:
* Clones (or refreshes) the target branch of aura/slds-scs and syncs its
* release-state directories (slds/, scs/, tnrp/, package.json) into the
* monorepo's packages/slds-scs/. This ensures Phase A starts from the
* real state of the downstream repo rather than stale monorepo data.
*
* Phase A – Assemble:
* Copies versioned CSS files from SLDS1 and SLDS2 dist outputs into
* packages/slds-scs/slds/ (including slds-plus, scoped-slds-plus, and
* slds-plus-theme-layer), runs FileParser to update scs/files.json with
* version retention, bumps the package version, and optionally updates
* the scs-client JAR.
* CSS files are gitignored in the monorepo (build artifacts only) —
* only files.json, package.json, and tnrp/ are committed here.
*
* Phase B – Export:
* Resets the clone to the target branch, syncs the assembled state from
* packages/slds-scs/ into it, and creates a PR targeting a core-XXX-patch
* production branch so the existing SFCI pipeline can build and publish.
*
* Configuration sources (in priority order):
* 1. CLI arguments (--key=value)
* 2. Environment variables
* 3. .release-config (versions, WI)
* 4. .distrc.json (nexusCreds)
* 5. Interactive prompts
*
* Usage:
* yarn workspace @salesforce-ux/design-system scs
* yarn workspace @salesforce-ux/design-system scs -- --wi W-9925295 --case=29996318
* yarn workspace @salesforce-ux/design-system scs -- --skip-seed # preserve local slds-scs edits
*
* Prerequisites:
* - TMP Auth (for Nexus scs-client lookup)
* - Push access to git.soma.salesforce.com:aura/slds-scs
* - .distrc.json with nexusCreds (or provide via CLI/prompt)
* - .release-config with version info (or provide via CLI/prompt)
*/
import { fileURLToPath } from 'node:url';
import path from 'node:path';
import process from 'node:process';
import fs from 'fs-extra';
import execa from './exec-adapter.js';
import enquirer from 'enquirer';
const { prompt } = enquirer;
import { FileParser } from './file-parser.js';
import { loadConfig } from './config-loader.js';
import * as autoVersion from './version-utils.js';
import { bumpScsVersionFromNexus, commitInMonorepo, pushReleaseBranchAndOpenPR } from './scs-helpers.js';
import { captureBaseline } from '../validation/capture-baseline-core.js';
// ------------------------------------------------------------------
// Path setup
// ------------------------------------------------------------------
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// packages/design-system (two levels up from scripts/scs/)
const packageRoot = path.resolve(__dirname, '../..');
const rootPath = (...args) => path.resolve(packageRoot, ...args);
// Monorepo root (two levels up from packages/design-system)
const monorepoRoot = path.resolve(packageRoot, '../..');
// packages/slds-scs — in-monorepo sub-package, seeded from the target branch
const scsPackageDir = path.resolve(monorepoRoot, 'packages/slds-scs');
const SCS_REPO = 'git@git.soma.salesforce.com:aura/slds-scs.git';
const SCS_CLONE_DIR = path.join(monorepoRoot, '.scs-clone');
// ------------------------------------------------------------------
// Configuration
// ------------------------------------------------------------------
const config = loadConfig(packageRoot);
// Source paths resolved locally within the monorepo
const SLDS1_DIST_PATH = rootPath('dist');
const SLDS2_DIST_PATH = rootPath('../design-system-2/dist');
// Internal (non-published) design-system-2 build artifacts — pearl sub-theme and
// theme-layer CSS live here, not in the published dist/.
const SLDS2_BUILD_PATH = rootPath('../design-system-2/build');
// Read SLDS1 version from dist package.json
let slds1DistVersion = null;
try {
slds1DistVersion = autoVersion.getVersion(path.join(SLDS1_DIST_PATH, 'package.json'));
} catch { /* dist not built yet — will prompt */ }
// Read SLDS2 version from design-system-2 package.json
let slds2DistVersion = null;
try {
slds2DistVersion = autoVersion.getVersion(rootPath('../design-system-2/package.json'));
} catch { /* dist not built yet — will prompt */ }
// Derive default core branch from the monorepo's salesforce-version.id
let defaultCoreBranch = null;
try {
const rootPkg = JSON.parse(
fs.readFileSync(path.join(monorepoRoot, 'package.json'), 'utf8'),
);
const releaseId = rootPkg['salesforce-version']?.id;
if (releaseId) {
defaultCoreBranch = `core-${releaseId}-patch`;
}
} catch { /* salesforce-version not set */ }
// ------------------------------------------------------------------
// Interactive prompts (fills in anything not provided via config)
// ------------------------------------------------------------------
async function ask() {
const prompts = [];
if (!config.pearlOnly) {
prompts.push(
config.nexusCreds || {
type: 'input',
name: 'nexusCreds',
message: 'Please provide your Nexus token in user:pass format\n ',
result(creds) {
return creds;
},
},
config.sldsVersion || {
type: 'input',
name: 'sldsVersion',
message: `SLDS1 Version?\n `,
initial: slds1DistVersion || '',
result(version) {
return version;
},
},
config.slds2Version || {
type: 'input',
name: 'slds2Version',
message: `SLDS2 Version (for slds-plus files)?\n `,
initial: slds2DistVersion || '',
result(version) {
return version;
},
},
);
}
prompts.push(
config.wi || {
type: 'input',
name: 'wi',
message: 'GUS Work Item Number?\n ',
result(wiNumber) {
return wiNumber;
},
},
config.case || {
type: 'input',
name: 'case',
message: 'GUS Change Case Number?\n ',
result(caseNumber) {
return caseNumber;
},
},
config.doPR || {
type: 'toggle',
name: 'doPR',
message: 'Do you want to create the PR on aura/slds-scs?\n ',
enabled: 'Yep',
disabled: 'Nope',
},
config.coreBranch || {
type: 'input',
name: 'coreBranch',
message: 'Target core branch on slds-scs?\n ',
initial: defaultCoreBranch || '',
},
);
return prompt(prompts).catch(console.error);
}
// ------------------------------------------------------------------
// Helpers
// ------------------------------------------------------------------
const gitInMonorepo = (cmd) =>
execa.commandSync(cmd, { cwd: monorepoRoot });
const scsPath = (...segments) => path.join(scsPackageDir, ...segments);
const gitAdd = (filePath) => {
const relPath = path.join('packages/slds-scs', filePath);
gitInMonorepo(`git add -f ${relPath}`);
console.log(` staged ${relPath}`);
};
// ------------------------------------------------------------------
// Main
// ------------------------------------------------------------------
ask().then(async (answers) => {
const nexusCredentials = config.nexusCreds || answers['nexusCreds'];
const workItemId = config.wi || answers['wi'];
const gusChangeCase = config.case || answers['case'];
const coreBranch = config.coreBranch || answers['coreBranch'];
const sldsVersion = config.sldsVersion || answers['sldsVersion'] || null;
const sldsVersionSemver = sldsVersion ? autoVersion.toSemver(sldsVersion) : null;
const slds2Version = config.slds2Version || answers['slds2Version'] || null;
const slds2VersionSemver = slds2Version ? autoVersion.toSemver(slds2Version) : null;
if (!config.pearlOnly) {
console.log(`\nSLDS1: ${sldsVersion} → ${sldsVersionSemver}`);
console.log(`SLDS2: ${slds2Version} → ${slds2VersionSemver}`);
}
console.log(`Target branch: ${coreBranch}`);
const prBody = `[GUS](https://gus.my.salesforce.com/apex/ADM_WorkLocator?bugorworknumber=${workItemId})
GUS Case Object:
@gus-change-case: ${gusChangeCase}@`;
// ================================================================
// Phase 0 — Seed packages/slds-scs/ from the target branch
// ================================================================
// Clone (or refresh) the target branch of aura/slds-scs and sync its
// release-state directories into packages/slds-scs/ so that Phase A
// starts from the real state of the downstream repo, not whatever
// happens to be committed (or left on disk) in the monorepo.
// Skipped with --skip-seed to preserve local edits for incremental updates.
if (config.skipSeed) {
console.log('\n── Phase 0: Skipped (--skip-seed) ──');
console.log(' Using local packages/slds-scs/ state as-is');
} else {
console.log(`\n── Phase 0: Seed from ${coreBranch} ──`);
if (!fs.existsSync(SCS_CLONE_DIR)) {
execa.commandSync(
`git clone --depth=1 --branch=${coreBranch} ${SCS_REPO} ${SCS_CLONE_DIR}`,
{ cwd: monorepoRoot },
);
} else {
execa.commandSync(`git fetch origin ${coreBranch}`, { cwd: SCS_CLONE_DIR });
execa.commandSync(`git checkout ${coreBranch}`, { cwd: SCS_CLONE_DIR });
execa.commandSync(`git reset --hard origin/${coreBranch}`, { cwd: SCS_CLONE_DIR });
}
const seedDirs = ['slds', 'scs', 'tnrp'];
for (const dir of seedDirs) {
const src = path.join(SCS_CLONE_DIR, dir) + '/';
const dest = scsPath(dir) + '/';
if (fs.existsSync(src)) {
fs.ensureDirSync(dest);
execa.sync('rsync', ['-a', '--delete', src, dest], { cwd: monorepoRoot });
console.log(` seeded ${dir}/`);
}
}
fs.copySync(
path.join(SCS_CLONE_DIR, 'package.json'),
scsPath('package.json'),
);
console.log(' seeded package.json');
// Capture a validation baseline from the seeded (target-branch) state
// so that compare-output can later diff against the assembled output.
await captureBaseline(
{ config: path.join(packageRoot, '.validation/scs.js') },
{ cwd: packageRoot },
);
}
// ================================================================
// Pearl-only mode — independent release of pearl subtheme CSS
// ================================================================
if (config.pearlOnly) {
const pearlVersion = config.pearlVersion || answers['pearlVersion'] || '0.0.1';
const pearlVersionSemver = autoVersion.toSemver(pearlVersion);
const pearlSourcePath = rootPath('../design-system-2/build/css/sub-themes/pearl.css');
console.log(`\n── Pearl-only mode ──`);
console.log(` Pearl version: ${pearlVersion} → ${pearlVersionSemver}`);
console.log(` Source: ${pearlSourcePath}`);
if (!fs.existsSync(pearlSourcePath)) {
console.error(`\nError: Pearl source file not found at ${pearlSourcePath}`);
console.error(' Run: yarn workspace @salesforce-ux/design-system-2 build:production');
process.exit(1);
}
// Copy pearl CSS
const scsSldsDir = scsPath('slds');
const pearlFilename = `slds-plus-pearl-subtheme-${pearlVersionSemver}.css`;
fs.copySync(pearlSourcePath, path.join(scsSldsDir, pearlFilename));
console.log(` ✓ ${pearlFilename}`);
// Update files.json
const filesJsonPath = scsPath('scs', 'files.json');
const jsonData = JSON.parse(fs.readFileSync(filesJsonPath, 'utf8'));
const [updatedFiles] = FileParser({
originalData: jsonData,
pearlVersionSemver,
});
fs.writeFileSync(filesJsonPath, JSON.stringify(updatedFiles, null, 2));
console.log(` Updated scs/files.json — added pearl entry ${pearlVersionSemver}`);
gitAdd('scs/files.json');
// Bump package version
const { to: newPackageVersion } = bumpScsVersionFromNexus({ monorepoRoot, scsPackageDir, gitAdd });
// Commit
const branchName = `release-${newPackageVersion}-pearl-subtheme-${pearlVersionSemver}`;
const commitMsg = `update pearl subtheme [${pearlVersionSemver}] in ${newPackageVersion}`;
commitInMonorepo(commitMsg, { monorepoRoot, gitInMonorepo });
// Phase B — Export (force-push without prompt — pearl iterates frequently)
const cliDoPR = config.doPR === true || config.doPR === 'true';
if (cliDoPR || answers['doPR']) {
const prTitle = `@${workItemId} bumped to ${newPackageVersion} with pearl subtheme ${pearlVersionSemver}`;
await pushReleaseBranchAndOpenPR({
branchName,
commitMsg,
prTitle,
prBody,
coreBranch,
workItemId,
confirmForcePush: false,
scsPackageDir,
scsCloneDir: SCS_CLONE_DIR,
monorepoRoot,
config,
});
}
console.log('\n✓ Pearl-only release complete');
return;
}
// ================================================================
// Phase A — Assemble new slds-scs version in the monorepo
// ================================================================
console.log('\n── Phase A: Assemble ──');
// ------------------------------------------------------------------
// CSS file mappings — write directly into packages/slds-scs/slds/
// ------------------------------------------------------------------
const scsSldsDir = scsPath('slds');
const srcDir = SLDS1_DIST_PATH;
const scsFiles = [
{
src: path.join(srcDir, 'assets/styles/salesforce-lightning-design-system_touch.css'),
dest: scsSldsDir,
filename: `slds-touch-${sldsVersionSemver}.css`,
},
{
src: path.join(srcDir, 'assets/styles/salesforce-lightning-design-system.css'),
dest: scsSldsDir,
filename: `slds-${sldsVersionSemver}.css`,
},
{
src: path.join(srcDir, 'assets/styles/salesforce-lightning-design-system-legacy.css'),
dest: scsSldsDir,
filename: `slds-legacy-${sldsVersionSemver}.css`,
},
{
src: path.join(srcDir, 'assets/styles/salesforce-lightning-design-system-offline.css'),
dest: scsSldsDir,
filename: `slds-offline-${sldsVersionSemver}.css`,
},
{
src: path.join(SLDS2_DIST_PATH, 'css/bundled/slds2.cosmos.css'),
dest: scsSldsDir,
filename: `slds-plus-${slds2VersionSemver}.css`,
},
{
src: path.join(SLDS2_DIST_PATH, 'css/bundled/slds2.scoped.cosmos.css'),
dest: scsSldsDir,
filename: `scoped-slds-plus-${slds2VersionSemver}.css`,
},
{
// Theme-layer is an internal pipeline artifact under build/, not part of
// the published design-system-2 package (unlike the bundled outputs above).
src: path.join(
SLDS2_BUILD_PATH,
'css/theme-layer/bundled/slds2.theme-layer.cosmos.css',
),
dest: scsSldsDir,
filename: `slds-plus-theme-layer-${slds2VersionSemver}.css`,
},
];
console.log('\nCopying CSS files into packages/slds-scs/slds/');
const copyResults = { ok: [], failed: [] };
scsFiles.forEach(({ src, dest, filename }) => {
try {
fs.copySync(src, path.join(dest, filename));
copyResults.ok.push(filename);
} catch {
copyResults.failed.push({ filename, src });
}
});
copyResults.ok.forEach((f) => console.log(` ✓ ${f}`));
copyResults.failed.forEach(({ filename, src }) =>
console.log(` ✗ ${filename}\n source missing: ${src}`),
);
console.log(` ${copyResults.ok.length} copied, ${copyResults.failed.length} failed`);
if (copyResults.failed.length) {
const slds2Missing = copyResults.failed.filter(({ src }) => src.includes('design-system-2'));
const slds1Missing = copyResults.failed.filter(({ src }) => !src.includes('design-system-2'));
console.error(`\nError: ${copyResults.failed.length} CSS source file(s) not found.`);
if (slds2Missing.length) {
console.error(
`\n SLDS2 (slds-plus) files missing — the design-system-2 package likely hasn't been built.\n` +
' Run: yarn workspace @salesforce-ux/design-system-2 build:production',
);
}
if (slds1Missing.length) {
console.error(
`\n SLDS1 files missing — the design-system dist has not been built.\n` +
' Run: yarn workspace @salesforce-ux/design-system build',
);
}
process.exit(1);
}
// CSS files in slds/ are gitignored in the monorepo (they are build
// artifacts tracked only in the downstream slds-scs repo). No git add
// here — Phase B syncs them to the clone independently.
// ------------------------------------------------------------------
// Update scs/files.json
// ------------------------------------------------------------------
const lwrMappedVersion =
autoVersion.parse(autoVersion.getVersion(path.join(srcDir, 'package.json'))).minor - 14;
const filesJsonPath = scsPath('scs', 'files.json');
const filesJsonString = fs.readFileSync(filesJsonPath, 'utf8');
const jsonData = JSON.parse(filesJsonString);
const [updatedFiles, rejectFiles] = FileParser({
sldsVersionSemver,
lwrMappedVersion,
originalData: jsonData,
rejectFiles: [],
versionRetentionLimit: [3, 3, 3],
slds2VersionSemver,
});
fs.writeFileSync(filesJsonPath, JSON.stringify(updatedFiles, null, 2));
const entryCount = updatedFiles.files?.length ?? 0;
console.log(`\nUpdated scs/files.json — ${entryCount} entries (SLDS1 ${sldsVersionSemver}, SLDS2 ${slds2VersionSemver})`);
gitAdd('scs/files.json');
if (rejectFiles.length) {
console.log(`\nRetention policy: removing ${rejectFiles.length} old file(s)`);
rejectFiles
.map((f) => f.filePath)
.forEach((filePath) => {
fs.removeSync(scsPath(filePath));
console.log(` ✗ ${filePath}`);
});
}
// ------------------------------------------------------------------
// Bump slds-scs package version (from latest published on Nexus)
// ------------------------------------------------------------------
const { to: newPackageVersion } = bumpScsVersionFromNexus({ monorepoRoot, scsPackageDir, gitAdd });
// ------------------------------------------------------------------
// SCS Client — check for updates
// ------------------------------------------------------------------
console.log('\nChecking scs-client JAR version...');
const cmdListScsClientVersion = `ls ${scsPath('tnrp')}/scs* | sed -E "s/..*([[:digit:]]\\.[[:digit:]]\\.[[:digit:]]{1,3})..*/\\1/g"`;
const { stdout: scsClientVersion } = execa.sync('sh', ['-c', cmdListScsClientVersion]);
const cmdLatestScsClientVersion = `curl -L -u '${nexusCredentials}' -X GET "https://nexus-dev.data.sfdc.net/nexus/service/rest/v1/search/assets?sort=version&repository=releases&maven.groupId=com.salesforce.armada&maven.artifactId=scs-client&maven.classifier=&maven.extension=jar&direction=desc" -H "accept: application/json" | jq -r ".items[0]"`;
const { stdout: scsClientLatestVersionStdOut } = execa.sync('sh', ['-c', cmdLatestScsClientVersion]);
const scsClientLatestVersionData = JSON.parse(scsClientLatestVersionStdOut);
const scsClientLatestVersion = scsClientLatestVersionData.maven2.version;
if (scsClientVersion === scsClientLatestVersion) {
console.log(` scs-client ${scsClientVersion} is up to date`);
} else {
console.log(` scs-client ${scsClientVersion} → ${scsClientLatestVersion} (updating)`);
const jarDest = scsPath('tnrp', `scs-client-${scsClientLatestVersion}.jar`);
execa.sync('curl', ['-k', '-o', jarDest, '-u', nexusCredentials, scsClientLatestVersionData.downloadUrl]);
gitAdd(`tnrp/scs-client-${scsClientLatestVersion}.jar`);
const tnrpPackagePath = scsPath('tnrp', 'package');
const scsClientRegex = `s/(scs-client-)[[:digit:]]\\.[[:digit:]]\\.[[:digit:]]{1,3}(\\.jar)/\\1${scsClientLatestVersion}\\2/`;
execa.sync('sed', ['-i', '', '-E', scsClientRegex, tnrpPackagePath]);
gitAdd('tnrp');
console.log(` updated tnrp/package to scs-client-${scsClientLatestVersion}.jar`);
}
// ------------------------------------------------------------------
// Commit in monorepo
// ------------------------------------------------------------------
const branchName = `release-${newPackageVersion}-slds-${sldsVersion}-slds-plus-${slds2Version}`;
const commitMsg = `update SLDS files [${sldsVersion}] in ${newPackageVersion}`;
commitInMonorepo(commitMsg, { monorepoRoot, gitInMonorepo });
// ================================================================
// Phase B — Export to aura/slds-scs and create PR
// ================================================================
const cliDoPR = config.doPR === true || config.doPR === 'true';
if (cliDoPR || answers['doPR']) {
const prTitle = `@${workItemId} bumped to ${newPackageVersion} with SLDS ${sldsVersion}, SLDS2/+ ${slds2Version}`;
await pushReleaseBranchAndOpenPR({
branchName,
commitMsg,
prTitle,
prBody,
coreBranch,
workItemId,
confirmForcePush: true,
scsPackageDir,
scsCloneDir: SCS_CLONE_DIR,
monorepoRoot,
config,
});
}
});
|