Revert "Use ora for build console message"
This reverts commit e0260fcbda.
This commit is contained in:
parent
d0b1101c0d
commit
2245b9f97a
5 changed files with 14 additions and 63 deletions
|
|
@ -1,7 +1,3 @@
|
||||||
## 0.2.2 - 2018-05-21
|
|
||||||
|
|
||||||
* Use ora for build console message
|
|
||||||
|
|
||||||
## 0.2.1 - 2018-05-17
|
## 0.2.1 - 2018-05-17
|
||||||
|
|
||||||
* Log netlifySiteUrl when viewing CMS on localhost
|
* Log netlifySiteUrl when viewing CMS on localhost
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ const _mergeWith = require('lodash/mergeWith')
|
||||||
const _isArray = require('lodash/isArray')
|
const _isArray = require('lodash/isArray')
|
||||||
const globCb = require('glob')
|
const globCb = require('glob')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
const ora = require('ora')
|
|
||||||
|
|
||||||
const glob = util.promisify(globCb)
|
const glob = util.promisify(globCb)
|
||||||
const readFile = util.promisify(fs.readFile)
|
const readFile = util.promisify(fs.readFile)
|
||||||
|
|
@ -17,8 +16,6 @@ const options = {
|
||||||
outputFile: './src/data.json'
|
outputFile: './src/data.json'
|
||||||
}
|
}
|
||||||
|
|
||||||
let spinner
|
|
||||||
|
|
||||||
const getCollectionType = filePath => {
|
const getCollectionType = filePath => {
|
||||||
const pathParsed = path.parse(filePath)
|
const pathParsed = path.parse(filePath)
|
||||||
const objectKey = pathParsed.dir
|
const objectKey = pathParsed.dir
|
||||||
|
|
@ -51,7 +48,6 @@ const parseYaml = data => {
|
||||||
|
|
||||||
const getFileContents = filePath => {
|
const getFileContents = filePath => {
|
||||||
return readFile(filePath, 'utf8').then(data => {
|
return readFile(filePath, 'utf8').then(data => {
|
||||||
spinner.start(`Processing ${filePath}`)
|
|
||||||
if (getDocumentExt(filePath) === '.md') {
|
if (getDocumentExt(filePath) === '.md') {
|
||||||
data = parseMarkdown(data)
|
data = parseMarkdown(data)
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +59,7 @@ const getFileContents = filePath => {
|
||||||
documentData.body = documentData.body || documentData.content
|
documentData.body = documentData.body || documentData.content
|
||||||
let obj = {}
|
let obj = {}
|
||||||
_set(obj, getCollectionType(filePath), [documentData])
|
_set(obj, getCollectionType(filePath), [documentData])
|
||||||
spinner.succeed(`Processed ${filePath}`)
|
console.log(`✨ Processed ${filePath}`)
|
||||||
return obj
|
return obj
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -74,8 +70,7 @@ const combineJSON = async () => {
|
||||||
// mergeCustomiser concats arrays items
|
// mergeCustomiser concats arrays items
|
||||||
const mergeCustomiser = (objValue, srcValue) =>
|
const mergeCustomiser = (objValue, srcValue) =>
|
||||||
_isArray(objValue) ? objValue.concat(srcValue) : objValue
|
_isArray(objValue) ? objValue.concat(srcValue) : objValue
|
||||||
|
console.log(`✨ Reading JSON files in ${options.contentDir}`)
|
||||||
spinner = ora(`Reading JSON files in ${options.contentDir}`).start()
|
|
||||||
const paths = await glob(`${options.contentDir}/**/**.+(json|md|yaml|yml)`)
|
const paths = await glob(`${options.contentDir}/**/**.+(json|md|yaml|yml)`)
|
||||||
const results = await readFiles(paths)
|
const results = await readFiles(paths)
|
||||||
const data = _mergeWith({}, ...results, mergeCustomiser)
|
const data = _mergeWith({}, ...results, mergeCustomiser)
|
||||||
|
|
@ -85,7 +80,7 @@ const combineJSON = async () => {
|
||||||
const writeJSON = async () => {
|
const writeJSON = async () => {
|
||||||
const json = await combineJSON()
|
const json = await combineJSON()
|
||||||
fs.writeFileSync(options.outputFile, json)
|
fs.writeFileSync(options.outputFile, json)
|
||||||
spinner.succeed(`Data saved to ${options.outputFile}`)
|
console.log(`✅ Data saved to ${options.outputFile}`)
|
||||||
process.exit()
|
process.exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ const path = require('path')
|
||||||
const globCb = require('glob')
|
const globCb = require('glob')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
const sharp = require('sharp')
|
const sharp = require('sharp')
|
||||||
const ora = require('ora')
|
|
||||||
|
|
||||||
const glob = util.promisify(globCb)
|
const glob = util.promisify(globCb)
|
||||||
const readFile = util.promisify(fs.readFile)
|
const readFile = util.promisify(fs.readFile)
|
||||||
|
|
@ -18,28 +17,23 @@ const options = {
|
||||||
imageFormats: ['jpg', 'jpeg', 'png', 'gif', 'webp']
|
imageFormats: ['jpg', 'jpeg', 'png', 'gif', 'webp']
|
||||||
}
|
}
|
||||||
|
|
||||||
let spinner
|
const saveImage = ({ buffer, size, outputFile }) => {
|
||||||
|
|
||||||
const saveImage = ({ buffer, size, outputFile, spinner }) => {
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
sharp(buffer)
|
sharp(buffer)
|
||||||
.resize(size)
|
.resize(size)
|
||||||
.withoutEnlargement()
|
.withoutEnlargement()
|
||||||
.toFile(outputFile, err => {
|
.toFile(outputFile, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
spinner.fail(err)
|
|
||||||
return reject(err)
|
return reject(err)
|
||||||
} else {
|
} else {
|
||||||
spinner.succeed(`Saved ${outputFile}`)
|
return resolve(console.log(`✅ Saved ${outputFile}`))
|
||||||
return resolve(`Saved ${outputFile}`)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveImages = ({ buffer, filename }) => {
|
const saveImages = ({ buffer, filename }) => {
|
||||||
spinner.text = `Processing ${filename}`
|
console.log(`🎞 Processing ${filename}`)
|
||||||
|
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
options.sizes.map(async size => {
|
options.sizes.map(async size => {
|
||||||
const extname = path.extname(filename)
|
const extname = path.extname(filename)
|
||||||
|
|
@ -49,11 +43,8 @@ const saveImages = ({ buffer, filename }) => {
|
||||||
)}.${size}${extname}`
|
)}.${size}${extname}`
|
||||||
const outputFile = path.resolve(options.outputDir, newFilename)
|
const outputFile = path.resolve(options.outputDir, newFilename)
|
||||||
const fileExists = await doesFileExist({ filename: outputFile })
|
const fileExists = await doesFileExist({ filename: outputFile })
|
||||||
if (fileExists) {
|
if (fileExists) return console.log(`↩️ ${outputFile} exists, skipping`)
|
||||||
spinner.info(`${outputFile} exists, skipping`)
|
return saveImage({ buffer, size, outputFile })
|
||||||
return `${outputFile} exists, skipping`
|
|
||||||
}
|
|
||||||
return saveImage({ buffer, size, outputFile, spinner })
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +67,7 @@ const doesFileExist = async ({ filename }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const resizeImages = async () => {
|
const resizeImages = async () => {
|
||||||
spinner = ora(`Reading image files in ${options.inputDir}`).start()
|
console.log(`✨ Reading image files in ${options.inputDir}`)
|
||||||
try {
|
try {
|
||||||
const fileGlob = `${options.inputDir}/**/**.+(${options.imageFormats.join(
|
const fileGlob = `${options.inputDir}/**/**.+(${options.imageFormats.join(
|
||||||
'|'
|
'|'
|
||||||
|
|
@ -88,13 +79,10 @@ const resizeImages = async () => {
|
||||||
const filesToResize = files.filter(filename => !filename.match(ignore))
|
const filesToResize = files.filter(filename => !filename.match(ignore))
|
||||||
const imageFiles = await readFiles(filesToResize)
|
const imageFiles = await readFiles(filesToResize)
|
||||||
Promise.all(imageFiles.map(saveImages))
|
Promise.all(imageFiles.map(saveImages))
|
||||||
.then(() => {
|
.then(() => process.exit())
|
||||||
spinner.succeed(`Finished reading image files in ${options.inputDir}`)
|
.catch(console.error)
|
||||||
process.exit()
|
|
||||||
})
|
|
||||||
.catch(spinner.fail)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
spinner.fail(e)
|
console.log(e)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
"heml": "^1.1.3",
|
"heml": "^1.1.3",
|
||||||
"js-yaml": "^3.10.0",
|
"js-yaml": "^3.10.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"ora": "^2.1.0",
|
|
||||||
"postcss": "^6.0.14",
|
"postcss": "^6.0.14",
|
||||||
"postcss-cli": "^5.0.0",
|
"postcss-cli": "^5.0.0",
|
||||||
"postcss-cssnext": "^3.0.2",
|
"postcss-cssnext": "^3.0.2",
|
||||||
|
|
|
||||||
31
yarn.lock
31
yarn.lock
|
|
@ -1656,7 +1656,7 @@ chalk@1.1.3, chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3:
|
||||||
strip-ansi "^3.0.0"
|
strip-ansi "^3.0.0"
|
||||||
supports-color "^2.0.0"
|
supports-color "^2.0.0"
|
||||||
|
|
||||||
chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.1, chalk@^2.4.1:
|
chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1:
|
||||||
version "2.4.1"
|
version "2.4.1"
|
||||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
|
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
@ -1821,10 +1821,6 @@ cli-cursor@^2.0.0, cli-cursor@^2.1.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
restore-cursor "^2.0.0"
|
restore-cursor "^2.0.0"
|
||||||
|
|
||||||
cli-spinners@^1.1.0:
|
|
||||||
version "1.3.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-1.3.1.tgz#002c1990912d0d59580c93bd36c056de99e4259a"
|
|
||||||
|
|
||||||
cli-width@^2.0.0:
|
cli-width@^2.0.0:
|
||||||
version "2.2.0"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
|
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
|
||||||
|
|
@ -2448,12 +2444,6 @@ default-require-extensions@^1.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
strip-bom "^2.0.0"
|
strip-bom "^2.0.0"
|
||||||
|
|
||||||
defaults@^1.0.3:
|
|
||||||
version "1.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
|
|
||||||
dependencies:
|
|
||||||
clone "^1.0.2"
|
|
||||||
|
|
||||||
define-properties@^1.1.2:
|
define-properties@^1.1.2:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
|
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
|
||||||
|
|
@ -5473,7 +5463,7 @@ log-symbols@^1.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
chalk "^1.0.0"
|
chalk "^1.0.0"
|
||||||
|
|
||||||
log-symbols@^2.0.0, log-symbols@^2.2.0:
|
log-symbols@^2.0.0:
|
||||||
version "2.2.0"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a"
|
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
@ -6179,17 +6169,6 @@ optionator@^0.8.1, optionator@^0.8.2:
|
||||||
type-check "~0.3.2"
|
type-check "~0.3.2"
|
||||||
wordwrap "~1.0.0"
|
wordwrap "~1.0.0"
|
||||||
|
|
||||||
ora@^2.1.0:
|
|
||||||
version "2.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/ora/-/ora-2.1.0.tgz#6caf2830eb924941861ec53a173799e008b51e5b"
|
|
||||||
dependencies:
|
|
||||||
chalk "^2.3.1"
|
|
||||||
cli-cursor "^2.1.0"
|
|
||||||
cli-spinners "^1.1.0"
|
|
||||||
log-symbols "^2.2.0"
|
|
||||||
strip-ansi "^4.0.0"
|
|
||||||
wcwidth "^1.0.1"
|
|
||||||
|
|
||||||
original@>=0.0.5:
|
original@>=0.0.5:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/original/-/original-1.0.1.tgz#b0a53ff42ba997a8c9cd1fb5daaeb42b9d693190"
|
resolved "https://registry.yarnpkg.com/original/-/original-1.0.1.tgz#b0a53ff42ba997a8c9cd1fb5daaeb42b9d693190"
|
||||||
|
|
@ -9273,12 +9252,6 @@ wbuf@^1.1.0, wbuf@^1.7.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
minimalistic-assert "^1.0.0"
|
minimalistic-assert "^1.0.0"
|
||||||
|
|
||||||
wcwidth@^1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"
|
|
||||||
dependencies:
|
|
||||||
defaults "^1.0.3"
|
|
||||||
|
|
||||||
web-resource-inliner@^4.2.0:
|
web-resource-inliner@^4.2.0:
|
||||||
version "4.2.1"
|
version "4.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/web-resource-inliner/-/web-resource-inliner-4.2.1.tgz#a3ec33d85794675cb526cfb93d2115741869f8be"
|
resolved "https://registry.yarnpkg.com/web-resource-inliner/-/web-resource-inliner-4.2.1.tgz#a3ec33d85794675cb526cfb93d2115741869f8be"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue