feat: add manager, entry and command

This commit is contained in:
2023-03-13 00:06:21 +03:00
parent a8788fbaf9
commit ccdbb00eff
11 changed files with 244 additions and 1 deletions
View File
+18
View File
@@ -0,0 +1,18 @@
from ..command import Command
__all__ = ("NpmCommand",)
class NpmCommand(Command):
EXECUTOR: str = "npm"
def __init__(self, *args: str) -> None:
super().__init__(self.EXECUTOR, *args)
@classmethod
def install(cls) -> "NpmCommand":
return cls("install")
@classmethod
def install_clean(cls) -> "NpmCommand":
return cls("install-clean")
+22
View File
@@ -0,0 +1,22 @@
from pathlib import Path
from typing import Optional
from project_manager.nodejs.command import NpmCommand
from ..entry import Entry
class NodejsEntry(Entry):
TYPE: str = "nodejs"
def __init__(self, basepath: Path):
super().__init__(self.TYPE, basepath)
def setup(self):
self._logger.info(f"setup:{self}")
NpmCommand.install_clean().run(self._basepath)
@classmethod
def detect(cls, basepath: Path) -> Optional["NodejsEntry"]:
if (basepath / "package.json").exists():
return cls(basepath)