Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Commit

Permalink
Bug #62, fix missing Google Maps API key - npm run build & `bin/rep…
Browse files Browse the repository at this point in the history
  • Loading branch information
nfreear committed Sep 3, 2018
1 parent b0d5edb commit 2085176
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .env.DIST.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"#": "Used in 'npm run build' & 'bin/replace.js'",

"_GOOGLE_MAP_KEY_": "EDIT ME / manage via, https://cloud.google.com/console/google/maps-apis/overview",
"_GOOGLE_ANALYTICS_ID_": "UA-55775559-1",
"_GOOGLE_GTM_ID_": "GTM-K3DZ53"
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

static/src/index.html

.env.json

app/src/main/webapp/WEB-INF/nquireit.properties
app/src/main/webapp/WEB-INF/nquireit-tests.properties
Expand Down
11 changes: 11 additions & 0 deletions bin/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const INDEX_HTML = path('/../static/src/index.html');
const CONFIG_JS = path('/../static/src/js/app/config.js');
const RAND = getRandomInt(11, 1000);

const PKG = require('./../package.json');
const ENV = require('./../.env.json');

console.warn('Version.json ~ describe, rand:', version.describe, RAND);

replace({
Expand All @@ -31,6 +34,14 @@ replace({
recursive: false
});

replace({
paths: [ INDEX_HTML ],
regex: /\/maps\/api\/js\?key=(_GOOGLE_MAP_KEY_|\w+)/,
replacement: '/maps/api/js?key=%s'.replace(/%s/, ENV._GOOGLE_MAP_KEY_),
count: true,
recursive: false
});

replace({
paths: [ CONFIG_JS ],
regex: /version: ['"][\w_\.\-]+['"],/,
Expand Down
2 changes: 1 addition & 1 deletion static/src/index.DIST.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</div>


<script src="https://maps.googleapis.com/maps/api/js?libraries=visualization&key=AIzaSyA8GJ4Ezsi6IcXfwCrtRMo0HVjAFJdafIA"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=_GOOGLE_MAP_KEY_&libraries=visualization"></script>

<script src="js/dist/libs.min.js?r=_RAND_"></script>
<script src="js/dist/helpers.min.js?r=_RAND_"></script>
Expand Down

0 comments on commit 2085176

Please sign in to comment.