-
Notifications
You must be signed in to change notification settings - Fork 1
Deploy Electron
- Preparing an Electron Build
- Overview
- Repo Paths
- Current Running Project Database Paths
- Prepare Resources
- Prepare Default Template
- Prepare Distribution Files
- PR Test Instructions
See Original Issue Request #84
See Original Pull Request #136
IMPORTANT: Read Reference Build Differences first to understand the different ways of building the app!!!
- Start
meme.app
for the first time should start with a blank template if nothing has been defined. - Researchers and teachers should be able to start
meme.app
with a default set of data (e.g. classroom/teacher/students/projects/resources etc) that can be defined easily via copying and pasting the wholeMEME macOS
distribution folder. - Technical users should be able to define a starting project database by editing template
*.db.js
files.
Generally when preparing an Electron package to deliver to another site, you need to define three things:
I. Prepare Resources
II. Prepare Default Template
III. Prepare Distribution Files
Where to find files (for clarity, we are assuming /
is the root repo directory, e.g. /src/
refers to /<repodir>/src/
):
Folder () | Source Code | Template Data | Local Runtime Data | Electron Runtime Data |
---|---|---|---|---|
/src/ |
X | |||
/docs/ |
X | |||
/node_modules/ |
from package.json
|
|||
/templates/ |
X | |||
/templates/_blank/ |
X | |||
/built/ |
built from /src/
|
|||
/data/ |
copied from /templates/
|
|||
/resources/ |
references /resources/ directly |
|||
/dist/ |
built from /src/ via electron compile |
|||
/dist/MEME macOS/ |
X | |||
/dist/MEME macOS/data/ |
copied from /data/
|
|||
/dist/MEME macOS/resources/ |
copied from /templates/_blank/ and manual override |
|||
/dist/MEME macOS/templates/ |
copied from /templates/ and manual override |
The current running project database files are saved in different paths depending on how you start the server.
Run Mode | Command | Sources | Runtime Path* |
---|---|---|---|
Development | npm run dev |
/meme/templates/test/*.db.js or if not exist, /meme/templates/_blank/*.db.js
|
/meme/data/db/test.loki |
Electron Debug from Command Line -- with live reload (does not build dist) | npm run electron |
meme.loki or if not exist, /meme/templates/meme/*.db.js or if not exist, /meme/templates/_blank_/*.db.js
|
/meme/data/db/meme.loki |
"App" Mode -- Production from Command Line -- with console output | npm run app |
same as electron | /meme/dist/MEME macOS/data/db/meme.loki |
"App" Mode -- Production from Electron App | Double-click meme.app
|
same as electron | /meme/dist/MEME macOS/data/db/meme.loki |
-
The default project database name is always:
-
test.loki
-- when running a Local Server vianpm run dev
, or -
meme.loki
-- when running an Electron app vianpm run electron
,npm run app
, or double clicking the Electronmeme.app
.
-
-
The two names (
test.loki
andmeme.loki
) are "burned in" and cannot be changed for loading. (But you can replace onememe.loki
with anothermeme.loki
file in the same folder to swap out databases. -
Since the project database is just a single file, you can copy, archive, and replace
test.loki
andmeme.loki
files at will to manage versions over time. -
Generally, you only change the name (e.g.
test.loki
vsmeme.loki
) if you need to manually create a backup for archival purposes. e.g. you want to save your pilot study asmeme_2023-0930.loki
. If you want to load a different db file, you'd either use the Electron MKZIP export/import, or rename the db file frommeme_2023-0930.loki
tomeme.loki
. -
NOTE that the initial
_blank
template project is created from*.db.js
files, that are then compiled and saved as*.loki
when the app loads. -
The default runtime folder is
<repo_folder>/data/test.loki
, typically/meme/data/test.loki
.
Projects rely on references to "resources". Resources might be files (e.g. pdfs of articles, graphics), or simply links (e.g. url to a website, url to a simulation). File resources must be prepared for a project in advance. Link resources can be set up with the project.
There are two ways to add resources:
- Use the "resources" defined in the main template to automatically copy resources for running during runtime, usually stored at
/<repodir>/templates/_blank/resources/*.*
, or - Add resources as you develop materials for the project directly to the corresponding runtime path, usually stored at
/<repodir>/resources/*.*
for local dev or at/<repodir>/dist/MEME macOS/resources/*.*
when using Electron.
Resources are saved either to the local server or to the Electron app, depending on how you start the app.
For Local Servers, during compile the resources are copied from the /<repodir>/templates/_blank/resources
to the /<repodir>/resources
folder. You can then add additional resources as needed.
For the Electron App, during compile the resources are copied from the /<repodir>/templates/_blank/resources
to the /<repodir>/dist/MEME macOS/resources
folder. You can then add additional resources as needed.
Here's a table summarizing the sources and paths of resources
Run Mode | Command | Sources | Runtime Path* |
---|---|---|---|
Development | npm run dev |
/<repodir>/templates/_blank/resources/*.* |
/<repodir>/resources/*.* |
Electron Debug from Command Line -- with live reload (does not build dist) | npm run electron |
/<repodir>/templates/_blank/resources/*.* |
/<repodir>/resources/*.* |
"App" Mode -- Production from Command Line -- with console output | npm run app |
/<repodir>/templates/_blank/resources/*.* |
/<repodir>/dist/MEME macOS/resources/*.* |
"App" Mode -- Production from Electron App | Double-click meme.app
|
/<repodir>/templates/_blank/resources/*.* |
/<repodir>/dist/MEME macOS/resources/*.* |
*Runtime Path -- You can add additional non-templated resources in the Runtime path folder.
All references should use .../static/dlc/*.*
as the URL for resources.
You can use subfolders as well, e.g. resources in the disk path /<repodir>/dist/MEME macOS/resources/subfolder/helloworld.pdf
would use a URL of .../static/dlc/subfolder/helloworld.pdf
.
New projects are always started from a template. By default, the _blank
template is used. But existing projects (database files and resources) can be used to override the defaults.
MEME tries to provide a graceful way to fall back to usable projects and templates. Here's the order in which MEME will attempt to create projects:
For local development, the test.loki
database will always be generated from the *.db.js
files with every run.
- Using the files in...
-
<repodir>/templates/_blank/*.db.js
and -
<repodir>/templates/_blank/resources/*
...
-
- ...generate and load
<repodir>/data/db/test.loki
For Electron Mode, we try these in order:
-
Use
meme.loki
- If
meme.loki
has been created... - ...copy
<repodir>/data/db/meme.loki
... - ...to
<repodir>/dist/MEME macOS/data/db/meme.loki
- If
-
Use
templates/meme/*.db.js
- If
meme.loki
has not been created yet, but there is a<repodir>/templates/meme
/ folder... - ...use
<repodir>/templates/meme/*.db.js
files to... - ...construct
<repodir>/dist/MEME macOS/data/db/meme.loki
- If
-
Fall back to
/templates/_blank
:- ...use
<repodir>/templates/_blank/*.db.js
to... - ...construct a new
<repodir>/dist/MEME macOS/data/db/meme.loki
- ...use
If you want to create a starting template for projects, e.g. you want to create water quality projects that share resources to use for a few different sites, you have two options:
The easiest method is to run the distributed electron version and update the files in the <repodir>/dist/MEME macOS/
folder:
- Build, package, and run the electron app
npm run electron
npm run package
npm run appsign
- Start Electron via
npm run app
or double clicking thememe.app
to load and run the files in<repodir>/dist/MEME macOS/
- Edit any resources, add any teachers, classrooms, and other settings
- Build and run the electron app to make sure the data is correct
npm run package
npm run appsign
- Once you've confirmed everything is to your liking
- Duplicate the whole
<repodir>/dist/MEME macOS/
folder
The copied app will start with the same project data.
This is somewhat fragile in that you'd need to lock down the meme.loki
and associated files to make sure you don't inadvertently change something. The eaiset method is probably to simply zip the <repodir>/dist/MEME macOS/
folder.
If you've already been refining the running meme.loki
file you can also just run the packager to build the distribution files.
npm run electron
- Edit any resources, add any teachers, classrooms, and other settings
- Build and run the electron app to make sure the data is correct
npm run package
npm run appsign
- Duplicate the whole
<repodir>/dist/MEME macOS/
folder
For advanced coders, you can edit the *.db.js
files directly. The easiest way here is to:
- Copy
<repodir>/templates/_blank/*.db.js
to<repodir>/templates/meme/*.db.js
- Edit the files in
<repodir>/templates/meme/*.db.js
- Build and run the electron app to make sure the data is correct
- Duplicate the whole
<repodir>/dist/MEME macOS/
folder
The copied app will then start with fresh *.db.js
files on the initial build.
NOTE that any changes you make to the Electron app will then be saved in the current meme.loki
file, and you can just copy those. Any changes to meme.loki
will NOT be reflected in the <repodir>/templates/meme/*.db.js
files though -- you'll have to duplicate those changes by hand editing the *.db.js
files.
Here's what you need to do to prepare the combined package of the Electron app and project data for sharing to other sites.
Generally you would start with the __blank
template. If you want to use another template, see II. Prepare Default Template for more information.
If you start with the _blank
template, any resources already defined in /<repodir>/templates/_blank/resources/*.*
will be copied over.
If you want to add additional resources add them to /<repodir>/resources/*.*
. During packaging, the resources will be copied over.
Do an initial compile to build the meme.loki
file to review the starting setup.
npm run electron
http://localhost/#/admin
Add any classrooms, teachers, student groups, and students you want to share across all copies.
Add any ratings definitions, criteria for a good model, sentence starters, and resource definitions.
If you want to add a starting demo project, login and create a model.
Please refer to README-signing.md for detailed instructions on Code Signing and Notarization.
npm run electron # build the `meme.loki` file from `*.db.js` files and run Electron locally
npm run package # build the the distribution files for `meme.app` Electron app
npm run appsign # code sign the `meme.app`
npm run app # or double click on `meme.app`
Run the app to make sure it looks right.
In addition to codesigning, if you want to copy the Electron app to another machine, you need to run a install.sh
script.
- Build the electron app (
npm run package
) and copy the/dist/MEME macOS folder
to your new computer/new location, e.g. to~/Desktop/MEME macOS
. - Open a terminal.
cd ~/Desktop/MEME macOS
./install.sh
- The quarantine flag should now be fixed.
- Double click the meme.app Electron application to start the server to make sure it works.
- If you see javascript error, then the quarantine flag was probably not removed successfully. Try typing
xattr meme.app
-- you should NOT see the linecom.apple.quarantine
If you copy the app to another computer you may have to run./install.sh
again.
Make sure everything works. Make sure you test:
- Intel Macs
- Apple Silicon Macs (M1, M2)
- Older macOS versions that you might be running on
Once everything is set you can zip the <repodir>/dist/MEME macoS/
folder and copy the zip file to another computer.
Unzip it to run it.
nvm use
-
npm run clean:all
-- note thedist
andbuilt
folders have been removed npm ci
-
npm run dev
-- compile to make sure it runs - Check
http://localhost:3000
andhttp://localhost:3000/#/admin
to make sure app loads - Make sure you prepped the files using the "Preparing for Electron" instructions above.
npm run package
- Check
boilerplate/dist/MEME macOS
to make sure the electron app has been built correctly:-
data/
-- should be empty -
resources/
-- should be empty -
templates/
-- should have a_blank
template folder LICENSE
LICENSE.chromium.html
meme.app
version
-
- If you haven't already set up code signing, see Signing
- Verify that you can run
meme.app
locally on your machine -- start the Electron app, and loadhttp://localhost:3000/#/admin
npm run appsign
Try different methods of starting a new project from scratch. You should always be able to create a new blank project without any errors.
- Delete
<repodir>/data
anddist
- Run
npm run dev
- A new
test.loki
file should be created in<repodir>/data/db/test.loki
- Going to
http://localhost:3000/#/admin
you should see a blank project
- Delete
<repodir>/data
anddist
- Run
npm run electron
- A new
meme.loki
file should be created in<repodir>/data/db/meme.loki
- An electron app should be built and started
- Going to
http://localhost:3000/#/admin
you should see a blank project
- Delete
<repodir>/data
anddist
- Run
npm run app
=> npm should complain
./dist/meme-darwin-x64/meme.app: No such file or directory
MEME EXEC - ERROR from codesign check
MEME EXEC - macos will not run this app until it is signed
- Run
npm run package
- Run
npm run app
=> npm should complain
./dist/meme-darwin-x64/meme.app: No such file or directory
MEME EXEC - ERROR from codesign check
MEME EXEC - macos will not run this app until it is signed
- Run
npm run electron
to build thememe.loki
file. - Run
npm run package
to build with the necessary depdencies. - Run
npm run appsign
(NOTE you need to have set up code signing -- see Signing) - A new
meme.loki
file should be created in<repodir>/data/db/meme.loki
- An electron app should be built and started
- Going to
http://localhost:3000/#/admin
you should see a blank project
Make sure that npm run dev
will generate test.loki
based on a starting template and that it'll fall back to templates/_blank
if templates/test
is not defined.
Test Blank
- Delete
<repodir>/data
anddist
- Delete
/<repodir>/templates/test
(if it exists) npm run dev
- The app should run with a blank project
Test test
- Delete
<repodir>/data
anddist
- Add
/<repodir>/templates/test
-- use the zip file attached. npm run dev
- The app should run with a test project that has three teachers added.
Make sure the various ways of setting a starting non-blank template work.
Test Blank
- Delete
<repodir>/data
anddist
- Delete
/<repodir>/templates/meme
(if it exists) npm run dev
- The app should run with a blank project
Test npm run electron
with meme
- Delete
<repodir>/data
anddist
- Add
/<repodir>/templates/meme
-- use the zip file attached. npm run electron
- The app should run with a test project that has three teachers added.
Test npm run app
with meme
- Delete
<repodir>/data
anddist
- Add
/<repodir>/templates/meme
-- use the zip file attached. npm run electron
npm run package
npm run appsign
npm run app
- The app should run with a test project that has three teachers added.
Test meme.app
with meme
- Delete
<repodir>/data
anddist
- Add
/<repodir>/templates/meme
-- use the zip file attached. npm run electron
npm run package
npm run appsign
- Double-click
meme.app
to start Electron - The app should run with a test project that has three teachers added.
Make sure it's possible to copy the distribution files to another computer.
-
Build the electron app (
npm run package
) and copy the/dist/MEME macOS folder
to your new computer/new location, e.g. to~/Desktop/MEME macOS
. -
Open a terminal.
-
cd ~/Desktop/MEME macOS
-
./install.sh
-
The quarantine flag should now be fixed.
-
Double click the meme.app Electron application to start the server.
-
If you see javascript error, then the quarantine flag was probably not removed successfully. Try typing
xattr meme.app
-- you should NOT see the linecom.apple.quarantine
If you copy the app to another computer you may have to run./install.sh
again.
See Deploy Electron 2022 for historical instructions.
User Manual
Developer Manual
Installation
Setting Up End-User Projects
Deploying
- Deploy Electron
- Electron Code Signing README-signing.md
- Digital Ocean Deployment
- Updating MEME for 2021+
--
Coding Practices
Background
Design Notes
- Dev Insights
- Design Data Management
- Student Login
- Reference Build Differences
- Design Settings Manager
- Why Electron?
Deprecated