feat: rework default entries

This commit is contained in:
2023-03-15 10:26:33 +03:00
parent 9345b27aef
commit 23ca8c0cac
14 changed files with 101 additions and 116 deletions
View File
+24
View File
@@ -0,0 +1,24 @@
from pathlib import Path
from typing import Optional
from ..entry import Entry
class NodejsEntry(Entry):
TYPE: str = "nodejs"
COMMANDS = {
"setup": [
["npm", "install-clean"],
],
"test": [
["npm", "test"],
],
}
def __init__(self, basepath: Path):
super().__init__(self.TYPE, self.COMMANDS, basepath)
@classmethod
def detect(cls, basepath: Path) -> Optional["NodejsEntry"]:
if (basepath / "package.json").exists():
return cls(basepath)
+33
View File
@@ -0,0 +1,33 @@
from pathlib import Path
from typing import Optional
from ..entry import Entry
class PythonEntry(Entry):
TYPE: str = "python"
COMMANDS = {
"setup": [
["poetry", "env", "use", "3.8"],
["poetry", "install"],
],
"lint": [
["poetry", "run", "black", "--check", "--diff", "./"],
["poetry", "run", "isort", "--profile", "black", "--check-only", "./"],
],
"format": [
["poetry", "run", "isort", "./"],
["poetry", "run", "black", "./"],
],
"test": [
["poetry", "run", "pytest", "-p", "no:warnings"],
],
}
def __init__(self, basepath: Path):
super().__init__(self.TYPE, self.COMMANDS, basepath)
@classmethod
def detect(cls, basepath: Path) -> Optional["PythonEntry"]:
if (basepath / "pyproject.toml").exists():
return cls(basepath)