DjangoGirls / tutorial

This is a tutorial we are using for Django Girls workshops
http://tutorial.djangogirls.org/
Other
1.53k stars 1.86k forks source link

[Improvement] Makefile for Development #1729

Closed nikhiljohn10 closed 2 years ago

nikhiljohn10 commented 3 years ago

Features

Make

Usage: make command [LANG=<language_short_code>]

    LANG: Language shortcodes are found in LANGS.md. Default is 'en'(English).
           ( Refer LANGS.md for shortcodes of Languages available. )

Commands:
  help      - Display make command list.
  dev       - Setup the project and start the development server with debugging enabled.
  check     - Check for the root directory for various dependencies.
  setup     - Setup the temporary language and install node dependencies for the development.
  build     - Build the honkit project.
  build-dev - Build the honkit project with debug log.
  serve     - Start honkit server locally for development.
  pdf       - Generate the PDF version of DjangoGirls tutorial.
  epub      - Generate the EPUB version of DjangoGirls tutorial.
  mobi      - Generate the MOBI version of DjangoGirls tutorial.
  mode      - Shows the development mode status.
  exit      - Exit development mode.

Example:

$ make dev LANG=es

The above command will start the development server using the language Español.
'LANG' argument is only required the first time until the exit command is executed.

1728 Completed

nikhiljohn10 commented 3 years ago

@ekohl Regarding LANGS.md.bak, it is used as a marker for detecting development mode. If this file exist, this means few things -> language is isolated, make check is success and server is ready to start.

The whole idea behind this script when I begun making it was based on one thought "Why am I waiting for all the languages to build each time I run a build or serve command, while I only dealing with english?"

Using this methods, the build time is decreased by 90%. Without using the script, it take 90s-100s. WIth this script, it takes only 7s-8s. Which means that I got around 12 times faster in my development process (ideal case). This is my philosphy.

I have checked the structure.languages variable. It would be much more complicated than this one. Chances for making error inside the file is so much higher. I have been testing this script in WSL, MacOS and Ubuntu. Everything works fine now. I have added few more commands on the way. I'll post it as command before pushing it to the PR.

nikhiljohn10 commented 3 years ago

Considering all previous converstion, I have made some tweaking is the whole structure and many targets. Not fully tested.

New Commands Added

nikhiljohn10 commented 3 years ago

@ekohl I have squashed the commits and pushed it. Let me know you thoughts.

nikhiljohn10 commented 3 years ago

I generally agree with that, so another option can be to make the node_modules target fail with a message "you need to run npx install. Also note that I think should be a regular target, not a PHONY. That way, if the directory exists, make will be happy and not run anything.

I'll try that out and get back to you. Thanks for the reply.

nikhiljohn10 commented 2 years ago

Lets take the scenario where npm modules are already installed. npm will have to run again before start serving when make serve is ran. But it is possible since it live reload server. Personally, I dont prefer this method incase I have network problem and my local server will not running. This is waste of time. But if your method is more acceptable generally, i can change that. Let me know your thoughts on my point of view.

I generally agree with that, so another option can be to make the node_modules target fail with a message "you need to run npx install. Also note that I think should be a regular target, not a PHONY. That way, if the directory exists, make will be happy and not run anything.

@ekohl It is fixed in c01634f

nikhiljohn10 commented 2 years ago

@das-g Anymore changes required?

das-g commented 2 years ago

@das-g Anymore changes required?

Sorry, I don't have time for a review right now (maybe mid-next-week). @ekohl can you take another look?

ekohl commented 2 years ago

Sorry, also swamped with work.

das-g commented 2 years ago

As I doubt that this can break anything already existing, I'll merge now. If needed, we can improve upon that later on.