watskeburt 4.0.2 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
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 extensions.
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
  },
@@ -4,6 +4,12 @@ const OUTPUT_TYPE_TO_FUNCTION = new Map([
4
4
  ["regex", formatAsRegex],
5
5
  ["json", formatAsJSON],
6
6
  ]);
7
- export function format(pChanges, pOutputType) {
8
- return OUTPUT_TYPE_TO_FUNCTION.get(pOutputType)(pChanges);
7
+ export function format(pChanges, pOutputType, pExtensions) {
8
+ const lExtensions = new Set(
9
+ pExtensions
10
+ .split(",")
11
+ .map((pExtension) => pExtension.trim())
12
+ .map((pExtension) => `.${pExtension}`),
13
+ );
14
+ return OUTPUT_TYPE_TO_FUNCTION.get(pOutputType)(pChanges, lExtensions);
9
15
  }
@@ -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 = DEFAULT_EXTENSIONS,
11
+ pExtensions,
31
12
  pChangeTypes = DEFAULT_CHANGE_TYPES,
32
13
  ) {
33
14
  const lChanges = pChanges
package/dist/main.js CHANGED
@@ -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();
@@ -1,4 +1,4 @@
1
- const CHANGE_CHAR_2_CHANGE_TYPE = new Map([
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 changeChar2ChangeType(pChar) {
15
- return CHANGE_CHAR_2_CHANGE_TYPE.get(pChar) ?? "unknown";
14
+ export function mapChangeType(pChar) {
15
+ return CHANGE_TYPE_MAP.get(pChar) ?? "unknown";
16
16
  }
@@ -1,5 +1,5 @@
1
1
  import { EOL } from "node:os";
2
- import { changeChar2ChangeType } from "./map-change-type.js";
2
+ import { mapChangeType } from "./map-change-type.js";
3
3
  const DIFF_NAME_STATUS_LINE_PATTERN =
4
4
  /^(?<type>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/;
5
5
  export function parseDiffLines(pString) {
@@ -13,7 +13,7 @@ export function parseDiffLine(pString) {
13
13
  const lMatchResult = pString.match(DIFF_NAME_STATUS_LINE_PATTERN);
14
14
  const lReturnValue = {};
15
15
  if (lMatchResult?.groups) {
16
- lReturnValue.type = changeChar2ChangeType(lMatchResult.groups.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 { changeChar2ChangeType } from "./map-change-type.js";
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) {
@@ -13,10 +13,8 @@ export function parseStatusLine(pString) {
13
13
  const lMatchResult = pString.match(DIFF_SHORT_STATUS_LINE_PATTERN);
14
14
  const lReturnValue = {};
15
15
  if (lMatchResult?.groups) {
16
- const lStagedType = changeChar2ChangeType(lMatchResult.groups.stagedType);
17
- const lUnStagedType = changeChar2ChangeType(
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.0.2";
1
+ export const VERSION = "4.1.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "watskeburt",
3
- "version": "4.0.2",
3
+ "version": "4.1.0",
4
4
  "description": "List files changed since a git revision",
5
5
  "keywords": [
6
6
  "git",
@@ -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 {