watskeburt 2.0.5 → 3.0.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 +5 -6
- package/dist/cli.js +5 -5
- package/dist/main.js +3 -3
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/types/watskeburt.d.ts +23 -38
package/README.md
CHANGED
@@ -37,11 +37,11 @@ const lChangedFiles = await list("main");
|
|
37
37
|
/** @type {import('watskeburt').IChange[]} */
|
38
38
|
const lChangedFiles = await list("v0.6.1", "v0.7.1");
|
39
39
|
|
40
|
-
// As a third parameter you can pass some options
|
41
|
-
// (pass null as the second parameter if you only want to compare between
|
42
|
-
// a revision and the working tree):
|
43
40
|
/** @type {import('watskeburt').IChange[]|string} */
|
44
|
-
const lChangedFiles = await list(
|
41
|
+
const lChangedFiles = await list({
|
42
|
+
oldRevision: "main",
|
43
|
+
// this compares the working tree with the oldRevision. If you want to compare
|
44
|
+
// to another branch or revision you can pass that in a `newRevision` field
|
45
45
|
trackedOnly: false, // when set to true leaves out files not under revision control
|
46
46
|
outputType: "object", // other options: "json" and "regex" (as used in the CLI)
|
47
47
|
});
|
@@ -69,8 +69,7 @@ The array of changes this returns looks like this:
|
|
69
69
|
|
70
70
|
### :shell: cli
|
71
71
|
|
72
|
-
|
73
|
-
node >=18.11).
|
72
|
+
There's also a simple command line interface (which works from node >=18.11).
|
74
73
|
|
75
74
|
```shell
|
76
75
|
# list all JavaScript-ish files changed since main in a regular expression
|
package/dist/cli.js
CHANGED
@@ -36,11 +36,11 @@ export async function cli(
|
|
36
36
|
process.exitCode = pErrorExitCode;
|
37
37
|
return;
|
38
38
|
}
|
39
|
-
const lResult = await list(
|
40
|
-
lArguments.
|
41
|
-
lArguments.positionals[
|
42
|
-
lArguments.
|
43
|
-
);
|
39
|
+
const lResult = await list({
|
40
|
+
...lArguments.values,
|
41
|
+
oldRevision: lArguments.positionals[0],
|
42
|
+
newRevision: lArguments.positionals[1],
|
43
|
+
});
|
44
44
|
pOutStream.write(`${lResult}${EOL}`);
|
45
45
|
} catch (pError) {
|
46
46
|
pErrorStream.write(`${EOL}ERROR: ${pError.message}${EOL}${EOL}`);
|
package/dist/main.js
CHANGED
@@ -2,11 +2,11 @@ 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
|
import format from "./formatters/format.js";
|
5
|
-
export async function list(
|
6
|
-
const lOldRevision =
|
5
|
+
export async function list(pOptions) {
|
6
|
+
const lOldRevision = pOptions?.oldRevision || (await primitives.getSHA());
|
7
7
|
const lOptions = pOptions || {};
|
8
8
|
const [lDiffLines, lStatusLines] = await Promise.all([
|
9
|
-
primitives.getDiffLines(lOldRevision,
|
9
|
+
primitives.getDiffLines(lOldRevision, pOptions?.newRevision),
|
10
10
|
!lOptions.trackedOnly ? primitives.getStatusShort() : "",
|
11
11
|
]);
|
12
12
|
let lChanges = parseDiffLines(lDiffLines);
|
package/dist/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "
|
1
|
+
export const VERSION = "3.0.0";
|
package/package.json
CHANGED
package/types/watskeburt.d.ts
CHANGED
@@ -29,12 +29,18 @@ export interface IChange {
|
|
29
29
|
|
30
30
|
export type outputTypeType = "regex" | "json" | "object";
|
31
31
|
|
32
|
-
export interface
|
32
|
+
export interface IBaseOptions {
|
33
33
|
/**
|
34
|
-
* The
|
35
|
-
*
|
34
|
+
* The revision against which to compare. E.g. a commit-hash,
|
35
|
+
* a branch or a tag. When not passed defaults to the _current_
|
36
|
+
* commit hash (if there's any)
|
36
37
|
*/
|
37
|
-
|
38
|
+
oldRevision?: string;
|
39
|
+
/**
|
40
|
+
* Newer revision against which to compare. Leave out or pass
|
41
|
+
* null when you want to compare against the working tree
|
42
|
+
*/
|
43
|
+
newRevision?: string;
|
38
44
|
/**
|
39
45
|
* When true _only_ takes already tracked files into account.
|
40
46
|
* When false also takes untracked files into account.
|
@@ -44,59 +50,38 @@ export interface IFormatOptions {
|
|
44
50
|
trackedOnly?: boolean;
|
45
51
|
}
|
46
52
|
|
47
|
-
export interface
|
53
|
+
export interface IFormatOptions extends IBaseOptions {
|
48
54
|
/**
|
49
55
|
* The type of output to deliver. Defaults to "object" - in which case
|
50
56
|
* the listSync function returns an IChange[] object
|
51
57
|
*/
|
52
|
-
outputType
|
58
|
+
outputType: "regex" | "json";
|
59
|
+
}
|
60
|
+
|
61
|
+
export interface IInternalOptions extends IBaseOptions {
|
53
62
|
/**
|
54
|
-
*
|
55
|
-
*
|
56
|
-
*
|
57
|
-
* Defaults to false.
|
63
|
+
* The type of output to deliver. Defaults to "object" - in which case
|
64
|
+
* the listSync function returns an IChange[] object
|
58
65
|
*/
|
59
|
-
|
66
|
+
outputType?: "object";
|
60
67
|
}
|
61
68
|
|
62
69
|
export type IOptions = IFormatOptions | IInternalOptions;
|
63
70
|
|
64
71
|
/**
|
65
|
-
* returns promise of a list of files changed since pOldRevision.
|
72
|
+
* returns a promise of a list of files changed since pOldRevision.
|
66
73
|
*
|
67
|
-
* @param pOldRevision The revision against which to compare. E.g. a commit-hash,
|
68
|
-
* a branch or a tag. When not passed defaults to the _current_
|
69
|
-
* commit hash (if there's any)
|
70
|
-
* @param pNewRevision Newer revision against which to compare. Leave out or pass
|
71
|
-
* null when you want to compare against the working tree
|
72
|
-
* @param pOptions Options that influence how the changes are returned and that
|
73
|
-
* filter what is returned and
|
74
74
|
* @throws {Error}
|
75
75
|
*/
|
76
|
-
export function list(
|
77
|
-
pOldRevision?: string,
|
78
|
-
pNewRevision?: string,
|
79
|
-
pOptions?: IInternalOptions,
|
80
|
-
): Promise<IChange[]>;
|
76
|
+
export function list(pOptions?: IInternalOptions): Promise<IChange[]>;
|
81
77
|
|
82
78
|
/**
|
83
|
-
* returns promise a list of files changed since pOldRevision, formatted
|
84
|
-
* string as a pOptions.outputType
|
79
|
+
* returns a promise of a list of files changed since pOldRevision, formatted
|
80
|
+
* into a string as a pOptions.outputType
|
85
81
|
*
|
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
82
|
* @throws {Error}
|
94
83
|
*/
|
95
|
-
export function list(
|
96
|
-
pOldRevision?: string,
|
97
|
-
pNewRevision?: string,
|
98
|
-
pOptions?: IFormatOptions,
|
99
|
-
): Promise<string>;
|
84
|
+
export function list(pOptions?: IFormatOptions): Promise<string>;
|
100
85
|
|
101
86
|
/**
|
102
87
|
* Returns the SHA1 of the current HEAD
|