declapract
Version:
A tool to declaratively define best practices, maintainable evolve them, and scalably enforce them.
81 lines • 3.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.invoke = void 0;
const commander_1 = require("commander");
const fs_1 = require("fs");
const path_1 = require("path");
const apply_1 = require("../../contract/sdk/apply");
const compile_1 = require("../../contract/sdk/compile");
const plan_1 = require("../../contract/sdk/plan");
const validate_1 = require("../../contract/sdk/validate");
const getVersion = () => {
const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../../package.json'), 'utf-8'));
return packageJson.version;
};
const invoke = async ({ args }) => {
const program = new commander_1.Command();
program
.name('declapract')
.description('A tool to declaratively define best practices, maintainable evolve them, and scalably enforce them.')
.version(getVersion());
program
.command('plan')
.description('Plan and display what actions need to be taken in order to make a software project adhere to its declared practices.')
.option('-c, --config <path>', 'path to the declapract usage config yml', 'declapract.use.yml')
.option('-p, --practice <name>', 'the name of a specific practice you want to scope checking for')
.option('-f, --file <path>', 'the file path of a specific file you want to scope checking for')
.action(async (options) => {
try {
await (0, plan_1.executePlan)(options);
}
catch (error) {
console.error(error);
process.exit(1);
}
});
program
.command('apply')
.description("Apply fixes to all files which have failed to adhere to any of the project's declared practices and have an automatic fix available.")
.option('-c, --config <path>', 'path to the declapract usage config yml', 'declapract.use.yml')
.option('-p, --practice <name>', 'the name of a specific practice you want to scope checking for')
.option('-f, --file <path>', 'the file path of a specific file you want to scope checking for')
.action(async (options) => {
try {
await (0, apply_1.executeApply)(options);
}
catch (error) {
console.error(error);
process.exit(1);
}
});
program
.command('validate')
.description("Validate the declared practices, use cases, and examples; checks that these declarations are usable and don't contain declaration errors.")
.option('-c, --config <path>', 'path to the declapract declarations config yml', 'declapract.declare.yml')
.action(async (options) => {
try {
await (0, validate_1.executeValidate)(options);
}
catch (error) {
console.error(error);
process.exit(1);
}
});
program
.command('compile')
.description('Compile the declared declarations so that they can be packaged and distributed by npm safely.')
.option('-s, --source-directory <path>', 'the source directory which contains the declarations to compile', 'src')
.option('-d, --distribution-directory <path>', 'the distribution directory to which we will compile the declarations', 'dist')
.action(async (options) => {
try {
await (0, compile_1.executeCompile)(options);
}
catch (error) {
console.error(error);
process.exit(1);
}
});
await program.parseAsync(args, { from: 'user' });
};
exports.invoke = invoke;
//# sourceMappingURL=invoke.js.map