A set of tweaks to simplify electron packaging (#421)

* Replace `ormconfig.js` with a newer mechanism of configuring
    TypeORM that can be included in the source code properly.
    The path to `ormconfig.js` has always been awkward to handle,
    and eliminating the file makes building different Grist setups
    a bit simpler.
  * Remove `electron` package. It is barely used, just for some old
    remnants of an older attempt at electron packaging. It was used
    for two types, which I left at `any` for now. More code pruning is
    no doubt possible here, but I'd rather do it when Electron packaging
    has solidified.
  * Add a hook for replacing the login system, and for adding some
    extra middleware the login system may need.
  * Add support for some more possible locations of Python, which
    arise when a standalone version of it is included in the Electron
    package. This isn't very general purpose, just configurations
    that I found useful.
  * Support using grist-core within a yarn workspace - the only tweak
    needed was webpack related.
  * Allow an external ID to be optionally associated with documents.
This commit is contained in:
Paul Fitzpatrick
2023-02-13 15:52:17 -05:00
committed by GitHub
parent d55e56297e
commit f7f76fb5e7
19 changed files with 192 additions and 255 deletions

View File

@@ -2,10 +2,25 @@
set -e
# Use a built-in standalone version of Python if available in a directory
# called python. This is used for Electron packaging. The standalone Python
# will have extra packages installed, and then be moved to a standard location
# (sandbox_venv3).
for possible_path in python/bin/python python/bin/python3 \
python/Scripts/python.exe python/python.exe; do
if [[ -e $possible_path ]]; then
echo "found $possible_path"
buildtools/prepare_python3.sh $possible_path python
# Make sure Python2 sandbox is not around.
rm -rf venv
exit 0
fi
done
echo "Use Python3 if available and recent enough, otherwise Python2"
if python3 -c 'import sys; assert sys.version_info >= (3,9)' 2> /dev/null; then
# Default to python3 if recent enough.
buildtools/prepare_python3.sh
buildtools/prepare_python3.sh python3
# Make sure python2 isn't around.
rm -rf venv
else

View File

@@ -1,12 +1,32 @@
#!/usr/bin/env bash
# Prepare a Python3 sandbox in the sandbox_venv3 directory.
# Optionally, can be called with the command to use for Python,
# and the directory of a standalone version of Python to incorporate.
set -e
echo "Making Python3 sandbox"
if [ ! -e sandbox_venv3 ]; then
python3 -m venv sandbox_venv3
if [[ -e sandbox_venv3 ]]; then
echo "Have Python3 sandbox"
exit 0
fi
python="$1"
python_dir="$2"
if [[ "$python_dir" = "" ]]; then
python=python3
pip=sandbox_venv3/bin/pip
echo "Making Python3 sandbox"
$python -m venv sandbox_venv3
else
pip="$python -m pip"
fi
echo "Updating Python3 packages"
sandbox_venv3/bin/pip install --no-deps -r sandbox/requirements3.txt
$pip install --no-deps -r sandbox/requirements3.txt
if [[ ! -e sandbox_venv3 ]]; then
echo "Moving $python_dir to sandbox_venv3"
mv $python_dir sandbox_venv3
fi
echo "Python3 packages ready in sandbox_venv3"

View File

@@ -1,5 +1,10 @@
const path = require('path');
// Get path to top-level node_modules if in a yarn workspace.
// Otherwise node_modules one level up won't get resolved.
// This is used in Electron packaging.
const base = path.dirname(path.dirname(require.resolve('grainjs/package.json')));
module.exports = {
target: 'web',
entry: {
@@ -18,7 +23,8 @@ module.exports = {
path.resolve('.'),
path.resolve('./ext'),
path.resolve('./stubs'),
path.resolve('./node_modules')
path.resolve('./node_modules'),
base,
],
fallback: {
'path': require.resolve("path-browserify"),

View File

@@ -2,6 +2,11 @@ const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
const { ProvidePlugin } = require('webpack');
const path = require('path');
// Get path to top-level node_modules if in a yarn workspace.
// Otherwise node_modules one level up won't get resolved.
// This is used in Electron packaging.
const base = path.dirname(path.dirname(require.resolve('grainjs/package.json')));
module.exports = {
target: 'web',
entry: {
@@ -39,7 +44,8 @@ module.exports = {
path.resolve('.'),
path.resolve('./ext'),
path.resolve('./stubs'),
path.resolve('./node_modules')
path.resolve('./node_modules'),
base,
],
fallback: {
'path': require.resolve("path-browserify"),