Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

now-client

7.0.1 • Public • Published

now client

Build Status Join the community on GitHub Discussions

The official Node.js client for deploying to Now. It supports v1 and v2 deployments.

Usage

Firstly, install the package:

npm install now-client
# or 
yarn add now-client

Next, load it:

// v2
const { createDeployment } = require('now-client');
// v1
const { createLegacyDeployment } = require('now-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 now.json-valid fields
async function deploy() {
  let deployment;
 
  for await (const event of createDeployment({
    token: process.env.TOKEN,
    path: '/Users/zeit-user/projects/front',
  })) {
    if (event.type === 'ready') {
      deployment = event.payload;
      break;
    }
  }
 
  return deployment;
}

Full list of events:

[
  // 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:

import { EVENTS } from 'now-client';

Keywords

none

Install

npm i now-client

DownloadsWeekly Downloads

1,661

Version

7.0.1

License

MIT

Unpacked Size

56.1 kB

Total Files

29

Homepage

zeit.co

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar