diff --git a/api/_lib/script/build.ts b/api/_lib/script/build.ts index 38c627e14..10bc86fd8 100644 --- a/api/_lib/script/build.ts +++ b/api/_lib/script/build.ts @@ -1,6 +1,5 @@ import fs from 'fs/promises'; import { join, dirname } from 'path'; -import execa from 'execa'; import { getExampleList } from '../examples/example-list'; import { mapOldToNew } from '../examples/map-old-to-new'; @@ -47,10 +46,6 @@ async function main() { JSON.stringify([...existingExamples, ...oldExamples]) ); - const { stdout: sha } = await execa('git', ['rev-parse', '--short', 'HEAD'], { - cwd: repoRoot, - }); - const tarballsDir = join(pubDir, 'tarballs'); const packagesDir = join(repoRoot, 'packages'); const packages = await fs.readdir(packagesDir); @@ -61,12 +56,21 @@ async function main() { 'utf-8' ); const packageJson = JSON.parse(packageJsonRaw); - const tarballName = `${packageJson.name - .replace('@', '') - .replace('/', '-')}-v${packageJson.version}-${sha.trim()}.tgz`; + const files = await fs.readdir(fullDir); + const tarballName = files.find(f => /^vercel-.+\.tgz$/.test(f)); + if (!tarballName) { + throw new Error( + `Expected vercel-*.tgz in ${fullDir} but found ${JSON.stringify( + files, + null, + 2 + )}` + ); + } + const srcTarballPath = join(fullDir, tarballName); const destTarballPath = join(tarballsDir, `${packageJson.name}.tgz`); await fs.mkdir(dirname(destTarballPath), { recursive: true }); - await fs.copyFile(join(fullDir, tarballName), destTarballPath); + await fs.copyFile(srcTarballPath, destTarballPath); } console.log('Completed building static frontend.');