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 | import path from 'node:path';
import fs from 'fs-extra';
import { fileURLToPath } from 'url';
import arg from 'arg';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const root = path.resolve(__dirname, '../');
const dist = path.resolve(root, 'dist');
const args = arg(
{
'--version': String,
},
{ permissive: true },
);
fs.copySync(path.resolve(root, 'package.json'), path.resolve(dist, 'package.json'));
const packageJson = fs.readJsonSync(path.resolve(dist, 'package.json'));
if (args['--version'] === packageJson.version) {
throw new Error(
`The version ${args['--version']} is the current version. Please provide a new semver version.`,
);
}
// Always strip dev-only fields so publishing from dist does not trigger lifecycle scripts again.
// This is necessary because:
// 1. Lerna publishes from the dist directory (via publishConfig.directory: "dist")
// 2. If lifecycle scripts (prepack, prepublishOnly, etc.) remain in dist/package.json,
// they will execute again during the publish process, potentially causing duplicate builds
// or other unintended side effects
// 3. Dev dependencies are not needed in the published package
// 4. Volta configuration is workspace-specific and shouldn't be published
delete packageJson.scripts;
delete packageJson.devDependencies;
delete packageJson.volta;
delete packageJson.type;
delete packageJson.private;
packageJson.name = '@salesforce-ux/sds-styling-hooks';
// Optionally bump version if provided via flag
if (args['--version']) {
packageJson.version = args['--version'];
}
fs.outputJsonSync(path.resolve(dist, 'package.json'), packageJson, { spaces: 2 });
|