watskeburt 0.12.0 → 0.12.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022-2022 Sander Verweij
3
+ Copyright (c) 2022-2023 Sander Verweij
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -24,7 +24,6 @@ but for just this simple usage they're a bit overkill.
24
24
  ### :scroll: API
25
25
 
26
26
  ```javascript
27
- // const { list, getSHA } = require("watskeburt"); // in commonjs contexts you can also require it
28
27
  import { list, getSHA } from "watskeburt";
29
28
 
30
29
  // print the SHA1 of the current HEAD
@@ -1,4 +1,5 @@
1
- import { convertDiffLines, convertStatusLines, } from "./convert-to-change-object.js";
1
+ import { parseDiffLines } from "./parse-diff-lines.js";
2
+ import { parseStatusLines } from "./parse-status-lines.js";
2
3
  import * as primitives from "./git-primitives.js";
3
4
  import format from "./formatters/format.js";
4
5
  export async function list(pOldRevision, pNewRevision, pOptions) {
@@ -8,9 +9,9 @@ export async function list(pOldRevision, pNewRevision, pOptions) {
8
9
  primitives.getDiffLines(lOldRevision, pNewRevision),
9
10
  !lOptions.trackedOnly ? primitives.getStatusShort() : "",
10
11
  ]);
11
- let lChanges = convertDiffLines(lDiffLines);
12
+ let lChanges = parseDiffLines(lDiffLines);
12
13
  if (!lOptions.trackedOnly) {
13
- lChanges = lChanges.concat(convertStatusLines(lStatusLines).filter(({ changeType }) => changeType === "untracked"));
14
+ lChanges = lChanges.concat(parseStatusLines(lStatusLines).filter(({ changeType }) => changeType === "untracked"));
14
15
  }
15
16
  return format(lChanges, lOptions.outputType);
16
17
  }
@@ -0,0 +1,16 @@
1
+ const CHANGE_CHAR_2_CHANGE_TYPE = new Map([
2
+ ["A", "added"],
3
+ ["C", "copied"],
4
+ ["D", "deleted"],
5
+ ["M", "modified"],
6
+ ["R", "renamed"],
7
+ ["T", "type changed"],
8
+ ["U", "unmerged"],
9
+ ["B", "pairing broken"],
10
+ [" ", "unmodified"],
11
+ ["?", "untracked"],
12
+ ["!", "ignored"],
13
+ ]);
14
+ export function changeChar2ChangeType(pChar) {
15
+ return CHANGE_CHAR_2_CHANGE_TYPE.get(pChar) ?? "unknown";
16
+ }
@@ -0,0 +1,25 @@
1
+ import { EOL } from "node:os";
2
+ import { changeChar2ChangeType } from "./map-change-type.js";
3
+ const DIFF_NAME_STATUS_LINE_PATTERN = /^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/;
4
+ export function parseDiffLines(pString) {
5
+ return pString
6
+ .split(EOL)
7
+ .filter(Boolean)
8
+ .map(parseDiffLine)
9
+ .filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
10
+ }
11
+ export function parseDiffLine(pString) {
12
+ const lMatchResult = pString.match(DIFF_NAME_STATUS_LINE_PATTERN);
13
+ const lReturnValue = {};
14
+ if (lMatchResult?.groups) {
15
+ lReturnValue.changeType = changeChar2ChangeType(lMatchResult.groups.changeType);
16
+ if (lMatchResult.groups.newName) {
17
+ lReturnValue.name = lMatchResult.groups.newName;
18
+ lReturnValue.oldName = lMatchResult.groups.name;
19
+ }
20
+ else {
21
+ lReturnValue.name = lMatchResult.groups.name;
22
+ }
23
+ }
24
+ return lReturnValue;
25
+ }
@@ -0,0 +1,30 @@
1
+ import { EOL } from "node:os";
2
+ import { changeChar2ChangeType } from "./map-change-type.js";
3
+ const DIFF_SHORT_STATUS_LINE_PATTERN = /^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/;
4
+ export function parseStatusLines(pString) {
5
+ return pString
6
+ .split(EOL)
7
+ .filter(Boolean)
8
+ .map(parseStatusLine)
9
+ .filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
10
+ }
11
+ export function parseStatusLine(pString) {
12
+ const lMatchResult = pString.match(DIFF_SHORT_STATUS_LINE_PATTERN);
13
+ const lReturnValue = {};
14
+ if (lMatchResult?.groups) {
15
+ const lStagedChangeType = changeChar2ChangeType(lMatchResult.groups.stagedChangeType);
16
+ const lUnStagedChangeType = changeChar2ChangeType(lMatchResult.groups.unStagedChangeType);
17
+ lReturnValue.changeType =
18
+ lStagedChangeType === "unmodified"
19
+ ? lUnStagedChangeType
20
+ : lStagedChangeType;
21
+ if (lMatchResult.groups.newName) {
22
+ lReturnValue.name = lMatchResult.groups.newName;
23
+ lReturnValue.oldName = lMatchResult.groups.name;
24
+ }
25
+ else {
26
+ lReturnValue.name = lMatchResult.groups.name;
27
+ }
28
+ }
29
+ return lReturnValue;
30
+ }
@@ -0,0 +1 @@
1
+ export const VERSION = "0.12.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "watskeburt",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "List files changed since a git revision",
5
5
  "keywords": [
6
6
  "git",
@@ -19,17 +19,17 @@
19
19
  "url": "https://sverweij.github.io"
20
20
  },
21
21
  "license": "MIT",
22
- "bin": "dist/esm/cli.js",
23
- "main": "dist/esm/main.js",
24
- "module": "dist/esm/main.js",
22
+ "bin": "dist/cli.js",
23
+ "main": "dist/main.js",
24
+ "module": "dist/main.js",
25
25
  "type": "module",
26
26
  "sideEffects": false,
27
27
  "exports": {
28
28
  ".": [
29
29
  {
30
- "import": "./dist/esm/main.js"
30
+ "import": "./dist/main.js"
31
31
  },
32
- "./dist/esm/main.js"
32
+ "./dist/main.js"
33
33
  ]
34
34
  },
35
35
  "types": "types/watskeburt.d.ts",
@@ -42,22 +42,22 @@
42
42
  "README.md"
43
43
  ],
44
44
  "devDependencies": {
45
- "@types/node": "20.4.1",
46
- "@typescript-eslint/eslint-plugin": "6.0.0",
47
- "c8": "8.0.0",
48
- "dependency-cruiser": "13.1.0",
49
- "eslint": "8.44.0",
45
+ "@types/node": "20.5.1",
46
+ "@typescript-eslint/eslint-plugin": "6.4.1",
47
+ "c8": "8.0.1",
48
+ "dependency-cruiser": "13.1.4",
49
+ "eslint": "8.47.0",
50
50
  "eslint-config-moving-meadow": "4.0.2",
51
- "eslint-config-prettier": "8.8.0",
51
+ "eslint-config-prettier": "9.0.0",
52
52
  "eslint-plugin-budapestian": "5.0.1",
53
53
  "eslint-plugin-eslint-comments": "3.2.0",
54
- "eslint-plugin-import": "2.27.5",
54
+ "eslint-plugin-import": "2.28.1",
55
55
  "eslint-plugin-mocha": "10.1.0",
56
56
  "eslint-plugin-node": "11.1.0",
57
57
  "eslint-plugin-security": "1.7.1",
58
- "eslint-plugin-unicorn": "47.0.0",
58
+ "eslint-plugin-unicorn": "48.0.1",
59
59
  "npm-run-all": "4.1.5",
60
- "prettier": "3.0.0",
60
+ "prettier": "3.0.2",
61
61
  "ts-node": "10.9.1",
62
62
  "typescript": "5.1.6",
63
63
  "upem": "8.0.0"
@@ -72,15 +72,14 @@
72
72
  "build:dist": "tsc",
73
73
  "check": "npm-run-all --parallel --aggregate-output lint depcruise test:cover",
74
74
  "clean": "rm -rf dist",
75
- "test": "node --no-warnings --loader 'ts-node/esm' --test-reporter dot --test src/*.spec.ts src/**/*.spec.ts",
75
+ "test": "node --no-warnings --loader 'ts-node/esm' --test-reporter ./tools/dot-with-summary.reporter.js --test src/*.spec.ts src/**/*.spec.ts",
76
76
  "test:cover": "c8 npm test",
77
- "test:only-for-node-16-without-the-test-reporter": "node --no-warnings --loader 'ts-node/esm' --test src/*.spec.ts src/**/*.spec.ts",
78
77
  "depcruise": "depcruise dist src types",
79
78
  "depcruise:graph": "depcruise src types --include-only '^(dist|src|types)' --output-type dot | dot -T svg | tee docs/dependency-graph.svg | depcruise-wrap-stream-in-html > docs/dependency-graph.html",
80
79
  "depcruise:graph:archi": "depcruise src --include-only '^(dist|src|types)' --output-type archi | dot -T svg | depcruise-wrap-stream-in-html > docs/high-level-dependency-graph.html",
81
80
  "depcruise:graph:dev": "depcruise dist src types --include-only '^(dist|src|types)' --prefix vscode://file/$(pwd)/ --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
82
- "depcruise:graph:diff:dev": "depcruise dist src types --include-only '^(dist|src|types)' --highlight \"$(node dist/esm/cli.js main -T regex)\" --prefix vscode://file/$(pwd)/ --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
83
- "depcruise:graph:diff:mermaid": "depcruise dist src types --include-only '^(dist|src|types)' --output-type mermaid --output-to - --highlight \"$(node dist/esm/cli.js $SHA -T regex)\"",
81
+ "depcruise:graph:diff:dev": "depcruise dist src types --include-only '^(dist|src|types)' --highlight \"$(node dist/cli.js main -T regex)\" --prefix vscode://file/$(pwd)/ --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
82
+ "depcruise:graph:diff:mermaid": "depcruise dist src types --include-only '^(dist|src|types)' --output-type mermaid --output-to - --highlight \"$(node dist/cli.js $SHA -T regex)\"",
84
83
  "depcruise:html": "depcruise src types --progress --output-type err-html --output-to dependency-violation-report.html",
85
84
  "depcruise:text": "depcruise src types --progress --output-type text",
86
85
  "depcruise:focus": "depcruise src types --progress --output-type text --focus",
@@ -1,68 +0,0 @@
1
- import { EOL } from "node:os";
2
- const DIFF_NAME_STATUS_LINE_PATTERN = /^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/;
3
- const DIFF_SHORT_STATUS_LINE_PATTERN = /^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/;
4
- const CHANGE_CHAR_2_CHANGE_TYPE = new Map([
5
- ["A", "added"],
6
- ["C", "copied"],
7
- ["D", "deleted"],
8
- ["M", "modified"],
9
- ["R", "renamed"],
10
- ["T", "type changed"],
11
- ["U", "unmerged"],
12
- ["B", "pairing broken"],
13
- [" ", "unmodified"],
14
- ["?", "untracked"],
15
- ["!", "ignored"],
16
- ]);
17
- export function convertStatusLines(pString) {
18
- return pString
19
- .split(EOL)
20
- .filter(Boolean)
21
- .map(convertStatusLine)
22
- .filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
23
- }
24
- export function convertStatusLine(pString) {
25
- const lMatchResult = pString.match(DIFF_SHORT_STATUS_LINE_PATTERN);
26
- const lReturnValue = {};
27
- if (lMatchResult?.groups) {
28
- const lStagedChangeType = changeChar2ChangeType(lMatchResult.groups.stagedChangeType);
29
- const lUnStagedChangeType = changeChar2ChangeType(lMatchResult.groups.unStagedChangeType);
30
- lReturnValue.changeType =
31
- lStagedChangeType === "unmodified"
32
- ? lUnStagedChangeType
33
- : lStagedChangeType;
34
- if (lMatchResult.groups.newName) {
35
- lReturnValue.name = lMatchResult.groups.newName;
36
- lReturnValue.oldName = lMatchResult.groups.name;
37
- }
38
- else {
39
- lReturnValue.name = lMatchResult.groups.name;
40
- }
41
- }
42
- return lReturnValue;
43
- }
44
- export function convertDiffLines(pString) {
45
- return pString
46
- .split(EOL)
47
- .filter(Boolean)
48
- .map(convertDiffLine)
49
- .filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
50
- }
51
- export function convertDiffLine(pString) {
52
- const lMatchResult = pString.match(DIFF_NAME_STATUS_LINE_PATTERN);
53
- const lReturnValue = {};
54
- if (lMatchResult?.groups) {
55
- lReturnValue.changeType = changeChar2ChangeType(lMatchResult.groups.changeType);
56
- if (lMatchResult.groups.newName) {
57
- lReturnValue.name = lMatchResult.groups.newName;
58
- lReturnValue.oldName = lMatchResult.groups.name;
59
- }
60
- else {
61
- lReturnValue.name = lMatchResult.groups.name;
62
- }
63
- }
64
- return lReturnValue;
65
- }
66
- function changeChar2ChangeType(pChar) {
67
- return CHANGE_CHAR_2_CHANGE_TYPE.get(pChar) ?? "unknown";
68
- }
@@ -1 +0,0 @@
1
- export const VERSION = "0.12.0";
File without changes
File without changes
File without changes
File without changes
File without changes