@augment-vir/node 30.0.0 → 30.0.1
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 +7 -10
- package/dist/augments/docker.d.ts +49 -2
- package/dist/augments/docker.js +48 -2
- package/dist/augments/fs/download.d.ts +11 -0
- package/dist/augments/{download.js → fs/download.js} +7 -0
- package/dist/augments/fs/json.d.ts +42 -0
- package/dist/augments/fs/json.js +34 -0
- package/dist/augments/fs/read-dir.d.ts +11 -3
- package/dist/augments/fs/read-dir.js +11 -3
- package/dist/augments/fs/read-file.d.ts +8 -0
- package/dist/augments/fs/read-file.js +8 -0
- package/dist/augments/fs/symlink.d.ts +7 -0
- package/dist/augments/fs/symlink.js +7 -0
- package/dist/augments/fs/write.d.ts +4 -0
- package/dist/augments/fs/write.js +4 -0
- package/dist/augments/npm/query-workspace.d.ts +14 -0
- package/dist/augments/npm/query-workspace.js +8 -1
- package/dist/augments/npm/read-package-json.d.ts +9 -0
- package/dist/augments/npm/read-package-json.js +9 -0
- package/dist/augments/os/operating-system.d.ts +15 -0
- package/dist/augments/os/operating-system.js +15 -0
- package/dist/augments/path/ancestor.d.ts +19 -0
- package/dist/augments/path/ancestor.js +28 -0
- package/dist/augments/path/os-path.d.ts +19 -3
- package/dist/augments/path/os-path.js +19 -3
- package/dist/augments/path/root.d.ts +7 -0
- package/dist/augments/path/root.js +7 -0
- package/dist/augments/prisma.d.ts +75 -1
- package/dist/augments/prisma.js +74 -1
- package/dist/augments/terminal/question.d.ts +50 -0
- package/dist/augments/{console → terminal}/question.js +23 -2
- package/dist/augments/{shell.d.ts → terminal/shell.d.ts} +87 -4
- package/dist/augments/{shell.js → terminal/shell.js} +63 -3
- package/dist/docker/containers/container-info.d.ts +35 -6
- package/dist/docker/containers/container-info.js +1 -7
- package/dist/docker/containers/container-status.d.ts +15 -0
- package/dist/docker/containers/container-status.js +16 -1
- package/dist/docker/containers/copy-to-container.d.ts +7 -0
- package/dist/docker/containers/copy-to-container.js +1 -1
- package/dist/docker/containers/docker-command-inputs.d.ts +54 -0
- package/dist/docker/containers/docker-command-inputs.js +9 -0
- package/dist/docker/containers/kill-container.js +1 -1
- package/dist/docker/containers/run-command.d.ts +8 -2
- package/dist/docker/containers/run-command.js +1 -2
- package/dist/docker/containers/run-container.d.ts +7 -0
- package/dist/docker/containers/run-container.js +1 -1
- package/dist/docker/docker-image.js +1 -1
- package/dist/docker/docker-startup.js +1 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/prisma/prisma-client.d.ts +0 -4
- package/dist/prisma/prisma-client.js +0 -4
- package/dist/prisma/prisma-errors.d.ts +25 -0
- package/dist/prisma/prisma-errors.js +25 -0
- package/dist/prisma/prisma-migrations.d.ts +12 -6
- package/dist/prisma/prisma-migrations.js +1 -7
- package/dist/prisma/run-prisma-command.d.ts +1 -1
- package/dist/prisma/run-prisma-command.js +1 -1
- package/package.json +16 -6
- package/dist/augments/console/question.d.ts +0 -14
- package/dist/augments/download.d.ts +0 -4
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { JsonCompatibleArray, JsonCompatibleObject } from '@augment-vir/common';
|
|
2
|
+
import type { DockerContainerStatus } from './container-status.js';
|
|
3
|
+
/**
|
|
4
|
+
* Properties on {@link DockerContainerInfo}.State, retrieved from {@link getContainerInfo}.
|
|
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
|
+
*/
|
|
6
10
|
export type DockerContainerInfoState = {
|
|
7
|
-
Status:
|
|
11
|
+
Status: DockerContainerStatus;
|
|
8
12
|
Running: boolean;
|
|
9
13
|
Paused: boolean;
|
|
10
14
|
Restarting: boolean;
|
|
@@ -17,12 +21,37 @@ export type DockerContainerInfoState = {
|
|
|
17
21
|
FinishedAt: string;
|
|
18
22
|
};
|
|
19
23
|
/** This type signature is incomplete. Add to it as necessary. */
|
|
24
|
+
/**
|
|
25
|
+
* Properties on the output from {@link getContainerInfo}. Not all these properties are filled in all
|
|
26
|
+
* 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
|
+
*/
|
|
20
32
|
export type DockerContainerInfo = Readonly<{
|
|
21
33
|
Id: string;
|
|
22
34
|
Created: string;
|
|
23
35
|
Path: string;
|
|
24
36
|
Args: ReadonlyArray<string>;
|
|
25
37
|
State: DockerContainerInfoState;
|
|
38
|
+
Image: string;
|
|
39
|
+
ResolvConfPath: string;
|
|
40
|
+
HostnamePath: string;
|
|
41
|
+
HostsPath: string;
|
|
42
|
+
LogPath: string;
|
|
26
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;
|
|
27
56
|
}>;
|
|
28
57
|
export declare function getContainerInfo(containerNameOrId: string): Promise<DockerContainerInfo | undefined>;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import { runShellCommand } from '../../augments/shell.js';
|
|
2
|
-
/** There may be other possible values for Status. */
|
|
3
|
-
export var DockerContainerStatusEnum;
|
|
4
|
-
(function (DockerContainerStatusEnum) {
|
|
5
|
-
DockerContainerStatusEnum["exited"] = "exited";
|
|
6
|
-
DockerContainerStatusEnum["running"] = "running";
|
|
7
|
-
})(DockerContainerStatusEnum || (DockerContainerStatusEnum = {}));
|
|
1
|
+
import { runShellCommand } from '../../augments/terminal/shell.js';
|
|
8
2
|
export async function getContainerInfo(containerNameOrId) {
|
|
9
3
|
const command = `docker inspect '${containerNameOrId}'`;
|
|
10
4
|
const output = await runShellCommand(command);
|
|
@@ -1,4 +1,11 @@
|
|
|
1
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
|
+
*/
|
|
2
9
|
export declare enum DockerContainerStatus {
|
|
3
10
|
Created = "created",
|
|
4
11
|
Running = "running",
|
|
@@ -10,6 +17,14 @@ export declare enum DockerContainerStatus {
|
|
|
10
17
|
/** This is not a native Docker status but indicates that the container does not exist. */
|
|
11
18
|
Removed = "removed"
|
|
12
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
|
+
*/
|
|
13
28
|
export declare const exitedDockerContainerStatuses: DockerContainerStatus[];
|
|
14
29
|
export declare function getContainerStatus(containerNameOrId: string): Promise<DockerContainerStatus>;
|
|
15
30
|
export declare function waitUntilContainerRunning(containerNameOrId: string, failureMessage?: string | undefined): Promise<void>;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { assert, waitUntil } from '@augment-vir/assert';
|
|
2
|
-
import { runShellCommand } from '../../augments/shell.js';
|
|
2
|
+
import { runShellCommand } from '../../augments/terminal/shell.js';
|
|
3
3
|
export async function getContainerLogs(containerNameOrId, latestLineCount) {
|
|
4
4
|
const latestLinesArg = latestLineCount == undefined ? '' : `--tail ${latestLineCount}`;
|
|
5
5
|
const logResult = await runShellCommand(`docker logs ${latestLinesArg} '${containerNameOrId}'`, { rejectOnError: true });
|
|
6
6
|
return logResult.stdout;
|
|
7
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
|
+
*/
|
|
8
15
|
export var DockerContainerStatus;
|
|
9
16
|
(function (DockerContainerStatus) {
|
|
10
17
|
DockerContainerStatus["Created"] = "created";
|
|
@@ -17,6 +24,14 @@ export var DockerContainerStatus;
|
|
|
17
24
|
/** This is not a native Docker status but indicates that the container does not exist. */
|
|
18
25
|
DockerContainerStatus["Removed"] = "removed";
|
|
19
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
|
+
*/
|
|
20
35
|
export const exitedDockerContainerStatuses = [
|
|
21
36
|
DockerContainerStatus.Dead,
|
|
22
37
|
DockerContainerStatus.Removed,
|
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
8
|
export type CopyToDockerContainerParams = {
|
|
2
9
|
hostPath: string;
|
|
3
10
|
containerAbsolutePath: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { addSuffix } from '@augment-vir/common';
|
|
2
2
|
import { stat } from 'node:fs/promises';
|
|
3
|
-
import { runShellCommand } from '../../augments/shell.js';
|
|
3
|
+
import { runShellCommand } from '../../augments/terminal/shell.js';
|
|
4
4
|
export async function copyToContainer({ containerAbsolutePath, hostPath, containerNameOrId, dockerFlags = [], }) {
|
|
5
5
|
const isDir = (await stat(hostPath)).isDirectory();
|
|
6
6
|
const suffix = isDir ? '/.' : '';
|
|
@@ -1,17 +1,71 @@
|
|
|
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
|
+
*/
|
|
1
10
|
export declare enum DockerVolumeMappingType {
|
|
2
11
|
Cached = "cached",
|
|
3
12
|
Delegated = "delegated"
|
|
4
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
|
+
*/
|
|
5
21
|
export type DockerVolumeMap = {
|
|
6
22
|
hostAbsolutePath: string;
|
|
7
23
|
containerAbsolutePath: string;
|
|
8
24
|
type?: DockerVolumeMappingType | undefined;
|
|
9
25
|
};
|
|
10
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
|
+
*/
|
|
11
34
|
export type DockerPortMap = {
|
|
12
35
|
hostPort: number;
|
|
13
36
|
containerPort: number;
|
|
14
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
|
+
*/
|
|
15
69
|
export type DockerEnvMap<RequiredKeys extends string = string> = Readonly<Record<RequiredKeys | string, {
|
|
16
70
|
value: string;
|
|
17
71
|
allowInterpolation: boolean;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
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
|
+
*/
|
|
2
11
|
export var DockerVolumeMappingType;
|
|
3
12
|
(function (DockerVolumeMappingType) {
|
|
4
13
|
DockerVolumeMappingType["Cached"] = "cached";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { runShellCommand } from '../../augments/shell.js';
|
|
1
|
+
import { runShellCommand } from '../../augments/terminal/shell.js';
|
|
2
2
|
import { waitUntilContainerExited, waitUntilContainerRemoved } from './container-status.js';
|
|
3
3
|
export async function killContainer(containerNameOrId, options = {}) {
|
|
4
4
|
await runShellCommand(`docker kill '${containerNameOrId}'`);
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { 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
|
+
*/
|
|
2
9
|
export type RunDockerContainerCommandParams = {
|
|
3
10
|
/** Creates an interactive shell connection. */
|
|
4
11
|
tty?: boolean | undefined;
|
|
@@ -8,5 +15,4 @@ export type RunDockerContainerCommandParams = {
|
|
|
8
15
|
executionEnv?: Record<string, string> | undefined;
|
|
9
16
|
dockerFlags?: ReadonlyArray<string> | undefined;
|
|
10
17
|
};
|
|
11
|
-
|
|
12
|
-
export declare function runContainerCommand({ tty, containerNameOrId, command, envMapping, executionEnv, dockerFlags, }: RunDockerContainerCommandParams): Promise<import("../../augments/shell.js").ShellOutput>;
|
|
18
|
+
export declare function runContainerCommand({ tty, containerNameOrId, command, envMapping, executionEnv, dockerFlags, }: RunDockerContainerCommandParams): Promise<import("../../augments/terminal/shell.js").ShellOutput>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
|
-
import { runShellCommand } from '../../augments/shell.js';
|
|
2
|
+
import { runShellCommand } from '../../augments/terminal/shell.js';
|
|
3
3
|
import { makeEnvFlags } from './docker-command-inputs.js';
|
|
4
|
-
/** Run a command on a container that is already running. */
|
|
5
4
|
export async function runContainerCommand({ tty, containerNameOrId, command, envMapping, executionEnv, dockerFlags = [], }) {
|
|
6
5
|
const envFlags = makeEnvFlags(envMapping);
|
|
7
6
|
/** Can't test tty in automated tests. */
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { DockerEnvMap, DockerPortMap, DockerVolumeMap } from './docker-command-inputs.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parameters for `docker.container.run`.
|
|
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
|
+
*/
|
|
2
9
|
export type RunDockerContainerParams = {
|
|
3
10
|
imageName: string;
|
|
4
11
|
detach: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
|
-
import { runShellCommand } from '../../augments/shell.js';
|
|
2
|
+
import { runShellCommand } from '../../augments/terminal/shell.js';
|
|
3
3
|
import { updateImage } from '../docker-image.js';
|
|
4
4
|
import { waitUntilContainerRunning } from './container-status.js';
|
|
5
5
|
import { makeEnvFlags, makePortMapFlags, makeVolumeFlags, } from './docker-command-inputs.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { waitUntil } from '@augment-vir/assert';
|
|
2
2
|
import { currentOperatingSystem, OperatingSystem } from '../augments/os/operating-system.js';
|
|
3
|
-
import { runShellCommand } from '../augments/shell.js';
|
|
3
|
+
import { runShellCommand } from '../augments/terminal/shell.js';
|
|
4
4
|
export async function isDockerRunning() {
|
|
5
5
|
const output = await runShellCommand('docker info');
|
|
6
6
|
return output.exitCode === 0;
|
|
@@ -20,7 +20,6 @@ const startDockerCommands = {
|
|
|
20
20
|
};
|
|
21
21
|
export async function startDocker() {
|
|
22
22
|
const command = startDockerCommands[currentOperatingSystem];
|
|
23
|
-
/** We */
|
|
24
23
|
/* node:coverage disable */
|
|
25
24
|
if (await isDockerRunning()) {
|
|
26
25
|
/** Docker is already running. Nothing to do. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export * from './augments/console/question.js';
|
|
2
1
|
export * from './augments/docker.js';
|
|
3
|
-
export * from './augments/download.js';
|
|
2
|
+
export * from './augments/fs/download.js';
|
|
4
3
|
export * from './augments/fs/json.js';
|
|
5
4
|
export * from './augments/fs/read-dir.js';
|
|
6
5
|
export * from './augments/fs/read-file.js';
|
|
@@ -13,4 +12,5 @@ export * from './augments/path/ancestor.js';
|
|
|
13
12
|
export * from './augments/path/os-path.js';
|
|
14
13
|
export * from './augments/path/root.js';
|
|
15
14
|
export * from './augments/prisma.js';
|
|
16
|
-
export * from './augments/
|
|
15
|
+
export * from './augments/terminal/question.js';
|
|
16
|
+
export * from './augments/terminal/shell.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export * from './augments/console/question.js';
|
|
2
1
|
export * from './augments/docker.js';
|
|
3
|
-
export * from './augments/download.js';
|
|
2
|
+
export * from './augments/fs/download.js';
|
|
4
3
|
export * from './augments/fs/json.js';
|
|
5
4
|
export * from './augments/fs/read-dir.js';
|
|
6
5
|
export * from './augments/fs/read-file.js';
|
|
@@ -13,4 +12,5 @@ export * from './augments/path/ancestor.js';
|
|
|
13
12
|
export * from './augments/path/os-path.js';
|
|
14
13
|
export * from './augments/path/root.js';
|
|
15
14
|
export * from './augments/prisma.js';
|
|
16
|
-
export * from './augments/
|
|
15
|
+
export * from './augments/terminal/question.js';
|
|
16
|
+
export * from './augments/terminal/shell.js';
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runs Prisma generators included in the given Prisma schema (which usually includes the Prisma JS
|
|
3
|
-
* client). This will work even if the database doesn't exist yet.
|
|
4
|
-
*/
|
|
5
1
|
export declare function generatePrismaClient(schemaFilePath: string, env?: Record<string, string>): Promise<void>;
|
|
6
2
|
export declare function isGeneratedPrismaClientCurrent({ jsClientOutputDir, schemaFilePath, }: {
|
|
7
3
|
schemaFilePath: string;
|
|
@@ -3,10 +3,6 @@ import { existsSync } from 'node:fs';
|
|
|
3
3
|
import { readFile } from 'node:fs/promises';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { runPrismaCommand } from './run-prisma-command.js';
|
|
6
|
-
/**
|
|
7
|
-
* Runs Prisma generators included in the given Prisma schema (which usually includes the Prisma JS
|
|
8
|
-
* client). This will work even if the database doesn't exist yet.
|
|
9
|
-
*/
|
|
10
6
|
export async function generatePrismaClient(schemaFilePath, env = {}) {
|
|
11
7
|
await runPrismaCommand({ command: 'generate' }, schemaFilePath, env);
|
|
12
8
|
}
|
|
@@ -1,11 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error thrown by the Prisma API that indicates that something is wrong with the given Prisma
|
|
3
|
+
* schema. See the error message for more details.
|
|
4
|
+
*
|
|
5
|
+
* @category Prisma : Node : Util
|
|
6
|
+
* @category Package : @augment-vir/node
|
|
7
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
8
|
+
*/
|
|
1
9
|
export declare class PrismaSchemaError extends Error {
|
|
2
10
|
readonly name = "PrismaSchemaError";
|
|
3
11
|
constructor(message: string);
|
|
4
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* An error thrown by the Prisma API that indicates that applying migrations in dev failed such that
|
|
15
|
+
* a new migration is needed. You can do that by prompting user for a new migration name and passing
|
|
16
|
+
* it to `prisma.migration.create`.
|
|
17
|
+
*
|
|
18
|
+
* @category Prisma : Node : Util
|
|
19
|
+
* @category Package : @augment-vir/node
|
|
20
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
21
|
+
*/
|
|
5
22
|
export declare class PrismaMigrationNeededError extends Error {
|
|
6
23
|
readonly name = "PrismaMigrationNeededError";
|
|
7
24
|
constructor(schemaFilePath: string);
|
|
8
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* An error thrown by the Prisma API that indicates that applying migrations in dev failed such that
|
|
28
|
+
* the entire database needs to be reset. You can do that by calling `prisma.database.resetDev`.
|
|
29
|
+
*
|
|
30
|
+
* @category Prisma : Node : Util
|
|
31
|
+
* @category Package : @augment-vir/node
|
|
32
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
33
|
+
*/
|
|
9
34
|
export declare class PrismaResetNeededError extends Error {
|
|
10
35
|
readonly name = "PrismaResetNeededError";
|
|
11
36
|
constructor(schemaFilePath: string);
|
|
@@ -1,15 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error thrown by the Prisma API that indicates that something is wrong with the given Prisma
|
|
3
|
+
* schema. See the error message for more details.
|
|
4
|
+
*
|
|
5
|
+
* @category Prisma : Node : Util
|
|
6
|
+
* @category Package : @augment-vir/node
|
|
7
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
8
|
+
*/
|
|
1
9
|
export class PrismaSchemaError extends Error {
|
|
2
10
|
name = 'PrismaSchemaError';
|
|
3
11
|
constructor(message) {
|
|
4
12
|
super(message);
|
|
5
13
|
}
|
|
6
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* An error thrown by the Prisma API that indicates that applying migrations in dev failed such that
|
|
17
|
+
* a new migration is needed. You can do that by prompting user for a new migration name and passing
|
|
18
|
+
* it to `prisma.migration.create`.
|
|
19
|
+
*
|
|
20
|
+
* @category Prisma : Node : Util
|
|
21
|
+
* @category Package : @augment-vir/node
|
|
22
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
23
|
+
*/
|
|
7
24
|
export class PrismaMigrationNeededError extends Error {
|
|
8
25
|
name = 'PrismaMigrationNeededError';
|
|
9
26
|
constructor(schemaFilePath) {
|
|
10
27
|
super(`A new Prisma migration is needed for '${schemaFilePath}'`);
|
|
11
28
|
}
|
|
12
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* An error thrown by the Prisma API that indicates that applying migrations in dev failed such that
|
|
32
|
+
* the entire database needs to be reset. You can do that by calling `prisma.database.resetDev`.
|
|
33
|
+
*
|
|
34
|
+
* @category Prisma : Node : Util
|
|
35
|
+
* @category Package : @augment-vir/node
|
|
36
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
37
|
+
*/
|
|
13
38
|
export class PrismaResetNeededError extends Error {
|
|
14
39
|
name = 'PrismaResetNeededError';
|
|
15
40
|
constructor(schemaFilePath) {
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output of `prisma.migration.status`.
|
|
3
|
+
*
|
|
4
|
+
* @category Prisma : Node : Util
|
|
5
|
+
* @category Package : @augment-vir/node
|
|
6
|
+
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
7
|
+
*/
|
|
1
8
|
export type PrismaMigrationStatus = {
|
|
2
9
|
totalMigrations: number;
|
|
3
10
|
unappliedMigrations: string[];
|
|
4
11
|
};
|
|
5
12
|
export declare function applyPrismaMigrationsToProd(schemaFilePath: string, env?: Record<string, string>): Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
* @throws `PrismaMigrationNeededError` when a new migration is required so the user needs to input
|
|
8
|
-
* a name.
|
|
9
|
-
* @throws `PrismaResetNeededError` when there's a migration mismatch with the database and it needs
|
|
10
|
-
* to be reset.
|
|
11
|
-
*/
|
|
12
13
|
export declare function applyPrismaMigrationsToDev(schemaFilePath: string, env?: Record<string, string>): Promise<void>;
|
|
13
14
|
export declare function getMigrationStatus(schemaFilePath: string, env?: Record<string, string>): Promise<PrismaMigrationStatus>;
|
|
14
15
|
export declare function createPrismaMigration({ migrationName, createOnly, }: {
|
|
15
16
|
migrationName: string;
|
|
17
|
+
/**
|
|
18
|
+
* Set this to `true` to create a new migration without applying it to the database.
|
|
19
|
+
*
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
16
22
|
createOnly?: boolean | undefined;
|
|
17
23
|
}, schemaFilePath: string, env?: Record<string, string>): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { log, safeMatch, toEnsuredNumber } from '@augment-vir/common';
|
|
3
3
|
import terminate from 'terminate';
|
|
4
|
-
import { runShellCommand } from '../augments/shell.js';
|
|
4
|
+
import { runShellCommand } from '../augments/terminal/shell.js';
|
|
5
5
|
import { PrismaMigrationNeededError, PrismaResetNeededError } from './prisma-errors.js';
|
|
6
6
|
import { runPrismaCommand, verifyOutput } from './run-prisma-command.js';
|
|
7
7
|
export async function applyPrismaMigrationsToProd(schemaFilePath, env = {}) {
|
|
@@ -12,12 +12,6 @@ var DbChangeRequired;
|
|
|
12
12
|
DbChangeRequired["MigrationNeeded"] = "migration-needed";
|
|
13
13
|
DbChangeRequired["ResetNeeded"] = "reset-needed";
|
|
14
14
|
})(DbChangeRequired || (DbChangeRequired = {}));
|
|
15
|
-
/**
|
|
16
|
-
* @throws `PrismaMigrationNeededError` when a new migration is required so the user needs to input
|
|
17
|
-
* a name.
|
|
18
|
-
* @throws `PrismaResetNeededError` when there's a migration mismatch with the database and it needs
|
|
19
|
-
* to be reset.
|
|
20
|
-
*/
|
|
21
15
|
export async function applyPrismaMigrationsToDev(schemaFilePath, env = {}) {
|
|
22
16
|
const command = [
|
|
23
17
|
'prisma',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { log } from '@augment-vir/common';
|
|
2
|
-
import { runShellCommand } from '../augments/shell.js';
|
|
2
|
+
import { runShellCommand } from '../augments/terminal/shell.js';
|
|
3
3
|
import { PrismaSchemaError } from './prisma-errors.js';
|
|
4
4
|
const prismaCommandsThatSupportNoHints = [
|
|
5
5
|
'generate',
|
package/package.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/node",
|
|
3
|
-
"version": "30.0.
|
|
3
|
+
"version": "30.0.1",
|
|
4
|
+
"description": "A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"augment",
|
|
7
|
+
"helper",
|
|
8
|
+
"util",
|
|
9
|
+
"node",
|
|
10
|
+
"browser",
|
|
11
|
+
"backend",
|
|
12
|
+
"frontend",
|
|
13
|
+
"vir",
|
|
14
|
+
"augment-vir"
|
|
15
|
+
],
|
|
4
16
|
"homepage": "https://github.com/electrovir/augment-vir",
|
|
5
17
|
"bugs": {
|
|
6
18
|
"url": "https://github.com/electrovir/augment-vir/issues"
|
|
@@ -20,15 +32,13 @@
|
|
|
20
32
|
"types": "dist/index.d.ts",
|
|
21
33
|
"scripts": {
|
|
22
34
|
"compile": "virmator compile",
|
|
23
|
-
"docs": "virmator docs",
|
|
24
35
|
"test": "virmator --no-deps test node --test-concurrency 1",
|
|
25
36
|
"test:coverage": "virmator test node coverage --test-concurrency 1",
|
|
26
|
-
"test:docs": "virmator docs check",
|
|
27
37
|
"test:update": "npm test"
|
|
28
38
|
},
|
|
29
39
|
"dependencies": {
|
|
30
|
-
"@augment-vir/assert": "^30.0.
|
|
31
|
-
"@augment-vir/common": "^30.0.
|
|
40
|
+
"@augment-vir/assert": "^30.0.1",
|
|
41
|
+
"@augment-vir/common": "^30.0.1",
|
|
32
42
|
"@date-vir/duration": "^6.0.0",
|
|
33
43
|
"ansi-styles": "^6.2.1",
|
|
34
44
|
"terminate": "^2.8.0",
|
|
@@ -36,7 +46,7 @@
|
|
|
36
46
|
"typed-event-target": "^3.4.0"
|
|
37
47
|
},
|
|
38
48
|
"devDependencies": {
|
|
39
|
-
"@augment-vir/test": "^30.0.
|
|
49
|
+
"@augment-vir/test": "^30.0.1",
|
|
40
50
|
"@prisma/client": "^5.19.0",
|
|
41
51
|
"@types/node": "^22.5.0",
|
|
42
52
|
"@web/dev-server-esbuild": "^1.0.2",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type AnyDuration } from '@date-vir/duration';
|
|
2
|
-
/** Can't test requiring user input. */
|
|
3
|
-
export type AskQuestionOptions = {
|
|
4
|
-
timeout: AnyDuration;
|
|
5
|
-
hideUserInput: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare function askQuestion(questionToAsk: string, { hideUserInput, timeout, }?: Partial<AskQuestionOptions>): Promise<string>;
|
|
8
|
-
export type QuestionUntilConditionMetConfig = {
|
|
9
|
-
questionToAsk: string;
|
|
10
|
-
conditionCallback: (response: string) => boolean | Promise<boolean>;
|
|
11
|
-
invalidInputMessage: string;
|
|
12
|
-
tryCountMax?: number;
|
|
13
|
-
} & Partial<AskQuestionOptions>;
|
|
14
|
-
export declare function askQuestionUntilConditionMet({ questionToAsk, conditionCallback, invalidInputMessage, tryCountMax, ...options }: QuestionUntilConditionMetConfig): Promise<string>;
|