watskeburt 0.3.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,56 +1,25 @@
1
1
  # watskeburt
2
2
 
3
- get git changed files & their statuses since _any revision_
3
+ Get changed files & their statuses since any git _revision_
4
4
 
5
5
  ## what's this do?
6
6
 
7
- A micro-lib to retrieve an array of file names that were changed (added,
8
- modified, renamed, deleted, ...) since the revision it got passed. Also
9
- sports a cli for use outside of JavaScript c.s.
7
+ A micro-lib to retrieve an array of file names that were changed since a
8
+ revision. Also sports a cli for use outside of JavaScript c.s.
10
9
 
11
- - :warning: in the process of getting 'production ready'. It's automatically
12
- tested + it's using itself - but a bunch of static analysis and a bit of
13
- automation still needs be added.
14
- - :warning: Interface is stable-ish, but can can change until 1.0.0 is published
15
- - :warning: expect some rough edges for e.g. error scenarios
10
+ - :warning: Interface is stable, but can can change until 1.0.0 is published :warning:
16
11
 
17
12
  ## why?
18
13
 
19
- Useful primitives to support e.g. auto-documenting pull requests, or to save
20
- processing power by only doing static analysis only over stuff that is changed.
14
+ I needed something simple and robust to support some upcoming features in
15
+ [dependency-cruiser](https://github.com/sverweij/dependency-cruiser) and to
16
+ run standalone to use _in combination_ with dependency-cruiser.
21
17
 
22
- There are a few packages like these like this on npm, but it seems they've
23
- fallen out of maintenance. More generic packages don't get plagued by this
18
+ There are a few specialized packages like this on npm, but it seems they've
19
+ fallen out of maintenance. More generic packages are still maintained,
24
20
  but for just this simple usage they're a bit overkill.
25
21
 
26
- ## usage
27
-
28
- ### :shell: cli
29
-
30
- For now there's also a simple command line interface
31
-
32
- ```shell
33
- # list all JavaScript-ish files changed since main in a regular expression
34
- $ npx watskeburt main
35
- ^(src/cli.mjs|src/formatters/regex.mjs|src/version.mjs)$
36
- ```
37
-
38
- By default this returns a regex that contains all changed files that could be
39
- source files in the JavaScript ecosystem (.js, .mjs, .ts, .tsx ...) that can
40
- be used in e.g. the `--focus` filter of dependency-cruiser:
41
-
42
- ```
43
- Usage: cli [options] <revision>
44
-
45
- lists files & their statuses since <revision>
46
-
47
- Options:
48
- -V, --version output the version number
49
- -T, --output-type <type> json,regex (default: "regex")
50
- --tracked-only only take tracked files into account (default: false)
51
- -h, --help display help for command
52
-
53
- ```
22
+ ## :construction_worker: usage
54
23
 
55
24
  ### :scroll: API
56
25
 
@@ -61,28 +30,73 @@ import { list, getSHA } from "watskeburt";
61
30
  // print the SHA1 of the current HEAD
62
31
  console.log(getSHA());
63
32
 
64
- // list all files that differ between 'main' and
33
+ // list all files that differ between 'main' and the current revision (including
34
+ // files not staged for commit and files not under revision control)
65
35
  /** @type {import('watskeburt').IChange[]} */
66
36
  const lChangedFiles = list("main");
37
+
38
+ // As a second parameter you can pass some options:
39
+ /** @type {import('watskeburt').IChange[]|string} */
40
+ const lChangedFiles = list("main", {
41
+ trackedOnly: false, // when set to true leaves out files not under revision control
42
+ outputType: "object", // other options: "json" and "regex" (as used in the CLI)
43
+ });
67
44
  ```
68
45
 
69
- An array of changes looks something like this:
46
+ The array of changes this returns looks like this:
70
47
 
71
48
  ```javascript
72
49
  [
73
- { name: "doc/cli.md", changeType: "modified" },
50
+ {
51
+ name: "doc/cli.md",
52
+ changeType: "modified",
53
+ },
74
54
  {
75
55
  name: "test/thing.spec.mjs",
76
56
  changeType: "renamed",
77
57
  oldName: "test/old-thing.spec.mjs",
78
- similarity: 66,
79
58
  },
80
- { name: "src/not-tracked-yet.mjs", changeType: "untracked" },
59
+ {
60
+ name: "src/not-tracked-yet.mjs",
61
+ changeType: "untracked",
62
+ },
81
63
  ];
82
64
  ```
83
65
 
84
- ## 🇳🇱 'watskeburt'??
66
+ ### :shell: cli
67
+
68
+ For now there's also a simple command line interface
69
+
70
+ ```shell
71
+ # list all JavaScript-ish files changed since main in a regular expression
72
+ $ npx watskeburt main
73
+ ^(src/cli.mjs|src/formatters/regex.mjs|src/version.mjs)$
74
+ ```
75
+
76
+ By default this returns a regex that contains all changed files that could be
77
+ source files in the JavaScript ecosystem (.js, .mjs, .ts, .tsx ...) that can
78
+ be used in e.g. the `--focus` and `--reaches` filters of dependency-cruiser.
79
+
80
+ The JSON output (which looks a lot like the array above) is unfiltered and
81
+ also contains other extensions.
82
+
83
+ ```
84
+ Usage: cli [options] [revision]
85
+
86
+ lists files & their statuses since [revision].
87
+
88
+ -> When you don't pass a revision the revision defaults to the current one.
89
+
90
+ Options:
91
+ -V, --version output the version number
92
+ -T, --output-type <type> json,regex (default: "regex")
93
+ --tracked-only only take tracked files into account (default: false)
94
+ -h, --help display help for command
95
+ ```
96
+
97
+ ## 🇳🇱 what does 'watskeburt' mean?
85
98
 
86
- _watskeburt_ is a fast pronunciation of the Dutch sentence "Wat is er gebeurd?"
87
- (What has happened?), as well as the title of a song by the Dutch hip hop group
88
- "De Jeugd van Tegenwoordig".
99
+ _watskeburt_ is a fast pronunciation of the Dutch "wat is er gebeurd?"
100
+ (_what has happened?_) or "wat er is gebeurd" (_what has happened_). It's
101
+ also the title of a song by the Dutch band "De Jeugd van Tegenwoordig"
102
+ (_Youth these days..._).
@@ -1 +1 @@
1
- var i=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},C=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of w(t))!x.call(e,o)&&o!==n&&i(e,o,{get:()=>t[o],enumerable:!(r=y(t,o))||r.enumerable});return e};var A=e=>C(i({},"__esModule",{value:!0}),e);var M={};E(M,{getSHA:()=>B,list:()=>j});module.exports=A(M);var u=require("os"),_=/^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/,D=/^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/,R={A:"added",C:"copied",D:"deleted",M:"modified",R:"renamed",T:"type changed",U:"unmerged",B:"pairing broken"," ":"unmodified","?":"untracked","!":"ignored"};function s(e){return R[e]||"unknown"}function L(e){let t=e.match(D),n={};if(t){let r=s(t.groups.stagedChangeType),o=s(t.groups.unStagedChangeType);n.changeType=r==="unmodified"?o:r,t.groups.newName?(n.name=t.groups.newName,n.oldName=t.groups.name):n.name=t.groups.name}return n}function U(e){let t=e.match(_),n={};return t&&(n.changeType=s(t.groups.changeType),t.groups.similarity&&(n.similarity=Number.parseInt(t.groups.similarity,10)),t.groups.newName?(n.name=t.groups.newName,n.oldName=t.groups.name):n.name=t.groups.name),n}function l(e){return e.split(u.EOL).filter(Boolean).map(L).filter(({changeType:t})=>Boolean(t))}function g(e){return e.split(u.EOL).filter(Boolean).map(U).filter(({changeType:t})=>Boolean(t))}var a=require("child_process");function d(e){return e instanceof Buffer?e.toString("utf8"):e}function O(e){throw e.code==="ENOENT"?new Error("git executable not found"):new Error(`internal spawn error: ${e}`)}function c(e,t,n){let r=n("git",e,{cwd:process.cwd(),env:process.env});if(r.error&&O(r.error),r.status===0)return d(r.stdout);throw new Error(t[r.status]||`internal git error: ${r.status} (${d(r.stderr)})`)}function T(e=a.spawnSync){let t={129:`'${process.cwd()}' does not seem to be a git repository`};return c(["status","--porcelain"],t,e)}function h(e,t=a.spawnSync){let n={128:`revision '${e}' unknown `,129:`'${process.cwd()}' does not seem to be a git repository`};return c(["diff",e,"--name-status"],n,t)}function S(e=a.spawnSync){return c(["rev-parse","HEAD"],{},e).slice(0,40)}var N=require("path");function f(e,t=[".js",".jsx",".mjs",".cjs",".ts",".tsx",".vue",".vuex",".json"],n=["modified","added","renamed","copied","untracked"]){return`^(${e.filter(o=>n.includes(o.changeType)).map(({name:o})=>o).filter(o=>t.includes((0,N.extname)(o))).join("|")})$`}function p(e){return JSON.stringify(e,null,2)}var v={regex:f,json:p,object:e=>e},$="object";function m(e,t){return v[t||$](e)}function j(e,t){let n=g(h(e)),r=t||{};return r.trackedOnly||(n=n.concat(l(T()).filter(({changeType:o})=>o==="untracked"))),m(n,r.outputType)}function B(){return S()}0&&(module.exports={getSHA,list});
1
+ "use strict";var a=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},_=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of y(t))!A.call(e,r)&&r!==n&&a(e,r,{get:()=>t[r],enumerable:!(o=x(t,r))||o.enumerable});return e};var D=e=>_(a({},"__esModule",{value:!0}),e);var I={};C(I,{getSHA:()=>E,list:()=>F});module.exports=D(I);var u=require("os"),L=/^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/,R=/^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/,U={A:"added",C:"copied",D:"deleted",M:"modified",R:"renamed",T:"type changed",U:"unmerged",B:"pairing broken"," ":"unmodified","?":"untracked","!":"ignored"};function i(e){return U[e]||"unknown"}function O(e){let t=e.match(R),n={};if(t){let o=i(t.groups.stagedChangeType),r=i(t.groups.unStagedChangeType);n.changeType=o==="unmodified"?r:o,t.groups.newName?(n.name=t.groups.newName,n.oldName=t.groups.name):n.name=t.groups.name}return n}function v(e){let t=e.match(L),n={};return t&&(n.changeType=i(t.groups.changeType),t.groups.newName?(n.name=t.groups.newName,n.oldName=t.groups.name):n.name=t.groups.name),n}function m(e){return e.split(u.EOL).filter(Boolean).map(O).filter(({changeType:t})=>Boolean(t))}function g(e){return e.split(u.EOL).filter(Boolean).map(v).filter(({changeType:t})=>Boolean(t))}var s=require("child_process");function d(e){return e instanceof Buffer?e.toString("utf8"):e}function j(e){throw e.code==="ENOENT"?new Error("git executable not found"):new Error(`internal spawn error: ${e}`)}function c(e,t,n){let o=n("git",e,{cwd:process.cwd(),env:process.env});if(o.error&&j(o.error),o.status===0)return d(o.stdout);throw new Error(t[o.status]||`internal git error: ${o.status} (${d(o.stderr)})`)}function T(e=s.spawnSync){let t={129:`'${process.cwd()}' does not seem to be a git repository`};return c(["status","--porcelain"],t,e)}function h(e,t=s.spawnSync){let n={128:`revision '${e}' unknown `,129:`'${process.cwd()}' does not seem to be a git repository`};return c(["diff",e,"--name-status"],n,t)}function S(e=s.spawnSync){return c(["rev-parse","HEAD"],{},e).slice(0,40)}var N=require("path"),$=new Set([".cjs",".cjsx",".coffee",".csx",".js",".json",".jsx",".litcoffee",".ls",".mjs",".svelte",".ts",".tsx",".vue",".vuex"]),B=new Set(["modified","added","renamed","copied","untracked"]);function f(e,t=$,n=B){return`^(${e.filter(r=>n.has(r.changeType)).map(({name:r})=>r).filter(r=>t.has((0,N.extname)(r))).join("|")})$`}function p(e){return JSON.stringify(e,null,2)}var H={regex:f,json:p,object:e=>e},M="object";function l(e,t){return H[t||M](e)}function E(){return S()}function F(e,t){let n=e||E(),o=g(h(n)),r=t||{};return r.trackedOnly||(o=o.concat(m(T()).filter(({changeType:w})=>w==="untracked"))),l(o,r.outputType)}0&&(module.exports={getSHA,list});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "watskeburt",
3
- "version": "0.3.0",
3
+ "version": "0.5.1",
4
4
  "description": "List files changed since a git revision",
5
5
  "keywords": [
6
6
  "git",
@@ -47,22 +47,25 @@
47
47
  "commander": "^9.3.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@typescript-eslint/eslint-plugin": "^5.30.5",
51
- "c8": "^7.11.3",
52
- "dependency-cruiser": "^11.11.0",
53
- "esbuild": "^0.14.48",
54
- "eslint": "^8.19.0",
50
+ "@types/mocha": "^9.1.1",
51
+ "@types/node": "^18.0.6",
52
+ "@typescript-eslint/eslint-plugin": "^5.30.7",
53
+ "c8": "^7.12.0",
54
+ "dependency-cruiser": "^11.12.0",
55
+ "esbuild": "^0.14.49",
56
+ "eslint": "^8.20.0",
55
57
  "eslint-config-moving-meadow": "^3.0.0",
56
58
  "eslint-config-prettier": "^8.5.0",
57
59
  "eslint-plugin-budapestian": "^4.0.0",
58
60
  "eslint-plugin-import": "^2.26.0",
59
- "eslint-plugin-mocha": "^10.0.5",
61
+ "eslint-plugin-mocha": "^10.1.0",
60
62
  "eslint-plugin-node": "^11.1.0",
61
63
  "eslint-plugin-security": "^1.5.0",
62
- "eslint-plugin-unicorn": "^43.0.1",
64
+ "eslint-plugin-unicorn": "^43.0.2",
63
65
  "mocha": "^10.0.0",
64
66
  "npm-run-all": "^4.1.5",
65
- "prettier": "^2.7.1"
67
+ "prettier": "^2.7.1",
68
+ "typescript": "^4.7.4"
66
69
  },
67
70
  "engines": {
68
71
  "node": "^12.20||^14||>=16"
@@ -71,24 +74,26 @@
71
74
  "build": "npm-run-all --sequential build:version build:dist",
72
75
  "build:version": "node tools/get-version.mjs > src/version.mjs",
73
76
  "build:dist": "esbuild src/main.mjs --format=cjs --target=node12 --platform=node --bundle --global-name=wkbtcjs --minify --outfile=dist/cjs-bundle.js",
77
+ "check": "npm-run-all --parallel --aggregate-output lint depcruise test:cover",
74
78
  "clean": "rm -rf dist",
75
79
  "test": "mocha \"src/**/*.spec.mjs\"",
76
80
  "test:cover": "c8 --check-coverage --statements 100 --branches 100 --functions 100 --lines 100 --exclude \"**/*.spec.mjs\" --reporter text-summary --reporter html --reporter json-summary npm test",
77
- "depcruise": "depcruise src --config",
78
- "depcruise:graph": "depcruise src --include-only '^(src)' --config --output-type dot | dot -T svg | tee docs/dependency-graph.svg | depcruise-wrap-stream-in-html > docs/dependency-graph.html",
81
+ "depcruise": "depcruise src types --config",
82
+ "depcruise:graph": "depcruise src types --include-only '^(src|types)' --config --output-type dot | dot -T svg | tee docs/dependency-graph.svg | depcruise-wrap-stream-in-html > docs/dependency-graph.html",
79
83
  "depcruise:graph:archi": "depcruise src --include-only '^(src)' --config --output-type archi | dot -T svg | depcruise-wrap-stream-in-html > docs/high-level-dependency-graph.html",
80
84
  "depcruise:graph:dev": "depcruise src --include-only '^(src)' --prefix vscode://file/$(pwd)/ --config --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
81
- "depcruise:graph:diff:dev": "depcruise src --include-only '^(src)' --focus \"$(node src/cli.mjs main -T regex)\" --prefix vscode://file/$(pwd)/ --config --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
82
- "depcruise:graph:diff:mermaid": "depcruise src --include-only '^(src)' --config --output-type mermaid --output-to - --focus \"$(node src/cli.mjs $SHA -T regex)\"",
85
+ "depcruise:graph:diff:dev": "depcruise src types --include-only '^(src|types)' --focus \"$(node src/cli.mjs main -T regex)\" --focus-depth 0 --prefix vscode://file/$(pwd)/ --config --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
86
+ "depcruise:graph:diff:mermaid": "depcruise src types --include-only '^(src|types)' --config --output-type mermaid --output-to - --focus \"$(node src/cli.mjs $SHA -T regex)\" --focus-depth 0",
83
87
  "depcruise:html": "depcruise src --progress --config --output-type err-html --output-to dependency-violation-report.html",
84
88
  "depcruise:text": "depcruise src --progress --config --output-type text",
85
89
  "depcruise:focus": "depcruise src --progress --config --output-type text --focus",
86
- "lint": "npm-run-all --parallel --aggregate-output lint:format lint:eslint",
90
+ "lint": "npm-run-all --parallel --aggregate-output lint:format lint:eslint lint:types",
87
91
  "lint:fix": "npm-run-all --parallel --aggregate-output lint:format:fix lint:eslint:fix",
88
- "lint:eslint": "eslint src --cache --cache-location node_modules/.cache/eslint/",
89
- "lint:eslint:fix": "eslint src tools --fix --cache --cache-location node_modules/.cache/eslint/",
92
+ "lint:eslint": "eslint src types tools --cache --cache-location node_modules/.cache/eslint/",
93
+ "lint:eslint:fix": "eslint src types tools --fix --cache --cache-location node_modules/.cache/eslint/",
90
94
  "lint:format": "prettier --check \"{src,tools}/**/*.mjs\" \"types/**/*.ts\" \"*.{json,yml,md,js}\"",
91
95
  "lint:format:fix": "prettier --loglevel warn --write \"{src,tools}/**/*.mjs\" \"types/**/*.ts\" \"*.{json,yml,md,js}\"",
96
+ "lint:types": "tsc",
92
97
  "scm:stage": "git add .",
93
98
  "version": "npm-run-all --sequential clean build lint depcruise:graph scm:stage"
94
99
  },
package/src/cli.mjs CHANGED
@@ -6,19 +6,18 @@ import { list } from "./main.mjs";
6
6
  import { VERSION } from "./version.mjs";
7
7
 
8
8
  program
9
- .description("lists files & their statuses since <revision>")
9
+ .description(
10
+ "lists files & their statuses since [revision].\n\n" +
11
+ "-> When you don't pass a revision the revision defaults to the current one."
12
+ )
10
13
  .version(VERSION)
11
14
  .option("-T, --output-type <type>", "json,regex", "regex")
12
15
  .option("--tracked-only", "only take tracked files into account", false)
13
- .arguments("<revision>")
16
+ .arguments("[revision]")
14
17
  .parse(process.argv);
15
18
 
16
- if (program.args[0]) {
17
- try {
18
- console.log(list(program.args[0], program.opts()));
19
- } catch (pError) {
20
- console.error(`ERROR: ${pError.message}`);
21
- }
22
- } else {
23
- program.help();
19
+ try {
20
+ console.log(list(program.args[0], program.opts()));
21
+ } catch (pError) {
22
+ console.error(`ERROR: ${pError.message}`);
24
23
  }
@@ -76,12 +76,6 @@ export function convertDiffLine(pString) {
76
76
  lReturnValue.changeType = changeChar2ChangeType(
77
77
  lMatchResult.groups.changeType
78
78
  );
79
- if (lMatchResult.groups.similarity) {
80
- lReturnValue.similarity = Number.parseInt(
81
- lMatchResult.groups.similarity,
82
- 10
83
- );
84
- }
85
79
  if (lMatchResult.groups.newName) {
86
80
  lReturnValue.name = lMatchResult.groups.newName;
87
81
  lReturnValue.oldName = lMatchResult.groups.name;
@@ -1,34 +1,47 @@
1
1
  import { extname } from "node:path";
2
2
 
3
+ const DEFAULT_EXTENSIONS = new Set([
4
+ ".cjs",
5
+ ".cjsx",
6
+ ".coffee",
7
+ ".csx",
8
+ ".js",
9
+ ".json",
10
+ ".jsx",
11
+ ".litcoffee",
12
+ ".ls",
13
+ ".mjs",
14
+ ".svelte",
15
+ ".ts",
16
+ ".tsx",
17
+ ".vue",
18
+ ".vuex",
19
+ ]);
20
+
21
+ const DEFAULT_CHANGE_TYPES = new Set([
22
+ "modified",
23
+ "added",
24
+ "renamed",
25
+ "copied",
26
+ "untracked",
27
+ ]);
3
28
  /**
4
29
  *
5
30
  * @param {import('../types/watskeburt').IChange[]} pChanges
6
- * @param {string[]} pExtensions
7
- * @param {import('../types/watskeburt').changeTypeType[]} pChangeTypes
31
+ * @param {Set<string>} pExtensions
32
+ * @param {Set<import('../types/watskeburt').changeTypeType>} pChangeTypes
8
33
  * @return {string}
9
34
  */
10
35
  export default function formatToRegex(
11
36
  pChanges,
12
- pExtensions = [
13
- ".js",
14
- ".jsx",
15
- ".mjs",
16
- ".cjs",
17
- ".ts",
18
- ".tsx",
19
- ".vue",
20
- ".vuex",
21
- ".json",
22
- ],
23
- pChangeTypes = ["modified", "added", "renamed", "copied", "untracked"]
37
+ pExtensions = DEFAULT_EXTENSIONS,
38
+ pChangeTypes = DEFAULT_CHANGE_TYPES
24
39
  ) {
25
40
  const lChanges = pChanges
26
- .filter((pChange) => pChangeTypes.includes(pChange.changeType))
27
- .map(
28
- // .replace(/\./g, "\\\\.")
29
- ({ name }) => name
30
- )
31
- .filter((pName) => pExtensions.includes(extname(pName)))
41
+ .filter((pChange) => pChangeTypes.has(pChange.changeType))
42
+ .map(({ name }) => name)
43
+ .filter((pName) => pExtensions.has(extname(pName)))
44
+ // .replace(/\./g, "\\\\.")
32
45
  .join("|");
33
46
  return `^(${lChanges})$`;
34
47
  }
package/src/main.mjs CHANGED
@@ -5,9 +5,15 @@ import {
5
5
  import { getDiffLines, getSHA1, getStatusShort } from "./git-primitives.mjs";
6
6
  import format from "./formatters/format.mjs";
7
7
 
8
+ /** @type {import("../types/watskeburt.js").getSHA} */
9
+ export function getSHA() {
10
+ return getSHA1();
11
+ }
12
+
8
13
  /** @type {import("../types/watskeburt.js").list} */
9
14
  export function list(pOldRevision, pOptions) {
10
- let lChanges = convertDiffLines(getDiffLines(pOldRevision));
15
+ const lOldRevision = pOldRevision || getSHA();
16
+ let lChanges = convertDiffLines(getDiffLines(lOldRevision));
11
17
  const lOptions = pOptions || {};
12
18
 
13
19
  if (!lOptions.trackedOnly) {
@@ -19,8 +25,3 @@ export function list(pOldRevision, pOptions) {
19
25
  }
20
26
  return format(lChanges, lOptions.outputType);
21
27
  }
22
-
23
- /** @type {import("../types/watskeburt.js").getSHA} */
24
- export function getSHA() {
25
- return getSHA1();
26
- }
package/src/version.mjs CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.3.0";
1
+ export const VERSION = "0.5.1";
@@ -21,10 +21,6 @@ export interface IChange {
21
21
  * how the file was changed
22
22
  */
23
23
  changeType: changeTypeType;
24
- /**
25
- * if the file was renamed: the % of similarity (range: 0 - 100)
26
- */
27
- similarity?: Number;
28
24
  /**
29
25
  * if the file was renamed: what the old file's name was
30
26
  */
@@ -51,15 +47,16 @@ export interface IOptions {
51
47
  /**
52
48
  * returns a list of files changed since pOldRevision.
53
49
  *
54
- * @param pOldRevision the revision against which to compare. E.g. a commit-hash,
55
- * a branch or a tag.
50
+ * @param pOldRevision The revision against which to compare. E.g. a commit-hash,
51
+ * a branch or a tag. When not passed defaults to the _current_
52
+ * commit hash (if there's any)
56
53
  * @param pOptions Options that influence how the changes are returned and that
57
54
  * filter what is returned and
58
55
  * @throws {Error}
59
56
  */
60
57
  export function list(
61
- pOldRevision: string,
62
- pOptions: IOptions
58
+ pOldRevision?: string,
59
+ pOptions?: IOptions
63
60
  ): IChange[] | string;
64
61
 
65
62
  /**
@@ -1,47 +0,0 @@
1
- {
2
- "root": true,
3
- "extends": ["moving-meadow"],
4
- "overrides": [
5
- {
6
- "files": ["**/*.mjs"],
7
- "rules": {
8
- "unicorn/no-null": "off",
9
- "unicorn/prefer-spread": "off",
10
- "node/no-unsupported-features/es-syntax": "off",
11
- "import/no-relative-parent-imports": "off",
12
- "sort-imports": "off",
13
- "unicorn/prefer-node-protocol": "error",
14
- "unicorn/prefer-module": "error"
15
- },
16
- "parserOptions": {
17
- "ecmaVersion": "latest"
18
- }
19
- },
20
- {
21
- "files": ["**/*.spec.mjs"],
22
- "env": {
23
- "mocha": true
24
- },
25
- "rules": {
26
- "no-magic-numbers": "off",
27
- "security/detect-non-literal-require": "off",
28
- "security/detect-non-literal-fs-filename": "off",
29
- "max-lines-per-function": "off",
30
- "max-lines": "off",
31
- "no-null": "off"
32
- }
33
- },
34
- {
35
- "files": ["types/*.ts"],
36
- "plugins": ["@typescript-eslint"],
37
- "extends": ["plugin:@typescript-eslint/recommended"],
38
- "parser": "@typescript-eslint/parser",
39
- "parserOptions": {
40
- "ecmaVersion": "latest"
41
- },
42
- "rules": {
43
- "node/no-unsupported-features/es-syntax": "off"
44
- }
45
- }
46
- ]
47
- }