feat!: add {{modeSuffix}} to zip templates and update defaults (#1623)
Co-authored-by: Aaron <aaronklinker1@gmail.com>
This commit is contained in:
@@ -64,21 +64,23 @@ describe('Zipping', () => {
|
||||
it('should correctly apply template variables for zip file names based on provided config', async () => {
|
||||
const project = new TestProject({
|
||||
name: 'test',
|
||||
version: '1.0.0',
|
||||
version: '1.0.0-beta.1',
|
||||
});
|
||||
project.addFile(
|
||||
'entrypoints/background.ts',
|
||||
'export default defineBackground(() => {});',
|
||||
);
|
||||
const artifactZip = '.output/test-1.0.0-firefox-development.zip';
|
||||
const sourcesZip = '.output/test-1.0.0-development-sources.zip';
|
||||
const artifactZip = '.output/test-1.0.0-beta.1-firefox-dev.zip';
|
||||
const sourcesZip = '.output/test-1.0.0-beta.1-sources-dev.zip';
|
||||
|
||||
await project.zip({
|
||||
browser: 'firefox',
|
||||
mode: 'development',
|
||||
zip: {
|
||||
artifactTemplate: '{{name}}-{{version}}-{{browser}}-{{mode}}.zip',
|
||||
sourcesTemplate: '{{name}}-{{version}}-{{mode}}-sources.zip',
|
||||
artifactTemplate:
|
||||
'{{name}}-{{packageVersion}}-{{browser}}{{modeSuffix}}.zip',
|
||||
sourcesTemplate:
|
||||
'{{name}}-{{packageVersion}}-sources{{modeSuffix}}.zip',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -308,8 +308,9 @@ function resolveZipConfig(
|
||||
const downloadedPackagesDir = path.resolve(root, '.wxt/local_modules');
|
||||
return {
|
||||
name: undefined,
|
||||
sourcesTemplate: '{{name}}-{{version}}-sources.zip',
|
||||
artifactTemplate: '{{name}}-{{version}}-{{browser}}.zip',
|
||||
sourcesTemplate: '{{name}}-{{packageVersion}}-sources{{modeSuffix}}.zip',
|
||||
artifactTemplate:
|
||||
'{{name}}-{{packageVersion}}-{{browser}}{{modeSuffix}}.zip',
|
||||
sourcesRoot: root,
|
||||
includeSources: [],
|
||||
compressionLevel: 9,
|
||||
|
||||
@@ -32,6 +32,11 @@ export async function zip(config?: InlineConfig): Promise<string[]> {
|
||||
const projectName =
|
||||
wxt.config.zip.name ??
|
||||
safeFilename(packageJson?.name || path.basename(process.cwd()));
|
||||
const modeSuffixes: Record<string, string | undefined> = {
|
||||
production: '',
|
||||
development: '-dev',
|
||||
};
|
||||
const modeSuffix = modeSuffixes[wxt.config.mode] ?? `-${wxt.config.mode}`;
|
||||
const applyTemplate = (template: string): string =>
|
||||
template
|
||||
.replaceAll('{{name}}', projectName)
|
||||
@@ -41,6 +46,7 @@ export async function zip(config?: InlineConfig): Promise<string[]> {
|
||||
output.manifest.version_name ?? output.manifest.version,
|
||||
)
|
||||
.replaceAll('{{packageVersion}}', packageJson?.version)
|
||||
.replaceAll('{{modeSuffix}}', modeSuffix)
|
||||
.replaceAll('{{mode}}', wxt.config.mode)
|
||||
.replaceAll('{{manifestVersion}}', `mv${wxt.config.manifestVersion}`);
|
||||
|
||||
|
||||
@@ -201,9 +201,11 @@ export interface InlineConfig {
|
||||
* - <span v-pre>`{{browser}}`</span> - The target browser from the
|
||||
* `--browser` CLI flag
|
||||
* - <span v-pre>`{{mode}}`</span> - The current mode
|
||||
* - <span v-pre>`{{modeSuffix}}`</span>: A suffix based on the mode ('-dev'
|
||||
* for development, '' for production)
|
||||
* - <span v-pre>`{{manifestVersion}}`</span> - Either "2" or "3"
|
||||
*
|
||||
* @default '{{name}}-{{version}}-{{browser}}.zip'
|
||||
* @default '{{name}}-{{packageVersion}}-{{browser}}{{modeSuffix}}.zip'
|
||||
*/
|
||||
artifactTemplate?: string;
|
||||
/**
|
||||
@@ -230,9 +232,11 @@ export interface InlineConfig {
|
||||
* - <span v-pre>`{{browser}}`</span> - The target browser from the
|
||||
* `--browser` CLI flag
|
||||
* - <span v-pre>`{{mode}}`</span> - The current mode
|
||||
* - <span v-pre>`{{modeSuffix}}`</span>: A suffix based on the mode ('-dev'
|
||||
* for development, '' for production)
|
||||
* - <span v-pre>`{{manifestVersion}}`</span> - Either "2" or "3"
|
||||
*
|
||||
* @default '{{name}}-{{version}}-sources.zip'
|
||||
* @default '{{name}}-{{packageVersion}}-sources{{modeSuffix}}.zip'
|
||||
*/
|
||||
sourcesTemplate?: string;
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user