screw-up 1.32.0 → 1.34.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/index.cjs +125 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3 -11
- package/dist/index.mjs.map +1 -1
- package/dist/main.cjs +132 -63
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +4 -6
- package/dist/main.mjs.map +1 -1
- package/dist/{metadata-file-D79yMa_A.js → metadata-file-DmnBAdfN.js} +130 -68
- package/dist/metadata-file-DmnBAdfN.js.map +1 -0
- package/dist/src/analyzer.d.ts +2 -2
- package/dist/src/analyzer.d.ts.map +1 -1
- package/dist/src/cli-internal.d.ts +2 -2
- package/dist/src/cli.d.ts +2 -2
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/declaration-import-fix.d.ts +2 -2
- package/dist/src/default-import-fix.d.ts +2 -2
- package/dist/src/fast-tags.d.ts +2 -2
- package/dist/src/generated/packageMetadata.d.ts +4 -4
- package/dist/src/git-operations.d.ts +2 -2
- package/dist/src/git-operations.d.ts.map +1 -1
- package/dist/src/git-ref-utils.d.ts +34 -6
- package/dist/src/git-ref-utils.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/internal.d.ts +2 -2
- package/dist/src/main.d.ts +2 -2
- package/dist/src/metadata-file.d.ts +2 -2
- package/dist/src/text-edits.d.ts +2 -2
- package/dist/src/types.d.ts +2 -2
- package/dist/src/vite-plugin.d.ts +2 -2
- package/package.json +10 -10
- package/dist/metadata-file-D79yMa_A.js.map +0 -1
- package/dist/packageMetadata-6po5LHyH.cjs +0 -55
- package/dist/packageMetadata-6po5LHyH.cjs.map +0 -1
- package/dist/packageMetadata-Cwh4Fqmw.cjs +0 -15
- package/dist/packageMetadata-Sm2NpI2b.js +0 -29
- package/dist/packageMetadata-Sm2NpI2b.js.map +0 -1
package/dist/main.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*!
|
|
3
3
|
* name: screw-up
|
|
4
|
-
* version: 1.
|
|
4
|
+
* version: 1.34.0
|
|
5
5
|
* description: Simply package metadata inserter on Vite plugin
|
|
6
6
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
7
7
|
* license: MIT
|
|
8
8
|
* repository.url: https://github.com/kekyo/screw-up.git
|
|
9
|
-
* git.commit.hash:
|
|
9
|
+
* git.commit.hash: bcd53f2a2326d1600b105c38a496c6c9c04b6a97
|
|
10
10
|
*/
|
|
11
11
|
//#region \0rolldown/runtime.js
|
|
12
12
|
var __create = Object.create;
|
|
@@ -15,7 +15,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
15
15
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
16
|
var __getProtoOf = Object.getPrototypeOf;
|
|
17
17
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
18
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
19
19
|
var __copyProps = (to, from, except, desc) => {
|
|
20
20
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
21
21
|
key = keys[i];
|
|
@@ -31,11 +31,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
31
|
enumerable: true
|
|
32
32
|
}) : target, mod));
|
|
33
33
|
//#endregion
|
|
34
|
-
const require_packageMetadata = require("./packageMetadata-6po5LHyH.cjs");
|
|
35
34
|
let path = require("path");
|
|
36
35
|
let fs = require("fs");
|
|
37
36
|
let fs_promises = require("fs/promises");
|
|
38
|
-
fs_promises = __toESM(fs_promises);
|
|
37
|
+
fs_promises = __toESM(fs_promises, 1);
|
|
39
38
|
let child_process = require("child_process");
|
|
40
39
|
let os = require("os");
|
|
41
40
|
let stream = require("stream");
|
|
@@ -43,7 +42,7 @@ let zlib = require("zlib");
|
|
|
43
42
|
let stream_promises = require("stream/promises");
|
|
44
43
|
let glob = require("glob");
|
|
45
44
|
let isomorphic_git = require("isomorphic-git");
|
|
46
|
-
isomorphic_git = __toESM(isomorphic_git);
|
|
45
|
+
isomorphic_git = __toESM(isomorphic_git, 1);
|
|
47
46
|
let crypto = require("crypto");
|
|
48
47
|
//#region node_modules/tar-vern/dist/index.js
|
|
49
48
|
/*!
|
|
@@ -2417,17 +2416,45 @@ var PACKED_OBJECT_TYPE_BY_CODE = new Map([
|
|
|
2417
2416
|
[7, "ref-delta"]
|
|
2418
2417
|
]);
|
|
2419
2418
|
/**
|
|
2420
|
-
* Resolve
|
|
2419
|
+
* Resolve Git directory paths for repositories, worktrees, and submodules.
|
|
2421
2420
|
* @param repoPath - Repository path
|
|
2422
|
-
* @returns The resolved Git directory
|
|
2421
|
+
* @returns The resolved Git directory paths
|
|
2423
2422
|
*/
|
|
2424
|
-
var
|
|
2423
|
+
var resolveGitDirectoryPaths = async (repoPath) => {
|
|
2425
2424
|
const gitDir = (0, path.join)(repoPath, ".git");
|
|
2426
2425
|
const gitStat = await (0, fs_promises.stat)(gitDir).catch(() => null);
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2426
|
+
const resolvedGitDir = !(gitStat === null || gitStat === void 0 ? void 0 : gitStat.isFile()) ? gitDir : await (async () => {
|
|
2427
|
+
const match = (await (0, fs_promises.readFile)(gitDir, "utf-8")).match(/^gitdir:\s*(.+)$/m);
|
|
2428
|
+
if (!match) return gitDir;
|
|
2429
|
+
return (0, path.isAbsolute)(match[1]) ? match[1] : (0, path.join)(repoPath, match[1]);
|
|
2430
|
+
})();
|
|
2431
|
+
return {
|
|
2432
|
+
gitDir: resolvedGitDir,
|
|
2433
|
+
commonGitDir: await (0, fs_promises.readFile)((0, path.join)(resolvedGitDir, "commondir"), "utf-8").then((content) => {
|
|
2434
|
+
const commondir = content.trim();
|
|
2435
|
+
if (!commondir) return resolvedGitDir;
|
|
2436
|
+
return (0, path.isAbsolute)(commondir) ? commondir : (0, path.join)(resolvedGitDir, commondir);
|
|
2437
|
+
}).catch((error) => {
|
|
2438
|
+
if ((error === null || error === void 0 ? void 0 : error.code) !== "ENOENT") throw error;
|
|
2439
|
+
return resolvedGitDir;
|
|
2440
|
+
})
|
|
2441
|
+
};
|
|
2442
|
+
};
|
|
2443
|
+
/**
|
|
2444
|
+
* Resolve the worktree-specific Git directory.
|
|
2445
|
+
* @param repoPath - Repository path
|
|
2446
|
+
* @returns The resolved worktree-specific Git directory path
|
|
2447
|
+
*/
|
|
2448
|
+
var getActualGitDir = async (repoPath) => {
|
|
2449
|
+
return (await resolveGitDirectoryPaths(repoPath)).gitDir;
|
|
2450
|
+
};
|
|
2451
|
+
/**
|
|
2452
|
+
* Resolve the common Git directory used for refs and objects.
|
|
2453
|
+
* @param repoPath - Repository path
|
|
2454
|
+
* @returns The resolved common Git directory path
|
|
2455
|
+
*/
|
|
2456
|
+
var getCommonGitDir = async (repoPath) => {
|
|
2457
|
+
return (await resolveGitDirectoryPaths(repoPath)).commonGitDir;
|
|
2431
2458
|
};
|
|
2432
2459
|
var readFixedRange = async (fileHandle, offset, length) => {
|
|
2433
2460
|
const buffer = Buffer.alloc(length);
|
|
@@ -2644,11 +2671,11 @@ var parseTreeEntries = (treeContent) => {
|
|
|
2644
2671
|
return entries;
|
|
2645
2672
|
};
|
|
2646
2673
|
var createGitObjectResolver = async (repoPath) => {
|
|
2647
|
-
const
|
|
2674
|
+
const commonGitDir = await getCommonGitDir(repoPath);
|
|
2648
2675
|
const resolvedObjects = /* @__PURE__ */ new Map();
|
|
2649
2676
|
let packStorePromise;
|
|
2650
2677
|
const getPackStore = async () => {
|
|
2651
|
-
if (!packStorePromise) packStorePromise = loadPackStore(
|
|
2678
|
+
if (!packStorePromise) packStorePromise = loadPackStore(commonGitDir);
|
|
2652
2679
|
return packStorePromise;
|
|
2653
2680
|
};
|
|
2654
2681
|
const readPackedObject = async (location) => {
|
|
@@ -2684,7 +2711,7 @@ var createGitObjectResolver = async (repoPath) => {
|
|
|
2684
2711
|
const cachedObject = resolvedObjects.get(oid);
|
|
2685
2712
|
if (cachedObject) return cachedObject;
|
|
2686
2713
|
const objectPromise = (async () => {
|
|
2687
|
-
const looseObject = await readLooseObject(
|
|
2714
|
+
const looseObject = await readLooseObject(commonGitDir, oid);
|
|
2688
2715
|
if (looseObject) return looseObject;
|
|
2689
2716
|
const location = (await getPackStore()).objectByOid.get(oid);
|
|
2690
2717
|
if (!location) throw new Error(`Git object not found: ${oid}`);
|
|
@@ -2759,14 +2786,14 @@ var collectTreeFiles = async (resolver, treeOid, prefix, files) => {
|
|
|
2759
2786
|
await collectTreeFiles(resolver, entry.oid, path$7, files);
|
|
2760
2787
|
continue;
|
|
2761
2788
|
}
|
|
2762
|
-
|
|
2789
|
+
files.set(path$7, entry.oid);
|
|
2763
2790
|
}
|
|
2764
2791
|
};
|
|
2765
2792
|
/**
|
|
2766
|
-
* Collect all tracked file
|
|
2793
|
+
* Collect all tracked file and submodule OIDs under the specified tree.
|
|
2767
2794
|
* @param repoPath - Repository path
|
|
2768
2795
|
* @param treeOid - Tree object OID
|
|
2769
|
-
* @returns Map of repository-relative file path to blob OID
|
|
2796
|
+
* @returns Map of repository-relative file path to blob or submodule OID
|
|
2770
2797
|
*/
|
|
2771
2798
|
var listTreeFiles = async (repoPath, treeOid) => {
|
|
2772
2799
|
const resolver = await createGitObjectResolver(repoPath);
|
|
@@ -2829,8 +2856,8 @@ var readLooseTags = async (refsTagsPath) => {
|
|
|
2829
2856
|
* @returns Array of all tag names
|
|
2830
2857
|
*/
|
|
2831
2858
|
var listTagsFast = async (repoPath) => {
|
|
2832
|
-
const
|
|
2833
|
-
const [packedTags, looseTags] = await Promise.all([parsePackedRefs((0, path.join)(
|
|
2859
|
+
const commonGitDir = await getCommonGitDir(repoPath);
|
|
2860
|
+
const [packedTags, looseTags] = await Promise.all([parsePackedRefs((0, path.join)(commonGitDir, "packed-refs")), readLooseTags((0, path.join)(commonGitDir, "refs", "tags"))]);
|
|
2834
2861
|
const allTags = new Set([...packedTags, ...looseTags]);
|
|
2835
2862
|
return Array.from(allTags).sort();
|
|
2836
2863
|
};
|
|
@@ -2843,11 +2870,11 @@ var listTagsFast = async (repoPath) => {
|
|
|
2843
2870
|
var resolveTagsBatchWithCommit = async (repoPath, tagNames, logger) => {
|
|
2844
2871
|
const startTime = Date.now();
|
|
2845
2872
|
const result = /* @__PURE__ */ new Map();
|
|
2846
|
-
const
|
|
2873
|
+
const commonGitDir = await getCommonGitDir(repoPath);
|
|
2847
2874
|
const tagSet = new Set(tagNames);
|
|
2848
2875
|
const packedRefsStart = Date.now();
|
|
2849
2876
|
try {
|
|
2850
|
-
const lines = (await (0, fs_promises.readFile)((0, path.join)(
|
|
2877
|
+
const lines = (await (0, fs_promises.readFile)((0, path.join)(commonGitDir, "packed-refs"), "utf-8")).split("\n");
|
|
2851
2878
|
for (let i = 0; i < lines.length; i++) {
|
|
2852
2879
|
const line = lines[i];
|
|
2853
2880
|
if (line.startsWith("#") || !line.trim()) continue;
|
|
@@ -2871,7 +2898,7 @@ var resolveTagsBatchWithCommit = async (repoPath, tagNames, logger) => {
|
|
|
2871
2898
|
if (remainingTags.length > 0) {
|
|
2872
2899
|
const looseRefsStart = Date.now();
|
|
2873
2900
|
const looseTagEntries = (await Promise.all(remainingTags.map(async (tagName) => {
|
|
2874
|
-
const looseRefPath = (0, path.join)(
|
|
2901
|
+
const looseRefPath = (0, path.join)(commonGitDir, "refs", "tags", tagName);
|
|
2875
2902
|
try {
|
|
2876
2903
|
return {
|
|
2877
2904
|
tagName,
|
|
@@ -3087,16 +3114,26 @@ var formatVersion = (version) => {
|
|
|
3087
3114
|
return result;
|
|
3088
3115
|
};
|
|
3089
3116
|
/**
|
|
3090
|
-
*
|
|
3117
|
+
* Build a Git read context that can operate correctly inside worktrees.
|
|
3091
3118
|
* @param repositoryPath - Local Git repository directory
|
|
3119
|
+
* @returns The resolved Git read context
|
|
3120
|
+
*/
|
|
3121
|
+
var createGitReadContext = async (repositoryPath) => ({
|
|
3122
|
+
dir: repositoryPath,
|
|
3123
|
+
gitdir: await getCommonGitDir(repositoryPath)
|
|
3124
|
+
});
|
|
3125
|
+
/**
|
|
3126
|
+
* Get a commit by hash
|
|
3127
|
+
* @param context - Git read context
|
|
3092
3128
|
* @param hash - The hash of the commit
|
|
3093
3129
|
* @returns The commit or undefined if the commit is not found
|
|
3094
3130
|
*/
|
|
3095
|
-
var getCommit = async (
|
|
3131
|
+
var getCommit = async (context, hash) => {
|
|
3096
3132
|
try {
|
|
3097
3133
|
const commit = await isomorphic_git.readCommit({
|
|
3098
3134
|
fs: fs_promises.default,
|
|
3099
|
-
dir:
|
|
3135
|
+
dir: context.dir,
|
|
3136
|
+
gitdir: context.gitdir,
|
|
3100
3137
|
oid: hash
|
|
3101
3138
|
});
|
|
3102
3139
|
return {
|
|
@@ -3113,19 +3150,20 @@ var getCommit = async (repositoryPath, hash) => {
|
|
|
3113
3150
|
};
|
|
3114
3151
|
/**
|
|
3115
3152
|
* Get the current commit
|
|
3116
|
-
* @param
|
|
3153
|
+
* @param context - Git read context
|
|
3117
3154
|
* @returns The current commit or undefined if the current commit is not found
|
|
3118
3155
|
*/
|
|
3119
|
-
var getCurrentCommit = async (
|
|
3156
|
+
var getCurrentCommit = async (context) => {
|
|
3120
3157
|
try {
|
|
3121
3158
|
const currentOid = await isomorphic_git.resolveRef({
|
|
3122
3159
|
fs: fs_promises.default,
|
|
3123
|
-
dir:
|
|
3160
|
+
dir: context.dir,
|
|
3124
3161
|
ref: "HEAD"
|
|
3125
3162
|
});
|
|
3126
3163
|
const commit = await isomorphic_git.readCommit({
|
|
3127
3164
|
fs: fs_promises.default,
|
|
3128
|
-
dir:
|
|
3165
|
+
dir: context.dir,
|
|
3166
|
+
gitdir: context.gitdir,
|
|
3129
3167
|
oid: currentOid
|
|
3130
3168
|
});
|
|
3131
3169
|
return {
|
|
@@ -3151,21 +3189,23 @@ var getRelatedTagsFromMap = (commitToTags, commitHash) => {
|
|
|
3151
3189
|
};
|
|
3152
3190
|
/**
|
|
3153
3191
|
* Get the commit related branch name.
|
|
3154
|
-
* @param
|
|
3192
|
+
* @param context - Git read context
|
|
3155
3193
|
* @param commitHash - The hash of the commit
|
|
3156
3194
|
* @returns The commit related branch name or undefined if not found
|
|
3157
3195
|
*/
|
|
3158
|
-
var getRelatedBranches = async (
|
|
3196
|
+
var getRelatedBranches = async (context, commitHash) => {
|
|
3159
3197
|
try {
|
|
3160
3198
|
const branches = await isomorphic_git.listBranches({
|
|
3161
3199
|
fs: fs_promises.default,
|
|
3162
|
-
dir:
|
|
3200
|
+
dir: context.dir,
|
|
3201
|
+
gitdir: context.gitdir
|
|
3163
3202
|
});
|
|
3164
3203
|
const relatedBranches = [];
|
|
3165
3204
|
for (const branch of branches) try {
|
|
3166
3205
|
if (await isomorphic_git.resolveRef({
|
|
3167
3206
|
fs: fs_promises.default,
|
|
3168
|
-
dir:
|
|
3207
|
+
dir: context.dir,
|
|
3208
|
+
gitdir: context.gitdir,
|
|
3169
3209
|
ref: branch
|
|
3170
3210
|
}) === commitHash) relatedBranches.push(branch);
|
|
3171
3211
|
} catch (_unused3) {}
|
|
@@ -3174,6 +3214,9 @@ var getRelatedBranches = async (repositoryPath, commitHash) => {
|
|
|
3174
3214
|
return [];
|
|
3175
3215
|
}
|
|
3176
3216
|
};
|
|
3217
|
+
var GITLINK_INDEX_MODE = 57344;
|
|
3218
|
+
var INDEX_MODE_TYPE_MASK = 61440;
|
|
3219
|
+
var isGitLinkIndexEntry = (entry) => (entry.mode & INDEX_MODE_TYPE_MASK) === GITLINK_INDEX_MODE;
|
|
3177
3220
|
var parseGitIndex = async (gitDir) => {
|
|
3178
3221
|
try {
|
|
3179
3222
|
const buffer = await fs_promises.default.readFile((0, path.join)(gitDir, "index"));
|
|
@@ -3185,6 +3228,7 @@ var parseGitIndex = async (gitDir) => {
|
|
|
3185
3228
|
const entries = /* @__PURE__ */ new Map();
|
|
3186
3229
|
for (let index = 0; index < entryCount; index++) {
|
|
3187
3230
|
const entryStart = offset;
|
|
3231
|
+
const mode = buffer.readUInt32BE(entryStart + 24);
|
|
3188
3232
|
const size = buffer.readUInt32BE(entryStart + 36);
|
|
3189
3233
|
const oid = buffer.subarray(entryStart + 40, entryStart + 60).toString("hex");
|
|
3190
3234
|
const flags = buffer.readUInt16BE(entryStart + 60);
|
|
@@ -3199,6 +3243,7 @@ var parseGitIndex = async (gitDir) => {
|
|
|
3199
3243
|
entries.set(path$3, {
|
|
3200
3244
|
path: path$3,
|
|
3201
3245
|
oid,
|
|
3246
|
+
mode,
|
|
3202
3247
|
size,
|
|
3203
3248
|
stage
|
|
3204
3249
|
});
|
|
@@ -3221,7 +3266,7 @@ var listTrackedDirectories = (indexEntries) => {
|
|
|
3221
3266
|
}
|
|
3222
3267
|
return directories;
|
|
3223
3268
|
};
|
|
3224
|
-
var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relativePath = "") => {
|
|
3269
|
+
var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, excludedDirectories, relativePath = "") => {
|
|
3225
3270
|
const directoryPath = relativePath ? (0, path.join)(repositoryPath, relativePath) : repositoryPath;
|
|
3226
3271
|
const entries = await fs_promises.default.readdir(directoryPath, { withFileTypes: true });
|
|
3227
3272
|
const files = [];
|
|
@@ -3229,6 +3274,7 @@ var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relat
|
|
|
3229
3274
|
if (entry.name === ".git") continue;
|
|
3230
3275
|
const entryPath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
|
|
3231
3276
|
if (entry.isDirectory()) {
|
|
3277
|
+
if (excludedDirectories.has(entryPath)) continue;
|
|
3232
3278
|
if (!trackedDirectories.has(entryPath)) {
|
|
3233
3279
|
if (await isomorphic_git.isIgnored({
|
|
3234
3280
|
fs: fs_promises.default,
|
|
@@ -3236,7 +3282,7 @@ var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relat
|
|
|
3236
3282
|
filepath: entryPath
|
|
3237
3283
|
})) continue;
|
|
3238
3284
|
}
|
|
3239
|
-
files.push(...await listWorkingDirectoryFiles(repositoryPath, trackedDirectories, entryPath));
|
|
3285
|
+
files.push(...await listWorkingDirectoryFiles(repositoryPath, trackedDirectories, excludedDirectories, entryPath));
|
|
3240
3286
|
continue;
|
|
3241
3287
|
}
|
|
3242
3288
|
if (entry.isFile() || entry.isSymbolicLink()) files.push(entryPath);
|
|
@@ -3251,7 +3297,7 @@ var getModifiedFiles = async (repositoryPath, headTreeOid) => {
|
|
|
3251
3297
|
try {
|
|
3252
3298
|
const gitDir = await getActualGitDir(repositoryPath);
|
|
3253
3299
|
const [headFiles, indexEntries] = await Promise.all([listTreeFiles(repositoryPath, headTreeOid), parseGitIndex(gitDir)]);
|
|
3254
|
-
const workdirFiles = await listWorkingDirectoryFiles(repositoryPath, listTrackedDirectories(indexEntries));
|
|
3300
|
+
const workdirFiles = await listWorkingDirectoryFiles(repositoryPath, listTrackedDirectories(indexEntries), new Set(Array.from(indexEntries.values()).filter(isGitLinkIndexEntry).map((entry) => entry.path)));
|
|
3255
3301
|
const modifiedFiles = /* @__PURE__ */ new Map();
|
|
3256
3302
|
const rememberModifiedFile = (path$5, reason) => {
|
|
3257
3303
|
if (!modifiedFiles.has(path$5)) modifiedFiles.set(path$5, {
|
|
@@ -3269,6 +3315,10 @@ var getModifiedFiles = async (repositoryPath, headTreeOid) => {
|
|
|
3269
3315
|
const absolutePath = (0, path.join)(repositoryPath, indexEntry.path);
|
|
3270
3316
|
try {
|
|
3271
3317
|
const stats = await fs_promises.default.lstat(absolutePath);
|
|
3318
|
+
if (isGitLinkIndexEntry(indexEntry)) {
|
|
3319
|
+
if (indexEntry.stage !== 0) rememberModifiedFile(indexEntry.path, "staged");
|
|
3320
|
+
continue;
|
|
3321
|
+
}
|
|
3272
3322
|
if (!stats.isFile() && !stats.isSymbolicLink()) {
|
|
3273
3323
|
rememberModifiedFile(indexEntry.path, "worktree");
|
|
3274
3324
|
continue;
|
|
@@ -3309,7 +3359,7 @@ var formatModifiedFile = (modifiedFile) => `'${modifiedFile.path}':${modifiedFil
|
|
|
3309
3359
|
* @param commitToTags - Map of commit hash to tags for performance
|
|
3310
3360
|
* @returns The version or undefined if no version is found
|
|
3311
3361
|
*/
|
|
3312
|
-
var lookupVersionLabelRecursive = async (
|
|
3362
|
+
var lookupVersionLabelRecursive = async (context, commit, reachedCommits, commitToTags) => {
|
|
3313
3363
|
const scheduledStack = [];
|
|
3314
3364
|
let version = {
|
|
3315
3365
|
major: 0,
|
|
@@ -3333,10 +3383,11 @@ var lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, commitToTa
|
|
|
3333
3383
|
try {
|
|
3334
3384
|
const parentHashes = (await isomorphic_git.readCommit({
|
|
3335
3385
|
fs: fs_promises.default,
|
|
3336
|
-
dir:
|
|
3386
|
+
dir: context.dir,
|
|
3387
|
+
gitdir: context.gitdir,
|
|
3337
3388
|
oid: currentCommit.hash
|
|
3338
3389
|
})).commit.parent || [];
|
|
3339
|
-
parentCommits = (await Promise.all(parentHashes.map((parentHash) => getCommit(
|
|
3390
|
+
parentCommits = (await Promise.all(parentHashes.map((parentHash) => getCommit(context, parentHash)))).filter((ci) => ci !== void 0);
|
|
3340
3391
|
} catch (_unused6) {}
|
|
3341
3392
|
if (parentCommits.length === 0) {
|
|
3342
3393
|
reachedCommits.set(currentCommit.hash, version);
|
|
@@ -3351,7 +3402,7 @@ var lookupVersionLabelRecursive = async (cwd, commit, reachedCommits, commitToTa
|
|
|
3351
3402
|
while (scheduledStack.length >= 1) {
|
|
3352
3403
|
const { commit: scheduledCommit, parents } = scheduledStack.pop();
|
|
3353
3404
|
if (parents.length >= 2) for (let index = 1; index < parents.length; index++) {
|
|
3354
|
-
const alternateParentVersion = await lookupVersionLabelRecursive(
|
|
3405
|
+
const alternateParentVersion = await lookupVersionLabelRecursive(context, parents[index], reachedCommits, commitToTags);
|
|
3355
3406
|
if (alternateParentVersion && compareVersions(alternateParentVersion, version) < 0) version = alternateParentVersion;
|
|
3356
3407
|
}
|
|
3357
3408
|
version = incrementLastVersionComponent(version);
|
|
@@ -3379,12 +3430,31 @@ var getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger)
|
|
|
3379
3430
|
logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
|
|
3380
3431
|
return metadata;
|
|
3381
3432
|
}
|
|
3433
|
+
let gitContext;
|
|
3382
3434
|
try {
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3435
|
+
gitContext = await createGitReadContext(gitRootPath);
|
|
3436
|
+
} catch (error) {
|
|
3437
|
+
logger.warn(`Failed to resolve git metadata context: ${error}`);
|
|
3438
|
+
logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
|
|
3439
|
+
return metadata;
|
|
3440
|
+
}
|
|
3441
|
+
const currentCommit = await getCurrentCommit(gitContext);
|
|
3442
|
+
if (!currentCommit) {
|
|
3443
|
+
logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
|
|
3444
|
+
return metadata;
|
|
3445
|
+
}
|
|
3446
|
+
const gitMetadata = {
|
|
3447
|
+
tags: [],
|
|
3448
|
+
branches: [],
|
|
3449
|
+
commit: {
|
|
3450
|
+
hash: currentCommit.hash,
|
|
3451
|
+
shortHash: currentCommit.shortHash,
|
|
3452
|
+
date: dayjs(currentCommit.date).format("YYYY-MM-DDTHH:mm:ssZ"),
|
|
3453
|
+
message: currentCommit.message
|
|
3387
3454
|
}
|
|
3455
|
+
};
|
|
3456
|
+
metadata.git = gitMetadata;
|
|
3457
|
+
try {
|
|
3388
3458
|
const buildStart = Date.now();
|
|
3389
3459
|
const commitToTags = await buildCompleteTagCache(gitRootPath, (tagName) => {
|
|
3390
3460
|
const version = parseVersion(tagName);
|
|
@@ -3392,12 +3462,7 @@ var getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger)
|
|
|
3392
3462
|
}, logger);
|
|
3393
3463
|
logger.debug(`[screw-up] buildCompleteTagCache: ${Date.now() - buildStart}ms`);
|
|
3394
3464
|
logger.debug(`Built tag map with ${commitToTags.size} commits`);
|
|
3395
|
-
let version = await lookupVersionLabelRecursive(
|
|
3396
|
-
const gitMetadata = {
|
|
3397
|
-
tags: [],
|
|
3398
|
-
branches: []
|
|
3399
|
-
};
|
|
3400
|
-
metadata.git = gitMetadata;
|
|
3465
|
+
let version = await lookupVersionLabelRecursive(gitContext, currentCommit, /* @__PURE__ */ new Map(), commitToTags);
|
|
3401
3466
|
if (version) {
|
|
3402
3467
|
if (checkWorkingDirectoryStatus) {
|
|
3403
3468
|
const modifiedFiles = await getModifiedFiles(gitRootPath, currentCommit.tree);
|
|
@@ -3411,16 +3476,14 @@ var getGitMetadata = async (repositoryPath, checkWorkingDirectoryStatus, logger)
|
|
|
3411
3476
|
gitMetadata.version = gitVersion;
|
|
3412
3477
|
metadata.version = gitVersion;
|
|
3413
3478
|
}
|
|
3414
|
-
gitMetadata.commit = {
|
|
3415
|
-
hash: currentCommit.hash,
|
|
3416
|
-
shortHash: currentCommit.shortHash,
|
|
3417
|
-
date: dayjs(currentCommit.date).format("YYYY-MM-DDTHH:mm:ssZ"),
|
|
3418
|
-
message: currentCommit.message
|
|
3419
|
-
};
|
|
3420
3479
|
gitMetadata.tags = getRelatedTagsFromMap(commitToTags, currentCommit.hash).map((tag) => tag.name);
|
|
3421
|
-
gitMetadata.branches = await getRelatedBranches(gitRootPath, currentCommit.hash);
|
|
3422
3480
|
} catch (error) {
|
|
3423
|
-
logger.warn(`Failed to
|
|
3481
|
+
logger.warn(`Failed to resolve git versioning metadata: ${error}`);
|
|
3482
|
+
}
|
|
3483
|
+
try {
|
|
3484
|
+
gitMetadata.branches = await getRelatedBranches(gitContext, currentCommit.hash);
|
|
3485
|
+
} catch (error) {
|
|
3486
|
+
logger.warn(`Failed to resolve git branch metadata: ${error}`);
|
|
3424
3487
|
}
|
|
3425
3488
|
logger.debug(`[screw-up] Total getGitMetadata: ${Date.now() - startTime}ms`);
|
|
3426
3489
|
return metadata;
|
|
@@ -3873,6 +3936,13 @@ var ensureMetadataGitignore = async (metadataSourcePath, logger) => {
|
|
|
3873
3936
|
}
|
|
3874
3937
|
};
|
|
3875
3938
|
//#endregion
|
|
3939
|
+
//#region src/generated/packageMetadata.ts
|
|
3940
|
+
var name = "screw-up";
|
|
3941
|
+
var version = "1.34.0";
|
|
3942
|
+
var author = "Kouji Matsui (@kekyo@mi.kekyo.net)";
|
|
3943
|
+
var repository_url = "https://github.com/kekyo/screw-up.git";
|
|
3944
|
+
var git_commit_hash = "bcd53f2a2326d1600b105c38a496c6c9c04b6a97";
|
|
3945
|
+
//#endregion
|
|
3876
3946
|
//#region src/cli.ts
|
|
3877
3947
|
var defaultInheritableFields = new Set([
|
|
3878
3948
|
"version",
|
|
@@ -4317,12 +4387,11 @@ var publishCommand = async (args, logger) => {
|
|
|
4317
4387
|
}
|
|
4318
4388
|
};
|
|
4319
4389
|
var showHelp = async () => {
|
|
4320
|
-
const { author, license, repository_url, version, git_commit_hash } = await Promise.resolve().then(() => require("./packageMetadata-Cwh4Fqmw.cjs"));
|
|
4321
4390
|
console.info(`screw-up [${version}-${git_commit_hash}]
|
|
4322
4391
|
Easy package metadata inserter CLI
|
|
4323
4392
|
Copyright (c) ${author}
|
|
4324
4393
|
Repository: ${repository_url}
|
|
4325
|
-
License:
|
|
4394
|
+
License: MIT
|
|
4326
4395
|
|
|
4327
4396
|
Usage: screw-up <command> [options]
|
|
4328
4397
|
|
|
@@ -4385,7 +4454,7 @@ var cliMain = async (args, logger) => {
|
|
|
4385
4454
|
};
|
|
4386
4455
|
//#endregion
|
|
4387
4456
|
//#region src/main.ts
|
|
4388
|
-
var logger = createConsoleLogger(`${
|
|
4457
|
+
var logger = createConsoleLogger(`${name}-cli`);
|
|
4389
4458
|
cliMain(process.argv.slice(2), logger).then((code) => process.exit(code)).catch((error) => {
|
|
4390
4459
|
logger.error(`CLI error: ${error}`);
|
|
4391
4460
|
process.exit(1);
|