Skip to content

Commit

Permalink
feat(nginx): split logic for nginx conf
Browse files Browse the repository at this point in the history
change a lot of var names, optimize some region codes, increase coverage of tests
  • Loading branch information
gerard2perez committed Nov 17, 2016
1 parent 3864283 commit 89045f8
Show file tree
Hide file tree
Showing 38 changed files with 503 additions and 383 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"istanbul"
],
"ignore": [
"serverconf",
"config/",
"docs/",
"lib/",
Expand Down
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rules:

import/no-mutable-exports: 0
import/no-dynamic-require: 0
import/no-unresolved: 0
no-tabs: 0
# Possible Errors
comma-dangle: [2, never]
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
/testcoverage/
/docs/
/lib/
/**/barebone.js
duplication.html
_*
npm-debug*
Expand Down
4 changes: 4 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"lcov",
"text"
],
"exclude":[
"/**/globals.js",
"utils"
],
"sourceMap": false,
"instrument": false,
"cache": true,
Expand Down
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
services:
- mongodb
language: node_js
node_js:
- "4.4.4"
- "6.5.0"
sudo: false
env:
- CXX=g++-4.8
Expand All @@ -12,20 +14,20 @@ addons:
packages:
- gcc-4.8
- g++-4.8
- nginx
cache:
directories:
- node_modules

before_install:
- "npm config set spin false"
- npm config set spin false
- npm install -g glob
- npm install -g ember-cli@2.7.0
- npm install -g ember-cli@2.9.1
- npm install -g bower
- npm install -g forever

install:
- npm i
- npm i . -g
- npm i .

script:
- npm test
2 changes: 2 additions & 0 deletions koaton
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/usr/bin/env node
process.env.NODE_ENV = process.argv.indexOf("-p") > -1 || process.argv.indexOf("--production") > -1 ? "production" : "development";
process.env.port = parseInt(process.argv[process.argv.indexOf("--port") + 1], 10) || 62626;
require('./lib');
212 changes: 101 additions & 111 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,113 +1,103 @@
{
"name": "koaton-cli",
"version": "0.0.0-semantic-release",
"description": "Koaton is a CLI tool that provides a nice starting point for full stack JavaScript Web development with Koa, Ember, and Node.js along with CaminateJS and WebSockets.",
"main": "./koaton",
"scripts": {
"export:live": "npm run export & chokidar src -c \"cls && npm run export\"",
"eslint:live": "npm run eslint & chokidar src -c \"cls && npm run eslint\"",
"eslint": "eslint src --ignore-path .gitignore",
"export": "node transpile.js v1",
"test": "cross-env NODE_ENV=koaton mocha test/unit/**/*.js test/integration.js --compilers js:babel-register",
"test:live": "npm t -- -w",
"cover": "nyc npm t",
"cover:reload": "node reloadcoverage.js",
"cover:watch": "npm run cover & chokidar src test -c \"cls & npm run cover\"",
"cover:live": "npm-run-all --parallel cover:watch cover:reload",
"codeclimate": "codeclimate analyze -f html -e duplication > duplication.html",
"doc": "esdoc -c esdoc.json",
"commit": "git-cz",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"bin": {
"koaton": "./koaton"
},
"directories": {
"lib": "lib"
},
"engines": {
"node": ">= 6.5.0"
},
"preferGlobal": true,
"repository": {
"type": "git",
"url": "https://github.com/gerard2p/koaton-cli.git"
},
"keywords": [
"koa",
"bootstrap",
"seed",
"mvc",
"emberjs",
"websockets"
],
"files": [
"lib",
"README.md",
"LICENSE.md"
],
"author": "Gerardo Pérez Pérez <gerard2perez@outlook.com>",
"license": "MIT",
"readmeFilename": "README.md",
"homepage": "https://github.com/gerard2p/koaton-cli.git",
"dependencies": {
"bcrypt": "^0.8.7",
"bluebird": "^3.3.5",
"chokidar": "^1.5.0",
"co": "^4.6.0",
"co-prompt": "^1.0.0",
"colors": "^1.1.2",
"commander": "^2.9.0",
"concat-with-sourcemaps": "^1.0.4",
"cross-spawn": "^4.0.0",
"glob": "^7.0.5",
"graceful-fs": "^4.1.4",
"gulp-livereload": "^3.8.1",
"handlebars-layout": "^0.1.3",
"i": "^0.3.4",
"imagemin": "^5.2.1",
"imagemin-mozjpeg": "^6.0.0",
"imagemin-pngquant": "^5.0.0",
"koa-compose": "^2.4.0",
"koa-convert": "^1.2.0",
"koa-passport": "^1.3.1",
"koa-send": "^3.2.0",
"less": "^2.7.1",
"less-plugin-clean-css": "^1.5.1",
"mkdirp": "^0.5.1",
"node-minify": "^1.3.7",
"node-notifier": "^4.5.0",
"node-sass": "^3.8.0",
"node-sass-css-importer": "0.0.3",
"nodemon": "^1.9.2",
"oauth2orize-koa": "^1.3.2",
"passport-http": "^0.3.0",
"passport-http-bearer": "^1.0.1",
"passport-local": "^1.0.0",
"passport-oauth2-client-password": "^0.1.2",
"recursive-copy": "^2.0.5",
"uglify-js": "^2.6.4",
"upath": "^0.2.0",
"fs-extra": "^0.30.0",
"ncp": "^2.0.0"
},
"devDependencies": {
"babel-plugin-istanbul": "^2.0.3",
"babel-plugin-transform-koa2-async-to-generator": "git+https://gerardopp@bitbucket.org/gerardopp/babel-plugin-transform-koa2-async-to-generator.git",
"babel-plugin-transform-koaton-es6-modules": "git+https://gerardopp@bitbucket.org/gerardopp/babel-plugin-transform-koaton-es6-modules.git",
"babel-register": "^6.18.0",
"commitizen": "^2.8.6",
"cz-conventional-changelog": "^1.2.0",
"eslint": "^3.7.0",
"eslint-config-airbnb-base": "^8.0.0",
"eslint-plugin-import": "^1.16.0",
"mocha": "^3.1.0",
"nyc": "^8.4.0",
"semantic-release": "^4.3.5"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
}
"name": "koaton-cli",
"version": "0.0.0-semantic-release",
"description": "Koaton is a CLI tool that provides a nice starting point for full stack JavaScript Web development with Koa, Ember, and Node.js along with CaminateJS and WebSockets.",
"main": "./koaton",
"scripts": {
"export:live": "npm run export & chokidar src -c \"cls && npm run export\"",
"eslint:live": "npm run eslint & chokidar src -c \"cls && npm run eslint\"",
"eslint": "eslint src --ignore-path .gitignore",
"export": "node transpile.js v1",
"test": "cross-env NODE_ENV=koaton mocha test/unit/**/*.js test/integration.js --compilers js:babel-register",
"test:live": "npm t -- -w",
"cover": "nyc npm t",
"cover:reload": "node reloadcoverage.js",
"cover:watch": "npm run cover & chokidar src test -c \"cls & npm run cover\"",
"cover:live": "npm-run-all --parallel cover:watch cover:reload",
"codeclimate": "codeclimate analyze -f html -e duplication > duplication.html",
"doc": "esdoc -c esdoc.json",
"commit": "git-cz",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"bin": {
"koaton": "./koaton"
},
"directories": {
"lib": "lib"
},
"engines": {
"node": ">= 6.5.0"
},
"preferGlobal": true,
"repository": {
"type": "git",
"url": "https://github.com/gerard2p/koaton-cli.git"
},
"keywords": [
"koa",
"bootstrap",
"seed",
"mvc",
"emberjs",
"websockets"
],
"files": [
"lib",
"README.md",
"LICENSE.md"
],
"author": "Gerardo Pérez Pérez <gerard2perez@outlook.com>",
"license": "MIT",
"readmeFilename": "README.md",
"homepage": "https://github.com/gerard2p/koaton-cli.git",
"dependencies": {
"bluebird": "^3.3.5",
"chokidar": "^1.5.0",
"co": "^4.6.0",
"co-prompt": "^1.0.0",
"colors": "^1.1.2",
"commander": "^2.9.0",
"concat-with-sourcemaps": "^1.0.4",
"cross-spawn": "^5.0.1",
"fs-extra": "^1.0.0",
"glob": "^7.0.5",
"graceful-fs": "^4.1.10",
"gulp-livereload": "^3.8.1",
"i": "^0.3.4",
"imagemin": "^5.2.1",
"imagemin-mozjpeg": "^6.0.0",
"imagemin-pngquant": "^5.0.0",
"less": "^2.7.1",
"less-plugin-clean-css": "^1.5.1",
"mkdirp": "^0.5.1",
"node-notifier": "^4.5.0",
"node-sass": "^3.13.0",
"node-sass-css-importer": "0.0.3",
"nodemon": "^1.9.2",
"uglify-js": "^2.6.4",
"upath": "^0.2.0"
},
"devDependencies": {
"babel-core": "^6.18.2",
"babel-plugin-istanbul": "^3.0.0",
"babel-plugin-transform-koa2-async-to-generator": "git+https://gerardopp@bitbucket.org/gerardopp/babel-plugin-transform-koa2-async-to-generator.git",
"babel-plugin-transform-koaton-es6-modules": "git+https://gerardopp@bitbucket.org/gerardopp/babel-plugin-transform-koaton-es6-modules.git",
"babel-plugin-transform-strict-mode": "^6.18.0",
"babel-register": "^6.18.0",
"commitizen": "^2.8.6",
"cross-env": "^3.1.3",
"cz-conventional-changelog": "^1.2.0",
"eslint": "^3.10.2",
"eslint-config-airbnb-base": "^10.0.1",
"eslint-plugin-import": "^2.2.0",
"mocha": "^3.1.0",
"npm-run-all": "^3.1.1",
"nyc": "^9.0.1",
"semantic-release": "^4.3.5"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
}
}
17 changes: 10 additions & 7 deletions src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {
import utils from '../utils';
import command from '../command';
import BundleItem from '../support/BundleItem';
import spin from '../spinner';


const spinner = spin();
const copystatic = async function copystatic() {
const copy = requireSafe(ProyPath("config", "copy"), {});
for (const dir in copy) {
Expand All @@ -22,7 +25,7 @@ const copystatic = async function copystatic() {
let directories = readSync(ProyPath(copy[dir][idx]));
for (const i in directories) {
const file = directories[i];
await utils.Copy(file, ProyPath("public", dir, path.basename(file)));
await utils.copy(file, ProyPath("public", dir, path.basename(file)));
}
}
}
Expand Down Expand Up @@ -52,11 +55,11 @@ const compressImages = function(files, dest) {
}
const buildCSS = async function buildCSS(target, source, development, onlypaths, logger) {
if (scfg.bundles.has(target)) {
scfg.bundles.item(target).clear();
scfg.bundles[target].clear();
} else {
scfg.bundles.add(new BundleItem(target, []));
}
const ITEM = scfg.bundles.item(target);
const ITEM = scfg.bundles[target];

utils.writeuseslog = logger;
const less = require('less'),
Expand Down Expand Up @@ -149,7 +152,7 @@ const buildCSS = async function buildCSS(target, source, development, onlypaths,
return watchinFiles;
}
const buildJS = async function buildJS(target, source, development, onlypaths, logger) {
const ITEM = scfg.bundles.item(target) || new BundleItem(target, []);
const ITEM = scfg.bundles[target] || new BundleItem(target, []);
ITEM.clear();
utils.writeuseslog = logger;
let AllFiles = [];
Expand Down Expand Up @@ -284,7 +287,7 @@ export default (new command(
process.env.NODE_ENV = options.prod;
const source_file = process.cwd() + (config_file || '/config/bundles.js');
const patterns = require(source_file);
await utils.Copy(path.join('assets', 'favicon.ico'), path.join('public', 'favicon.ico'), {
await utils.copy(path.join('assets', 'favicon.ico'), path.join('public', 'favicon.ico'), {
encoding: "binary"
});
if (Object.keys(patterns).length === 0) {
Expand Down Expand Up @@ -321,8 +324,8 @@ export default (new command(
});
await postBuildEmber(ember_app, configuration);
}
utils.log("Compressing Images");
spinner.start(50, "Compressing Images", undefined, process.stdout.columns);
await compressImages([path.join('assets', 'img', '*.{jpg,png}')], path.join('public', 'img'));
utils.nlog("Images Compressed");
spinner.end("Images Compressed".green);
}
});
10 changes: 6 additions & 4 deletions src/commands/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const list = async function list() {
let has = data[0].indexOf("No forever processes running") === -1;
return {
hasProcess: has,
header: has !== null ? data[1].trim().split(' ').slice(1) : [],
data: has !== null ? data.slice(2).map((d) => {
header: has ? data[1].trim().split(' ').slice(1) : [],
data: has ? data.slice(2).map((d) => {
return d.trim().split(' ')
}) : []
}
Expand Down Expand Up @@ -96,10 +96,12 @@ export default (new command(__filename, "Runs your awsome Koaton on production m
}
}
} else if (options.stop) {
if (app === "all") {
if (options.stop === "all") {
await utils.exec(`forever stopall`, {});
} else if (options.stop === ".") {
await utils.exec(`forever stop koaton_${app}`, {});
} else {
await utils.exec(`forever stopall`, {});
await utils.exec(`forever stop koaton_${options.stop}`, {});
}
} else if (options.list) {
let r = await list();
Expand Down
16 changes: 2 additions & 14 deletions src/commands/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
import * as path from 'path';
import read from '../utils/.include_base';

let mods = {};
readDir(__dirname)
.filter(item => !(/(^|\/)\.[^\/\.]/g).test(item))
.filter(item => item !== "index.js")
.filter(item => item !== "help.js")
.forEach((file) => {
if (file.indexOf("barebone") === -1) {
let module = require(path.join(__dirname, file));
mods[path.basename(file).replace(".js", "")] = module.default ? module.default : module;
}
});
makeObjIterable(mods);
export default mods;
module.exports = read(__dirname);
Loading

0 comments on commit 89045f8

Please sign in to comment.