Comparing version 0.2.2 to 0.2.3
@@ -1,7 +0,7 @@ | ||
async function tool ({ path, args = [], returnEarly }) { | ||
async function tool ({ path, args = [] }) { | ||
const { currentLoc } = this.bajo.helper | ||
const { runToolMethod } = this.bajoCli.helper | ||
await runToolMethod({ path, args, dir: `${currentLoc(import.meta).dir}/tool`, returnEarly }) | ||
await runToolMethod({ path, args, dir: `${currentLoc(import.meta).dir}/tool` }) | ||
} | ||
export default tool |
@@ -1,2 +0,2 @@ | ||
async function buildBooks ({ path, args, returnEarly }) { | ||
async function buildBooks ({ path, args }) { | ||
const { importPkg, print, importModule, getConfig } = this.bajo.helper | ||
@@ -3,0 +3,0 @@ const { buildBooks } = this.bajoBook.helper |
@@ -1,6 +0,7 @@ | ||
async function createBook ({ path, args, returnEarly }) { | ||
const { importPkg, print, getConfig } = this.bajo.helper | ||
async function createBook ({ path, args }) { | ||
const { importPkg, print, getConfig, spinner } = this.bajo.helper | ||
const { isEmpty, keys, map, kebabCase, without } = await importPkg('lodash-es') | ||
const [fs, select, input] = await importPkg('fs-extra', 'bajo-cli:@inquirer/select', | ||
'bajo-cli:@inquirer/input') | ||
const config = getConfig() | ||
let [plugin, bookName, author] = args | ||
@@ -14,10 +15,4 @@ const plugins = without(keys(this), 'dump') | ||
} | ||
if (isEmpty(plugin)) { | ||
print.fail('You must select a plugin first', { exit: !returnEarly }) | ||
if (returnEarly) return | ||
} | ||
if (!this[plugin]) { | ||
print.fail('Invalid plugin \'%s\'', plugin, { exit: !returnEarly }) | ||
if (returnEarly) return | ||
} | ||
if (isEmpty(plugin)) return print.fail('You must select a plugin first', { exit: config.tool }) | ||
if (!this[plugin]) return print.fail('Invalid plugin \'%s\'', plugin, { exit: config.tool }) | ||
bookName = await input({ | ||
@@ -27,17 +22,11 @@ message: print.__('Please enter a book name:'), | ||
}) | ||
if (isEmpty(bookName)) { | ||
print.fail('You must enter a book name first', { exit: !returnEarly }) | ||
if (returnEarly) return | ||
} | ||
if (isEmpty(bookName)) return print.fail('You must enter a book name first', { exit: config.tool }) | ||
const cfg = getConfig(plugin, { full: true }) | ||
const cfgBook = getConfig('bajoBook', { full: true }) | ||
const dir = `${cfg.dir.pkg}/bajoBook/book/${kebabCase(bookName)}` | ||
if (fs.existsSync(dir)) { | ||
print.fail('Book \'%s\' already exist', dir, { exit: !returnEarly }) | ||
if (returnEarly) return | ||
} | ||
if (fs.existsSync(dir)) return print.fail('Book \'%s\' already exist', dir, { exit: config.tool }) | ||
author = await input({ | ||
message: print.__('Please enter author info:') | ||
}) | ||
const spinner = print.bora('Creating a book...').start() | ||
const spin = spinner().start('Creating a book...') | ||
const file = 'open-book-icon-symbol-yellow-background-education-bookstore-concept-3d-rendering.jpg' | ||
@@ -54,5 +43,5 @@ await fs.ensureDir(dir) | ||
}, { spaces: 2 }) | ||
spinner.succeed('Done!') | ||
spin.succeed('Done!') | ||
} | ||
export default createBook |
@@ -22,3 +22,3 @@ import getBookPathAndPlugin from '../lib/get-book-path-and-plugin.js' | ||
async function createHelperSkels ({ path, args, returnEarly }) { | ||
async function createHelperSkels ({ path, args }) { | ||
const { importPkg, print, getConfig } = this.bajo.helper | ||
@@ -28,2 +28,3 @@ const { isEmpty, keys, kebabCase } = await importPkg('lodash-es') | ||
const { plugin, bookPath } = await getBookPathAndPlugin.call(this, args) | ||
const config = getConfig() | ||
let [helperPath] = args | ||
@@ -34,11 +35,4 @@ helperPath = await input({ | ||
}) | ||
if (isEmpty(helperPath)) { | ||
print.fail('You must enter a root directory for helper pages first', { exit: !returnEarly }) | ||
if (returnEarly) return | ||
} | ||
const config = getConfig() | ||
if (keys(this[plugin].helper).length === 0) { | ||
print.fail('Plugin doesn\'t have any helper', { exit: !returnEarly }) | ||
if (returnEarly) return | ||
} | ||
if (isEmpty(helperPath)) return print.fail('You must enter a root directory for helper pages first', { exit: config.tool }) | ||
if (keys(this[plugin].helper).length === 0) return print.fail('Plugin doesn\'t have any helper', { exit: config.tool }) | ||
const dir = `${bookPath}/pages/${helperPath}` | ||
@@ -45,0 +39,0 @@ if (fs.existsSync(dir)) print.warn('Directory \'%s\' already exist', dir) |
{ | ||
"name": "bajo-book", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Book App for Bajo Framework", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
165229
732