@blockforfun/plugin-git
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -6,2 +6,18 @@ # Change Log | ||
# [4.2.0](https://github.com/blockforfun/cli/compare/@blockforfun/plugin-git@4.1.0...@blockforfun/plugin-git@4.2.0) (2018-12-09) | ||
### Bug Fixes | ||
* Don't forget to stringify before out ([5c9334a](https://github.com/blockforfun/cli/commit/5c9334a)) | ||
### Features | ||
* Add output support to delete ([07816bd](https://github.com/blockforfun/cli/commit/07816bd)) | ||
# [4.1.0](https://github.com/blockforfun/cli/compare/@blockforfun/plugin-git@4.0.0...@blockforfun/plugin-git@4.1.0) (2018-12-09) | ||
@@ -8,0 +24,0 @@ |
@@ -1,1 +0,1 @@ | ||
{"version":"4.1.0","commands":{"delete:json":{"id":"delete:json","description":"deletes entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["rm:json","del:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true}]},"delete:text":{"id":"delete:text","description":"deletes entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["rm","del","rm:text","del:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true}]},"list:json":{"id":"list:json","description":"lists entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["ls:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"output","description":"output file path"}]},"list:text":{"id":"list:text","description":"lists entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["ls","ls:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"output","description":"output file path"}]},"read:json":{"id":"read:json","description":"reads entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["get:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"read:text":{"id":"read:text","description":"reads entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["get","get:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"write:json":{"id":"write:json","description":"writes entries in json format to a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["put:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"input","description":"input file path","required":true}]},"write:text":{"id":"write:text","description":"writes entries in text format to a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["put","put:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"input","description":"input file path","required":true}]}}} | ||
{"version":"4.2.0","commands":{"delete:json":{"id":"delete:json","description":"deletes entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["rm:json","del:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"delete:text":{"id":"delete:text","description":"deletes entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["rm","del","rm:text","del:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"list:json":{"id":"list:json","description":"lists entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["ls:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"output","description":"output file path"}]},"list:text":{"id":"list:text","description":"lists entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["ls","ls:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"output","description":"output file path"}]},"read:json":{"id":"read:json","description":"reads entries in json format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["get:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"read:text":{"id":"read:text","description":"reads entries in text format from a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["get","get:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"output","description":"output file path"}]},"write:json":{"id":"write:json","description":"writes entries in json format to a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["put:json"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"input","description":"input file path","required":true}]},"write:text":{"id":"write:text","description":"writes entries in text format to a BlockFor.fun git registry","pluginName":"@blockforfun/plugin-git","pluginType":"core","aliases":["put","put:text"],"flags":{"ref":{"name":"ref","type":"option","char":"r","description":"git ref","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git fetch refspec","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch URL"}},"args":[{"name":"source","description":"git repository URL or path","required":true},{"name":"path","description":"git file path","required":true},{"name":"input","description":"input file path","required":true}]}}} |
{ | ||
"name": "@blockforfun/plugin-git", | ||
"description": "BlockFor.fun CLI git plugin", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"author": "Mikael Karon <mikael@karon.se>", | ||
@@ -74,3 +74,3 @@ "bugs": "https://github.com/blockforfun/cli/issues", | ||
}, | ||
"gitHead": "bf89fcdb305989018602bcf6cf910753f77dc83b" | ||
"gitHead": "b8b9fe5c518cd157f39d77d72c34e2e68a7c24de" | ||
} |
@@ -25,3 +25,3 @@ @blockforfun/plugin-git | ||
$ oclif-example (-v|--version|version) | ||
@blockforfun/plugin-git/4.1.0 win32-x64 node-v10.10.0 | ||
@blockforfun/plugin-git/4.2.0 win32-x64 node-v10.10.0 | ||
$ oclif-example --help [COMMAND] | ||
@@ -37,4 +37,4 @@ USAGE | ||
<!-- commands --> | ||
* [`oclif-example delete:json SOURCE PATH`](#oclif-example-deletejson-source-path) | ||
* [`oclif-example delete:text SOURCE PATH`](#oclif-example-deletetext-source-path) | ||
* [`oclif-example delete:json SOURCE PATH [OUTPUT]`](#oclif-example-deletejson-source-path-output) | ||
* [`oclif-example delete:text SOURCE PATH [OUTPUT]`](#oclif-example-deletetext-source-path-output) | ||
* [`oclif-example list:json SOURCE [OUTPUT]`](#oclif-example-listjson-source-output) | ||
@@ -47,3 +47,3 @@ * [`oclif-example list:text SOURCE [OUTPUT]`](#oclif-example-listtext-source-output) | ||
## `oclif-example delete:json SOURCE PATH` | ||
## `oclif-example delete:json SOURCE PATH [OUTPUT]` | ||
@@ -54,3 +54,3 @@ deletes entries in json format from a BlockFor.fun git registry | ||
USAGE | ||
$ oclif-example delete:json SOURCE PATH | ||
$ oclif-example delete:json SOURCE PATH [OUTPUT] | ||
@@ -60,2 +60,3 @@ ARGUMENTS | ||
PATH git file path | ||
OUTPUT output file path | ||
@@ -72,5 +73,5 @@ OPTIONS | ||
_See code: [src\commands\delete\json.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\delete\json.js)_ | ||
_See code: [src\commands\delete\json.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\delete\json.js)_ | ||
## `oclif-example delete:text SOURCE PATH` | ||
## `oclif-example delete:text SOURCE PATH [OUTPUT]` | ||
@@ -81,3 +82,3 @@ deletes entries in text format from a BlockFor.fun git registry | ||
USAGE | ||
$ oclif-example delete:text SOURCE PATH | ||
$ oclif-example delete:text SOURCE PATH [OUTPUT] | ||
@@ -87,2 +88,3 @@ ARGUMENTS | ||
PATH git file path | ||
OUTPUT output file path | ||
@@ -101,3 +103,3 @@ OPTIONS | ||
_See code: [src\commands\delete\text.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\delete\text.js)_ | ||
_See code: [src\commands\delete\text.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\delete\text.js)_ | ||
@@ -125,3 +127,3 @@ ## `oclif-example list:json SOURCE [OUTPUT]` | ||
_See code: [src\commands\list\json.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\list\json.js)_ | ||
_See code: [src\commands\list\json.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\list\json.js)_ | ||
@@ -150,3 +152,3 @@ ## `oclif-example list:text SOURCE [OUTPUT]` | ||
_See code: [src\commands\list\text.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\list\text.js)_ | ||
_See code: [src\commands\list\text.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\list\text.js)_ | ||
@@ -175,3 +177,3 @@ ## `oclif-example read:json SOURCE PATH [OUTPUT]` | ||
_See code: [src\commands\read\json.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\read\json.js)_ | ||
_See code: [src\commands\read\json.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\read\json.js)_ | ||
@@ -201,3 +203,3 @@ ## `oclif-example read:text SOURCE PATH [OUTPUT]` | ||
_See code: [src\commands\read\text.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\read\text.js)_ | ||
_See code: [src\commands\read\text.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\read\text.js)_ | ||
@@ -226,3 +228,3 @@ ## `oclif-example write:json SOURCE PATH INPUT` | ||
_See code: [src\commands\write\json.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\write\json.js)_ | ||
_See code: [src\commands\write\json.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\write\json.js)_ | ||
@@ -252,3 +254,3 @@ ## `oclif-example write:text SOURCE PATH INPUT` | ||
_See code: [src\commands\write\text.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\write\text.js)_ | ||
_See code: [src\commands\write\text.js](https://github.com/blockforfun/cli/blob/v4.2.0/src\commands\write\text.js)_ | ||
<!-- commandsstop --> |
@@ -6,5 +6,12 @@ const DeleteTextCommand = require('./text') | ||
async delete(repo, source, path, options) { | ||
const {ref} = options | ||
await this.mount(repo, source, options) | ||
this.log(await repo.saveEntry(ref, parse(path, null, options), options)) | ||
const {ref, output} = options | ||
try { | ||
const out = output ? message => output.write(`${message}\n`) : this.log | ||
await this.mount(repo, source, options) | ||
out(await repo.saveEntry(ref, parse(path, null, options), options)) | ||
} finally { | ||
if (output) { | ||
output.end() | ||
} | ||
} | ||
return 1 | ||
@@ -11,0 +18,0 @@ } |
@@ -0,1 +1,2 @@ | ||
const {createWriteStream} = require('fs') | ||
const GitCommand = require('../../git-command') | ||
@@ -7,6 +8,13 @@ const {MemRepo, FsRepo} = require('../../repo') | ||
async delete(repo, source, path, options) { | ||
const {ref} = options | ||
await this.mount(repo, source, options) | ||
const file = await repo.saveEntry(ref, parse(path, null, options), options) | ||
this.log(`${file.hash} ${file.path.join('/')}`) | ||
const {ref, output} = options | ||
try { | ||
const out = output ? message => output.write(`${message}\n`) : this.log | ||
await this.mount(repo, source, options) | ||
const hash = await repo.saveEntry(ref, parse(path, null, options), options) | ||
out(`${hash} ${path}`) | ||
} finally { | ||
if (output) { | ||
output.end() | ||
} | ||
} | ||
return 1 | ||
@@ -17,5 +25,5 @@ } | ||
const {args, flags} = this.parse(DeleteTextCommand) | ||
const {source, path} = args | ||
const {source, output, path} = args | ||
try { | ||
const count = await this.delete(source.protocol ? new MemRepo() : new FsRepo(source.path), source, path, flags) | ||
const count = await this.delete(source.protocol ? new MemRepo() : new FsRepo(source.path), source, path, {output, ...flags}) | ||
this.log(`Deleted ${count} ${count === 1 ? 'entry' : 'entries'}`) | ||
@@ -36,2 +44,7 @@ } catch (error) { | ||
}, | ||
{ | ||
name: 'output', | ||
description: 'output file path', | ||
parse: input => createWriteStream(input), | ||
}, | ||
] | ||
@@ -38,0 +51,0 @@ DeleteTextCommand.flags = GitCommand.flags |
@@ -9,3 +9,3 @@ const ReadTextCommand = require('./text') | ||
await this.mount(repo, source, options) | ||
out(await repo.loadEntry(await this.tree(repo, options), path, options)) | ||
out(JSON.stringify(await repo.loadEntry(await this.tree(repo, options), path, options))) | ||
} finally { | ||
@@ -12,0 +12,0 @@ if (output) { |
35049
462
242
5