@augment-vir/node 31.18.0 → 31.19.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.
@@ -1,3 +1,11 @@
1
1
  export declare function getPrismaDiff(schemaFilePath: string, env?: Record<string, string>): Promise<string>;
2
2
  export declare function doesPrismaDiffExist(schemaFilePath: string, env?: Record<string, string>): Promise<boolean>;
3
- export declare function resetDevPrismaDatabase(schemaFilePath: string, env?: Record<string, string>): Promise<void>;
3
+ export declare function resetDevPrismaDatabase(schemaFilePath: string, options: {
4
+ /**
5
+ * If you already have migrations created, set this to `true`. If you don't, set it to
6
+ * `false`. If you don't know which one to use, try both, see which one creates a valid
7
+ * database for you (try querying it with PrismaClient after running this; if it errors,
8
+ * this didn't create a valid database).
9
+ */
10
+ withMigrations: boolean;
11
+ }, env?: Record<string, string>): Promise<void>;
@@ -17,6 +17,13 @@ export async function getPrismaDiff(schemaFilePath, env = {}) {
17
17
  export async function doesPrismaDiffExist(schemaFilePath, env = {}) {
18
18
  return !!(await getPrismaDiff(schemaFilePath, env));
19
19
  }
20
- export async function resetDevPrismaDatabase(schemaFilePath, env = {}) {
21
- await runPrismaCommand({ command: 'migrate reset --force' }, schemaFilePath, env);
20
+ export async function resetDevPrismaDatabase(schemaFilePath, options, env = {}) {
21
+ if (options.withMigrations) {
22
+ await runPrismaCommand({ command: 'migrate reset --force --skip-generate --skip-seed' }, schemaFilePath, env);
23
+ }
24
+ else {
25
+ await runPrismaCommand({
26
+ command: 'db push --accept-data-loss --skip-generate',
27
+ }, schemaFilePath, env);
28
+ }
22
29
  }
@@ -1,3 +1,4 @@
1
+ import { type PartialWithUndefined } from '@augment-vir/common';
1
2
  import { type ShellOutput } from '../augments/terminal/shell.js';
2
3
  /**
3
4
  * All commands in the Prisma CLI that support the `--no-hints` flag, used to turn off ads.
@@ -14,10 +15,13 @@ export declare const prismaCommandsThatSupportNoHints: string[];
14
15
  * @category Package : @augment-vir/node
15
16
  * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
16
17
  */
17
- export declare function runPrismaCommand({ command, ignoreExitCode, }: {
18
+ export declare function runPrismaCommand({ command, ignoreExitCode, hideLogs, }: {
18
19
  command: string;
19
- ignoreExitCode?: boolean | undefined;
20
- },
20
+ } & PartialWithUndefined<{
21
+ /** If `true`, prevents errors from being thrown if this command exits with a non-0 status. */
22
+ ignoreExitCode: boolean;
23
+ hideLogs: boolean;
24
+ }>,
21
25
  /** Set to `undefined` to omit the `--schema` flag. */
22
26
  schemaFilePath: string | undefined, env?: Record<string, string> | undefined): Promise<Readonly<ShellOutput>>;
23
27
  export declare function verifyOutput(schemaFilePath: string, shellOutput: Readonly<ShellOutput>, ignoreExitCode: boolean): Readonly<ShellOutput>;
@@ -18,7 +18,7 @@ export const prismaCommandsThatSupportNoHints = ['generate'];
18
18
  * @category Package : @augment-vir/node
19
19
  * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
20
20
  */
21
- export async function runPrismaCommand({ command, ignoreExitCode = false, },
21
+ export async function runPrismaCommand({ command, ignoreExitCode = false, hideLogs = false, },
22
22
  /** Set to `undefined` to omit the `--schema` flag. */
23
23
  schemaFilePath, env = {}) {
24
24
  const schemaFileArgs = schemaFilePath
@@ -43,7 +43,7 @@ schemaFilePath, env = {}) {
43
43
  ...process.env,
44
44
  ...env,
45
45
  },
46
- hookUpToConsole: true,
46
+ hookUpToConsole: !hideLogs,
47
47
  cwd: schemaFilePath ? dirname(schemaFilePath) : process.cwd(),
48
48
  });
49
49
  return verifyOutput(schemaFilePath || '', result, ignoreExitCode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/node",
3
- "version": "31.18.0",
3
+ "version": "31.19.1",
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.18.0",
42
- "@augment-vir/common": "^31.18.0",
41
+ "@augment-vir/assert": "^31.19.1",
42
+ "@augment-vir/common": "^31.19.1",
43
43
  "@date-vir/duration": "^7.3.1",
44
44
  "ansi-styles": "^6.2.1",
45
45
  "terminate": "^2.8.0",
@@ -48,7 +48,7 @@
48
48
  "typed-event-target": "^4.0.4"
49
49
  },
50
50
  "devDependencies": {
51
- "@augment-vir/test": "^31.18.0",
51
+ "@augment-vir/test": "^31.19.1",
52
52
  "@prisma/client": "^6.7.0",
53
53
  "@types/node": "^22.15.17",
54
54
  "@web/dev-server-esbuild": "^1.0.4",
@@ -29,7 +29,30 @@ export async function doesPrismaDiffExist(
29
29
 
30
30
  export async function resetDevPrismaDatabase(
31
31
  schemaFilePath: string,
32
+ options: {
33
+ /**
34
+ * If you already have migrations created, set this to `true`. If you don't, set it to
35
+ * `false`. If you don't know which one to use, try both, see which one creates a valid
36
+ * database for you (try querying it with PrismaClient after running this; if it errors,
37
+ * this didn't create a valid database).
38
+ */
39
+ withMigrations: boolean;
40
+ },
32
41
  env: Record<string, string> = {},
33
42
  ) {
34
- await runPrismaCommand({command: 'migrate reset --force'}, schemaFilePath, env);
43
+ if (options.withMigrations) {
44
+ await runPrismaCommand(
45
+ {command: 'migrate reset --force --skip-generate --skip-seed'},
46
+ schemaFilePath,
47
+ env,
48
+ );
49
+ } else {
50
+ await runPrismaCommand(
51
+ {
52
+ command: 'db push --accept-data-loss --skip-generate',
53
+ },
54
+ schemaFilePath,
55
+ env,
56
+ );
57
+ }
35
58
  }
@@ -1,4 +1,4 @@
1
- import {log, wrapString} from '@augment-vir/common';
1
+ import {log, type PartialWithUndefined, wrapString} from '@augment-vir/common';
2
2
  import {dirname} from 'node:path';
3
3
  import {interpolationSafeWindowsPath} from '../augments/path/os-path.js';
4
4
  import {runShellCommand, type ShellOutput} from '../augments/terminal/shell.js';
@@ -24,10 +24,14 @@ export async function runPrismaCommand(
24
24
  {
25
25
  command,
26
26
  ignoreExitCode = false,
27
+ hideLogs = false,
27
28
  }: {
28
29
  command: string;
29
- ignoreExitCode?: boolean | undefined;
30
- },
30
+ } & PartialWithUndefined<{
31
+ /** If `true`, prevents errors from being thrown if this command exits with a non-0 status. */
32
+ ignoreExitCode: boolean;
33
+ hideLogs: boolean;
34
+ }>,
31
35
  /** Set to `undefined` to omit the `--schema` flag. */
32
36
  schemaFilePath: string | undefined,
33
37
  env: Record<string, string> | undefined = {},
@@ -60,7 +64,7 @@ export async function runPrismaCommand(
60
64
  ...process.env,
61
65
  ...env,
62
66
  },
63
- hookUpToConsole: true,
67
+ hookUpToConsole: !hideLogs,
64
68
  cwd: schemaFilePath ? dirname(schemaFilePath) : process.cwd(),
65
69
  });
66
70