Skip to content

Commit

Permalink
chore(deps): update dependency xo to v0.24.0 (#115)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency xo to v0.24.0

* make xo happy
  • Loading branch information
renovate[bot] authored and egoist committed May 2, 2019
1 parent 274379e commit e596812
Show file tree
Hide file tree
Showing 27 changed files with 357 additions and 207 deletions.
2 changes: 2 additions & 0 deletions other-packages/extract-sfc-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function stringifyNode(node) {
if (typeof node === 'string') {
return node
}

const content = node.content || []
return `<${node.tag}${stringifyAttrs(node.attrs || {})}>${content
.map(n => stringifyNode(n))
Expand All @@ -20,6 +21,7 @@ module.exports = input => {
blocks.push(stringifyNode(node))
return
}

return node
})
]).process(input, {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"lerna": "3.13.4",
"lint-staged": "8.1.5",
"prettier": "1.17.0",
"xo": "0.23.0"
"xo": "0.24.0"
},
"xo": {
"extends": [
Expand All @@ -35,7 +35,8 @@
"import/no-unassigned-import": "off",
"unicorn/filename-case": "off",
"no-await-in-loop": "off",
"unicorn/no-abusive-eslint-disable": "off"
"unicorn/no-abusive-eslint-disable": "off",
"camelcase": "off"
},
"ignore": [
"**/dist/**",
Expand Down
1 change: 1 addition & 0 deletions packages/create-site/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ promisify(ncp)(path.join(__dirname, 'template'), dir)
console.log(colors.cyan(`$ npm install`))
console.log(colors.cyan(`$ npm run dev`))
}

console.log(colors.dim(`For more details, please check out the README.md`))
})
.catch(console.error)
6 changes: 6 additions & 0 deletions packages/saber-highlighter-prism/loadLanguages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ function getPeerDependentsMap() {
if (language === 'meta') {
return false
}

if (components.languages[language].peerDependencies) {
let { peerDependencies } = components.languages[language]
if (!Array.isArray(peerDependencies)) {
peerDependencies = [peerDependencies]
}

peerDependencies.forEach(peerDependency => {
if (!peerDependentsMap[peerDependency]) {
peerDependentsMap[peerDependency] = []
}

peerDependentsMap[peerDependency].push(language)
})
}
Expand All @@ -29,6 +32,7 @@ function getPeerDependents(mainLanguage) {
if (!peerDependentsMap) {
peerDependentsMap = getPeerDependentsMap()
}

return peerDependentsMap[mainLanguage] || []
}

Expand All @@ -39,6 +43,7 @@ function loadLanguages(arr, withoutDependencies) {
return language !== 'meta'
})
}

if (arr && arr.length === 0) {
return
}
Expand Down Expand Up @@ -83,6 +88,7 @@ function loadLanguages(arr, withoutDependencies) {
delete Prism.languages[dependent]
return true
}

return false
})
if (dependents.length > 0) {
Expand Down
12 changes: 6 additions & 6 deletions packages/saber-plugin-generate-feed/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const path = require('path')
const url = require('url')
const { Feed } = require('feed')
const { getFeedPath } = require('./utils')
const { getFeedPath, resolveURL } = require('./utils')

const ID = 'generate-feed'

Expand All @@ -28,9 +27,9 @@ exports.apply = (api, options = {}) => {
const rss2FeedPath = getFeedPath(options.rss2Feed, 'rss2.xml')

const feedLinks = {
json: jsonFeedPath && url.resolve(siteConfig.url, jsonFeedPath),
atom: atomFeedPath && url.resolve(siteConfig.url, atomFeedPath),
rss2: rss2FeedPath && url.resolve(siteConfig.url, rss2FeedPath)
json: jsonFeedPath && resolveURL(siteConfig.url, jsonFeedPath),
atom: atomFeedPath && resolveURL(siteConfig.url, atomFeedPath),
rss2: rss2FeedPath && resolveURL(siteConfig.url, rss2FeedPath)
}

api.hooks.afterGenerate.tapPromise(ID, async () => {
Expand All @@ -42,7 +41,7 @@ exports.apply = (api, options = {}) => {
posts.push({
title: page.attributes.title,
id: page.attributes.permalink,
link: url.resolve(siteConfig.url, page.attributes.permalink),
link: resolveURL(siteConfig.url, page.attributes.permalink),
// Strip HTML tags in excerpt and use it as description (a.k.a. summary)
description: excerpt && excerpt.replace(/<(?:.|\n)*?>/gm, ''),
content: page.content,
Expand All @@ -51,6 +50,7 @@ exports.apply = (api, options = {}) => {
})
}
}

// Order by published
const items = posts
.sort((a, b) => {
Expand Down
11 changes: 11 additions & 0 deletions packages/saber-plugin-generate-feed/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// @ts-check
const { URL } = require('url')

/**
* Get feed path
* @param {string|boolean|undefined} feedPath
Expand All @@ -15,3 +17,12 @@ exports.getFeedPath = (feedPath, defaultPath) => {

return null
}

/**
* @param {string} base
* @param {string} pathname
* @returns {string}
*/
exports.resolveURL = (base, pathname) => {
return new URL(base, pathname).href
}
1 change: 1 addition & 0 deletions packages/saber-plugin-netlify-redirect/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports.apply = api => {
config.toPath
)} ${config.isPermanent ? '301' : '302'}\n`
}

return content
}

Expand Down
4 changes: 4 additions & 0 deletions packages/saber-plugin-query-posts/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ exports.apply = (api, options = {}) => {
if (page.attributes.draft) {
continue
}

if (page.attributes.injectAllPosts) {
injectPostsToPages.add(page)
continue
}

if (page.attributes.type === 'post') {
const pagePublicFields = api.pages.getPagePublicFields(page)
allPosts.add(pagePublicFields)
Expand Down Expand Up @@ -236,9 +238,11 @@ exports.apply = (api, options = {}) => {
if (pageIndex === 1) {
return permalink
}

if (pageIndex === 0) {
return
}

return urlJoin(permalink, `page/${pageIndex}`)
}
}
4 changes: 4 additions & 0 deletions packages/saber-plugin-query-posts/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function paginate(arr, options) {
for (let i = 0; i < totalPages; i++) {
result[i] = arr.slice(i * options.perPage, (i + 1) * options.perPage)
}

return result
}

Expand All @@ -18,6 +19,7 @@ function getIdFromMap(map, name) {
id = slugify(name.replace(/\//g, '-'))
map[name] = id
}

return id
}

Expand All @@ -27,6 +29,7 @@ function getNameFromMap(map, id) {
return name
}
}

return id
}

Expand All @@ -39,6 +42,7 @@ function renderPermalink(permalink, data) {
for (const key of Object.keys(data)) {
permalink = permalink.replace(`:${key}`, data[key])
}

return permalink
}

Expand Down
1 change: 0 additions & 1 deletion packages/saber-utils/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-unresolved
module.exports = require('./dist')

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/saber/lib/Pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ module.exports = class Pages extends Map {
if (!page.internal || !page.internal.id) {
throw new Error(`Page must have an internal id.`)
}

// Ensure this page is not saved
// So that it will be emitted to disk later in `emitPages` hook
page.internal.saved = false
Expand All @@ -123,6 +124,7 @@ module.exports = class Pages extends Map {
if (normalize !== false) {
page = this.normalizePage(page, file)
}

this.pageProps.set(page.internal.id, {})
this.set(page.internal.id, page)
}
Expand Down Expand Up @@ -156,6 +158,7 @@ module.exports = class Pages extends Map {
if (!page) {
return page
}

return Object.assign({}, page, { content: undefined, internal: undefined })
}

Expand Down
1 change: 1 addition & 0 deletions packages/saber/lib/Transformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = class Transformers {
for (const transformer of this.transformers.values()) {
extensions = [...extensions, ...(transformer.extensions || [])]
}

return extensions
}

Expand Down
6 changes: 6 additions & 0 deletions packages/saber/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ class Saber {
const msg = `${hook} ${colors.dim(`(${name})`)}`
log.verbose(msg)
}

return fn(...args)
}

return tapInfo
}
})
Expand Down Expand Up @@ -131,6 +133,7 @@ class Saber {
this.theme = distDir
}
}

log.info(`Using theme: ${colors.dim(this.config.theme)}`)
log.verbose(() => `Theme directory: ${colors.dim(this.theme)}`)
} else {
Expand Down Expand Up @@ -197,6 +200,7 @@ class Saber {
if (typeof p === 'string') {
p = { resolve: p }
}

p.resolve = resolveFrom(this.configDir, p.resolve)
return p
})
Expand All @@ -211,6 +215,7 @@ class Saber {
plugin.filterPlugins(plugins, options)
)
}

return plugin
}
)
Expand Down Expand Up @@ -255,6 +260,7 @@ class Saber {
await this.renderer.build()
await this.hooks.afterBuild.promise()
}

await this.renderer.generate()
await this.hooks.afterGenerate.promise()
}
Expand Down
3 changes: 1 addition & 2 deletions packages/saber/lib/markdown/escape-interpolations-plugin.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module.exports = md => {
const defaultCodeInline = md.renderer.rules.code_inline
// eslint-disable-next-line camelcase
md.renderer.rules.code_inline = (...args) => {
const [tokens, idx] = args
const token = tokens[idx]
token.attrSet('v-pre', '')
return defaultCodeInline(...args)
}

const defaultFence = md.renderer.rules.fence
// eslint-disable-next-line camelcase
md.renderer.rules.fence = (...args) => {
const [tokens, idx] = args
const token = tokens[idx]
Expand Down
5 changes: 2 additions & 3 deletions packages/saber/lib/markdown/excerpt-plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const hasExcerptMark = value => /<!--\s*more\s*-->/.test(value.trim())

module.exports = (md, { paragraphOnly = true } = {}) => {
// eslint-disable-next-line camelcase
md.renderer.rules.paragraph_close = (...args) => {
const [tokens, idx, options, env, self] = args

Expand All @@ -22,6 +21,7 @@ module.exports = (md, { paragraphOnly = true } = {}) => {
}
}
}

env.setAttribute(
'excerpt',
self.render(tokens.slice(startIndex, idx + 1), options, env)
Expand All @@ -32,9 +32,8 @@ module.exports = (md, { paragraphOnly = true } = {}) => {
return self.renderToken(tokens, idx, options)
}

// eslint-disable-next-line camelcase
const htmlRule = md.renderer.rules.html_block
// eslint-disable-next-line camelcase

md.renderer.rules.html_block = (...args) => {
const [tokens, idx, options, env, self] = args
const token = tokens[idx]
Expand Down
2 changes: 2 additions & 0 deletions packages/saber/lib/markdown/highlight-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module.exports = (md, { highlightedLineBackground } = {}) => {
if (start && end) {
return lineNumber >= start && lineNumber <= end
}

return lineNumber === start
})
if (inRange) {
Expand All @@ -75,6 +76,7 @@ module.exports = (md, { highlightedLineBackground } = {}) => {
: ''
return `<div class="code-line highlighted"${style}>${split}</div>`
}

return `<div class="code-line">${split}</div>`
})
.join('') +
Expand Down
2 changes: 1 addition & 1 deletion packages/saber/lib/markdown/hoist-tags-plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = md => {
const RE = /^<(style|script)(?=(\s|>|$))/i

// eslint-disable-next-line camelcase
md.renderer.rules.html_block = (tokens, idx, options, env) => {
const { content } = tokens[idx]
const hoistedTags = env.getInternal('hoistedTags') || []
Expand All @@ -10,6 +9,7 @@ module.exports = md => {
env.setInternal('hoistedTags', hoistedTags)
return ''
}

return content
}
}
3 changes: 1 addition & 2 deletions packages/saber/lib/markdown/link-plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const path = require('path')

module.exports = function(md) {
// eslint-disable-next-line camelcase
md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
const token = tokens[idx]

Expand Down Expand Up @@ -43,7 +42,6 @@ module.exports = function(md) {
return self.renderToken(tokens, idx, options)
}

// eslint-disable-next-line camelcase
md.renderer.rules.link_close = (tokens, idx, options, env, self) => {
const openToken = tokens[idx - 2]
const token = tokens[idx]
Expand All @@ -53,6 +51,7 @@ module.exports = function(md) {
token.tag = 'saber-link'
}
}

return prefix + self.renderToken(tokens, idx, options)
}
}
Loading

0 comments on commit e596812

Please sign in to comment.