screw-up 1.5.0 → 1.7.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.
- package/dist/analyzer.d.ts +20 -2
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/cli-internal.d.ts +2 -2
- package/dist/cli.d.ts +2 -2
- package/dist/fast-tags.d.ts +42 -0
- package/dist/fast-tags.d.ts.map +1 -0
- package/dist/generated/packageMetadata.d.ts +4 -4
- package/dist/git-operations.d.ts +69 -0
- package/dist/git-operations.d.ts.map +1 -0
- package/dist/index.cjs +21 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/main.cjs +4 -4
- package/dist/main.d.ts +2 -2
- package/dist/main.js +4 -4
- package/dist/{packageMetadata-CbqTWPYD.cjs → packageMetadata-B3Z9TVh6.cjs} +220 -126
- package/dist/packageMetadata-B3Z9TVh6.cjs.map +1 -0
- package/dist/{packageMetadata-C2Yob7-F.js → packageMetadata-CTjfzPVl.js} +222 -128
- package/dist/packageMetadata-CTjfzPVl.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/vite-plugin.d.ts +2 -2
- package/dist/vite-plugin.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/packageMetadata-C2Yob7-F.js.map +0 -1
- package/dist/packageMetadata-CbqTWPYD.cjs.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: screw-up
|
|
3
|
-
* version: 1.
|
|
3
|
+
* version: 1.7.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:
|
|
8
|
+
* git.commit.hash: 0865d5a2d4d1e89be8dae4b6abeba1393a767707
|
|
9
9
|
*/
|
|
10
10
|
import { existsSync } from "fs";
|
|
11
11
|
import * as fs from "fs/promises";
|
|
12
|
-
import { readFile } from "fs/promises";
|
|
13
|
-
import { dirname, join } from "path";
|
|
12
|
+
import fs__default, { readFile } from "fs/promises";
|
|
13
|
+
import path, { dirname, join } from "path";
|
|
14
14
|
import { glob } from "glob";
|
|
15
15
|
import * as git from "isomorphic-git";
|
|
16
16
|
var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
|
@@ -1651,6 +1651,195 @@ function requireDayjs_min() {
|
|
|
1651
1651
|
}
|
|
1652
1652
|
var dayjs_minExports = requireDayjs_min();
|
|
1653
1653
|
const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
|
|
1654
|
+
const parsePackedRefs = async (packedRefsPath) => {
|
|
1655
|
+
try {
|
|
1656
|
+
const content = await fs__default.readFile(packedRefsPath, "utf-8");
|
|
1657
|
+
const lines = content.split("\n");
|
|
1658
|
+
const tags = [];
|
|
1659
|
+
for (const line2 of lines) {
|
|
1660
|
+
if (line2.startsWith("#") || !line2.trim()) continue;
|
|
1661
|
+
const match = line2.match(/^[0-9a-f]{40}\s+refs\/tags\/(.+)$/);
|
|
1662
|
+
if (match) {
|
|
1663
|
+
const tagName = match[1];
|
|
1664
|
+
if (!tagName.endsWith("^{}")) {
|
|
1665
|
+
tags.push(tagName);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
return tags;
|
|
1670
|
+
} catch (error) {
|
|
1671
|
+
if (error.code === "ENOENT") {
|
|
1672
|
+
return [];
|
|
1673
|
+
}
|
|
1674
|
+
throw error;
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
const readLooseTags = async (refsTagsPath) => {
|
|
1678
|
+
try {
|
|
1679
|
+
const entries = await fs__default.readdir(refsTagsPath, { withFileTypes: true });
|
|
1680
|
+
const tags = [];
|
|
1681
|
+
for (const entry of entries) {
|
|
1682
|
+
if (entry.isFile()) {
|
|
1683
|
+
tags.push(entry.name);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
return tags;
|
|
1687
|
+
} catch (error) {
|
|
1688
|
+
if (error.code === "ENOENT") {
|
|
1689
|
+
return [];
|
|
1690
|
+
}
|
|
1691
|
+
throw error;
|
|
1692
|
+
}
|
|
1693
|
+
};
|
|
1694
|
+
const listTagsFast = async (repoPath) => {
|
|
1695
|
+
const gitDir = path.join(repoPath, ".git");
|
|
1696
|
+
const gitStat = await fs__default.stat(gitDir).catch(() => null);
|
|
1697
|
+
let actualGitDir = gitDir;
|
|
1698
|
+
if (gitStat == null ? void 0 : gitStat.isFile()) {
|
|
1699
|
+
const content = await fs__default.readFile(gitDir, "utf-8");
|
|
1700
|
+
const match = content.match(/^gitdir:\s*(.+)$/m);
|
|
1701
|
+
if (match) {
|
|
1702
|
+
actualGitDir = path.isAbsolute(match[1]) ? match[1] : path.join(repoPath, match[1]);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
const [packedTags, looseTags] = await Promise.all([
|
|
1706
|
+
parsePackedRefs(path.join(actualGitDir, "packed-refs")),
|
|
1707
|
+
readLooseTags(path.join(actualGitDir, "refs", "tags"))
|
|
1708
|
+
]);
|
|
1709
|
+
const allTags = /* @__PURE__ */ new Set([...packedTags, ...looseTags]);
|
|
1710
|
+
return Array.from(allTags).sort();
|
|
1711
|
+
};
|
|
1712
|
+
const resolveTagsBatchWithCommit = async (repoPath, tagNames, logger) => {
|
|
1713
|
+
const startTime = Date.now();
|
|
1714
|
+
const gitDir = path.join(repoPath, ".git");
|
|
1715
|
+
const result = /* @__PURE__ */ new Map();
|
|
1716
|
+
const gitStat = await fs__default.stat(gitDir).catch(() => null);
|
|
1717
|
+
let actualGitDir = gitDir;
|
|
1718
|
+
if (gitStat == null ? void 0 : gitStat.isFile()) {
|
|
1719
|
+
const content = await fs__default.readFile(gitDir, "utf-8");
|
|
1720
|
+
const match = content.match(/^gitdir:\s*(.+)$/m);
|
|
1721
|
+
if (match) {
|
|
1722
|
+
actualGitDir = path.isAbsolute(match[1]) ? match[1] : path.join(repoPath, match[1]);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
const tagSet = new Set(tagNames);
|
|
1726
|
+
const packedRefsStart = Date.now();
|
|
1727
|
+
try {
|
|
1728
|
+
const content = await fs__default.readFile(
|
|
1729
|
+
path.join(actualGitDir, "packed-refs"),
|
|
1730
|
+
"utf-8"
|
|
1731
|
+
);
|
|
1732
|
+
const lines = content.split("\n");
|
|
1733
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1734
|
+
const line2 = lines[i];
|
|
1735
|
+
if (line2.startsWith("#") || !line2.trim()) continue;
|
|
1736
|
+
const match = line2.match(/^([0-9a-f]{40})\s+refs\/tags\/(.+)$/);
|
|
1737
|
+
if (match && tagSet.has(match[2])) {
|
|
1738
|
+
const tagName = match[2];
|
|
1739
|
+
const oid = match[1];
|
|
1740
|
+
let commitOid = oid;
|
|
1741
|
+
if (i + 1 < lines.length && lines[i + 1].startsWith("^")) {
|
|
1742
|
+
commitOid = lines[i + 1].substring(1, 41);
|
|
1743
|
+
}
|
|
1744
|
+
result.set(tagName, { oid, commitOid });
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
} catch (error) {
|
|
1748
|
+
if (error.code !== "ENOENT") {
|
|
1749
|
+
throw error;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
logger.debug(
|
|
1753
|
+
`[fast-tags] read packed-refs: ${Date.now() - packedRefsStart}ms`
|
|
1754
|
+
);
|
|
1755
|
+
const remainingTags = tagNames.filter((tag) => !result.has(tag));
|
|
1756
|
+
if (remainingTags.length > 0) {
|
|
1757
|
+
const looseRefsStart = Date.now();
|
|
1758
|
+
await Promise.all(
|
|
1759
|
+
remainingTags.map(async (tagName) => {
|
|
1760
|
+
const looseRefPath = path.join(actualGitDir, "refs", "tags", tagName);
|
|
1761
|
+
try {
|
|
1762
|
+
const hash = await fs__default.readFile(looseRefPath, "utf-8");
|
|
1763
|
+
const oid = hash.trim();
|
|
1764
|
+
let commitOid = oid;
|
|
1765
|
+
try {
|
|
1766
|
+
const { execSync } = require("child_process");
|
|
1767
|
+
const objectType = execSync(
|
|
1768
|
+
`git -C "${repoPath}" cat-file -t ${oid}`,
|
|
1769
|
+
{ encoding: "utf-8" }
|
|
1770
|
+
).trim();
|
|
1771
|
+
if (objectType === "tag") {
|
|
1772
|
+
const tagContent = execSync(
|
|
1773
|
+
`git -C "${repoPath}" cat-file -p ${oid}`,
|
|
1774
|
+
{ encoding: "utf-8" }
|
|
1775
|
+
);
|
|
1776
|
+
const objectMatch = tagContent.match(/^object ([0-9a-f]{40})$/m);
|
|
1777
|
+
if (objectMatch) {
|
|
1778
|
+
commitOid = objectMatch[1];
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
} catch (error) {
|
|
1782
|
+
logger.debug(
|
|
1783
|
+
`[fast-tags] Could not determine object type for ${tagName}: ${error}`
|
|
1784
|
+
);
|
|
1785
|
+
}
|
|
1786
|
+
result.set(tagName, { oid, commitOid });
|
|
1787
|
+
} catch (error) {
|
|
1788
|
+
if (error.code !== "ENOENT") {
|
|
1789
|
+
throw error;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
})
|
|
1793
|
+
);
|
|
1794
|
+
logger.debug(
|
|
1795
|
+
`[fast-tags] read loose refs: ${Date.now() - looseRefsStart}ms`
|
|
1796
|
+
);
|
|
1797
|
+
}
|
|
1798
|
+
const totalTime = Date.now() - startTime;
|
|
1799
|
+
logger.debug(`[fast-tags] resolveTagsBatchWithCommit total: ${totalTime}ms`);
|
|
1800
|
+
logger.debug(`[fast-tags] Resolved ${result.size}/${tagNames.length} tags`);
|
|
1801
|
+
return result;
|
|
1802
|
+
};
|
|
1803
|
+
const buildCompleteTagCache = async (repoPath, parseVersion2, logger) => {
|
|
1804
|
+
const totalStart = Date.now();
|
|
1805
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1806
|
+
const listStart = Date.now();
|
|
1807
|
+
const tags = await listTagsFast(repoPath);
|
|
1808
|
+
logger.debug(`[git-ops] listTagsFast: ${Date.now() - listStart}ms`);
|
|
1809
|
+
logger.debug(`[git-ops] Found ${tags.length} tags`);
|
|
1810
|
+
const resolveStart = Date.now();
|
|
1811
|
+
const tagData = await resolveTagsBatchWithCommit(repoPath, tags, logger);
|
|
1812
|
+
logger.debug(
|
|
1813
|
+
`[git-ops] resolveTagsBatchWithCommit: ${Date.now() - resolveStart}ms`
|
|
1814
|
+
);
|
|
1815
|
+
const buildStart = Date.now();
|
|
1816
|
+
for (const tagName of tags) {
|
|
1817
|
+
const data = tagData.get(tagName);
|
|
1818
|
+
if (!data) continue;
|
|
1819
|
+
const { commitOid } = data;
|
|
1820
|
+
const version2 = parseVersion2(tagName);
|
|
1821
|
+
const tagInfo = {
|
|
1822
|
+
name: tagName,
|
|
1823
|
+
hash: commitOid,
|
|
1824
|
+
version: version2
|
|
1825
|
+
};
|
|
1826
|
+
if (!cache.has(commitOid)) {
|
|
1827
|
+
cache.set(commitOid, []);
|
|
1828
|
+
}
|
|
1829
|
+
cache.get(commitOid).push(tagInfo);
|
|
1830
|
+
}
|
|
1831
|
+
logger.debug(`[git-ops] build cache map: ${Date.now() - buildStart}ms`);
|
|
1832
|
+
const sortStart = Date.now();
|
|
1833
|
+
for (const tags2 of cache.values()) {
|
|
1834
|
+
tags2.sort((a, b) => a.name.localeCompare(b.name));
|
|
1835
|
+
}
|
|
1836
|
+
logger.debug(`[git-ops] sort tags: ${Date.now() - sortStart}ms`);
|
|
1837
|
+
logger.debug(
|
|
1838
|
+
`[git-ops] buildCompleteTagCache total: ${Date.now() - totalStart}ms`
|
|
1839
|
+
);
|
|
1840
|
+
logger.debug(`[git-ops] Built cache with ${cache.size} unique commits`);
|
|
1841
|
+
return cache;
|
|
1842
|
+
};
|
|
1654
1843
|
const parseVersionComponent = (value) => {
|
|
1655
1844
|
const num = parseInt(value, 10);
|
|
1656
1845
|
return num < 0 || num > 65535 ? void 0 : num;
|
|
@@ -1776,120 +1965,8 @@ const getCurrentCommit = async (repositoryPath) => {
|
|
|
1776
1965
|
return void 0;
|
|
1777
1966
|
}
|
|
1778
1967
|
};
|
|
1779
|
-
const
|
|
1780
|
-
|
|
1781
|
-
commitToTags: /* @__PURE__ */ new Map(),
|
|
1782
|
-
initialized: true
|
|
1783
|
-
};
|
|
1784
|
-
try {
|
|
1785
|
-
const tags = await git.listTags({ fs, dir: repositoryPath });
|
|
1786
|
-
await Promise.all(
|
|
1787
|
-
tags.map(async (tagName) => {
|
|
1788
|
-
try {
|
|
1789
|
-
const tagOid = await git.resolveRef({
|
|
1790
|
-
fs,
|
|
1791
|
-
dir: repositoryPath,
|
|
1792
|
-
ref: `refs/tags/${tagName}`
|
|
1793
|
-
});
|
|
1794
|
-
const version2 = parseVersion(tagName);
|
|
1795
|
-
const tagInfo = {
|
|
1796
|
-
name: tagName,
|
|
1797
|
-
hash: tagOid,
|
|
1798
|
-
// This will be updated for annotated tags
|
|
1799
|
-
version: version2 && isValidVersion(version2) ? version2 : void 0
|
|
1800
|
-
};
|
|
1801
|
-
if (!cache.commitToTags.has(tagOid)) {
|
|
1802
|
-
cache.commitToTags.set(tagOid, []);
|
|
1803
|
-
}
|
|
1804
|
-
cache.commitToTags.get(tagOid).push({ ...tagInfo, hash: tagOid });
|
|
1805
|
-
try {
|
|
1806
|
-
const tagObject = await git.readTag({
|
|
1807
|
-
fs,
|
|
1808
|
-
dir: repositoryPath,
|
|
1809
|
-
oid: tagOid
|
|
1810
|
-
});
|
|
1811
|
-
if (tagObject && tagObject.tag.object) {
|
|
1812
|
-
const commitOid = tagObject.tag.object;
|
|
1813
|
-
const lightweightTags = cache.commitToTags.get(tagOid);
|
|
1814
|
-
if (lightweightTags) {
|
|
1815
|
-
const index = lightweightTags.findIndex(
|
|
1816
|
-
(t) => t.name === tagName
|
|
1817
|
-
);
|
|
1818
|
-
if (index >= 0) {
|
|
1819
|
-
lightweightTags.splice(index, 1);
|
|
1820
|
-
if (lightweightTags.length === 0) {
|
|
1821
|
-
cache.commitToTags.delete(tagOid);
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
if (!cache.commitToTags.has(commitOid)) {
|
|
1826
|
-
cache.commitToTags.set(commitOid, []);
|
|
1827
|
-
}
|
|
1828
|
-
cache.commitToTags.get(commitOid).push({ ...tagInfo, hash: commitOid });
|
|
1829
|
-
}
|
|
1830
|
-
} catch (e) {
|
|
1831
|
-
}
|
|
1832
|
-
} catch (e) {
|
|
1833
|
-
}
|
|
1834
|
-
})
|
|
1835
|
-
);
|
|
1836
|
-
} catch (e) {
|
|
1837
|
-
}
|
|
1838
|
-
return cache;
|
|
1839
|
-
};
|
|
1840
|
-
const getRelatedTagsFromCache = (cache, commitHash) => {
|
|
1841
|
-
if (!cache.initialized) {
|
|
1842
|
-
return [];
|
|
1843
|
-
}
|
|
1844
|
-
return cache.commitToTags.get(commitHash) || [];
|
|
1845
|
-
};
|
|
1846
|
-
const getRelatedTagsForVersioning = async (repositoryPath, commitHash) => {
|
|
1847
|
-
try {
|
|
1848
|
-
const tags = await git.listTags({ fs, dir: repositoryPath });
|
|
1849
|
-
const tagInfos = [];
|
|
1850
|
-
for (const tagName of tags) {
|
|
1851
|
-
try {
|
|
1852
|
-
const tagOid = await git.resolveRef({
|
|
1853
|
-
fs,
|
|
1854
|
-
dir: repositoryPath,
|
|
1855
|
-
ref: `refs/tags/${tagName}`
|
|
1856
|
-
});
|
|
1857
|
-
if (tagOid === commitHash) {
|
|
1858
|
-
const version2 = parseVersion(tagName);
|
|
1859
|
-
if (version2 && isValidVersion(version2)) {
|
|
1860
|
-
tagInfos.push({
|
|
1861
|
-
name: tagName,
|
|
1862
|
-
hash: commitHash,
|
|
1863
|
-
version: version2
|
|
1864
|
-
});
|
|
1865
|
-
}
|
|
1866
|
-
} else {
|
|
1867
|
-
try {
|
|
1868
|
-
const tagObject = await git.readTag({
|
|
1869
|
-
fs,
|
|
1870
|
-
dir: repositoryPath,
|
|
1871
|
-
oid: tagOid
|
|
1872
|
-
});
|
|
1873
|
-
if (tagObject && tagObject.tag.object === commitHash) {
|
|
1874
|
-
const version2 = parseVersion(tagName);
|
|
1875
|
-
if (version2 && isValidVersion(version2)) {
|
|
1876
|
-
tagInfos.push({
|
|
1877
|
-
name: tagName,
|
|
1878
|
-
hash: commitHash,
|
|
1879
|
-
version: version2
|
|
1880
|
-
});
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
} catch (e) {
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
} catch (e) {
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
return tagInfos;
|
|
1890
|
-
} catch (e) {
|
|
1891
|
-
return [];
|
|
1892
|
-
}
|
|
1968
|
+
const getRelatedTagsFromMap = (commitToTags, commitHash) => {
|
|
1969
|
+
return commitToTags.get(commitHash) || [];
|
|
1893
1970
|
};
|
|
1894
1971
|
const getRelatedBranches = async (repositoryPath, commitHash) => {
|
|
1895
1972
|
try {
|
|
@@ -1931,7 +2008,7 @@ const getModifiedFiles = async (repositoryPath) => {
|
|
|
1931
2008
|
const formatModifiedFile = (modifiedFile) => {
|
|
1932
2009
|
return `'${modifiedFile[0]}':${modifiedFile[1]}:${modifiedFile[2]}:${modifiedFile[3]}`;
|
|
1933
2010
|
};
|
|
1934
|
-
const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits,
|
|
2011
|
+
const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, commitToTags) => {
|
|
1935
2012
|
const scheduledStack = [];
|
|
1936
2013
|
let version2 = { major: 0, minor: 0, build: 1, original: "0.0.1" };
|
|
1937
2014
|
let currentCommit = commit;
|
|
@@ -1940,7 +2017,7 @@ const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, tagCache
|
|
|
1940
2017
|
version2 = reachedCommits.get(currentCommit.hash);
|
|
1941
2018
|
break;
|
|
1942
2019
|
}
|
|
1943
|
-
const relatedTags =
|
|
2020
|
+
const relatedTags = getRelatedTagsFromMap(commitToTags, currentCommit.hash);
|
|
1944
2021
|
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));
|
|
1945
2022
|
if (versionCandidates.length >= 1) {
|
|
1946
2023
|
version2 = versionCandidates[0].version;
|
|
@@ -1976,7 +2053,7 @@ const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, tagCache
|
|
|
1976
2053
|
cwd,
|
|
1977
2054
|
parents[index],
|
|
1978
2055
|
reachedCommits,
|
|
1979
|
-
|
|
2056
|
+
commitToTags
|
|
1980
2057
|
);
|
|
1981
2058
|
if (alternateParentVersion && compareVersions(alternateParentVersion, version2) < 0) {
|
|
1982
2059
|
version2 = alternateParentVersion;
|
|
@@ -1989,28 +2066,44 @@ const lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, tagCache
|
|
|
1989
2066
|
return version2;
|
|
1990
2067
|
};
|
|
1991
2068
|
const getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger) => {
|
|
2069
|
+
const startTime = Date.now();
|
|
1992
2070
|
const metadata = {};
|
|
1993
2071
|
let gitRootPath;
|
|
1994
2072
|
try {
|
|
1995
2073
|
gitRootPath = await git.findRoot({ fs, filepath: repositoryPath });
|
|
1996
2074
|
} catch (e) {
|
|
2075
|
+
logger.debug(
|
|
2076
|
+
`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`
|
|
2077
|
+
);
|
|
1997
2078
|
return metadata;
|
|
1998
2079
|
}
|
|
1999
2080
|
try {
|
|
2000
2081
|
const currentCommit = await getCurrentCommit(gitRootPath);
|
|
2001
2082
|
if (!currentCommit) {
|
|
2083
|
+
logger.debug(
|
|
2084
|
+
`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`
|
|
2085
|
+
);
|
|
2002
2086
|
return metadata;
|
|
2003
2087
|
}
|
|
2004
|
-
const
|
|
2088
|
+
const buildStart = Date.now();
|
|
2089
|
+
const commitToTags = await buildCompleteTagCache(
|
|
2090
|
+
gitRootPath,
|
|
2091
|
+
(tagName) => {
|
|
2092
|
+
const version22 = parseVersion(tagName);
|
|
2093
|
+
return version22 && isValidVersion(version22) ? version22 : void 0;
|
|
2094
|
+
},
|
|
2095
|
+
logger
|
|
2096
|
+
);
|
|
2005
2097
|
logger.debug(
|
|
2006
|
-
`
|
|
2098
|
+
`[screw-up] buildCompleteTagCache: ${Date.now() - buildStart}ms`
|
|
2007
2099
|
);
|
|
2100
|
+
logger.debug(`Built tag map with ${commitToTags.size} commits`);
|
|
2008
2101
|
const reachedCommits = /* @__PURE__ */ new Map();
|
|
2009
2102
|
let version2 = await lookupVersionLabelRecursive(
|
|
2010
2103
|
gitRootPath,
|
|
2011
2104
|
currentCommit,
|
|
2012
2105
|
reachedCommits,
|
|
2013
|
-
|
|
2106
|
+
commitToTags
|
|
2014
2107
|
);
|
|
2015
2108
|
const gitMetadata = { tags: [], branches: [] };
|
|
2016
2109
|
metadata.git = gitMetadata;
|
|
@@ -2035,7 +2128,7 @@ const getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logge
|
|
|
2035
2128
|
date: dayjs(currentCommit.date).format("YYYY-MM-DDTHH:mm:ssZ[Z]"),
|
|
2036
2129
|
message: currentCommit.message
|
|
2037
2130
|
};
|
|
2038
|
-
const relatedTags =
|
|
2131
|
+
const relatedTags = getRelatedTagsFromMap(commitToTags, currentCommit.hash);
|
|
2039
2132
|
gitMetadata.tags = relatedTags.map((tag) => tag.name);
|
|
2040
2133
|
const relatedBranches = await getRelatedBranches(
|
|
2041
2134
|
gitRootPath,
|
|
@@ -2045,6 +2138,7 @@ const getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logge
|
|
|
2045
2138
|
} catch (error) {
|
|
2046
2139
|
logger.warn(`Failed to extract git metadata: ${error}`);
|
|
2047
2140
|
}
|
|
2141
|
+
logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
|
|
2048
2142
|
return metadata;
|
|
2049
2143
|
};
|
|
2050
2144
|
const getFetchGitMetadata = (targetDir, checkWorkingDirectoryStatus, logger) => {
|
|
@@ -2061,11 +2155,11 @@ const getFetchGitMetadata = (targetDir, checkWorkingDirectoryStatus, logger) =>
|
|
|
2061
2155
|
};
|
|
2062
2156
|
};
|
|
2063
2157
|
const name = "screw-up";
|
|
2064
|
-
const version = "1.
|
|
2158
|
+
const version = "1.7.0";
|
|
2065
2159
|
const author = "Kouji Matsui (@kekyo@mi.kekyo.net)";
|
|
2066
2160
|
const license = "MIT";
|
|
2067
2161
|
const repository_url = "https://github.com/kekyo/screw-up.git";
|
|
2068
|
-
const git_commit_hash = "
|
|
2162
|
+
const git_commit_hash = "0865d5a2d4d1e89be8dae4b6abeba1393a767707";
|
|
2069
2163
|
const packageMetadata = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2070
2164
|
__proto__: null,
|
|
2071
2165
|
author,
|
|
@@ -2088,4 +2182,4 @@ export {
|
|
|
2088
2182
|
resolvePackageMetadata as r,
|
|
2089
2183
|
version as v
|
|
2090
2184
|
};
|
|
2091
|
-
//# sourceMappingURL=packageMetadata-
|
|
2185
|
+
//# sourceMappingURL=packageMetadata-CTjfzPVl.js.map
|