mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4733] Create an adf-cli dispatcher to run the docker-publish (#4914)
* Create an adf-cli dispatcher to run the docker-publish * not needed * fix typo comma * Create the adf-cli dist folder that contains -bin -script -package.json Build the dist folder during the ADF CI/CI pipeline
This commit is contained in:
committed by
Eugenio Romano
parent
fadcc19eba
commit
a6e18e6c1b
60
lib/cli/bin/adf-cli
Executable file
60
lib/cli/bin/adf-cli
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env node
|
||||
const minimist = require('minimist');
|
||||
const path = require('path');
|
||||
|
||||
const args = minimist(process.argv.slice(2), {
|
||||
boolean: ['verbose']
|
||||
});
|
||||
const scriptName = args._.shift();
|
||||
const scriptPath = path.join('../scripts', scriptName);
|
||||
|
||||
const cwd = process.cwd();
|
||||
process.chdir(path.join(__dirname, '..'));
|
||||
|
||||
|
||||
// This might get awkward, so we fallback to console if there was an error.
|
||||
let logger = null;
|
||||
try {
|
||||
logger = new (require('@angular-devkit/core').logging.IndentLogger)('root');
|
||||
const { bold, gray, red, yellow, white } = require('@angular-devkit/core').terminal;
|
||||
const filter = require('rxjs/operators').filter;
|
||||
|
||||
logger
|
||||
.pipe(filter(entry => (entry.level !== 'debug' || args.verbose)))
|
||||
.subscribe(entry => {
|
||||
let color = gray;
|
||||
let output = process.stdout;
|
||||
switch (entry.level) {
|
||||
case 'info': color = white; break;
|
||||
case 'warn': color = yellow; break;
|
||||
case 'error': color = red; output = process.stderr; break;
|
||||
case 'fatal': color = x => bold(red(x)); output = process.stderr; break;
|
||||
}
|
||||
|
||||
output.write(color(entry.message) + '\n');
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(`Reverting to manual console logging.\nReason: ${e.message}.`);
|
||||
logger = {
|
||||
debug: console.log.bind(console),
|
||||
info: console.log.bind(console),
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console),
|
||||
fatal: x => { console.error(x); process.exit(100); },
|
||||
createChild: () => logger,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Promise.resolve()
|
||||
.then(() => require(scriptPath).default(args, logger, cwd))
|
||||
.then(exitCode => process.exit(exitCode || 0))
|
||||
.catch(err => {
|
||||
logger.fatal(err && err.stack);
|
||||
process.exit(99);
|
||||
});
|
||||
} catch (err) {
|
||||
logger.fatal(err.stack);
|
||||
process.exit(99);
|
||||
}
|
Reference in New Issue
Block a user