@simbo/git-changes 1.0.1 → 1.0.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @simbo/git-changes
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - fcd0224: improve types to reflect staged and unstaged states
8
+
9
+ ## 1.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 5d6bd64: improve types to reflect staged and unstaged states
14
+
3
15
  ## 1.0.1
4
16
 
5
17
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import type { GitChange } from './git-change.interface.js';
1
+ import type { GitChange } from './git-changes.types.js';
2
2
  /**
3
3
  * Gets the uncommitted Git changes in the specified working directory.
4
4
  *
@@ -0,0 +1,61 @@
1
+ import type { GitChangeStatus } from './git-change-status.enum.js';
2
+ /**
3
+ * Common git change statuses for both staged and unstaged changes.
4
+ */
5
+ export type GitChangeStatusCommon = GitChangeStatus.Modified | GitChangeStatus.Deleted;
6
+ /**
7
+ * Git change statuses that include an origin path.
8
+ */
9
+ export type GitChangeStatusWithOriginPath = GitChangeStatus.Renamed | GitChangeStatus.Copied;
10
+ /**
11
+ * Added git change status (only for staged changes).
12
+ */
13
+ export type GitChangeStatusAdded = GitChangeStatus.Added;
14
+ /**
15
+ * Untracked git change status (only for unstaged changes).
16
+ */
17
+ export type GitChangeStatusUntracked = GitChangeStatus.Untracked;
18
+ export type GitChangeStagedStatus = GitChangeStatusCommon | GitChangeStatusAdded | GitChangeStatusWithOriginPath;
19
+ export type GitChangeUnstagedStatus = GitChangeStatusCommon | GitChangeStatusUntracked | GitChangeStatusWithOriginPath;
20
+ /**
21
+ * A change in a Git repository.
22
+ */
23
+ export type GitChange<Staged extends GitChangeStagedStatus | undefined = GitChangeStagedStatus | undefined, Unstaged extends GitChangeUnstagedStatus | undefined = GitChangeUnstagedStatus | undefined> = GitChangeBase & (Staged extends GitChangeStagedStatus ? GitChangeStaged : object) & (Unstaged extends GitChangeUnstagedStatus ? GitChangeUnstaged : object) & (Staged extends GitChangeStatusWithOriginPath ? GitChangeWithOriginPath : object) & (Unstaged extends GitChangeStatusWithOriginPath ? GitChangeWithOriginPath : object);
24
+ /**
25
+ * Base interface for a change in a Git repository.
26
+ */
27
+ export interface GitChangeBase {
28
+ /**
29
+ * The file path of the change.
30
+ */
31
+ path: string;
32
+ }
33
+ /**
34
+ * A change in a Git repository that is staged.
35
+ */
36
+ export interface GitChangeStaged {
37
+ /**
38
+ * The status of the change when it is staged.
39
+ * This can be one of the GitChangeStatus values or undefined if not staged.
40
+ */
41
+ staged: GitChangeStagedStatus;
42
+ }
43
+ /**
44
+ * A change in a Git repository that is unstaged.
45
+ */
46
+ export interface GitChangeUnstaged {
47
+ /**
48
+ * The status of the change when it is unstaged.
49
+ * This can be one of the GitChangeStatus values or undefined if not unstaged.
50
+ */
51
+ unstaged: GitChangeUnstagedStatus;
52
+ }
53
+ /**
54
+ * A change in a Git repository that includes an origin path.
55
+ */
56
+ export interface GitChangeWithOriginPath {
57
+ /**
58
+ * The original file path before the change (for renamed or copied files).
59
+ */
60
+ originPath: string;
61
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=git-changes.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-changes.types.js","sourceRoot":"","sources":["../src/git-changes.types.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './get-git-changes.js';
2
2
  export * from './git-change-status.enum.js';
3
- export type * from './git-change.interface.js';
3
+ export type * from './git-changes.types.js';
4
4
  export * from './git-status-constants.js';
5
5
  export * from './parse-git-change-status.js';
6
6
  export * from './parse-git-status-output.js';
@@ -1,4 +1,4 @@
1
- import type { GitChange } from './git-change.interface.js';
1
+ import type { GitChangeStagedStatus, GitChangeUnstagedStatus } from './git-changes.types.js';
2
2
  /**
3
3
  * Parses a Git change status string into staged and unstaged statuses.
4
4
  *
@@ -14,6 +14,6 @@ import type { GitChange } from './git-change.interface.js';
14
14
  * @returns An object containing the staged and unstaged statuses.
15
15
  */
16
16
  export declare function parseGitChangeStatus(status: string): {
17
- staged: GitChange['staged'];
18
- unstaged: GitChange['unstaged'];
17
+ staged: GitChangeStagedStatus | undefined;
18
+ unstaged: GitChangeUnstagedStatus | undefined;
19
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"parse-git-change-status.js","sourceRoot":"","sources":["../src/parse-git-change-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACpD,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,CAAC,SAAS,EAAE,CAAC;IACpE,CAAC;IAED,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAC3D,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,yBAAyB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAC/B,CAAC;IAElD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
1
+ {"version":3,"file":"parse-git-change-status.js","sourceRoot":"","sources":["../src/parse-git-change-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IAIjD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACpD,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,CAAC,SAAS,EAAE,CAAC;IACpE,CAAC;IAED,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAC3D,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,yBAAyB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CACH,CAAC;IAE9E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { GitChange } from './git-change.interface.js';
1
+ import type { GitChange } from './git-changes.types.js';
2
2
  /**
3
3
  * Parses the output of the git status command and returns a map of Git changes.
4
4
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simbo/git-changes",
3
3
  "description": "A library to read, parse and provide Git changes information from `git status` for a local repository.",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "keywords": [
6
6
  "git",
7
7
  "changes",
@@ -47,9 +47,9 @@
47
47
  "prettier": "^3.7.4",
48
48
  "typescript": "^5.9.3",
49
49
  "vitest": "^3.2.4",
50
- "@simbo/eslint-config": "2.0.3",
51
- "@simbo/prettier-config": "2.0.0",
52
- "@simbo/tsconfig": "1.0.4"
50
+ "@simbo/eslint-config": "2.0.4",
51
+ "@simbo/tsconfig": "1.0.4",
52
+ "@simbo/prettier-config": "2.0.0"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsc --project tsconfig.build.json",
@@ -1,25 +0,0 @@
1
- import type { GitChangeStatus } from './git-change-status.enum.js';
2
- /**
3
- * Represents a change in a Git repository.
4
- */
5
- export interface GitChange {
6
- /**
7
- * The file path of the change.
8
- */
9
- path: string;
10
- /**
11
- * The origin file path if the change is a rename or copy.
12
- * This is only set for changes that involve renaming or copying files.
13
- */
14
- originPath?: string;
15
- /**
16
- * The status of the change when it is staged.
17
- * This can be one of the GitChangeStatus values or undefined if not staged.
18
- */
19
- staged?: GitChangeStatus.Added | GitChangeStatus.Modified | GitChangeStatus.Deleted | GitChangeStatus.Renamed | GitChangeStatus.Copied;
20
- /**
21
- * The status of the change when it is unstaged.
22
- * This can be one of the GitChangeStatus values or undefined if not unstaged.
23
- */
24
- unstaged?: GitChangeStatus.Untracked | GitChangeStatus.Modified | GitChangeStatus.Deleted | GitChangeStatus.Renamed | GitChangeStatus.Copied;
25
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=git-change.interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-change.interface.js","sourceRoot":"","sources":["../src/git-change.interface.ts"],"names":[],"mappings":""}