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

@eumentis/hasura-cli

v2.37.1

Published

A package that automatically installs and wraps Hasura CLI binary in isolated manner

Downloads

17

Readme

hasura-cli

Publish

Update the version in package.json and

npm publish --access public

An npm package that automatically installs and wraps Hasura CLI binary in isolated manner

npm version npm beta version npm alpha version npm download

license test code style:airbnb code style:prettier Conventional Commits Commitizen friendly pr welcome

Why?

The Original Hasura CLI, which is not this package, is a compiled binary originally written in go. But just installing it on your system could cause some problems.

  1. Difficult to use different hasura versions on multiple projects.
  2. Inconvenient to ensure every colleagues having same version installed.
  3. Manual installation not specified as npm devDependency.

hasura-cli solves them. It automatically downloads the CLI and exposes the command hasura. Downloaded CLI would be isolated, making it only dedicated to the "project" that installed it. Of course, you can install it as global package as well.

Installation

You can just simply install hasura-cli through npm or yarn. Note that this package follows version of the Original Hasura CLI. If you want to check its releases, go here.

Currently there are 3 npm tags (npm tags are different from versions), latest, beta and alpha. latest tag refers to Hasura's latest stable version(e.g. npm version), while beta and alpha, respectively beta version(e.g. npm beta version) and alpha version(e.g. npm alpha version).

Of course, you can install it globally,

npm install --global @eumentis/hasura-cli[@tag|@version]

or in a project.

# latest version from latest tag (Same as @eumentis/hasura-cli@latest)
npm install --save-dev @eumentis/hasura-cli

# specific version
npm install --save-dev @eumentis/[email protected]

# latest version from beta tag
npm install --save-dev @eumentis/hasura-cli@beta

# latest version from alpha tag
npm install --save-dev @eumentis/hasura-cli@alpha

Then you will be able to run hasura command.

For example,

# print hasura version
npx hasura version

Or configure npm scripts on package.json in the way you want. (tip. provide env vars like $HASURA_GRAPHQL_ENDPOINT or $HASURA_GRAPHQL_ADMIN_SECRET)

{
  "scripts": {
    "hasura": "hasura --project hasura --skip-update-check",
    "hasura:console": "npm run hasura console",
    "hasura:apply": "npm run hasura migrate apply"
  }
}

Support

Generally, it works on 64 bits architecture of any Linux, macOS, and Windows with node@>=8.

Development (Contribution)

Quick PR for new version

It's simple. Just update the version in package.json, then make a Pull Request. That's it!

{
  "name": "hasura-cli",
  "version": "1.3.0", // Patch this to "1.3.1-beta.1", for example.
  "license": "MIT"
  // ...
}

Note

Please read NOTE.md, before getting started.

Environment variables

Environment variables are intended to be only used on development environment.

First, create .env file, and configure it as you want.

cp .env.example .env

You can simply populate the variables by executing yarn dev or yarn dev:no-respawn. Otherwise, you have to manually feed them (e.g. dotenv -- <your command>). That's because this project doesn't use dotenv, but dotenv-cli. So, the application does not read .env by itself.

HASURA_CLI_INSTALL (boolean)

Whether src/index.ts would install the cli. You can set it false to prevent unwanted downloads.

HASURA_CLI_DEST_DIR (string)

A directory where Hasura CLI should be installed.

HASURA_CLI_DEST_FILENAME (string)

A file name of Hasura CLI.

Getting started

Install dependencies. Lifecycle script postinstall is only for clients who want to install the binary. So, ignore it with --ignore-scripts option. It should also be used on CI.

yarn install --ignore-scripts

On development, you can run

yarn dev
# or
yarn dev:no-respawn
# or
yarn dev:build

yarn dev watches source code and restarts a process when file changes. It does not write compiled js to the file system. ts-node-dev does watching, compiling and restarting.

yarn dev:no-respawn does the same thing except it does not restart.

yarn dev:build logically does the identical job at the high viewpoint. But it compiles (tsc -w) ts, writes js on file system, and run (nodemon) js. concurrently runs tsc and nodemon simualtaneously.

To manually test compiled js, you can run

yarn build # compiles ts to js
yarn start # runs dist/index.js

Other scripts

yarn test # runs all tests (against "*.test.ts")
yarn test:coverage # runs all tests and measures coverage
yarn lint # lint
yarn format # format(fix)

How does this work?

Here is a brief file system tree.

hasura-cli
├── dist // to be generated by build process (e.g. `yarn build`), and ignored by git
├── hasura
├── package.json
└── src
    ├── asset.ts
    ├── index.ts
    └── install.ts

package.json exposes the command hasura as a symlink to the flie hasura. Only the directory dist and file hasura are packed as a package.

{
  "bin": {
    "hasura": "./hasura"
  },
  "files": ["dist", "hasura"]
}

However, when publishing (npm publish on development environment) the package, the file hasura is just a dummy 'text' file, not a binary flie. The file will be replaced to a binary only when a client installs the package on Linux or macOS. On Windows, unlike Linux or macOS, the file hasura is to be removed, and a new file hasura.exe will be created. postinstall lifecycle hook executes dist/index.js, which would install the platform-specfic binary.

The binaries are hosted on GitHub as release assets. src/asset.ts exposes functions of "getting GitHub asset url" and "downloading the asset from the url". src/install.ts exposes a function of "composing them and handling how installation should be processed". src/index.ts uses the function to actually install the asset with some additional control.

License

MIT License. Copyright © 2019, GIL B. Chan <[email protected]>