localwp-mcp 0.1.1 → 0.1.3
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/README.md +33 -22
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/local-graphql.d.ts +8 -0
- package/dist/local-graphql.js +78 -0
- package/dist/local-graphql.js.map +1 -0
- package/dist/site-files.d.ts +196 -0
- package/dist/site-files.js +411 -0
- package/dist/site-files.js.map +1 -0
- package/dist/site-lifecycle.d.ts +33 -0
- package/dist/site-lifecycle.js +66 -0
- package/dist/site-lifecycle.js.map +1 -0
- package/dist/tool-schemas.d.ts +1 -0
- package/dist/tool-schemas.js +4 -0
- package/dist/tool-schemas.js.map +1 -1
- package/dist/tools/delete-site-file.d.ts +2 -0
- package/dist/tools/delete-site-file.js +29 -0
- package/dist/tools/delete-site-file.js.map +1 -0
- package/dist/tools/index.js +16 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/list-site-files.d.ts +2 -0
- package/dist/tools/list-site-files.js +46 -0
- package/dist/tools/list-site-files.js.map +1 -0
- package/dist/tools/read-site-file.d.ts +2 -0
- package/dist/tools/read-site-file.js +30 -0
- package/dist/tools/read-site-file.js.map +1 -0
- package/dist/tools/restart-local-site.d.ts +2 -0
- package/dist/tools/restart-local-site.js +19 -0
- package/dist/tools/restart-local-site.js.map +1 -0
- package/dist/tools/search-site-files.d.ts +2 -0
- package/dist/tools/search-site-files.js +57 -0
- package/dist/tools/search-site-files.js.map +1 -0
- package/dist/tools/start-local-site.d.ts +2 -0
- package/dist/tools/start-local-site.js +19 -0
- package/dist/tools/start-local-site.js.map +1 -0
- package/dist/tools/stop-local-site.d.ts +2 -0
- package/dist/tools/stop-local-site.js +19 -0
- package/dist/tools/stop-local-site.js.map +1 -0
- package/dist/tools/write-site-file.d.ts +2 -0
- package/dist/tools/write-site-file.js +30 -0
- package/dist/tools/write-site-file.js.map +1 -0
- package/dist/types.d.ts +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ It automatically finds your Local sites, uses the correct Local PHP and MySQL ru
|
|
|
7
7
|
## What You Can Do
|
|
8
8
|
|
|
9
9
|
- inspect Local sites and their runtime details
|
|
10
|
+
- start, stop, and restart Local sites
|
|
11
|
+
- list, read, search, write, and delete files inside a selected Local site
|
|
10
12
|
- run WP-CLI against the correct site
|
|
11
13
|
- query the WordPress database
|
|
12
14
|
- allow full database writes when you want unrestricted local development
|
|
@@ -104,6 +106,29 @@ Use:
|
|
|
104
106
|
- `local_doctor`
|
|
105
107
|
- `local_logs`
|
|
106
108
|
|
|
109
|
+
### Work With Site Files
|
|
110
|
+
|
|
111
|
+
Use:
|
|
112
|
+
|
|
113
|
+
- `list_site_files`
|
|
114
|
+
- `read_site_file`
|
|
115
|
+
- `search_site_files`
|
|
116
|
+
- `write_site_file`
|
|
117
|
+
- `delete_site_file`
|
|
118
|
+
|
|
119
|
+
These tools are always scoped to the selected site's root directory.
|
|
120
|
+
|
|
121
|
+
- In `safe`, you can list, read, and search files.
|
|
122
|
+
- In `full-access`, you can also write and delete files.
|
|
123
|
+
|
|
124
|
+
### Control a Local Site
|
|
125
|
+
|
|
126
|
+
Use:
|
|
127
|
+
|
|
128
|
+
- `start_local_site`
|
|
129
|
+
- `stop_local_site`
|
|
130
|
+
- `restart_local_site`
|
|
131
|
+
|
|
107
132
|
### Work With WordPress
|
|
108
133
|
|
|
109
134
|
Use:
|
|
@@ -149,10 +174,18 @@ The `full` backup format is folder-based and includes the site's `app`, `conf`,
|
|
|
149
174
|
### Tools
|
|
150
175
|
|
|
151
176
|
- `list_local_sites`
|
|
177
|
+
- `start_local_site`
|
|
178
|
+
- `stop_local_site`
|
|
179
|
+
- `restart_local_site`
|
|
152
180
|
- `local_environment_check`
|
|
153
181
|
- `local_doctor`
|
|
154
182
|
- `local_logs`
|
|
155
183
|
- `local_site_info`
|
|
184
|
+
- `list_site_files`
|
|
185
|
+
- `read_site_file`
|
|
186
|
+
- `search_site_files`
|
|
187
|
+
- `write_site_file`
|
|
188
|
+
- `delete_site_file`
|
|
156
189
|
- `execute_wp_cli`
|
|
157
190
|
- `mysql_query`
|
|
158
191
|
- `mysql_execute`
|
|
@@ -212,28 +245,6 @@ Those tools are the fastest way to see whether the problem is:
|
|
|
212
245
|
- MySQL connectivity
|
|
213
246
|
- missing or stopped Local services
|
|
214
247
|
|
|
215
|
-
## From Source
|
|
216
|
-
|
|
217
|
-
If you are running from a local clone instead of npm:
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
pnpm install
|
|
221
|
-
pnpm build
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Then point your MCP client at:
|
|
225
|
-
|
|
226
|
-
```json
|
|
227
|
-
{
|
|
228
|
-
"mcpServers": {
|
|
229
|
-
"localwp": {
|
|
230
|
-
"command": "node",
|
|
231
|
-
"args": ["/path/to/localwp-mcp/dist/index.js"]
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
248
|
## For Contributors
|
|
238
249
|
|
|
239
250
|
Contributor and maintainer docs live outside the main user guide:
|
package/dist/config.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const config: {
|
|
|
9
9
|
readonly localLightningServicesDirs: string[];
|
|
10
10
|
readonly localSitesJson: string;
|
|
11
11
|
readonly localSiteStatusesJson: string;
|
|
12
|
+
readonly localGraphqlConnectionInfoJson: string;
|
|
12
13
|
readonly localWpCliPharCandidates: string[];
|
|
13
14
|
readonly localWpCliConfigCandidates: string[];
|
|
14
15
|
readonly localHelperBinDirCandidates: string[];
|
package/dist/config.js
CHANGED
|
@@ -27,6 +27,8 @@ export const config = {
|
|
|
27
27
|
path.join(process.env.LOCAL_APP_SUPPORT_DIR || defaultLocalAppSupportDir, "sites.json"),
|
|
28
28
|
localSiteStatusesJson: process.env.LOCAL_SITE_STATUSES_JSON ||
|
|
29
29
|
path.join(process.env.LOCAL_APP_SUPPORT_DIR || defaultLocalAppSupportDir, "site-statuses.json"),
|
|
30
|
+
localGraphqlConnectionInfoJson: process.env.LOCAL_GRAPHQL_CONNECTION_INFO ||
|
|
31
|
+
path.join(process.env.LOCAL_APP_SUPPORT_DIR || defaultLocalAppSupportDir, "graphql-connection-info.json"),
|
|
30
32
|
localWpCliPharCandidates: process.env.LOCAL_WP_CLI_PHAR
|
|
31
33
|
? [process.env.LOCAL_WP_CLI_PHAR]
|
|
32
34
|
: getWpCliPharCandidates(platform, localExtraResourcesDirs),
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,4BAA4B,EAC5B,iCAAiC,EACjC,mCAAmC,EACnC,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;AAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC1B,MAAM,yBAAyB,GAAG,4BAA4B,CAC5D,QAAQ,EACR,OAAO,EACP,OAAO,CAAC,GAAG,CACZ,CAAC;AACF,MAAM,8BAA8B,GAAG,iCAAiC,CACtE,QAAQ,EACR,OAAO,EACP,OAAO,CAAC,GAAG,CACZ,CAAC;AACF,MAAM,uBAAuB,GAC3B,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7E,8BAA8B,CAAC;AACjC,MAAM,0BAA0B,GAC9B,OAAO,CAAC,GAAG,CAAC,6BAA6B;IACvC,EAAE,KA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sBAAsB,CAC7B,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,MAAM,CAC1C;CACO,CAAC;AAEX,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE9C,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAChE,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LocalSiteLifecycleMutationResult } from "./types.js";
|
|
2
|
+
interface LocalGraphqlError {
|
|
3
|
+
message?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function startLocalSite(siteId: string): Promise<LocalSiteLifecycleMutationResult>;
|
|
6
|
+
export declare function stopLocalSite(siteId: string): Promise<LocalSiteLifecycleMutationResult>;
|
|
7
|
+
export declare function formatLocalGraphqlErrors(errors?: LocalGraphqlError[]): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import { config } from "./config.js";
|
|
3
|
+
import { assertReadable } from "./process-utils.js";
|
|
4
|
+
export async function startLocalSite(siteId) {
|
|
5
|
+
return runSiteLifecycleMutation("startSite", siteId);
|
|
6
|
+
}
|
|
7
|
+
export async function stopLocalSite(siteId) {
|
|
8
|
+
return runSiteLifecycleMutation("stopSite", siteId);
|
|
9
|
+
}
|
|
10
|
+
export function formatLocalGraphqlErrors(errors = []) {
|
|
11
|
+
const messages = errors
|
|
12
|
+
.map((error) => error.message?.trim())
|
|
13
|
+
.filter((message) => Boolean(message));
|
|
14
|
+
return messages.join("; ") || "Local GraphQL request failed.";
|
|
15
|
+
}
|
|
16
|
+
async function runSiteLifecycleMutation(mutationName, siteId) {
|
|
17
|
+
const query = `mutation ($siteID: ID!) { ${mutationName}(id: $siteID) { id name status } }`;
|
|
18
|
+
const payload = await requestLocalGraphql(query, { siteID: siteId });
|
|
19
|
+
const result = payload[mutationName];
|
|
20
|
+
if (!result) {
|
|
21
|
+
throw new Error(`Local GraphQL did not return '${mutationName}' data.`);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
async function requestLocalGraphql(query, variables) {
|
|
26
|
+
const connection = await readLocalGraphqlConnectionInfo();
|
|
27
|
+
let response;
|
|
28
|
+
try {
|
|
29
|
+
response = await fetch(connection.url, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: {
|
|
32
|
+
"content-type": "application/json",
|
|
33
|
+
authorization: `Bearer ${connection.authToken}`,
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify({ query, variables }),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
40
|
+
throw new Error(`Failed to reach Local's GraphQL API at ${connection.url}. Make sure the Local app is running. ${message}`);
|
|
41
|
+
}
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
throw new Error(`Local GraphQL API responded with HTTP ${response.status} ${response.statusText}.`);
|
|
44
|
+
}
|
|
45
|
+
const payload = (await response.json());
|
|
46
|
+
if (payload.errors?.length) {
|
|
47
|
+
throw new Error(formatLocalGraphqlErrors(payload.errors));
|
|
48
|
+
}
|
|
49
|
+
if (!payload.data) {
|
|
50
|
+
throw new Error("Local GraphQL API returned no data.");
|
|
51
|
+
}
|
|
52
|
+
return payload.data;
|
|
53
|
+
}
|
|
54
|
+
async function readLocalGraphqlConnectionInfo() {
|
|
55
|
+
await assertReadable(config.localGraphqlConnectionInfoJson, "Local GraphQL connection info is not readable. Open the Local app first");
|
|
56
|
+
let parsed;
|
|
57
|
+
try {
|
|
58
|
+
parsed = JSON.parse(await readFile(config.localGraphqlConnectionInfoJson, "utf8"));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
62
|
+
throw new Error(`Failed to read Local GraphQL connection info from '${config.localGraphqlConnectionInfoJson}': ${message}`);
|
|
63
|
+
}
|
|
64
|
+
if (!isLocalGraphqlConnectionInfo(parsed)) {
|
|
65
|
+
throw new Error(`Local GraphQL connection info is invalid: ${config.localGraphqlConnectionInfoJson}`);
|
|
66
|
+
}
|
|
67
|
+
return parsed;
|
|
68
|
+
}
|
|
69
|
+
function isLocalGraphqlConnectionInfo(value) {
|
|
70
|
+
if (!value || typeof value !== "object") {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const candidate = value;
|
|
74
|
+
return (typeof candidate.port === "number" &&
|
|
75
|
+
typeof candidate.authToken === "string" &&
|
|
76
|
+
typeof candidate.url === "string");
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=local-graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-graphql.js","sourceRoot":"","sources":["../src/local-graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAepD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAc;IACjD,OAAO,wBAAwB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc;IAChD,OAAO,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,SAA8B,EAAE;IACvE,MAAM,QAAQ,GAAG,MAAM;SACpB,GAAG,CAA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MAAM,IAAI,KAAK,CACb,6CAA6C,MAAM,CAAC,8BAA8B,EAAE,CACrF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,4BAA4B,CACnC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,KAA4C,CAAC;IAC/D,OAAO,CACL,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QAClC,OAAO,SAAS,CAAC,SAAS,KAAK,QAAQ;QACvC,OAAO,SAAS,CAAC,GAAG,KAAK,QAAQ,CAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { SiteSelection } from "./types.js";
|
|
2
|
+
interface ResolvedSiteFileTarget {
|
|
3
|
+
siteRoot: string;
|
|
4
|
+
siteRootReal: string;
|
|
5
|
+
absolutePath: string;
|
|
6
|
+
relativePath: string;
|
|
7
|
+
exists: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface SiteFileListEntry {
|
|
10
|
+
path: string;
|
|
11
|
+
absolutePath: string;
|
|
12
|
+
kind: "file" | "directory" | "symlink" | "other";
|
|
13
|
+
sizeBytes: number;
|
|
14
|
+
modifiedAt: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function clampSiteFileReadBytes(value: number | undefined): number;
|
|
17
|
+
export declare function clampSiteFileListEntries(value: number | undefined): number;
|
|
18
|
+
export declare function clampSiteFileSearchMatches(value: number | undefined): number;
|
|
19
|
+
export declare function listSiteFiles(selection: SiteSelection, options?: {
|
|
20
|
+
directoryPath?: string;
|
|
21
|
+
recursive?: boolean;
|
|
22
|
+
maxDepth?: number;
|
|
23
|
+
maxEntries?: number;
|
|
24
|
+
includeHidden?: boolean;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
site: {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
status: string;
|
|
30
|
+
domain: string | undefined;
|
|
31
|
+
path: string;
|
|
32
|
+
wpRoot: string;
|
|
33
|
+
localVersion: string | undefined;
|
|
34
|
+
phpVersion: string | null;
|
|
35
|
+
mysqlVersion: string | null;
|
|
36
|
+
httpPort: number | null;
|
|
37
|
+
mysqlPort: number | null;
|
|
38
|
+
};
|
|
39
|
+
selectionMethod: string;
|
|
40
|
+
directoryPath: string;
|
|
41
|
+
absoluteDirectoryPath: string;
|
|
42
|
+
recursive: boolean;
|
|
43
|
+
maxDepth: number;
|
|
44
|
+
maxEntries: number;
|
|
45
|
+
includeHidden: boolean;
|
|
46
|
+
truncated: boolean;
|
|
47
|
+
entries: SiteFileListEntry[];
|
|
48
|
+
}>;
|
|
49
|
+
export declare function readSiteFile(selection: SiteSelection, options: {
|
|
50
|
+
filePath: string;
|
|
51
|
+
maxBytes?: number;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
site: {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
status: string;
|
|
57
|
+
domain: string | undefined;
|
|
58
|
+
path: string;
|
|
59
|
+
wpRoot: string;
|
|
60
|
+
localVersion: string | undefined;
|
|
61
|
+
phpVersion: string | null;
|
|
62
|
+
mysqlVersion: string | null;
|
|
63
|
+
httpPort: number | null;
|
|
64
|
+
mysqlPort: number | null;
|
|
65
|
+
};
|
|
66
|
+
selectionMethod: string;
|
|
67
|
+
filePath: string;
|
|
68
|
+
absolutePath: string;
|
|
69
|
+
sizeBytes: number;
|
|
70
|
+
returnedBytes: number;
|
|
71
|
+
maxBytes: number;
|
|
72
|
+
truncated: boolean;
|
|
73
|
+
content: string;
|
|
74
|
+
}>;
|
|
75
|
+
export declare function searchSiteFiles(selection: SiteSelection, options: {
|
|
76
|
+
query: string;
|
|
77
|
+
directoryPath?: string;
|
|
78
|
+
caseSensitive?: boolean;
|
|
79
|
+
includeHidden?: boolean;
|
|
80
|
+
maxDepth?: number;
|
|
81
|
+
maxMatches?: number;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
site: {
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
status: string;
|
|
87
|
+
domain: string | undefined;
|
|
88
|
+
path: string;
|
|
89
|
+
wpRoot: string;
|
|
90
|
+
localVersion: string | undefined;
|
|
91
|
+
phpVersion: string | null;
|
|
92
|
+
mysqlVersion: string | null;
|
|
93
|
+
httpPort: number | null;
|
|
94
|
+
mysqlPort: number | null;
|
|
95
|
+
};
|
|
96
|
+
selectionMethod: string;
|
|
97
|
+
query: string;
|
|
98
|
+
caseSensitive: boolean;
|
|
99
|
+
directoryPath: string;
|
|
100
|
+
absoluteDirectoryPath: string;
|
|
101
|
+
includeHidden: boolean;
|
|
102
|
+
maxDepth: number;
|
|
103
|
+
maxMatches: number;
|
|
104
|
+
scannedFiles: number;
|
|
105
|
+
skippedBinaryFiles: number;
|
|
106
|
+
skippedLargeFiles: number;
|
|
107
|
+
truncated: boolean;
|
|
108
|
+
matches: {
|
|
109
|
+
path: string;
|
|
110
|
+
absolutePath: string;
|
|
111
|
+
line: number;
|
|
112
|
+
column: number;
|
|
113
|
+
excerpt: string;
|
|
114
|
+
}[];
|
|
115
|
+
}>;
|
|
116
|
+
export declare function writeSiteFile(selection: SiteSelection, options: {
|
|
117
|
+
filePath: string;
|
|
118
|
+
content: string;
|
|
119
|
+
createDirectories?: boolean;
|
|
120
|
+
overwrite?: boolean;
|
|
121
|
+
}): Promise<{
|
|
122
|
+
site: {
|
|
123
|
+
id: string;
|
|
124
|
+
name: string;
|
|
125
|
+
status: string;
|
|
126
|
+
domain: string | undefined;
|
|
127
|
+
path: string;
|
|
128
|
+
wpRoot: string;
|
|
129
|
+
localVersion: string | undefined;
|
|
130
|
+
phpVersion: string | null;
|
|
131
|
+
mysqlVersion: string | null;
|
|
132
|
+
httpPort: number | null;
|
|
133
|
+
mysqlPort: number | null;
|
|
134
|
+
};
|
|
135
|
+
selectionMethod: string;
|
|
136
|
+
filePath: string;
|
|
137
|
+
absolutePath: string;
|
|
138
|
+
existedBefore: boolean;
|
|
139
|
+
overwrite: boolean;
|
|
140
|
+
createdDirectories: boolean;
|
|
141
|
+
bytesWritten: number;
|
|
142
|
+
}>;
|
|
143
|
+
export declare function deleteSiteFile(selection: SiteSelection, options: {
|
|
144
|
+
targetPath: string;
|
|
145
|
+
recursive?: boolean;
|
|
146
|
+
missingOk?: boolean;
|
|
147
|
+
}): Promise<{
|
|
148
|
+
site: {
|
|
149
|
+
id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
status: string;
|
|
152
|
+
domain: string | undefined;
|
|
153
|
+
path: string;
|
|
154
|
+
wpRoot: string;
|
|
155
|
+
localVersion: string | undefined;
|
|
156
|
+
phpVersion: string | null;
|
|
157
|
+
mysqlVersion: string | null;
|
|
158
|
+
httpPort: number | null;
|
|
159
|
+
mysqlPort: number | null;
|
|
160
|
+
};
|
|
161
|
+
selectionMethod: string;
|
|
162
|
+
targetPath: string;
|
|
163
|
+
absolutePath: string;
|
|
164
|
+
existedBefore: boolean;
|
|
165
|
+
deleted: boolean;
|
|
166
|
+
recursive: boolean;
|
|
167
|
+
missingOk: boolean;
|
|
168
|
+
kind?: undefined;
|
|
169
|
+
} | {
|
|
170
|
+
site: {
|
|
171
|
+
id: string;
|
|
172
|
+
name: string;
|
|
173
|
+
status: string;
|
|
174
|
+
domain: string | undefined;
|
|
175
|
+
path: string;
|
|
176
|
+
wpRoot: string;
|
|
177
|
+
localVersion: string | undefined;
|
|
178
|
+
phpVersion: string | null;
|
|
179
|
+
mysqlVersion: string | null;
|
|
180
|
+
httpPort: number | null;
|
|
181
|
+
mysqlPort: number | null;
|
|
182
|
+
};
|
|
183
|
+
selectionMethod: string;
|
|
184
|
+
targetPath: string;
|
|
185
|
+
absolutePath: string;
|
|
186
|
+
existedBefore: boolean;
|
|
187
|
+
deleted: boolean;
|
|
188
|
+
kind: "file" | "directory" | "symlink" | "other";
|
|
189
|
+
recursive: boolean;
|
|
190
|
+
missingOk: boolean;
|
|
191
|
+
}>;
|
|
192
|
+
export declare function resolveSiteScopedPath(siteRoot: string, requestedPath: string, options?: {
|
|
193
|
+
allowSiteRoot?: boolean;
|
|
194
|
+
allowMissingTarget?: boolean;
|
|
195
|
+
}): Promise<ResolvedSiteFileTarget>;
|
|
196
|
+
export {};
|