Skip to content

Instantly share code, notes, and snippets.

@huang-xiao-jian
Created June 26, 2018 02:52
Show Gist options
  • Save huang-xiao-jian/5663696ac4071da706f8eb9030cbb4c0 to your computer and use it in GitHub Desktop.
Save huang-xiao-jian/5663696ac4071da706f8eb9030cbb4c0 to your computer and use it in GitHub Desktop.
#!/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