watskeburt 0.10.0 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/{cli.mjs → cli.js} +2 -2
- 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 +13 -0
- package/package.json +39 -29
- package/bin/version.mjs +0 -1
- package/dist/esm-bundle.mjs +0 -1
package/bin/{cli.mjs → cli.js}
RENAMED
@@ -2,8 +2,8 @@
|
|
2
2
|
/* eslint-disable no-console */
|
3
3
|
import { EOL } from "node:os";
|
4
4
|
import { Option, program } from "commander";
|
5
|
-
import { listSync } from "../dist/esm
|
6
|
-
import { VERSION } from "./version.
|
5
|
+
import { listSync } from "../dist/esm/main.js";
|
6
|
+
import { VERSION } from "./version.js";
|
7
7
|
|
8
8
|
program
|
9
9
|
.description(
|
package/bin/version.js
ADDED
package/dist/cjs-bundle.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var p=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var n in e)p(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&&p(t,o,{get:()=>e[o],enumerable:!(r=w(e,o))||r.enumerable});return t};var _=t=>A(p({},"__esModule",{value:!0}),t);var R={};x(R,{getSHASync:()=>a,listSync:()=>P});module.exports=_(R);var u=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 g(t){return O[t]??"unknown"}function j(t){let e=t.match(L),n={};if(e!=null&&e.groups){let r=g(e.groups.stagedChangeType),o=g(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=g(e.groups.changeType),e.groups.newName?(n.name=e.groups.newName,n.oldName=e.groups.name):n.name=e.groups.name),n}function T(t){return t.split(u.EOL).filter(Boolean).map(j).filter(({name:e,changeType:n})=>!!e&&!!n)}function l(t){return t.split(u.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 c(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 c(["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 c(e?["diff",t,e,"--name-status"]:["diff",t,"--name-status"],r,n)}function a(t=s.spawnSync){return c(["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 y(t,e){return(M.get(e??"unknown")||b)(t)}function P(t,e,n){let r=t||a(),o=n||{},i=l(S(r,e));return o.trackedOnly||(i=i.concat(T(h()).filter(({changeType:I})=>I==="untracked"))),y(i,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 getGitResultSync(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 getStatusShortSync(pSpawnFunction = spawnSync) {
|
43
|
+
const lErrorMap = {
|
44
|
+
129: `'${process.cwd()}' does not seem to be a git repository`,
|
45
|
+
};
|
46
|
+
return getGitResultSync(["status", "--porcelain"], lErrorMap, pSpawnFunction);
|
47
|
+
}
|
48
|
+
/**
|
49
|
+
*
|
50
|
+
* @throws {Error}
|
51
|
+
*/
|
52
|
+
export function getDiffLinesSync(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 getGitResultSync(pNewRevision
|
58
|
+
? ["diff", pOldRevision, pNewRevision, "--name-status"]
|
59
|
+
: ["diff", pOldRevision, "--name-status"], lErrorMap, pSpawnFunction);
|
60
|
+
}
|
61
|
+
export function getSHASync(pSpawnFunction = spawnSync) {
|
62
|
+
const lSha1Length = 40;
|
63
|
+
return getGitResultSync(["rev-parse", "HEAD"], {}, pSpawnFunction).slice(0, lSha1Length);
|
64
|
+
}
|
package/dist/esm/main.js
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import { convertDiffLines, convertStatusLines, } from "./convert-to-change-object.js";
|
2
|
+
import { getDiffLinesSync, getSHASync, getStatusShortSync, } from "./git-primitives.js";
|
3
|
+
import format from "./formatters/format.js";
|
4
|
+
export function listSync(pOldRevision, pNewRevision, pOptions) {
|
5
|
+
const lOldRevision = pOldRevision || getSHASync();
|
6
|
+
const lOptions = pOptions || {};
|
7
|
+
let lChanges = convertDiffLines(getDiffLinesSync(lOldRevision, pNewRevision));
|
8
|
+
if (!lOptions.trackedOnly) {
|
9
|
+
lChanges = lChanges.concat(convertStatusLines(getStatusShortSync()).filter(({ changeType }) => changeType === "untracked"));
|
10
|
+
}
|
11
|
+
return format(lChanges, lOptions.outputType);
|
12
|
+
}
|
13
|
+
export { getSHASync } from "./git-primitives.js";
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "watskeburt",
|
3
|
-
"version": "0.10.
|
3
|
+
"version": "0.10.2",
|
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,58 +48,68 @@
|
|
48
48
|
},
|
49
49
|
"devDependencies": {
|
50
50
|
"@types/mocha": "10.0.1",
|
51
|
-
"@types/node": "18.
|
52
|
-
"@typescript-eslint/eslint-plugin": "5.
|
51
|
+
"@types/node": "18.15.11",
|
52
|
+
"@typescript-eslint/eslint-plugin": "5.58.0",
|
53
53
|
"c8": "7.13.0",
|
54
|
-
"dependency-cruiser": "
|
55
|
-
"esbuild": "0.17.
|
56
|
-
"eslint": "8.
|
54
|
+
"dependency-cruiser": "13.0.0-beta-1",
|
55
|
+
"esbuild": "0.17.16",
|
56
|
+
"eslint": "8.38.0",
|
57
57
|
"eslint-config-moving-meadow": "4.0.2",
|
58
|
-
"eslint-config-prettier": "8.
|
58
|
+
"eslint-config-prettier": "8.8.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
|
-
"prettier": "2.8.
|
68
|
+
"prettier": "2.8.7",
|
69
69
|
"ts-node": "10.9.1",
|
70
|
-
"typescript": "
|
70
|
+
"typescript": "5.0.4",
|
71
71
|
"upem": "7.3.2"
|
72
72
|
},
|
73
|
+
"upem": {
|
74
|
+
"policies": [
|
75
|
+
{
|
76
|
+
"package": "dependency-cruiser",
|
77
|
+
"policy": "wanted",
|
78
|
+
"because": "we're beta testing v13 & policy 'latest' would downgraded it back to v12 again"
|
79
|
+
}
|
80
|
+
]
|
81
|
+
},
|
73
82
|
"engines": {
|
74
83
|
"node": "^14||^16||>=18"
|
75
84
|
},
|
76
85
|
"scripts": {
|
77
|
-
"build": "npm-run-all --sequential build:version build:dist",
|
78
|
-
"build:version": "node tools/get-version.
|
86
|
+
"build": "npm-run-all --sequential build:clean build:version build:dist",
|
87
|
+
"build:version": "ts-node --esm tools/get-version.ts > bin/version.js",
|
88
|
+
"build:clean": "rm -rf dist/*",
|
79
89
|
"build:dist": "npm-run-all build:dist:*",
|
80
90
|
"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": "
|
91
|
+
"build:dist:esm": "tsc",
|
82
92
|
"check": "npm-run-all --parallel --aggregate-output lint depcruise test:cover",
|
83
93
|
"clean": "rm -rf dist",
|
84
94
|
"test": "NODE_OPTIONS=--no-warnings mocha",
|
85
95
|
"test:cover": "NODE_OPTIONS=--no-warnings c8 mocha",
|
86
|
-
"depcruise": "depcruise bin dist src types
|
87
|
-
"depcruise:graph": "depcruise bin src types --include-only '^(bin|dist|src|types)' --
|
88
|
-
"depcruise:graph:archi": "depcruise bin src --include-only '^(bin|dist|src|types)' --
|
89
|
-
"depcruise:graph:dev": "depcruise bin dist src types --include-only '^(bin|dist|src|types)' --prefix vscode://file/$(pwd)/ --
|
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)' --
|
92
|
-
"depcruise:html": "depcruise bin src types --progress --
|
93
|
-
"depcruise:text": "depcruise bin src types --progress --
|
94
|
-
"depcruise:focus": "depcruise bin src types --progress --
|
95
|
-
"depcruise:reaches": "depcruise bin src types --progress --
|
96
|
-
"format": "prettier --write \"{bin,src,tools}/**/*.
|
97
|
-
"format:check": "prettier --loglevel warn --check \"{bin,src,tools}/**/*.
|
96
|
+
"depcruise": "depcruise bin dist src types",
|
97
|
+
"depcruise:graph": "depcruise bin src types --include-only '^(bin|dist|src|types)' --output-type dot | dot -T svg | tee docs/dependency-graph.svg | depcruise-wrap-stream-in-html > docs/dependency-graph.html",
|
98
|
+
"depcruise:graph:archi": "depcruise bin src --include-only '^(bin|dist|src|types)' --output-type archi | dot -T svg | depcruise-wrap-stream-in-html > docs/high-level-dependency-graph.html",
|
99
|
+
"depcruise:graph:dev": "depcruise bin dist src types --include-only '^(bin|dist|src|types)' --prefix vscode://file/$(pwd)/ --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
|
100
|
+
"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)/ --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
|
101
|
+
"depcruise:graph:diff:mermaid": "depcruise bin dist src types --include-only '^(bin|dist|src|types)' --output-type mermaid --output-to - --highlight \"$(node bin/cli.js $SHA -T regex)\"",
|
102
|
+
"depcruise:html": "depcruise bin src types --progress --output-type err-html --output-to dependency-violation-report.html",
|
103
|
+
"depcruise:text": "depcruise bin src types --progress --output-type text",
|
104
|
+
"depcruise:focus": "depcruise bin src types --progress --output-type text --focus",
|
105
|
+
"depcruise:reaches": "depcruise bin src types --progress --output-type text --reaches",
|
106
|
+
"format": "prettier --write \"{bin,src,tools}/**/*.{js,ts}\" \"types/**/*.ts\" \"*.{json,yml,md,js}\"",
|
107
|
+
"format:check": "prettier --loglevel warn --check \"{bin,src,tools}/**/*.ts\" \"types/**/*.ts\" \"*.{json,yml,md,js}\"",
|
98
108
|
"lint": "npm-run-all --parallel --aggregate-output format:check lint:eslint lint:types",
|
99
109
|
"lint:fix": "npm-run-all --parallel --aggregate-output format lint:eslint:fix",
|
100
110
|
"lint:eslint": "eslint bin src types tools --cache --cache-location node_modules/.cache/eslint/",
|
101
111
|
"lint:eslint:fix": "eslint bin src types tools --fix --cache --cache-location node_modules/.cache/eslint/",
|
102
|
-
"lint:types": "tsc",
|
112
|
+
"lint:types": "tsc --noEmit",
|
103
113
|
"scm:stage": "git add .",
|
104
114
|
"update-dependencies": "run-s upem:update upem:install lint:fix check",
|
105
115
|
"upem-outdated": "npm outdated --json --long | upem --dry-run",
|
package/bin/version.mjs
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export const VERSION = "0.10.0";
|
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]+))?$/,w={A:"added",C:"copied",D:"deleted",M:"modified",R:"renamed",T:"type changed",U:"unmerged",B:"pairing broken"," ":"unmodified","?":"untracked","!":"ignored"};function s(t){return w[t]??"unknown"}function E(t){let e=t.match(I),n={};if(e!=null&&e.groups){let r=s(e.groups.stagedChangeType),o=s(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 N(t){let e=t.match(C),n={};return e!=null&&e.groups&&(n.changeType=s(e.groups.changeType),e.groups.newName?(n.name=e.groups.newName,n.oldName=e.groups.name):n.name=e.groups.name),n}function T(t){return t.split(m).filter(Boolean).map(E).filter(({name:e,changeType:n})=>Boolean(e)&&Boolean(n))}function y(t){return t.split(m).filter(Boolean).map(N).filter(({name:e,changeType:n})=>Boolean(e)&&Boolean(n))}import{spawnSync as i}from"child_process";function l(t){return t instanceof Buffer?t.toString("utf8"):t}function x(t){throw t.code==="ENOENT"?new Error("git executable not found"):new Error(`internal spawn error: ${t}`)}function p(t,e,n){let r=n("git",t,{cwd:process.cwd(),env:process.env});if(r.error&&x(r.error),r.status===0)return l(r.stdout);throw new Error(e[r.status??0]||`internal git error: ${r.status} (${l(r.stderr)})`)}function d(t=i){let e={129:`'${process.cwd()}' does not seem to be a git repository`};return p(["status","--porcelain"],e,t)}function h(t,e,n=i){let r={128:`revision '${t}' ${e?`(or '${e}') `:""}unknown`,129:`'${process.cwd()}' does not seem to be a git repository`};return p(e?["diff",t,e,"--name-status"]:["diff",t,"--name-status"],r,n)}function g(t=i){return p(["rev-parse","HEAD"],{},t).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(t,e=_,n=D){return`^(${t.filter(o=>n.has(o.changeType)).map(({name:o})=>o).filter(o=>e.has(A(o))).join("|")})$`}function c(t){return JSON.stringify(t,null,2)}var L=t=>t,O=new Map([["regex",u],["json",c]]);function f(t,e){return(O.get(e??"unknown")||L)(t)}function J(){return g()}function Y(t,e,n){let r=t||g(),o=n||{},a=y(h(r,e));return o.trackedOnly||(a=a.concat(T(d()).filter(({changeType:S})=>S==="untracked"))),f(a,o.outputType)}export{J as getSHASync,Y as listSync};
|