-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.d.ts
1860 lines (1472 loc) · 46.2 KB
/
main.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* eslint-disable max-classes-per-file, @typescript-eslint/no-use-before-define */
declare module '@getflywheel/local/main' {
import * as Local from '@getflywheel/local';
import {
ExecFileOptions, ChildProcess, Serializable, SendHandle, MessageOptions, SpawnOptions,
} from 'child_process';
import * as Awilix from 'awilix';
import * as Electron from 'electron';
import * as Winston from 'winston';
import * as os from 'os';
import type { DocumentNode } from 'graphql';
import type { RequestInit as NodeFetchRequestInit } from 'node-fetch';
import type { IResolvers } from '@graphql-tools/utils';
import type { PubSub } from 'graphql-subscriptions';
import type { ApolloClient } from 'apollo-boost';
import type fetch from 'cross-fetch';
import type { SiteGroup } from '@getflywheel/local/graphql';
export { default as gql } from 'graphql-tag';
export type ServiceContainer = Awilix.AwilixContainer<ServiceContainerServices>;
export const getServiceContainer: () => ServiceContainer;
export interface ServiceContainerServices {
addonLoader: Services.AddonLoader
appEvent: Services.AppEvent
adminer: Services.Adminer
electron: typeof Electron
os: typeof os
siteData: Services.SiteDataService
featureFlags: Services.FeatureFlagService
cache: Services.Cache
httpGateway: Services.HttpGateway
userData: typeof UserData
sendIPCEvent: typeof sendIPCEvent
addIpcAsyncListener: typeof addIpcAsyncListener
appState: Services.AppState
addonInstaller: Services.AddonInstaller
downloader: Services.Downloader
errorHandler: Services.ErrorHandler
siteProvisioner: Services.SiteProvisioner
siteProcessManager: Services.SiteProcessManager
siteDatabase: Services.SiteDatabase
sitesOrganization: Services.SitesOrganizationService
changeSiteDomain: Services.ChangeSiteDomain
importSite: Services.ImportSite
importSQLFile: (site: Local.Site, sqlFile: string) => Promise<string>
addSite: Services.AddSite
cloneSite: Services.CloneSite
exportSite: Services.ExportSite
deleteSite: Services.DeleteSite
rsync: Services.Rsync
ssh: Services.Ssh
capi: Services.CAPI
siteShellEntry: Services.SiteShellEntry
browserManager: Services.BrowserManager
wpCli: Services.WpCli
vsCode: Services.VSCode
ports: Services.Ports
configTemplates: Services.ConfigTemplates
localLogger: Winston.Logger
x509Cert: Services.X509Cert
multiSite: Services.MultiSite
router: Services.Router
formatHomePath: typeof formatHomePath
blueprints: Services.Blueprints
lightningServices: Services.LightningServices
liveLinks: Services.LiveLinks
liveLinksMuPlugin: Services.LiveLinksMuPlugin
localHubClient: ApolloClient<{ uri: string; fetch: typeof fetch }>
analyticsV2: Services.AnalyticsV2Service
userEvent: Services.UserEvent
graphql: Services.GraphQLService
jobs: Services.JobsService
runSiteSQLCmd: (args: { site: Local.Site; query: string; additionalArgs?: string[]; }) => Promise<string>
}
export function sendIPCEvent(channel: string, ...args: any[]): void;
/**
* Utility function for setting up IPC listener on the main thread and replying to it. This should be used only with
* LocalRenderer.ipcAsync()
*
* @see LocalRenderer.ipcAsync()
*/
export function addIpcAsyncListener(channel: string, callback: (...any) => any): void;
export function formatHomePath(string: any, untrailingslashit?: boolean): any;
export function formatSiteNicename(siteName: string): string;
/**
* Very efficient in file string replacements using streams.
*
* @param file Path to the file
* @param replacements Array of replacements to perform: [ [ 'before', 'after' ] ]
* @param replaceStreamArgs Optional arguments for replacestream package.
*/
export function replaceInFileAsync(file: string, replacements: any, replaceStreamArgs?: any): Promise<void>;
export type CustomSend<T extends Serializable> = {
(message: T, callback?: ((error: Error | null) => void)): boolean;
(message: T, sendHandle?: SendHandle, callback?: ((error: Error | null) => void)): boolean;
(message: T, sendHandle?: SendHandle, options?: MessageOptions, callback?:
((error: Error | null) => void)): boolean;
};
export interface WorkerForkMessage {
siteMessage?: string;
siteID?: string;
notify?: {
title?: string;
body?: string;
click?: string;
};
result?: any;
}
export interface WorkerFork<T extends Serializable> extends Omit<ChildProcess, 'send'> {
send: CustomSend<T>;
}
/**
* Helper function to create a forked child process.
*
* Utilizes the Node standard lib child_process.fork with some defaults to help keep code DRY
* and help functionality to just work with the Local code base.
*
* Check out the docs for ChildProcess.fork for more info:
* https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options
*
* @param execPath path to file that should be executed
* @param envVarDependencies environment variables that need to be copied over to forked process
*/
export function workerFork<T extends Serializable>(
execPath: string, envVarDependencies: Local.GenericObject
): WorkerFork<T> | undefined;
export type ChildProcessMessagePromiseHelper = <T>(name: string, payload?: any) => Promise<T>;
/**
* Returns up a helper function to easily communcicate between the main thread and a child thread/process
* by wrapping an event listener for the "message" event with a promise which allows you to await a "call"
* to another thread. It also removes the event listener once complete.
*
* This pairs nicely with the workerFork helper function
*
* @param childProcess childProcess to bind this helper to
*
* @returns ChildProcessMessagePromiseHelper
*/
export function childProcessMessagePromiseFactory(
childProcess: ChildProcess
): ChildProcessMessagePromiseHelper;
/**
* @deprecated Use LocalMain.Services.SiteDataService instead
*/
export class SiteData {
static getSites(): Local.Sites;
static getSite (siteID: Local.Site['id']) : Local.Site | null;
static getSiteByProperty (property: string, value: any) : Local.Site | null;
static addSite (siteID: Local.Site['id'], site: Local.SiteJSON) : void;
static updateSite (siteID: Local.Site['id'], site: Partial<Local.SiteJSON>) : void;
static deleteSite (siteID: Local.Site['id']) : void;
static reformatSites () : void;
}
export interface GetOpts {
name: string;
defaults?: Local.GenericObject;
includeCreatedTime?: boolean;
persistDefaults?: boolean;
persistDefaultsEncrypted?: boolean;
}
export interface SetOpts {
name: string;
data: Local.GenericObject;
encrypted?: boolean;
}
export class UserData {
static getPath(name: string): string;
static get(
name: string,
defaults?: Local.GenericObject,
includeCreatedTime?: boolean,
persistDefaults?: boolean,
persistDefaultsEncrypted?: boolean,
): any;
// eslint-disable-next-line no-dupe-class-members
static get(opts: GetOpts): any;
static set(
name: string,
data?: Local.GenericObject,
encrypted?: boolean,
): void;
// eslint-disable-next-line no-dupe-class-members
static set(opts: SetOpts): void;
static remove(name: string): any;
}
export interface SelectableSiteService {
/**
* @description Name of the Lightning Service
* @TJS-examples ["php"]
*/
name: string
/**
* @description Label of Lightning Service that's suitable for use in a UI
* @TJS-examples ["PHP"]
*/
label: string
/**
* @description Build version of Lightning Service. This is typically the binVersion followed by build metadata.
* This allows us to iterate on a specific binVersion by patching configs, etc.
*
* @TJS-examples ["7.3.5+2"]
*/
version: string
/**
* @description Binary version for the service.
*
* @TJS-examples ["7.3.5"]
*/
binVersion: string
}
export type RegisteredServices = { [serviceName: string]: { [binVersion: string]: RegisteredService } };
/**
* Registered Services are loaded and registered so downloading the service is not required.
*/
export interface RegisteredService extends SelectableSiteService {
registered: true
platform: LightningServicePlatform
}
/**
* DownloadableServices, DownloadableService, and ServiceBin can be converted to JSON schema using
* https://github.com/YousefED/typescript-json-schema
*
* Command to generate JSON Schema:
* typescript-json-schema --required
* ./DownloadableServices.d.ts DownloadableServices > ./DownloadableServices.schema.json
*
* @description Downloadable/Available Services for Local
*/
export type DownloadableServices = { [serviceName: string]: { [binVersion: string]: DownloadableService } };
export interface DownloadableService extends SelectableSiteService {
/**
* @description Engine version requirement ranges. Used to prevent users from downloading services that aren't
* supported by the version of Local that they're using.
*/
engines: {
/**
* @description Version range of Local that the service is compatible with.
*
* @TJS-examples ["^5.1.2"]
*/
'local-by-flywheel': string
}
/**
* @description Download URL to the core JS and configs for a given service.
*
* @format uri
*
* @TJS-examples ["https://local-cdn.fake-url/lightning/services/php/7.3.5+3/php-7.3.5.tgz"]
*/
url: string
/**
* @description Compressed size (in bytes) of core JS files, configs, etc. (Does not include bins)
* @TJS-type integer
* @TJS-examples [51280]
*/
size: number
/**
* @description Object containing the bin info for each platform. Platforms are optional.
*/
bins: {
['darwin-arm64']?: ServiceBin
darwin?: ServiceBin
linux?: ServiceBin
win32?: ServiceBin
win64?: ServiceBin
}
/**
* @description Date for deprecation of service. If this field exists, the service won't be downloadable
* after the specified date.
*
* @format UTC Date string
*
* @TJS-examples ["2022-10-19T00:00:00z"]
*/
endOfLife?: string
}
export type AvailableServices = {
[serviceName: string]: { [binVersion: string]: DownloadableService | RegisteredService };
};
interface ServiceBin {
/**
* @description Compressed size (in bytes) of binaries for a given platform.
* @TJS-type integer
* @TJS-examples [27355695]
*/
size: number
/**
* @description Compressed size (in bytes) of binaries for a given platform.
* @format uri
* @TJS-examples ["https://local-cdn.fake-url/lightning/services/php/7.3.5+3/bin-darwin.tar.gz"]
*/
url: string
}
export enum LightningServicePlatform {
DarwinArm64 = 'darwin-arm64',
Darwin = 'darwin',
Win32 = 'win32',
Win32x64 = 'win64',
Linux = 'linux',
}
export enum ProfileTypes {
TEAMS = 'teams',
USER = 'user',
HUB = 'hub',
}
type Scalar = string | number | boolean;
type ConfigVariables = { [key: string]: Scalar | Scalar[] | ConfigVariables };
export class LightningService {
public _site: Local.Site;
public _lightningServices: Services.LightningServices;
public _logger: any;
constructor(_site:Local.Site, _lightningServices: any);
/**
* Get properties and computed getters from instance. This is handy for passing the service info from the main
* thread to the renderer thread.
*
* @returns Properties and computed getters from instance.
*/
public toJSON(): Pick<LightningService,
'_site'
| 'serviceName'
| 'binVersion'
| 'configTemplatePath'
| 'siteConfigTemplatePath'
| 'bins'
| 'bin'
| '$PATH'
| '$PATHs'
| 'socket'
| 'port'
| 'ports'
| 'env'
| 'configVariables'
| 'configPath'
| 'runPath'
| 'logsPath'
>;
/**
* @remarks
* Should be lowercase with no spaces and special characters.
*
* Examples:
* nginx
* php
* mysql
*
* @returns Name of the service.
*/
readonly serviceName: string;
/**
* Examples:
* Nginx
* PHP
* MySQL
*
* @returns Label of the service that's suitable for use in a UI
*/
readonly label?: string;
/**
* @remarks
* The version format should be parsable by semver, but does not
* need to be compliant.
*
* @returns Version of the binary included with the service.
*/
readonly binVersion: string;
/**
* @returns Path to the config templates included with the service.
*
* @getter
*/
get configTemplatePath() : string | null;
/**
* @returns Path to config templates after they've been copied to the site directory.
*
* @getter
*/
readonly siteConfigTemplatePath: string;
/**
* @remarks
* Platforms can be omitted.
*
* @returns Path to binaries for each platform.
*
* @getter
*/
get bins() : { [K in LightningServicePlatform]?: { [bin: string]: string } };
/**
* @returns Paths to binaries for service on current platform.
*
* @getter
*/
readonly bin: { [bin: string]: string } | undefined;
/**
* @returns Path to socket for service on current platform.
*
* @getter
*/
get socket() : string | null;
/**
* @remarks
* These environment variables are used when Local calls WP-CLI directly.
*
* @returns Object containing environment variables for the process.
*
* @getter
*/
get env() : NodeJS.ProcessEnv;
/**
* @remarks
* Platforms can be omitted.
*
* @returns Valid path to be used in $PATH for each platform.
*
* @getter
*/
get $PATHs() : { [K in LightningServicePlatform]?: string };
/**
* @returns Path to be used in $PATH for current platform.
*
* @getter
*/
readonly $PATH?: string;
/**
* @returns Object containing variables to be replaced in config templates using Handlebars.
*
* @getter
*/
get configVariables() : ConfigVariables;
/**
* @see LocalSiteJSON.ports
*
* @returns Port identifiers and number of ports needed. Keys should be uppercase.
*
* @getter
*/
get requiredPorts() : { [portKey: string]: Local.SitePort };
/**
* @see LocalSiteJSON.ports
*
* @returns Allocated ports on site for current service.
*
* @getter
*/
readonly ports: { [portKey: string]: Local.SitePort[] } | null;
/**
* @see LocalSiteJSON.ports
*
* @returns First allocated port for service.
*
* @getter
*/
readonly port: Local.SitePort | null;
/**
* @remarks
* In most cases, this path will be where the Handlebars config templates are compiled to.
*
* @returns Path to config path that the service will consume.
*
* @getter
*/
readonly configPath: string;
/**
* @remarks
* Generally used for 'tmp' directories, 'data' directories, and other things you'd find in '/var/run'.
*
* @returns Path to 'run' directory for service.
*
* @getter
*/
readonly runPath: string;
/**
* @remarks
* Path will typically be in the site's 'logs' directory adjacent to the 'app' directory.
*
* @returns Path to log directory the service.
*
* @getter
*/
readonly logsPath: string;
/**
* @remarks
* Only used by PHP service attached to site at this time.
*
* @returns Shell script to be added to the Site Shell Entry startup script.
*
* @getter
*/
get siteShellStartupPOSIX() : string;
/**
* @remarks
* Only used by PHP service attached to site at this time.
*
* @returns Batch script be added to the Site Shell Entry startup script.
*
* @getter
*/
get siteShellStartupBat() : string;
/**
* Ran before a service is started for the first time.
*
* @remarks
* This is commonly used for setting up data directories or whatever is necessary to allow a service to start
* for the first time.
*
* @returns Promise
*/
preprovision?(): Promise<void>;
/**
* Ran after a service is started for the first time.
*
* @remarks
* Used for setting up MySQL databases, users, etc.
*
* @returns Promise
*/
provision?(): Promise<void>;
/**
* Ran after WordPress is fully installed when a new site is created. This will not be ran during
* imports or pulls.
*
* @returns Promise
*/
finalizeNewSite?() : Promise<void>;
/**
* @returns IProcessOpts[] Necessary processes for a given service.
*/
start(): Local.IProcessOpts[];
/**
* Do things before a service is stopped. Can be used for dumping databases prior to completely stopping
* the process.
*
* @returns Promise
*/
stop?(): Promise<void>
}
export const registerLightningService: (
service: typeof LightningService,
serviceName:string,
binVersion:string,
) => void;
export function execFilePromise(
command: string,
args: string[],
execFileOptions?: ExecFileOptions,
): Promise<string>;
/**
* Downloadable item that can be passed to LocalMain.DownloaderQueue
*/
export interface DownloaderQueueItem {
id?: string
size: number
url: string
label: string
extract?: boolean,
onCancel?: () => void
dest: string
status?: 'aborted' | 'waiting' | 'done' | 'in-progress'
/* bytes downloaded */
downloaded?: number
/* md5Hash that the download will be verified against after downloading */
md5Hash?: string
/* Integer (0 to 100) representing progress */
progress?: number
}
export class DownloaderQueue {
public id: string;
public queue: any[];
static getInstance(id) : DownloaderQueue;
public updateItem(queueItem:DownloaderQueueItem, updated:Partial<DownloaderQueueItem>) : void;
public clear() : void;
public addItem(item:DownloaderQueueItem) : void;
public run(args:{ rejectOnCancel: boolean }) : Promise<void>;
}
export class HooksMain {
static registeredHooks: {
actions: {};
filters: {};
};
static addAction(hook: any, callback: any, priority?: number): void;
static doActions(hook: any, ...args: any[]): Promise<any[] | undefined>;
static addFilter(hook: any, callback: any, priority?: number): void;
static applyFilters(hook: any, value: any, ...args: any[]): any;
}
export interface IAppState {
siteStatuses: { [siteId: string]: Local.SiteStatus }
addons: Local.AddonPackage[]
enabledAddons: { [name: string]: boolean };
loadedAddons: Local.AddonPackage[]
addonStatuses: { [name: string]: Local.AddonStatus };
updatedAddons: Local.AddonPackage['name'][]
selectedSites: Local.SiteJSON['id'][]
flywheelUser: any
flywheelTeams: any
}
/**
* Jobs
*/
export enum JobStatus {
CREATED = 'created',
RUNNING = 'running',
SUCCESSFUL = 'successful',
FAILED = 'failed',
}
export class Job {
public id: string;
public status: JobStatus;
public logs: string;
public error: Error;
public readonly meta: Local.GenericObject;
constructor(meta: Local.GenericObject);
await(promise: Promise<any>) : Promise<Job>;
start(): void;
succeed(): void;
fail(e: Error): void;
log(log: string): void;
}
/**
* Process and Process Groups
*/
export class ProcessGroup {
processes: Process[];
constructor(processes: Process[]);
startAll(): Promise<any[]>;
stopAll(): Promise<any[]>;
restartAll(): Promise<any[]>;
attachProcess(p: Process): void;
}
export interface ProcessStat {
/**
* percentage (from 0 to 100*vcore)
*/
cpu: number;
/**
* bytes
*/
memory: number;
/**
* PPID
*/
ppid: number;
/**
* PID
*/
pid: number;
/**
* ms user + system time
*/
ctime: number;
/**
* ms since the start of the process
*/
elapsed: number;
/**
* ms since epoch
*/
timestamp: number;
}
export class Process implements Local.IProcessOpts {
childProcess: ChildProcess | undefined;
name: Local.IProcessOpts['name'];
binPath: Local.IProcessOpts['binPath'];
args: Local.IProcessOpts['args'];
env?: Local.IProcessOpts['env'];
cwd?: Local.IProcessOpts['cwd'];
onError?: Local.IProcessOpts['onError'];
stdioLogging: Local.IProcessOpts['stdioLogging'];
errored: boolean;
/**
* Number of restarts the process has encountered since the process was initialized.
*/
restarts: number;
constructor(opts: Local.IProcessOpts);
start(): Promise<void>;
restart(): Promise<void>;
listen(): void;
removeListeners(): void;
/**
* Attach a readline interface no matter what. MailHog will eventually hang if it doesn't have anything
* listening to its output.
*/
readline(): void;
autoRestarter: () => Promise<void>;
errorListener: (err: any) => void;
closeListener: (code: any, signal: any) => void;
stop: () => Promise<void>;
stats(): Promise<ProcessStat>;
}
/**
* Importer Interfaces
*/
export interface IImportSiteSettings extends Local.NewSiteInfo {
importData: IImportData
zip: string
}
export interface IImportData {
wpVersion?: string,
multiSiteInfo?: any,
oldSite?: any
fileDir?: string
sql?: any
metadata?: any
type?: string
}
/**
* The data that a `wpmigrate-export.json` file contains.
*/
export interface WpMigrateJSON {
name: string;
domain: string;
path: string;
wpVersion: string;
services: {
php?: {
name: string;
version: string;
};
mysql?: {
name: string;
version: string;
};
mariadb?: {
name: string;
version: string;
};
nginx?: {
name: string,
version: string,
},
apache?: {
name: string;
version?: string;
};
flywheel?: {
name: string;
version: string;
};
};
wpMigrate: {
version: string;
};
}
/**
* The data needed to import a WP Migrate archive.
*
* @property zip The path to the archive is on disk.
*/
export interface WpMigrateImport extends WpMigrateJSON {
zip: string;
}
export interface AddonMainContext {
environment: {
appPath: any;
userHome: any;
version: any;
userDataPath: any;
};
process: NodeJS.Process;
electron: typeof Electron;
fileSystem: any;
fileSystemJetpack: any;
notifier: {
notify: ({ title, message, open }: {
title?: string;
message?: string;
/** url to open via shell.openExternal */
open?: string;
}) => void;
};
events: {
send: any;
};
storage: {
get: (defaultValue?: any) => void;
set: (value: any) => void;
};
hooks: typeof HooksMain;
}
export { SiteGroup } from '@getflywheel/local/graphql';
/** Data structure stored in site-groups.json */
export interface SiteGroupsData {
/**
* Maps sites to their groups, like a join table.
* Useful for speeding up operations.
* */
siteMap: {
[siteId: string]: SiteGroup['id'];
}
/** Site groups in object format */
groups: {
[siteGroupId: SiteGroup['id']]: SiteGroup;
}
/** Whether to sort sites in a group by last started timestamp. */
sortSitesByLastStarted: boolean;
/** Open state for the sidebar, as it's collapsable */
sidebarCollapsed?: boolean;
}
export const WpeEnvironmentEnum = {
Production: 'production',
Staging: 'staging',
Development: 'development',
} as const;
export type WpeEnvironmentEnum = typeof WpeEnvironmentEnum[keyof typeof WpeEnvironmentEnum];
export interface WPEConnectArgs {
includeSql?: boolean
requiresProvisioning?: boolean
wpengineInstallName: string
wpengineInstallId: string
wpengineSiteId: string
wpenginePrimaryDomain: string
localSiteId: string
environment?: WpeEnvironmentEnum
files?: string[],
isMagicSync?: boolean,
}
export interface RsyncRunArgs {
/** Array of flags to send to the rsync command */
args: string[];
/** Working directory for the spawned rsync process. For Connect, it should be app/public folder */
cwd?: string;
/** Progress handler function, will receive output from rsync */
progress?: (string: string) => void;
}
export interface SshRunArgs {
/** Remote username */
username: string;
/** Remote host */
host: string;
/** Path to private SSH key (used for -i flag) */
sshKey?: string;
/** Array of flags/args to send to the ssh command */
sshArgs?: string[];
/** Command to execute remotely as a single string, like 'wp plugin list' */
command?: string;
/** SpawnOptions are options passed to the exec command. Common would include CWD */
spawnOptions?: SpawnOptions;
}
/**
* Modules for Service Container
*
* The typings here exclude the constructor and any properties in services that are used to reference other
* services.
*
* Important! While Services is exported here, it's only for typings. To access the services here, you will need to
* use LocalMain.getServiceContainer()
*
* @see ServiceContainer
* @see getServiceContainer()
*/
export module Services {
export class AddonLoader {