Add bin CLI tool
This commit is contained in:
parent
142684f134
commit
9380736640
3 changed files with 1663 additions and 0 deletions
51
lbry-format.js
Normal file
51
lbry-format.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env node
|
||||
const {
|
||||
packDirectory,
|
||||
unpackDirectory,
|
||||
} = require('lbry-format');
|
||||
const path = require('path');
|
||||
|
||||
require('yargs')
|
||||
.scriptName('lbry-pack')
|
||||
.usage('$0 <cmd> [args]')
|
||||
.command('pack [directory] [file]', 'Pack a directory', (yargs) => {
|
||||
yargs.positional('directory', {
|
||||
default: './src',
|
||||
describe: 'The source directory to pack'
|
||||
}).positional('file', {
|
||||
describe: 'Output file',
|
||||
default: './package.lbry',
|
||||
})
|
||||
}, function (argv) {
|
||||
console.log(`Packing ${argv.directory} to ${argv.file}`);
|
||||
|
||||
const resolvedDirectory = path.resolve(argv.directory);
|
||||
const resolvedfile = path.resolve(argv.file);
|
||||
|
||||
packDirectory(resolvedDirectory, {
|
||||
fileName: resolvedfile,
|
||||
});
|
||||
})
|
||||
.command('unpack [directory] [file]', 'Unpack a file', (yargs) => {
|
||||
yargs.positional('destination', {
|
||||
type: 'string',
|
||||
default: './src',
|
||||
describe: 'The folder destination to unpack to'
|
||||
}).positional('file', {
|
||||
describe: 'Input filename',
|
||||
default: 'package.lbry',
|
||||
})
|
||||
}, function (argv) {
|
||||
console.log(`Packing ${argv.directory} to ${argv.file}`);
|
||||
|
||||
|
||||
const resolvedDirectory = path.resolve(argv.directory);
|
||||
const resolvedfile = path.resolve(argv.file);
|
||||
|
||||
unpackDirectory(resolvedDirectory, {
|
||||
fileName: resolvedfile,
|
||||
});
|
||||
})
|
||||
.help()
|
||||
.demandCommand()
|
||||
.argv
|
1604
package-lock.json
generated
1604
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -10,6 +10,14 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tar-stream": "^1.6.2",
|
||||
"yargs": "^13.2.2",
|
||||
"zstd-codec": "^0.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.2.3",
|
||||
"filereader-stream": "^2.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"lbry-format": "./lbry-format.js"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue