@wp-playground/tools 3.1.55 → 3.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/get-sqlite-database-path.d.ts +2 -0
- package/get-sqlite-database-size.d.ts +3 -0
- package/index.cjs +13 -1
- package/index.cjs.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +67 -21
- package/index.js.map +1 -1
- package/package.json +8 -4
package/index.cjs
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@php-wasm/util"),s="5.2.3",P=`https://files.phpmyadmin.net/phpMyAdmin/${s}/phpMyAdmin-${s}-english.zip`,e="/tools/phpmyadmin",h=l.joinPaths(e,"config.inc.php"),A="/phpmyadmin",u="/index.php?route=/database/structure&db=wordpress",M={urlPrefix:A,fsPath:e};async function c(){return[{step:"unzip",zipFile:{resource:"url",url:P},extractToPath:"/tmp"},{step:"mkdir",path:e},{step:"mv",fromPath:`/tmp/phpMyAdmin-${s}-english`,toPath:e},{step:"writeFile",path:`${e}/libraries/classes/Dbal/DbiMysqli.php`,data:(await Promise.resolve().then(()=>require("./DbiMysqli-B38TcdRZ.cjs"))).default},{step:"writeFile",path:h,data:(await Promise.resolve().then(()=>require("./config.inc-BPj6j876.cjs"))).default}]}async function _(i){const a=await i.runStream({code:`<?php
|
|
2
|
+
$wp_env = require '/internal/shared/wp-env.php';
|
|
3
|
+
if ($wp_env['db']['type'] !== 'sqlite') {
|
|
4
|
+
throw new RuntimeException('The site does not use SQLite.');
|
|
5
|
+
}
|
|
6
|
+
echo $wp_env['db']['path'];
|
|
7
|
+
`}),[t,r,n]=await Promise.all([a.stdoutText,a.stderrText,a.exitCode]);if(n!==0)throw new Error(r||"Could not read the SQLite database path.");if(t==="")throw new Error("The SQLite database path is invalid.");return t}async function m(i,a){const t=await i.runStream({code:`<?php
|
|
8
|
+
$stat = stat(getenv('DATABASE_PATH'));
|
|
9
|
+
if ($stat === false) {
|
|
10
|
+
throw new RuntimeException('Could not stat the database.');
|
|
11
|
+
}
|
|
12
|
+
echo $stat['size'];
|
|
13
|
+
`,env:{DATABASE_PATH:a}}),[r,n,d]=await Promise.all([t.stdoutText,t.stderrText,t.exitCode]);if(d!==0)throw new Error(n||"Could not stat the database.");const p=r.trim(),o=Number(p);if(p===""||!Number.isSafeInteger(o)||o<0)throw new Error("Database stat returned an invalid size.");return o}exports.PHPMYADMIN_CONFIG_PATH=h;exports.PHPMYADMIN_DOWNLOAD_URL=P;exports.PHPMYADMIN_ENTRY_PATH=u;exports.PHPMYADMIN_INSTALL_PATH=e;exports.PHPMYADMIN_PATH_ALIAS=M;exports.PHPMYADMIN_URL_PATH=A;exports.PHPMYADMIN_VERSION=s;exports.getPhpMyAdminInstallSteps=c;exports.getSqliteDatabasePath=_;exports.getSqliteDatabaseSize=m;
|
|
2
14
|
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../packages/playground/tools/src/phpmyadmin/index.ts"],"sourcesContent":["import type { StepDefinition } from '@wp-playground/blueprints';\nimport { joinPaths } from '@php-wasm/util';\n\n/**\n * phpMyAdmin installation, detection, URL construction, and request routing\n * live in separate consumers (Website, Personal WP, and CLI). These values are\n * exported from one place to keep that shared contract in sync.\n */\n\n// Keep the downloaded archive and its extracted directory name on the same release.\nexport const PHPMYADMIN_VERSION = '5.2.3';\n\n// The archive installed by the shared Blueprint steps.\nexport const PHPMYADMIN_DOWNLOAD_URL = `https://files.phpmyadmin.net/phpMyAdmin/${PHPMYADMIN_VERSION}/phpMyAdmin-${PHPMYADMIN_VERSION}-english.zip`;\n\n// PHP filesystem path, kept outside the WordPress document root and site exports.\nexport const PHPMYADMIN_INSTALL_PATH = '/tools/phpmyadmin';\n\n// Complete-install marker checked by the UI before deciding whether to reinstall.\nexport const PHPMYADMIN_CONFIG_PATH = joinPaths(\n\tPHPMYADMIN_INSTALL_PATH,\n\t'config.inc.php'\n);\n\n// Default public URL shared by the browser UIs and CLI.\nexport const PHPMYADMIN_URL_PATH = '/phpmyadmin';\n\n// Initial phpMyAdmin route opened after installation.\nexport const PHPMYADMIN_ENTRY_PATH =\n\t'/index.php?route=/database/structure&db=wordpress';\n\n// Default browser-runtime mapping from the public URL to the PHP filesystem path.\nexport const PHPMYADMIN_PATH_ALIAS = {\n\turlPrefix: PHPMYADMIN_URL_PATH,\n\tfsPath: PHPMYADMIN_INSTALL_PATH,\n} as const;\n\n/**\n * Returns the blueprint steps needed to install phpMyAdmin in Playground.\n *\n * This installs phpMyAdmin and applies the following modifications:\n * 1. Inject a \"config.inc.php\" file to configure phpMyAdmin for Playground.\n * 2. Inject a \"DbiMysqli.php\" file to implement the MySQL-on-SQLite driver.\n *\n * @returns Blueprint steps to install phpMyAdmin in Playground.\n */\nexport async function getPhpMyAdminInstallSteps(): Promise<StepDefinition[]> {\n\treturn [\n\t\t{\n\t\t\tstep: 'unzip',\n\t\t\tzipFile: {\n\t\t\t\tresource: 'url',\n\t\t\t\turl: PHPMYADMIN_DOWNLOAD_URL,\n\t\t\t},\n\t\t\textractToPath: '/tmp',\n\t\t},\n\t\t{\n\t\t\tstep: 'mkdir',\n\t\t\tpath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'mv',\n\t\t\tfromPath: `/tmp/phpMyAdmin-${PHPMYADMIN_VERSION}-english`,\n\t\t\ttoPath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: `${PHPMYADMIN_INSTALL_PATH}/libraries/classes/Dbal/DbiMysqli.php`,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./DbiMysqli.php?raw')).default as string,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: PHPMYADMIN_CONFIG_PATH,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./config.inc.php?raw')).default as string,\n\t\t},\n\t];\n}\n"],"names":["PHPMYADMIN_VERSION","PHPMYADMIN_DOWNLOAD_URL","PHPMYADMIN_INSTALL_PATH","PHPMYADMIN_CONFIG_PATH","joinPaths","PHPMYADMIN_URL_PATH","PHPMYADMIN_ENTRY_PATH","PHPMYADMIN_PATH_ALIAS","getPhpMyAdminInstallSteps"],"mappings":"kHAUaA,EAAqB,QAGrBC,EAA0B,2CAA2CD,CAAkB,eAAeA,CAAkB,eAGxHE,EAA0B,oBAG1BC,EAAyBC,EAAAA,UACrCF,EACA,gBACD,EAGaG,EAAsB,cAGtBC,EACZ,oDAGYC,EAAwB,CACpC,UAAWF,EACX,OAAQH,CACT,EAWA,eAAsBM,GAAuD,CAC5E,MAAO,CACN,CACC,KAAM,QACN,QAAS,CACR,SAAU,MACV,IAAKP,CAAA,EAEN,cAAe,MAAA,EAEhB,CACC,KAAM,QACN,KAAMC,CAAA,EAEP,CACC,KAAM,KACN,SAAU,mBAAmBF,CAAkB,WAC/C,OAAQE,CAAA,EAET,CACC,KAAM,YACN,KAAM,GAAGA,CAAuB,wCAEhC,MAAO,MAAM,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,0BAAqB,IAAG,OAAA,EAE7C,CACC,KAAM,YACN,KAAMC,EAEN,MAAO,MAAM,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,2BAAsB,IAAG,OAAA,CAC9C,CAEF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../packages/playground/tools/src/phpmyadmin/index.ts","../../../../packages/playground/tools/src/get-sqlite-database-path.ts","../../../../packages/playground/tools/src/get-sqlite-database-size.ts"],"sourcesContent":["import type { StepDefinition } from '@wp-playground/blueprints';\nimport { joinPaths } from '@php-wasm/util';\n\n/**\n * phpMyAdmin installation, detection, URL construction, and request routing\n * live in separate consumers (Website, Personal WP, and CLI). These values are\n * exported from one place to keep that shared contract in sync.\n */\n\n// Keep the downloaded archive and its extracted directory name on the same release.\nexport const PHPMYADMIN_VERSION = '5.2.3';\n\n// The archive installed by the shared Blueprint steps.\nexport const PHPMYADMIN_DOWNLOAD_URL = `https://files.phpmyadmin.net/phpMyAdmin/${PHPMYADMIN_VERSION}/phpMyAdmin-${PHPMYADMIN_VERSION}-english.zip`;\n\n// PHP filesystem path, kept outside the WordPress document root and site exports.\nexport const PHPMYADMIN_INSTALL_PATH = '/tools/phpmyadmin';\n\n// Complete-install marker checked by the UI before deciding whether to reinstall.\nexport const PHPMYADMIN_CONFIG_PATH = joinPaths(\n\tPHPMYADMIN_INSTALL_PATH,\n\t'config.inc.php'\n);\n\n// Default public URL shared by the browser UIs and CLI.\nexport const PHPMYADMIN_URL_PATH = '/phpmyadmin';\n\n// Initial phpMyAdmin route opened after installation.\nexport const PHPMYADMIN_ENTRY_PATH =\n\t'/index.php?route=/database/structure&db=wordpress';\n\n// Default browser-runtime mapping from the public URL to the PHP filesystem path.\nexport const PHPMYADMIN_PATH_ALIAS = {\n\turlPrefix: PHPMYADMIN_URL_PATH,\n\tfsPath: PHPMYADMIN_INSTALL_PATH,\n} as const;\n\n/**\n * Returns the blueprint steps needed to install phpMyAdmin in Playground.\n *\n * This installs phpMyAdmin and applies the following modifications:\n * 1. Inject a \"config.inc.php\" file to configure phpMyAdmin for Playground.\n * 2. Inject a \"DbiMysqli.php\" file to implement the MySQL-on-SQLite driver.\n *\n * @returns Blueprint steps to install phpMyAdmin in Playground.\n */\nexport async function getPhpMyAdminInstallSteps(): Promise<StepDefinition[]> {\n\treturn [\n\t\t{\n\t\t\tstep: 'unzip',\n\t\t\tzipFile: {\n\t\t\t\tresource: 'url',\n\t\t\t\turl: PHPMYADMIN_DOWNLOAD_URL,\n\t\t\t},\n\t\t\textractToPath: '/tmp',\n\t\t},\n\t\t{\n\t\t\tstep: 'mkdir',\n\t\t\tpath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'mv',\n\t\t\tfromPath: `/tmp/phpMyAdmin-${PHPMYADMIN_VERSION}-english`,\n\t\t\ttoPath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: `${PHPMYADMIN_INSTALL_PATH}/libraries/classes/Dbal/DbiMysqli.php`,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./DbiMysqli.php?raw')).default as string,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: PHPMYADMIN_CONFIG_PATH,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./config.inc.php?raw')).default as string,\n\t\t},\n\t];\n}\n","import type { UniversalPHP } from '@php-wasm/universal';\n\nexport async function getSqliteDatabasePath(\n\tphp: UniversalPHP\n): Promise<string> {\n\tconst response = await php.runStream({\n\t\tcode: `<?php\n$wp_env = require '/internal/shared/wp-env.php';\nif ($wp_env['db']['type'] !== 'sqlite') {\n\tthrow new RuntimeException('The site does not use SQLite.');\n}\necho $wp_env['db']['path'];\n`,\n\t});\n\tconst [path, errors, exitCode] = await Promise.all([\n\t\tresponse.stdoutText,\n\t\tresponse.stderrText,\n\t\tresponse.exitCode,\n\t]);\n\tif (exitCode !== 0) {\n\t\tthrow new Error(errors || 'Could not read the SQLite database path.');\n\t}\n\tif (path === '') {\n\t\tthrow new Error('The SQLite database path is invalid.');\n\t}\n\treturn path;\n}\n","import type { UniversalPHP } from '@php-wasm/universal';\n\n/** Stats the database inside PHP without copying its contents into JavaScript. */\nexport async function getSqliteDatabaseSize(\n\tphp: UniversalPHP,\n\tdatabasePath: string\n): Promise<number> {\n\tconst response = await php.runStream({\n\t\tcode: `<?php\n$stat = stat(getenv('DATABASE_PATH'));\nif ($stat === false) {\n\tthrow new RuntimeException('Could not stat the database.');\n}\necho $stat['size'];\n`,\n\t\tenv: {\n\t\t\tDATABASE_PATH: databasePath,\n\t\t},\n\t});\n\tconst [output, errors, exitCode] = await Promise.all([\n\t\tresponse.stdoutText,\n\t\tresponse.stderrText,\n\t\tresponse.exitCode,\n\t]);\n\tif (exitCode !== 0) {\n\t\tthrow new Error(errors || 'Could not stat the database.');\n\t}\n\tconst sizeText = output.trim();\n\tconst size = Number(sizeText);\n\tif (sizeText === '' || !Number.isSafeInteger(size) || size < 0) {\n\t\tthrow new Error('Database stat returned an invalid size.');\n\t}\n\treturn size;\n}\n"],"names":["PHPMYADMIN_VERSION","PHPMYADMIN_DOWNLOAD_URL","PHPMYADMIN_INSTALL_PATH","PHPMYADMIN_CONFIG_PATH","joinPaths","PHPMYADMIN_URL_PATH","PHPMYADMIN_ENTRY_PATH","PHPMYADMIN_PATH_ALIAS","getPhpMyAdminInstallSteps","getSqliteDatabasePath","php","response","path","errors","exitCode","getSqliteDatabaseSize","databasePath","output","sizeText","size"],"mappings":"kHAUaA,EAAqB,QAGrBC,EAA0B,2CAA2CD,CAAkB,eAAeA,CAAkB,eAGxHE,EAA0B,oBAG1BC,EAAyBC,EAAAA,UACrCF,EACA,gBACD,EAGaG,EAAsB,cAGtBC,EACZ,oDAGYC,EAAwB,CACpC,UAAWF,EACX,OAAQH,CACT,EAWA,eAAsBM,GAAuD,CAC5E,MAAO,CACN,CACC,KAAM,QACN,QAAS,CACR,SAAU,MACV,IAAKP,CAAA,EAEN,cAAe,MAAA,EAEhB,CACC,KAAM,QACN,KAAMC,CAAA,EAEP,CACC,KAAM,KACN,SAAU,mBAAmBF,CAAkB,WAC/C,OAAQE,CAAA,EAET,CACC,KAAM,YACN,KAAM,GAAGA,CAAuB,wCAEhC,MAAO,MAAM,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,0BAAqB,IAAG,OAAA,EAE7C,CACC,KAAM,YACN,KAAMC,EAEN,MAAO,MAAM,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,2BAAsB,IAAG,OAAA,CAC9C,CAEF,CC5EA,eAAsBM,EACrBC,EACkB,CAClB,MAAMC,EAAW,MAAMD,EAAI,UAAU,CACpC,KAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAON,EACK,CAACE,EAAMC,EAAQC,CAAQ,EAAI,MAAM,QAAQ,IAAI,CAClDH,EAAS,WACTA,EAAS,WACTA,EAAS,QAAA,CACT,EACD,GAAIG,IAAa,EAChB,MAAM,IAAI,MAAMD,GAAU,0CAA0C,EAErE,GAAID,IAAS,GACZ,MAAM,IAAI,MAAM,sCAAsC,EAEvD,OAAOA,CACR,CCvBA,eAAsBG,EACrBL,EACAM,EACkB,CAClB,MAAML,EAAW,MAAMD,EAAI,UAAU,CACpC,KAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAON,IAAK,CACJ,cAAeM,CAAA,CAChB,CACA,EACK,CAACC,EAAQJ,EAAQC,CAAQ,EAAI,MAAM,QAAQ,IAAI,CACpDH,EAAS,WACTA,EAAS,WACTA,EAAS,QAAA,CACT,EACD,GAAIG,IAAa,EAChB,MAAM,IAAI,MAAMD,GAAU,8BAA8B,EAEzD,MAAMK,EAAWD,EAAO,KAAA,EAClBE,EAAO,OAAOD,CAAQ,EAC5B,GAAIA,IAAa,IAAM,CAAC,OAAO,cAAcC,CAAI,GAAKA,EAAO,EAC5D,MAAM,IAAI,MAAM,yCAAyC,EAE1D,OAAOA,CACR"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,52 +1,98 @@
|
|
|
1
|
-
import { joinPaths as
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
import { joinPaths as d } from "@php-wasm/util";
|
|
2
|
+
const o = "5.2.3", l = `https://files.phpmyadmin.net/phpMyAdmin/${o}/phpMyAdmin-${o}-english.zip`, a = "/tools/phpmyadmin", u = d(
|
|
3
|
+
a,
|
|
4
4
|
"config.inc.php"
|
|
5
|
-
),
|
|
6
|
-
urlPrefix:
|
|
7
|
-
fsPath:
|
|
5
|
+
), c = "/phpmyadmin", m = "/index.php?route=/database/structure&db=wordpress", A = {
|
|
6
|
+
urlPrefix: c,
|
|
7
|
+
fsPath: a
|
|
8
8
|
};
|
|
9
|
-
async function
|
|
9
|
+
async function w() {
|
|
10
10
|
return [
|
|
11
11
|
{
|
|
12
12
|
step: "unzip",
|
|
13
13
|
zipFile: {
|
|
14
14
|
resource: "url",
|
|
15
|
-
url:
|
|
15
|
+
url: l
|
|
16
16
|
},
|
|
17
17
|
extractToPath: "/tmp"
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
step: "mkdir",
|
|
21
|
-
path:
|
|
21
|
+
path: a
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
step: "mv",
|
|
25
|
-
fromPath: `/tmp/phpMyAdmin-${
|
|
26
|
-
toPath:
|
|
25
|
+
fromPath: `/tmp/phpMyAdmin-${o}-english`,
|
|
26
|
+
toPath: a
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
step: "writeFile",
|
|
30
|
-
path: `${
|
|
30
|
+
path: `${a}/libraries/classes/Dbal/DbiMysqli.php`,
|
|
31
31
|
/* @ts-ignore */
|
|
32
32
|
data: (await import("./DbiMysqli-xDyCceKO.js")).default
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
step: "writeFile",
|
|
36
|
-
path:
|
|
36
|
+
path: u,
|
|
37
37
|
/* @ts-ignore */
|
|
38
38
|
data: (await import("./config.inc-Bc6yvduk.js")).default
|
|
39
39
|
}
|
|
40
40
|
];
|
|
41
41
|
}
|
|
42
|
+
async function f(s) {
|
|
43
|
+
const e = await s.runStream({
|
|
44
|
+
code: `<?php
|
|
45
|
+
$wp_env = require '/internal/shared/wp-env.php';
|
|
46
|
+
if ($wp_env['db']['type'] !== 'sqlite') {
|
|
47
|
+
throw new RuntimeException('The site does not use SQLite.');
|
|
48
|
+
}
|
|
49
|
+
echo $wp_env['db']['path'];
|
|
50
|
+
`
|
|
51
|
+
}), [t, i, r] = await Promise.all([
|
|
52
|
+
e.stdoutText,
|
|
53
|
+
e.stderrText,
|
|
54
|
+
e.exitCode
|
|
55
|
+
]);
|
|
56
|
+
if (r !== 0)
|
|
57
|
+
throw new Error(i || "Could not read the SQLite database path.");
|
|
58
|
+
if (t === "")
|
|
59
|
+
throw new Error("The SQLite database path is invalid.");
|
|
60
|
+
return t;
|
|
61
|
+
}
|
|
62
|
+
async function M(s, e) {
|
|
63
|
+
const t = await s.runStream({
|
|
64
|
+
code: `<?php
|
|
65
|
+
$stat = stat(getenv('DATABASE_PATH'));
|
|
66
|
+
if ($stat === false) {
|
|
67
|
+
throw new RuntimeException('Could not stat the database.');
|
|
68
|
+
}
|
|
69
|
+
echo $stat['size'];
|
|
70
|
+
`,
|
|
71
|
+
env: {
|
|
72
|
+
DATABASE_PATH: e
|
|
73
|
+
}
|
|
74
|
+
}), [i, r, h] = await Promise.all([
|
|
75
|
+
t.stdoutText,
|
|
76
|
+
t.stderrText,
|
|
77
|
+
t.exitCode
|
|
78
|
+
]);
|
|
79
|
+
if (h !== 0)
|
|
80
|
+
throw new Error(r || "Could not stat the database.");
|
|
81
|
+
const p = i.trim(), n = Number(p);
|
|
82
|
+
if (p === "" || !Number.isSafeInteger(n) || n < 0)
|
|
83
|
+
throw new Error("Database stat returned an invalid size.");
|
|
84
|
+
return n;
|
|
85
|
+
}
|
|
42
86
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
87
|
+
u as PHPMYADMIN_CONFIG_PATH,
|
|
88
|
+
l as PHPMYADMIN_DOWNLOAD_URL,
|
|
89
|
+
m as PHPMYADMIN_ENTRY_PATH,
|
|
90
|
+
a as PHPMYADMIN_INSTALL_PATH,
|
|
91
|
+
A as PHPMYADMIN_PATH_ALIAS,
|
|
92
|
+
c as PHPMYADMIN_URL_PATH,
|
|
93
|
+
o as PHPMYADMIN_VERSION,
|
|
94
|
+
w as getPhpMyAdminInstallSteps,
|
|
95
|
+
f as getSqliteDatabasePath,
|
|
96
|
+
M as getSqliteDatabaseSize
|
|
51
97
|
};
|
|
52
98
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../packages/playground/tools/src/phpmyadmin/index.ts"],"sourcesContent":["import type { StepDefinition } from '@wp-playground/blueprints';\nimport { joinPaths } from '@php-wasm/util';\n\n/**\n * phpMyAdmin installation, detection, URL construction, and request routing\n * live in separate consumers (Website, Personal WP, and CLI). These values are\n * exported from one place to keep that shared contract in sync.\n */\n\n// Keep the downloaded archive and its extracted directory name on the same release.\nexport const PHPMYADMIN_VERSION = '5.2.3';\n\n// The archive installed by the shared Blueprint steps.\nexport const PHPMYADMIN_DOWNLOAD_URL = `https://files.phpmyadmin.net/phpMyAdmin/${PHPMYADMIN_VERSION}/phpMyAdmin-${PHPMYADMIN_VERSION}-english.zip`;\n\n// PHP filesystem path, kept outside the WordPress document root and site exports.\nexport const PHPMYADMIN_INSTALL_PATH = '/tools/phpmyadmin';\n\n// Complete-install marker checked by the UI before deciding whether to reinstall.\nexport const PHPMYADMIN_CONFIG_PATH = joinPaths(\n\tPHPMYADMIN_INSTALL_PATH,\n\t'config.inc.php'\n);\n\n// Default public URL shared by the browser UIs and CLI.\nexport const PHPMYADMIN_URL_PATH = '/phpmyadmin';\n\n// Initial phpMyAdmin route opened after installation.\nexport const PHPMYADMIN_ENTRY_PATH =\n\t'/index.php?route=/database/structure&db=wordpress';\n\n// Default browser-runtime mapping from the public URL to the PHP filesystem path.\nexport const PHPMYADMIN_PATH_ALIAS = {\n\turlPrefix: PHPMYADMIN_URL_PATH,\n\tfsPath: PHPMYADMIN_INSTALL_PATH,\n} as const;\n\n/**\n * Returns the blueprint steps needed to install phpMyAdmin in Playground.\n *\n * This installs phpMyAdmin and applies the following modifications:\n * 1. Inject a \"config.inc.php\" file to configure phpMyAdmin for Playground.\n * 2. Inject a \"DbiMysqli.php\" file to implement the MySQL-on-SQLite driver.\n *\n * @returns Blueprint steps to install phpMyAdmin in Playground.\n */\nexport async function getPhpMyAdminInstallSteps(): Promise<StepDefinition[]> {\n\treturn [\n\t\t{\n\t\t\tstep: 'unzip',\n\t\t\tzipFile: {\n\t\t\t\tresource: 'url',\n\t\t\t\turl: PHPMYADMIN_DOWNLOAD_URL,\n\t\t\t},\n\t\t\textractToPath: '/tmp',\n\t\t},\n\t\t{\n\t\t\tstep: 'mkdir',\n\t\t\tpath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'mv',\n\t\t\tfromPath: `/tmp/phpMyAdmin-${PHPMYADMIN_VERSION}-english`,\n\t\t\ttoPath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: `${PHPMYADMIN_INSTALL_PATH}/libraries/classes/Dbal/DbiMysqli.php`,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./DbiMysqli.php?raw')).default as string,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: PHPMYADMIN_CONFIG_PATH,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./config.inc.php?raw')).default as string,\n\t\t},\n\t];\n}\n"],"names":["PHPMYADMIN_VERSION","PHPMYADMIN_DOWNLOAD_URL","PHPMYADMIN_INSTALL_PATH","PHPMYADMIN_CONFIG_PATH","joinPaths","PHPMYADMIN_URL_PATH","PHPMYADMIN_ENTRY_PATH","PHPMYADMIN_PATH_ALIAS","getPhpMyAdminInstallSteps"],"mappings":";AAUO,MAAMA,IAAqB,SAGrBC,IAA0B,2CAA2CD,CAAkB,eAAeA,CAAkB,gBAGxHE,IAA0B,qBAG1BC,IAAyBC;AAAA,EACrCF;AAAA,EACA;AACD,GAGaG,IAAsB,eAGtBC,IACZ,qDAGYC,IAAwB;AAAA,EACpC,WAAWF;AAAA,EACX,QAAQH;AACT;AAWA,eAAsBM,IAAuD;AAC5E,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,SAAS;AAAA,QACR,UAAU;AAAA,QACV,KAAKP;AAAA,MAAA;AAAA,MAEN,eAAe;AAAA,IAAA;AAAA,IAEhB;AAAA,MACC,MAAM;AAAA,MACN,MAAMC;AAAA,IAAA;AAAA,IAEP;AAAA,MACC,MAAM;AAAA,MACN,UAAU,mBAAmBF,CAAkB;AAAA,MAC/C,QAAQE;AAAA,IAAA;AAAA,IAET;AAAA,MACC,MAAM;AAAA,MACN,MAAM,GAAGA,CAAuB;AAAA;AAAA,MAEhC,OAAO,MAAM,OAAO,yBAAqB,GAAG;AAAA,IAAA;AAAA,IAE7C;AAAA,MACC,MAAM;AAAA,MACN,MAAMC;AAAA;AAAA,MAEN,OAAO,MAAM,OAAO,0BAAsB,GAAG;AAAA,IAAA;AAAA,EAC9C;AAEF;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/playground/tools/src/phpmyadmin/index.ts","../../../../packages/playground/tools/src/get-sqlite-database-path.ts","../../../../packages/playground/tools/src/get-sqlite-database-size.ts"],"sourcesContent":["import type { StepDefinition } from '@wp-playground/blueprints';\nimport { joinPaths } from '@php-wasm/util';\n\n/**\n * phpMyAdmin installation, detection, URL construction, and request routing\n * live in separate consumers (Website, Personal WP, and CLI). These values are\n * exported from one place to keep that shared contract in sync.\n */\n\n// Keep the downloaded archive and its extracted directory name on the same release.\nexport const PHPMYADMIN_VERSION = '5.2.3';\n\n// The archive installed by the shared Blueprint steps.\nexport const PHPMYADMIN_DOWNLOAD_URL = `https://files.phpmyadmin.net/phpMyAdmin/${PHPMYADMIN_VERSION}/phpMyAdmin-${PHPMYADMIN_VERSION}-english.zip`;\n\n// PHP filesystem path, kept outside the WordPress document root and site exports.\nexport const PHPMYADMIN_INSTALL_PATH = '/tools/phpmyadmin';\n\n// Complete-install marker checked by the UI before deciding whether to reinstall.\nexport const PHPMYADMIN_CONFIG_PATH = joinPaths(\n\tPHPMYADMIN_INSTALL_PATH,\n\t'config.inc.php'\n);\n\n// Default public URL shared by the browser UIs and CLI.\nexport const PHPMYADMIN_URL_PATH = '/phpmyadmin';\n\n// Initial phpMyAdmin route opened after installation.\nexport const PHPMYADMIN_ENTRY_PATH =\n\t'/index.php?route=/database/structure&db=wordpress';\n\n// Default browser-runtime mapping from the public URL to the PHP filesystem path.\nexport const PHPMYADMIN_PATH_ALIAS = {\n\turlPrefix: PHPMYADMIN_URL_PATH,\n\tfsPath: PHPMYADMIN_INSTALL_PATH,\n} as const;\n\n/**\n * Returns the blueprint steps needed to install phpMyAdmin in Playground.\n *\n * This installs phpMyAdmin and applies the following modifications:\n * 1. Inject a \"config.inc.php\" file to configure phpMyAdmin for Playground.\n * 2. Inject a \"DbiMysqli.php\" file to implement the MySQL-on-SQLite driver.\n *\n * @returns Blueprint steps to install phpMyAdmin in Playground.\n */\nexport async function getPhpMyAdminInstallSteps(): Promise<StepDefinition[]> {\n\treturn [\n\t\t{\n\t\t\tstep: 'unzip',\n\t\t\tzipFile: {\n\t\t\t\tresource: 'url',\n\t\t\t\turl: PHPMYADMIN_DOWNLOAD_URL,\n\t\t\t},\n\t\t\textractToPath: '/tmp',\n\t\t},\n\t\t{\n\t\t\tstep: 'mkdir',\n\t\t\tpath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'mv',\n\t\t\tfromPath: `/tmp/phpMyAdmin-${PHPMYADMIN_VERSION}-english`,\n\t\t\ttoPath: PHPMYADMIN_INSTALL_PATH,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: `${PHPMYADMIN_INSTALL_PATH}/libraries/classes/Dbal/DbiMysqli.php`,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./DbiMysqli.php?raw')).default as string,\n\t\t},\n\t\t{\n\t\t\tstep: 'writeFile',\n\t\t\tpath: PHPMYADMIN_CONFIG_PATH,\n\t\t\t/* @ts-ignore */\n\t\t\tdata: (await import('./config.inc.php?raw')).default as string,\n\t\t},\n\t];\n}\n","import type { UniversalPHP } from '@php-wasm/universal';\n\nexport async function getSqliteDatabasePath(\n\tphp: UniversalPHP\n): Promise<string> {\n\tconst response = await php.runStream({\n\t\tcode: `<?php\n$wp_env = require '/internal/shared/wp-env.php';\nif ($wp_env['db']['type'] !== 'sqlite') {\n\tthrow new RuntimeException('The site does not use SQLite.');\n}\necho $wp_env['db']['path'];\n`,\n\t});\n\tconst [path, errors, exitCode] = await Promise.all([\n\t\tresponse.stdoutText,\n\t\tresponse.stderrText,\n\t\tresponse.exitCode,\n\t]);\n\tif (exitCode !== 0) {\n\t\tthrow new Error(errors || 'Could not read the SQLite database path.');\n\t}\n\tif (path === '') {\n\t\tthrow new Error('The SQLite database path is invalid.');\n\t}\n\treturn path;\n}\n","import type { UniversalPHP } from '@php-wasm/universal';\n\n/** Stats the database inside PHP without copying its contents into JavaScript. */\nexport async function getSqliteDatabaseSize(\n\tphp: UniversalPHP,\n\tdatabasePath: string\n): Promise<number> {\n\tconst response = await php.runStream({\n\t\tcode: `<?php\n$stat = stat(getenv('DATABASE_PATH'));\nif ($stat === false) {\n\tthrow new RuntimeException('Could not stat the database.');\n}\necho $stat['size'];\n`,\n\t\tenv: {\n\t\t\tDATABASE_PATH: databasePath,\n\t\t},\n\t});\n\tconst [output, errors, exitCode] = await Promise.all([\n\t\tresponse.stdoutText,\n\t\tresponse.stderrText,\n\t\tresponse.exitCode,\n\t]);\n\tif (exitCode !== 0) {\n\t\tthrow new Error(errors || 'Could not stat the database.');\n\t}\n\tconst sizeText = output.trim();\n\tconst size = Number(sizeText);\n\tif (sizeText === '' || !Number.isSafeInteger(size) || size < 0) {\n\t\tthrow new Error('Database stat returned an invalid size.');\n\t}\n\treturn size;\n}\n"],"names":["PHPMYADMIN_VERSION","PHPMYADMIN_DOWNLOAD_URL","PHPMYADMIN_INSTALL_PATH","PHPMYADMIN_CONFIG_PATH","joinPaths","PHPMYADMIN_URL_PATH","PHPMYADMIN_ENTRY_PATH","PHPMYADMIN_PATH_ALIAS","getPhpMyAdminInstallSteps","getSqliteDatabasePath","php","response","path","errors","exitCode","getSqliteDatabaseSize","databasePath","output","sizeText","size"],"mappings":";AAUO,MAAMA,IAAqB,SAGrBC,IAA0B,2CAA2CD,CAAkB,eAAeA,CAAkB,gBAGxHE,IAA0B,qBAG1BC,IAAyBC;AAAA,EACrCF;AAAA,EACA;AACD,GAGaG,IAAsB,eAGtBC,IACZ,qDAGYC,IAAwB;AAAA,EACpC,WAAWF;AAAA,EACX,QAAQH;AACT;AAWA,eAAsBM,IAAuD;AAC5E,SAAO;AAAA,IACN;AAAA,MACC,MAAM;AAAA,MACN,SAAS;AAAA,QACR,UAAU;AAAA,QACV,KAAKP;AAAA,MAAA;AAAA,MAEN,eAAe;AAAA,IAAA;AAAA,IAEhB;AAAA,MACC,MAAM;AAAA,MACN,MAAMC;AAAA,IAAA;AAAA,IAEP;AAAA,MACC,MAAM;AAAA,MACN,UAAU,mBAAmBF,CAAkB;AAAA,MAC/C,QAAQE;AAAA,IAAA;AAAA,IAET;AAAA,MACC,MAAM;AAAA,MACN,MAAM,GAAGA,CAAuB;AAAA;AAAA,MAEhC,OAAO,MAAM,OAAO,yBAAqB,GAAG;AAAA,IAAA;AAAA,IAE7C;AAAA,MACC,MAAM;AAAA,MACN,MAAMC;AAAA;AAAA,MAEN,OAAO,MAAM,OAAO,0BAAsB,GAAG;AAAA,IAAA;AAAA,EAC9C;AAEF;AC5EA,eAAsBM,EACrBC,GACkB;AAClB,QAAMC,IAAW,MAAMD,EAAI,UAAU;AAAA,IACpC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,CAON,GACK,CAACE,GAAMC,GAAQC,CAAQ,IAAI,MAAM,QAAQ,IAAI;AAAA,IAClDH,EAAS;AAAA,IACTA,EAAS;AAAA,IACTA,EAAS;AAAA,EAAA,CACT;AACD,MAAIG,MAAa;AAChB,UAAM,IAAI,MAAMD,KAAU,0CAA0C;AAErE,MAAID,MAAS;AACZ,UAAM,IAAI,MAAM,sCAAsC;AAEvD,SAAOA;AACR;ACvBA,eAAsBG,EACrBL,GACAM,GACkB;AAClB,QAAML,IAAW,MAAMD,EAAI,UAAU;AAAA,IACpC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAON,KAAK;AAAA,MACJ,eAAeM;AAAA,IAAA;AAAA,EAChB,CACA,GACK,CAACC,GAAQJ,GAAQC,CAAQ,IAAI,MAAM,QAAQ,IAAI;AAAA,IACpDH,EAAS;AAAA,IACTA,EAAS;AAAA,IACTA,EAAS;AAAA,EAAA,CACT;AACD,MAAIG,MAAa;AAChB,UAAM,IAAI,MAAMD,KAAU,8BAA8B;AAEzD,QAAMK,IAAWD,EAAO,KAAA,GAClBE,IAAO,OAAOD,CAAQ;AAC5B,MAAIA,MAAa,MAAM,CAAC,OAAO,cAAcC,CAAI,KAAKA,IAAO;AAC5D,UAAM,IAAI,MAAM,yCAAyC;AAE1D,SAAOA;AACR;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/tools",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.56",
|
|
4
4
|
"description": "Tools for WordPress Playground",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,10 +28,14 @@
|
|
|
28
28
|
"access": "public",
|
|
29
29
|
"directory": "../../../dist/packages/playground/tools"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "d5f85094eeee6c77339ec6365618f233c099cf00",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
33
|
+
"@php-wasm/node": "3.1.56",
|
|
34
|
+
"@wp-playground/common": "3.1.56",
|
|
35
|
+
"@wp-playground/wordpress": "3.1.56",
|
|
36
|
+
"@php-wasm/util": "3.1.56",
|
|
37
|
+
"@php-wasm/universal": "3.1.56",
|
|
38
|
+
"@wp-playground/blueprints": "3.1.56"
|
|
35
39
|
},
|
|
36
40
|
"packageManager": "npm@10.9.2",
|
|
37
41
|
"overrides": {
|