@augment-vir/node 31.40.0 → 31.42.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.
- package/dist/augments/docker.d.ts +2 -1
- package/dist/augments/docker.js +2 -1
- package/dist/augments/terminal/shell.js +7 -2
- package/dist/docker/containers/run-container.mock.js +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/scripts/fix-ts-bin.script.js +6 -0
- package/package.json +9 -9
- package/src/augments/docker.ts +2 -1
- package/src/augments/terminal/shell.ts +7 -2
- package/src/docker/containers/run-container.mock.ts +2 -0
- package/src/index.ts +0 -1
- package/src/scripts/fix-ts-bin.script.ts +6 -0
- package/dist/augments/prisma.d.ts +0 -157
- package/dist/augments/prisma.js +0 -156
- package/dist/prisma/disable-ci-env.mock.d.ts +0 -2
- package/dist/prisma/disable-ci-env.mock.js +0 -81
- package/dist/prisma/model-data.d.ts +0 -88
- package/dist/prisma/model-data.js +0 -84
- package/dist/prisma/prisma-client.d.ts +0 -5
- package/dist/prisma/prisma-client.js +0 -25
- package/dist/prisma/prisma-database.d.ts +0 -11
- package/dist/prisma/prisma-database.js +0 -30
- package/dist/prisma/prisma-database.mock.d.ts +0 -1
- package/dist/prisma/prisma-database.mock.js +0 -25
- package/dist/prisma/prisma-errors.d.ts +0 -37
- package/dist/prisma/prisma-errors.js +0 -43
- package/dist/prisma/prisma-migrations.d.ts +0 -24
- package/dist/prisma/prisma-migrations.js +0 -98
- package/dist/prisma/run-prisma-command.d.ts +0 -29
- package/dist/prisma/run-prisma-command.js +0 -67
- package/src/augments/prisma.ts +0 -177
- package/src/prisma/disable-ci-env.mock.ts +0 -88
- package/src/prisma/model-data.ts +0 -252
- package/src/prisma/prisma-client.ts +0 -45
- package/src/prisma/prisma-database.mock.ts +0 -31
- package/src/prisma/prisma-database.ts +0 -60
- package/src/prisma/prisma-errors.ts +0 -45
- package/src/prisma/prisma-migrations.ts +0 -153
- package/src/prisma/run-prisma-command.ts +0 -94
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
2
|
-
|
|
3
|
-
import {log, type PartialWithUndefined, wrapString} from '@augment-vir/common';
|
|
4
|
-
import {dirname} from 'node:path';
|
|
5
|
-
import {interpolationSafeWindowsPath} from '../augments/path/os-path.js';
|
|
6
|
-
import {runShellCommand, type ShellOutput} from '../augments/terminal/shell.js';
|
|
7
|
-
import {PrismaSchemaError} from './prisma-errors.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* All commands in the Prisma CLI that support the `--no-hints` flag, used to turn off ads.
|
|
11
|
-
*
|
|
12
|
-
* @deprecated Use the `prisma-vir` package instead.
|
|
13
|
-
* @category Prisma : Node : Util
|
|
14
|
-
* @category Package : @augment-vir/node
|
|
15
|
-
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
16
|
-
*/
|
|
17
|
-
export const prismaCommandsThatSupportNoHints = ['generate'];
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Directly run a Prisma command.
|
|
21
|
-
*
|
|
22
|
-
* @deprecated Use the `prisma-vir` package instead.
|
|
23
|
-
* @category Prisma : Node : Util
|
|
24
|
-
* @category Package : @augment-vir/node
|
|
25
|
-
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
26
|
-
*/
|
|
27
|
-
export async function runPrismaCommand(
|
|
28
|
-
{
|
|
29
|
-
command,
|
|
30
|
-
ignoreExitCode = false,
|
|
31
|
-
hideLogs = false,
|
|
32
|
-
}: {
|
|
33
|
-
command: string;
|
|
34
|
-
} & PartialWithUndefined<{
|
|
35
|
-
/** If `true`, prevents errors from being thrown if this command exits with a non-0 status. */
|
|
36
|
-
ignoreExitCode: boolean;
|
|
37
|
-
hideLogs: boolean;
|
|
38
|
-
}>,
|
|
39
|
-
/** Set to `undefined` to omit the `--schema` flag. */
|
|
40
|
-
schemaFilePath: string | undefined,
|
|
41
|
-
env: Record<string, string> | undefined = {},
|
|
42
|
-
) {
|
|
43
|
-
const schemaFileArgs = schemaFilePath
|
|
44
|
-
? [
|
|
45
|
-
'--schema',
|
|
46
|
-
wrapString({value: schemaFilePath, wrapper: "'"}),
|
|
47
|
-
]
|
|
48
|
-
: [];
|
|
49
|
-
|
|
50
|
-
/** Disable Prisma's in-CLI ads. */
|
|
51
|
-
const noHintsArg = prismaCommandsThatSupportNoHints.some((commandName) =>
|
|
52
|
-
command.startsWith(commandName),
|
|
53
|
-
)
|
|
54
|
-
? '--no-hints'
|
|
55
|
-
: '';
|
|
56
|
-
|
|
57
|
-
const fullCommand = [
|
|
58
|
-
'prisma',
|
|
59
|
-
command,
|
|
60
|
-
...schemaFileArgs,
|
|
61
|
-
noHintsArg,
|
|
62
|
-
].join(' ');
|
|
63
|
-
|
|
64
|
-
log.faint(`> ${fullCommand}`);
|
|
65
|
-
|
|
66
|
-
const result = await runShellCommand(interpolationSafeWindowsPath(fullCommand), {
|
|
67
|
-
env: {
|
|
68
|
-
...process.env,
|
|
69
|
-
...env,
|
|
70
|
-
},
|
|
71
|
-
hookUpToConsole: !hideLogs,
|
|
72
|
-
cwd: schemaFilePath ? dirname(schemaFilePath) : process.cwd(),
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return verifyOutput(schemaFilePath || '', result, ignoreExitCode);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function verifyOutput(
|
|
79
|
-
schemaFilePath: string,
|
|
80
|
-
shellOutput: Readonly<ShellOutput>,
|
|
81
|
-
ignoreExitCode: boolean,
|
|
82
|
-
) {
|
|
83
|
-
if (shellOutput.stderr.includes('Validation Error Count')) {
|
|
84
|
-
throw new PrismaSchemaError(
|
|
85
|
-
`Invalid schema file at '${schemaFilePath}':\n\n${shellOutput.stderr}`,
|
|
86
|
-
);
|
|
87
|
-
} else if (shellOutput.stderr.includes('does not exist')) {
|
|
88
|
-
throw new PrismaSchemaError(`Database does not exist: ${shellOutput.stderr}`);
|
|
89
|
-
} else if (shellOutput.exitCode === 0 || ignoreExitCode) {
|
|
90
|
-
return shellOutput;
|
|
91
|
-
} else {
|
|
92
|
-
throw new Error(shellOutput.stdout + shellOutput.stderr);
|
|
93
|
-
}
|
|
94
|
-
}
|