thomaschampagne / elevate

A sport app to "Elevate" your training experience and goals! Track your fitness and progressions over time. Analyse deeper your activities. And more...
https://thomaschampagne.github.io/elevate-docs/
Mozilla Public License 2.0
1.24k stars 175 forks source link
angular chrome cycling electron running strava swim webextension

Elevate

Install

Desktop App

Download & Install

Build from sources

Go to chapter Environment setup.

Web extension

Download for Chrome, Chromium, Edge (from 2020), Brave, Opera, Vivaldi, Yandex, ...

Go to https://thomaschampagne.github.io/elevate/

From the sources

Go to chapter Environment setup.

Development

This section covers the environment setup to develop and build both desktop app and web extension.

Global solution structure

The solution is cut in 3 folders/projects: the appcore, the desktop & webextension

App-core project

Contains the Elevate App shared and loaded by both desktop and webextensionprojects. Appcore contains core features like fitness trend, year progressions, athlete settings...

The Appcore main technology stack is:

Desktop project

Holds the container behaviour to provide a cross-platform desktop app under Windows, Linux & MacOS. It contains desktop specific features like connectors synchronization (to fetch athlete activities from external).

The Desktop main technology stack is:

Web-extension project

Contains the web extension behaviour that acts directly on strava.com website. This includes extended stats on activities & segments efforts, best splits, etc...

Environments setup

Install requirements

You will need to install NodeJS (v15+) to build both desktop and chrome web extension.

Clone the git-flow based project

git clone https://github.com/thomaschampagne/elevate.git

or

git clone git@github.com:thomaschampagne/elevate.git

The new mono-repo including the desktop app and the web extension is on develop-new branch at the moment. So checkout/track this branch to build the desktop app:

cd ./elevate
git checkout --track origin/develop-new

Then install npm dependencies:

npm install

Run solution tests (appcore + desktop + webextension):

npm test

(Should be executed with success for any pull request submission).

Desktop development environment

All commands displayed in this section will be executed in ./desktop/ folder. So:

cd ./desktop/
npm start

This npm task will create a ./desktop/dist output folder and re-compile both appcore and desktop projects on any code changes

To open the desktop app, open another terminal, then run:

npm run launch:dev:app
npm test

First switch to desktop directory with cd desktop/

Output installers will be located in ./desktop/package/ The build targets are defined in ./desktop/package.json (build key section). See https://www.electron.build for more info.

npm run clean

Web extension development environment

To develop the web extension, you need a Chrome based browser such as Chrome, Chromium, Edge (from 2020), Brave, Opera, Vivaldi, Yandex, ...

All commands displayed in this section will be executed in ./webextension/ folder. So:

cd ./webextension/
npm start

This npm task will create a ./webextension/dist output folder and re-compile both appcore and webextension projects on any code changes

npm test

You can package the extension with the following command

npm run package

Output release will be located in ./webextension/package/

npm run clean

Build with docker

Desktop app

@TODO

Web extension

Create docker your image from Dockerfile

docker build . -t elevate-chrome-builder

Run a docker production build through a container. Replace /path/to/your/directory/ with a folder on your host to fetch the packaged build when done.

docker run --rm --name elevate-chrome-build -v /path/to/your/directory/:/package elevate-chrome-builder

Appendix

Add a new desktop migration for a next release

Register your new migration in below file

./appcore/src/app/desktop/migration/desktop-registered-migrations.ts

Tip: to emulate a version upgrade, you may downgrade the version property inside ipc.storage.json file (user app data folder)

Sign application

Self-sign with OpenSSL for windows build

[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
countryName             = FR
stateOrProvinceName     = Rhone Alpes
localityName            = Grenoble
organizationName        = Elevate
commonName              = Elevate Sports App
emailAddress            = you@email.com

[v3_req]
basicConstraints        = CA:FALSE
keyUsage                = critical,digitalSignature
extendedKeyUsage        = critical,codeSigning
openssl req -x509 -newkey rsa:4096 -sha256 -keyout code_sign.key -out code_sign.crt -days 1096 -config code_sign.cnf
openssl pkcs12 -export -name "elevate-sports-app" -out code_sign.pfx -inkey code_sign.key -in code_sign.crt
base64 code_sign.pfx -w 0
CSC_LINK=
CSC_KEY_PASSWORD=
npm run package:windows

Publish to github releases

GH_TOKEN=

Note: To publish a new version on github, a github draft release has to exist on the remote target repo. The github draft release value should match the version value of ./desktop/package.json file. New version must be compliant with semver convention and higher than previous version if exists. You can use this semver compare tool that your new version is higher than your previous one.

Note: You may already pushed a git tag matching your version. If not, the git tag will be created on publish.

npm run publish:win

or

npm run publish:mac

Use custom browser for unit-testing (web-extension only)

Create a browsers.karma.conf.js file in webextension folder.

To run unit test in a headless chromium instead of chrome, inject below javascript code:

module.exports = {
    browsers: [
        "HeadlessChrome"
    ],
    customLaunchers: {
        HeadlessChrome: {
            base: "Chromium",
            flags: [
                "--no-sandbox",
                // See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
                "--headless",
                "--disable-gpu",
                // Without a remote debugging port, Google Chrome exits immediately.
                " --remote-debugging-port=9222"
            ]
        }
    }
};

Desktop: Debug the calculated watts against real power

This works in development build only