Skip to content

Commit 55cfb87

Browse files
feat: no frontend build in repo
In other words, build frontend when creating installer. Changes to `create_installer.sh` - If `python` is not in `PATH` but `python3` is, alias them (well, via function). This is needed on some machines to run the installer without symlinking to `python3`. - Make the messages about pushing tags clearer. The script force-pushes, so it's possible to accidentally take destructive action. I'm not sure how to otherwise prevent damage, so I just added a warning. - Print out `pwd` when prompting about being in the `installer` dir. - Rebuild the frontend - if there is already a frontend build, first checks if the user wants to rebuild it. - Checks for existence of `../build` dir before deleting - if the dir doesn't exist, the script errors and exits at this point. - Format and spell check. Other changes: - Ignore `dist/` folder. - Delete `dist/`. **Note: you may need to use `git rm --cached invokeai/app/frontend/web/dist/` if git still wants to track `dist/`.**
1 parent 40d4c7c commit 55cfb87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+52
-14470
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ __pycache__/
1616
.Python
1717
build/
1818
develop-eggs/
19-
# dist/
19+
dist/
2020
downloads/
2121
eggs/
2222
.eggs/
@@ -187,3 +187,4 @@ installer/install.bat
187187
installer/install.sh
188188
installer/update.bat
189189
installer/update.sh
190+
installer/InvokeAI-Installer/

installer/create_installer.sh

+47-9
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,45 @@ set -e
44

55
cd "$(dirname "$0")"
66

7+
function is_bin_in_path {
8+
builtin type -P "$1" &>/dev/null
9+
}
10+
11+
if ! is_bin_in_path python && is_bin_in_path python3; then
12+
echo "Aliasing python3 to python..."
13+
function python {
14+
python3 "$@"
15+
}
16+
fi
17+
718
if [[ -v "VIRTUAL_ENV" ]]; then
819
# we can't just call 'deactivate' because this function is not exported
920
# to the environment of this script from the bash process that runs the script
1021
echo "A virtual environment is activated. Please deactivate it before proceeding".
1122
exit -1
1223
fi
1324

14-
VERSION=$(cd ..; python -c "from invokeai.version import __version__ as version; print(version)")
25+
VERSION=$(
26+
cd ..
27+
python -c "from invokeai.version import __version__ as version; print(version)"
28+
)
1529
PATCH=""
1630
VERSION="v${VERSION}${PATCH}"
1731
LATEST_TAG="v3-latest"
1832

1933
echo Building installer for version $VERSION
2034
echo "Be certain that you're in the 'installer' directory before continuing."
35+
echo "Currently in '$(pwd)'"
2136
read -p "Press any key to continue, or CTRL-C to exit..."
2237

23-
read -e -p "Tag this repo with '${VERSION}' and '${LATEST_TAG}'? [n]: " input
38+
read -e -p "Tag this repo with '${VERSION}' and '${LATEST_TAG}'? Immediately pushes! [n]: " input
2439
RESPONSE=${input:='n'}
2540
if [ "$RESPONSE" == 'y' ]; then
2641

2742
git push origin :refs/tags/$VERSION
28-
if ! git tag -fa $VERSION ; then
29-
echo "Existing/invalid tag"
30-
exit -1
43+
if ! git tag -fa $VERSION; then
44+
echo "Existing/invalid tag"
45+
exit -1
3146
fi
3247

3348
git push origin :refs/tags/$LATEST_TAG
@@ -36,7 +51,27 @@ if [ "$RESPONSE" == 'y' ]; then
3651
echo "remember to push --tags!"
3752
fi
3853

39-
# ----------------------
54+
# ---------------------- FRONTEND ----------------------
55+
56+
function build_frontend {
57+
echo Building frontend
58+
pushd ../invokeai/frontend/web
59+
pnpm i --frozen-lockfile
60+
pnpm build
61+
popd
62+
}
63+
64+
if [ -d ../invokeai/frontend/web/dist ]; then
65+
read -e -p "Frontend build exists. Rebuild? [n]: " input
66+
RESPONSE=${input:='n'}
67+
if [ "$RESPONSE" == 'y' ]; then
68+
build_frontend
69+
fi
70+
else
71+
build_frontend
72+
fi
73+
74+
# ---------------------- BACKEND ----------------------
4075

4176
echo Building the wheel
4277

@@ -46,12 +81,15 @@ if [[ $(python -c 'from importlib.util import find_spec; print(find_spec("build"
4681
pip install --user build
4782
fi
4883

49-
rm -r ../build
84+
if [ -d ../build ]; then
85+
rm -Rf ../build
86+
fi
87+
5088
python -m build --wheel --outdir dist/ ../.
5189

5290
# ----------------------
5391

54-
echo Building installer zip fles for InvokeAI $VERSION
92+
echo Building installer zip files for InvokeAI $VERSION
5593

5694
# get rid of any old ones
5795
rm -f *.zip
@@ -72,7 +110,7 @@ cp install.sh.in InvokeAI-Installer/install.sh
72110
chmod a+x InvokeAI-Installer/install.sh
73111

74112
# Windows
75-
perl -p -e "s/^set INVOKEAI_VERSION=.*/set INVOKEAI_VERSION=$VERSION/" install.bat.in > InvokeAI-Installer/install.bat
113+
perl -p -e "s/^set INVOKEAI_VERSION=.*/set INVOKEAI_VERSION=$VERSION/" install.bat.in >InvokeAI-Installer/install.bat
76114
cp WinLongPathsEnabled.reg InvokeAI-Installer/
77115

78116
# Zip everything up

invokeai/frontend/web/.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ lerna-debug.log*
99

1010
node_modules
1111
# We want to distribute the repo
12-
# dist
12+
dist
13+
dist/**
1314
dist-ssr
1415
*.local
1516

@@ -38,4 +39,4 @@ stats.html
3839

3940
# Yalc
4041
.yalc
41-
yalc.lock
42+
yalc.lock

invokeai/frontend/web/dist/assets/App-6125620a.css

-1
This file was deleted.

0 commit comments

Comments
 (0)