diff --git a/.devcontainer.json b/.devcontainer.json index c8b423bb..82b6eac9 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -11,7 +11,8 @@ "[python]": { "editor": { "defaultFormatter": "ms-python.black-formatter" - } + }, + "pipenvPath": "pipenv" } } } diff --git a/.gitignore b/.gitignore index bc01357d..845bdfcb 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ devenv.local.nix # pre-commit .pre-commit-config.yaml +.vscode \ No newline at end of file diff --git a/.vscode/launch.template.json b/.vscode/launch.template.json new file mode 100644 index 00000000..ddc23bdc --- /dev/null +++ b/.vscode/launch.template.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Django", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/manage.py", + "env": { + "DEBUG": "False" + }, + "args": [ + "runserver" + ], + "django": true, + "justMyCode": true + } + ] +} \ No newline at end of file diff --git a/devenv.nix b/devenv.nix index dc52b12d..884a28b9 100644 --- a/devenv.nix +++ b/devenv.nix @@ -18,9 +18,12 @@ pipenv install --dev npm i gulp migrate - gulp ''; + processes = { + gulp.exec = "gulp"; + }; + # https://devenv.sh/languages/ languages.python.enable = true; languages.javascript = { @@ -31,6 +34,7 @@ devcontainer = { enable = true; settings.customizations.vscode.settings."[python]".editor.defaultFormatter = "ms-python.black-formatter"; + settings.customizations.vscode.settings."[python]".pipenvPath = "pipenv"; settings.customizations.vscode.extensions = [ "bbenoist.Nix" "ms-python.python" diff --git a/docs/contributing/development-environment.md b/docs/contributing/development-environment.md index 06ac6657..64449952 100644 --- a/docs/contributing/development-environment.md +++ b/docs/contributing/development-environment.md @@ -81,8 +81,41 @@ username and password (`admin`/`admin`). 1. Install devenv (linux/mac/windows subsystem for linux/docker) via https://devenv.sh/getting-started/ 1. git clone the repo -1. run `devenv shell` +1. here you have two options + 1. run `devenv shell` and then run `gulp` + 1. _OR_ run `devenv up` which automatically runs gulp/nodejs/python as well 1. Open [http://127.0.0.1:8000](http://127.0.0.1:8000) and log in with the default username and password (`admin`/`admin`). -Devenv also generates the devcontainer for vscode, and sets up github codespaces support. To run babybuddy, open a terminal after opening this repo in the devcontainer \ No newline at end of file +Devenv also generates the **.devcontainer for vscode**, and sets up **github codespaces support**. To run babybuddy in the devcontainer or codespaces, open a terminal after opening this repo in the devcontainer, which causes the dependencies to be installed via `devenv shell`. Then, run `gulp` to start the baby buddy server. + +### Debugging in devenv + vscode +To debug in devenv + vscode/codespaces: + +1. add a `.vscode/launch.json` file like this: +```json +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Django", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/manage.py", + "env": { + "DEBUG": "False" + }, + "args": [ + "runserver" + ], + "django": true, + "justMyCode": true + } + ] +} +``` +2. Consider running `gulp fake --children 5 --days 7` as explained in the [gulp command reference](./gulp-command-reference.md) to add some fake data to the database +3. Click Run -> Start Debugging (F5) and set your breakpoints in the python as desired