22
33namespace Appwrite \SDK \Language ;
44
5+ use Twig \TwigFunction ;
6+
57class CLI extends Node
68{
9+ /**
10+ * List of functions to ignore for console preview.
11+ * @var array
12+ */
13+ private $ consoleIgnoreFunctions = [
14+ 'listidentities ' ,
15+ 'listmfafactors ' ,
16+ 'getprefs ' ,
17+ 'getsession ' ,
18+ 'getattribute ' ,
19+ 'listdocumentlogs ' ,
20+ 'getindex ' ,
21+ 'listcollectionlogs ' ,
22+ 'getcollectionusage ' ,
23+ 'listlogs ' ,
24+ 'listruntimes ' ,
25+ 'getusage ' ,
26+ 'getusage ' ,
27+ 'listvariables ' ,
28+ 'getvariable ' ,
29+ 'listproviderlogs ' ,
30+ 'listsubscriberlogs ' ,
31+ 'getsubscriber ' ,
32+ 'listtopiclogs ' ,
33+ 'getemailtemplate ' ,
34+ 'getsmstemplate ' ,
35+ 'getfiledownload ' ,
36+ 'getfilepreview ' ,
37+ 'getfileview ' ,
38+ 'getusage ' ,
39+ 'listlogs ' ,
40+ 'getprefs ' ,
41+ 'getusage ' ,
42+ 'listlogs ' ,
43+ 'getmembership ' ,
44+ 'listmemberships ' ,
45+ 'listmfafactors ' ,
46+ 'getmfarecoverycodes ' ,
47+ 'getprefs ' ,
48+ 'listtargets ' ,
49+ 'gettarget ' ,
50+ ];
51+
52+ /**
53+ * List of SDK services to ignore for console preview.
54+ * @var array
55+ */
56+ private $ consoleIgnoreServices = [
57+ 'health ' ,
58+ 'migrations ' ,
59+ 'locale ' ,
60+ 'avatars ' ,
61+ 'project ' ,
62+ 'proxy ' ,
63+ 'vcs '
64+ ];
765 /**
866 * @var array
967 */
@@ -127,6 +185,16 @@ public function getFiles(): array
127185 'destination ' => 'lib/questions.js ' ,
128186 'template ' => 'cli/lib/questions.js.twig ' ,
129187 ],
188+ [
189+ 'scope ' => 'default ' ,
190+ 'destination ' => 'lib/validations.js ' ,
191+ 'template ' => 'cli/lib/validations.js.twig ' ,
192+ ],
193+ [
194+ 'scope ' => 'default ' ,
195+ 'destination ' => 'lib/spinner.js ' ,
196+ 'template ' => 'cli/lib/spinner.js.twig ' ,
197+ ],
130198 [
131199 'scope ' => 'default ' ,
132200 'destination ' => 'lib/parser.js ' ,
@@ -152,6 +220,11 @@ public function getFiles(): array
152220 'destination ' => 'lib/client.js ' ,
153221 'template ' => 'cli/lib/client.js.twig ' ,
154222 ],
223+ [
224+ 'scope ' => 'default ' ,
225+ 'destination ' => 'lib/id.js ' ,
226+ 'template ' => 'cli/lib/id.js.twig ' ,
227+ ],
155228 [
156229 'scope ' => 'default ' ,
157230 'destination ' => 'lib/utils.js ' ,
@@ -164,8 +237,28 @@ public function getFiles(): array
164237 ],
165238 [
166239 'scope ' => 'default ' ,
167- 'destination ' => 'lib/commands/deploy.js ' ,
168- 'template ' => 'cli/lib/commands/deploy.js.twig ' ,
240+ 'destination ' => 'lib/commands/pull.js ' ,
241+ 'template ' => 'cli/lib/commands/pull.js.twig ' ,
242+ ],
243+ [
244+ 'scope ' => 'default ' ,
245+ 'destination ' => 'lib/commands/push.js ' ,
246+ 'template ' => 'cli/lib/commands/push.js.twig ' ,
247+ ],
248+ [
249+ 'scope ' => 'default ' ,
250+ 'destination ' => 'lib/commands/run.js ' ,
251+ 'template ' => 'cli/lib/commands/run.js.twig ' ,
252+ ],
253+ [
254+ 'scope ' => 'default ' ,
255+ 'destination ' => 'lib/emulation/docker.js ' ,
256+ 'template ' => 'cli/lib/emulation/docker.js.twig ' ,
257+ ],
258+ [
259+ 'scope ' => 'default ' ,
260+ 'destination ' => 'lib/emulation/utils.js ' ,
261+ 'template ' => 'cli/lib/emulation/utils.js.twig ' ,
169262 ],
170263 [
171264 'scope ' => 'service ' ,
@@ -270,4 +363,18 @@ public function getParamExample(array $param): string
270363
271364 return $ output ;
272365 }
366+
367+ /**
368+ * Language specific filters.
369+ * @return array
370+ */
371+ public function getFunctions (): array
372+ {
373+ return [
374+ /** Return true if the entered service->method is enabled for a console preview link */
375+ new TwigFunction ('hasConsolePreview ' , fn ($ method , $ service ) => preg_match ('/^([Gg]et|[Ll]ist)/ ' , $ method )
376+ && !in_array (strtolower ($ method ), $ this ->consoleIgnoreFunctions )
377+ && !in_array ($ service , $ this ->consoleIgnoreServices )),
378+ ];
379+ }
273380}
0 commit comments