"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("@oclif/command");
const semver_1 = require("semver");
const util_1 = require("../lib/util");
const exit_code_1 = require("../lib/exit-code");
class CheckVersionCommand extends command_1.Command {
    async run() {
        const { args } = this.parse(CheckVersionCommand);
        // if (!valid(args.expected)) {
        //     return this.error(new Error(`Invalid version format: ${args.expected}. It must be a valid semantic version.`));
        // }
        const { version, name } = util_1.getPackageInfo();
        if (!semver_1.satisfies(version, args.expected)) {
            this.warn(`Your current cli version ${version} does not match expected version ${args.expected}`);
            this.warn(`Please, update your cli version by running command: `);
            this.warn(`npm install --global ${name}@${args.expected}`);
            this.exit(exit_code_1.CliExitCode.INVALID_VERSION_CHECK);
        }
        else {
            this.log('CLI version matches!');
        }
    }
}
exports.default = CheckVersionCommand;
CheckVersionCommand.description = 'Check CLI version';
// static flags: flags.Input<any> = {
// };
CheckVersionCommand.args = [
    {
        name: 'expected',
        required: true,
        description: 'Expected cli version. For example ^1.0.0 for version >= 1.0.0.'
    }
];
//# sourceMappingURL=check-version.js.map