@php-wasm/cli 1.0.17 → 1.0.19

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.
@@ -1 +1,2 @@
1
1
  const p="/assets/php-9094d88a.ini";export{p as default};
2
+ //# sourceMappingURL=php-e1f9edd4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"php-e1f9edd4.js","sources":["../../../../../packages/php-wasm/cli/src/php.ini"],"sourcesContent":["export default \"__VITE_ASSET__243dae86__\""],"names":["php"],"mappings":"AAAA,MAAeA,EAAA"}
package/main.js CHANGED
@@ -2,3 +2,4 @@ import{existsSync as v,writeFileSync as f,mkdtempSync as P,rmSync as w,rmdirSync
2
2
  `));o.unshift("-d",`openssl.cafile=${h}`);async function x(){const a=await _(()=>import("./assets/php-e1f9edd4.js"),[]),r=process.env.PHP||S;if(!$.includes(r))throw new Error(`Unsupported PHP version ${r}`);const{TMPDIR:c,...p}=process.env,i=new g(await C(r,{emscriptenOptions:{ENV:{...p,TERM:"xterm"}}}));k(i),i.setSpawnHandler(e=>{const m=`${process.argv[0]} ${process.execArgv.join(" ")} ${process.argv[1]}`,u=e.replace(/^(?:\\ |[^ ])*php\d?(\s|$)/,m+"$1"),s=P("php-wasm-"),n=`${s}/script.sh`;f(n,`#!/bin/sh
3
3
  ${u} < /dev/stdin
4
4
  `);try{return R(u,[],{shell:!0,stdio:["pipe","pipe","pipe"],timeout:5e3})}finally{w(n),y(s)}}),o.some(e=>e.startsWith("-c"))||o.unshift("-c",a),await i.cli(["php",...o]).catch(e=>{throw e.name==="ExitStatus"&&process.exit(e.status===void 0?1:e.status),e}).finally(()=>{setTimeout(()=>{process.exit(0)},100)})}x();
5
+ //# sourceMappingURL=main.js.map
package/main.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"mappings":"urCAgBA,IAAIA,EAAO,QAAQ,KAAK,MAAM,CAAC,EAC1BA,EAAK,SACTA,EAAO,CAAC,QAAQ,GAIjB,MAAMC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O,SAAW,OAAY,EAAIA,EAAO,MAAM,EAEvDA,CAAA,CACN,EACA,QAAQ,IAAM,CACd,WAAW,IAAM,CAChB,QAAQ,KAAK,CAAC,GAGZ,GAAG,EACN,CACH,CAEAtB,EAAI","names":["args","caBundlePath","existsSync","writeFileSync","rootCertificates","run","defaultPhpIniPath","__vitePreload","phpVersion","LatestSupportedPHPVersion","SupportedPHPVersionsList","TMPDIR","envVariables","php","PHP","loadNodeRuntime","useHostFilesystem","command","phpWasmCommand","updatedCommand","tempDir","mkdtempSync","tempScriptPath","spawn","rmSync","rmdirSync","arg","result"],"sources":["../../../../packages/php-wasm/cli/src/main.ts"],"sourcesContent":["/**\n * A CLI script that runs PHP CLI via the WebAssembly build.\n */\nimport { writeFileSync, existsSync, mkdtempSync, rmSync, rmdirSync } from 'fs';\nimport { rootCertificates } from 'tls';\n\nimport {\n\tLatestSupportedPHPVersion,\n\tSupportedPHPVersion,\n\tSupportedPHPVersionsList,\n} from '@php-wasm/universal';\n\nimport { PHP } from '@php-wasm/universal';\nimport { spawn } from 'child_process';\nimport { loadNodeRuntime, useHostFilesystem } from '@php-wasm/node';\n\nlet args = process.argv.slice(2);\nif (!args.length) {\n\targs = ['--help'];\n}\n\n// Write the ca-bundle.crt file to disk so that PHP can find it.\nconst caBundlePath = new URL('ca-bundle.crt', (import.meta || {}).url).pathname;\nif (!existsSync(caBundlePath)) {\n\twriteFileSync(caBundlePath, rootCertificates.join('\\n'));\n}\nargs.unshift('-d', `openssl.cafile=${caBundlePath}`);\n\nasync function run() {\n\t// @ts-ignore\n\tconst defaultPhpIniPath = await import('./php.ini');\n\tconst phpVersion = (process.env['PHP'] ||\n\t\tLatestSupportedPHPVersion) as SupportedPHPVersion;\n\tif (!SupportedPHPVersionsList.includes(phpVersion)) {\n\t\tthrow new Error(`Unsupported PHP version ${phpVersion}`);\n\t}\n\n\t// npm scripts set the TMPDIR env variable\n\t// PHP accepts a TMPDIR env variable and expects it to\n\t// be a writable directory within the PHP filesystem.\n\t// These two clash and prevent PHP from creating temporary\n\t// files and directories so let's just not pass the npm TMPDIR\n\t// to PHP.\n\t// @see https://github.com/npm/npm/issues/4531\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tconst { TMPDIR, ...envVariables } = process.env;\n\tconst php = new PHP(\n\t\tawait loadNodeRuntime(phpVersion, {\n\t\t\temscriptenOptions: {\n\t\t\t\tENV: {\n\t\t\t\t\t...envVariables,\n\t\t\t\t\tTERM: 'xterm',\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t);\n\n\tuseHostFilesystem(php);\n\tphp.setSpawnHandler((command: string) => {\n\t\tconst phpWasmCommand = `${process.argv[0]} ${process.execArgv.join(\n\t\t\t' '\n\t\t)} ${process.argv[1]}`;\n\t\t// Naively replace the PHP binary with the PHP-WASM command\n\t\t// @TODO: Don't process the command. Lean on the shell to do it, e.g.\n\t\t// through a PATH or an alias.\n\t\tconst updatedCommand = command.replace(\n\t\t\t/^(?:\\\\ |[^ ])*php\\d?(\\s|$)/,\n\t\t\tphpWasmCommand + '$1'\n\t\t);\n\n\t\t// Create a shell script in a temporary directory\n\t\tconst tempDir = mkdtempSync('php-wasm-');\n\t\tconst tempScriptPath = `${tempDir}/script.sh`;\n\t\twriteFileSync(\n\t\t\ttempScriptPath,\n\t\t\t`#!/bin/sh\n\t${updatedCommand} < /dev/stdin\n\t`\n\t\t);\n\n\t\ttry {\n\t\t\treturn spawn(updatedCommand, [], {\n\t\t\t\tshell: true,\n\t\t\t\tstdio: ['pipe', 'pipe', 'pipe'],\n\t\t\t\ttimeout: 5000,\n\t\t\t});\n\t\t} finally {\n\t\t\t// Remove the temporary directory\n\t\t\trmSync(tempScriptPath);\n\t\t\trmdirSync(tempDir);\n\t\t}\n\t});\n\n\tconst hasMinusCOption = args.some((arg) => arg.startsWith('-c'));\n\tif (!hasMinusCOption) {\n\t\targs.unshift('-c', defaultPhpIniPath);\n\t}\n\n\tawait php\n\t\t.cli(['php', ...args])\n\t\t.catch((result) => {\n\t\t\tif (result.name === 'ExitStatus') {\n\t\t\t\tprocess.exit(result.status === undefined ? 1 : result.status);\n\t\t\t}\n\t\t\tthrow result;\n\t\t})\n\t\t.finally(() => {\n\t\t\tsetTimeout(() => {\n\t\t\t\tprocess.exit(0);\n\t\t\t\t// 100 is an arbitrary number. It's there to give any child processes\n\t\t\t\t// a chance to pass their output to JS before the main process exits.\n\t\t\t}, 100);\n\t\t});\n}\n\nrun();\n"],"file":"main.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/cli",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "PHP.wasm CLI for node.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,14 +23,14 @@
23
23
  "type": "module",
24
24
  "main": "main.js",
25
25
  "bin": "php-wasm.js",
26
- "gitHead": "c6b9b151a8baf922d23294d953e346458b9616cb",
26
+ "gitHead": "13938f0d995655ef9e174ddc9ef51408210237d5",
27
27
  "dependencies": {
28
28
  "comlink": "^4.4.1",
29
29
  "events": "3.3.0",
30
30
  "ini": "4.1.2",
31
31
  "wasm-feature-detect": "1.8.0",
32
32
  "ws": "8.18.0",
33
- "@php-wasm/universal": "1.0.17",
34
- "@php-wasm/node": "1.0.17"
33
+ "@php-wasm/universal": "1.0.19",
34
+ "@php-wasm/node": "1.0.19"
35
35
  }
36
36
  }