Skip to content

Commit 91b6060

Browse files
committed
Merge branch 'trunk' into add-intl-dynamic-extension-support-to-php-wasm-web
2 parents 71aaf62 + 8b2bf6a commit 91b6060

File tree

10 files changed

+661
-75
lines changed

10 files changed

+661
-75
lines changed

packages/php-wasm/node/src/test/mount.spec.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { type ErrnoError } from '@php-wasm/universal';
44
import { RecommendedPHPVersion } from '@wp-playground/common';
55
import path, { dirname } from 'path';
66
import fs from 'fs';
7+
import os from 'os';
78

89
describe('Mounting', () => {
910
let php: PHP;
@@ -538,4 +539,93 @@ describe('Mounting', () => {
538539
});
539540
});
540541
});
542+
543+
interface DirectoryTree {
544+
[key: string]: string | DirectoryTree;
545+
}
546+
547+
function createFsFiles(root: string, tree: DirectoryTree) {
548+
for (const [key, value] of Object.entries(tree)) {
549+
if (typeof value === 'string') {
550+
fs.writeFileSync(path.join(root, key), value);
551+
} else {
552+
fs.mkdirSync(path.join(root, key));
553+
createFsFiles(path.join(root, key), value);
554+
}
555+
}
556+
}
557+
558+
it('Should support nested directory mounts', async () => {
559+
const tempBase = fs.mkdtempSync(
560+
path.join(os.tmpdir(), 'playground-nested-')
561+
);
562+
createFsFiles(tempBase, {
563+
root: {
564+
'long-post-body.txt': 'long post body',
565+
},
566+
'overlay-1': {
567+
'hello.txt': 'hello from overlay',
568+
sub: {
569+
'inner.txt': 'inner',
570+
},
571+
},
572+
'overlay-2': {
573+
'greet.txt': 'hello from overlay2',
574+
deep: {
575+
'note.txt': 'deep note',
576+
},
577+
},
578+
});
579+
580+
// Mount the base directory
581+
await php.mount(
582+
'/mount-test',
583+
createNodeFsMountHandler(`${tempBase}/root`)
584+
);
585+
586+
try {
587+
expect(php.listFiles('/mount-test')).toEqual([
588+
'long-post-body.txt',
589+
]);
590+
591+
// Mount the first overlay at a non-existing subpath – a new
592+
// directory will be created.
593+
await php.mount(
594+
`/mount-test/overlay-1`,
595+
createNodeFsMountHandler(`${tempBase}/overlay-1`)
596+
);
597+
expect(php.listFiles('/mount-test')).toEqual([
598+
'long-post-body.txt',
599+
'overlay-1',
600+
]);
601+
expect(php.listFiles('/mount-test/overlay-1')).toEqual([
602+
'hello.txt',
603+
'sub',
604+
]);
605+
606+
// List a `sub` directory in the first overlay.
607+
expect(php.listFiles('/mount-test/overlay-1/sub')).toEqual([
608+
'inner.txt',
609+
]);
610+
611+
// Now, let's mount the second overlay at the `sub` directory
612+
// we've just inspected...
613+
await php.mount(
614+
'/mount-test/overlay-1/sub',
615+
createNodeFsMountHandler(`${tempBase}/overlay-2`)
616+
);
617+
// ...and confirm listing the files shows the files from the second overlay.
618+
expect(php.listFiles('/mount-test/overlay-1/sub')).toEqual([
619+
'deep',
620+
'greet.txt',
621+
]);
622+
623+
// Let's read one of the files just for good measure.
624+
expect(
625+
php.readFileAsText('/mount-test/overlay-1/sub/greet.txt')
626+
).toBe('hello from overlay2');
627+
} finally {
628+
fs.rmSync(tempBase, { recursive: true, force: true });
629+
}
630+
});
541631
});

packages/playground/blueprints/src/lib/compile.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,8 @@ function compileBlueprintJson(
286286
blueprint.steps?.splice(importWxrStepIndex, 0, {
287287
step: 'installPlugin',
288288
pluginData: {
289-
resource: 'url',
290-
url: 'https://playground.wordpress.net/wordpress-importer.zip',
291-
caption: 'Downloading the WordPress Importer plugin',
289+
resource: 'wordpress.org/plugins',
290+
slug: 'wordpress-importer',
292291
},
293292
});
294293
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
3+
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
4+
<!-- You may use this file to transfer that content from one site to another. -->
5+
<!-- This file is not intended to serve as a complete backup of your site. -->
6+
7+
<!-- To import this information into a WordPress site follow these steps: -->
8+
<!-- 1. Log in to that site as an administrator. -->
9+
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
10+
<!-- 3. Install the "WordPress" importer from the list. -->
11+
<!-- 4. Activate & Run Importer. -->
12+
<!-- 5. Upload this file using the form provided on that page. -->
13+
<!-- 6. You will first be asked to map the authors in this export file to users -->
14+
<!-- on the site. For each author, you may choose to map to an -->
15+
<!-- existing user on the site or to create a new user. -->
16+
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
17+
<!-- contained in this file into your site. -->
18+
19+
<!-- generator="WordPress/6.7-alpha-59070" created="2024-09-20 08:57" -->
20+
<rss version="2.0"
21+
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
22+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
23+
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
24+
xmlns:dc="http://purl.org/dc/elements/1.1/"
25+
xmlns:wp="http://wordpress.org/export/1.2/"
26+
>
27+
28+
<channel>
29+
<title>WordPress 6.7</title>
30+
<link>http://wordpress-67.local</link>
31+
<description></description>
32+
<pubDate>Fri, 20 Sep 2024 08:57:25 +0000</pubDate>
33+
<language>en-US</language>
34+
<wp:wxr_version>1.2</wp:wxr_version>
35+
<wp:base_site_url>http://wordpress-67.local</wp:base_site_url>
36+
<wp:base_blog_url>http://wordpress-67.local</wp:base_blog_url>
37+
38+
<wp:author><wp:author_id>1</wp:author_id><wp:author_login><![CDATA[birgit]]></wp:author_login><wp:author_email><![CDATA[[email protected]]]></wp:author_email><wp:author_display_name><![CDATA[Birgit Pauli-Haack]]></wp:author_display_name><wp:author_first_name><![CDATA[Birgit]]></wp:author_first_name><wp:author_last_name><![CDATA[Pauli-Haack]]></wp:author_last_name></wp:author>
39+
40+
<item>
41+
<title><![CDATA[Templates]]></title>
42+
<link>http://wordpress-67.local/templates/</link>
43+
<pubDate>Mon, 16 Sep 2024 15:52:28 +0000</pubDate>
44+
<dc:creator><![CDATA[birgit]]></dc:creator>
45+
<guid isPermaLink="false">http://wordpress-67.local/?page_id=63</guid>
46+
<description></description>
47+
<content:encoded><![CDATA[<!-- wp:paragraph -->
48+
<p>Template are the blueprints for different layouts for your web pages. There following template are available in the theme:</p>
49+
<!-- /wp:paragraph -->
50+
51+
<!-- wp:list -->
52+
<ul class="wp-block-list"><!-- wp:list-item -->
53+
<li>a <a href="/templates/single-page-layout/" data-type="page" data-id="65">single page template</a>, showing the single page layout</li>
54+
<!-- /wp:list-item -->
55+
56+
<!-- wp:list-item -->
57+
<li>a <a href="/page-no-title/" data-type="page" data-id="192">page no title template</a> that allows for a Hero image or a Cover block directly on the top of the page. </li>
58+
<!-- /wp:list-item -->
59+
60+
<!-- wp:list-item -->
61+
<li><a href="/notfound">404 page not found</a> template, the message that is displayed when vistors caught a bad link to your site. </li>
62+
<!-- /wp:list-item --></ul>
63+
<!-- /wp:list -->
64+
65+
<!-- wp:paragraph -->
66+
<p></p>
67+
<!-- /wp:paragraph -->]]></content:encoded>
68+
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
69+
<wp:post_id>63</wp:post_id>
70+
<wp:post_date><![CDATA[2024-09-16 15:52:28]]></wp:post_date>
71+
<wp:post_date_gmt><![CDATA[2024-09-16 15:52:28]]></wp:post_date_gmt>
72+
<wp:post_modified><![CDATA[2024-09-19 16:18:56]]></wp:post_modified>
73+
<wp:post_modified_gmt><![CDATA[2024-09-19 16:18:56]]></wp:post_modified_gmt>
74+
<wp:comment_status><![CDATA[closed]]></wp:comment_status>
75+
<wp:ping_status><![CDATA[closed]]></wp:ping_status>
76+
<wp:post_name><![CDATA[templates]]></wp:post_name>
77+
<wp:status><![CDATA[publish]]></wp:status>
78+
<wp:post_parent>0</wp:post_parent>
79+
<wp:menu_order>0</wp:menu_order>
80+
<wp:post_type><![CDATA[page]]></wp:post_type>
81+
<wp:post_password><![CDATA[]]></wp:post_password>
82+
<wp:is_sticky>0</wp:is_sticky>
83+
</item>
84+
</channel>
85+
</rss>
86+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
3+
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
4+
<!-- You may use this file to transfer that content from one site to another. -->
5+
<!-- This file is not intended to serve as a complete backup of your site. -->
6+
7+
<!-- To import this information into a WordPress site follow these steps: -->
8+
<!-- 1. Log in to that site as an administrator. -->
9+
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
10+
<!-- 3. Install the "WordPress" importer from the list. -->
11+
<!-- 4. Activate & Run Importer. -->
12+
<!-- 5. Upload this file using the form provided on that page. -->
13+
<!-- 6. You will first be asked to map the authors in this export file to users -->
14+
<!-- on the site. For each author, you may choose to map to an -->
15+
<!-- existing user on the site or to create a new user. -->
16+
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
17+
<!-- contained in this file into your site. -->
18+
19+
<!-- generator="WordPress/6.5.4" created="2024-06-10 12:29" -->
20+
<rss version="2.0"
21+
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
22+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
23+
xmlns:dc="http://purl.org/dc/elements/1.1/"
24+
xmlns:wp="http://wordpress.org/export/1.2/">
25+
26+
<channel>
27+
<title>My WordPress Website</title>
28+
<link>https://🚀-science.com/science</link>
29+
<description></description>
30+
<pubDate>Mon, 10 Jun 2024 12:29:10 +0000</pubDate>
31+
<language>en-US</language>
32+
<wp:wxr_version>1.2</wp:wxr_version>
33+
<wp:base_site_url>https://🚀-science.com/science</wp:base_site_url>
34+
<wp:base_blog_url>https://🚀-science.com/science</wp:base_blog_url>
35+
36+
<wp:author>
37+
<wp:author_id>1</wp:author_id>
38+
<wp:author_login><![CDATA[admin]]></wp:author_login>
39+
<wp:author_email><![CDATA[[email protected]]]></wp:author_email>
40+
<wp:author_display_name><![CDATA[admin]]></wp:author_display_name>
41+
<wp:author_first_name><![CDATA[]]></wp:author_first_name>
42+
<wp:author_last_name><![CDATA[]]></wp:author_last_name>
43+
</wp:author>
44+
45+
46+
<generator>https://wordpress.org/?v=6.5.4</generator>
47+
48+
<item>
49+
<title><![CDATA["The Road Not Taken" by Robert Frost]]></title>
50+
<link>https://🚀-science.com/science/?p=1</link>
51+
<pubDate>Wed, 05 Jun 2024 16:04:48 +0000</pubDate>
52+
<dc:creator><![CDATA[admin]]></dc:creator>
53+
<guid isPermaLink="false">https://🚀-science.com/science/?p=1</guid>
54+
<description></description>
55+
<content:encoded><![CDATA[<!-- wp:paragraph -->
56+
<p>
57+
<!-- Rewrites URLs that match the base URL -->
58+
URLs to rewrite:
59+
60+
https://🚀-science.com/science
61+
https://🚀-science.com/%73%63ience
62+
https://xn---science-7f85g.com/science
63+
&#104;ttps://xn---&#115;&#99;ience-7f85g.com/%73%63ience/
64+
<a href="&#104;ttps://xn---&#115;&#99;ience-7f85g.com/science/wp-content/image.png">Test</a>
65+
66+
<!-- Correctly ignores URLs that are similar to the base URL but do not match it -->
67+
This isn't migrated: https://🚀-science.comcast/science <br>
68+
Or this: super-🚀-science.com/science
69+
</p>
70+
<!-- /wp:paragraph -->
71+
72+
<!-- wp:image {"src": "https:\/\/\ud83d\ude80-\u0073\u0063ience.com/science/wp-content/image.png"} -->
73+
<img src="&#104;ttps://xn---&#115;&#99;ience-7f85g.com/science/wp-content/image.png">
74+
<!-- /wp:image -->
75+
]]></content:encoded>
76+
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
77+
<wp:post_id>10</wp:post_id>
78+
<wp:post_date><![CDATA[2024-06-05 16:04:48]]></wp:post_date>
79+
<wp:post_date_gmt><![CDATA[2024-06-05 16:04:48]]></wp:post_date_gmt>
80+
<wp:post_modified><![CDATA[2024-06-10 12:28:55]]></wp:post_modified>
81+
<wp:post_modified_gmt><![CDATA[2024-06-10 12:28:55]]></wp:post_modified_gmt>
82+
<wp:comment_status><![CDATA[open]]></wp:comment_status>
83+
<wp:ping_status><![CDATA[open]]></wp:ping_status>
84+
<wp:post_name><![CDATA[hello-world]]></wp:post_name>
85+
<wp:status><![CDATA[publish]]></wp:status>
86+
<wp:post_parent>0</wp:post_parent>
87+
<wp:menu_order>0</wp:menu_order>
88+
<wp:post_type><![CDATA[post]]></wp:post_type>
89+
<wp:post_password><![CDATA[]]></wp:post_password>
90+
<wp:is_sticky>0</wp:is_sticky>
91+
<category domain="category" nicename="uncategorized"><![CDATA[Uncategorized]]></category>
92+
<wp:postmeta>
93+
<wp:meta_key><![CDATA[_pingme]]></wp:meta_key>
94+
<wp:meta_value><![CDATA[1]]></wp:meta_value>
95+
</wp:postmeta>
96+
<wp:postmeta>
97+
<wp:meta_key><![CDATA[_encloseme]]></wp:meta_key>
98+
<wp:meta_value><![CDATA[1]]></wp:meta_value>
99+
</wp:postmeta>
100+
</item>
101+
</channel>
102+
</rss>

0 commit comments

Comments
 (0)