watskeburt 0.11.0 → 0.11.1

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/README.md CHANGED
@@ -35,13 +35,14 @@ console.log(getSHASync());
35
35
  // files not staged for commit and files not under revision control)
36
36
  /** @type {import('watskeburt').IChange[]} */
37
37
  const lChangedFiles = await list("main");
38
- // or, with the sync interface:
38
+ // or with the synchronous interface:
39
39
  // const lChangedFiles = listSync("main");
40
40
 
41
41
  // list all files that differ between 'v0.6.1' and 'v0.7.1' (by definition
42
42
  // won't include files staged for commit and/ or not under revision control)
43
43
  /** @type {import('watskeburt').IChange[]} */
44
44
  const lChangedFiles = await list("v0.6.1", "v0.7.1");
45
+ // or with the synchronous interface:
45
46
  // const lChangedFiles = listSync("v0.6.1", "v0.7.1");
46
47
 
47
48
  // As a third parameter you can pass some options
@@ -52,8 +53,8 @@ const lChangedFiles = await list("main", null, {
52
53
  trackedOnly: false, // when set to true leaves out files not under revision control
53
54
  outputType: "object", // other options: "json" and "regex" (as used in the CLI)
54
55
  });
55
- // or with synchronous code:
56
- // const lChangedFiles = listSynd("main", null, {
56
+ // or with the synchronous interface:
57
+ // const lChangedFiles = listSync("main", null, {
57
58
  // trackedOnly: false, // when set to true leaves out files not under revision control
58
59
  // outputType: "object", // other options: "json" and "regex" (as used in the CLI)
59
60
  // });
package/bin/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by tools/get-version.ts - edits will be overwritten
2
- export const VERSION = "0.11.0";
2
+ export const VERSION = "0.11.1";
@@ -1,7 +1,3 @@
1
- // the security (and unicorn) plugins don't seem to detect named caption
2
- // groups very well - false-flagging below regular expressions to be susceptible
3
- // to redos attacks.
4
- /* eslint-disable unicorn/no-unsafe-regex, security/detect-unsafe-regex */
5
1
  import { EOL } from "node:os";
6
2
  const DIFF_NAME_STATUS_LINE_PATTERN = /^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/;
7
3
  const DIFF_SHORT_STATUS_LINE_PATTERN = /^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/;
@@ -17,10 +13,8 @@ const CHANGE_CHAR_2_CHANGE_TYPE = {
17
13
  " ": "unmodified",
18
14
  "?": "untracked",
19
15
  "!": "ignored",
20
- // X: "unknown"
21
16
  };
22
17
  function changeChar2ChangeType(pChar) {
23
- // eslint-disable-next-line security/detect-object-injection
24
18
  return CHANGE_CHAR_2_CHANGE_TYPE[pChar] ?? "unknown";
25
19
  }
26
20
  export function convertStatusLine(pString) {
@@ -30,7 +30,6 @@ export default function formatToRegex(pChanges, pExtensions = DEFAULT_EXTENSIONS
30
30
  .filter((pChange) => pChangeTypes.has(pChange.changeType))
31
31
  .map(({ name }) => name)
32
32
  .filter((pName) => pExtensions.has(extname(pName)))
33
- // .replace(/\./g, "\\\\.")
34
33
  .join("|");
35
34
  return `^(${lChanges})$`;
36
35
  }
@@ -7,7 +7,6 @@ function stringifyOutStream(pError) {
7
7
  return pError;
8
8
  }
9
9
  }
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
10
  function throwSpawnError(pError) {
12
11
  if (pError.code === "ENOENT") {
13
12
  throw new Error("git executable not found");
@@ -16,13 +15,9 @@ function throwSpawnError(pError) {
16
15
  throw new Error(`internal spawn error: ${pError}`);
17
16
  }
18
17
  }
19
- /**
20
- * @throws {Error}
21
- */
22
18
  function getGitResultSync(pArguments, pErrorMap, pSpawnFunction) {
23
19
  const lGitResult = pSpawnFunction("git", pArguments, {
24
20
  cwd: process.cwd(),
25
- // eslint-disable-next-line node/no-process-env
26
21
  env: process.env,
27
22
  });
28
23
  if (lGitResult.error) {
@@ -36,19 +31,12 @@ function getGitResultSync(pArguments, pErrorMap, pSpawnFunction) {
36
31
  `internal git error: ${lGitResult.status} (${stringifyOutStream(lGitResult.stderr)})`);
37
32
  }
38
33
  }
39
- /**
40
- * @throws {Error}
41
- */
42
34
  export function getStatusShortSync(pSpawnFunction = spawnSync) {
43
35
  const lErrorMap = {
44
36
  129: `'${process.cwd()}' does not seem to be a git repository`,
45
37
  };
46
38
  return getGitResultSync(["status", "--porcelain"], lErrorMap, pSpawnFunction);
47
39
  }
48
- /**
49
- *
50
- * @throws {Error}
51
- */
52
40
  export function getDiffLinesSync(pOldRevision, pNewRevision, pSpawnFunction = spawnSync) {
53
41
  const lErrorMap = {
54
42
  128: `revision '${pOldRevision}' ${pNewRevision ? `(or '${pNewRevision}') ` : ""}unknown`,
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  import { spawn } from "node:child_process";
3
2
  function stringifyOutStream(pBufferOrString) {
4
3
  if (pBufferOrString instanceof Buffer) {
@@ -8,13 +7,9 @@ function stringifyOutStream(pBufferOrString) {
8
7
  return pBufferOrString;
9
8
  }
10
9
  }
11
- /**
12
- * @throws {Error}
13
- */
14
10
  function getGitResult(pArguments, pErrorMap, pSpawnFunction) {
15
11
  const lGit = pSpawnFunction("git", pArguments, {
16
12
  cwd: process.cwd(),
17
- // eslint-disable-next-line node/no-process-env
18
13
  env: process.env,
19
14
  });
20
15
  let lStdOutData = "";
@@ -45,9 +40,6 @@ function getGitResult(pArguments, pErrorMap, pSpawnFunction) {
45
40
  });
46
41
  });
47
42
  }
48
- /**
49
- * @throws {Error}
50
- */
51
43
  export async function getStatusShort(pSpawnFunction = spawn) {
52
44
  const lErrorMap = {
53
45
  129: `'${process.cwd()}' does not seem to be a git repository`,
@@ -55,10 +47,6 @@ export async function getStatusShort(pSpawnFunction = spawn) {
55
47
  const lResult = await getGitResult(["status", "--porcelain"], lErrorMap, pSpawnFunction);
56
48
  return lResult;
57
49
  }
58
- /**
59
- *
60
- * @throws {Error}
61
- */
62
50
  export async function getDiffLines(pOldRevision, pNewRevision, pSpawnFunction = spawn) {
63
51
  const lErrorMap = {
64
52
  128: `revision '${pOldRevision}' ${pNewRevision ? `(or '${pNewRevision}') ` : ""}unknown`,
package/dist/esm/main.js CHANGED
@@ -16,7 +16,7 @@ export async function list(pOldRevision, pNewRevision, pOptions) {
16
16
  const lOptions = pOptions || {};
17
17
  const [lDiffLines, lStatusLines] = await Promise.all([
18
18
  getDiffLines(lOldRevision, pNewRevision),
19
- lOptions.trackedOnly ? "" : getStatusShort(),
19
+ !lOptions.trackedOnly ? getStatusShort() : "",
20
20
  ]);
21
21
  let lChanges = convertDiffLines(lDiffLines);
22
22
  if (!lOptions.trackedOnly) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "watskeburt",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "List files changed since a git revision",
5
5
  "keywords": [
6
6
  "git",