mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-06 04:22:01 +00:00
<picture data-single-emoji=":pnpm:" title=":pnpm:"><img class="emoji" src="https://single-emoji.vercel.app/api/emoji/eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..4mJzrO94AnSn0Pue.4apgaKtTUdQ-wxNyahjdJj28u8bbXreLoTA8AGqYjLta3MrsFvbo9DsQFth4CoIkBgXFhQ5_BVcKNfYbwLg4bKzyIvItKe4OFS8AzG7Kkicz2kUUZk0.nXyK_PvHzZFGA-MQB6XHfA" alt=":pnpm:" width="20" height="auto" align="absmiddle"></picture> yarn has become increasingly more difficult to use as the v1 we rely on no longer receives updates. pnpm is faster and is actively maintained. This PR migrates us to pnpm.
57 lines
1.8 KiB
TypeScript
Vendored
57 lines
1.8 KiB
TypeScript
Vendored
import execa from 'execa';
|
|
import path from 'path';
|
|
import fs from 'fs-extra';
|
|
import { TurboDryRun } from './types';
|
|
|
|
const rootDir = path.join(__dirname, '..');
|
|
|
|
async function main() {
|
|
const { stdout: sha } = await execa('git', ['rev-parse', '--short', 'HEAD'], {
|
|
cwd: rootDir,
|
|
});
|
|
const { stdout: turboStdout } = await execa(
|
|
'turbo',
|
|
['run', 'build', '--dry=json'],
|
|
{
|
|
cwd: rootDir,
|
|
}
|
|
);
|
|
const turboJson: TurboDryRun = JSON.parse(turboStdout);
|
|
for (const task of turboJson.tasks) {
|
|
const dir = path.join(rootDir, task.directory);
|
|
const packageJsonPath = path.join(dir, 'package.json');
|
|
const originalPackageObj = await fs.readJson(packageJsonPath);
|
|
// api is not a package that will be published of this repo, but is used when deployed to Vercel
|
|
if (originalPackageObj.name === 'api') {
|
|
continue;
|
|
}
|
|
const packageObj = await fs.readJson(packageJsonPath);
|
|
packageObj.version += `-${sha.trim()}`;
|
|
|
|
if (task.dependencies.length > 0) {
|
|
for (const dependency of task.dependencies) {
|
|
const name = dependency.split('#')[0];
|
|
const tarballUrl = `https://${process.env.VERCEL_URL}/tarballs/${name}.tgz`;
|
|
if (packageObj.dependencies && name in packageObj.dependencies) {
|
|
packageObj.dependencies[name] = tarballUrl;
|
|
}
|
|
if (packageObj.devDependencies && name in packageObj.devDependencies) {
|
|
packageObj.devDependencies[name] = tarballUrl;
|
|
}
|
|
}
|
|
}
|
|
await fs.writeJson(packageJsonPath, packageObj, { spaces: 2 });
|
|
|
|
await execa('pnpm', ['pack'], {
|
|
cwd: dir,
|
|
stdio: 'inherit',
|
|
});
|
|
await fs.writeJson(packageJsonPath, originalPackageObj, { spaces: 2 });
|
|
}
|
|
}
|
|
|
|
main().catch(err => {
|
|
console.log('error running pack:', err);
|
|
process.exit(1);
|
|
});
|