Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a97e26b

Browse files
feat(config): Load server config with mastarm in development
1 parent 6afc856 commit a97e26b

File tree

7 files changed

+36
-54
lines changed

7 files changed

+36
-54
lines changed

client/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var config = JSON.parse(process.env.SETTINGS)
44
config.env = process.env.NODE_ENV
55

66
each(config, function (key, val) {
7-
module.exports[key] = module.exports[key] = function () {
7+
module.exports[key] = function () {
88
return val
99
}
1010
})

client/planner-nav/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
const Remarkable = require('remarkable')
2+
const md = new Remarkable()
3+
14
var config = require('../config')
25
var evnt = require('component-event')
36
var MarkdownModal = require('../markdown-modal')
47
var showWalkThrough = require('../planner-walkthrough')
58
var page = require('page')
69
var view = require('../view')
710

8-
var aboutContent = require('../../configurations/default/about.md')
9-
var termsContent = require('../../configurations/default/terms.md')
11+
var aboutContent = md.render(config.About())
12+
var termsContent = md.render(config.Terms())
1013

1114
/**
1215
* Expose `View`

lib/api.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ app.set('view engine', 'jade')
1414

1515
if (config.env === 'development') {
1616
const build = require('mastarm/lib/build')
17-
const loadConfig = require('mastarm/lib/load-config')
1817
const util = require('mastarm/lib/util')
1918

20-
const config = loadConfig(process.cwd(), 'configurations/example', 'development')
2119
build({
22-
config,
23-
files: util.parseEntries(config.settings.entries),
20+
config: config.rawConfig,
21+
files: util.parseEntries(config.entries),
2422
watch: true
2523
})
2624
.then(() => console.log('JavaScript & CSS built..'))

lib/config.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ const toSlugCase = require('to-slug-case')
33
const env = process.env.NODE_ENV || 'development'
44
const config = module.exports = {env}
55
let json = {
6-
application: '',
7-
environments: {}
6+
application: ''
87
}
8+
99
if (process.env.MODEIFY_CONFIG) {
1010
json = JSON.parse(new Buffer(process.env.MODEIFY_CONFIG, 'base64').toString())
11+
} else { // local development
12+
const argv = require('minimist')(process.argv.slice(2))
13+
const loadConfig = require('mastarm/lib/load-config')
14+
const baseConfig = config.rawConfig = loadConfig(process.cwd(), argv.config, 'development')
15+
// override environment
16+
process.env = Object.assign({}, process.env, baseConfig.env)
17+
json = baseConfig.settings
1118
}
1219

1320
for (const key in json) {

lib/spark.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ const Sparkpost = require('sparkpost')
55

66
const config = require('./config')
77

8-
const spark = new Sparkpost()
8+
let spark = {
9+
transmissions: {
10+
get () {},
11+
send () {}
12+
}
13+
}
14+
15+
if (process.env.SPARKPOST_API_KEY) {
16+
spark = new Sparkpost()
17+
}
18+
919
const templates = {}
1020

1121
module.exports.send = function send (options, callback, template) {

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"mandrill-api": "^1.0.45",
4343
"mapbox": "^1.0.0-beta6",
4444
"mastarm": "^3.2.1",
45+
"minimist": "^1.2.0",
4546
"moment": "^2.13.0",
4647
"moment-timezone": "^0.5.11",
4748
"mongoose": "^4.5.0",
@@ -56,6 +57,7 @@
5657
"otp-profile-score": "^0.6.3",
5758
"polyline": "^0.2.0",
5859
"priorityqueuejs": "^1.0.0",
60+
"remarkable": "^1.7.1",
5961
"ridematcher": "^0.2.0",
6062
"serve-static": "^1.11.1",
6163
"sparkpost": "^1.3.5",
@@ -148,7 +150,7 @@
148150
"lint": "mastarm lint \"client/**/*.js\" \"lib/**/*.js\"",
149151
"push-config": "bin/push-config-to-heroku",
150152
"prestart": "yarn",
151-
"start": "source bin/autoenv && nodemon --watch lib lib/server.js",
153+
"start": "nodemon --watch lib lib/server.js",
152154
"test": "yarn run lint && mastarm test",
153155
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
154156
},

yarn.lock

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,7 +3144,7 @@ errorify@^0.3.1:
31443144
version "0.3.1"
31453145
resolved "https://registry.yarnpkg.com/errorify/-/errorify-0.3.1.tgz#53e0aaeeb18adc3e55f9f1eb4e2d95929f41b79b"
31463146

3147-
es-abstract@^1.4.3, es-abstract@^1.5.0, es-abstract@^1.7.0:
3147+
es-abstract@^1.5.0, es-abstract@^1.7.0:
31483148
version "1.7.0"
31493149
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
31503150
dependencies:
@@ -5598,9 +5598,9 @@ lowercase-keys@^1.0.0:
55985598
version "1.0.0"
55995599
resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.0.tgz#4e3366b39e7f5457e35f1324bdf6f88d0bfc7306"
56005600

5601-
lru-cache@2:
5602-
version "2.7.3"
5603-
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952"
5601+
lru-cache@2, lru-cache@~2.6.5:
5602+
version "2.6.5"
5603+
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.6.5.tgz#e56d6354148ede8d7707b58d143220fd08df0fd5"
56045604

56055605
lru-cache@^4.0.0, lru-cache@^4.0.1:
56065606
version "4.0.2"
@@ -5613,10 +5613,6 @@ lru-cache@~2.5.0:
56135613
version "2.5.2"
56145614
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.5.2.tgz#1fddad938aae1263ce138680be1b3f591c0ab41c"
56155615

5616-
lru-cache@~2.6.5:
5617-
version "2.6.5"
5618-
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.6.5.tgz#e56d6354148ede8d7707b58d143220fd08df0fd5"
5619-
56205616
56215617
version "1.0.11"
56225618
resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.11.tgz#e01a5c9109f2af79660e4e8b9587790184f5a96c"
@@ -6318,18 +6314,6 @@ npm-registry-client@^7.0.1:
63186314
optionalDependencies:
63196315
npmlog "2 || ^3.1.0 || ^4.0.0"
63206316

6321-
npm-run-all@^4.0.1:
6322-
version "4.0.2"
6323-
resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.0.2.tgz#a84669348e6db6ccbe052200b4cdb6bfe034a4fe"
6324-
dependencies:
6325-
chalk "^1.1.3"
6326-
cross-spawn "^5.0.1"
6327-
minimatch "^3.0.2"
6328-
ps-tree "^1.0.1"
6329-
read-pkg "^2.0.0"
6330-
shell-quote "^1.6.1"
6331-
string.prototype.padend "^3.0.0"
6332-
63336317
npm-run-path@^1.0.0:
63346318
version "1.0.0"
63356319
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-1.0.0.tgz#f5c32bf595fe81ae927daec52e82f8b000ac3c8f"
@@ -6735,12 +6719,6 @@ path-type@^1.0.0:
67356719
pify "^2.0.0"
67366720
pinkie-promise "^2.0.0"
67376721

6738-
path-type@^2.0.0:
6739-
version "2.0.0"
6740-
resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73"
6741-
dependencies:
6742-
pify "^2.0.0"
6743-
67446722
67456723
version "0.0.11"
67466724
resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445"
@@ -7413,14 +7391,6 @@ read-pkg@^1.0.0:
74137391
normalize-package-data "^2.3.2"
74147392
path-type "^1.0.0"
74157393

7416-
read-pkg@^2.0.0:
7417-
version "2.0.0"
7418-
resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8"
7419-
dependencies:
7420-
load-json-file "^2.0.0"
7421-
normalize-package-data "^2.3.2"
7422-
path-type "^2.0.0"
7423-
74247394
74257395
version "1.0.7"
74267396
resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4"
@@ -7638,7 +7608,7 @@ regjsparser@^0.1.4:
76387608
dependencies:
76397609
jsesc "~0.5.0"
76407610

7641-
remarkable@^1.6.0:
7611+
remarkable@^1.6.0, remarkable@^1.7.1:
76427612
version "1.7.1"
76437613
resolved "https://registry.yarnpkg.com/remarkable/-/remarkable-1.7.1.tgz#aaca4972100b66a642a63a1021ca4bac1be3bff6"
76447614
dependencies:
@@ -8614,14 +8584,6 @@ string.prototype.codepointat@^0.2.0:
86148584
version "0.2.0"
86158585
resolved "https://registry.yarnpkg.com/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz#6b26e9bd3afcaa7be3b4269b526de1b82000ac78"
86168586

8617-
string.prototype.padend@^3.0.0:
8618-
version "3.0.0"
8619-
resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.0.0.tgz#f3aaef7c1719f170c5eab1c32bf780d96e21f2f0"
8620-
dependencies:
8621-
define-properties "^1.1.2"
8622-
es-abstract "^1.4.3"
8623-
function-bind "^1.0.2"
8624-
86258587
string.prototype.trim@^1.1.2:
86268588
version "1.1.2"
86278589
resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"

0 commit comments

Comments
 (0)