From 4c9a3f01ca6f85eb268a3354dc548dfc0cec8d60 Mon Sep 17 00:00:00 2001 From: Ryan Gang Date: Tue, 23 Apr 2024 14:23:14 +0530 Subject: [PATCH] feat: add support for package.json update deno run to take --allow-all. --- compiled_starters/typescript/.gitignore | 1 + compiled_starters/typescript/package.json | 9 +++++++++ compiled_starters/typescript/your_grep.sh | 2 +- dockerfiles/deno-1.42.Dockerfile | 17 +++++++++++++++++ solutions/typescript/01-init/code/.gitignore | 1 + solutions/typescript/01-init/code/package.json | 9 +++++++++ solutions/typescript/01-init/code/your_grep.sh | 2 +- starter-repository-definitions.yml | 4 ++++ starter_templates/typescript/.gitignore | 1 + starter_templates/typescript/deno.json | 3 --- starter_templates/typescript/deno.lock | 6 ------ starter_templates/typescript/package.json | 9 +++++++++ starter_templates/typescript/your_grep.sh | 2 +- 13 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 compiled_starters/typescript/.gitignore create mode 100644 compiled_starters/typescript/package.json create mode 100644 solutions/typescript/01-init/code/.gitignore create mode 100644 solutions/typescript/01-init/code/package.json create mode 100644 starter_templates/typescript/.gitignore delete mode 100644 starter_templates/typescript/deno.json delete mode 100644 starter_templates/typescript/deno.lock create mode 100644 starter_templates/typescript/package.json diff --git a/compiled_starters/typescript/.gitignore b/compiled_starters/typescript/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/compiled_starters/typescript/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/compiled_starters/typescript/package.json b/compiled_starters/typescript/package.json new file mode 100644 index 0000000..788486a --- /dev/null +++ b/compiled_starters/typescript/package.json @@ -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": {} +} \ No newline at end of file diff --git a/compiled_starters/typescript/your_grep.sh b/compiled_starters/typescript/your_grep.sh index 9b97e54..3633b46 100755 --- a/compiled_starters/typescript/your_grep.sh +++ b/compiled_starters/typescript/your_grep.sh @@ -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 "$@" diff --git a/dockerfiles/deno-1.42.Dockerfile b/dockerfiles/deno-1.42.Dockerfile index 8ef460e..b2b4128 100644 --- a/dockerfiles/deno-1.42.Dockerfile +++ b/dockerfiles/deno-1.42.Dockerfile @@ -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 diff --git a/solutions/typescript/01-init/code/.gitignore b/solutions/typescript/01-init/code/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/solutions/typescript/01-init/code/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/solutions/typescript/01-init/code/package.json b/solutions/typescript/01-init/code/package.json new file mode 100644 index 0000000..788486a --- /dev/null +++ b/solutions/typescript/01-init/code/package.json @@ -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": {} +} \ No newline at end of file diff --git a/solutions/typescript/01-init/code/your_grep.sh b/solutions/typescript/01-init/code/your_grep.sh index 9b97e54..3633b46 100755 --- a/solutions/typescript/01-init/code/your_grep.sh +++ b/solutions/typescript/01-init/code/your_grep.sh @@ -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 "$@" diff --git a/starter-repository-definitions.yml b/starter-repository-definitions.yml index 717a391..e5b8db3 100644 --- a/starter-repository-definitions.yml +++ b/starter-repository-definitions.yml @@ -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" diff --git a/starter_templates/typescript/.gitignore b/starter_templates/typescript/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/starter_templates/typescript/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/starter_templates/typescript/deno.json b/starter_templates/typescript/deno.json deleted file mode 100644 index 9f5a19a..0000000 --- a/starter_templates/typescript/deno.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "imports": {} -} diff --git a/starter_templates/typescript/deno.lock b/starter_templates/typescript/deno.lock deleted file mode 100644 index 8709ae0..0000000 --- a/starter_templates/typescript/deno.lock +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "3", - "packages": { - }, - "remote": {} -} \ No newline at end of file diff --git a/starter_templates/typescript/package.json b/starter_templates/typescript/package.json new file mode 100644 index 0000000..788486a --- /dev/null +++ b/starter_templates/typescript/package.json @@ -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": {} +} \ No newline at end of file diff --git a/starter_templates/typescript/your_grep.sh b/starter_templates/typescript/your_grep.sh index 9b97e54..3633b46 100755 --- a/starter_templates/typescript/your_grep.sh +++ b/starter_templates/typescript/your_grep.sh @@ -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 "$@"