File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import shutil
2+ import os
3+ from pathlib import Path
4+ import sys
5+
6+ _here = Path (os .path .abspath (os .path .dirname (__file__ )))
7+ build_dir = _here / 'frontend/dist'
8+
9+
10+ def validate_static (static_dir ):
11+ if os .path .isdir (static_dir ):
12+ print (f'This will remove the contents of "{ dest } ". Continue? [y/n]' )
13+ response = input ()
14+ if response != 'y' :
15+ print ('Aborting.' )
16+ exit ()
17+ if os .path .isfile (static_dir ):
18+ raise NotADirectoryError (f'{ static_dir } is a file, not a directory' )
19+
20+
21+ def clean_static (static_dir ):
22+ if os .path .exists (static_dir ):
23+ shutil .rmtree (static_dir )
24+
25+
26+ def collect_static (static_dir ):
27+ if os .path .isdir (build_dir ):
28+ shutil .copytree (build_dir , static_dir )
29+
30+ if __name__ == '__main__' :
31+ if len (sys .argv ) > 1 :
32+ dest = Path (sys .argv [1 ])
33+ validate_static (dest )
34+ else :
35+ dest = _here / 'static'
36+
37+ clean_static (dest )
38+ collect_static (dest )
39+
Original file line number Diff line number Diff line change 2020 "start" : " yarn start-front" ,
2121 "build" : " yarn front yarn build" ,
2222 "build-p" : " yarn front yarn build --prod" ,
23- "collectstatic-p" : " cd backend && python manage.py collectstatic --noinput -v 0 --settings collect --pythonpath .." ,
24- "clean-static" : " rm -rf static || rd /S /Q static" ,
25- "static-p" : " yarn build-p && yarn clean-static && yarn collectstatic-p" ,
23+ "collectstatic-p" : " python collectstatic.py" ,
24+ "static-p" : " yarn build-p && yarn collectstatic-p" ,
2625 "watch-front-p" : " yarn front yarn watch" ,
2726 "start-p" : " yarn static-p && yarn watch-front-p"
2827 },
You can’t perform that action at this time.
0 commit comments