Add default gitignore on pc init (#206)
This commit is contained in:
parent
d93e2cec00
commit
d7cd792b57
@ -121,6 +121,10 @@ DEFAULT_DESCRIPTION = "A Pynecone app."
|
||||
DEFAULT_IMAGE = "favicon.ico"
|
||||
|
||||
|
||||
# The gitignore file.
|
||||
GITIGNORE_FILE = ".gitignore"
|
||||
# Files to gitignore.
|
||||
DEFAULT_GITIGNORE = {".web", DB_NAME}
|
||||
# The name of the pynecone config module.
|
||||
CONFIG_MODULE = "pcconfig"
|
||||
# The python config file.
|
||||
|
@ -39,6 +39,9 @@ def init():
|
||||
utils.create_config(app_name)
|
||||
utils.initialize_app_directory(app_name)
|
||||
|
||||
# Initialize the .gitignore.
|
||||
utils.initialize_gitignore()
|
||||
|
||||
# Finish initializing the app.
|
||||
utils.console.log(f"[bold green]Finished Initializing: {app_name}")
|
||||
|
||||
|
@ -377,6 +377,21 @@ def create_config(app_name: str):
|
||||
f.write(templates.PCCONFIG.format(app_name=app_name))
|
||||
|
||||
|
||||
def initialize_gitignore():
|
||||
"""Initialize the template .gitignore file."""
|
||||
# The files to add to the .gitignore file.
|
||||
files = constants.DEFAULT_GITIGNORE
|
||||
|
||||
# Subtract current ignored files.
|
||||
if os.path.exists(constants.GITIGNORE_FILE):
|
||||
with open(constants.GITIGNORE_FILE, "r") as f:
|
||||
files -= set(f.read().splitlines())
|
||||
|
||||
# Add the new files to the .gitignore file.
|
||||
with open(constants.GITIGNORE_FILE, "a") as f:
|
||||
f.write(join(files))
|
||||
|
||||
|
||||
def initialize_app_directory(app_name: str):
|
||||
"""Initialize the app directory on pc init.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user