Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make kitchen sink extension bundle the default #1191

Merged
merged 6 commits into from
Apr 3, 2024
Merged
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
2 changes: 1 addition & 1 deletion packages/docs/site/docs/08-query-api/01-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can go ahead and try it out. The Playground will automatically install the t
| `php` | `8.0` | Loads the specified PHP version. Supported values: `7.0`, `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `latest` |
| `wp` | `latest` | Loads the specified WordPress version. Supported values: `6.0`, `6.1`, `6.2`, `6.3`, `6.4`, `latest`, `nightly`, `beta` |
| `blueprint-url` | | The URL of the Blueprint that will be used to configure this Playground instance. |
| `php-extension-bundle` | | Loads a bundle of PHP extensions. Supported bundles: `kitchen-sink` (for gd, mbstring, iconv, openssl, libxml, xml, dom, simplexml, xmlreader, xmlwriter) |
| `php-extension-bundle` | | Loads a bundle of PHP extensions. Supported bundles: `kitchen-sink` (for finfo, gd, mbstring, iconv, openssl, libxml, xml, dom, simplexml, xmlreader, xmlwriter), `light` (saves 6MB of downloads, loads none of the above extensions) |
| `networking` | `yes` or `no` | Enables or disables the networking support for Playground. Defaults to `no` |
| `plugin` | | Installs the specified plugin. Use the plugin name from the plugins directory URL, e.g. for a URL like `https://wordpress.org/plugins/wp-lazy-loading/`, the plugin name would be `wp-lazy-loading`. You can pre-install multiple plugins by saying `plugin=coblocks&plugin=wp-lazy-loading&…`. Installing a plugin automatically logs the user in as an admin |
| `theme` | | Installs the specified theme. Use the theme name from the themes directory URL, e.g. for a URL like `https://wordpress.org/themes/disco/`, the theme name would be `disco`. Installing a theme automatically logs the user in as an admin |
Expand Down
3 changes: 2 additions & 1 deletion packages/docs/site/docs/09-blueprints-api/03-data-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ The `preferredVersions` property, unsurprisingly, declares the preferred of PHP

The `phpExtensionBundles` property is an array of PHP extension bundles to load. The following bundles are supported:

- `kitchen-sink`: Installs `gd`, `mbstring`, `iconv`, `openssl`, `libxml`, `xml`, `dom`, `simplexml`, `xmlreader`, `xmlwriter`
- `kitchen-sink`: Default choice. Installs `gd`, `mbstring`, `iconv`, `openssl`, `libxml`, `xml`, `dom`, `simplexml`, `xmlreader`, `xmlwriter`
- `light`: Saves 6MB of downloads, loads none of the above extensions.

## Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export const SupportedPHPExtensionsList = [

export const SupportedPHPExtensionBundles = {
'kitchen-sink': SupportedPHPExtensionsList,
light: [],
};
export type SupportedPHPExtensionBundle = 'kitchen-sink';
export type SupportedPHPExtensionBundle = 'kitchen-sink' | 'light';
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
},
"SupportedPHPExtensionBundle": {
"type": "string",
"const": "kitchen-sink"
"enum": ["kitchen-sink", "light"]
},
"StepDefinition": {
"type": "object",
Expand Down
12 changes: 9 additions & 3 deletions packages/playground/blueprints/src/lib/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ export function compileBlueprint(
});
}

if (!blueprint.phpExtensionBundles) {
blueprint.phpExtensionBundles = [];
}
// Default to the "kitchen sink" PHP extensions bundle if no
// other bundles are specified.
if (blueprint.phpExtensionBundles.length === 0) {
blueprint.phpExtensionBundles.push('kitchen-sink');
}

/**
* Download WP-CLI. {{{
* Hardcoding this in the compilt() function is a temporary solution
Expand All @@ -145,9 +154,6 @@ export function compileBlueprint(
(step) => typeof step === 'object' && step?.step === 'wp-cli'
);
if (wpCliStepIndex !== undefined && wpCliStepIndex > -1) {
if (!blueprint.phpExtensionBundles) {
blueprint.phpExtensionBundles = [];
}
if (!blueprint.phpExtensionBundles.includes('kitchen-sink')) {
blueprint.phpExtensionBundles.push('kitchen-sink');
console.warn(
Expand Down
4 changes: 3 additions & 1 deletion packages/playground/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export async function startPlaygroundWeb({
if (!blueprint) {
const playground = await doStartPlaygroundWeb(
iframe,
remoteUrl,
setQueryParams(remoteUrl, {
['php-extension']: 'kitchen-sink',
}),
progressTracker
);
onClientConnected(playground);
Expand Down
20 changes: 16 additions & 4 deletions packages/playground/website/cypress/e2e/query-api.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,26 @@ describe('Query API', () => {
});

describe('option `php-extension-bundle`', () => {
it('should load the specified PHP extensions', () => {
it('should load XMLWriter with the kitchen sink extension bundle', () => {
cy.visit('/?php-extension-bundle=kitchen-sink&url=/phpinfo.php');
cy.wordPressDocument()
.its('body')
.should('contain', '--enable-xmlwriter');
});

it('should not load XMLWriter with the light extension bundle', () => {
cy.visit('/?php-extension-bundle=light&url=/phpinfo.php');
cy.wordPressDocument()
.its('body')
.should('contain', '--disable-xmlwriter');
});

it('should default to the kitchen sink extension bundle', () => {
cy.visit('/?url=/phpinfo.php');
cy.wordPressDocument()
.its('body')
.should('contain', '--enable-xmlwriter');
});
});

describe('option `networking`', () => {
Expand All @@ -73,9 +87,7 @@ describe('Query API', () => {
* @see https://github.com/WordPress/wordpress-playground/pull/1045
*/
it('should enable networking when requested AND the kitchen sink extension bundle is enabled', () => {
cy.visit(
'/?php-extension-bundle=kitchen-sink&networking=yes&url=/wp-admin/plugin-install.php'
);
cy.visit('/?networking=yes&url=/wp-admin/plugin-install.php');
cy.wordPressDocument()
.find('.plugin-card')
.should('have.length.above', 4);
Expand Down
1 change: 1 addition & 0 deletions packages/playground/website/cypress/e2e/website-ui.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('Playground website UI', () => {
// Update settings in Playground configurator
cy.get('button#configurator').click();
cy.get('select#php-version').select(LatestSupportedPHPVersion);
cy.get('input[name=with-extensions]').uncheck();
cy.get('#modal-content button[type=submit]').click();
// Wait for the page to finish loading
cy.document().should('exist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ export function PlaygroundConfigurationForm({
}
/>
  Load extensions: libxml, openssl, mbstring,
iconv, gd
iconv, gd. Uncheck to save ~6MB of initial
downloads.
</label>
<label
className={forms.groupLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export async function reloadWithNewConfiguration(
url.searchParams.set('wp', config.wp);
url.searchParams.set('storage', config.storage);
url.searchParams.delete('php-extension-bundle');
if (config.withExtensions) {
url.searchParams.append('php-extension-bundle', 'kitchen-sink');
if (!config.withExtensions) {
url.searchParams.append('php-extension-bundle', 'light');
}
url.searchParams.delete('networking');
if (config.withNetworking) {
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/website/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const currentConfiguration: PlaygroundConfiguration = {
wp: blueprint.preferredVersions?.wp || 'latest',
php: resolveVersion(blueprint.preferredVersions?.php, SupportedPHPVersions),
storage: storage || 'none',
withExtensions: blueprint.phpExtensionBundles?.[0] === 'kitchen-sink',
withExtensions: blueprint.phpExtensionBundles?.[0] !== 'light',
withNetworking: blueprint.features?.networking || false,
resetSite: false,
};
Expand Down
Loading