From 4045480a516010f11585d150dec17a728d895c14 Mon Sep 17 00:00:00 2001 From: Lucas Hrabovsky Date: Tue, 15 Jan 2019 15:32:00 -0500 Subject: [PATCH] Sunsetting this project --- .travis.yml | 14 +---- README.md | 25 ++++++++ bin/mongodb-js-fmt.js | 57 ++++-------------- index.js | 4 +- lib/index.js | 135 ------------------------------------------ package.json | 53 +---------------- test/index.test.js | 8 --- test/mocha.opts | 1 - 8 files changed, 44 insertions(+), 253 deletions(-) delete mode 100644 lib/index.js delete mode 100644 test/index.test.js delete mode 100644 test/mocha.opts diff --git a/.travis.yml b/.travis.yml index 3b79a1d..c6b2744 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,4 @@ language: node_js node_js: - 4 -before_install: - - npm install -g npm@3 - - npm config set loglevel error - - npm config -g list -l - - npm --version -script: npm run-script ci -# Disable cache to force travis to use node_js ver 4 -#cache: -# directories: -# - node_modules -# Post build notifications to the Integrations Flowdock -notifications: - flowdock: e3dc17bc8a2c1b3412abe3e5747f8291 +script: echo "Sunset" diff --git a/README.md b/README.md index 8a8f3b7..1f57406 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,28 @@ +# :wave: Sunset + +If you're seeing this message, it's because your module is still using `mongodb-js-fmt` which has been sunset. This project has been hanging around for far too long... `jsfmt` has long been replaced by `prettier` and editor's are now completely different. It no longer is, it was. :) + +`mongodb-js-fmt` never even made it to a minor release, but it snuck into lots of project templates so I'm including this message to help cleanup. + + +Here's how to make this go away: + +1. Remove `"fmt": "mongodb-js-fmt"` from `"scripts"` in your package.json +2. `npm uninstall --save-dev mongodb-js-fmt` +3. Install [prettier for the IDE/Editor of your choice](https://prettier.io/docs/en/editors.html) +4. If you see `"mongodb-js-fmt": "0.0.3"` in a friend's `package.json`, send them a PR or this link https://github.com/mongodb-js/fmt + +## Why? + +This project has been hanging around for far too long... `jsfmt` has long been replaced by `prettier` and editor's are now completely different. + +Install [prettier for the IDE/Editor of your choice](https://prettier.io/docs/en/editors.html). + +The README below is preserved for future travelers. + +--- + + # mongodb-js-fmt [![travis][travis_img]][travis_url] [![npm][npm_img]][npm_url] > Automatically rewrites [our code][mongodb-js] to [a shared spec][styleguide] because style is for tailors. diff --git a/bin/mongodb-js-fmt.js b/bin/mongodb-js-fmt.js index 8aac329..6214b61 100755 --- a/bin/mongodb-js-fmt.js +++ b/bin/mongodb-js-fmt.js @@ -1,50 +1,17 @@ #!/usr/bin/env node -/* eslint no-sync:0 */ -var path = require('path'); -var fs = require('fs'); -var chalk = require('chalk'); -var figures = require('figures'); -var format = require('util').format; +console.error('⚠ mongodb-js-fmt has been sunset!'); +console.error(' Please read: https://github.com/mongodb-js/fmt'); +console.error(` +--- +If you're seeing this message, it's because your module is still using 'mongodb-js-fmt' which has been sunset. It no longer is, it was. :) -var usage = fs.readFileSync(path.resolve(__dirname, '../usage.txt')).toString(); -var args = require('minimist')(process.argv.slice(2), { - boolean: ['debug', 'dry', 'json'] -}); +mongodb-js-fmt never even made it to a minor release, but it snuck into lots of project templates so I'm including this message to help cleanup. -if (args.debug) { - process.env.DEBUG = 'mongodb-js-fmt'; -} -var fmt = require('../'); -var pkg = require('../package.json'); +Here's how to make this go away: -args.globs = args._; - - -if (args.help || args.h) { - console.error(usage); - process.exit(1); -} -if (args.version) { - console.error(pkg.version); - process.exit(1); -} - -fmt(args, function(err, res) { - if (err) { - if (args.json) { - err = JSON.stringify(err, null, 2); - } - console.error(chalk.red(figures.cross), err.message); - console.error(chalk.gray(err.stack)); - process.exit(1); - return; - } - if (args.json) { - console.log(JSON.stringify(res, null, 2)); - } else { - console.log(chalk.green(figures.tick), - format('formatted (%d), unchanged (%d)', - res.formatted.length, res.unchanged.length)); - } -}); +1. Remove \`"fmt": "mongodb-js-fmt"\` from \`"scripts"\` in your package.json +2. npm uninstall --save-dev mongodb-js-fmt +3. Install prettier for the IDE/Editor of your choice: https://prettier.io/docs/en/editors.html +4. If you see \`"mongodb-js-fmt": "0.0.3"\` in a friend's \`package.json\`, send them a PR or this link https://github.com/mongodb-js/fmt +`); diff --git a/index.js b/index.js index bb0a047..d34bb72 100644 --- a/index.js +++ b/index.js @@ -1 +1,3 @@ -module.exports = require('./lib'); +module.exports = function(opts, done) { + throw new Error('Project sunsetted'); +}; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 57940ea..0000000 --- a/lib/index.js +++ /dev/null @@ -1,135 +0,0 @@ -var fs = require('fs'); -var glob = require('glob'); -var jsfmt = require('jsfmt'); -var async = require('async'); -var defaults = require('lodash.defaults'); -var unique = require('lodash.uniq'); -var debug = require('debug')('mongodb-js-fmt'); -var chalk = require('chalk'); -var figures = require('figures'); - -/** - * Expand globs into paths. - */ -function resolve(opts, done) { - debug('resolving paths for globs:\n', JSON.stringify(opts.globs)); - var tasks = opts.globs.map(function(pattern) { - return function(cb) { - debug('resolving `%s`...', pattern); - glob(pattern, {}, function(err, files) { - if (err) { - return cb(err); - } - debug('resolved %d file(s) for `%s`', files.length, pattern); - if (files.length > 0) { - opts.files.push.apply(opts.files, files); - } - cb(); - }); - }; - }); - async.parallel(tasks, function(err) { - if (err) { - return done(err); - } - debug('checking and removing duplicate paths...'); - opts.files = unique(opts.files); - debug('final result has `%d` files', opts.files.length); - done(null, opts.files); - }); -} - -function formatOne(opts, src, done) { - debug('formatting `%s`...', src); - fs.readFile(src, function(err, buf) { - if (err) { - return done(err); - } - - var original = buf.toString('utf-8'); - try { - var formatted = jsfmt.format(original, opts.jsfmtConfig); - if (formatted === original) { - debug('no formatting needed for `%s`', src); - opts.unchanged.push(src); - done(); - } else if (opts.dry === true) { - // @todo (imlucas): Find module that computes diff and console.log(diff) - debug('needs formatting but `--dry` specified `%s`...', src); - opts.formatted.push(src); - done(); - } else { - debug('writing formatted version of `%s`...', src); - opts.formatted.push(src); - fs.writeFile(src, formatted, done); - } - } catch (e) { - debug('error while formatting `%s`: %s', src, err); - return done(e); - } - }); -} - -function format(opts, done) { - debug('`%d` files will be formatted...', opts.files.length); - async.parallel(opts.files.map(function(src) { - return formatOne.bind(null, opts, src); - }), done); -} - -/** - * @param {Object} opts - * @param {Function} done - * @api public - */ -module.exports = function(opts, done) { - defaults(opts, { - dir: process.cwd(), - files: [], - dry: false, - json: false, - formatted: [], - unchanged: [] - }); - - if (opts.globs.length === 0) { - // @todo (imlucas): yeah, I can never remember how - // to properly exclude node_modules either... - opts.globs = [ - './bin/*.js', - './lib/{**/*,*}.js', - './examples/{**/*,*}.js', - './src/{**/*,*}.js', - './test/{**/*,*}.js', - './*.js' - ]; - } - - if (!Array.isArray(opts.globs)) { - opts.globs = [opts.globs]; - } - - // @todo (imlucas): Support config via package.json. - // var path = require('path'); - // var pkg = require(path.join(opts.dir, 'package.json')); - // debug('Loaded package.json from `%s`', opts.dir); - - opts.jsfmtConfig = jsfmt.getConfig(); - debug('loaded jshint config'); - - console.log(chalk.gray(figures.pointerSmall, - 'Applying shared JavaScript guidelines to your code...')); - console.log(chalk.gray(' Use the'), - chalk.gray.bold('--debug'), - chalk.gray('flag for diagnostic info') - ); - - async.series([resolve.bind(null, opts), format.bind(null, opts)], function(err) { - if (err) { - return done(err); - } - delete opts.jsfmtConfig; - debug('fmt complete: %j', opts); - done(null, opts); - }); -}; diff --git a/package.json b/package.json index 3a05564..e508bcc 100644 --- a/package.json +++ b/package.json @@ -2,61 +2,14 @@ "name": "mongodb-js-fmt", "description": "Automatically rewrites our code to a shared spec because style is for tailors.", "version": "0.0.3", - "scripts": { - "check": "mongodb-js-precommit", - "fmt": "node bin/mongodb-js-fmt.js", - "test": "mocha", - "ci": "npm run check && npm test" - }, "bin": { "mongodb-js-fmt": "bin/mongodb-js-fmt.js" }, - "homepage": "http://mongodb-js.github.io/fmt", + "homepage": "https://github.com/mongodb-js/fmt", "repository": { "type": "git", "url": "git://github.com/mongodb-js/fmt.git" }, - "dependencies": { - "async": "^2.1.2", - "chalk": "^1.1.1", - "debug": "^2.2.0", - "esformatter-braces": "^1.2.1", - "esformatter-dot-notation": "^1.3.1", - "esformatter-eol-last": "^1.0.0", - "esformatter-parseint": "^1.0.3", - "esformatter-quote-props": "^2.0.0", - "esformatter-quotes": "^1.0.3", - "esformatter-remove-trailing-commas": "^1.0.1", - "esformatter-semicolons": "^1.1.1", - "esformatter-spaced-lined-comment": "^2.0.1", - "esformatter-var-each": "^2.1.0", - "figures": "^2.0.0", - "glob": "^7.1.1", - "jsfmt": "^0.5.0", - "lodash.defaults": "^4.2.0", - "lodash.uniq": "^4.5.0", - "minimist": "^1.2.0" - }, - "devDependencies": { - "eslint-config-mongodb-js": "^2.2.0", - "mocha": "^3.1.2", - "mongodb-js-precommit": "^0.2.2", - "pre-commit": "^1.1.1" - }, - "license": "Apache 2", - "precommit": "check", - "dependency-check": { - "ignore": [ - "esformatter-braces", - "esformatter-dot-notation", - "esformatter-eol-last", - "esformatter-parseint", - "esformatter-quote-props", - "esformatter-quotes", - "esformatter-remove-trailing-commas", - "esformatter-semicolons", - "esformatter-spaced-lined-comment", - "esformatter-var-each" - ] - } + "dependencies": {}, + "license": "Apache 2" } diff --git a/test/index.test.js b/test/index.test.js deleted file mode 100644 index 2e29f27..0000000 --- a/test/index.test.js +++ /dev/null @@ -1,8 +0,0 @@ -var mongodbJsFmt = require('../'); -var assert = require('assert'); - -describe('mongodb-js-fmt', function() { - it('should work', function() { - assert(mongodbJsFmt); - }); -}); diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index ec648f2..0000000 --- a/test/mocha.opts +++ /dev/null @@ -1 +0,0 @@ --R spec