testcontainers 12.0.1 → 12.0.2

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.
@@ -60,6 +60,7 @@ export declare class GenericContainer implements TestContainer {
60
60
  withNetworkAliases(...networkAliases: string[]): this;
61
61
  withExtraHosts(extraHosts: ExtraHost[]): this;
62
62
  withExposedPorts(...ports: PortWithOptionalBinding[]): this;
63
+ protected hasExposedPort(port: PortWithOptionalBinding): boolean;
63
64
  withBindMounts(bindMounts: BindMount[]): this;
64
65
  withHealthCheck(healthCheck: HealthCheck): this;
65
66
  withStartupTimeout(startupTimeoutMs: number): this;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GenericContainer = void 0;
7
- const archiver_1 = __importDefault(require("archiver"));
7
+ const archiver_1 = require("archiver");
8
8
  const async_lock_1 = __importDefault(require("async-lock"));
9
9
  const fs_1 = require("fs");
10
10
  const common_1 = require("../common");
@@ -186,7 +186,7 @@ class GenericContainer {
186
186
  }
187
187
  }
188
188
  async createArchiveToCopyToContainer() {
189
- const tar = (0, archiver_1.default)("tar");
189
+ const tar = new archiver_1.TarArchive();
190
190
  const filesToCopyWithStats = await Promise.all(this.filesToCopy.map(async (fileToCopy) => ({
191
191
  ...fileToCopy,
192
192
  stats: await fs_1.promises.stat(fileToCopy.source),
@@ -305,6 +305,11 @@ class GenericContainer {
305
305
  };
306
306
  return this;
307
307
  }
308
+ hasExposedPort(port) {
309
+ const containerPort = (0, port_1.getContainerPort)(port);
310
+ const protocol = (0, port_1.getProtocol)(port);
311
+ return Object.hasOwn(this.createOpts.ExposedPorts ?? {}, `${containerPort}/${protocol}`);
312
+ }
308
313
  withBindMounts(bindMounts) {
309
314
  this.hostConfig.Binds = bindMounts
310
315
  .map((bindMount) => ({ mode: "rw", ...bindMount }))
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.StartedGenericContainer = void 0;
7
- const archiver_1 = __importDefault(require("archiver"));
7
+ const archiver_1 = require("archiver");
8
8
  const async_lock_1 = __importDefault(require("async-lock"));
9
9
  const fs_1 = require("fs");
10
10
  const common_1 = require("../common");
@@ -151,7 +151,7 @@ class StartedGenericContainer {
151
151
  async copyFilesToContainer(filesToCopy) {
152
152
  common_1.log.debug(`Copying files to container...`, { containerId: this.container.id });
153
153
  const client = await (0, container_runtime_1.getContainerRuntimeClient)();
154
- const tar = (0, archiver_1.default)("tar");
154
+ const tar = new archiver_1.TarArchive();
155
155
  const filesToCopyWithStats = await Promise.all(filesToCopy.map(async (fileToCopy) => ({
156
156
  ...fileToCopy,
157
157
  stats: await fs_1.promises.stat(fileToCopy.source),
@@ -164,7 +164,7 @@ class StartedGenericContainer {
164
164
  async copyDirectoriesToContainer(directoriesToCopy) {
165
165
  common_1.log.debug(`Copying directories to container...`, { containerId: this.container.id });
166
166
  const client = await (0, container_runtime_1.getContainerRuntimeClient)();
167
- const tar = (0, archiver_1.default)("tar");
167
+ const tar = new archiver_1.TarArchive();
168
168
  directoriesToCopy.forEach(({ source, target }) => tar.directory(source, target));
169
169
  tar.finalize();
170
170
  await client.container.putArchive(this.container, tar, "/");
@@ -173,7 +173,7 @@ class StartedGenericContainer {
173
173
  async copyContentToContainer(contentsToCopy) {
174
174
  common_1.log.debug(`Copying content to container...`, { containerId: this.container.id });
175
175
  const client = await (0, container_runtime_1.getContainerRuntimeClient)();
176
- const tar = (0, archiver_1.default)("tar");
176
+ const tar = new archiver_1.TarArchive();
177
177
  contentsToCopy.forEach(({ content, target, mode }) => tar.append(content, { name: target, mode: mode }));
178
178
  tar.finalize();
179
179
  await client.container.putArchive(this.container, tar, "/");
@@ -49,17 +49,16 @@ class BoundPorts {
49
49
  }
50
50
  filter(ports) {
51
51
  const boundPorts = new BoundPorts();
52
- const containerPortsWithProtocol = new Map();
52
+ const containerPortsWithProtocol = new Set();
53
53
  ports.forEach((port) => {
54
54
  const containerPort = (0, port_1.getContainerPort)(port);
55
- const protocol = (0, port_1.getProtocol)(port);
56
- containerPortsWithProtocol.set(containerPort, protocol);
55
+ const protocol = (0, port_1.getProtocol)(port).toLowerCase();
56
+ containerPortsWithProtocol.add(`${containerPort}/${protocol}`);
57
57
  });
58
58
  for (const [internalPortWithProtocol, hostPort] of this.iterator()) {
59
59
  const [internalPortStr, protocol] = internalPortWithProtocol.split("/");
60
60
  const internalPort = parseInt(internalPortStr, 10);
61
- if (containerPortsWithProtocol.has(internalPort) &&
62
- containerPortsWithProtocol.get(internalPort)?.toLowerCase() === protocol?.toLowerCase()) {
61
+ if (containerPortsWithProtocol.has(`${internalPort}/${protocol?.toLowerCase()}`)) {
63
62
  boundPorts.setBinding(internalPortWithProtocol, hostPort);
64
63
  }
65
64
  }
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "12.0.1";
1
+ export declare const LIB_VERSION = "12.0.2";
package/build/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LIB_VERSION = void 0;
4
- exports.LIB_VERSION = "12.0.1";
4
+ exports.LIB_VERSION = "12.0.2";
@@ -28,6 +28,9 @@ class LogWaitStrategy extends wait_strategy_1.AbstractWaitStrategy {
28
28
  }, this.startupTimeoutMs);
29
29
  const comparisonFn = (line) => {
30
30
  if (this.message instanceof RegExp) {
31
+ if (this.message.global || this.message.sticky) {
32
+ this.message.lastIndex = 0;
33
+ }
31
34
  return this.message.test(line);
32
35
  }
33
36
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testcontainers",
3
- "version": "12.0.1",
3
+ "version": "12.0.2",
4
4
  "author": "Cristian Greco",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@balena/dockerignore": "^1.0.2",
34
34
  "@types/dockerode": "^4.0.1",
35
- "archiver": "^7.0.1",
35
+ "archiver": "^8.0.0",
36
36
  "async-lock": "^1.4.1",
37
37
  "byline": "^5.0.0",
38
38
  "debug": "^4.4.3",
@@ -43,11 +43,11 @@
43
43
  "properties-reader": "^3.0.1",
44
44
  "ssh-remote-port-forward": "^1.0.4",
45
45
  "tar-fs": "^3.1.2",
46
- "tmp": "^0.2.6",
47
- "undici": "^7.25.0"
46
+ "tmp": "^0.2.7",
47
+ "undici": "^8.3.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@types/archiver": "^7.0.0",
50
+ "@types/archiver": "^8.0.0",
51
51
  "@types/async-lock": "^1.4.2",
52
52
  "@types/byline": "^4.2.36",
53
53
  "@types/debug": "^4.1.13",