Skip to content

Commit

Permalink
Make channel an option for the build script
Browse files Browse the repository at this point in the history
Co-authored-by: Sid Vishnoi <[email protected]>
  • Loading branch information
raducristianpopa and sidvishnoi committed Aug 20, 2024
1 parent 20e426f commit 37223e2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- name: Build
shell: bash
run: pnpm build ${{ matrix.browser }} nightly
run: pnpm build ${{ matrix.browser }} --channel=nightly

- name: Upload artifacts
uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Build
shell: bash
run: pnpm build ${{ matrix.browser}} nightly
run: pnpm build ${{ matrix.browser}} --channel=nightly

test:
name: Test
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ pnpm i

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `pnpm dev [target]` | Builds the extension for development, rebuilding on source code changes, for a specified target (`chrome` or `firefox`). If the target is not specified the script will build the extension for a Chromium based browser. Output folder: `dev`. |
| `pnpm build [TARGET] [CHANNEL]` | Builds the extension for production usage, for a specified target (`chrome` or `firefox`) and channel (`nightly`, `preview` or `stable`). If the target is not specified the script will build the extension for all available targets. If the channel is not specified the script will build the extension for the `nightly` channel. Output folder: `dist`. |
| `pnpm test` | Runs all test files using Jest. |
| Command | Action |
| :-------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `pnpm dev [target]` | Builds the extension for development, rebuilding on source code changes, for a specified target (`chrome` or `firefox`). If the target is not specified the script will build the extension for a Chromium based browser. Output folder: `dev`. |
| `pnpm build [TARGET] --channel=CHANNEL` | Builds the extension for production usage, for a specified target (`chrome` or `firefox`) and channel (`nightly`, `preview` or `stable`). If the target is not specified the script will build the extension for all available targets. If the channel is not specified the script will build the extension for the `nightly` channel. Output folder: `dist`. |
| `pnpm test` | Runs all test files using Jest. |

### Installing the extension from source, in Chromium based browsers (Chrome, Opera, Edge, Brave, Arc, Vivaldi)

Expand Down
18 changes: 7 additions & 11 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import fs from 'node:fs'
import esbuild from 'esbuild'
import {
BuildArgs,
Channel,
CHANNELS,
DEV_DIR,
DIST_DIR,
Expand All @@ -19,16 +18,14 @@ import {
import { getDevOptions } from '../esbuild/dev'
import { getProdOptions } from '../esbuild/prod'

sade('build [target] [channel]', true)
sade('build [target]', true)
.option('--channel', `One of: ${CHANNELS.join(', ')}`, 'nightly')
.option('--dev', 'Dev-mode (watch, live-reload)', false)
.example('chrome nightly')
.example('firefox stable')
.describe([
'`target` should be one of ' + TARGETS.join(', '),
'`channel` should be one of ' + CHANNELS.join(', ')
])
.action(async (target: Target, channel: Channel, opts: BuildArgs) => {
const options = { ...opts, target, channel: channel || 'nightly' }
.example('chrome --channel=nightly')
.example('firefox --channel=stable')
.describe(['`target` should be one of ' + TARGETS.join(', ')])
.action(async (target: Target, opts: BuildArgs) => {
const options = { ...opts, target }
if (!options.target && !options.dev) {
console.log(`Building all targets with channel: ${options.channel}`)
return Promise.all(TARGETS.map((t) => build({ ...options, target: t })))
Expand All @@ -37,7 +34,6 @@ sade('build [target] [channel]', true)
// Default to chrome in dev build
if (options.dev) {
options.target ||= 'chrome'
options.channel ||= 'nightly'
}

if (!TARGETS.includes(options.target)) {
Expand Down

0 comments on commit 37223e2

Please sign in to comment.