Skip to content

Commit

Permalink
feat: support docker compose v2 plugin version (#228)
Browse files Browse the repository at this point in the history
* feat: support docker compose v2 plugin version

* test: run v2 tests only

* chore: replace jest with vitest

* test: run vitest command instead of jest

* refactor: create v2 tests in test folder, move old tests to old folder

* fix(lint): remove jest plugin reference

* fix(lint): no-useless-escape for \" characters

* fix(build): exclude old tests temporarily

* test: support versions with extensions like 2.17.2+azure-1 (gh ci)

* chore(ci): use v3 checkout

* test: (re-)add tests for v2 port mapping

* chore: increase test timeout to 30s (as was in the past)

* refactor: move v2 test files to v2 subfolder

* fix: expect volume name to match changed folder name

* refactor: move v1 tests back to v1 test subfolder

remove outdated v2 tests

* refactor: use jest style vitest for v1 tests

* refactor: run v1 and v2 tests consecutively

* chore(release): 0.23.20-preview.0

* build: export v2 via index

* docs: describe v2 imports and issues
  • Loading branch information
AlexZeitler authored Apr 28, 2023
1 parent ccc9566 commit 95250be
Show file tree
Hide file tree
Showing 27 changed files with 2,382 additions and 1,846 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:jest/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
],
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-22.04
name: info
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
Expand All @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-22.04
name: Lint
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
Expand All @@ -32,10 +32,11 @@ jobs:
runs-on: ubuntu-22.04
name: Build + Test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: yarn
- run: yarn build
- run: yarn test
- run: yarn test-v1
- run: yarn test-v2
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.23.20-preview.0](https://github.com/PDMLab/docker-compose/compare/v0.23.19...v0.23.20-preview.0) (2023-04-27)


### Features

* support docker compose v2 plugin version ([81e72e9](https://github.com/PDMLab/docker-compose/commit/81e72e9985aba05474463306852501287ad32680))


### Bug Fixes

* expect volume name to match changed folder name ([85c4c15](https://github.com/PDMLab/docker-compose/commit/85c4c150ce5191c95116e98145e2d3c75604a4a4))
* **build:** exclude old tests temporarily ([36d543d](https://github.com/PDMLab/docker-compose/commit/36d543db56822be95c9cd31eaa890a4c46e789a4))
* **lint:** no-useless-escape for \" characters ([fcabbc2](https://github.com/PDMLab/docker-compose/commit/fcabbc2ea7c7d42f15f45a26badab9fe73030a6c))
* **lint:** remove jest plugin reference ([892e6db](https://github.com/PDMLab/docker-compose/commit/892e6db60302ef734e5b42b74da6f583c1fb9e52))

### [0.23.19](https://github.com/PDMLab/docker-compose/compare/v0.23.18...v0.23.19) (2023-02-05)

### [0.23.18](https://github.com/PDMLab/docker-compose/compare/v0.23.17...v0.23.18) (2023-01-24)
Expand Down
34 changes: 27 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,40 @@ home: false
npm install --save-dev docker-compose
```

## Usage
## Import for docker-compose (v1)

You can either import particular functions like `upAll`:
To import commands for the v1 version, please use this import statement:

```typescript
import { upAll, down, exec, stopOne, logs } from "docker-compose";
```ts
import * as compose from 'docker-compose'
```

or you can just import the complete library:
You can also import only the required commands:

```typescript
import * as compose from "docker-compose";
```ts
import { run, upAll } from 'docker-compose'
```

### Import for docker-compose (v2)

To import commands for the v2 version, please use this import statement:

```ts
import { v2 as compose } from 'docker-compose'
```

You can also import only the required commands:

```ts
import { run, upAll } from 'docker-compose/dist/v2'
```

## Known issues with v2 support

* During testing we noticed that `docker compose` seems to send it's exit code also commands don't seem to have finished. This doesn't occur for all commands, but for example with `stop` or `down`. We had the option to wait for stopped / removed containers using third party libraries but this would make bootstrapping `docker-compose` much more complicated for the users. So we decided to use a `setTimeout(500)` workaround. We're aware this is not perfect but it seems to be the most appropriate solution for now. Details can be found in the [v2 PR discussion](https://github.com/PDMLab/docker-compose/pull/228#issuecomment-1422895821) (we're happy to get help here).

## Usage

`docker-compose` current supports these commands:

* `buildAll(options)` - Build or rebuild services
Expand Down
187 changes: 0 additions & 187 deletions jest.config.js

This file was deleted.

11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "docker-compose",
"version": "0.23.19",
"version": "0.23.20-preview.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"types": "dist/index.d.ts",
"scripts": {
"test": "jest test --verbose",
"test-v1": "npx vitest --dir test/v1 --test-timeout=30000",
"test-v2": "npx vitest --dir test/v2 --test-timeout=30000",
"lint": "eslint src/**/*.ts test/**/*.ts",
"build": "tsc",
"prepublishOnly": "tsc",
Expand Down Expand Up @@ -83,23 +84,21 @@
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "13.1.0",
"@types/dockerode": "^2.5.27",
"@types/jest": "^29.4.0",
"@types/node": "^12.12.6",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"@vitest/ui": "^0.30.1",
"dockerode": "^3.2.1",
"eslint": "^7.24.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.3.4",
"eslint-plugin-prettier": "^3.3.1",
"eslint-watch": "^7.0.0",
"husky": "^6.0.0",
"jest": "^29.4.1",
"prettier": "^2.2.1",
"standard-version": "9.3.1",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5",
"vitest": "^0.30.1",
"vuepress": "^2.0.0-beta.7"
},
"engines": {
Expand Down
Loading

0 comments on commit 95250be

Please sign in to comment.