Created
June 26, 2018 02:52
-
-
Save huang-xiao-jian/5663696ac4071da706f8eb9030cbb4c0 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env node | |
const path = require('path'); | |
const fs = require('fs'); | |
const fse = require('fs-extra'); | |
const program = require('commander'); | |
const glob = require('glob'); | |
// internal | |
const welcome = require('../lib/welcome'); | |
const { version } = require('../package.json'); | |
// scope | |
const basedir = process.cwd(); | |
const outDir = path.resolve(basedir, 'ansible'); | |
const pattern = '*.jar'; | |
program | |
.version(version) | |
.usage('[options]') | |
.option('-c, --config <file>', 'declare athena make config file') | |
.parse(process.argv); | |
// welcome(); | |
const projects = [ | |
'api-authorize', | |
'api-platform-data', | |
'api-platform-monitor', | |
'service-config', | |
'service-discover', | |
'service-push', | |
'service-consumer', | |
]; | |
const matches = projects.map((project) => { | |
const context = path.resolve(basedir, project, 'target'); | |
const [jar] = glob.sync(pattern, { cwd: context }); | |
const source = path.resolve(context, jar); | |
const destiny = path.resolve(outDir, jar); | |
return { | |
project, | |
source, | |
destiny, | |
}; | |
}); | |
const mappings = matches.reduce( | |
(acc, match) => ({ | |
...acc, | |
[match.project]: match.destiny, | |
}), | |
{} | |
); | |
// output dictionary | |
fs.writeFileSync( | |
path.resolve(outDir, 'manifest.json'), | |
JSON.stringify(mappings, null, 2) | |
); | |
// copy jars | |
matches.forEach(({ source, destiny }) => fse.copy(source, destiny)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment