Skip to content

Commit

Permalink
feat: make system compatible with koaton 2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
gerard2perez committed Sep 18, 2017
1 parent 957d896 commit 1779e8b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 23 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"node-sass-css-importer": "0.0.3",
"passport-local": "^1.0.0",
"uglify-js": "^3.0.27",
"babel-plugin-transform-koaton-es6-modules": "^1.0.0",
"upath": "^1.0.0"
},
"devDependencies": {
Expand Down
14 changes: 8 additions & 6 deletions src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import utils from '../utils';
import Command from 'cmd-line/lib/Command';
import BundleItem from '../support/BundleItem';
// import spin from '../spinner';
import { buildNginx } from '../functins/nginx';
import { buildNginx } from '../functions/nginx';
import { buildAllImages } from '../functions/imagecompressor';
import EmberBuilder from '../support/EmberBuilder';

Expand Down Expand Up @@ -161,14 +161,16 @@ async function buildJS (target, bundle, development, onlypaths, logger) {
for (const file of AllFiles) {
readfiles[path.basename(file)] = fs.readFileSync(file, 'utf-8');
}
console.log(target);
let map = target.replace('.js', '.map');
let result = uglify.minify(readfiles, {
mangle: false,
sourceMap: onlypaths ? false : {
url: ' /js/' + target + '.map'
root: '/src/',
includeSources: onlypaths ? false : development,
// filename: target,
url: path.join('/js', map)
},
// outSourceMap: onlypaths ? false : ' /js/' + target + '.map',
// sourceMapIncludeSources: onlypaths ? false : development,
// sourceRoot: '/' + path.changeExt(target, '.min.js'),
compress: {
dead_code: true,
sequences: true,
Expand All @@ -181,7 +183,7 @@ async function buildJS (target, bundle, development, onlypaths, logger) {
encoding: 'utf-8'
}, true);
if (development) {
fs.writeFileSync(path.join('public', 'js', target + '.map'), result.map, 'utf8');
fs.writeFileSync(path.join('public', 'js', map), result.map, 'utf8');
}

ITEM.add('/js/' + file);
Expand Down
6 changes: 3 additions & 3 deletions src/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ export default (new Command(__filename, 'Runs your awsome Koaton applicaction es
await Events('pre', 'ember_build');
let buildingAppsEmber = Object.entries(embercfg).map(([app, cfg]) => (new EmberBuilder(app, 'development', cfg)));
screen.line1(true);
// const building = spinner();
// building.start(100, `Building ${buildingAppsEmber.map(e => e.name).join(', ').green}`, undefined, process.stdout.columns);
const building = spinner();
building.start(100, `Building ${buildingAppsEmber.map(e => e.name).join(', ').green}`, undefined, process.stdout.columns);
let EmberPids = await Promise.all(buildingAppsEmber.map(e => e.serve(nginxbuilt))).then((reports) => {
// building.end(' Ember apps:');
building.end(' Ember apps:');
for (const report of reports) {
report.log = true;
console.log(` ${report.result}`);
Expand Down
12 changes: 6 additions & 6 deletions src/functions/nginx.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import exec from '../utils/exec';
import {join} from 'upath';
import { sync as glob } from 'glob';
import * as fs from 'fs-extra';
import copy from './copy';
import shell from './shell';
import mkdir from './mkdir';
import compile from './compile';
import write from './write';
import copy from '../utils/copy';
import shell from '../utils/shell';
import mkdir from '../utils/mkdir';
import compile from '../utils/compile';
import write from '../utils/write';

let nginxpath;
export async function getnginxpath () {
Expand Down Expand Up @@ -44,7 +44,7 @@ export async function buildNginx () {

let listen = '';
if (configuration.server.https && configuration.server.https.key) {
listen = `listen 443 ssl;\n\tssl on;\n\tssl_certificate ${configuration.server.https.cert};\n\tssl_certificate_key ${configuration.server.https.key};\n\tssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n\tssl_prefer_server_ciphers on;`;
listen = `listen 443 ssl;\n\tssl on;\n\tssl_certificate ${configuration.server.https.cert};\n\tssl_certificate_key ${configuration.server.https.key};\n\tssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n\tssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';\n\tssl_prefer_server_ciphers on;`;
if (configuration.server.https.dhparam) {
listen += `\n\tssl_dhparam ${configuration.server.https.dhparam};`;
}
Expand Down
10 changes: 6 additions & 4 deletions src/support/EmberBuilder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { write, mkdir, shell, compile, render, challenge } from '../utils';
import { sync as glob } from 'glob';
import { readFile, unlink } from 'fs-extra';
import { readFile, unlink, exists } from 'fs-extra';
import { join, basename } from 'path';
import * as spawn from 'cross-spawn';
import { watch as Watch } from 'chokidar';
Expand All @@ -21,11 +21,11 @@ export default class EmberBuilder {
uncontable: JSON.stringify(uncontable)
}, show ? 1 : null);
}
constructor (app, env, config) {
constructor (app, env, config = {}) {
this.index = index++;
this.name = app;
this.env = env;
this.directory = config.directory;
this.directory = config.directory || app.toLowerCase().replace(/ /g, '_').replace(/-/g, '_').replace(/_+/g, '_');
this.mount = join('/', config.mount || '', '/').replace(/\\/igm, '/');
this.adapter = config.adapter;
this.subdomain = config.subdomain;
Expand All @@ -36,7 +36,9 @@ export default class EmberBuilder {
}
async create (options) {
if (await challenge(this.path(), `destination ${this.path().yellow} is not empty, continue?`, options.force)) {
await unlink(this.path());
if (await exists(this.path())) {
await unlink(this.path());
}
await shell(`Installing ${this.name.green}`, ['ember', 'new', this.name, '-dir', this.path()], process.cwd());
await mkdir(this.path('app', 'initializers'));
await this.getInflections(true);
Expand Down
3 changes: 1 addition & 2 deletions templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"scripts": {
"commit": "git add -A & git-cz",
"convert": "koaton-exporter **/*.es6 ./ -e js",
"assets":"node ./node_modules/koaton/scripts/build.js",
"prestart": "npm run assets",
"start": "node app.js"
},
Expand All @@ -18,7 +17,7 @@
"author": "",
"license": "",
"dependencies": {
"koaton":"^2.0.2"
"koaton":"^2.0.5"
},
"config": {
"commitizen": {
Expand Down
2 changes: 1 addition & 1 deletion templates/server.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server {
listen 80;
server_name {{hostname}};
server_name {{hostname}} www.{{hostname}};
return 301 {{protocol}}://www.{{hostname}}$request_uri;
}
2 changes: 1 addition & 1 deletion templates/subdomain.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server {
client_max_body_size {{client_max_body_size}};
{{listen}}
{{listen}}
server_name {{subdomain}}.{{hostname}};
location / {
proxy_pass {{protocol}}://127.0.0.1:{{port}};
Expand Down

0 comments on commit 1779e8b

Please sign in to comment.