-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from Hacksore/develop
6.0.1
- Loading branch information
Showing
11 changed files
with
2,118 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,5 @@ | ||
import stamps from './european.hyundai.token.collection'; | ||
|
||
export const getStamp = (): string => { | ||
return stamps[Math.floor(Math.random() * stamps.length)]; | ||
}; |
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
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,32 @@ | ||
const { execSync, spawn } = require('child_process'); | ||
|
||
const APP_IDS = { | ||
hyundai: '99cfff84-f4e2-4be8-a5ed-e5b755eb6581', | ||
kia: '693a33fa-c117-43f2-ae3b-61a02d24f417' | ||
}; | ||
|
||
exports.getStamps = async (brand) => { | ||
if (!APP_IDS[brand]) { | ||
throw new Error(`${brand} is not managed.`); | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
execSync('docker pull hacksore/hks'); | ||
const process = spawn('docker', ['run', 'hacksore/hks', brand, 'list', APP_IDS[brand]]); | ||
const list = []; | ||
let errors = ''; | ||
process.stdout.on('data', (data) => { | ||
const chunk = data.toString().split('\n').map(s => s.trim()).filter(s => s != ''); | ||
list.push(...chunk); | ||
}); | ||
process.stderr.on('data', (data) => { | ||
errors += data + '\n'; | ||
}); | ||
process.on('close', (code) => { | ||
if(code === 0) { | ||
return resolve(list); | ||
} | ||
reject(errors); | ||
}); | ||
}); | ||
}; |
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,19 @@ | ||
const { join, resolve } = require('path'); | ||
const { writeFileSync } = require('fs'); | ||
const { getStamps } = require('./european.tools.js'); | ||
|
||
const SIZE = 1000; | ||
|
||
const generateStampsForBrand = async (brand) => { | ||
const stamps = await getStamps(brand); | ||
const array = stamps.slice(1, SIZE + 1); | ||
|
||
writeFileSync( | ||
join(resolve('.'), 'src', 'tools', `european.${brand}.token.collection.ts`), | ||
`/* eslint-disable */ | ||
export default ${JSON.stringify(array, undefined, 4)};` | ||
); | ||
}; | ||
|
||
generateStampsForBrand('hyundai').catch((err) => console.error(err)); | ||
generateStampsForBrand('kia').catch((err) => console.error(err)); |