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 | #!/usr/bin/env node
/**
* Capture an SCS validation baseline from the upstream aura/slds-scs repo
* at the given target branch.
*
* Useful when you want to validate work done out-of-band (manual edits in
* `.scs-clone/`, recovery from a failed `release:scs` run, etc.) without
* re-running the full release flow.
*
* Workflow:
* 1. Clone (or refresh) aura/slds-scs at --branch into a temp dir.
* 2. Run `capture-baseline.js --config .validation/scs.js --source <clone>`
* so the captured baseline represents the upstream pre-release state.
*
* Usage:
* node scripts/scs/baseline-from-upstream.js [--branch core-XXX-patch] [--keep-temp]
*
* Defaults:
* --branch core-<salesforce-version.id>-patch (from monorepo root package.json)
* --repo git@git.soma.salesforce.com:aura/slds-scs.git
* --config .validation/scs.js
*/
import path from 'node:path';
import fs from 'fs-extra';
import chalk from 'chalk';
import yargs from 'yargs';
import { execFileSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const PACKAGE_ROOT = path.resolve(__dirname, '../..');
const MONOREPO_ROOT = path.resolve(PACKAGE_ROOT, '../..');
const DEFAULT_REPO = 'git@git.soma.salesforce.com:aura/slds-scs.git';
function deriveDefaultBranch() {
try {
const rootPkg = JSON.parse(
fs.readFileSync(path.join(MONOREPO_ROOT, 'package.json'), 'utf8'),
);
const id = rootPkg['salesforce-version']?.id;
return id ? `core-${id}-patch` : null;
} catch {
return null;
}
}
const argv = yargs(process.argv.slice(2))
.option('branch', {
alias: 'b',
type: 'string',
description: 'Target branch on aura/slds-scs',
default: deriveDefaultBranch(),
})
.option('repo', {
type: 'string',
description: 'SCS repo URL',
default: DEFAULT_REPO,
})
.option('config', {
alias: 'c',
type: 'string',
description: 'Validation config file',
default: '.validation/scs.js',
})
.option('keep-temp', {
type: 'boolean',
description: 'Keep the upstream clone after capture for inspection',
default: false,
})
.help()
.check((args) => {
if (!args.branch) {
throw new Error(
'Could not derive --branch from salesforce-version.id; pass --branch core-XXX-patch explicitly.',
);
}
return true;
})
.argv;
async function main() {
const branch = argv.branch;
const repo = argv.repo;
const keepTemp = argv['keep-temp'];
const tempDir = path.join(MONOREPO_ROOT, '.tmp', 'scs-upstream-baseline');
console.log(chalk.blue(`\nš” Capturing SCS baseline from upstream\n`));
console.log(chalk.gray(` Repo: ${repo}`));
console.log(chalk.gray(` Branch: ${branch}`));
console.log(chalk.gray(` Temp: ${tempDir}\n`));
fs.removeSync(tempDir);
fs.ensureDirSync(path.dirname(tempDir));
try {
execFileSync(
'git',
['clone', '--depth=1', `--branch=${branch}`, repo, tempDir],
{ stdio: ['ignore', 'pipe', 'inherit'] },
);
} catch (err) {
console.error(chalk.red(`ā git clone failed:`), err.shortMessage || err.message);
if (!keepTemp) fs.removeSync(tempDir);
process.exit(1);
}
const captureScript = path.resolve(__dirname, '../validation/capture-baseline.js');
try {
execFileSync(
'node',
[captureScript, '--config', argv.config, '--source', tempDir],
{ cwd: PACKAGE_ROOT, stdio: 'inherit' },
);
} catch (err) {
console.error(chalk.red(`ā capture-baseline failed:`), err.shortMessage || err.message);
if (!keepTemp) fs.removeSync(tempDir);
process.exit(1);
}
if (keepTemp) {
console.log(chalk.gray(`\n Upstream clone kept: ${tempDir}`));
} else {
fs.removeSync(tempDir);
}
console.log(
chalk.green(
`\nā
Baseline captured from upstream ${branch}. Run release:scs:compare to validate.\n`,
),
);
}
main().catch((err) => {
console.error(chalk.red('ā Error:'), err);
process.exit(1);
});
|