watskeburt 0.11.2 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -7
- package/bin/cli.js +2 -26
- package/dist/cjs-bundle.cjs +1 -1
- package/dist/esm/cli.js +63 -0
- package/dist/esm/convert-to-change-object.js +15 -15
- package/dist/esm/formatters/regex.js +1 -1
- package/dist/esm/git-primitives-sync.js +31 -31
- package/dist/esm/git-primitives.js +28 -28
- package/dist/esm/version.js +1 -0
- package/package.json +11 -14
- package/types/watskeburt.d.ts +62 -7
- package/bin/version.js +0 -2
package/README.md
CHANGED
@@ -98,17 +98,17 @@ The JSON output (which looks a lot like the array above) is unfiltered and
|
|
98
98
|
also contains other extensions.
|
99
99
|
|
100
100
|
```
|
101
|
-
Usage:
|
101
|
+
Usage: watskeburt [options] [old-revision] [new-revision]
|
102
102
|
|
103
|
-
lists files & their statuses since [revision].
|
103
|
+
lists files & their statuses since [old-revision] or between [old-revision] and [new-revision].
|
104
104
|
|
105
|
-
-> When you don't pass a revision
|
105
|
+
-> When you don't pass a revision at all old-revision defaults to the current one.
|
106
106
|
|
107
107
|
Options:
|
108
|
-
-
|
109
|
-
|
110
|
-
--
|
111
|
-
-h, --help
|
108
|
+
-T, --outputType <type> what format to emit (choices: "json", "regex", default: "regex")
|
109
|
+
--trackedOnly only take tracked files into account (default: false)
|
110
|
+
-V, --version output the version number
|
111
|
+
-h, --help display help for command
|
112
112
|
```
|
113
113
|
|
114
114
|
## 🇳🇱 what does 'watskeburt' mean?
|
package/bin/cli.js
CHANGED
@@ -1,29 +1,5 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
/* eslint-disable no-console */
|
3
|
-
import { EOL } from "node:os";
|
4
|
-
import { Option, program } from "commander";
|
5
|
-
import { list } from "../dist/esm/main.js";
|
6
|
-
import { VERSION } from "./version.js";
|
7
2
|
|
8
|
-
|
9
|
-
.description(
|
10
|
-
"lists files & their statuses since [old-revision] " +
|
11
|
-
"or between [old-revision] and [new-revision]." +
|
12
|
-
`${EOL}${EOL}` +
|
13
|
-
"-> When you don't pass a revision at all old-revision defaults to the current one."
|
14
|
-
)
|
15
|
-
.addOption(
|
16
|
-
new Option("-T, --output-type <type>", "what format to emit")
|
17
|
-
.choices(["json", "regex"])
|
18
|
-
.default("regex")
|
19
|
-
)
|
20
|
-
.option("--tracked-only", "only take tracked files into account", false)
|
21
|
-
.arguments("[old-revision] [new-revision]")
|
22
|
-
.version(VERSION)
|
23
|
-
.parse(process.argv);
|
3
|
+
import { cli } from "../dist/esm/cli.js";
|
24
4
|
|
25
|
-
|
26
|
-
console.log(await list(program.args[0], program.args[1], program.opts()));
|
27
|
-
} catch (pError) {
|
28
|
-
console.error(`ERROR: ${pError.message}`);
|
29
|
-
}
|
5
|
+
await cli();
|
package/dist/cjs-bundle.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var l=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var M=(t
|
1
|
+
"use strict";var l=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)l(e,n,{get:t[n],enumerable:!0})},H=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of _(t))!k.call(e,s)&&s!==n&&l(e,s,{get:()=>t[s],enumerable:!(r=v(t,s))||r.enumerable});return e};var b=e=>H(l({},"__esModule",{value:!0}),e);var ee={};M(ee,{getSHA:()=>W,getSHASync:()=>Z,list:()=>K,listSync:()=>Q});module.exports=b(ee);var y=require("os"),B=/^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/,U=/^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/,j={A:"added",C:"copied",D:"deleted",M:"modified",R:"renamed",T:"type changed",U:"unmerged",B:"pairing broken"," ":"unmodified","?":"untracked","!":"ignored"};function d(e){return e.split(y.EOL).filter(Boolean).map(R).filter(({name:t,changeType:n})=>!!t&&!!n)}function R(e){let t=e.match(U),n={};if(t!=null&&t.groups){let r=m(t.groups.stagedChangeType),s=m(t.groups.unStagedChangeType);n.changeType=r==="unmodified"?s:r,t.groups.newName?(n.name=t.groups.newName,n.oldName=t.groups.name):n.name=t.groups.name}return n}function T(e){return e.split(y.EOL).filter(Boolean).map(F).filter(({name:t,changeType:n})=>!!t&&!!n)}function F(e){let t=e.match(B),n={};return t!=null&&t.groups&&(n.changeType=m(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 j[e]??"unknown"}var p=require("child_process");function N(e=p.spawnSync){let t={129:`'${process.cwd()}' does not seem to be a git repository`};return h(["status","--porcelain"],t,e)}function D(e,t,n=p.spawnSync){let r={128:`revision '${e}' ${t?`(or '${t}') `:""}unknown`,129:`'${process.cwd()}' does not seem to be a git repository`};return h(t?["diff",e,t,"--name-status"]:["diff",e,"--name-status"],r,n)}function S(e=p.spawnSync){return h(["rev-parse","HEAD"],{},e).slice(0,40)}function h(e,t,n){let r=n("git",e,{cwd:process.cwd(),env:process.env});if(r.error&&G(r.error),r.status===0)return A(r.stdout);throw new Error(t[r.status??0]||`internal git error: ${r.status} (${A(r.stderr)})`)}function A(e){return e instanceof Buffer?e.toString("utf8"):e}function G(e){throw e.code==="ENOENT"?new Error("git executable not found"):new Error(`internal spawn error: ${e}`)}var u=require("child_process");async function O(e=u.spawn){let t={129:`'${process.cwd()}' does not seem to be a git repository`};return await C(["status","--porcelain"],t,e)}async function P(e,t,n=u.spawn){let r={128:`revision '${e}' ${t?`(or '${t}') `:""}unknown`,129:`'${process.cwd()}' does not seem to be a git repository`};return await C(t?["diff",e,t,"--name-status"]:["diff",e,"--name-status"],r,n)}async function w(e=u.spawn){return(await C(["rev-parse","HEAD"],{},e)).slice(0,40)}function C(e,t,n){let r=n("git",e,{cwd:process.cwd(),env:process.env}),s="",i="";return new Promise((c,a)=>{var g,x;(g=r.stdout)==null||g.on("data",o=>{s=s.concat(o)}),(x=r.stderr)==null||x.on("data",o=>{i=i.concat(o)}),r.on("close",o=>{o===0?c(L(s)):a(new Error(t[o??0]||`internal git error: ${o} (${L(i)})`))}),r.on("error",o=>{(o==null?void 0:o.code)==="ENOENT"?a(new Error("git executable not found")):a(new Error(`internal spawn error: ${o}`))})})}function L(e){return e instanceof Buffer?e.toString("utf8"):e}var $=require("path"),Y=new Set([".cjs",".cjsx",".coffee",".csx",".cts",".js",".json",".jsx",".litcoffee",".ls",".mjs",".mts",".svelte",".ts",".tsx",".vue",".vuex"]),V=new Set(["modified","added","renamed","copied","untracked"]);function I(e,t=Y,n=V){return`^(${e.filter(s=>n.has(s.changeType)).map(({name:s})=>s).filter(s=>t.has((0,$.extname)(s))).map(s=>s.replace(/\\/g,"\\\\").replace(/\./g,"\\.")).join("|")})$`}function E(e){return JSON.stringify(e,null,2)}var q=e=>e,z=new Map([["regex",I],["json",E]]);function f(e,t){return(z.get(t??"unknown")||q)(e)}async function K(e,t,n){let r=e||await w(),s=n||{},[i,c]=await Promise.all([P(r,t),s.trackedOnly?"":O()]),a=T(i);return s.trackedOnly||(a=a.concat(d(c).filter(({changeType:g})=>g==="untracked"))),f(a,s.outputType)}function Q(e,t,n){let r=e||S(),s=n||{},i=T(D(r,t));return s.trackedOnly||(i=i.concat(d(N()).filter(({changeType:c})=>c==="untracked"))),f(i,s.outputType)}function W(){return w()}function Z(){return S()}0&&(module.exports={getSHA,getSHASync,list,listSync});
|
package/dist/esm/cli.js
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
import { EOL } from "node:os";
|
2
|
+
import { parseArgs } from "node:util";
|
3
|
+
import { list } from "./main.js";
|
4
|
+
import { VERSION } from "./version.js";
|
5
|
+
const HELP_MESSAGE = `Usage: watskeburt [options] [old-revision] [new-revision]
|
6
|
+
|
7
|
+
lists files & their statuses since [old-revision] or between [old-revision] and [new-revision].
|
8
|
+
|
9
|
+
-> When you don't pass a revision at all old-revision defaults to the current one.
|
10
|
+
|
11
|
+
Options:
|
12
|
+
-T, --outputType <type> what format to emit (choices: "json", "regex", default: "regex")
|
13
|
+
--trackedOnly only take tracked files into account (default: false)
|
14
|
+
-V, --version output the version number
|
15
|
+
-h, --help display help for command${EOL}`;
|
16
|
+
export async function cli(pArguments = process.argv.slice(2), pOutStream = process.stdout, pErrorStream = process.stderr) {
|
17
|
+
try {
|
18
|
+
const lArguments = getArguments(pArguments);
|
19
|
+
if (lArguments.values.help) {
|
20
|
+
pOutStream.write(HELP_MESSAGE);
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
if (lArguments.values.version) {
|
24
|
+
pOutStream.write(`${VERSION}${EOL}`);
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
if (!outputTypeIsValid(lArguments.values.outputType)) {
|
28
|
+
pErrorStream.write(`error: option '-T, --outputType <type>' argument '${lArguments.values.outputType}' is invalid. Allowed choices are json, regex.${EOL}`);
|
29
|
+
process.exitCode = 1;
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
const lResult = await list(lArguments.positionals[0], lArguments.positionals[1], lArguments.values);
|
33
|
+
pOutStream.write(`${lResult}${EOL}`);
|
34
|
+
}
|
35
|
+
catch (pError) {
|
36
|
+
pErrorStream.write(`${EOL}ERROR: ${pError.message}${EOL}${EOL}`);
|
37
|
+
process.exitCode = 1;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
function getArguments(pArguments) {
|
41
|
+
return parseArgs({
|
42
|
+
args: pArguments,
|
43
|
+
options: {
|
44
|
+
outputType: {
|
45
|
+
type: "string",
|
46
|
+
short: "T",
|
47
|
+
default: "regex",
|
48
|
+
},
|
49
|
+
trackedOnly: {
|
50
|
+
type: "boolean",
|
51
|
+
default: false,
|
52
|
+
},
|
53
|
+
help: { type: "boolean", short: "h", default: false },
|
54
|
+
version: { type: "boolean", short: "V", default: false },
|
55
|
+
},
|
56
|
+
strict: true,
|
57
|
+
allowPositionals: true,
|
58
|
+
tokens: false,
|
59
|
+
});
|
60
|
+
}
|
61
|
+
function outputTypeIsValid(pOutputType) {
|
62
|
+
return ["json", "regex"].includes(pOutputType);
|
63
|
+
}
|
@@ -14,8 +14,12 @@ const CHANGE_CHAR_2_CHANGE_TYPE = {
|
|
14
14
|
"?": "untracked",
|
15
15
|
"!": "ignored",
|
16
16
|
};
|
17
|
-
function
|
18
|
-
return
|
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));
|
19
23
|
}
|
20
24
|
export function convertStatusLine(pString) {
|
21
25
|
const lMatchResult = pString.match(DIFF_SHORT_STATUS_LINE_PATTERN);
|
@@ -37,6 +41,13 @@ export function convertStatusLine(pString) {
|
|
37
41
|
}
|
38
42
|
return lReturnValue;
|
39
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
|
+
}
|
40
51
|
export function convertDiffLine(pString) {
|
41
52
|
const lMatchResult = pString.match(DIFF_NAME_STATUS_LINE_PATTERN);
|
42
53
|
const lReturnValue = {};
|
@@ -52,17 +63,6 @@ export function convertDiffLine(pString) {
|
|
52
63
|
}
|
53
64
|
return lReturnValue;
|
54
65
|
}
|
55
|
-
|
56
|
-
return
|
57
|
-
.split(EOL)
|
58
|
-
.filter(Boolean)
|
59
|
-
.map(convertStatusLine)
|
60
|
-
.filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
|
61
|
-
}
|
62
|
-
export function convertDiffLines(pString) {
|
63
|
-
return pString
|
64
|
-
.split(EOL)
|
65
|
-
.filter(Boolean)
|
66
|
-
.map(convertDiffLine)
|
67
|
-
.filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
|
66
|
+
function changeChar2ChangeType(pChar) {
|
67
|
+
return CHANGE_CHAR_2_CHANGE_TYPE[pChar] ?? "unknown";
|
68
68
|
}
|
@@ -30,7 +30,7 @@ export default function formatToRegex(pChanges, pExtensions = DEFAULT_EXTENSIONS
|
|
30
30
|
.filter((pChange) => pChangeTypes.has(pChange.changeType))
|
31
31
|
.map(({ name }) => name)
|
32
32
|
.filter((pName) => pExtensions.has(extname(pName)))
|
33
|
-
.map((pName) => pName.replace(/\./g, "\\."))
|
33
|
+
.map((pName) => pName.replace(/\\/g, "\\\\").replace(/\./g, "\\."))
|
34
34
|
.join("|");
|
35
35
|
return `^(${lChanges})$`;
|
36
36
|
}
|
@@ -1,19 +1,22 @@
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
2
|
-
function
|
3
|
-
|
4
|
-
|
5
|
-
}
|
6
|
-
|
7
|
-
return pError;
|
8
|
-
}
|
2
|
+
export function getStatusShortSync(pSpawnFunction = spawnSync) {
|
3
|
+
const lErrorMap = {
|
4
|
+
129: `'${process.cwd()}' does not seem to be a git repository`,
|
5
|
+
};
|
6
|
+
return getGitResultSync(["status", "--porcelain"], lErrorMap, pSpawnFunction);
|
9
7
|
}
|
10
|
-
function
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
export function getDiffLinesSync(pOldRevision, pNewRevision, pSpawnFunction = spawnSync) {
|
9
|
+
const lErrorMap = {
|
10
|
+
128: `revision '${pOldRevision}' ${pNewRevision ? `(or '${pNewRevision}') ` : ""}unknown`,
|
11
|
+
129: `'${process.cwd()}' does not seem to be a git repository`,
|
12
|
+
};
|
13
|
+
return getGitResultSync(pNewRevision
|
14
|
+
? ["diff", pOldRevision, pNewRevision, "--name-status"]
|
15
|
+
: ["diff", pOldRevision, "--name-status"], lErrorMap, pSpawnFunction);
|
16
|
+
}
|
17
|
+
export function getSHASync(pSpawnFunction = spawnSync) {
|
18
|
+
const lSha1Length = 40;
|
19
|
+
return getGitResultSync(["rev-parse", "HEAD"], {}, pSpawnFunction).slice(0, lSha1Length);
|
17
20
|
}
|
18
21
|
function getGitResultSync(pArguments, pErrorMap, pSpawnFunction) {
|
19
22
|
const lGitResult = pSpawnFunction("git", pArguments, {
|
@@ -31,22 +34,19 @@ function getGitResultSync(pArguments, pErrorMap, pSpawnFunction) {
|
|
31
34
|
`internal git error: ${lGitResult.status} (${stringifyOutStream(lGitResult.stderr)})`);
|
32
35
|
}
|
33
36
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
const lErrorMap = {
|
42
|
-
128: `revision '${pOldRevision}' ${pNewRevision ? `(or '${pNewRevision}') ` : ""}unknown`,
|
43
|
-
129: `'${process.cwd()}' does not seem to be a git repository`,
|
44
|
-
};
|
45
|
-
return getGitResultSync(pNewRevision
|
46
|
-
? ["diff", pOldRevision, pNewRevision, "--name-status"]
|
47
|
-
: ["diff", pOldRevision, "--name-status"], lErrorMap, pSpawnFunction);
|
37
|
+
function stringifyOutStream(pError) {
|
38
|
+
if (pError instanceof Buffer) {
|
39
|
+
return pError.toString("utf8");
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
return pError;
|
43
|
+
}
|
48
44
|
}
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
function throwSpawnError(pError) {
|
46
|
+
if (pError.code === "ENOENT") {
|
47
|
+
throw new Error("git executable not found");
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
throw new Error(`internal spawn error: ${pError}`);
|
51
|
+
}
|
52
52
|
}
|
@@ -1,11 +1,25 @@
|
|
1
1
|
import { spawn } from "node:child_process";
|
2
|
-
function
|
3
|
-
|
4
|
-
|
5
|
-
}
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
export async function getStatusShort(pSpawnFunction = spawn) {
|
3
|
+
const lErrorMap = {
|
4
|
+
129: `'${process.cwd()}' does not seem to be a git repository`,
|
5
|
+
};
|
6
|
+
const lResult = await getGitResult(["status", "--porcelain"], lErrorMap, pSpawnFunction);
|
7
|
+
return lResult;
|
8
|
+
}
|
9
|
+
export async function getDiffLines(pOldRevision, pNewRevision, pSpawnFunction = spawn) {
|
10
|
+
const lErrorMap = {
|
11
|
+
128: `revision '${pOldRevision}' ${pNewRevision ? `(or '${pNewRevision}') ` : ""}unknown`,
|
12
|
+
129: `'${process.cwd()}' does not seem to be a git repository`,
|
13
|
+
};
|
14
|
+
const lResult = await getGitResult(pNewRevision
|
15
|
+
? ["diff", pOldRevision, pNewRevision, "--name-status"]
|
16
|
+
: ["diff", pOldRevision, "--name-status"], lErrorMap, pSpawnFunction);
|
17
|
+
return lResult;
|
18
|
+
}
|
19
|
+
export async function getSHA(pSpawnFunction = spawn) {
|
20
|
+
const lSha1Length = 40;
|
21
|
+
const lResult = await getGitResult(["rev-parse", "HEAD"], {}, pSpawnFunction);
|
22
|
+
return lResult.slice(0, lSha1Length);
|
9
23
|
}
|
10
24
|
function getGitResult(pArguments, pErrorMap, pSpawnFunction) {
|
11
25
|
const lGit = pSpawnFunction("git", pArguments, {
|
@@ -40,25 +54,11 @@ function getGitResult(pArguments, pErrorMap, pSpawnFunction) {
|
|
40
54
|
});
|
41
55
|
});
|
42
56
|
}
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
}
|
47
|
-
|
48
|
-
|
49
|
-
}
|
50
|
-
export async function getDiffLines(pOldRevision, pNewRevision, pSpawnFunction = spawn) {
|
51
|
-
const lErrorMap = {
|
52
|
-
128: `revision '${pOldRevision}' ${pNewRevision ? `(or '${pNewRevision}') ` : ""}unknown`,
|
53
|
-
129: `'${process.cwd()}' does not seem to be a git repository`,
|
54
|
-
};
|
55
|
-
const lResult = await getGitResult(pNewRevision
|
56
|
-
? ["diff", pOldRevision, pNewRevision, "--name-status"]
|
57
|
-
: ["diff", pOldRevision, "--name-status"], lErrorMap, pSpawnFunction);
|
58
|
-
return lResult;
|
59
|
-
}
|
60
|
-
export async function getSHA(pSpawnFunction = spawn) {
|
61
|
-
const lSha1Length = 40;
|
62
|
-
const lResult = await getGitResult(["rev-parse", "HEAD"], {}, pSpawnFunction);
|
63
|
-
return lResult.slice(0, lSha1Length);
|
57
|
+
function stringifyOutStream(pBufferOrString) {
|
58
|
+
if (pBufferOrString instanceof Buffer) {
|
59
|
+
return pBufferOrString.toString("utf8");
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
return pBufferOrString;
|
63
|
+
}
|
64
64
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export const VERSION = "0.11.4";
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "watskeburt",
|
3
|
-
"version": "0.11.
|
3
|
+
"version": "0.11.4",
|
4
4
|
"description": "List files changed since a git revision",
|
5
5
|
"keywords": [
|
6
6
|
"git",
|
@@ -43,17 +43,14 @@
|
|
43
43
|
"package.json",
|
44
44
|
"README.md"
|
45
45
|
],
|
46
|
-
"dependencies": {
|
47
|
-
"commander": "10.0.1"
|
48
|
-
},
|
49
46
|
"devDependencies": {
|
50
47
|
"@types/mocha": "10.0.1",
|
51
|
-
"@types/node": "20.1
|
52
|
-
"@typescript-eslint/eslint-plugin": "5.59.
|
53
|
-
"c8": "
|
54
|
-
"dependency-cruiser": "13.0.
|
55
|
-
"esbuild": "0.
|
56
|
-
"eslint": "8.
|
48
|
+
"@types/node": "20.3.1",
|
49
|
+
"@typescript-eslint/eslint-plugin": "5.59.11",
|
50
|
+
"c8": "8.0.0",
|
51
|
+
"dependency-cruiser": "13.0.3",
|
52
|
+
"esbuild": "0.18.4",
|
53
|
+
"eslint": "8.43.0",
|
57
54
|
"eslint-config-moving-meadow": "4.0.2",
|
58
55
|
"eslint-config-prettier": "8.8.0",
|
59
56
|
"eslint-plugin-budapestian": "5.0.1",
|
@@ -67,15 +64,15 @@
|
|
67
64
|
"npm-run-all": "4.1.5",
|
68
65
|
"prettier": "2.8.8",
|
69
66
|
"ts-node": "10.9.1",
|
70
|
-
"typescript": "5.
|
71
|
-
"upem": "
|
67
|
+
"typescript": "5.1.3",
|
68
|
+
"upem": "8.0.0"
|
72
69
|
},
|
73
70
|
"engines": {
|
74
|
-
"node": "^
|
71
|
+
"node": "^16.19||^18.11||>=20"
|
75
72
|
},
|
76
73
|
"scripts": {
|
77
74
|
"build": "npm-run-all --sequential build:clean build:version build:dist",
|
78
|
-
"build:version": "node --no-warnings --loader ts-node/esm tools/get-version.ts >
|
75
|
+
"build:version": "node --no-warnings --loader ts-node/esm tools/get-version.ts > src/version.ts",
|
79
76
|
"build:clean": "rm -rf dist/*",
|
80
77
|
"build:dist": "npm-run-all build:dist:*",
|
81
78
|
"build:dist:cjs": "esbuild src/main.ts --format=cjs --target=node14 --platform=node --bundle --global-name=wkbtcjs --minify --outfile=dist/cjs-bundle.cjs",
|
package/types/watskeburt.d.ts
CHANGED
@@ -29,12 +29,12 @@ export interface IChange {
|
|
29
29
|
|
30
30
|
export type outputTypeType = "regex" | "json" | "object";
|
31
31
|
|
32
|
-
export interface
|
32
|
+
export interface IFormatOptions {
|
33
33
|
/**
|
34
34
|
* The type of output to deliver. Defaults to "object" - in which case
|
35
35
|
* the listSync function returns an IChange[] object
|
36
36
|
*/
|
37
|
-
outputType
|
37
|
+
outputType: "regex" | "json";
|
38
38
|
/**
|
39
39
|
* When true _only_ takes already tracked files into account.
|
40
40
|
* When false also takes untracked files into account.
|
@@ -44,6 +44,23 @@ export interface IOptions {
|
|
44
44
|
trackedOnly?: boolean;
|
45
45
|
}
|
46
46
|
|
47
|
+
export interface IInternalOptions {
|
48
|
+
/**
|
49
|
+
* The type of output to deliver. Defaults to "object" - in which case
|
50
|
+
* the listSync function returns an IChange[] object
|
51
|
+
*/
|
52
|
+
outputType?: "object";
|
53
|
+
/**
|
54
|
+
* When true _only_ takes already tracked files into account.
|
55
|
+
* When false also takes untracked files into account.
|
56
|
+
*
|
57
|
+
* Defaults to false.
|
58
|
+
*/
|
59
|
+
trackedOnly?: boolean;
|
60
|
+
}
|
61
|
+
|
62
|
+
export type IOptions = IFormatOptions | IInternalOptions;
|
63
|
+
|
47
64
|
/**
|
48
65
|
* returns a list of files changed since pOldRevision.
|
49
66
|
*
|
@@ -59,11 +76,49 @@ export interface IOptions {
|
|
59
76
|
export function listSync(
|
60
77
|
pOldRevision?: string,
|
61
78
|
pNewRevision?: string,
|
62
|
-
pOptions?:
|
63
|
-
): IChange[]
|
79
|
+
pOptions?: IInternalOptions
|
80
|
+
): IChange[];
|
64
81
|
|
65
82
|
/**
|
66
|
-
* returns a list of files changed since pOldRevision
|
83
|
+
* returns a list of files changed since pOldRevision formatted into a string
|
84
|
+
* as pOptions.outputType
|
85
|
+
*
|
86
|
+
* @param pOldRevision The revision against which to compare. E.g. a commit-hash,
|
87
|
+
* a branch or a tag. When not passed defaults to the _current_
|
88
|
+
* commit hash (if there's any)
|
89
|
+
* @param pNewRevision Newer revision against which to compare. Leave out or pass
|
90
|
+
* null when you want to compare against the working tree
|
91
|
+
* @param pOptions Options that influence how the changes are returned and that
|
92
|
+
* filter what is returned and
|
93
|
+
* @throws {Error}
|
94
|
+
*/
|
95
|
+
export function listSync(
|
96
|
+
pOldRevision?: string,
|
97
|
+
pNewRevision?: string,
|
98
|
+
pOptions?: IFormatOptions
|
99
|
+
): string;
|
100
|
+
|
101
|
+
/**
|
102
|
+
* returns promise of a list of files changed since pOldRevision.
|
103
|
+
*
|
104
|
+
* @param pOldRevision The revision against which to compare. E.g. a commit-hash,
|
105
|
+
* a branch or a tag. When not passed defaults to the _current_
|
106
|
+
* commit hash (if there's any)
|
107
|
+
* @param pNewRevision Newer revision against which to compare. Leave out or pass
|
108
|
+
* null when you want to compare against the working tree
|
109
|
+
* @param pOptions Options that influence how the changes are returned and that
|
110
|
+
* filter what is returned and
|
111
|
+
* @throws {Error}
|
112
|
+
*/
|
113
|
+
export function list(
|
114
|
+
pOldRevision?: string,
|
115
|
+
pNewRevision?: string,
|
116
|
+
pOptions?: IInternalOptions
|
117
|
+
): Promise<IChange[]>;
|
118
|
+
|
119
|
+
/**
|
120
|
+
* returns promise a list of files changed since pOldRevision, formatted into a
|
121
|
+
* string as a pOptions.outputType
|
67
122
|
*
|
68
123
|
* @param pOldRevision The revision against which to compare. E.g. a commit-hash,
|
69
124
|
* a branch or a tag. When not passed defaults to the _current_
|
@@ -77,8 +132,8 @@ export function listSync(
|
|
77
132
|
export function list(
|
78
133
|
pOldRevision?: string,
|
79
134
|
pNewRevision?: string,
|
80
|
-
pOptions?:
|
81
|
-
): Promise<
|
135
|
+
pOptions?: IFormatOptions
|
136
|
+
): Promise<string>;
|
82
137
|
|
83
138
|
/**
|
84
139
|
* Returns the SHA1 of the current HEAD
|
package/bin/version.js
DELETED