Skip to content

Commit

Permalink
Merge pull request #105 from mediumroast/v0.6.0_interaction_repository
Browse files Browse the repository at this point in the history
Changed to use azure hosted services for company_dns, etc.
  • Loading branch information
miha42-github authored Apr 17, 2024
2 parents a8e5cf4 + 9b8b549 commit cbeb708
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cli/mrcli-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function parseCLIArgs(name, version, description) {
function getEnv () {
return {
DEFAULT: {
company_dns: "https://www.mediumroast.io/company_dns",
company_logos: "https://logo-server.mediumroast.io:7000/allicons.json?url=",
company_dns: "https://company-dns.mediumroast.io",
company_logos: "https://icon-server.mediumroast.io/allicons.json?url=",
echarts: "https://chart-server.mediumroast.io:11000",
nominatim: 'https://nominatim.openstreetmap.org/search?addressdetails=1&q=',
working_directory: "working",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mediumroast_js",
"version": "0.6.0",
"version": "0.6.1",
"description": "A Command Line Interface (CLI) and Javascript SDK to interact with mediumroast.io.",
"main": "cli/mrcli.js",
"scripts": {
Expand Down
14 changes: 9 additions & 5 deletions src/cli/companyWizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* A class used to build CLIs for accessing and reporting on mediumroast.io objects
* @author Michael Hay <michael.hay@mediumroast.io>
* @file companyCLIwizard.js
* @copyright 2023 Mediumroast, Inc. All rights reserved.
* @copyright 2024 Mediumroast, Inc. All rights reserved.
* @license Apache-2.0
* @version 1.1.0
*/
Expand Down Expand Up @@ -131,7 +131,7 @@ class AddCompany {

async getLogo (companyWebsite) {
try {
const response = await axios.get(`https://logo-server.mediumroast.io:7000/allicons.json?url=${companyWebsite}`)
const response = await axios.get(`${this.env.companyLogos}${companyWebsite}`)
const myLogos = response.data
return myLogos.icons[0].url
} catch (err) {
Expand All @@ -140,7 +140,7 @@ class AddCompany {
}

async getLatLong(address) {
const response = await axios.get(`https://nominatim.openstreetmap.org/search?q=${address}&format=json`)
const response = await axios.get(`${this.env.nominatim}${address}&format=json`)
if (response.data && response.data[0]) {
return [true, {status_code: 200, status_msg: `found coordinates for ${address}`}, [parseFloat(response.data[0].lat), parseFloat(response.data[0].lon)]]
} else {
Expand Down Expand Up @@ -334,7 +334,7 @@ class AddCompany {
prototype.company_type.value = prototype.company_type.value

// If prototype.company_type.value has text after "Public" then set it to "Public"
if (prototype.company_type.value.search(/Public/g)) {
if (prototype.company_type.value.search(/Public/g ) !== -1) {
prototype.company_type.value = "Public"
}

Expand Down Expand Up @@ -824,14 +824,18 @@ class AddCompany {
// Logo
myCompany.logo_url = this.defaultValue
if (myCompany.url !== 'Unknown') {
const spinner = ora(chalk.bold.blue(`Fetching the logo url for [${myCompany.name}]...`))
spinner.start() // Start the spinner
const logo_url = await this.getLogo(myCompany.url)
// console.log(chalk.blue.bold(`Setting the company logo to [${logo_url}]`))
logo_url ? myCompany.logo_url = logo_url : myCompany.logo_url = this.defaultValue
spinner.stop() // Stop the spinner
}
console.log(chalk.green('Finished company definition.'))

// Either return the company object or create it
if (createObj) {
const spinner = ora(chalk.bold.blue(`Saving ${myCompany.name} to GitHub ... `))
const spinner = ora(chalk.bold.blue(`Saving [${myCompany.name}] to GitHub...`))
spinner.start() // Start the spinner
const myCompanyResp = await this.apiController.createObj([myCompany])
spinner.stop() // Stop the spinner
Expand Down

0 comments on commit cbeb708

Please sign in to comment.