Compare commits
7 Commits
da59155954
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7460d784b6 | |||
| c9976b9c08 | |||
| 9075342661 | |||
| 904ef85f54 | |||
| f6bfa6b8fd | |||
| 5bc61e30a6 | |||
| e75da2f297 |
14
dig/build.py
14
dig/build.py
@@ -17,7 +17,7 @@ def find_c_files(path: str):
|
||||
for entry in os.listdir(path):
|
||||
full_path = os.path.join(path, entry)
|
||||
if os.path.isdir(full_path):
|
||||
list_files_recursive(full_path)
|
||||
find_c_files(full_path)
|
||||
else:
|
||||
if full_path.endswith(".c"):
|
||||
paths.append(full_path)
|
||||
@@ -29,6 +29,9 @@ def build_mineral(args):
|
||||
if not os.path.isdir(args.folder_path):
|
||||
console.print("[b red]digpkg: failed to build mineral: specified folder doesn't exist![/]")
|
||||
sys.exit(1)
|
||||
if os.path.isfile(os.path.join(args.folder_path, "main.so")):
|
||||
console.print("[b red]digpkg: failed to build mineral: attempt to build compiled mineral![/]")
|
||||
sys.exit(1)
|
||||
if not shutil.which("gcc"):
|
||||
console.print("[b red]digpkg: failed to build mineral: gcc was not found![/]")
|
||||
sys.exit(1)
|
||||
@@ -37,6 +40,10 @@ def build_mineral(args):
|
||||
with console.status("Compiling", spinner="bouncingBall", spinner_style="green") as status:
|
||||
c_files = find_c_files(args.folder_path)
|
||||
|
||||
if len(c_files) == 0:
|
||||
console.print("[b red]digpkg: failed to build mineral: no .c files found in the specified folder, are you sure you're compiling a mineral?[/]")
|
||||
sys.exit(1)
|
||||
|
||||
if subprocess.run([
|
||||
"gcc",
|
||||
"-shared",
|
||||
@@ -102,7 +109,10 @@ def build(args):
|
||||
f.write("# mylib\n")
|
||||
f.write("Introduce your module here!\n\nThis file will serve as an index page for all your docs.\n\n")
|
||||
f.write("## Subtitle (use this for categories)\n")
|
||||
f.write("- [mylib_MyFunction](docs/my_function.md)")
|
||||
f.write("- [mylib_MyFunction](docs/my_function.md)\n\n")
|
||||
f.write("## Changelog\n")
|
||||
f.write("### v0.0.1 (latest)\n")
|
||||
f.write("- Initial release.\n")
|
||||
|
||||
console.print("[:white_check_mark:] Generated a new package for you!")
|
||||
|
||||
|
||||
57
dig/docs.py
57
dig/docs.py
@@ -3,7 +3,10 @@ import os, sys
|
||||
from rich.console import Console
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import MarkdownViewer, Header, Footer
|
||||
from textual.widgets import MarkdownViewer, Header, Footer, Input, Button
|
||||
from textual.containers import Horizontal
|
||||
from textual_autocomplete import PathAutoComplete
|
||||
from textual import on
|
||||
|
||||
|
||||
console = Console()
|
||||
@@ -13,9 +16,45 @@ class DocsApp(App):
|
||||
TITLE = "Digpkg Docs"
|
||||
SUB_TITLE = "made with ❤️ by SpookyDervish"
|
||||
|
||||
CSS = """
|
||||
#search {
|
||||
margin: 1;
|
||||
width: 1fr;
|
||||
}
|
||||
|
||||
#back {
|
||||
margin-top: 1;
|
||||
margin-left: 1;
|
||||
}
|
||||
|
||||
#bottom {
|
||||
height: 5;
|
||||
}
|
||||
"""
|
||||
|
||||
def __init__(self, inital_markdown_path: str):
|
||||
|
||||
super().__init__()
|
||||
self.inital_markdown_path = inital_markdown_path
|
||||
self.docs_folder = os.path.join(os.path.dirname(self.inital_markdown_path), "docs")
|
||||
|
||||
async def on_input_submitted(self, event: Input.Submitted):
|
||||
if event.input.id == "search":
|
||||
|
||||
if not os.path.isdir(self.docs_folder):
|
||||
return
|
||||
|
||||
file_path = os.path.join(self.docs_folder, event.input.value)
|
||||
if os.path.isfile(file_path):
|
||||
event.input.clear()
|
||||
event.input.focus()
|
||||
await self.query_one(MarkdownViewer).go(file_path)
|
||||
else:
|
||||
self.notify("That file wasn't found.", title="Uh oh", severity="error")
|
||||
|
||||
async def on_button_pressed(self, event: Button.Pressed):
|
||||
if event.button.id == "back":
|
||||
await self.query_one(MarkdownViewer).back()
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with open(self.inital_markdown_path, "r") as f:
|
||||
@@ -23,6 +62,22 @@ class DocsApp(App):
|
||||
|
||||
yield Header()
|
||||
yield MarkdownViewer(markdown)
|
||||
|
||||
with Horizontal(id="bottom"):
|
||||
yield Button(label="Back", id="back", flat=True, variant="error")
|
||||
search_input = Input(id="search", placeholder="Search . . .")
|
||||
yield search_input
|
||||
|
||||
|
||||
if os.path.isdir(self.docs_folder):
|
||||
yield PathAutoComplete(
|
||||
search_input,
|
||||
path=self.docs_folder
|
||||
)
|
||||
else:
|
||||
search_input.disabled = True
|
||||
search_input.tooltip = "This mineral doesn't have a docs folder and can't be searched."
|
||||
|
||||
yield Footer()
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ def parse_arguments():
|
||||
|
||||
# publish command
|
||||
publish_command = sub_parsers.add_parser(name="publish", description="publish a package to the repository")
|
||||
publish_command.add_argument("name", help="name and version of the package")
|
||||
#publish_command.add_argument("name", help="name and version of the package")
|
||||
publish_command.add_argument("folder_path", help="path to the folder that will be uploaded")
|
||||
|
||||
# remove command
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import configparser
|
||||
import tarfile
|
||||
import tempfile
|
||||
import os, sys
|
||||
@@ -13,13 +14,7 @@ console = Console()
|
||||
|
||||
|
||||
def publish(args):
|
||||
if not "@" in args.name:
|
||||
console.print(f"[b red]digpkg: failed to publish mineral: please include the version number in the package name. e.g: request@1.0.0")
|
||||
sys.exit(1)
|
||||
|
||||
split_name = args.name.split("@")
|
||||
mineral_name = split_name[0]
|
||||
version = split_name[1]
|
||||
mineral_name = os.path.basename(args.folder_path)
|
||||
|
||||
# sanity checks
|
||||
if not os.path.isdir(args.folder_path):
|
||||
@@ -31,6 +26,10 @@ def publish(args):
|
||||
if os.path.basename(os.path.normpath(args.folder_path)).endswith("_build"):
|
||||
console.print(f"\n[b yellow]You didn't remove the \"_build\" suffix from your mineral's folder name!\n\nIf this is intentional you can ignore this message, however it is bad practice.\nIf this is not intentional, you will be unable to install your package properly using dig.[/]")
|
||||
|
||||
config_parser = configparser.ConfigParser()
|
||||
config_parser.read(os.path.join(args.folder_path, "mineral.ini"))
|
||||
version = config_parser["package"]["version"]
|
||||
|
||||
# ask for user and pass
|
||||
console.print("[b]Please authenticate.\n[/]")
|
||||
try:
|
||||
|
||||
BIN
mineral.tar
Normal file
BIN
mineral.tar
Normal file
Binary file not shown.
5
setup.py
5
setup.py
@@ -2,11 +2,12 @@ from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name="digpkg",
|
||||
version="1.0",
|
||||
version="1.1",
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
"textual>=7.3.0",
|
||||
"requests>=2.32.5"
|
||||
"requests>=2.32.5",
|
||||
"textual-autocomplete>=4.0.6"
|
||||
],
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
|
||||
Reference in New Issue
Block a user