@augment-vir/node 31.43.2 → 31.44.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 (47) hide show
  1. package/README.md +0 -2
  2. package/dist/file-paths.mock.d.ts +0 -6
  3. package/dist/file-paths.mock.js +0 -6
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.js +0 -1
  6. package/package.json +4 -6
  7. package/src/file-paths.mock.ts +0 -7
  8. package/src/index.ts +0 -1
  9. package/dist/augments/docker.d.ts +0 -92
  10. package/dist/augments/docker.js +0 -87
  11. package/dist/docker/containers/container-info.d.ts +0 -57
  12. package/dist/docker/containers/container-info.js +0 -18
  13. package/dist/docker/containers/container-status.d.ts +0 -32
  14. package/dist/docker/containers/container-status.js +0 -68
  15. package/dist/docker/containers/copy-to-container.d.ts +0 -14
  16. package/dist/docker/containers/copy-to-container.js +0 -10
  17. package/dist/docker/containers/docker-command-inputs.d.ts +0 -74
  18. package/dist/docker/containers/docker-command-inputs.js +0 -45
  19. package/dist/docker/containers/kill-container.d.ts +0 -10
  20. package/dist/docker/containers/kill-container.js +0 -12
  21. package/dist/docker/containers/run-command.d.ts +0 -18
  22. package/dist/docker/containers/run-command.js +0 -24
  23. package/dist/docker/containers/run-container.d.ts +0 -23
  24. package/dist/docker/containers/run-container.js +0 -47
  25. package/dist/docker/containers/run-container.mock.d.ts +0 -2
  26. package/dist/docker/containers/run-container.mock.js +0 -16
  27. package/dist/docker/containers/try-or-kill-container.d.ts +0 -6
  28. package/dist/docker/containers/try-or-kill-container.js +0 -14
  29. package/dist/docker/docker-image.d.ts +0 -9
  30. package/dist/docker/docker-image.js +0 -50
  31. package/dist/docker/docker-startup.d.ts +0 -2
  32. package/dist/docker/docker-startup.js +0 -39
  33. package/dist/docker/run-docker-test.mock.d.ts +0 -2
  34. package/dist/docker/run-docker-test.mock.js +0 -23
  35. package/src/augments/docker.ts +0 -119
  36. package/src/docker/containers/container-info.ts +0 -83
  37. package/src/docker/containers/container-status.ts +0 -110
  38. package/src/docker/containers/copy-to-container.ts +0 -34
  39. package/src/docker/containers/docker-command-inputs.ts +0 -122
  40. package/src/docker/containers/kill-container.ts +0 -25
  41. package/src/docker/containers/run-command.ts +0 -51
  42. package/src/docker/containers/run-container.mock.ts +0 -22
  43. package/src/docker/containers/run-container.ts +0 -92
  44. package/src/docker/containers/try-or-kill-container.ts +0 -18
  45. package/src/docker/docker-image.ts +0 -61
  46. package/src/docker/docker-startup.ts +0 -49
  47. package/src/docker/run-docker-test.mock.ts +0 -26
package/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.
4
4
 
5
- - Includes a custom Prisma API built on its CLI: [`prisma`](https://electrovir.github.io/augment-vir/variables/prisma.html).
6
- - Includes a custom Docker API built on its CLI: [`docker`](https://electrovir.github.io/augment-vir/variables/docker.html).
7
5
  - Includes an easy to use shell script runner: [`runShellCommand`](https://electrovir.github.io/augment-vir/functions/runShellCommand.html).
8
6
  - and much more!
9
7
 
@@ -10,9 +10,3 @@ export declare const workspaceQueryPackageJsonPath: string;
10
10
  export declare const tempWorkspaceQueryFile: string;
11
11
  export declare const recursiveFileReadDir: string;
12
12
  export declare const invalidPackageDirPath: string;
13
- export declare const testPrismaSchemaPath: string;
14
- export declare const testPrismaSchema2Path: string;
15
- export declare const testInvalidPrismaSchemaPath: string;
16
- export declare const testSqliteDbPath: string;
17
- export declare const generatedPrismaClientDirPath: string;
18
- export declare const testPrismaMigrationsDirPath: string;
@@ -12,9 +12,3 @@ export const workspaceQueryPackageJsonPath = join(workspaceQueryDir, 'package.js
12
12
  export const tempWorkspaceQueryFile = join(workspaceQueryDir, 'temp-workspace-query-output.ts');
13
13
  export const recursiveFileReadDir = join(testFilesDir, 'recursive-reading');
14
14
  export const invalidPackageDirPath = join(testFilesDir, 'invalid-package');
15
- export const testPrismaSchemaPath = join(testFilesDir, 'schema.prisma');
16
- export const testPrismaSchema2Path = join(testFilesDir, 'schema2.prisma');
17
- export const testInvalidPrismaSchemaPath = join(testFilesDir, 'invalid-schema.prisma');
18
- export const testSqliteDbPath = join(notCommittedDirPath, 'dev.db');
19
- export const generatedPrismaClientDirPath = join(nodePackageDir, 'node_modules', '.prisma');
20
- export const testPrismaMigrationsDirPath = join(testFilesDir, 'migrations');
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './augments/docker.js';
2
1
  export * from './augments/fs/dir-contents.js';
3
2
  export * from './augments/fs/download.js';
4
3
  export * from './augments/fs/json.js';
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export * from './augments/docker.js';
2
1
  export * from './augments/fs/dir-contents.js';
3
2
  export * from './augments/fs/download.js';
4
3
  export * from './augments/fs/json.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/node",
3
- "version": "31.43.2",
3
+ "version": "31.44.0",
4
4
  "description": "A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.",
5
5
  "keywords": [
6
6
  "augment",
@@ -38,8 +38,8 @@
38
38
  "test:update": "npm test"
39
39
  },
40
40
  "dependencies": {
41
- "@augment-vir/assert": "^31.43.2",
42
- "@augment-vir/common": "^31.43.2",
41
+ "@augment-vir/assert": "^31.44.0",
42
+ "@augment-vir/common": "^31.44.0",
43
43
  "@date-vir/duration": "^8.0.0",
44
44
  "ansi-styles": "^6.2.3",
45
45
  "sanitize-filename": "^1.6.3",
@@ -49,8 +49,7 @@
49
49
  "typed-event-target": "^4.1.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@augment-vir/test": "^31.43.2",
53
- "@prisma/client": "^6.17.1",
52
+ "@augment-vir/test": "^31.44.0",
54
53
  "@types/node": "^24.9.1",
55
54
  "@web/dev-server-esbuild": "^1.0.4",
56
55
  "@web/test-runner": "^0.20.2",
@@ -59,7 +58,6 @@
59
58
  "@web/test-runner-visual-regression": "^0.10.0",
60
59
  "c8": "^10.1.3",
61
60
  "istanbul-smart-text-reporter": "^1.1.5",
62
- "prisma": "^6.17.1",
63
61
  "typescript": "^5.9.3"
64
62
  },
65
63
  "peerDependencies": {
@@ -20,10 +20,3 @@ export const tempWorkspaceQueryFile = join(workspaceQueryDir, 'temp-workspace-qu
20
20
  export const recursiveFileReadDir = join(testFilesDir, 'recursive-reading');
21
21
 
22
22
  export const invalidPackageDirPath = join(testFilesDir, 'invalid-package');
23
-
24
- export const testPrismaSchemaPath = join(testFilesDir, 'schema.prisma');
25
- export const testPrismaSchema2Path = join(testFilesDir, 'schema2.prisma');
26
- export const testInvalidPrismaSchemaPath = join(testFilesDir, 'invalid-schema.prisma');
27
- export const testSqliteDbPath = join(notCommittedDirPath, 'dev.db');
28
- export const generatedPrismaClientDirPath = join(nodePackageDir, 'node_modules', '.prisma');
29
- export const testPrismaMigrationsDirPath = join(testFilesDir, 'migrations');
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './augments/docker.js';
2
1
  export * from './augments/fs/dir-contents.js';
3
2
  export * from './augments/fs/download.js';
4
3
  export * from './augments/fs/json.js';
@@ -1,92 +0,0 @@
1
- import { getContainerInfo } from '../docker/containers/container-info.js';
2
- import { getContainerLogs, getContainerStatus, waitUntilContainerExited, waitUntilContainerRemoved, waitUntilContainerRunning } from '../docker/containers/container-status.js';
3
- import { copyToContainer } from '../docker/containers/copy-to-container.js';
4
- import { makeEnvFlags, makePortMapFlags, makeVolumeFlags } from '../docker/containers/docker-command-inputs.js';
5
- import { killContainer } from '../docker/containers/kill-container.js';
6
- import { runContainerCommand } from '../docker/containers/run-command.js';
7
- import { runContainer } from '../docker/containers/run-container.js';
8
- import { tryOrKillContainer } from '../docker/containers/try-or-kill-container.js';
9
- import { isImageInLocalRegistry, removeImageFromLocalRegistry, updateImage } from '../docker/docker-image.js';
10
- import { isDockerRunning, startDocker } from '../docker/docker-startup.js';
11
- export { type DockerContainerInfo, type DockerContainerInfoState, } from '../docker/containers/container-info.js';
12
- export { DockerContainerStatus, exitedDockerContainerStatuses, } from '../docker/containers/container-status.js';
13
- export { type CopyToDockerContainerParams } from '../docker/containers/copy-to-container.js';
14
- export { type DockerEnvMap, type DockerPortMap, type DockerVolumeMap, type DockerVolumeMappingType, } from '../docker/containers/docker-command-inputs.js';
15
- export { type RunDockerContainerCommandParams } from '../docker/containers/run-command.js';
16
- export { type RunDockerContainerParams } from '../docker/containers/run-container.js';
17
- /**
18
- * Centralized Docker API.
19
- *
20
- * @deprecated Use the [docker-vir](https://www.npmjs.com/package/docker-vir) package instead.
21
- * @category Node : Docker
22
- * @category Package : @augment-vir/node
23
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
24
- */
25
- export declare const docker: {
26
- /** Detects if the Docker service is running. */
27
- isRunning: typeof isDockerRunning;
28
- /**
29
- * Tries to start Docker based ont he current operating system's supported commands. The success
30
- * of this operation is heavily dependent on how you have Docker setup on your system.
31
- */
32
- start: typeof startDocker;
33
- image: {
34
- /** Downloads an image if it is missing from the local registry. */
35
- update: typeof updateImage;
36
- /** Removes an image from the local registry. */
37
- remove: typeof removeImageFromLocalRegistry;
38
- /** Detects if an image exists in the local registry. */
39
- exists: typeof isImageInLocalRegistry;
40
- };
41
- container: {
42
- /**
43
- * Get the current status of a container. If the container does not exist at all, the status
44
- * will be {@link DockerContainerStatus.Removed}.
45
- */
46
- getStatus: typeof getContainerStatus;
47
- /** Wait until a container is running and responsive. */
48
- waitUntilRunning: typeof waitUntilContainerRunning;
49
- /**
50
- * Wait until a container has a status that can be classified as "exited".
51
- *
52
- * @see {@link exitedDockerContainerStatuses}
53
- */
54
- waitUntilExited: typeof waitUntilContainerExited;
55
- /** Wait until a container is completely removed. */
56
- waitUntilRemoved: typeof waitUntilContainerRemoved;
57
- /**
58
- * Runs a callback (which presumably will run a command within the given `containerName`)
59
- * and kills the container if the callback fails.
60
- */
61
- tryOrKill: typeof tryOrKillContainer;
62
- /** Run a container that isn't already running. */
63
- run: typeof runContainer;
64
- /** Kill a container. */
65
- kill: typeof killContainer;
66
- /** Copy a file or directory to a container. */
67
- copyTo: typeof copyToContainer;
68
- /** Run a command on a container that is already running. */
69
- runCommand: typeof runContainerCommand;
70
- /** Run `docker inspect` on a container and return its output. */
71
- getInfo: typeof getContainerInfo;
72
- /** Get a container's logs. */
73
- getLogs: typeof getContainerLogs;
74
- };
75
- util: {
76
- /**
77
- * Manually create a string of volume mapping flags. This is automatically done already
78
- * inside the run container methods.
79
- */
80
- makeVolumeFlags: typeof makeVolumeFlags;
81
- /**
82
- * Manually create a string of port mapping flags. This is automatically done already inside
83
- * the run container methods.
84
- */
85
- makePortMapFlags: typeof makePortMapFlags;
86
- /**
87
- * Manually create a string of env mapping flags. This is automatically done already inside
88
- * the run container methods.
89
- */
90
- makeEnvFlags: typeof makeEnvFlags;
91
- };
92
- };
@@ -1,87 +0,0 @@
1
- import { getContainerInfo } from '../docker/containers/container-info.js';
2
- import { getContainerLogs, getContainerStatus, waitUntilContainerExited, waitUntilContainerRemoved, waitUntilContainerRunning, } from '../docker/containers/container-status.js';
3
- import { copyToContainer } from '../docker/containers/copy-to-container.js';
4
- import { makeEnvFlags, makePortMapFlags, makeVolumeFlags, } from '../docker/containers/docker-command-inputs.js';
5
- import { killContainer } from '../docker/containers/kill-container.js';
6
- import { runContainerCommand } from '../docker/containers/run-command.js';
7
- import { runContainer } from '../docker/containers/run-container.js';
8
- import { tryOrKillContainer } from '../docker/containers/try-or-kill-container.js';
9
- import { isImageInLocalRegistry, removeImageFromLocalRegistry, updateImage, } from '../docker/docker-image.js';
10
- import { isDockerRunning, startDocker } from '../docker/docker-startup.js';
11
- export { DockerContainerStatus, exitedDockerContainerStatuses, } from '../docker/containers/container-status.js';
12
- /**
13
- * Centralized Docker API.
14
- *
15
- * @deprecated Use the [docker-vir](https://www.npmjs.com/package/docker-vir) package instead.
16
- * @category Node : Docker
17
- * @category Package : @augment-vir/node
18
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
19
- */
20
- export const docker = {
21
- /** Detects if the Docker service is running. */
22
- isRunning: isDockerRunning,
23
- /**
24
- * Tries to start Docker based ont he current operating system's supported commands. The success
25
- * of this operation is heavily dependent on how you have Docker setup on your system.
26
- */
27
- start: startDocker,
28
- image: {
29
- /** Downloads an image if it is missing from the local registry. */
30
- update: updateImage,
31
- /** Removes an image from the local registry. */
32
- remove: removeImageFromLocalRegistry,
33
- /** Detects if an image exists in the local registry. */
34
- exists: isImageInLocalRegistry,
35
- },
36
- container: {
37
- /**
38
- * Get the current status of a container. If the container does not exist at all, the status
39
- * will be {@link DockerContainerStatus.Removed}.
40
- */
41
- getStatus: getContainerStatus,
42
- /** Wait until a container is running and responsive. */
43
- waitUntilRunning: waitUntilContainerRunning,
44
- /**
45
- * Wait until a container has a status that can be classified as "exited".
46
- *
47
- * @see {@link exitedDockerContainerStatuses}
48
- */
49
- waitUntilExited: waitUntilContainerExited,
50
- /** Wait until a container is completely removed. */
51
- waitUntilRemoved: waitUntilContainerRemoved,
52
- /**
53
- * Runs a callback (which presumably will run a command within the given `containerName`)
54
- * and kills the container if the callback fails.
55
- */
56
- tryOrKill: tryOrKillContainer,
57
- /** Run a container that isn't already running. */
58
- run: runContainer,
59
- /** Kill a container. */
60
- kill: killContainer,
61
- /** Copy a file or directory to a container. */
62
- copyTo: copyToContainer,
63
- /** Run a command on a container that is already running. */
64
- runCommand: runContainerCommand,
65
- /** Run `docker inspect` on a container and return its output. */
66
- getInfo: getContainerInfo,
67
- /** Get a container's logs. */
68
- getLogs: getContainerLogs,
69
- },
70
- util: {
71
- /**
72
- * Manually create a string of volume mapping flags. This is automatically done already
73
- * inside the run container methods.
74
- */
75
- makeVolumeFlags,
76
- /**
77
- * Manually create a string of port mapping flags. This is automatically done already inside
78
- * the run container methods.
79
- */
80
- makePortMapFlags,
81
- /**
82
- * Manually create a string of env mapping flags. This is automatically done already inside
83
- * the run container methods.
84
- */
85
- makeEnvFlags,
86
- },
87
- };
@@ -1,57 +0,0 @@
1
- import { type JsonCompatibleArray, type JsonCompatibleObject } from '@augment-vir/common';
2
- import { type DockerContainerStatus } from './container-status.js';
3
- /**
4
- * Properties on {@link DockerContainerInfo}.State, retrieved from `docker.container.getInfo()`.
5
- *
6
- * @category Node : Docker : Util
7
- * @category Package : @augment-vir/node
8
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
9
- */
10
- export type DockerContainerInfoState = {
11
- Status: DockerContainerStatus;
12
- Running: boolean;
13
- Paused: boolean;
14
- Restarting: boolean;
15
- OOMKilled: boolean;
16
- Dead: boolean;
17
- Pid: number;
18
- ExitCode: number;
19
- Error: string;
20
- StartedAt: string;
21
- FinishedAt: string;
22
- };
23
- /** This type signature is incomplete. Add to it as necessary. */
24
- /**
25
- * Properties on the output from `docker.container.getInfo()`. Not all these properties are filled
26
- * in all the way, particularly most of properties with nested objects.
27
- *
28
- * @category Node : Docker : Util
29
- * @category Package : @augment-vir/node
30
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
31
- */
32
- export type DockerContainerInfo = Readonly<{
33
- Id: string;
34
- Created: string;
35
- Path: string;
36
- Args: ReadonlyArray<string>;
37
- State: DockerContainerInfoState;
38
- Image: string;
39
- ResolvConfPath: string;
40
- HostnamePath: string;
41
- HostsPath: string;
42
- LogPath: string;
43
- Name: string;
44
- RestartCount: number;
45
- Driver: string;
46
- Platform: string;
47
- MountLabel: string;
48
- ProcessLabel: string;
49
- AppArmorProfile: string;
50
- ExecIDs: unknown;
51
- HostConfig: JsonCompatibleObject;
52
- GraphDriver: JsonCompatibleObject;
53
- Mounts: JsonCompatibleArray;
54
- Config: JsonCompatibleObject;
55
- NetworkSettings: JsonCompatibleObject;
56
- }>;
57
- export declare function getContainerInfo(containerNameOrId: string): Promise<DockerContainerInfo | undefined>;
@@ -1,18 +0,0 @@
1
- import { runShellCommand } from '../../augments/terminal/shell.js';
2
- export async function getContainerInfo(containerNameOrId) {
3
- const command = `docker inspect '${containerNameOrId}'`;
4
- const output = await runShellCommand(command);
5
- if (output.stderr.includes('Error: No such object')) {
6
- return undefined;
7
- }
8
- const parsedOutput = JSON.parse(output.stdout);
9
- /** Edge cases that I don't know how to intentionally trigger. */
10
- /* node:coverage ignore next 5 */
11
- if (parsedOutput.length === 0) {
12
- throw new Error(`Got no output from "${command}"`);
13
- }
14
- else if (parsedOutput.length > 1) {
15
- throw new Error(`Got more than one output from "${command}"`);
16
- }
17
- return parsedOutput[0];
18
- }
@@ -1,32 +0,0 @@
1
- export declare function getContainerLogs(containerNameOrId: string, latestLineCount?: number): Promise<string>;
2
- /**
3
- * All possible statuses for an existing container.
4
- *
5
- * @category Node : Docker : Util
6
- * @category Package : @augment-vir/node
7
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
8
- */
9
- export declare enum DockerContainerStatus {
10
- Created = "created",
11
- Running = "running",
12
- Paused = "paused",
13
- Restarting = "restarting",
14
- Exited = "exited",
15
- Removing = "removing",
16
- Dead = "dead",
17
- /** This is not a native Docker status but indicates that the container does not exist. */
18
- Removed = "removed"
19
- }
20
- /**
21
- * Statuses from {@link DockerContainerStatus} that indicate that a container has been exited in some
22
- * way.
23
- *
24
- * @category Node : Docker : Util
25
- * @category Package : @augment-vir/node
26
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
27
- */
28
- export declare const exitedDockerContainerStatuses: DockerContainerStatus[];
29
- export declare function getContainerStatus(containerNameOrId: string): Promise<DockerContainerStatus>;
30
- export declare function waitUntilContainerRunning(containerNameOrId: string, failureMessage?: string | undefined): Promise<void>;
31
- export declare function waitUntilContainerRemoved(containerNameOrId: string, failureMessage?: string | undefined): Promise<void>;
32
- export declare function waitUntilContainerExited(containerNameOrId: string, failureMessage?: string | undefined): Promise<void>;
@@ -1,68 +0,0 @@
1
- import { assert, waitUntil } from '@augment-vir/assert';
2
- import { runShellCommand } from '../../augments/terminal/shell.js';
3
- export async function getContainerLogs(containerNameOrId, latestLineCount) {
4
- const latestLinesArg = latestLineCount == undefined ? '' : `--tail ${latestLineCount}`;
5
- const logResult = await runShellCommand(`docker logs ${latestLinesArg} '${containerNameOrId}'`, { rejectOnError: true });
6
- return logResult.stdout;
7
- }
8
- /**
9
- * All possible statuses for an existing container.
10
- *
11
- * @category Node : Docker : Util
12
- * @category Package : @augment-vir/node
13
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
14
- */
15
- export var DockerContainerStatus;
16
- (function (DockerContainerStatus) {
17
- DockerContainerStatus["Created"] = "created";
18
- DockerContainerStatus["Running"] = "running";
19
- DockerContainerStatus["Paused"] = "paused";
20
- DockerContainerStatus["Restarting"] = "restarting";
21
- DockerContainerStatus["Exited"] = "exited";
22
- DockerContainerStatus["Removing"] = "removing";
23
- DockerContainerStatus["Dead"] = "dead";
24
- /** This is not a native Docker status but indicates that the container does not exist. */
25
- DockerContainerStatus["Removed"] = "removed";
26
- })(DockerContainerStatus || (DockerContainerStatus = {}));
27
- /**
28
- * Statuses from {@link DockerContainerStatus} that indicate that a container has been exited in some
29
- * way.
30
- *
31
- * @category Node : Docker : Util
32
- * @category Package : @augment-vir/node
33
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
34
- */
35
- export const exitedDockerContainerStatuses = [
36
- DockerContainerStatus.Dead,
37
- DockerContainerStatus.Removed,
38
- DockerContainerStatus.Exited,
39
- ];
40
- export async function getContainerStatus(containerNameOrId) {
41
- const statusResult = await runShellCommand(`docker container inspect -f '{{.State.Status}}' '${containerNameOrId}'`);
42
- if (statusResult.exitCode !== 0) {
43
- return DockerContainerStatus.Removed;
44
- }
45
- const status = statusResult.stdout.trim();
46
- assert.isEnumValue(status, DockerContainerStatus, 'Unexpected container status value');
47
- return status;
48
- }
49
- export async function waitUntilContainerRunning(containerNameOrId, failureMessage) {
50
- await waitUntil.isTrue(async () => {
51
- /** Check if logs can be accessed yet. */
52
- await getContainerLogs(containerNameOrId, 1);
53
- const status = await getContainerStatus(containerNameOrId);
54
- return status === DockerContainerStatus.Running;
55
- }, {}, failureMessage);
56
- }
57
- export async function waitUntilContainerRemoved(containerNameOrId, failureMessage) {
58
- await waitUntil.isTrue(async () => {
59
- const status = await getContainerStatus(containerNameOrId);
60
- return status === DockerContainerStatus.Removed;
61
- }, {}, failureMessage);
62
- }
63
- export async function waitUntilContainerExited(containerNameOrId, failureMessage) {
64
- await waitUntil.isTrue(async () => {
65
- const status = await getContainerStatus(containerNameOrId);
66
- return exitedDockerContainerStatuses.includes(status);
67
- }, {}, failureMessage);
68
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Parameters for `docker.container.copyTo`.
3
- *
4
- * @category Node : Docker : Util
5
- * @category Package : @augment-vir/node
6
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
7
- */
8
- export type CopyToDockerContainerParams = {
9
- hostPath: string;
10
- containerAbsolutePath: string;
11
- containerNameOrId: string;
12
- dockerFlags?: ReadonlyArray<string>;
13
- };
14
- export declare function copyToContainer({ containerAbsolutePath, hostPath, containerNameOrId, dockerFlags, }: CopyToDockerContainerParams): Promise<void>;
@@ -1,10 +0,0 @@
1
- import { addSuffix } from '@augment-vir/common';
2
- import { stat } from 'node:fs/promises';
3
- import { runShellCommand } from '../../augments/terminal/shell.js';
4
- export async function copyToContainer({ containerAbsolutePath, hostPath, containerNameOrId, dockerFlags = [], }) {
5
- const isDir = (await stat(hostPath)).isDirectory();
6
- const suffix = isDir ? '/.' : '';
7
- const fullHostPath = addSuffix({ value: hostPath, suffix });
8
- const extraInputs = dockerFlags.join(' ');
9
- await runShellCommand(`docker cp ${extraInputs} '${fullHostPath}' '${containerNameOrId}:${containerAbsolutePath}'`, { rejectOnError: true });
10
- }
@@ -1,74 +0,0 @@
1
- /**
2
- * Used for `type` in {@link DockerVolumeMap}. These types are apparently only relevant for running
3
- * Docker on macOS and are potentially irrelevant now. It's likely best to leave the `type` property
4
- * empty (`undefined`).
5
- *
6
- * @category Node : Docker : Util
7
- * @category Package : @augment-vir/node
8
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
9
- */
10
- export declare enum DockerVolumeMappingType {
11
- Cached = "cached",
12
- Delegated = "delegated"
13
- }
14
- /**
15
- * A mapping of a single docker volume for mounting host files to a container.
16
- *
17
- * @category Node : Docker : Util
18
- * @category Package : @augment-vir/node
19
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
20
- */
21
- export type DockerVolumeMap = {
22
- hostAbsolutePath: string;
23
- containerAbsolutePath: string;
24
- type?: DockerVolumeMappingType | undefined;
25
- };
26
- export declare function makeVolumeFlags(volumeMapping?: ReadonlyArray<DockerVolumeMap>): string;
27
- /**
28
- * A single docker container port mapping. This is usually used in an array.
29
- *
30
- * @category Node : Docker : Util
31
- * @category Package : @augment-vir/node
32
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
33
- */
34
- export type DockerPortMap = {
35
- hostPort: number;
36
- containerPort: number;
37
- };
38
- /**
39
- * A set of environment mappings for a docker container.
40
- *
41
- * - Each key in this object represents the env var name within the Docker container.
42
- * - Each `value` property can be either the value that the env var should be set to _or_ an existing
43
- * env var's interpolation into the value.
44
- * - If the value string is meant to be interpolated within the shell context, make sure to set
45
- * `allowInterpolation` to `true`. Otherwise, it's best to leave it as `false`.
46
- *
47
- * @category Node : Docker : Util
48
- * @category Package : @augment-vir/node
49
- * @example
50
- *
51
- * ```ts
52
- * const envMapping: DockerEnvMap = {
53
- * VAR_1: {
54
- * value: 'hi',
55
- * // set to false because this is a raw string value that is not meant to be interpolated
56
- * allowInterpolation: false,
57
- * },
58
- * VAR_2: {
59
- * // the value here will be interpolated from the current shell's value for `EXISTING_VAR`
60
- * value: '$EXISTING_VAR',
61
- * // set to true to allow '$EXISTING_VAR' to be interpolated by the shell
62
- * allowInterpolation: true,
63
- * },
64
- * };
65
- * ```
66
- *
67
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
68
- */
69
- export type DockerEnvMap<RequiredKeys extends string = string> = Readonly<Record<RequiredKeys | string, {
70
- value: string;
71
- allowInterpolation: boolean;
72
- }>>;
73
- export declare function makePortMapFlags(portMapping?: ReadonlyArray<DockerPortMap> | undefined): string;
74
- export declare function makeEnvFlags(envMapping?: DockerEnvMap | undefined): string;
@@ -1,45 +0,0 @@
1
- import { wrapString } from '@augment-vir/common';
2
- /**
3
- * Used for `type` in {@link DockerVolumeMap}. These types are apparently only relevant for running
4
- * Docker on macOS and are potentially irrelevant now. It's likely best to leave the `type` property
5
- * empty (`undefined`).
6
- *
7
- * @category Node : Docker : Util
8
- * @category Package : @augment-vir/node
9
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
10
- */
11
- export var DockerVolumeMappingType;
12
- (function (DockerVolumeMappingType) {
13
- DockerVolumeMappingType["Cached"] = "cached";
14
- DockerVolumeMappingType["Delegated"] = "delegated";
15
- })(DockerVolumeMappingType || (DockerVolumeMappingType = {}));
16
- export function makeVolumeFlags(volumeMapping) {
17
- if (!volumeMapping) {
18
- return '';
19
- }
20
- const parts = volumeMapping.map((volume) => {
21
- const mountType = volume.type ? `:${volume.type}` : '';
22
- return `-v '${volume.hostAbsolutePath}':'${volume.containerAbsolutePath}'${mountType}`;
23
- });
24
- return parts.join(' ');
25
- }
26
- export function makePortMapFlags(portMapping) {
27
- if (!portMapping) {
28
- return '';
29
- }
30
- return portMapping
31
- .map((portMap) => {
32
- return `-p ${portMap.hostPort}:${portMap.containerPort}`;
33
- })
34
- .join(' ');
35
- }
36
- export function makeEnvFlags(envMapping) {
37
- if (!envMapping) {
38
- return '';
39
- }
40
- const flags = Object.entries(envMapping).map(([key, { value, allowInterpolation },]) => {
41
- const quote = allowInterpolation ? '"' : "'";
42
- return `-e ${key}=${wrapString({ value, wrapper: quote })}`;
43
- });
44
- return flags.join(' ');
45
- }
@@ -1,10 +0,0 @@
1
- import { type PartialWithUndefined } from '@augment-vir/core';
2
- export declare function killContainer(containerNameOrId: string, options?: PartialWithUndefined<{
3
- /**
4
- * If set to `true`, the container will be killed but won't be removed. (You'll still see it
5
- * in your Docker Dashboard but it'll have a status of exited.)
6
- *
7
- * @default false
8
- */
9
- keepContainer: boolean;
10
- }>): Promise<void>;
@@ -1,12 +0,0 @@
1
- import { runShellCommand } from '../../augments/terminal/shell.js';
2
- import { waitUntilContainerExited, waitUntilContainerRemoved } from './container-status.js';
3
- export async function killContainer(containerNameOrId, options = {}) {
4
- await runShellCommand(`docker kill '${containerNameOrId}'`);
5
- if (options.keepContainer) {
6
- await waitUntilContainerExited(containerNameOrId);
7
- }
8
- else {
9
- await runShellCommand(`docker rm '${containerNameOrId}'`);
10
- await waitUntilContainerRemoved(containerNameOrId);
11
- }
12
- }
@@ -1,18 +0,0 @@
1
- import { type DockerEnvMap } from './docker-command-inputs.js';
2
- /**
3
- * Parameters for `docker.container.runCommand`.
4
- *
5
- * @category Node : Docker : Util
6
- * @category Package : @augment-vir/node
7
- * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
8
- */
9
- export type RunDockerContainerCommandParams = {
10
- /** Creates an interactive shell connection. */
11
- tty?: boolean | undefined;
12
- containerNameOrId: string;
13
- command: string;
14
- envMapping?: DockerEnvMap | undefined;
15
- executionEnv?: Record<string, string> | undefined;
16
- dockerFlags?: ReadonlyArray<string> | undefined;
17
- };
18
- export declare function runContainerCommand({ tty, containerNameOrId, command, envMapping, executionEnv, dockerFlags, }: RunDockerContainerCommandParams): Promise<import("../../augments/terminal/shell.js").ShellOutput>;