Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static dump(text: string, config?: Configuration, language?: string): void {
if (config && language && config.get('highlight')) {
text = highlight(text, { language, ignoreIllegals: true, theme: config.getHighlightTheme() });
}
// tslint:disable-next-line:no-console
console.log(text);
}
'Content-type': 'application/json-patch+json',
},
body: JSON.stringify(OPERATIONS),
throwHttpErrors: false,
}
);
if (200 === UPDATE_RESPONSE.statusCode) {
spinner.text = `Work item ${ID} updated`;
} else {
// failed
spinner.fail(`Unexpected response for work item ${ID}: [${UPDATE_RESPONSE.statusCode}] '${UPDATE_RESPONSE.statusMessage}'
${
cliHighlight.highlight(
JSON.stringify(
JSON.parse(UPDATE_RESPONSE.body), null, 2
),
{
"language": "javascript"
}
)
}`);
}
} else {
spinner.text = `Work item ${ID} updated`;
}
}
} else {
spinner.warn(`Empty result for work item ${ID}!`);
}
public async showHelp(): Promise {
writeLine(`Examples: ego job my-job.js "0 * * * * *"`);
writeLine(` ego job my-job "* */15 * * * *"`);
writeLine();
writeLine(`Relative paths will be mapped to the current working directory or the '.ego' subfolder inside the user's home directory.`);
writeLine();
writeLine(`It is also possible to run shell scripts (with .sh or .cmd extension).`);
writeLine();
writeLine();
writeLine(`Example script:`);
writeLine(
cliHighlight.highlight(
`
exports.execute = async (context) => {
// context => s. https://egodigital.github.io/ego-cli/interfaces/_contracts_.commandexecutecontext.html
// context.args => List of command line arguments, s. https://www.npmjs.com/package/minimist
// context.cwd => The full path of the current working directory
// context.getFullPath() => Returns the full version of a path, based on the value of 'cwd'
// context.package => The 'package.json' file of the e.GO CLI
// context.queue => A queue, that only executes 1 action at the same time, s. https://www.npmjs.com/package/p-queue
// context.require() => Allows to include a NPM module of the e.GO CLI
// context.values => A key/value pair storage, that is available while the execution
// context.verbose => Indicates, if script should output additional information or not
// docker utils, s. https://egodigital.github.io/ego-cli/modules/_docker_.html
const docker = context.require('./docker');
// git utils, s. https://egodigital.github.io/ego-cli/modules/_git_.html
filter: Number,
default: 2592000,
validate(value) {
try {
ow(value, ow.number.greaterThanOrEqual(0).lessThanOrEqual(3153600000));
return true;
} catch (e) {
return e.message;
}
},
}]);
const config = createConfigYaml({ stage, ...inputs });
console.log("Generated configuration file contents: \n");
console.log(highlight(config, { language: "yaml" }));
const { hasConfirmed } = await inquirer.prompt<{ hasConfirmed: boolean; }>([{
type: "confirm",
name: "hasConfirmed",
message: "Does it looks good?",
default: true,
}]);
if (!hasConfirmed) {
console.log("\nAborted.");
return;
}
await new Promise(((resolve, reject) => {
fs.writeFile(CONFIG_FILE_PATH, config, (e) => {
if (e) { return reject(e); }
constructor(options: Options, validate = true) {
this.options = Utils.merge({}, Configuration.DEFAULTS, options);
this.options.baseDir = Utils.absolutePath(this.options.baseDir);
if (validate) {
this.validateOptions();
}
this.logger = new Logger(this.options.logger, this.options.debug);
this.driver = this.initDriver();
this.platform = this.driver.getPlatform();
this.highlightTheme = fromJson(this.options.highlightTheme!);
this.init();
}
static highlightJson(json: string) {
return highlight(json, { language: "json" });
}
const printLog = data => highlight(decoder.write(data), {language : 'accesslog'}).replace(/<span class="\"hljs-string\"">/g, '').replace(/<\/span>/g, '');
const printSQL = data => highlight(decoder.write(data), {language : 'sql'});</span>
function formatSinglePassClosureCompilerError(message) {
const singlePassJavaInvocationLine = /java -jar[^]*--js_module_root .*?\n/;
message = message.replace(singlePassJavaInvocationLine, '');
message = highlight(message, {ignoreIllegals: true});
message = message.replace(/WARNING/g, colors.yellow('WARNING'));
message = message.replace(/ERROR/g, colors.red('ERROR'));
return message;
}
if (isPretty) {
return pass({
start,
end: new Date(),
test: { path: testPath }
});
}
const formatted = prettier.format(contents, prettierConfig);
return fail({
start,
end: new Date(),
test: {
path: testPath,
errorMessage: diff(highlight(formatted), highlight(contents), {
expand: false
})
}
});
});
};
function formatClosureCompilerError(message) {
const closurePluginLoggingPrefix = /^.*?gulp-google-closure-compiler.*?: /;
message = message.replace(closurePluginLoggingPrefix, '');
message = highlight(message, {ignoreIllegals: true});
message = message.replace(/WARNING/g, colors.yellow('WARNING'));
message = message.replace(/ERROR/g, colors.red('ERROR'));
return message;
}