-
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.
- Loading branch information
Showing
17 changed files
with
1,396 additions
and
142 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
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,6 @@ | ||
import { getBrandEnvironment } from '../src/constants/australia'; | ||
import { exportCfb } from './export_cfb'; | ||
|
||
exportCfb('hacksore/hks:native-au', 'australia.cfb.ts', getBrandEnvironment).catch(e => | ||
console.error(e) | ||
); |
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,76 @@ | ||
/* eslint-disable no-console */ | ||
import { execSync, spawn } from 'child_process'; | ||
import { writeFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
import { AustraliaBrandEnvironment } from '../src/constants/australia'; | ||
import { EuropeanBrandEnvironment } from '../src/constants/europe'; | ||
import { Brand } from '../src/interfaces/common.interfaces'; | ||
|
||
const brands: Brand[] = ['kia', 'hyundai']; | ||
|
||
export const exportCfb = async ( | ||
dockerImage: string, | ||
outputFilename: string, | ||
getBrandEnvironment: (config: { | ||
brand: Brand; | ||
}) => EuropeanBrandEnvironment | AustraliaBrandEnvironment | ||
) => { | ||
console.debug(`Pulling image ${dockerImage}`); | ||
// execSync(`docker pull ${dockerImage}`); | ||
const brandCFB = { | ||
kia: '', | ||
hyundai: '', | ||
}; | ||
for (const brand of brands) { | ||
try { | ||
const { appId } = getBrandEnvironment({ brand }); | ||
|
||
const [first] = await new Promise<string[]>((resolve, reject) => { | ||
console.debug(`Starting image ${dockerImage} - ${brand}`); | ||
const process = spawn('docker', [ | ||
'run', | ||
'--rm', | ||
dockerImage, | ||
brand, | ||
'dumpCFB', | ||
`${appId}:${Date.now()}`, | ||
]); | ||
const list: Array<string> = []; | ||
let errors = ''; | ||
|
||
process.stdout.on('data', data => { | ||
const chunk: Array<string> = 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 => { | ||
console.debug(`Done with ${dockerImage} - ${brand}`); | ||
if (code === 0) { | ||
return resolve(list); | ||
} | ||
reject(errors); | ||
}); | ||
}); | ||
brandCFB[brand] = first; | ||
} catch (e) { | ||
// Skip any unsupported brands in regions | ||
continue; | ||
} | ||
} | ||
|
||
const cfbFile = `// Auto generated file on ${new Date().toISOString()} | ||
// run \`npm run eu:export:cfb\` or \`npm run au:export:cfb\` respectively to update it | ||
${brandCFB.kia.length > 0 ? `export const kiaCFB = Buffer.from('${brandCFB.kia}', 'base64');` : ''} | ||
export const hyundaiCFB = Buffer.from('${brandCFB.hyundai}', 'base64');`; | ||
|
||
writeFileSync(join(__dirname, '..', 'src', 'constants', outputFilename), cfbFile); | ||
}; |
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 |
---|---|---|
@@ -1,66 +1,4 @@ | ||
/* eslint-disable no-console */ | ||
import { execSync, spawn } from 'child_process'; | ||
import { writeFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
import { getBrandEnvironment } from '../src/constants/europe'; | ||
import { Brand } from '../src/interfaces/common.interfaces'; | ||
import { exportCfb } from './export_cfb'; | ||
|
||
const brands: Brand[] = ['kia', 'hyundai']; | ||
|
||
const main = async () => { | ||
console.debug(`Pulling image hacksore/hks:native`); | ||
execSync('docker pull hacksore/hks:native'); | ||
const brandCFB = { | ||
kia: '', | ||
hyundai: '', | ||
}; | ||
for (const brand of brands) { | ||
const { appId } = getBrandEnvironment({ brand }); | ||
|
||
const [first] = await new Promise<string[]>((resolve, reject) => { | ||
console.debug(`Starting image hacksore/hks:native - ${brand}`); | ||
const process = spawn('docker', [ | ||
'run', | ||
'--rm', | ||
'hacksore/hks:native', | ||
brand, | ||
'dumpCFB', | ||
`${appId}:${Date.now()}`, | ||
]); | ||
const list: Array<string> = []; | ||
let errors = ''; | ||
|
||
process.stdout.on('data', data => { | ||
const chunk: Array<string> = 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 => { | ||
console.debug(`Done with hacksore/hks:native - ${brand}`); | ||
if (code === 0) { | ||
return resolve(list); | ||
} | ||
reject(errors); | ||
}); | ||
}); | ||
brandCFB[brand] = first; | ||
} | ||
|
||
const cfbFile = `// Auto generated file on ${new Date().toISOString()} | ||
// run \`npm run eu:export:cfb\` to update it | ||
export const kiaCFB = Buffer.from('${brandCFB.kia}', 'base64'); | ||
export const hyundaiCFB = Buffer.from('${brandCFB.hyundai}', 'base64');`; | ||
|
||
writeFileSync(join(__dirname, '..', 'src', 'constants', 'europe.cfb.ts'), cfbFile); | ||
}; | ||
|
||
main().catch(e => console.error(e)); | ||
exportCfb('hacksore/hks:native', 'europe.cfb.ts', getBrandEnvironment).catch(e => console.error(e)); |
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,11 @@ | ||
// Auto generated file on 2023-07-29T15:08:36.193Z | ||
// run `npm run eu:export:cfb` or `npm run au:export:cfb` respectively to update it | ||
|
||
export const hyundaiCFB = Buffer.from( | ||
'V60WkEmyRQaAfrBF1623/7QL62MjLVbCHdItGzQ1g5T/hkmKmMVTaMHv4cKGzgD3gL8=', | ||
'base64' | ||
); | ||
export const kiaCFB = Buffer.from( | ||
'IDbMgWBXgic4MAyMgf5PFFRAdGX5O3IyC3uvN3scCs0gDpTFDuyvBorlAH9JMM2/wMc=', | ||
'base64' | ||
); |
Oops, something went wrong.