Comparing version 0.2.5 to 0.3.0
@@ -10,5 +10,4 @@ import path from 'path' | ||
async function setLevel (level = '') { | ||
const { importPkg } = this.bajo.helper | ||
const { padStart } = await importPkg('lodash-es') | ||
function setLevel (level = '') { | ||
const { padStart } = this.bajo.helper._ | ||
const [...levels] = (level + '').split('.') | ||
@@ -22,6 +21,6 @@ for (const i in levels) { | ||
async function getPages (book) { | ||
const { importPkg, titleize } = this.bajo.helper | ||
const { fastGlob, importPkg, fs, titleize } = this.bajo.helper | ||
const { doctypes, getTitleFromPath, rereadMetadata } = this.bajoBook.helper | ||
const { find, merge, concat, isEmpty } = await importPkg('lodash-es') | ||
const [fs, fastGlob, matter] = await importPkg('fs-extra', 'fast-glob', 'bajo-web-mpa:gray-matter') | ||
const { find, merge, concat, isEmpty } = this.bajo.helper._ | ||
const matter = await importPkg('bajoWebMpa:gray-matter') | ||
if (isEmpty(metadata.pages)) { | ||
@@ -60,3 +59,3 @@ metadata = await rereadMetadata({ resetPages: true, bookPath: book.dir }) | ||
}, extra) | ||
sitem.level = await setLevel.call(this, sitem.level) | ||
sitem.level = setLevel.call(this, sitem.level) | ||
sections.push(sitem) | ||
@@ -73,3 +72,3 @@ const parentId = path.dirname(sectionId) | ||
}, extra) | ||
item.level = await setLevel.call(this, item.level) | ||
item.level = setLevel.call(this, item.level) | ||
pages.push(item) | ||
@@ -89,3 +88,3 @@ } | ||
}, extra, extraMatter) | ||
item.level = await setLevel.call(this, item.level) | ||
item.level = setLevel.call(this, item.level) | ||
pages.push(item) | ||
@@ -111,4 +110,4 @@ } | ||
async function buildBooks (progress) { | ||
const { readConfig, eachPlugins, importPkg } = this.bajo.helper | ||
const { merge, omit } = await importPkg('lodash-es') | ||
const { readConfig, eachPlugins } = this.bajo.helper | ||
const { merge, omit } = this.bajo.helper._ | ||
await eachPlugins(async function ({ file, plugin, dir, alias }) { | ||
@@ -115,0 +114,0 @@ metadata = {} |
@@ -17,10 +17,9 @@ import path from 'path' | ||
async function rereadMetadata ({ bookPath, resetPages } = {}) { | ||
const { importPkg, readJson } = this.bajo.helper | ||
const { fastGlob, readJson, fs } = this.bajo.helper | ||
const { doctypes } = this.bajoBook.helper | ||
const { filter, get, set } = await importPkg('lodash-es') | ||
const [fg, fs] = await importPkg('fast-glob', 'fs-extra') | ||
const { filter, get, set } = this.bajo.helper._ | ||
const mfile = `${bookPath}/.metadata.json` | ||
const metadata = await readJson(mfile) | ||
metadata.pages = resetPages ? {} : (metadata.pages ?? {}) | ||
const files = await fg(`${bookPath}/pages/**/*.{${doctypes.map(t => t.slice(1)).join(',')}}`) | ||
const files = await fastGlob(`${bookPath}/pages/**/*.{${doctypes.map(t => t.slice(1)).join(',')}}`) | ||
for (const f of files) { | ||
@@ -27,0 +26,0 @@ let base = f.replace(`${bookPath}/pages`, '') |
async function beforeResourceMerge (lng, content) { | ||
const { eachPlugins, readConfig, importPkg } = this.bajo.helper | ||
const { merge } = await importPkg('lodash-es') | ||
const { eachPlugins, readConfig } = this.bajo.helper | ||
const { merge } = this.bajo.helper._ | ||
await eachPlugins(async function ({ file, plugin, dir }) { | ||
@@ -5,0 +5,0 @@ const item = await readConfig(file) |
async function getBookPathAndPlugin (args) { | ||
const { importPkg, print, getConfig } = this.bajo.helper | ||
const { isEmpty, keys, map, without } = await importPkg('lodash-es') | ||
const [fastGlob, select] = await importPkg('fast-glob', 'bajo-cli:@inquirer/select') | ||
const { fastGlob, importPkg, print, getConfig } = this.bajo.helper | ||
const { isEmpty, keys, map, without } = this.bajo.helper._ | ||
const select = await importPkg('bajoCli:@inquirer/select') | ||
let [plugin, bookId] = args | ||
@@ -6,0 +6,0 @@ const plugins = without(keys(this), 'dump') |
async function buildBooks ({ path, args }) { | ||
const { importPkg, print, importModule, getConfig } = this.bajo.helper | ||
const { buildBooks } = this.bajoBook.helper | ||
const prompts = await importPkg('bajo-cli:@inquirer/prompts') | ||
const prompts = await importPkg('bajoCli:@inquirer/prompts') | ||
const { confirm } = prompts | ||
@@ -6,0 +6,0 @@ const answer = await confirm({ |
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 { importPkg, print, getConfig, spinner, fs } = this.bajo.helper | ||
const { isEmpty, keys, map, kebabCase, without } = this.bajo.helper._ | ||
const [select, input] = await importPkg('bajoCli:@inquirer/select', 'bajoCli:@inquirer/input') | ||
const config = getConfig() | ||
@@ -7,0 +6,0 @@ let [plugin, bookName, author] = args |
import getBookPathAndPlugin from '../lib/get-book-path-and-plugin.js' | ||
async function generateContent (name, item) { | ||
const { importPkg } = this.bajo.helper | ||
const { isArray, isFunction, isPlainObject } = await importPkg('lodash-es') | ||
function generateContent (name, item) { | ||
const { isArray, isFunction, isPlainObject } = this.bajo.helper._ | ||
const results = ['---'] | ||
@@ -23,5 +22,5 @@ let type = '' | ||
async function createHelperSkels ({ path, args }) { | ||
const { importPkg, print, getConfig } = this.bajo.helper | ||
const { isEmpty, keys, kebabCase } = await importPkg('lodash-es') | ||
const [fs, input] = await importPkg('fs-extra', 'bajo-cli:@inquirer/input') | ||
const { fs, importPkg, print, getConfig } = this.bajo.helper | ||
const { isEmpty, keys, kebabCase } = this.bajo.helper._ | ||
const input = await importPkg('bajoCli:@inquirer/input') | ||
const { plugin, bookPath } = await getBookPathAndPlugin.call(this, args) | ||
@@ -45,3 +44,3 @@ const config = getConfig() | ||
} | ||
const content = await generateContent.call(this, name, this[plugin].helper[name]) | ||
const content = generateContent.call(this, name, this[plugin].helper[name]) | ||
await fs.outputFile(file, content, 'utf8') | ||
@@ -48,0 +47,0 @@ print.succeed('Writing to \'%s\'', `/${basename}`) |
import getBookPathAndPlugin from '../lib/get-book-path-and-plugin.js' | ||
async function rereadMetadata (_, args) { | ||
const { print, importPkg, getConfig } = this.bajo.helper | ||
const { get, isEmpty } = await importPkg('lodash-es') | ||
const { print, getConfig } = this.bajo.helper | ||
const { get, isEmpty } = this.bajo.helper._ | ||
const { rereadMetadata } = this.bajoBook.helper | ||
@@ -7,0 +7,0 @@ const { bookPath } = await getBookPathAndPlugin.call(this, args) |
@@ -7,4 +7,4 @@ import formatLevel from './format-level.js' | ||
const { recordFind } = this.bajoDb.helper | ||
const { merge, map, concat } = await importPkg('lodash-es') | ||
const { arrayToTree } = await importPkg('bajo-extra:performant-array-to-tree') | ||
const { merge, map, concat } = this.bajo.helper._ | ||
const { arrayToTree } = await importPkg('bajoExtra:performant-array-to-tree') | ||
const cfg = getConfig('bajoWebMpa') | ||
@@ -29,5 +29,4 @@ const ns = concat(['bajoBook', cfg.i18n.defaultNs]) | ||
async function list (ctx, req, reply) { | ||
const { importPkg } = this.bajo.helper | ||
const { recordFind } = this.bajoWeb.helper | ||
const { isEmpty, omit } = await importPkg('lodash-es') | ||
const { isEmpty, omit } = this.bajo.helper._ | ||
const [, plugin, name] = req.params['*'].split('/') | ||
@@ -34,0 +33,0 @@ const query = {} |
@@ -1,5 +0,5 @@ | ||
async function breadcrumb (path, { pages, sections, params, book } = {}) { | ||
const { importPkg, getConfig } = this.bajo.helper | ||
function breadcrumb (path, { pages, sections, params, book } = {}) { | ||
const { getConfig } = this.bajo.helper | ||
const { routePath } = this.bajoWeb.helper | ||
const { map, find, concat } = await importPkg('lodash-es') | ||
const { map, find, concat } = this.bajo.helper._ | ||
const [, alias, name, ...paths] = path.split('/') | ||
@@ -6,0 +6,0 @@ const prev = [] |
import formatLevel from '../format-level.js' | ||
async function getRef (page, { params, book } = {}) { | ||
const { importPkg, getConfig } = this.bajo.helper | ||
const { getConfig } = this.bajo.helper | ||
const { routePath } = this.bajoWeb.helper | ||
const { recordFind } = this.bajoDb.helper | ||
const { isEmpty, map, find, concat } = await importPkg('lodash-es') | ||
const { isEmpty, map, find, concat } = this.bajo.helper._ | ||
const cfg = getConfig('bajoWebMpa') | ||
@@ -9,0 +9,0 @@ const ns = concat(['bajoBook', cfg.i18n.defaultNs]) |
@@ -1,5 +0,5 @@ | ||
async function inSections (path, { pages, sections, params, pageId, book } = {}) { | ||
const { importPkg, getConfig } = this.bajo.helper | ||
function inSections (path, { pages, sections, params, pageId, book } = {}) { | ||
const { getConfig } = this.bajo.helper | ||
const { routePath } = this.bajoWeb.helper | ||
const { filter, map, concat } = await importPkg('lodash-es') | ||
const { filter, map, concat } = this.bajo.helper._ | ||
const cfg = getConfig('bajoWebMpa') | ||
@@ -6,0 +6,0 @@ const ns = concat(['bajoBook', cfg.i18n.defaultNs]) |
@@ -8,4 +8,3 @@ import path from 'path' | ||
async function download (file, reply) { | ||
const { importPkg } = this.bajo.helper | ||
const fs = await importPkg('fs-extra') | ||
const { fs } = this.bajo.helper | ||
const stream = fs.createReadStream(file) | ||
@@ -17,3 +16,3 @@ reply.header('Content-Type', 'application/octet-stream') | ||
async function page (ctx, req, reply) { | ||
const { importPkg, getConfig } = this.bajo.helper | ||
const { importPkg, getConfig, fs } = this.bajo.helper | ||
const { redirectTo, routePath, notFound } = this.bajoWeb.helper | ||
@@ -23,4 +22,4 @@ const { renderString, buildLocals, markdownParse } = this.bajoWebMpa.helper | ||
const { doctypes, getRealPageFile } = this.bajoBook.helper | ||
const { isEmpty, findIndex, merge, map } = await importPkg('lodash-es') | ||
const [fs, matter] = await importPkg('fs-extra', 'bajo-web-mpa:gray-matter') | ||
const { isEmpty, findIndex, merge, map } = this.bajo.helper._ | ||
const matter = await importPkg('bajoWebMpa:gray-matter') | ||
const paths = req.params['*'].split('/') | ||
@@ -66,4 +65,4 @@ paths.shift() | ||
} | ||
const bc = await breadcrumb.call(this, page.sectionId, { pages, sections, params, book }) | ||
const items = await inSections.call(this, page.sectionId, { pages, sections, params, pageId: page.id, book }) | ||
const bc = breadcrumb.call(this, page.sectionId, { pages, sections, params, book }) | ||
const items = inSections.call(this, page.sectionId, { pages, sections, params, pageId: page.id, book }) | ||
const ref = await getRef.call(this, page, { params, book }) | ||
@@ -70,0 +69,0 @@ return reply.view('bajoBook:/book/page', { book, page, content, breadcrumb: bc, pages: items, ref }) |
{ | ||
"name": "bajo-book", | ||
"version": "0.2.5", | ||
"version": "0.3.0", | ||
"description": "Book App for Bajo Framework", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
164647
727