2021-05-26 20:01:52 +00:00
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import glob
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from app.plugins import build_plugins
|
|
|
|
|
|
|
|
def cleanup():
|
|
|
|
# Delete all node_modules and build directories within plugins' public/ folders
|
|
|
|
root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", ".."))
|
2021-06-17 17:39:32 +00:00
|
|
|
for d in glob.glob(os.path.join(root, "coreplugins", "**", "public", "node_modules")):
|
2021-05-26 20:01:52 +00:00
|
|
|
shutil.rmtree(d)
|
|
|
|
print("R\t" + d)
|
2021-06-17 17:39:32 +00:00
|
|
|
for d in glob.glob(os.path.join(root, "coreplugins", "**", "public", "build")):
|
2021-05-26 20:01:52 +00:00
|
|
|
shutil.rmtree(d)
|
|
|
|
print("R\t" + d)
|
|
|
|
|
|
|
|
print("Cleanup done!")
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2021-05-27 13:55:27 +00:00
|
|
|
requires_system_checks = []
|
|
|
|
|
2021-05-26 20:01:52 +00:00
|
|
|
def add_arguments(self, parser):
|
|
|
|
super(Command, self).add_arguments(parser)
|
|
|
|
|
|
|
|
def handle(self, **options):
|
|
|
|
cleanup()
|
|
|
|
build_plugins()
|