This commit improves collection file editing and error detection directly in the IDE. It adds YAML schema, IDE configuration and automatic tests to validate it. - Introduce a YAML schema for collection file. - Use `yaml-language-server` for enhanced YAML support in VSCode. - Add telemetry disabling in `configure_vscode.py` to respect user privacy. - Add automated checks to validate YAML file structure against the schema. - Remove unused properties and do not allow them in compiler.
5.1 KiB
5.1 KiB
Development
Before your commit, a good practice is to:
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.js:
- Refer to action.yml for the minimum required version compatible with the automated workflows.
- 💡 Recommended: Use
nvmCLI to install and switch between Node.js versions.
- Install dependencies using
npm install(ornpm run install-depsfor more options). - For Visual Studio Code users, running the configuration script is recommended to optimize the IDE settings, as detailed in utility scripts.
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
- You can set environment variables active its flags such as
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 buildbeforenpm run preview.
- Start a local web server that serves the built solution from
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 throughelectron-builder.
Docker:
- Build:
docker build -t undergroundwires/privacy.sexy:latest . - Run:
docker run -it -p 8080:80 --rm --name privacy.sexy undergroundwires/privacy.sexy:latest - Application should be available at
http://localhost:8080
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
npm run install-deps [-- <options>]:- Manages NPM dependency installation, it offers capabilities like doing a fresh install, retries on network errors, and other features.
- For example, you can run
npm run install-deps -- --freshto do clean installation of dependencies.
python3 ./scripts/configure_vscode.py:- Optimizes Visual Studio Code settings and installs essential extensions, enhancing the development environment.
python3 ./scripts/validate-collections-yaml:- Validates the syntax and structure of collection YAML files.
Automation scripts
node scripts/print-dist-dir.js [<options>]:- Determines the absolute path of a distribution directory based on CLI arguments and outputs its absolute path.
npm run check:verify-build-artifacts [-- <options>]:- Verifies the existence and content of build artifacts. Useful for ensuring that the build process is generating the expected output.
node scripts/verify-web-server-status.js --url [URL]:- Checks if a specified server is up with retries and returns an HTTP 200 status code.
Recommended extensions
You should use EditorConfig to follow project style.
For Visual Studio Code, .vscode/extensions.json includes list of recommended extensions.
You can use VSCode configuration script to automatically install those.