@depup/docker-compose 1.3.2-depup.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/readme.md ADDED
@@ -0,0 +1,146 @@
1
+ [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
2
+ [![Discord](https://img.shields.io/discord/1070453198000767076)](https://discord.gg/pR6duvNHtV)
3
+ <img src="https://img.shields.io/github/actions/workflow/status/pdmlab/docker-compose/ci.yml?branch=master" />
4
+ <img src="https://img.shields.io/npm/dm/docker-compose.svg" />
5
+
6
+ # Manage Docker-Compose via Node.js
7
+
8
+ `docker-compose` is a small library that allows you to run [docker-compose](https://docs.docker.com/compose/) (which is still required) via Node.js. This is useful to bootstrap test environments.
9
+
10
+ As of version 1.0, this library supports `docker compose` (v2, the docker "compose" plugin) by default. The `docker-compose` (v1) has been removed from recent releases of Docker Desktop and is no longer supported. However, you can still force the use of `docker-compose` by using the [standanlone mode](#standalone-mode).
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ yarn add --dev docker-compose
16
+ ```
17
+
18
+ ## Documentation
19
+
20
+ The documentation can be found [here](https://pdmlab.github.io/docker-compose/).
21
+
22
+ ## Example
23
+
24
+ ### Import for `docker-compose`
25
+
26
+ ```ts
27
+ import * as compose from 'docker-compose'
28
+ ```
29
+
30
+ You can also import only the required commands:
31
+
32
+ ```ts
33
+ import { run, upAll } from 'docker-compose'
34
+ ```
35
+
36
+ ### Usage
37
+
38
+ To start service containers based on the `docker-compose.yml` file in your current directory, just call `compose.upAll` like this:
39
+
40
+ ```javascript
41
+ compose.upAll({ cwd: path.join(__dirname), log: true }).then(
42
+ () => {
43
+ console.log('done')
44
+ },
45
+ (err) => {
46
+ console.log('something went wrong:', err.message)
47
+ }
48
+ )
49
+ ```
50
+
51
+ Start specific services using `compose.upMany`:
52
+
53
+ ```javascript
54
+ const services = ['serviceA', 'serviceB']
55
+ compose.upMany(services, { cwd: path.join(__dirname), log: true })
56
+ ```
57
+
58
+ Or start a single service with `compose.upOne`:
59
+
60
+ ```javascript
61
+ const service = 'serviceA'
62
+ compose.upOne(service, { cwd: path.join(__dirname), log: true })
63
+ ```
64
+
65
+ To execute command inside a running container
66
+
67
+ ```javascript
68
+ compose.exec('node', 'npm install', { cwd: path.join(__dirname) })
69
+ ```
70
+
71
+ To list the containers for a compose project
72
+
73
+ ```javascript
74
+ const result = await compose.ps({ cwd: path.join(__dirname) })
75
+ result.data.services.forEach((service) => {
76
+ console.log(service.name, service.command, service.state, service.ports)
77
+ // state is e.g. 'Up 2 hours'
78
+ })
79
+ ```
80
+
81
+ The `--format json` command option can be used to get a better state support:
82
+
83
+ ```javascript
84
+ const result = await compose.ps({ cwd: path.join(__dirname), commandOptions: [["--format", "json"]] })
85
+ result.data.services.forEach((service) => {
86
+ console.log(service.name, service.command, service.state, service.ports)
87
+ // state is one of the defined states: paused | restarting | removing | running | dead | created | exited
88
+ })
89
+ ```
90
+
91
+ ### Standalone mode
92
+
93
+ While the `docker-compose` executable is no longer part of a default docker installation, it is still possible to download its binary [standalone](https://docs.docker.com/compose/install/standalone/). This is useful for example when building docker images, avoiding the need to install the whole docker stack.
94
+
95
+ To use a standalone binary, you can set the `executable.standalone` option to `true`. You can also set the `executablePath` option to the path of the `docker-compose` binary.
96
+
97
+ ```js
98
+ compose.upAll({
99
+ executable: {
100
+ standalone: true,
101
+ executablePath: '/path/to/docker-compose' // optional
102
+ }
103
+ })
104
+ ```
105
+
106
+ ## Known issues
107
+
108
+ * During testing we noticed that `docker compose` seems to send its 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).
109
+
110
+ ## Running the tests
111
+
112
+ While `docker-compose` runs on Node.js 6+, running the tests requires you to use Node.js 8+ as they make use of `async/await`.
113
+
114
+ ```bash
115
+ yarn test
116
+ ```
117
+
118
+ ## Want to help?
119
+
120
+ This project is just getting off the ground and could use some help with cleaning things up and refactoring.
121
+
122
+ If you want to contribute - we'd love it! Just open an issue to work against so you get full credit for your fork. You can open the issue first so we can discuss and you can work your fork as we go along.
123
+
124
+ If you see a bug, please be so kind as to show how it's failing, and we'll do our best to get it fixed quickly.
125
+
126
+ Before sending a PR, please [create an issue](https://github.com/PDMLab/docker-compose/issues/new) to introduce your idea and have a reference for your PR.
127
+
128
+ We're using [conventional commits](https://www.conventionalcommits.org), so please use it for your commits as well.
129
+
130
+ Also please add tests and make sure to run `yarn lint`.
131
+
132
+ ### Discussions
133
+
134
+ If you want to discuss an `docker-compose` issue or PR in more detail, feel free to [start a discussion](https://github.com/PDMLab/docker-compose/discussions).
135
+
136
+ ## License
137
+
138
+ MIT License
139
+
140
+ Copyright (c) 2017 - 2021 PDMLab
141
+
142
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
143
+
144
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
145
+
146
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/tsconfig.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Basic Options */
4
+ // "incremental": true, /* Enable incremental compilation */
5
+ "target": "ES2021" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
6
+ "module": "node16" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
7
+ "lib": [
8
+ "es2021",
9
+ "dom"
10
+ ] /* Specify library files to be included in the compilation. */,
11
+ // "allowJs": true, /* Allow javascript files to be compiled. */
12
+ // "checkJs": true, /* Report errors in .js files. */
13
+ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
14
+ "declaration": true /* Generates corresponding '.d.ts' file. */,
15
+ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
16
+ // "sourceMap": true, /* Generates corresponding '.map' file. */
17
+ // "outFile": "./", /* Concatenate and emit output to single file. */
18
+ "outDir": "./dist" /* Redirect output structure to the directory. */,
19
+ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
20
+ // "composite": true, /* Enable project compilation */
21
+ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
22
+ // "removeComments": true, /* Do not emit comments to output. */
23
+ // "noEmit": true, /* Do not emit outputs. */
24
+ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
25
+ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
26
+ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
27
+
28
+ /* Strict Type-Checking Options */
29
+ "strict": true /* Enable all strict type-checking options. */,
30
+ "noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */,
31
+ // "strictNullChecks": true, /* Enable strict null checks. */
32
+ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
33
+ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
34
+ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
35
+ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
36
+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
37
+
38
+ /* Additional Checks */
39
+ // "noUnusedLocals": true, /* Report errors on unused locals. */
40
+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
41
+ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
42
+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
43
+
44
+ /* Module Resolution Options */
45
+ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
46
+ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
47
+ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
48
+ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
49
+ // "typeRoots": [], /* List of folders to include type definitions from. */
50
+ // "types": [], /* Type declaration files to be included in compilation. */
51
+ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
52
+ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
53
+ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
54
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
55
+
56
+ /* Source Map Options */
57
+ // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
58
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
59
+ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
60
+ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
61
+
62
+ /* Experimental Options */
63
+ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
64
+ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
65
+ },
66
+ "exclude": ["node_modules", "dist", "test", "old"]
67
+ }