Skip to content

Commit 05d985f

Browse files
wojteknepeicher
andauthored
Add archiver patches back to fix following symlinks on export (#3060)
* Add archiver patches back to fix following symlinks on export * Remove @types/archiver patches The @types/archiver patches added followSymlinks to CoreOptions, but this is unnecessary — ARCHIVER_OPTIONS in constants.ts uses plain object inference so followSymlinks is never checked against CoreOptions. The CLI patch also broke CI because install:bundle uses --omit=dev, meaning @types/archiver is absent when patch-package runs. * Remove @types/archiver patches and restore ArchiverOptions casts The @types/archiver patches added followSymlinks to CoreOptions, but @types/archiver@7 dropped followSymlinks from CoreOptions (it's still supported at runtime). The CLI patch also broke CI because install:bundle uses --omit=dev, meaning @types/archiver is absent when patch-package runs. Restore the `as archiver.ArchiverOptions` casts at call sites. * Remove cast and explicitly silence TS error --------- Co-authored-by: Roberto Aranda <roberto.aranda@automattic.com>
1 parent cf86585 commit 05d985f

5 files changed

Lines changed: 32 additions & 3 deletions

File tree

apps/cli/lib/archive.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ export async function archiveSiteContent(
1717
const output = fs.createWriteStream( archivePath );
1818
const archiveBuilder = archiver( 'zip', {
1919
zlib: { level: ZIP_COMPRESSION_LEVEL },
20+
// @ts-expect-error The `followSymlinks` option comes from a patch
2021
followSymlinks: true,
21-
} as archiver.ArchiverOptions );
22+
} );
2223

2324
output.on( 'close', () => {
2425
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 ] as archiver.ArchiverOptions );
156+
return archiver( format, ARCHIVER_OPTIONS[ format ] );
157157
}
158158

159159
private setupArchiveListeners( output: fs.WriteStream ): Promise< void > {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/node_modules/archiver/lib/core.js b/node_modules/archiver/lib/core.js
2+
index 7c0a74d..2934fe5 100644
3+
--- a/node_modules/archiver/lib/core.js
4+
+++ b/node_modules/archiver/lib/core.js
5+
@@ -631,7 +631,8 @@
6+
7+
var globOptions = {
8+
stat: true,
9+
- dot: true
10+
+ dot: true,
11+
+ follow: this.options.followSymlinks
12+
};
13+
14+
function onGlobEnd() {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/node_modules/archiver/lib/core.js b/node_modules/archiver/lib/core.js
2+
index 7c0a74d..2934fe5 100644
3+
--- a/node_modules/archiver/lib/core.js
4+
+++ b/node_modules/archiver/lib/core.js
5+
@@ -631,7 +631,8 @@
6+
7+
var globOptions = {
8+
stat: true,
9+
- dot: true
10+
+ dot: true,
11+
+ follow: this.options.followSymlinks
12+
};
13+
14+
function onGlobEnd() {

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 ] as archiver.ArchiverOptions );
157+
return archiver( format, ARCHIVER_OPTIONS[ format ] );
158158
}
159159

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

0 commit comments

Comments
 (0)