UNPKG

@navikt/aksel

Version:

Aksel command line interface. Handles css-imports, codemods and more

41 lines (40 loc) 1.71 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateMigration = validateMigration; exports.validateGit = validateGit; const chalk_1 = __importDefault(require("chalk")); const is_git_clean_1 = __importDefault(require("is-git-clean")); const migrations_js_1 = require("./migrations.js"); function validateMigration(str, program) { if (!(0, migrations_js_1.getMigrationNames)().includes(str)) { program.error(chalk_1.default.red(`Migration <${str}> not found!\n${chalk_1.default.gray(`\nAvailable migrations:\n${(0, migrations_js_1.getMigrationString)()}`)}`)); } const path = (0, migrations_js_1.getMigrationPath)(str); if (!path) { program.error(chalk_1.default.red(`Code for migration <${str}> not found!\n${chalk_1.default.gray(`\nContact creator (Aksel) to get it fixed!\n`)}`)); } } function validateGit(options, program) { if (options.dryRun) { return; } if (options.force) { console.info(chalk_1.default.yellow("Forcing migration without git check")); return; } let clean = false; try { clean = is_git_clean_1.default.sync(process.cwd()); } catch (err) { if ((err === null || err === void 0 ? void 0 : err.stderr) && err.stderr.indexOf("Not a git repository") >= 0) { clean = true; } } if (!clean) { program.error(`${chalk_1.default.yellow("\nBefore we continue, please stash or commit your git changes.")}${"\nYou can use the --force flag to override this safety check."}`); } }