Files
privacy.sexy/docs/development.md
undergroundwires 0a2a1a026b Refactor build configs and improve CI/CD checks
This commit makes the build process more robust, simplifies
configurations and reduce the risk of incomplete or erroneous
deployments.

- Centralize output directory definitions by introducing
  `dist-dirs.json`.
- Add `verify-build-artifacts` utility to ensure correct build outputs
  and `print-dist-dir` to determine distribution directory.
- Add steps in CI/CD pipeline to verify build artifacts.
- Migrate Electron Builder config from YAML to CJS for capability to
  read JSON.
- Fix `release-site.yaml` failing due to pointing to wrong distribution
  directory, change it to use `print-dist-dir`.
- Improve `check-desktop-runtime-errors` to verify build artifacts for
  more reliable builds. Ensure tests fail and succeed reliably.
- Update `.gitignore` and configure ESLint to use it to define and
  ignore build artifact directories from one place, remove
  `.eslintignore` that does not add anything after this change.
- Keep `"main"` field in `package.json` as `electron-vite` depends on it
  (alex8088/electron-vite#270).
- Improve documentation
2023-09-03 14:50:31 +02:00

4.0 KiB

Development

Before your commit, a good practice is to:

  1. Run unit tests
  2. Lint your code

You could run other types of tests as well, but they may take longer time and overkill for your changes. Automated actions are set up to execute these tests as necessary. See ci-cd.md for more information.

Commands

Prerequisites

  • Install node >15.x.
  • Install dependencies using npm install.

Testing

  • Run unit tests: npm run test:unit
  • Run integration tests: npm run test:integration
  • Run end-to-end (e2e) tests:
    • npm run test:cy:open: Run tests interactively using the development server with hot-reloading.
    • npm run test:cy:run: Run tests on the production build in a headless mode.
  • Run checks:
    • npm run check:desktop: Run runtime checks for packaged desktop applications (README.md).
      • You can set environment variables active its flags such as BUILD=true SCREENSHOT=true npm run check:desktop
    • npm run check:external-urls: Test whether external URLs used in applications are alive.

📖 Read more about testing in tests.

Linting

  • Lint all (recommended 💡): npm run lint
  • Markdown: npm run lint:md
  • Markdown consistency npm run lint:md:consistency
  • Markdown relative URLs: npm run lint:md:relative-urls
  • JavaScript/TypeScript: npm run lint:eslint
  • Yaml: npm run lint:yaml

Running

Web:

  • Run in local server: npm run dev
    • 💡 Meant for local development with features such as hot-reloading.
  • Preview production build: npm run preview
    • Start a local web server that serves the built solution from ./dist.
    • 💡 Run npm run build before npm run preview.

Desktop apps:

  • npm run electron:dev: The command will build the main process and preload scripts source code, and start a dev server for the renderer, and start the Electron app.
  • npm run electron:preview: The command will build the main process, preload scripts and renderer source code, and start the Electron app to preview.
  • npm run electron:prebuild: The command will build the main process, preload scripts and renderer source code. Usually before packaging the Electron application, you need to execute this command.
  • npm run electron:build: Prebuilds the Electron application, packages and publishes it through electron-builder.

Docker:

  1. Build: docker build -t undergroundwires/privacy.sexy:latest .
  2. Run: docker run -it -p 8080:80 --rm --name privacy.sexy undergroundwires/privacy.sexy:latest

Building

  • Build web application: npm run build
  • Build desktop application: npm run electron:build
  • (Re)create icons (see documentation): npm run create-icons

Scripts

📖 For detailed options and behavior for any of the following scripts, please refer to the script file itself.

Utility scripts

  • ./scripts/fresh-npm-install.sh:
    • Run fresh NPM install.
    • This script provides a clean NPM install, removing existing node modules and optionally the package-lock.json (when run with -n), then installs dependencies and runs unit tests.
  • ./scripts/configure-vscode.sh:
    • This script checks and sets the necessary configurations for VSCode in settings.json file.

Automation scripts

You should use EditorConfig to follow project style.

For Visual Studio Code, .vscode/extensions.json includes list of recommended extensions.