UNPKG

git-semver-tagger

Version:

![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/robertfmurdock/ze-great-tools?label=Release) ![NPM Version](https://img.shields.io/npm/v/git-semver-tagger?label=npm%20git-semver-tagger)

417 lines (415 loc) 16.6 kB
(function (_, childProcess, kotlin_kotlin) { 'use strict'; //region block: imports var imul = Math.imul; var toString = kotlin_kotlin.$_$.t9; var protoOf = kotlin_kotlin.$_$.q9; var getStringHashCode = kotlin_kotlin.$_$.o8; var hashCode = kotlin_kotlin.$_$.p8; var THROW_CCE = kotlin_kotlin.$_$.md; var equals = kotlin_kotlin.$_$.k8; var initMetadataForClass = kotlin_kotlin.$_$.q8; var plus = kotlin_kotlin.$_$.q6; var emptyMap = kotlin_kotlin.$_$.n5; var VOID = kotlin_kotlin.$_$.f; var emptyList = kotlin_kotlin.$_$.m5; var listOf = kotlin_kotlin.$_$.j6; var split = kotlin_kotlin.$_$.xb; var ArrayList_init_$Create$ = kotlin_kotlin.$_$.j; var joinToString = kotlin_kotlin.$_$.y5; var reversed = kotlin_kotlin.$_$.w6; var Companion_getInstance = kotlin_kotlin.$_$.p3; var last = kotlin_kotlin.$_$.f6; var Unit_instance = kotlin_kotlin.$_$.y3; var isBlank = kotlin_kotlin.$_$.jb; var collectionSizeOrDefault = kotlin_kotlin.$_$.w4; var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.i; var charSequenceLength = kotlin_kotlin.$_$.h8; var startsWith = kotlin_kotlin.$_$.yb; var substring = kotlin_kotlin.$_$.dc; var listOf_0 = kotlin_kotlin.$_$.i6; var plus_0 = kotlin_kotlin.$_$.t6; var to = kotlin_kotlin.$_$.ne; var mapOf = kotlin_kotlin.$_$.l6; var firstOrNull = kotlin_kotlin.$_$.p5; var toInt = kotlin_kotlin.$_$.kc; var Companion_instance = kotlin_kotlin.$_$.t3; var isCharSequence = kotlin_kotlin.$_$.a9; var trim = kotlin_kotlin.$_$.vc; var _Result___init__impl__xyqfz8 = kotlin_kotlin.$_$.r1; var createFailure = kotlin_kotlin.$_$.be; var _Result___get_value__impl__bjfvqg = kotlin_kotlin.$_$.v1; var _Result___get_isFailure__impl__jpiriv = kotlin_kotlin.$_$.t1; var getBooleanHashCode = kotlin_kotlin.$_$.l8; var first = kotlin_kotlin.$_$.q5; var copyToArray = kotlin_kotlin.$_$.k5; var json = kotlin_kotlin.$_$.i9; var Exception_init_$Create$ = kotlin_kotlin.$_$.a1; var toList = kotlin_kotlin.$_$.i7; //endregion //region block: pre-declaration initMetadataForClass(CommitRef, 'CommitRef'); initMetadataForClass(GitAdapter, 'GitAdapter'); initMetadataForClass(GitStatus, 'GitStatus'); initMetadataForClass(TagRef, 'TagRef'); //endregion function CommitRef(id, authorEmail, committerEmail, dateTime, parents, fullMessage) { this.e16_1 = id; this.f16_1 = authorEmail; this.g16_1 = committerEmail; this.h16_1 = dateTime; this.i16_1 = parents; this.j16_1 = fullMessage; } protoOf(CommitRef).toString = function () { return 'CommitRef(id=' + this.e16_1 + ', authorEmail=' + this.f16_1 + ', committerEmail=' + this.g16_1 + ', dateTime=' + this.h16_1.toString() + ', parents=' + toString(this.i16_1) + ', fullMessage=' + this.j16_1 + ')'; }; protoOf(CommitRef).hashCode = function () { var result = getStringHashCode(this.e16_1); result = imul(result, 31) + getStringHashCode(this.f16_1) | 0; result = imul(result, 31) + getStringHashCode(this.g16_1) | 0; result = imul(result, 31) + this.h16_1.hashCode() | 0; result = imul(result, 31) + hashCode(this.i16_1) | 0; result = imul(result, 31) + getStringHashCode(this.j16_1) | 0; return result; }; protoOf(CommitRef).equals = function (other) { if (this === other) return true; if (!(other instanceof CommitRef)) return false; var tmp0_other_with_cast = other instanceof CommitRef ? other : THROW_CCE(); if (!(this.e16_1 === tmp0_other_with_cast.e16_1)) return false; if (!(this.f16_1 === tmp0_other_with_cast.f16_1)) return false; if (!(this.g16_1 === tmp0_other_with_cast.g16_1)) return false; if (!this.h16_1.equals(tmp0_other_with_cast.h16_1)) return false; if (!equals(this.i16_1, tmp0_other_with_cast.i16_1)) return false; if (!(this.j16_1 === tmp0_other_with_cast.j16_1)) return false; return true; }; function runProcess($this, args, env) { return runProcess_0(args, $this.k16_1, plus(env, $this.l16_1)); } function runProcess$default($this, args, env, $super) { env = env === VOID ? emptyMap() : env; return runProcess($this, args, env); } function inlineConfig($this, property, value) { return !(value == null) ? listOf(['-c', property + '=' + value]) : emptyList(); } function parseTagRefs($this, outputText) { // Inline function 'kotlin.collections.mapNotNull' call var tmp0 = split(outputText, ['\n']); // Inline function 'kotlin.collections.mapNotNullTo' call var destination = ArrayList_init_$Create$(); // Inline function 'kotlin.collections.forEach' call var _iterator__ex2g4s = tmp0.m(); while (_iterator__ex2g4s.n()) { var element = _iterator__ex2g4s.o(); var commaSplit = split(element, [',']); var tmp; if (commaSplit.p() >= 3) { tmp = new TagRef(joinToString(commaSplit.z1(0, commaSplit.p() - 2 | 0), ''), reversed(commaSplit).q(1), Companion_getInstance().dj(last(commaSplit))); } else { tmp = null; } var tmp0_safe_receiver = tmp; if (tmp0_safe_receiver == null) null; else { // Inline function 'kotlin.let' call destination.e(tmp0_safe_receiver); } } var output = destination; return output; } function parseLog($this, outputText) { // Inline function 'kotlin.collections.filter' call var tmp0 = split(outputText, [$this.m16_1 + '\n']); // Inline function 'kotlin.collections.filterTo' call var destination = ArrayList_init_$Create$(); var _iterator__ex2g4s = tmp0.m(); while (_iterator__ex2g4s.n()) { var element = _iterator__ex2g4s.o(); // Inline function 'kotlin.text.isNotBlank' call if (!isBlank(element)) { destination.e(element); } } // Inline function 'kotlin.collections.map' call // Inline function 'kotlin.collections.mapTo' call var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(destination, 10)); var _iterator__ex2g4s_0 = destination.m(); while (_iterator__ex2g4s_0.n()) { var item = _iterator__ex2g4s_0.o(); var elements = split(item, ['\n']); var tmp = elements.q(0); var tmp_0 = elements.q(1); var tmp_1 = elements.q(2); var tmp_2 = Companion_getInstance().dj(elements.q(3)); // Inline function 'kotlin.collections.filter' call var tmp0_0 = split(elements.q(4), [' ']); // Inline function 'kotlin.collections.filterTo' call var destination_1 = ArrayList_init_$Create$(); var _iterator__ex2g4s_1 = tmp0_0.m(); while (_iterator__ex2g4s_1.n()) { var element_0 = _iterator__ex2g4s_1.o(); // Inline function 'kotlin.text.isNotEmpty' call if (charSequenceLength(element_0) > 0) { destination_1.e(element_0); } } var tmp$ret$8 = new CommitRef(tmp, tmp_0, tmp_1, tmp_2, destination_1, joinToString(elements.z1(5, elements.p()), '\n')); destination_0.e(tmp$ret$8); } return destination_0; } function findByPrefix($this, _this__u8e3s4, prefix) { // Inline function 'kotlin.collections.find' call var tmp$ret$1; $l$block: { // Inline function 'kotlin.collections.firstOrNull' call var _iterator__ex2g4s = _this__u8e3s4.m(); while (_iterator__ex2g4s.n()) { var element = _iterator__ex2g4s.o(); if (startsWith(element, prefix)) { tmp$ret$1 = element; break $l$block; } } tmp$ret$1 = null; } var tmp0_safe_receiver = tmp$ret$1; return tmp0_safe_receiver == null ? null : substring(tmp0_safe_receiver, prefix.length); } function GitAdapter(workingDirectory, env) { env = env === VOID ? emptyMap() : env; this.k16_1 = workingDirectory; this.l16_1 = env; this.m16_1 = '--------!--------'; this.n16_1 = '%H%n%ae%n%ce%n%aI%n%P%n%B%n' + this.m16_1; } protoOf(GitAdapter).o16 = function (name, ref, userName, userEmail) { var tmp = plus_0(plus_0(plus_0(listOf_0('git'), inlineConfig(this, 'user.name', userName)), inlineConfig(this, 'user.email', userEmail)), listOf(['tag', '--annotate', '--message=' + name, name, ref])); var tmp_0 = emptyMap(); var tmp_1; if (!(userName == null)) { tmp_1 = mapOf(to('GIT_COMMITTER_NAME', userName)); } else { tmp_1 = emptyMap(); } var tmp_2 = plus(tmp_0, tmp_1); var tmp_3; if (!(userEmail == null)) { tmp_3 = mapOf(to('GIT_COMMITTER_EMAIL', userEmail)); } else { tmp_3 = emptyMap(); } runProcess(this, tmp, plus(tmp_2, tmp_3)); }; protoOf(GitAdapter).p16 = function () { runProcess$default(this, listOf(['git', 'push', '--tags'])); }; protoOf(GitAdapter).q16 = function (ref) { // Inline function 'kotlin.let' call var p0 = runProcess$default(this, listOf(['git', '--no-pager', 'tag', '--list', '--format=%(refname:strip=2),%(*objectname),%(creatordate:iso-strict)', '--points-at=' + ref])); var tmp$ret$1 = parseTagRefs(this, p0); return firstOrNull(tmp$ret$1); }; protoOf(GitAdapter).r16 = function (begin, end) { return parseLog(this, runProcess$default(this, plus_0(listOf(['git', '--no-pager', 'log', '--format=' + this.n16_1, begin]), !(end == null) ? listOf_0(end) : emptyList()))); }; protoOf(GitAdapter).s16 = function () { // Inline function 'kotlin.let' call var output = runProcess$default(this, listOf(['git', 'status', '--porcelain=2', '--branch', '--ahead-behind'])); var lines = split(output, ['\n']); var head = findByPrefix(this, lines, '# branch.head '); var upstream = findByPrefix(this, lines, '# branch.upstream '); var tmp0_safe_receiver = findByPrefix(this, lines, '# branch.ab '); var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : split(tmp0_safe_receiver, [' ']); var tmp; if (tmp1_safe_receiver == null) { tmp = null; } else { // Inline function 'kotlin.collections.map' call // Inline function 'kotlin.collections.mapTo' call var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(tmp1_safe_receiver, 10)); var _iterator__ex2g4s = tmp1_safe_receiver.m(); while (_iterator__ex2g4s.n()) { var item = _iterator__ex2g4s.o(); var tmp$ret$0 = substring(item, 1); destination.e(tmp$ret$0); } tmp = destination; } var tmp2_elvis_lhs = tmp; var _destruct__k2r9zo = tmp2_elvis_lhs == null ? listOf(['-1', '-1']) : tmp2_elvis_lhs; // Inline function 'kotlin.collections.component1' call var a = _destruct__k2r9zo.q(0); // Inline function 'kotlin.collections.component2' call var b = _destruct__k2r9zo.q(1); // Inline function 'kotlin.collections.filterNot' call // Inline function 'kotlin.collections.filterNotTo' call var destination_0 = ArrayList_init_$Create$(); var _iterator__ex2g4s_0 = lines.m(); while (_iterator__ex2g4s_0.n()) { var element = _iterator__ex2g4s_0.o(); if (!startsWith(element, '#')) { destination_0.e(element); } } // Inline function 'kotlin.collections.filterNot' call // Inline function 'kotlin.collections.filterNotTo' call var destination_1 = ArrayList_init_$Create$(); var _iterator__ex2g4s_1 = destination_0.m(); while (_iterator__ex2g4s_1.n()) { var element_0 = _iterator__ex2g4s_1.o(); if (!isBlank(element_0)) { destination_1.e(element_0); } } var tmp_0 = destination_1.j(); var tmp_1 = toInt(a); var tmp_2 = toInt(b); var tmp_3 = head == null ? '' : head; return new GitStatus(tmp_0, tmp_1, tmp_2, tmp_3, upstream == null ? '' : upstream); }; protoOf(GitAdapter).t16 = function (abbrev) { // Inline function 'kotlin.runCatching' call var tmp; try { // Inline function 'kotlin.text.trim' call var this_0 = runProcess$default(this, listOf(['git', 'describe', '--abbrev=' + abbrev])); // Inline function 'kotlin.Companion.success' call var value = toString(trim(isCharSequence(this_0) ? this_0 : THROW_CCE())); tmp = _Result___init__impl__xyqfz8(value); } catch ($p) { var tmp_0; if ($p instanceof Error) { var e = $p; // Inline function 'kotlin.Companion.failure' call tmp_0 = _Result___init__impl__xyqfz8(createFailure(e)); } else { throw $p; } tmp = tmp_0; } // Inline function 'kotlin.Result.getOrNull' call var this_1 = tmp; var tmp_1; if (_Result___get_isFailure__impl__jpiriv(this_1)) { tmp_1 = null; } else { var tmp_2 = _Result___get_value__impl__bjfvqg(this_1); tmp_1 = (tmp_2 == null ? true : !(tmp_2 == null)) ? tmp_2 : THROW_CCE(); } return tmp_1; }; function GitStatus(isClean, ahead, behind, head, upstream) { this.u16_1 = isClean; this.v16_1 = ahead; this.w16_1 = behind; this.x16_1 = head; this.y16_1 = upstream; } protoOf(GitStatus).toString = function () { return 'GitStatus(isClean=' + this.u16_1 + ', ahead=' + this.v16_1 + ', behind=' + this.w16_1 + ', head=' + this.x16_1 + ', upstream=' + this.y16_1 + ')'; }; protoOf(GitStatus).hashCode = function () { var result = getBooleanHashCode(this.u16_1); result = imul(result, 31) + this.v16_1 | 0; result = imul(result, 31) + this.w16_1 | 0; result = imul(result, 31) + getStringHashCode(this.x16_1) | 0; result = imul(result, 31) + getStringHashCode(this.y16_1) | 0; return result; }; protoOf(GitStatus).equals = function (other) { if (this === other) return true; if (!(other instanceof GitStatus)) return false; var tmp0_other_with_cast = other instanceof GitStatus ? other : THROW_CCE(); if (!(this.u16_1 === tmp0_other_with_cast.u16_1)) return false; if (!(this.v16_1 === tmp0_other_with_cast.v16_1)) return false; if (!(this.w16_1 === tmp0_other_with_cast.w16_1)) return false; if (!(this.x16_1 === tmp0_other_with_cast.x16_1)) return false; if (!(this.y16_1 === tmp0_other_with_cast.y16_1)) return false; return true; }; function TagRef(name, commitId, dateTime) { this.z16_1 = name; this.a17_1 = commitId; this.b17_1 = dateTime; } protoOf(TagRef).toString = function () { return 'TagRef(name=' + this.z16_1 + ', commitId=' + this.a17_1 + ', dateTime=' + this.b17_1.toString() + ')'; }; protoOf(TagRef).hashCode = function () { var result = getStringHashCode(this.z16_1); result = imul(result, 31) + getStringHashCode(this.a17_1) | 0; result = imul(result, 31) + this.b17_1.hashCode() | 0; return result; }; protoOf(TagRef).equals = function (other) { if (this === other) return true; if (!(other instanceof TagRef)) return false; var tmp0_other_with_cast = other instanceof TagRef ? other : THROW_CCE(); if (!(this.z16_1 === tmp0_other_with_cast.z16_1)) return false; if (!(this.a17_1 === tmp0_other_with_cast.a17_1)) return false; if (!this.b17_1.equals(tmp0_other_with_cast.b17_1)) return false; return true; }; function runProcess_0(args, workingDirectory, env) { var tmp; if (env === VOID) { // Inline function 'kotlin.collections.mapOf' call tmp = emptyMap(); } else { tmp = env; } env = tmp; var program = first(args); // Inline function 'kotlin.collections.toTypedArray' call var this_0 = args.z1(1, args.p()); var tmp$ret$1 = copyToArray(this_0); var spawn = childProcess.spawnSync(program, tmp$ret$1, json([to('cwd', workingDirectory), to('maxBuffer', 10485760), to('env', toJson(env))])); if (spawn.status != 0) { var tmp0_safe_receiver = spawn.stderr; // Inline function 'kotlin.js.unsafeCast' call var tmp$ret$2 = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.toString('utf8'); throw Exception_init_$Create$(tmp$ret$2); } var tmp1_safe_receiver = spawn.stdout; // Inline function 'kotlin.js.unsafeCast' call return tmp1_safe_receiver == null ? null : tmp1_safe_receiver.toString('utf8'); } function toJson(_this__u8e3s4) { // Inline function 'kotlin.collections.toTypedArray' call var this_0 = toList(_this__u8e3s4); var tmp$ret$0 = copyToArray(this_0); return json(tmp$ret$0.slice()); } //region block: exports _.$_$ = _.$_$ || {}; _.$_$.a = GitAdapter; //endregion return _; }(module.exports, require('node:child_process'), require('./kotlin-kotlin-stdlib.js'))); //# sourceMappingURL=tools-git-adapter.js.map