@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/.claude/settings.local.json +10 -0
- package/CHANGELOG.md +341 -0
- package/LICENSE +21 -0
- package/README.md +31 -0
- package/changes.json +10 -0
- package/dist/index.d.ts +181 -0
- package/dist/index.js +519 -0
- package/dist/map-ports.d.ts +11 -0
- package/dist/map-ports.js +27 -0
- package/package.json +135 -0
- package/readme.md +146 -0
- package/tsconfig.json +67 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.stats = exports.version = exports.port = exports.logs = exports.restartOne = exports.restartMany = exports.restartAll = exports.push = exports.images = exports.ps = exports.configVolumes = exports.configServices = exports.config = exports.pullOne = exports.pullMany = exports.pullAll = exports.createOne = exports.createMany = exports.createAll = exports.buildOne = exports.buildMany = exports.buildAll = exports.run = exports.exec = exports.rm = exports.kill = exports.unpauseOne = exports.pauseOne = exports.stopMany = exports.stopOne = exports.stop = exports.downOne = exports.downMany = exports.down = exports.downAll = exports.upOne = exports.upMany = exports.upAll = exports.execCompose = exports.mapImListOutput = exports.mapPsOutput = void 0;
|
|
7
|
+
const child_process_1 = __importDefault(require("child_process"));
|
|
8
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
9
|
+
const map_ports_1 = __importDefault(require("./map-ports"));
|
|
10
|
+
const nonEmptyString = (v) => v !== '';
|
|
11
|
+
const arrayIncludesTuple = (arr, tuple) => {
|
|
12
|
+
return arr.some((subArray) => Array.isArray(subArray) &&
|
|
13
|
+
subArray.length === tuple.length &&
|
|
14
|
+
subArray.every((value, index) => value === tuple[index]));
|
|
15
|
+
};
|
|
16
|
+
const mapPsOutput = (output, options) => {
|
|
17
|
+
let isQuiet = false;
|
|
18
|
+
let isJson = false;
|
|
19
|
+
if (options?.commandOptions) {
|
|
20
|
+
isQuiet =
|
|
21
|
+
options.commandOptions.includes('-q') ||
|
|
22
|
+
options.commandOptions.includes('--quiet') ||
|
|
23
|
+
options.commandOptions.includes('--services');
|
|
24
|
+
isJson = arrayIncludesTuple(options.commandOptions, ['--format', 'json']);
|
|
25
|
+
}
|
|
26
|
+
const services = output
|
|
27
|
+
.split(`\n`)
|
|
28
|
+
.filter(nonEmptyString)
|
|
29
|
+
.filter((_, index) => isQuiet || isJson || index >= 1)
|
|
30
|
+
.map((line) => {
|
|
31
|
+
let nameFragment = line;
|
|
32
|
+
let commandFragment = '';
|
|
33
|
+
let stateFragment = '';
|
|
34
|
+
let untypedPortsFragment = '';
|
|
35
|
+
if (!isQuiet) {
|
|
36
|
+
if (isJson) {
|
|
37
|
+
const serviceLine = JSON.parse(line);
|
|
38
|
+
nameFragment = serviceLine.Name;
|
|
39
|
+
commandFragment = serviceLine.Command;
|
|
40
|
+
stateFragment = serviceLine.State;
|
|
41
|
+
untypedPortsFragment = serviceLine.Ports;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const lineColumns = line.split(/\s{3,}/);
|
|
45
|
+
// the line has the columns in the following order:
|
|
46
|
+
// NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
|
47
|
+
// @see https://docs.docker.com/engine/reference/commandline/compose_ps/#description
|
|
48
|
+
nameFragment = lineColumns[0];
|
|
49
|
+
commandFragment = lineColumns[2];
|
|
50
|
+
stateFragment = lineColumns[5];
|
|
51
|
+
untypedPortsFragment = lineColumns[6];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
name: nameFragment.trim(),
|
|
56
|
+
command: commandFragment.trim(),
|
|
57
|
+
state: stateFragment.trim(),
|
|
58
|
+
ports: (0, map_ports_1.default)(untypedPortsFragment.trim())
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
return { services };
|
|
62
|
+
};
|
|
63
|
+
exports.mapPsOutput = mapPsOutput;
|
|
64
|
+
const mapImListOutput = (output, options) => {
|
|
65
|
+
let isQuiet = false;
|
|
66
|
+
let isJson = false;
|
|
67
|
+
if (options?.commandOptions) {
|
|
68
|
+
isQuiet =
|
|
69
|
+
options.commandOptions.includes('-q') ||
|
|
70
|
+
options.commandOptions.includes('--quiet');
|
|
71
|
+
isJson = arrayIncludesTuple(options.commandOptions, ['--format', 'json']);
|
|
72
|
+
}
|
|
73
|
+
if (isJson) {
|
|
74
|
+
const data = JSON.parse(output);
|
|
75
|
+
const services = data.map((serviceLine) => {
|
|
76
|
+
let idFragment = serviceLine.ID;
|
|
77
|
+
// trim json 64B id format "type:id" to 12B id
|
|
78
|
+
const idTypeIndex = idFragment.indexOf(':');
|
|
79
|
+
if (idTypeIndex > 0)
|
|
80
|
+
idFragment = idFragment.slice(idTypeIndex + 1, idTypeIndex + 13);
|
|
81
|
+
return {
|
|
82
|
+
container: serviceLine.ContainerName,
|
|
83
|
+
repository: serviceLine.Repository,
|
|
84
|
+
tag: serviceLine.Tag,
|
|
85
|
+
platform: serviceLine.Platform || '',
|
|
86
|
+
id: idFragment
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
return { services };
|
|
90
|
+
}
|
|
91
|
+
const services = output
|
|
92
|
+
.split(`\n`)
|
|
93
|
+
.filter(nonEmptyString)
|
|
94
|
+
.filter((_, index) => isQuiet || isJson || index >= 1)
|
|
95
|
+
.map((line) => {
|
|
96
|
+
// the line has the columns in the following order:
|
|
97
|
+
// CONTAINER REPOSITORY TAG IMAGE ID SIZE
|
|
98
|
+
// Note: newer docker compose versions may include PLATFORM column
|
|
99
|
+
const lineColumns = line.split(/\s{3,}/);
|
|
100
|
+
const containerFragment = lineColumns[0] || line;
|
|
101
|
+
const repositoryFragment = lineColumns[1] || '';
|
|
102
|
+
const tagFragment = lineColumns[2] || '';
|
|
103
|
+
const idFragment = lineColumns[3] || '';
|
|
104
|
+
return {
|
|
105
|
+
container: containerFragment.trim(),
|
|
106
|
+
repository: repositoryFragment.trim(),
|
|
107
|
+
tag: tagFragment.trim(),
|
|
108
|
+
platform: '',
|
|
109
|
+
id: idFragment.trim()
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
return { services };
|
|
113
|
+
};
|
|
114
|
+
exports.mapImListOutput = mapImListOutput;
|
|
115
|
+
/**
|
|
116
|
+
* Converts supplied yml files to cli arguments
|
|
117
|
+
* https://docs.docker.com/compose/reference/overview/#use--f-to-specify-name-and-path-of-one-or-more-compose-files
|
|
118
|
+
*/
|
|
119
|
+
const configToArgs = (config) => {
|
|
120
|
+
if (typeof config === 'undefined') {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
else if (typeof config === 'string') {
|
|
124
|
+
return ['-f', config];
|
|
125
|
+
}
|
|
126
|
+
else if (config instanceof Array) {
|
|
127
|
+
return config.reduce((args, item) => args.concat(['-f', item]), []);
|
|
128
|
+
}
|
|
129
|
+
throw new Error(`Invalid argument supplied: ${config}`);
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Converts docker compose commandline options to cli arguments
|
|
133
|
+
*/
|
|
134
|
+
const composeOptionsToArgs = (composeOptions) => {
|
|
135
|
+
let composeArgs = [];
|
|
136
|
+
composeOptions.forEach((option) => {
|
|
137
|
+
if (option instanceof Array) {
|
|
138
|
+
composeArgs = composeArgs.concat(option);
|
|
139
|
+
}
|
|
140
|
+
if (typeof option === 'string') {
|
|
141
|
+
composeArgs = composeArgs.concat([option]);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return composeArgs;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Executes docker compose command with common options
|
|
148
|
+
*/
|
|
149
|
+
const execCompose = (command, args, options = {}) => new Promise((resolve, reject) => {
|
|
150
|
+
const composeOptions = options.composeOptions || [];
|
|
151
|
+
const commandOptions = options.commandOptions || [];
|
|
152
|
+
let composeArgs = composeOptionsToArgs(composeOptions);
|
|
153
|
+
const isConfigProvidedAsString = !!options.configAsString;
|
|
154
|
+
const configArgs = isConfigProvidedAsString
|
|
155
|
+
? ['-f', '-']
|
|
156
|
+
: configToArgs(options.config);
|
|
157
|
+
composeArgs = composeArgs.concat(configArgs.concat([command].concat(composeOptionsToArgs(commandOptions), args)));
|
|
158
|
+
const cwd = options.cwd;
|
|
159
|
+
const env = options.env || undefined;
|
|
160
|
+
const executable = options.executable;
|
|
161
|
+
let executablePath;
|
|
162
|
+
let executableArgs = [];
|
|
163
|
+
if (executable?.standalone) {
|
|
164
|
+
executablePath = executable.executablePath || 'docker-compose';
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
executablePath = executable?.executablePath || 'docker';
|
|
168
|
+
const executableOptions = executable?.options || [];
|
|
169
|
+
executableArgs = [...composeOptionsToArgs(executableOptions), 'compose'];
|
|
170
|
+
}
|
|
171
|
+
const childProc = child_process_1.default.spawn(executablePath, [...executableArgs, ...composeArgs], {
|
|
172
|
+
cwd,
|
|
173
|
+
env
|
|
174
|
+
});
|
|
175
|
+
childProc.on('error', (err) => {
|
|
176
|
+
reject(err);
|
|
177
|
+
});
|
|
178
|
+
const result = {
|
|
179
|
+
exitCode: null,
|
|
180
|
+
err: '',
|
|
181
|
+
out: ''
|
|
182
|
+
};
|
|
183
|
+
childProc.stdout.on('data', (chunk) => {
|
|
184
|
+
result.out += chunk.toString();
|
|
185
|
+
options.callback?.(chunk, 'stdout');
|
|
186
|
+
});
|
|
187
|
+
childProc.stderr.on('data', (chunk) => {
|
|
188
|
+
result.err += chunk.toString();
|
|
189
|
+
options.callback?.(chunk, 'stderr');
|
|
190
|
+
});
|
|
191
|
+
childProc.on('exit', (exitCode) => {
|
|
192
|
+
result.exitCode = exitCode;
|
|
193
|
+
setTimeout(() => {
|
|
194
|
+
if (exitCode === 0) {
|
|
195
|
+
resolve(result);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
reject(result);
|
|
199
|
+
}
|
|
200
|
+
}, 500);
|
|
201
|
+
});
|
|
202
|
+
if (isConfigProvidedAsString) {
|
|
203
|
+
childProc.stdin.write(options.configAsString);
|
|
204
|
+
childProc.stdin.end();
|
|
205
|
+
}
|
|
206
|
+
if (options.log) {
|
|
207
|
+
childProc.stdout.pipe(process.stdout);
|
|
208
|
+
childProc.stderr.pipe(process.stderr);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
exports.execCompose = execCompose;
|
|
212
|
+
/**
|
|
213
|
+
* Determines whether or not to use the default non-interactive flag -d for up commands
|
|
214
|
+
*/
|
|
215
|
+
const shouldUseDefaultNonInteractiveFlag = function (options = {}) {
|
|
216
|
+
const commandOptions = options.commandOptions || [];
|
|
217
|
+
const noDetachModeFlags = [
|
|
218
|
+
'--abort-on-container-exit',
|
|
219
|
+
'--no-start',
|
|
220
|
+
'--attach',
|
|
221
|
+
'--attach-dependencies',
|
|
222
|
+
'--exit-code-from'
|
|
223
|
+
];
|
|
224
|
+
const containsOtherNonInteractiveFlag = commandOptions.reduce((memo, item) => {
|
|
225
|
+
return memo && noDetachModeFlags.every((flag) => !item.includes(flag));
|
|
226
|
+
}, true);
|
|
227
|
+
return containsOtherNonInteractiveFlag;
|
|
228
|
+
};
|
|
229
|
+
const upAll = function (options) {
|
|
230
|
+
const args = shouldUseDefaultNonInteractiveFlag(options) ? ['-d'] : [];
|
|
231
|
+
return (0, exports.execCompose)('up', args, options);
|
|
232
|
+
};
|
|
233
|
+
exports.upAll = upAll;
|
|
234
|
+
const upMany = function (services, options) {
|
|
235
|
+
const args = shouldUseDefaultNonInteractiveFlag(options)
|
|
236
|
+
? ['-d'].concat(services)
|
|
237
|
+
: services;
|
|
238
|
+
return (0, exports.execCompose)('up', args, options);
|
|
239
|
+
};
|
|
240
|
+
exports.upMany = upMany;
|
|
241
|
+
const upOne = function (service, options) {
|
|
242
|
+
const args = shouldUseDefaultNonInteractiveFlag(options)
|
|
243
|
+
? ['-d', service]
|
|
244
|
+
: [service];
|
|
245
|
+
return (0, exports.execCompose)('up', args, options);
|
|
246
|
+
};
|
|
247
|
+
exports.upOne = upOne;
|
|
248
|
+
const downAll = function (options) {
|
|
249
|
+
return (0, exports.execCompose)('down', [], options);
|
|
250
|
+
};
|
|
251
|
+
exports.downAll = downAll;
|
|
252
|
+
exports.down = exports.downAll;
|
|
253
|
+
const downMany = function (services, options) {
|
|
254
|
+
const args = services;
|
|
255
|
+
return (0, exports.execCompose)('down', args, options);
|
|
256
|
+
};
|
|
257
|
+
exports.downMany = downMany;
|
|
258
|
+
const downOne = function (service, options) {
|
|
259
|
+
const args = [service];
|
|
260
|
+
return (0, exports.execCompose)('down', args, options);
|
|
261
|
+
};
|
|
262
|
+
exports.downOne = downOne;
|
|
263
|
+
const stop = function (options) {
|
|
264
|
+
return (0, exports.execCompose)('stop', [], options);
|
|
265
|
+
};
|
|
266
|
+
exports.stop = stop;
|
|
267
|
+
const stopOne = function (service, options) {
|
|
268
|
+
return (0, exports.execCompose)('stop', [service], options);
|
|
269
|
+
};
|
|
270
|
+
exports.stopOne = stopOne;
|
|
271
|
+
const stopMany = function (options, ...services) {
|
|
272
|
+
return (0, exports.execCompose)('stop', [...services], options);
|
|
273
|
+
};
|
|
274
|
+
exports.stopMany = stopMany;
|
|
275
|
+
const pauseOne = function (service, options) {
|
|
276
|
+
return (0, exports.execCompose)('pause', [service], options);
|
|
277
|
+
};
|
|
278
|
+
exports.pauseOne = pauseOne;
|
|
279
|
+
const unpauseOne = function (service, options) {
|
|
280
|
+
return (0, exports.execCompose)('unpause', [service], options);
|
|
281
|
+
};
|
|
282
|
+
exports.unpauseOne = unpauseOne;
|
|
283
|
+
const kill = function (options) {
|
|
284
|
+
return (0, exports.execCompose)('kill', [], options);
|
|
285
|
+
};
|
|
286
|
+
exports.kill = kill;
|
|
287
|
+
const rm = function (options, ...services) {
|
|
288
|
+
return (0, exports.execCompose)('rm', ['-f', ...services], options);
|
|
289
|
+
};
|
|
290
|
+
exports.rm = rm;
|
|
291
|
+
const exec = function (container, command, options) {
|
|
292
|
+
const args = Array.isArray(command) ? command : command.split(/\s+/);
|
|
293
|
+
return (0, exports.execCompose)('exec', ['-T', container].concat(args), options);
|
|
294
|
+
};
|
|
295
|
+
exports.exec = exec;
|
|
296
|
+
const run = function (container, command, options) {
|
|
297
|
+
const args = Array.isArray(command) ? command : command.split(/\s+/);
|
|
298
|
+
return (0, exports.execCompose)('run', ['-T', container].concat(args), options);
|
|
299
|
+
};
|
|
300
|
+
exports.run = run;
|
|
301
|
+
const buildAll = function (options = {}) {
|
|
302
|
+
return (0, exports.execCompose)('build', options.parallel ? ['--parallel'] : [], options);
|
|
303
|
+
};
|
|
304
|
+
exports.buildAll = buildAll;
|
|
305
|
+
const buildMany = function (services, options = {}) {
|
|
306
|
+
return (0, exports.execCompose)('build', options.parallel ? ['--parallel'].concat(services) : services, options);
|
|
307
|
+
};
|
|
308
|
+
exports.buildMany = buildMany;
|
|
309
|
+
const buildOne = function (service, options) {
|
|
310
|
+
return (0, exports.execCompose)('build', [service], options);
|
|
311
|
+
};
|
|
312
|
+
exports.buildOne = buildOne;
|
|
313
|
+
const createAll = function (options = {}) {
|
|
314
|
+
return (0, exports.execCompose)('create', [], options);
|
|
315
|
+
};
|
|
316
|
+
exports.createAll = createAll;
|
|
317
|
+
const createMany = function (services, options = {}) {
|
|
318
|
+
return (0, exports.execCompose)('create', services, options);
|
|
319
|
+
};
|
|
320
|
+
exports.createMany = createMany;
|
|
321
|
+
const createOne = function (service, options) {
|
|
322
|
+
return (0, exports.execCompose)('create', [service], options);
|
|
323
|
+
};
|
|
324
|
+
exports.createOne = createOne;
|
|
325
|
+
const pullAll = function (options = {}) {
|
|
326
|
+
return (0, exports.execCompose)('pull', [], options);
|
|
327
|
+
};
|
|
328
|
+
exports.pullAll = pullAll;
|
|
329
|
+
const pullMany = function (services, options = {}) {
|
|
330
|
+
return (0, exports.execCompose)('pull', services, options);
|
|
331
|
+
};
|
|
332
|
+
exports.pullMany = pullMany;
|
|
333
|
+
const pullOne = function (service, options) {
|
|
334
|
+
return (0, exports.execCompose)('pull', [service], options);
|
|
335
|
+
};
|
|
336
|
+
exports.pullOne = pullOne;
|
|
337
|
+
const config = async function (options) {
|
|
338
|
+
try {
|
|
339
|
+
const result = await (0, exports.execCompose)('config', [], options);
|
|
340
|
+
const config = yaml_1.default.parse(result.out);
|
|
341
|
+
return {
|
|
342
|
+
...result,
|
|
343
|
+
data: { config }
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
return Promise.reject(error);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
exports.config = config;
|
|
351
|
+
const configServices = async function (options) {
|
|
352
|
+
try {
|
|
353
|
+
const result = await (0, exports.execCompose)('config', ['--services'], options);
|
|
354
|
+
const services = result.out.split('\n').filter(nonEmptyString);
|
|
355
|
+
return {
|
|
356
|
+
...result,
|
|
357
|
+
data: { services }
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
catch (error) {
|
|
361
|
+
return Promise.reject(error);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
exports.configServices = configServices;
|
|
365
|
+
const configVolumes = async function (options) {
|
|
366
|
+
try {
|
|
367
|
+
const result = await (0, exports.execCompose)('config', ['--volumes'], options);
|
|
368
|
+
const volumes = result.out.split('\n').filter(nonEmptyString);
|
|
369
|
+
return {
|
|
370
|
+
...result,
|
|
371
|
+
data: { volumes }
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
return Promise.reject(error);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
exports.configVolumes = configVolumes;
|
|
379
|
+
const ps = async function (options) {
|
|
380
|
+
try {
|
|
381
|
+
const result = await (0, exports.execCompose)('ps', [], options);
|
|
382
|
+
const data = (0, exports.mapPsOutput)(result.out, options);
|
|
383
|
+
return {
|
|
384
|
+
...result,
|
|
385
|
+
data
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
return Promise.reject(error);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
exports.ps = ps;
|
|
393
|
+
const images = async function (options) {
|
|
394
|
+
try {
|
|
395
|
+
// Always use JSON format for robust parsing across docker compose versions
|
|
396
|
+
const jsonOptions = {
|
|
397
|
+
...options,
|
|
398
|
+
commandOptions: [...(options?.commandOptions || []), ['--format', 'json']]
|
|
399
|
+
};
|
|
400
|
+
const result = await (0, exports.execCompose)('images', [], jsonOptions);
|
|
401
|
+
const data = (0, exports.mapImListOutput)(result.out, jsonOptions);
|
|
402
|
+
return {
|
|
403
|
+
...result,
|
|
404
|
+
data
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
catch (error) {
|
|
408
|
+
return Promise.reject(error);
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
exports.images = images;
|
|
412
|
+
const push = function (options = {}) {
|
|
413
|
+
return (0, exports.execCompose)('push', options.ignorePushFailures ? ['--ignore-push-failures'] : [], options);
|
|
414
|
+
};
|
|
415
|
+
exports.push = push;
|
|
416
|
+
const restartAll = function (options) {
|
|
417
|
+
return (0, exports.execCompose)('restart', [], options);
|
|
418
|
+
};
|
|
419
|
+
exports.restartAll = restartAll;
|
|
420
|
+
const restartMany = function (services, options) {
|
|
421
|
+
return (0, exports.execCompose)('restart', services, options);
|
|
422
|
+
};
|
|
423
|
+
exports.restartMany = restartMany;
|
|
424
|
+
const restartOne = function (service, options) {
|
|
425
|
+
return (0, exports.restartMany)([service], options);
|
|
426
|
+
};
|
|
427
|
+
exports.restartOne = restartOne;
|
|
428
|
+
const logs = function (services, options = {}) {
|
|
429
|
+
const args = Array.isArray(services) ? services : [services];
|
|
430
|
+
if (options.follow) {
|
|
431
|
+
args.unshift('--follow');
|
|
432
|
+
}
|
|
433
|
+
if (options.timestamps) {
|
|
434
|
+
args.unshift('--timestamps');
|
|
435
|
+
}
|
|
436
|
+
return (0, exports.execCompose)('logs', args, options);
|
|
437
|
+
};
|
|
438
|
+
exports.logs = logs;
|
|
439
|
+
const port = async function (service, containerPort, options) {
|
|
440
|
+
const args = [service, containerPort];
|
|
441
|
+
try {
|
|
442
|
+
const result = await (0, exports.execCompose)('port', args, options);
|
|
443
|
+
const [address, port] = result.out.split(':');
|
|
444
|
+
return {
|
|
445
|
+
...result,
|
|
446
|
+
data: {
|
|
447
|
+
address,
|
|
448
|
+
port: Number(port)
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
catch (error) {
|
|
453
|
+
return Promise.reject(error);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
exports.port = port;
|
|
457
|
+
const version = async function (options) {
|
|
458
|
+
try {
|
|
459
|
+
const result = await (0, exports.execCompose)('version', ['--short'], options);
|
|
460
|
+
const version = result.out.replace('\n', '').trim();
|
|
461
|
+
return {
|
|
462
|
+
...result,
|
|
463
|
+
data: { version }
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
catch (error) {
|
|
467
|
+
return Promise.reject(error);
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
exports.version = version;
|
|
471
|
+
const stats = async function (service, options) {
|
|
472
|
+
const args = ['--no-stream', '--format', '"{{ json . }}"', service];
|
|
473
|
+
try {
|
|
474
|
+
const result = await (0, exports.execCompose)('stats', args, options);
|
|
475
|
+
// Remove first and last quote from output, as well as newline.
|
|
476
|
+
const output = result.out.replace('\n', '').trim().slice(1, -1);
|
|
477
|
+
return JSON.parse(output);
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
return Promise.reject(error);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
exports.stats = stats;
|
|
484
|
+
exports.default = {
|
|
485
|
+
upAll: exports.upAll,
|
|
486
|
+
upMany: exports.upMany,
|
|
487
|
+
upOne: exports.upOne,
|
|
488
|
+
down: exports.down,
|
|
489
|
+
downAll: exports.downAll,
|
|
490
|
+
downOne: exports.downOne,
|
|
491
|
+
downMany: exports.downMany,
|
|
492
|
+
stop: exports.stop,
|
|
493
|
+
stopOne: exports.stopOne,
|
|
494
|
+
stopMany: exports.stopMany,
|
|
495
|
+
pauseOne: exports.pauseOne,
|
|
496
|
+
unpauseOne: exports.unpauseOne,
|
|
497
|
+
kill: exports.kill,
|
|
498
|
+
rm: exports.rm,
|
|
499
|
+
exec: exports.exec,
|
|
500
|
+
run: exports.run,
|
|
501
|
+
buildAll: exports.buildAll,
|
|
502
|
+
buildMany: exports.buildMany,
|
|
503
|
+
buildOne: exports.buildOne,
|
|
504
|
+
pullAll: exports.pullAll,
|
|
505
|
+
pullMany: exports.pullMany,
|
|
506
|
+
pullOne: exports.pullOne,
|
|
507
|
+
config: exports.config,
|
|
508
|
+
configServices: exports.configServices,
|
|
509
|
+
configVolumes: exports.configVolumes,
|
|
510
|
+
ps: exports.ps,
|
|
511
|
+
push: exports.push,
|
|
512
|
+
restartAll: exports.restartAll,
|
|
513
|
+
restartMany: exports.restartMany,
|
|
514
|
+
restartOne: exports.restartOne,
|
|
515
|
+
logs: exports.logs,
|
|
516
|
+
port: exports.port,
|
|
517
|
+
version: exports.version,
|
|
518
|
+
stats: exports.stats
|
|
519
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mapPorts = (ports) => {
|
|
4
|
+
if (!ports) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return ports.split(',').map((untypedPort) => {
|
|
8
|
+
const exposedFragments = untypedPort.trim().split('->');
|
|
9
|
+
const [port, protocol] = exposedFragments.length === 1
|
|
10
|
+
? exposedFragments[0].split('/')
|
|
11
|
+
: exposedFragments[1].split('/');
|
|
12
|
+
const mapped = exposedFragments[0];
|
|
13
|
+
const lastDoubleColon = mapped.lastIndexOf(':');
|
|
14
|
+
if (lastDoubleColon === -1) {
|
|
15
|
+
return {
|
|
16
|
+
exposed: { port: Number(port), protocol }
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const address = mapped.substr(0, lastDoubleColon);
|
|
20
|
+
const mappedPort = mapped.substr(lastDoubleColon + 1);
|
|
21
|
+
return {
|
|
22
|
+
exposed: { port: Number(port), protocol },
|
|
23
|
+
mapped: { port: Number(mappedPort), address }
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
exports.default = mapPorts;
|
package/package.json
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@depup/docker-compose",
|
|
3
|
+
"version": "1.3.2-depup.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"typings": "dist/index.d.ts",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"ci": "yarn install --frozen-lockfile",
|
|
9
|
+
"test": "npx vitest --dir test --test-timeout=30000",
|
|
10
|
+
"lint": "eslint src/**/*.ts test/**/*.ts",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"release": "yarn build && standard-version"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"url": "git@github.com:PDMLab/docker-compose.git"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://pdmlab.github.io/docker-compose/",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"docker-compose",
|
|
20
|
+
"depup",
|
|
21
|
+
"updated-dependencies",
|
|
22
|
+
"security",
|
|
23
|
+
"latest",
|
|
24
|
+
"patched",
|
|
25
|
+
"devops",
|
|
26
|
+
"devops-tools",
|
|
27
|
+
"docker",
|
|
28
|
+
"test",
|
|
29
|
+
"test-tools"
|
|
30
|
+
],
|
|
31
|
+
"author": "Alexander Zeitler <alexander.zeitler@pdmlab.com>",
|
|
32
|
+
"contributors": [
|
|
33
|
+
{
|
|
34
|
+
"name": "Ignatiev Mikhail"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Ezekiel Warren"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "Palash Mondal"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "lacabra"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "Lance Rutkin"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "MartinJLee"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "Sergey Falinsky"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "Lars Kumbier",
|
|
56
|
+
"url": "https://kumbier.it"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "Paweł Niedzielski"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "Jannis Pohlmann"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "Eduardo Weiland"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "Nacho González Bullón"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "Will O'Beirne"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "Sebastián Balay"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "Gabriel Fürstenheim",
|
|
78
|
+
"url": "https://github.com/furstenheim"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "gautaz"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"license": "MIT",
|
|
85
|
+
"description": "Manage docker-compose from Node.js (with updated dependencies)",
|
|
86
|
+
"devDependencies": {
|
|
87
|
+
"@commitlint/cli": "^20.3.1",
|
|
88
|
+
"@commitlint/config-conventional": "^20.3.1",
|
|
89
|
+
"@types/dockerode": "^2.5.27",
|
|
90
|
+
"@types/node": "^12.12.6",
|
|
91
|
+
"@typescript-eslint/eslint-plugin": "^4.21.0",
|
|
92
|
+
"@typescript-eslint/parser": "^4.21.0",
|
|
93
|
+
"@vitest/ui": "^4.0.18",
|
|
94
|
+
"dockerode": "^4.0.9",
|
|
95
|
+
"eslint": "^7.24.0",
|
|
96
|
+
"eslint-config-prettier": "^8.1.0",
|
|
97
|
+
"eslint-plugin-import": "^2.22.1",
|
|
98
|
+
"eslint-plugin-prettier": "^3.3.1",
|
|
99
|
+
"eslint-watch": "^7.0.0",
|
|
100
|
+
"husky": "^6.0.0",
|
|
101
|
+
"prettier": "^2.2.1",
|
|
102
|
+
"standard-version": "9.5.0",
|
|
103
|
+
"typescript": "^5.0.0",
|
|
104
|
+
"vitest": "^4.0.18"
|
|
105
|
+
},
|
|
106
|
+
"engines": {
|
|
107
|
+
"node": ">= 6.0.0"
|
|
108
|
+
},
|
|
109
|
+
"husky": {
|
|
110
|
+
"hooks": {
|
|
111
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"commitlint": {
|
|
115
|
+
"extends": [
|
|
116
|
+
"@commitlint/config-conventional"
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
"dependencies": {
|
|
120
|
+
"yaml": "^2.8.3"
|
|
121
|
+
},
|
|
122
|
+
"depup": {
|
|
123
|
+
"changes": {
|
|
124
|
+
"yaml": {
|
|
125
|
+
"from": "^2.2.2",
|
|
126
|
+
"to": "^2.8.3"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"depsUpdated": 1,
|
|
130
|
+
"originalPackage": "docker-compose",
|
|
131
|
+
"originalVersion": "1.3.2",
|
|
132
|
+
"processedAt": "2026-03-22T00:39:25.770Z",
|
|
133
|
+
"smokeTest": "passed"
|
|
134
|
+
}
|
|
135
|
+
}
|