Skip to content

Commit 98864c6

Browse files
authored
V4 (#1193)
* - remove `simple-git/promise` and associated `gitP` export * - switch from yarn to pnpm * - convert jest to vitest * - upgrade biome - apply formatting to "new" code * - migrate types into `src` - add vite build script * - vite build for mjs / cjs outputs, reusing the `baseConfig` helper from the `@simple-git/` sub-packages. - apply the `node:` schema for node specific imports - generate types with `tsc` * - apply lint across tests * - apply import ordering and type import settings to more packages * - update package scripts to use pnpm from yarn * - add declaration maps * - enforce the use of `GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS` environment variable to disable abbreviations in `git` commands * - enforce the use of `GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS` environment variable to disable abbreviations in `git` commands * - split unit and integration tests as `projects` in vitest, apply module mocks only in unit tests. * - use pnpm in the github actions * - use `pnpm/setup` action in favour of `actions/setup-node` * - use `pnpm/setup` action in favour of `actions/setup-node` * - use `pnpm/setup` action in favour of `actions/setup-node` - upgrade `actions/checkout` * - update self-referential tests to import from root barrel file (argv-parser) * - update self-referential tests to import from root barrel file (argv-parser) * - update unit tests to be aware of the constant environment variable, and remove test asserting ability to use a default export on `simple-git` * Lint * Update unsafe spec - no longer viable to pwn with `--u` * Use pnpm in build scripts * - use `.ts` rather than `.d.ts` in source files * - CI runs consumer tests outside of main test flow - Remove duplication in consumer tests - Remove babel configuration, obsolete following move to vitest * - examples directory uses the named import * - docs content uses the named import * - add debug logging to the custom-binary plugin - remove `console.warn` when permitting unsafe (configured through `unsafe.allowUnsafeCustomBinary`) * - remove duplication in exported types * - remove deprecated build tools * - remove deprecated interfaces * Update lock file * - lint * - path to windows test file * - path to windows test file * - path to windows test file * - path to windows test file * - path to windows test file * - path to windows test file * - path to windows test file * - consumer tests allow rewriting lockfile before running * - consumer tests allow rewriting lockfile before running * - support `build:pkg` only modifying the `export` publish block, rather than full removal of `scripts` and `devDependencies`. - `typescript-esm-consumer` package updated to build ESM JavaScript (includes type check) then run directly with node (includes validation of exported functionality). * - add consumer tests asserting both TypeScript compilation and test running (directly via node to avoid any inline TS transpilation by TSX) - removed obsolete block from biome config * - apply config-only `build:pkg` switch to the github actions setup * - Include `tar.command` to vulnerable config list - `simple-git` depends on current workspace version rather than `^` version of arv-parser, avoids inconsistency in vulnerability detection expectations, noting an upgrade to argv-parser will require a new release of `simple-git`. * - Add vulnerability test for use of `include.path` * - Add option to `unsafe.allowAbbreviatedOptions` * - Documentation for v4 release * - Lint * - Add `includeIf.<condition>.path` to the vulnerabilities list * Add support for `input` plugin. Closes #1178 * Create the `git.interpretTrailers` interface Closes #1178
1 parent c427fba commit 98864c6

312 files changed

Lines changed: 5499 additions & 10833 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.changeset/calm-birds-listen.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"simple-git": minor
3+
---
4+
5+
Support one-shot stdin via `git.input(data)` (`string` or `Buffer`).
6+
7+
Thanks to @felipecrs for the feature request and initial implementation.

‎.changeset/sha-zam-four.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@simple-git/args-pathspec": patch
3+
"@simple-git/argv-parser": major
4+
---
5+
6+
Updates ahead of the v4 release for `simple-git`.
7+
8+
- Adds support for TypeScript declaration maps
9+
- Exports the `isGitEnvKey` helper to detect whether an environment variable can be used to configure a `git` operation
10+
11+
- Adds detection for `includeIf.<condition>.path`, thanks to @NotAFlightRisk for identifying the vulnerability

‎.changeset/slow-pens-hear.md‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
"simple-git": major
3+
---
4+
5+
Major upgrade to v4. In this version:
6+
7+
- Removed previously available default export, now uses a consistently named `simpleGit` export.
8+
- Removed previously deprecated import `simple-git/promise` (change to using the main `simple-git` import).
9+
- Removed legacy `gitP` export (change to using the main `simpleGit` export).
10+
11+
```typescript
12+
// v3 - previously supported imports
13+
import simpleGit from 'simple-git';
14+
import { gitP } from 'simple-git';
15+
import simpleGit from 'simple-git/promise';
16+
const simpleGit = require('simple-git');
17+
18+
// v4 - consolidates to a single supported import
19+
import { simpleGit } from 'simple-git';
20+
const { simpleGit } = require('simple-git');
21+
```
22+
23+
- Prevents the use of abbreviated long-form `git` options:
24+
25+
```typescript
26+
// v3 - allowed the use of unambiguous long-form options
27+
git.raw('clone', '--conf=user.name=me', '...');
28+
29+
// v4 - requires full option names, abbreviated option names will now throw a GitConfigurationError
30+
git.raw('fetch', '--config=user.name=me', '...');
31+
```
32+
33+
- Ambient environment variables are filtered before passing into the `git` child process.
34+
35+
```typescript
36+
// v3
37+
process.env.FOO = 'bar';
38+
process.env.GIT_TEMPLATE_DIR = './some/path';
39+
simpleGit().raw('clone'); // git child process can see both environment variables
40+
41+
// v4
42+
process.env.FOO = 'bar';
43+
process.env.GIT_TEMPLATE_DIR = './some/path';
44+
simpleGit().raw('clone'); // git child process now sees only FOO
45+
46+
simpleGit({
47+
// explicitly allow the named environment variable so it can pass through.
48+
allowEnvoronment: ['GIT_TEMPLATE_DIR'],
49+
// and enable the use of an unsafe behaviour
50+
unsafe: { allowUnsafeTemplateDir: true },
51+
})
52+
```
53+
54+
- Explicitly supplied disallowed environment variables will throw when used.
55+
56+
```typescript
57+
// v3 used a single opt-in to potential unsafe actiity
58+
simpleGit({ unsafe: { allowUnsafeTemplateDir: true } })
59+
.env({ GIT_TEMPLATE_DIR: './foo' })
60+
.init();
61+
62+
// v4 uses a double opt-in, allow the behaviour and the mechanism
63+
simpleGit({
64+
allowEnvoronment: ['GIT_TEMPLATE_DIR'],
65+
unsafe: { allowUnsafeTemplateDir: true }
66+
})
67+
.env({ GIT_TEMPLATE_DIR: './foo' }).init();
68+
69+
```
70+
71+
- Removed content deprecated during the v2 to v3 major change
72+
- `simpleGit.silent()` logging is configured through environment variables in the `debug` package
73+
- `simpleGit.clearQueue()` this has been a noop since v3, switch to using the `abort` plugin
74+
- Accessing parsed properties of a `GitResponseError` through a trailing callback function are available only through the `error.git` property (previously properties were also spread onto the `error` itself with a deprecation notice).

‎.github/workflows/changesets.yml‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,20 @@ jobs:
1616
environment: npm
1717
if: github.repository == 'steveukx/git-js'
1818
steps:
19-
- uses: actions/checkout@v6
19+
- uses: actions/checkout@v7
2020
with:
2121
fetch-depth: 0
2222

23-
- uses: actions/setup-node@v6
23+
- uses: pnpm/setup@v2
2424
with:
25-
cache: yarn
26-
node-version: 24
25+
runtime: node@24
26+
cache: true
2727

28-
- run: yarn install --immutable
29-
- run: yarn build
28+
- run: pnpm build
3029

3130
- uses: changesets/action@v1
3231
with:
33-
publish: yarn changeset publish
32+
publish: pnpm changeset publish
3433
env:
3534
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3635
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

‎.github/workflows/ci.yml‎

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,48 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
node-version: [20, 22, 23, 24, 25]
17+
node-version: [20, 22, 24, 25, 26]
1818
steps:
19-
- uses: actions/checkout@v6
20-
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v6
19+
- uses: actions/checkout@v7
20+
- uses: pnpm/setup@v2
2221
with:
23-
node-version: ${{ matrix.node-version }}
24-
cache: yarn
25-
- run: yarn install --immutable
26-
- run: yarn build
22+
runtime: node@${{ matrix.node-version }}
23+
cache: true
24+
- run: pnpm build
2725
- name: Test
2826
env:
2927
GIT_AUTHOR_NAME: 'Simple Git Tests'
3028
GIT_AUTHOR_EMAIL: 'tests@simple-git.dev'
31-
run: yarn test
32-
- run: yarn build:pkg
33-
- run: yarn test:consumer
29+
run: pnpm test
3430

3531
build-windows:
3632
runs-on: windows-latest
3733
steps:
38-
- uses: actions/checkout@v6
39-
- name: Use Node.js 24
40-
uses: actions/setup-node@v6
34+
- uses: actions/checkout@v7
35+
- uses: pnpm/setup@v2
4136
with:
42-
node-version: 24
43-
cache: yarn
44-
- run: yarn install --immutable
45-
- run: yarn build
37+
runtime: node@24
38+
cache: true
39+
- run: pnpm build
4640
- name: Test
4741
env:
4842
GIT_AUTHOR_NAME: 'Simple Git Tests'
4943
GIT_AUTHOR_EMAIL: 'tests@simple-git.dev'
50-
run: yarn test:win
44+
run: pnpm test:win
45+
46+
consumer:
47+
runs-on: ubuntu-latest
48+
strategy:
49+
matrix:
50+
node-version: [ 22, 24, 26 ]
51+
steps:
52+
- uses: actions/checkout@v7
53+
- uses: pnpm/setup@v2
54+
with:
55+
runtime: node@${{ matrix.node-version }}
56+
cache: true
57+
- name: Build
58+
env:
59+
SIMPLE_GIT_PKG_CONFIG_ONLY: true
60+
run: pnpm build && pnpm build:pkg
61+
- run: pnpm test:consumer

‎.github/workflows/quality.yml‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ jobs:
1313
lint:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v6
17-
- name: Use Node.js
18-
uses: actions/setup-node@v6
16+
- uses: actions/checkout@v7
17+
- uses: pnpm/setup@v2
1918
with:
20-
node-version: 24
21-
cache: yarn
22-
- run: yarn install --immutable
23-
- run: yarn lint
19+
runtime: node@24
20+
cache: true
21+
- run: pnpm lint

0 commit comments

Comments
 (0)