Skip to main content

A local development server to get live previews of [cookiecutter templates](https://github.com/cookiecutter/cookiecutter).

Project description

cookiecutter-server

build PyPI PyPI - Python Version PyPI - License

A local development server to get live previews of cookiecutter templates.

Are there too many code paths in your cookiecutter templates? You need an easy way to check what your template looks like with different parameters? cookiecutter-server got you covered! It's a process that watches the source folder of your template and serves the rendered template in a different folder. Whenever you make a change in your template or select different parameters, the rendered template gets updated automatically.

Getting Started

Install cookiecutter-server with

pip install cookiecutter-server

This will make the cc_server command available on your terminal. Test it with

cc_server --help

In case the command was not registered, you can use python -m cc_server instead.

Now switch to your cookiecutter template folder and run

cc_server .

This will launch cookiecutter-server in the current folder and render the template in a new folder named serve under the current folder. Of course, you can also provide custom paths, if you prefer:

cc_server path/to/cookiecutter -o path/to/output

The server process will now watch your template folder for changes. Please make a change in one of your template files and save the file. On the terminal, cc_server will tell you

updating due to change in {changed file}

Now open this file in the output folder; your changes have already been applied. If you don't see the changes, please re-open the file or use an editor that automatically updates files when they change on disk, like PyCharm or VSCode.

How do you change your template parameters? In your cookiecutter template folder, a new file named cookiecutter-server.yml was created, which contains all the parameters of your template. Change the parameters to your liking and save the file, cookiecutter-server will immediately update the contents of the output folder.

To stop the server, use Ctrl+C on your terminal.

If you're having trouble with cookiecutter-server, please have a look at the open issues and open a new one, if you can't find a solution.

Contributing

To set up your local development environment, please use a fresh virtual environment, then run:

pip install -r requirements.txt -r requirements-dev.txt
pip install -e .

You can now launch the server from the command line; try cc_server --help.

We use pytest as test framework. To execute the tests, please run

python setup.py test

To build a distribution package (wheel), please use

python setup.py dist

this will clean up the build folder and then run the bdist_wheel command.

Before contributing code, please set up the pre-commit hooks to reduce errors and ensure consistency

pip install -U pre-commit
pre-commit install

PyPI Release

This project is released on PyPI. Most of the tedious steps that are required to test & publish your release are automated by CI pipelines. All you have to do is to write your code and when the time comes to make a release, please follow these steps:

  • update the program version in src/cc_server/version.py
  • write a summary of your changes in CHANGELOG.md
  • add a tag on the master branch with the new version number preceded by the letter v, e.g. for version 1.0.0 the tag would be v1.0.0. To tag the head of the current branch, use git tag v1.0.0
  • push your changes to GitHub and don't forget to push the tag with git push origin v1.0.0
  • now have a look at the release pipeline; if it finishes without errors, you can find your release on TestPyPI. Please verify that your release works as expected.
  • Now for the live deployment on PyPI. To avoid mistakes, this is only triggered, when a release is published on GitHub first. Please have a look at the Releases now; there should be a draft release with your version number (this was created by the CI pipeline which also made the TestPyPI release). Edit the draft release, copy the text you added to CHANGELOG.md into the description field and publish it.
  • After you publish the release, the deploy pipeline is triggered on GitHub. It will publish the release directly to PyPI where everyone can enjoy your latest features.

Contact

Sebastian Straub (sebastian.straub [at] alexanderthamm.com)

Developed with ❤ at Alexander Thamm GmbH

License

Copyright 2021 Alexander Thamm GmbH

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cookiecutter_server-1.2.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cookiecutter_server-1.2.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file cookiecutter_server-1.2.0.tar.gz.

File metadata

  • Download URL: cookiecutter_server-1.2.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for cookiecutter_server-1.2.0.tar.gz
Algorithm Hash digest
SHA256 51f2980483798fc7e251bd058639c98126821c0c1dd60342a91c7c7b9f894997
MD5 00fa8f25914c070f64b84703bd1bbab2
BLAKE2b-256 268859f60f0487766ea56e7cb87354cde2eb4d8887009b14353ec9a5cbcb41df

See more details on using hashes here.

File details

Details for the file cookiecutter_server-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cookiecutter_server-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f52e4a72207668ff60145c8cee2496862d7c765f21924d8107de27aa844c9e7
MD5 ca5bbc5335681acd2d596b618d68102e
BLAKE2b-256 87b448721cc2c440a148a9e4f41d9402633825cd6db5b888f54e61cc1f23d361

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page