Skip to content

Commit

Permalink
fix: tutorial code fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yanksyoon committed Jan 13, 2025
1 parent cea6fe4 commit b20ebea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
22 changes: 11 additions & 11 deletions docs/tutorial/code/expressjs/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@ summary: Getting started with FastAPI tutorial
environment:

execute: |
# [docs:create-venv]
sudo apt update && sudo apt install npm
# [docs:init-app]
sudo apt-get update -y && sudo apt-get install npm -y
npm install -g express-generator
echo "y" | npx express-generator app
cd app && npm install
# [docs:create-venv-end]
# [docs:init-app-end]
npm start &
cd ..
retry -n 5 --wait 2 curl --fail localhost:3000
# [docs:curl-expressjs]
curl localhost:3000
# [docs:curl-expressjs-end]
kill $!
kill $(lsof -t -i:3000)
# [docs:create-rockcraft-yaml]
rockcraft init --profile expressjs-framework
Expand Down Expand Up @@ -68,9 +70,7 @@ execute: |
# [docs:stop-docker-end]
# [docs:change-base]
sed -i \
"s/base: .*/base: bare\nbuild-base: [email protected]/g" \
rockcraft.yaml
sed -i "s/base: bare/base: [email protected]/g" rockcraft.yaml
# [docs:change-base-end]
sed -i "s/version: .*/version: 0.1-chiselled/g" rockcraft.yaml
Expand Down Expand Up @@ -101,7 +101,9 @@ execute: |
sudo docker rmi expressjs-hello-world:0.1-chiselled
# [docs:stop-docker-chisel-end]
cat time_app.py > app.py
ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=True rockcraft clean
mv time.js app/routes/
mv app.js app/
sed -i "s/version: .*/version: 0.2/g" rockcraft.yaml
# [docs:docker-run-update]
Expand All @@ -126,11 +128,9 @@ execute: |
# [docs:cleanup]
# exit and delete the virtual environment
deactivate
rm -rf .venv __pycache__
# delete all the files created during the tutorial
rm expressjs-hello-world_0.1_amd64.rock \
expressjs-hello-world_0.1-chiselled_amd64.rock \
expressjs-hello-world_0.2_amd64.rock \
rockcraft.yaml app.py requirements.txt
rockcraft.yaml
# [docs:cleanup-end]
4 changes: 2 additions & 2 deletions docs/tutorial/expressjs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Create the ExpressJS application by running the express-generator.

.. literalinclude:: code/expressjs/task.yaml
:language: bash
:start-after: [docs:create-venv]
:end-before: [docs:create-venv-end]
:start-after: [docs:init-app]
:end-before: [docs:init-app-end]
:dedent: 2

Run the ExpressJS application using ``npm start`` to verify
Expand Down
1 change: 0 additions & 1 deletion rockcraft/templates/expressjs-framework/rockcraft.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: {{name}}
# see {{versioned_url}}/explanation/bases/
# for more information about bases and using 'bare' bases for chiselled rocks
base: [email protected] # as an alternative, a 'bare' base can be used
build-base: [email protected] # build-base is required when the base is bare
version: '0.1' # just for humans. Semantic versioning is recommended
summary: A summary of your ExpresssJS application # 79 char long summary
description: |
Expand Down

0 comments on commit b20ebea

Please sign in to comment.