Skip to content

Commit 14843e0

Browse files
committed
feat: replace deno runtime with bun runtime + dependency manager
1 parent 0fa68a3 commit 14843e0

File tree

22 files changed

+86
-62
lines changed

22 files changed

+86
-62
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
course_definition_tester
2+
.history/

compiled_starters/typescript/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Time to move on to the next stage!
3030

3131
Note: This section is for stages 2 and beyond.
3232

33-
1. Ensure you have `deno (1.42)` installed locally
33+
1. Ensure you have `bun (1.1)` installed locally
3434
1. Run `./your_sqlite3.sh` to run your program, which is implemented in
3535
`app/main.ts`.
3636
1. Commit your changes and run `git push origin master` to submit your solution
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
const databaseFilePath: string = Deno.args[0];
2-
const command: string = Deno.args[1];
1+
import { open } from 'fs/promises';
2+
import { constants } from 'fs';
3+
4+
const args = process.argv;
5+
const databaseFilePath: string = args[2]
6+
const command: string = args[3];
37

48
if (command === ".dbinfo") {
5-
const databaseFileHandler = await Deno.open(databaseFilePath, { read: true });
6-
const buffer = new Uint8Array(100);
7-
await databaseFileHandler.read(buffer);
9+
const databaseFileHandler = await open(databaseFilePath, constants.O_RDONLY);
10+
const buffer: Uint8Array = new Uint8Array(100);
11+
await databaseFileHandler.read(buffer, 0, buffer.length, 0);
812

913
// You can use print statements as follows for debugging, they'll be visible when running tests.
1014
console.log("Logs from your program will appear here!");
@@ -13,7 +17,7 @@ if (command === ".dbinfo") {
1317
// const pageSize = new DataView(buffer.buffer, 0, buffer.byteLength).getUint16(16);
1418
// console.log(`database page size: ${pageSize}`);
1519

16-
databaseFileHandler.close();
20+
await databaseFileHandler.close();
1721
} else {
1822
throw new Error(`Unknown command ${command}`);
1923
}
2.33 KB
Binary file not shown.

compiled_starters/typescript/codecrafters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ debug: false
77
# Use this to change the TypeScript version used to run your code
88
# on Codecrafters.
99
#
10-
# Available versions: deno-1.42
11-
language_pack: deno-1.42
10+
# Available versions: bun-1.1
11+
language_pack: bun-1.1

compiled_starters/typescript/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"description": "Build your own SQLite challenge, from CodeCrafters",
44
"type": "module",
55
"scripts": {
6-
"dev": "deno run --allow-all app/main.ts"
6+
"dev": "bun run app/main.ts"
77
},
8-
"dependencies": {}
8+
"dependencies": {
9+
"fs-extra": "^11.2.0"
10+
}
911
}

compiled_starters/typescript/your_sqlite3.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# CodeCrafters uses this file to test your code. Don't make any changes here!
66
#
77
# DON'T EDIT THIS!
8-
exec deno run --allow-all ./app/main.ts "$@"
8+
exec bun run ./app/main.ts "$@"

dockerfiles/bun-1.1.Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM oven/bun:1.1.4-alpine
2+
3+
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="package.json,bun.lockb"
4+
5+
WORKDIR /app
6+
7+
COPY package.json ./
8+
COPY bun.lockb ./
9+
10+
# For reproducible builds.
11+
# This will install the exact versions of each package specified in the lockfile.
12+
# If package.json disagrees with bun.lockb, Bun will exit with an error. The lockfile will not be updated.
13+
RUN bun install --frozen-lockfile
14+
15+
RUN mkdir -p /app-cached
16+
# If the node_modules directory exists, move it to /app-cached
17+
RUN if [ -d "/app/node_modules" ]; then mv /app/node_modules /app-cached; fi

dockerfiles/deno-1.42.Dockerfile

Lines changed: 0 additions & 19 deletions
This file was deleted.

solutions/typescript/01-init/code/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Time to move on to the next stage!
3030

3131
Note: This section is for stages 2 and beyond.
3232

33-
1. Ensure you have `deno (1.42)` installed locally
33+
1. Ensure you have `bun (1.1)` installed locally
3434
1. Run `./your_sqlite3.sh` to run your program, which is implemented in
3535
`app/main.ts`.
3636
1. Commit your changes and run `git push origin master` to submit your solution

0 commit comments

Comments
 (0)