-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/water-fountains/datablue/issues/47
- Loading branch information
Showing
8 changed files
with
11,874 additions
and
14,455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Create or update fountain_properties JSON file ('src/assets/fountain_properties.json'). | ||
// Command: 'npm run fountain_properties' | ||
|
||
const writeFileSync = require('fs').writeFileSync; | ||
const axios = require('axios'); | ||
const util = require('util'); | ||
const exec = util.promisify(require('child_process').exec); | ||
|
||
// API URL. | ||
const apiUrlBeta = 'https://api.beta.water-fountains.org/'; | ||
const apiUrlStable = 'https://api.water-fountains.org/'; | ||
const apiUrlLocal = 'http://localhost:3000/'; // use in development. | ||
|
||
// create fountain_properties.JSON | ||
async function createFountainProperties(filename) { | ||
|
||
// use travis branch environment variable if available, because in Travis the git branch is called HEAD by default | ||
const branch = process.env.TRAVIS_BRANCH || (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim(); | ||
|
||
const apiUrl = (branch === 'stable') ? apiUrlStable : apiUrlBeta; | ||
|
||
let metadataUrl = `${apiUrl}api/v1/metadata/fountain_properties`; | ||
|
||
// Get fountain_properties data from server and create file. | ||
axios.get(metadataUrl) | ||
.then(function (response) { | ||
// handle success | ||
const locations = JSON.stringify(response.data, null, 4); | ||
|
||
writeFileSync(filename, locations, {encoding: 'utf8'}); | ||
}) | ||
.catch(function (error) { | ||
// handle error | ||
console.log(error); | ||
}); | ||
|
||
} | ||
|
||
// File save path. | ||
createFountainProperties('src/assets/fountain_properties.json'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Create or update location JSON file ('src/assets/locations.json'). | ||
// Command: 'npm run location' | ||
|
||
const writeFileSync = require('fs').writeFileSync; | ||
const axios = require('axios'); | ||
const util = require('util'); | ||
const exec = util.promisify(require('child_process').exec); | ||
|
||
// API URL. | ||
const apiUrlBeta = 'https://api.beta.water-fountains.org/'; | ||
const apiUrlStable = 'https://api.water-fountains.org/'; | ||
const apiUrlLocal = 'http://localhost:3000/'; // use in development. | ||
|
||
// create location.JSON | ||
async function createLocationFile(filename) { | ||
|
||
// use travis branch environment variable if available, because in Travis the git branch is called HEAD by default | ||
const branch = process.env.TRAVIS_BRANCH || (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim(); | ||
|
||
const apiUrl = (branch === 'stable') ? apiUrlStable : apiUrlBeta; | ||
|
||
let metadataUrl = `${apiUrl}api/v1/metadata/locations`; | ||
|
||
// Get location data from server and create file. | ||
axios.get(metadataUrl) | ||
.then(function (response) { | ||
// handle success | ||
const locations = JSON.stringify(response.data, null, 4); | ||
|
||
writeFileSync(filename, locations, {encoding: 'utf8'}); | ||
}) | ||
.catch(function (error) { | ||
// handle error | ||
console.log(error); | ||
}); | ||
|
||
} | ||
|
||
// File save path. | ||
createLocationFile('src/assets/locations.json'); |
Oops, something went wrong.