@blockforfun/plugin-git
Advanced tools
Comparing version 1.1.3 to 2.0.0
@@ -6,2 +6,24 @@ # Change Log | ||
# [2.0.0](https://github.com/blockforfun/cli/compare/@blockforfun/plugin-git@1.1.3...@blockforfun/plugin-git@2.0.0) (2018-11-27) | ||
### Bug Fixes | ||
* Update ARGS docs for list:text ([f3d3de1](https://github.com/blockforfun/cli/commit/f3d3de1)) | ||
### Features | ||
* Implement read command ([f368823](https://github.com/blockforfun/cli/commit/f368823)) | ||
* Slim down listEntries result ([bfd2b5c](https://github.com/blockforfun/cli/commit/bfd2b5c)) | ||
### BREAKING CHANGES | ||
* This changes `list:json` output | ||
## [1.1.3](https://github.com/blockforfun/cli/compare/@blockforfun/plugin-git@1.1.2...@blockforfun/plugin-git@1.1.3) (2018-11-27) | ||
@@ -8,0 +30,0 @@ |
@@ -1,1 +0,1 @@ | ||
{"version":"1.1.3","commands":{"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 to read from","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git refspec to fetch","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch repository URL"}},"args":[{"name":"source","description":"git source repository URL or path","required":true},{"name":"target","description":"path to target json file"}]},"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 to read from","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git refspec to fetch","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch repository URL"}},"args":[{"name":"source","description":"git source repository URL or path","required":true},{"name":"target","description":"path to target json file"}]}}} | ||
{"version":"2.0.0","commands":{"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 to read from","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git refspec to fetch","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch repository URL"}},"args":[{"name":"source","description":"git source repository URL or path","required":true},{"name":"target","description":"path to target text file"}]},"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 to read from","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git refspec to fetch","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch repository URL"}},"args":[{"name":"source","description":"git source repository URL or path","required":true},{"name":"target","description":"path to target text file"}]},"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 to read from","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git refspec to fetch","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch repository URL"}},"args":[{"name":"source","description":"git source repository URL or path","required":true},{"name":"path","description":"path to git file","required":true},{"name":"target","description":"path to target text file"}]},"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 to read from","default":"refs/heads/master"},"spec":{"name":"spec","type":"option","char":"s","description":"git refspec to fetch","default":"refs/heads/*:refs/heads/*"},"fetch":{"name":"fetch","type":"option","char":"f","description":"git fetch repository URL"}},"args":[{"name":"source","description":"git source repository URL or path","required":true},{"name":"path","description":"path to git file","required":true},{"name":"target","description":"path to target text file"}]}}} |
{ | ||
"name": "@blockforfun/plugin-git", | ||
"description": "BlockFor.fun CLI git plugin", | ||
"version": "1.1.3", | ||
"version": "2.0.0", | ||
"author": "Mikael Karon <mikael@karon.se>", | ||
@@ -15,2 +15,3 @@ "bugs": "https://github.com/blockforfun/cli/issues", | ||
"@es-git/object-mixin": "^0.9.0", | ||
"@es-git/path-to-object-mixin": "^0.9.0", | ||
"@es-git/walkers-mixin": "^0.9.0", | ||
@@ -49,2 +50,5 @@ "@es-git/zlib-mixin": "^0.9.0", | ||
"description": "lists entries from a BlockFor.fun git registry" | ||
}, | ||
"read": { | ||
"description": "reads entries from a BlockFor.fun git registry" | ||
} | ||
@@ -64,3 +68,3 @@ }, | ||
}, | ||
"gitHead": "8cb88ccf1fd60fc74a08ee7273879df80f6bd368" | ||
"gitHead": "6868e35a8ba418b8ff50e0a959265fbfd80751ea" | ||
} |
121
README.md
@@ -7,3 +7,3 @@ @blockforfun/plugin-git | ||
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io) | ||
[![GitHub](https://img.shields.io/badge/github-%40blockforfun%2Fcli-lightgrey.svg?logo=github)](https://github.com/blockforfun/cli/tree/master/plugins/plugin-git) | ||
[![GitHub](https://img.shields.io/github/stars/blockforfun/cli.svg?logo=github)](https://github.com/blockforfun/cli/tree/master/plugins/plugin-git) | ||
[![Version](https://img.shields.io/npm/v/@blockforfun/plugin-git.svg?logo=npm)](https://npmjs.org/package/@blockforfun/plugin-git) | ||
@@ -14,2 +14,8 @@ [![Downloads/week](https://img.shields.io/npm/dw/@blockforfun/plugin-git.svg?logo=npm)](https://npmjs.org/package/@blockforfun/plugin-git) | ||
<!-- toc --> | ||
* [Usage ](#usage) | ||
* [Commands ](#commands) | ||
<!-- tocstop --> | ||
* [Usage ](#usage) | ||
* [Commands ](#commands) | ||
<!-- tocstop --> | ||
* [Usage](#usage) | ||
@@ -25,2 +31,14 @@ * [Commands](#commands) | ||
$ oclif-example (-v|--version|version) | ||
@blockforfun/plugin-git/2.0.0 win32-x64 node-v10.10.0 | ||
$ oclif-example --help [COMMAND] | ||
USAGE | ||
$ oclif-example COMMAND | ||
... | ||
``` | ||
<!-- usagestop --> | ||
```sh-session | ||
$ npm install -g @blockforfun/plugin-git | ||
$ oclif-example COMMAND | ||
running command... | ||
$ oclif-example (-v|--version|version) | ||
@blockforfun/plugin-git/1.1.3 win32-x64 node-v10.10.0 | ||
@@ -37,2 +55,4 @@ $ oclif-example --help [COMMAND] | ||
* [`oclif-example list:text SOURCE [TARGET]`](#oclif-example-listtext-source-target) | ||
* [`oclif-example read:json SOURCE PATH [TARGET]`](#oclif-example-readjson-source-path-target) | ||
* [`oclif-example read:text SOURCE PATH [TARGET]`](#oclif-example-readtext-source-path-target) | ||
@@ -49,2 +69,101 @@ ## `oclif-example list:json SOURCE [TARGET]` | ||
SOURCE git source repository URL or path | ||
TARGET path to target text file | ||
OPTIONS | ||
-f, --fetch=fetch git fetch repository URL | ||
-r, --ref=ref [default: refs/heads/master] git ref to read from | ||
-s, --spec=spec [default: refs/heads/*:refs/heads/*] git refspec to fetch | ||
ALIASES | ||
$ oclif-example ls:json | ||
``` | ||
_See code: [src\commands\list\json.js](https://github.com/blockforfun/cli/blob/v2.0.0/src\commands\list\json.js)_ | ||
## `oclif-example list:text SOURCE [TARGET]` | ||
lists entries in text format from a BlockFor.fun git registry | ||
``` | ||
USAGE | ||
$ oclif-example list:text SOURCE [TARGET] | ||
ARGUMENTS | ||
SOURCE git source repository URL or path | ||
TARGET path to target text file | ||
OPTIONS | ||
-f, --fetch=fetch git fetch repository URL | ||
-r, --ref=ref [default: refs/heads/master] git ref to read from | ||
-s, --spec=spec [default: refs/heads/*:refs/heads/*] git refspec to fetch | ||
ALIASES | ||
$ oclif-example ls | ||
$ oclif-example ls:text | ||
``` | ||
_See code: [src\commands\list\text.js](https://github.com/blockforfun/cli/blob/v2.0.0/src\commands\list\text.js)_ | ||
## `oclif-example read:json SOURCE PATH [TARGET]` | ||
reads entries in json format from a BlockFor.fun git registry | ||
``` | ||
USAGE | ||
$ oclif-example read:json SOURCE PATH [TARGET] | ||
ARGUMENTS | ||
SOURCE git source repository URL or path | ||
PATH path to git file | ||
TARGET path to target text file | ||
OPTIONS | ||
-f, --fetch=fetch git fetch repository URL | ||
-r, --ref=ref [default: refs/heads/master] git ref to read from | ||
-s, --spec=spec [default: refs/heads/*:refs/heads/*] git refspec to fetch | ||
ALIASES | ||
$ oclif-example get:json | ||
``` | ||
_See code: [src\commands\read\json.js](https://github.com/blockforfun/cli/blob/v2.0.0/src\commands\read\json.js)_ | ||
## `oclif-example read:text SOURCE PATH [TARGET]` | ||
reads entries in text format from a BlockFor.fun git registry | ||
``` | ||
USAGE | ||
$ oclif-example read:text SOURCE PATH [TARGET] | ||
ARGUMENTS | ||
SOURCE git source repository URL or path | ||
PATH path to git file | ||
TARGET path to target text file | ||
OPTIONS | ||
-f, --fetch=fetch git fetch repository URL | ||
-r, --ref=ref [default: refs/heads/master] git ref to read from | ||
-s, --spec=spec [default: refs/heads/*:refs/heads/*] git refspec to fetch | ||
ALIASES | ||
$ oclif-example get | ||
$ oclif-example get:text | ||
``` | ||
_See code: [src\commands\read\text.js](https://github.com/blockforfun/cli/blob/v2.0.0/src\commands\read\text.js)_ | ||
<!-- commandsstop --> | ||
* [`oclif-example list:json SOURCE [TARGET]`](#oclif-example-listjson-source-target) | ||
* [`oclif-example list:text SOURCE [TARGET]`](#oclif-example-listtext-source-target) | ||
## `oclif-example list:json SOURCE [TARGET]` | ||
lists entries in json format from a BlockFor.fun git registry | ||
``` | ||
USAGE | ||
$ oclif-example list:json SOURCE [TARGET] | ||
ARGUMENTS | ||
SOURCE git source repository URL or path | ||
TARGET path to target json file | ||
@@ -51,0 +170,0 @@ |
@@ -1,10 +0,11 @@ | ||
const ListCommand = require('./text') | ||
const ListTextCommand = require('./text') | ||
class ListJsonCommand extends ListCommand { | ||
async list(repo, url, target, options) { | ||
const write = target ? message => target.write(`${message}\n`) : this.log | ||
class ListJsonCommand extends ListTextCommand { | ||
async list(repo, url, options) { | ||
const {target} = options | ||
const log = target ? message => target.write(`${message}\n`) : this.log | ||
let count = 0 | ||
try { | ||
for await (const entry of repo.listEntries(await this.tree(repo, url, options), options)) { | ||
write(JSON.stringify(entry)) | ||
log(JSON.stringify(entry)) | ||
count++ | ||
@@ -22,6 +23,6 @@ } | ||
ListJsonCommand.description = 'lists entries in json format from a BlockFor.fun git registry' | ||
ListJsonCommand.args = ListCommand.args | ||
ListJsonCommand.flags = ListCommand.flags | ||
ListJsonCommand.args = ListTextCommand.args | ||
ListJsonCommand.flags = ListTextCommand.flags | ||
ListJsonCommand.aliases = ['ls:json'] | ||
module.exports = ListJsonCommand |
const {createWriteStream} = require('fs') | ||
const GitCommand = require('../../lib/command') | ||
const GitCommand = require('../../lib/git-command') | ||
const {MemRepo, FsRepo} = require('../../lib/repo') | ||
class ListCommand extends GitCommand { | ||
async list(repo, url, target, options) { | ||
const write = target ? message => target.write(`${message}\n`) : this.log | ||
class ListTextCommand extends GitCommand { | ||
async list(repo, url, options) { | ||
const {target} = options | ||
const log = target ? message => target.write(`${message}\n`) : this.log | ||
let count = 0 | ||
try { | ||
for await (const entry of repo.listEntries(await this.tree(repo, url, options), options)) { | ||
write(`${entry.number.join('')}\t${entry.flags.join(',')}\t${entry.description}`) | ||
log(`${entry.number.join('')}\t${entry.flags.join(',')}\t${entry.description}`) | ||
count++ | ||
@@ -23,6 +24,6 @@ } | ||
async run() { | ||
const {args, flags} = this.parse(ListCommand) | ||
const {args, flags} = this.parse(ListTextCommand) | ||
const {source, target} = args | ||
try { | ||
const count = await this.list(source.protocol ? new MemRepo() : new FsRepo(source.path), source, target, flags) | ||
const count = await this.list(source.protocol ? new MemRepo() : new FsRepo(source.path), source, {target, ...flags}) | ||
this.log(`${target ? 'Wrote' : 'Listed'} ${count} ${count === 1 ? 'entry' : 'entries'}`) | ||
@@ -35,14 +36,14 @@ } catch (error) { | ||
ListCommand.description = 'lists entries in text format from a BlockFor.fun git registry' | ||
ListCommand.args = [ | ||
ListTextCommand.description = 'lists entries in text format from a BlockFor.fun git registry' | ||
ListTextCommand.args = [ | ||
...GitCommand.args, | ||
{ | ||
name: 'target', | ||
description: 'path to target json file', | ||
description: 'path to target text file', | ||
parse: input => createWriteStream(input), | ||
}, | ||
] | ||
ListCommand.flags = GitCommand.flags | ||
ListCommand.aliases = ['ls', 'ls:text'] | ||
ListTextCommand.flags = GitCommand.flags | ||
ListTextCommand.aliases = ['ls', 'ls:text'] | ||
module.exports = ListCommand | ||
module.exports = ListTextCommand |
const {isMatch} = require('micromatch') | ||
const {GLOB, EXT, DELIM} = require('../consts') | ||
const GLOB = '**/*.txt' | ||
const EXT = /\..+$/g | ||
const DELIM = /[,\s]+/ | ||
module.exports = repo => { | ||
@@ -12,12 +9,13 @@ return class EntriesRepo extends repo { | ||
for await (const file of super.listFiles(tree)) { | ||
const {path} = file | ||
if (isMatch(path.join('/'), glob)) { | ||
const {path: number} = file | ||
const path = number.join('/') | ||
if (isMatch(path, glob)) { | ||
const body = await super.loadText(file.hash) | ||
const [flags, description] = body.split('\n') | ||
path.push(path.pop().replace(ext, '')) | ||
number.push(number.pop().replace(ext, '')) | ||
yield { | ||
number: path, | ||
number, | ||
flags: flags.split(delim).sort(), | ||
description, | ||
file, | ||
path, | ||
} | ||
@@ -24,0 +22,0 @@ } |
@@ -10,2 +10,3 @@ const fetch = require('node-fetch') | ||
const {default: walkersMixin} = require('@es-git/walkers-mixin') | ||
const {default: pathToObjectMixin} = require('@es-git/path-to-object-mixin') | ||
const entriesMixin = require('./entries-mixin') | ||
@@ -19,2 +20,3 @@ | ||
.with(walkersMixin) | ||
.with(pathToObjectMixin) | ||
.with(entriesMixin) | ||
@@ -27,2 +29,3 @@ | ||
.with(walkersMixin) | ||
.with(pathToObjectMixin) | ||
.with(entriesMixin) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22557
12
244
201
15
3
3
+ Added@es-git/path-to-object-mixin@0.9.0(transitive)