watskeburt 0.1.0 → 0.2.0
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 +4 -6
- package/dist/cjs-bundle.js +1 -0
- package/package.json +16 -7
- package/src/main.mjs +3 -2
package/README.md
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
# watskeburt
|
2
2
|
|
3
|
-
get git changed files & their
|
3
|
+
get git changed files & their statuses since _any reference_
|
4
4
|
|
5
5
|
## what's this do?
|
6
6
|
|
7
7
|
A micro-lib to retrieve an array of file names that were changed (added,
|
8
8
|
modified, renamed, deleted, ...) since the reference it got passed.
|
9
9
|
|
10
|
-
- :warning: NOT yet published on npm
|
11
10
|
- :warning: in the process of getting 'production ready'. It's automatically
|
12
|
-
tested + it's using itself
|
13
|
-
|
14
|
-
-
|
15
|
-
previous point.
|
11
|
+
tested + it's using itself - but a bunch of static analysis and a bit of
|
12
|
+
automation still needs be added.
|
13
|
+
- Interface is stable-ish, but can can change until 1.0.0 is published
|
16
14
|
|
17
15
|
## sample return value
|
18
16
|
|
@@ -0,0 +1 @@
|
|
1
|
+
var a=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var R=(t,e)=>{for(var n in e)a(t,n,{get:e[n],enumerable:!0})},_=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of N(e))!C.call(t,r)&&r!==n&&a(t,r,{get:()=>e[r],enumerable:!(o=S(e,r))||o.enumerable});return t};var w=t=>_(a({},"__esModule",{value:!0}),t);var B={};R(B,{convert:()=>v});module.exports=w(B);var u=require("os"),x=new RegExp("^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ ]+(?<name>[^ ]+)[ ]*(?<newName>[^ ]+)?$"),E=new RegExp("^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ ]+(?<name>[^ ]+)(( -> )(?<newName>[^ ]+))?$"),A={A:"added",C:"copied",D:"deleted",M:"modified",R:"renamed",T:"type changed",U:"unmerged",B:"pairing broken"," ":"unmodified","?":"untracked","!":"ignored"};function i(t){return A[t]||"unknown"}function U(t){let e=t.match(E),n={};if(e){let o=i(e.groups.stagedChangeType),r=i(e.groups.unStagedChangeType);n.changeType=o==="unmodified"?r:o,e.groups.newName?(n.name=e.groups.newName,n.oldName=e.groups.name):n.name=e.groups.name}return n}function D(t){let e=t.match(x),n={};return e&&(n.changeType=i(e.groups.changeType),e.groups.similarity&&(n.similarity=Number.parseInt(e.groups.similarity,10)),e.groups.newName?(n.name=e.groups.newName,n.oldName=e.groups.name):n.name=e.groups.name),n}function p(t){return t.split(u.EOL).filter(Boolean).map(U).filter(({changeType:e})=>Boolean(e))}function g(t){return t.split(u.EOL).filter(Boolean).map(D).filter(({changeType:e})=>Boolean(e))}var s=require("child_process");function l(t){return t instanceof Buffer?t.toString("utf8"):t}function d(t,e){let n=e("git",t,{cwd:process.cwd(),env:process.env});if(n.error)throw new Error(l(n.error));if(n.status===0)return l(n.stdout);throw new Error(n.output)}function T(t=s.spawnSync){return d(["status","--porcelain"],t)}function h(t,e=s.spawnSync){return d(["diff",t,"--name-status"],e)}var y=require("path");function f(t,e=[".js",".ts",".mjs",".cjs"],n=["modified","added","renamed","copied","untracked"]){return`^(${t.filter(r=>n.includes(r.changeType)).map(({name:r})=>r).filter(r=>e.includes((0,y.extname)(r))).join("|")})$`}function c(t){return JSON.stringify(t,null,2)}var L={regex:f,json:c,object:t=>t},O="object";function m(t,e){return L[e||O](t)}function v(t,e){let n=g(h(t)),o=e||{};return o.trackedOnly||(n=n.concat(p(T()).filter(({changeType:r})=>r==="untracked"))),m(n,o.outputType)}0&&(module.exports={convert});
|
package/package.json
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
{
|
2
2
|
"name": "watskeburt",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.2.0",
|
4
4
|
"description": "list files changed since a git reference",
|
5
5
|
"bin": "src/cli.mjs",
|
6
|
-
"main": "
|
6
|
+
"main": "dist/cjs-bundle.js",
|
7
7
|
"module": "src/main.mjs",
|
8
8
|
"exports": {
|
9
9
|
".": [
|
10
10
|
{
|
11
|
-
"import": "./src/main.mjs"
|
12
|
-
|
11
|
+
"import": "./src/main.mjs",
|
12
|
+
"require": "./dist/cjs-bundle.js"
|
13
|
+
},
|
14
|
+
"./dist/cjs-bundle.js"
|
13
15
|
]
|
14
16
|
},
|
15
17
|
"types": "types/watskeburt.d.ts",
|
16
18
|
"files": [
|
17
19
|
"src",
|
20
|
+
"dist",
|
18
21
|
"!src/**/*.spec.mjs",
|
19
22
|
"!**/*.DS_Store",
|
20
23
|
"types",
|
@@ -23,17 +26,21 @@
|
|
23
26
|
"README.md"
|
24
27
|
],
|
25
28
|
"scripts": {
|
29
|
+
"build": "esbuild src/main.mjs --format=cjs --target=node12 --platform=node --bundle --global-name=wkbtcjs --minify --outfile=dist/cjs-bundle.js",
|
30
|
+
"clean": "rm -rf dist",
|
26
31
|
"test": "mocha \"src/**/*.spec.mjs\"",
|
27
32
|
"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",
|
28
33
|
"depcruise": "depcruise src --config",
|
29
|
-
"depcruise:graph": "depcruise src --include-only '^(src)' --config --output-type dot | dot -T svg | depcruise-wrap-stream-in-html > docs/dependency-graph.html",
|
34
|
+
"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",
|
30
35
|
"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",
|
31
36
|
"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",
|
32
37
|
"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",
|
33
38
|
"depcruise:graph:diff:mermaid": "depcruise src --include-only '^(src)' --config --output-type mermaid --output-to - --focus \"$(node src/cli.mjs $SHA -T regex)\"",
|
34
39
|
"depcruise:html": "depcruise src --progress --config --output-type err-html --output-to dependency-violation-report.html",
|
35
40
|
"depcruise:text": "depcruise src --progress --config --output-type text",
|
36
|
-
"depcruise:focus": "depcruise src --progress --config --output-type text --focus"
|
41
|
+
"depcruise:focus": "depcruise src --progress --config --output-type text --focus",
|
42
|
+
"scm:stage": "git add .",
|
43
|
+
"version": "run-s clean build depcruise:graph scm:stage"
|
37
44
|
},
|
38
45
|
"keywords": [
|
39
46
|
"git",
|
@@ -44,7 +51,9 @@
|
|
44
51
|
"devDependencies": {
|
45
52
|
"c8": "^7.11.3",
|
46
53
|
"dependency-cruiser": "^11.11.0",
|
47
|
-
"
|
54
|
+
"esbuild": "^0.14.48",
|
55
|
+
"mocha": "^10.0.0",
|
56
|
+
"npm-run-all": "^4.1.5"
|
48
57
|
},
|
49
58
|
"dependencies": {
|
50
59
|
"commander": "^9.3.0"
|
package/src/main.mjs
CHANGED
@@ -20,13 +20,14 @@ import format from "./formatters/format.mjs";
|
|
20
20
|
*/
|
21
21
|
export function convert(pOldThing, pOptions) {
|
22
22
|
let lChanges = convertDiffLines(getDiffLines(pOldThing));
|
23
|
+
const lOptions = pOptions || {};
|
23
24
|
|
24
|
-
if (!
|
25
|
+
if (!lOptions.trackedOnly) {
|
25
26
|
lChanges = lChanges.concat(
|
26
27
|
convertStatusLines(getStatusShort()).filter(
|
27
28
|
({ changeType }) => changeType === "untracked"
|
28
29
|
)
|
29
30
|
);
|
30
31
|
}
|
31
|
-
return format(lChanges,
|
32
|
+
return format(lChanges, lOptions.outputType);
|
32
33
|
}
|