@augment-vir/node 30.0.2 → 30.0.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.
@@ -7,10 +7,10 @@ import { sep } from 'node:path';
7
7
  * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
8
8
  */
9
9
  export function replaceWithWindowsPathIfNeeded(input) {
10
+ /** No single system will test all of these lines so we must ignore them all. */
11
+ /* node:coverage ignore next 5 */
10
12
  if (sep === '/') {
11
13
  return input;
12
- /** Can't test on Windows. */
13
- /* node:coverage ignore next 3 */
14
14
  }
15
15
  else {
16
16
  return input.replace(/\//g, sep);
@@ -18,5 +18,6 @@ export type RunDockerContainerParams = {
18
18
  removeWhenDone?: boolean;
19
19
  dockerFlags?: ReadonlyArray<string>;
20
20
  useCurrentUser?: boolean;
21
+ platform?: string;
21
22
  };
22
- export declare function runContainer({ containerName, imageName, detach, command, portMapping, volumeMapping, envMapping, executionEnv, removeWhenDone, useCurrentUser, dockerFlags, }: RunDockerContainerParams): Promise<void>;
23
+ export declare function runContainer({ containerName, imageName, detach, command, portMapping, volumeMapping, envMapping, executionEnv, removeWhenDone, useCurrentUser, dockerFlags, platform, }: RunDockerContainerParams): Promise<void>;
@@ -4,7 +4,7 @@ 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';
6
6
  import { killContainer } from './kill-container.js';
7
- export async function runContainer({ containerName, imageName, detach, command, portMapping, volumeMapping, envMapping, executionEnv, removeWhenDone, useCurrentUser, dockerFlags = [], }) {
7
+ export async function runContainer({ containerName, imageName, detach, command, portMapping, volumeMapping, envMapping, executionEnv, removeWhenDone, useCurrentUser, dockerFlags = [], platform, }) {
8
8
  try {
9
9
  const portMapFlags = makePortMapFlags(portMapping);
10
10
  const envFlags = makeEnvFlags(envMapping);
@@ -12,7 +12,7 @@ export async function runContainer({ containerName, imageName, detach, command,
12
12
  const volumeMapFlags = makeVolumeFlags(volumeMapping);
13
13
  const rmFlag = removeWhenDone ? '--rm' : '';
14
14
  const userFlag = useCurrentUser ? '--user "$(id -u)":"$(id -g)"' : '';
15
- await updateImage(imageName);
15
+ await updateImage(imageName, platform);
16
16
  const fullCommand = [
17
17
  'docker',
18
18
  'run',
@@ -9,6 +9,7 @@ export async function runMockLongLivingContainer(containerName, args = {}) {
9
9
  '-t',
10
10
  ],
11
11
  command: 'sh',
12
+ platform: 'amd64',
12
13
  ...args,
13
14
  });
14
15
  }
@@ -1,6 +1,6 @@
1
1
  export declare function updateImage(
2
2
  /** @example 'alpine:3.20.2' */
3
- imageName: string): Promise<void>;
3
+ imageName: string, platform?: string): Promise<void>;
4
4
  export declare function isImageInLocalRegistry(
5
5
  /** @example 'alpine:3.20.2' */
6
6
  imageName: string): Promise<boolean>;
@@ -1,13 +1,25 @@
1
+ import { wrapString } from '@augment-vir/common';
1
2
  import { ensureError } from '@augment-vir/core';
2
3
  import { runShellCommand } from '../augments/terminal/shell.js';
3
4
  export async function updateImage(
4
5
  /** @example 'alpine:3.20.2' */
5
- imageName) {
6
+ imageName, platform) {
6
7
  if (await isImageInLocalRegistry(imageName)) {
7
8
  /** If image already exists then we don't need to update it. */
8
9
  return;
9
10
  }
10
- await runShellCommand(`docker pull '${imageName}'`, {
11
+ const command = [
12
+ 'docker',
13
+ 'pull',
14
+ ...(platform
15
+ ? [
16
+ '--platform',
17
+ platform,
18
+ ]
19
+ : []),
20
+ wrapString({ value: imageName, wrapper: "'" }),
21
+ ].join(' ');
22
+ await runShellCommand(command, {
11
23
  rejectOnError: true,
12
24
  });
13
25
  }
@@ -1,6 +1,6 @@
1
1
  import { isOperatingSystem, OperatingSystem } from '../augments/os/operating-system.js';
2
2
  export function dockerTest(callback) {
3
- if (isOperatingSystem(OperatingSystem.Mac) && process.env.CI) {
3
+ if (!isOperatingSystem(OperatingSystem.Linux) && process.env.CI) {
4
4
  /**
5
5
  * We cannot test Docker on macOS GitHub Actions runners.
6
6
  *
@@ -10,6 +10,13 @@ export function dockerTest(callback) {
10
10
  * - https://github.com/actions/runner-images/issues/2150
11
11
  * - https://github.com/actions/runner/issues/1456
12
12
  */
13
+ /**
14
+ * We cannot test Docker on Windows GitHub Actions runners because Docker cannot run in
15
+ * Linux container mode on Windows GitHub Actions runners.
16
+ *
17
+ * @see
18
+ * - https://github.com/orgs/community/discussions/25491#discussioncomment-3248089
19
+ */
13
20
  return () => { };
14
21
  }
15
22
  return callback;
@@ -1,4 +1,5 @@
1
1
  import { BasePrismaClient, PrismaAllModelsCreate, type PartialWithUndefined, type PrismaAllBasicModels, type PrismaModelName } from '@augment-vir/common';
2
+ import type { IsAny } from 'type-fest';
2
3
  /**
3
4
  * Params for {@link addData}. This is similar to {@link PrismaAllModelsCreate} but allows an array of
4
5
  * {@link PrismaAllModelsCreate} for sequential data creation.
@@ -47,7 +48,7 @@ import { BasePrismaClient, PrismaAllModelsCreate, type PartialWithUndefined, typ
47
48
  * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
48
49
  */
49
50
  export type PrismaAddDataData<PrismaClient extends BasePrismaClient> = Readonly<PrismaAllModelsCreate<PrismaClient>> | ReadonlyArray<Readonly<PrismaAllModelsCreate<PrismaClient>>>;
50
- export declare function addData<const PrismaClient extends BasePrismaClient>(prismaClient: Readonly<PrismaClient>, data: PrismaAddDataData<PrismaClient>): Promise<void>;
51
+ export declare function addData<const PrismaClient extends BasePrismaClient>(prismaClient: Readonly<PrismaClient>, data: IsAny<PrismaClient> extends true ? any : PrismaAddDataData<PrismaClient>): Promise<void>;
51
52
  export declare function getAllPrismaModelNames<const PrismaClient extends BasePrismaClient>(prismaClient: PrismaClient): PrismaModelName<PrismaClient>[];
52
53
  /**
53
54
  * Options for `prisma.client.dumpData`.
@@ -1,7 +1,25 @@
1
- import { rm } from 'node:fs/promises';
1
+ import { awaitedForEach, callWithRetries, wait } from '@augment-vir/common';
2
+ import { interpolationSafeWindowsPath } from '../augments/path/os-path.js';
3
+ import { runShellCommand } from '../augments/terminal/shell.js';
2
4
  import { generatedPrismaClientDirPath, notCommittedDirPath, testPrismaMigrationsDirPath, } from '../file-paths.mock.js';
5
+ const pathsToDelete = [
6
+ generatedPrismaClientDirPath,
7
+ notCommittedDirPath,
8
+ testPrismaMigrationsDirPath,
9
+ ];
3
10
  export async function clearTestDatabaseOutputs() {
4
- await rm(generatedPrismaClientDirPath, { force: true, recursive: true });
5
- await rm(notCommittedDirPath, { force: true, recursive: true });
6
- await rm(testPrismaMigrationsDirPath, { force: true, recursive: true });
11
+ await callWithRetries(10, async () => {
12
+ await wait({ seconds: 1 });
13
+ await awaitedForEach(pathsToDelete, async (pathToDelete) => {
14
+ /**
15
+ * This way of deleting files is required for Windows tests running on GitHub Actions.
16
+ * Otherwise, we get the following error:
17
+ *
18
+ * EPERM: operation not permitted, unlink 'D:\a\augment-vir\augment-vir\packages\node\node_modules\.prisma\query_engine-windows.dll.node'
19
+ */
20
+ await runShellCommand(`rm -rf ${interpolationSafeWindowsPath(pathToDelete)}`, {
21
+ rejectOnError: true,
22
+ });
23
+ });
24
+ });
7
25
  }
@@ -1,4 +1,5 @@
1
1
  import { log } from '@augment-vir/common';
2
+ import { interpolationSafeWindowsPath } from '../augments/path/os-path.js';
2
3
  import { runShellCommand } from '../augments/terminal/shell.js';
3
4
  import { PrismaSchemaError } from './prisma-errors.js';
4
5
  const prismaCommandsThatSupportNoHints = [
@@ -24,7 +25,7 @@ schemaFilePath, env = {}) {
24
25
  noHintsArg,
25
26
  ].join(' ');
26
27
  log.faint(`> ${fullCommand}`);
27
- const result = await runShellCommand(fullCommand, {
28
+ const result = await runShellCommand(interpolationSafeWindowsPath(fullCommand), {
28
29
  env: {
29
30
  ...process.env,
30
31
  ...env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/node",
3
- "version": "30.0.2",
3
+ "version": "30.0.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",
@@ -32,8 +32,8 @@
32
32
  "types": "dist/index.d.ts",
33
33
  "scripts": {
34
34
  "compile": "virmator compile",
35
- "test": "virmator --no-deps test node --test-concurrency 1",
36
- "test:coverage": "virmator test node coverage --test-concurrency 1",
35
+ "test": "npm i @prisma/client && virmator --no-deps test node --test-concurrency 1",
36
+ "test:coverage": "npm i @prisma/client && virmator test node coverage --test-concurrency 1",
37
37
  "test:update": "npm test"
38
38
  },
39
39
  "dependencies": {
@@ -55,7 +55,7 @@
55
55
  "@web/test-runner-playwright": "^0.11.0",
56
56
  "@web/test-runner-visual-regression": "^0.10.0",
57
57
  "c8": "^10.1.2",
58
- "concurrently": "^9.0.0",
58
+ "concurrently": "^9.0.1",
59
59
  "istanbul-smart-text-reporter": "^1.1.4",
60
60
  "prisma": "^5.19.1"
61
61
  },