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 (#145)
Enable Vercel deployments to upload tarballs of each package, so that they can be installed and tested before being released in a mainline npm package release. For example: ``` npm i https://proxy-agents-git-pack-tootallnate.vercel.app/proxy-agent.tgz ```
- Loading branch information
1 parent
4b3e591
commit b3b08f9
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
b3b08f9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
proxy-agents – ./
proxy-agents-tootallnate.vercel.app
proxy-agents-git-main-tootallnate.vercel.app
proxy-agents.vercel.app