-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.js
98 lines (89 loc) · 2.25 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use strict';
const deepmerge = require('deepmerge');
/**
* Simple is object check.
* @param {Object} item
* @return {boolean}
*/
const isObject = item => {
return (item && typeof item === 'object' && !Array.isArray(item) && item !== null);
};
/**
* Default CLI config
* @param {string} __CWD [description]
* @param {string} __ROOT [description]
* @param {string} __ENV [description]
* @return {object} [description]
*/
module.exports = function(__CWD, __ROOT, __ENV) {
// ======================
// Base config
// ======================
let applicationConfig = {};
let packageJson = require('./package');
try {
applicationConfig = require(`${__ROOT}/ship.config`);
} catch (err) {
//
}
// get versions and description
const version = packageJson.version || '0.0.1';
const description = packageJson.description || 'RSHIP';
// ======================
// Base config
// ======================
let config = {
name: 'SHIP',
details: {
version: version,
description: description
},
description: 'CLI for building Isomorphic Web App',
cwd: __CWD,
dir: __ROOT,
env: __ENV,
requirments: {
node: '6.3.0'
},
generator: {
'react-redux-boilerplate': 'https://github.com/mrsum/react-redux-boilerplate/archive/master.tar.gz'
},
webpack: {
client: `${__ROOT}/webpack/webpack.client.js`,
server: `${__ROOT}/webpack/webpack.server.js`,
},
aliases: {
_app: `${__ROOT}/source`,
_config: `${__ROOT}/ship.config.js`,
_server: `${__ROOT}/source/server`,
_client: `${__ROOT}/source/client`,
_shared: `${__ROOT}/source/shared`,
},
development: {
server: {
host: '127.0.0.1',
port: '3000'
},
client: {
host: '127.0.0.1',
port: '8090'
}
},
build: {
path: `${__ROOT}/dist/`,
minify: true,
server: {
file: 'server.js',
path: `${__ROOT}/dist/server`
},
client: {
file: 'application.js',
path: `${__ROOT}/dist/client`,
static: `${__ROOT}/dist/client/static`,
}
}
};
return deepmerge(config, applicationConfig);
};
// export testable function
module.exports.isObject = isObject;