Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit bbf66d5

Browse files
committed
refactor(config): use jq-tool for diff env
1 parent 230d266 commit bbf66d5

9 files changed

+50
-92
lines changed

Makefile

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
include Makefile.include.mk
22

3+
json_cli:
4+
chmod 755 $(JSON_CLI)
5+
36
help:
47
$(call serve.help)
58
$(call gen.help)
@@ -19,19 +22,20 @@ dep:
1922
npm install # for commitizen
2023

2124
# shortcut for serve.local
22-
dev:
23-
cp config/config.local.json config/config.json
25+
dev: json_cli
26+
$(JSON_CLI) -s '.[0] * .[1]' config/config.json config/config.local.json > /tmp/config.json
27+
cp /tmp/config.json ./config/config.json
2428
npm run local
2529

2630
build:
2731
npm build
2832

2933
build.dev:
30-
cp config/config.dev.json config/config.json
34+
$(JSON_CLI) -s '.[0] * .[1]' config/config.json config/config.dev.json > /config.json
3135
npm run build.dev
3236

3337
build.prod:
34-
cp config/config.prod.json config/config.json
38+
$(JSON_CLI) -s '.[0] * .[1]' config/config.json config/config.prod.json > /config.json
3539
npm run build.prod
3640

3741
serve.help:

Makefile.include.mk

+3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ GITHUB_APP_LINK = "https://github.com/settings/applications/689577"
2727

2828
ifeq ($(OS),Darwin) # Mac OS X
2929
BROWSER_TOOL = open
30+
JSON_CLI=./utils/bin/jq-mac
3031
endif
3132
ifeq ($(OS),Linux)
3233
BROWSER_TOOL = google-chrome
34+
JSON_CLI=./utils/bin/jq-linux
3335
endif
3436
ifeq ($(OS),Windows)
3537
BROWSER_TOOL = explorer
38+
JSON_CLI=./utils/bin/jq-win
3639
endif
3740

3841
define browse

config/config.ci.json

+2-20
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
{
2-
"// endpoint configs //": "--------------------------------",
3-
"ASSETS_ENDPOINT": "https://cps-oss.oss-cn-shanghai.aliyuncs.com",
4-
"GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql",
5-
6-
"// general configs //": "--------------------------------",
7-
"DEFAULT_THEME": "cyan",
8-
"SENIOR_AMOUNT_THRESHOLD": 51.2,
9-
"SPONSOR_AMOUNT_THRESHOLD": 3999,
10-
"PAGE_SIZE": {
11-
"S": 10,
12-
"D": 20,
13-
"M": 30,
14-
"L": 40
15-
},
16-
17-
"// contact configs //": "--------------------------------",
18-
"EMAIL_CLUB": "club@group.coderplanets.com",
19-
"EMAIL_SUPPORT": "support@group.coderplanets.com",
20-
"EMAIL_HELLO": "hello@group.coderplanets.com",
21-
"EMAIL_BUSINESS": "business@group.coderplanets.com"
2+
"//--- endpoint configs ---//": "",
3+
"GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql"
224
}

config/config.dev.json

+2-20
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
{
2-
"// endpoint configs //": "--------------------------------",
3-
"ASSETS_ENDPOINT": "https://cps-oss.oss-cn-shanghai.aliyuncs.com",
4-
"GRAPHQL_ENDPOINT": "https://devapi.coderplanets.com/graphiql",
5-
6-
"// general configs //": "--------------------------------",
7-
"DEFAULT_THEME": "cyan",
8-
"SENIOR_AMOUNT_THRESHOLD": 51.2,
9-
"SPONSOR_AMOUNT_THRESHOLD": 3999,
10-
"PAGE_SIZE": {
11-
"S": 10,
12-
"D": 20,
13-
"M": 30,
14-
"L": 40
15-
},
16-
17-
"// contact configs //": "--------------------------------",
18-
"EMAIL_CLUB": "club@group.coderplanets.com",
19-
"EMAIL_SUPPORT": "support@group.coderplanets.com",
20-
"EMAIL_HELLO": "hello@group.coderplanets.com",
21-
"EMAIL_BUSINESS": "business@group.coderplanets.com"
2+
"//--- endpoint configs ---//": "",
3+
"GRAPHQL_ENDPOINT": "https://devapi.coderplanets.com/graphiql"
224
}

config/config.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
2-
"// endpoint configs //": "--------------------------------",
2+
"//--- endpoint configs ---//": "",
33
"ASSETS_ENDPOINT": "https://cps-oss.oss-cn-shanghai.aliyuncs.com",
44
"GRAPHQL_ENDPOINT": "https://api.coderplanets.com/graphiql",
5-
"//GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql",
6-
7-
"// general configs //": "--------------------------------",
5+
"//--- general configs ---//": "",
86
"DEFAULT_THEME": "cyan",
97
"SENIOR_AMOUNT_THRESHOLD": 51.2,
108
"SPONSOR_AMOUNT_THRESHOLD": 3999,
@@ -14,10 +12,10 @@
1412
"M": 30,
1513
"L": 40
1614
},
17-
18-
"// contact configs //": "--------------------------------",
15+
"//--- contact configs ---//": "",
1916
"EMAIL_CLUB": "club@group.coderplanets.com",
2017
"EMAIL_SUPPORT": "support@group.coderplanets.com",
2118
"EMAIL_HELLO": "hello@group.coderplanets.com",
22-
"EMAIL_BUSINESS": "business@group.coderplanets.com"
19+
"EMAIL_BUSINESS": "business@group.coderplanets.com",
20+
"// GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql"
2321
}

config/config.local.json

+2-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,4 @@
11
{
2-
"// endpoint configs //": "--------------------------------",
3-
"ASSETS_ENDPOINT": "https://cps-oss.oss-cn-shanghai.aliyuncs.com",
4-
"GRAPHQL_ENDPOINT": "https://api.coderplanets.com/graphiql",
5-
"//GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql",
6-
7-
"// general configs //": "--------------------------------",
8-
"DEFAULT_THEME": "cyan",
9-
"SENIOR_AMOUNT_THRESHOLD": 51.2,
10-
"SPONSOR_AMOUNT_THRESHOLD": 3999,
11-
"PAGE_SIZE": {
12-
"S": 10,
13-
"D": 20,
14-
"M": 30,
15-
"L": 40
16-
},
17-
18-
"// contact configs //": "--------------------------------",
19-
"EMAIL_CLUB": "club@group.coderplanets.com",
20-
"EMAIL_SUPPORT": "support@group.coderplanets.com",
21-
"EMAIL_HELLO": "hello@group.coderplanets.com",
22-
"EMAIL_BUSINESS": "business@group.coderplanets.com"
2+
"//--- endpoint configs ---//": "",
3+
"// GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql"
234
}

config/config.prod.json

+2-20
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
{
2-
"// endpoint configs //": "--------------------------------",
3-
"ASSETS_ENDPOINT": "https://cps-oss.oss-cn-shanghai.aliyuncs.com",
4-
"GRAPHQL_ENDPOINT": "https://api.coderplanets.com/graphiql",
5-
6-
"// general configs //": "--------------------------------",
7-
"DEFAULT_THEME": "cyan",
8-
"SENIOR_AMOUNT_THRESHOLD": 51.2,
9-
"SPONSOR_AMOUNT_THRESHOLD": 3999,
10-
"PAGE_SIZE": {
11-
"S": 10,
12-
"D": 20,
13-
"M": 30,
14-
"L": 40
15-
},
16-
17-
"// contact configs //": "--------------------------------",
18-
"EMAIL_CLUB": "club@group.coderplanets.com",
19-
"EMAIL_SUPPORT": "support@group.coderplanets.com",
20-
"EMAIL_HELLO": "hello@group.coderplanets.com",
21-
"EMAIL_BUSINESS": "business@group.coderplanets.com"
2+
"//--- endpoint configs ---//": "",
3+
"GRAPHQL_ENDPOINT": "https://api.coderplanets.com/graphiql"
224
}

config/tmp/1.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"status": "1 status",
3+
"timestamp": 1382461861,
4+
"value": {
5+
"aaa": {
6+
"value3": "v3",
7+
"value4": 4
8+
},
9+
"bbb": {
10+
"value3": "v3"
11+
}
12+
}
13+
}

config/tmp/2.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"status": "2 status",
3+
"timestamp": 1382461861,
4+
"value": {
5+
"ccc": {
6+
"value3": "v3",
7+
"value4": 4
8+
},
9+
"ddd": {
10+
"value3": "v3"
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)