mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 04:22:07 +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.
68 lines
1.4 KiB
Markdown
68 lines
1.4 KiB
Markdown
# @vercel/client
|
|
|
|
[](https://github.com/vercel/vercel/discussions)
|
|
|
|
The official Node.js client for deploying to [Vercel](https://vercel.com).
|
|
|
|
## Usage
|
|
|
|
Firstly, install the package:
|
|
|
|
```bash
|
|
npm install @vercel/client
|
|
```
|
|
|
|
Next, load it:
|
|
|
|
```js
|
|
const { createDeployment } = require('@vercel/client');
|
|
```
|
|
|
|
Then call inside a `for...of` loop to follow the progress with the following arguments:
|
|
|
|
- `<path>` - a directory path / file path / array of file paths (must be on the same level)
|
|
- `<options>` - An object containing `token`, an optional `teamId` and any `vercel.json`-valid [fields](https://vercel.com/docs/api#endpoints/deployments/create-a-new-deployment)
|
|
|
|
```js
|
|
async function deploy() {
|
|
let deployment;
|
|
|
|
for await (const event of createDeployment({
|
|
token: process.env.TOKEN,
|
|
path: '/Users/me/Code/myproject',
|
|
})) {
|
|
if (event.type === 'ready') {
|
|
deployment = event.payload;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return deployment;
|
|
}
|
|
```
|
|
|
|
Full list of events:
|
|
|
|
```js
|
|
[
|
|
// File events
|
|
'hashes-calculated',
|
|
'file-count',
|
|
'file-uploaded',
|
|
'all-files-uploaded',
|
|
// Deployment events
|
|
'created',
|
|
'building',
|
|
'ready',
|
|
'alias-assigned',
|
|
'warning',
|
|
'error',
|
|
];
|
|
```
|
|
|
|
You can also get the events set programmatically:
|
|
|
|
```js
|
|
import { EVENTS } from '@vercel/client';
|
|
```
|