1.0.0 • Published 7 years ago

app-up v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

🚀 AppUp

Write high quality, maintable, ES6 and ES7 NodeJS applications right now!

😳 Wut⁉️

AppUp is a slightly opinionated NodeJS configuration/boilerplate used to quickstart NodeJS application and service development with a strong focus on good JavaScript programming practices.

✨ Features

  • Strong focus on good JavaScript programming practices
  • Babel: Write ES6/ES7 JavaScript for your NodeJS applications!
  • Mocha: Because, testing! You can also write your tests in ES6/ES7
  • ESLint: Enforces good programming practices using Airbnb style guide

😎 Install

npm i app-up --save

or

git clone https://github.com/JamesTheHacker/app-up
cd app-up
npm install

🙏 Demo

After installation run the following command and watch the terminal:

npm run demo

This runs a demo build that beings by linting the code, then runs a couple of unit tests, followed by the build/transpilation process, and finally it launches the app. This gives you a clear view of what's going on and how things work when using AppUp.

💻 Init New Project

This projects comes with the demo file by default. You probably don't want to include the demo file in your own project. Let me show you how to initialize a blank AppUp project:

Initialize a new project by running:

npm run init

This deletes all the demo files and gives you a blank canvas to start from.

Commands

The following commands are available:

  • npm run init: Initializes a blank project
  • npm run lint: Runs eslint using Airbnb's style guide
  • npm run build: Transpiles ES6/ES7 code in src/ to ES5 and stores in lib/
  • npm test: Runs unit tests
  • npm run demo: Runs the AppUp demo

Note: Both npm run build and npm test will run npm run lint

Writing ES6/ES7

As of writing NodeJS lacks many ES6/ES7 features (don't worry, the Node developers are working on it. It's just taking a while). This means we can't natively write ES6/ES7 with NodeJS. But, we can use Babel to fill the gap.

If you didn't already know Babel can be used to convert (transpile) ES6 and ES7 JavaScript to ES5. Which means you can start writing NodeJS applications using future JavaScript now! You can use ES6/ES7 to your tests. It'll work just fine 😺

How?

All of your application code must be stored in the src/ directory. All files within this directory are transpiled from ES6/ES7 to ES5 by babel. ES5 files are stored in the lib/ directory and can be ran as normal.

To transpile code within the src/ directory run:

npm run build

💪 ESLint Enforces The Law

This project enforces good programming practices. It follows the Airbnb JavaScript style guide. Running any npm command will first run eslint. If any of your code doesn't conform to the style guide your project will refuse to transpile and test.

⁉️⁉️WTF⁉️⁉️

If this pisses you off, tough! Learn to code properly. Tough love homie 💜

Back on point ...

You can run eslint at any time by using the following command:

npm run lint

This will test all JavaScript file in the src/ and test/ directory.

If your code is not valid when compared to the style guide NodeJS eslint will scream at you. Example:

[~/Projects/app-up] npm run lint

> unit-testing@1.0.0 lint /Users/jamesjeffery/Projects/app-up
> eslint src/ test/

/Users/jamesjeffery/Projects/app-up/src/app.js
  4:3  error  Newline required at end of file but not found  eol-last

/Users/jamesjeffery/Projects/app-up/test/app.js
  9:4  error  Newline required at end of file but not found  eol-last

✖ 2 problems (2 errors, 0 warnings)
  2 errors, 0 warnings potentially fixable with the `--fix` option.

If you use a text editor such as VSCode you will also get nice little warnings in the UI, and on the "Problems" tab. It's super helpful.

The lib/ directory is ignored by eslint. You shouldn't be storing code in the lib/ directory.

🐛 Unit Testing

Keeping in tune with strong programming practices is the art of testing. Unit tests will help you write better, more maintainable, code.

Mocha is an awesome testing library which is why I've included it within this project. I haven't included an assertion library. I will leave that choice up to the programmer. See here for list of assertion libraries.

All tests should be placed in the test/ directory. To run tests use:

npm test

If you'd like to alter any of the command line arguments for Mocha edit the following line within package.json:

"test": "npm run lint && mocha --compilers js:babel-core/register"

Finally ...

This project is nothing special, but it certainly shaves off some precious time. I get sick and tired of creating the same old boiler plate.

Let me know what you think. Send me an email, I'd love to hear from you: jameslovescode [at] gmail [dot] com

1.0.0

7 years ago