appwrite-cli 13.0.0-rc.1 → 13.0.0-rc.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.
Files changed (430) hide show
  1. package/.github/workflows/publish.yml +68 -0
  2. package/CHANGELOG.md +10 -1
  3. package/LICENSE.md +1 -1
  4. package/README.md +3 -3
  5. package/cli.ts +152 -0
  6. package/dist/bundle.cjs +95813 -0
  7. package/dist/cli.d.ts +3 -0
  8. package/dist/cli.d.ts.map +1 -0
  9. package/dist/cli.js +145 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/index.d.ts +10 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +7 -142
  14. package/dist/index.js.map +1 -1
  15. package/dist/lib/client.d.ts +2 -3
  16. package/dist/lib/client.d.ts.map +1 -1
  17. package/dist/lib/client.js +57 -45
  18. package/dist/lib/client.js.map +1 -1
  19. package/dist/lib/commands/config.d.ts +562 -0
  20. package/dist/lib/commands/config.d.ts.map +1 -0
  21. package/dist/lib/commands/config.js +416 -0
  22. package/dist/lib/commands/config.js.map +1 -0
  23. package/dist/lib/commands/db.d.ts +34 -0
  24. package/dist/lib/commands/db.d.ts.map +1 -0
  25. package/dist/lib/commands/db.js +247 -0
  26. package/dist/lib/commands/db.js.map +1 -0
  27. package/dist/lib/commands/errors.d.ts +68 -0
  28. package/dist/lib/commands/errors.d.ts.map +1 -0
  29. package/dist/lib/commands/errors.js +72 -0
  30. package/dist/lib/commands/errors.js.map +1 -0
  31. package/dist/lib/commands/generic.d.ts +2 -2
  32. package/dist/lib/commands/generic.d.ts.map +1 -1
  33. package/dist/lib/commands/generic.js +170 -157
  34. package/dist/lib/commands/generic.js.map +1 -1
  35. package/dist/lib/commands/init.d.ts +1 -1
  36. package/dist/lib/commands/init.d.ts.map +1 -1
  37. package/dist/lib/commands/init.js +201 -192
  38. package/dist/lib/commands/init.js.map +1 -1
  39. package/dist/lib/commands/pull.d.ts +105 -3
  40. package/dist/lib/commands/pull.d.ts.map +1 -1
  41. package/dist/lib/commands/pull.js +530 -370
  42. package/dist/lib/commands/pull.js.map +1 -1
  43. package/dist/lib/commands/push.d.ts +106 -0
  44. package/dist/lib/commands/push.d.ts.map +1 -1
  45. package/dist/lib/commands/push.js +1432 -1830
  46. package/dist/lib/commands/push.js.map +1 -1
  47. package/dist/lib/commands/run.d.ts +1 -1
  48. package/dist/lib/commands/run.d.ts.map +1 -1
  49. package/dist/lib/commands/run.js +129 -127
  50. package/dist/lib/commands/run.js.map +1 -1
  51. package/dist/lib/commands/schema.d.ts +59 -0
  52. package/dist/lib/commands/schema.d.ts.map +1 -0
  53. package/dist/lib/commands/schema.js +86 -0
  54. package/dist/lib/commands/schema.js.map +1 -0
  55. package/dist/lib/commands/services/account.d.ts +3 -0
  56. package/dist/lib/commands/services/account.d.ts.map +1 -0
  57. package/dist/lib/commands/services/account.js +328 -0
  58. package/dist/lib/commands/services/account.js.map +1 -0
  59. package/dist/lib/commands/services/console.d.ts +3 -0
  60. package/dist/lib/commands/services/console.d.ts.map +1 -0
  61. package/dist/lib/commands/services/console.js +28 -0
  62. package/dist/lib/commands/services/console.js.map +1 -0
  63. package/dist/lib/commands/services/databases.d.ts +3 -0
  64. package/dist/lib/commands/services/databases.d.ts.map +1 -0
  65. package/dist/lib/commands/services/databases.js +620 -0
  66. package/dist/lib/commands/services/databases.js.map +1 -0
  67. package/dist/lib/commands/services/functions.d.ts +3 -0
  68. package/dist/lib/commands/services/functions.d.ts.map +1 -0
  69. package/dist/lib/commands/services/functions.js +266 -0
  70. package/dist/lib/commands/services/functions.js.map +1 -0
  71. package/dist/lib/commands/services/graphql.d.ts +3 -0
  72. package/dist/lib/commands/services/graphql.d.ts.map +1 -0
  73. package/dist/lib/commands/services/graphql.js +28 -0
  74. package/dist/lib/commands/services/graphql.js.map +1 -0
  75. package/dist/lib/commands/services/health.d.ts +3 -0
  76. package/dist/lib/commands/services/health.d.ts.map +1 -0
  77. package/dist/lib/commands/services/health.js +123 -0
  78. package/dist/lib/commands/services/health.js.map +1 -0
  79. package/dist/lib/commands/services/locale.d.ts +3 -0
  80. package/dist/lib/commands/services/locale.d.ts.map +1 -0
  81. package/dist/lib/commands/services/locale.js +52 -0
  82. package/dist/lib/commands/services/locale.js.map +1 -0
  83. package/dist/lib/commands/services/messaging.d.ts +3 -0
  84. package/dist/lib/commands/services/messaging.d.ts.map +1 -0
  85. package/dist/lib/commands/services/messaging.js +505 -0
  86. package/dist/lib/commands/services/messaging.js.map +1 -0
  87. package/dist/lib/commands/services/migrations.d.ts +3 -0
  88. package/dist/lib/commands/services/migrations.d.ts.map +1 -0
  89. package/dist/lib/commands/services/migrations.js +135 -0
  90. package/dist/lib/commands/services/migrations.js.map +1 -0
  91. package/dist/lib/commands/services/project.d.ts +3 -0
  92. package/dist/lib/commands/services/project.d.ts.map +1 -0
  93. package/dist/lib/commands/services/project.js +54 -0
  94. package/dist/lib/commands/services/project.js.map +1 -0
  95. package/dist/lib/commands/services/projects.d.ts +3 -0
  96. package/dist/lib/commands/services/projects.d.ts.map +1 -0
  97. package/dist/lib/commands/services/projects.js +415 -0
  98. package/dist/lib/commands/services/projects.js.map +1 -0
  99. package/dist/lib/commands/services/proxy.d.ts +3 -0
  100. package/dist/lib/commands/services/proxy.d.ts.map +1 -0
  101. package/dist/lib/commands/services/proxy.js +68 -0
  102. package/dist/lib/commands/services/proxy.js.map +1 -0
  103. package/dist/lib/commands/services/sites.d.ts +3 -0
  104. package/dist/lib/commands/services/sites.d.ts.map +1 -0
  105. package/dist/lib/commands/services/sites.js +250 -0
  106. package/dist/lib/commands/services/sites.js.map +1 -0
  107. package/dist/lib/commands/services/storage.d.ts +3 -0
  108. package/dist/lib/commands/services/storage.d.ts.map +1 -0
  109. package/dist/lib/commands/services/storage.js +175 -0
  110. package/dist/lib/commands/services/storage.js.map +1 -0
  111. package/dist/lib/commands/services/tables-db.d.ts +3 -0
  112. package/dist/lib/commands/services/tables-db.d.ts.map +1 -0
  113. package/dist/lib/commands/services/tables-db.js +613 -0
  114. package/dist/lib/commands/services/tables-db.js.map +1 -0
  115. package/dist/lib/commands/services/teams.d.ts +3 -0
  116. package/dist/lib/commands/services/teams.d.ts.map +1 -0
  117. package/dist/lib/commands/services/teams.js +123 -0
  118. package/dist/lib/commands/services/teams.js.map +1 -0
  119. package/dist/lib/commands/services/tokens.d.ts +3 -0
  120. package/dist/lib/commands/services/tokens.d.ts.map +1 -0
  121. package/dist/lib/commands/services/tokens.js +49 -0
  122. package/dist/lib/commands/services/tokens.js.map +1 -0
  123. package/dist/lib/commands/services/users.d.ts +3 -0
  124. package/dist/lib/commands/services/users.d.ts.map +1 -0
  125. package/dist/lib/commands/services/users.js +312 -0
  126. package/dist/lib/commands/services/users.js.map +1 -0
  127. package/dist/lib/commands/services/vcs.d.ts +3 -0
  128. package/dist/lib/commands/services/vcs.d.ts.map +1 -0
  129. package/dist/lib/commands/services/vcs.js +87 -0
  130. package/dist/lib/commands/services/vcs.js.map +1 -0
  131. package/dist/lib/commands/types.d.ts +1 -1
  132. package/dist/lib/commands/types.d.ts.map +1 -1
  133. package/dist/lib/commands/types.js +53 -57
  134. package/dist/lib/commands/types.js.map +1 -1
  135. package/dist/lib/commands/update.d.ts +1 -1
  136. package/dist/lib/commands/update.d.ts.map +1 -1
  137. package/dist/lib/commands/update.js +69 -69
  138. package/dist/lib/commands/update.js.map +1 -1
  139. package/dist/lib/commands/utils/attributes.d.ts +47 -0
  140. package/dist/lib/commands/utils/attributes.d.ts.map +1 -0
  141. package/dist/lib/commands/utils/attributes.js +514 -0
  142. package/dist/lib/commands/utils/attributes.js.map +1 -0
  143. package/dist/lib/commands/utils/change-approval.d.ts +25 -0
  144. package/dist/lib/commands/utils/change-approval.d.ts.map +1 -0
  145. package/dist/lib/commands/utils/change-approval.js +129 -0
  146. package/dist/lib/commands/utils/change-approval.js.map +1 -0
  147. package/dist/lib/commands/utils/database-sync.d.ts +10 -0
  148. package/dist/lib/commands/utils/database-sync.d.ts.map +1 -0
  149. package/dist/lib/commands/utils/database-sync.js +136 -0
  150. package/dist/lib/commands/utils/database-sync.js.map +1 -0
  151. package/dist/lib/commands/utils/deployment.d.ts +34 -0
  152. package/dist/lib/commands/utils/deployment.d.ts.map +1 -0
  153. package/dist/lib/commands/utils/deployment.js +109 -0
  154. package/dist/lib/commands/utils/deployment.js.map +1 -0
  155. package/dist/lib/commands/utils/error-formatter.d.ts +19 -0
  156. package/dist/lib/commands/utils/error-formatter.d.ts.map +1 -0
  157. package/dist/lib/commands/utils/error-formatter.js +333 -0
  158. package/dist/lib/commands/utils/error-formatter.js.map +1 -0
  159. package/dist/lib/commands/utils/pools.d.ts +16 -0
  160. package/dist/lib/commands/utils/pools.d.ts.map +1 -0
  161. package/dist/lib/commands/utils/pools.js +198 -0
  162. package/dist/lib/commands/utils/pools.js.map +1 -0
  163. package/dist/lib/config.d.ts +41 -40
  164. package/dist/lib/config.d.ts.map +1 -1
  165. package/dist/lib/config.js +264 -239
  166. package/dist/lib/config.js.map +1 -1
  167. package/dist/lib/constants.d.ts +14 -0
  168. package/dist/lib/constants.d.ts.map +1 -0
  169. package/dist/lib/constants.js +19 -0
  170. package/dist/lib/constants.js.map +1 -0
  171. package/dist/lib/emulation/docker.d.ts +4 -12
  172. package/dist/lib/emulation/docker.d.ts.map +1 -1
  173. package/dist/lib/emulation/docker.js +159 -142
  174. package/dist/lib/emulation/docker.js.map +1 -1
  175. package/dist/lib/emulation/utils.d.ts +1 -1
  176. package/dist/lib/emulation/utils.d.ts.map +1 -1
  177. package/dist/lib/emulation/utils.js +55 -58
  178. package/dist/lib/emulation/utils.js.map +1 -1
  179. package/dist/lib/id.d.ts +1 -1
  180. package/dist/lib/id.d.ts.map +1 -1
  181. package/dist/lib/id.js +13 -18
  182. package/dist/lib/id.js.map +1 -1
  183. package/dist/lib/paginate.d.ts +3 -4
  184. package/dist/lib/paginate.d.ts.map +1 -1
  185. package/dist/lib/paginate.js +7 -10
  186. package/dist/lib/paginate.js.map +1 -1
  187. package/dist/lib/parser.d.ts +1 -1
  188. package/dist/lib/parser.d.ts.map +1 -1
  189. package/dist/lib/parser.js +92 -103
  190. package/dist/lib/parser.js.map +1 -1
  191. package/dist/lib/questions.d.ts +1 -1
  192. package/dist/lib/questions.d.ts.map +1 -1
  193. package/dist/lib/questions.js +381 -385
  194. package/dist/lib/questions.js.map +1 -1
  195. package/dist/lib/sdks.d.ts +1 -1
  196. package/dist/lib/sdks.d.ts.map +1 -1
  197. package/dist/lib/sdks.js +39 -30
  198. package/dist/lib/sdks.js.map +1 -1
  199. package/dist/lib/services.d.ts +13 -0
  200. package/dist/lib/services.d.ts.map +1 -0
  201. package/dist/lib/services.js +47 -0
  202. package/dist/lib/services.js.map +1 -0
  203. package/dist/lib/spinner.d.ts +1 -1
  204. package/dist/lib/spinner.d.ts.map +1 -1
  205. package/dist/lib/spinner.js +25 -27
  206. package/dist/lib/spinner.js.map +1 -1
  207. package/dist/lib/type-generation/attribute.d.ts +1 -1
  208. package/dist/lib/type-generation/attribute.d.ts.map +1 -1
  209. package/dist/lib/type-generation/attribute.js +14 -17
  210. package/dist/lib/type-generation/attribute.js.map +1 -1
  211. package/dist/lib/type-generation/languages/csharp.d.ts +1 -1
  212. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -1
  213. package/dist/lib/type-generation/languages/csharp.js +34 -34
  214. package/dist/lib/type-generation/languages/csharp.js.map +1 -1
  215. package/dist/lib/type-generation/languages/dart.d.ts +1 -1
  216. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -1
  217. package/dist/lib/type-generation/languages/dart.js +57 -57
  218. package/dist/lib/type-generation/languages/dart.js.map +1 -1
  219. package/dist/lib/type-generation/languages/java.d.ts +1 -1
  220. package/dist/lib/type-generation/languages/java.d.ts.map +1 -1
  221. package/dist/lib/type-generation/languages/java.js +35 -35
  222. package/dist/lib/type-generation/languages/java.js.map +1 -1
  223. package/dist/lib/type-generation/languages/javascript.d.ts +1 -1
  224. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -1
  225. package/dist/lib/type-generation/languages/javascript.js +45 -44
  226. package/dist/lib/type-generation/languages/javascript.js.map +1 -1
  227. package/dist/lib/type-generation/languages/kotlin.d.ts +1 -1
  228. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -1
  229. package/dist/lib/type-generation/languages/kotlin.js +35 -35
  230. package/dist/lib/type-generation/languages/kotlin.js.map +1 -1
  231. package/dist/lib/type-generation/languages/language.d.ts.map +1 -1
  232. package/dist/lib/type-generation/languages/language.js +32 -37
  233. package/dist/lib/type-generation/languages/language.js.map +1 -1
  234. package/dist/lib/type-generation/languages/php.d.ts +1 -1
  235. package/dist/lib/type-generation/languages/php.d.ts.map +1 -1
  236. package/dist/lib/type-generation/languages/php.js +34 -34
  237. package/dist/lib/type-generation/languages/php.js.map +1 -1
  238. package/dist/lib/type-generation/languages/swift.d.ts +1 -1
  239. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -1
  240. package/dist/lib/type-generation/languages/swift.js +35 -35
  241. package/dist/lib/type-generation/languages/swift.js.map +1 -1
  242. package/dist/lib/type-generation/languages/typescript.d.ts +1 -1
  243. package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -1
  244. package/dist/lib/type-generation/languages/typescript.js +49 -46
  245. package/dist/lib/type-generation/languages/typescript.js.map +1 -1
  246. package/dist/lib/types.d.ts +38 -108
  247. package/dist/lib/types.d.ts.map +1 -1
  248. package/dist/lib/types.js +1 -2
  249. package/dist/lib/utils.d.ts +3 -0
  250. package/dist/lib/utils.d.ts.map +1 -1
  251. package/dist/lib/utils.js +142 -98
  252. package/dist/lib/utils.js.map +1 -1
  253. package/dist/lib/validations.d.ts.map +1 -1
  254. package/dist/lib/validations.js +2 -6
  255. package/dist/lib/validations.js.map +1 -1
  256. package/dist/package.json +68 -0
  257. package/index.ts +25 -149
  258. package/install.ps1 +2 -2
  259. package/install.sh +1 -1
  260. package/lib/client.ts +261 -220
  261. package/lib/commands/config.ts +494 -0
  262. package/lib/commands/db.ts +324 -0
  263. package/lib/commands/errors.ts +93 -0
  264. package/lib/commands/generic.ts +371 -269
  265. package/lib/commands/init.ts +631 -519
  266. package/lib/commands/pull.ts +827 -453
  267. package/lib/commands/push.ts +2191 -2349
  268. package/lib/commands/run.ts +382 -302
  269. package/lib/commands/schema.ts +122 -0
  270. package/lib/commands/services/account.ts +647 -0
  271. package/lib/commands/services/console.ts +52 -0
  272. package/lib/commands/services/databases.ts +1163 -0
  273. package/lib/commands/services/functions.ts +536 -0
  274. package/lib/commands/services/graphql.ts +50 -0
  275. package/lib/commands/services/health.ts +260 -0
  276. package/lib/commands/services/locale.ts +102 -0
  277. package/lib/commands/services/messaging.ts +1052 -0
  278. package/lib/commands/services/migrations.ts +249 -0
  279. package/lib/commands/services/project.ts +112 -0
  280. package/lib/commands/services/projects.ts +785 -0
  281. package/lib/commands/services/proxy.ts +135 -0
  282. package/lib/commands/services/sites.ts +505 -0
  283. package/lib/commands/services/storage.ts +338 -0
  284. package/lib/commands/services/tables-db.ts +1150 -0
  285. package/lib/commands/services/teams.ts +232 -0
  286. package/lib/commands/services/tokens.ts +94 -0
  287. package/lib/commands/services/users.ts +616 -0
  288. package/lib/commands/services/vcs.ts +165 -0
  289. package/lib/commands/types.ts +145 -118
  290. package/lib/commands/update.ts +189 -159
  291. package/lib/commands/utils/attributes.ts +719 -0
  292. package/lib/commands/utils/change-approval.ts +186 -0
  293. package/lib/commands/utils/database-sync.ts +180 -0
  294. package/lib/commands/utils/deployment.ts +184 -0
  295. package/lib/commands/utils/error-formatter.ts +417 -0
  296. package/lib/commands/utils/pools.ts +355 -0
  297. package/lib/config.ts +766 -687
  298. package/lib/constants.ts +22 -0
  299. package/lib/emulation/docker.ts +277 -216
  300. package/lib/emulation/utils.ts +188 -174
  301. package/lib/id.ts +23 -23
  302. package/lib/paginate.ts +69 -55
  303. package/lib/parser.ts +220 -189
  304. package/lib/questions.ts +1024 -948
  305. package/lib/sdks.ts +84 -51
  306. package/lib/services.ts +72 -0
  307. package/lib/spinner.ts +112 -99
  308. package/lib/type-generation/attribute.ts +15 -14
  309. package/lib/type-generation/languages/csharp.ts +71 -60
  310. package/lib/type-generation/languages/dart.ts +106 -93
  311. package/lib/type-generation/languages/java.ts +69 -58
  312. package/lib/type-generation/languages/javascript.ts +84 -73
  313. package/lib/type-generation/languages/kotlin.ts +71 -60
  314. package/lib/type-generation/languages/language.ts +103 -95
  315. package/lib/type-generation/languages/php.ts +67 -56
  316. package/lib/type-generation/languages/swift.ts +71 -60
  317. package/lib/type-generation/languages/typescript.ts +93 -76
  318. package/lib/types.ts +50 -125
  319. package/lib/utils.ts +304 -233
  320. package/lib/validations.ts +17 -14
  321. package/package.json +31 -22
  322. package/scoop/appwrite.config.json +3 -3
  323. package/tsconfig.json +7 -13
  324. package/.github/workflows/autoclose.yml +0 -11
  325. package/.github/workflows/npm-publish.yml +0 -49
  326. package/dist/lib/commands/account.d.ts +0 -379
  327. package/dist/lib/commands/account.d.ts.map +0 -1
  328. package/dist/lib/commands/account.js +0 -1228
  329. package/dist/lib/commands/account.js.map +0 -1
  330. package/dist/lib/commands/console.d.ts +0 -20
  331. package/dist/lib/commands/console.d.ts.map +0 -1
  332. package/dist/lib/commands/console.js +0 -78
  333. package/dist/lib/commands/console.js.map +0 -1
  334. package/dist/lib/commands/databases.d.ts +0 -732
  335. package/dist/lib/commands/databases.d.ts.map +0 -1
  336. package/dist/lib/commands/databases.js +0 -2196
  337. package/dist/lib/commands/databases.js.map +0 -1
  338. package/dist/lib/commands/functions.d.ts +0 -310
  339. package/dist/lib/commands/functions.d.ts.map +0 -1
  340. package/dist/lib/commands/functions.js +0 -1100
  341. package/dist/lib/commands/functions.js.map +0 -1
  342. package/dist/lib/commands/graphql.d.ts +0 -19
  343. package/dist/lib/commands/graphql.d.ts.map +0 -1
  344. package/dist/lib/commands/graphql.js +0 -77
  345. package/dist/lib/commands/graphql.js.map +0 -1
  346. package/dist/lib/commands/health.d.ts +0 -153
  347. package/dist/lib/commands/health.d.ts.map +0 -1
  348. package/dist/lib/commands/health.js +0 -464
  349. package/dist/lib/commands/health.js.map +0 -1
  350. package/dist/lib/commands/locale.d.ts +0 -53
  351. package/dist/lib/commands/locale.d.ts.map +0 -1
  352. package/dist/lib/commands/locale.js +0 -165
  353. package/dist/lib/commands/locale.js.map +0 -1
  354. package/dist/lib/commands/messaging.d.ts +0 -588
  355. package/dist/lib/commands/messaging.d.ts.map +0 -1
  356. package/dist/lib/commands/messaging.js +0 -2042
  357. package/dist/lib/commands/messaging.js.map +0 -1
  358. package/dist/lib/commands/migrations.d.ts +0 -150
  359. package/dist/lib/commands/migrations.d.ts.map +0 -1
  360. package/dist/lib/commands/migrations.js +0 -524
  361. package/dist/lib/commands/migrations.js.map +0 -1
  362. package/dist/lib/commands/organizations.d.ts +0 -11
  363. package/dist/lib/commands/organizations.d.ts.map +0 -1
  364. package/dist/lib/commands/organizations.js +0 -31
  365. package/dist/lib/commands/organizations.js.map +0 -1
  366. package/dist/lib/commands/project.d.ts +0 -53
  367. package/dist/lib/commands/project.d.ts.map +0 -1
  368. package/dist/lib/commands/project.js +0 -176
  369. package/dist/lib/commands/project.js.map +0 -1
  370. package/dist/lib/commands/projects.d.ts +0 -516
  371. package/dist/lib/commands/projects.d.ts.map +0 -1
  372. package/dist/lib/commands/projects.js +0 -1590
  373. package/dist/lib/commands/projects.js.map +0 -1
  374. package/dist/lib/commands/proxy.d.ts +0 -71
  375. package/dist/lib/commands/proxy.d.ts.map +0 -1
  376. package/dist/lib/commands/proxy.js +0 -240
  377. package/dist/lib/commands/proxy.js.map +0 -1
  378. package/dist/lib/commands/sites.d.ts +0 -296
  379. package/dist/lib/commands/sites.d.ts.map +0 -1
  380. package/dist/lib/commands/sites.js +0 -1046
  381. package/dist/lib/commands/sites.js.map +0 -1
  382. package/dist/lib/commands/storage.d.ts +0 -170
  383. package/dist/lib/commands/storage.d.ts.map +0 -1
  384. package/dist/lib/commands/storage.js +0 -651
  385. package/dist/lib/commands/storage.js.map +0 -1
  386. package/dist/lib/commands/tables-db.d.ts +0 -728
  387. package/dist/lib/commands/tables-db.d.ts.map +0 -1
  388. package/dist/lib/commands/tables-db.js +0 -2198
  389. package/dist/lib/commands/tables-db.js.map +0 -1
  390. package/dist/lib/commands/teams.d.ts +0 -129
  391. package/dist/lib/commands/teams.d.ts.map +0 -1
  392. package/dist/lib/commands/teams.js +0 -403
  393. package/dist/lib/commands/teams.js.map +0 -1
  394. package/dist/lib/commands/tokens.d.ts +0 -48
  395. package/dist/lib/commands/tokens.d.ts.map +0 -1
  396. package/dist/lib/commands/tokens.js +0 -156
  397. package/dist/lib/commands/tokens.js.map +0 -1
  398. package/dist/lib/commands/users.d.ts +0 -382
  399. package/dist/lib/commands/users.d.ts.map +0 -1
  400. package/dist/lib/commands/users.js +0 -1195
  401. package/dist/lib/commands/users.js.map +0 -1
  402. package/dist/lib/commands/vcs.d.ts +0 -92
  403. package/dist/lib/commands/vcs.d.ts.map +0 -1
  404. package/dist/lib/commands/vcs.js +0 -276
  405. package/dist/lib/commands/vcs.js.map +0 -1
  406. package/dist/lib/exception.d.ts +0 -8
  407. package/dist/lib/exception.d.ts.map +0 -1
  408. package/dist/lib/exception.js +0 -16
  409. package/dist/lib/exception.js.map +0 -1
  410. package/lib/commands/account.ts +0 -1867
  411. package/lib/commands/console.ts +0 -112
  412. package/lib/commands/databases.ts +0 -3272
  413. package/lib/commands/functions.ts +0 -1587
  414. package/lib/commands/graphql.ts +0 -110
  415. package/lib/commands/health.ts +0 -753
  416. package/lib/commands/locale.ts +0 -270
  417. package/lib/commands/messaging.ts +0 -2878
  418. package/lib/commands/migrations.ts +0 -754
  419. package/lib/commands/organizations.ts +0 -46
  420. package/lib/commands/project.ts +0 -266
  421. package/lib/commands/projects.ts +0 -2370
  422. package/lib/commands/proxy.ts +0 -357
  423. package/lib/commands/sites.ts +0 -1514
  424. package/lib/commands/storage.ts +0 -919
  425. package/lib/commands/tables-db.ts +0 -3260
  426. package/lib/commands/teams.ts +0 -609
  427. package/lib/commands/tokens.ts +0 -232
  428. package/lib/commands/users.ts +0 -1804
  429. package/lib/commands/vcs.ts +0 -428
  430. package/lib/exception.ts +0 -20
@@ -1,24 +1,18 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.init = void 0;
7
- const fs = require("fs");
8
- const path = require("path");
9
- const childProcess = require("child_process");
10
- const commander_1 = require("commander");
11
- const inquirer_1 = __importDefault(require("inquirer"));
12
- const projects_1 = require("./projects");
13
- const pull_1 = require("./pull");
14
- const id_1 = __importDefault(require("../id"));
15
- const config_1 = require("../config");
16
- const questions_1 = require("../questions");
17
- const parser_1 = require("../parser");
18
- const account_1 = require("./account");
19
- const sites_1 = require("./sites");
20
- const sdks_1 = require("../sdks");
21
- const utils_1 = require("../utils");
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import childProcess from "child_process";
4
+ import { Command } from "commander";
5
+ import inquirer from "inquirer";
6
+ import { getProjectsService, getSitesService } from "../services.js";
7
+ import { pullResources } from "./pull.js";
8
+ import ID from "../id.js";
9
+ import { localConfig, globalConfig } from "../config.js";
10
+ import { questionsCreateFunction, questionsCreateFunctionSelectTemplate, questionsCreateSite, questionsCreateBucket, questionsCreateMessagingTopic, questionsCreateCollection, questionsCreateTable, questionsInitProject, questionsInitProjectAutopull, questionsInitResources, questionsCreateTeam, } from "../questions.js";
11
+ import { cliConfig, success, log, hint, error, actionRunner, commandDescriptions, } from "../parser.js";
12
+ import { sdkForConsole } from "../sdks.js";
13
+ import { isCloud } from "../utils.js";
14
+ import { Account } from "@appwrite.io/console";
15
+ import { DEFAULT_ENDPOINT, EXECUTABLE_NAME } from "../constants.js";
22
16
  const initResources = async () => {
23
17
  const actions = {
24
18
  function: initFunction,
@@ -27,50 +21,53 @@ const initResources = async () => {
27
21
  bucket: initBucket,
28
22
  team: initTeam,
29
23
  message: initTopic,
30
- collection: initCollection
24
+ collection: initCollection,
31
25
  };
32
- const answers = await inquirer_1.default.prompt(questions_1.questionsInitResources[0]);
26
+ const answers = await inquirer.prompt([questionsInitResources[0]]);
33
27
  const action = actions[answers.resource];
34
28
  if (action !== undefined) {
35
29
  await action({ returnOnZero: true });
36
30
  }
37
31
  };
38
- const initProject = async ({ organizationId, projectId, projectName } = {}) => {
32
+ const initProject = async ({ organizationId, projectId, projectName, } = {}) => {
39
33
  let response = {};
40
34
  try {
41
- if (config_1.globalConfig.getEndpoint() === '' || config_1.globalConfig.getCookie() === '') {
42
- throw '';
35
+ if (globalConfig.getEndpoint() === "" || globalConfig.getCookie() === "") {
36
+ throw new Error(`Missing endpoint or cookie configuration. Please run '${EXECUTABLE_NAME} login' first.`);
43
37
  }
44
- const client = await (0, sdks_1.sdkForConsole)();
45
- await (0, account_1.accountGet)({
46
- parseOutput: false,
47
- sdk: client
48
- });
38
+ const client = await sdkForConsole();
39
+ const accountClient = new Account(client);
40
+ await accountClient.get();
49
41
  }
50
42
  catch (e) {
51
- (0, parser_1.error)("Error Session not found. Please run 'appwrite login' to create a session");
43
+ error(`Error Session not found. Please run '${EXECUTABLE_NAME} login' to create a session`);
52
44
  process.exit(1);
53
45
  }
54
46
  let answers = {};
55
47
  if (!organizationId && !projectId && !projectName) {
56
- answers = await inquirer_1.default.prompt(questions_1.questionsInitProject);
48
+ answers = await inquirer.prompt(questionsInitProject);
57
49
  if (answers.override === false) {
58
50
  process.exit(1);
59
51
  }
60
52
  }
61
53
  else {
62
- answers.start = 'existing';
54
+ answers.start = "existing";
63
55
  answers.project = {};
64
56
  answers.organization = {};
65
- answers.organization = organizationId ?? (await inquirer_1.default.prompt(questions_1.questionsInitProject[2])).organization;
66
- answers.project.name = projectName ?? (await inquirer_1.default.prompt(questions_1.questionsInitProject[3])).project;
67
- answers.project = projectId ?? (await inquirer_1.default.prompt(questions_1.questionsInitProject[4])).id;
57
+ answers.organization =
58
+ organizationId ??
59
+ (await inquirer.prompt([questionsInitProject[2]])).organization;
60
+ answers.project.name =
61
+ projectName ?? (await inquirer.prompt([questionsInitProject[3]])).project;
62
+ answers.project =
63
+ projectId ?? (await inquirer.prompt([questionsInitProject[4]])).id;
68
64
  try {
69
- await (0, projects_1.projectsGet)({ projectId, parseOutput: false });
65
+ const projectsService = await getProjectsService();
66
+ await projectsService.get(projectId);
70
67
  }
71
68
  catch (e) {
72
69
  if (e.code === 404) {
73
- answers.start = 'new';
70
+ answers.start = "new";
74
71
  answers.id = answers.project;
75
72
  answers.project = answers.project.name;
76
73
  }
@@ -79,137 +76,133 @@ const initProject = async ({ organizationId, projectId, projectName } = {}) => {
79
76
  }
80
77
  }
81
78
  }
82
- config_1.localConfig.clear(); // Clear the config to avoid any conflicts
83
- const url = new URL("https://cloud.appwrite.io/v1");
84
- if (answers.start === 'new') {
85
- response = await (0, projects_1.projectsCreate)({
86
- projectId: answers.id,
87
- name: answers.project,
88
- teamId: answers.organization,
89
- parseOutput: false
90
- });
91
- config_1.localConfig.setProject(response['$id']);
79
+ localConfig.clear(); // Clear the config to avoid any conflicts
80
+ const url = new URL(DEFAULT_ENDPOINT);
81
+ if (answers.start === "new") {
82
+ const projectsService = await getProjectsService();
83
+ response = await projectsService.create(answers.id, answers.project, answers.organization, answers.region);
84
+ localConfig.setProject(response["$id"]);
92
85
  if (answers.region) {
93
- config_1.localConfig.setEndpoint(`https://${answers.region}.${url.host}${url.pathname}`);
86
+ localConfig.setEndpoint(`https://${answers.region}.${url.host}${url.pathname}`);
94
87
  }
95
88
  }
96
89
  else {
97
- config_1.localConfig.setProject(answers.project["$id"]);
98
- if ((0, utils_1.isCloud)()) {
99
- config_1.localConfig.setEndpoint(`https://${answers.project["region"]}.${url.host}${url.pathname}`);
90
+ localConfig.setProject(answers.project["$id"]);
91
+ if (isCloud()) {
92
+ localConfig.setEndpoint(`https://${answers.project["region"]}.${url.host}${url.pathname}`);
100
93
  }
101
94
  }
102
- (0, parser_1.success)(`Project successfully ${answers.start === 'existing' ? 'linked' : 'created'}. Details are now stored in appwrite.config.json file.`);
103
- if (answers.start === 'existing') {
104
- answers = await inquirer_1.default.prompt(questions_1.questionsInitProjectAutopull);
95
+ success(`Project successfully ${answers.start === "existing" ? "linked" : "created"}. Details are now stored in appwrite.config.json file.`);
96
+ if (answers.start === "existing") {
97
+ answers = await inquirer.prompt(questionsInitProjectAutopull);
105
98
  if (answers.autopull) {
106
- parser_1.cliConfig.all = true;
107
- parser_1.cliConfig.force = true;
108
- await (0, pull_1.pullResources)({
109
- skipDeprecated: true
99
+ cliConfig.all = true;
100
+ cliConfig.force = true;
101
+ await pullResources({
102
+ skipDeprecated: true,
110
103
  });
111
104
  }
112
105
  else {
113
- (0, parser_1.log)("You can run 'appwrite pull all' to synchronize all of your existing resources.");
106
+ log(`You can run '${EXECUTABLE_NAME} pull all' to synchronize all of your existing resources.`);
114
107
  }
115
108
  }
116
- (0, parser_1.hint)("Next you can use 'appwrite init' to create resources in your project, or use 'appwrite pull' and 'appwrite push' to synchronize your project.");
109
+ hint(`Next you can use '${EXECUTABLE_NAME} init' to create resources in your project, or use '${EXECUTABLE_NAME} pull' and '${EXECUTABLE_NAME} push' to synchronize your project.`);
117
110
  };
118
111
  const initBucket = async () => {
119
- const answers = await inquirer_1.default.prompt(questions_1.questionsCreateBucket);
120
- config_1.localConfig.addBucket({
121
- $id: answers.id === 'unique()' ? id_1.default.unique() : answers.id,
112
+ const answers = await inquirer.prompt(questionsCreateBucket);
113
+ localConfig.addBucket({
114
+ $id: answers.id === "unique()" ? ID.unique() : answers.id,
122
115
  name: answers.bucket,
123
- fileSecurity: answers.fileSecurity.toLowerCase() === 'yes',
116
+ fileSecurity: answers.fileSecurity.toLowerCase() === "yes",
124
117
  enabled: true,
125
118
  });
126
- (0, parser_1.success)("Initialing bucket");
127
- (0, parser_1.log)("Next you can use 'appwrite push bucket' to deploy the changes.");
119
+ success("Initialing bucket");
120
+ log(`Next you can use '${EXECUTABLE_NAME} push bucket' to deploy the changes.`);
128
121
  };
129
122
  const initTeam = async () => {
130
- const answers = await inquirer_1.default.prompt(questions_1.questionsCreateTeam);
131
- config_1.localConfig.addTeam({
132
- $id: answers.id === 'unique()' ? id_1.default.unique() : answers.id,
133
- name: answers.bucket,
123
+ const answers = await inquirer.prompt(questionsCreateTeam);
124
+ localConfig.addTeam({
125
+ $id: answers.id === "unique()" ? ID.unique() : answers.id,
126
+ name: answers.team,
134
127
  });
135
- (0, parser_1.success)("Initialing team");
136
- (0, parser_1.log)("Next you can use 'appwrite push team' to deploy the changes.");
128
+ success("Initialing team");
129
+ log(`Next you can use '${EXECUTABLE_NAME} push team' to deploy the changes.`);
137
130
  };
138
131
  const initTable = async () => {
139
- const answers = await inquirer_1.default.prompt(questions_1.questionsCreateTable);
140
- const newDatabase = (answers.method ?? '').toLowerCase() !== 'existing';
132
+ const answers = await inquirer.prompt(questionsCreateTable);
133
+ const newDatabase = (answers.method ?? "").toLowerCase() !== "existing";
141
134
  if (!newDatabase) {
142
135
  answers.databaseId = answers.database;
143
- answers.databaseName = config_1.localConfig.getTablesDB(answers.database).name;
136
+ answers.databaseName = localConfig.getTablesDB(answers.database).name;
144
137
  }
145
- const databaseId = answers.databaseId === 'unique()' ? id_1.default.unique() : answers.databaseId;
146
- if (newDatabase || !config_1.localConfig.getTablesDB(answers.databaseId)) {
147
- config_1.localConfig.addTablesDB({
138
+ const databaseId = answers.databaseId === "unique()" ? ID.unique() : answers.databaseId;
139
+ if (newDatabase || !localConfig.getTablesDB(answers.databaseId)) {
140
+ localConfig.addTablesDB({
148
141
  $id: databaseId,
149
142
  name: answers.databaseName,
150
- enabled: true
143
+ enabled: true,
151
144
  });
152
145
  }
153
- config_1.localConfig.addTable({
154
- $id: answers.id === 'unique()' ? id_1.default.unique() : answers.id,
146
+ localConfig.addTable({
147
+ $id: answers.id === "unique()" ? ID.unique() : answers.id,
155
148
  $permissions: [],
156
149
  databaseId: databaseId,
157
150
  name: answers.table,
158
151
  enabled: true,
159
- rowSecurity: answers.rowSecurity.toLowerCase() === 'yes',
152
+ rowSecurity: answers.rowSecurity.toLowerCase() === "yes",
160
153
  columns: [],
161
154
  indexes: [],
162
155
  });
163
- (0, parser_1.success)("Initialing table");
164
- (0, parser_1.log)("Next you can use 'appwrite push table' to deploy the changes.");
156
+ success("Initialing table");
157
+ log(`Next you can use '${EXECUTABLE_NAME} push table' to deploy the changes.`);
165
158
  };
166
159
  const initCollection = async () => {
167
- const answers = await inquirer_1.default.prompt(questions_1.questionsCreateCollection);
168
- const newDatabase = (answers.method ?? '').toLowerCase() !== 'existing';
160
+ const answers = await inquirer.prompt(questionsCreateCollection);
161
+ const newDatabase = (answers.method ?? "").toLowerCase() !== "existing";
169
162
  if (!newDatabase) {
170
163
  answers.databaseId = answers.database;
171
- answers.databaseName = config_1.localConfig.getDatabase(answers.database).name;
164
+ answers.databaseName = localConfig.getDatabase(answers.database).name;
172
165
  }
173
- const databaseId = answers.databaseId === 'unique()' ? id_1.default.unique() : answers.databaseId;
174
- if (newDatabase || !config_1.localConfig.getDatabase(answers.databaseId)) {
175
- config_1.localConfig.addDatabase({
166
+ const databaseId = answers.databaseId === "unique()" ? ID.unique() : answers.databaseId;
167
+ if (newDatabase || !localConfig.getDatabase(answers.databaseId)) {
168
+ localConfig.addDatabase({
176
169
  $id: databaseId,
177
170
  name: answers.databaseName,
178
- enabled: true
171
+ enabled: true,
179
172
  });
180
173
  }
181
- config_1.localConfig.addCollection({
182
- $id: answers.id === 'unique()' ? id_1.default.unique() : answers.id,
174
+ localConfig.addCollection({
175
+ $id: answers.id === "unique()" ? ID.unique() : answers.id,
183
176
  databaseId: databaseId,
184
177
  name: answers.collection,
185
- documentSecurity: answers.documentSecurity.toLowerCase() === 'yes',
178
+ documentSecurity: answers.documentSecurity.toLowerCase() === "yes",
186
179
  attributes: [],
187
180
  indexes: [],
188
181
  enabled: true,
189
182
  });
190
- (0, parser_1.success)("Initialing collection");
191
- (0, parser_1.log)("Next you can use 'appwrite push collection' to deploy the changes.");
183
+ success("Initialing collection");
184
+ log(`Next you can use '${EXECUTABLE_NAME} push collection' to deploy the changes.`);
192
185
  };
193
186
  const initTopic = async () => {
194
- const answers = await inquirer_1.default.prompt(questions_1.questionsCreateMessagingTopic);
195
- config_1.localConfig.addMessagingTopic({
196
- $id: answers.id === 'unique()' ? id_1.default.unique() : answers.id,
187
+ const answers = await inquirer.prompt(questionsCreateMessagingTopic);
188
+ localConfig.addMessagingTopic({
189
+ $id: answers.id === "unique()" ? ID.unique() : answers.id,
197
190
  name: answers.topic,
198
191
  });
199
- (0, parser_1.success)("Initialing topic");
200
- (0, parser_1.log)("Next you can use 'appwrite push topic' to deploy the changes.");
192
+ success("Initialing topic");
193
+ log(`Next you can use '${EXECUTABLE_NAME} push topic' to deploy the changes.`);
201
194
  };
202
195
  const initFunction = async () => {
203
- process.chdir(config_1.localConfig.configDirectoryPath);
196
+ process.chdir(localConfig.configDirectoryPath);
204
197
  // TODO: Add CI/CD support (ID, name, runtime)
205
- const answers = await inquirer_1.default.prompt(questions_1.questionsCreateFunction);
206
- const functionFolder = path.join(process.cwd(), 'functions');
198
+ const answers = await inquirer.prompt(questionsCreateFunction);
199
+ const functionFolder = path.join(process.cwd(), "functions");
207
200
  if (!fs.existsSync(functionFolder)) {
208
201
  fs.mkdirSync(functionFolder, {
209
- recursive: true
202
+ recursive: true,
210
203
  });
211
204
  }
212
- const functionId = answers.id === 'unique()' ? id_1.default.unique() : answers.id;
205
+ const functionId = answers.id === "unique()" ? ID.unique() : answers.id;
213
206
  const functionName = answers.name;
214
207
  const functionDir = path.join(functionFolder, functionName);
215
208
  const templatesDir = path.join(functionFolder, `${functionId}-templates`);
@@ -218,35 +211,44 @@ const initFunction = async () => {
218
211
  throw new Error(`( ${functionName} ) already exists in the current directory. Please choose another name.`);
219
212
  }
220
213
  if (!answers.runtime.entrypoint) {
221
- (0, parser_1.log)(`Entrypoint for this runtime not found. You will be asked to configure entrypoint when you first push the function.`);
214
+ log(`Entrypoint for this runtime not found. You will be asked to configure entrypoint when you first push the function.`);
222
215
  }
223
216
  if (!answers.runtime.commands) {
224
- (0, parser_1.log)(`Installation command for this runtime not found. You will be asked to configure the install command when you first push the function.`);
217
+ log(`Installation command for this runtime not found. You will be asked to configure the install command when you first push the function.`);
225
218
  }
226
219
  fs.mkdirSync(functionDir, { mode: 0o777 });
227
220
  fs.mkdirSync(templatesDir, { mode: 0o777 });
228
221
  const repo = "https://github.com/appwrite/templates";
229
222
  const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`;
230
- let selected = { template: 'starter' };
231
- const sparse = (selected ? `${answers.runtime.name}/${selected.template}` : answers.runtime.name).toLowerCase();
223
+ let selected = { template: "starter" };
224
+ const sparse = (selected
225
+ ? `${answers.runtime.name}/${selected.template}`
226
+ : answers.runtime.name).toLowerCase();
232
227
  let gitInitCommands = `git clone --single-branch --depth 1 --sparse ${repo} .`; // depth prevents fetching older commits reducing the amount fetched
233
228
  let gitPullCommands = `git sparse-checkout add ${sparse}`;
234
229
  /* Force use CMD as powershell does not support && */
235
- if (process.platform === 'win32') {
230
+ if (process.platform === "win32") {
236
231
  gitInitCommands = 'cmd /c "' + gitInitCommands + '"';
237
232
  gitPullCommands = 'cmd /c "' + gitPullCommands + '"';
238
233
  }
239
234
  /* Execute the child process but do not print any std output */
240
235
  try {
241
- childProcess.execSync(gitInitCommands, { stdio: 'pipe', cwd: templatesDir });
242
- childProcess.execSync(gitPullCommands, { stdio: 'pipe', cwd: templatesDir });
236
+ childProcess.execSync(gitInitCommands, {
237
+ stdio: "pipe",
238
+ cwd: templatesDir,
239
+ });
240
+ childProcess.execSync(gitPullCommands, {
241
+ stdio: "pipe",
242
+ cwd: templatesDir,
243
+ });
243
244
  }
244
245
  catch (err) {
245
246
  /* Specialised errors with recommended actions to take */
246
- if (err.message.includes('error: unknown option')) {
247
+ if (err.message.includes("error: unknown option")) {
247
248
  throw new Error(`${err.message} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`);
248
249
  }
249
- else if (err.message.includes('is not recognized as an internal or external command,') || err.message.includes('command not found')) {
250
+ else if (err.message.includes("is not recognized as an internal or external command,") ||
251
+ err.message.includes("command not found")) {
250
252
  throw new Error(`${err.message} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`);
251
253
  }
252
254
  else {
@@ -256,12 +258,13 @@ const initFunction = async () => {
256
258
  fs.rmSync(path.join(templatesDir, ".git"), { recursive: true });
257
259
  if (!selected) {
258
260
  const templates = [];
259
- templates.push(...fs.readdirSync(runtimeDir, { withFileTypes: true })
260
- .filter(item => item.isDirectory() && item.name !== 'starter')
261
- .map(dirent => dirent.name));
262
- selected = { template: 'starter' };
261
+ templates.push(...fs
262
+ .readdirSync(runtimeDir, { withFileTypes: true })
263
+ .filter((item) => item.isDirectory() && item.name !== "starter")
264
+ .map((dirent) => dirent.name));
265
+ selected = { template: "starter" };
263
266
  if (templates.length > 1) {
264
- selected = await inquirer_1.default.prompt((0, questions_1.questionsCreateFunctionSelectTemplate)(templates));
267
+ selected = await inquirer.prompt(questionsCreateFunctionSelectTemplate(templates));
265
268
  }
266
269
  }
267
270
  const copyRecursiveSync = (src, dest) => {
@@ -282,12 +285,12 @@ const initFunction = async () => {
282
285
  };
283
286
  copyRecursiveSync(path.join(runtimeDir, selected.template), functionDir);
284
287
  fs.rmSync(templatesDir, { recursive: true, force: true });
285
- const readmePath = path.join(process.cwd(), 'functions', functionName, 'README.md');
288
+ const readmePath = path.join(process.cwd(), "functions", functionName, "README.md");
286
289
  const readmeFile = fs.readFileSync(readmePath).toString();
287
- const newReadmeFile = readmeFile.split('\n');
290
+ const newReadmeFile = readmeFile.split("\n");
288
291
  newReadmeFile[0] = `# ${answers.name}`;
289
292
  newReadmeFile.splice(1, 2);
290
- fs.writeFileSync(readmePath, newReadmeFile.join('\n'));
293
+ fs.writeFileSync(readmePath, newReadmeFile.join("\n"));
291
294
  let data = {
292
295
  $id: functionId,
293
296
  name: answers.name,
@@ -300,25 +303,25 @@ const initFunction = async () => {
300
303
  timeout: 15,
301
304
  enabled: true,
302
305
  logging: true,
303
- entrypoint: answers.runtime.entrypoint || '',
304
- commands: answers.runtime.commands || '',
306
+ entrypoint: answers.runtime.entrypoint || "",
307
+ commands: answers.runtime.commands || "",
305
308
  ignore: answers.runtime.ignore || null,
306
309
  path: `functions/${functionName}`,
307
310
  };
308
- config_1.localConfig.addFunction(data);
309
- (0, parser_1.success)("Initialing function");
310
- (0, parser_1.log)("Next you can use 'appwrite run function' to develop a function locally. To deploy the function, use 'appwrite push function'");
311
+ localConfig.addFunction(data);
312
+ success("Initialing function");
313
+ log(`Next you can use '${EXECUTABLE_NAME} run function' to develop a function locally. To deploy the function, use '${EXECUTABLE_NAME} push function'`);
311
314
  };
312
315
  const initSite = async () => {
313
- process.chdir(config_1.localConfig.configDirectoryPath);
314
- const answers = await inquirer_1.default.prompt(questions_1.questionsCreateSite);
315
- const siteFolder = path.join(process.cwd(), 'sites');
316
+ process.chdir(localConfig.configDirectoryPath);
317
+ const answers = await inquirer.prompt(questionsCreateSite);
318
+ const siteFolder = path.join(process.cwd(), "sites");
316
319
  if (!fs.existsSync(siteFolder)) {
317
320
  fs.mkdirSync(siteFolder, {
318
- recursive: true
321
+ recursive: true,
319
322
  });
320
323
  }
321
- const siteId = answers.id === 'unique()' ? id_1.default.unique() : answers.id;
324
+ const siteId = answers.id === "unique()" ? ID.unique() : answers.id;
322
325
  const siteName = answers.name;
323
326
  const siteDir = path.join(siteFolder, siteName);
324
327
  const templatesDir = path.join(siteFolder, `${siteId}-templates`);
@@ -327,12 +330,8 @@ const initSite = async () => {
327
330
  }
328
331
  let templateDetails;
329
332
  try {
330
- const response = await (0, sites_1.sitesListTemplates)({
331
- frameworks: [answers.framework.key],
332
- useCases: ['starter'],
333
- limit: 1,
334
- parseOutput: false
335
- });
333
+ const sitesService = await getSitesService();
334
+ const response = await sitesService.listTemplates([answers.framework.key], ["starter"], 1);
336
335
  if (response.total == 0) {
337
336
  throw new Error(`No starter template found for framework ${answers.framework.key}`);
338
337
  }
@@ -344,11 +343,15 @@ const initSite = async () => {
344
343
  fs.mkdirSync(siteDir, { mode: 0o777 });
345
344
  fs.mkdirSync(templatesDir, { mode: 0o777 });
346
345
  const repo = `https://github.com/${templateDetails.providerOwner}/${templateDetails.providerRepositoryId}`;
347
- let selected = { template: templateDetails.frameworks[0].providerRootDirectory };
348
- let gitCloneCommands = '';
349
- const sparse = selected.template.startsWith('./') ? selected.template.substring(2) : selected.template;
350
- (0, parser_1.log)('Fetching site code ...');
351
- if (selected.template === './') {
346
+ let selected = {
347
+ template: templateDetails.frameworks[0].providerRootDirectory,
348
+ };
349
+ let gitCloneCommands = "";
350
+ const sparse = selected.template.startsWith("./")
351
+ ? selected.template.substring(2)
352
+ : selected.template;
353
+ log("Fetching site code ...");
354
+ if (selected.template === "./") {
352
355
  gitCloneCommands = `
353
356
  mkdir -p .
354
357
  cd .
@@ -375,19 +378,23 @@ const initSite = async () => {
375
378
  `.trim();
376
379
  }
377
380
  /* Force use CMD as powershell does not support && */
378
- if (process.platform === 'win32') {
381
+ if (process.platform === "win32") {
379
382
  gitCloneCommands = 'cmd /c "' + gitCloneCommands + '"';
380
383
  }
381
384
  /* Execute the child process but do not print any std output */
382
385
  try {
383
- childProcess.execSync(gitCloneCommands, { stdio: 'pipe', cwd: templatesDir });
386
+ childProcess.execSync(gitCloneCommands, {
387
+ stdio: "pipe",
388
+ cwd: templatesDir,
389
+ });
384
390
  }
385
391
  catch (err) {
386
392
  /* Specialised errors with recommended actions to take */
387
- if (err.message.includes('error: unknown option')) {
393
+ if (err.message.includes("error: unknown option")) {
388
394
  throw new Error(`${err.message} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`);
389
395
  }
390
- else if (err.message.includes('is not recognized as an internal or external command,') || err.message.includes('command not found')) {
396
+ else if (err.message.includes("is not recognized as an internal or external command,") ||
397
+ err.message.includes("command not found")) {
391
398
  throw new Error(`${err.message} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`);
392
399
  }
393
400
  else {
@@ -411,20 +418,22 @@ const initSite = async () => {
411
418
  fs.copyFileSync(src, dest);
412
419
  }
413
420
  };
414
- copyRecursiveSync(selected.template === './' ? templatesDir : path.join(templatesDir, selected.template), siteDir);
421
+ copyRecursiveSync(selected.template === "./"
422
+ ? templatesDir
423
+ : path.join(templatesDir, selected.template), siteDir);
415
424
  fs.rmSync(templatesDir, { recursive: true, force: true });
416
- const readmePath = path.join(process.cwd(), 'sites', siteName, 'README.md');
425
+ const readmePath = path.join(process.cwd(), "sites", siteName, "README.md");
417
426
  const readmeFile = fs.readFileSync(readmePath).toString();
418
- const newReadmeFile = readmeFile.split('\n');
419
- newReadmeFile[0] = `# ${answers.key}`;
427
+ const newReadmeFile = readmeFile.split("\n");
428
+ newReadmeFile[0] = `# ${answers.name}`;
420
429
  newReadmeFile.splice(1, 2);
421
- fs.writeFileSync(readmePath, newReadmeFile.join('\n'));
430
+ fs.writeFileSync(readmePath, newReadmeFile.join("\n"));
422
431
  let vars = (templateDetails.variables ?? []).map((variable) => {
423
432
  let value = variable.value;
424
433
  const replacements = {
425
- '{apiEndpoint}': config_1.globalConfig.getEndpoint(),
426
- '{projectId}': config_1.localConfig.getProject().projectId,
427
- '{projectName}': config_1.localConfig.getProject().projectName,
434
+ "{apiEndpoint}": globalConfig.getEndpoint(),
435
+ "{projectId}": localConfig.getProject().projectId,
436
+ "{projectName}": localConfig.getProject().projectName,
428
437
  };
429
438
  for (const placeholder in replacements) {
430
439
  if (value?.includes(placeholder)) {
@@ -433,86 +442,86 @@ const initSite = async () => {
433
442
  }
434
443
  return {
435
444
  key: variable.name,
436
- value: value
445
+ value: value,
437
446
  };
438
447
  });
439
448
  let data = {
440
449
  $id: siteId,
441
450
  name: answers.name,
442
451
  framework: answers.framework.key,
443
- adapter: templateDetails.frameworks[0].adapter || '',
444
- buildRuntime: templateDetails.frameworks[0].buildRuntime || '',
445
- installCommand: templateDetails.frameworks[0].installCommand || '',
446
- buildCommand: templateDetails.frameworks[0].buildCommand || '',
447
- outputDirectory: templateDetails.frameworks[0].outputDirectory || '',
448
- fallbackFile: templateDetails.frameworks[0].fallbackFile || '',
452
+ adapter: templateDetails.frameworks[0].adapter || "",
453
+ buildRuntime: templateDetails.frameworks[0].buildRuntime || "",
454
+ installCommand: templateDetails.frameworks[0].installCommand || "",
455
+ buildCommand: templateDetails.frameworks[0].buildCommand || "",
456
+ outputDirectory: templateDetails.frameworks[0].outputDirectory || "",
457
+ fallbackFile: templateDetails.frameworks[0].fallbackFile || "",
449
458
  specification: answers.specification,
450
459
  enabled: true,
451
460
  timeout: 30,
452
461
  logging: true,
453
462
  ignore: answers.framework.ignore || null,
454
463
  path: `sites/${siteName}`,
455
- vars: vars
464
+ vars: vars,
456
465
  };
457
466
  if (!data.buildRuntime) {
458
- (0, parser_1.log)(`Build runtime for this framework not found. You will be asked to configure build runtime when you first push the site.`);
467
+ log(`Build runtime for this framework not found. You will be asked to configure build runtime when you first push the site.`);
459
468
  }
460
469
  if (!data.installCommand) {
461
- (0, parser_1.log)(`Installation command for this framework not found. You will be asked to configure the install command when you first push the site.`);
470
+ log(`Installation command for this framework not found. You will be asked to configure the install command when you first push the site.`);
462
471
  }
463
472
  if (!data.buildCommand) {
464
- (0, parser_1.log)(`Build command for this framework not found. You will be asked to configure the build command when you first push the site.`);
473
+ log(`Build command for this framework not found. You will be asked to configure the build command when you first push the site.`);
465
474
  }
466
475
  if (!data.outputDirectory) {
467
- (0, parser_1.log)(`Output directory for this framework not found. You will be asked to configure the output directory when you first push the site.`);
476
+ log(`Output directory for this framework not found. You will be asked to configure the output directory when you first push the site.`);
468
477
  }
469
- config_1.localConfig.addSite(data);
470
- (0, parser_1.success)("Initializing site");
471
- (0, parser_1.log)("Next you can use 'appwrite push site' to deploy the changes.");
478
+ localConfig.addSite(data);
479
+ success("Initializing site");
480
+ log(`Next you can use '${EXECUTABLE_NAME} push site' to deploy the changes.`);
472
481
  };
473
- exports.init = new commander_1.Command("init")
474
- .description(parser_1.commandDescriptions['init'])
475
- .action((0, parser_1.actionRunner)(initResources));
476
- exports.init
482
+ export const init = new Command("init")
483
+ .description(commandDescriptions["init"])
484
+ .action(actionRunner(initResources));
485
+ init
477
486
  .command("project")
478
487
  .description("Init a new Appwrite project")
479
488
  .option("--organization-id <organization-id>", "Appwrite organization ID")
480
489
  .option("--project-id <project-id>", "Appwrite project ID")
481
490
  .option("--project-name <project-name>", "Appwrite project ID")
482
- .action((0, parser_1.actionRunner)(initProject));
483
- exports.init
491
+ .action(actionRunner(initProject));
492
+ init
484
493
  .command("function")
485
494
  .alias("functions")
486
495
  .description("Init a new Appwrite function")
487
- .action((0, parser_1.actionRunner)(initFunction));
488
- exports.init
496
+ .action(actionRunner(initFunction));
497
+ init
489
498
  .command("site")
490
499
  .alias("sites")
491
500
  .description("Init a new Appwrite site")
492
- .action((0, parser_1.actionRunner)(initSite));
493
- exports.init
501
+ .action(actionRunner(initSite));
502
+ init
494
503
  .command("bucket")
495
504
  .alias("buckets")
496
505
  .description("Init a new Appwrite bucket")
497
- .action((0, parser_1.actionRunner)(initBucket));
498
- exports.init
506
+ .action(actionRunner(initBucket));
507
+ init
499
508
  .command("team")
500
509
  .alias("teams")
501
510
  .description("Init a new Appwrite team")
502
- .action((0, parser_1.actionRunner)(initTeam));
503
- exports.init
511
+ .action(actionRunner(initTeam));
512
+ init
504
513
  .command("collection")
505
514
  .alias("collections")
506
515
  .description("Init a new Appwrite collection")
507
- .action((0, parser_1.actionRunner)(initCollection));
508
- exports.init
516
+ .action(actionRunner(initCollection));
517
+ init
509
518
  .command("table")
510
519
  .alias("tables")
511
520
  .description("Init a new Appwrite table")
512
- .action((0, parser_1.actionRunner)(initTable));
513
- exports.init
521
+ .action(actionRunner(initTable));
522
+ init
514
523
  .command("topic")
515
524
  .alias("topics")
516
525
  .description("Init a new Appwrite topic")
517
- .action((0, parser_1.actionRunner)(initTopic));
526
+ .action(actionRunner(initTopic));
518
527
  //# sourceMappingURL=init.js.map