103 lines
2.7 KiB
TOML
103 lines
2.7 KiB
TOML
# Set TARGET using duckscript rather than the usual `env_not_set` way as there's
|
|
# currently a potential bug with using decode maps and conditions.
|
|
# https://github.com/sagiegurari/cargo-make/issues/1018
|
|
env_scripts = ["""
|
|
#!@duckscript
|
|
|
|
target = get_env TARGET
|
|
if is_empty ${target}
|
|
browser = get_env BROWSER
|
|
if eq ${browser} "firefox"
|
|
set_env TARGET "firefox-desktop"
|
|
else
|
|
set_env TARGET ${browser}
|
|
end
|
|
end
|
|
"""]
|
|
|
|
[env]
|
|
# Set BROWSER="firefox" if not already defined.
|
|
# All browser targets are defined in `source/types.d.ts` as a global `$browser`.
|
|
BROWSER = { condition = { env_not_set = ["BROWSER"] }, value = "firefox" }
|
|
# Set NODE_ENV="development" if not already defined.
|
|
# Either "development" or "production" should be used.
|
|
NODE_ENV = { condition = { env_not_set = ["NODE_ENV"] }, value = "development" }
|
|
|
|
# Start a browser instance that will reload the extension when changes are made.
|
|
[tasks.dev]
|
|
clear = true
|
|
dependencies = ["pnpm-install", "build"]
|
|
command = "pnpm"
|
|
args = ["conc", "-c=auto", "-k", "makers watch", "makers run"]
|
|
|
|
# Build the WebExtension.
|
|
[tasks.build]
|
|
clear = true
|
|
command = "pnpm"
|
|
args = ["tsx", "source/build.ts"]
|
|
|
|
# Remove build directories.
|
|
[tasks.clean]
|
|
clear = true
|
|
command = "pnpm"
|
|
args = ["trash", "build/${BROWSER}"]
|
|
|
|
# Run all other linting tasks.
|
|
[tasks.lint]
|
|
clear = true
|
|
dependencies = ["lint-js", "lint-scss"]
|
|
|
|
# Run XO.
|
|
[tasks.lint-js]
|
|
clear = true
|
|
command = "pnpm"
|
|
args = ["xo"]
|
|
|
|
# Run Stylelint.
|
|
[tasks.lint-scss]
|
|
clear = true
|
|
command = "pnpm"
|
|
args = ["stylelint", "source/**/*.scss"]
|
|
|
|
# Re-build and pack the WebExtension for publishing.
|
|
[tasks.pack]
|
|
clear = true
|
|
dependencies = ["pnpm-install", "clean", "build"]
|
|
command = "pnpm"
|
|
args = ["web-ext", "build", "--config=build/web-ext-${BROWSER}.json"]
|
|
|
|
# Run "pnpm install" if the node_modules directory doesn't exist.
|
|
[tasks.pnpm-install]
|
|
clear = true
|
|
# Disable NODE_ENV so pnpm installs everything.
|
|
env = { NODE_ENV = "" }
|
|
condition = { files_not_exist = ["node_modules/"] }
|
|
command = "pnpm"
|
|
args = ["install", "--silent"]
|
|
|
|
# Start a browser instance with the extension loaded.
|
|
[tasks.run]
|
|
clear = true
|
|
command = "pnpm"
|
|
args = [
|
|
"web-ext",
|
|
"run",
|
|
# Set --target explicitly, since web-ext for some reason doesn't use the target
|
|
# set in the configuration file. https://github.com/mozilla/web-ext/issues/1862
|
|
"--target=${TARGET}",
|
|
"--config=build/web-ext-${BROWSER}.json",
|
|
"--adb-device=${ADB_DEVICE}",
|
|
"--firefox-apk=org.mozilla.fenix"
|
|
]
|
|
|
|
# Alias for `WATCH=true makers build`.
|
|
[tasks.watch]
|
|
env = { WATCH="true" }
|
|
extend = "build"
|
|
|
|
# Create a ZIP archive with only the source code, for AMO publishing.
|
|
[tasks.zip-source]
|
|
clear = true
|
|
command = "git"
|
|
args = ["archive", "--format=zip", "--output=build/tildes-reextended-source.zip", "HEAD"]
|