build-strap 3.0.0-dev.42 → 4.0.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.
Files changed (130) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -34
  3. package/dist/src/ant.d.ts +19 -0
  4. package/dist/src/ant.js +18 -0
  5. package/dist/src/cert.d.ts +12 -0
  6. package/dist/src/cert.js +91 -0
  7. package/dist/src/clean.d.ts +4 -0
  8. package/dist/src/clean.js +11 -0
  9. package/dist/src/copy.d.ts +7 -0
  10. package/dist/src/copy.js +53 -0
  11. package/dist/src/cp.d.ts +17 -0
  12. package/dist/src/cp.js +88 -0
  13. package/dist/src/docker.container.d.ts +73 -0
  14. package/dist/src/docker.container.js +247 -0
  15. package/dist/src/docker.d.ts +68 -0
  16. package/dist/src/docker.js +188 -0
  17. package/dist/src/docker.network.d.ts +42 -0
  18. package/dist/src/docker.network.js +85 -0
  19. package/dist/src/docker.volume.d.ts +26 -0
  20. package/dist/src/docker.volume.js +62 -0
  21. package/dist/src/dockerCleanup.d.ts +38 -0
  22. package/dist/src/dockerCleanup.js +77 -0
  23. package/dist/src/dockerCompose.d.ts +154 -0
  24. package/dist/src/dockerCompose.js +439 -0
  25. package/dist/src/fs.d.ts +5 -0
  26. package/dist/src/fs.js +38 -0
  27. package/dist/src/git.d.ts +9 -0
  28. package/dist/src/git.js +24 -0
  29. package/dist/src/index.d.ts +20 -0
  30. package/dist/src/index.js +20 -0
  31. package/dist/src/maps.d.ts +33 -0
  32. package/dist/src/maps.js +41 -0
  33. package/dist/src/npm.d.ts +35 -0
  34. package/dist/src/npm.js +104 -0
  35. package/dist/src/pkg.d.ts +33 -0
  36. package/dist/src/pkg.js +33 -0
  37. package/dist/src/publish.d.ts +27 -0
  38. package/dist/src/publish.js +57 -0
  39. package/dist/src/run.d.ts +13 -0
  40. package/dist/src/run.js +44 -0
  41. package/dist/src/tgz.d.ts +13 -0
  42. package/dist/src/tgz.js +67 -0
  43. package/dist/src/version.d.ts +34 -0
  44. package/dist/src/version.js +101 -0
  45. package/dist/src/yarn.d.ts +26 -0
  46. package/dist/src/yarn.js +75 -0
  47. package/package.json +74 -20
  48. package/ant.js +0 -43
  49. package/ant.js.flow +0 -42
  50. package/artifactory.js +0 -617
  51. package/artifactory.js.flow +0 -616
  52. package/cert.conf +0 -20
  53. package/cert.js +0 -153
  54. package/cert.js.flow +0 -152
  55. package/clean.js +0 -20
  56. package/clean.js.flow +0 -19
  57. package/copy.js +0 -80
  58. package/copy.js.flow +0 -79
  59. package/cp.js +0 -173
  60. package/cp.js.flow +0 -172
  61. package/docker.container.js +0 -390
  62. package/docker.container.js.flow +0 -389
  63. package/docker.js +0 -368
  64. package/docker.js.flow +0 -367
  65. package/docker.network.js +0 -160
  66. package/docker.network.js.flow +0 -159
  67. package/docker.volume.js +0 -136
  68. package/docker.volume.js.flow +0 -136
  69. package/dockerCleanup.js +0 -152
  70. package/dockerCleanup.js.flow +0 -151
  71. package/dockerCompose.js +0 -766
  72. package/dockerCompose.js.flow +0 -765
  73. package/flow.js +0 -21
  74. package/flow.js.flow +0 -20
  75. package/fs.js +0 -95
  76. package/fs.js.flow +0 -96
  77. package/git.js +0 -35
  78. package/git.js.flow +0 -34
  79. package/hg.js +0 -35
  80. package/hg.js.flow +0 -34
  81. package/index.js +0 -27
  82. package/index.js.flow +0 -26
  83. package/inline-resources.js +0 -158
  84. package/inline-resources.js.flow +0 -157
  85. package/maps.js +0 -112
  86. package/maps.js.flow +0 -111
  87. package/npm.js +0 -145
  88. package/npm.js.flow +0 -144
  89. package/pkg.js +0 -81
  90. package/pkg.js.flow +0 -80
  91. package/publish.js +0 -145
  92. package/publish.js.flow +0 -144
  93. package/run.js +0 -90
  94. package/run.js.flow +0 -89
  95. package/src/ant.js +0 -42
  96. package/src/artifactory.js +0 -616
  97. package/src/cert.conf +0 -20
  98. package/src/cert.js +0 -152
  99. package/src/clean.js +0 -19
  100. package/src/copy.js +0 -79
  101. package/src/cp.js +0 -172
  102. package/src/docker.container.js +0 -389
  103. package/src/docker.js +0 -367
  104. package/src/docker.network.js +0 -159
  105. package/src/docker.volume.js +0 -136
  106. package/src/dockerCleanup.js +0 -151
  107. package/src/dockerCompose.js +0 -765
  108. package/src/flow.js +0 -20
  109. package/src/fs.js +0 -96
  110. package/src/git.js +0 -34
  111. package/src/hg.js +0 -34
  112. package/src/index.js +0 -26
  113. package/src/inline-resources.js +0 -157
  114. package/src/maps.js +0 -111
  115. package/src/npm.js +0 -144
  116. package/src/pkg.js +0 -80
  117. package/src/publish.js +0 -144
  118. package/src/run.js +0 -89
  119. package/src/test.js +0 -55
  120. package/src/tgz.js +0 -101
  121. package/src/version.js +0 -141
  122. package/src/yarn.js +0 -123
  123. package/test.js +0 -56
  124. package/test.js.flow +0 -55
  125. package/tgz.js +0 -102
  126. package/tgz.js.flow +0 -101
  127. package/version.js +0 -142
  128. package/version.js.flow +0 -141
  129. package/yarn.js +0 -124
  130. package/yarn.js.flow +0 -123
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 Justin Murray
3
+ Copyright (c) 2021 Justin Murray
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # build-strap
2
- A suite of functions to help with writing build scripts using javascript code (which run on node).
2
+ A suite of functions to help with writing build scripts using TypeScript (or javascript) code (which run on node).
3
3
 
4
- This project builds itself, so take a look in the `tools/` folder for an example project. Run `./bs` to build.
4
+ This project builds itself, so take a look in the `targets/` folder for an example. Run `./bs` to build.
5
5
 
6
6
  [![CI Build](https://github.com/murrayju/build-strap/workflows/CI%20Build/badge.svg?branch=master)](https://github.com/murrayju/build-strap/actions?query=workflow%3A%22CI+Build%22)
7
7
  [![version](https://img.shields.io/github/v/tag/murrayju/build-strap.svg?label=version&sort=semver)](https://github.com/murrayju/build-strap/releases/latest)
@@ -41,39 +41,14 @@ By default, the build tools read project-specific configuration from your `packa
41
41
  "npm": {
42
42
  "publish": true,
43
43
  },
44
- "artifactory": {
45
- "root": "https://artifactory.your-company.com/artifactory/",
46
- "path": "com/your-company/your-project-name",
47
- "version-folders": false,
48
- "integration": "integration-repo",
49
- "integration-branch-folders": true,
50
- "integration-days-to-keep": 14,
51
- "integration-max-to-keep": 10,
52
- "release": "releases-repo",
53
- "release-branch": "master",
54
- "npm": "npm-repo",
55
- "npm-clean": "internal-npm-repo"
56
- },
57
44
  "docker": {
58
- "registry": "artifactory.your-company.com",
45
+ "registry": "ghcr.io",
59
46
  "repository": "your-company",
60
47
  "name": "your-project-name"
61
48
  }
62
49
  }
63
50
  }
64
51
  ```
65
- ### artifactory
66
- * **root**: base URL for the artifactory server
67
- * **path**: path to project root in the artifactory tree.
68
- * **version-folders**: if `true`, artifacts will be organized into subfolders for each version number
69
- * **integration**: name of the artifactory repo in which to place integration (not official release) artifacts.
70
- * **integration-branch-folders**: if `true`, artifacts will be organized into subfolders for each branch.
71
- * **integration-days-to-keep**: for artifact cleanup, specifies the max age in days before an artifact will be deleted.
72
- * **integration-max-to-keep**: for artifact cleanup, specifies the maximum number of artifacts to keep, regardless of age. Only the newest N artifacts will be kept.
73
- * **release**: name of the artifactory repo in which to place release artifacts.
74
- * **release-branch**: name of the mercurial branch from which official releases are built/published. Defaults to `master`.
75
- * **npm**: name of the artifactory repo in which to publish npm artifacts.
76
- * **npm-clean**: for artifact cleanup, the name of the artifactory repo used to find and delete old npm artifacts.
77
52
 
78
53
  ### docker
79
54
  * **registry**: base URL for the docker registry, as needed by `docker push`.
@@ -135,9 +110,3 @@ In order to publish to NPM, proper credentials must be provided to the script. B
135
110
  ```
136
111
  { "email": "builder@your-company.com", "username":"builder", "password":"abc123" }
137
112
  ```
138
-
139
- ## Artifactory Credentials
140
- In order to publish and/or delete things from Artifactory, proper credentials must be provided to the script. By default, these are read from the `ARTIFACTORY_CREDS` environment variable, but it is also possible to pass them as an argument to most functions. This is expected to be a JSON encoded string in the following format:
141
- ```
142
- { "email": "builder@your-company.com", "username":"builder", "password":"abc123" }
143
- ```
@@ -0,0 +1,19 @@
1
+ import { SpawnOptions } from './cp.js';
2
+ /**
3
+ * Named value pair to use when configuring an Ant build property
4
+ */
5
+ export interface AntPropertyConfiguration {
6
+ name: string;
7
+ value: string;
8
+ }
9
+ export interface AntSpawnOptions {
10
+ args?: string[];
11
+ properties?: AntPropertyConfiguration[];
12
+ spawnOptions?: SpawnOptions;
13
+ }
14
+ /**
15
+ * Executes the given ant command
16
+ * @param {string} target the ant target to invoke
17
+ * @param {AntSpawnOptions} options
18
+ */
19
+ export declare function ant(target: string, opts?: AntSpawnOptions): Promise<void>;
@@ -0,0 +1,18 @@
1
+ import { spawn } from './cp.js';
2
+ /**
3
+ * Executes the given ant command
4
+ * @param {string} target the ant target to invoke
5
+ * @param {AntSpawnOptions} options
6
+ */
7
+ export async function ant(target, opts) {
8
+ const { properties = [], args = [], spawnOptions } = opts || {};
9
+ await spawn('ant', [
10
+ target,
11
+ ...args,
12
+ ...properties.map(({ name, value }) => `-D${name}=${value}`),
13
+ ], {
14
+ pipeOutput: true,
15
+ stdio: 'inherit',
16
+ ...spawnOptions,
17
+ });
18
+ }
@@ -0,0 +1,12 @@
1
+ export interface CertConfig {
2
+ commonName?: string;
3
+ countryName?: string;
4
+ emailAddress?: string;
5
+ localityName?: string;
6
+ organizationName?: string;
7
+ organizationalUnitName?: string;
8
+ stateOrProvinceName?: string;
9
+ }
10
+ export declare const getCertConfig: () => CertConfig;
11
+ export declare const getIpAddresses: () => string[];
12
+ export declare function generateCert(targetDir: string, force?: boolean): Promise<void>;
@@ -0,0 +1,91 @@
1
+ import fs from 'fs-extra';
2
+ import fetch from 'node-fetch';
3
+ import os from 'os';
4
+ import path from 'path';
5
+ import { spawn } from './cp.js';
6
+ import { readDir } from './fs.js';
7
+ import { getCfg } from './pkg.js';
8
+ import { buildLog } from './run.js';
9
+ export const getCertConfig = () => getCfg().cert ?? {};
10
+ export const getIpAddresses = () => Object.values(os.networkInterfaces()).flatMap((iFaces) => iFaces?.map((iFace) => iFace.address) ?? []);
11
+ // Generate a self-signed certificate (if it doesn't exist)
12
+ export async function generateCert(targetDir, force = process.argv.includes('--force-generateCert')) {
13
+ if (process.argv.includes('--no-generateCert')) {
14
+ buildLog('Skipping due to --no-generateCert');
15
+ return;
16
+ }
17
+ buildLog(`scanning ${targetDir} for certificates...`);
18
+ if (!force &&
19
+ (await readDir(`${targetDir}/server.@(crt|key)`)).length === 2) {
20
+ buildLog('Skipping certificate generation: certificate already exists');
21
+ return;
22
+ }
23
+ buildLog('Generating self-signed certificate...');
24
+ const { commonName = 'app.company.com', countryName = 'US', emailAddress = 'contact@company.com', localityName = 'SomeCity', organizationName = 'Company', organizationalUnitName = 'Product', stateOrProvinceName = 'Pennsylvania', } = getCertConfig();
25
+ const hostname = os.hostname();
26
+ buildLog(`hostname: ${hostname}`);
27
+ const ipAddresses = getIpAddresses();
28
+ buildLog(`ip addresses: ${JSON.stringify(ipAddresses)}`);
29
+ const ifconfig = await fetch('https://ifconfig.co').then((r) => r.json());
30
+ const externalIp4 = ifconfig.ip;
31
+ buildLog(`external ipv4: ${externalIp4}`);
32
+ const dnsName = ifconfig.hostname;
33
+ buildLog(`dnsName: ${dnsName}`);
34
+ await fs.ensureDir(targetDir);
35
+ const keyFile = path.resolve(targetDir, 'server.key');
36
+ const csrFile = path.resolve(targetDir, 'server.csr');
37
+ const crtFile = path.resolve(targetDir, 'server.crt');
38
+ const confTemplateFile = path.resolve(__dirname, 'cert.conf');
39
+ const confFile = path.resolve(targetDir, 'cert.conf.generated');
40
+ const confTemplate = await fs.readFile(confTemplateFile, 'utf8');
41
+ await fs.writeFile(confFile, confTemplate
42
+ .replace('{{countryName}}', countryName)
43
+ .replace('{{stateOrProvinceName}}', stateOrProvinceName)
44
+ .replace('{{localityName}}', localityName)
45
+ .replace('{{organizationName}}', organizationName)
46
+ .replace('{{organizationalUnitName}}', organizationalUnitName)
47
+ .replace('{{commonName}}', commonName)
48
+ .replace('{{emailAddress}}', emailAddress)
49
+ .replace('{{SAN_IP}}', ipAddresses.reduce((acc, next) => `${acc},IP:${next}`, ''))
50
+ .replace('{{SAN_DNS}}', `,DNS:${hostname},DNS:${dnsName}`), 'utf8');
51
+ buildLog('generating key file...');
52
+ await spawn('openssl', [
53
+ 'genpkey',
54
+ '-algorithm',
55
+ 'RSA',
56
+ '-pkeyopt',
57
+ 'rsa_keygen_bits:2048',
58
+ '-out',
59
+ keyFile,
60
+ ], { pipeOutput: true });
61
+ buildLog('generating csr file...');
62
+ await spawn('openssl', [
63
+ 'req',
64
+ '-new',
65
+ '-key',
66
+ keyFile,
67
+ '-out',
68
+ csrFile,
69
+ '-subj',
70
+ `/C=${countryName}/ST=${stateOrProvinceName}/L=${localityName}/O=${organizationName}/OU=${organizationalUnitName}/CN=${commonName}/CN=${externalIp4}/CN=${hostname}/CN=${dnsName}${ipAddresses.reduce((acc, next) => `${acc}/CN=${next}`)}/CN=localhost`,
71
+ '-config',
72
+ confFile,
73
+ ], { pipeOutput: true });
74
+ buildLog('generating cert...');
75
+ await spawn('openssl', [
76
+ 'x509',
77
+ '-req',
78
+ '-days',
79
+ '365',
80
+ '-in',
81
+ csrFile,
82
+ '-signkey',
83
+ keyFile,
84
+ '-out',
85
+ crtFile,
86
+ '-extfile',
87
+ confFile,
88
+ '-extensions',
89
+ 'v3_req',
90
+ ], { pipeOutput: true });
91
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Cleans up the build output directories.
3
+ */
4
+ export declare function clean(globs?: string[]): Promise<void>;
@@ -0,0 +1,11 @@
1
+ import { cleanDir } from './fs.js';
2
+ /**
3
+ * Cleans up the build output directories.
4
+ */
5
+ export async function clean(globs = ['dist/*', 'out/*', 'build/*']) {
6
+ await Promise.all(globs.map((glob) => cleanDir(glob, {
7
+ dot: true,
8
+ ignore: ['.git', '.hg'],
9
+ nosort: true,
10
+ })));
11
+ }
@@ -0,0 +1,7 @@
1
+ export interface CopySrcOptions {
2
+ cbFn?: () => void;
3
+ from: string;
4
+ to: string;
5
+ watch?: boolean;
6
+ }
7
+ export declare function copySrc({ from, to, watch, cbFn, }: CopySrcOptions): Promise<void>;
@@ -0,0 +1,53 @@
1
+ import chokidar from 'chokidar';
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ import { onKillSignal } from './cp.js';
5
+ import { cleanDir, copyDir } from './fs.js';
6
+ import { buildLog } from './run.js';
7
+ let timer = null;
8
+ async function throttledCallback(cbFn) {
9
+ if (!cbFn || typeof cbFn !== 'function') {
10
+ return;
11
+ }
12
+ if (timer) {
13
+ clearTimeout(timer);
14
+ timer = null;
15
+ }
16
+ timer = setTimeout(() => {
17
+ timer = null;
18
+ cbFn();
19
+ }, 200);
20
+ }
21
+ export async function copySrc({ from, to, watch = process.argv.includes('--watch'), cbFn, }) {
22
+ await copyDir(from, to);
23
+ if (cbFn)
24
+ await cbFn();
25
+ if (watch) {
26
+ const watcher = chokidar.watch([path.join(from, '/**/*')], {
27
+ ignoreInitial: true,
28
+ });
29
+ watcher.on('all', async (event, filePath) => {
30
+ const start = new Date();
31
+ const src = path.relative(from, filePath);
32
+ const dest = path.join(to, src);
33
+ switch (event) {
34
+ case 'add':
35
+ case 'change':
36
+ await fs.ensureDir(path.dirname(dest));
37
+ await fs.copyFile(filePath, dest);
38
+ break;
39
+ case 'unlink':
40
+ case 'unlinkDir':
41
+ cleanDir(dest, { dot: true, nosort: true });
42
+ break;
43
+ default:
44
+ return;
45
+ }
46
+ const end = new Date();
47
+ const time = end.getTime() - start.getTime();
48
+ buildLog(`${event} '${dest}' after ${time} ms`, end);
49
+ throttledCallback(cbFn);
50
+ });
51
+ onKillSignal(() => watcher.close());
52
+ }
53
+ }
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" />
2
+ import cp from 'child_process';
3
+ export interface SpawnOptions extends cp.SpawnOptions {
4
+ captureOutput?: boolean;
5
+ pipeOutput?: boolean;
6
+ rejectOnErrorCode?: boolean;
7
+ }
8
+ export interface SpawnResult {
9
+ code: number;
10
+ output: string;
11
+ signal: string;
12
+ stderr: string;
13
+ stdout: string;
14
+ }
15
+ export declare function spawn(command: string, args?: string[], opts?: SpawnOptions | null): Promise<SpawnResult>;
16
+ export declare const exec: typeof cp.exec.__promisify__;
17
+ export declare const onKillSignal: (cbFn: () => void) => void;
package/dist/src/cp.js ADDED
@@ -0,0 +1,88 @@
1
+ import cp from 'child_process';
2
+ import crossSpawn from 'cross-spawn';
3
+ import { promisify } from 'util';
4
+ import { buildLog } from './run.js';
5
+ export async function spawn(command, args, opts) {
6
+ const { captureOutput = false, pipeOutput = false, rejectOnErrorCode = true, ...options } = opts || {};
7
+ return new Promise((resolve, reject) => {
8
+ try {
9
+ const toStr = () => `${command}${args ? ` ${args.join(' ')}` : ''}`;
10
+ const p = crossSpawn(command, args, {
11
+ ...(pipeOutput && !captureOutput ? { stdio: 'inherit' } : {}),
12
+ ...options,
13
+ });
14
+ let output = '';
15
+ let stdout = '';
16
+ let stderr = '';
17
+ if (captureOutput) {
18
+ if (p.stdout) {
19
+ if (pipeOutput) {
20
+ p.stdout.pipe(process.stdout);
21
+ }
22
+ p.stdout.on('data', (d) => {
23
+ const str = d.toString();
24
+ stdout += str;
25
+ output += str;
26
+ });
27
+ }
28
+ else {
29
+ buildLog(`Warning: cannot capture stdout for \`${toStr()}\``);
30
+ }
31
+ if (p.stderr) {
32
+ if (pipeOutput) {
33
+ p.stderr.pipe(process.stderr);
34
+ }
35
+ p.stderr.on('data', (d) => {
36
+ const str = d.toString();
37
+ stderr += str;
38
+ output += str;
39
+ });
40
+ }
41
+ else {
42
+ buildLog(`Warning: cannot capture stderr for \`${toStr()}\``);
43
+ }
44
+ }
45
+ let exitHandled = false;
46
+ const handleExit = (code, signal) => {
47
+ if (!exitHandled) {
48
+ if (rejectOnErrorCode && code) {
49
+ reject(new Error(`${toStr()} => ${code} (error)`));
50
+ }
51
+ else {
52
+ resolve({
53
+ code,
54
+ output,
55
+ signal,
56
+ stderr,
57
+ stdout,
58
+ });
59
+ }
60
+ exitHandled = true;
61
+ }
62
+ };
63
+ p.on('close', handleExit);
64
+ p.on('exit', handleExit);
65
+ // only fires if we failed to spawn
66
+ p.on('error', (err) => {
67
+ // Here we have a workaround that reverses a "feature" of cross-spawn on Windows. See:
68
+ // https://github.com/moxystudio/node-cross-spawn/blob/master/lib/enoent.js#L23
69
+ // https://github.com/moxystudio/node-cross-spawn/issues/104
70
+ if (process.platform === 'win32' &&
71
+ err.code === 'ENOENT' &&
72
+ err.errno === 'ENOENT') {
73
+ handleExit(1, 'ENOENT');
74
+ }
75
+ else {
76
+ reject(err);
77
+ }
78
+ });
79
+ }
80
+ catch (err) {
81
+ reject(err);
82
+ }
83
+ });
84
+ }
85
+ export const exec = promisify(cp.exec);
86
+ export const onKillSignal = (cbFn) => {
87
+ ['SIGINT', 'SIGTERM'].forEach((sig) => process.on(sig, cbFn));
88
+ };
@@ -0,0 +1,73 @@
1
+ import { SpawnOptions } from './cp.js';
2
+ interface DockerContainerInspectOutput {
3
+ State: {
4
+ Running: boolean;
5
+ };
6
+ }
7
+ interface Port {
8
+ dest: number;
9
+ iface: string;
10
+ src: number;
11
+ }
12
+ export interface DockerContainer {
13
+ command: string;
14
+ created: Date;
15
+ exists: () => Promise<boolean>;
16
+ exited: boolean;
17
+ id: string;
18
+ image: string;
19
+ inspect: () => Promise<DockerContainerInspectOutput | undefined>;
20
+ isRunning: () => Promise<boolean>;
21
+ kill: (ignoreError?: boolean) => Promise<void>;
22
+ labels: string[];
23
+ mounts: string[];
24
+ name: string;
25
+ names: string[];
26
+ networks: string[];
27
+ ports: Port[];
28
+ restart: () => Promise<void>;
29
+ rm: (ignoreError?: boolean) => Promise<void>;
30
+ runningFor: string;
31
+ size: number;
32
+ start: () => Promise<void>;
33
+ status: string;
34
+ stop: (ignoreError?: boolean) => Promise<void>;
35
+ teardown: (verbose?: boolean) => Promise<void>;
36
+ }
37
+ interface DockerContainerLsOptions {
38
+ all?: boolean;
39
+ filter?: (container: DockerContainer) => boolean;
40
+ }
41
+ export declare function unthrottledDockerContainerLs({ all, filter, }?: DockerContainerLsOptions): Promise<DockerContainer[]>;
42
+ export declare const dockerContainerLs: (options: DockerContainerLsOptions | undefined) => Promise<DockerContainer[]> | undefined;
43
+ export declare function dockerContainerFind(search: string, options?: DockerContainerLsOptions): Promise<DockerContainer | null>;
44
+ export declare function dockerContainerStop(id: string | string[], ignoreErrors?: boolean): Promise<void>;
45
+ export declare function dockerContainerKill(id: string | string[], ignoreErrors?: boolean): Promise<void>;
46
+ export declare function dockerTryStopContainer(id: string | null, name?: string): Promise<void>;
47
+ export declare function dockerContainerRm(id: string | string[], ignoreErrors?: boolean): Promise<void>;
48
+ export declare function dockerContainerRestart(id: string | string[]): Promise<void>;
49
+ export declare function dockerContainerStart(id: string | string[]): Promise<void>;
50
+ export declare function unthrottledDockerContainerInspect(id: string | string[]): Promise<DockerContainerInspectOutput[]>;
51
+ export declare const dockerContainerInspect: (id: string | string[]) => Promise<DockerContainerInspectOutput[]> | undefined;
52
+ interface DockerContainerRunDaemonArgs {
53
+ cmd?: string[];
54
+ image: string;
55
+ runArgs?: string[];
56
+ waitAttempts?: number;
57
+ waitDuration?: number;
58
+ }
59
+ interface DockerContainerRunArgs extends DockerContainerRunDaemonArgs {
60
+ spawnOptions?: SpawnOptions | null;
61
+ }
62
+ export declare function dockerContainerRun({ image, runArgs, cmd, spawnOptions, }: DockerContainerRunArgs): Promise<string>;
63
+ export declare function dockerContainerRunDaemon({ image, runArgs, cmd, waitAttempts, waitDuration, }: DockerContainerRunDaemonArgs): Promise<DockerContainer>;
64
+ /**
65
+ * Waits for the given container to be fully started. Checks that the container is
66
+ * running, and test with the provided testFn every second until it returns true.
67
+ * @param {DockerContainer} container The container to test
68
+ * @param {Function} testFn A function that validates that the container is ready (e.g. by calling an API on the container)
69
+ * @param {number} timeoutMs The amount of time to wait between attempts.
70
+ * @param {number} maxAttempts The maximum number of attempts before giving up (rejects promise)
71
+ */
72
+ export declare const dockerContainerWaitForStart: (container: DockerContainer, testFn: (container: DockerContainer) => Promise<boolean>, timeoutMs?: number, maxAttempts?: number) => Promise<void>;
73
+ export {};