Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions apps/cli/commands/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ExportEvents } from 'cli/lib/import-export/export/events';
import { exportBackup } from 'cli/lib/import-export/export/export-manager';
import { BackupCreateProgressEventData, ExportOptions } from 'cli/lib/import-export/export/types';
import { ImportExportEventData } from 'cli/lib/import-export/handle-events';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import { untildify } from 'cli/lib/utils';
import { Logger, LoggerError } from 'cli/logger';
import { StudioArgv } from 'cli/types';
Expand Down Expand Up @@ -87,13 +86,6 @@ export async function runCommand(
const site = await getSiteByFolder( siteFolder );
logger.reportSuccess( __( 'Site loaded' ) );

logger.reportStart(
LoggerAction.INSTALL_SQLITE,
__( 'Setting up SQLite integration, if needed…' )
);
await keepSqliteIntegrationUpdated( siteFolder );
logger.reportSuccess( __( 'SQLite integration configured as needed' ) );

const includes: ExportOptions[ 'includes' ] = { database: true, wpContent: true };

if ( mode === 'db' ) {
Expand Down
8 changes: 0 additions & 8 deletions apps/cli/commands/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
ImportWpContentProgressEventData,
} from 'cli/lib/import-export/import/types';
import { getBackupFileType } from 'cli/lib/import-export/utils';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import { untildify } from 'cli/lib/utils';
import {
isServerRunning,
Expand Down Expand Up @@ -236,13 +235,6 @@ export async function runCommand( siteFolder: string, importFile: string ): Prom
} finally {
try {
if ( site && wasServerRunning ) {
logger.reportStart(
LoggerAction.INSTALL_SQLITE,
__( 'Setting up SQLite integration, if needed…' )
);
await keepSqliteIntegrationUpdated( siteFolder );
logger.reportSuccess( __( 'SQLite integration configured as needed' ) );

logger.reportStart( LoggerAction.START_SITE, __( 'Starting WordPress server…' ) );
await startWordPressServer( site, logger );
logger.reportSuccess( __( 'WordPress server started' ) );
Expand Down
8 changes: 0 additions & 8 deletions apps/cli/commands/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
DEFAULT_IMPORTER_OPTIONS,
importBackup,
} from 'cli/lib/import-export/import/import-manager';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import {
checkBackupSize,
fetchSyncableSites,
Expand Down Expand Up @@ -204,13 +203,6 @@ export async function runCommand(
} finally {
try {
if ( site && wasServerRunning ) {
logger.reportStart(
LoggerAction.INSTALL_SQLITE,
__( 'Setting up SQLite integration, if needed…' )
);
await keepSqliteIntegrationUpdated( siteFolder );
logger.reportSuccess( __( 'SQLite integration configured as needed' ) );

logger.reportStart( LoggerAction.START_SITE, __( 'Starting WordPress server…' ) );
await startWordPressServer( site, logger );
logger.reportSuccess( __( 'WordPress server started' ) );
Expand Down
8 changes: 0 additions & 8 deletions apps/cli/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { __, sprintf } from '@wordpress/i18n';
import { getSiteByFolder } from 'cli/lib/cli-config/sites';
import { exportBackup } from 'cli/lib/import-export/export/export-manager';
import { ExportOptions } from 'cli/lib/import-export/export/types';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import {
fetchSyncableSites,
initiateImport,
Expand Down Expand Up @@ -47,13 +46,6 @@ export async function runCommand(
const site = await getSiteByFolder( siteFolder );
logger.reportSuccess( __( 'Site loaded' ) );

logger.reportStart(
LoggerAction.INSTALL_SQLITE,
__( 'Setting up SQLite integration, if needed…' )
);
await keepSqliteIntegrationUpdated( siteFolder );
logger.reportSuccess( __( 'SQLite integration configured as needed' ) );

logger.reportStart( LoggerAction.FETCH_REMOTE_SITES, __( 'Fetching WordPress.com sites…' ) );
const remoteSites = await fetchSyncableSites( token.accessToken );
logger.spinner.stop();
Expand Down
7 changes: 0 additions & 7 deletions apps/cli/commands/site/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ import { getPreferredSiteLanguage } from 'cli/lib/site-language';
import { generateSiteName } from 'cli/lib/site-name';
import { getDefaultSitePath } from 'cli/lib/site-paths';
import { logSiteDetails, openSiteInBrowser, setupCustomDomain } from 'cli/lib/site-utils';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import { StatsGroup } from 'cli/lib/types/bump-stats';
import { untildify } from 'cli/lib/utils';
import { ValidationError } from 'cli/lib/validation-error';
Expand Down Expand Up @@ -250,12 +249,6 @@ export async function runCommand(
);
}

logger.reportStart( LoggerAction.INSTALL_SQLITE, __( 'Setting up SQLite integration…' ) );
const isSqliteUpdated = await keepSqliteIntegrationUpdated( sitePath );
logger.reportSuccess(
isSqliteUpdated ? __( 'SQLite integration configured' ) : __( 'SQLite integration skipped' )
);

try {
const sharedConfig = await readSharedConfig();
const selectedSkills = sharedConfig.selectedSkills ?? [];
Expand Down
8 changes: 0 additions & 8 deletions apps/cli/commands/site/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import { connectToDaemon, disconnectFromDaemon } from 'cli/lib/daemon-client';
import { getAiInstructionsPath } from 'cli/lib/server-files';
import { logSiteDetails, openSiteInBrowser, setupCustomDomain } from 'cli/lib/site-utils';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import { isServerRunning, startWordPressServer } from 'cli/lib/wordpress-server-manager';
import { Logger, LoggerError } from 'cli/logger';
import { StudioArgv } from 'cli/types';
Expand Down Expand Up @@ -47,13 +46,6 @@ export async function runCommand(

await setupCustomDomain( site, logger );

logger.reportStart(
LoggerAction.INSTALL_SQLITE,
__( 'Setting up SQLite integration, if needed…' )
);
await keepSqliteIntegrationUpdated( sitePath );
logger.reportSuccess( __( 'SQLite integration configured as needed' ) );

try {
await updateManagedInstructionFiles( sitePath, getAiInstructionsPath() );
} catch ( error ) {
Expand Down
38 changes: 0 additions & 38 deletions apps/cli/commands/site/tests/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { updateServerFiles } from 'cli/lib/dependency-management/setup';
import { copyLanguagePackToSite } from 'cli/lib/language-packs';
import { getPreferredSiteLanguage } from 'cli/lib/site-language';
import { logSiteDetails, openSiteInBrowser, setupCustomDomain } from 'cli/lib/site-utils';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import { ProcessDescription } from 'cli/lib/types/process-manager-ipc';
import { runBlueprint, startWordPressServer } from 'cli/lib/wordpress-server-manager';
import { Logger } from 'cli/logger';
Expand Down Expand Up @@ -80,7 +79,6 @@ vi.mock( import( '@studio/common/lib/well-known-paths' ), async ( importOriginal
vi.mock( 'cli/lib/site-language' );
vi.mock( 'cli/lib/site-utils' );
vi.mock( '@studio/common/lib/agent-skills' );
vi.mock( 'cli/lib/sqlite-integration' );
vi.mock( 'cli/lib/wordpress-server-manager' );

describe( 'CLI: studio site create', () => {
Expand Down Expand Up @@ -121,7 +119,6 @@ describe( 'CLI: studio site create', () => {

let consoleLogSpy: MockInstance;
let fsMkdirSyncSpy: MockInstance;
let loggerReportSuccessSpy: MockInstance;

const createPathExistsMock = ( sitePathExists = false ) => {
const path = require( 'path' );
Expand All @@ -143,7 +140,6 @@ describe( 'CLI: studio site create', () => {

consoleLogSpy = vi.spyOn( console, 'log' ).mockImplementation( () => {} );
fsMkdirSyncSpy = vi.spyOn( fs, 'mkdirSync' ).mockReturnValue( undefined );
loggerReportSuccessSpy = vi.spyOn( Logger.prototype, 'reportSuccess' );
vi.mocked( getServerFilesPath ).mockReturnValue( '/test/server-files' );
createPathExistsMock( false );
vi.mocked( isEmptyDir ).mockResolvedValue( true );
Expand All @@ -158,7 +154,6 @@ describe( 'CLI: studio site create', () => {
vi.mocked( saveCliConfig ).mockResolvedValue( undefined );
vi.mocked( lockCliConfig ).mockResolvedValue( undefined );
vi.mocked( unlockCliConfig ).mockResolvedValue( undefined );
vi.mocked( keepSqliteIntegrationUpdated ).mockResolvedValue( true );
vi.mocked( connectToDaemon ).mockResolvedValue( undefined );
vi.mocked( disconnectFromDaemon ).mockResolvedValue( undefined );
vi.mocked( updateServerFiles ).mockResolvedValue( undefined );
Expand Down Expand Up @@ -252,27 +247,13 @@ describe( 'CLI: studio site create', () => {

expect( disconnectFromDaemon ).toHaveBeenCalled();
} );

it( 'should error if SQLite integration is not available', async () => {
vi.mocked( keepSqliteIntegrationUpdated ).mockRejectedValue(
new Error( 'SQLite integration files not found. Please ensure Studio is installed.' )
);

await expect( runCommand( mockSitePath, { ...defaultTestOptions } ) ).rejects.toThrow(
'SQLite integration files not found'
);

expect( disconnectFromDaemon ).toHaveBeenCalled();
} );
} );

describe( 'Success Cases', () => {
it( 'should create a basic site successfully', async () => {
await runCommand( mockSitePath, { ...defaultTestOptions } );

expect( fsMkdirSyncSpy ).toHaveBeenCalledWith( mockSitePath, { recursive: true } );
expect( keepSqliteIntegrationUpdated ).toHaveBeenCalledWith( mockSitePath );
expect( loggerReportSuccessSpy ).toHaveBeenCalledWith( 'SQLite integration configured' );
expect( portFinder.getOpenPort ).toHaveBeenCalled();
expect( lockCliConfig ).toHaveBeenCalled();
expect( saveCliConfig ).toHaveBeenCalled();
Expand All @@ -284,15 +265,6 @@ describe( 'CLI: studio site create', () => {
expect( disconnectFromDaemon ).toHaveBeenCalled();
} );

it( 'should skip SQLite integration when it is already configured', async () => {
vi.mocked( keepSqliteIntegrationUpdated ).mockResolvedValue( false );

await runCommand( mockSitePath, { ...defaultTestOptions } );

expect( keepSqliteIntegrationUpdated ).toHaveBeenCalledWith( mockSitePath );
expect( loggerReportSuccessSpy ).toHaveBeenCalledWith( 'SQLite integration skipped' );
} );

it( 'should create site with custom name', async () => {
await runCommand( mockSitePath, {
...defaultTestOptions,
Expand Down Expand Up @@ -789,16 +761,6 @@ describe( 'CLI: studio site create', () => {

expect( disconnectFromDaemon ).toHaveBeenCalled();
} );

it( 'should handle SQLite setup failure', async () => {
vi.mocked( keepSqliteIntegrationUpdated ).mockRejectedValue(
new Error( 'SQLite setup failed' )
);

await expect( runCommand( mockSitePath, { ...defaultTestOptions } ) ).rejects.toThrow();

expect( disconnectFromDaemon ).toHaveBeenCalled();
} );
} );

describe( 'Cleanup', () => {
Expand Down
4 changes: 0 additions & 4 deletions apps/cli/commands/site/tests/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getSiteByFolder } from 'cli/lib/cli-config/sites';
import { connectToDaemon, disconnectFromDaemon } from 'cli/lib/daemon-client';
import { ExportEvents } from 'cli/lib/import-export/export/events';
import { exportBackup } from 'cli/lib/import-export/export/export-manager';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import { Logger, LoggerError } from 'cli/logger';
import { registerCommand, runCommand } from '../../export';
import type { SiteData } from 'cli/lib/cli-config/core';
Expand All @@ -22,7 +21,6 @@ vi.mock( 'cli/lib/cli-config/sites', () => ( {
getSiteByFolder: vi.fn(),
} ) );
vi.mock( 'cli/lib/daemon-client' );
vi.mock( 'cli/lib/sqlite-integration' );
vi.mock( 'cli/lib/import-export/export/export-manager', () => ( {
exportBackup: vi.fn(),
} ) );
Expand All @@ -46,7 +44,6 @@ describe( 'CLI: studio export', () => {
vi.mocked( connectToDaemon ).mockResolvedValue( undefined );
vi.mocked( disconnectFromDaemon ).mockResolvedValue( undefined );
vi.mocked( getSiteByFolder ).mockResolvedValue( testSite );
vi.mocked( keepSqliteIntegrationUpdated ).mockResolvedValue( false );
vi.mocked( exportBackup ).mockResolvedValue( true );
} );

Expand All @@ -59,7 +56,6 @@ describe( 'CLI: studio export', () => {

expect( connectToDaemon ).toHaveBeenCalled();
expect( getSiteByFolder ).toHaveBeenCalledWith( testSitePath );
expect( keepSqliteIntegrationUpdated ).toHaveBeenCalledWith( testSitePath );
expect( exportBackup ).toHaveBeenCalledWith(
{
site: testSite,
Expand Down
6 changes: 0 additions & 6 deletions apps/cli/commands/site/tests/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
DEFAULT_IMPORTER_OPTIONS,
importBackup,
} from 'cli/lib/import-export/import/import-manager';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import { isServerRunning, stopWordPressServer } from 'cli/lib/wordpress-server-manager';
import { Logger, LoggerError } from 'cli/logger';
import { runCommand } from '../../import';
Expand All @@ -23,9 +22,6 @@ vi.mock( 'cli/lib/cli-config/sites', () => ( {
getSiteUrl: vi.fn(),
} ) );
vi.mock( 'cli/lib/daemon-client' );
vi.mock( 'cli/lib/sqlite-integration', () => ( {
keepSqliteIntegrationUpdated: vi.fn(),
} ) );
vi.mock( 'cli/lib/wordpress-server-manager', () => ( {
isServerRunning: vi.fn(),
stopWordPressServer: vi.fn(),
Expand Down Expand Up @@ -61,7 +57,6 @@ describe( 'CLI: studio import', () => {
vi.mocked( getSiteByFolder ).mockResolvedValue( testSite );
vi.mocked( isServerRunning ).mockResolvedValue( undefined );
vi.mocked( stopWordPressServer ).mockResolvedValue( undefined );
vi.mocked( keepSqliteIntegrationUpdated ).mockResolvedValue( false );
vi.mocked( isWordPressDirectory ).mockReturnValue( true );
vi.mocked( getServerFilesPath ).mockReturnValue( '/server-files' );
vi.mocked( recursiveCopyDirectory ).mockResolvedValue( undefined );
Expand Down Expand Up @@ -167,7 +162,6 @@ describe( 'CLI: studio import', () => {
it( 'preserves import error when restore steps fail', async () => {
vi.mocked( isServerRunning ).mockResolvedValue( { pid: 1234 } as never );
vi.mocked( importBackup ).mockRejectedValue( new Error( 'import failed' ) );
vi.mocked( keepSqliteIntegrationUpdated ).mockRejectedValue( new Error( 'restart failed' ) );

await expect( runCommand( testSitePath, testImportPath ) ).rejects.toThrow( 'import failed' );
expect( stopWordPressServer ).toHaveBeenCalledWith( testSite.id );
Expand Down
19 changes: 0 additions & 19 deletions apps/cli/commands/site/tests/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from 'cli/lib/cli-config/sites';
import { connectToDaemon, disconnectFromDaemon } from 'cli/lib/daemon-client';
import { logSiteDetails, openSiteInBrowser, setupCustomDomain } from 'cli/lib/site-utils';
import { keepSqliteIntegrationUpdated } from 'cli/lib/sqlite-integration';
import { ProcessDescription } from 'cli/lib/types/process-manager-ipc';
import { isServerRunning, startWordPressServer } from 'cli/lib/wordpress-server-manager';
import { Logger } from 'cli/logger';
Expand All @@ -22,7 +21,6 @@ vi.mock( 'cli/lib/cli-config/sites', async () => ( {
vi.mock( 'cli/lib/daemon-client' );
vi.mock( 'cli/lib/site-utils' );
vi.mock( 'cli/lib/wordpress-server-manager' );
vi.mock( 'cli/lib/sqlite-integration' );

describe( 'CLI: studio site start', () => {
// Simple test data
Expand Down Expand Up @@ -56,7 +54,6 @@ describe( 'CLI: studio site start', () => {
vi.mocked( disconnectFromDaemon ).mockResolvedValue( undefined );
vi.mocked( isServerRunning ).mockResolvedValue( undefined );
vi.mocked( setupCustomDomain ).mockResolvedValue( undefined );
vi.mocked( keepSqliteIntegrationUpdated ).mockResolvedValue( false );
vi.mocked( startWordPressServer ).mockResolvedValue( testProcessDescription );
vi.mocked( updateSiteLatestCliPid ).mockResolvedValue( undefined );
vi.mocked( logSiteDetails ).mockImplementation( () => {} );
Expand Down Expand Up @@ -105,15 +102,6 @@ describe( 'CLI: studio site start', () => {
expect( disconnectFromDaemon ).toHaveBeenCalled();
} );

it( 'should throw when SQLite integration setup fails', async () => {
vi.mocked( keepSqliteIntegrationUpdated ).mockRejectedValue(
new Error( 'SQLite setup failed' )
);

await expect( runCommand( '/test/site' ) ).rejects.toThrow( 'SQLite setup failed' );
expect( disconnectFromDaemon ).toHaveBeenCalled();
} );

it( 'should throw when browser fails', async () => {
vi.mocked( openSiteInBrowser ).mockRejectedValue( new Error( 'Browser error' ) );

Expand All @@ -138,7 +126,6 @@ describe( 'CLI: studio site start', () => {
expect( connectToDaemon ).toHaveBeenCalled();
expect( isServerRunning ).toHaveBeenCalledWith( testSite.id );
expect( setupCustomDomain ).toHaveBeenCalledWith( testSite, expect.any( Logger ) );
expect( keepSqliteIntegrationUpdated ).toHaveBeenCalledWith( '/test/site' );
expect( startWordPressServer ).toHaveBeenCalledWith( testSite, expect.any( Logger ) );
expect( updateSiteLatestCliPid ).toHaveBeenCalledWith(
testSite.id,
Expand Down Expand Up @@ -179,12 +166,6 @@ describe( 'CLI: studio site start', () => {
expect( disconnectFromDaemon ).toHaveBeenCalled();
} );

it( 'should update SQLite integration', async () => {
await runCommand( '/test/site' );

expect( keepSqliteIntegrationUpdated ).toHaveBeenCalledWith( '/test/site' );
} );

it( 'should skip browser when skipBrowser is true', async () => {
await runCommand( '/test/site', true );

Expand Down
Loading
Loading