npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dattel-client

v0.8.3

Published

The client side of the dattel static site hosting solution.

Downloads

245

Readme

dattel-client

TODO: This is still very much a work in progress. Neither the code nor this README is done yet. Expect breaking changes.

Take a look at the CircleCI sample config to see how to deploy to a dattel-managed site from CI. A sample config including Hugo builds is also provided.

Example

A small example on how to use the client:

const api = require('dattel-client')({
    server_url: 'https://dattel-05.acme.tld:3000',
    auth_token: 'NkZB32dKm7HLRd4mIHIylYHuzMGZLRa1'
});

async function main() {
    try {
        const site_id = 'my-site';
        const domains = ['my-site.my-domain.tld'];

        console.log('Creating site…');
        await api.createSite(site_id, domains);

        console.log('Starting deploy…');
        const deploy_details = (await api.startDeploy(site_id)).deploy;

        console.log('Deploying directory…');
        await api.deployDirectory(
            site_id,
            deploy_details.id,
            deploy_details.files,
            '/path/to/static/site'
        );

        console.log('Publishing deploy…');
        await api.publishDeploy(site_id, deploy_details.id);
    } catch (err) {
        console.error(err);
        process.exit(1);
    }
}

main();

CLI

dattel-client can also be used as a CLI. See below for the commands.

Short demonstration of using dattel CLI

To use the dattel CLI, you need to provide the server URL and auth token. You can either do this dynamically at runtime (dattel CLI will prompt you if the values are missing) or conveniently through environment variables:

export DATTEL_SERVER="https://dattel-05.acme.tld:3000"
export DATTEL_TOKEN="NkZB32dKm7HLRd4mIHIylYHuzMGZLRa1"

Config

When you create a new site using dattel site:create, a dattel config file called dattel.json is generated. Using this file, you can set the options that dattel deploy uses to deploy your site.

You can set the following options (all folder and file paths are relative to your dattel config's directory):

  • site_id: the site ID to deploy to (required, and filled automatically when creating a new site)
  • publish_dir: the folder to deploy from (defaults to public)
  • headers_file: the file to read headers from or false to not set any headers (defaults to _headers, uses Netlify's syntax)
  • redirects_file: the file to read redirects from or false to not set any redirects (defaults to _redirects, uses Netlify's syntax with some restrictions)

See the schema for the full specification of the available options.

You can also have multiple dattel configs, for different environments for example, and then pass the config path using dattel deploy -c <path>.

Commands

dattel autocomplete [SHELL]

display autocomplete installation instructions

USAGE
  $ dattel autocomplete [SHELL]

ARGUMENTS
  SHELL  shell type

OPTIONS
  -r, --refresh-cache  Refresh cache (ignores displaying instructions)

EXAMPLES
  $ dattel autocomplete
  $ dattel autocomplete bash
  $ dattel autocomplete zsh
  $ dattel autocomplete --refresh-cache

See code: @oclif/plugin-autocomplete

dattel deploy

perform a new deploy for a dattel-powered site

USAGE
  $ dattel deploy

OPTIONS
  -c, --config-file=config-file      [default: dattel.json] path of the site config file

  --fail-on-existing-deploy          fail if there is an existing deploy, otherwise all in-progress or stale deploys are
                                     deleted

  --no-update-headers-and-redirects  don't update headers and redirects after publishing the deploy

DESCRIPTION
  This works on the properties set in the dattel config file. You can find all properties in the README: 
  https://github.com/binaro-xyz/dattel-client#CLI

  Dattel will walk up the directory tree starting from your cwd until it finds the dattel config or error out if it 
  doesn't.

EXAMPLES
  $ dattel deploy
  $ dattel deploy -c dattel.prod.json
  $ dattel deploy --fail-on-existing-deploy
  $ dattel deploy --no-update-headers-and-redirects

dattel help [COMMAND]

display help for dattel

USAGE
  $ dattel help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

dattel site:create [SITE_ID]

create a new dattel-powered site

USAGE
  $ dattel site:create [SITE_ID]

ARGUMENTS
  SITE_ID  ID the new site should have

OPTIONS
  -d, --domain=domain       (required) domain(s) the new site should be reachable under (specify multiple times to use
                            multiple domains)

  --bunny-pricing-type=0|1  the Bunny pricing type (0 for "standard", 1 for "high volume") to use for the CDN (only
                            applicable when the CDN is enabled, defaults to 0)

  --disable-cdn             don't put the new site behind a CDN but instead serve directly from dattel

EXAMPLES
  $ dattel site:create my-new-site -d site.mydomain.tld
  $ dattel site:create my-new-site -d site.mydomain.tld -d site.myotherdomain.tld
  $ dattel site:create my-new-site -d site.mydomain.tld --disable-cdn
  $ dattel site:create my-new-site -d site.mydomain.tld --bunny-pricing-type 1

dattel site:delete [SITE_ID]

delete an existing dattel-powered site

USAGE
  $ dattel site:delete [SITE_ID]

ARGUMENTS
  SITE_ID  ID of the site to delete

OPTIONS
  --delete-token=delete-token  delete token (used to prevent unintentional deletes, will be prompted for otherwise)

EXAMPLES
  $ dattel site:delete my-site
  $ dattel site:delete my-site --delete-token 6jkhRTzqxDLSrmQYPMHY9