Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7d1ab4f
Add .deployignore support to Site Sync
ivan-ottinger Apr 1, 2026
e70aff5
Check deployIgnore on top-level archive paths
ivan-ottinger Apr 1, 2026
e88ba03
Filter meta.json plugin and theme lists against deployIgnore
ivan-ottinger Apr 1, 2026
f2cba66
Merge remote-tracking branch 'origin/trunk' into stu-16-add-deployign…
ivan-ottinger Apr 1, 2026
fd6e94c
Update SYNC_ADDITIONAL_DEFAULTS comment to clarify overridability
ivan-ottinger Apr 1, 2026
edfa8e5
Add tests for additionalDefaults parameter and negation override
ivan-ottinger Apr 1, 2026
3e53189
Merge remote-tracking branch 'origin/trunk' into stu-16-add-deployign…
ivan-ottinger Apr 15, 2026
cac9ae9
Apply .deployignore to CLI sync push
ivan-ottinger Apr 15, 2026
2d2216b
Simplify createDeployIgnoreFilter with a single basePatterns argument
ivan-ottinger Apr 15, 2026
3c7c651
Move DEPLOY_IGNORE_DEFAULTS into SYNC_IGNORE_DEFAULTS
ivan-ottinger Apr 15, 2026
d0d5648
Inline deploy defaults in SYNC_IGNORE_DEFAULTS to fix renderer build
ivan-ottinger Apr 15, 2026
69ce780
Drop redundant Windows path normalization around ignore.ignores()
ivan-ottinger Apr 15, 2026
9f574e7
Merge remote-tracking branch 'origin/trunk' into stu-16-add-deployign…
ivan-ottinger Apr 17, 2026
ac5c848
Merge remote-tracking branch 'origin/trunk' into stu-16-add-deployign…
ivan-ottinger Apr 20, 2026
35e0516
Fix import order in CLI export types
ivan-ottinger Apr 20, 2026
f20bc03
Extract DEPLOY_IGNORE_DEFAULTS to a renderer-safe module
ivan-ottinger Apr 20, 2026
3b6c91e
Show dotfiles in the sync tree UI
ivan-ottinger Apr 20, 2026
856e670
Merge remote-tracking branch 'origin/trunk' into stu-16-add-deployign…
ivan-ottinger Apr 21, 2026
e0b2e81
Revert dotfile visibility in sync tree
ivan-ottinger Apr 21, 2026
719eebc
Merge remote-tracking branch 'origin/trunk' into stu-16-add-deployign…
ivan-ottinger Apr 22, 2026
5491082
Document dotfile handling in sync filter and tree UI
ivan-ottinger Apr 23, 2026
7192dd3
Add ignore as a direct dependency and upgrade to v7
ivan-ottinger Apr 23, 2026
c67ce33
Use path.join for consistent separators when building ignore paths
ivan-ottinger Apr 23, 2026
0a16cd8
Rename exporter option deployIgnore to ignoreFilter
ivan-ottinger Apr 23, 2026
6eb29dd
Merge remote-tracking branch 'origin/trunk' into stu-16-add-deployign…
ivan-ottinger Apr 23, 2026
9348670
Fix import order in CLI export command
ivan-ottinger Apr 23, 2026
e01525a
Move shouldExcludeFromSync to its own module and use path.basename
ivan-ottinger Apr 23, 2026
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions apps/cli/commands/export.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import path from 'path';
import { DEFAULT_PHP_VERSION } from '@studio/common/constants';
import { createDeployIgnoreFilter } from '@studio/common/lib/deploy-ignore';
import {
ExportEvents,
ExportEventTuple,
ExportIpcEvent,
} from '@studio/common/lib/import-export-events';
import { SYNC_IGNORE_DEFAULTS } from '@studio/common/lib/sync/constants';
import { SiteCommandLoggerAction as LoggerAction } from '@studio/common/logger-actions';
import { __, _n, sprintf } from '@wordpress/i18n';
import { getSiteByFolder } from 'cli/lib/cli-config/sites';
Expand Down Expand Up @@ -124,7 +126,8 @@ export async function runCommand(
exportPath: string,
mode: 'full' | 'content' | 'db' = 'full',
splitDbDumpByTable = false,
includeOnlyPaths?: string[]
includeOnlyPaths?: string[],
applyDeployIgnore = false
): Promise< void > {
try {
logger.reportStart( LoggerAction.START_DAEMON, __( 'Starting process daemon…' ) );
Expand All @@ -150,13 +153,18 @@ export async function runCommand(
includes.database = false;
}

const ignoreFilter = applyDeployIgnore
? await createDeployIgnoreFilter( site.path, SYNC_IGNORE_DEFAULTS )
: undefined;

const exporter = await getExporter( {
site,
backupFile: exportPath,
phpVersion: DEFAULT_PHP_VERSION,
includes,
splitDatabaseDumpByTable: splitDbDumpByTable,
specificSelectionPaths: includeOnlyPaths,
ignoreFilter,
} );

if ( ! exporter ) {
Expand Down Expand Up @@ -230,6 +238,12 @@ export const registerCommand = ( yargs: StudioArgv ) => {
return value.map( String );
},
hidden: true,
} )
.option( 'apply-deploy-ignore', {
type: 'boolean',
default: false,
description: __( 'Apply .deployignore patterns when exporting' ),
hidden: true,
} );
},
handler: async ( argv ) => {
Expand Down Expand Up @@ -262,7 +276,8 @@ export const registerCommand = ( yargs: StudioArgv ) => {
exportFile,
argv.mode,
argv.splitDbDumpByTable,
argv.includeOnly
argv.includeOnly,
argv.applyDeployIgnore
);
} catch ( error ) {
if ( error instanceof LoggerError ) {
Expand Down
5 changes: 5 additions & 0 deletions apps/cli/commands/push.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import fs from 'fs';
import os from 'os';
import path from 'path';
import { createDeployIgnoreFilter } from '@studio/common/lib/deploy-ignore';
import { readAuthToken } from '@studio/common/lib/shared-config';
import {
SYNC_IGNORE_DEFAULTS,
SYNC_MAX_STALLED_ATTEMPTS,
SYNC_POLL_INTERVAL_MS,
SYNC_PUSH_SIZE_LIMIT_BYTES,
Expand Down Expand Up @@ -105,13 +107,16 @@ export async function runCommand(
};
}

const deployIgnore = await createDeployIgnoreFilter( site.path, SYNC_IGNORE_DEFAULTS );

const exporter = await getExporter( {
site,
backupFile: archivePath,
includes,
phpVersion: site.phpVersion,
splitDatabaseDumpByTable: true,
specificSelectionPaths,
ignoreFilter: deployIgnore,
} );

if ( ! exporter ) {
Expand Down
15 changes: 15 additions & 0 deletions apps/cli/commands/tests/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { Logger, LoggerError } from 'cli/logger';
import { registerCommand, runCommand } from '../export';
import type { SiteData } from 'cli/lib/cli-config/core';

vi.mock( '@studio/common/lib/deploy-ignore', () => ( {
createDeployIgnoreFilter: vi.fn().mockResolvedValue( { ignores: vi.fn() } ),
} ) );

function getYargsArgvMock() {
return yargs().option( 'path', {
type: 'string',
Expand Down Expand Up @@ -82,10 +86,21 @@ describe( 'CLI: studio export', () => {
},
specificSelectionPaths: undefined,
splitDatabaseDumpByTable: false,
ignoreFilter: undefined,
} );
expect( disconnectFromDaemon ).toHaveBeenCalled();
} );

it( 'applies deploy-ignore filter when applyDeployIgnore is set', async () => {
await runCommand( testSitePath, testExportPath, 'full', false, undefined, true );

expect( getExporter ).toHaveBeenCalledWith(
expect.objectContaining( {
ignoreFilter: expect.objectContaining( { ignores: expect.any( Function ) } ),
} )
);
} );

it( 'maps export events to logger actions', async () => {
const reportStartSpy = vi.spyOn( Logger.prototype, 'reportStart' );
const reportProgressSpy = vi.spyOn( Logger.prototype, 'reportProgress' );
Expand Down
34 changes: 29 additions & 5 deletions apps/cli/lib/import-export/export/exporters/default-exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ import { getWordPressVersionFromInstallation } from 'cli/lib/dependency-manageme
import { runWpCliCommand } from 'cli/lib/run-wp-cli-command';
import { ImportExportEventEmitter } from '../../events';
import { exportDatabaseToFile, exportDatabaseToMultipleFiles } from '../export-database';
import { ExportOptions, BackupContents, Exporter, StudioJson } from '../types';
import {
ExportOptions,
BackupContents,
Exporter,
StudioJson,
StudioJsonPluginOrTheme,
} from '../types';

export class DefaultExporter extends ImportExportEventEmitter implements Exporter {
private archiveBuilder!: archiver.Archiver;
Expand Down Expand Up @@ -208,6 +214,10 @@ export class DefaultExporter extends ImportExportEventEmitter implements Exporte
continue;
}

if ( this.options.ignoreFilter?.ignores( archivePath ) ) {
continue;
}

const stat = await fsPromises.stat( fullPath );
if ( stat.isDirectory() ) {
this.archiveBuilder.directory( fullPath, archivePath, ( entry ) => {
Expand All @@ -218,14 +228,18 @@ export class DefaultExporter extends ImportExportEventEmitter implements Exporte
);
if (
this.isExactPathExcluded( entryPathRelativeToArchiveRoot ) ||
this.isPathExcludedByPattern( fullEntryPathOnDisk )
this.isPathExcludedByPattern( fullEntryPathOnDisk ) ||
this.options.ignoreFilter?.ignores( entryPathRelativeToArchiveRoot )
) {
Comment thread
ivan-ottinger marked this conversation as resolved.
return false;
}
return entry;
} );
} else {
if ( this.isExactPathExcluded( archivePath ) ) {
if (
this.isExactPathExcluded( archivePath ) ||
this.options.ignoreFilter?.ignores( archivePath )
) {
continue;
}
this.archiveBuilder.file( fullPath, { name: archivePath } );
Expand Down Expand Up @@ -284,8 +298,18 @@ export class DefaultExporter extends ImportExportEventEmitter implements Exporte
this.getSiteThemes( this.options.site.path ),
] );

studioJson.plugins = plugins;
studioJson.themes = themes;
studioJson.plugins = this.options.ignoreFilter
? plugins.filter(
( p: StudioJsonPluginOrTheme ) =>
! this.options.ignoreFilter!.ignores( `wp-content/plugins/${ p.name }` )
)
: plugins;
studioJson.themes = this.options.ignoreFilter
? themes.filter(
( t: StudioJsonPluginOrTheme ) =>
! this.options.ignoreFilter!.ignores( `wp-content/themes/${ t.name }` )
)
: themes;

const tempDir = await fsPromises.mkdtemp( path.join( os.tmpdir(), 'studio-export-' ) );
const studioJsonPath = path.join( tempDir, 'meta.json' );
Expand Down
2 changes: 2 additions & 0 deletions apps/cli/lib/import-export/export/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SiteData } from 'cli/lib/cli-config/core';
import type { ImportExportEventEmitter } from '../events';
import type { Ignore } from 'ignore';

export interface ExportOptions {
site: SiteData;
Expand All @@ -8,6 +9,7 @@ export interface ExportOptions {
phpVersion: string;
splitDatabaseDumpByTable?: boolean;
specificSelectionPaths?: string[];
ignoreFilter?: Ignore;
}

export type ExportOptionsIncludes = 'wpContent' | 'database';
Expand Down
21 changes: 16 additions & 5 deletions apps/cli/lib/sync-file-tree.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
import fs from 'fs';
import nodePath from 'path';
import { shouldExcludeFromSync, shouldLimitDepth } from '@studio/common/lib/sync/tree-utils';
import { createDeployIgnoreFilter } from '@studio/common/lib/deploy-ignore';
import { SYNC_IGNORE_DEFAULTS } from '@studio/common/lib/sync/constants';
import { shouldExcludeFromSync } from '@studio/common/lib/sync/exclude-from-sync';
import { shouldLimitDepth } from '@studio/common/lib/sync/tree-utils';
import type { RawDirectoryEntry } from '@studio/common/types/sync-tree';
import type { Ignore } from 'ignore';

export async function listLocalFileTree(
sitePath: string,
relativePath: string,
maxDepth: number = 2,
currentDepth: number = 0
currentDepth: number = 0,
deployIgnore?: Ignore
): Promise< RawDirectoryEntry[] > {
if ( ! deployIgnore ) {
deployIgnore = await createDeployIgnoreFilter( sitePath, SYNC_IGNORE_DEFAULTS );
}

const fullPath = nodePath.join( sitePath, relativePath );

try {
const entries = await fs.promises.readdir( fullPath, { withFileTypes: true } );
const result: RawDirectoryEntry[] = [];

for ( const entry of entries ) {
if ( shouldExcludeFromSync( entry.name ) ) {
const itemPath = nodePath.join( relativePath, entry.name ).replace( /\\/g, '/' );

if ( shouldExcludeFromSync( itemPath, deployIgnore ) ) {
continue;
}

const isDirectory = entry.isDirectory();
const itemPath = nodePath.join( relativePath, entry.name ).replace( /\\/g, '/' );

const directoryEntry: RawDirectoryEntry = {
name: entry.name,
Expand All @@ -36,7 +46,8 @@ export async function listLocalFileTree(
sitePath,
itemPath,
maxDepth,
currentDepth + 1
currentDepth + 1,
deployIgnore
);
} catch {
directoryEntry.children = [];
Expand Down
1 change: 1 addition & 0 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"cli-table3": "^0.6.5",
"fs-extra": "^11.3.4",
"http-proxy": "^1.18.1",
"ignore": "^7.0.5",
"node-forge": "^1.3.3",
"patch-package": "^8.0.1",
"picospinner": "^3.0.0",
Expand Down
1 change: 1 addition & 0 deletions apps/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"fs-extra": "^11.3.2",
"hpagent": "1.2.0",
"http-proxy": "^1.18.1",
"ignore": "^7.0.5",
"lockfile": "^1.0.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
21 changes: 16 additions & 5 deletions apps/studio/src/ipc-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
} from '@studio/common/lib/agent-skills';
import { validateBlueprintData } from '@studio/common/lib/blueprint-validation';
import { parseCliError, errorMessageContains } from '@studio/common/lib/cli-error';
import { createDeployIgnoreFilter } from '@studio/common/lib/deploy-ignore';
import { extractZip } from '@studio/common/lib/extract-zip';
import {
calculateDirectorySizeForArchive,
Expand All @@ -55,7 +56,9 @@ import {
readSharedConfig,
updateSharedConfig,
} from '@studio/common/lib/shared-config';
import { shouldExcludeFromSync, shouldLimitDepth } from '@studio/common/lib/sync/tree-utils';
import { SYNC_IGNORE_DEFAULTS } from '@studio/common/lib/sync/constants';
import { shouldExcludeFromSync } from '@studio/common/lib/sync/exclude-from-sync';
import { shouldLimitDepth } from '@studio/common/lib/sync/tree-utils';
import { isWordPressDevVersion } from '@studio/common/lib/wordpress-version-utils';
import { __, sprintf, LocaleData, defaultI18n } from '@wordpress/i18n';
import {
Expand Down Expand Up @@ -120,6 +123,7 @@ import { Blueprint } from 'src/stores/wpcom-api';
import { captureSiteThumbnail } from './lib/capture-site-thumbnail';
import type { AiSessionSummary, LoadedAiSession } from '@studio/common/ai/sessions/types';
import type { RawDirectoryEntry } from '@studio/common/types/sync-tree';
import type { Ignore } from 'ignore';
import type { WpCliResult } from 'src/site-server';

export {
Expand Down Expand Up @@ -1845,24 +1849,30 @@ export async function listLocalFileTree(
siteId: string,
path: string,
maxDepth: number = 3,
currentDepth: number = 0
currentDepth: number = 0,
deployIgnore?: Ignore
): Promise< RawDirectoryEntry[] > {
const server = SiteServer.get( siteId );
if ( ! server ) throw new Error( 'Site not found' );

if ( ! deployIgnore ) {
deployIgnore = await createDeployIgnoreFilter( server.details.path, SYNC_IGNORE_DEFAULTS );
}

const fullPath = nodePath.join( server.details.path, path );

try {
const entries = await fs.promises.readdir( fullPath, { withFileTypes: true } );
const result = [];

for ( const entry of entries ) {
if ( shouldExcludeFromSync( entry.name ) ) {
const itemPath = nodePath.join( path, entry.name ).replace( /\\/g, '/' );

if ( shouldExcludeFromSync( itemPath, deployIgnore ) ) {
continue;
}

const isDirectory = entry.isDirectory();
const itemPath = nodePath.join( path, entry.name ).replace( /\\/g, '/' );

const directoryEntry: RawDirectoryEntry = {
name: entry.name,
Expand All @@ -1878,7 +1888,8 @@ export async function listLocalFileTree(
siteId,
itemPath,
maxDepth,
currentDepth + 1
currentDepth + 1,
deployIgnore
);
} catch ( childErr ) {
console.warn( `Failed to load children for ${ itemPath }:`, childErr );
Expand Down
6 changes: 6 additions & 0 deletions apps/studio/src/modules/import-export/lib/ipc-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ type ExportOptions = {
showNotification?: boolean;
splitDatabaseDumpByTable?: boolean;
specificSelectionPaths?: string[];
applyDeployIgnore?: boolean;
abortSignal?: AbortSignal;
};

Expand All @@ -201,6 +202,7 @@ export async function exportSite(
showNotification = false,
splitDatabaseDumpByTable = false,
specificSelectionPaths = [],
applyDeployIgnore = false,
abortSignal,
} = options;

Expand All @@ -211,6 +213,10 @@ export async function exportSite(
args.push( '--split-db-dump-by-table' );
}

if ( applyDeployIgnore ) {
args.push( '--apply-deploy-ignore' );
}

if ( specificSelectionPaths.length > 0 ) {
args.push( '--include-only', ...specificSelectionPaths );
}
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/modules/sync/lib/ipc-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export async function exportSiteForPush(
mode,
splitDatabaseDumpByTable: true,
specificSelectionPaths: configuration?.specificSelectionPaths,
applyDeployIgnore: true,
abortSignal: abortController.signal,
} );

Expand Down
Loading
Loading