-
Notifications
You must be signed in to change notification settings - Fork 322
Remove DOMParser from Blueprints: installPlugin and installTheme #427
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
Merged
adamziel
merged 45 commits into
WordPress:trunk
from
eliot-akira:remove-dom-parser-from-blueprints
May 31, 2023
Merged
Changes from 12 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
815acec
Rough draft for installPlugin
eliot-akira 61e33f3
Format
eliot-akira 7eb0e26
Merge remote-tracking branch 'upstream/trunk'
eliot-akira 304e256
Test zip package name different from extracted plugin folder name
eliot-akira 9c34cf4
Remove test plugin after install
eliot-akira 89a627d
Use unzip step and find extracted plugin folder name
eliot-akira d53a55a
Format
eliot-akira 98cde65
playground.documentRoot getter returns a promise
eliot-akira bfaef98
Remove temporary zip file after extraction
eliot-akira 3f8eb82
Format
eliot-akira f2ed29b
activatePlugin step: await playground.documentRoot because it can ret…
eliot-akira 7840907
BasePHP: Use FS.rename for method mv
eliot-akira daf74b3
Improve error message when extracted plugin folder not found
eliot-akira 82ad36e
Make server-side test pass: Create plugins folder; Patch VFSResource …
eliot-akira 3520de3
Format
eliot-akira 579c568
Add comment about Gutenberg patch becoming unnecessary as the issue h…
eliot-akira 534d10f
Rewrite installTheme step
eliot-akira 0615596
Format
eliot-akira 11bee55
Find plugin entry file to pass to activatePlugin step
eliot-akira 6080b0d
activateTheme step: await playground.documentRoot because it can retu…
eliot-akira fa4f559
VFSResource: Clean up workaround
eliot-akira 3fce74e
Tests: Clarify comment about zip file names being different from extr…
eliot-akira 2b8d31b
Remove asDOM helper function, which used DOMParser available only on …
eliot-akira e5ae9b5
Remove unnecessary timeout value for tests
eliot-akira 3dbd17a
Create findPluginEntryFile function for reusable logic
eliot-akira ca7b8c1
Remove comment about using plugin/theme upload form, since it's no lo…
eliot-akira 9eed478
Merge branch 'trunk' into remove-dom-parser-from-blueprints
eliot-akira 56cb9d3
Extract common logic between install plugin/theme into installAsset f…
eliot-akira 28f7163
Format
eliot-akira dc05730
Install asset: Clean up temporary folder before throwing an error
eliot-akira 81bb68f
Clarify comment about JSDOM's `File` class missing `arrayBuffer` meth…
eliot-akira a368526
installAsset: Make generic by replacing assetType with targetPath; Us…
eliot-akira 7d4f233
Format
eliot-akira 30d5c9a
activatePlugin step: Accept path to plugin directory and find plugin …
eliot-akira 9ed3d75
installAsset: Clean up temporary folder and zip file on success or an…
eliot-akira 3b67796
Polyfill the File class in JSDOM which lacks arrayBuffer() method
eliot-akira c121866
Format
eliot-akira 661eda9
activatePlugin: Simplify logic to find plugin entry file
eliot-akira 3cbea6a
activatePlugin: Simplify logic to find plugin entry file
eliot-akira 4487c3a
activatePlugin: Clarify accepted value for pluginPath option (absolut…
eliot-akira 6b0f60f
Merge branch 'trunk' into remove-dom-parser-from-blueprints
eliot-akira 1671b88
Clean up after merge from trunk
eliot-akira 3526f57
Format
eliot-akira 6f81a34
activatePlugin: Use error code for entry file not found; Rethrow any …
eliot-akira 977230f
Format
eliot-akira 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
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/playground/blueprints/src/lib/steps/install-plugin.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { NodePHP } from '@php-wasm/node'; | ||
import { compileBlueprint, runBlueprintSteps } from '../compile'; | ||
|
||
const phpVersion = '8.0'; | ||
describe('Blueprint step installPlugin', () => { | ||
let php: NodePHP; | ||
beforeEach(async () => { | ||
php = await NodePHP.load(phpVersion, { | ||
requestHandler: { | ||
documentRoot: '/', | ||
isStaticFilePath: (path) => !path.endsWith('.php'), | ||
}, | ||
}); | ||
}); | ||
|
||
it('should install a plugin', async () => { | ||
// Create test plugin | ||
|
||
php.mkdir('/tmp/test-plugin'); | ||
php.writeFile( | ||
'/tmp/test-plugin/index.php', | ||
`/**\n * Plugin Name: Test Plugin` | ||
); | ||
|
||
const zipFileName = 'test-plugin-0.0.1.zip'; | ||
|
||
await php.run({ | ||
code: `<?php $zip = new ZipArchive(); $zip->open("${zipFileName}", ZIPARCHIVE::CREATE); $zip->addFile("/tmp/test-plugin/index.php"); $zip->close();`, | ||
}); | ||
|
||
php.rmdir('/tmp/test-plugin'); | ||
|
||
// Note the package name is different from plugin folder name | ||
expect(php.fileExists(zipFileName)).toBe(true); | ||
|
||
await runBlueprintSteps( | ||
compileBlueprint({ | ||
steps: [ | ||
{ | ||
step: 'installPlugin', | ||
pluginZipFile: { | ||
resource: 'vfs', | ||
path: zipFileName, | ||
}, | ||
}, | ||
], | ||
}), | ||
php | ||
); | ||
|
||
php.unlink(zipFileName); | ||
|
||
expect( | ||
php.fileExists(`${php.documentRoot}/wp-content/test-plugin`) | ||
).toBe(true); | ||
}, 30000); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.