@cardstack/git
Git data source plugin for @cardstack/hub.
Last updated 4 months ago by alexspeller .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @cardstack/git 
SYNC missed versions from official npm registry.

@cardstack/git

This is a Cardstack data source plugin for reading and writing to Git. Always have access to see how data has changed across time.

Features:

  • Just like using git for code, your data is versioned. A deleted or changed record can be retrieved!
  • Card data can be saved to either local or remote git repositories
  • Data can be stored in either the same repository as the project code, or a separate repository
  • Data for multiple projects can be saved to the same repository

Installing in a Cardstack project

To use a git as a data source, include @cardstack/git in the devDependencies of cardhost/package.json

yarn add --dev @cardstack/git
yarn install

See the "Troubleshooting" section of this README if you encounter any issues installing.

Configuration

Data plugins are configured in cardhost/data-sources. The only required configuration is to set either repo or remote.

Parameter Type Description
remote object Use a remote git repository, such as one hosted on Github. The object should contain url and privateKey with type string. Example: remote: { url: 'some-url', privateKey: process.env.GIT_PRIVATE_KEY}
repo string The path to a local git repository that already exists on disk, and has an initial commit
branchPrefix string optional - a prefix to prepend to the git branch when saving data. This is especially useful when you are storing data in the same repository as your project, or you have one repository that holds code for multiple projects. Example: if you set basePath: 'cs-', data will be stored at cs-master
basePath string optional - specify the directory within a repository where the data should be stored. Example: if you set basePath to my/base and you save an article Card, data will be stored at my/base/contents/articles/

You can set variables such as process.env.GIT_PRIVATE_KEY from the command line. For the example below, substitute your own path to the key:

GIT_PRIVATE_KEY="your private key here"

Example configuration

For example, the configuration below is set in cardhost/data-sources/default.js. This config creates a @cardstack/git data source named default and configures it as the Hub's default-data-source. Now, if a Card does not have its own data source defined, it will use git.

let sources = [
  {
    type: 'plugin-configs',
    id: '@cardstack/hub',
    attributes: {
      'plugin-config': {
        'application-card': { type: 'app-cards', id: 'cardhost' }
      }
    },
    relationships: {
      'default-data-source': {
        data: { type: 'data-sources', id: 'default' }
      }
    }
  },
  {
    type: 'data-sources',
    id: 'default',
    attributes: {
      'source-type': '@cardstack/git',
      params: {
        repo: '/path/to/some-git-repo'
      }
    }
  }
];

module.exports = sources;

Learn more

To learn more about how it can be used in your project, see the Cardstack Guides about git.

Troubleshooting

Windows installation - Building native nodegit dep

Windows users should install windows-build-tools, which are needed in order to build the nodegit dependency.

OSX installation - Building native nodegit dep

You need the latest Xcode and you need to manually tell it to get the latest CLI tools via

sudo xcode-select --install

Merely upgrading Xcode will still leave you broken and frustrated.

I cloned and built nodegit in its own repo, and then used yarn link. This seems to function as insurance against yarn deciding to rebuild it from scratch (which takes a long time).

Mac OS X Mojave users beware: nodegit does not appear to be compatible with the newer style OpenSSH keys that are generated by default from ssh-keygen. When generating ssh keys make sure to specify -m PEM in the ssh-keygen command in order to generate the older style PEM keypair. If you encounter the error:

Error: Failed to authenticate SSH session: Unable to extract public key from private key.

Then it is likely because you are generating the newer style OpenSSH keypair.

The older PEM style private keys (that are compatible with nodegit) are identifable by having a private key preamble that begins with:

-----BEGIN RSA PRIVATE KEY-----

More information is detailed here: https://github.com/nodegit/nodegit/issues/1606.

In order to use the private key as an env var in TravisCI you will need to replace the newlines in the private key. This issue describes this more in detail: https://github.com/travis-ci/travis-ci/issues/7715#issuecomment-362536708. You can use the following perl script to convert newlines into \n from the private key file and write to stdout:

$ perl -p -e 's/\n/\\n/' ~/.ssh/my-private-key_id_rsa

Then in Travis you can specify the env var in the following in manner within the Travis env var text field for the newlines to be converted correctly. Note that the " and ' characters are very critical:

"$(echo -e '-----BEGIN RSA PRIVATE KEY-----\nMKOQ1zYTmd\nzkRpTFq4xu\n-----END RSA PRIVATE KEY-----\n')"

Current Tags

  • 0.0.15-alpha.2                                ...           alpha (3 years ago)
  • 0.2.12-dotbc.0                                ...           dotbc (3 years ago)
  • 0.14.38-patch.0                                ...           latest (4 months ago)

298 Versions

  • 0.14.38-patch.0                                ...           4 months ago
  • 0.14.24-patch.1                                ...           5 months ago
  • 0.17.0                                ...           5 months ago
  • 0.16.32                                ...           5 months ago
  • 0.16.31                                ...           5 months ago
  • 0.16.30                                ...           5 months ago
  • 0.16.29                                ...           5 months ago
  • 0.16.28                                ...           5 months ago
  • 0.16.27                                ...           5 months ago
  • 0.16.26                                ...           6 months ago
  • 0.16.25                                ...           6 months ago
  • 0.16.24                                ...           6 months ago
  • 0.16.23                                ...           6 months ago
  • 0.16.22                                ...           7 months ago
  • 0.16.21                                ...           7 months ago
  • 0.16.20                                ...           7 months ago
  • 0.16.19                                ...           7 months ago
  • 0.16.18                                ...           7 months ago
  • 0.16.17                                ...           7 months ago
  • 0.16.16                                ...           7 months ago
  • 0.16.15                                ...           7 months ago
  • 0.16.14                                ...           7 months ago
  • 0.16.13                                ...           7 months ago
  • 0.16.12                                ...           7 months ago
  • 0.16.11                                ...           8 months ago
  • 0.16.10                                ...           8 months ago
  • 0.16.9                                ...           8 months ago
  • 0.16.8                                ...           8 months ago
  • 0.16.7                                ...           8 months ago
  • 0.16.6                                ...           8 months ago
  • 0.16.5                                ...           8 months ago
  • 0.16.4                                ...           8 months ago
  • 0.16.3                                ...           9 months ago
  • 0.16.2                                ...           9 months ago
  • 0.16.1                                ...           9 months ago
  • 0.16.0                                ...           9 months ago
  • 0.15.0                                ...           9 months ago
  • 0.14.50                                ...           9 months ago
  • 0.14.49                                ...           9 months ago
  • 0.14.48                                ...           9 months ago
  • 0.14.47                                ...           9 months ago
  • 0.14.46                                ...           9 months ago
  • 0.14.45                                ...           9 months ago
  • 0.14.43                                ...           9 months ago
  • 0.14.42                                ...           9 months ago
  • 0.14.41                                ...           9 months ago
  • 0.14.40                                ...           9 months ago
  • 0.14.39                                ...           9 months ago
  • 0.14.38                                ...           9 months ago
  • 0.14.37                                ...           9 months ago
  • 0.14.36                                ...           9 months ago
  • 0.14.35                                ...           9 months ago
  • 0.14.34                                ...           9 months ago
  • 0.14.33                                ...           9 months ago
  • 0.14.32                                ...           9 months ago
  • 0.14.31                                ...           10 months ago
  • 0.14.30                                ...           10 months ago
  • 0.14.29                                ...           10 months ago
  • 0.14.28                                ...           10 months ago
  • 0.14.27                                ...           10 months ago
  • 0.14.26                                ...           10 months ago
  • 0.14.25                                ...           10 months ago
  • 0.14.24                                ...           10 months ago
  • 0.14.24-alpha.0                                ...           a year ago
  • 0.14.23                                ...           a year ago
  • 0.14.22                                ...           a year ago
  • 0.14.21                                ...           a year ago
  • 0.14.20                                ...           a year ago
  • 0.14.18                                ...           a year ago
  • 0.14.17                                ...           a year ago
  • 0.14.16                                ...           a year ago
  • 0.14.12                                ...           a year ago
  • 0.14.10                                ...           a year ago
  • 0.14.8                                ...           a year ago
  • 0.14.6                                ...           a year ago
  • 0.14.5                                ...           a year ago
  • 0.14.4                                ...           a year ago
  • 0.14.0                                ...           a year ago
  • 0.13.71                                ...           a year ago
  • 0.13.70                                ...           a year ago
  • 0.13.69                                ...           a year ago
  • 0.13.68                                ...           a year ago
  • 0.13.67                                ...           a year ago
  • 0.13.66                                ...           a year ago
  • 0.13.65                                ...           a year ago
  • 0.13.63                                ...           a year ago
  • 0.13.62                                ...           a year ago
  • 0.13.61                                ...           a year ago
  • 0.13.60                                ...           a year ago
  • 0.13.59                                ...           a year ago
  • 0.13.58                                ...           a year ago
  • 0.13.57                                ...           a year ago
  • 0.13.54                                ...           a year ago
  • 0.13.53                                ...           a year ago
  • 0.13.52                                ...           a year ago
  • 0.13.51                                ...           a year ago
  • 0.13.50                                ...           a year ago
  • 0.13.48                                ...           a year ago
  • 0.13.45                                ...           a year ago
  • 0.13.39                                ...           a year ago
  • 0.13.37                                ...           a year ago
  • 0.13.36                                ...           a year ago
  • 0.13.35                                ...           a year ago
  • 0.13.34                                ...           a year ago
  • 0.13.33                                ...           a year ago
  • 0.13.32                                ...           a year ago
  • 0.13.31                                ...           a year ago
  • 0.13.30                                ...           a year ago
  • 0.13.29                                ...           2 years ago
  • 0.13.28                                ...           2 years ago
  • 0.13.27                                ...           2 years ago
  • 0.13.26                                ...           2 years ago
  • 0.13.25                                ...           2 years ago
  • 0.13.24                                ...           2 years ago
  • 0.13.23                                ...           2 years ago
  • 0.13.22                                ...           2 years ago
  • 0.13.21                                ...           2 years ago
  • 0.13.20                                ...           2 years ago
  • 0.13.19                                ...           2 years ago
  • 0.13.18                                ...           2 years ago
  • 0.13.16                                ...           2 years ago
  • 0.13.15                                ...           2 years ago
  • 0.13.14                                ...           2 years ago
  • 0.13.13                                ...           2 years ago
  • 0.13.11                                ...           2 years ago
  • 0.13.10                                ...           2 years ago
  • 0.13.6                                ...           2 years ago
  • 0.13.5                                ...           2 years ago
  • 0.13.4                                ...           2 years ago
  • 0.13.3                                ...           2 years ago
  • 0.13.2                                ...           2 years ago
  • 0.13.0                                ...           2 years ago
  • 0.12.21                                ...           2 years ago
  • 0.12.19                                ...           2 years ago
  • 0.12.18                                ...           2 years ago
  • 0.12.17                                ...           2 years ago
  • 0.12.15                                ...           2 years ago
  • 0.12.13                                ...           2 years ago
  • 0.12.11                                ...           2 years ago
  • 0.12.9                                ...           2 years ago
  • 0.12.7                                ...           2 years ago
  • 0.12.7-alpha.1                                ...           2 years ago
  • 0.12.7-alpha.0                                ...           2 years ago
  • 0.12.3-alpha.0                                ...           2 years ago
  • 0.12.6                                ...           2 years ago
  • 0.12.5                                ...           2 years ago
  • 0.12.3                                ...           2 years ago
  • 0.12.2                                ...           2 years ago
  • 0.12.1                                ...           2 years ago
  • 0.12.0                                ...           2 years ago
  • 0.11.10                                ...           2 years ago
  • 0.11.9                                ...           2 years ago
  • 0.11.8                                ...           2 years ago
  • 0.11.7                                ...           2 years ago
  • 0.11.6                                ...           2 years ago
  • 0.11.5                                ...           2 years ago
  • 0.11.4                                ...           2 years ago
  • 0.11.3                                ...           2 years ago
  • 0.11.3-alpha.0                                ...           2 years ago
  • 0.11.2                                ...           2 years ago
  • 0.11.1                                ...           2 years ago
  • 0.11.0                                ...           2 years ago
  • 0.10.25-alpha.2                                ...           2 years ago
  • 0.10.25                                ...           2 years ago
  • 0.10.24                                ...           2 years ago
  • 0.10.23                                ...           2 years ago
  • 0.10.22                                ...           2 years ago
  • 0.10.21                                ...           2 years ago
  • 0.10.20                                ...           2 years ago
  • 0.10.18                                ...           2 years ago
  • 0.10.17                                ...           2 years ago
  • 0.10.16                                ...           2 years ago
  • 0.10.15                                ...           2 years ago
  • 0.10.14                                ...           2 years ago
  • 0.10.13                                ...           2 years ago
  • 0.10.12                                ...           2 years ago
  • 0.10.11                                ...           2 years ago
  • 0.10.10                                ...           2 years ago
  • 0.10.9                                ...           2 years ago
  • 0.10.8                                ...           2 years ago
  • 0.10.7                                ...           2 years ago
  • 0.10.6                                ...           2 years ago
  • 0.10.5                                ...           2 years ago
  • 0.10.4                                ...           2 years ago
  • 0.10.3                                ...           2 years ago
  • 0.10.2                                ...           2 years ago
  • 0.10.1                                ...           2 years ago
  • 0.10.0                                ...           2 years ago
  • 0.9.16                                ...           2 years ago
  • 0.9.15                                ...           2 years ago
  • 0.9.14                                ...           2 years ago
  • 0.9.13                                ...           2 years ago
  • 0.9.11                                ...           2 years ago
  • 0.9.9                                ...           2 years ago
  • 0.9.8                                ...           2 years ago
  • 0.9.6                                ...           2 years ago
  • 0.9.5                                ...           2 years ago
  • 0.9.4                                ...           2 years ago
  • 0.9.2                                ...           2 years ago
  • 0.9.0                                ...           2 years ago
  • 0.8.3                                ...           2 years ago
  • 0.8.0                                ...           2 years ago
  • 0.7.12                                ...           2 years ago
  • 0.7.10                                ...           2 years ago
  • 0.7.1                                ...           2 years ago
  • 0.7.0                                ...           2 years ago
  • 0.6.19                                ...           2 years ago
  • 0.6.18                                ...           2 years ago
  • 0.6.16                                ...           2 years ago
  • 0.6.14                                ...           2 years ago
  • 0.6.13                                ...           2 years ago
  • 0.6.12                                ...           2 years ago
  • 0.6.11                                ...           2 years ago
  • 0.6.9                                ...           2 years ago
  • 0.6.8                                ...           2 years ago
  • 0.6.7                                ...           2 years ago
  • 0.6.6                                ...           2 years ago
  • 0.6.5                                ...           2 years ago
  • 0.6.3                                ...           2 years ago
  • 0.6.2                                ...           2 years ago
  • 0.6.0                                ...           2 years ago
  • 0.5.13                                ...           2 years ago
  • 0.5.11                                ...           2 years ago
  • 0.5.10                                ...           2 years ago
  • 0.5.9                                ...           2 years ago
  • 0.5.8                                ...           2 years ago
  • 0.5.7                                ...           2 years ago
  • 0.5.6                                ...           2 years ago
  • 0.5.5                                ...           2 years ago
  • 0.5.4                                ...           2 years ago
  • 0.5.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.13                                ...           2 years ago
  • 0.4.12                                ...           2 years ago
  • 0.4.6                                ...           3 years ago
  • 0.4.5                                ...           3 years ago
  • 0.4.4                                ...           3 years ago
  • 0.4.1                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.4                                ...           3 years ago
  • 0.3.3                                ...           3 years ago
  • 0.3.2                                ...           3 years ago
  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.12-dotbc.0                                ...           3 years ago
  • 0.2.12                                ...           3 years ago
  • 0.2.11-dotbc.2                                ...           3 years ago
  • 0.2.11-dotbc.1                                ...           3 years ago
  • 0.2.11-dotbc.0                                ...           3 years ago
  • 0.2.11                                ...           3 years ago
  • 0.2.11-alpha.0                                ...           3 years ago
  • 0.2.10-alpha.2                                ...           3 years ago
  • 0.2.10                                ...           3 years ago
  • 0.2.10-alpha.1                                ...           3 years ago
  • 0.2.10-alpha.0                                ...           3 years ago
  • 0.2.8                                ...           3 years ago
  • 0.2.7                                ...           3 years ago
  • 0.2.6                                ...           3 years ago
  • 0.2.5                                ...           3 years ago
  • 0.2.4-alpha.1                                ...           3 years ago
  • 0.2.4                                ...           3 years ago
  • 0.2.4-alpha.0                                ...           3 years ago
  • 0.2.3                                ...           3 years ago
  • 0.2.2                                ...           3 years ago
  • 0.2.2-alpha.2                                ...           3 years ago
  • 0.2.2-alpha.1                                ...           3 years ago
  • 0.2.2-alpha.0                                ...           3 years ago
  • 0.2.1                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.0.20-alpha.4                                ...           3 years ago
  • 0.1.3                                ...           3 years ago
  • 0.0.20-alpha.3                                ...           3 years ago
  • 0.0.20-alpha.2                                ...           3 years ago
  • 0.0.20-alpha.1                                ...           3 years ago
  • 0.0.20-alpha.0                                ...           3 years ago
  • 0.1.3-alpha.1                                ...           3 years ago
  • 0.1.3-alpha.0                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.17                                ...           3 years ago
  • 0.0.16                                ...           3 years ago
  • 0.0.15                                ...           3 years ago
  • 0.0.15-alpha.2                                ...           3 years ago
  • 0.0.15-alpha.1                                ...           3 years ago
  • 0.0.15-alpha.0                                ...           3 years ago
  • 0.0.14                                ...           3 years ago
  • 0.0.13                                ...           3 years ago
  • 0.0.12                                ...           3 years ago
  • 0.0.11                                ...           3 years ago
  • 0.0.10                                ...           3 years ago
  • 0.0.9                                ...           3 years ago
  • 0.0.8                                ...           3 years ago
  • 0.0.7                                ...           3 years ago
  • 0.0.6                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (13)
Dev Dependencies (4)

Copyright 2014 - 2016 © taobao.org |