diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bf74f4..17a5bd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,3 @@ -## 0.2.2 - 2018-05-21 - -* Use ora for build console message - ## 0.2.1 - 2018-05-17 * Log netlifySiteUrl when viewing CMS on localhost diff --git a/functions/parse-content.js b/functions/parse-content.js index 864668d..16290f6 100644 --- a/functions/parse-content.js +++ b/functions/parse-content.js @@ -5,7 +5,6 @@ const _mergeWith = require('lodash/mergeWith') const _isArray = require('lodash/isArray') const globCb = require('glob') const util = require('util') -const ora = require('ora') const glob = util.promisify(globCb) const readFile = util.promisify(fs.readFile) @@ -17,8 +16,6 @@ const options = { outputFile: './src/data.json' } -let spinner - const getCollectionType = filePath => { const pathParsed = path.parse(filePath) const objectKey = pathParsed.dir @@ -51,7 +48,6 @@ const parseYaml = data => { const getFileContents = filePath => { return readFile(filePath, 'utf8').then(data => { - spinner.start(`Processing ${filePath}`) if (getDocumentExt(filePath) === '.md') { data = parseMarkdown(data) } @@ -63,7 +59,7 @@ const getFileContents = filePath => { documentData.body = documentData.body || documentData.content let obj = {} _set(obj, getCollectionType(filePath), [documentData]) - spinner.succeed(`Processed ${filePath}`) + console.log(`✨ Processed ${filePath}`) return obj }) } @@ -74,8 +70,7 @@ const combineJSON = async () => { // mergeCustomiser concats arrays items const mergeCustomiser = (objValue, srcValue) => _isArray(objValue) ? objValue.concat(srcValue) : objValue - - spinner = ora(`Reading JSON files in ${options.contentDir}`).start() + console.log(`✨ Reading JSON files in ${options.contentDir}`) const paths = await glob(`${options.contentDir}/**/**.+(json|md|yaml|yml)`) const results = await readFiles(paths) const data = _mergeWith({}, ...results, mergeCustomiser) @@ -85,7 +80,7 @@ const combineJSON = async () => { const writeJSON = async () => { const json = await combineJSON() fs.writeFileSync(options.outputFile, json) - spinner.succeed(`Data saved to ${options.outputFile}`) + console.log(`✅ Data saved to ${options.outputFile}`) process.exit() } diff --git a/functions/resize-images.js b/functions/resize-images.js index 01b8732..dd22566 100644 --- a/functions/resize-images.js +++ b/functions/resize-images.js @@ -3,7 +3,6 @@ const path = require('path') const globCb = require('glob') const util = require('util') const sharp = require('sharp') -const ora = require('ora') const glob = util.promisify(globCb) const readFile = util.promisify(fs.readFile) @@ -18,28 +17,23 @@ const options = { imageFormats: ['jpg', 'jpeg', 'png', 'gif', 'webp'] } -let spinner - -const saveImage = ({ buffer, size, outputFile, spinner }) => { +const saveImage = ({ buffer, size, outputFile }) => { return new Promise((resolve, reject) => { sharp(buffer) .resize(size) .withoutEnlargement() .toFile(outputFile, err => { if (err) { - spinner.fail(err) return reject(err) } else { - spinner.succeed(`Saved ${outputFile}`) - return resolve(`Saved ${outputFile}`) + return resolve(console.log(`✅ Saved ${outputFile}`)) } }) }) } const saveImages = ({ buffer, filename }) => { - spinner.text = `Processing ${filename}` - + console.log(`🎞 Processing ${filename}`) return Promise.all( options.sizes.map(async size => { const extname = path.extname(filename) @@ -49,11 +43,8 @@ const saveImages = ({ buffer, filename }) => { )}.${size}${extname}` const outputFile = path.resolve(options.outputDir, newFilename) const fileExists = await doesFileExist({ filename: outputFile }) - if (fileExists) { - spinner.info(`${outputFile} exists, skipping`) - return `${outputFile} exists, skipping` - } - return saveImage({ buffer, size, outputFile, spinner }) + if (fileExists) return console.log(`â†Šī¸ ${outputFile} exists, skipping`) + return saveImage({ buffer, size, outputFile }) }) ) } @@ -76,7 +67,7 @@ const doesFileExist = async ({ filename }) => { } const resizeImages = async () => { - spinner = ora(`Reading image files in ${options.inputDir}`).start() + console.log(`✨ Reading image files in ${options.inputDir}`) try { const fileGlob = `${options.inputDir}/**/**.+(${options.imageFormats.join( '|' @@ -88,13 +79,10 @@ const resizeImages = async () => { const filesToResize = files.filter(filename => !filename.match(ignore)) const imageFiles = await readFiles(filesToResize) Promise.all(imageFiles.map(saveImages)) - .then(() => { - spinner.succeed(`Finished reading image files in ${options.inputDir}`) - process.exit() - }) - .catch(spinner.fail) + .then(() => process.exit()) + .catch(console.error) } catch (e) { - spinner.fail(e) + console.log(e) process.exit(1) } } diff --git a/package.json b/package.json index 52ba3b1..8861b1a 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "heml": "^1.1.3", "js-yaml": "^3.10.0", "npm-run-all": "^4.1.2", - "ora": "^2.1.0", "postcss": "^6.0.14", "postcss-cli": "^5.0.0", "postcss-cssnext": "^3.0.2", diff --git a/yarn.lock b/yarn.lock index ce4fde6..f6e6d67 100644 --- a/yarn.lock +++ b/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" 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" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" dependencies: @@ -1821,10 +1821,6 @@ cli-cursor@^2.0.0, cli-cursor@^2.1.0: dependencies: 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: version "2.2.0" 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: 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: version "1.1.2" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" @@ -5473,7 +5463,7 @@ log-symbols@^1.0.2: dependencies: chalk "^1.0.0" -log-symbols@^2.0.0, log-symbols@^2.2.0: +log-symbols@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" dependencies: @@ -6179,17 +6169,6 @@ optionator@^0.8.1, optionator@^0.8.2: type-check "~0.3.2" 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: version "1.0.1" 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: 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: version "4.2.1" resolved "https://registry.yarnpkg.com/web-resource-inliner/-/web-resource-inliner-4.2.1.tgz#a3ec33d85794675cb526cfb93d2115741869f8be"