screw-up 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: screw-up
3
- * version: 1.0.0
3
+ * version: 1.2.0
4
4
  * description: Simply package metadata inserter on Vite plugin
5
5
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
6
  * license: MIT
7
7
  * repository.url: https://github.com/kekyo/screw-up.git
8
- * git.commit.hash: 4129fb42a594608860d2ac0d9d10871739f39091
8
+ * git.commit.hash: cc82696555da70d209bcd4d7ca6cba330360e074
9
9
  */
10
10
  import { existsSync } from "fs";
11
11
  import * as fs from "fs/promises";
@@ -66,8 +66,8 @@ var parse = function parse2(text, reviver) {
66
66
  }
67
67
  return root;
68
68
  };
69
- function internalize(holder, name, reviver) {
70
- const value = holder[name];
69
+ function internalize(holder, name2, reviver) {
70
+ const value = holder[name2];
71
71
  if (value != null && typeof value === "object") {
72
72
  if (Array.isArray(value)) {
73
73
  for (let i = 0; i < value.length; i++) {
@@ -100,7 +100,7 @@ function internalize(holder, name, reviver) {
100
100
  }
101
101
  }
102
102
  }
103
- return reviver.call(holder, name, value);
103
+ return reviver.call(holder, name2, value);
104
104
  }
105
105
  let lexState;
106
106
  let buffer;
@@ -1095,13 +1095,28 @@ const JSON5 = {
1095
1095
  stringify
1096
1096
  };
1097
1097
  var lib = JSON5;
1098
- const createConsoleLogger = () => {
1099
- return {
1100
- debug: (msg) => console.debug(msg),
1101
- info: (msg) => console.info(msg),
1102
- warn: (msg) => console.warn(msg),
1103
- error: (msg) => console.error(msg)
1104
- };
1098
+ const createConsoleLogger = (prefix, driver) => {
1099
+ var _a, _b, _c, _d;
1100
+ const d = (_a = driver == null ? void 0 : driver.debug) != null ? _a : (() => {
1101
+ });
1102
+ const i = (_b = driver == null ? void 0 : driver.info) != null ? _b : globalThis.console.info;
1103
+ const w = (_c = driver == null ? void 0 : driver.warn) != null ? _c : globalThis.console.warn;
1104
+ const e = (_d = driver == null ? void 0 : driver.error) != null ? _d : globalThis.console.error;
1105
+ if (prefix) {
1106
+ return {
1107
+ debug: (msg) => d(`[${prefix}]: ${msg}`),
1108
+ info: (msg) => i(`[${prefix}]: ${msg}`),
1109
+ warn: (msg) => w(`[${prefix}]: ${msg}`),
1110
+ error: (msg) => e(`[${prefix}]: ${msg}`)
1111
+ };
1112
+ } else {
1113
+ return {
1114
+ debug: (msg) => d(`${msg}`),
1115
+ info: (msg) => i(`${msg}`),
1116
+ warn: (msg) => w(`${msg}`),
1117
+ error: (msg) => e(`${msg}`)
1118
+ };
1119
+ }
1105
1120
  };
1106
1121
  const flattenObject = (obj, prefix, map) => {
1107
1122
  for (const [key2, value] of Object.entries(obj)) {
@@ -1340,9 +1355,9 @@ function requireDayjs_min() {
1340
1355
  if (hasRequiredDayjs_min) return dayjs_min$1.exports;
1341
1356
  hasRequiredDayjs_min = 1;
1342
1357
  (function(module, exports) {
1343
- !function(t, e) {
1358
+ !(function(t, e) {
1344
1359
  module.exports = e();
1345
- }(dayjs_min, function() {
1360
+ })(dayjs_min, (function() {
1346
1361
  var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c2 = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
1347
1362
  var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
1348
1363
  return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
@@ -1387,13 +1402,13 @@ function requireDayjs_min() {
1387
1402
  b.l = w, b.i = S, b.w = function(t2, e2) {
1388
1403
  return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
1389
1404
  };
1390
- var _ = function() {
1405
+ var _ = (function() {
1391
1406
  function M2(t2) {
1392
1407
  this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
1393
1408
  }
1394
1409
  var m2 = M2.prototype;
1395
1410
  return m2.parse = function(t2) {
1396
- this.$d = function(t3) {
1411
+ this.$d = (function(t3) {
1397
1412
  var e2 = t3.date, n2 = t3.utc;
1398
1413
  if (null === e2) return /* @__PURE__ */ new Date(NaN);
1399
1414
  if (b.u(e2)) return /* @__PURE__ */ new Date();
@@ -1406,7 +1421,7 @@ function requireDayjs_min() {
1406
1421
  }
1407
1422
  }
1408
1423
  return new Date(e2);
1409
- }(t2), this.init();
1424
+ })(t2), this.init();
1410
1425
  }, m2.init = function() {
1411
1426
  var t2 = this.$d;
1412
1427
  this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
@@ -1493,8 +1508,8 @@ function requireDayjs_min() {
1493
1508
  var r3 = t3 < 12 ? "AM" : "PM";
1494
1509
  return n3 ? r3.toLowerCase() : r3;
1495
1510
  };
1496
- return r2.replace(y, function(t3, r3) {
1497
- return r3 || function(t4) {
1511
+ return r2.replace(y, (function(t3, r3) {
1512
+ return r3 || (function(t4) {
1498
1513
  switch (t4) {
1499
1514
  case "YY":
1500
1515
  return String(e2.$y).slice(-2);
@@ -1546,8 +1561,8 @@ function requireDayjs_min() {
1546
1561
  return i2;
1547
1562
  }
1548
1563
  return null;
1549
- }(t3) || i2.replace(":", "");
1550
- });
1564
+ })(t3) || i2.replace(":", "");
1565
+ }));
1551
1566
  }, m2.utcOffset = function() {
1552
1567
  return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
1553
1568
  }, m2.diff = function(r2, d2, l2) {
@@ -1602,17 +1617,17 @@ function requireDayjs_min() {
1602
1617
  }, m2.toString = function() {
1603
1618
  return this.$d.toUTCString();
1604
1619
  }, M2;
1605
- }(), k = _.prototype;
1606
- return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c2], ["$y", h], ["$D", d]].forEach(function(t2) {
1620
+ })(), k = _.prototype;
1621
+ return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c2], ["$y", h], ["$D", d]].forEach((function(t2) {
1607
1622
  k[t2[1]] = function(e2) {
1608
1623
  return this.$g(e2, t2[0], t2[1]);
1609
1624
  };
1610
- }), O.extend = function(t2, e2) {
1625
+ })), O.extend = function(t2, e2) {
1611
1626
  return t2.$i || (t2(e2, _, O), t2.$i = true), O;
1612
1627
  }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
1613
1628
  return O(1e3 * t2);
1614
1629
  }, O.en = D[g], O.Ls = D, O.p = {}, O;
1615
- });
1630
+ }));
1616
1631
  })(dayjs_min$1);
1617
1632
  return dayjs_min$1.exports;
1618
1633
  }
@@ -1633,7 +1648,7 @@ const parseVersion = (tagName) => {
1633
1648
  if (major === void 0) {
1634
1649
  return void 0;
1635
1650
  }
1636
- const version = {
1651
+ const version2 = {
1637
1652
  major,
1638
1653
  original: tagName
1639
1654
  };
@@ -1642,26 +1657,26 @@ const parseVersion = (tagName) => {
1642
1657
  if (minor === void 0) {
1643
1658
  return void 0;
1644
1659
  }
1645
- version.minor = minor;
1660
+ version2.minor = minor;
1646
1661
  }
1647
1662
  if (match[3] !== void 0) {
1648
1663
  const build = parseVersionComponent(match[3]);
1649
1664
  if (build === void 0) {
1650
1665
  return void 0;
1651
1666
  }
1652
- version.build = build;
1667
+ version2.build = build;
1653
1668
  }
1654
1669
  if (match[4] !== void 0) {
1655
1670
  const revision = parseVersionComponent(match[4]);
1656
1671
  if (revision === void 0) {
1657
1672
  return void 0;
1658
1673
  }
1659
- version.revision = revision;
1674
+ version2.revision = revision;
1660
1675
  }
1661
- return version;
1676
+ return version2;
1662
1677
  };
1663
- const isValidVersion = (version) => {
1664
- return version.major >= 0 && (version.minor === void 0 || version.minor >= 0);
1678
+ const isValidVersion = (version2) => {
1679
+ return version2.major >= 0 && (version2.minor === void 0 || version2.minor >= 0);
1665
1680
  };
1666
1681
  const compareVersions = (a, b) => {
1667
1682
  var _a, _b, _c, _d, _e, _f;
@@ -1677,30 +1692,30 @@ const compareVersions = (a, b) => {
1677
1692
  if (aRevision !== bRevision) return bRevision - aRevision;
1678
1693
  return 0;
1679
1694
  };
1680
- const incrementLastVersionComponent = (version) => {
1681
- if (version.revision !== void 0) {
1682
- return { ...version, revision: version.revision + 1 };
1695
+ const incrementLastVersionComponent = (version2) => {
1696
+ if (version2.revision !== void 0) {
1697
+ return { ...version2, revision: version2.revision + 1 };
1683
1698
  }
1684
- if (version.build !== void 0) {
1685
- return { ...version, build: version.build + 1 };
1699
+ if (version2.build !== void 0) {
1700
+ return { ...version2, build: version2.build + 1 };
1686
1701
  }
1687
- if (version.minor !== void 0) {
1688
- return { ...version, minor: version.minor + 1 };
1702
+ if (version2.minor !== void 0) {
1703
+ return { ...version2, minor: version2.minor + 1 };
1689
1704
  }
1690
1705
  return {
1691
- ...version,
1692
- major: version.major + 1,
1693
- original: `${version.major + 1}`
1706
+ ...version2,
1707
+ major: version2.major + 1,
1708
+ original: `${version2.major + 1}`
1694
1709
  };
1695
1710
  };
1696
- const formatVersion = (version) => {
1697
- let result = `${version.major}`;
1698
- if (version.minor !== void 0) {
1699
- result += `.${version.minor}`;
1700
- if (version.build !== void 0) {
1701
- result += `.${version.build}`;
1702
- if (version.revision !== void 0) {
1703
- result += `.${version.revision}`;
1711
+ const formatVersion = (version2) => {
1712
+ let result = `${version2.major}`;
1713
+ if (version2.minor !== void 0) {
1714
+ result += `.${version2.minor}`;
1715
+ if (version2.build !== void 0) {
1716
+ result += `.${version2.build}`;
1717
+ if (version2.revision !== void 0) {
1718
+ result += `.${version2.revision}`;
1704
1719
  }
1705
1720
  }
1706
1721
  }
@@ -1742,13 +1757,21 @@ const getRelatedTags = async (repositoryPath, commitHash) => {
1742
1757
  for (const tagName of tags) {
1743
1758
  try {
1744
1759
  const tagOid = await git.resolveRef({ fs, dir: repositoryPath, ref: `refs/tags/${tagName}` });
1745
- if (tagOid === commitHash) {
1746
- const version = parseVersion(tagName);
1747
- if (version && isValidVersion(version)) {
1760
+ let targetCommitOid = tagOid;
1761
+ try {
1762
+ const tagObject = await git.readTag({ fs, dir: repositoryPath, oid: tagOid });
1763
+ if (tagObject && tagObject.tag.object) {
1764
+ targetCommitOid = tagObject.tag.object;
1765
+ }
1766
+ } catch (e) {
1767
+ }
1768
+ if (targetCommitOid === commitHash) {
1769
+ const version2 = parseVersion(tagName);
1770
+ if (version2 && isValidVersion(version2)) {
1748
1771
  tagInfos.push({
1749
1772
  name: tagName,
1750
1773
  hash: commitHash,
1751
- version
1774
+ version: version2
1752
1775
  });
1753
1776
  } else {
1754
1777
  tagInfos.push({
@@ -1773,13 +1796,21 @@ const getRelatedTagsForVersioning = async (repositoryPath, commitHash) => {
1773
1796
  for (const tagName of tags) {
1774
1797
  try {
1775
1798
  const tagOid = await git.resolveRef({ fs, dir: repositoryPath, ref: `refs/tags/${tagName}` });
1776
- if (tagOid === commitHash) {
1777
- const version = parseVersion(tagName);
1778
- if (version && isValidVersion(version)) {
1799
+ let targetCommitOid = tagOid;
1800
+ try {
1801
+ const tagObject = await git.readTag({ fs, dir: repositoryPath, oid: tagOid });
1802
+ if (tagObject && tagObject.tag.object) {
1803
+ targetCommitOid = tagObject.tag.object;
1804
+ }
1805
+ } catch (e) {
1806
+ }
1807
+ if (targetCommitOid === commitHash) {
1808
+ const version2 = parseVersion(tagName);
1809
+ if (version2 && isValidVersion(version2)) {
1779
1810
  tagInfos.push({
1780
1811
  name: tagName,
1781
1812
  hash: commitHash,
1782
- version
1813
+ version: version2
1783
1814
  });
1784
1815
  }
1785
1816
  }
@@ -1829,18 +1860,18 @@ const formatModifiedFile = (modifiedFile) => {
1829
1860
  };
1830
1861
  const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits) => {
1831
1862
  const scheduledStack = [];
1832
- let version = { major: 0, minor: 0, build: 1, original: "0.0.1" };
1863
+ let version2 = { major: 0, minor: 0, build: 1, original: "0.0.1" };
1833
1864
  let currentCommit = commit;
1834
1865
  while (true) {
1835
1866
  if (reachedCommits.has(currentCommit.hash)) {
1836
- version = reachedCommits.get(currentCommit.hash);
1867
+ version2 = reachedCommits.get(currentCommit.hash);
1837
1868
  break;
1838
1869
  }
1839
1870
  const relatedTags = await getRelatedTagsForVersioning(cwd, currentCommit.hash);
1840
1871
  const versionCandidates = relatedTags.filter((tag) => tag.version && isValidVersion(tag.version)).filter((tag) => tag.version.minor !== void 0).sort((a, b) => compareVersions(a.version, b.version));
1841
1872
  if (versionCandidates.length >= 1) {
1842
- version = versionCandidates[0].version;
1843
- reachedCommits.set(currentCommit.hash, version);
1873
+ version2 = versionCandidates[0].version;
1874
+ reachedCommits.set(currentCommit.hash, version2);
1844
1875
  break;
1845
1876
  }
1846
1877
  let parentCommits = [];
@@ -1851,7 +1882,7 @@ const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits) => {
1851
1882
  } catch (e) {
1852
1883
  }
1853
1884
  if (parentCommits.length === 0) {
1854
- reachedCommits.set(currentCommit.hash, version);
1885
+ reachedCommits.set(currentCommit.hash, version2);
1855
1886
  break;
1856
1887
  }
1857
1888
  scheduledStack.push({ commit: currentCommit, parents: parentCommits });
@@ -1863,15 +1894,15 @@ const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits) => {
1863
1894
  if (parents.length >= 2) {
1864
1895
  for (let index = 1; index < parents.length; index++) {
1865
1896
  const alternateParentVersion = await lookupVersionLabelRecursive(cwd, parents[index], reachedCommits);
1866
- if (alternateParentVersion && compareVersions(alternateParentVersion, version) < 0) {
1867
- version = alternateParentVersion;
1897
+ if (alternateParentVersion && compareVersions(alternateParentVersion, version2) < 0) {
1898
+ version2 = alternateParentVersion;
1868
1899
  }
1869
1900
  }
1870
1901
  }
1871
- version = incrementLastVersionComponent(version);
1872
- reachedCommits.set(scheduledCommit.hash, version);
1902
+ version2 = incrementLastVersionComponent(version2);
1903
+ reachedCommits.set(scheduledCommit.hash, version2);
1873
1904
  }
1874
- return version;
1905
+ return version2;
1875
1906
  };
1876
1907
  const getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger) => {
1877
1908
  const metadata = {};
@@ -1887,19 +1918,19 @@ const getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logge
1887
1918
  return metadata;
1888
1919
  }
1889
1920
  const reachedCommits = /* @__PURE__ */ new Map();
1890
- let version = await lookupVersionLabelRecursive(gitRootPath, currentCommit, reachedCommits);
1921
+ let version2 = await lookupVersionLabelRecursive(gitRootPath, currentCommit, reachedCommits);
1891
1922
  const gitMetadata = { tags: [], branches: [] };
1892
1923
  metadata.git = gitMetadata;
1893
- if (version) {
1924
+ if (version2) {
1894
1925
  if (checkWorkingDirectoryStatus) {
1895
1926
  const modifiedFiles = await getModifiedFiles(gitRootPath);
1896
1927
  if (modifiedFiles.length >= 1) {
1897
- const newVersion = incrementLastVersionComponent(version);
1898
- logger.debug(`Increased git version by detected modified items: ${formatVersion(version)} ---> ${formatVersion(newVersion)}, Files=[${modifiedFiles.map(formatModifiedFile).join(", ")}]`);
1899
- version = newVersion;
1928
+ const newVersion = incrementLastVersionComponent(version2);
1929
+ logger.debug(`Increased git version by detected modified items: ${formatVersion(version2)} ---> ${formatVersion(newVersion)}, Files=[${modifiedFiles.map(formatModifiedFile).join(", ")}]`);
1930
+ version2 = newVersion;
1900
1931
  }
1901
1932
  }
1902
- const gitVersion = formatVersion(version);
1933
+ const gitVersion = formatVersion(version2);
1903
1934
  gitMetadata.version = gitVersion;
1904
1935
  metadata.version = gitVersion;
1905
1936
  }
@@ -1931,13 +1962,32 @@ const getFetchGitMetadata = (targetDir, checkWorkingDirectoryStatus, logger) =>
1931
1962
  return cachedMetadata;
1932
1963
  };
1933
1964
  };
1965
+ const name = "screw-up";
1966
+ const version = "1.2.0";
1967
+ const author = "Kouji Matsui (@kekyo@mi.kekyo.net)";
1968
+ const license = "MIT";
1969
+ const repository_url = "https://github.com/kekyo/screw-up.git";
1970
+ const git_commit_hash = "cc82696555da70d209bcd4d7ca6cba330360e074";
1971
+ const packageMetadata = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1972
+ __proto__: null,
1973
+ author,
1974
+ git_commit_hash,
1975
+ license,
1976
+ name,
1977
+ repository_url,
1978
+ version
1979
+ }, Symbol.toStringTag, { value: "Module" }));
1934
1980
  export {
1935
- resolveRawPackageJsonObject as a,
1936
- collectWorkspaceSiblings as b,
1981
+ git_commit_hash as a,
1982
+ resolveRawPackageJsonObject as b,
1937
1983
  createConsoleLogger as c,
1938
- replacePeerDependenciesWildcards as d,
1984
+ collectWorkspaceSiblings as d,
1985
+ replacePeerDependenciesWildcards as e,
1939
1986
  findWorkspaceRoot as f,
1940
1987
  getFetchGitMetadata as g,
1941
- resolvePackageMetadata as r
1988
+ name as n,
1989
+ packageMetadata as p,
1990
+ resolvePackageMetadata as r,
1991
+ version as v
1942
1992
  };
1943
- //# sourceMappingURL=analyzer-DxAKRQPj.js.map
1993
+ //# sourceMappingURL=packageMetadata-DOzhlPbz.js.map