Socket
Socket
Sign inDemoInstall

watskeburt

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

watskeburt - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

2

dist/cjs-bundle.js

@@ -1,1 +0,1 @@

var a=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var A=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},_=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of E(t))!C.call(e,r)&&r!==n&&a(e,r,{get:()=>t[r],enumerable:!(o=y(t,r))||o.enumerable});return e};var R=e=>_(a({},"__esModule",{value:!0}),e);var H={};A(H,{getSHA:()=>w,list:()=>M});module.exports=R(H);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]+))?$/,v={A:"added",C:"copied",D:"deleted",M:"modified",R:"renamed",T:"type changed",U:"unmerged",B:"pairing broken"," ":"unmodified","?":"untracked","!":"ignored"};function i(e){return v[e]||"unknown"}function O(e){let t=e.match(L),n={};if(t){let o=i(t.groups.stagedChangeType),r=i(t.groups.unStagedChangeType);n.changeType=o==="unmodified"?r:o,t.groups.newName?(n.name=t.groups.newName,n.oldName=t.groups.name):n.name=t.groups.name}return n}function U(e){let t=e.match(D),n={};return t&&(n.changeType=i(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 e.split(u.EOL).filter(Boolean).map(O).filter(({changeType:t})=>Boolean(t))}function g(e){return e.split(u.EOL).filter(Boolean).map(U).filter(({changeType:t})=>Boolean(t))}var s=require("child_process");function d(e){return e instanceof Buffer?e.toString("utf8"):e}function j(e){throw e.code==="ENOENT"?new Error("git executable not found"):new Error(`internal spawn error: ${e}`)}function c(e,t,n){let o=n("git",e,{cwd:process.cwd(),env:process.env});if(o.error&&j(o.error),o.status===0)return d(o.stdout);throw new Error(t[o.status]||`internal git error: ${o.status} (${d(o.stderr)})`)}function T(e=s.spawnSync){let t={129:`'${process.cwd()}' does not seem to be a git repository`};return c(["status","--porcelain"],t,e)}function h(e,t=s.spawnSync){let n={128:`revision '${e}' unknown `,129:`'${process.cwd()}' does not seem to be a git repository`};return c(["diff",e,"--name-status"],n,t)}function S(e=s.spawnSync){return c(["rev-parse","HEAD"],{},e).slice(0,40)}var N=require("path");function f(e,t=[".js",".mjs",".cjs",".json",".jsx",".ts",".tsx",".vue",".vuex",".svelte",".coffee",".litcoffee",".csx",".cjsx",".ls"],n=["modified","added","renamed","copied","untracked"]){return`^(${e.filter(r=>n.includes(r.changeType)).map(({name:r})=>r).filter(r=>t.includes((0,N.extname)(r))).join("|")})$`}function l(e){return JSON.stringify(e,null,2)}var $={regex:f,json:l,object:e=>e},B="object";function p(e,t){return $[t||B](e)}function w(){return S()}function M(e,t){let n=e||w(),o=g(h(n)),r=t||{};return r.trackedOnly||(o=o.concat(m(T()).filter(({changeType:x})=>x==="untracked"))),p(o,r.outputType)}0&&(module.exports={getSHA,list});
"use strict";var a=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},_=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of y(t))!A.call(e,r)&&r!==n&&a(e,r,{get:()=>t[r],enumerable:!(o=x(t,r))||o.enumerable});return e};var D=e=>_(a({},"__esModule",{value:!0}),e);var I={};C(I,{getSHA:()=>E,list:()=>F});module.exports=D(I);var u=require("os"),L=/^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/,R=/^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/,U={A:"added",C:"copied",D:"deleted",M:"modified",R:"renamed",T:"type changed",U:"unmerged",B:"pairing broken"," ":"unmodified","?":"untracked","!":"ignored"};function i(e){return U[e]||"unknown"}function O(e){let t=e.match(R),n={};if(t){let o=i(t.groups.stagedChangeType),r=i(t.groups.unStagedChangeType);n.changeType=o==="unmodified"?r:o,t.groups.newName?(n.name=t.groups.newName,n.oldName=t.groups.name):n.name=t.groups.name}return n}function v(e){let t=e.match(L),n={};return t&&(n.changeType=i(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 e.split(u.EOL).filter(Boolean).map(O).filter(({changeType:t})=>Boolean(t))}function g(e){return e.split(u.EOL).filter(Boolean).map(v).filter(({changeType:t})=>Boolean(t))}var s=require("child_process");function d(e){return e instanceof Buffer?e.toString("utf8"):e}function j(e){throw e.code==="ENOENT"?new Error("git executable not found"):new Error(`internal spawn error: ${e}`)}function c(e,t,n){let o=n("git",e,{cwd:process.cwd(),env:process.env});if(o.error&&j(o.error),o.status===0)return d(o.stdout);throw new Error(t[o.status]||`internal git error: ${o.status} (${d(o.stderr)})`)}function T(e=s.spawnSync){let t={129:`'${process.cwd()}' does not seem to be a git repository`};return c(["status","--porcelain"],t,e)}function h(e,t=s.spawnSync){let n={128:`revision '${e}' unknown `,129:`'${process.cwd()}' does not seem to be a git repository`};return c(["diff",e,"--name-status"],n,t)}function S(e=s.spawnSync){return c(["rev-parse","HEAD"],{},e).slice(0,40)}var N=require("path"),$=new Set([".cjs",".cjsx",".coffee",".csx",".js",".json",".jsx",".litcoffee",".ls",".mjs",".svelte",".ts",".tsx",".vue",".vuex"]),B=new Set(["modified","added","renamed","copied","untracked"]);function f(e,t=$,n=B){return`^(${e.filter(r=>n.has(r.changeType)).map(({name:r})=>r).filter(r=>t.has((0,N.extname)(r))).join("|")})$`}function p(e){return JSON.stringify(e,null,2)}var H={regex:f,json:p,object:e=>e},M="object";function l(e,t){return H[t||M](e)}function E(){return S()}function F(e,t){let n=e||E(),o=g(h(n)),r=t||{};return r.trackedOnly||(o=o.concat(m(T()).filter(({changeType:w})=>w==="untracked"))),l(o,r.outputType)}0&&(module.exports={getSHA,list});
{
"name": "watskeburt",
"version": "0.5.0",
"version": "0.5.1",
"description": "List files changed since a git revision",

@@ -50,7 +50,9 @@ "keywords": [

"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.30.5",
"c8": "^7.11.3",
"dependency-cruiser": "^11.11.0",
"esbuild": "^0.14.48",
"eslint": "^8.19.0",
"@types/mocha": "^9.1.1",
"@types/node": "^18.0.6",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"c8": "^7.12.0",
"dependency-cruiser": "^11.12.0",
"esbuild": "^0.14.49",
"eslint": "^8.20.0",
"eslint-config-moving-meadow": "^3.0.0",

@@ -60,6 +62,6 @@ "eslint-config-prettier": "^8.5.0",

"eslint-plugin-import": "^2.26.0",
"eslint-plugin-mocha": "^10.0.5",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-security": "^1.5.0",
"eslint-plugin-unicorn": "^43.0.1",
"eslint-plugin-unicorn": "^43.0.2",
"mocha": "^10.0.0",

@@ -81,17 +83,18 @@ "npm-run-all": "^4.1.5",

"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",
"depcruise": "depcruise src --config",
"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",
"depcruise": "depcruise src types --config",
"depcruise:graph": "depcruise src types --include-only '^(src|types)' --config --output-type dot | dot -T svg | tee docs/dependency-graph.svg | depcruise-wrap-stream-in-html > docs/dependency-graph.html",
"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",
"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",
"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",
"depcruise:graph:diff:mermaid": "depcruise src --include-only '^(src)' --config --output-type mermaid --output-to - --focus \"$(node src/cli.mjs $SHA -T regex)\"",
"depcruise:graph:diff:dev": "depcruise src types --include-only '^(src|types)' --focus \"$(node src/cli.mjs main -T regex)\" --focus-depth 0 --prefix vscode://file/$(pwd)/ --config --output-type dot | dot -T svg | depcruise-wrap-stream-in-html | browser",
"depcruise:graph:diff:mermaid": "depcruise src types --include-only '^(src|types)' --config --output-type mermaid --output-to - --focus \"$(node src/cli.mjs $SHA -T regex)\" --focus-depth 0",
"depcruise:html": "depcruise src --progress --config --output-type err-html --output-to dependency-violation-report.html",
"depcruise:text": "depcruise src --progress --config --output-type text",
"depcruise:focus": "depcruise src --progress --config --output-type text --focus",
"lint": "npm-run-all --parallel --aggregate-output lint:format lint:eslint",
"lint": "npm-run-all --parallel --aggregate-output lint:format lint:eslint lint:types",
"lint:fix": "npm-run-all --parallel --aggregate-output lint:format:fix lint:eslint:fix",
"lint:eslint": "eslint src --cache --cache-location node_modules/.cache/eslint/",
"lint:eslint:fix": "eslint src tools --fix --cache --cache-location node_modules/.cache/eslint/",
"lint:eslint": "eslint src types tools --cache --cache-location node_modules/.cache/eslint/",
"lint:eslint:fix": "eslint src types tools --fix --cache --cache-location node_modules/.cache/eslint/",
"lint:format": "prettier --check \"{src,tools}/**/*.mjs\" \"types/**/*.ts\" \"*.{json,yml,md,js}\"",
"lint:format:fix": "prettier --loglevel warn --write \"{src,tools}/**/*.mjs\" \"types/**/*.ts\" \"*.{json,yml,md,js}\"",
"lint:types": "tsc",
"scm:stage": "git add .",

@@ -98,0 +101,0 @@ "version": "npm-run-all --sequential clean build lint depcruise:graph scm:stage"

# watskeburt
get git changed files & their statuses since _any revision_
Get changed files & their statuses since any git _revision_
## what's this do?
A micro-lib to retrieve an array of file names that were changed (added,
modified, renamed, deleted, ...) since the revision it got passed. Also
sports a cli for use outside of JavaScript c.s.
A micro-lib to retrieve an array of file names that were changed since a
revision. Also sports a cli for use outside of JavaScript c.s.
- :warning: in the process of getting 'production ready'. It's automatically
tested + it's using itself - but a bunch of static analysis and a bit of
automation still needs be added.
- :warning: Interface is stable-ish, but can can change until 1.0.0 is published
- :warning: expect some rough edges for e.g. error scenarios
- :warning: Interface is stable, but can can change until 1.0.0 is published :warning:
## why?
Useful primitives to support e.g. auto-documenting pull requests, or to save
processing power by only doing static analysis only over stuff that is changed.
I needed something simple and robust to support some upcoming features in
[dependency-cruiser](https://github.com/sverweij/dependency-cruiser) and to
run standalone to use _in combination_ with dependency-cruiser.
There are a few packages like these like this on npm, but it seems they've
fallen out of maintenance. More generic packages don't get plagued by this
There are a few specialized packages like this on npm, but it seems they've
fallen out of maintenance. More generic packages are still maintained,
but for just this simple usage they're a bit overkill.
## usage
## :construction_worker: usage
### :scroll: API
```javascript
// const { list } = require('watskeburt'); // will work in commonjs contexts as well
import { list, getSHA } from "watskeburt";
// print the SHA1 of the current HEAD
console.log(getSHA());
// list all files that differ between 'main' and the current revision (including
// files not staged for commit and files not under revision control)
/** @type {import('watskeburt').IChange[]} */
const lChangedFiles = list("main");
// As a second parameter you can pass some options:
/** @type {import('watskeburt').IChange[]|string} */
const lChangedFiles = list("main", {
trackedOnly: false, // when set to true leaves out files not under revision control
outputType: "object", // other options: "json" and "regex" (as used in the CLI)
});
```
The array of changes this returns looks like this:
```javascript
[
{
name: "doc/cli.md",
changeType: "modified",
},
{
name: "test/thing.spec.mjs",
changeType: "renamed",
oldName: "test/old-thing.spec.mjs",
},
{
name: "src/not-tracked-yet.mjs",
changeType: "untracked",
},
];
```
### :shell: cli

@@ -40,4 +78,7 @@

source files in the JavaScript ecosystem (.js, .mjs, .ts, .tsx ...) that can
be used in e.g. the `--focus` filter of dependency-cruiser:
be used in e.g. the `--focus` and `--reaches` filters of dependency-cruiser.
The JSON output (which looks a lot like the array above) is unfiltered and
also contains other extensions.
```

@@ -57,34 +98,7 @@ Usage: cli [options] [revision]

### :scroll: API
## 🇳🇱 what does 'watskeburt' mean?
```javascript
// const { list } = require('watskeburt'); // will work in commonjs contexts as well
import { list, getSHA } from "watskeburt";
// print the SHA1 of the current HEAD
console.log(getSHA());
// list all files that differ between 'main' and
/** @type {import('watskeburt').IChange[]} */
const lChangedFiles = list("main");
```
An array of changes looks something like this:
```javascript
[
{ name: "doc/cli.md", changeType: "modified" },
{
name: "test/thing.spec.mjs",
changeType: "renamed",
oldName: "test/old-thing.spec.mjs",
},
{ name: "src/not-tracked-yet.mjs", changeType: "untracked" },
];
```
## 🇳🇱 'watskeburt'??
_watskeburt_ is a fast pronunciation of the Dutch sentence "Wat is er gebeurd?"
(What has happened?), as well as the title of a song by the Dutch hip hop group
"De Jeugd van Tegenwoordig".
_watskeburt_ is a fast pronunciation of the Dutch "wat is er gebeurd?"
(_what has happened?_) or "wat er is gebeurd" (_what has happened_). It's
also the title of a song by the Dutch band "De Jeugd van Tegenwoordig"
(_Youth these days..._).

@@ -50,3 +50,3 @@ export type changeTypeType =

*
* @param pOldRevision the revision against which to compare. E.g. a commit-hash,
* @param pOldRevision The revision against which to compare. E.g. a commit-hash,
* a branch or a tag. When not passed defaults to the _current_

@@ -53,0 +53,0 @@ * commit hash (if there's any)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc