Skip to content

Commit

Permalink
Change build output directory to public/build dist/build
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Sep 9, 2024
1 parent 957664d commit a28bbaf
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 34 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
all: build_rules
python3 scripts/lint_groups.py '../public/groups.json'
bash scripts/update-public-build.sh
bash scripts/update-dist.sh

build_rules:
# There are cases where only public/json needs to be updated, so it is separated into `build_rules`.
Expand All @@ -23,8 +23,8 @@ rebuild:
touch ../src/json/*
$(MAKE) all

update-public-build:
bash scripts/update-public-build.sh
update-dist:
bash scripts/update-dist.sh

server:
/usr/bin/python3 scripts/dev_server.py
preview-server: update-dist
(cd ../dist && /usr/bin/python3 ../core/scripts/preview_server.py)
6 changes: 3 additions & 3 deletions scripts/make_distjson.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python3

'''Update public/build/dist.json'''
'''Update dist/build/dist.json'''

import contextlib
import glob
Expand All @@ -27,7 +27,7 @@ def check_safe_path(path):


def make_distjson():
'''Update public/build/dist.json'''
'''Update dist/build/dist.json'''

with remember_cwd():
os.chdir(f'{os.path.dirname(__file__)}/../../public')
Expand Down Expand Up @@ -131,7 +131,7 @@ def make_distjson():
capture_output=True, check=False, encoding='utf-8')
groups_json['updatedAt'] = int(git.stdout.strip())

with open('build/dist.json', 'w', encoding='utf-8') as build_groups_json_file:
with open('../dist/build/dist.json', 'w', encoding='utf-8') as build_groups_json_file:
json.dump(groups_json, build_groups_json_file,
ensure_ascii=False, indent=2)

Expand Down
38 changes: 38 additions & 0 deletions scripts/update-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -u # forbid undefined variables
set -e # forbid command failure

cd $(dirname "$0")/../..

#
# Update dist.json
#

rm -fr dist
mkdir -p dist/build
/usr/bin/python3 core/scripts/make_distjson.py

#
# Copy json
#

cp -R public/json dist

#
# Update extra_descriptions
#

cp -R public/extra_descriptions dist/build

for f in $(find dist/build/extra_descriptions -name '*.html'); do
echo '<script src="../../vendor/js/iframeResizer.contentWindow.min.js"></script>' >"$f.tmp"
cat "$f" >>"$f.tmp"
mv "$f.tmp" "$f"
done

#
# Copy react files
#

cp -R core/react/dist/* dist
26 changes: 0 additions & 26 deletions scripts/update-public-build.sh

This file was deleted.

0 comments on commit a28bbaf

Please sign in to comment.