Fixed install script (bis)

This commit is contained in:
Clément GOUIN
2019-06-19 13:44:02 +02:00
parent 7bfdbbf511
commit b8d88eb00c
8 changed files with 208 additions and 233 deletions
+1
View File
@@ -1,4 +1,5 @@
/.idea
/node_modules
/config.json
/config.example.json
/data
+1 -1
View File
@@ -57,7 +57,7 @@ then edit the config.json file with your values :
**3. Start your server**
```bash
npm start
npm run
#or
node src/server.js
```
+183 -208
View File
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -1,4 +1,5 @@
{
"nodePort": 5000,
"name": "gitblog.md",
"version": "1.0.0",
"description": "A static blog using Markdown pulled from your git repository.",
@@ -7,6 +8,7 @@
"express": "^4.17.1",
"ncp": "^2.0.0",
"showdown": "^1.9.0",
"shx": "^0.3.2",
"xml": "^1.0.1"
},
"devDependencies": {
@@ -17,8 +19,9 @@
"supertest": "^4.0.2"
},
"scripts": {
"start": "node src/server.js",
"test": "jest",
"install": "node src/postinstall.js"
"install": "shx mkdir -p ./data/$(date +%Y)/$(date +%m)/$(date +%d)/ && shx cp -rf ./sample_data/* ./data/$(date +%Y)/$(date +%m)/$(date +%d) && shx cp -f ./src/default_config.json ./config.example.json"
},
"repository": {
"type": "git",
+16
View File
@@ -0,0 +1,16 @@
const refConfig = require('./default_config.json');
const srcConfig = require('../config.json');
const merge = function (ref, src) {
if (typeof ref !== typeof src) {
return ref;
} else if (typeof ref === 'object') {
const out = {};
Object.keys(ref).forEach(key => out[key] = merge(ref[key], src[key]));
return out;
} else {
return src;
}
};
module.exports = merge(refConfig, srcConfig);
-18
View File
@@ -1,18 +0,0 @@
const fs = require('fs');
const ncp = require('ncp').ncp;
const pad0 = n => ('0'+n).substr(-2);
const datetime = new Date();
const dir = `./data/${datetime.getFullYear()}/${pad0(datetime.getMonth())}/${pad0(datetime.getDay())}/`;
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, {recursive: true});
}
ncp('./sample_data/',dir, function(err){
if(err)
console.error(err);
else
console.log(`sample data copied to ${dir}`);
});
+3 -5
View File
@@ -1,9 +1,7 @@
const config = require('../config.json');
const config = require('./config');
const app = require('./app')(config);
const port = config.nodePort|3000;
app.listen(config.nodePort|3000, () => {
console.log(`gitblog.md server listening on port ${port}`);
app.listen(config.nodePort, () => {
console.log(`gitblog.md server listening on port ${config.nodePort}`);
});