Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "pack" script for Vercel deployment
- Loading branch information
1 parent
4b3e591
commit 7b872f8
Showing
16 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,7 @@ yarn-error.log* | |
|
||
# vercel | ||
.vercel | ||
|
||
# `pack` script | ||
*.tgz | ||
/public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { join } from 'path'; | ||
import { spawnSync } from 'child_process'; | ||
import { | ||
readFileSync, | ||
writeFileSync, | ||
readdirSync, | ||
mkdirSync, | ||
renameSync, | ||
} from "fs"; | ||
|
||
// eslint-disable-next-line turbo/no-undeclared-env-vars | ||
const { VERCEL_URL } = process.env; | ||
|
||
const cwd = process.cwd(); | ||
const publicDir = new URL('../public/', import.meta.url); | ||
mkdirSync(publicDir, { recursive: true }); | ||
|
||
const packages = readdirSync(join(cwd, '..')); | ||
const pkgPath = join(cwd, 'package.json'); | ||
const pkg = JSON.parse(readFileSync(pkgPath)); | ||
if (pkg.dependencies) { | ||
for (const dep of Object.keys(pkg.dependencies)) { | ||
if (packages.includes(dep)) { | ||
// This dep is one of the ones within the monorepo, | ||
// so update to use a tarball URL | ||
pkg.dependencies[dep] = `https://${VERCEL_URL}/${dep}.tgz` | ||
} | ||
} | ||
} | ||
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`); | ||
spawnSync('pnpm', ['pack']); | ||
|
||
const tarball = readdirSync(cwd).find(f => f.endsWith('.tgz')); | ||
const dest = new URL(`${pkg.name}.tgz`, publicDir); | ||
renameSync(join(cwd, tarball), dest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters