@mxpicture/build-api 0.2.31 → 0.2.33
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/dist/barrel/Barrel.js +1 -1
- package/dist/git/GitChanges.d.ts +7 -11
- package/dist/git/GitChanges.js +33 -29
- package/dist/types/types.git.d.ts +2 -2
- package/package.json +1 -1
package/dist/barrel/Barrel.js
CHANGED
|
@@ -128,7 +128,7 @@ export class Barrel {
|
|
|
128
128
|
extractExports(result) {
|
|
129
129
|
const record = {};
|
|
130
130
|
for (const barrelDir of result.barrelDirs) {
|
|
131
|
-
const ex = relative(
|
|
131
|
+
const ex = relative(result.pkg.srcPath, barrelDir);
|
|
132
132
|
record[`./${ex}`] = `./dist/${ex}/index.js`;
|
|
133
133
|
}
|
|
134
134
|
record["./package.json"] = "./package.json";
|
package/dist/git/GitChanges.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { GitChangedResult, GitChangedContentsResult } from "../types/types.git.js";
|
|
2
|
+
export declare const initGitChanges: (repoRoot: string, sinceRef?: string) => Promise<GitChanges>;
|
|
3
|
+
export declare const gitChanges: () => GitChanges;
|
|
2
4
|
export declare class GitChanges {
|
|
3
5
|
readonly rootDir: string;
|
|
4
|
-
protected
|
|
6
|
+
protected _sinceRef: string | null;
|
|
5
7
|
constructor(rootDir: string);
|
|
6
|
-
set
|
|
7
|
-
get
|
|
8
|
+
set sinceRef(sinceRef: string);
|
|
9
|
+
get sinceRef(): string;
|
|
8
10
|
/**
|
|
9
11
|
* Checks if a specific file or directory has been changed since a given git commit.
|
|
10
12
|
* Includes both committed and uncommitted changes (staged + unstaged).
|
|
11
13
|
*
|
|
12
14
|
* @param target - Relative path to the file or directory to check.
|
|
13
|
-
* @param
|
|
15
|
+
* @param sinceRef - The git commit hash (or ref like a tag/branch) to compare against.
|
|
14
16
|
* @returns A result object indicating whether changes were detected.
|
|
15
17
|
*/
|
|
16
18
|
hasChanged(path: string): Promise<GitChangedResult>;
|
|
@@ -22,15 +24,9 @@ export declare class GitChanges {
|
|
|
22
24
|
* Deleted files are excluded from the result since they no longer exist on disk.
|
|
23
25
|
*
|
|
24
26
|
* @param target - Relative path to the file or directory to check.
|
|
25
|
-
* @param
|
|
27
|
+
* @param sinceRef - The git commit hash (or ref like a tag/branch) to compare against.
|
|
26
28
|
* @param cwd - The working directory of the git repository (defaults to process.cwd()).
|
|
27
29
|
* @returns A result object containing the current content of each changed file.
|
|
28
30
|
*/
|
|
29
31
|
readChangedFiles(readContent?: boolean): Promise<GitChangedContentsResult>;
|
|
30
32
|
}
|
|
31
|
-
export declare class GitChangesCommit extends GitChanges {
|
|
32
|
-
constructor(rootDir: string, sinceCommit: string);
|
|
33
|
-
}
|
|
34
|
-
export declare class GitChangesTag extends GitChangesCommit {
|
|
35
|
-
constructor(rootDir: string, sinceTag: string);
|
|
36
|
-
}
|
package/dist/git/GitChanges.js
CHANGED
|
@@ -1,42 +1,57 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
|
-
import { verifiedGit } from "./git.util.js";
|
|
4
|
+
import { lastCommitHash, lastTag, verifiedGit } from "./git.util.js";
|
|
5
|
+
let __instance = null;
|
|
6
|
+
export const initGitChanges = async (repoRoot, sinceRef) => {
|
|
7
|
+
__instance = new GitChanges(repoRoot);
|
|
8
|
+
__instance.sinceRef =
|
|
9
|
+
sinceRef ??
|
|
10
|
+
(await lastTag(repoRoot)) ??
|
|
11
|
+
(await lastCommitHash(repoRoot)) ??
|
|
12
|
+
"HEAD~1";
|
|
13
|
+
return __instance;
|
|
14
|
+
};
|
|
15
|
+
export const gitChanges = () => {
|
|
16
|
+
if (!__instance)
|
|
17
|
+
throw new Error("GitChanges not initialized. initGitChanges[Ref]()");
|
|
18
|
+
return __instance;
|
|
19
|
+
};
|
|
5
20
|
export class GitChanges {
|
|
6
21
|
rootDir;
|
|
7
|
-
|
|
22
|
+
_sinceRef = null;
|
|
8
23
|
constructor(rootDir) {
|
|
9
24
|
this.rootDir = rootDir;
|
|
10
25
|
}
|
|
11
|
-
set
|
|
12
|
-
this.
|
|
26
|
+
set sinceRef(sinceRef) {
|
|
27
|
+
this._sinceRef = sinceRef;
|
|
13
28
|
}
|
|
14
|
-
get
|
|
15
|
-
if (!this.
|
|
16
|
-
throw new Error("
|
|
17
|
-
return this.
|
|
29
|
+
get sinceRef() {
|
|
30
|
+
if (!this._sinceRef)
|
|
31
|
+
throw new Error("SinceRef missing");
|
|
32
|
+
return this._sinceRef;
|
|
18
33
|
}
|
|
19
34
|
/**
|
|
20
35
|
* Checks if a specific file or directory has been changed since a given git commit.
|
|
21
36
|
* Includes both committed and uncommitted changes (staged + unstaged).
|
|
22
37
|
*
|
|
23
38
|
* @param target - Relative path to the file or directory to check.
|
|
24
|
-
* @param
|
|
39
|
+
* @param sinceRef - The git commit hash (or ref like a tag/branch) to compare against.
|
|
25
40
|
* @returns A result object indicating whether changes were detected.
|
|
26
41
|
*/
|
|
27
42
|
async hasChanged(path) {
|
|
28
|
-
const
|
|
43
|
+
const sinceRef = this.sinceRef;
|
|
29
44
|
const resolvedTarget = resolve(this.rootDir, path);
|
|
30
45
|
if (!existsSync(resolvedTarget)) {
|
|
31
46
|
throw new Error(`Target path does not exist: ${resolvedTarget}`);
|
|
32
47
|
}
|
|
33
|
-
const git = await verifiedGit(this.rootDir,
|
|
48
|
+
const git = await verifiedGit(this.rootDir, sinceRef);
|
|
34
49
|
// Compare commit to working directory (includes uncommitted changes)
|
|
35
|
-
const diff = await git.diffSummary([
|
|
50
|
+
const diff = await git.diffSummary([sinceRef, "--", path]);
|
|
36
51
|
const changedFiles = diff.files.map((file) => file.file);
|
|
37
52
|
return {
|
|
38
53
|
path,
|
|
39
|
-
|
|
54
|
+
sinceRef,
|
|
40
55
|
hasChanged: changedFiles.length > 0,
|
|
41
56
|
changedFiles,
|
|
42
57
|
};
|
|
@@ -49,15 +64,15 @@ export class GitChanges {
|
|
|
49
64
|
* Deleted files are excluded from the result since they no longer exist on disk.
|
|
50
65
|
*
|
|
51
66
|
* @param target - Relative path to the file or directory to check.
|
|
52
|
-
* @param
|
|
67
|
+
* @param sinceRef - The git commit hash (or ref like a tag/branch) to compare against.
|
|
53
68
|
* @param cwd - The working directory of the git repository (defaults to process.cwd()).
|
|
54
69
|
* @returns A result object containing the current content of each changed file.
|
|
55
70
|
*/
|
|
56
71
|
async readChangedFiles(readContent) {
|
|
57
|
-
const
|
|
58
|
-
const git = await verifiedGit(this.rootDir,
|
|
72
|
+
const sinceRef = this.sinceRef;
|
|
73
|
+
const git = await verifiedGit(this.rootDir, sinceRef);
|
|
59
74
|
// Compare commit to working directory (includes uncommitted changes)
|
|
60
|
-
const diff = await git.diffSummary([
|
|
75
|
+
const diff = await git.diffSummary([sinceRef, "--", this.rootDir]);
|
|
61
76
|
const files = [];
|
|
62
77
|
for (const entry of diff.files) {
|
|
63
78
|
const repoFilePath = entry.file;
|
|
@@ -72,19 +87,8 @@ export class GitChanges {
|
|
|
72
87
|
}
|
|
73
88
|
return {
|
|
74
89
|
path: this.rootDir,
|
|
75
|
-
|
|
90
|
+
sinceRef,
|
|
76
91
|
files,
|
|
77
92
|
};
|
|
78
93
|
}
|
|
79
94
|
}
|
|
80
|
-
export class GitChangesCommit extends GitChanges {
|
|
81
|
-
constructor(rootDir, sinceCommit) {
|
|
82
|
-
super(rootDir);
|
|
83
|
-
this.sinceCommitTag = sinceCommit;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
export class GitChangesTag extends GitChangesCommit {
|
|
87
|
-
constructor(rootDir, sinceTag) {
|
|
88
|
-
super(rootDir, sinceTag);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DiffResult } from "simple-git";
|
|
2
2
|
export interface GitChangedResult {
|
|
3
3
|
path: string;
|
|
4
|
-
|
|
4
|
+
sinceRef: string;
|
|
5
5
|
hasChanged: boolean;
|
|
6
6
|
changedFiles: string[];
|
|
7
7
|
}
|
|
@@ -12,7 +12,7 @@ export interface GitChangedContent {
|
|
|
12
12
|
}
|
|
13
13
|
export interface GitChangedContentsResult {
|
|
14
14
|
path: string;
|
|
15
|
-
|
|
15
|
+
sinceRef: string;
|
|
16
16
|
files: GitChangedContent[];
|
|
17
17
|
}
|
|
18
18
|
export interface GitCommitHash {
|