UNPKG

projex

Version:
34 lines (33 loc) 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SetupConventionalUtil = void 0; const _shared_1 = require("../../../../../shared/index"); class SetupConventionalUtil { filesUtils; constructor() { this.filesUtils = new _shared_1.FilesUtils(); } /* The `setupConventional` function is responsible for setting up Husky, Commitlint and CHANGELOG.md in a given project directory. Here's a breakdown of what it does: */ async setupConventional(root) { // install husky await (0, _shared_1.runCommand)('npm install husky -D', root, 'install husky package'); // configure husky prepare await (0, _shared_1.runCommand)('npm pkg set scripts.prepare="npx husky"', root, 'husky prepare script added in the package.json'); // run husky prepare await (0, _shared_1.runCommand)('npm run prepare', root, 'run prepare script'); // install commitlint await (0, _shared_1.runCommand)('npm install @commitlint/cli @commitlint/config-conventional -D -W', root, 'commitlint installation complete'); // delete .husky/commit-msg await (0, _shared_1.runCommand)('rm -rf .husky/commit-msg', root, 'commit-msg deleted'); // delete commitlint.config.js await (0, _shared_1.runCommand)('rm -rf ./commitlint.config.js', root, 'commitlint.config.js deleted'); // create commitlint.config.js await this.filesUtils.createFile(root + '/commitlint.config.js', _shared_1.COMMIT_LINT_SETTINGS_CODE); // create .husky/commit-msg await this.filesUtils.createFile(root + '/.husky/commit-msg', _shared_1.HUSKY_COMMIT_MESSAGE_CODE); // add husky hook for prepare-commit-msg await (0, _shared_1.runCommand)('chmod ug+x .husky/*', root, 'husky hooks permissions set'); } } exports.SetupConventionalUtil = SetupConventionalUtil;