Skip to content

Commit

Permalink
feat: add support for package.json
Browse files Browse the repository at this point in the history
update deno run to take --allow-all.
  • Loading branch information
ryan-gang committed Apr 23, 2024
1 parent 1d8b084 commit 4c9a3f0
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 12 deletions.
1 change: 1 addition & 0 deletions compiled_starters/typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
9 changes: 9 additions & 0 deletions compiled_starters/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@codecrafters/build-your-own-grep",
"description": "Build your own Grep challenge, from CodeCrafters",
"type": "module",
"scripts": {
"dev": "deno run --allow-all app/main.ts"
},
"dependencies": {}
}
2 changes: 1 addition & 1 deletion compiled_starters/typescript/your_grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# CodeCrafters uses this file to test your code. Don't make any changes here!
#
# DON'T EDIT THIS!
exec deno run --allow-read --allow-write app/main.ts "$@"
exec deno run --allow-all app/main.ts "$@"
17 changes: 17 additions & 0 deletions dockerfiles/deno-1.42.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
FROM denoland/deno:alpine-1.42.0

RUN apk add --no-cache 'git>=2.40'

ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="package.json"

WORKDIR /app

COPY package.json ./
# If users import dependencies in files foo.ts and bar.ts, unless those files are present while running deno cache, these dependencies will not be resolved.
# Even if they are present in package.json#dependencies.
COPY app/ ./app/
RUN deno cache app/main.ts
RUN rm -rf ./app/

RUN mkdir -p /app-cached
# If the node_modules directory exists, move it to /app-cached
RUN if [ -d "/app/node_modules" ]; then mv /app/node_modules /app-cached; fi

RUN printf "cd \${CODECRAFTERS_SUBMISSION_DIR} && deno cache app/main.ts" > /codecrafters-precompile.sh
RUN chmod +x /codecrafters-precompile.sh
1 change: 1 addition & 0 deletions solutions/typescript/01-init/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
9 changes: 9 additions & 0 deletions solutions/typescript/01-init/code/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@codecrafters/build-your-own-grep",
"description": "Build your own Grep challenge, from CodeCrafters",
"type": "module",
"scripts": {
"dev": "deno run --allow-all app/main.ts"
},
"dependencies": {}
}
2 changes: 1 addition & 1 deletion solutions/typescript/01-init/code/your_grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# CodeCrafters uses this file to test your code. Don't make any changes here!
#
# DON'T EDIT THIS!
exec deno run --allow-read --allow-write app/main.ts "$@"
exec deno run --allow-all app/main.ts "$@"
4 changes: 4 additions & 0 deletions starter-repository-definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,14 @@
target: codecrafters.yml
- source: starter_templates/typescript/app/main.ts
target: app/main.ts
- source: starter_templates/typescript/package.json
target: package.json
- source: starter_templates/typescript/your_grep.sh
target: your_grep.sh
- source: starter_templates/.gitattributes
target: .gitattributes
- source: starter_templates/typescript/.gitignore
target: .gitignore
template_attributes:
required_executable: "deno (1.42)"
user_editable_file: "app/main.ts"
1 change: 1 addition & 0 deletions starter_templates/typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 0 additions & 3 deletions starter_templates/typescript/deno.json

This file was deleted.

6 changes: 0 additions & 6 deletions starter_templates/typescript/deno.lock

This file was deleted.

9 changes: 9 additions & 0 deletions starter_templates/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@codecrafters/build-your-own-grep",
"description": "Build your own Grep challenge, from CodeCrafters",
"type": "module",
"scripts": {
"dev": "deno run --allow-all app/main.ts"
},
"dependencies": {}
}
2 changes: 1 addition & 1 deletion starter_templates/typescript/your_grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# CodeCrafters uses this file to test your code. Don't make any changes here!
#
# DON'T EDIT THIS!
exec deno run --allow-read --allow-write app/main.ts "$@"
exec deno run --allow-all app/main.ts "$@"

0 comments on commit 4c9a3f0

Please sign in to comment.