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)

427 lines (425 loc) 17 kB
(function (_, childProcess, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_datetime) { 'use strict'; //region block: imports var imul = Math.imul; var toString = kotlin_kotlin.$_$.ea; var protoOf = kotlin_kotlin.$_$.aa; var getStringHashCode = kotlin_kotlin.$_$.y8; var hashCode = kotlin_kotlin.$_$.z8; var THROW_CCE = kotlin_kotlin.$_$.ce; var equals = kotlin_kotlin.$_$.u8; var initMetadataForClass = kotlin_kotlin.$_$.a9; var plus = kotlin_kotlin.$_$.x6; var emptyMap = kotlin_kotlin.$_$.u5; var VOID = kotlin_kotlin.$_$.f; var emptyList = kotlin_kotlin.$_$.t5; var listOf = kotlin_kotlin.$_$.q6; var split = kotlin_kotlin.$_$.nc; var ArrayList_init_$Create$ = kotlin_kotlin.$_$.j; var joinToString = kotlin_kotlin.$_$.f6; var reversed = kotlin_kotlin.$_$.e7; var Companion_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_datetime.$_$.a; var last = kotlin_kotlin.$_$.m6; var Unit_instance = kotlin_kotlin.$_$.e4; var isBlank = kotlin_kotlin.$_$.wb; var collectionSizeOrDefault = kotlin_kotlin.$_$.c5; var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.i; var charSequenceLength = kotlin_kotlin.$_$.r8; var startsWith = kotlin_kotlin.$_$.oc; var listOf_0 = kotlin_kotlin.$_$.p6; var plus_0 = kotlin_kotlin.$_$.a7; var to = kotlin_kotlin.$_$.df; var mapOf = kotlin_kotlin.$_$.s6; var firstOrNull = kotlin_kotlin.$_$.w5; var toInt = kotlin_kotlin.$_$.zc; var Companion_instance = kotlin_kotlin.$_$.z3; var isCharSequence = kotlin_kotlin.$_$.k9; var trim = kotlin_kotlin.$_$.kd; var _Result___init__impl__xyqfz8 = kotlin_kotlin.$_$.y1; var createFailure = kotlin_kotlin.$_$.re; var _Result___get_value__impl__bjfvqg = kotlin_kotlin.$_$.c2; var _Result___get_isFailure__impl__jpiriv = kotlin_kotlin.$_$.a2; var getBooleanHashCode = kotlin_kotlin.$_$.v8; var first = kotlin_kotlin.$_$.x5; var copyToArray = kotlin_kotlin.$_$.q5; var json = kotlin_kotlin.$_$.s9; var Exception_init_$Create$ = kotlin_kotlin.$_$.c1; var toList = kotlin_kotlin.$_$.r7; //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.p1l_1 = id; this.q1l_1 = authorEmail; this.r1l_1 = committerEmail; this.s1l_1 = dateTime; this.t1l_1 = parents; this.u1l_1 = fullMessage; } protoOf(CommitRef).toString = function () { return 'CommitRef(id=' + this.p1l_1 + ', authorEmail=' + this.q1l_1 + ', committerEmail=' + this.r1l_1 + ', dateTime=' + this.s1l_1.toString() + ', parents=' + toString(this.t1l_1) + ', fullMessage=' + this.u1l_1 + ')'; }; protoOf(CommitRef).hashCode = function () { var result = getStringHashCode(this.p1l_1); result = imul(result, 31) + getStringHashCode(this.q1l_1) | 0; result = imul(result, 31) + getStringHashCode(this.r1l_1) | 0; result = imul(result, 31) + this.s1l_1.hashCode() | 0; result = imul(result, 31) + hashCode(this.t1l_1) | 0; result = imul(result, 31) + getStringHashCode(this.u1l_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.p1l_1 === tmp0_other_with_cast.p1l_1)) return false; if (!(this.q1l_1 === tmp0_other_with_cast.q1l_1)) return false; if (!(this.r1l_1 === tmp0_other_with_cast.r1l_1)) return false; if (!this.s1l_1.equals(tmp0_other_with_cast.s1l_1)) return false; if (!equals(this.t1l_1, tmp0_other_with_cast.t1l_1)) return false; if (!(this.u1l_1 === tmp0_other_with_cast.u1l_1)) return false; return true; }; function runProcess($this, args, env) { return runProcess_0(args, $this.v1l_1, plus(env, $this.w1l_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.p(); while (_iterator__ex2g4s.q()) { var element = _iterator__ex2g4s.r(); var commaSplit = split(element, [',']); var tmp; if (commaSplit.s() >= 3) { tmp = new TagRef(joinToString(commaSplit.a2(0, commaSplit.s() - 2 | 0), ''), reversed(commaSplit).t(1), Companion_getInstance().r1k(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.x1l_1 + '\n']); // Inline function 'kotlin.collections.filterTo' call var destination = ArrayList_init_$Create$(); var _iterator__ex2g4s = tmp0.p(); while (_iterator__ex2g4s.q()) { var element = _iterator__ex2g4s.r(); // 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.p(); while (_iterator__ex2g4s_0.q()) { var item = _iterator__ex2g4s_0.r(); var elements = split(item, ['\n']); var tmp = elements.t(0); var tmp_0 = elements.t(1); var tmp_1 = elements.t(2); var tmp_2 = Companion_getInstance().r1k(elements.t(3)); // Inline function 'kotlin.collections.filter' call var tmp0_0 = split(elements.t(4), [' ']); // Inline function 'kotlin.collections.filterTo' call var destination_1 = ArrayList_init_$Create$(); var _iterator__ex2g4s_1 = tmp0_0.p(); while (_iterator__ex2g4s_1.q()) { var element_0 = _iterator__ex2g4s_1.r(); // 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.a2(5, elements.s()), '\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.p(); while (_iterator__ex2g4s.q()) { var element = _iterator__ex2g4s.r(); if (startsWith(element, prefix)) { tmp$ret$1 = element; break $l$block; } } tmp$ret$1 = null; } var tmp0_safe_receiver = tmp$ret$1; var tmp; if (tmp0_safe_receiver == null) { tmp = null; } else { // Inline function 'kotlin.text.substring' call var startIndex = prefix.length; // Inline function 'kotlin.js.asDynamic' call tmp = tmp0_safe_receiver.substring(startIndex); } return tmp; } function GitAdapter(workingDirectory, env) { env = env === VOID ? emptyMap() : env; this.v1l_1 = workingDirectory; this.w1l_1 = env; this.x1l_1 = '--------!--------'; this.y1l_1 = '%H%n%ae%n%ce%n%aI%n%P%n%B%n' + this.x1l_1; } protoOf(GitAdapter).z1l = 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).a1m = function () { runProcess$default(this, listOf(['git', 'push', '--tags'])); }; protoOf(GitAdapter).b1m = 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).c1m = function (begin, end) { return parseLog(this, runProcess$default(this, plus_0(listOf(['git', '--no-pager', 'log', '--format=' + this.y1l_1, begin]), !(end == null) ? listOf_0(end) : emptyList()))); }; protoOf(GitAdapter).d1m = 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.p(); while (_iterator__ex2g4s.q()) { var item = _iterator__ex2g4s.r(); // Inline function 'kotlin.text.substring' call // Inline function 'kotlin.js.asDynamic' call var tmp$ret$2 = item.substring(1); destination.e(tmp$ret$2); } 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.t(0); // Inline function 'kotlin.collections.component2' call var b = _destruct__k2r9zo.t(1); // Inline function 'kotlin.collections.filterNot' call // Inline function 'kotlin.collections.filterNotTo' call var destination_0 = ArrayList_init_$Create$(); var _iterator__ex2g4s_0 = lines.p(); while (_iterator__ex2g4s_0.q()) { var element = _iterator__ex2g4s_0.r(); 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.p(); while (_iterator__ex2g4s_1.q()) { var element_0 = _iterator__ex2g4s_1.r(); if (!isBlank(element_0)) { destination_1.e(element_0); } } var tmp_0 = destination_1.m(); 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).e1m = 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.f1m_1 = isClean; this.g1m_1 = ahead; this.h1m_1 = behind; this.i1m_1 = head; this.j1m_1 = upstream; } protoOf(GitStatus).toString = function () { return 'GitStatus(isClean=' + this.f1m_1 + ', ahead=' + this.g1m_1 + ', behind=' + this.h1m_1 + ', head=' + this.i1m_1 + ', upstream=' + this.j1m_1 + ')'; }; protoOf(GitStatus).hashCode = function () { var result = getBooleanHashCode(this.f1m_1); result = imul(result, 31) + this.g1m_1 | 0; result = imul(result, 31) + this.h1m_1 | 0; result = imul(result, 31) + getStringHashCode(this.i1m_1) | 0; result = imul(result, 31) + getStringHashCode(this.j1m_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.f1m_1 === tmp0_other_with_cast.f1m_1)) return false; if (!(this.g1m_1 === tmp0_other_with_cast.g1m_1)) return false; if (!(this.h1m_1 === tmp0_other_with_cast.h1m_1)) return false; if (!(this.i1m_1 === tmp0_other_with_cast.i1m_1)) return false; if (!(this.j1m_1 === tmp0_other_with_cast.j1m_1)) return false; return true; }; function TagRef(name, commitId, dateTime) { this.k1m_1 = name; this.l1m_1 = commitId; this.m1m_1 = dateTime; } protoOf(TagRef).toString = function () { return 'TagRef(name=' + this.k1m_1 + ', commitId=' + this.l1m_1 + ', dateTime=' + this.m1m_1.toString() + ')'; }; protoOf(TagRef).hashCode = function () { var result = getStringHashCode(this.k1m_1); result = imul(result, 31) + getStringHashCode(this.l1m_1) | 0; result = imul(result, 31) + this.m1m_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.k1m_1 === tmp0_other_with_cast.k1m_1)) return false; if (!(this.l1m_1 === tmp0_other_with_cast.l1m_1)) return false; if (!this.m1m_1.equals(tmp0_other_with_cast.m1m_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.a2(1, args.s()); 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'), require('./Kotlin-DateTime-library-kotlinx-datetime.js'))); //# sourceMappingURL=tools-git-adapter.js.map