From 0fda42dd7c76163fb57dbb783d211ac6373f3f96 Mon Sep 17 00:00:00 2001 From: Pranav Prakash Date: Sun, 30 Sep 2018 11:32:21 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20Bump=20version=20to=201.1.0,=20u?= =?UTF-8?q?pgrade=20to=20Babel=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 21 +++++++++++++-------- bin/koa-api.js | 46 ++++++++++++++++++++++++---------------------- package-lock.json | 2 +- package.json | 11 +++++++++-- 4 files changed, 47 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 36bb820..1c9e016 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,15 @@ [![Dependency Status](https://david-dm.org/pranavpr/koa-api-generator.svg?maxAge=43200)](https://david-dm.org/pranavpr/koa-api-generator) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) - A mostly unopinionated generator for creating Rest APIs using Koa2 and ES2017+ features in a Node.js server environment as well as providing linting and testing support. It provides the setup for compiling, linting and testing your code but doesn't make any further assumptions on how your project should be structured. Make sure you read the FAQ for more details and info. ### Features: + - [Koa](http://koajs.com/) as the web framework. - ES2017+ support with [Babel](https://babeljs.io/). -- Automatic polyfill requires based on environment with [babel-preset-env](https://github.com/babel/babel-preset-env). +- Automatic polyfill requires based on environment with [@babel/preset-env](https://github.com/babel/babel/tree/master/packages/babel-preset-env). - Linting with [ESLint](http://eslint.org/). - Testing with [Jest](https://facebook.github.io/jest/). @@ -28,18 +28,22 @@ yarn add global koa-api-generator ``` ## Quick Start + Create the app: + ```sh koa-api /tmp/foo && cd /tmp/foo ``` Install dependencies: + ```sh npm install # or if you're using Yarn yarn ``` + _If you don't use [Yarn](https://yarnpkg.com/) you can just replace `yarn` with `npm` in the commands that follow._ Then you can begin development: @@ -68,7 +72,7 @@ yarn test --coverage ### Linting -Linting is set up using [ESLint](http://eslint.org/). It uses ESLint's default [eslint:recommended](https://github.com/eslint/eslint/blob/master/conf/eslint.json) rules. Feel free to use your own rules and/or extend another popular linting config (e.g. [airbnb's](https://www.npmjs.com/package/eslint-config-airbnb) or [standard](https://github.com/feross/eslint-config-standard)). +Linting is set up using [ESLint](http://eslint.org/). It uses ESLint's default [eslint:recommended](https://eslint.org/docs/rules/) rules. Feel free to use your own rules and/or extend another popular linting config (e.g. [airbnb's](https://www.npmjs.com/package/eslint-config-airbnb) or [standard](https://github.com/feross/eslint-config-standard)). Begin linting in watch mode with: @@ -78,7 +82,7 @@ yarn run lint ### Environmental variables in development -The project uses [dotenv](https://www.npmjs.com/package/dotenv) for setting environmental variables during development. Simply copy `.env.example`, rename it to `.env` and add your env vars as you see fit. +The project uses [dotenv](https://www.npmjs.com/package/dotenv) for setting environmental variables during development. Simply copy `.env.example`, rename it to `.env` and add your env vars as you see fit. It is **strongly** recommended **never** to check in your .env file to version control. It should only include environment-specific values such as database passwords or API keys used in development. Your production env variables should be different and be set differently depending on your hosting solution. `dotenv` is only for development. @@ -90,7 +94,7 @@ Deployment is specific to hosting platform/provider but generally: yarn run build ``` -will compile your src into `/dist`, and +will compile your src into `/dist`, and ```sh yarn start @@ -106,11 +110,12 @@ The last command is generally what most hosting providers use to start your appl In `package.json`. Feel free to extract them in separate respective config files if you like. -**Why are you using `babel-register` instead of `babel-node`?** +**Why are you using `@babel/register` instead of `@babel/node`?** -`babel-node` contains a small "trap", it loads Babel's [polyfill](https://babeljs.io/docs/usage/polyfill/) by default. This means that if you use something that needs to be polyfilled, it'll work just fine in development (because `babel-node` polyfills it automatically) but it'll break in production because it needs to be explicitely included in Babel's CLI which handles the final build. +`@babel/node` contains a small "trap", it loads Babel's [polyfill](https://babeljs.io/docs/usage/polyfill/) by default. This means that if you use something that needs to be polyfilled, it'll work just fine in development (because `@babel/node` polyfills it automatically) but it'll break in production because it needs to be explicitely included in Babel's CLI which handles the final build. -In order to avoid such confusions, `babel-register` is a more sensible approach in keeping the development and production runtimes equal. By using [babel-preset-env](https://github.com/babel/babel-preset-env) only code that's not supported by the running environment is transpiled and any polyfills required are automatically inserted. +In order to avoid such confusions, `@babel/register` is a more sensible approach in keeping the development and production runtimes equal. By using [@babel/preset-env](https://github.com/babel/babel/tree/master/packages/babel-preset-env) only code that's not supported by the running environment is transpiled and any polyfills required are automatically inserted. ## License + MIT License. See the [LICENSE](LICENSE) file. diff --git a/bin/koa-api.js b/bin/koa-api.js index 0a17288..46fd2dc 100755 --- a/bin/koa-api.js +++ b/bin/koa-api.js @@ -150,14 +150,14 @@ function createApplication(name, path) { private: true, main: 'dist/index.js', engines: { - node: '~8.5.0', - npm: '>=5.3.0' + node: '~8.12.0', + npm: '>=6.4.1' }, scripts: { prestart: 'npm run -s build', start: 'node dist/index.js', dev: - 'nodemon src/index.js --exec "node -r dotenv/config -r babel-register"', + 'nodemon src/index.js --exec "node -r dotenv/config -r @babel/register"', clean: 'rimraf dist', build: 'npm run clean && mkdir -p dist && babel src -s -D -d dist', test: 'jest', @@ -165,32 +165,34 @@ function createApplication(name, path) { }, dependencies: { '@koa/cors': '2', - 'babel-cli': '^6.26.0', - 'babel-plugin-transform-object-rest-spread': '^6.26.0', - 'babel-preset-env': '^1.6.0', - koa: '^2.3.0', - 'koa-bodyparser': '^4.2.0', + '@babel/cli': '^7.1.0', + '@babel/core': '^7.1.0', + '@babel/plugin-proposal-object-rest-spread': '^7.0.0', + '@babel/preset-env': '^7.1.0', + koa: '^2.5.3', + 'koa-bodyparser': '^4.2.1', 'koa-morgan': '^1.0.1', - 'koa-router': '^7.2.1', + 'koa-router': '^7.4.0', rimraf: '^2.6.2' }, devDependencies: { - 'babel-eslint': '^8.0.0', - 'babel-jest': '^21.0.2', - 'babel-register': '^6.26.0', - dotenv: '^4.0.0', - eslint: '^4.7.2', - 'eslint-plugin-import': '^2.7.0', - 'eslint-plugin-jest': '^21.1.0', - 'eslint-watch': '^3.1.2', - jest: '^21.1.0', - nodemon: '^1.12.1', - supertest: '^3.0.0' + 'babel-eslint': '^10.0.1', + 'babel-jest': '^23.6.0', + '@babel/register': '^7.0.0', + 'babel-core': '7.0.0-bridge.0', + dotenv: '^6.0.0', + eslint: '^5.6.1', + 'eslint-plugin-import': '^2.14.0', + 'eslint-plugin-jest': '^21.23.0', + 'eslint-watch': '^4.0.2', + jest: '^23.6.0', + nodemon: '^1.18.4', + supertest: '^3.3.0' }, babel: { presets: [ [ - 'env', + '@babel/preset-env', { targets: { node: 'current' @@ -198,7 +200,7 @@ function createApplication(name, path) { } ] ], - plugins: ['transform-object-rest-spread'], + plugins: ['@babel/plugin-proposal-object-rest-spread'], sourceMaps: true, retainLines: true }, diff --git a/package-lock.json b/package-lock.json index 342b3a4..9cd9d07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "koa-api-generator", - "version": "1.0.3", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index bd97a56..e080f3e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "koa-api-generator", - "version": "1.0.4", + "version": "1.1.0", "description": "Koa API generator", "main": "./bin/koa-api.js", "preferGlobal": true, @@ -14,7 +14,14 @@ "type": "git", "url": "git+ssh://git@github.com/pranavpr/koa-api-generator.git" }, - "keywords": ["koa", "koa2", "api", "generator", "boilerplate", "jest"], + "keywords": [ + "koa", + "koa2", + "api", + "generator", + "boilerplate", + "jest" + ], "author": "Pranav Prakash ", "license": "MIT", "bugs": {