Cookiecutter Extended
Project description
CCExtender -- Cookiecutter with branching builds
(Public github link to be added soon)
Commands
ccextender
help
--ccx_config, -c <Path to configuration file>
--std_template, -s <Path to template containing defaults for your standards> (See #standards)
--test_mode, -t #Activates test mode (which disables prompts for stdin)
--outdir, -o <Path to desired repository location>
Installation
Prequisites:
Python 3
oyaml - a python package allowing for yaml files to read as an ordered dictionary cookiecutter - a templating application
pip3 install cookiecutter oyaml
pip3 install ccextender
Usage
CCExtender requires a yaml configuration file and at least one cookiecutter template directory to function.
For more information on how to set up cookiecutter templates, visit: https://cookiecutter.readthedocs.io/en/latest/first_steps.html
For how to setup a configuration file, read the #Configuration section of this doc.
- Create a configuration file.
Your configuration file will contain the logic for your interactive build, directions to the templates you plan to use, and what templatized changes should be associated with your decisions.
By default, ccextender will look for a file named ccextender.yaml in your current directory, but you can direct it to read any file through the --ccx_config flag:
ccextender --ccx_config=/Users/me/Documents/myconfig.yaml
Your configuration file must follow the YAML format. To see how to write a CCExtender config file, see #Configuration.
- Run CCExtender
Once the configuration file is created, CCExtender will do the rest. All that remains is for you to respond to the prompts established in your YAML file.
Examples of use:
To read in a particular configuration file and write the output to a different directory:
ccextender -c /Users/me/Documents/SecDev_Build.yaml -o /python/src/github.com/asecurityteam/
To see available commands:
ccextender help
To use a specific template for the default values for your standards (#standards):
ccextender -s template-standards
NOTE: This isn't a path or location of the template, but merely the template's directory name. You should add the templates location in the configuration file under the "locations" section.(#configuration)
To run using the default variables:
ccextender
The default values for each command is:
--ccx_config, -c = ccextender.yaml
--std_template, -s = template-standards
--test_mode, -t = None
--outdir, -o = .
- Create practice templates
Create template directories
mkdir templates
cd templates
mkdir -p template-project-info/{{cookiecutter.project_name}}
mkdir -p template-hello/{{cookiecutter.project_name}}
mkdir -p template-goodbye/{{cookiecutter.project_name}}
mkdir -p template-standards/{{cookiecutter.project_name}}
Create README template
In the template-project-info/ directory, add file cookiecutter.json with the following contents:
{
"project_name": "HelloWorld",
"owner": "New User",
"contact_email": "you@default.com"
}
Then move into the lower directory:
cd {{cookiecutter.project_name}}
Add file README.txt with the following contents:
{{cookiecutter.project_name}} Project Documentation
This project was created by:
{{cookiecutter.owner}}
For questions about this project, please email {{cookiecutter.contact_email}}.
Create Hello World template
In the template-hello directory, add file cookiecutter.json with the following contents:
{
"project_name": "HelloWorld",
"contact_email": "you@default.com",
"owner": "New User",
"greeting": "Hello"
}
Then move into the lower directory:
cd {{cookiecutter.project_name}}
Add file hello.py with the following contents:
print("{{cookiecutter.owner}} would like to say {{cookiecutter.greeting}}")
Create Goodbye template
In the template-goodbye directory, add a file cookiecutter.json with the following content:
{
"project_name": "HelloWorld",
"contact_email": "you@default.com",
"owner": "New User",
"greeting": "Goodbye"
}
Then move into the lower directory:
cd {{cookiecutter.project_name}}
Add file hello.py with the following contents:
print("{{cookiecutter.owner}} would like to say {{cookiecutter.greeting}}")
Create Standards Template
In the template-standards directory, add file cookiecutter.json with the following contents:
{
"project_name": "HelloWorld",
"owner": "New User",
"contact_email": "you@default.com"
}
Create your configuration file
In your templates folder, create a file ccextender.yaml with the following content:
CCX_Version: 1.1
standard-context:
project_name: "HelloWorld"
owner: "New User"
contact_email: "you@default.com"
decisions:
readme:
query:
prompt: "Would you like to [1] add project readme info?"
yes:
- project-info
greeting:
query:
prompt: "Would you like to say [1] hello or [2] goodbye?"
include-if:
- yes
hello:
- hello-pack
goodbye:
- goodbye-pack
change-packs:
hello-pack:
template-hello:
greeting: "Howdy"
goodbye-pack:
template-goodbye:
project-info:
template-project-info:
locations:
home:
- <path to your templates folder>
template-hello:
- $!home$
- template-hello
template-goodbye:
- $!home$
- template-goodbye
template-project-info:
- $!home$
- template-project-info
template-standards:
- $!home$
- template-standards
Run CCExtender
Now, navigate to the directory where you saved ccextender.yaml and then type:
ccextender
Answer the prompts. Once you are finished, you should see a new repository has been created in your current directory. Navigate into the repo and the run:
python hello.py
You should see that your changes have been implemented. Try running the program a few times, and you’ll see how the build changes.
Configuration
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for ccextender-1.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e6c0471668acee2e8730540b4cb1a50ce6e8ff429f7b33e6b40a68b1684f867 |
|
MD5 | f57f942c9a2a254108474903fcba3490 |
|
BLAKE2b-256 | c1ab80526c5364af0366b8d0a714f670f0d3c99911fe50990c465c9909aec05b |