@augment-vir/node 31.9.1 → 31.9.3
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/fs/dir-contents.js +1 -1
- package/dist/augments/path/resolve-import.js +1 -1
- package/dist/augments/terminal/relevant-args.d.ts +7 -1
- package/dist/augments/terminal/relevant-args.js +7 -1
- package/dist/augments/terminal/run-cli-script.js +5 -1
- package/dist/augments/terminal/shell.js +4 -1
- package/dist/docker/containers/docker-command-inputs.js +1 -1
- package/dist/docker/containers/run-container.mock.js +4 -1
- package/dist/docker/docker-image.js +6 -1
- package/dist/prisma/model-data.js +12 -6
- package/dist/prisma/prisma-migrations.js +7 -2
- package/dist/prisma/run-prisma-command.js +10 -2
- package/package.json +13 -13
- package/src/augments/fs/dir-contents.ts +13 -8
- package/src/augments/path/resolve-import.ts +4 -1
- package/src/augments/terminal/relevant-args.ts +7 -1
- package/src/augments/terminal/run-cli-script.ts +7 -1
- package/src/augments/terminal/shell.ts +4 -1
- package/src/docker/containers/docker-command-inputs.ts +4 -1
- package/src/docker/containers/run-container.mock.ts +4 -1
- package/src/docker/docker-image.ts +6 -1
- package/src/prisma/model-data.ts +52 -39
- package/src/prisma/prisma-migrations.ts +10 -2
- package/src/prisma/run-prisma-command.ts +10 -2
|
@@ -65,7 +65,7 @@ export async function resetDirContents(rootDir, contents) {
|
|
|
65
65
|
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
66
66
|
*/
|
|
67
67
|
export async function writeDirContents(rootDir, contents) {
|
|
68
|
-
await Promise.all(getObjectTypedEntries(contents).map(async ([relativePath, content]) => {
|
|
68
|
+
await Promise.all(getObjectTypedEntries(contents).map(async ([relativePath, content,]) => {
|
|
69
69
|
const fullPath = join(rootDir, relativePath);
|
|
70
70
|
if (check.isString(content)) {
|
|
71
71
|
await writeFileAndDir(fullPath, content);
|
|
@@ -61,7 +61,7 @@ function mapImportPath(importPath, tsconfig, tsconfigPath) {
|
|
|
61
61
|
if (!paths) {
|
|
62
62
|
return importPath;
|
|
63
63
|
}
|
|
64
|
-
const mappedPaths = filterMap(getObjectTypedEntries(paths), ([alias, paths]) => {
|
|
64
|
+
const mappedPaths = filterMap(getObjectTypedEntries(paths), ([alias, paths,]) => {
|
|
65
65
|
const aliasRegex = new RegExp('^' + String(alias).replace(/\*/g, '(.*)') + '$');
|
|
66
66
|
const match = importPath.match(aliasRegex);
|
|
67
67
|
if (!match) {
|
|
@@ -37,7 +37,13 @@ export type RelevantArgsInput = {
|
|
|
37
37
|
*
|
|
38
38
|
* ```ts
|
|
39
39
|
* extractRelevantArgs({
|
|
40
|
-
* rawArgs: [
|
|
40
|
+
* rawArgs: [
|
|
41
|
+
* 'npx',
|
|
42
|
+
* 'ts-node',
|
|
43
|
+
* './my-script.ts',
|
|
44
|
+
* 'arg1',
|
|
45
|
+
* '--arg2',
|
|
46
|
+
* ], // typically will be process.argv
|
|
41
47
|
* binName: 'my-script', // should be your package.json "bin" property name, can be undefined
|
|
42
48
|
* fileName: 'my-script.ts', // should be __filename from the script that will be executed
|
|
43
49
|
* });
|
|
@@ -9,7 +9,13 @@ import { basename } from 'node:path';
|
|
|
9
9
|
*
|
|
10
10
|
* ```ts
|
|
11
11
|
* extractRelevantArgs({
|
|
12
|
-
* rawArgs: [
|
|
12
|
+
* rawArgs: [
|
|
13
|
+
* 'npx',
|
|
14
|
+
* 'ts-node',
|
|
15
|
+
* './my-script.ts',
|
|
16
|
+
* 'arg1',
|
|
17
|
+
* '--arg2',
|
|
18
|
+
* ], // typically will be process.argv
|
|
13
19
|
* binName: 'my-script', // should be your package.json "bin" property name, can be undefined
|
|
14
20
|
* fileName: 'my-script.ts', // should be __filename from the script that will be executed
|
|
15
21
|
* });
|
|
@@ -51,7 +51,11 @@ binName) {
|
|
|
51
51
|
binName: runner.npx,
|
|
52
52
|
startPath: dirname(cliScriptFilePath),
|
|
53
53
|
}) || runner.npx;
|
|
54
|
-
const results = await runShellCommand(interpolationSafeWindowsPath([
|
|
54
|
+
const results = await runShellCommand(interpolationSafeWindowsPath([
|
|
55
|
+
runnerPath,
|
|
56
|
+
scriptPath,
|
|
57
|
+
...args,
|
|
58
|
+
].join(' ')), {
|
|
55
59
|
hookUpToConsole: true,
|
|
56
60
|
});
|
|
57
61
|
process.exit(results.exitCode || 0);
|
|
@@ -169,7 +169,10 @@ export async function runShellCommand(command, options = {}) {
|
|
|
169
169
|
}
|
|
170
170
|
/* node:coverage enable */
|
|
171
171
|
shellTarget.destroy();
|
|
172
|
-
const rejectionErrorMessage = combineErrors([
|
|
172
|
+
const rejectionErrorMessage = combineErrors([
|
|
173
|
+
new Error(stderr),
|
|
174
|
+
...errors,
|
|
175
|
+
]);
|
|
173
176
|
/** Reject now because the "done" listener won't get fired after killing the process. */
|
|
174
177
|
reject(rejectionErrorMessage);
|
|
175
178
|
});
|
|
@@ -37,7 +37,7 @@ export function makeEnvFlags(envMapping) {
|
|
|
37
37
|
if (!envMapping) {
|
|
38
38
|
return '';
|
|
39
39
|
}
|
|
40
|
-
const flags = Object.entries(envMapping).map(([key, { value, allowInterpolation }]) => {
|
|
40
|
+
const flags = Object.entries(envMapping).map(([key, { value, allowInterpolation },]) => {
|
|
41
41
|
const quote = allowInterpolation ? '"' : "'";
|
|
42
42
|
return `-e ${key}=${wrapString({ value, wrapper: quote })}`;
|
|
43
43
|
});
|
|
@@ -4,7 +4,10 @@ export async function runMockLongLivingContainer(containerName, args = {}) {
|
|
|
4
4
|
containerName: containerName,
|
|
5
5
|
detach: true,
|
|
6
6
|
imageName: 'alpine:3.20.2',
|
|
7
|
-
dockerFlags: [
|
|
7
|
+
dockerFlags: [
|
|
8
|
+
'-i',
|
|
9
|
+
'-t',
|
|
10
|
+
],
|
|
8
11
|
command: 'sh',
|
|
9
12
|
platform: 'amd64',
|
|
10
13
|
...args,
|
|
@@ -11,7 +11,12 @@ imageName, platform) {
|
|
|
11
11
|
const command = [
|
|
12
12
|
'docker',
|
|
13
13
|
'pull',
|
|
14
|
-
...(platform
|
|
14
|
+
...(platform
|
|
15
|
+
? [
|
|
16
|
+
'--platform',
|
|
17
|
+
platform,
|
|
18
|
+
]
|
|
19
|
+
: []),
|
|
15
20
|
wrapString({ value: imageName, wrapper: "'" }),
|
|
16
21
|
].join(' ');
|
|
17
22
|
await runShellCommand(command, {
|
|
@@ -8,11 +8,11 @@ export async function addData(prismaClient, data) {
|
|
|
8
8
|
}
|
|
9
9
|
async function addModelDataObject(prismaClient, data) {
|
|
10
10
|
/** Add the mock data to the mock prisma client. */
|
|
11
|
-
await awaitedForEach(getObjectTypedEntries(data), async ([modelName, mockData]) => {
|
|
11
|
+
await awaitedForEach(getObjectTypedEntries(data), async ([modelName, mockData,]) => {
|
|
12
12
|
/**
|
|
13
|
-
* This type is dumbed down to just `AnyObject[]` because the union of all possible
|
|
14
|
-
* data is just way too big (and not helpful as the inputs to this function are
|
|
15
|
-
* guarded).
|
|
13
|
+
* This type is dumbed down to just `AnyObject[]` because the union of all possible
|
|
14
|
+
* model data is just way too big (and not helpful as the inputs to this function are
|
|
15
|
+
* already type guarded).
|
|
16
16
|
*/
|
|
17
17
|
const mockModelInstances = Array.isArray(mockData)
|
|
18
18
|
? mockData
|
|
@@ -37,10 +37,16 @@ async function addModelDataObject(prismaClient, data) {
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
const prismockKeys = [
|
|
40
|
+
const prismockKeys = [
|
|
41
|
+
'getData',
|
|
42
|
+
'setData',
|
|
43
|
+
];
|
|
41
44
|
export function getAllPrismaModelNames(prismaClient) {
|
|
42
45
|
return Object.keys(prismaClient)
|
|
43
|
-
.filter((key) => !key.startsWith('$') &&
|
|
46
|
+
.filter((key) => !key.startsWith('$') &&
|
|
47
|
+
!key.startsWith('_') &&
|
|
48
|
+
!prismockKeys.includes(key) &&
|
|
49
|
+
key !== 'constructor')
|
|
44
50
|
.sort();
|
|
45
51
|
}
|
|
46
52
|
const defaultPrismaDumpDataOptions = {
|
|
@@ -13,7 +13,12 @@ var DbChangeRequired;
|
|
|
13
13
|
DbChangeRequired["ResetNeeded"] = "reset-needed";
|
|
14
14
|
})(DbChangeRequired || (DbChangeRequired = {}));
|
|
15
15
|
export async function applyPrismaMigrationsToDev(schemaFilePath, env = {}) {
|
|
16
|
-
const command = [
|
|
16
|
+
const command = [
|
|
17
|
+
'prisma',
|
|
18
|
+
'migrate',
|
|
19
|
+
'dev',
|
|
20
|
+
`--schema='${schemaFilePath}'`,
|
|
21
|
+
].join(' ');
|
|
17
22
|
log.faint(`> ${command}`);
|
|
18
23
|
let dbRequirement = undefined;
|
|
19
24
|
const result = await runShellCommand(command, {
|
|
@@ -71,7 +76,7 @@ export async function getMigrationStatus(schemaFilePath, env = {}) {
|
|
|
71
76
|
foundNotAppliedMigrations = true;
|
|
72
77
|
}
|
|
73
78
|
else {
|
|
74
|
-
const [, countMatch] = safeMatch(line, /^([\d,]+) migrations? found in/);
|
|
79
|
+
const [, countMatch,] = safeMatch(line, /^([\d,]+) migrations? found in/);
|
|
75
80
|
if (countMatch) {
|
|
76
81
|
listedMigrations.totalMigrations = toEnsuredNumber(countMatch);
|
|
77
82
|
}
|
|
@@ -8,13 +8,21 @@ export async function runPrismaCommand({ command, ignoreExitCode = false, },
|
|
|
8
8
|
/** Set to `undefined` to omit the `--schema` flag. */
|
|
9
9
|
schemaFilePath, env = {}) {
|
|
10
10
|
const schemaFileArgs = schemaFilePath
|
|
11
|
-
? [
|
|
11
|
+
? [
|
|
12
|
+
'--schema',
|
|
13
|
+
wrapString({ value: schemaFilePath, wrapper: "'" }),
|
|
14
|
+
]
|
|
12
15
|
: [];
|
|
13
16
|
/** Disable Prisma's in-CLI ads. */
|
|
14
17
|
const noHintsArg = prismaCommandsThatSupportNoHints.some((commandName) => command.startsWith(commandName))
|
|
15
18
|
? '--no-hints'
|
|
16
19
|
: '';
|
|
17
|
-
const fullCommand = [
|
|
20
|
+
const fullCommand = [
|
|
21
|
+
'prisma',
|
|
22
|
+
command,
|
|
23
|
+
...schemaFileArgs,
|
|
24
|
+
noHintsArg,
|
|
25
|
+
].join(' ');
|
|
18
26
|
log.faint(`> ${fullCommand}`);
|
|
19
27
|
const result = await runShellCommand(interpolationSafeWindowsPath(fullCommand), {
|
|
20
28
|
env: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/node",
|
|
3
|
-
"version": "31.9.
|
|
3
|
+
"version": "31.9.3",
|
|
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",
|
|
@@ -37,29 +37,29 @@
|
|
|
37
37
|
"test:update": "npm test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@augment-vir/assert": "^31.9.
|
|
41
|
-
"@augment-vir/common": "^31.9.
|
|
42
|
-
"@date-vir/duration": "^7.1
|
|
40
|
+
"@augment-vir/assert": "^31.9.3",
|
|
41
|
+
"@augment-vir/common": "^31.9.3",
|
|
42
|
+
"@date-vir/duration": "^7.2.1",
|
|
43
43
|
"ansi-styles": "^6.2.1",
|
|
44
44
|
"terminate": "^2.8.0",
|
|
45
|
-
"tsx": "^4.19.
|
|
46
|
-
"type-fest": "^4.
|
|
45
|
+
"tsx": "^4.19.3",
|
|
46
|
+
"type-fest": "^4.37.0",
|
|
47
47
|
"typed-event-target": "^4.0.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@augment-vir/test": "^31.9.
|
|
51
|
-
"@prisma/client": "^6.
|
|
52
|
-
"@types/node": "^22.13.
|
|
53
|
-
"@web/dev-server-esbuild": "^1.0.
|
|
54
|
-
"@web/test-runner": "^0.
|
|
50
|
+
"@augment-vir/test": "^31.9.3",
|
|
51
|
+
"@prisma/client": "^6.4.1",
|
|
52
|
+
"@types/node": "^22.13.9",
|
|
53
|
+
"@web/dev-server-esbuild": "^1.0.4",
|
|
54
|
+
"@web/test-runner": "^0.20.0",
|
|
55
55
|
"@web/test-runner-commands": "^0.9.0",
|
|
56
56
|
"@web/test-runner-playwright": "^0.11.0",
|
|
57
57
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
58
58
|
"c8": "^10.1.3",
|
|
59
59
|
"concurrently": "^9.1.2",
|
|
60
60
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
61
|
-
"prisma": "^6.
|
|
62
|
-
"typescript": "^5.
|
|
61
|
+
"prisma": "^6.4.1",
|
|
62
|
+
"typescript": "^5.8.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"typescript": "*"
|
|
@@ -104,13 +104,18 @@ export async function writeDirContents(
|
|
|
104
104
|
contents: Readonly<DirContents>,
|
|
105
105
|
): Promise<void> {
|
|
106
106
|
await Promise.all(
|
|
107
|
-
getObjectTypedEntries(contents).map(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
getObjectTypedEntries(contents).map(
|
|
108
|
+
async ([
|
|
109
|
+
relativePath,
|
|
110
|
+
content,
|
|
111
|
+
]) => {
|
|
112
|
+
const fullPath = join(rootDir, relativePath);
|
|
113
|
+
if (check.isString(content)) {
|
|
114
|
+
await writeFileAndDir(fullPath, content);
|
|
115
|
+
} else {
|
|
116
|
+
await writeDirContents(fullPath, content);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
),
|
|
115
120
|
);
|
|
116
121
|
}
|
|
@@ -93,7 +93,10 @@ function mapImportPath(
|
|
|
93
93
|
|
|
94
94
|
const mappedPaths = filterMap(
|
|
95
95
|
getObjectTypedEntries(paths),
|
|
96
|
-
([
|
|
96
|
+
([
|
|
97
|
+
alias,
|
|
98
|
+
paths,
|
|
99
|
+
]) => {
|
|
97
100
|
const aliasRegex = new RegExp('^' + String(alias).replace(/\*/g, '(.*)') + '$');
|
|
98
101
|
const match = importPath.match(aliasRegex);
|
|
99
102
|
|
|
@@ -40,7 +40,13 @@ export type RelevantArgsInput = {
|
|
|
40
40
|
*
|
|
41
41
|
* ```ts
|
|
42
42
|
* extractRelevantArgs({
|
|
43
|
-
* rawArgs: [
|
|
43
|
+
* rawArgs: [
|
|
44
|
+
* 'npx',
|
|
45
|
+
* 'ts-node',
|
|
46
|
+
* './my-script.ts',
|
|
47
|
+
* 'arg1',
|
|
48
|
+
* '--arg2',
|
|
49
|
+
* ], // typically will be process.argv
|
|
44
50
|
* binName: 'my-script', // should be your package.json "bin" property name, can be undefined
|
|
45
51
|
* fileName: 'my-script.ts', // should be __filename from the script that will be executed
|
|
46
52
|
* });
|
|
@@ -62,7 +62,13 @@ export async function runCliScript(
|
|
|
62
62
|
}) || runner.npx;
|
|
63
63
|
|
|
64
64
|
const results = await runShellCommand(
|
|
65
|
-
interpolationSafeWindowsPath(
|
|
65
|
+
interpolationSafeWindowsPath(
|
|
66
|
+
[
|
|
67
|
+
runnerPath,
|
|
68
|
+
scriptPath,
|
|
69
|
+
...args,
|
|
70
|
+
].join(' '),
|
|
71
|
+
),
|
|
66
72
|
{
|
|
67
73
|
hookUpToConsole: true,
|
|
68
74
|
},
|
|
@@ -247,7 +247,10 @@ export async function runShellCommand(
|
|
|
247
247
|
|
|
248
248
|
shellTarget.destroy();
|
|
249
249
|
|
|
250
|
-
const rejectionErrorMessage: Error = combineErrors([
|
|
250
|
+
const rejectionErrorMessage: Error = combineErrors([
|
|
251
|
+
new Error(stderr),
|
|
252
|
+
...errors,
|
|
253
|
+
]);
|
|
251
254
|
/** Reject now because the "done" listener won't get fired after killing the process. */
|
|
252
255
|
reject(rejectionErrorMessage);
|
|
253
256
|
});
|
|
@@ -109,7 +109,10 @@ export function makeEnvFlags(envMapping?: DockerEnvMap | undefined): string {
|
|
|
109
109
|
return '';
|
|
110
110
|
}
|
|
111
111
|
const flags: ReadonlyArray<string> = Object.entries(envMapping).map(
|
|
112
|
-
([
|
|
112
|
+
([
|
|
113
|
+
key,
|
|
114
|
+
{value, allowInterpolation},
|
|
115
|
+
]) => {
|
|
113
116
|
const quote = allowInterpolation ? '"' : "'";
|
|
114
117
|
return `-e ${key}=${wrapString({value, wrapper: quote})}`;
|
|
115
118
|
},
|
|
@@ -15,7 +15,12 @@ export async function updateImage(
|
|
|
15
15
|
const command = [
|
|
16
16
|
'docker',
|
|
17
17
|
'pull',
|
|
18
|
-
...(platform
|
|
18
|
+
...(platform
|
|
19
|
+
? [
|
|
20
|
+
'--platform',
|
|
21
|
+
platform,
|
|
22
|
+
]
|
|
23
|
+
: []),
|
|
19
24
|
wrapString({value: imageName, wrapper: "'"}),
|
|
20
25
|
].join(' ');
|
|
21
26
|
|
package/src/prisma/model-data.ts
CHANGED
|
@@ -89,55 +89,68 @@ async function addModelDataObject(
|
|
|
89
89
|
data: Record<string, AnyObject>,
|
|
90
90
|
) {
|
|
91
91
|
/** Add the mock data to the mock prisma client. */
|
|
92
|
-
await awaitedForEach(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
modelEntry
|
|
118
|
-
|
|
92
|
+
await awaitedForEach(
|
|
93
|
+
getObjectTypedEntries(data),
|
|
94
|
+
async ([
|
|
95
|
+
modelName,
|
|
96
|
+
mockData,
|
|
97
|
+
]) => {
|
|
98
|
+
/**
|
|
99
|
+
* This type is dumbed down to just `AnyObject[]` because the union of all possible
|
|
100
|
+
* model data is just way too big (and not helpful as the inputs to this function are
|
|
101
|
+
* already type guarded).
|
|
102
|
+
*/
|
|
103
|
+
const mockModelInstances: AnyObject[] = Array.isArray(mockData)
|
|
104
|
+
? mockData
|
|
105
|
+
: getObjectTypedValues(mockData);
|
|
106
|
+
|
|
107
|
+
const modelApi: AnyObject | undefined = prismaClient[modelName];
|
|
108
|
+
|
|
109
|
+
assert.isDefined(modelApi, `No PrismaClient API found for model '${modelName}'`);
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
const allData = filterMap(
|
|
113
|
+
mockModelInstances,
|
|
114
|
+
(entry) => {
|
|
115
|
+
return entry;
|
|
116
|
+
},
|
|
117
|
+
(mapped, modelEntry) => !modelEntry[prismaModelCreateExclude],
|
|
118
|
+
);
|
|
119
119
|
|
|
120
|
-
await
|
|
121
|
-
|
|
120
|
+
await awaitedForEach(allData, async (modelEntry) => {
|
|
121
|
+
if (modelEntry[prismaModelCreateOmitId]) {
|
|
122
|
+
modelEntry = omitObjectKeys<AnyObject, PropertyKey>(modelEntry, ['id']);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
await modelApi.create({
|
|
126
|
+
data: modelEntry,
|
|
127
|
+
});
|
|
122
128
|
});
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
129
|
+
} catch (error) {
|
|
130
|
+
throw ensureErrorAndPrependMessage(
|
|
131
|
+
error,
|
|
132
|
+
`Failed to create many '${modelName}' entries.\n\n${JSON.stringify(mockModelInstances, null, 4)}\n\n`,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
);
|
|
131
137
|
}
|
|
132
138
|
|
|
133
|
-
const prismockKeys = [
|
|
139
|
+
const prismockKeys = [
|
|
140
|
+
'getData',
|
|
141
|
+
'setData',
|
|
142
|
+
];
|
|
134
143
|
|
|
135
144
|
export function getAllPrismaModelNames<const PrismaClient extends BasePrismaClient>(
|
|
136
145
|
prismaClient: PrismaClient,
|
|
137
146
|
): PrismaModelName<PrismaClient>[] {
|
|
138
147
|
return Object.keys(prismaClient)
|
|
139
148
|
.filter(
|
|
140
|
-
(key) =>
|
|
149
|
+
(key) =>
|
|
150
|
+
!key.startsWith('$') &&
|
|
151
|
+
!key.startsWith('_') &&
|
|
152
|
+
!prismockKeys.includes(key) &&
|
|
153
|
+
key !== 'constructor',
|
|
141
154
|
)
|
|
142
155
|
.sort() as PrismaModelName<PrismaClient>[];
|
|
143
156
|
}
|
|
@@ -33,7 +33,12 @@ export async function applyPrismaMigrationsToDev(
|
|
|
33
33
|
schemaFilePath: string,
|
|
34
34
|
env: Record<string, string> = {},
|
|
35
35
|
) {
|
|
36
|
-
const command = [
|
|
36
|
+
const command = [
|
|
37
|
+
'prisma',
|
|
38
|
+
'migrate',
|
|
39
|
+
'dev',
|
|
40
|
+
`--schema='${schemaFilePath}'`,
|
|
41
|
+
].join(' ');
|
|
37
42
|
|
|
38
43
|
log.faint(`> ${command}`);
|
|
39
44
|
|
|
@@ -106,7 +111,10 @@ export async function getMigrationStatus(
|
|
|
106
111
|
} else if (line.endsWith('not yet been applied:')) {
|
|
107
112
|
foundNotAppliedMigrations = true;
|
|
108
113
|
} else {
|
|
109
|
-
const [
|
|
114
|
+
const [
|
|
115
|
+
,
|
|
116
|
+
countMatch,
|
|
117
|
+
] = safeMatch(line, /^([\d,]+) migrations? found in/);
|
|
110
118
|
|
|
111
119
|
if (countMatch) {
|
|
112
120
|
listedMigrations.totalMigrations = toEnsuredNumber(countMatch);
|
|
@@ -19,7 +19,10 @@ export async function runPrismaCommand(
|
|
|
19
19
|
env: Record<string, string> | undefined = {},
|
|
20
20
|
) {
|
|
21
21
|
const schemaFileArgs = schemaFilePath
|
|
22
|
-
? [
|
|
22
|
+
? [
|
|
23
|
+
'--schema',
|
|
24
|
+
wrapString({value: schemaFilePath, wrapper: "'"}),
|
|
25
|
+
]
|
|
23
26
|
: [];
|
|
24
27
|
|
|
25
28
|
/** Disable Prisma's in-CLI ads. */
|
|
@@ -29,7 +32,12 @@ export async function runPrismaCommand(
|
|
|
29
32
|
? '--no-hints'
|
|
30
33
|
: '';
|
|
31
34
|
|
|
32
|
-
const fullCommand = [
|
|
35
|
+
const fullCommand = [
|
|
36
|
+
'prisma',
|
|
37
|
+
command,
|
|
38
|
+
...schemaFileArgs,
|
|
39
|
+
noHintsArg,
|
|
40
|
+
].join(' ');
|
|
33
41
|
|
|
34
42
|
log.faint(`> ${fullCommand}`);
|
|
35
43
|
|