Skip to content

Latest commit

 

History

History
153 lines (104 loc) · 5.69 KB

CONTRIBUTING.md

File metadata and controls

153 lines (104 loc) · 5.69 KB

Contributing

Conventional Commits

This project uses Conventional Commits to automate versioning. If you're a new contributor, don't worry about this. When you open a PR, a maintainer will change the PR's title so it's in the style of conventional commits, but that's all.

Setup

The extension requires globally installed:

  • Node.js with Corepack enabled

    The version of Node.js used is specified in .nvmrc. It is recommended to use version managers - e.g. fnm.

  • Rust

    If rustup is used, it should automatically install everything you need when building. If not, you need to manually install the version and target specified in the rust-toolchain.toml file.

  • cargo-run-bin

    To install:

    cargo install --locked cargo-run-bin

Development

Development of an extension

  1. install dependencies::

    pnpm i

    this will also automatically build segmenter-utils

  2. if you don't want the dev-version of the extension to conflict with the prod-version, create a .env.local file with the contents:

    [email protected]
    
    # more about Gecko ID:
    # https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings#extension_id_format
  3. run pnpm dev:ff to build an extension for Firefox-based browsers

  4. load the extension from the .output/firefox-mv2 directory

Available commands

Here are some helpful commands:

  • pnpm build:ff - builds an extension for Firefox
  • pnpm zip:ff - builds and packages an extension for Firefox
  • pnpm test - runs the tests once
  • pnpm test:watch - runs tests in watch mode
  • pnpm su:watch - starts a dev build of segmenter-utils in watch mode
  • pnpm test-build-reproducibility - checks if build is reproducible (this is required to pass an AMO review)

GraphQL

A copy of the https://coub.com/graphql GraphQL schema is stored in the repository for type checking. Usually there is no need to touch it, but if the schema becomes outdated, to update it, execute:

pnpm gql:fetch-schema # executes an Introspection query and saves its response
pnpm gql:gen          # generates types based on the scheme

Utilities

To generate N fake channels for the blockedChannels storage:

  1. run
    $ node ./utils/fakeBlockedChannels.js N # N is a positive integer
    Wrote 1,000 channels to blockedChannels.json
    
  2. open the extension settings and import the backup from the created blockedChannels.json file

How to test auto-updating

  1. set up a local server that serves files from the docs directory

    This server must work over HTTPS, but even self-signed certificates will work. I have a server listening on localhost:8080, but if you have a different host - replace it in the following steps.

  2. create .env.local with the contents:

    VITE_GECKO_UPDATE_URL=https://localhost:8080/updates.json
  3. disable certificate validation in about:config by creating a settings:

    extensions.install.requireBuiltInCerts = false
    extensions.update.requireBuiltInCerts = false
  4. build a ZIP with the new version of the extension, change its extension from .zip to .xpi and copy it to docs so that the new version is in docs/coub-addons-x.x.x-firefox.xpi

    Here and below x.x.x is used instead of the extension version, don't forget to replace it with the real one.

  5. add the new version to docs/updates.json in the updates field:

    {
    	"updates": [
    		// ... other updates ...
    		{
    			"version": "x.x.x",
    			"update_link": "https://localhost:8080/coub-addons-x.x.x-firefox.xpi"
    		}
    	]
    }
  6. open about:addons, click on the gear and select Check for Updates to force check for updates

If something doesn't work, see Testing Automatic Updating.

Releasing updates

At the moment releases are done manually. To create a release, run pnpm bump.

This will automatically bump up the version based on new commits added since the previous tag, generate a CHANGELOG.md, build and package the extension for Firefox, creating two files in the .output directory:

  • coub-addons-x.x.x-firefox.zip - unsigned extension
  • coub-addons-x.x.x-sources.zip - source code of the extension for review in AMO

where x.x.x is the new version of the extension after bump (e.g. 0.1.20).

To publish a release, run:

  1. pnpm release-build
  2. pnpm tsx ./utils/upload/index.ts