Skip to content

Commit 9c2052d

Browse files
wojteknKateryna Kodonenko
authored andcommitted
Upgrade archiver to v7 to fix glob and inflight deprecation warnings (#3050)
* CLI: upgrade archiver to v7 to fix glob and inflight deprecation warnings archiver@6 → archiver@7 pulls in archiver-utils@5 which uses glob@10 instead of glob@8, eliminating the glob and inflight deprecation warnings. @types/archiver@7 dropped followSymlinks from CoreOptions (it's still supported at runtime), so cast ArchiverOptions at call sites instead of patching node_modules. Also fixes the broken ProgressData named import which doesn't work with the export= module style in @types/archiver@7. * Studio: upgrade archiver to v7, drop @types/archiver patch Consistent with the CLI upgrade. Drops the @types+archiver+6.0.4 patch in favour of the same cast-based approach used in apps/cli. * Studio: remove obsolete archiver@6 runtime patch
1 parent 4e23a55 commit 9c2052d

12 files changed

Lines changed: 375 additions & 102 deletions

File tree

apps/cli/lib/archive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function archiveSiteContent(
1818
const archiveBuilder = archiver( 'zip', {
1919
zlib: { level: ZIP_COMPRESSION_LEVEL },
2020
followSymlinks: true,
21-
} );
21+
} as archiver.ArchiverOptions );
2222

2323
output.on( 'close', () => {
2424
resolve( archiveBuilder );

apps/cli/lib/import-export/export/exporters/default-exporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class DefaultExporter extends EventEmitter implements Exporter {
153153
this.emit( ExportEvents.BACKUP_CREATE_START );
154154
const isZip = this.options.backupFile.endsWith( '.zip' );
155155
const format = isZip ? 'zip' : 'tar';
156-
return archiver( format, ARCHIVER_OPTIONS[ format ] );
156+
return archiver( format, ARCHIVER_OPTIONS[ format ] as archiver.ArchiverOptions );
157157
}
158158

159159
private setupArchiveListeners( output: fs.WriteStream ): Promise< void > {

apps/cli/lib/import-export/export/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SiteData } from 'cli/lib/cli-config/core';
2-
import type { ProgressData } from 'archiver';
2+
import type archiver from 'archiver';
33
import type { EventEmitter } from 'events';
44

55
export interface ExportOptions {
@@ -24,7 +24,7 @@ export interface Exporter extends Partial< EventEmitter > {
2424
}
2525

2626
export interface BackupCreateProgressEventData {
27-
progress: ProgressData;
27+
progress: archiver.ProgressData;
2828
}
2929

3030
export type NewExporter = new ( options: ExportOptions ) => Exporter;

apps/cli/lib/tests/archive.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ describe( 'Archive Module', () => {
5151
vi.clearAllMocks();
5252
mockArchiver = createMockArchiver();
5353
mockWriteStream = createMockWriteStream();
54-
vi.mocked( archiver ).mockReturnValue(
55-
mockArchiver as unknown as ReturnType< typeof archiver >
54+
vi.mocked( archiver as unknown as ( ...args: unknown[] ) => unknown ).mockReturnValue(
55+
mockArchiver
5656
);
5757
vi.mocked( fs.createWriteStream ).mockReturnValue(
5858
mockWriteStream as unknown as ReturnType< typeof fs.createWriteStream >

apps/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@wp-playground/common": "3.1.18",
3838
"@wp-playground/storage": "3.1.18",
3939
"@wp-playground/wordpress": "3.1.18",
40-
"archiver": "^6.0.2",
40+
"archiver": "^7.0.1",
4141
"atomically": "^2.1.1",
4242
"chalk": "^5.6.2",
4343
"cli-table3": "^0.6.5",
@@ -68,7 +68,7 @@
6868
},
6969
"devDependencies": {
7070
"@studio/common": "file:../../tools/common",
71-
"@types/archiver": "^6.0.4",
71+
"@types/archiver": "^7.0.0",
7272
"@types/http-proxy": "^1.17.17",
7373
"@types/node-forge": "^1.3.14",
7474
"@types/yargs": "^17.0.35",

apps/studio/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@wordpress/i18n": "^6.9.0",
4444
"@wordpress/icons": "^11.4.0",
4545
"@wordpress/react-i18n": "^4.41.0",
46-
"archiver": "^6.0.2",
46+
"archiver": "^7.0.1",
4747
"atomically": "^2.1.0",
4848
"cli-table3": "^0.6.5",
4949
"compressible": "2.0.18",
@@ -86,7 +86,7 @@
8686
"@electron-forge/maker-zip": "^7.11.1",
8787
"@electron-forge/plugin-auto-unpack-natives": "^7.11.1",
8888
"@sentry/vite-plugin": "^5.1.1",
89-
"@types/archiver": "^6.0.4",
89+
"@types/archiver": "^7.0.0",
9090
"@types/follow-redirects": "^1.14.4",
9191
"@types/fs-extra": "^11.0.4",
9292
"@types/http-proxy": "^1.17.17",

apps/studio/patches/@types+archiver+6.0.4.patch

Lines changed: 0 additions & 12 deletions
This file was deleted.

apps/studio/patches/archiver+6.0.2.patch

Lines changed: 0 additions & 14 deletions
This file was deleted.

apps/studio/src/lib/import-export/export/exporters/default-exporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class DefaultExporter extends EventEmitter implements Exporter {
154154
this.emit( ExportEvents.BACKUP_CREATE_START );
155155
const isZip = this.options.backupFile.endsWith( '.zip' );
156156
const format = isZip ? 'zip' : 'tar';
157-
return archiver( format, ARCHIVER_OPTIONS[ format ] );
157+
return archiver( format, ARCHIVER_OPTIONS[ format ] as archiver.ArchiverOptions );
158158
}
159159

160160
private setupArchiveListeners( output: fs.WriteStream ): Promise< void > {

apps/studio/src/lib/import-export/export/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ProgressData } from 'archiver';
1+
import type archiver from 'archiver';
22
import type { EventEmitter } from 'events';
33

44
export interface ExportOptions {
@@ -23,7 +23,7 @@ export interface Exporter extends Partial< EventEmitter > {
2323
}
2424

2525
export interface BackupCreateProgressEventData {
26-
progress: ProgressData;
26+
progress: archiver.ProgressData;
2727
}
2828

2929
export type NewExporter = new ( options: ExportOptions ) => Exporter;

0 commit comments

Comments
 (0)