mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
ddd9a786d2
- frappe start command - starts frappejs server - sets up webpack middleware to bundle files - introduce frappe.conf.js for configuration
44 lines
950 B
JavaScript
44 lines
950 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const chalk = require('chalk');
|
|
const deepmerge = require('deepmerge');
|
|
const logger = require('./logger');
|
|
|
|
const frappeConf = 'frappe.conf.js';
|
|
|
|
function getAppDir() {
|
|
let dir = process.cwd();
|
|
|
|
if (fs.existsSync(path.join(dir, frappeConf))) {
|
|
return dir;
|
|
}
|
|
|
|
warn = logger('utils', 'red')
|
|
|
|
warn();
|
|
warn(`Looks like this is not the root of a FrappeJS project`);
|
|
warn(`Please run this command from a folder which contains ${chalk.yellow(frappeConf)} file`);
|
|
warn();
|
|
process.exit(1);
|
|
}
|
|
|
|
function getAppConfig() {
|
|
const defaults = {
|
|
dev: {
|
|
devServerHost: 'localhost',
|
|
devServerPort: 8000
|
|
}
|
|
}
|
|
const appConfig = require(path.resolve(getAppDir(), frappeConf));
|
|
return deepmerge(defaults, appConfig);
|
|
}
|
|
|
|
function resolveAppDir(...args) {
|
|
return path.resolve(getAppDir(), ...args);
|
|
}
|
|
|
|
module.exports = {
|
|
getAppDir,
|
|
getAppConfig,
|
|
resolveAppDir
|
|
} |