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
  "use strict";
11
11
  const fs = require("fs");
@@ -84,8 +84,8 @@ var parse = function parse2(text, reviver) {
84
84
  }
85
85
  return root;
86
86
  };
87
- function internalize(holder, name, reviver) {
88
- const value = holder[name];
87
+ function internalize(holder, name2, reviver) {
88
+ const value = holder[name2];
89
89
  if (value != null && typeof value === "object") {
90
90
  if (Array.isArray(value)) {
91
91
  for (let i = 0; i < value.length; i++) {
@@ -118,7 +118,7 @@ function internalize(holder, name, reviver) {
118
118
  }
119
119
  }
120
120
  }
121
- return reviver.call(holder, name, value);
121
+ return reviver.call(holder, name2, value);
122
122
  }
123
123
  let lexState;
124
124
  let buffer;
@@ -1113,13 +1113,28 @@ const JSON5 = {
1113
1113
  stringify
1114
1114
  };
1115
1115
  var lib = JSON5;
1116
- const createConsoleLogger = () => {
1117
- return {
1118
- debug: (msg) => console.debug(msg),
1119
- info: (msg) => console.info(msg),
1120
- warn: (msg) => console.warn(msg),
1121
- error: (msg) => console.error(msg)
1122
- };
1116
+ const createConsoleLogger = (prefix, driver) => {
1117
+ var _a, _b, _c, _d;
1118
+ const d = (_a = driver == null ? void 0 : driver.debug) != null ? _a : (() => {
1119
+ });
1120
+ const i = (_b = driver == null ? void 0 : driver.info) != null ? _b : globalThis.console.info;
1121
+ const w = (_c = driver == null ? void 0 : driver.warn) != null ? _c : globalThis.console.warn;
1122
+ const e = (_d = driver == null ? void 0 : driver.error) != null ? _d : globalThis.console.error;
1123
+ if (prefix) {
1124
+ return {
1125
+ debug: (msg) => d(`[${prefix}]: ${msg}`),
1126
+ info: (msg) => i(`[${prefix}]: ${msg}`),
1127
+ warn: (msg) => w(`[${prefix}]: ${msg}`),
1128
+ error: (msg) => e(`[${prefix}]: ${msg}`)
1129
+ };
1130
+ } else {
1131
+ return {
1132
+ debug: (msg) => d(`${msg}`),
1133
+ info: (msg) => i(`${msg}`),
1134
+ warn: (msg) => w(`${msg}`),
1135
+ error: (msg) => e(`${msg}`)
1136
+ };
1137
+ }
1123
1138
  };
1124
1139
  const flattenObject = (obj, prefix, map) => {
1125
1140
  for (const [key2, value] of Object.entries(obj)) {
@@ -1358,9 +1373,9 @@ function requireDayjs_min() {
1358
1373
  if (hasRequiredDayjs_min) return dayjs_min$1.exports;
1359
1374
  hasRequiredDayjs_min = 1;
1360
1375
  (function(module2, exports2) {
1361
- !function(t, e) {
1376
+ !(function(t, e) {
1362
1377
  module2.exports = e();
1363
- }(dayjs_min, function() {
1378
+ })(dayjs_min, (function() {
1364
1379
  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) {
1365
1380
  var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
1366
1381
  return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
@@ -1405,13 +1420,13 @@ function requireDayjs_min() {
1405
1420
  b.l = w, b.i = S, b.w = function(t2, e2) {
1406
1421
  return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
1407
1422
  };
1408
- var _ = function() {
1423
+ var _ = (function() {
1409
1424
  function M2(t2) {
1410
1425
  this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
1411
1426
  }
1412
1427
  var m2 = M2.prototype;
1413
1428
  return m2.parse = function(t2) {
1414
- this.$d = function(t3) {
1429
+ this.$d = (function(t3) {
1415
1430
  var e2 = t3.date, n2 = t3.utc;
1416
1431
  if (null === e2) return /* @__PURE__ */ new Date(NaN);
1417
1432
  if (b.u(e2)) return /* @__PURE__ */ new Date();
@@ -1424,7 +1439,7 @@ function requireDayjs_min() {
1424
1439
  }
1425
1440
  }
1426
1441
  return new Date(e2);
1427
- }(t2), this.init();
1442
+ })(t2), this.init();
1428
1443
  }, m2.init = function() {
1429
1444
  var t2 = this.$d;
1430
1445
  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();
@@ -1511,8 +1526,8 @@ function requireDayjs_min() {
1511
1526
  var r3 = t3 < 12 ? "AM" : "PM";
1512
1527
  return n3 ? r3.toLowerCase() : r3;
1513
1528
  };
1514
- return r2.replace(y, function(t3, r3) {
1515
- return r3 || function(t4) {
1529
+ return r2.replace(y, (function(t3, r3) {
1530
+ return r3 || (function(t4) {
1516
1531
  switch (t4) {
1517
1532
  case "YY":
1518
1533
  return String(e2.$y).slice(-2);
@@ -1564,8 +1579,8 @@ function requireDayjs_min() {
1564
1579
  return i2;
1565
1580
  }
1566
1581
  return null;
1567
- }(t3) || i2.replace(":", "");
1568
- });
1582
+ })(t3) || i2.replace(":", "");
1583
+ }));
1569
1584
  }, m2.utcOffset = function() {
1570
1585
  return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
1571
1586
  }, m2.diff = function(r2, d2, l2) {
@@ -1620,17 +1635,17 @@ function requireDayjs_min() {
1620
1635
  }, m2.toString = function() {
1621
1636
  return this.$d.toUTCString();
1622
1637
  }, M2;
1623
- }(), k = _.prototype;
1624
- return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c2], ["$y", h], ["$D", d]].forEach(function(t2) {
1638
+ })(), k = _.prototype;
1639
+ return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c2], ["$y", h], ["$D", d]].forEach((function(t2) {
1625
1640
  k[t2[1]] = function(e2) {
1626
1641
  return this.$g(e2, t2[0], t2[1]);
1627
1642
  };
1628
- }), O.extend = function(t2, e2) {
1643
+ })), O.extend = function(t2, e2) {
1629
1644
  return t2.$i || (t2(e2, _, O), t2.$i = true), O;
1630
1645
  }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
1631
1646
  return O(1e3 * t2);
1632
1647
  }, O.en = D[g], O.Ls = D, O.p = {}, O;
1633
- });
1648
+ }));
1634
1649
  })(dayjs_min$1);
1635
1650
  return dayjs_min$1.exports;
1636
1651
  }
@@ -1651,7 +1666,7 @@ const parseVersion = (tagName) => {
1651
1666
  if (major === void 0) {
1652
1667
  return void 0;
1653
1668
  }
1654
- const version = {
1669
+ const version2 = {
1655
1670
  major,
1656
1671
  original: tagName
1657
1672
  };
@@ -1660,26 +1675,26 @@ const parseVersion = (tagName) => {
1660
1675
  if (minor === void 0) {
1661
1676
  return void 0;
1662
1677
  }
1663
- version.minor = minor;
1678
+ version2.minor = minor;
1664
1679
  }
1665
1680
  if (match[3] !== void 0) {
1666
1681
  const build = parseVersionComponent(match[3]);
1667
1682
  if (build === void 0) {
1668
1683
  return void 0;
1669
1684
  }
1670
- version.build = build;
1685
+ version2.build = build;
1671
1686
  }
1672
1687
  if (match[4] !== void 0) {
1673
1688
  const revision = parseVersionComponent(match[4]);
1674
1689
  if (revision === void 0) {
1675
1690
  return void 0;
1676
1691
  }
1677
- version.revision = revision;
1692
+ version2.revision = revision;
1678
1693
  }
1679
- return version;
1694
+ return version2;
1680
1695
  };
1681
- const isValidVersion = (version) => {
1682
- return version.major >= 0 && (version.minor === void 0 || version.minor >= 0);
1696
+ const isValidVersion = (version2) => {
1697
+ return version2.major >= 0 && (version2.minor === void 0 || version2.minor >= 0);
1683
1698
  };
1684
1699
  const compareVersions = (a, b) => {
1685
1700
  var _a, _b, _c, _d, _e, _f;
@@ -1695,30 +1710,30 @@ const compareVersions = (a, b) => {
1695
1710
  if (aRevision !== bRevision) return bRevision - aRevision;
1696
1711
  return 0;
1697
1712
  };
1698
- const incrementLastVersionComponent = (version) => {
1699
- if (version.revision !== void 0) {
1700
- return { ...version, revision: version.revision + 1 };
1713
+ const incrementLastVersionComponent = (version2) => {
1714
+ if (version2.revision !== void 0) {
1715
+ return { ...version2, revision: version2.revision + 1 };
1701
1716
  }
1702
- if (version.build !== void 0) {
1703
- return { ...version, build: version.build + 1 };
1717
+ if (version2.build !== void 0) {
1718
+ return { ...version2, build: version2.build + 1 };
1704
1719
  }
1705
- if (version.minor !== void 0) {
1706
- return { ...version, minor: version.minor + 1 };
1720
+ if (version2.minor !== void 0) {
1721
+ return { ...version2, minor: version2.minor + 1 };
1707
1722
  }
1708
1723
  return {
1709
- ...version,
1710
- major: version.major + 1,
1711
- original: `${version.major + 1}`
1724
+ ...version2,
1725
+ major: version2.major + 1,
1726
+ original: `${version2.major + 1}`
1712
1727
  };
1713
1728
  };
1714
- const formatVersion = (version) => {
1715
- let result = `${version.major}`;
1716
- if (version.minor !== void 0) {
1717
- result += `.${version.minor}`;
1718
- if (version.build !== void 0) {
1719
- result += `.${version.build}`;
1720
- if (version.revision !== void 0) {
1721
- result += `.${version.revision}`;
1729
+ const formatVersion = (version2) => {
1730
+ let result = `${version2.major}`;
1731
+ if (version2.minor !== void 0) {
1732
+ result += `.${version2.minor}`;
1733
+ if (version2.build !== void 0) {
1734
+ result += `.${version2.build}`;
1735
+ if (version2.revision !== void 0) {
1736
+ result += `.${version2.revision}`;
1722
1737
  }
1723
1738
  }
1724
1739
  }
@@ -1760,13 +1775,21 @@ const getRelatedTags = async (repositoryPath, commitHash) => {
1760
1775
  for (const tagName of tags) {
1761
1776
  try {
1762
1777
  const tagOid = await git__namespace.resolveRef({ fs: fs__namespace, dir: repositoryPath, ref: `refs/tags/${tagName}` });
1763
- if (tagOid === commitHash) {
1764
- const version = parseVersion(tagName);
1765
- if (version && isValidVersion(version)) {
1778
+ let targetCommitOid = tagOid;
1779
+ try {
1780
+ const tagObject = await git__namespace.readTag({ fs: fs__namespace, dir: repositoryPath, oid: tagOid });
1781
+ if (tagObject && tagObject.tag.object) {
1782
+ targetCommitOid = tagObject.tag.object;
1783
+ }
1784
+ } catch (e) {
1785
+ }
1786
+ if (targetCommitOid === commitHash) {
1787
+ const version2 = parseVersion(tagName);
1788
+ if (version2 && isValidVersion(version2)) {
1766
1789
  tagInfos.push({
1767
1790
  name: tagName,
1768
1791
  hash: commitHash,
1769
- version
1792
+ version: version2
1770
1793
  });
1771
1794
  } else {
1772
1795
  tagInfos.push({
@@ -1791,13 +1814,21 @@ const getRelatedTagsForVersioning = async (repositoryPath, commitHash) => {
1791
1814
  for (const tagName of tags) {
1792
1815
  try {
1793
1816
  const tagOid = await git__namespace.resolveRef({ fs: fs__namespace, dir: repositoryPath, ref: `refs/tags/${tagName}` });
1794
- if (tagOid === commitHash) {
1795
- const version = parseVersion(tagName);
1796
- if (version && isValidVersion(version)) {
1817
+ let targetCommitOid = tagOid;
1818
+ try {
1819
+ const tagObject = await git__namespace.readTag({ fs: fs__namespace, dir: repositoryPath, oid: tagOid });
1820
+ if (tagObject && tagObject.tag.object) {
1821
+ targetCommitOid = tagObject.tag.object;
1822
+ }
1823
+ } catch (e) {
1824
+ }
1825
+ if (targetCommitOid === commitHash) {
1826
+ const version2 = parseVersion(tagName);
1827
+ if (version2 && isValidVersion(version2)) {
1797
1828
  tagInfos.push({
1798
1829
  name: tagName,
1799
1830
  hash: commitHash,
1800
- version
1831
+ version: version2
1801
1832
  });
1802
1833
  }
1803
1834
  }
@@ -1847,18 +1878,18 @@ const formatModifiedFile = (modifiedFile) => {
1847
1878
  };
1848
1879
  const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits) => {
1849
1880
  const scheduledStack = [];
1850
- let version = { major: 0, minor: 0, build: 1, original: "0.0.1" };
1881
+ let version2 = { major: 0, minor: 0, build: 1, original: "0.0.1" };
1851
1882
  let currentCommit = commit;
1852
1883
  while (true) {
1853
1884
  if (reachedCommits.has(currentCommit.hash)) {
1854
- version = reachedCommits.get(currentCommit.hash);
1885
+ version2 = reachedCommits.get(currentCommit.hash);
1855
1886
  break;
1856
1887
  }
1857
1888
  const relatedTags = await getRelatedTagsForVersioning(cwd, currentCommit.hash);
1858
1889
  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));
1859
1890
  if (versionCandidates.length >= 1) {
1860
- version = versionCandidates[0].version;
1861
- reachedCommits.set(currentCommit.hash, version);
1891
+ version2 = versionCandidates[0].version;
1892
+ reachedCommits.set(currentCommit.hash, version2);
1862
1893
  break;
1863
1894
  }
1864
1895
  let parentCommits = [];
@@ -1869,7 +1900,7 @@ const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits) => {
1869
1900
  } catch (e) {
1870
1901
  }
1871
1902
  if (parentCommits.length === 0) {
1872
- reachedCommits.set(currentCommit.hash, version);
1903
+ reachedCommits.set(currentCommit.hash, version2);
1873
1904
  break;
1874
1905
  }
1875
1906
  scheduledStack.push({ commit: currentCommit, parents: parentCommits });
@@ -1881,15 +1912,15 @@ const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits) => {
1881
1912
  if (parents.length >= 2) {
1882
1913
  for (let index = 1; index < parents.length; index++) {
1883
1914
  const alternateParentVersion = await lookupVersionLabelRecursive(cwd, parents[index], reachedCommits);
1884
- if (alternateParentVersion && compareVersions(alternateParentVersion, version) < 0) {
1885
- version = alternateParentVersion;
1915
+ if (alternateParentVersion && compareVersions(alternateParentVersion, version2) < 0) {
1916
+ version2 = alternateParentVersion;
1886
1917
  }
1887
1918
  }
1888
1919
  }
1889
- version = incrementLastVersionComponent(version);
1890
- reachedCommits.set(scheduledCommit.hash, version);
1920
+ version2 = incrementLastVersionComponent(version2);
1921
+ reachedCommits.set(scheduledCommit.hash, version2);
1891
1922
  }
1892
- return version;
1923
+ return version2;
1893
1924
  };
1894
1925
  const getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger) => {
1895
1926
  const metadata = {};
@@ -1905,19 +1936,19 @@ const getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logge
1905
1936
  return metadata;
1906
1937
  }
1907
1938
  const reachedCommits = /* @__PURE__ */ new Map();
1908
- let version = await lookupVersionLabelRecursive(gitRootPath, currentCommit, reachedCommits);
1939
+ let version2 = await lookupVersionLabelRecursive(gitRootPath, currentCommit, reachedCommits);
1909
1940
  const gitMetadata = { tags: [], branches: [] };
1910
1941
  metadata.git = gitMetadata;
1911
- if (version) {
1942
+ if (version2) {
1912
1943
  if (checkWorkingDirectoryStatus) {
1913
1944
  const modifiedFiles = await getModifiedFiles(gitRootPath);
1914
1945
  if (modifiedFiles.length >= 1) {
1915
- const newVersion = incrementLastVersionComponent(version);
1916
- logger.debug(`Increased git version by detected modified items: ${formatVersion(version)} ---> ${formatVersion(newVersion)}, Files=[${modifiedFiles.map(formatModifiedFile).join(", ")}]`);
1917
- version = newVersion;
1946
+ const newVersion = incrementLastVersionComponent(version2);
1947
+ logger.debug(`Increased git version by detected modified items: ${formatVersion(version2)} ---> ${formatVersion(newVersion)}, Files=[${modifiedFiles.map(formatModifiedFile).join(", ")}]`);
1948
+ version2 = newVersion;
1918
1949
  }
1919
1950
  }
1920
- const gitVersion = formatVersion(version);
1951
+ const gitVersion = formatVersion(version2);
1921
1952
  gitMetadata.version = gitVersion;
1922
1953
  metadata.version = gitVersion;
1923
1954
  }
@@ -1949,11 +1980,30 @@ const getFetchGitMetadata = (targetDir, checkWorkingDirectoryStatus, logger) =>
1949
1980
  return cachedMetadata;
1950
1981
  };
1951
1982
  };
1983
+ const name = "screw-up";
1984
+ const version = "1.2.0";
1985
+ const author = "Kouji Matsui (@kekyo@mi.kekyo.net)";
1986
+ const license = "MIT";
1987
+ const repository_url = "https://github.com/kekyo/screw-up.git";
1988
+ const git_commit_hash = "cc82696555da70d209bcd4d7ca6cba330360e074";
1989
+ const packageMetadata = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1990
+ __proto__: null,
1991
+ author,
1992
+ git_commit_hash,
1993
+ license,
1994
+ name,
1995
+ repository_url,
1996
+ version
1997
+ }, Symbol.toStringTag, { value: "Module" }));
1952
1998
  exports.collectWorkspaceSiblings = collectWorkspaceSiblings;
1953
1999
  exports.createConsoleLogger = createConsoleLogger;
1954
2000
  exports.findWorkspaceRoot = findWorkspaceRoot;
1955
2001
  exports.getFetchGitMetadata = getFetchGitMetadata;
2002
+ exports.git_commit_hash = git_commit_hash;
2003
+ exports.name = name;
2004
+ exports.packageMetadata = packageMetadata;
1956
2005
  exports.replacePeerDependenciesWildcards = replacePeerDependenciesWildcards;
1957
2006
  exports.resolvePackageMetadata = resolvePackageMetadata;
1958
2007
  exports.resolveRawPackageJsonObject = resolveRawPackageJsonObject;
1959
- //# sourceMappingURL=analyzer-BxxtJjNH.cjs.map
2008
+ exports.version = version;
2009
+ //# sourceMappingURL=packageMetadata-Bg66jaR4.cjs.map