watskeburt 4.0.2 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -1
- package/dist/cli.js +6 -0
- package/dist/format/format.js +5 -2
- package/dist/format/regex.js +1 -20
- package/dist/git-primitives.js +1 -1
- package/dist/main.js +2 -2
- package/dist/map-change-type.js +3 -3
- package/dist/parse-diff-lines.js +4 -4
- package/dist/parse-status-lines.js +4 -6
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/types/watskeburt.d.ts +5 -0
package/README.md
CHANGED
@@ -69,7 +69,8 @@ This emits a regex that contains all changed files that could be
|
|
69
69
|
source files in the JavaScript ecosystem (.js, .mjs, .ts, .tsx ...). It can
|
70
70
|
be used in e.g. dependency-cruiser's `--focus` and `--reaches` filters.
|
71
71
|
|
72
|
-
The JSON output (= the array above, serialized) also contains other
|
72
|
+
The JSON output (= the array above, serialized) also contains all other
|
73
|
+
extensions.
|
73
74
|
|
74
75
|
```
|
75
76
|
Usage: watskeburt [options] [old-revision] [new-revision]
|
package/dist/cli.js
CHANGED
@@ -60,6 +60,12 @@ function getArguments(pArguments) {
|
|
60
60
|
type: "boolean",
|
61
61
|
default: false,
|
62
62
|
},
|
63
|
+
extensions: {
|
64
|
+
type: "string",
|
65
|
+
short: "x",
|
66
|
+
default:
|
67
|
+
"cjs,cjsx,coffee,csx,cts,js,json,jsx,litcoffee,ls,mjs,mts,svelte,ts,tsx,vue,vuex",
|
68
|
+
},
|
63
69
|
help: { type: "boolean", short: "h", default: false },
|
64
70
|
version: { type: "boolean", short: "V", default: false },
|
65
71
|
},
|
package/dist/format/format.js
CHANGED
@@ -4,6 +4,9 @@ const OUTPUT_TYPE_TO_FUNCTION = new Map([
|
|
4
4
|
["regex", formatAsRegex],
|
5
5
|
["json", formatAsJSON],
|
6
6
|
]);
|
7
|
-
export function format(pChanges, pOutputType) {
|
8
|
-
|
7
|
+
export function format(pChanges, pOutputType, pExtensions) {
|
8
|
+
const lExtensions = new Set(
|
9
|
+
pExtensions.split(",").map((pExtension) => `.${pExtension.trim()}`),
|
10
|
+
);
|
11
|
+
return OUTPUT_TYPE_TO_FUNCTION.get(pOutputType)(pChanges, lExtensions);
|
9
12
|
}
|
package/dist/format/regex.js
CHANGED
@@ -1,23 +1,4 @@
|
|
1
1
|
import { extname } from "node:path";
|
2
|
-
const DEFAULT_EXTENSIONS = new Set([
|
3
|
-
".cjs",
|
4
|
-
".cjsx",
|
5
|
-
".coffee",
|
6
|
-
".csx",
|
7
|
-
".cts",
|
8
|
-
".js",
|
9
|
-
".json",
|
10
|
-
".jsx",
|
11
|
-
".litcoffee",
|
12
|
-
".ls",
|
13
|
-
".mjs",
|
14
|
-
".mts",
|
15
|
-
".svelte",
|
16
|
-
".ts",
|
17
|
-
".tsx",
|
18
|
-
".vue",
|
19
|
-
".vuex",
|
20
|
-
]);
|
21
2
|
const DEFAULT_CHANGE_TYPES = new Set([
|
22
3
|
"modified",
|
23
4
|
"added",
|
@@ -27,7 +8,7 @@ const DEFAULT_CHANGE_TYPES = new Set([
|
|
27
8
|
]);
|
28
9
|
export default function formatAsRegex(
|
29
10
|
pChanges,
|
30
|
-
pExtensions
|
11
|
+
pExtensions,
|
31
12
|
pChangeTypes = DEFAULT_CHANGE_TYPES,
|
32
13
|
) {
|
33
14
|
const lChanges = pChanges
|
package/dist/git-primitives.js
CHANGED
package/dist/main.js
CHANGED
@@ -2,7 +2,7 @@ import { parseDiffLines } from "./parse-diff-lines.js";
|
|
2
2
|
import { parseStatusLines } from "./parse-status-lines.js";
|
3
3
|
import * as primitives from "./git-primitives.js";
|
4
4
|
export async function list(pOptions) {
|
5
|
-
const lOldRevision = pOptions?.oldRevision
|
5
|
+
const lOldRevision = pOptions?.oldRevision ?? (await primitives.getSHA());
|
6
6
|
const lOptions = pOptions || {};
|
7
7
|
const [lDiffLines, lStatusLines] = await Promise.all([
|
8
8
|
primitives.getDiffLines(lOldRevision, pOptions?.newRevision),
|
@@ -20,7 +20,7 @@ export async function list(pOptions) {
|
|
20
20
|
return lChanges;
|
21
21
|
}
|
22
22
|
const { format } = await import("./format/format.js");
|
23
|
-
return format(lChanges, lOptions.outputType);
|
23
|
+
return format(lChanges, lOptions.outputType, lOptions.extensions);
|
24
24
|
}
|
25
25
|
export function getSHA() {
|
26
26
|
return primitives.getSHA();
|
package/dist/map-change-type.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
const
|
1
|
+
const CHANGE_TYPE_MAP = new Map([
|
2
2
|
["A", "added"],
|
3
3
|
["C", "copied"],
|
4
4
|
["D", "deleted"],
|
@@ -11,6 +11,6 @@ const CHANGE_CHAR_2_CHANGE_TYPE = new Map([
|
|
11
11
|
["?", "untracked"],
|
12
12
|
["!", "ignored"],
|
13
13
|
]);
|
14
|
-
export function
|
15
|
-
return
|
14
|
+
export function mapChangeType(pChar) {
|
15
|
+
return CHANGE_TYPE_MAP.get(pChar) ?? "unknown";
|
16
16
|
}
|
package/dist/parse-diff-lines.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { EOL } from "node:os";
|
2
|
-
import {
|
2
|
+
import { mapChangeType } from "./map-change-type.js";
|
3
3
|
const DIFF_NAME_STATUS_LINE_PATTERN =
|
4
|
-
/^(?<type>[ACDMRTUXB])(?<similarity
|
4
|
+
/^(?<type>[ACDMRTUXB])(?<similarity>\d{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/;
|
5
5
|
export function parseDiffLines(pString) {
|
6
6
|
return pString
|
7
7
|
.split(EOL)
|
@@ -10,10 +10,10 @@ export function parseDiffLines(pString) {
|
|
10
10
|
.filter(({ name, type }) => Boolean(name) && Boolean(type));
|
11
11
|
}
|
12
12
|
export function parseDiffLine(pString) {
|
13
|
-
const lMatchResult =
|
13
|
+
const lMatchResult = DIFF_NAME_STATUS_LINE_PATTERN.exec(pString);
|
14
14
|
const lReturnValue = {};
|
15
15
|
if (lMatchResult?.groups) {
|
16
|
-
lReturnValue.type =
|
16
|
+
lReturnValue.type = mapChangeType(lMatchResult.groups.type);
|
17
17
|
if (lMatchResult.groups.newName) {
|
18
18
|
lReturnValue.name = lMatchResult.groups.newName;
|
19
19
|
lReturnValue.oldName = lMatchResult.groups.name;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { EOL } from "node:os";
|
2
|
-
import {
|
2
|
+
import { mapChangeType } from "./map-change-type.js";
|
3
3
|
const DIFF_SHORT_STATUS_LINE_PATTERN =
|
4
4
|
/^(?<stagedType>[ ACDMRTUXB?!])(?<unStagedType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/;
|
5
5
|
export function parseStatusLines(pString) {
|
@@ -10,13 +10,11 @@ export function parseStatusLines(pString) {
|
|
10
10
|
.filter(({ name, type }) => Boolean(name) && Boolean(type));
|
11
11
|
}
|
12
12
|
export function parseStatusLine(pString) {
|
13
|
-
const lMatchResult =
|
13
|
+
const lMatchResult = DIFF_SHORT_STATUS_LINE_PATTERN.exec(pString);
|
14
14
|
const lReturnValue = {};
|
15
15
|
if (lMatchResult?.groups) {
|
16
|
-
const lStagedType =
|
17
|
-
const lUnStagedType =
|
18
|
-
lMatchResult.groups.unStagedType,
|
19
|
-
);
|
16
|
+
const lStagedType = mapChangeType(lMatchResult.groups.stagedType);
|
17
|
+
const lUnStagedType = mapChangeType(lMatchResult.groups.unStagedType);
|
20
18
|
lReturnValue.type =
|
21
19
|
lStagedType === "unmodified" ? lUnStagedType : lStagedType;
|
22
20
|
if (lMatchResult.groups.newName) {
|
package/dist/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "4.
|
1
|
+
export const VERSION = "4.1.1";
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "watskeburt",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.1.1",
|
4
4
|
"description": "List files changed since a git revision",
|
5
5
|
"keywords": [
|
6
6
|
"git",
|
@@ -48,6 +48,6 @@
|
|
48
48
|
"node": "^18||>=20"
|
49
49
|
},
|
50
50
|
"scripts": {
|
51
|
-
"test": "echo for test, build and
|
51
|
+
"test": "echo see github for test, build and analysis scripts"
|
52
52
|
}
|
53
53
|
}
|
package/types/watskeburt.d.ts
CHANGED
@@ -52,6 +52,11 @@ export interface IFormatOptions extends IBaseOptions {
|
|
52
52
|
* The type of output to deliver.
|
53
53
|
*/
|
54
54
|
outputType: "regex" | "json";
|
55
|
+
|
56
|
+
/**
|
57
|
+
* A comma-separated list of file extensions to include in the output
|
58
|
+
*/
|
59
|
+
extensions: string;
|
55
60
|
}
|
56
61
|
|
57
62
|
export interface IInternalOptions extends IBaseOptions {
|