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

drcts

v0.1.7

Published

Directus Data Model CLI (drcts) to migrate schemas from one instance to an other.

Downloads

10

Readme

Directus Data Model CLI

Directus Data Model CLI (drcts) to migrate schemas from one instance to another without the need for a server component.

GitHub go.mod Go version GitHub Release GitHub Release Date GitHub branch check runs

It is a Go implementation of the Directus Migration, allowing you to:

  • migrate schemas from one instance to another
  • save schemas to files
  • restore schemas from files
  • save schema differences

It is planned to be extended with additional features in the future:

  • selective migration
  • creation of custom collection presets
  • data migration

For complete backup and restore functionality, see Postgres Migration.

Installation

If you have Go installed, you can install the CLI by running:

go install github.com/Piitschy/drcts@latest

Alternatively, you can use npm to install the CLI:

npm i -g drcts

Usage

Authenticate

You can authenticate with the Directus API by providing the URL with a token or by login with an email and password. The token is the primary way to authenticate with the Directus API, so if set, the email and password will be ignored.

  • --bu or --base-url - URL of the base Directus instance.
  • --bt or --base-token - Token of the base Directus instance.
  • --be or --base-email - Email of the base Directus instance.
  • --bp or --base-password - Password of the base Directus instance.

Same for the target instance:

  • --tu or --target-url - URL of the target Directus instance.
  • --tt or --target-token - Token of the target Directus instance.
  • --te or --target-email - Email of the target Directus instance.
  • --tp or --target-password - Password of the target Directus instance.

In the following examples, we will use the --bu and --bt flags to authenticate with the Directus API. You can also use the --be and --bp flags to authenticate with the Directus API by providing an email and password.

You can get the token from the Directus instance by going to the account settings and creating a new token. I recommend creating a new role and account with only the necessary permissions for the migration.

IMPORTANT: Only collections that are readable by the directus user can be migrated. On the target system, the user must have the appropriate permissions to create collections!

Migrate

drcts --bu <base-url> --bt <base-token> --tu <target-url> --tt <target-token> migrate

Or just run drcts migrate and follow the instructions.

Don't forget to set -y flag in scripts to skip the confirmation prompt.

Export

To export the schema of a Directus instance to a file, run:

drcts --bu <base-url> --bt <base-token> save -o <output-file>

Formats supported: json, yaml, csv, xml. But only json is appliable.

Apply

To apply a schema from a file to a Directus instance, run:

drcts --tu <target-url> --tt <target-token> apply -i <input-file>

It's only possible to apply a schema in json format.

Diff

To compare the schema of two Directus instances, run:

drcts --bu <base-url> --bt <base-token> --tu <target-url> --tt <target-token> save-diff -o <diff-output-file>

or

drcts  --tu <target-url> --tt <target-token> save-diff -i <base-schema-file> -o <diff-output-file>

Or just run drcts save-diff and follow the instructions.

Formats supported: json, yaml, csv, xml. But only json is appliable.

Apply Diff

To apply a schema diff from a file to a Directus instance, run:

drcts --tu <target-url> --tt <target-token> apply-diff -i <diff-file>

Or just run drcts apply-diff and follow the instructions.

It's only possible to apply a schema diff in json format.

Environment Variables

You can also use environment variables to set the Directus instance URL and token:

  • DRCTS_BASE_URL

  • DRCTS_BASE_TOKEN

  • DRCTS_TARGET_URL

  • DRCTS_TARGET_TOKEN

  • DRCTS_SCHEMA_FILE (for save and apply)

  • DRCTS_DIFF_FILE (for save-diff and apply-diff)

Licensing

For version 1.0.0+ I will change the license from GPL-3.0 to MIT to facilitate the use in commercial products. Until then, the current GPL-3.0 license applies.