adce-git 0.0.0-stage → 0.1.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.
@@ -0,0 +1 @@
1
+ export declare const isGitRepository: (roothPath: string) => Promise<boolean>;
package/dist/detect.js ADDED
@@ -0,0 +1,13 @@
1
+ import { access } from "node:fs/promises";
2
+ import path from "node:path";
3
+ // Detect if a directory is inside a git working tree
4
+ export const isGitRepository = async (roothPath) => {
5
+ try {
6
+ await access(path.join(roothPath, ".git"));
7
+ return true;
8
+ }
9
+ catch {
10
+ return false;
11
+ }
12
+ };
13
+ //# sourceMappingURL=detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.js","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,qDAAqD;AAErD,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,SAAiB,EAAoB,EAAE;IAC3E,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface GitCommitEvent {
2
+ hash: string;
3
+ date: string;
4
+ message: string;
5
+ author: string;
6
+ }
7
+ /** Best-effort file history. Returns [] when Git is absent or path has no log. */
8
+ export declare const getPathCommitHistory: (rootPath: string, relativePath: string, limit?: number) => Promise<GitCommitEvent[]>;
@@ -0,0 +1,27 @@
1
+ import { simpleGit } from "simple-git";
2
+ import { isGitRepository } from "./detect.js";
3
+ /** Best-effort file history. Returns [] when Git is absent or path has no log. */
4
+ export const getPathCommitHistory = async (rootPath, relativePath, limit = 10) => {
5
+ if (!(await isGitRepository(rootPath)))
6
+ return [];
7
+ if (!relativePath)
8
+ return [];
9
+ try {
10
+ const git = simpleGit(rootPath);
11
+ const log = await git.log({
12
+ file: relativePath.replace(/\\/g, "/"),
13
+ maxCount: limit,
14
+ strictDate: true,
15
+ });
16
+ return log.all.map((entry) => ({
17
+ hash: entry.hash,
18
+ date: entry.date,
19
+ message: entry.message,
20
+ author: entry.author_name,
21
+ }));
22
+ }
23
+ catch {
24
+ return [];
25
+ }
26
+ };
27
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAS9C,kFAAkF;AAClF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACvC,QAAgB,EAChB,YAAoB,EACpB,KAAK,GAAG,EAAE,EACiB,EAAE;IAC7B,IAAI,CAAC,CAAC,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAClD,IAAI,CAAC,YAAY;QAAE,OAAO,EAAE,CAAC;IAE7B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAChC,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC;YACxB,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;YACtC,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,WAAW;SAC1B,CAAC,CAAC,CAAC;IACN,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { isGitRepository } from "./detect.js";
2
+ export { getPathCommitHistory, type GitCommitEvent, } from "./history.js";
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { isGitRepository } from "./detect.js";
2
+ export { getPathCommitHistory, } from "./history.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,oBAAoB,GAErB,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "adce-git",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Git helpers for ADCE",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "simple-git": "^3.36.0"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^26.4.1"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc -p tsconfig.json",
30
+ "typecheck": "tsc -p tsconfig.json --noEmit",
31
+ "test": "vitest run --passWithNoTests"
32
+ }
6
33
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.