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.
- package/.github/workflows/publish.yml +68 -0
- package/CHANGELOG.md +10 -1
- package/LICENSE.md +1 -1
- package/README.md +3 -3
- package/cli.ts +152 -0
- package/dist/bundle.cjs +95813 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +145 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -142
- package/dist/index.js.map +1 -1
- package/dist/lib/client.d.ts +2 -3
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +57 -45
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/commands/config.d.ts +562 -0
- package/dist/lib/commands/config.d.ts.map +1 -0
- package/dist/lib/commands/config.js +416 -0
- package/dist/lib/commands/config.js.map +1 -0
- package/dist/lib/commands/db.d.ts +34 -0
- package/dist/lib/commands/db.d.ts.map +1 -0
- package/dist/lib/commands/db.js +247 -0
- package/dist/lib/commands/db.js.map +1 -0
- package/dist/lib/commands/errors.d.ts +68 -0
- package/dist/lib/commands/errors.d.ts.map +1 -0
- package/dist/lib/commands/errors.js +72 -0
- package/dist/lib/commands/errors.js.map +1 -0
- package/dist/lib/commands/generic.d.ts +2 -2
- package/dist/lib/commands/generic.d.ts.map +1 -1
- package/dist/lib/commands/generic.js +170 -157
- package/dist/lib/commands/generic.js.map +1 -1
- package/dist/lib/commands/init.d.ts +1 -1
- package/dist/lib/commands/init.d.ts.map +1 -1
- package/dist/lib/commands/init.js +201 -192
- package/dist/lib/commands/init.js.map +1 -1
- package/dist/lib/commands/pull.d.ts +105 -3
- package/dist/lib/commands/pull.d.ts.map +1 -1
- package/dist/lib/commands/pull.js +530 -370
- package/dist/lib/commands/pull.js.map +1 -1
- package/dist/lib/commands/push.d.ts +106 -0
- package/dist/lib/commands/push.d.ts.map +1 -1
- package/dist/lib/commands/push.js +1432 -1830
- package/dist/lib/commands/push.js.map +1 -1
- package/dist/lib/commands/run.d.ts +1 -1
- package/dist/lib/commands/run.d.ts.map +1 -1
- package/dist/lib/commands/run.js +129 -127
- package/dist/lib/commands/run.js.map +1 -1
- package/dist/lib/commands/schema.d.ts +59 -0
- package/dist/lib/commands/schema.d.ts.map +1 -0
- package/dist/lib/commands/schema.js +86 -0
- package/dist/lib/commands/schema.js.map +1 -0
- package/dist/lib/commands/services/account.d.ts +3 -0
- package/dist/lib/commands/services/account.d.ts.map +1 -0
- package/dist/lib/commands/services/account.js +328 -0
- package/dist/lib/commands/services/account.js.map +1 -0
- package/dist/lib/commands/services/console.d.ts +3 -0
- package/dist/lib/commands/services/console.d.ts.map +1 -0
- package/dist/lib/commands/services/console.js +28 -0
- package/dist/lib/commands/services/console.js.map +1 -0
- package/dist/lib/commands/services/databases.d.ts +3 -0
- package/dist/lib/commands/services/databases.d.ts.map +1 -0
- package/dist/lib/commands/services/databases.js +620 -0
- package/dist/lib/commands/services/databases.js.map +1 -0
- package/dist/lib/commands/services/functions.d.ts +3 -0
- package/dist/lib/commands/services/functions.d.ts.map +1 -0
- package/dist/lib/commands/services/functions.js +266 -0
- package/dist/lib/commands/services/functions.js.map +1 -0
- package/dist/lib/commands/services/graphql.d.ts +3 -0
- package/dist/lib/commands/services/graphql.d.ts.map +1 -0
- package/dist/lib/commands/services/graphql.js +28 -0
- package/dist/lib/commands/services/graphql.js.map +1 -0
- package/dist/lib/commands/services/health.d.ts +3 -0
- package/dist/lib/commands/services/health.d.ts.map +1 -0
- package/dist/lib/commands/services/health.js +123 -0
- package/dist/lib/commands/services/health.js.map +1 -0
- package/dist/lib/commands/services/locale.d.ts +3 -0
- package/dist/lib/commands/services/locale.d.ts.map +1 -0
- package/dist/lib/commands/services/locale.js +52 -0
- package/dist/lib/commands/services/locale.js.map +1 -0
- package/dist/lib/commands/services/messaging.d.ts +3 -0
- package/dist/lib/commands/services/messaging.d.ts.map +1 -0
- package/dist/lib/commands/services/messaging.js +505 -0
- package/dist/lib/commands/services/messaging.js.map +1 -0
- package/dist/lib/commands/services/migrations.d.ts +3 -0
- package/dist/lib/commands/services/migrations.d.ts.map +1 -0
- package/dist/lib/commands/services/migrations.js +135 -0
- package/dist/lib/commands/services/migrations.js.map +1 -0
- package/dist/lib/commands/services/project.d.ts +3 -0
- package/dist/lib/commands/services/project.d.ts.map +1 -0
- package/dist/lib/commands/services/project.js +54 -0
- package/dist/lib/commands/services/project.js.map +1 -0
- package/dist/lib/commands/services/projects.d.ts +3 -0
- package/dist/lib/commands/services/projects.d.ts.map +1 -0
- package/dist/lib/commands/services/projects.js +415 -0
- package/dist/lib/commands/services/projects.js.map +1 -0
- package/dist/lib/commands/services/proxy.d.ts +3 -0
- package/dist/lib/commands/services/proxy.d.ts.map +1 -0
- package/dist/lib/commands/services/proxy.js +68 -0
- package/dist/lib/commands/services/proxy.js.map +1 -0
- package/dist/lib/commands/services/sites.d.ts +3 -0
- package/dist/lib/commands/services/sites.d.ts.map +1 -0
- package/dist/lib/commands/services/sites.js +250 -0
- package/dist/lib/commands/services/sites.js.map +1 -0
- package/dist/lib/commands/services/storage.d.ts +3 -0
- package/dist/lib/commands/services/storage.d.ts.map +1 -0
- package/dist/lib/commands/services/storage.js +175 -0
- package/dist/lib/commands/services/storage.js.map +1 -0
- package/dist/lib/commands/services/tables-db.d.ts +3 -0
- package/dist/lib/commands/services/tables-db.d.ts.map +1 -0
- package/dist/lib/commands/services/tables-db.js +613 -0
- package/dist/lib/commands/services/tables-db.js.map +1 -0
- package/dist/lib/commands/services/teams.d.ts +3 -0
- package/dist/lib/commands/services/teams.d.ts.map +1 -0
- package/dist/lib/commands/services/teams.js +123 -0
- package/dist/lib/commands/services/teams.js.map +1 -0
- package/dist/lib/commands/services/tokens.d.ts +3 -0
- package/dist/lib/commands/services/tokens.d.ts.map +1 -0
- package/dist/lib/commands/services/tokens.js +49 -0
- package/dist/lib/commands/services/tokens.js.map +1 -0
- package/dist/lib/commands/services/users.d.ts +3 -0
- package/dist/lib/commands/services/users.d.ts.map +1 -0
- package/dist/lib/commands/services/users.js +312 -0
- package/dist/lib/commands/services/users.js.map +1 -0
- package/dist/lib/commands/services/vcs.d.ts +3 -0
- package/dist/lib/commands/services/vcs.d.ts.map +1 -0
- package/dist/lib/commands/services/vcs.js +87 -0
- package/dist/lib/commands/services/vcs.js.map +1 -0
- package/dist/lib/commands/types.d.ts +1 -1
- package/dist/lib/commands/types.d.ts.map +1 -1
- package/dist/lib/commands/types.js +53 -57
- package/dist/lib/commands/types.js.map +1 -1
- package/dist/lib/commands/update.d.ts +1 -1
- package/dist/lib/commands/update.d.ts.map +1 -1
- package/dist/lib/commands/update.js +69 -69
- package/dist/lib/commands/update.js.map +1 -1
- package/dist/lib/commands/utils/attributes.d.ts +47 -0
- package/dist/lib/commands/utils/attributes.d.ts.map +1 -0
- package/dist/lib/commands/utils/attributes.js +514 -0
- package/dist/lib/commands/utils/attributes.js.map +1 -0
- package/dist/lib/commands/utils/change-approval.d.ts +25 -0
- package/dist/lib/commands/utils/change-approval.d.ts.map +1 -0
- package/dist/lib/commands/utils/change-approval.js +129 -0
- package/dist/lib/commands/utils/change-approval.js.map +1 -0
- package/dist/lib/commands/utils/database-sync.d.ts +10 -0
- package/dist/lib/commands/utils/database-sync.d.ts.map +1 -0
- package/dist/lib/commands/utils/database-sync.js +136 -0
- package/dist/lib/commands/utils/database-sync.js.map +1 -0
- package/dist/lib/commands/utils/deployment.d.ts +34 -0
- package/dist/lib/commands/utils/deployment.d.ts.map +1 -0
- package/dist/lib/commands/utils/deployment.js +109 -0
- package/dist/lib/commands/utils/deployment.js.map +1 -0
- package/dist/lib/commands/utils/error-formatter.d.ts +19 -0
- package/dist/lib/commands/utils/error-formatter.d.ts.map +1 -0
- package/dist/lib/commands/utils/error-formatter.js +333 -0
- package/dist/lib/commands/utils/error-formatter.js.map +1 -0
- package/dist/lib/commands/utils/pools.d.ts +16 -0
- package/dist/lib/commands/utils/pools.d.ts.map +1 -0
- package/dist/lib/commands/utils/pools.js +198 -0
- package/dist/lib/commands/utils/pools.js.map +1 -0
- package/dist/lib/config.d.ts +41 -40
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +264 -239
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/constants.d.ts +14 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +19 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/emulation/docker.d.ts +4 -12
- package/dist/lib/emulation/docker.d.ts.map +1 -1
- package/dist/lib/emulation/docker.js +159 -142
- package/dist/lib/emulation/docker.js.map +1 -1
- package/dist/lib/emulation/utils.d.ts +1 -1
- package/dist/lib/emulation/utils.d.ts.map +1 -1
- package/dist/lib/emulation/utils.js +55 -58
- package/dist/lib/emulation/utils.js.map +1 -1
- package/dist/lib/id.d.ts +1 -1
- package/dist/lib/id.d.ts.map +1 -1
- package/dist/lib/id.js +13 -18
- package/dist/lib/id.js.map +1 -1
- package/dist/lib/paginate.d.ts +3 -4
- package/dist/lib/paginate.d.ts.map +1 -1
- package/dist/lib/paginate.js +7 -10
- package/dist/lib/paginate.js.map +1 -1
- package/dist/lib/parser.d.ts +1 -1
- package/dist/lib/parser.d.ts.map +1 -1
- package/dist/lib/parser.js +92 -103
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/questions.d.ts +1 -1
- package/dist/lib/questions.d.ts.map +1 -1
- package/dist/lib/questions.js +381 -385
- package/dist/lib/questions.js.map +1 -1
- package/dist/lib/sdks.d.ts +1 -1
- package/dist/lib/sdks.d.ts.map +1 -1
- package/dist/lib/sdks.js +39 -30
- package/dist/lib/sdks.js.map +1 -1
- package/dist/lib/services.d.ts +13 -0
- package/dist/lib/services.d.ts.map +1 -0
- package/dist/lib/services.js +47 -0
- package/dist/lib/services.js.map +1 -0
- package/dist/lib/spinner.d.ts +1 -1
- package/dist/lib/spinner.d.ts.map +1 -1
- package/dist/lib/spinner.js +25 -27
- package/dist/lib/spinner.js.map +1 -1
- package/dist/lib/type-generation/attribute.d.ts +1 -1
- package/dist/lib/type-generation/attribute.d.ts.map +1 -1
- package/dist/lib/type-generation/attribute.js +14 -17
- package/dist/lib/type-generation/attribute.js.map +1 -1
- package/dist/lib/type-generation/languages/csharp.d.ts +1 -1
- package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/csharp.js +34 -34
- package/dist/lib/type-generation/languages/csharp.js.map +1 -1
- package/dist/lib/type-generation/languages/dart.d.ts +1 -1
- package/dist/lib/type-generation/languages/dart.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/dart.js +57 -57
- package/dist/lib/type-generation/languages/dart.js.map +1 -1
- package/dist/lib/type-generation/languages/java.d.ts +1 -1
- package/dist/lib/type-generation/languages/java.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/java.js +35 -35
- package/dist/lib/type-generation/languages/java.js.map +1 -1
- package/dist/lib/type-generation/languages/javascript.d.ts +1 -1
- package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/javascript.js +45 -44
- package/dist/lib/type-generation/languages/javascript.js.map +1 -1
- package/dist/lib/type-generation/languages/kotlin.d.ts +1 -1
- package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/kotlin.js +35 -35
- package/dist/lib/type-generation/languages/kotlin.js.map +1 -1
- package/dist/lib/type-generation/languages/language.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/language.js +32 -37
- package/dist/lib/type-generation/languages/language.js.map +1 -1
- package/dist/lib/type-generation/languages/php.d.ts +1 -1
- package/dist/lib/type-generation/languages/php.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/php.js +34 -34
- package/dist/lib/type-generation/languages/php.js.map +1 -1
- package/dist/lib/type-generation/languages/swift.d.ts +1 -1
- package/dist/lib/type-generation/languages/swift.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/swift.js +35 -35
- package/dist/lib/type-generation/languages/swift.js.map +1 -1
- package/dist/lib/type-generation/languages/typescript.d.ts +1 -1
- package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/typescript.js +49 -46
- package/dist/lib/type-generation/languages/typescript.js.map +1 -1
- package/dist/lib/types.d.ts +38 -108
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +1 -2
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +142 -98
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/validations.d.ts.map +1 -1
- package/dist/lib/validations.js +2 -6
- package/dist/lib/validations.js.map +1 -1
- package/dist/package.json +68 -0
- package/index.ts +25 -149
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.ts +261 -220
- package/lib/commands/config.ts +494 -0
- package/lib/commands/db.ts +324 -0
- package/lib/commands/errors.ts +93 -0
- package/lib/commands/generic.ts +371 -269
- package/lib/commands/init.ts +631 -519
- package/lib/commands/pull.ts +827 -453
- package/lib/commands/push.ts +2191 -2349
- package/lib/commands/run.ts +382 -302
- package/lib/commands/schema.ts +122 -0
- package/lib/commands/services/account.ts +647 -0
- package/lib/commands/services/console.ts +52 -0
- package/lib/commands/services/databases.ts +1163 -0
- package/lib/commands/services/functions.ts +536 -0
- package/lib/commands/services/graphql.ts +50 -0
- package/lib/commands/services/health.ts +260 -0
- package/lib/commands/services/locale.ts +102 -0
- package/lib/commands/services/messaging.ts +1052 -0
- package/lib/commands/services/migrations.ts +249 -0
- package/lib/commands/services/project.ts +112 -0
- package/lib/commands/services/projects.ts +785 -0
- package/lib/commands/services/proxy.ts +135 -0
- package/lib/commands/services/sites.ts +505 -0
- package/lib/commands/services/storage.ts +338 -0
- package/lib/commands/services/tables-db.ts +1150 -0
- package/lib/commands/services/teams.ts +232 -0
- package/lib/commands/services/tokens.ts +94 -0
- package/lib/commands/services/users.ts +616 -0
- package/lib/commands/services/vcs.ts +165 -0
- package/lib/commands/types.ts +145 -118
- package/lib/commands/update.ts +189 -159
- package/lib/commands/utils/attributes.ts +719 -0
- package/lib/commands/utils/change-approval.ts +186 -0
- package/lib/commands/utils/database-sync.ts +180 -0
- package/lib/commands/utils/deployment.ts +184 -0
- package/lib/commands/utils/error-formatter.ts +417 -0
- package/lib/commands/utils/pools.ts +355 -0
- package/lib/config.ts +766 -687
- package/lib/constants.ts +22 -0
- package/lib/emulation/docker.ts +277 -216
- package/lib/emulation/utils.ts +188 -174
- package/lib/id.ts +23 -23
- package/lib/paginate.ts +69 -55
- package/lib/parser.ts +220 -189
- package/lib/questions.ts +1024 -948
- package/lib/sdks.ts +84 -51
- package/lib/services.ts +72 -0
- package/lib/spinner.ts +112 -99
- package/lib/type-generation/attribute.ts +15 -14
- package/lib/type-generation/languages/csharp.ts +71 -60
- package/lib/type-generation/languages/dart.ts +106 -93
- package/lib/type-generation/languages/java.ts +69 -58
- package/lib/type-generation/languages/javascript.ts +84 -73
- package/lib/type-generation/languages/kotlin.ts +71 -60
- package/lib/type-generation/languages/language.ts +103 -95
- package/lib/type-generation/languages/php.ts +67 -56
- package/lib/type-generation/languages/swift.ts +71 -60
- package/lib/type-generation/languages/typescript.ts +93 -76
- package/lib/types.ts +50 -125
- package/lib/utils.ts +304 -233
- package/lib/validations.ts +17 -14
- package/package.json +31 -22
- package/scoop/appwrite.config.json +3 -3
- package/tsconfig.json +7 -13
- package/.github/workflows/autoclose.yml +0 -11
- package/.github/workflows/npm-publish.yml +0 -49
- package/dist/lib/commands/account.d.ts +0 -379
- package/dist/lib/commands/account.d.ts.map +0 -1
- package/dist/lib/commands/account.js +0 -1228
- package/dist/lib/commands/account.js.map +0 -1
- package/dist/lib/commands/console.d.ts +0 -20
- package/dist/lib/commands/console.d.ts.map +0 -1
- package/dist/lib/commands/console.js +0 -78
- package/dist/lib/commands/console.js.map +0 -1
- package/dist/lib/commands/databases.d.ts +0 -732
- package/dist/lib/commands/databases.d.ts.map +0 -1
- package/dist/lib/commands/databases.js +0 -2196
- package/dist/lib/commands/databases.js.map +0 -1
- package/dist/lib/commands/functions.d.ts +0 -310
- package/dist/lib/commands/functions.d.ts.map +0 -1
- package/dist/lib/commands/functions.js +0 -1100
- package/dist/lib/commands/functions.js.map +0 -1
- package/dist/lib/commands/graphql.d.ts +0 -19
- package/dist/lib/commands/graphql.d.ts.map +0 -1
- package/dist/lib/commands/graphql.js +0 -77
- package/dist/lib/commands/graphql.js.map +0 -1
- package/dist/lib/commands/health.d.ts +0 -153
- package/dist/lib/commands/health.d.ts.map +0 -1
- package/dist/lib/commands/health.js +0 -464
- package/dist/lib/commands/health.js.map +0 -1
- package/dist/lib/commands/locale.d.ts +0 -53
- package/dist/lib/commands/locale.d.ts.map +0 -1
- package/dist/lib/commands/locale.js +0 -165
- package/dist/lib/commands/locale.js.map +0 -1
- package/dist/lib/commands/messaging.d.ts +0 -588
- package/dist/lib/commands/messaging.d.ts.map +0 -1
- package/dist/lib/commands/messaging.js +0 -2042
- package/dist/lib/commands/messaging.js.map +0 -1
- package/dist/lib/commands/migrations.d.ts +0 -150
- package/dist/lib/commands/migrations.d.ts.map +0 -1
- package/dist/lib/commands/migrations.js +0 -524
- package/dist/lib/commands/migrations.js.map +0 -1
- package/dist/lib/commands/organizations.d.ts +0 -11
- package/dist/lib/commands/organizations.d.ts.map +0 -1
- package/dist/lib/commands/organizations.js +0 -31
- package/dist/lib/commands/organizations.js.map +0 -1
- package/dist/lib/commands/project.d.ts +0 -53
- package/dist/lib/commands/project.d.ts.map +0 -1
- package/dist/lib/commands/project.js +0 -176
- package/dist/lib/commands/project.js.map +0 -1
- package/dist/lib/commands/projects.d.ts +0 -516
- package/dist/lib/commands/projects.d.ts.map +0 -1
- package/dist/lib/commands/projects.js +0 -1590
- package/dist/lib/commands/projects.js.map +0 -1
- package/dist/lib/commands/proxy.d.ts +0 -71
- package/dist/lib/commands/proxy.d.ts.map +0 -1
- package/dist/lib/commands/proxy.js +0 -240
- package/dist/lib/commands/proxy.js.map +0 -1
- package/dist/lib/commands/sites.d.ts +0 -296
- package/dist/lib/commands/sites.d.ts.map +0 -1
- package/dist/lib/commands/sites.js +0 -1046
- package/dist/lib/commands/sites.js.map +0 -1
- package/dist/lib/commands/storage.d.ts +0 -170
- package/dist/lib/commands/storage.d.ts.map +0 -1
- package/dist/lib/commands/storage.js +0 -651
- package/dist/lib/commands/storage.js.map +0 -1
- package/dist/lib/commands/tables-db.d.ts +0 -728
- package/dist/lib/commands/tables-db.d.ts.map +0 -1
- package/dist/lib/commands/tables-db.js +0 -2198
- package/dist/lib/commands/tables-db.js.map +0 -1
- package/dist/lib/commands/teams.d.ts +0 -129
- package/dist/lib/commands/teams.d.ts.map +0 -1
- package/dist/lib/commands/teams.js +0 -403
- package/dist/lib/commands/teams.js.map +0 -1
- package/dist/lib/commands/tokens.d.ts +0 -48
- package/dist/lib/commands/tokens.d.ts.map +0 -1
- package/dist/lib/commands/tokens.js +0 -156
- package/dist/lib/commands/tokens.js.map +0 -1
- package/dist/lib/commands/users.d.ts +0 -382
- package/dist/lib/commands/users.d.ts.map +0 -1
- package/dist/lib/commands/users.js +0 -1195
- package/dist/lib/commands/users.js.map +0 -1
- package/dist/lib/commands/vcs.d.ts +0 -92
- package/dist/lib/commands/vcs.d.ts.map +0 -1
- package/dist/lib/commands/vcs.js +0 -276
- package/dist/lib/commands/vcs.js.map +0 -1
- package/dist/lib/exception.d.ts +0 -8
- package/dist/lib/exception.d.ts.map +0 -1
- package/dist/lib/exception.js +0 -16
- package/dist/lib/exception.js.map +0 -1
- package/lib/commands/account.ts +0 -1867
- package/lib/commands/console.ts +0 -112
- package/lib/commands/databases.ts +0 -3272
- package/lib/commands/functions.ts +0 -1587
- package/lib/commands/graphql.ts +0 -110
- package/lib/commands/health.ts +0 -753
- package/lib/commands/locale.ts +0 -270
- package/lib/commands/messaging.ts +0 -2878
- package/lib/commands/migrations.ts +0 -754
- package/lib/commands/organizations.ts +0 -46
- package/lib/commands/project.ts +0 -266
- package/lib/commands/projects.ts +0 -2370
- package/lib/commands/proxy.ts +0 -357
- package/lib/commands/sites.ts +0 -1514
- package/lib/commands/storage.ts +0 -919
- package/lib/commands/tables-db.ts +0 -3260
- package/lib/commands/teams.ts +0 -609
- package/lib/commands/tokens.ts +0 -232
- package/lib/commands/users.ts +0 -1804
- package/lib/commands/vcs.ts +0 -428
- package/lib/exception.ts +0 -20
package/lib/commands/pull.ts
CHANGED
|
@@ -1,557 +1,931 @@
|
|
|
1
|
-
import fs
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Command } from
|
|
5
|
-
import inquirer from
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import inquirer from "inquirer";
|
|
6
|
+
import {
|
|
7
|
+
Databases,
|
|
8
|
+
Functions,
|
|
9
|
+
Messaging,
|
|
10
|
+
Projects,
|
|
11
|
+
Sites,
|
|
12
|
+
Storage,
|
|
13
|
+
TablesDB,
|
|
14
|
+
Teams,
|
|
15
|
+
Client,
|
|
16
|
+
Query,
|
|
17
|
+
Models,
|
|
18
|
+
} from "@appwrite.io/console";
|
|
19
|
+
import { getFunctionsService, getSitesService } from "../services.js";
|
|
20
|
+
import { sdkForProject, sdkForConsole } from "../sdks.js";
|
|
21
|
+
import { localConfig } from "../config.js";
|
|
22
|
+
import { paginate } from "../paginate.js";
|
|
23
|
+
import {
|
|
24
|
+
questionsPullFunctions,
|
|
25
|
+
questionsPullFunctionsCode,
|
|
26
|
+
questionsPullSites,
|
|
27
|
+
questionsPullSitesCode,
|
|
28
|
+
questionsPullResources,
|
|
29
|
+
} from "../questions.js";
|
|
30
|
+
import {
|
|
31
|
+
cliConfig,
|
|
32
|
+
success,
|
|
33
|
+
log,
|
|
34
|
+
warn,
|
|
35
|
+
error,
|
|
36
|
+
actionRunner,
|
|
37
|
+
commandDescriptions,
|
|
38
|
+
} from "../parser.js";
|
|
39
|
+
import type { ConfigType } from "./config.js";
|
|
40
|
+
import { createSettingsObject } from "../utils.js";
|
|
41
|
+
import { ProjectNotInitializedError } from "./errors.js";
|
|
42
|
+
import type { SettingsType, FunctionType, SiteType } from "./config.js";
|
|
43
|
+
import { downloadDeploymentCode } from "./utils/deployment.js";
|
|
44
|
+
|
|
45
|
+
export interface PullOptions {
|
|
46
|
+
all?: boolean;
|
|
47
|
+
settings?: boolean;
|
|
48
|
+
functions?: boolean;
|
|
49
|
+
sites?: boolean;
|
|
50
|
+
collections?: boolean;
|
|
51
|
+
tables?: boolean;
|
|
52
|
+
buckets?: boolean;
|
|
53
|
+
teams?: boolean;
|
|
54
|
+
topics?: boolean;
|
|
55
|
+
skipDeprecated?: boolean;
|
|
56
|
+
withVariables?: boolean;
|
|
57
|
+
noCode?: boolean;
|
|
21
58
|
}
|
|
22
59
|
|
|
23
60
|
interface PullFunctionsOptions {
|
|
24
|
-
|
|
25
|
-
|
|
61
|
+
code?: boolean;
|
|
62
|
+
withVariables?: boolean;
|
|
63
|
+
functionIds?: string[];
|
|
26
64
|
}
|
|
27
65
|
|
|
28
66
|
interface PullSitesOptions {
|
|
29
|
-
|
|
30
|
-
|
|
67
|
+
code?: boolean;
|
|
68
|
+
withVariables?: boolean;
|
|
69
|
+
siteIds?: string[];
|
|
31
70
|
}
|
|
32
71
|
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
teams: pullTeam,
|
|
44
|
-
messages: pullMessagingTopic
|
|
45
|
-
}
|
|
72
|
+
export interface PullSettingsResult {
|
|
73
|
+
projectName: string;
|
|
74
|
+
settings: SettingsType;
|
|
75
|
+
project: Models.Project;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function createPullInstance(): Promise<Pull> {
|
|
79
|
+
const projectClient = await sdkForProject();
|
|
80
|
+
const consoleClient = await sdkForConsole();
|
|
81
|
+
const pullInstance = new Pull(projectClient, consoleClient);
|
|
46
82
|
|
|
47
|
-
|
|
48
|
-
|
|
83
|
+
pullInstance.setConfigDirectoryPath(localConfig.configDirectoryPath);
|
|
84
|
+
return pullInstance;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export class Pull {
|
|
88
|
+
private projectClient: Client;
|
|
89
|
+
private consoleClient: Client;
|
|
90
|
+
private configDirectoryPath: string;
|
|
91
|
+
private silent: boolean;
|
|
92
|
+
|
|
93
|
+
constructor(projectClient: Client, consoleClient: Client, silent = false) {
|
|
94
|
+
this.projectClient = projectClient;
|
|
95
|
+
this.consoleClient = consoleClient;
|
|
96
|
+
this.configDirectoryPath = process.cwd();
|
|
97
|
+
this.silent = silent;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Set the base directory path for config files and resources
|
|
102
|
+
*/
|
|
103
|
+
public setConfigDirectoryPath(path: string): void {
|
|
104
|
+
this.configDirectoryPath = path;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Log a message (respects silent mode)
|
|
109
|
+
*/
|
|
110
|
+
private log(message: string): void {
|
|
111
|
+
if (!this.silent) {
|
|
112
|
+
log(message);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Log a success message (respects silent mode)
|
|
118
|
+
*/
|
|
119
|
+
private success(message: string): void {
|
|
120
|
+
if (!this.silent) {
|
|
121
|
+
success(message);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Log a warning message (respects silent mode)
|
|
127
|
+
*/
|
|
128
|
+
private warn(message: string): void {
|
|
129
|
+
if (!this.silent) {
|
|
130
|
+
warn(message);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Pull resources from Appwrite project and return updated config
|
|
136
|
+
*
|
|
137
|
+
* @param config - Current configuration object
|
|
138
|
+
* @param options - Pull options specifying which resources to pull
|
|
139
|
+
* @returns Updated configuration object with pulled resources
|
|
140
|
+
*/
|
|
141
|
+
public async pullResources(
|
|
142
|
+
config: ConfigType,
|
|
143
|
+
options: PullOptions = { all: true, skipDeprecated: true },
|
|
144
|
+
): Promise<ConfigType> {
|
|
145
|
+
const { skipDeprecated = true } = options;
|
|
146
|
+
if (!config.projectId) {
|
|
147
|
+
throw new ProjectNotInitializedError();
|
|
49
148
|
}
|
|
50
149
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
cliConfig.all = true;
|
|
54
|
-
await action({ returnOnZero: true });
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
const answers = await inquirer.prompt(questionsPullResources[0]);
|
|
150
|
+
const updatedConfig: ConfigType = { ...config };
|
|
151
|
+
const shouldPullAll = options.all === true;
|
|
58
152
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
153
|
+
if (shouldPullAll || options.settings) {
|
|
154
|
+
const settings = await this.pullSettings(config.projectId);
|
|
155
|
+
updatedConfig.settings = settings.settings;
|
|
156
|
+
updatedConfig.projectName = settings.projectName;
|
|
63
157
|
}
|
|
64
|
-
};
|
|
65
158
|
|
|
66
|
-
|
|
67
|
-
|
|
159
|
+
if (shouldPullAll || options.functions) {
|
|
160
|
+
const functions = await this.pullFunctions({
|
|
161
|
+
code: options.noCode === true ? false : true,
|
|
162
|
+
withVariables: options.withVariables,
|
|
163
|
+
});
|
|
164
|
+
updatedConfig.functions = functions;
|
|
165
|
+
}
|
|
68
166
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
167
|
+
if (shouldPullAll || options.sites) {
|
|
168
|
+
const sites = await this.pullSites({
|
|
169
|
+
code: options.noCode === true ? false : true,
|
|
170
|
+
withVariables: options.withVariables,
|
|
171
|
+
});
|
|
172
|
+
updatedConfig.sites = sites;
|
|
173
|
+
}
|
|
74
174
|
|
|
75
|
-
|
|
175
|
+
if (shouldPullAll || options.tables) {
|
|
176
|
+
const { databases, tables } = await this.pullTables();
|
|
177
|
+
updatedConfig.databases = databases;
|
|
178
|
+
updatedConfig.tables = tables;
|
|
179
|
+
}
|
|
76
180
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
181
|
+
if (options.collections || (shouldPullAll && !skipDeprecated)) {
|
|
182
|
+
const { databases, collections } = await this.pullCollections();
|
|
183
|
+
updatedConfig.databases = databases;
|
|
184
|
+
updatedConfig.collections = collections;
|
|
80
185
|
}
|
|
81
|
-
}
|
|
82
186
|
|
|
83
|
-
|
|
84
|
-
|
|
187
|
+
if (shouldPullAll || options.buckets) {
|
|
188
|
+
const buckets = await this.pullBuckets();
|
|
189
|
+
updatedConfig.buckets = buckets;
|
|
190
|
+
}
|
|
85
191
|
|
|
86
|
-
|
|
87
|
-
|
|
192
|
+
if (shouldPullAll || options.teams) {
|
|
193
|
+
const teams = await this.pullTeams();
|
|
194
|
+
updatedConfig.teams = teams;
|
|
195
|
+
}
|
|
88
196
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
if (fetchResponse["functions"].length <= 0) {
|
|
94
|
-
log("No functions found.");
|
|
95
|
-
success(`Successfully pulled ${chalk.bold(total)} functions.`);
|
|
96
|
-
return;
|
|
197
|
+
if (shouldPullAll || options.topics) {
|
|
198
|
+
const topics = await this.pullMessagingTopics();
|
|
199
|
+
updatedConfig.topics = topics;
|
|
97
200
|
}
|
|
98
201
|
|
|
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
|
-
log("Source code download skipped because function doesn't have any available deployment");
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
log("Pulling latest deployment code ...");
|
|
163
|
-
|
|
164
|
-
const compressedFileName = `${func['$id']}-${+new Date()}.tar.gz`
|
|
165
|
-
await functionsGetDeploymentDownload({
|
|
166
|
-
functionId: func['$id'],
|
|
167
|
-
deploymentId,
|
|
168
|
-
destination: compressedFileName,
|
|
169
|
-
overrideForCli: true,
|
|
170
|
-
parseOutput: false
|
|
171
|
-
});
|
|
202
|
+
return updatedConfig;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Pull project settings
|
|
207
|
+
*/
|
|
208
|
+
public async pullSettings(projectId: string): Promise<PullSettingsResult> {
|
|
209
|
+
this.log("Pulling project settings ...");
|
|
210
|
+
|
|
211
|
+
const projectsService = new Projects(this.consoleClient);
|
|
212
|
+
const project = await projectsService.get({ projectId: projectId });
|
|
213
|
+
|
|
214
|
+
this.success(`Successfully pulled ${chalk.bold("all")} project settings.`);
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
projectName: project.name,
|
|
218
|
+
settings: createSettingsObject(project),
|
|
219
|
+
project,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Pull functions from the project
|
|
225
|
+
*/
|
|
226
|
+
public async pullFunctions(
|
|
227
|
+
options: PullFunctionsOptions = {},
|
|
228
|
+
): Promise<FunctionType[]> {
|
|
229
|
+
this.log("Fetching functions ...");
|
|
230
|
+
|
|
231
|
+
const functionsService = new Functions(this.projectClient);
|
|
232
|
+
let functions: Models.Function[];
|
|
233
|
+
|
|
234
|
+
if (options.functionIds && options.functionIds.length > 0) {
|
|
235
|
+
functions = await Promise.all(
|
|
236
|
+
options.functionIds.map((id) =>
|
|
237
|
+
functionsService.get({
|
|
238
|
+
functionId: id,
|
|
239
|
+
}),
|
|
240
|
+
),
|
|
241
|
+
);
|
|
242
|
+
} else {
|
|
243
|
+
const fetchResponse = await functionsService.list({
|
|
244
|
+
queries: [Query.limit(1)],
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
if (fetchResponse["functions"].length <= 0) {
|
|
248
|
+
this.log("No functions found.");
|
|
249
|
+
this.success(`Successfully pulled ${chalk.bold(0)} functions.`);
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const { functions: allFunctions } = await paginate(
|
|
254
|
+
async () => new Functions(this.projectClient).list(),
|
|
255
|
+
{},
|
|
256
|
+
100,
|
|
257
|
+
"functions",
|
|
258
|
+
);
|
|
259
|
+
functions = allFunctions;
|
|
260
|
+
}
|
|
172
261
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
262
|
+
const result: FunctionType[] = [];
|
|
263
|
+
|
|
264
|
+
for (const func of functions) {
|
|
265
|
+
this.log(`Pulling function ${chalk.bold(func.name)} ...`);
|
|
266
|
+
|
|
267
|
+
const funcPath = `functions/${func.name}`;
|
|
268
|
+
const absoluteFuncPath = path.resolve(this.configDirectoryPath, funcPath);
|
|
269
|
+
const holdingVars = func.vars || [];
|
|
270
|
+
|
|
271
|
+
const functionConfig: FunctionType = {
|
|
272
|
+
$id: func.$id,
|
|
273
|
+
name: func.name,
|
|
274
|
+
runtime: func.runtime,
|
|
275
|
+
path: funcPath,
|
|
276
|
+
entrypoint: func.entrypoint,
|
|
277
|
+
execute: func.execute,
|
|
278
|
+
enabled: func.enabled,
|
|
279
|
+
logging: func.logging,
|
|
280
|
+
events: func.events,
|
|
281
|
+
schedule: func.schedule,
|
|
282
|
+
timeout: func.timeout,
|
|
283
|
+
commands: func.commands,
|
|
284
|
+
scopes: func.scopes,
|
|
285
|
+
specification: func.specification,
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
result.push(functionConfig);
|
|
289
|
+
|
|
290
|
+
if (!fs.existsSync(absoluteFuncPath)) {
|
|
291
|
+
fs.mkdirSync(absoluteFuncPath, { recursive: true });
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (options.code !== false) {
|
|
295
|
+
await downloadDeploymentCode({
|
|
296
|
+
resourceId: func["$id"],
|
|
297
|
+
resourcePath: absoluteFuncPath,
|
|
298
|
+
holdingVars,
|
|
299
|
+
withVariables: options.withVariables,
|
|
300
|
+
listDeployments: () =>
|
|
301
|
+
functionsService.listDeployments({
|
|
302
|
+
functionId: func["$id"],
|
|
303
|
+
queries: [Query.limit(1), Query.orderDesc("$id")],
|
|
304
|
+
}),
|
|
305
|
+
getDownloadUrl: (deploymentId) =>
|
|
306
|
+
functionsService.getDeploymentDownload({
|
|
307
|
+
functionId: func["$id"],
|
|
308
|
+
deploymentId,
|
|
309
|
+
}),
|
|
310
|
+
projectClient: this.projectClient,
|
|
178
311
|
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
179
314
|
|
|
180
|
-
|
|
315
|
+
if (options.code === false) {
|
|
316
|
+
this.warn("Source code download skipped.");
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
this.success(`Successfully pulled ${chalk.bold(result.length)} functions.`);
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Pull sites from the project
|
|
325
|
+
*/
|
|
326
|
+
public async pullSites(options: PullSitesOptions = {}): Promise<SiteType[]> {
|
|
327
|
+
this.log("Fetching sites ...");
|
|
328
|
+
|
|
329
|
+
const sitesService = new Sites(this.projectClient);
|
|
330
|
+
let sites: Models.Site[];
|
|
331
|
+
|
|
332
|
+
if (options.siteIds && options.siteIds.length > 0) {
|
|
333
|
+
sites = await Promise.all(
|
|
334
|
+
options.siteIds.map((id) =>
|
|
335
|
+
sitesService.get({
|
|
336
|
+
siteId: id,
|
|
337
|
+
}),
|
|
338
|
+
),
|
|
339
|
+
);
|
|
340
|
+
} else {
|
|
341
|
+
const fetchResponse = await sitesService.list({
|
|
342
|
+
queries: [Query.limit(1)],
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
if (fetchResponse["sites"].length <= 0) {
|
|
346
|
+
this.log("No sites found.");
|
|
347
|
+
this.success(`Successfully pulled ${chalk.bold(0)} sites.`);
|
|
348
|
+
return [];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const { sites: fetchedSites } = await paginate(
|
|
352
|
+
async () => new Sites(this.projectClient).list(),
|
|
353
|
+
{},
|
|
354
|
+
100,
|
|
355
|
+
"sites",
|
|
356
|
+
);
|
|
357
|
+
sites = fetchedSites;
|
|
358
|
+
}
|
|
181
359
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
360
|
+
const result: SiteType[] = [];
|
|
361
|
+
|
|
362
|
+
for (const site of sites) {
|
|
363
|
+
this.log(`Pulling site ${chalk.bold(site.name)} ...`);
|
|
364
|
+
|
|
365
|
+
const sitePath = `sites/${site.name}`;
|
|
366
|
+
const absoluteSitePath = path.resolve(this.configDirectoryPath, sitePath);
|
|
367
|
+
const holdingVars = site.vars || [];
|
|
368
|
+
|
|
369
|
+
const siteConfig: SiteType = {
|
|
370
|
+
$id: site.$id,
|
|
371
|
+
name: site.name,
|
|
372
|
+
path: sitePath,
|
|
373
|
+
framework: site.framework,
|
|
374
|
+
enabled: site.enabled,
|
|
375
|
+
logging: site.logging,
|
|
376
|
+
timeout: site.timeout,
|
|
377
|
+
buildRuntime: site.buildRuntime,
|
|
378
|
+
adapter: site.adapter,
|
|
379
|
+
installCommand: site.installCommand,
|
|
380
|
+
buildCommand: site.buildCommand,
|
|
381
|
+
outputDirectory: site.outputDirectory,
|
|
382
|
+
fallbackFile: site.fallbackFile,
|
|
383
|
+
specification: site.specification,
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
result.push(siteConfig);
|
|
387
|
+
|
|
388
|
+
if (!fs.existsSync(absoluteSitePath)) {
|
|
389
|
+
fs.mkdirSync(absoluteSitePath, { recursive: true });
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (options.code !== false) {
|
|
393
|
+
await downloadDeploymentCode({
|
|
394
|
+
resourceId: site["$id"],
|
|
395
|
+
resourcePath: absoluteSitePath,
|
|
396
|
+
holdingVars,
|
|
397
|
+
withVariables: options.withVariables,
|
|
398
|
+
listDeployments: () =>
|
|
399
|
+
sitesService.listDeployments({
|
|
400
|
+
siteId: site["$id"],
|
|
401
|
+
queries: [Query.limit(1), Query.orderDesc("$id")],
|
|
402
|
+
}),
|
|
403
|
+
getDownloadUrl: (deploymentId) =>
|
|
404
|
+
sitesService.getDeploymentDownload({
|
|
405
|
+
siteId: site["$id"],
|
|
406
|
+
deploymentId,
|
|
407
|
+
}),
|
|
408
|
+
projectClient: this.projectClient,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
188
412
|
|
|
189
|
-
|
|
190
|
-
|
|
413
|
+
if (options.code === false) {
|
|
414
|
+
this.warn("Source code download skipped.");
|
|
191
415
|
}
|
|
192
416
|
|
|
193
|
-
success(`Successfully pulled ${chalk.bold(
|
|
194
|
-
|
|
417
|
+
this.success(`Successfully pulled ${chalk.bold(result.length)} sites.`);
|
|
418
|
+
return result;
|
|
419
|
+
}
|
|
195
420
|
|
|
196
|
-
|
|
197
|
-
|
|
421
|
+
/**
|
|
422
|
+
* Pull collections from the project (deprecated)
|
|
423
|
+
*/
|
|
424
|
+
public async pullCollections(): Promise<{
|
|
425
|
+
databases: any[];
|
|
426
|
+
collections: any[];
|
|
427
|
+
}> {
|
|
428
|
+
this.warn(
|
|
429
|
+
"appwrite pull collection has been deprecated. Please consider using 'appwrite pull tables' instead",
|
|
430
|
+
);
|
|
431
|
+
this.log("Fetching collections ...");
|
|
198
432
|
|
|
199
|
-
|
|
200
|
-
let total = 0;
|
|
433
|
+
const databasesService = new Databases(this.projectClient);
|
|
201
434
|
|
|
202
|
-
const fetchResponse = await
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
435
|
+
const fetchResponse = await databasesService.list([Query.limit(1)]);
|
|
436
|
+
|
|
437
|
+
if (fetchResponse["databases"].length <= 0) {
|
|
438
|
+
this.log("No collections found.");
|
|
439
|
+
this.success(
|
|
440
|
+
`Successfully pulled ${chalk.bold(0)} collections from ${chalk.bold(0)} databases.`,
|
|
441
|
+
);
|
|
442
|
+
return { databases: [], collections: [] };
|
|
210
443
|
}
|
|
211
444
|
|
|
212
|
-
const
|
|
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
|
-
if (allowCodePull === null) {
|
|
243
|
-
const codeAnswer = await inquirer.prompt(questionsPullSitesCode);
|
|
244
|
-
allowCodePull = codeAnswer.override;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (!allowCodePull) {
|
|
248
|
-
continue;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
let deploymentId: string | null = null;
|
|
252
|
-
|
|
253
|
-
try {
|
|
254
|
-
const fetchResponse = await sitesListDeployments({
|
|
255
|
-
siteId: site['$id'],
|
|
256
|
-
queries: [
|
|
257
|
-
JSON.stringify({ method: 'limit', values: [1] }),
|
|
258
|
-
JSON.stringify({ method: 'orderDesc', values: ['$id'] })
|
|
259
|
-
],
|
|
260
|
-
parseOutput: false
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
if (fetchResponse['total'] > 0) {
|
|
264
|
-
deploymentId = fetchResponse['deployments'][0]['$id'];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
} catch {
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if (deploymentId === null) {
|
|
271
|
-
log("Source code download skipped because site doesn't have any available deployment");
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
log("Pulling latest deployment code ...");
|
|
276
|
-
|
|
277
|
-
const compressedFileName = `${site['$id']}-${+new Date()}.tar.gz`
|
|
278
|
-
await sitesGetDeploymentDownload({
|
|
279
|
-
siteId: site['$id'],
|
|
280
|
-
deploymentId,
|
|
281
|
-
destination: compressedFileName,
|
|
282
|
-
overrideForCli: true,
|
|
283
|
-
parseOutput: false
|
|
445
|
+
const { databases } = await paginate(
|
|
446
|
+
async () => new Databases(this.projectClient).list(),
|
|
447
|
+
{},
|
|
448
|
+
100,
|
|
449
|
+
"databases",
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
const allDatabases: any[] = [];
|
|
453
|
+
const allCollections: any[] = [];
|
|
454
|
+
|
|
455
|
+
for (const database of databases) {
|
|
456
|
+
this.log(
|
|
457
|
+
`Pulling all collections from ${chalk.bold(database.name)} database ...`,
|
|
458
|
+
);
|
|
459
|
+
allDatabases.push(database);
|
|
460
|
+
|
|
461
|
+
const { collections } = await paginate(
|
|
462
|
+
async () =>
|
|
463
|
+
new Databases(this.projectClient).listCollections(database.$id),
|
|
464
|
+
{},
|
|
465
|
+
100,
|
|
466
|
+
"collections",
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
for (const collection of collections) {
|
|
470
|
+
allCollections.push({
|
|
471
|
+
...collection,
|
|
472
|
+
$createdAt: undefined,
|
|
473
|
+
$updatedAt: undefined,
|
|
284
474
|
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
this.success(
|
|
479
|
+
`Successfully pulled ${chalk.bold(allCollections.length)} collections from ${chalk.bold(allDatabases.length)} databases.`,
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
return {
|
|
483
|
+
databases: allDatabases,
|
|
484
|
+
collections: allCollections,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Pull tables from the project
|
|
490
|
+
*/
|
|
491
|
+
public async pullTables(): Promise<{
|
|
492
|
+
databases: any[];
|
|
493
|
+
tables: any[];
|
|
494
|
+
}> {
|
|
495
|
+
this.log("Fetching tables ...");
|
|
496
|
+
|
|
497
|
+
const tablesDBService = new TablesDB(this.projectClient);
|
|
498
|
+
|
|
499
|
+
const fetchResponse = await tablesDBService.list({
|
|
500
|
+
queries: [Query.limit(1)],
|
|
501
|
+
});
|
|
285
502
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
503
|
+
if (fetchResponse["databases"].length <= 0) {
|
|
504
|
+
this.log("No tables found.");
|
|
505
|
+
this.success(
|
|
506
|
+
`Successfully pulled ${chalk.bold(0)} tables from ${chalk.bold(0)} tableDBs.`,
|
|
507
|
+
);
|
|
508
|
+
return { databases: [], tables: [] };
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const { databases } = await paginate(
|
|
512
|
+
async () => new TablesDB(this.projectClient).list(),
|
|
513
|
+
{},
|
|
514
|
+
100,
|
|
515
|
+
"databases",
|
|
516
|
+
);
|
|
517
|
+
|
|
518
|
+
const allDatabases: any[] = [];
|
|
519
|
+
const allTables: any[] = [];
|
|
520
|
+
|
|
521
|
+
for (const database of databases) {
|
|
522
|
+
this.log(
|
|
523
|
+
`Pulling all tables from ${chalk.bold(database.name)} database ...`,
|
|
524
|
+
);
|
|
525
|
+
allDatabases.push(database);
|
|
526
|
+
|
|
527
|
+
const { tables } = await paginate(
|
|
528
|
+
async () => new TablesDB(this.projectClient).listTables(database.$id),
|
|
529
|
+
{},
|
|
530
|
+
100,
|
|
531
|
+
"tables",
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
for (const table of tables) {
|
|
535
|
+
allTables.push({
|
|
536
|
+
...table,
|
|
537
|
+
$createdAt: undefined,
|
|
538
|
+
$updatedAt: undefined,
|
|
291
539
|
});
|
|
540
|
+
}
|
|
541
|
+
}
|
|
292
542
|
|
|
293
|
-
|
|
543
|
+
this.success(
|
|
544
|
+
`Successfully pulled ${chalk.bold(allTables.length)} tables from ${chalk.bold(allDatabases.length)} tableDBs.`,
|
|
545
|
+
);
|
|
294
546
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
547
|
+
return {
|
|
548
|
+
databases: allDatabases,
|
|
549
|
+
tables: allTables,
|
|
550
|
+
};
|
|
551
|
+
}
|
|
301
552
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
553
|
+
/**
|
|
554
|
+
* Pull storage buckets from the project
|
|
555
|
+
*/
|
|
556
|
+
public async pullBuckets(): Promise<any[]> {
|
|
557
|
+
this.log("Fetching buckets ...");
|
|
305
558
|
|
|
306
|
-
|
|
307
|
-
}
|
|
559
|
+
const storageService = new Storage(this.projectClient);
|
|
308
560
|
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
log("Fetching collections ...");
|
|
312
|
-
let totalDatabases = 0;
|
|
313
|
-
let totalCollections = 0;
|
|
314
|
-
|
|
315
|
-
const fetchResponse = await databasesList({
|
|
316
|
-
queries: [JSON.stringify({ method: 'limit', values: [1] })],
|
|
317
|
-
parseOutput: false
|
|
561
|
+
const fetchResponse = await storageService.listBuckets({
|
|
562
|
+
queries: [Query.limit(1)],
|
|
318
563
|
});
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
564
|
+
|
|
565
|
+
if (fetchResponse["buckets"].length <= 0) {
|
|
566
|
+
this.log("No buckets found.");
|
|
567
|
+
this.success(`Successfully pulled ${chalk.bold(0)} buckets.`);
|
|
568
|
+
return [];
|
|
323
569
|
}
|
|
324
570
|
|
|
325
|
-
|
|
571
|
+
const { buckets } = await paginate(
|
|
572
|
+
async () => new Storage(this.projectClient).listBuckets(),
|
|
573
|
+
{},
|
|
574
|
+
100,
|
|
575
|
+
"buckets",
|
|
576
|
+
);
|
|
326
577
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
databases = (await paginate(databasesList, { parseOutput: false }, 100, 'databases')).databases.map((database: any) => database.$id);
|
|
330
|
-
} else {
|
|
331
|
-
databases = (await inquirer.prompt(questionsPullCollection)).databases;
|
|
332
|
-
}
|
|
578
|
+
for (const bucket of buckets) {
|
|
579
|
+
this.log(`Pulling bucket ${chalk.bold(bucket.name)} ...`);
|
|
333
580
|
}
|
|
334
581
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
});
|
|
582
|
+
this.success(`Successfully pulled ${chalk.bold(buckets.length)} buckets.`);
|
|
583
|
+
|
|
584
|
+
return buckets;
|
|
585
|
+
}
|
|
340
586
|
|
|
341
|
-
|
|
342
|
-
|
|
587
|
+
/**
|
|
588
|
+
* Pull teams from the project
|
|
589
|
+
*/
|
|
590
|
+
public async pullTeams(): Promise<any[]> {
|
|
591
|
+
this.log("Fetching teams ...");
|
|
343
592
|
|
|
344
|
-
|
|
593
|
+
const teamsService = new Teams(this.projectClient);
|
|
345
594
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}, 100, 'collections');
|
|
595
|
+
const fetchResponse = await teamsService.list({
|
|
596
|
+
queries: [Query.limit(1)],
|
|
597
|
+
});
|
|
350
598
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
'$createdAt': undefined,
|
|
356
|
-
'$updatedAt': undefined
|
|
357
|
-
});
|
|
358
|
-
}
|
|
599
|
+
if (fetchResponse["teams"].length <= 0) {
|
|
600
|
+
this.log("No teams found.");
|
|
601
|
+
this.success(`Successfully pulled ${chalk.bold(0)} teams.`);
|
|
602
|
+
return [];
|
|
359
603
|
}
|
|
360
604
|
|
|
361
|
-
|
|
362
|
-
|
|
605
|
+
const { teams } = await paginate(
|
|
606
|
+
async () => new Teams(this.projectClient).list(),
|
|
607
|
+
{},
|
|
608
|
+
100,
|
|
609
|
+
"teams",
|
|
610
|
+
);
|
|
363
611
|
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
612
|
+
for (const team of teams) {
|
|
613
|
+
this.log(`Pulling team ${chalk.bold(team.name)} ...`);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
this.success(`Successfully pulled ${chalk.bold(teams.length)} teams.`);
|
|
617
|
+
|
|
618
|
+
return teams;
|
|
619
|
+
}
|
|
368
620
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
621
|
+
/**
|
|
622
|
+
* Pull messaging topics from the project
|
|
623
|
+
*/
|
|
624
|
+
public async pullMessagingTopics(): Promise<any[]> {
|
|
625
|
+
this.log("Fetching topics ...");
|
|
626
|
+
|
|
627
|
+
const messagingService = new Messaging(this.projectClient);
|
|
628
|
+
|
|
629
|
+
const fetchResponse = await messagingService.listTopics({
|
|
630
|
+
queries: [Query.limit(1)],
|
|
372
631
|
});
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
632
|
+
|
|
633
|
+
if (fetchResponse["topics"].length <= 0) {
|
|
634
|
+
this.log("No topics found.");
|
|
635
|
+
this.success(`Successfully pulled ${chalk.bold(0)} topics.`);
|
|
636
|
+
return [];
|
|
377
637
|
}
|
|
378
638
|
|
|
379
|
-
|
|
639
|
+
const { topics } = await paginate(
|
|
640
|
+
async () => new Messaging(this.projectClient).listTopics(),
|
|
641
|
+
{},
|
|
642
|
+
100,
|
|
643
|
+
"topics",
|
|
644
|
+
);
|
|
380
645
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
databases = (await paginate(tablesDBList, { parseOutput: false }, 100, 'databases')).databases.map((database: any) => database.$id);
|
|
384
|
-
} else {
|
|
385
|
-
databases = (await inquirer.prompt(questionsPullCollection)).databases;
|
|
386
|
-
}
|
|
646
|
+
for (const topic of topics) {
|
|
647
|
+
this.log(`Pulling topic ${chalk.bold(topic.name)} ...`);
|
|
387
648
|
}
|
|
388
649
|
|
|
389
|
-
|
|
390
|
-
const database = await tablesDBGet({
|
|
391
|
-
databaseId,
|
|
392
|
-
parseOutput: false
|
|
393
|
-
});
|
|
650
|
+
this.success(`Successfully pulled ${chalk.bold(topics.length)} topics.`);
|
|
394
651
|
|
|
395
|
-
|
|
396
|
-
|
|
652
|
+
return topics;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
397
655
|
|
|
398
|
-
|
|
656
|
+
/** Helper methods for CLI commands */
|
|
399
657
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
658
|
+
export const pullResources = async ({
|
|
659
|
+
skipDeprecated = true,
|
|
660
|
+
}: {
|
|
661
|
+
skipDeprecated?: boolean;
|
|
662
|
+
} = {}): Promise<void> => {
|
|
663
|
+
const project = localConfig.getProject();
|
|
664
|
+
if (!project.projectId) {
|
|
665
|
+
error(
|
|
666
|
+
"Project configuration not found. Please run 'appwrite init project' to initialize your project first.",
|
|
667
|
+
);
|
|
668
|
+
process.exit(1);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
const actions: Record<string, (options?: any) => Promise<void>> = {
|
|
672
|
+
settings: pullSettings,
|
|
673
|
+
functions: pullFunctions,
|
|
674
|
+
sites: pullSites,
|
|
675
|
+
collections: pullCollection,
|
|
676
|
+
tables: pullTable,
|
|
677
|
+
buckets: pullBucket,
|
|
678
|
+
teams: pullTeam,
|
|
679
|
+
messages: pullMessagingTopic,
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
if (skipDeprecated) {
|
|
683
|
+
delete actions.collections;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
if (cliConfig.all) {
|
|
687
|
+
for (let action of Object.values(actions)) {
|
|
688
|
+
cliConfig.all = true;
|
|
689
|
+
await action({ returnOnZero: true });
|
|
690
|
+
}
|
|
691
|
+
} else {
|
|
692
|
+
const answers = await inquirer.prompt([questionsPullResources[0]]);
|
|
404
693
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
...table,
|
|
409
|
-
'$createdAt': undefined,
|
|
410
|
-
'$updatedAt': undefined
|
|
411
|
-
});
|
|
412
|
-
}
|
|
694
|
+
const action = actions[answers.resource];
|
|
695
|
+
if (action !== undefined) {
|
|
696
|
+
await action({ returnOnZero: true });
|
|
413
697
|
}
|
|
698
|
+
}
|
|
699
|
+
};
|
|
414
700
|
|
|
415
|
-
|
|
416
|
-
|
|
701
|
+
const pullSettings = async (): Promise<void> => {
|
|
702
|
+
const pullInstance = await createPullInstance();
|
|
703
|
+
const projectId = localConfig.getProject().projectId;
|
|
704
|
+
const settings = await pullInstance.pullSettings(projectId);
|
|
417
705
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
let total = 0;
|
|
706
|
+
localConfig.setProject(projectId, settings.projectName, settings.project);
|
|
707
|
+
};
|
|
421
708
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
709
|
+
const pullFunctions = async ({
|
|
710
|
+
code,
|
|
711
|
+
withVariables,
|
|
712
|
+
}: PullFunctionsOptions = {}): Promise<void> => {
|
|
713
|
+
const functionsService = await getFunctionsService();
|
|
714
|
+
const fetchResponse = await functionsService.list([Query.limit(1)]);
|
|
715
|
+
if (fetchResponse["functions"].length <= 0) {
|
|
716
|
+
log("No functions found.");
|
|
717
|
+
success(`Successfully pulled ${chalk.bold(0)} functions.`);
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
const functionsToCheck = cliConfig.all
|
|
722
|
+
? (
|
|
723
|
+
await paginate(
|
|
724
|
+
async () => (await getFunctionsService()).list(),
|
|
725
|
+
{},
|
|
726
|
+
100,
|
|
727
|
+
"functions",
|
|
728
|
+
)
|
|
729
|
+
).functions
|
|
730
|
+
: (await inquirer.prompt(questionsPullFunctions)).functions;
|
|
731
|
+
|
|
732
|
+
let allowCodePull: boolean | null = cliConfig.force === true ? true : null;
|
|
733
|
+
if (code !== false && allowCodePull === null) {
|
|
734
|
+
const codeAnswer = await inquirer.prompt(questionsPullFunctionsCode);
|
|
735
|
+
allowCodePull = codeAnswer.override;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
const shouldPullCode = code !== false && allowCodePull === true;
|
|
739
|
+
const selectedFunctionIds = functionsToCheck.map((f: any) => f.$id);
|
|
740
|
+
|
|
741
|
+
const pullInstance = await createPullInstance();
|
|
742
|
+
const functions = await pullInstance.pullFunctions({
|
|
743
|
+
code: shouldPullCode,
|
|
744
|
+
withVariables,
|
|
745
|
+
functionIds: selectedFunctionIds,
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
for (const func of functions) {
|
|
749
|
+
const localFunction = localConfig.getFunction(func.$id);
|
|
750
|
+
func["path"] = localFunction["path"] || func["path"];
|
|
751
|
+
localConfig.addFunction(func);
|
|
752
|
+
}
|
|
753
|
+
};
|
|
431
754
|
|
|
432
|
-
|
|
755
|
+
const pullSites = async ({
|
|
756
|
+
code,
|
|
757
|
+
withVariables,
|
|
758
|
+
}: PullSitesOptions = {}): Promise<void> => {
|
|
759
|
+
const sitesService = await getSitesService();
|
|
760
|
+
const fetchResponse = await sitesService.list({
|
|
761
|
+
queries: [Query.limit(1)],
|
|
762
|
+
});
|
|
763
|
+
if (fetchResponse["sites"].length <= 0) {
|
|
764
|
+
log("No sites found.");
|
|
765
|
+
success(`Successfully pulled ${chalk.bold(0)} sites.`);
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
const sitesToCheck = cliConfig.all
|
|
770
|
+
? (
|
|
771
|
+
await paginate(
|
|
772
|
+
async () => (await getSitesService()).list(),
|
|
773
|
+
{},
|
|
774
|
+
100,
|
|
775
|
+
"sites",
|
|
776
|
+
)
|
|
777
|
+
).sites
|
|
778
|
+
: (await inquirer.prompt(questionsPullSites)).sites;
|
|
779
|
+
|
|
780
|
+
let allowCodePull: boolean | null = cliConfig.force === true ? true : null;
|
|
781
|
+
if (code !== false && allowCodePull === null) {
|
|
782
|
+
const codeAnswer = await inquirer.prompt(questionsPullSitesCode);
|
|
783
|
+
allowCodePull = codeAnswer.override;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const shouldPullCode = code !== false && allowCodePull === true;
|
|
787
|
+
const selectedSiteIds = sitesToCheck.map((s: any) => s.$id);
|
|
788
|
+
|
|
789
|
+
const pullInstance = await createPullInstance();
|
|
790
|
+
const sites = await pullInstance.pullSites({
|
|
791
|
+
code: shouldPullCode,
|
|
792
|
+
withVariables,
|
|
793
|
+
siteIds: selectedSiteIds,
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
for (const site of sites) {
|
|
797
|
+
const localSite = localConfig.getSite(site.$id);
|
|
798
|
+
site["path"] = localSite["path"] || site["path"];
|
|
799
|
+
localConfig.addSite(site);
|
|
800
|
+
}
|
|
801
|
+
};
|
|
433
802
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
localConfig.addBucket(bucket);
|
|
438
|
-
}
|
|
803
|
+
const pullCollection = async (): Promise<void> => {
|
|
804
|
+
const pullInstance = await createPullInstance();
|
|
805
|
+
const { databases, collections } = await pullInstance.pullCollections();
|
|
439
806
|
|
|
440
|
-
|
|
441
|
-
|
|
807
|
+
for (const database of databases) {
|
|
808
|
+
localConfig.addDatabase(database);
|
|
809
|
+
}
|
|
442
810
|
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
|
|
811
|
+
for (const collection of collections) {
|
|
812
|
+
localConfig.addCollection(collection);
|
|
813
|
+
}
|
|
814
|
+
};
|
|
446
815
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
});
|
|
451
|
-
if (fetchResponse["teams"].length <= 0) {
|
|
452
|
-
log("No teams found.");
|
|
453
|
-
success(`Successfully pulled ${chalk.bold(total)} teams.`);
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
816
|
+
const pullTable = async (): Promise<void> => {
|
|
817
|
+
const pullInstance = await createPullInstance();
|
|
818
|
+
const { databases, tables } = await pullInstance.pullTables();
|
|
456
819
|
|
|
457
|
-
|
|
820
|
+
for (const database of databases) {
|
|
821
|
+
localConfig.addTablesDB(database);
|
|
822
|
+
}
|
|
458
823
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
824
|
+
for (const table of tables) {
|
|
825
|
+
localConfig.addTable(table);
|
|
826
|
+
}
|
|
827
|
+
};
|
|
464
828
|
|
|
465
|
-
|
|
466
|
-
|
|
829
|
+
const pullBucket = async (): Promise<void> => {
|
|
830
|
+
const pullInstance = await createPullInstance();
|
|
831
|
+
const buckets = await pullInstance.pullBuckets();
|
|
467
832
|
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
833
|
+
for (const bucket of buckets) {
|
|
834
|
+
localConfig.addBucket(bucket);
|
|
835
|
+
}
|
|
836
|
+
};
|
|
471
837
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
});
|
|
476
|
-
if (fetchResponse["topics"].length <= 0) {
|
|
477
|
-
log("No topics found.");
|
|
478
|
-
success(`Successfully pulled ${chalk.bold(total)} topics.`);
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
838
|
+
const pullTeam = async (): Promise<void> => {
|
|
839
|
+
const pullInstance = await createPullInstance();
|
|
840
|
+
const teams = await pullInstance.pullTeams();
|
|
481
841
|
|
|
482
|
-
|
|
842
|
+
for (const team of teams) {
|
|
843
|
+
localConfig.addTeam(team);
|
|
844
|
+
}
|
|
845
|
+
};
|
|
483
846
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
localConfig.addMessagingTopic(topic);
|
|
488
|
-
}
|
|
847
|
+
const pullMessagingTopic = async (): Promise<void> => {
|
|
848
|
+
const pullInstance = await createPullInstance();
|
|
849
|
+
const topics = await pullInstance.pullMessagingTopics();
|
|
489
850
|
|
|
490
|
-
|
|
491
|
-
|
|
851
|
+
for (const topic of topics) {
|
|
852
|
+
localConfig.addMessagingTopic(topic);
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
/** Commander.js exports */
|
|
492
857
|
|
|
493
858
|
export const pull = new Command("pull")
|
|
494
|
-
|
|
495
|
-
|
|
859
|
+
.description(commandDescriptions["pull"])
|
|
860
|
+
.action(actionRunner(() => pullResources({ skipDeprecated: true })));
|
|
496
861
|
|
|
497
862
|
pull
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
863
|
+
.command("all")
|
|
864
|
+
.description("Pull all resources")
|
|
865
|
+
.action(
|
|
866
|
+
actionRunner(() => {
|
|
867
|
+
cliConfig.all = true;
|
|
868
|
+
return pullResources({
|
|
869
|
+
skipDeprecated: true,
|
|
870
|
+
});
|
|
871
|
+
}),
|
|
872
|
+
);
|
|
506
873
|
|
|
507
874
|
pull
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
875
|
+
.command("settings")
|
|
876
|
+
.description("Pull your Appwrite project name, services and auth settings")
|
|
877
|
+
.action(actionRunner(pullSettings));
|
|
511
878
|
|
|
512
879
|
pull
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
880
|
+
.command("function")
|
|
881
|
+
.alias("functions")
|
|
882
|
+
.description("Pull your Appwrite cloud function")
|
|
883
|
+
.option("--no-code", "Don't pull the function's code")
|
|
884
|
+
.option(
|
|
885
|
+
"--with-variables",
|
|
886
|
+
`Pull function variables. ${chalk.red("recommend for testing purposes only")}`,
|
|
887
|
+
)
|
|
888
|
+
.action(actionRunner(pullFunctions));
|
|
519
889
|
|
|
520
890
|
pull
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
891
|
+
.command("site")
|
|
892
|
+
.alias("sites")
|
|
893
|
+
.description("Pull your Appwrite site")
|
|
894
|
+
.option("--no-code", "Don't pull the site's code")
|
|
895
|
+
.option(
|
|
896
|
+
"--with-variables",
|
|
897
|
+
`Pull site variables. ${chalk.red("recommend for testing purposes only")}`,
|
|
898
|
+
)
|
|
899
|
+
.action(actionRunner(pullSites));
|
|
527
900
|
|
|
528
901
|
pull
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
902
|
+
.command("collection")
|
|
903
|
+
.alias("collections")
|
|
904
|
+
.description(
|
|
905
|
+
"Pull your Appwrite collections (deprecated, please use 'pull tables' instead)",
|
|
906
|
+
)
|
|
907
|
+
.action(actionRunner(pullCollection));
|
|
533
908
|
|
|
534
909
|
pull
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
910
|
+
.command("table")
|
|
911
|
+
.alias("tables")
|
|
912
|
+
.description("Pull your Appwrite tables")
|
|
913
|
+
.action(actionRunner(pullTable));
|
|
539
914
|
|
|
540
915
|
pull
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
916
|
+
.command("bucket")
|
|
917
|
+
.alias("buckets")
|
|
918
|
+
.description("Pull your Appwrite buckets")
|
|
919
|
+
.action(actionRunner(pullBucket));
|
|
545
920
|
|
|
546
921
|
pull
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
922
|
+
.command("team")
|
|
923
|
+
.alias("teams")
|
|
924
|
+
.description("Pull your Appwrite teams")
|
|
925
|
+
.action(actionRunner(pullTeam));
|
|
551
926
|
|
|
552
927
|
pull
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
928
|
+
.command("topic")
|
|
929
|
+
.alias("topics")
|
|
930
|
+
.description("Pull your Appwrite messaging topics")
|
|
931
|
+
.action(actionRunner(pullMessagingTopic));
|