@simbo/git-changes 3.0.0 → 4.0.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.
- package/CHANGELOG.md +36 -0
- package/README.md +1 -1
- package/dist/get-git-changes.js.map +1 -1
- package/dist/git-change-status.enum.js.map +1 -1
- package/dist/git-changes.types.js.map +1 -1
- package/dist/git-status-constants.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/parse-git-change-status.js.map +1 -1
- package/dist/parse-git-status-output.js.map +1 -1
- package/package.json +13 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @simbo/git-changes
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 19c8dc1: Require Node.js ^24.15.0 || >=26.0.0 across all packages, as Node.js
|
|
8
|
+
22 reaches its end of life on 2027-04-30.
|
|
9
|
+
|
|
10
|
+
- Remove `^22.22.2` from `engines.node` in every package.
|
|
11
|
+
- Update the requirements in the package READMEs.
|
|
12
|
+
|
|
13
|
+
Node.js 22 is no longer supported. Upgrade to Node.js ^24.15.0 or >=26.0.0
|
|
14
|
+
before updating these packages.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 19c8dc1: Point the `repository` field of the manifest to the workspace folder.
|
|
19
|
+
|
|
20
|
+
- `repository` uses the object form with `type`, `url`, and `directory`, so
|
|
21
|
+
npm links the package folder and resolves relative links in the README from
|
|
22
|
+
there.
|
|
23
|
+
- `packages-changelog` gets the field for the first time.
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [19c8dc1]
|
|
26
|
+
- Updated dependencies [19c8dc1]
|
|
27
|
+
- @simbo/find-git-repository-root@3.0.0
|
|
28
|
+
|
|
29
|
+
## 3.0.1
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 6f304e0: Include the original sources in source maps (`inlineSources`), so
|
|
34
|
+
debuggers and stack traces show the TypeScript code without publishing `src`.
|
|
35
|
+
- 760573e: Update `execa` to ^10.2.1.
|
|
36
|
+
- Updated dependencies [6f304e0]
|
|
37
|
+
- @simbo/find-git-repository-root@2.0.1
|
|
38
|
+
|
|
3
39
|
## 3.0.0
|
|
4
40
|
|
|
5
41
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-git-changes.js","sourceRoot":"","sources":["../src/get-git-changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,UAAU,GAAG,GAAG,EAAE;IACpD,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAEzD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,UAAU,oCAAoC,CAAC,CAAC;IACpF,CAAC;IAED,IAAI,CAAC;QACH;;;;;;;;;;;;;;;;;;WAkBG;QACH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAA,qDAAqD,CAAC;QAE/G,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GACV,KAAK,YAAY,UAAU;YACzB,CAAC,CAAC,KAAK,CAAC,YAAY;YACpB,CAAC,CAAC,KAAK,YAAY,KAAK;gBACtB,CAAC,CAAC,KAAK,CA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3C,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC","sourcesContent":["import { cwd } from 'node:process';\n\nimport { findGitRepositoryRoot } from '@simbo/find-git-repository-root';\nimport { execa, ExecaError } from 'execa';\n\nimport type { GitChange } from './git-changes.types.js';\nimport { parseGitStatusOutput } from './parse-git-status-output.js';\n\n/**\n * Gets the uncommitted Git changes in the specified working directory.\n *\n * @param workingDir - The working directory of the Git repository. Defaults to the current working directory.\n * @returns A ReadonlyMap of file paths to their corresponding GitChange objects.\n */\nexport async function getGitChanges(workingDir = cwd()): Promise<ReadonlyMap<string, GitChange>> {\n const repoRoot = await findGitRepositoryRoot(workingDir);\n\n if (!repoRoot) {\n throw new Error(`The directory \"${workingDir}\" is not part of a Git repository.`);\n }\n\n try {\n /**\n * This command provides a machine-readable, null-separated output of the\n * current status of the Git repository, including staged and unstaged changes,\n * as well as untracked files. Untracked directories are listed as individual\n * files, regardless of the `status.showUntrackedFiles` configuration.\n * Paths are relative to the repository root.\n *\n * Example output (renamed and copied entries list the new path first):\n * '?? untracked.ts\\0'\n * ' M unstaged-modified.ts\\0'\n * 'M staged-modified.ts\\0'\n * 'MM both-modified.ts\\0'\n * ' D unstaged-deleted.ts\\0'\n * 'A staged-added.ts\\0'\n * ' T type-changed.ts\\0'\n * 'UU conflicted.ts\\0'\n * 'R new.ts\\0old.ts\\0'\n * 'C copied.ts\\0source.ts\\0'\n */\n const { stdout: output } = await execa({ cwd: repoRoot })`git status --porcelain --null --untracked-files=all`;\n\n return parseGitStatusOutput(output);\n } catch (error) {\n const reason =\n error instanceof ExecaError\n ? error.shortMessage\n : error instanceof Error\n ? error.message\n : `Unknown error (${String(error)})`;\n throw new Error(`Failed to get Git changes: ${reason}`, { cause: error });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-change-status.enum.js","sourceRoot":"","sources":["../src/git-change-status.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,eASX;AATD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,iCAAc,CAAA;IACd,oCAAiB,CAAA;IACjB,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,+BAAY,CAAA;IACZ,iCAAc,CAAA;IACd,kCAAe,CAAA;AACjB,CAAC,EATW,eAAe,KAAf,eAAe,QAS1B"}
|
|
1
|
+
{"version":3,"file":"git-change-status.enum.js","sourceRoot":"","sources":["../src/git-change-status.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,eASX;AATD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,iCAAc,CAAA;IACd,oCAAiB,CAAA;IACjB,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,+BAAY,CAAA;IACZ,iCAAc,CAAA;IACd,kCAAe,CAAA;AACjB,CAAC,EATW,eAAe,KAAf,eAAe,QAS1B","sourcesContent":["/**\n * Enum representing the possible statuses of a change in a Git repository.\n * Each status corresponds to a single character used in the output of `git status`.\n */\nexport enum GitChangeStatus {\n Added = 'A',\n Modified = 'M',\n TypeChanged = 'T',\n Deleted = 'D',\n Renamed = 'R',\n Copied = 'C',\n Unmerged = 'U',\n Untracked = '?',\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-changes.types.js","sourceRoot":"","sources":["../src/git-changes.types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"git-changes.types.js","sourceRoot":"","sources":["../src/git-changes.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { GitChangeStatus } from './git-change-status.enum.js';\n\n/**\n * Common Git change statuses for both staged and unstaged changes.\n */\nexport type GitChangeStatusCommon = GitChangeStatus.Modified | GitChangeStatus.TypeChanged | GitChangeStatus.Deleted;\n\n/**\n * Git change statuses that include an origin path.\n */\nexport type GitChangeStatusWithOriginPath = GitChangeStatus.Renamed | GitChangeStatus.Copied;\n\n/**\n * Added Git change status.\n */\nexport type GitChangeStatusAdded = GitChangeStatus.Added;\n\n/**\n * Untracked Git change status (only for unstaged changes).\n */\nexport type GitChangeStatusUntracked = GitChangeStatus.Untracked;\n\n/**\n * Unmerged Git change status (always set for both staged and unstaged changes\n * of a file with merge conflicts).\n */\nexport type GitChangeStatusUnmerged = GitChangeStatus.Unmerged;\n\n/**\n * Combined type for staged changes field.\n */\nexport type GitChangeStagedStatus =\n GitChangeStatusCommon | GitChangeStatusAdded | GitChangeStatusWithOriginPath | GitChangeStatusUnmerged;\n\n/**\n * Combined type for unstaged changes field.\n */\nexport type GitChangeUnstagedStatus =\n | GitChangeStatusCommon\n | GitChangeStatusAdded\n | GitChangeStatusUntracked\n | GitChangeStatusWithOriginPath\n | GitChangeStatusUnmerged;\n\n/**\n * Interface for a change in a Git repository.\n */\nexport interface GitChange {\n /**\n * The file path of the change, relative to the repository root.\n * For renamed or copied files, this is the new path.\n */\n path: string;\n\n /**\n * The status of the change if it is staged.\n * This can be one of the GitChangeStatus values or undefined if not staged.\n */\n staged?: GitChangeStagedStatus;\n\n /**\n * The status of the change if it is unstaged.\n * This can be one of the GitChangeStatus values or undefined if not unstaged.\n */\n unstaged?: GitChangeUnstagedStatus;\n\n /**\n * The original file path before the change (for renamed or copied files),\n * relative to the repository root.\n */\n originPath?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-status-constants.js","sourceRoot":"","sources":["../src/git-status-constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"git-status-constants.js","sourceRoot":"","sources":["../src/git-status-constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAwB,CAAC","sourcesContent":["import { GitChangeStatus } from './git-change-status.enum.js';\n\n/**\n * The separator used in the output of the Git status command.\n * This is a null character, which is used to separate entries in the output.\n */\nexport const ENTRY_SEPARATOR = '\\0';\n\n/**\n * The index in the Git change entry where the staged status is located.\n */\nexport const ENTRY_STATUS_INDEX = 0;\n\n/**\n * The length of the status string in a Git change entry.\n */\nexport const ENTRY_STATUS_LENGTH = 2;\n\n/**\n * The index in the Git change entry where the file path starts.\n */\nexport const ENTRY_PATH_INDEX = ENTRY_STATUS_INDEX + ENTRY_STATUS_LENGTH + 1;\n\n/**\n * A set of known GitChangeStatus values for validation purposes.\n */\nexport const KNOWN_GIT_CHANGE_STATUSES = new Set<string>(Object.values(GitChangeStatus)) as ReadonlySet<string>;\n"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC","sourcesContent":["export * from './get-git-changes.js';\nexport * from './git-change-status.enum.js';\nexport type * from './git-changes.types.js';\nexport * from './git-status-constants.js';\nexport * from './parse-git-change-status.js';\nexport * from './parse-git-status-output.js';\n"]}
|
|
@@ -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;AAG9D,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,CAC3D,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,eAAe,CAAC,SAAS,IAAI,KAAK,KAAK,eAAe,CAAC,QAAQ,CACnF,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,OAAO,EAAE,MA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,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;;;GAgBG;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,IAAI,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAC,QAAQ,EAAE,CAAC;IAClF,CAAC;IAED,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import { GitChangeStatus } from './git-change-status.enum.js';\nimport type { GitChange } from './git-changes.types.js';\n\nconst trackedStatuses = Object.values(GitChangeStatus).filter(\n value => value !== GitChangeStatus.Untracked && value !== GitChangeStatus.Unmerged,\n);\n\n/**\n * Status combinations that mark a file with merge conflicts (\"unmerged\").\n * - `DD`: both deleted\n * - `AU`: added by us\n * - `UD`: deleted by them\n * - `UA`: added by them\n * - `DU`: deleted by us\n * - `AA`: both added\n * - `UU`: both modified\n */\nconst unmergedStatuses = new Set(['DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU']);\n\n/**\n * Parses a Git change status string into staged and unstaged statuses.\n *\n * The status string is expected to be at least two characters long, where:\n * - The first character represents the staged status.\n * - The second character represents the unstaged status.\n *\n * If the status is '??', it indicates an untracked file.\n *\n * If the status is one of the unmerged combinations (DD, AU, UD, UA, DU, AA, UU),\n * it indicates a file with merge conflicts and both statuses are `Unmerged`.\n *\n * This should match the output of `git status --porcelain`.\n *\n * @param status - A two-character string representing the Git change status.\n * @returns An object containing the staged and unstaged statuses.\n */\nexport function parseGitChangeStatus(status: string): Pick<GitChange, 'staged' | 'unstaged'> {\n if (typeof status !== 'string' || status.length < 2) {\n return { staged: undefined, unstaged: undefined };\n }\n\n if (status.startsWith('??')) {\n return { staged: undefined, unstaged: GitChangeStatus.Untracked };\n }\n\n if (unmergedStatuses.has(status.slice(0, 2))) {\n return { staged: GitChangeStatus.Unmerged, unstaged: GitChangeStatus.Unmerged };\n }\n\n const staged = trackedStatuses.find((value: string) => value === status[0]);\n const unstaged = trackedStatuses.find((value: string) => value === status[1]);\n\n return { staged, unstaged };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-git-status-output.js","sourceRoot":"","sources":["../src/parse-git-status-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACvH,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAE9C,IAAI,KAAK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AE,CAAC;YACpC,SAAS;QACX,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { GitChangeStatus } from './git-change-status.enum.js';\nimport type { GitChange } from './git-changes.types.js';\nimport { ENTRY_PATH_INDEX, ENTRY_SEPARATOR, ENTRY_STATUS_INDEX, ENTRY_STATUS_LENGTH } from './git-status-constants.js';\nimport { parseGitChangeStatus } from './parse-git-change-status.js';\n\n/**\n * Parses the output of the Git status command and returns a map of Git changes.\n *\n * @param output - The output string from the Git status command.\n * @returns A ReadonlyMap of file paths to their corresponding GitChange objects.\n */\nexport function parseGitStatusOutput(output: string): ReadonlyMap<string, GitChange> {\n const changes = new Map<string, GitChange>();\n const entries = output.split(ENTRY_SEPARATOR);\n\n let index = 0;\n\n while (index < entries.length) {\n const entry = entries[index++];\n\n if (!entry) {\n continue;\n }\n\n const { staged, unstaged } = parseGitChangeStatus(entry.slice(ENTRY_STATUS_INDEX, ENTRY_STATUS_LENGTH));\n\n const path = entry.slice(ENTRY_PATH_INDEX);\n\n // Renamed or copied entries contain the new path, followed by an entry with the original path.\n // The original path is consumed even if the entry is invalid, so it is never parsed as an entry.\n if (\n staged === GitChangeStatus.Renamed ||\n staged === GitChangeStatus.Copied ||\n unstaged === GitChangeStatus.Renamed ||\n unstaged === GitChangeStatus.Copied\n ) {\n const originPath = entries[index++];\n if (path && originPath) {\n changes.set(path, { path, originPath, staged, unstaged });\n }\n continue;\n }\n\n if (!path || (!staged && !unstaged)) {\n continue;\n }\n\n changes.set(path, { path, staged, unstaged });\n }\n\n return changes;\n}\n"]}
|
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": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"git",
|
|
7
7
|
"changes",
|
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
"homepage": "https://github.com/simbo/packages/tree/main/packages/git-changes",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "github
|
|
22
|
+
"url": "git+https://github.com/simbo/packages.git",
|
|
23
|
+
"directory": "packages/git-changes"
|
|
23
24
|
},
|
|
24
25
|
"bugs": "https://github.com/simbo/packages/issues",
|
|
25
26
|
"engines": {
|
|
26
|
-
"node": "^
|
|
27
|
+
"node": "^24.15.0 || >=26.0.0"
|
|
27
28
|
},
|
|
28
29
|
"type": "module",
|
|
29
30
|
"exports": {
|
|
@@ -36,28 +37,24 @@
|
|
|
36
37
|
"README.md"
|
|
37
38
|
],
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@simbo/find-git-repository-root": "
|
|
40
|
-
"execa": "^10.2.
|
|
40
|
+
"@simbo/find-git-repository-root": "3.0.0",
|
|
41
|
+
"execa": "^10.2.1"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"@simbo/
|
|
45
|
-
"@simbo/prettier-config": "3.0.1",
|
|
46
|
-
"@simbo/tsconfig": "2.0.0",
|
|
44
|
+
"@simbo/eslint-config": "5.0.0",
|
|
45
|
+
"@simbo/tsconfig": "3.0.0",
|
|
47
46
|
"@types/node": "^24.19.2",
|
|
48
|
-
"@vitest/coverage-v8": "^5.1.
|
|
49
|
-
"@vitest/ui": "^5.1.
|
|
50
|
-
"eslint": "^10.
|
|
47
|
+
"@vitest/coverage-v8": "^5.1.1",
|
|
48
|
+
"@vitest/ui": "^5.1.1",
|
|
49
|
+
"eslint": "^10.15.0",
|
|
51
50
|
"jiti": "^2.7.0",
|
|
52
|
-
"prettier": "^3.9.10",
|
|
53
51
|
"typescript": "^6.0.3",
|
|
54
|
-
"vitest": "^5.1.
|
|
52
|
+
"vitest": "^5.1.1"
|
|
55
53
|
},
|
|
56
54
|
"scripts": {
|
|
57
55
|
"build": "tsc --project tsconfig.build.json",
|
|
58
|
-
"check": "pnpm run check:eslint && pnpm run check:
|
|
56
|
+
"check": "pnpm run check:eslint && pnpm run check:types",
|
|
59
57
|
"check:eslint": "eslint --config ./eslint.config.ts --max-warnings 0",
|
|
60
|
-
"check:format": "prettier --check .",
|
|
61
58
|
"check:types": "tsc --noEmit",
|
|
62
59
|
"clean": "pnpm run clean:dist && pnpm run clean:coverage && pnpm run clean:turbo && pnpm run clean:node_modules",
|
|
63
60
|
"clean:dist": "rm -rf dist",
|
|
@@ -65,7 +62,6 @@
|
|
|
65
62
|
"clean:turbo": "rm -rf .turbo",
|
|
66
63
|
"clean:coverage": "rm -rf coverage",
|
|
67
64
|
"fix:eslint": "pnpm run check:eslint --fix",
|
|
68
|
-
"fix:format": "prettier --write .",
|
|
69
65
|
"test": "vitest run --coverage",
|
|
70
66
|
"test:ui": "pnpm run test:watch --ui",
|
|
71
67
|
"test:watch": "vitest dev --coverage"
|