From 3018801f06564bb4dbbcd101bda21c4fc148a997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=CE=9ENS=CE=9BI?= Date: Thu, 24 Apr 2025 19:06:50 +0200 Subject: [PATCH] feat: add `{{packageVersion}}` as template variable (#1604) --- packages/wxt/src/core/zip.ts | 6 +++--- packages/wxt/src/types.ts | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/wxt/src/core/zip.ts b/packages/wxt/src/core/zip.ts index 092d5c27..ceda07ef 100644 --- a/packages/wxt/src/core/zip.ts +++ b/packages/wxt/src/core/zip.ts @@ -26,11 +26,10 @@ export async function zip(config?: InlineConfig): Promise { wxt.logger.info('Zipping extension...'); const zipFiles: string[] = []; + const packageJson = await getPackageJson(); const projectName = wxt.config.zip.name ?? - safeFilename( - (await getPackageJson())?.name || path.basename(process.cwd()), - ); + safeFilename(packageJson?.name || path.basename(process.cwd())); const applyTemplate = (template: string): string => template .replaceAll('{{name}}', projectName) @@ -39,6 +38,7 @@ export async function zip(config?: InlineConfig): Promise { '{{version}}', output.manifest.version_name ?? output.manifest.version, ) + .replaceAll('{{packageVersion}}', packageJson?.version) .replaceAll('{{mode}}', wxt.config.mode) .replaceAll('{{manifestVersion}}', `mv${wxt.config.manifestVersion}`); diff --git a/packages/wxt/src/types.ts b/packages/wxt/src/types.ts index 7d394aa7..b1ef253b 100644 --- a/packages/wxt/src/types.ts +++ b/packages/wxt/src/types.ts @@ -147,6 +147,7 @@ export interface InlineConfig { * * - `{{name}}` - The project's name converted to kebab-case * - `{{version}}` - The version_name or version from the manifest + * - `{{packageVersion}}` - The version from the package.json * - `{{browser}}` - The target browser from the `--browser` CLI flag * - `{{mode}}` - The current mode * - `{{manifestVersion}}` - Either "2" or "3" @@ -171,6 +172,7 @@ export interface InlineConfig { * * - `{{name}}` - The project's name converted to kebab-case * - `{{version}}` - The version_name or version from the manifest + * - `{{packageVersion}}` - The version from the package.json * - `{{browser}}` - The target browser from the `--browser` CLI flag * - `{{mode}}` - The current mode * - `{{manifestVersion}}` - Either "2" or "3"