A simple way to work with remote data.
Install clone.io.
$ npm install -g clone.io
Clone a resource using its url. The JSON will be pretty-printed, and the information needed to update it will be added if it doesn't already exist. If it's a hypermedia API, like GitHub, the url in the original request will be used.
$ cd ~/Desktop
$ clone.io https://github.com/resources/clone.io get
$ ls -A1p
clone.io.json
Note that the command appears after the resource. This makes it easy to perform a different command on the same resource.
The first argument can either be a URL or a file. The local file contains a link to the remote resource, so it can be used to perform actions involving both the local and remote resource.
Running the command with just the name of the file:
$ cd ~/Desktop
$ clone.io clone.io.json
Will print out the following YAML:
url: https://github.com/resources/clone.io
type: /services/github/repo
subresources:
- clone.io clone.io.json ./code get
- clone.io clone.io.json ./issues get
- clone.io clone.io.json ./wiki get
- clone.io clone.io.json get --all
actions:
- clone.io clone.io.json get # update clone.io.json
- clone.io clone.io.json diff # compare local and remote resource
- clone.io clone.io.json patch # patch remote resource with local updates
- clone.io clone.io.json show # pretty-print the data
To update the local resource from the remote resource, call get
:
$ clone.io clone.io.json get
TODO: provide a tool or recommend a practice to preserve the old data.
First, open index.json in an editor and change the description. If you like, you can use $EDITOR:
$ clone.io clone.io.json edit
Now you can view a diff, which uses jsonpointer:
$ clone.io clone.io.json diff
https://api.github.com/repos/resources/clone.io#/description
- "A way to work with remote data using your own tools on your own filesystem."
+ "a simple way to work with remote data"
Now that you know what is going to change, you can patch it on the server:
$ clone.io clone.io.json patch
Patching https://api.github.com/repos/resources/clone.io...
Enter GitHub username:
Enter GitHub password:
Successfully patched https://api.github.com/repos/resources/clone.io.
Not yet implemented. Starting with github project data.
MIT.