Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scripts): make channel an option for the build script #517

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading