Skip to content

Commit

Permalink
Default project is installed locally for faster initializations
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSpaar committed Dec 22, 2023
1 parent 78c9335 commit 6f23a5d
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 25 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
graft src/markdown_spa/cli/blank
include src/markdown_spa/extensions/Tailwind/tailwind.config.js
include src/markdown_spa/extensions/SASS/main.scss
include src/markdown_spa/extensions/Sitemap/sitemap.xml
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 8 additions & 25 deletions src/markdown_spa/cli/project.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from ..generator import Generator, Dependency
from .utils import echo, initialize_extension, silent_call, ensure_installed, build_project
from .utils import echo, initialize_extension, echo_wrap, ensure_installed, build_project


from os.path import exists
from shutil import copytree
from os import listdir, chdir
from pathlib import Path as PPath
from shutil import copytree, rmtree

from click import Path, command, option, argument, prompt

Expand All @@ -18,30 +19,11 @@ def init(path: str) -> int:
echo("A file or directory with that name already exists!", fg="red", bold=True)
return 1

echo("Cloning blank project... ", nl=False)
if err := silent_call(f"git clone --depth=1 https://github.com/MrSpaar/markdown_spa.git --no-checkout {path}"):
echo("failed.", fg="red", bold=True)
echo(err)
return 1

chdir(path)
commands = (
"git config core.sparseCheckout true",
"echo 'blank/' >> .git/info/sparse-checkout",
"git checkout"
)

for command in commands:
if err := silent_call(command):
echo("failed.", fg="red", bold=True)
echo(err)
return 1

copytree("blank", ".", dirs_exist_ok=True); rmtree("blank")
echo("done.", fg="green", bold=True)
echo_wrap("Copying blank project... ",
copytree, PPath(__file__).parent/"blank", path, dirs_exist_ok=True)

dirs = [
path for path in listdir(PPath(__file__).parent.parent / "extensions")
path for path in listdir(PPath(__file__).parent.parent/"extensions")
if not path.endswith(".py") and not path.startswith("__")
]

Expand All @@ -60,6 +42,7 @@ def init(path: str) -> int:
echo(f"Unknown extensions: {', '.join(diff)}", fg="red", bold=True)
return 1

chdir(path)
for extension in extensions:
if err := initialize_extension(extension):
echo(err, fg="red", bold=True)
Expand Down Expand Up @@ -104,4 +87,4 @@ def watch(config: str, path: str) -> int:
@argument("path", default=".", type=Path(exists=True))
def build(config: str, path: str) -> int:
"""Build a Markdown-SPA project"""
return build_project(Generator(path, config or 'config.ini'))
return build_project(Generator(path, config or 'config.ini'))

0 comments on commit 6f23a5d

Please sign in to comment.