screw-up 1.28.0 → 1.29.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/main.mjs CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  /*!
3
3
  * name: screw-up
4
- * version: 1.28.0
4
+ * version: 1.29.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: 4bc8c338f32ab8ed9bbf0b9ad0ba4166d584be65
9
+ * git.commit.hash: 3833f6ef842d9e5a0b4f7277ca3b118f26fd4a6b
10
10
  */
11
- import { a as collectWorkspaceSiblings, c as replacePeerDependenciesWildcards, d as require_dist, i as getFetchGitMetadata, l as resolvePackageMetadata, n as generateMetadataFileContent, o as createConsoleLogger, p as __toESM, r as writeFileIfChanged, s as findWorkspaceRoot, t as ensureMetadataGitignore, u as resolveRawPackageJsonObject } from "./metadata-file-DtvzENuT.js";
12
- import { n as name } from "./packageMetadata-11MbeI_K.js";
11
+ import { a as collectWorkspaceSiblings, c as replacePeerDependenciesWildcards, d as require_dist, i as getFetchGitMetadata, l as resolvePackageMetadata, n as generateMetadataFileContent, o as createConsoleLogger, p as __toESM, r as writeFileIfChanged, s as findWorkspaceRoot, t as ensureMetadataGitignore, u as resolveRawPackageJsonObject } from "./metadata-file-CyQ2yue9.js";
12
+ import { n as name } from "./packageMetadata-DnXbVLQ5.js";
13
13
  import { copyFile, mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "fs/promises";
14
14
  import { createReadStream, createWriteStream, existsSync, statSync } from "fs";
15
15
  import { dirname, isAbsolute, join, resolve } from "path";
@@ -1357,7 +1357,7 @@ var publishCommand = async (args, logger) => {
1357
1357
  }
1358
1358
  };
1359
1359
  var showHelp = async () => {
1360
- const { author, license, repository_url, version, git_commit_hash } = await import("./packageMetadata-11MbeI_K.js").then((n) => n.r);
1360
+ const { author, license, repository_url, version, git_commit_hash } = await import("./packageMetadata-DnXbVLQ5.js").then((n) => n.r);
1361
1361
  console.info(`screw-up [${version}-${git_commit_hash}]
1362
1362
  Easy package metadata inserter CLI
1363
1363
  Copyright (c) ${author}
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: screw-up
3
- * version: 1.28.0
3
+ * version: 1.29.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: 4bc8c338f32ab8ed9bbf0b9ad0ba4166d584be65
8
+ * git.commit.hash: 3833f6ef842d9e5a0b4f7277ca3b118f26fd4a6b
9
9
  */
10
10
  import fs, { mkdir, readFile, readdir, stat, writeFile } from "fs/promises";
11
11
  import { existsSync } from "fs";
@@ -2293,12 +2293,81 @@ var getRelatedBranches = async (repositoryPath, commitHash) => {
2293
2293
  * @param repositoryPath - Local Git repository directory
2294
2294
  * @returns Modified files
2295
2295
  */
2296
+ var isModifiedFile = ([, head, workdir, stage]) => {
2297
+ return workdir === 2 || stage === 2 || stage === 3 || head === 1 && workdir === 0 || head === 0 && workdir === 1;
2298
+ };
2299
+ var getStatusRow = async (filepath, entries) => {
2300
+ const [head, workdir, stage] = entries;
2301
+ const [headType, workdirType, stageType] = await Promise.all([
2302
+ head ? head.type() : void 0,
2303
+ workdir ? workdir.type() : void 0,
2304
+ stage ? stage.type() : void 0
2305
+ ]);
2306
+ const isBlob = [
2307
+ headType,
2308
+ workdirType,
2309
+ stageType
2310
+ ].includes("blob");
2311
+ if ((headType === "tree" || headType === "special") && !isBlob) return;
2312
+ if (headType === "commit") return;
2313
+ if ((workdirType === "tree" || workdirType === "special") && !isBlob) return;
2314
+ if (stageType === "commit") return;
2315
+ if ((stageType === "tree" || stageType === "special") && !isBlob) return;
2316
+ const headOid = headType === "blob" ? await head.oid() : void 0;
2317
+ const stageOid = stageType === "blob" ? await stage.oid() : void 0;
2318
+ let workdirOid;
2319
+ if (headType !== "blob" && workdirType === "blob" && stageType !== "blob") workdirOid = "42";
2320
+ else if (workdirType === "blob") workdirOid = await workdir.oid();
2321
+ const entry = [
2322
+ void 0,
2323
+ headOid,
2324
+ workdirOid,
2325
+ stageOid
2326
+ ];
2327
+ const statusValues = entry.map((value) => entry.indexOf(value));
2328
+ return [
2329
+ filepath,
2330
+ statusValues[1],
2331
+ statusValues[2],
2332
+ statusValues[3]
2333
+ ];
2334
+ };
2335
+ var reduceModifiedFiles = async (parent, children) => {
2336
+ const modifiedFiles = parent ? [parent] : [];
2337
+ for (const child of children) modifiedFiles.push(...child);
2338
+ return modifiedFiles;
2339
+ };
2340
+ var iterateSequentially = async (walk, children) => {
2341
+ const results = [];
2342
+ for (const child of children) results.push(await walk(child));
2343
+ return results;
2344
+ };
2296
2345
  var getModifiedFiles = async (repositoryPath) => {
2297
2346
  try {
2298
- return (await git.statusMatrix({
2347
+ return await git.walk({
2299
2348
  fs,
2300
- dir: repositoryPath
2301
- })).filter(([, head, workdir, stage]) => workdir === 2 || stage === 2 || stage === 3 || head === 1 && workdir === 0 || head === 0 && workdir === 1);
2349
+ dir: repositoryPath,
2350
+ trees: [
2351
+ git.TREE({ ref: "HEAD" }),
2352
+ git.WORKDIR(),
2353
+ git.STAGE()
2354
+ ],
2355
+ map: async (filepath, entries) => {
2356
+ const [head, workdir, stage] = entries;
2357
+ if (!head && !stage && workdir) {
2358
+ if (await git.isIgnored({
2359
+ fs,
2360
+ dir: repositoryPath,
2361
+ filepath
2362
+ })) return null;
2363
+ }
2364
+ const statusRow = await getStatusRow(filepath, entries);
2365
+ if (!statusRow || !isModifiedFile(statusRow)) return;
2366
+ return statusRow;
2367
+ },
2368
+ reduce: reduceModifiedFiles,
2369
+ iterate: iterateSequentially
2370
+ });
2302
2371
  } catch (_unused5) {
2303
2372
  return [];
2304
2373
  }
@@ -2511,4 +2580,4 @@ var ensureMetadataGitignore = async (metadataSourcePath, logger) => {
2511
2580
  //#endregion
2512
2581
  export { collectWorkspaceSiblings as a, replacePeerDependenciesWildcards as c, require_dist as d, __exportAll as f, getFetchGitMetadata as i, resolvePackageMetadata as l, generateMetadataFileContent as n, createConsoleLogger as o, __toESM as p, writeFileIfChanged as r, findWorkspaceRoot as s, ensureMetadataGitignore as t, resolveRawPackageJsonObject as u };
2513
2582
 
2514
- //# sourceMappingURL=metadata-file-DtvzENuT.js.map
2583
+ //# sourceMappingURL=metadata-file-CyQ2yue9.js.map