build-strap 4.0.0-dev.46 → 4.0.0-dev.54
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 +3 -34
- package/package.json +23 -19
- package/src/ant.d.ts +19 -0
- package/src/ant.js +12 -36
- package/src/cert.d.ts +12 -0
- package/src/cert.js +87 -148
- package/src/clean.d.ts +4 -0
- package/src/clean.js +5 -13
- package/src/copy.d.ts +7 -0
- package/src/copy.js +48 -74
- package/src/cp.d.ts +17 -0
- package/src/cp.js +81 -165
- package/src/docker.container.d.ts +73 -0
- package/src/docker.container.js +208 -350
- package/src/docker.d.ts +68 -0
- package/src/docker.js +163 -339
- package/src/docker.network.d.ts +42 -0
- package/src/docker.network.js +67 -141
- package/src/docker.volume.d.ts +26 -0
- package/src/docker.volume.js +50 -124
- package/src/dockerCleanup.d.ts +38 -0
- package/src/dockerCleanup.js +62 -136
- package/src/dockerCompose.d.ts +154 -0
- package/src/dockerCompose.js +390 -716
- package/src/fs.d.ts +5 -0
- package/src/fs.js +33 -91
- package/src/git.d.ts +9 -0
- package/src/git.js +19 -29
- package/src/index.d.ts +20 -0
- package/src/index.js +20 -26
- package/src/maps.d.ts +33 -0
- package/src/maps.js +12 -82
- package/src/npm.d.ts +48 -0
- package/src/npm.js +128 -131
- package/src/pkg.d.ts +38 -0
- package/src/pkg.js +27 -74
- package/src/publish.d.ts +27 -0
- package/src/publish.js +51 -138
- package/src/run.d.ts +13 -0
- package/src/run.js +39 -84
- package/src/tgz.d.ts +13 -0
- package/src/tgz.js +54 -88
- package/src/version.d.ts +34 -0
- package/src/version.js +85 -126
- package/src/yarn.d.ts +44 -0
- package/src/yarn.js +147 -115
- package/ant.js +0 -43
- package/ant.js.flow +0 -42
- package/artifactory.js +0 -617
- package/artifactory.js.flow +0 -616
- package/cert.conf +0 -20
- package/cert.js +0 -153
- package/cert.js.flow +0 -152
- package/clean.js +0 -20
- package/clean.js.flow +0 -19
- package/copy.js +0 -80
- package/copy.js.flow +0 -79
- package/cp.js +0 -173
- package/cp.js.flow +0 -172
- package/docker.container.js +0 -390
- package/docker.container.js.flow +0 -389
- package/docker.js +0 -365
- package/docker.js.flow +0 -364
- package/docker.network.js +0 -160
- package/docker.network.js.flow +0 -159
- package/docker.volume.js +0 -136
- package/docker.volume.js.flow +0 -136
- package/dockerCleanup.js +0 -152
- package/dockerCleanup.js.flow +0 -151
- package/dockerCompose.js +0 -766
- package/dockerCompose.js.flow +0 -765
- package/flow.js +0 -21
- package/flow.js.flow +0 -20
- package/fs.js +0 -95
- package/fs.js.flow +0 -96
- package/git.js +0 -35
- package/git.js.flow +0 -34
- package/hg.js +0 -35
- package/hg.js.flow +0 -34
- package/index.js +0 -27
- package/index.js.flow +0 -26
- package/inline-resources.js +0 -158
- package/inline-resources.js.flow +0 -157
- package/maps.js +0 -112
- package/maps.js.flow +0 -111
- package/npm.js +0 -145
- package/npm.js.flow +0 -144
- package/pkg.js +0 -81
- package/pkg.js.flow +0 -80
- package/publish.js +0 -145
- package/publish.js.flow +0 -144
- package/run.js +0 -90
- package/run.js.flow +0 -89
- package/src/artifactory.js +0 -616
- package/src/cert.conf +0 -20
- package/src/flow.js +0 -20
- package/src/hg.js +0 -34
- package/src/inline-resources.js +0 -157
- package/src/test.js +0 -55
- package/test.js +0 -56
- package/test.js.flow +0 -55
- package/tgz.js +0 -102
- package/tgz.js.flow +0 -101
- package/version.js +0 -143
- package/version.js.flow +0 -142
- package/yarn.js +0 -124
- package/yarn.js.flow +0 -123
package/src/docker.network.js
CHANGED
|
@@ -1,159 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { parseDockerDate } from './docker';
|
|
5
|
-
|
|
6
|
-
export type DockerNetwork = {|
|
|
7
|
-
id: string,
|
|
8
|
-
name: string,
|
|
9
|
-
driver: string,
|
|
10
|
-
scope: string,
|
|
11
|
-
created: Date,
|
|
12
|
-
IPv6: boolean,
|
|
13
|
-
labels: string[],
|
|
14
|
-
exists: () => Promise<boolean>,
|
|
15
|
-
rm: () => Promise<void>,
|
|
16
|
-
|};
|
|
17
|
-
|
|
18
|
-
type DockerNetworkLsOptions = {
|
|
19
|
-
filter?: (network: DockerNetwork) => boolean,
|
|
20
|
-
};
|
|
21
|
-
|
|
1
|
+
import { throttle } from 'lodash-es';
|
|
2
|
+
import { spawn } from './cp.js';
|
|
3
|
+
import { parseDockerDate } from './docker.js';
|
|
22
4
|
// calling this function in rapid succession can lead to errors.
|
|
23
5
|
// prefer throttled version
|
|
24
|
-
export async function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
6
|
+
export async function unthrottledDockerNetworkLs({ filter, } = {}) {
|
|
7
|
+
return (await spawn('docker', ['network', 'ls', '--format', '{{json .}}'], {
|
|
8
|
+
captureOutput: true,
|
|
9
|
+
})).output
|
|
10
|
+
.split('\n')
|
|
11
|
+
.filter((line) => !!line.trim())
|
|
12
|
+
.map((line) => {
|
|
13
|
+
const { CreatedAt, Driver: driver, ID: id, IPv6, Labels, Name: name, Scope: scope, } = JSON.parse(line.trim());
|
|
14
|
+
return {
|
|
15
|
+
IPv6: IPv6 === 'true',
|
|
16
|
+
created: parseDockerDate(CreatedAt),
|
|
17
|
+
driver,
|
|
18
|
+
exists: async () => !!(await dockerNetworkFind(id)),
|
|
19
|
+
id,
|
|
20
|
+
labels: Labels.split(',').map((l) => l.trim()),
|
|
21
|
+
name,
|
|
22
|
+
rm: async () => dockerNetworkRm(id),
|
|
23
|
+
scope,
|
|
24
|
+
};
|
|
30
25
|
})
|
|
31
|
-
|
|
32
|
-
.split('\n')
|
|
33
|
-
.filter((line) => !!line.trim())
|
|
34
|
-
.map((line) => {
|
|
35
|
-
const {
|
|
36
|
-
ID: id,
|
|
37
|
-
Name: name,
|
|
38
|
-
Driver: driver,
|
|
39
|
-
Scope: scope,
|
|
40
|
-
CreatedAt,
|
|
41
|
-
IPv6,
|
|
42
|
-
Labels,
|
|
43
|
-
} = JSON.parse(line.trim());
|
|
44
|
-
return {
|
|
45
|
-
id,
|
|
46
|
-
name,
|
|
47
|
-
driver,
|
|
48
|
-
scope,
|
|
49
|
-
created: parseDockerDate(CreatedAt),
|
|
50
|
-
IPv6: IPv6 === 'true',
|
|
51
|
-
labels: Labels.split(',').map((l) => l.trim()),
|
|
52
|
-
exists: async () => !!(await dockerNetworkFind(id)),
|
|
53
|
-
rm: async () => dockerNetworkRm(id),
|
|
54
|
-
};
|
|
55
|
-
})
|
|
56
|
-
.filter((n) => n.id && (typeof filter === 'function' ? filter(n) : true));
|
|
26
|
+
.filter((n) => n.id && (typeof filter === 'function' ? filter(n) : true));
|
|
57
27
|
}
|
|
58
|
-
export const dockerNetworkLs
|
|
59
|
-
|
|
60
|
-
) => Promise<DockerNetwork[]> = throttle(_dockerNetworkLs, 500, {
|
|
61
|
-
trailing: false,
|
|
28
|
+
export const dockerNetworkLs = throttle(unthrottledDockerNetworkLs, 500, {
|
|
29
|
+
trailing: false,
|
|
62
30
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
networkName: string,
|
|
66
|
-
options?: DockerNetworkLsOptions,
|
|
67
|
-
): Promise<?DockerNetwork> {
|
|
68
|
-
return (await dockerNetworkLs(options)).find(
|
|
69
|
-
(n) => n.name === networkName || n.id === networkName,
|
|
70
|
-
);
|
|
31
|
+
export async function dockerNetworkFind(networkName, options) {
|
|
32
|
+
return ((await dockerNetworkLs(options))?.find((n) => n.name === networkName || n.id === networkName) || null);
|
|
71
33
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
gateways = [],
|
|
93
|
-
subnets = [],
|
|
94
|
-
auxAddresses = [],
|
|
95
|
-
ingress,
|
|
96
|
-
internal,
|
|
97
|
-
ipv6,
|
|
98
|
-
labels = [],
|
|
99
|
-
}: DockerNetworkCreateOptions = {},
|
|
100
|
-
): Promise<?DockerNetwork> {
|
|
101
|
-
const existing = await dockerNetworkFind(networkName);
|
|
102
|
-
if (existing) return existing;
|
|
103
|
-
await spawn('docker', [
|
|
104
|
-
'network',
|
|
105
|
-
'create',
|
|
106
|
-
...labels.flatMap((l) => ['--label', l]),
|
|
107
|
-
...gateways.flatMap((g) => ['--gateway', g]),
|
|
108
|
-
...subnets.flatMap((s) => ['--subnet', s]),
|
|
109
|
-
...auxAddresses.flatMap((a) => ['--aux-address', a]),
|
|
110
|
-
...(ipRange ? ['--ip-range', ipRange] : []),
|
|
111
|
-
...(ingress ? ['--ingress'] : []),
|
|
112
|
-
...(internal ? ['--internal'] : []),
|
|
113
|
-
...(ipv6 ? ['--ipv6'] : []),
|
|
114
|
-
...(driver ? ['-d', driver] : []),
|
|
115
|
-
...Object.entries(driverOpts).flatMap(([k, v]) => [
|
|
116
|
-
'-o',
|
|
117
|
-
`${k}=${(v: any)}`,
|
|
118
|
-
]),
|
|
119
|
-
networkName,
|
|
120
|
-
]);
|
|
121
|
-
return dockerNetworkFind(networkName);
|
|
34
|
+
export async function dockerNetworkCreate(networkName, { driver, driverOpts = {}, ipRange, gateways = [], subnets = [], auxAddresses = [], ingress, internal, ipv6, labels = [], } = {}) {
|
|
35
|
+
const existing = await dockerNetworkFind(networkName);
|
|
36
|
+
if (existing)
|
|
37
|
+
return existing;
|
|
38
|
+
await spawn('docker', [
|
|
39
|
+
'network',
|
|
40
|
+
'create',
|
|
41
|
+
...labels.flatMap((l) => ['--label', l]),
|
|
42
|
+
...gateways.flatMap((g) => ['--gateway', g]),
|
|
43
|
+
...subnets.flatMap((s) => ['--subnet', s]),
|
|
44
|
+
...auxAddresses.flatMap((a) => ['--aux-address', a]),
|
|
45
|
+
...(ipRange ? ['--ip-range', ipRange] : []),
|
|
46
|
+
...(ingress ? ['--ingress'] : []),
|
|
47
|
+
...(internal ? ['--internal'] : []),
|
|
48
|
+
...(ipv6 ? ['--ipv6'] : []),
|
|
49
|
+
...(driver ? ['-d', driver] : []),
|
|
50
|
+
...Object.entries(driverOpts).flatMap(([k, v]) => ['-o', `${k}=${v}`]),
|
|
51
|
+
networkName,
|
|
52
|
+
]);
|
|
53
|
+
return dockerNetworkFind(networkName);
|
|
122
54
|
}
|
|
123
|
-
|
|
124
55
|
/**
|
|
125
56
|
* Removes a network by id
|
|
126
57
|
* @param {string} id The id of the network
|
|
127
58
|
*/
|
|
128
|
-
export async function dockerNetworkRm(id
|
|
129
|
-
|
|
59
|
+
export async function dockerNetworkRm(id) {
|
|
60
|
+
await spawn('docker', ['network', 'rm', id]);
|
|
130
61
|
}
|
|
131
|
-
|
|
132
62
|
/**
|
|
133
63
|
* Removes all networks with the given name
|
|
134
64
|
* @param {string} networkName The name of the network
|
|
135
65
|
*/
|
|
136
|
-
export async function dockerNetworkDelete(networkName
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
66
|
+
export async function dockerNetworkDelete(networkName) {
|
|
67
|
+
let existing;
|
|
68
|
+
// eslint-disable-next-line no-cond-assign, no-await-in-loop
|
|
69
|
+
while ((existing = await dockerNetworkFind(networkName))) {
|
|
70
|
+
// eslint-disable-next-line no-await-in-loop
|
|
71
|
+
await existing.rm();
|
|
72
|
+
}
|
|
143
73
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
...(alias ? ['--alias', alias] : []),
|
|
156
|
-
net.id,
|
|
157
|
-
containerId,
|
|
158
|
-
]);
|
|
74
|
+
export async function dockerNetworkConnect(networkName, containerId, alias) {
|
|
75
|
+
const net = await dockerNetworkCreate(networkName);
|
|
76
|
+
if (!net)
|
|
77
|
+
throw new Error('Failed to create docker network');
|
|
78
|
+
await spawn('docker', [
|
|
79
|
+
'network',
|
|
80
|
+
'connect',
|
|
81
|
+
...(alias ? ['--alias', alias] : []),
|
|
82
|
+
net.id,
|
|
83
|
+
containerId,
|
|
84
|
+
]);
|
|
159
85
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare type DockerVolumeInspectOutput = Record<string, any>;
|
|
2
|
+
export interface DockerVolume {
|
|
3
|
+
driver: string;
|
|
4
|
+
inspect: () => Promise<null | DockerVolumeInspectOutput>;
|
|
5
|
+
labels: string[];
|
|
6
|
+
mountPoint: string;
|
|
7
|
+
name: string;
|
|
8
|
+
rm: () => Promise<void>;
|
|
9
|
+
scope: string;
|
|
10
|
+
}
|
|
11
|
+
interface DockerVolumeLsOptions {
|
|
12
|
+
filter?: (vol: DockerVolume) => boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function unthrottledDockerVolumeLs({ filter, }?: DockerVolumeLsOptions): Promise<DockerVolume[]>;
|
|
15
|
+
export declare const dockerVolumeLs: (options?: DockerVolumeLsOptions) => undefined | Promise<DockerVolume[]>;
|
|
16
|
+
export declare function dockerVolumeFind(search: string, options?: DockerVolumeLsOptions): Promise<null | DockerVolume>;
|
|
17
|
+
export interface DockerVolumeCreateOptions {
|
|
18
|
+
driver?: string;
|
|
19
|
+
driverOpts?: Record<string, string>;
|
|
20
|
+
labels?: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare function dockerVolumeCreate(name: string, { labels, driver, driverOpts }?: DockerVolumeCreateOptions): Promise<null | DockerVolume>;
|
|
23
|
+
export declare function dockerVolumeRm(id: string | string[], ignoreErrors?: boolean): Promise<void>;
|
|
24
|
+
export declare function unthrottledDockerVolumeInspect(id: string | string[]): Promise<DockerVolumeInspectOutput[]>;
|
|
25
|
+
export declare const dockerVolumeInspect: (id: string | string[]) => undefined | Promise<DockerVolumeInspectOutput[]>;
|
|
26
|
+
export {};
|
package/src/docker.volume.js
CHANGED
|
@@ -1,136 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { spawn } from './cp';
|
|
4
|
-
|
|
5
|
-
type DockerVolumeInspectOutput = {
|
|
6
|
-
[string]: any,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type DockerVolume = {|
|
|
10
|
-
name: string,
|
|
11
|
-
driver: string,
|
|
12
|
-
scope: string,
|
|
13
|
-
labels: string[],
|
|
14
|
-
mountPoint: string,
|
|
15
|
-
inspect: () => Promise<DockerVolumeInspectOutput>,
|
|
16
|
-
rm: () => Promise<void>,
|
|
17
|
-
|};
|
|
18
|
-
|
|
19
|
-
type DockerVolumeLsOptions = {
|
|
20
|
-
filter?: (vol: DockerVolume) => boolean,
|
|
21
|
-
};
|
|
22
|
-
|
|
1
|
+
import { throttle } from 'lodash-es';
|
|
2
|
+
import { spawn } from './cp.js';
|
|
23
3
|
// calling this function in rapid succession can lead to errors.
|
|
24
4
|
// prefer throttled version
|
|
25
|
-
export async function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
export async function unthrottledDockerVolumeLs({ filter, } = {}) {
|
|
6
|
+
return (await spawn('docker', ['volume', 'ls', '--format', '{{json .}}'], {
|
|
7
|
+
captureOutput: true,
|
|
8
|
+
})).output
|
|
9
|
+
.split('\n')
|
|
10
|
+
.filter((line) => !!line.trim())
|
|
11
|
+
.map((line) => {
|
|
12
|
+
const { Driver: driver, Labels, Mountpoint: mountPoint, Name: name, Scope: scope, } = JSON.parse(line.trim());
|
|
13
|
+
return {
|
|
14
|
+
driver,
|
|
15
|
+
inspect: async () => (await dockerVolumeInspect(name))?.[0] || null,
|
|
16
|
+
labels: Labels.split(',').map((l) => l.trim()),
|
|
17
|
+
mountPoint,
|
|
18
|
+
name,
|
|
19
|
+
rm: async () => dockerVolumeRm(name),
|
|
20
|
+
scope,
|
|
21
|
+
};
|
|
31
22
|
})
|
|
32
|
-
|
|
33
|
-
.split('\n')
|
|
34
|
-
.filter((line) => !!line.trim())
|
|
35
|
-
.map((line) => {
|
|
36
|
-
const {
|
|
37
|
-
Name: name,
|
|
38
|
-
Driver: driver,
|
|
39
|
-
Scope: scope,
|
|
40
|
-
Labels,
|
|
41
|
-
Mountpoint: mountPoint,
|
|
42
|
-
} = JSON.parse(line.trim());
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
name,
|
|
46
|
-
driver,
|
|
47
|
-
scope,
|
|
48
|
-
labels: Labels.split(',').map((l) => l.trim()),
|
|
49
|
-
mountPoint,
|
|
50
|
-
inspect: async () => (await dockerVolumeInspect(name))[0],
|
|
51
|
-
rm: async () => dockerVolumeRm(name),
|
|
52
|
-
};
|
|
53
|
-
})
|
|
54
|
-
.filter((v) => v.name && (typeof filter === 'function' ? filter(v) : true));
|
|
23
|
+
.filter((v) => v.name && (typeof filter === 'function' ? filter(v) : true));
|
|
55
24
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
DockerVolumeLsOptions | void,
|
|
59
|
-
) => Promise<DockerVolume[]> = throttle(_dockerVolumeLs, 500, {
|
|
60
|
-
trailing: false,
|
|
25
|
+
export const dockerVolumeLs = throttle(unthrottledDockerVolumeLs, 500, {
|
|
26
|
+
trailing: false,
|
|
61
27
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
search: string,
|
|
65
|
-
options?: DockerVolumeLsOptions,
|
|
66
|
-
): Promise<?DockerVolume> {
|
|
67
|
-
return (await dockerVolumeLs(options)).find(
|
|
68
|
-
(v) => v.name === search || v.name.startsWith(search),
|
|
69
|
-
);
|
|
28
|
+
export async function dockerVolumeFind(search, options) {
|
|
29
|
+
return ((await dockerVolumeLs(options))?.find((v) => v.name === search || v.name.startsWith(search)) ?? null);
|
|
70
30
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
'volume',
|
|
85
|
-
'create',
|
|
86
|
-
...labels.flatMap((l) => ['--label', l]),
|
|
87
|
-
...(driver ? ['-d', driver] : []),
|
|
88
|
-
...Object.entries(driverOpts).flatMap(([k, v]) => [
|
|
89
|
-
'-o',
|
|
90
|
-
`${k}=${(v: any)}`,
|
|
91
|
-
]),
|
|
92
|
-
name,
|
|
93
|
-
]);
|
|
94
|
-
return dockerVolumeFind(name);
|
|
31
|
+
export async function dockerVolumeCreate(name, { labels = [], driver, driverOpts = {} } = {}) {
|
|
32
|
+
const existing = await dockerVolumeFind(name);
|
|
33
|
+
if (existing)
|
|
34
|
+
return existing;
|
|
35
|
+
await spawn('docker', [
|
|
36
|
+
'volume',
|
|
37
|
+
'create',
|
|
38
|
+
...labels.flatMap((l) => ['--label', l]),
|
|
39
|
+
...(driver ? ['-d', driver] : []),
|
|
40
|
+
...Object.entries(driverOpts).flatMap(([k, v]) => ['-o', `${k}=${v}`]),
|
|
41
|
+
name,
|
|
42
|
+
]);
|
|
43
|
+
return dockerVolumeFind(name);
|
|
95
44
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (!ignoreErrors) {
|
|
106
|
-
throw new Error(`Failed to remove volume(s): ${e.message}`);
|
|
45
|
+
export async function dockerVolumeRm(id, ignoreErrors = true) {
|
|
46
|
+
const ids = Array.isArray(id) ? id : [id];
|
|
47
|
+
try {
|
|
48
|
+
await spawn('docker', ['volume', 'rm', ...ids]);
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
if (!ignoreErrors) {
|
|
52
|
+
throw new Error(`Failed to remove volume(s): ${e.message}`);
|
|
53
|
+
}
|
|
107
54
|
}
|
|
108
|
-
}
|
|
109
55
|
}
|
|
110
|
-
|
|
111
56
|
// calling this function in rapid succession can lead to errors.
|
|
112
57
|
// prefer throttled version
|
|
113
|
-
export async function
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const ids = Array.isArray(id) ? id : [id];
|
|
117
|
-
return (
|
|
118
|
-
JSON.parse(
|
|
119
|
-
(
|
|
120
|
-
await spawn(
|
|
121
|
-
'docker',
|
|
122
|
-
['volume', 'inspect', '--format', '{{json .}}', ...ids],
|
|
123
|
-
{ captureOutput: true },
|
|
124
|
-
)
|
|
125
|
-
).trim(),
|
|
126
|
-
) || []
|
|
127
|
-
);
|
|
58
|
+
export async function unthrottledDockerVolumeInspect(id) {
|
|
59
|
+
const ids = Array.isArray(id) ? id : [id];
|
|
60
|
+
return (JSON.parse((await spawn('docker', ['volume', 'inspect', '--format', '{{json .}}', ...ids], { captureOutput: true })).output.trim()) || []);
|
|
128
61
|
}
|
|
129
|
-
|
|
130
|
-
export const dockerVolumeInspect: (
|
|
131
|
-
string | string[],
|
|
132
|
-
) => Promise<DockerVolumeInspectOutput[]> = throttle(
|
|
133
|
-
_dockerVolumeInspect,
|
|
134
|
-
500,
|
|
135
|
-
{ trailing: true },
|
|
136
|
-
);
|
|
62
|
+
export const dockerVolumeInspect = throttle(unthrottledDockerVolumeInspect, 500, { trailing: true });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface CommonDockerCleanupOptions {
|
|
2
|
+
/** print matched items to console instead of deleting */
|
|
3
|
+
dryRun?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Purge stopped containers
|
|
7
|
+
*/
|
|
8
|
+
export declare const dockerContainerCleanup: ({ dryRun, }?: CommonDockerCleanupOptions) => Promise<void>;
|
|
9
|
+
interface DockerImageCleanupOptions extends CommonDockerCleanupOptions {
|
|
10
|
+
/** Image ids known to be produced by this build */
|
|
11
|
+
buildImageIds?: string[];
|
|
12
|
+
/** Explicit image names/ids to delete unconditionally */
|
|
13
|
+
images?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* ignore default exclusions of :latest* and images < 1hr old
|
|
16
|
+
* this will delete all images in the given repos
|
|
17
|
+
*/
|
|
18
|
+
purgeAll?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* looks for other builds of the same repos
|
|
21
|
+
* this will still exclude :latest* and images < 1hr old
|
|
22
|
+
* useful to clean up after past builds that failed to clean themselves properly
|
|
23
|
+
*/
|
|
24
|
+
purgeOld?: boolean;
|
|
25
|
+
/** Image repositories to clean (defaults to the one configured in package.json) */
|
|
26
|
+
repos?: string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Purge docker images created during build process
|
|
30
|
+
*/
|
|
31
|
+
export declare const dockerImageCleanup: ({ repos, buildImageIds, images, purgeAll, purgeOld, dryRun, }?: DockerImageCleanupOptions) => Promise<void>;
|
|
32
|
+
interface DockerCleanupOptions extends DockerImageCleanupOptions, CommonDockerCleanupOptions {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Purge docker images created during build process
|
|
36
|
+
*/
|
|
37
|
+
export declare const dockerCleanup: ({ dryRun, ...rest }?: DockerCleanupOptions) => Promise<void>;
|
|
38
|
+
export default dockerCleanup;
|