From caceea4a55c0ee7832354f571bbe9ddccd1b414d Mon Sep 17 00:00:00 2001
From: James Hammond <james_hammond@live.com>
Date: Fri, 30 Aug 2024 18:46:54 +0100
Subject: [PATCH 1/3] feat: Allow Override of Container Image Name #60

---
 README.md                      | 14 +++++++++++++-
 src/config/configFileSchema.ts |  1 +
 src/database/db.ts             | 32 +++++++++++++++++++++++++++-----
 src/index.ts                   |  5 ++++-
 4 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 3d7939f..bc63bfa 100644
--- a/README.md
+++ b/README.md
@@ -80,6 +80,8 @@ Options:
   -o, --outputFolder    output folder (default: client_generated)
   -g, --generateClient  generate client (default: true)
   --no-generateClient   no client generation
+  -i, --surrealImage    SurrealDB docker image (default: surrealdb/surrealdb:latest)
+  
   -h, --help            display help for command
 ```
 
@@ -100,7 +102,9 @@ Example:
   "db": "my_database",
   "outputFolder": "./out",
   "generateClient": true,
-  "lib": "surrealdb"
+  "lib": "surrealdb",
+  "surrealImage": "surrealdb/surrealdb:latest"
+  
 }
 ```
 
@@ -119,6 +123,14 @@ or you can specify the path in the config file:
 }
 ```
 
+using a schema file utilises a temporary in-memory SurrealDB instance to generate the zod schemas; this instance runs in a docker container.
+If you want to use a different image, you can specify it in the config file:
+```json
+{
+  "surrealImage": "surrealdb/surrealdb:latest"
+}
+```
+
 ## Connecting to an Existing SurrealDB Instance
 
 To connect to an existing SurrealDB instance, simply omit the `-f` option, or omit the `schemaFile` in the config file.
diff --git a/src/config/configFileSchema.ts b/src/config/configFileSchema.ts
index 1a61f8a..bd35574 100644
--- a/src/config/configFileSchema.ts
+++ b/src/config/configFileSchema.ts
@@ -9,4 +9,5 @@ export const configFileSchema = z.object({
 	password: z.string().default('root'),
 	outputFolder: z.string().default('client_generated'),
 	generateClient: z.boolean().default(true),
+	surrealImage: z.string().default('surrealdb/surrealdb:latest'),
 })
diff --git a/src/database/db.ts b/src/database/db.ts
index f781f45..0a9176f 100644
--- a/src/database/db.ts
+++ b/src/database/db.ts
@@ -13,19 +13,41 @@ export const getDb = () => {
 	throw new Error('Not connected to a database')
 }
 
-export const connectDb = async (config: Config, createInstance = false) => {
-	if (createInstance) {
+async function startSurrealDBContainer(config: Config): Promise<StartedTestContainer> {
+	try {
 		console.log('Starting temporary SurrealDB instance')
-		container = await new GenericContainer('surrealdb/surrealdb:latest')
+		const newContainer = await new GenericContainer(config.surrealImage)
 			.withExposedPorts(8000)
 			.withCommand(['start', '--user', config.username, '--pass', config.password, 'memory'])
 			.withWaitStrategy(Wait.forLogMessage('Started web server'))
 			.start()
 
-		const port = container.getMappedPort(8000)
-		const host = container.getHost()
+		const port = newContainer.getMappedPort(8000)
+		const host = newContainer.getHost()
 		config.surreal = `http://${host}:${port}`
 		console.log(`Temporary SurrealDB instance started at ${config.surreal}`)
+
+		return newContainer
+	} catch (error) {
+		if (error instanceof Error) {
+			if (error.message.includes('pull access denied') || error.message.includes('not found')) {
+				throw new Error(`Invalid or inaccessible Docker image: ${config.surrealImage}`)
+			} else if (error.message.includes('connection refused')) {
+				throw new Error('Unable to connect to Docker daemon. Is Docker running?')
+			}
+		}
+		throw new Error(`Failed to start SurrealDB container: ${error}`)
+	}
+}
+
+export const connectDb = async (config: Config, createInstance = false) => {
+	if (createInstance) {
+		try {
+			container = await startSurrealDBContainer(config)
+		} catch (error: any) {
+			console.error('Error starting SurrealDB container:', error.message)
+			throw error // Re-throw to be caught by the caller if needed
+		}
 	}
 
 	console.log('Connecting to database')
diff --git a/src/index.ts b/src/index.ts
index 28973de..0137f94 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -18,7 +18,7 @@ const main = async () => {
 		.version('1.0.0')
 
 	program
-		.option('-f, --schemaFile [schemaFile]', 'a SurrealQL file containing the definitions')
+		.option('-f, --schemaFile [schemaFile]', 'a SurrealQL file containing the definitions', )
 		.option('-c, --config [config]', 'config file', 'surql-gen.json')
 		.option('-s, --surreal [surreal]', 'SurrealDB connection url', 'http://localhost:8000')
 		.option('-u, --username [username]', 'auth username', 'root')
@@ -28,6 +28,7 @@ const main = async () => {
 		.option('-o, --outputFolder [outputFolder]', 'output folder', 'client_generated')
 		.option('-g, --generateClient', 'generate client', true)
 		.option('--no-generateClient', 'no client generation')
+		.option('-i, --surrealImage [surrealImage]', 'SurrealDB image', 'surrealdb/surrealdb:latest')
 
 	program.parse()
 
@@ -63,6 +64,8 @@ const main = async () => {
 
 	const config = configFileSchema.parse({ ...options, ...fileContent })
 
+	console.log("config", config)
+
 	try {
 		if (config.schemaFile) {
 			await connectDb(config, true)

From 31ff173c89d387e149de899ace13256db5937bee Mon Sep 17 00:00:00 2001
From: Sebastian Wessel <sebastianwessel@users.noreply.github.com>
Date: Fri, 30 Aug 2024 20:08:23 +0100
Subject: [PATCH 2/3] chore: add ci and update deps and bump version

---
 .github/workflows/ci.yml |  45 ++++++
 .nvmrc                   |   2 +-
 package-lock.json        | 293 +++------------------------------------
 package.json             |  10 +-
 4 files changed, 69 insertions(+), 281 deletions(-)
 create mode 100644 .github/workflows/ci.yml

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..28cbb25
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,45 @@
+name: Continuous Integration
+
+on:
+  pull_request:
+    branches:
+      - main
+  push:
+    branches:
+      - main
+
+permissions:
+  contents: read
+
+jobs:
+  test-and-build:
+    name: TypeScript Tests
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout
+        id: checkout
+        uses: actions/checkout@v4
+
+      - name: Setup Node.js
+        id: setup-node
+        uses: actions/setup-node@v4
+        with:
+          node-version-file: .nvmrc
+          cache: npm
+
+      - name: Install Dependencies
+        id: npm-ci
+        run: npm ci
+
+      - name: Lint
+        id: npm-lint
+        run: npm run lint
+
+      - name: Test
+        id: npm-ci-test
+        run: npm test
+
+      - name: Build
+        id: npm-ci-build
+        run: npm run build
\ No newline at end of file
diff --git a/.nvmrc b/.nvmrc
index a3597ec..65da8ce 100644
--- a/.nvmrc
+++ b/.nvmrc
@@ -1 +1 @@
-20.11
+20.17
diff --git a/package-lock.json b/package-lock.json
index e69b83a..960a7a4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,31 +1,30 @@
 {
 	"name": "@sebastianwessel/surql-gen",
-	"version": "2.6.0",
+	"version": "2.6.1",
 	"lockfileVersion": 3,
 	"requires": true,
 	"packages": {
 		"": {
 			"name": "@sebastianwessel/surql-gen",
-			"version": "2.6.0",
+			"version": "2.6.1",
 			"license": "MIT",
 			"dependencies": {
 				"commander": "^12.1.0",
 				"mkdirp": "^3.0.1",
 				"rimraf": "^6.0.1",
 				"surrealdb": "^1.0.0-beta.20",
-				"testcontainers": "^10.11.0",
+				"testcontainers": "^10.12.0",
 				"zod": "^3.23.8"
 			},
 			"bin": {
-				"surql-gen": "dist/commonjs/index.js"
+				"surql-gen": "dist/index.js"
 			},
 			"devDependencies": {
 				"@biomejs/biome": "^1.8.3",
-				"@types/node": "^22.5.0",
+				"@types/node": "^22.5.1",
 				"esbuild": "^0.23.1",
 				"jsr": "^0.13.1",
-				"tshy": "^3.0.2",
-				"tsx": "^4.17.0",
+				"tsx": "^4.19.0",
 				"typescript": "^5.5.4",
 				"vitest": "^2.0.5"
 			},
@@ -793,9 +792,10 @@
 			"dev": true
 		},
 		"node_modules/@types/node": {
-			"version": "22.5.0",
-			"resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz",
-			"integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==",
+			"version": "22.5.1",
+			"resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.1.tgz",
+			"integrity": "sha512-KkHsxej0j9IW1KKOOAA/XBA0z08UFSrRQHErzEfA3Vgq57eXIMYboIlHJuYIfd+lwCQjtKqUu3UnmKbtUc9yRw==",
+			"license": "MIT",
 			"dependencies": {
 				"undici-types": "~6.19.2"
 			}
@@ -932,19 +932,6 @@
 				"url": "https://github.com/chalk/ansi-regex?sponsor=1"
 			}
 		},
-		"node_modules/anymatch": {
-			"version": "3.1.3",
-			"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
-			"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
-			"dev": true,
-			"dependencies": {
-				"normalize-path": "^3.0.0",
-				"picomatch": "^2.0.4"
-			},
-			"engines": {
-				"node": ">= 8"
-			}
-		},
 		"node_modules/archiver": {
 			"version": "7.0.1",
 			"resolved": "https://registry.npmjs.org/archiver/-/archiver-7.0.1.tgz",
@@ -1162,18 +1149,6 @@
 				"tweetnacl": "^0.14.3"
 			}
 		},
-		"node_modules/binary-extensions": {
-			"version": "2.3.0",
-			"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
-			"integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
-			"dev": true,
-			"engines": {
-				"node": ">=8"
-			},
-			"funding": {
-				"url": "https://github.com/sponsors/sindresorhus"
-			}
-		},
 		"node_modules/bl": {
 			"version": "4.1.0",
 			"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
@@ -1228,18 +1203,6 @@
 				"balanced-match": "^1.0.0"
 			}
 		},
-		"node_modules/braces": {
-			"version": "3.0.3",
-			"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
-			"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
-			"dev": true,
-			"dependencies": {
-				"fill-range": "^7.1.1"
-			},
-			"engines": {
-				"node": ">=8"
-			}
-		},
 		"node_modules/buffer": {
 			"version": "6.0.3",
 			"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
@@ -1326,18 +1289,6 @@
 				"node": ">=12"
 			}
 		},
-		"node_modules/chalk": {
-			"version": "5.3.0",
-			"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
-			"integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==",
-			"dev": true,
-			"engines": {
-				"node": "^12.17.0 || ^14.13 || >=16.0.0"
-			},
-			"funding": {
-				"url": "https://github.com/chalk/chalk?sponsor=1"
-			}
-		},
 		"node_modules/check-error": {
 			"version": "2.1.1",
 			"resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz",
@@ -1347,30 +1298,6 @@
 				"node": ">= 16"
 			}
 		},
-		"node_modules/chokidar": {
-			"version": "3.6.0",
-			"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
-			"integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
-			"dev": true,
-			"dependencies": {
-				"anymatch": "~3.1.2",
-				"braces": "~3.0.2",
-				"glob-parent": "~5.1.2",
-				"is-binary-path": "~2.1.0",
-				"is-glob": "~4.0.1",
-				"normalize-path": "~3.0.0",
-				"readdirp": "~3.6.0"
-			},
-			"engines": {
-				"node": ">= 8.10.0"
-			},
-			"funding": {
-				"url": "https://paulmillr.com/funding/"
-			},
-			"optionalDependencies": {
-				"fsevents": "~2.3.2"
-			}
-		},
 		"node_modules/chownr": {
 			"version": "1.1.4",
 			"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
@@ -1706,18 +1633,6 @@
 			"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz",
 			"integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ=="
 		},
-		"node_modules/fill-range": {
-			"version": "7.1.1",
-			"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
-			"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
-			"dev": true,
-			"dependencies": {
-				"to-regex-range": "^5.0.1"
-			},
-			"engines": {
-				"node": ">=8"
-			}
-		},
 		"node_modules/foreground-child": {
 			"version": "3.2.1",
 			"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz",
@@ -1818,18 +1733,6 @@
 				"url": "https://github.com/sponsors/isaacs"
 			}
 		},
-		"node_modules/glob-parent": {
-			"version": "5.1.2",
-			"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
-			"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
-			"dev": true,
-			"dependencies": {
-				"is-glob": "^4.0.1"
-			},
-			"engines": {
-				"node": ">= 6"
-			}
-		},
 		"node_modules/graceful-fs": {
 			"version": "4.2.11",
 			"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
@@ -1868,27 +1771,6 @@
 			"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
 			"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
 		},
-		"node_modules/is-binary-path": {
-			"version": "2.1.0",
-			"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
-			"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
-			"dev": true,
-			"dependencies": {
-				"binary-extensions": "^2.0.0"
-			},
-			"engines": {
-				"node": ">=8"
-			}
-		},
-		"node_modules/is-extglob": {
-			"version": "2.1.1",
-			"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
-			"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
-			"dev": true,
-			"engines": {
-				"node": ">=0.10.0"
-			}
-		},
 		"node_modules/is-fullwidth-code-point": {
 			"version": "3.0.0",
 			"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
@@ -1897,27 +1779,6 @@
 				"node": ">=8"
 			}
 		},
-		"node_modules/is-glob": {
-			"version": "4.0.3",
-			"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
-			"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
-			"dev": true,
-			"dependencies": {
-				"is-extglob": "^2.1.1"
-			},
-			"engines": {
-				"node": ">=0.10.0"
-			}
-		},
-		"node_modules/is-number": {
-			"version": "7.0.0",
-			"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
-			"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
-			"dev": true,
-			"engines": {
-				"node": ">=0.12.0"
-			}
-		},
 		"node_modules/is-stream": {
 			"version": "3.0.0",
 			"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz",
@@ -2279,30 +2140,6 @@
 			"integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==",
 			"dev": true
 		},
-		"node_modules/picomatch": {
-			"version": "2.3.1",
-			"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
-			"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
-			"dev": true,
-			"engines": {
-				"node": ">=8.6"
-			},
-			"funding": {
-				"url": "https://github.com/sponsors/jonschlinkert"
-			}
-		},
-		"node_modules/polite-json": {
-			"version": "5.0.0",
-			"resolved": "https://registry.npmjs.org/polite-json/-/polite-json-5.0.0.tgz",
-			"integrity": "sha512-OLS/0XeUAcE8a2fdwemNja+udKgXNnY6yKVIXqAD2zVRx1KvY6Ato/rZ2vdzbxqYwPW0u6SCNC/bAMPNzpzxbw==",
-			"dev": true,
-			"engines": {
-				"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
-			},
-			"funding": {
-				"url": "https://github.com/sponsors/isaacs"
-			}
-		},
 		"node_modules/postcss": {
 			"version": "8.4.41",
 			"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.41.tgz",
@@ -2433,34 +2270,6 @@
 				"node": ">=10"
 			}
 		},
-		"node_modules/readdirp": {
-			"version": "3.6.0",
-			"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
-			"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
-			"dev": true,
-			"dependencies": {
-				"picomatch": "^2.2.1"
-			},
-			"engines": {
-				"node": ">=8.10.0"
-			}
-		},
-		"node_modules/resolve-import": {
-			"version": "2.0.0",
-			"resolved": "https://registry.npmjs.org/resolve-import/-/resolve-import-2.0.0.tgz",
-			"integrity": "sha512-jpKjLibLuc8D1XEV2+7zb0aqN7I8d12u89g/v6IsgCzdVlccMQJq4TKkPw5fbhHdxhm7nbVtN+KvOTnjFf+nEA==",
-			"dev": true,
-			"dependencies": {
-				"glob": "^11.0.0",
-				"walk-up-path": "^4.0.0"
-			},
-			"engines": {
-				"node": "20 || >=22"
-			},
-			"funding": {
-				"url": "https://github.com/sponsors/isaacs"
-			}
-		},
 		"node_modules/resolve-pkg-maps": {
 			"version": "1.0.0",
 			"resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz",
@@ -2810,28 +2619,6 @@
 				"uuidv7": "cli.js"
 			}
 		},
-		"node_modules/sync-content": {
-			"version": "2.0.1",
-			"resolved": "https://registry.npmjs.org/sync-content/-/sync-content-2.0.1.tgz",
-			"integrity": "sha512-NI1mo514yFhr8pV/5Etvgh+pSBUIpoAKoiBIUwALVlQQNAwb40bTw8hhPFaip/dvv0GhpHVOq0vq8iY02ppLTg==",
-			"dev": true,
-			"dependencies": {
-				"glob": "^11.0.0",
-				"mkdirp": "^3.0.1",
-				"path-scurry": "^2.0.0",
-				"rimraf": "^6.0.0",
-				"tshy": "^3.0.0"
-			},
-			"bin": {
-				"sync-content": "dist/esm/bin.mjs"
-			},
-			"engines": {
-				"node": "20 || >=22"
-			},
-			"funding": {
-				"url": "https://github.com/sponsors/isaacs"
-			}
-		},
 		"node_modules/tar-fs": {
 			"version": "3.0.6",
 			"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.6.tgz",
@@ -2856,9 +2643,10 @@
 			}
 		},
 		"node_modules/testcontainers": {
-			"version": "10.11.0",
-			"resolved": "https://registry.npmjs.org/testcontainers/-/testcontainers-10.11.0.tgz",
-			"integrity": "sha512-TYgpR+MjZSuX7kSUxTa0f/CsN6eErbMFrAFumW08IvOnU8b+EoRzpzEu7mF0d29M1ItnHfHPUP44HYiE4yP3Zg==",
+			"version": "10.12.0",
+			"resolved": "https://registry.npmjs.org/testcontainers/-/testcontainers-10.12.0.tgz",
+			"integrity": "sha512-KEtFj7VvfZPZuyugYJe5aYC/frFN2LRHwQVOVbdZf1vYYGDa4VQt6d0/bM3PcgTE1BOAY6cWBD/S41yu4JQ1Kg==",
+			"license": "MIT",
 			"dependencies": {
 				"@balena/dockerignore": "^1.0.2",
 				"@types/dockerode": "^3.3.29",
@@ -2926,43 +2714,6 @@
 				"node": ">=14.14"
 			}
 		},
-		"node_modules/to-regex-range": {
-			"version": "5.0.1",
-			"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
-			"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
-			"dev": true,
-			"dependencies": {
-				"is-number": "^7.0.0"
-			},
-			"engines": {
-				"node": ">=8.0"
-			}
-		},
-		"node_modules/tshy": {
-			"version": "3.0.2",
-			"resolved": "https://registry.npmjs.org/tshy/-/tshy-3.0.2.tgz",
-			"integrity": "sha512-8GkWnAfmNXxl8iDTZ1o2H4jdaj9H7HeDKkr5qd0ZhQBCNA41D3xqTyg2Ycs51VCfmjJ5e+0v9AUmD6ylAI9Bgw==",
-			"dev": true,
-			"dependencies": {
-				"chalk": "^5.3.0",
-				"chokidar": "^3.6.0",
-				"foreground-child": "^3.1.1",
-				"minimatch": "^10.0.0",
-				"mkdirp": "^3.0.1",
-				"polite-json": "^5.0.0",
-				"resolve-import": "^2.0.0",
-				"rimraf": "^6.0.0",
-				"sync-content": "^2.0.1",
-				"typescript": "^5.5.3",
-				"walk-up-path": "^4.0.0"
-			},
-			"bin": {
-				"tshy": "dist/esm/index.js"
-			},
-			"engines": {
-				"node": "20 || >=22"
-			}
-		},
 		"node_modules/tslib": {
 			"version": "2.7.0",
 			"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz",
@@ -2970,10 +2721,11 @@
 			"peer": true
 		},
 		"node_modules/tsx": {
-			"version": "4.17.0",
-			"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.17.0.tgz",
-			"integrity": "sha512-eN4mnDA5UMKDt4YZixo9tBioibaMBpoxBkD+rIPAjVmYERSG0/dWEY1CEFuV89CgASlKL499q8AhmkMnnjtOJg==",
+			"version": "4.19.0",
+			"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.0.tgz",
+			"integrity": "sha512-bV30kM7bsLZKZIOCHeMNVMJ32/LuJzLVajkQI/qf92J2Qr08ueLQvW00PUZGiuLPP760UINwupgUj8qrSCPUKg==",
 			"dev": true,
+			"license": "MIT",
 			"dependencies": {
 				"esbuild": "~0.23.0",
 				"get-tsconfig": "^4.7.5"
@@ -3590,15 +3342,6 @@
 				}
 			}
 		},
-		"node_modules/walk-up-path": {
-			"version": "4.0.0",
-			"resolved": "https://registry.npmjs.org/walk-up-path/-/walk-up-path-4.0.0.tgz",
-			"integrity": "sha512-3hu+tD8YzSLGuFYtPRb48vdhKMi0KQV5sn+uWr8+7dMEq/2G/dtLrdDinkLjqq5TIbIBjYJ4Ax/n3YiaW7QM8A==",
-			"dev": true,
-			"engines": {
-				"node": "20 || >=22"
-			}
-		},
 		"node_modules/which": {
 			"version": "2.0.2",
 			"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
diff --git a/package.json b/package.json
index 546c993..d48292a 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
 	"name": "@sebastianwessel/surql-gen",
 	"private": false,
-	"version": "2.6.0",
+	"version": "2.6.1",
 	"engines": {
 		"node": ">=18"
 	},
@@ -30,16 +30,16 @@
 		"dev": "tsx src/index.ts",
 		"build": "node build.mjs",
 		"lint": "npx @biomejs/biome check --write .",
-		"test": "vitest",
+		"test": "vitest --run",
 		"prepublishOnly": "npm run lint && vitest --no-watch && npm run build",
 		"postpublish": "npx jsr publish"
 	},
 	"devDependencies": {
 		"@biomejs/biome": "^1.8.3",
-		"@types/node": "^22.5.0",
+		"@types/node": "^22.5.1",
 		"esbuild": "^0.23.1",
 		"jsr": "^0.13.1",
-		"tsx": "^4.17.0",
+		"tsx": "^4.19.0",
 		"typescript": "^5.5.4",
 		"vitest": "^2.0.5"
 	},
@@ -48,7 +48,7 @@
 		"mkdirp": "^3.0.1",
 		"rimraf": "^6.0.1",
 		"surrealdb": "^1.0.0-beta.20",
-		"testcontainers": "^10.11.0",
+		"testcontainers": "^10.12.0",
 		"zod": "^3.23.8"
 	},
 	"exports": {

From 98f69f78392153db1ecc40ec07e41f3aa6c06afb Mon Sep 17 00:00:00 2001
From: Sebastian Wessel <sebastianwessel@users.noreply.github.com>
Date: Fri, 30 Aug 2024 20:08:57 +0100
Subject: [PATCH 3/3] chore: lint and cleanup code

---
 .github/workflows/ci.yml | 10 +++++++---
 src/database/db.ts       |  7 ++++---
 src/index.ts             |  4 +---
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 28cbb25..77eb010 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -21,6 +21,11 @@ jobs:
         id: checkout
         uses: actions/checkout@v4
 
+      - name: Setup Biome
+        uses: biomejs/setup-biome@v2
+        with:
+          version: latest
+
       - name: Setup Node.js
         id: setup-node
         uses: actions/setup-node@v4
@@ -32,9 +37,8 @@ jobs:
         id: npm-ci
         run: npm ci
 
-      - name: Lint
-        id: npm-lint
-        run: npm run lint
+      - name: Run Biome
+        run: biome ci .
 
       - name: Test
         id: npm-ci-test
diff --git a/src/database/db.ts b/src/database/db.ts
index 0a9176f..96e4150 100644
--- a/src/database/db.ts
+++ b/src/database/db.ts
@@ -32,7 +32,8 @@ async function startSurrealDBContainer(config: Config): Promise<StartedTestConta
 		if (error instanceof Error) {
 			if (error.message.includes('pull access denied') || error.message.includes('not found')) {
 				throw new Error(`Invalid or inaccessible Docker image: ${config.surrealImage}`)
-			} else if (error.message.includes('connection refused')) {
+			}
+			if (error.message.includes('connection refused')) {
 				throw new Error('Unable to connect to Docker daemon. Is Docker running?')
 			}
 		}
@@ -44,8 +45,8 @@ export const connectDb = async (config: Config, createInstance = false) => {
 	if (createInstance) {
 		try {
 			container = await startSurrealDBContainer(config)
-		} catch (error: any) {
-			console.error('Error starting SurrealDB container:', error.message)
+		} catch (error) {
+			console.error('Error starting SurrealDB container:', error instanceof Error ? error.message : error)
 			throw error // Re-throw to be caught by the caller if needed
 		}
 	}
diff --git a/src/index.ts b/src/index.ts
index 0137f94..0205129 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -18,7 +18,7 @@ const main = async () => {
 		.version('1.0.0')
 
 	program
-		.option('-f, --schemaFile [schemaFile]', 'a SurrealQL file containing the definitions', )
+		.option('-f, --schemaFile [schemaFile]', 'a SurrealQL file containing the definitions')
 		.option('-c, --config [config]', 'config file', 'surql-gen.json')
 		.option('-s, --surreal [surreal]', 'SurrealDB connection url', 'http://localhost:8000')
 		.option('-u, --username [username]', 'auth username', 'root')
@@ -64,8 +64,6 @@ const main = async () => {
 
 	const config = configFileSchema.parse({ ...options, ...fileContent })
 
-	console.log("config", config)
-
 	try {
 		if (config.schemaFile) {
 			await connectDb(config, true)