@blockforfun/plugin-git
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -6,2 +6,18 @@ # Change Log | ||
# [4.1.0](https://github.com/blockforfun/cli/compare/@blockforfun/plugin-git@4.0.0...@blockforfun/plugin-git@4.1.0) (2018-12-09) | ||
### Bug Fixes | ||
* compile should check before serializing ([141c6b7](https://github.com/blockforfun/cli/commit/141c6b7)) | ||
### Features | ||
* Added delete command(s) ([48940b8](https://github.com/blockforfun/cli/commit/48940b8)) | ||
# [4.0.0](https://github.com/blockforfun/cli/compare/@blockforfun/plugin-git@3.0.0...@blockforfun/plugin-git@4.0.0) (2018-12-08) | ||
@@ -8,0 +24,0 @@ |
@@ -1,1 +0,1 @@ | ||
{"version":"4.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","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 json formatted entries 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 text formatted entries 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.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}]}}} |
{ | ||
"name": "@blockforfun/plugin-git", | ||
"description": "BlockFor.fun CLI git plugin", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"author": "Mikael Karon <mikael@karon.se>", | ||
@@ -74,3 +74,3 @@ "bugs": "https://github.com/blockforfun/cli/issues", | ||
}, | ||
"gitHead": "f498cc22a93330e86aa27652a69d2cb3af4b63e6" | ||
"gitHead": "bf89fcdb305989018602bcf6cf910753f77dc83b" | ||
} |
@@ -25,3 +25,3 @@ @blockforfun/plugin-git | ||
$ oclif-example (-v|--version|version) | ||
@blockforfun/plugin-git/4.0.0 win32-x64 node-v10.10.0 | ||
@blockforfun/plugin-git/4.1.0 win32-x64 node-v10.10.0 | ||
$ oclif-example --help [COMMAND] | ||
@@ -37,2 +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 list:json SOURCE [OUTPUT]`](#oclif-example-listjson-source-output) | ||
@@ -45,2 +47,52 @@ * [`oclif-example list:text SOURCE [OUTPUT]`](#oclif-example-listtext-source-output) | ||
## `oclif-example delete:json SOURCE PATH` | ||
deletes entries in json format from a BlockFor.fun git registry | ||
``` | ||
USAGE | ||
$ oclif-example delete:json SOURCE PATH | ||
ARGUMENTS | ||
SOURCE git repository URL or path | ||
PATH git file path | ||
OPTIONS | ||
-f, --fetch=fetch git fetch URL | ||
-r, --ref=ref [default: refs/heads/master] git ref | ||
-s, --spec=spec [default: refs/heads/*:refs/heads/*] git fetch refspec | ||
ALIASES | ||
$ oclif-example rm:json | ||
$ oclif-example del:json | ||
``` | ||
_See code: [src\commands\delete\json.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\delete\json.js)_ | ||
## `oclif-example delete:text SOURCE PATH` | ||
deletes entries in text format from a BlockFor.fun git registry | ||
``` | ||
USAGE | ||
$ oclif-example delete:text SOURCE PATH | ||
ARGUMENTS | ||
SOURCE git repository URL or path | ||
PATH git file path | ||
OPTIONS | ||
-f, --fetch=fetch git fetch URL | ||
-r, --ref=ref [default: refs/heads/master] git ref | ||
-s, --spec=spec [default: refs/heads/*:refs/heads/*] git fetch refspec | ||
ALIASES | ||
$ oclif-example rm | ||
$ oclif-example del | ||
$ oclif-example rm:text | ||
$ oclif-example del:text | ||
``` | ||
_See code: [src\commands\delete\text.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\delete\text.js)_ | ||
## `oclif-example list:json SOURCE [OUTPUT]` | ||
@@ -67,3 +119,3 @@ | ||
_See code: [src\commands\list\json.js](https://github.com/blockforfun/cli/blob/v4.0.0/src\commands\list\json.js)_ | ||
_See code: [src\commands\list\json.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\list\json.js)_ | ||
@@ -92,3 +144,3 @@ ## `oclif-example list:text SOURCE [OUTPUT]` | ||
_See code: [src\commands\list\text.js](https://github.com/blockforfun/cli/blob/v4.0.0/src\commands\list\text.js)_ | ||
_See code: [src\commands\list\text.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\list\text.js)_ | ||
@@ -117,3 +169,3 @@ ## `oclif-example read:json SOURCE PATH [OUTPUT]` | ||
_See code: [src\commands\read\json.js](https://github.com/blockforfun/cli/blob/v4.0.0/src\commands\read\json.js)_ | ||
_See code: [src\commands\read\json.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\read\json.js)_ | ||
@@ -143,7 +195,7 @@ ## `oclif-example read:text SOURCE PATH [OUTPUT]` | ||
_See code: [src\commands\read\text.js](https://github.com/blockforfun/cli/blob/v4.0.0/src\commands\read\text.js)_ | ||
_See code: [src\commands\read\text.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\read\text.js)_ | ||
## `oclif-example write:json SOURCE PATH INPUT` | ||
writes json formatted entries to a BlockFor.fun git registry | ||
writes entries in json format to a BlockFor.fun git registry | ||
@@ -168,7 +220,7 @@ ``` | ||
_See code: [src\commands\write\json.js](https://github.com/blockforfun/cli/blob/v4.0.0/src\commands\write\json.js)_ | ||
_See code: [src\commands\write\json.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\write\json.js)_ | ||
## `oclif-example write:text SOURCE PATH INPUT` | ||
writes text formatted entries to a BlockFor.fun git registry | ||
writes entries in text format to a BlockFor.fun git registry | ||
@@ -194,3 +246,3 @@ ``` | ||
_See code: [src\commands\write\text.js](https://github.com/blockforfun/cli/blob/v4.0.0/src\commands\write\text.js)_ | ||
_See code: [src\commands\write\text.js](https://github.com/blockforfun/cli/blob/v4.1.0/src\commands\write\text.js)_ | ||
<!-- commandsstop --> |
@@ -10,4 +10,3 @@ const toString = require('stream-to-string') | ||
await this.mount(repo, source, options) | ||
const commit = await repo.saveEntry(ref, {...JSON.parse(await toString(input)), ...parse(path, null, options)}) | ||
this.log(`Committed ${commit}`) | ||
this.log(await repo.saveEntry(ref, {...JSON.parse(await toString(input)), ...parse(path, null, options)})) | ||
} finally { | ||
@@ -20,3 +19,3 @@ input.destroy() | ||
WriteJsonCommand.description = 'writes json formatted entries to a BlockFor.fun git registry' | ||
WriteJsonCommand.description = 'writes entries in json format to a BlockFor.fun git registry' | ||
WriteJsonCommand.args = WriteTextCommand.args | ||
@@ -23,0 +22,0 @@ WriteJsonCommand.flags = WriteTextCommand.flags |
@@ -32,3 +32,3 @@ const {createReadStream} = require('fs') | ||
WriteTextCommand.description = 'writes text formatted entries to a BlockFor.fun git registry' | ||
WriteTextCommand.description = 'writes entries in text format to a BlockFor.fun git registry' | ||
WriteTextCommand.args = [ | ||
@@ -35,0 +35,0 @@ ...GitCommand.args, |
@@ -7,3 +7,3 @@ const {isMatch} = require('micromatch') | ||
const recursivelyMakeFile = (parent, path, mode, hash, body) => { | ||
const recursivelyMakeFile = (parent, path, hash, body) => { | ||
const [name, ...subPath] = path | ||
@@ -14,3 +14,3 @@ const {folders} = parent | ||
hash, | ||
mode, | ||
mode: Mode.file, | ||
body, | ||
@@ -22,3 +22,4 @@ get text() { | ||
} else { | ||
recursivelyMakeFile(folders[name] || (folders[name] = {files: {}, folders: {}}), subPath, mode, hash, body) | ||
const folder = folders[name] || (folders[name] = {files: {}, folders: {}}) | ||
return recursivelyMakeFile(folder, subPath, hash, body) | ||
} | ||
@@ -28,4 +29,23 @@ return parent | ||
const recursivelyDeleteFile = (parent, path) => { | ||
const [name, ...subPath] = path | ||
const {folders} = parent | ||
if (subPath.length === 0) { | ||
if (!parent.files[name]) { | ||
// no file | ||
return | ||
} | ||
delete parent.files[name] | ||
} else if (folders[name]) { | ||
// child folder | ||
return recursivelyDeleteFile(folders[name], subPath) | ||
} else { | ||
// no folder | ||
return | ||
} | ||
return parent | ||
} | ||
module.exports = repo => { | ||
return class EntriesRepo extends repo { | ||
return class EntryRepo extends repo { | ||
async * listEntries(tree, options = {glob: GLOB}) { | ||
@@ -54,9 +74,17 @@ const {glob = GLOB} = options | ||
const {path, body} = compile(entry) | ||
return super.commit(ref, recursivelyMakeFile(await super.checkout(ref), path.split('/'), Mode.file, await super.saveText(body), body), message, { | ||
const parts = path.split('/') | ||
const tree = await super.checkout(ref) | ||
const commiter = { | ||
date: new Date(), | ||
...PERSON, | ||
...person, | ||
}) | ||
} | ||
// !entry - delete | ||
if (!entry.body) { | ||
return super.commit(ref, recursivelyDeleteFile(tree, parts), message, commiter) | ||
} | ||
// !!entry - save | ||
return super.commit(ref, recursivelyMakeFile(tree, parts, await super.saveText(body), body), message, commiter) | ||
} | ||
} | ||
} |
@@ -17,2 +17,11 @@ const {DELIM, EXT} = require('./const') | ||
exports.compile = entry => ({path: `${entry.number.join('/')}.txt`, body: `${entry.flags.join(',')}\n${entry.description}`}) | ||
exports.compile = entry => { | ||
const file = {} | ||
if (entry.number) { | ||
file.path = `${entry.number.join('/')}.txt` | ||
} | ||
if (entry.flags) { | ||
file.body = `${entry.flags.join(',')}\n${entry.description || ''}` | ||
} | ||
return file | ||
} |
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
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
33937
17
442
240
4