wp-studio 1.7.7-alpha1

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.
Files changed (48) hide show
  1. package/LICENSE.md +257 -0
  2. package/README.md +87 -0
  3. package/dist/cli/_events-BeOo0LuG.js +116 -0
  4. package/dist/cli/appdata-07CF2rhg.js +21090 -0
  5. package/dist/cli/archive-xDmkN4wb.js +15942 -0
  6. package/dist/cli/browser-CgWK-yoe.js +44 -0
  7. package/dist/cli/certificate-manager-DdBumKZp.js +250 -0
  8. package/dist/cli/create-BHVhkvTx.js +80 -0
  9. package/dist/cli/create-ZS29BDDi.js +40999 -0
  10. package/dist/cli/delete-BgQn-elT.js +56 -0
  11. package/dist/cli/delete-g8pgaLna.js +132 -0
  12. package/dist/cli/get-wordpress-version-BwSCJujO.js +18 -0
  13. package/dist/cli/index-7pbG_s_U.js +434 -0
  14. package/dist/cli/index-BXRYeCYG.js +1393 -0
  15. package/dist/cli/index-T3F1GwxX.js +2668 -0
  16. package/dist/cli/is-errno-exception-t38xF2pB.js +6 -0
  17. package/dist/cli/list-BE_UBjL5.js +105 -0
  18. package/dist/cli/list-DKz0XxM7.js +1032 -0
  19. package/dist/cli/logger-actions-OaIvl-ai.js +45 -0
  20. package/dist/cli/login-B4PkfKOu.js +82 -0
  21. package/dist/cli/logout-BC9gKlTj.js +48 -0
  22. package/dist/cli/main.js +5 -0
  23. package/dist/cli/mu-plugins-GEfKsl5U.js +530 -0
  24. package/dist/cli/passwords-DyzWd9Xi.js +80 -0
  25. package/dist/cli/process-manager-daemon.js +327 -0
  26. package/dist/cli/process-manager-ipc-AUZeYYDT.js +454 -0
  27. package/dist/cli/proxy-daemon.js +197 -0
  28. package/dist/cli/run-wp-cli-command-BctnMDWG.js +88 -0
  29. package/dist/cli/sequential-BQFuixXz.js +46 -0
  30. package/dist/cli/server-files-C_oy-mnI.js +26 -0
  31. package/dist/cli/set-DknhAZpw.js +327 -0
  32. package/dist/cli/site-utils-CfsabjUn.js +243 -0
  33. package/dist/cli/snapshots-6XE53y_F.js +874 -0
  34. package/dist/cli/sqlite-integration-H4OwSlwR.js +83 -0
  35. package/dist/cli/start-CRJqm09_.js +90 -0
  36. package/dist/cli/status-CWNHIOaY.js +44 -0
  37. package/dist/cli/status-CWWx9jYF.js +110 -0
  38. package/dist/cli/stop-CQosmjqA.js +117 -0
  39. package/dist/cli/update-BgL2HKHW.js +101 -0
  40. package/dist/cli/validation-error-DqLxqQuA.js +40 -0
  41. package/dist/cli/wordpress-server-child.js +514 -0
  42. package/dist/cli/wordpress-server-ipc-Dwsg9jSb.js +140 -0
  43. package/dist/cli/wordpress-server-manager-CtiuJqEb.js +566 -0
  44. package/dist/cli/wordpress-version-utils-B6UVeTh_.js +51 -0
  45. package/dist/cli/wp-UGSnlkN0.js +103 -0
  46. package/package.json +73 -0
  47. package/patches/@wp-playground+wordpress+3.1.12.patch +28 -0
  48. package/scripts/postinstall-npm.mjs +38 -0
@@ -0,0 +1,103 @@
1
+ import { __ } from "@wordpress/i18n";
2
+ import yargsParser from "yargs-parser";
3
+ import { L as LoggerError, a as Logger, k as getSiteByFolder } from "./appdata-07CF2rhg.js";
4
+ import { d as disconnectFromDaemon, c as connectToDaemon, i as isServerRunning, b as sendWpCliCommand } from "./wordpress-server-manager-CtiuJqEb.js";
5
+ import { a as runGlobalWpCliCommand, r as runWpCliCommand } from "./run-wp-cli-command-BctnMDWG.js";
6
+ import { v as validatePhpVersion } from "./index-7pbG_s_U.js";
7
+ const logger = new Logger();
8
+ async function pipePHPResponse(response) {
9
+ const decoder = new TextDecoder();
10
+ await response.stderr.pipeTo(
11
+ new WritableStream({
12
+ write(chunk) {
13
+ process.stderr.write(chunk);
14
+ }
15
+ })
16
+ );
17
+ await response.stdout.pipeTo(
18
+ new WritableStream({
19
+ write(chunk) {
20
+ const text = decoder.decode(chunk, { stream: true });
21
+ if (!text.startsWith("#!/usr/bin/env")) {
22
+ process.stdout.write(chunk);
23
+ }
24
+ }
25
+ })
26
+ );
27
+ }
28
+ async function runCommand(mode, siteFolder, args, options = {}) {
29
+ if (mode === "global") {
30
+ const [response2, exitPhp2] = await runGlobalWpCliCommand(args);
31
+ await pipePHPResponse(response2);
32
+ process.exitCode = await response2.exitCode;
33
+ exitPhp2();
34
+ return;
35
+ }
36
+ const site = await getSiteByFolder(siteFolder);
37
+ const phpVersion = validatePhpVersion(options.phpVersion ?? site.phpVersion);
38
+ const useCustomPhpVersion = options.phpVersion && options.phpVersion !== site.phpVersion;
39
+ if (!useCustomPhpVersion) {
40
+ process.on("SIGINT", disconnectFromDaemon);
41
+ process.on("SIGTERM", disconnectFromDaemon);
42
+ try {
43
+ await connectToDaemon();
44
+ if (await isServerRunning(site.id)) {
45
+ const result = await sendWpCliCommand(site.id, args);
46
+ process.stdout.write(result.stdout);
47
+ process.stderr.write(result.stderr);
48
+ process.exit(result.exitCode);
49
+ }
50
+ } finally {
51
+ await disconnectFromDaemon();
52
+ }
53
+ }
54
+ process.on("SIGINT", () => process.exit(1));
55
+ process.on("SIGTERM", () => process.exit(1));
56
+ const [response, exitPhp] = await runWpCliCommand(siteFolder, phpVersion, args);
57
+ await pipePHPResponse(response);
58
+ process.exitCode = await response.exitCode;
59
+ exitPhp();
60
+ }
61
+ function removeArgumentFromArgv(argv, argName, hasValue = true) {
62
+ argv = argv.slice(0);
63
+ while (argv.indexOf(`--${argName}`) !== -1) {
64
+ const argIndex = argv.indexOf(`--${argName}`);
65
+ argv.splice(argIndex, hasValue ? 2 : 1);
66
+ }
67
+ while (argv.find((arg) => arg.startsWith(`--${argName}=`))) {
68
+ const argIndex = argv.findIndex((arg) => arg.startsWith(`--${argName}=`));
69
+ argv.splice(argIndex, 1);
70
+ }
71
+ return argv;
72
+ }
73
+ async function commandHandler(argv) {
74
+ try {
75
+ let wpCliArgv = removeArgumentFromArgv(process.argv.slice(3), "path");
76
+ wpCliArgv = removeArgumentFromArgv(wpCliArgv, "studio-no-path", false);
77
+ const parsedWpCliArgs = yargsParser(wpCliArgv);
78
+ if (parsedWpCliArgs._[0] === "shell") {
79
+ throw new LoggerError(
80
+ __(
81
+ "Studio CLI does not support the WP-CLI `shell` command. Consider adding your code to a file and using the `eval` command."
82
+ )
83
+ );
84
+ }
85
+ const phpVersion = parsedWpCliArgs["php-version"] !== void 0 ? String(parsedWpCliArgs["php-version"]) : void 0;
86
+ wpCliArgv = removeArgumentFromArgv(wpCliArgv, "php-version");
87
+ wpCliArgv = removeArgumentFromArgv(wpCliArgv, "avoid-telemetry", false);
88
+ await runCommand(argv.studioNoPath ? "global" : "site", argv.path, wpCliArgv, {
89
+ phpVersion
90
+ });
91
+ } catch (error) {
92
+ if (error instanceof LoggerError) {
93
+ logger.reportError(error);
94
+ } else {
95
+ const loggerError = new LoggerError(__("Failed to run WP-CLI command"), error);
96
+ logger.reportError(loggerError);
97
+ }
98
+ }
99
+ }
100
+ export {
101
+ commandHandler,
102
+ runCommand
103
+ };
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "wp-studio",
3
+ "author": "Automattic Inc.",
4
+ "version": "1.7.7-alpha1",
5
+ "productName": "Studio CLI",
6
+ "description": "WordPress Studio CLI",
7
+ "license": "GPL-2.0-or-later",
8
+ "type": "module",
9
+ "bin": {
10
+ "studio": "dist/cli/main.js"
11
+ },
12
+ "files": [
13
+ "dist/cli/*.js",
14
+ "patches/",
15
+ "scripts/"
16
+ ],
17
+ "engines": {
18
+ "node": ">=22.0.0"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Automattic/studio.git",
23
+ "directory": "apps/cli"
24
+ },
25
+ "dependencies": {
26
+ "@anthropic-ai/claude-agent-sdk": "^0.2.45",
27
+ "@mariozechner/pi-tui": "^0.54.0",
28
+ "@modelcontextprotocol/sdk": "^1.27.1",
29
+ "@php-wasm/node": "3.1.12",
30
+ "@php-wasm/universal": "3.1.12",
31
+ "@php-wasm/util": "3.1.12",
32
+ "@vscode/sudo-prompt": "^9.3.2",
33
+ "@wordpress/i18n": "^6.14.0",
34
+ "@wp-playground/blueprints": "3.1.12",
35
+ "@wp-playground/cli": "3.1.12",
36
+ "@wp-playground/common": "3.1.12",
37
+ "@wp-playground/storage": "3.1.12",
38
+ "@wp-playground/wordpress": "3.1.12",
39
+ "atomically": "^2.1.1",
40
+ "chalk": "^5.6.2",
41
+ "cli-table3": "^0.6.5",
42
+ "http-proxy": "^1.18.1",
43
+ "node-forge": "^1.3.3",
44
+ "ora": "^8.2.0",
45
+ "patch-package": "^8.0.1",
46
+ "playwright": "^1.52.0",
47
+ "semver": "^7.7.4",
48
+ "trash": "^10.0.1",
49
+ "yargs": "^18.0.0",
50
+ "yargs-parser": "^22.0.0",
51
+ "zod": "^4.3.6"
52
+ },
53
+ "scripts": {
54
+ "build": "vite build --config ./vite.config.dev.ts",
55
+ "build:prod": "vite build --config ./vite.config.prod.ts",
56
+ "build:npm": "vite build --config ./vite.config.npm.ts",
57
+ "install:bundle": "npm install --omit=dev --no-package-lock --no-progress --install-links --no-workspaces && patch-package && node ../../scripts/remove-fs-ext-other-platform-binaries.mjs",
58
+ "package": "npm run install:bundle && npm run build:prod",
59
+ "watch": "vite build --config ./vite.config.dev.ts --watch",
60
+ "prepublishOnly": "npm run build:npm",
61
+ "postinstall": "node scripts/postinstall-npm.mjs",
62
+ "typecheck": "tsc -p tsconfig.json --noEmit"
63
+ },
64
+ "devDependencies": {
65
+ "@studio/common": "file:../../tools/common",
66
+ "@types/archiver": "^6.0.4",
67
+ "@types/http-proxy": "^1.17.17",
68
+ "@types/node-forge": "^1.3.14",
69
+ "@types/yargs": "^17.0.35",
70
+ "vite": "^7.3.1",
71
+ "vite-plugin-static-copy": "^3.1.5"
72
+ }
73
+ }
@@ -0,0 +1,28 @@
1
+ diff --git a/node_modules/@wp-playground/wordpress/index.cjs b/node_modules/@wp-playground/wordpress/index.cjs
2
+ index 0f93ab4..97a2ad1 100644
3
+ --- a/node_modules/@wp-playground/wordpress/index.cjs
4
+ +++ b/node_modules/@wp-playground/wordpress/index.cjs
5
+ @@ -469,7 +469,7 @@ class WP_Config_Transformer {
6
+ && ( T_WHITESPACE === $token[0] || T_COMMENT === $token[0] || T_DOC_COMMENT === $token[0] );
7
+ }
8
+ }
9
+ -`;async function g(t,e){const n=r.joinPaths(e,"wp-config.php"),i={DB_NAME:"wordpress"};if(!t.fileExists(n)&&t.fileExists(r.joinPaths(e,"wp-config-sample.php"))&&await t.writeFile(n,await t.readFileAsBuffer(r.joinPaths(e,"wp-config-sample.php"))),!t.fileExists(n))return;const a=r.phpVars({wpConfigPath:n,constants:i});if((await t.run({code:`${$}
10
+ +`;async function g(t,e){const n=r.joinPaths(e,"wp-config.php"),i={};if(!t.fileExists(n)&&t.fileExists(r.joinPaths(e,"wp-config-sample.php"))&&await t.writeFile(n,await t.readFileAsBuffer(r.joinPaths(e,"wp-config-sample.php"))),!t.fileExists(n))return;const a=r.phpVars({wpConfigPath:n,constants:i});if((await t.run({code:`${$}
11
+ $wp_config_path = ${a.wpConfigPath};
12
+ $transformer = WP_Config_Transformer::from_file($wp_config_path);
13
+ foreach ( ${a.constants} as $name => $value ) {
14
+ diff --git a/node_modules/@wp-playground/wordpress/index.js b/node_modules/@wp-playground/wordpress/index.js
15
+ index 7ef25c4..46a3b7c 100644
16
+ --- a/node_modules/@wp-playground/wordpress/index.js
17
+ +++ b/node_modules/@wp-playground/wordpress/index.js
18
+ @@ -475,9 +475,7 @@ class WP_Config_Transformer {
19
+ }
20
+ `;
21
+ async function I(t, e) {
22
+ - const n = s(e, "wp-config.php"), i = {
23
+ - DB_NAME: "wordpress"
24
+ - };
25
+ + const n = s(e, "wp-config.php"), i = {};
26
+ if (!t.fileExists(n) && t.fileExists(s(e, "wp-config-sample.php")) && await t.writeFile(
27
+ n,
28
+ await t.readFileAsBuffer(
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Postinstall script for npm consumers of wp-studio.
3
+ *
4
+ * Applies patches via patch-package.
5
+ *
6
+ * This script is a no-op in workspace (monorepo) contexts where dependencies
7
+ * are hoisted to the root node_modules and aren't present locally.
8
+ */
9
+
10
+ import { execSync } from 'child_process';
11
+ import { existsSync } from 'fs';
12
+ import { dirname, join, resolve } from 'path';
13
+ import { fileURLToPath } from 'url';
14
+
15
+ const scriptDir = dirname( fileURLToPath( import.meta.url ) );
16
+ const packageDir = resolve( scriptDir, '..' );
17
+
18
+ // Skip if the patched packages aren't installed locally (e.g. in a monorepo
19
+ // workspace where dependencies are hoisted to the root node_modules).
20
+ const patchedPackages = [
21
+ join( packageDir, 'node_modules', '@wp-playground', 'wordpress' ),
22
+ join( packageDir, 'node_modules', 'ps-man' ),
23
+ ];
24
+ if ( ! patchedPackages.some( ( pkg ) => existsSync( pkg ) ) ) {
25
+ process.exit( 0 );
26
+ }
27
+
28
+ // Apply patches via patch-package
29
+ try {
30
+ execSync( 'npx --no-install patch-package --patch-dir ./patches', {
31
+ cwd: packageDir,
32
+ stdio: 'inherit',
33
+ } );
34
+ } catch ( error ) {
35
+ console.error( 'patch-package failed — patches may not apply cleanly.' );
36
+ console.error( error instanceof Error ? error.message : error );
37
+ process.exit( 1 );
38
+ }