watskeburt 0.9.2 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/{cli.mjs → cli.js} +11 -7
- package/bin/version.js +2 -0
- package/dist/cjs-bundle.cjs +1 -1
- package/dist/esm/convert-to-change-object.js +74 -0
- package/dist/esm/formatters/format.js +10 -0
- package/dist/esm/formatters/json.js +4 -0
- package/dist/esm/formatters/regex.js +36 -0
- package/dist/esm/git-primitives.js +64 -0
- package/dist/esm/main.js +15 -0
- package/package.json +23 -22
- package/bin/version.mjs +0 -1
- package/dist/esm-bundle.mjs +0 -1
package/bin/{cli.mjs → cli.js}
RENAMED
@@ -1,21 +1,25 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
/* eslint-disable no-console */
|
3
|
-
|
4
|
-
import { program } from "commander";
|
5
|
-
import { listSync } from "../dist/esm
|
6
|
-
import { VERSION } from "./version.
|
3
|
+
import { EOL } from "node:os";
|
4
|
+
import { Option, program } from "commander";
|
5
|
+
import { listSync } from "../dist/esm/main.js";
|
6
|
+
import { VERSION } from "./version.js";
|
7
7
|
|
8
8
|
program
|
9
9
|
.description(
|
10
10
|
"lists files & their statuses since [old-revision] " +
|
11
11
|
"or between [old-revision] and [new-revision]." +
|
12
|
-
|
12
|
+
`${EOL}${EOL}` +
|
13
13
|
"-> When you don't pass a revision at all old-revision defaults to the current one."
|
14
14
|
)
|
15
|
-
.
|
16
|
-
|
15
|
+
.addOption(
|
16
|
+
new Option("-T, --output-type <type>", "what format to emit")
|
17
|
+
.choices(["json", "regex"])
|
18
|
+
.default("regex")
|
19
|
+
)
|
17
20
|
.option("--tracked-only", "only take tracked files into account", false)
|
18
21
|
.arguments("[old-revision] [new-revision]")
|
22
|
+
.version(VERSION)
|
19
23
|
.parse(process.argv);
|
20
24
|
|
21
25
|
try {
|
package/bin/version.js
ADDED
package/dist/cjs-bundle.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var i=Object.defineProperty;var
|
1
|
+
"use strict";var i=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var n in e)i(t,n,{get:e[n],enumerable:!0})},A=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!N.call(t,o)&&o!==n&&i(t,o,{get:()=>e[o],enumerable:!(r=w(e,o))||r.enumerable});return t};var _=t=>A(i({},"__esModule",{value:!0}),t);var v={};x(v,{getSHASync:()=>P,listSync:()=>R});module.exports=_(v);var g=require("os"),D=/^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/,L=/^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/,O={A:"added",C:"copied",D:"deleted",M:"modified",R:"renamed",T:"type changed",U:"unmerged",B:"pairing broken"," ":"unmodified","?":"untracked","!":"ignored"};function p(t){return O[t]??"unknown"}function j(t){let e=t.match(L),n={};if(e!=null&&e.groups){let r=p(e.groups.stagedChangeType),o=p(e.groups.unStagedChangeType);n.changeType=r==="unmodified"?o:r,e.groups.newName?(n.name=e.groups.newName,n.oldName=e.groups.name):n.name=e.groups.name}return n}function k(t){let e=t.match(D),n={};return e!=null&&e.groups&&(n.changeType=p(e.groups.changeType),e.groups.newName?(n.name=e.groups.newName,n.oldName=e.groups.name):n.name=e.groups.name),n}function y(t){return t.split(g.EOL).filter(Boolean).map(j).filter(({name:e,changeType:n})=>!!e&&!!n)}function l(t){return t.split(g.EOL).filter(Boolean).map(k).filter(({name:e,changeType:n})=>!!e&&!!n)}var s=require("child_process");function d(t){return t instanceof Buffer?t.toString("utf8"):t}function B(t){throw t.code==="ENOENT"?new Error("git executable not found"):new Error(`internal spawn error: ${t}`)}function u(t,e,n){let r=n("git",t,{cwd:process.cwd(),env:process.env});if(r.error&&B(r.error),r.status===0)return d(r.stdout);throw new Error(e[r.status??0]||`internal git error: ${r.status} (${d(r.stderr)})`)}function h(t=s.spawnSync){let e={129:`'${process.cwd()}' does not seem to be a git repository`};return u(["status","--porcelain"],e,t)}function S(t,e,n=s.spawnSync){let r={128:`revision '${t}' ${e?`(or '${e}') `:""}unknown`,129:`'${process.cwd()}' does not seem to be a git repository`};return u(e?["diff",t,e,"--name-status"]:["diff",t,"--name-status"],r,n)}function c(t=s.spawnSync){return u(["rev-parse","HEAD"],{},t).slice(0,40)}var C=require("path"),U=new Set([".cjs",".cjsx",".coffee",".csx",".cts",".js",".json",".jsx",".litcoffee",".ls",".mjs",".mts",".svelte",".ts",".tsx",".vue",".vuex"]),$=new Set(["modified","added","renamed","copied","untracked"]);function f(t,e=U,n=$){return`^(${t.filter(o=>n.has(o.changeType)).map(({name:o})=>o).filter(o=>e.has((0,C.extname)(o))).join("|")})$`}function m(t){return JSON.stringify(t,null,2)}var b=t=>t,M=new Map([["regex",f],["json",m]]);function T(t,e){return(M.get(e??"unknown")||b)(t)}function P(){return c()}function R(t,e,n){let r=t||c(),o=n||{},a=l(S(r,e));return o.trackedOnly||(a=a.concat(y(h()).filter(({changeType:I})=>I==="untracked"))),T(a,o.outputType)}0&&(module.exports={getSHASync,listSync});
|
@@ -0,0 +1,74 @@
|
|
1
|
+
// the security (and unicorn) plugins don't seem to detect named caption
|
2
|
+
// groups very well - false-flagging below regular expressions to be susceptible
|
3
|
+
// to redos attacks.
|
4
|
+
/* eslint-disable unicorn/no-unsafe-regex, security/detect-unsafe-regex */
|
5
|
+
import { EOL } from "node:os";
|
6
|
+
const DIFF_NAME_STATUS_LINE_PATTERN = /^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/;
|
7
|
+
const DIFF_SHORT_STATUS_LINE_PATTERN = /^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/;
|
8
|
+
const CHANGE_CHAR_2_CHANGE_TYPE = {
|
9
|
+
A: "added",
|
10
|
+
C: "copied",
|
11
|
+
D: "deleted",
|
12
|
+
M: "modified",
|
13
|
+
R: "renamed",
|
14
|
+
T: "type changed",
|
15
|
+
U: "unmerged",
|
16
|
+
B: "pairing broken",
|
17
|
+
" ": "unmodified",
|
18
|
+
"?": "untracked",
|
19
|
+
"!": "ignored",
|
20
|
+
// X: "unknown"
|
21
|
+
};
|
22
|
+
function changeChar2ChangeType(pChar) {
|
23
|
+
// eslint-disable-next-line security/detect-object-injection
|
24
|
+
return CHANGE_CHAR_2_CHANGE_TYPE[pChar] ?? "unknown";
|
25
|
+
}
|
26
|
+
export function convertStatusLine(pString) {
|
27
|
+
const lMatchResult = pString.match(DIFF_SHORT_STATUS_LINE_PATTERN);
|
28
|
+
const lReturnValue = {};
|
29
|
+
if (lMatchResult?.groups) {
|
30
|
+
const lStagedChangeType = changeChar2ChangeType(lMatchResult.groups.stagedChangeType);
|
31
|
+
const lUnStagedChangeType = changeChar2ChangeType(lMatchResult.groups.unStagedChangeType);
|
32
|
+
lReturnValue.changeType =
|
33
|
+
lStagedChangeType === "unmodified"
|
34
|
+
? lUnStagedChangeType
|
35
|
+
: lStagedChangeType;
|
36
|
+
if (lMatchResult.groups.newName) {
|
37
|
+
lReturnValue.name = lMatchResult.groups.newName;
|
38
|
+
lReturnValue.oldName = lMatchResult.groups.name;
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
lReturnValue.name = lMatchResult.groups.name;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
return lReturnValue;
|
45
|
+
}
|
46
|
+
export function convertDiffLine(pString) {
|
47
|
+
const lMatchResult = pString.match(DIFF_NAME_STATUS_LINE_PATTERN);
|
48
|
+
const lReturnValue = {};
|
49
|
+
if (lMatchResult?.groups) {
|
50
|
+
lReturnValue.changeType = changeChar2ChangeType(lMatchResult.groups.changeType);
|
51
|
+
if (lMatchResult.groups.newName) {
|
52
|
+
lReturnValue.name = lMatchResult.groups.newName;
|
53
|
+
lReturnValue.oldName = lMatchResult.groups.name;
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
lReturnValue.name = lMatchResult.groups.name;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
return lReturnValue;
|
60
|
+
}
|
61
|
+
export function convertStatusLines(pString) {
|
62
|
+
return pString
|
63
|
+
.split(EOL)
|
64
|
+
.filter(Boolean)
|
65
|
+
.map(convertStatusLine)
|
66
|
+
.filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
|
67
|
+
}
|
68
|
+
export function convertDiffLines(pString) {
|
69
|
+
return pString
|
70
|
+
.split(EOL)
|
71
|
+
.filter(Boolean)
|
72
|
+
.map(convertDiffLine)
|
73
|
+
.filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
|
74
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import formatToRegex from "./regex.js";
|
2
|
+
import formatToJSON from "./json.js";
|
3
|
+
const identity = (pX) => pX;
|
4
|
+
const OUTPUT_TYPE_TO_FUNCTION = new Map([
|
5
|
+
["regex", formatToRegex],
|
6
|
+
["json", formatToJSON],
|
7
|
+
]);
|
8
|
+
export default function format(pChanges, pOutputType) {
|
9
|
+
return (OUTPUT_TYPE_TO_FUNCTION.get(pOutputType ?? "unknown") || identity)(pChanges);
|
10
|
+
}
|
@@ -0,0 +1,36 @@
|
|
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
|
+
const DEFAULT_CHANGE_TYPES = new Set([
|
22
|
+
"modified",
|
23
|
+
"added",
|
24
|
+
"renamed",
|
25
|
+
"copied",
|
26
|
+
"untracked",
|
27
|
+
]);
|
28
|
+
export default function formatToRegex(pChanges, pExtensions = DEFAULT_EXTENSIONS, pChangeTypes = DEFAULT_CHANGE_TYPES) {
|
29
|
+
const lChanges = pChanges
|
30
|
+
.filter((pChange) => pChangeTypes.has(pChange.changeType))
|
31
|
+
.map(({ name }) => name)
|
32
|
+
.filter((pName) => pExtensions.has(extname(pName)))
|
33
|
+
// .replace(/\./g, "\\\\.")
|
34
|
+
.join("|");
|
35
|
+
return `^(${lChanges})$`;
|
36
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
2
|
+
function stringifyOutStream(pError) {
|
3
|
+
if (pError instanceof Buffer) {
|
4
|
+
return pError.toString("utf8");
|
5
|
+
}
|
6
|
+
else {
|
7
|
+
return pError;
|
8
|
+
}
|
9
|
+
}
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
11
|
+
function throwSpawnError(pError) {
|
12
|
+
if (pError.code === "ENOENT") {
|
13
|
+
throw new Error("git executable not found");
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
throw new Error(`internal spawn error: ${pError}`);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* @throws {Error}
|
21
|
+
*/
|
22
|
+
function getGitResult(pArguments, pErrorMap, pSpawnFunction) {
|
23
|
+
const lGitResult = pSpawnFunction("git", pArguments, {
|
24
|
+
cwd: process.cwd(),
|
25
|
+
// eslint-disable-next-line node/no-process-env
|
26
|
+
env: process.env,
|
27
|
+
});
|
28
|
+
if (lGitResult.error) {
|
29
|
+
throwSpawnError(lGitResult.error);
|
30
|
+
}
|
31
|
+
if (lGitResult.status === 0) {
|
32
|
+
return stringifyOutStream(lGitResult.stdout);
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
throw new Error(pErrorMap[lGitResult.status ?? 0] ||
|
36
|
+
`internal git error: ${lGitResult.status} (${stringifyOutStream(lGitResult.stderr)})`);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
/**
|
40
|
+
* @throws {Error}
|
41
|
+
*/
|
42
|
+
export function getStatusShort(pSpawnFunction = spawnSync) {
|
43
|
+
const lErrorMap = {
|
44
|
+
129: `'${process.cwd()}' does not seem to be a git repository`,
|
45
|
+
};
|
46
|
+
return getGitResult(["status", "--porcelain"], lErrorMap, pSpawnFunction);
|
47
|
+
}
|
48
|
+
/**
|
49
|
+
*
|
50
|
+
* @throws {Error}
|
51
|
+
*/
|
52
|
+
export function getDiffLines(pOldRevision, pNewRevision, pSpawnFunction = spawnSync) {
|
53
|
+
const lErrorMap = {
|
54
|
+
128: `revision '${pOldRevision}' ${pNewRevision ? `(or '${pNewRevision}') ` : ""}unknown`,
|
55
|
+
129: `'${process.cwd()}' does not seem to be a git repository`,
|
56
|
+
};
|
57
|
+
return getGitResult(pNewRevision
|
58
|
+
? ["diff", pOldRevision, pNewRevision, "--name-status"]
|
59
|
+
: ["diff", pOldRevision, "--name-status"], lErrorMap, pSpawnFunction);
|
60
|
+
}
|
61
|
+
export function getSHA1(pSpawnFunction = spawnSync) {
|
62
|
+
const lSha1Length = 40;
|
63
|
+
return getGitResult(["rev-parse", "HEAD"], {}, pSpawnFunction).slice(0, lSha1Length);
|
64
|
+
}
|
package/dist/esm/main.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
import { convertDiffLines, convertStatusLines, } from "./convert-to-change-object.js";
|
2
|
+
import { getDiffLines, getSHA1, getStatusShort } from "./git-primitives.js";
|
3
|
+
import format from "./formatters/format.js";
|
4
|
+
export function getSHASync() {
|
5
|
+
return getSHA1();
|
6
|
+
}
|
7
|
+
export function listSync(pOldRevision, pNewRevision, pOptions) {
|
8
|
+
const lOldRevision = pOldRevision || getSHA1();
|
9
|
+
const lOptions = pOptions || {};
|
10
|
+
let lChanges = convertDiffLines(getDiffLines(lOldRevision, pNewRevision));
|
11
|
+
if (!lOptions.trackedOnly) {
|
12
|
+
lChanges = lChanges.concat(convertStatusLines(getStatusShort()).filter(({ changeType }) => changeType === "untracked"));
|
13
|
+
}
|
14
|
+
return format(lChanges, lOptions.outputType);
|
15
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "watskeburt",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.10.1",
|
4
4
|
"description": "List files changed since a git revision",
|
5
5
|
"keywords": [
|
6
6
|
"git",
|
@@ -19,15 +19,15 @@
|
|
19
19
|
"url": "https://sverweij.github.io"
|
20
20
|
},
|
21
21
|
"license": "MIT",
|
22
|
-
"bin": "bin/cli.
|
22
|
+
"bin": "bin/cli.js",
|
23
23
|
"main": "dist/cjs-bundle.cjs",
|
24
|
-
"module": "dist/esm
|
24
|
+
"module": "dist/esm/main.js",
|
25
25
|
"type": "module",
|
26
26
|
"sideEffects": false,
|
27
27
|
"exports": {
|
28
28
|
".": [
|
29
29
|
{
|
30
|
-
"import": "./dist/esm
|
30
|
+
"import": "./dist/esm/main.js",
|
31
31
|
"require": "./dist/cjs-bundle.cjs"
|
32
32
|
},
|
33
33
|
"./dist/cjs-bundle.cjs"
|
@@ -48,37 +48,38 @@
|
|
48
48
|
},
|
49
49
|
"devDependencies": {
|
50
50
|
"@types/mocha": "10.0.1",
|
51
|
-
"@types/node": "18.
|
52
|
-
"@typescript-eslint/eslint-plugin": "5.
|
53
|
-
"c8": "7.
|
54
|
-
"dependency-cruiser": "12.
|
55
|
-
"esbuild": "0.17.
|
56
|
-
"eslint": "8.
|
51
|
+
"@types/node": "18.15.3",
|
52
|
+
"@typescript-eslint/eslint-plugin": "5.55.0",
|
53
|
+
"c8": "7.13.0",
|
54
|
+
"dependency-cruiser": "12.10.2",
|
55
|
+
"esbuild": "0.17.12",
|
56
|
+
"eslint": "8.36.0",
|
57
57
|
"eslint-config-moving-meadow": "4.0.2",
|
58
|
-
"eslint-config-prettier": "8.
|
58
|
+
"eslint-config-prettier": "8.7.0",
|
59
59
|
"eslint-plugin-budapestian": "5.0.1",
|
60
60
|
"eslint-plugin-eslint-comments": "3.2.0",
|
61
61
|
"eslint-plugin-import": "2.27.5",
|
62
62
|
"eslint-plugin-mocha": "10.1.0",
|
63
63
|
"eslint-plugin-node": "11.1.0",
|
64
64
|
"eslint-plugin-security": "1.7.1",
|
65
|
-
"eslint-plugin-unicorn": "
|
65
|
+
"eslint-plugin-unicorn": "46.0.0",
|
66
66
|
"mocha": "10.2.0",
|
67
67
|
"npm-run-all": "4.1.5",
|
68
68
|
"prettier": "2.8.4",
|
69
69
|
"ts-node": "10.9.1",
|
70
|
-
"typescript": "
|
71
|
-
"upem": "7.3.
|
70
|
+
"typescript": "5.0.2",
|
71
|
+
"upem": "7.3.2"
|
72
72
|
},
|
73
73
|
"engines": {
|
74
74
|
"node": "^14||^16||>=18"
|
75
75
|
},
|
76
76
|
"scripts": {
|
77
|
-
"build": "npm-run-all --sequential build:version build:dist",
|
78
|
-
"build:version": "node tools/get-version.
|
77
|
+
"build": "npm-run-all --sequential build:clean build:version build:dist",
|
78
|
+
"build:version": "ts-node --esm tools/get-version.ts > bin/version.js",
|
79
|
+
"build:clean": "rm -rf dist/*",
|
79
80
|
"build:dist": "npm-run-all build:dist:*",
|
80
81
|
"build:dist:cjs": "esbuild src/main.ts --format=cjs --target=node14 --platform=node --bundle --global-name=wkbtcjs --minify --outfile=dist/cjs-bundle.cjs",
|
81
|
-
"build:dist:esm": "
|
82
|
+
"build:dist:esm": "tsc",
|
82
83
|
"check": "npm-run-all --parallel --aggregate-output lint depcruise test:cover",
|
83
84
|
"clean": "rm -rf dist",
|
84
85
|
"test": "NODE_OPTIONS=--no-warnings mocha",
|
@@ -87,19 +88,19 @@
|
|
87
88
|
"depcruise:graph": "depcruise bin src types --include-only '^(bin|dist|src|types)' --config --output-type dot | dot -T svg | tee docs/dependency-graph.svg | depcruise-wrap-stream-in-html > docs/dependency-graph.html",
|
88
89
|
"depcruise:graph:archi": "depcruise bin src --include-only '^(bin|dist|src|types)' --config --output-type archi | dot -T svg | depcruise-wrap-stream-in-html > docs/high-level-dependency-graph.html",
|
89
90
|
"depcruise:graph:dev": "depcruise bin dist src types --include-only '^(bin|dist|src|types)' --prefix vscode://file/$(pwd)/ --config --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
|
90
|
-
"depcruise:graph:diff:dev": "depcruise bin dist src types --include-only '^(bin|dist|src|types)' --highlight \"$(node bin/cli.
|
91
|
-
"depcruise:graph:diff:mermaid": "depcruise bin dist src types --include-only '^(bin|dist|src|types)' --config --output-type mermaid --output-to - --highlight \"$(node bin/cli.
|
91
|
+
"depcruise:graph:diff:dev": "depcruise bin dist src types --include-only '^(bin|dist|src|types)' --highlight \"$(node bin/cli.js main -T regex)\" --prefix vscode://file/$(pwd)/ --config --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
|
92
|
+
"depcruise:graph:diff:mermaid": "depcruise bin dist src types --include-only '^(bin|dist|src|types)' --config --output-type mermaid --output-to - --highlight \"$(node bin/cli.js $SHA -T regex)\"",
|
92
93
|
"depcruise:html": "depcruise bin src types --progress --config --output-type err-html --output-to dependency-violation-report.html",
|
93
94
|
"depcruise:text": "depcruise bin src types --progress --config --output-type text",
|
94
95
|
"depcruise:focus": "depcruise bin src types --progress --config --output-type text --focus",
|
95
96
|
"depcruise:reaches": "depcruise bin src types --progress --config --output-type text --reaches",
|
96
|
-
"format": "prettier --write \"{bin,src,tools}/**/*.
|
97
|
-
"format:check": "prettier --loglevel warn --check \"{bin,src,tools}/**/*.
|
97
|
+
"format": "prettier --write \"{bin,src,tools}/**/*.{js,ts}\" \"types/**/*.ts\" \"*.{json,yml,md,js}\"",
|
98
|
+
"format:check": "prettier --loglevel warn --check \"{bin,src,tools}/**/*.ts\" \"types/**/*.ts\" \"*.{json,yml,md,js}\"",
|
98
99
|
"lint": "npm-run-all --parallel --aggregate-output format:check lint:eslint lint:types",
|
99
100
|
"lint:fix": "npm-run-all --parallel --aggregate-output format lint:eslint:fix",
|
100
101
|
"lint:eslint": "eslint bin src types tools --cache --cache-location node_modules/.cache/eslint/",
|
101
102
|
"lint:eslint:fix": "eslint bin src types tools --fix --cache --cache-location node_modules/.cache/eslint/",
|
102
|
-
"lint:types": "tsc",
|
103
|
+
"lint:types": "tsc --noEmit",
|
103
104
|
"scm:stage": "git add .",
|
104
105
|
"update-dependencies": "run-s upem:update upem:install lint:fix check",
|
105
106
|
"upem-outdated": "npm outdated --json --long | upem --dry-run",
|
package/bin/version.mjs
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export const VERSION = "0.9.2";
|
package/dist/esm-bundle.mjs
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import{EOL as m}from"os";var C=/^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/,I=/^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/,E={A:"added",C:"copied",D:"deleted",M:"modified",R:"renamed",T:"type changed",U:"unmerged",B:"pairing broken"," ":"unmodified","?":"untracked","!":"ignored"};function s(n){return E[n]??"unknown"}function w(n){let e=n.match(I),t={};if(e!=null&&e.groups){let r=s(e.groups.stagedChangeType),o=s(e.groups.unStagedChangeType);t.changeType=r==="unmodified"?o:r,e.groups.newName?(t.name=e.groups.newName,t.oldName=e.groups.name):t.name=e.groups.name}return t}function x(n){let e=n.match(C),t={};return e!=null&&e.groups&&(t.changeType=s(e.groups.changeType),e.groups.newName?(t.name=e.groups.newName,t.oldName=e.groups.name):t.name=e.groups.name),t}function T(n){return n.split(m).filter(Boolean).map(w).filter(({name:e,changeType:t})=>Boolean(e)&&Boolean(t))}function l(n){return n.split(m).filter(Boolean).map(x).filter(({name:e,changeType:t})=>Boolean(e)&&Boolean(t))}import{spawnSync as i}from"child_process";function d(n){return n instanceof Buffer?n.toString("utf8"):n}function N(n){throw n.code==="ENOENT"?new Error("git executable not found"):new Error(`internal spawn error: ${n}`)}function g(n,e,t){let r=t("git",n,{cwd:process.cwd(),env:process.env});if(r.error&&N(r.error),r.status===0)return d(r.stdout);throw new Error(e[r.status??0]||`internal git error: ${r.status} (${d(r.stderr)})`)}function h(n=i){let e={129:`'${process.cwd()}' does not seem to be a git repository`};return g(["status","--porcelain"],e,n)}function y(n,e,t=i){let r={128:`revision '${n}' ${e?`(or '${e}') `:""}unknown`,129:`'${process.cwd()}' does not seem to be a git repository`};return g(e?["diff",n,e,"--name-status"]:["diff",n,"--name-status"],r,t)}function p(n=i){return g(["rev-parse","HEAD"],{},n).slice(0,40)}import{extname as A}from"path";var _=new Set([".cjs",".cjsx",".coffee",".csx",".cts",".js",".json",".jsx",".litcoffee",".ls",".mjs",".mts",".svelte",".ts",".tsx",".vue",".vuex"]),D=new Set(["modified","added","renamed","copied","untracked"]);function u(n,e=_,t=D){return`^(${n.filter(o=>t.has(o.changeType)).map(({name:o})=>o).filter(o=>e.has(A(o))).join("|")})$`}var L=2;function c(n){return JSON.stringify(n,null,L)}var O=n=>n,B=new Map([["regex",u],["json",c]]);function f(n,e){return(B.get(e??"unknown")||O)(n)}function Y(){return p()}function V(n,e,t){let r=n||p(),o=t||{},a=l(y(r,e));return o.trackedOnly||(a=a.concat(T(h()).filter(({changeType:S})=>S==="untracked"))),f(a,o.outputType)}export{Y as getSHASync,V as listSync};
|