Skip to content

Commit

Permalink
feat: add no-git option to new-app command
Browse files Browse the repository at this point in the history
  • Loading branch information
phot0n committed Nov 30, 2021
1 parent b11f5b0 commit 2a25a6d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
21 changes: 18 additions & 3 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,27 @@ def get_app(
app.install(verbose=verbose, skip_assets=skip_assets)


def new_app(app, bench_path="."):
def new_app(app, no_git=None, bench_path="."):
if bench.FRAPPE_VERSION in (0, None):
raise NotInBenchDirectoryError(
f"{os.path.realpath(bench_path)} is not a valid bench directory."
)

# For backwards compatibility
app = app.lower().replace(" ", "_").replace("-", "_")
logger.log(f"creating new app {app}")
apps = os.path.abspath(os.path.join(bench_path, "apps"))
run_frappe_cmd("make-app", apps, app, bench_path=bench_path)
args = ["make-app", apps, app]
if no_git:
if bench.FRAPPE_VERSION < 14:
click.secho(
"Frappe v14 or greater is needed for '--no-git' flag",
fg="red"
)
return
args.append(no_git)

logger.log(f"creating new app {app}")
run_frappe_cmd(*args, bench_path=bench_path)
install_app(app, bench_path=bench_path)


Expand Down
10 changes: 8 additions & 2 deletions bench/commands/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,17 @@ def get_app(


@click.command("new-app", help="Create a new Frappe application under apps folder")
@click.option(
"--no-git",
is_flag=True,
flag_value="--no-git",
help="Do not initialize git repository for the app (available in Frappe v14+)"
)
@click.argument("app-name")
def new_app(app_name):
def new_app(app_name, no_git=None):
from bench.app import new_app

new_app(app_name)
new_app(app_name, no_git)


@click.command(
Expand Down

0 comments on commit 2a25a6d

Please sign in to comment.