Skip to content

Commit

Permalink
Merge pull request #67 from codecrafters-io/CC-1157-npm
Browse files Browse the repository at this point in the history
CC-1157: add dependency resolution for js projects + update nodejs
  • Loading branch information
rohitpaulk authored Apr 26, 2024
2 parents 06fda55 + a1c7ec8 commit 34c6968
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 9 deletions.
1 change: 1 addition & 0 deletions compiled_starters/javascript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
2 changes: 1 addition & 1 deletion compiled_starters/javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Time to move on to the next stage!

Note: This section is for stages 2 and beyond.

1. Ensure you have `node (18)` installed locally
1. Ensure you have `node (21)` installed locally
1. Run `./your_grep.sh` to run your program, which is implemented in
`app/main.js`.
1. Commit your changes and run `git push origin master` to submit your solution
Expand Down
4 changes: 2 additions & 2 deletions compiled_starters/javascript/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ debug: false
# Use this to change the JavaScript version used to run your code
# on Codecrafters.
#
# Available versions: nodejs-18
language_pack: nodejs-18
# Available versions: nodejs-21
language_pack: nodejs-21
14 changes: 14 additions & 0 deletions compiled_starters/javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions compiled_starters/javascript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@codecrafters/build-your-own-grep",
"version": "1.0.0",
"description": "Build your own Grep challenge, from CodeCrafters",
"main": "main.js",
"scripts": {
"dev": "node app/main.js"
},
"keywords": [
"build-your-own-x"
],
"author": "",
"license": "MIT",
"dependencies": {}
}
15 changes: 15 additions & 0 deletions dockerfiles/nodejs-21.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:21.7-alpine3.19

ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="package.json,package-lock.json"

WORKDIR /app

COPY package.json ./
COPY package-lock.json ./

# If dependencies in the package lock do not match those in package.json, instead of updating the package lock, npm ci will exit with an error.
RUN npm ci

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
1 change: 1 addition & 0 deletions solutions/javascript/01-init/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
2 changes: 1 addition & 1 deletion solutions/javascript/01-init/code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Time to move on to the next stage!

Note: This section is for stages 2 and beyond.

1. Ensure you have `node (18)` installed locally
1. Ensure you have `node (21)` installed locally
1. Run `./your_grep.sh` to run your program, which is implemented in
`app/main.js`.
1. Commit your changes and run `git push origin master` to submit your solution
Expand Down
4 changes: 2 additions & 2 deletions solutions/javascript/01-init/code/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ debug: false
# Use this to change the JavaScript version used to run your code
# on Codecrafters.
#
# Available versions: nodejs-18
language_pack: nodejs-18
# Available versions: nodejs-21
language_pack: nodejs-21
14 changes: 14 additions & 0 deletions solutions/javascript/01-init/code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions solutions/javascript/01-init/code/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@codecrafters/build-your-own-grep",
"version": "1.0.0",
"description": "Build your own Grep challenge, from CodeCrafters",
"main": "main.js",
"scripts": {
"dev": "node app/main.js"
},
"keywords": [
"build-your-own-x"
],
"author": "",
"license": "MIT",
"dependencies": {}
}
8 changes: 7 additions & 1 deletion starter-repository-definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,20 @@
target: README.md
- source: starter_templates/codecrafters.yml
target: codecrafters.yml
- source: starter_templates/javascript/package.json
target: package.json
- source: starter_templates/javascript/package-lock.json
target: package-lock.json
- source: starter_templates/javascript/app/main.js
target: app/main.js
- source: starter_templates/javascript/your_grep.sh
target: your_grep.sh
- source: starter_templates/.gitattributes
target: .gitattributes
- source: starter_templates/javascript/.gitignore
target: .gitignore
template_attributes:
required_executable: "node (18)"
required_executable: "node (21)"
user_editable_file: "app/main.js"

- language: csharp
Expand Down
4 changes: 2 additions & 2 deletions starter_templates/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ language_pack: go-1.22
language_pack: php-7.4
{{/ language_is_php }}
{{# language_is_javascript }}
# Available versions: nodejs-18
language_pack: nodejs-18
# Available versions: nodejs-21
language_pack: nodejs-21
{{/ language_is_javascript }}
{{# language_is_c }}
# Available versions: c-9.2
Expand Down
1 change: 1 addition & 0 deletions starter_templates/javascript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
14 changes: 14 additions & 0 deletions starter_templates/javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions starter_templates/javascript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@codecrafters/build-your-own-grep",
"version": "1.0.0",
"description": "Build your own Grep challenge, from CodeCrafters",
"main": "main.js",
"scripts": {
"dev": "node app/main.js"
},
"keywords": [
"build-your-own-x"
],
"author": "",
"license": "MIT",
"dependencies": {}
}

0 comments on commit 34c6968

Please sign in to comment.