chirag-appwrite-cli 0.1.1 → 0.2.0
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/build-verify.yml +71 -0
- package/.github/workflows/npm-publish.yml +41 -22
- package/CHANGELOG.md +190 -1
- package/LICENSE.md +12 -1
- package/README.md +182 -15
- package/bun.lock +627 -0
- package/dist/bundle.cjs +108228 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +149 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client.d.ts +88 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +238 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/commands/config.d.ts +557 -0
- package/dist/lib/commands/config.d.ts.map +1 -0
- package/dist/lib/commands/config.js +415 -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 +17 -0
- package/dist/lib/commands/generic.d.ts.map +1 -0
- package/dist/lib/commands/generic.js +292 -0
- package/dist/lib/commands/generic.js.map +1 -0
- package/dist/lib/commands/init.d.ts +3 -0
- package/dist/lib/commands/init.d.ts.map +1 -0
- package/dist/lib/commands/init.js +526 -0
- package/dist/lib/commands/init.js.map +1 -0
- package/dist/lib/commands/pull.d.ts +110 -0
- package/dist/lib/commands/pull.d.ts.map +1 -0
- package/dist/lib/commands/pull.js +626 -0
- package/dist/lib/commands/pull.js.map +1 -0
- package/dist/lib/commands/push.d.ts +82 -0
- package/dist/lib/commands/push.d.ts.map +1 -0
- package/dist/lib/commands/push.js +1666 -0
- package/dist/lib/commands/push.js.map +1 -0
- package/dist/lib/commands/run.d.ts +3 -0
- package/dist/lib/commands/run.d.ts.map +1 -0
- package/dist/lib/commands/run.js +289 -0
- package/dist/lib/commands/run.js.map +1 -0
- package/dist/lib/commands/schema.d.ts +57 -0
- package/dist/lib/commands/schema.d.ts.map +1 -0
- package/dist/lib/commands/schema.js +75 -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 +306 -0
- package/dist/lib/commands/services/account.js.map +1 -0
- package/dist/lib/commands/services/avatars.d.ts +3 -0
- package/dist/lib/commands/services/avatars.d.ts.map +1 -0
- package/dist/lib/commands/services/avatars.js +118 -0
- package/dist/lib/commands/services/avatars.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 +41 -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 +612 -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 +258 -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 +242 -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 +153 -0
- package/dist/lib/commands/services/storage.js.map +1 -0
- package/dist/lib/commands/services/tablesdb.d.ts +3 -0
- package/dist/lib/commands/services/tablesdb.d.ts.map +1 -0
- package/dist/lib/commands/services/tablesdb.js +605 -0
- package/dist/lib/commands/services/tablesdb.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 +3 -0
- package/dist/lib/commands/types.d.ts.map +1 -0
- package/dist/lib/commands/types.js +151 -0
- package/dist/lib/commands/types.js.map +1 -0
- package/dist/lib/commands/update.d.ts +3 -0
- package/dist/lib/commands/update.d.ts.map +1 -0
- package/dist/lib/commands/update.js +201 -0
- package/dist/lib/commands/update.js.map +1 -0
- package/dist/lib/commands/utils/attributes.d.ts +46 -0
- package/dist/lib/commands/utils/attributes.d.ts.map +1 -0
- package/dist/lib/commands/utils/attributes.js +521 -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 +108 -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 +197 -0
- package/dist/lib/commands/utils/pools.js.map +1 -0
- package/dist/lib/config.d.ts +119 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +728 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/emulation/docker.d.ts +7 -0
- package/dist/lib/emulation/docker.d.ts.map +1 -0
- package/dist/lib/emulation/docker.js +224 -0
- package/dist/lib/emulation/docker.js.map +1 -0
- package/dist/lib/emulation/utils.d.ts +29 -0
- package/dist/lib/emulation/utils.d.ts.map +1 -0
- package/dist/lib/emulation/utils.js +165 -0
- package/dist/lib/emulation/utils.js.map +1 -0
- package/dist/lib/id.d.ts +7 -0
- package/dist/lib/id.d.ts.map +1 -0
- package/dist/lib/id.js +27 -0
- package/dist/lib/id.js.map +1 -0
- package/dist/lib/paginate.d.ts +9 -0
- package/dist/lib/paginate.d.ts.map +1 -0
- package/dist/lib/paginate.js +43 -0
- package/dist/lib/paginate.js.map +1 -0
- package/dist/lib/parser.d.ts +18 -0
- package/dist/lib/parser.d.ts.map +1 -0
- package/dist/lib/parser.js +225 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/questions.d.ts +59 -0
- package/dist/lib/questions.d.ts.map +1 -0
- package/dist/lib/questions.js +991 -0
- package/dist/lib/questions.js.map +1 -0
- package/dist/lib/sdks.d.ts +4 -0
- package/dist/lib/sdks.d.ts.map +1 -0
- package/dist/lib/sdks.js +61 -0
- package/dist/lib/sdks.js.map +1 -0
- 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 +28 -0
- package/dist/lib/spinner.d.ts.map +1 -0
- package/dist/lib/spinner.js +91 -0
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/type-generation/attribute.d.ts +17 -0
- package/dist/lib/type-generation/attribute.d.ts.map +1 -0
- package/dist/lib/type-generation/attribute.js +16 -0
- package/dist/lib/type-generation/attribute.js.map +1 -0
- package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
- package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/csharp.js +180 -0
- package/dist/lib/type-generation/languages/csharp.js.map +1 -0
- package/dist/lib/type-generation/languages/dart.d.ts +8 -0
- package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/dart.js +197 -0
- package/dist/lib/type-generation/languages/dart.js.map +1 -0
- package/dist/lib/type-generation/languages/java.d.ts +7 -0
- package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/java.js +140 -0
- package/dist/lib/type-generation/languages/java.js.map +1 -0
- package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
- package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/javascript.js +109 -0
- package/dist/lib/type-generation/languages/javascript.js.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.js +95 -0
- package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
- package/dist/lib/type-generation/languages/language.d.ts +43 -0
- package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/language.js +77 -0
- package/dist/lib/type-generation/languages/language.js.map +1 -0
- package/dist/lib/type-generation/languages/php.d.ts +7 -0
- package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/php.js +116 -0
- package/dist/lib/type-generation/languages/php.js.map +1 -0
- package/dist/lib/type-generation/languages/swift.d.ts +7 -0
- package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/swift.js +179 -0
- package/dist/lib/type-generation/languages/swift.js.map +1 -0
- package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
- package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/typescript.js +115 -0
- package/dist/lib/type-generation/languages/typescript.js.map +1 -0
- package/dist/lib/types.d.ts +63 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +18 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +323 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/validations.d.ts +2 -0
- package/dist/lib/validations.d.ts.map +1 -0
- package/dist/lib/validations.js +16 -0
- package/dist/lib/validations.js.map +1 -0
- package/dist/package.json +68 -0
- package/dist/scripts/generate-commands.d.ts +2 -0
- package/dist/scripts/generate-commands.d.ts.map +1 -0
- package/dist/scripts/generate-commands.js +398 -0
- package/dist/scripts/generate-commands.js.map +1 -0
- package/dist/sites/profile-website/src/lib/utils.d.ts +4 -0
- package/dist/sites/profile-website/src/lib/utils.d.ts.map +1 -0
- package/dist/sites/profile-website/src/lib/utils.js +32 -0
- package/dist/sites/profile-website/src/lib/utils.js.map +1 -0
- package/dist/sites/profile-website/tailwind.config.d.ts +3 -0
- package/dist/sites/profile-website/tailwind.config.d.ts.map +1 -0
- package/dist/sites/profile-website/tailwind.config.js +110 -0
- package/dist/sites/profile-website/tailwind.config.js.map +1 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +38 -0
- package/dist/test.js.map +1 -0
- package/index.ts +190 -0
- package/install.ps1 +5 -8
- package/install.sh +4 -5
- package/lib/client.ts +292 -0
- package/lib/commands/config.ts +493 -0
- package/lib/commands/db.ts +324 -0
- package/lib/commands/errors.ts +93 -0
- package/lib/commands/generic.ts +440 -0
- package/lib/commands/init.ts +713 -0
- package/lib/commands/pull.ts +944 -0
- package/lib/commands/push.ts +2355 -0
- package/lib/commands/run.ts +416 -0
- package/lib/commands/schema.ts +103 -0
- package/lib/commands/services/account.ts +832 -0
- package/lib/commands/services/avatars.ts +400 -0
- package/lib/commands/services/console.ts +73 -0
- package/lib/commands/services/databases.ts +2080 -0
- package/lib/commands/services/functions.ts +855 -0
- package/lib/commands/services/graphql.ts +47 -0
- package/lib/commands/services/health.ts +322 -0
- package/lib/commands/services/locale.ts +99 -0
- package/lib/commands/services/messaging.ts +1871 -0
- package/lib/commands/services/migrations.ts +421 -0
- package/lib/commands/services/project.ts +116 -0
- package/lib/commands/services/projects.ts +1317 -0
- package/lib/commands/services/proxy.ts +163 -0
- package/lib/commands/services/sites.ts +777 -0
- package/lib/commands/services/storage.ts +547 -0
- package/lib/commands/services/tablesdb.ts +1928 -0
- package/lib/commands/services/teams.ts +294 -0
- package/lib/commands/services/tokens.ts +106 -0
- package/lib/commands/services/users.ts +886 -0
- package/lib/commands/services/vcs.ts +268 -0
- package/lib/commands/types.ts +220 -0
- package/lib/commands/update.ts +245 -0
- package/lib/commands/utils/attributes.ts +734 -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 +180 -0
- package/lib/commands/utils/error-formatter.ts +417 -0
- package/lib/commands/utils/pools.ts +354 -0
- package/lib/config.ts +932 -0
- package/lib/emulation/docker.ts +312 -0
- package/lib/emulation/utils.ts +207 -0
- package/lib/id.ts +30 -0
- package/lib/paginate.ts +77 -0
- package/lib/parser.ts +264 -0
- package/lib/questions.ts +1167 -0
- package/lib/sdks.ts +84 -0
- package/lib/services.ts +72 -0
- package/lib/spinner.ts +131 -0
- package/lib/type-generation/attribute.ts +18 -0
- package/lib/type-generation/languages/csharp.ts +192 -0
- package/lib/type-generation/languages/dart.ts +217 -0
- package/lib/type-generation/languages/java.ts +152 -0
- package/lib/type-generation/languages/javascript.ts +122 -0
- package/lib/type-generation/languages/kotlin.ts +107 -0
- package/lib/type-generation/languages/language.ts +127 -0
- package/lib/type-generation/languages/php.ts +128 -0
- package/lib/type-generation/languages/swift.ts +191 -0
- package/lib/type-generation/languages/typescript.ts +133 -0
- package/lib/types.ts +75 -0
- package/lib/utils.ts +394 -0
- package/lib/validations.ts +20 -0
- package/package.json +39 -21
- package/scoop/appwrite.config.json +20 -0
- package/scripts/generate-commands.ts +539 -0
- package/tsconfig.json +24 -0
- package/appwrite.config.json +0 -420
- package/docs/examples/account/create-anonymous-session.md +0 -1
- package/docs/examples/account/create-email-password-session.md +0 -3
- package/docs/examples/account/create-email-token.md +0 -4
- package/docs/examples/account/create-j-w-t.md +0 -1
- package/docs/examples/account/create-magic-u-r-l-token.md +0 -5
- package/docs/examples/account/create-mfa-authenticator.md +0 -2
- package/docs/examples/account/create-mfa-challenge.md +0 -2
- package/docs/examples/account/create-mfa-recovery-codes.md +0 -1
- package/docs/examples/account/create-o-auth2session.md +0 -5
- package/docs/examples/account/create-o-auth2token.md +0 -5
- package/docs/examples/account/create-phone-token.md +0 -3
- package/docs/examples/account/create-phone-verification.md +0 -1
- package/docs/examples/account/create-push-target.md +0 -4
- package/docs/examples/account/create-recovery.md +0 -3
- package/docs/examples/account/create-session.md +0 -3
- package/docs/examples/account/create-verification.md +0 -2
- package/docs/examples/account/create.md +0 -5
- package/docs/examples/account/delete-identity.md +0 -2
- package/docs/examples/account/delete-mfa-authenticator.md +0 -2
- package/docs/examples/account/delete-push-target.md +0 -2
- package/docs/examples/account/delete-session.md +0 -2
- package/docs/examples/account/delete-sessions.md +0 -1
- package/docs/examples/account/delete.md +0 -1
- package/docs/examples/account/get-mfa-recovery-codes.md +0 -1
- package/docs/examples/account/get-prefs.md +0 -1
- package/docs/examples/account/get-session.md +0 -2
- package/docs/examples/account/get.md +0 -1
- package/docs/examples/account/list-identities.md +0 -2
- package/docs/examples/account/list-logs.md +0 -2
- package/docs/examples/account/list-mfa-factors.md +0 -1
- package/docs/examples/account/list-sessions.md +0 -1
- package/docs/examples/account/update-email.md +0 -3
- package/docs/examples/account/update-m-f-a.md +0 -2
- package/docs/examples/account/update-magic-u-r-l-session.md +0 -3
- package/docs/examples/account/update-mfa-authenticator.md +0 -3
- package/docs/examples/account/update-mfa-challenge.md +0 -3
- package/docs/examples/account/update-mfa-recovery-codes.md +0 -1
- package/docs/examples/account/update-name.md +0 -2
- package/docs/examples/account/update-password.md +0 -3
- package/docs/examples/account/update-phone-session.md +0 -3
- package/docs/examples/account/update-phone-verification.md +0 -3
- package/docs/examples/account/update-phone.md +0 -3
- package/docs/examples/account/update-prefs.md +0 -2
- package/docs/examples/account/update-push-target.md +0 -3
- package/docs/examples/account/update-recovery.md +0 -4
- package/docs/examples/account/update-session.md +0 -2
- package/docs/examples/account/update-status.md +0 -1
- package/docs/examples/account/update-verification.md +0 -3
- package/docs/examples/avatars/get-browser.md +0 -5
- package/docs/examples/avatars/get-credit-card.md +0 -5
- package/docs/examples/avatars/get-favicon.md +0 -2
- package/docs/examples/avatars/get-flag.md +0 -5
- package/docs/examples/avatars/get-image.md +0 -4
- package/docs/examples/avatars/get-initials.md +0 -5
- package/docs/examples/avatars/get-q-r.md +0 -5
- package/docs/examples/console/get-resource.md +0 -3
- package/docs/examples/console/variables.md +0 -1
- package/docs/examples/databases/create-boolean-attribute.md +0 -7
- package/docs/examples/databases/create-collection.md +0 -7
- package/docs/examples/databases/create-datetime-attribute.md +0 -7
- package/docs/examples/databases/create-document.md +0 -6
- package/docs/examples/databases/create-documents.md +0 -4
- package/docs/examples/databases/create-email-attribute.md +0 -7
- package/docs/examples/databases/create-enum-attribute.md +0 -8
- package/docs/examples/databases/create-float-attribute.md +0 -9
- package/docs/examples/databases/create-index.md +0 -8
- package/docs/examples/databases/create-integer-attribute.md +0 -9
- package/docs/examples/databases/create-ip-attribute.md +0 -7
- package/docs/examples/databases/create-relationship-attribute.md +0 -9
- package/docs/examples/databases/create-string-attribute.md +0 -9
- package/docs/examples/databases/create-url-attribute.md +0 -7
- package/docs/examples/databases/create.md +0 -4
- package/docs/examples/databases/decrement-document-attribute.md +0 -7
- package/docs/examples/databases/delete-attribute.md +0 -4
- package/docs/examples/databases/delete-collection.md +0 -3
- package/docs/examples/databases/delete-document.md +0 -4
- package/docs/examples/databases/delete-documents.md +0 -4
- package/docs/examples/databases/delete-index.md +0 -4
- package/docs/examples/databases/delete.md +0 -2
- package/docs/examples/databases/get-attribute.md +0 -4
- package/docs/examples/databases/get-collection-usage.md +0 -4
- package/docs/examples/databases/get-collection.md +0 -3
- package/docs/examples/databases/get-database-usage.md +0 -3
- package/docs/examples/databases/get-document.md +0 -5
- package/docs/examples/databases/get-index.md +0 -4
- package/docs/examples/databases/get-usage.md +0 -2
- package/docs/examples/databases/get.md +0 -2
- package/docs/examples/databases/increment-document-attribute.md +0 -7
- package/docs/examples/databases/list-attributes.md +0 -4
- package/docs/examples/databases/list-collection-logs.md +0 -4
- package/docs/examples/databases/list-collections.md +0 -4
- package/docs/examples/databases/list-document-logs.md +0 -5
- package/docs/examples/databases/list-documents.md +0 -4
- package/docs/examples/databases/list-indexes.md +0 -4
- package/docs/examples/databases/list-logs.md +0 -3
- package/docs/examples/databases/list-usage.md +0 -2
- package/docs/examples/databases/list.md +0 -3
- package/docs/examples/databases/update-boolean-attribute.md +0 -7
- package/docs/examples/databases/update-collection.md +0 -7
- package/docs/examples/databases/update-datetime-attribute.md +0 -7
- package/docs/examples/databases/update-document.md +0 -6
- package/docs/examples/databases/update-documents.md +0 -5
- package/docs/examples/databases/update-email-attribute.md +0 -7
- package/docs/examples/databases/update-enum-attribute.md +0 -8
- package/docs/examples/databases/update-float-attribute.md +0 -9
- package/docs/examples/databases/update-integer-attribute.md +0 -9
- package/docs/examples/databases/update-ip-attribute.md +0 -7
- package/docs/examples/databases/update-relationship-attribute.md +0 -6
- package/docs/examples/databases/update-string-attribute.md +0 -8
- package/docs/examples/databases/update-url-attribute.md +0 -7
- package/docs/examples/databases/update.md +0 -4
- package/docs/examples/databases/upsert-document.md +0 -6
- package/docs/examples/databases/upsert-documents.md +0 -4
- package/docs/examples/functions/create-deployment.md +0 -6
- package/docs/examples/functions/create-duplicate-deployment.md +0 -4
- package/docs/examples/functions/create-execution.md +0 -8
- package/docs/examples/functions/create-template-deployment.md +0 -7
- package/docs/examples/functions/create-variable.md +0 -5
- package/docs/examples/functions/create-vcs-deployment.md +0 -5
- package/docs/examples/functions/create.md +0 -19
- package/docs/examples/functions/delete-deployment.md +0 -3
- package/docs/examples/functions/delete-execution.md +0 -3
- package/docs/examples/functions/delete-variable.md +0 -3
- package/docs/examples/functions/delete.md +0 -2
- package/docs/examples/functions/get-deployment-download.md +0 -4
- package/docs/examples/functions/get-deployment.md +0 -3
- package/docs/examples/functions/get-execution.md +0 -3
- package/docs/examples/functions/get-template.md +0 -2
- package/docs/examples/functions/get-usage.md +0 -3
- package/docs/examples/functions/get-variable.md +0 -3
- package/docs/examples/functions/get.md +0 -2
- package/docs/examples/functions/list-deployments.md +0 -4
- package/docs/examples/functions/list-executions.md +0 -3
- package/docs/examples/functions/list-runtimes.md +0 -1
- package/docs/examples/functions/list-specifications.md +0 -1
- package/docs/examples/functions/list-templates.md +0 -5
- package/docs/examples/functions/list-usage.md +0 -2
- package/docs/examples/functions/list-variables.md +0 -2
- package/docs/examples/functions/list.md +0 -3
- package/docs/examples/functions/update-deployment-status.md +0 -3
- package/docs/examples/functions/update-function-deployment.md +0 -3
- package/docs/examples/functions/update-variable.md +0 -6
- package/docs/examples/functions/update.md +0 -19
- package/docs/examples/graphql/mutation.md +0 -2
- package/docs/examples/graphql/query.md +0 -2
- package/docs/examples/health/get-antivirus.md +0 -1
- package/docs/examples/health/get-cache.md +0 -1
- package/docs/examples/health/get-certificate.md +0 -2
- package/docs/examples/health/get-d-b.md +0 -1
- package/docs/examples/health/get-failed-jobs.md +0 -3
- package/docs/examples/health/get-pub-sub.md +0 -1
- package/docs/examples/health/get-queue-builds.md +0 -2
- package/docs/examples/health/get-queue-certificates.md +0 -2
- package/docs/examples/health/get-queue-databases.md +0 -3
- package/docs/examples/health/get-queue-deletes.md +0 -2
- package/docs/examples/health/get-queue-functions.md +0 -2
- package/docs/examples/health/get-queue-logs.md +0 -2
- package/docs/examples/health/get-queue-mails.md +0 -2
- package/docs/examples/health/get-queue-messaging.md +0 -2
- package/docs/examples/health/get-queue-migrations.md +0 -2
- package/docs/examples/health/get-queue-stats-resources.md +0 -2
- package/docs/examples/health/get-queue-usage.md +0 -2
- package/docs/examples/health/get-queue-webhooks.md +0 -2
- package/docs/examples/health/get-storage-local.md +0 -1
- package/docs/examples/health/get-storage.md +0 -1
- package/docs/examples/health/get-time.md +0 -1
- package/docs/examples/health/get.md +0 -1
- package/docs/examples/locale/get.md +0 -1
- package/docs/examples/locale/list-codes.md +0 -1
- package/docs/examples/locale/list-continents.md +0 -1
- package/docs/examples/locale/list-countries-e-u.md +0 -1
- package/docs/examples/locale/list-countries-phones.md +0 -1
- package/docs/examples/locale/list-countries.md +0 -1
- package/docs/examples/locale/list-currencies.md +0 -1
- package/docs/examples/locale/list-languages.md +0 -1
- package/docs/examples/messaging/create-apns-provider.md +0 -9
- package/docs/examples/messaging/create-email.md +0 -13
- package/docs/examples/messaging/create-fcm-provider.md +0 -5
- package/docs/examples/messaging/create-mailgun-provider.md +0 -11
- package/docs/examples/messaging/create-msg91provider.md +0 -7
- package/docs/examples/messaging/create-push.md +0 -20
- package/docs/examples/messaging/create-sendgrid-provider.md +0 -9
- package/docs/examples/messaging/create-sms.md +0 -8
- package/docs/examples/messaging/create-smtp-provider.md +0 -15
- package/docs/examples/messaging/create-subscriber.md +0 -4
- package/docs/examples/messaging/create-telesign-provider.md +0 -7
- package/docs/examples/messaging/create-textmagic-provider.md +0 -7
- package/docs/examples/messaging/create-topic.md +0 -4
- package/docs/examples/messaging/create-twilio-provider.md +0 -7
- package/docs/examples/messaging/create-vonage-provider.md +0 -7
- package/docs/examples/messaging/delete-provider.md +0 -2
- package/docs/examples/messaging/delete-subscriber.md +0 -3
- package/docs/examples/messaging/delete-topic.md +0 -2
- package/docs/examples/messaging/delete.md +0 -2
- package/docs/examples/messaging/get-message.md +0 -2
- package/docs/examples/messaging/get-provider.md +0 -2
- package/docs/examples/messaging/get-subscriber.md +0 -3
- package/docs/examples/messaging/get-topic.md +0 -2
- package/docs/examples/messaging/list-message-logs.md +0 -3
- package/docs/examples/messaging/list-messages.md +0 -3
- package/docs/examples/messaging/list-provider-logs.md +0 -3
- package/docs/examples/messaging/list-providers.md +0 -3
- package/docs/examples/messaging/list-subscriber-logs.md +0 -3
- package/docs/examples/messaging/list-subscribers.md +0 -4
- package/docs/examples/messaging/list-targets.md +0 -3
- package/docs/examples/messaging/list-topic-logs.md +0 -3
- package/docs/examples/messaging/list-topics.md +0 -3
- package/docs/examples/messaging/update-apns-provider.md +0 -9
- package/docs/examples/messaging/update-email.md +0 -13
- package/docs/examples/messaging/update-fcm-provider.md +0 -5
- package/docs/examples/messaging/update-mailgun-provider.md +0 -11
- package/docs/examples/messaging/update-msg91provider.md +0 -7
- package/docs/examples/messaging/update-push.md +0 -20
- package/docs/examples/messaging/update-sendgrid-provider.md +0 -9
- package/docs/examples/messaging/update-sms.md +0 -8
- package/docs/examples/messaging/update-smtp-provider.md +0 -15
- package/docs/examples/messaging/update-telesign-provider.md +0 -7
- package/docs/examples/messaging/update-textmagic-provider.md +0 -7
- package/docs/examples/messaging/update-topic.md +0 -4
- package/docs/examples/messaging/update-twilio-provider.md +0 -7
- package/docs/examples/messaging/update-vonage-provider.md +0 -7
- package/docs/examples/migrations/create-appwrite-migration.md +0 -5
- package/docs/examples/migrations/create-csv-migration.md +0 -4
- package/docs/examples/migrations/create-firebase-migration.md +0 -3
- package/docs/examples/migrations/create-n-host-migration.md +0 -9
- package/docs/examples/migrations/create-supabase-migration.md +0 -8
- package/docs/examples/migrations/delete.md +0 -2
- package/docs/examples/migrations/get-appwrite-report.md +0 -5
- package/docs/examples/migrations/get-firebase-report.md +0 -3
- package/docs/examples/migrations/get-n-host-report.md +0 -9
- package/docs/examples/migrations/get-supabase-report.md +0 -8
- package/docs/examples/migrations/get.md +0 -2
- package/docs/examples/migrations/list.md +0 -3
- package/docs/examples/migrations/retry.md +0 -2
- package/docs/examples/project/create-variable.md +0 -4
- package/docs/examples/project/delete-variable.md +0 -2
- package/docs/examples/project/get-usage.md +0 -4
- package/docs/examples/project/get-variable.md +0 -2
- package/docs/examples/project/list-variables.md +0 -1
- package/docs/examples/project/update-variable.md +0 -5
- package/docs/examples/projects/create-dev-key.md +0 -4
- package/docs/examples/projects/create-j-w-t.md +0 -4
- package/docs/examples/projects/create-key.md +0 -5
- package/docs/examples/projects/create-platform.md +0 -7
- package/docs/examples/projects/create-smtp-test.md +0 -11
- package/docs/examples/projects/create-webhook.md +0 -9
- package/docs/examples/projects/create.md +0 -14
- package/docs/examples/projects/delete-dev-key.md +0 -3
- package/docs/examples/projects/delete-email-template.md +0 -4
- package/docs/examples/projects/delete-key.md +0 -3
- package/docs/examples/projects/delete-platform.md +0 -3
- package/docs/examples/projects/delete-sms-template.md +0 -4
- package/docs/examples/projects/delete-webhook.md +0 -3
- package/docs/examples/projects/delete.md +0 -2
- package/docs/examples/projects/get-dev-key.md +0 -3
- package/docs/examples/projects/get-email-template.md +0 -4
- package/docs/examples/projects/get-key.md +0 -3
- package/docs/examples/projects/get-platform.md +0 -3
- package/docs/examples/projects/get-sms-template.md +0 -4
- package/docs/examples/projects/get-webhook.md +0 -3
- package/docs/examples/projects/get.md +0 -2
- package/docs/examples/projects/list-dev-keys.md +0 -3
- package/docs/examples/projects/list-keys.md +0 -2
- package/docs/examples/projects/list-platforms.md +0 -2
- package/docs/examples/projects/list-webhooks.md +0 -2
- package/docs/examples/projects/list.md +0 -3
- package/docs/examples/projects/update-api-status-all.md +0 -3
- package/docs/examples/projects/update-api-status.md +0 -4
- package/docs/examples/projects/update-auth-duration.md +0 -3
- package/docs/examples/projects/update-auth-limit.md +0 -3
- package/docs/examples/projects/update-auth-password-dictionary.md +0 -3
- package/docs/examples/projects/update-auth-password-history.md +0 -3
- package/docs/examples/projects/update-auth-sessions-limit.md +0 -3
- package/docs/examples/projects/update-auth-status.md +0 -4
- package/docs/examples/projects/update-dev-key.md +0 -5
- package/docs/examples/projects/update-email-template.md +0 -9
- package/docs/examples/projects/update-key.md +0 -6
- package/docs/examples/projects/update-memberships-privacy.md +0 -5
- package/docs/examples/projects/update-mock-numbers.md +0 -3
- package/docs/examples/projects/update-o-auth2.md +0 -6
- package/docs/examples/projects/update-personal-data-check.md +0 -3
- package/docs/examples/projects/update-platform.md +0 -7
- package/docs/examples/projects/update-service-status-all.md +0 -3
- package/docs/examples/projects/update-service-status.md +0 -4
- package/docs/examples/projects/update-session-alerts.md +0 -3
- package/docs/examples/projects/update-session-invalidation.md +0 -3
- package/docs/examples/projects/update-sms-template.md +0 -5
- package/docs/examples/projects/update-smtp.md +0 -11
- package/docs/examples/projects/update-team.md +0 -3
- package/docs/examples/projects/update-webhook-signature.md +0 -3
- package/docs/examples/projects/update-webhook.md +0 -10
- package/docs/examples/projects/update.md +0 -12
- package/docs/examples/proxy/create-a-p-i-rule.md +0 -2
- package/docs/examples/proxy/create-function-rule.md +0 -4
- package/docs/examples/proxy/create-redirect-rule.md +0 -6
- package/docs/examples/proxy/create-site-rule.md +0 -4
- package/docs/examples/proxy/delete-rule.md +0 -2
- package/docs/examples/proxy/get-rule.md +0 -2
- package/docs/examples/proxy/list-rules.md +0 -3
- package/docs/examples/proxy/update-rule-verification.md +0 -2
- package/docs/examples/sites/create-deployment.md +0 -7
- package/docs/examples/sites/create-duplicate-deployment.md +0 -3
- package/docs/examples/sites/create-template-deployment.md +0 -7
- package/docs/examples/sites/create-variable.md +0 -5
- package/docs/examples/sites/create-vcs-deployment.md +0 -5
- package/docs/examples/sites/create.md +0 -19
- package/docs/examples/sites/delete-deployment.md +0 -3
- package/docs/examples/sites/delete-log.md +0 -3
- package/docs/examples/sites/delete-variable.md +0 -3
- package/docs/examples/sites/delete.md +0 -2
- package/docs/examples/sites/get-deployment-download.md +0 -4
- package/docs/examples/sites/get-deployment.md +0 -3
- package/docs/examples/sites/get-log.md +0 -3
- package/docs/examples/sites/get-template.md +0 -2
- package/docs/examples/sites/get-usage.md +0 -3
- package/docs/examples/sites/get-variable.md +0 -3
- package/docs/examples/sites/get.md +0 -2
- package/docs/examples/sites/list-deployments.md +0 -4
- package/docs/examples/sites/list-frameworks.md +0 -1
- package/docs/examples/sites/list-logs.md +0 -3
- package/docs/examples/sites/list-specifications.md +0 -1
- package/docs/examples/sites/list-templates.md +0 -5
- package/docs/examples/sites/list-usage.md +0 -2
- package/docs/examples/sites/list-variables.md +0 -2
- package/docs/examples/sites/list.md +0 -3
- package/docs/examples/sites/update-deployment-status.md +0 -3
- package/docs/examples/sites/update-site-deployment.md +0 -3
- package/docs/examples/sites/update-variable.md +0 -6
- package/docs/examples/sites/update.md +0 -19
- package/docs/examples/storage/create-bucket.md +0 -11
- package/docs/examples/storage/create-file.md +0 -5
- package/docs/examples/storage/delete-bucket.md +0 -2
- package/docs/examples/storage/delete-file.md +0 -3
- package/docs/examples/storage/get-bucket-usage.md +0 -3
- package/docs/examples/storage/get-bucket.md +0 -2
- package/docs/examples/storage/get-file-download.md +0 -4
- package/docs/examples/storage/get-file-preview.md +0 -15
- package/docs/examples/storage/get-file-view.md +0 -4
- package/docs/examples/storage/get-file.md +0 -3
- package/docs/examples/storage/get-usage.md +0 -2
- package/docs/examples/storage/list-buckets.md +0 -3
- package/docs/examples/storage/list-files.md +0 -4
- package/docs/examples/storage/update-bucket.md +0 -11
- package/docs/examples/storage/update-file.md +0 -5
- package/docs/examples/tables/create-boolean-column.md +0 -7
- package/docs/examples/tables/create-datetime-column.md +0 -7
- package/docs/examples/tables/create-email-column.md +0 -7
- package/docs/examples/tables/create-enum-column.md +0 -8
- package/docs/examples/tables/create-float-column.md +0 -9
- package/docs/examples/tables/create-index.md +0 -8
- package/docs/examples/tables/create-integer-column.md +0 -9
- package/docs/examples/tables/create-ip-column.md +0 -7
- package/docs/examples/tables/create-relationship-column.md +0 -9
- package/docs/examples/tables/create-row.md +0 -6
- package/docs/examples/tables/create-rows.md +0 -4
- package/docs/examples/tables/create-string-column.md +0 -9
- package/docs/examples/tables/create-url-column.md +0 -7
- package/docs/examples/tables/create.md +0 -7
- package/docs/examples/tables/decrement-row-column.md +0 -7
- package/docs/examples/tables/delete-column.md +0 -4
- package/docs/examples/tables/delete-index.md +0 -4
- package/docs/examples/tables/delete-row.md +0 -4
- package/docs/examples/tables/delete-rows.md +0 -4
- package/docs/examples/tables/delete.md +0 -3
- package/docs/examples/tables/get-column.md +0 -4
- package/docs/examples/tables/get-index.md +0 -4
- package/docs/examples/tables/get-row.md +0 -5
- package/docs/examples/tables/get-usage.md +0 -4
- package/docs/examples/tables/get.md +0 -3
- package/docs/examples/tables/increment-row-column.md +0 -7
- package/docs/examples/tables/list-columns.md +0 -4
- package/docs/examples/tables/list-indexes.md +0 -4
- package/docs/examples/tables/list-logs.md +0 -4
- package/docs/examples/tables/list-row-logs.md +0 -5
- package/docs/examples/tables/list-rows.md +0 -4
- package/docs/examples/tables/list.md +0 -4
- package/docs/examples/tables/update-boolean-column.md +0 -7
- package/docs/examples/tables/update-datetime-column.md +0 -7
- package/docs/examples/tables/update-email-column.md +0 -7
- package/docs/examples/tables/update-enum-column.md +0 -8
- package/docs/examples/tables/update-float-column.md +0 -9
- package/docs/examples/tables/update-integer-column.md +0 -9
- package/docs/examples/tables/update-ip-column.md +0 -7
- package/docs/examples/tables/update-relationship-column.md +0 -6
- package/docs/examples/tables/update-row.md +0 -6
- package/docs/examples/tables/update-rows.md +0 -5
- package/docs/examples/tables/update-string-column.md +0 -8
- package/docs/examples/tables/update-url-column.md +0 -7
- package/docs/examples/tables/update.md +0 -7
- package/docs/examples/tables/upsert-row.md +0 -4
- package/docs/examples/tables/upsert-rows.md +0 -3
- package/docs/examples/teams/create-membership.md +0 -8
- package/docs/examples/teams/create.md +0 -4
- package/docs/examples/teams/delete-membership.md +0 -3
- package/docs/examples/teams/delete.md +0 -2
- package/docs/examples/teams/get-membership.md +0 -3
- package/docs/examples/teams/get-prefs.md +0 -2
- package/docs/examples/teams/get.md +0 -2
- package/docs/examples/teams/list-logs.md +0 -3
- package/docs/examples/teams/list-memberships.md +0 -4
- package/docs/examples/teams/list.md +0 -3
- package/docs/examples/teams/update-membership-status.md +0 -5
- package/docs/examples/teams/update-membership.md +0 -4
- package/docs/examples/teams/update-name.md +0 -3
- package/docs/examples/teams/update-prefs.md +0 -3
- package/docs/examples/tokens/create-file-token.md +0 -4
- package/docs/examples/tokens/delete.md +0 -2
- package/docs/examples/tokens/get.md +0 -2
- package/docs/examples/tokens/list.md +0 -4
- package/docs/examples/tokens/update.md +0 -3
- package/docs/examples/users/create-argon2user.md +0 -5
- package/docs/examples/users/create-bcrypt-user.md +0 -5
- package/docs/examples/users/create-j-w-t.md +0 -4
- package/docs/examples/users/create-m-d5user.md +0 -5
- package/docs/examples/users/create-mfa-recovery-codes.md +0 -2
- package/docs/examples/users/create-p-h-pass-user.md +0 -5
- package/docs/examples/users/create-s-h-a-user.md +0 -6
- package/docs/examples/users/create-scrypt-modified-user.md +0 -8
- package/docs/examples/users/create-scrypt-user.md +0 -10
- package/docs/examples/users/create-session.md +0 -2
- package/docs/examples/users/create-target.md +0 -7
- package/docs/examples/users/create-token.md +0 -4
- package/docs/examples/users/create.md +0 -6
- package/docs/examples/users/delete-identity.md +0 -2
- package/docs/examples/users/delete-mfa-authenticator.md +0 -3
- package/docs/examples/users/delete-session.md +0 -3
- package/docs/examples/users/delete-sessions.md +0 -2
- package/docs/examples/users/delete-target.md +0 -3
- package/docs/examples/users/delete.md +0 -2
- package/docs/examples/users/get-mfa-recovery-codes.md +0 -2
- package/docs/examples/users/get-prefs.md +0 -2
- package/docs/examples/users/get-target.md +0 -3
- package/docs/examples/users/get-usage.md +0 -2
- package/docs/examples/users/get.md +0 -2
- package/docs/examples/users/list-identities.md +0 -3
- package/docs/examples/users/list-logs.md +0 -3
- package/docs/examples/users/list-memberships.md +0 -4
- package/docs/examples/users/list-mfa-factors.md +0 -2
- package/docs/examples/users/list-sessions.md +0 -2
- package/docs/examples/users/list-targets.md +0 -3
- package/docs/examples/users/list.md +0 -3
- package/docs/examples/users/update-email-verification.md +0 -3
- package/docs/examples/users/update-email.md +0 -3
- package/docs/examples/users/update-labels.md +0 -3
- package/docs/examples/users/update-mfa-recovery-codes.md +0 -2
- package/docs/examples/users/update-mfa.md +0 -3
- package/docs/examples/users/update-name.md +0 -3
- package/docs/examples/users/update-password.md +0 -3
- package/docs/examples/users/update-phone-verification.md +0 -3
- package/docs/examples/users/update-phone.md +0 -3
- package/docs/examples/users/update-prefs.md +0 -3
- package/docs/examples/users/update-status.md +0 -3
- package/docs/examples/users/update-target.md +0 -6
- package/docs/examples/vcs/create-repository-detection.md +0 -5
- package/docs/examples/vcs/create-repository.md +0 -4
- package/docs/examples/vcs/delete-installation.md +0 -2
- package/docs/examples/vcs/get-installation.md +0 -2
- package/docs/examples/vcs/get-repository-contents.md +0 -5
- package/docs/examples/vcs/get-repository.md +0 -3
- package/docs/examples/vcs/list-installations.md +0 -3
- package/docs/examples/vcs/list-repositories.md +0 -4
- package/docs/examples/vcs/list-repository-branches.md +0 -3
- package/docs/examples/vcs/update-external-deployments.md +0 -4
- package/functions/Starter function/.prettierrc.json +0 -6
- package/functions/Starter function/README.md +0 -48
- package/functions/Starter function/package-lock.json +0 -60
- package/functions/Starter function/package.json +0 -16
- package/functions/Starter function/src/main.js +0 -35
- package/generate/appwrite.d.ts +0 -55
- package/generate/appwrite.db.ts +0 -75
- package/index.js +0 -109
- package/lib/client-generation/languages/typescript.js +0 -65
- package/lib/client.js +0 -259
- package/lib/commands/account.js +0 -2074
- package/lib/commands/avatars.js +0 -491
- package/lib/commands/console.js +0 -129
- package/lib/commands/databases.js +0 -2972
- package/lib/commands/functions.js +0 -1737
- package/lib/commands/generic.js +0 -328
- package/lib/commands/graphql.js +0 -128
- package/lib/commands/health.js +0 -891
- package/lib/commands/init.js +0 -566
- package/lib/commands/locale.js +0 -324
- package/lib/commands/messaging.js +0 -2970
- package/lib/commands/migrations.js +0 -751
- package/lib/commands/organizations.js +0 -48
- package/lib/commands/project.js +0 -308
- package/lib/commands/projects.js +0 -2615
- package/lib/commands/proxy.js +0 -406
- package/lib/commands/pull.js +0 -474
- package/lib/commands/push.js +0 -2117
- package/lib/commands/run.js +0 -330
- package/lib/commands/sites.js +0 -1663
- package/lib/commands/storage.js +0 -990
- package/lib/commands/tables.js +0 -2607
- package/lib/commands/teams.js +0 -682
- package/lib/commands/tokens.js +0 -261
- package/lib/commands/types.js +0 -191
- package/lib/commands/users.js +0 -2035
- package/lib/commands/vcs.js +0 -484
- package/lib/config.js +0 -717
- package/lib/emulation/docker.js +0 -264
- package/lib/emulation/utils.js +0 -186
- package/lib/exception.js +0 -9
- package/lib/id.js +0 -30
- package/lib/paginate.js +0 -52
- package/lib/parser.js +0 -246
- package/lib/questions.js +0 -1006
- package/lib/sdks.js +0 -60
- package/lib/spinner.js +0 -104
- package/lib/type-generation/attribute.js +0 -16
- package/lib/type-generation/languages/dart.js +0 -196
- package/lib/type-generation/languages/java.js +0 -130
- package/lib/type-generation/languages/javascript.js +0 -102
- package/lib/type-generation/languages/kotlin.js +0 -85
- package/lib/type-generation/languages/language.js +0 -125
- package/lib/type-generation/languages/php.js +0 -110
- package/lib/type-generation/languages/swift.js +0 -169
- package/lib/type-generation/languages/typescript.js +0 -105
- package/lib/utils.js +0 -289
- package/lib/validations.js +0 -17
- package/scoop/appwrite.json +0 -30
- package/sites/JavaScript starter2/.env.example +0 -3
- package/sites/JavaScript starter2/LICENSE +0 -21
- package/sites/JavaScript starter2/images/appwrite.svg +0 -8
- package/sites/JavaScript starter2/images/javascript.svg +0 -5
- package/sites/JavaScript starter2/index.html +0 -250
- package/sites/JavaScript starter2/lib/appwrite.js +0 -10
- package/sites/JavaScript starter2/package-lock.json +0 -1431
- package/sites/JavaScript starter2/package.json +0 -21
- package/sites/JavaScript starter2/readme.md +0 -26
- package/sites/JavaScript starter2/src/javascript.svg +0 -1
- package/sites/JavaScript starter2/style/app.css +0 -20
- package/sites/JavaScript starter2/vite.config.js +0 -7
|
@@ -0,0 +1,2355 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { parse as parseDotenv } from "dotenv";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import inquirer from "inquirer";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import ID from "../id.js";
|
|
7
|
+
import {
|
|
8
|
+
localConfig,
|
|
9
|
+
globalConfig,
|
|
10
|
+
KeysFunction,
|
|
11
|
+
KeysSite,
|
|
12
|
+
KeysTopics,
|
|
13
|
+
KeysStorage,
|
|
14
|
+
KeysTeams,
|
|
15
|
+
KeysCollection,
|
|
16
|
+
KeysTable,
|
|
17
|
+
} from "../config.js";
|
|
18
|
+
import type { SettingsType, ConfigType } from "./config.js";
|
|
19
|
+
import { createSettingsObject } from "../utils.js";
|
|
20
|
+
import { Spinner, SPINNER_DOTS } from "../spinner.js";
|
|
21
|
+
import { paginate } from "../paginate.js";
|
|
22
|
+
import { pushDeployment } from "./utils/deployment.js";
|
|
23
|
+
import {
|
|
24
|
+
questionsPushBuckets,
|
|
25
|
+
questionsPushTeams,
|
|
26
|
+
questionsPushFunctions,
|
|
27
|
+
questionsPushSites,
|
|
28
|
+
questionsGetEntrypoint,
|
|
29
|
+
questionsPushCollections,
|
|
30
|
+
questionsPushTables,
|
|
31
|
+
questionsPushMessagingTopics,
|
|
32
|
+
questionsPushResources,
|
|
33
|
+
} from "../questions.js";
|
|
34
|
+
import {
|
|
35
|
+
cliConfig,
|
|
36
|
+
actionRunner,
|
|
37
|
+
success,
|
|
38
|
+
warn,
|
|
39
|
+
log,
|
|
40
|
+
hint,
|
|
41
|
+
error,
|
|
42
|
+
commandDescriptions,
|
|
43
|
+
drawTable,
|
|
44
|
+
} from "../parser.js";
|
|
45
|
+
import {
|
|
46
|
+
getProxyService,
|
|
47
|
+
getConsoleService,
|
|
48
|
+
getFunctionsService,
|
|
49
|
+
getSitesService,
|
|
50
|
+
getDatabasesService,
|
|
51
|
+
getTablesDBService,
|
|
52
|
+
getStorageService,
|
|
53
|
+
getMessagingService,
|
|
54
|
+
getTeamsService,
|
|
55
|
+
getProjectsService,
|
|
56
|
+
} from "../services.js";
|
|
57
|
+
import { sdkForProject, sdkForConsole } from "../sdks.js";
|
|
58
|
+
import {
|
|
59
|
+
ApiService,
|
|
60
|
+
AuthMethod,
|
|
61
|
+
AppwriteException,
|
|
62
|
+
Client,
|
|
63
|
+
Query,
|
|
64
|
+
} from "@appwrite.io/console";
|
|
65
|
+
import { checkDeployConditions } from "../utils.js";
|
|
66
|
+
import { Pools } from "./utils/pools.js";
|
|
67
|
+
import { Attributes, Collection } from "./utils/attributes.js";
|
|
68
|
+
import {
|
|
69
|
+
getConfirmation,
|
|
70
|
+
approveChanges,
|
|
71
|
+
getObjectChanges,
|
|
72
|
+
} from "./utils/change-approval.js";
|
|
73
|
+
import { checkAndApplyTablesDBChanges } from "./utils/database-sync.js";
|
|
74
|
+
|
|
75
|
+
const POLL_DEBOUNCE = 2000; // Milliseconds
|
|
76
|
+
const POLL_DEFAULT_VALUE = 30;
|
|
77
|
+
|
|
78
|
+
export interface PushOptions {
|
|
79
|
+
all?: boolean;
|
|
80
|
+
settings?: boolean;
|
|
81
|
+
functions?: boolean;
|
|
82
|
+
sites?: boolean;
|
|
83
|
+
collections?: boolean;
|
|
84
|
+
tables?: boolean;
|
|
85
|
+
buckets?: boolean;
|
|
86
|
+
teams?: boolean;
|
|
87
|
+
topics?: boolean;
|
|
88
|
+
skipDeprecated?: boolean;
|
|
89
|
+
functionOptions?: {
|
|
90
|
+
async?: boolean;
|
|
91
|
+
code?: boolean;
|
|
92
|
+
withVariables?: boolean;
|
|
93
|
+
};
|
|
94
|
+
siteOptions?: {
|
|
95
|
+
async?: boolean;
|
|
96
|
+
code?: boolean;
|
|
97
|
+
withVariables?: boolean;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface PushSiteOptions {
|
|
102
|
+
siteId?: string;
|
|
103
|
+
async?: boolean;
|
|
104
|
+
code?: boolean;
|
|
105
|
+
withVariables?: boolean;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface PushFunctionOptions {
|
|
109
|
+
functionId?: string;
|
|
110
|
+
async?: boolean;
|
|
111
|
+
code?: boolean;
|
|
112
|
+
withVariables?: boolean;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface PushTableOptions {
|
|
116
|
+
attempts?: number;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class Push {
|
|
120
|
+
private projectClient: Client;
|
|
121
|
+
private consoleClient: Client;
|
|
122
|
+
|
|
123
|
+
constructor(projectClient: Client, consoleClient: Client) {
|
|
124
|
+
this.projectClient = projectClient;
|
|
125
|
+
this.consoleClient = consoleClient;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public async pushResources(
|
|
129
|
+
config: ConfigType,
|
|
130
|
+
options: PushOptions = { all: true, skipDeprecated: true },
|
|
131
|
+
): Promise<{
|
|
132
|
+
results: Record<string, any>;
|
|
133
|
+
errors: any[];
|
|
134
|
+
}> {
|
|
135
|
+
const { skipDeprecated = true } = options;
|
|
136
|
+
const results: Record<string, any> = {};
|
|
137
|
+
const allErrors: any[] = [];
|
|
138
|
+
const shouldPushAll = options.all === true;
|
|
139
|
+
|
|
140
|
+
// Push settings
|
|
141
|
+
if (
|
|
142
|
+
(shouldPushAll || options.settings) &&
|
|
143
|
+
(config.projectName || config.settings)
|
|
144
|
+
) {
|
|
145
|
+
try {
|
|
146
|
+
log("Pushing settings ...");
|
|
147
|
+
await this.pushSettings({
|
|
148
|
+
projectId: config.projectId,
|
|
149
|
+
projectName: config.projectName,
|
|
150
|
+
settings: config.settings,
|
|
151
|
+
});
|
|
152
|
+
results.settings = { success: true };
|
|
153
|
+
} catch (e: any) {
|
|
154
|
+
allErrors.push(e);
|
|
155
|
+
results.settings = { success: false, error: e.message };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Push buckets
|
|
160
|
+
if (
|
|
161
|
+
(shouldPushAll || options.buckets) &&
|
|
162
|
+
config.buckets &&
|
|
163
|
+
config.buckets.length > 0
|
|
164
|
+
) {
|
|
165
|
+
try {
|
|
166
|
+
log("Pushing buckets ...");
|
|
167
|
+
const result = await this.pushBuckets(config.buckets);
|
|
168
|
+
results.buckets = result;
|
|
169
|
+
allErrors.push(...result.errors);
|
|
170
|
+
} catch (e: any) {
|
|
171
|
+
allErrors.push(e);
|
|
172
|
+
results.buckets = { successfullyPushed: 0, errors: [e] };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Push teams
|
|
177
|
+
if (
|
|
178
|
+
(shouldPushAll || options.teams) &&
|
|
179
|
+
config.teams &&
|
|
180
|
+
config.teams.length > 0
|
|
181
|
+
) {
|
|
182
|
+
try {
|
|
183
|
+
log("Pushing teams ...");
|
|
184
|
+
const result = await this.pushTeams(config.teams);
|
|
185
|
+
results.teams = result;
|
|
186
|
+
allErrors.push(...result.errors);
|
|
187
|
+
} catch (e: any) {
|
|
188
|
+
allErrors.push(e);
|
|
189
|
+
results.teams = { successfullyPushed: 0, errors: [e] };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Push messaging topics
|
|
194
|
+
if (
|
|
195
|
+
(shouldPushAll || options.topics) &&
|
|
196
|
+
config.topics &&
|
|
197
|
+
config.topics.length > 0
|
|
198
|
+
) {
|
|
199
|
+
try {
|
|
200
|
+
log("Pushing topics ...");
|
|
201
|
+
const result = await this.pushMessagingTopics(config.topics);
|
|
202
|
+
results.topics = result;
|
|
203
|
+
allErrors.push(...result.errors);
|
|
204
|
+
} catch (e: any) {
|
|
205
|
+
allErrors.push(e);
|
|
206
|
+
results.topics = { successfullyPushed: 0, errors: [e] };
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Push functions
|
|
211
|
+
if (
|
|
212
|
+
(shouldPushAll || options.functions) &&
|
|
213
|
+
config.functions &&
|
|
214
|
+
config.functions.length > 0
|
|
215
|
+
) {
|
|
216
|
+
try {
|
|
217
|
+
log("Pushing functions ...");
|
|
218
|
+
const result = await this.pushFunctions(
|
|
219
|
+
config.functions,
|
|
220
|
+
options.functionOptions,
|
|
221
|
+
);
|
|
222
|
+
results.functions = result;
|
|
223
|
+
allErrors.push(...result.errors);
|
|
224
|
+
} catch (e: any) {
|
|
225
|
+
allErrors.push(e);
|
|
226
|
+
results.functions = {
|
|
227
|
+
successfullyPushed: 0,
|
|
228
|
+
successfullyDeployed: 0,
|
|
229
|
+
failedDeployments: [],
|
|
230
|
+
errors: [e],
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Push sites
|
|
236
|
+
if (
|
|
237
|
+
(shouldPushAll || options.sites) &&
|
|
238
|
+
config.sites &&
|
|
239
|
+
config.sites.length > 0
|
|
240
|
+
) {
|
|
241
|
+
try {
|
|
242
|
+
log("Pushing sites ...");
|
|
243
|
+
const result = await this.pushSites(config.sites, options.siteOptions);
|
|
244
|
+
results.sites = result;
|
|
245
|
+
allErrors.push(...result.errors);
|
|
246
|
+
} catch (e: any) {
|
|
247
|
+
allErrors.push(e);
|
|
248
|
+
results.sites = {
|
|
249
|
+
successfullyPushed: 0,
|
|
250
|
+
successfullyDeployed: 0,
|
|
251
|
+
failedDeployments: [],
|
|
252
|
+
errors: [e],
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Push tables
|
|
258
|
+
if (
|
|
259
|
+
(shouldPushAll || options.tables) &&
|
|
260
|
+
config.tables &&
|
|
261
|
+
config.tables.length > 0
|
|
262
|
+
) {
|
|
263
|
+
try {
|
|
264
|
+
log("Pushing tables ...");
|
|
265
|
+
const result = await this.pushTables(config.tables);
|
|
266
|
+
results.tables = result;
|
|
267
|
+
allErrors.push(...result.errors);
|
|
268
|
+
} catch (e: any) {
|
|
269
|
+
allErrors.push(e);
|
|
270
|
+
results.tables = { successfullyPushed: 0, errors: [e] };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Push collections (unless skipDeprecated is true)
|
|
275
|
+
if (
|
|
276
|
+
!skipDeprecated &&
|
|
277
|
+
(shouldPushAll || options.collections) &&
|
|
278
|
+
config.collections &&
|
|
279
|
+
config.collections.length > 0
|
|
280
|
+
) {
|
|
281
|
+
try {
|
|
282
|
+
log("Pushing collections ...");
|
|
283
|
+
// Add database names to collections
|
|
284
|
+
const collectionsWithDbNames = config.collections.map(
|
|
285
|
+
(collection: any) => {
|
|
286
|
+
const database = config.databases?.find(
|
|
287
|
+
(db: any) => db.$id === collection.databaseId,
|
|
288
|
+
);
|
|
289
|
+
return {
|
|
290
|
+
...collection,
|
|
291
|
+
databaseName: database?.name ?? collection.databaseId,
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
);
|
|
295
|
+
const result = await this.pushCollections(collectionsWithDbNames);
|
|
296
|
+
results.collections = result;
|
|
297
|
+
allErrors.push(...result.errors);
|
|
298
|
+
} catch (e: any) {
|
|
299
|
+
allErrors.push(e);
|
|
300
|
+
results.collections = { successfullyPushed: 0, errors: [e] };
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return {
|
|
305
|
+
results,
|
|
306
|
+
errors: allErrors,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
public async pushSettings(config: {
|
|
311
|
+
projectId: string;
|
|
312
|
+
projectName?: string;
|
|
313
|
+
settings?: SettingsType;
|
|
314
|
+
}): Promise<void> {
|
|
315
|
+
const projectsService = await getProjectsService(this.consoleClient);
|
|
316
|
+
const projectId = config.projectId;
|
|
317
|
+
const projectName = config.projectName;
|
|
318
|
+
const settings = config.settings ?? {};
|
|
319
|
+
|
|
320
|
+
if (projectName) {
|
|
321
|
+
await projectsService.update({
|
|
322
|
+
projectId: projectId,
|
|
323
|
+
name: projectName,
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (settings.services) {
|
|
328
|
+
for (let [service, status] of Object.entries(settings.services)) {
|
|
329
|
+
await projectsService.updateServiceStatus({
|
|
330
|
+
projectId: projectId,
|
|
331
|
+
service: service as ApiService,
|
|
332
|
+
status: status,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (settings.auth) {
|
|
338
|
+
if (settings.auth.security) {
|
|
339
|
+
await projectsService.updateAuthDuration({
|
|
340
|
+
projectId,
|
|
341
|
+
duration: settings.auth.security.duration,
|
|
342
|
+
});
|
|
343
|
+
await projectsService.updateAuthLimit({
|
|
344
|
+
projectId,
|
|
345
|
+
limit: settings.auth.security.limit,
|
|
346
|
+
});
|
|
347
|
+
await projectsService.updateAuthSessionsLimit({
|
|
348
|
+
projectId,
|
|
349
|
+
limit: settings.auth.security.sessionsLimit,
|
|
350
|
+
});
|
|
351
|
+
await projectsService.updateAuthPasswordDictionary({
|
|
352
|
+
projectId,
|
|
353
|
+
enabled: settings.auth.security.passwordDictionary,
|
|
354
|
+
});
|
|
355
|
+
await projectsService.updateAuthPasswordHistory({
|
|
356
|
+
projectId,
|
|
357
|
+
limit: settings.auth.security.passwordHistory,
|
|
358
|
+
});
|
|
359
|
+
await projectsService.updatePersonalDataCheck({
|
|
360
|
+
projectId,
|
|
361
|
+
enabled: settings.auth.security.personalDataCheck,
|
|
362
|
+
});
|
|
363
|
+
await projectsService.updateSessionAlerts({
|
|
364
|
+
projectId,
|
|
365
|
+
alerts: settings.auth.security.sessionAlerts,
|
|
366
|
+
});
|
|
367
|
+
await projectsService.updateMockNumbers({
|
|
368
|
+
projectId,
|
|
369
|
+
numbers: settings.auth.security.mockNumbers,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (settings.auth.methods) {
|
|
374
|
+
for (let [method, status] of Object.entries(settings.auth.methods)) {
|
|
375
|
+
await projectsService.updateAuthStatus({
|
|
376
|
+
projectId,
|
|
377
|
+
method: method as AuthMethod,
|
|
378
|
+
status: status,
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
public async pushBuckets(buckets: any[]): Promise<{
|
|
386
|
+
successfullyPushed: number;
|
|
387
|
+
errors: any[];
|
|
388
|
+
}> {
|
|
389
|
+
let successfullyPushed = 0;
|
|
390
|
+
const errors: any[] = [];
|
|
391
|
+
|
|
392
|
+
for (const bucket of buckets) {
|
|
393
|
+
try {
|
|
394
|
+
log(`Pushing bucket ${chalk.bold(bucket["name"])} ...`);
|
|
395
|
+
const storageService = await getStorageService(this.projectClient);
|
|
396
|
+
|
|
397
|
+
try {
|
|
398
|
+
await storageService.getBucket(bucket["$id"]);
|
|
399
|
+
await storageService.updateBucket({
|
|
400
|
+
bucketId: bucket["$id"],
|
|
401
|
+
name: bucket.name,
|
|
402
|
+
permissions: bucket["$permissions"],
|
|
403
|
+
fileSecurity: bucket.fileSecurity,
|
|
404
|
+
enabled: bucket.enabled,
|
|
405
|
+
maximumFileSize: bucket.maximumFileSize,
|
|
406
|
+
allowedFileExtensions: bucket.allowedFileExtensions,
|
|
407
|
+
encryption: bucket.encryption,
|
|
408
|
+
antivirus: bucket.antivirus,
|
|
409
|
+
compression: bucket.compression,
|
|
410
|
+
});
|
|
411
|
+
} catch (e: unknown) {
|
|
412
|
+
if (e instanceof AppwriteException && Number(e.code) === 404) {
|
|
413
|
+
await storageService.createBucket({
|
|
414
|
+
bucketId: bucket["$id"],
|
|
415
|
+
name: bucket.name,
|
|
416
|
+
permissions: bucket["$permissions"],
|
|
417
|
+
fileSecurity: bucket.fileSecurity,
|
|
418
|
+
enabled: bucket.enabled,
|
|
419
|
+
maximumFileSize: bucket.maximumFileSize,
|
|
420
|
+
allowedFileExtensions: bucket.allowedFileExtensions,
|
|
421
|
+
compression: bucket.compression,
|
|
422
|
+
encryption: bucket.encryption,
|
|
423
|
+
antivirus: bucket.antivirus,
|
|
424
|
+
});
|
|
425
|
+
} else {
|
|
426
|
+
throw e;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
successfullyPushed++;
|
|
431
|
+
} catch (e: any) {
|
|
432
|
+
errors.push(e);
|
|
433
|
+
error(`Failed to push bucket ${bucket["name"]}: ${e.message}`);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
return {
|
|
438
|
+
successfullyPushed,
|
|
439
|
+
errors,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
public async pushTeams(teams: any[]): Promise<{
|
|
444
|
+
successfullyPushed: number;
|
|
445
|
+
errors: any[];
|
|
446
|
+
}> {
|
|
447
|
+
let successfullyPushed = 0;
|
|
448
|
+
const errors: any[] = [];
|
|
449
|
+
|
|
450
|
+
for (const team of teams) {
|
|
451
|
+
try {
|
|
452
|
+
log(`Pushing team ${chalk.bold(team["name"])} ...`);
|
|
453
|
+
const teamsService = await getTeamsService(this.projectClient);
|
|
454
|
+
|
|
455
|
+
try {
|
|
456
|
+
await teamsService.get(team["$id"]);
|
|
457
|
+
await teamsService.updateName({
|
|
458
|
+
teamId: team["$id"],
|
|
459
|
+
name: team.name,
|
|
460
|
+
});
|
|
461
|
+
} catch (e: unknown) {
|
|
462
|
+
if (e instanceof AppwriteException && Number(e.code) === 404) {
|
|
463
|
+
await teamsService.create({
|
|
464
|
+
teamId: team["$id"],
|
|
465
|
+
name: team.name,
|
|
466
|
+
});
|
|
467
|
+
} else {
|
|
468
|
+
throw e;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
successfullyPushed++;
|
|
473
|
+
} catch (e: any) {
|
|
474
|
+
errors.push(e);
|
|
475
|
+
error(`Failed to push team ${team["name"]}: ${e.message}`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return {
|
|
480
|
+
successfullyPushed,
|
|
481
|
+
errors,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
public async pushMessagingTopics(topics: any[]): Promise<{
|
|
486
|
+
successfullyPushed: number;
|
|
487
|
+
errors: any[];
|
|
488
|
+
}> {
|
|
489
|
+
let successfullyPushed = 0;
|
|
490
|
+
const errors: any[] = [];
|
|
491
|
+
|
|
492
|
+
for (const topic of topics) {
|
|
493
|
+
try {
|
|
494
|
+
log(`Pushing topic ${chalk.bold(topic["name"])} ...`);
|
|
495
|
+
const messagingService = await getMessagingService(this.projectClient);
|
|
496
|
+
|
|
497
|
+
try {
|
|
498
|
+
await messagingService.getTopic(topic["$id"]);
|
|
499
|
+
await messagingService.updateTopic({
|
|
500
|
+
topicId: topic["$id"],
|
|
501
|
+
name: topic.name,
|
|
502
|
+
subscribe: topic.subscribe,
|
|
503
|
+
});
|
|
504
|
+
} catch (e: unknown) {
|
|
505
|
+
if (e instanceof AppwriteException && Number(e.code) === 404) {
|
|
506
|
+
await messagingService.createTopic({
|
|
507
|
+
topicId: topic["$id"],
|
|
508
|
+
name: topic.name,
|
|
509
|
+
subscribe: topic.subscribe,
|
|
510
|
+
});
|
|
511
|
+
} else {
|
|
512
|
+
throw e;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
success(`Created ${topic.name} ( ${topic["$id"]} )`);
|
|
517
|
+
successfullyPushed++;
|
|
518
|
+
} catch (e: any) {
|
|
519
|
+
errors.push(e);
|
|
520
|
+
error(`Failed to push topic ${topic["name"]}: ${e.message}`);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return {
|
|
525
|
+
successfullyPushed,
|
|
526
|
+
errors,
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
public async pushFunctions(
|
|
531
|
+
functions: any[],
|
|
532
|
+
options: {
|
|
533
|
+
async?: boolean;
|
|
534
|
+
code?: boolean;
|
|
535
|
+
withVariables?: boolean;
|
|
536
|
+
} = {},
|
|
537
|
+
): Promise<{
|
|
538
|
+
successfullyPushed: number;
|
|
539
|
+
successfullyDeployed: number;
|
|
540
|
+
failedDeployments: any[];
|
|
541
|
+
errors: any[];
|
|
542
|
+
}> {
|
|
543
|
+
const { async: asyncDeploy, code, withVariables } = options;
|
|
544
|
+
|
|
545
|
+
Spinner.start(false);
|
|
546
|
+
let successfullyPushed = 0;
|
|
547
|
+
let successfullyDeployed = 0;
|
|
548
|
+
const failedDeployments: any[] = [];
|
|
549
|
+
const errors: any[] = [];
|
|
550
|
+
|
|
551
|
+
await Promise.all(
|
|
552
|
+
functions.map(async (func: any) => {
|
|
553
|
+
let response: any = {};
|
|
554
|
+
|
|
555
|
+
const ignore = func.ignore ? "appwrite.config.json" : ".gitignore";
|
|
556
|
+
let functionExists = false;
|
|
557
|
+
let deploymentCreated = false;
|
|
558
|
+
|
|
559
|
+
const updaterRow = new Spinner({
|
|
560
|
+
status: "",
|
|
561
|
+
resource: func.name,
|
|
562
|
+
id: func["$id"],
|
|
563
|
+
end: `Ignoring using: ${ignore}`,
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
updaterRow.update({ status: "Getting" }).startSpinner(SPINNER_DOTS);
|
|
567
|
+
const functionsService = await getFunctionsService(this.projectClient);
|
|
568
|
+
try {
|
|
569
|
+
response = await functionsService.get({ functionId: func["$id"] });
|
|
570
|
+
functionExists = true;
|
|
571
|
+
if (response.runtime !== func.runtime) {
|
|
572
|
+
updaterRow.fail({
|
|
573
|
+
errorMessage: `Runtime mismatch! (local=${func.runtime},remote=${response.runtime}) Please delete remote function or update your appwrite.config.json`,
|
|
574
|
+
});
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
updaterRow
|
|
579
|
+
.update({ status: "Updating" })
|
|
580
|
+
.replaceSpinner(SPINNER_DOTS);
|
|
581
|
+
|
|
582
|
+
response = await functionsService.update({
|
|
583
|
+
functionId: func["$id"],
|
|
584
|
+
name: func.name,
|
|
585
|
+
runtime: func.runtime,
|
|
586
|
+
execute: func.execute,
|
|
587
|
+
events: func.events,
|
|
588
|
+
schedule: func.schedule,
|
|
589
|
+
timeout: func.timeout,
|
|
590
|
+
enabled: func.enabled,
|
|
591
|
+
logging: func.logging,
|
|
592
|
+
entrypoint: func.entrypoint,
|
|
593
|
+
commands: func.commands,
|
|
594
|
+
scopes: func.scopes,
|
|
595
|
+
specification: func.specification,
|
|
596
|
+
});
|
|
597
|
+
} catch (e: any) {
|
|
598
|
+
if (Number(e.code) === 404) {
|
|
599
|
+
functionExists = false;
|
|
600
|
+
} else {
|
|
601
|
+
errors.push(e);
|
|
602
|
+
updaterRow.fail({
|
|
603
|
+
errorMessage:
|
|
604
|
+
e.message ?? "General error occurs please try again",
|
|
605
|
+
});
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (!functionExists) {
|
|
611
|
+
updaterRow
|
|
612
|
+
.update({ status: "Creating" })
|
|
613
|
+
.replaceSpinner(SPINNER_DOTS);
|
|
614
|
+
|
|
615
|
+
try {
|
|
616
|
+
response = await functionsService.create({
|
|
617
|
+
functionId: func.$id,
|
|
618
|
+
name: func.name,
|
|
619
|
+
runtime: func.runtime,
|
|
620
|
+
execute: func.execute,
|
|
621
|
+
events: func.events,
|
|
622
|
+
schedule: func.schedule,
|
|
623
|
+
timeout: func.timeout,
|
|
624
|
+
enabled: func.enabled,
|
|
625
|
+
logging: func.logging,
|
|
626
|
+
entrypoint: func.entrypoint,
|
|
627
|
+
commands: func.commands,
|
|
628
|
+
scopes: func.scopes,
|
|
629
|
+
specification: func.specification,
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
let domain = "";
|
|
633
|
+
try {
|
|
634
|
+
const consoleService = await getConsoleService(
|
|
635
|
+
this.projectClient,
|
|
636
|
+
);
|
|
637
|
+
const variables = await consoleService.variables();
|
|
638
|
+
domain = ID.unique() + "." + variables["_APP_DOMAIN_FUNCTIONS"];
|
|
639
|
+
} catch (error) {
|
|
640
|
+
console.error("Error fetching console variables.");
|
|
641
|
+
throw error;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
try {
|
|
645
|
+
const proxyService = await getProxyService(this.projectClient);
|
|
646
|
+
await proxyService.createFunctionRule(domain, func.$id);
|
|
647
|
+
} catch (error) {
|
|
648
|
+
console.error("Error creating function rule.");
|
|
649
|
+
throw error;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
updaterRow.update({ status: "Created" });
|
|
653
|
+
} catch (e: any) {
|
|
654
|
+
errors.push(e);
|
|
655
|
+
updaterRow.fail({
|
|
656
|
+
errorMessage:
|
|
657
|
+
e.message ?? "General error occurs please try again",
|
|
658
|
+
});
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (withVariables) {
|
|
664
|
+
updaterRow
|
|
665
|
+
.update({ status: "Updating variables" })
|
|
666
|
+
.replaceSpinner(SPINNER_DOTS);
|
|
667
|
+
|
|
668
|
+
const functionsServiceForVars = await getFunctionsService(
|
|
669
|
+
this.projectClient,
|
|
670
|
+
);
|
|
671
|
+
const { variables } = await paginate(
|
|
672
|
+
async (args: any) => {
|
|
673
|
+
return await functionsServiceForVars.listVariables({
|
|
674
|
+
functionId: args.functionId,
|
|
675
|
+
});
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
functionId: func["$id"],
|
|
679
|
+
},
|
|
680
|
+
100,
|
|
681
|
+
"variables",
|
|
682
|
+
);
|
|
683
|
+
|
|
684
|
+
await Promise.all(
|
|
685
|
+
variables.map(async (variable: any) => {
|
|
686
|
+
const functionsServiceDel = await getFunctionsService(
|
|
687
|
+
this.projectClient,
|
|
688
|
+
);
|
|
689
|
+
await functionsServiceDel.deleteVariable({
|
|
690
|
+
functionId: func["$id"],
|
|
691
|
+
variableId: variable["$id"],
|
|
692
|
+
});
|
|
693
|
+
}),
|
|
694
|
+
);
|
|
695
|
+
|
|
696
|
+
const envFileLocation = `${func["path"]}/.env`;
|
|
697
|
+
let envVariables: Array<{ key: string; value: string }> = [];
|
|
698
|
+
try {
|
|
699
|
+
if (fs.existsSync(envFileLocation)) {
|
|
700
|
+
const envObject = parseDotenv(
|
|
701
|
+
fs.readFileSync(envFileLocation, "utf8"),
|
|
702
|
+
);
|
|
703
|
+
envVariables = Object.entries(envObject || {}).map(
|
|
704
|
+
([key, value]) => ({ key, value }),
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
} catch (error) {
|
|
708
|
+
envVariables = [];
|
|
709
|
+
}
|
|
710
|
+
await Promise.all(
|
|
711
|
+
envVariables.map(async (variable) => {
|
|
712
|
+
const functionsServiceCreate = await getFunctionsService(
|
|
713
|
+
this.projectClient,
|
|
714
|
+
);
|
|
715
|
+
await functionsServiceCreate.createVariable({
|
|
716
|
+
functionId: func["$id"],
|
|
717
|
+
key: variable.key,
|
|
718
|
+
value: variable.value,
|
|
719
|
+
secret: false,
|
|
720
|
+
});
|
|
721
|
+
}),
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
if (code === false) {
|
|
726
|
+
successfullyPushed++;
|
|
727
|
+
successfullyDeployed++;
|
|
728
|
+
updaterRow.update({ status: "Pushed" });
|
|
729
|
+
updaterRow.stopSpinner();
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
try {
|
|
734
|
+
updaterRow.update({ status: "Pushing" }).replaceSpinner(SPINNER_DOTS);
|
|
735
|
+
const functionsServiceDeploy = await getFunctionsService(
|
|
736
|
+
this.projectClient,
|
|
737
|
+
);
|
|
738
|
+
|
|
739
|
+
const result = await pushDeployment({
|
|
740
|
+
resourcePath: func.path,
|
|
741
|
+
createDeployment: async (codeFile) => {
|
|
742
|
+
return await functionsServiceDeploy.createDeployment({
|
|
743
|
+
functionId: func["$id"],
|
|
744
|
+
entrypoint: func.entrypoint,
|
|
745
|
+
commands: func.commands,
|
|
746
|
+
code: codeFile,
|
|
747
|
+
activate: true,
|
|
748
|
+
});
|
|
749
|
+
},
|
|
750
|
+
pollForStatus: false,
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
response = result.deployment;
|
|
754
|
+
updaterRow.update({ status: "Pushed" });
|
|
755
|
+
|
|
756
|
+
deploymentCreated = true;
|
|
757
|
+
successfullyPushed++;
|
|
758
|
+
} catch (e: any) {
|
|
759
|
+
errors.push(e);
|
|
760
|
+
|
|
761
|
+
switch (e.code) {
|
|
762
|
+
case "ENOENT":
|
|
763
|
+
updaterRow.fail({
|
|
764
|
+
errorMessage: "Not found in the current directory. Skipping...",
|
|
765
|
+
});
|
|
766
|
+
break;
|
|
767
|
+
default:
|
|
768
|
+
updaterRow.fail({
|
|
769
|
+
errorMessage:
|
|
770
|
+
e.message ?? "An unknown error occurred. Please try again.",
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
if (deploymentCreated && !asyncDeploy) {
|
|
776
|
+
try {
|
|
777
|
+
const deploymentId = response["$id"];
|
|
778
|
+
updaterRow.update({
|
|
779
|
+
status: "Deploying",
|
|
780
|
+
end: "Checking deployment status...",
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
while (true) {
|
|
784
|
+
const functionsServicePoll = await getFunctionsService(
|
|
785
|
+
this.projectClient,
|
|
786
|
+
);
|
|
787
|
+
response = await functionsServicePoll.getDeployment({
|
|
788
|
+
functionId: func["$id"],
|
|
789
|
+
deploymentId: deploymentId,
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
const status = response["status"];
|
|
793
|
+
if (status === "ready") {
|
|
794
|
+
successfullyDeployed++;
|
|
795
|
+
|
|
796
|
+
let url = "";
|
|
797
|
+
const proxyServiceUrl = await getProxyService(
|
|
798
|
+
this.projectClient,
|
|
799
|
+
);
|
|
800
|
+
const res = await proxyServiceUrl.listRules({
|
|
801
|
+
queries: [
|
|
802
|
+
Query.limit(1),
|
|
803
|
+
Query.equal("deploymentResourceType", "function"),
|
|
804
|
+
Query.equal("deploymentResourceId", func["$id"]),
|
|
805
|
+
Query.equal("trigger", "manual"),
|
|
806
|
+
],
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
if (Number(res.total) === 1) {
|
|
810
|
+
url = `https://${res.rules[0].domain}`;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
updaterRow.update({ status: "Deployed", end: url });
|
|
814
|
+
|
|
815
|
+
break;
|
|
816
|
+
} else if (status === "failed") {
|
|
817
|
+
failedDeployments.push({
|
|
818
|
+
name: func["name"],
|
|
819
|
+
$id: func["$id"],
|
|
820
|
+
deployment: response["$id"],
|
|
821
|
+
});
|
|
822
|
+
updaterRow.fail({ errorMessage: `Failed to deploy` });
|
|
823
|
+
|
|
824
|
+
break;
|
|
825
|
+
} else {
|
|
826
|
+
updaterRow.update({
|
|
827
|
+
status: "Deploying",
|
|
828
|
+
end: `Current status: ${status}`,
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
await new Promise((resolve) =>
|
|
833
|
+
setTimeout(resolve, POLL_DEBOUNCE * 1.5),
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
} catch (e: any) {
|
|
837
|
+
errors.push(e);
|
|
838
|
+
updaterRow.fail({
|
|
839
|
+
errorMessage:
|
|
840
|
+
e.message ?? "Unknown error occurred. Please try again",
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
updaterRow.stopSpinner();
|
|
846
|
+
}),
|
|
847
|
+
);
|
|
848
|
+
|
|
849
|
+
Spinner.stop();
|
|
850
|
+
|
|
851
|
+
return {
|
|
852
|
+
successfullyPushed,
|
|
853
|
+
successfullyDeployed,
|
|
854
|
+
failedDeployments,
|
|
855
|
+
errors,
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
public async pushSites(
|
|
860
|
+
sites: any[],
|
|
861
|
+
options: {
|
|
862
|
+
async?: boolean;
|
|
863
|
+
code?: boolean;
|
|
864
|
+
withVariables?: boolean;
|
|
865
|
+
} = {},
|
|
866
|
+
): Promise<{
|
|
867
|
+
successfullyPushed: number;
|
|
868
|
+
successfullyDeployed: number;
|
|
869
|
+
failedDeployments: any[];
|
|
870
|
+
errors: any[];
|
|
871
|
+
}> {
|
|
872
|
+
const { async: asyncDeploy, code, withVariables } = options;
|
|
873
|
+
|
|
874
|
+
Spinner.start(false);
|
|
875
|
+
let successfullyPushed = 0;
|
|
876
|
+
let successfullyDeployed = 0;
|
|
877
|
+
const failedDeployments: any[] = [];
|
|
878
|
+
const errors: any[] = [];
|
|
879
|
+
|
|
880
|
+
await Promise.all(
|
|
881
|
+
sites.map(async (site: any) => {
|
|
882
|
+
let response: any = {};
|
|
883
|
+
|
|
884
|
+
const ignore = site.ignore ? "appwrite.config.json" : ".gitignore";
|
|
885
|
+
let siteExists = false;
|
|
886
|
+
let deploymentCreated = false;
|
|
887
|
+
|
|
888
|
+
const updaterRow = new Spinner({
|
|
889
|
+
status: "",
|
|
890
|
+
resource: site.name,
|
|
891
|
+
id: site["$id"],
|
|
892
|
+
end: `Ignoring using: ${ignore}`,
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
updaterRow.update({ status: "Getting" }).startSpinner(SPINNER_DOTS);
|
|
896
|
+
|
|
897
|
+
const sitesService = await getSitesService(this.projectClient);
|
|
898
|
+
try {
|
|
899
|
+
response = await sitesService.get({ siteId: site["$id"] });
|
|
900
|
+
siteExists = true;
|
|
901
|
+
if (response.framework !== site.framework) {
|
|
902
|
+
updaterRow.fail({
|
|
903
|
+
errorMessage: `Framework mismatch! (local=${site.framework},remote=${response.framework}) Please delete remote site or update your appwrite.config.json`,
|
|
904
|
+
});
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
updaterRow
|
|
909
|
+
.update({ status: "Updating" })
|
|
910
|
+
.replaceSpinner(SPINNER_DOTS);
|
|
911
|
+
|
|
912
|
+
response = await sitesService.update({
|
|
913
|
+
siteId: site["$id"],
|
|
914
|
+
name: site.name,
|
|
915
|
+
framework: site.framework,
|
|
916
|
+
enabled: site.enabled,
|
|
917
|
+
logging: site.logging,
|
|
918
|
+
timeout: site.timeout,
|
|
919
|
+
installCommand: site.installCommand,
|
|
920
|
+
buildCommand: site.buildCommand,
|
|
921
|
+
outputDirectory: site.outputDirectory,
|
|
922
|
+
buildRuntime: site.buildRuntime,
|
|
923
|
+
adapter: site.adapter,
|
|
924
|
+
specification: site.specification,
|
|
925
|
+
});
|
|
926
|
+
} catch (e: any) {
|
|
927
|
+
if (Number(e.code) === 404) {
|
|
928
|
+
siteExists = false;
|
|
929
|
+
} else {
|
|
930
|
+
errors.push(e);
|
|
931
|
+
updaterRow.fail({
|
|
932
|
+
errorMessage:
|
|
933
|
+
e.message ?? "General error occurs please try again",
|
|
934
|
+
});
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
if (!siteExists) {
|
|
940
|
+
updaterRow
|
|
941
|
+
.update({ status: "Creating" })
|
|
942
|
+
.replaceSpinner(SPINNER_DOTS);
|
|
943
|
+
|
|
944
|
+
try {
|
|
945
|
+
response = await sitesService.create({
|
|
946
|
+
siteId: site.$id,
|
|
947
|
+
name: site.name,
|
|
948
|
+
framework: site.framework,
|
|
949
|
+
enabled: site.enabled,
|
|
950
|
+
logging: site.logging,
|
|
951
|
+
timeout: site.timeout,
|
|
952
|
+
installCommand: site.installCommand,
|
|
953
|
+
buildCommand: site.buildCommand,
|
|
954
|
+
outputDirectory: site.outputDirectory,
|
|
955
|
+
buildRuntime: site.buildRuntime,
|
|
956
|
+
adapter: site.adapter,
|
|
957
|
+
specification: site.specification,
|
|
958
|
+
});
|
|
959
|
+
|
|
960
|
+
let domain = "";
|
|
961
|
+
try {
|
|
962
|
+
const consoleService = await getConsoleService(
|
|
963
|
+
this.projectClient,
|
|
964
|
+
);
|
|
965
|
+
const variables = await consoleService.variables();
|
|
966
|
+
domain = ID.unique() + "." + variables["_APP_DOMAIN_SITES"];
|
|
967
|
+
} catch (error) {
|
|
968
|
+
console.error("Error fetching console variables.");
|
|
969
|
+
throw error;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
try {
|
|
973
|
+
const proxyService = await getProxyService(this.projectClient);
|
|
974
|
+
await proxyService.createSiteRule(domain, site.$id);
|
|
975
|
+
} catch (error) {
|
|
976
|
+
console.error("Error creating site rule.");
|
|
977
|
+
throw error;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
updaterRow.update({ status: "Created" });
|
|
981
|
+
} catch (e: any) {
|
|
982
|
+
errors.push(e);
|
|
983
|
+
updaterRow.fail({
|
|
984
|
+
errorMessage:
|
|
985
|
+
e.message ?? "General error occurs please try again",
|
|
986
|
+
});
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
if (withVariables) {
|
|
992
|
+
updaterRow
|
|
993
|
+
.update({ status: "Creating variables" })
|
|
994
|
+
.replaceSpinner(SPINNER_DOTS);
|
|
995
|
+
|
|
996
|
+
const sitesServiceForVars = await getSitesService(this.projectClient);
|
|
997
|
+
const { variables } = await paginate(
|
|
998
|
+
async (args: any) => {
|
|
999
|
+
return await sitesServiceForVars.listVariables({
|
|
1000
|
+
siteId: args.siteId,
|
|
1001
|
+
});
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
siteId: site["$id"],
|
|
1005
|
+
},
|
|
1006
|
+
100,
|
|
1007
|
+
"variables",
|
|
1008
|
+
);
|
|
1009
|
+
|
|
1010
|
+
await Promise.all(
|
|
1011
|
+
variables.map(async (variable: any) => {
|
|
1012
|
+
const sitesServiceDel = await getSitesService(this.projectClient);
|
|
1013
|
+
await sitesServiceDel.deleteVariable({
|
|
1014
|
+
siteId: site["$id"],
|
|
1015
|
+
variableId: variable["$id"],
|
|
1016
|
+
});
|
|
1017
|
+
}),
|
|
1018
|
+
);
|
|
1019
|
+
|
|
1020
|
+
const envFileLocation = `${site["path"]}/.env`;
|
|
1021
|
+
let envVariables: Array<{ key: string; value: string }> = [];
|
|
1022
|
+
try {
|
|
1023
|
+
if (fs.existsSync(envFileLocation)) {
|
|
1024
|
+
const envObject = parseDotenv(
|
|
1025
|
+
fs.readFileSync(envFileLocation, "utf8"),
|
|
1026
|
+
);
|
|
1027
|
+
envVariables = Object.entries(envObject || {}).map(
|
|
1028
|
+
([key, value]) => ({ key, value }),
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
1031
|
+
} catch (error) {
|
|
1032
|
+
envVariables = [];
|
|
1033
|
+
}
|
|
1034
|
+
await Promise.all(
|
|
1035
|
+
envVariables.map(async (variable) => {
|
|
1036
|
+
const sitesServiceCreate = await getSitesService(
|
|
1037
|
+
this.projectClient,
|
|
1038
|
+
);
|
|
1039
|
+
await sitesServiceCreate.createVariable({
|
|
1040
|
+
siteId: site["$id"],
|
|
1041
|
+
key: variable.key,
|
|
1042
|
+
value: variable.value,
|
|
1043
|
+
secret: false,
|
|
1044
|
+
});
|
|
1045
|
+
}),
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
if (code === false) {
|
|
1050
|
+
successfullyPushed++;
|
|
1051
|
+
successfullyDeployed++;
|
|
1052
|
+
updaterRow.update({ status: "Pushed" });
|
|
1053
|
+
updaterRow.stopSpinner();
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
try {
|
|
1058
|
+
updaterRow.update({ status: "Pushing" }).replaceSpinner(SPINNER_DOTS);
|
|
1059
|
+
const sitesServiceDeploy = await getSitesService(this.projectClient);
|
|
1060
|
+
|
|
1061
|
+
const result = await pushDeployment({
|
|
1062
|
+
resourcePath: site.path,
|
|
1063
|
+
createDeployment: async (codeFile) => {
|
|
1064
|
+
return await sitesServiceDeploy.createDeployment({
|
|
1065
|
+
siteId: site["$id"],
|
|
1066
|
+
installCommand: site.installCommand,
|
|
1067
|
+
buildCommand: site.buildCommand,
|
|
1068
|
+
outputDirectory: site.outputDirectory,
|
|
1069
|
+
code: codeFile,
|
|
1070
|
+
activate: true,
|
|
1071
|
+
});
|
|
1072
|
+
},
|
|
1073
|
+
pollForStatus: false,
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
response = result.deployment;
|
|
1077
|
+
updaterRow.update({ status: "Pushed" });
|
|
1078
|
+
deploymentCreated = true;
|
|
1079
|
+
successfullyPushed++;
|
|
1080
|
+
} catch (e: any) {
|
|
1081
|
+
errors.push(e);
|
|
1082
|
+
|
|
1083
|
+
switch (e.code) {
|
|
1084
|
+
case "ENOENT":
|
|
1085
|
+
updaterRow.fail({
|
|
1086
|
+
errorMessage: "Not found in the current directory. Skipping...",
|
|
1087
|
+
});
|
|
1088
|
+
break;
|
|
1089
|
+
default:
|
|
1090
|
+
updaterRow.fail({
|
|
1091
|
+
errorMessage:
|
|
1092
|
+
e.message ?? "An unknown error occurred. Please try again.",
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
if (deploymentCreated && !asyncDeploy) {
|
|
1098
|
+
try {
|
|
1099
|
+
const deploymentId = response["$id"];
|
|
1100
|
+
updaterRow.update({
|
|
1101
|
+
status: "Deploying",
|
|
1102
|
+
end: "Checking deployment status...",
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
while (true) {
|
|
1106
|
+
const sitesServicePoll = await getSitesService(
|
|
1107
|
+
this.projectClient,
|
|
1108
|
+
);
|
|
1109
|
+
response = await sitesServicePoll.getDeployment({
|
|
1110
|
+
siteId: site["$id"],
|
|
1111
|
+
deploymentId: deploymentId,
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
const status = response["status"];
|
|
1115
|
+
if (status === "ready") {
|
|
1116
|
+
successfullyDeployed++;
|
|
1117
|
+
|
|
1118
|
+
let url = "";
|
|
1119
|
+
const proxyServiceUrl = await getProxyService(
|
|
1120
|
+
this.projectClient,
|
|
1121
|
+
);
|
|
1122
|
+
const res = await proxyServiceUrl.listRules([
|
|
1123
|
+
Query.limit(1),
|
|
1124
|
+
Query.equal("deploymentResourceType", "site"),
|
|
1125
|
+
Query.equal("deploymentResourceId", site["$id"]),
|
|
1126
|
+
Query.equal("trigger", "manual"),
|
|
1127
|
+
]);
|
|
1128
|
+
|
|
1129
|
+
if (Number(res.total) === 1) {
|
|
1130
|
+
url = `https://${res.rules[0].domain}`;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
updaterRow.update({ status: "Deployed", end: url });
|
|
1134
|
+
|
|
1135
|
+
break;
|
|
1136
|
+
} else if (status === "failed") {
|
|
1137
|
+
failedDeployments.push({
|
|
1138
|
+
name: site["name"],
|
|
1139
|
+
$id: site["$id"],
|
|
1140
|
+
deployment: response["$id"],
|
|
1141
|
+
});
|
|
1142
|
+
updaterRow.fail({ errorMessage: `Failed to deploy` });
|
|
1143
|
+
|
|
1144
|
+
break;
|
|
1145
|
+
} else {
|
|
1146
|
+
updaterRow.update({
|
|
1147
|
+
status: "Deploying",
|
|
1148
|
+
end: `Current status: ${status}`,
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
await new Promise((resolve) =>
|
|
1153
|
+
setTimeout(resolve, POLL_DEBOUNCE * 1.5),
|
|
1154
|
+
);
|
|
1155
|
+
}
|
|
1156
|
+
} catch (e: any) {
|
|
1157
|
+
errors.push(e);
|
|
1158
|
+
updaterRow.fail({
|
|
1159
|
+
errorMessage:
|
|
1160
|
+
e.message ?? "Unknown error occurred. Please try again",
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
updaterRow.stopSpinner();
|
|
1166
|
+
}),
|
|
1167
|
+
);
|
|
1168
|
+
|
|
1169
|
+
Spinner.stop();
|
|
1170
|
+
|
|
1171
|
+
return {
|
|
1172
|
+
successfullyPushed,
|
|
1173
|
+
successfullyDeployed,
|
|
1174
|
+
failedDeployments,
|
|
1175
|
+
errors,
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
public async pushTables(
|
|
1180
|
+
tables: any[],
|
|
1181
|
+
attempts?: number,
|
|
1182
|
+
): Promise<{
|
|
1183
|
+
successfullyPushed: number;
|
|
1184
|
+
errors: any[];
|
|
1185
|
+
}> {
|
|
1186
|
+
const pollMaxDebounces = attempts ?? POLL_DEFAULT_VALUE;
|
|
1187
|
+
const pools = new Pools(pollMaxDebounces);
|
|
1188
|
+
const attributes = new Attributes(pools);
|
|
1189
|
+
|
|
1190
|
+
let tablesChanged = new Set();
|
|
1191
|
+
const errors: any[] = [];
|
|
1192
|
+
|
|
1193
|
+
// Parallel tables actions
|
|
1194
|
+
await Promise.all(
|
|
1195
|
+
tables.map(async (table: any) => {
|
|
1196
|
+
try {
|
|
1197
|
+
const tablesService = await getTablesDBService(this.projectClient);
|
|
1198
|
+
const remoteTable = await tablesService.getTable({
|
|
1199
|
+
databaseId: table["databaseId"],
|
|
1200
|
+
tableId: table["$id"],
|
|
1201
|
+
});
|
|
1202
|
+
|
|
1203
|
+
const changes: string[] = [];
|
|
1204
|
+
if (remoteTable.name !== table.name) changes.push("name");
|
|
1205
|
+
if (remoteTable.rowSecurity !== table.rowSecurity)
|
|
1206
|
+
changes.push("rowSecurity");
|
|
1207
|
+
if (remoteTable.enabled !== table.enabled) changes.push("enabled");
|
|
1208
|
+
if (
|
|
1209
|
+
JSON.stringify(remoteTable["$permissions"]) !==
|
|
1210
|
+
JSON.stringify(table["$permissions"])
|
|
1211
|
+
)
|
|
1212
|
+
changes.push("permissions");
|
|
1213
|
+
|
|
1214
|
+
if (changes.length > 0) {
|
|
1215
|
+
await tablesService.updateTable(
|
|
1216
|
+
table["databaseId"],
|
|
1217
|
+
table["$id"],
|
|
1218
|
+
table.name,
|
|
1219
|
+
table.rowSecurity,
|
|
1220
|
+
table["$permissions"],
|
|
1221
|
+
);
|
|
1222
|
+
|
|
1223
|
+
success(
|
|
1224
|
+
`Updated ${table.name} ( ${table["$id"]} ) - ${changes.join(", ")}`,
|
|
1225
|
+
);
|
|
1226
|
+
tablesChanged.add(table["$id"]);
|
|
1227
|
+
}
|
|
1228
|
+
table.remoteVersion = remoteTable;
|
|
1229
|
+
|
|
1230
|
+
table.isExisted = true;
|
|
1231
|
+
} catch (e: any) {
|
|
1232
|
+
if (Number(e.code) === 404) {
|
|
1233
|
+
log(
|
|
1234
|
+
`Table ${table.name} does not exist in the project. Creating ... `,
|
|
1235
|
+
);
|
|
1236
|
+
const tablesService = await getTablesDBService(this.projectClient);
|
|
1237
|
+
await tablesService.createTable(
|
|
1238
|
+
table["databaseId"],
|
|
1239
|
+
table["$id"],
|
|
1240
|
+
table.name,
|
|
1241
|
+
table.rowSecurity,
|
|
1242
|
+
table["$permissions"],
|
|
1243
|
+
);
|
|
1244
|
+
|
|
1245
|
+
success(`Created ${table.name} ( ${table["$id"]} )`);
|
|
1246
|
+
tablesChanged.add(table["$id"]);
|
|
1247
|
+
} else {
|
|
1248
|
+
errors.push(e);
|
|
1249
|
+
throw e;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
}),
|
|
1253
|
+
);
|
|
1254
|
+
|
|
1255
|
+
// Serialize attribute actions
|
|
1256
|
+
for (let table of tables) {
|
|
1257
|
+
let columns = table.columns;
|
|
1258
|
+
let indexes = table.indexes;
|
|
1259
|
+
|
|
1260
|
+
if (table.isExisted) {
|
|
1261
|
+
columns = await attributes.attributesToCreate(
|
|
1262
|
+
table.remoteVersion.columns,
|
|
1263
|
+
table.columns,
|
|
1264
|
+
table as Collection,
|
|
1265
|
+
);
|
|
1266
|
+
indexes = await attributes.attributesToCreate(
|
|
1267
|
+
table.remoteVersion.indexes,
|
|
1268
|
+
table.indexes,
|
|
1269
|
+
table as Collection,
|
|
1270
|
+
true,
|
|
1271
|
+
);
|
|
1272
|
+
|
|
1273
|
+
if (
|
|
1274
|
+
Array.isArray(columns) &&
|
|
1275
|
+
columns.length <= 0 &&
|
|
1276
|
+
Array.isArray(indexes) &&
|
|
1277
|
+
indexes.length <= 0
|
|
1278
|
+
) {
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
log(
|
|
1284
|
+
`Pushing table ${table.name} ( ${table["databaseId"]} - ${table["$id"]} ) attributes`,
|
|
1285
|
+
);
|
|
1286
|
+
|
|
1287
|
+
try {
|
|
1288
|
+
await attributes.createColumns(columns, table as Collection);
|
|
1289
|
+
} catch (e) {
|
|
1290
|
+
errors.push(e);
|
|
1291
|
+
throw e;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
try {
|
|
1295
|
+
await attributes.createIndexes(indexes, table as Collection);
|
|
1296
|
+
} catch (e) {
|
|
1297
|
+
errors.push(e);
|
|
1298
|
+
throw e;
|
|
1299
|
+
}
|
|
1300
|
+
tablesChanged.add(table["$id"]);
|
|
1301
|
+
success(`Successfully pushed ${table.name} ( ${table["$id"]} )`);
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
return {
|
|
1305
|
+
successfullyPushed: tablesChanged.size,
|
|
1306
|
+
errors,
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
public async pushCollections(collections: any[]): Promise<{
|
|
1311
|
+
successfullyPushed: number;
|
|
1312
|
+
errors: any[];
|
|
1313
|
+
}> {
|
|
1314
|
+
const pools = new Pools(POLL_DEFAULT_VALUE);
|
|
1315
|
+
const attributes = new Attributes(pools);
|
|
1316
|
+
|
|
1317
|
+
const errors: any[] = [];
|
|
1318
|
+
|
|
1319
|
+
const databases = Array.from(
|
|
1320
|
+
new Set(collections.map((collection: any) => collection["databaseId"])),
|
|
1321
|
+
);
|
|
1322
|
+
|
|
1323
|
+
// Parallel db actions
|
|
1324
|
+
await Promise.all(
|
|
1325
|
+
databases.map(async (databaseId: any) => {
|
|
1326
|
+
const databasesService = await getDatabasesService(this.projectClient);
|
|
1327
|
+
try {
|
|
1328
|
+
const database = await databasesService.get(databaseId);
|
|
1329
|
+
|
|
1330
|
+
// Note: We can't get the local database name here since we don't have access to localConfig
|
|
1331
|
+
// This will need to be handled by the caller if needed
|
|
1332
|
+
const localDatabaseName =
|
|
1333
|
+
collections.find((c: any) => c.databaseId === databaseId)
|
|
1334
|
+
?.databaseName ?? databaseId;
|
|
1335
|
+
|
|
1336
|
+
if (database.name !== localDatabaseName) {
|
|
1337
|
+
await databasesService.update(databaseId, localDatabaseName);
|
|
1338
|
+
|
|
1339
|
+
success(`Updated ${localDatabaseName} ( ${databaseId} ) name`);
|
|
1340
|
+
}
|
|
1341
|
+
} catch (err) {
|
|
1342
|
+
log(`Database ${databaseId} not found. Creating it now ...`);
|
|
1343
|
+
|
|
1344
|
+
const localDatabaseName =
|
|
1345
|
+
collections.find((c: any) => c.databaseId === databaseId)
|
|
1346
|
+
?.databaseName ?? databaseId;
|
|
1347
|
+
|
|
1348
|
+
await databasesService.create(databaseId, localDatabaseName);
|
|
1349
|
+
}
|
|
1350
|
+
}),
|
|
1351
|
+
);
|
|
1352
|
+
|
|
1353
|
+
// Parallel collection actions
|
|
1354
|
+
await Promise.all(
|
|
1355
|
+
collections.map(async (collection: any) => {
|
|
1356
|
+
try {
|
|
1357
|
+
const databasesService = await getDatabasesService(
|
|
1358
|
+
this.projectClient,
|
|
1359
|
+
);
|
|
1360
|
+
const remoteCollection = await databasesService.getCollection(
|
|
1361
|
+
collection["databaseId"],
|
|
1362
|
+
collection["$id"],
|
|
1363
|
+
);
|
|
1364
|
+
|
|
1365
|
+
if (remoteCollection.name !== collection.name) {
|
|
1366
|
+
await databasesService.updateCollection(
|
|
1367
|
+
collection["databaseId"],
|
|
1368
|
+
collection["$id"],
|
|
1369
|
+
collection.name,
|
|
1370
|
+
);
|
|
1371
|
+
|
|
1372
|
+
success(`Updated ${collection.name} ( ${collection["$id"]} ) name`);
|
|
1373
|
+
}
|
|
1374
|
+
collection.remoteVersion = remoteCollection;
|
|
1375
|
+
|
|
1376
|
+
collection.isExisted = true;
|
|
1377
|
+
} catch (e: any) {
|
|
1378
|
+
if (Number(e.code) === 404) {
|
|
1379
|
+
log(
|
|
1380
|
+
`Collection ${collection.name} does not exist in the project. Creating ... `,
|
|
1381
|
+
);
|
|
1382
|
+
const databasesService = await getDatabasesService(
|
|
1383
|
+
this.projectClient,
|
|
1384
|
+
);
|
|
1385
|
+
await databasesService.createCollection(
|
|
1386
|
+
collection["databaseId"],
|
|
1387
|
+
collection["$id"],
|
|
1388
|
+
collection.name,
|
|
1389
|
+
collection.documentSecurity,
|
|
1390
|
+
collection["$permissions"],
|
|
1391
|
+
);
|
|
1392
|
+
} else {
|
|
1393
|
+
errors.push(e);
|
|
1394
|
+
throw e;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
}),
|
|
1398
|
+
);
|
|
1399
|
+
|
|
1400
|
+
let numberOfCollections = 0;
|
|
1401
|
+
// Serialize attribute actions
|
|
1402
|
+
for (let collection of collections) {
|
|
1403
|
+
let collectionAttributes = collection.attributes;
|
|
1404
|
+
let indexes = collection.indexes;
|
|
1405
|
+
|
|
1406
|
+
if (collection.isExisted) {
|
|
1407
|
+
collectionAttributes = await attributes.attributesToCreate(
|
|
1408
|
+
collection.remoteVersion.attributes,
|
|
1409
|
+
collection.attributes,
|
|
1410
|
+
collection as Collection,
|
|
1411
|
+
);
|
|
1412
|
+
indexes = await attributes.attributesToCreate(
|
|
1413
|
+
collection.remoteVersion.indexes,
|
|
1414
|
+
collection.indexes,
|
|
1415
|
+
collection as Collection,
|
|
1416
|
+
true,
|
|
1417
|
+
);
|
|
1418
|
+
|
|
1419
|
+
if (
|
|
1420
|
+
Array.isArray(collectionAttributes) &&
|
|
1421
|
+
collectionAttributes.length <= 0 &&
|
|
1422
|
+
Array.isArray(indexes) &&
|
|
1423
|
+
indexes.length <= 0
|
|
1424
|
+
) {
|
|
1425
|
+
continue;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
log(
|
|
1430
|
+
`Pushing collection ${collection.name} ( ${collection["databaseId"]} - ${collection["$id"]} ) attributes`,
|
|
1431
|
+
);
|
|
1432
|
+
|
|
1433
|
+
try {
|
|
1434
|
+
await attributes.createAttributes(
|
|
1435
|
+
collectionAttributes,
|
|
1436
|
+
collection as Collection,
|
|
1437
|
+
);
|
|
1438
|
+
} catch (e) {
|
|
1439
|
+
errors.push(e);
|
|
1440
|
+
throw e;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
try {
|
|
1444
|
+
await attributes.createIndexes(indexes, collection as Collection);
|
|
1445
|
+
} catch (e) {
|
|
1446
|
+
errors.push(e);
|
|
1447
|
+
throw e;
|
|
1448
|
+
}
|
|
1449
|
+
numberOfCollections++;
|
|
1450
|
+
success(
|
|
1451
|
+
`Successfully pushed ${collection.name} ( ${collection["$id"]} )`,
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
return {
|
|
1456
|
+
successfullyPushed: numberOfCollections,
|
|
1457
|
+
errors,
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
async function createPushInstance(): Promise<Push> {
|
|
1463
|
+
const projectClient = await sdkForProject();
|
|
1464
|
+
const consoleClient = await sdkForConsole();
|
|
1465
|
+
return new Push(projectClient, consoleClient);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
const pushResources = async ({
|
|
1469
|
+
skipDeprecated = false,
|
|
1470
|
+
}: {
|
|
1471
|
+
skipDeprecated?: boolean;
|
|
1472
|
+
} = {}): Promise<void> => {
|
|
1473
|
+
if (cliConfig.all) {
|
|
1474
|
+
checkDeployConditions(localConfig);
|
|
1475
|
+
|
|
1476
|
+
const pushInstance = await createPushInstance();
|
|
1477
|
+
const config = localConfig.getProject() as ConfigType;
|
|
1478
|
+
|
|
1479
|
+
await pushInstance.pushResources(config, {
|
|
1480
|
+
skipDeprecated,
|
|
1481
|
+
functionOptions: { code: true, withVariables: false },
|
|
1482
|
+
siteOptions: { code: true, withVariables: false },
|
|
1483
|
+
});
|
|
1484
|
+
} else {
|
|
1485
|
+
const actions: Record<string, (options?: any) => Promise<void>> = {
|
|
1486
|
+
settings: pushSettings,
|
|
1487
|
+
functions: pushFunction,
|
|
1488
|
+
sites: pushSite,
|
|
1489
|
+
collections: pushCollection,
|
|
1490
|
+
tables: pushTable,
|
|
1491
|
+
buckets: pushBucket,
|
|
1492
|
+
teams: pushTeam,
|
|
1493
|
+
messages: pushMessagingTopic,
|
|
1494
|
+
};
|
|
1495
|
+
|
|
1496
|
+
if (skipDeprecated) {
|
|
1497
|
+
delete actions.collections;
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
const answers = await inquirer.prompt(questionsPushResources);
|
|
1501
|
+
|
|
1502
|
+
const action = actions[answers.resource];
|
|
1503
|
+
if (action !== undefined) {
|
|
1504
|
+
await action();
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1509
|
+
const pushSettings = async (): Promise<void> => {
|
|
1510
|
+
checkDeployConditions(localConfig);
|
|
1511
|
+
|
|
1512
|
+
try {
|
|
1513
|
+
const projectsService = await getProjectsService();
|
|
1514
|
+
let response = await projectsService.get(
|
|
1515
|
+
localConfig.getProject().projectId,
|
|
1516
|
+
);
|
|
1517
|
+
|
|
1518
|
+
const remoteSettings = createSettingsObject(response);
|
|
1519
|
+
const localSettings = localConfig.getProject().projectSettings ?? {};
|
|
1520
|
+
|
|
1521
|
+
log("Checking for changes ...");
|
|
1522
|
+
const changes: any[] = [];
|
|
1523
|
+
|
|
1524
|
+
changes.push(
|
|
1525
|
+
...getObjectChanges(remoteSettings, localSettings, "services", "Service"),
|
|
1526
|
+
);
|
|
1527
|
+
changes.push(
|
|
1528
|
+
...getObjectChanges(
|
|
1529
|
+
remoteSettings["auth"] ?? {},
|
|
1530
|
+
localSettings["auth"] ?? {},
|
|
1531
|
+
"methods",
|
|
1532
|
+
"Auth method",
|
|
1533
|
+
),
|
|
1534
|
+
);
|
|
1535
|
+
changes.push(
|
|
1536
|
+
...getObjectChanges(
|
|
1537
|
+
remoteSettings["auth"] ?? {},
|
|
1538
|
+
localSettings["auth"] ?? {},
|
|
1539
|
+
"security",
|
|
1540
|
+
"Auth security",
|
|
1541
|
+
),
|
|
1542
|
+
);
|
|
1543
|
+
|
|
1544
|
+
if (changes.length > 0) {
|
|
1545
|
+
drawTable(changes);
|
|
1546
|
+
if ((await getConfirmation()) !== true) {
|
|
1547
|
+
success(`Successfully pushed 0 project settings.`);
|
|
1548
|
+
return;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
} catch (e) {}
|
|
1552
|
+
|
|
1553
|
+
try {
|
|
1554
|
+
log("Pushing project settings ...");
|
|
1555
|
+
|
|
1556
|
+
const pushInstance = await createPushInstance();
|
|
1557
|
+
const config = localConfig.getProject();
|
|
1558
|
+
const settings = config.projectSettings ?? {};
|
|
1559
|
+
|
|
1560
|
+
if (config.projectName) {
|
|
1561
|
+
log("Applying project name ...");
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
if (settings.services) {
|
|
1565
|
+
log("Applying service statuses ...");
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
if (settings.auth) {
|
|
1569
|
+
if (settings.auth.security) {
|
|
1570
|
+
log("Applying auth security settings ...");
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
if (settings.auth.methods) {
|
|
1574
|
+
log("Applying auth methods statuses ...");
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
await pushInstance.pushSettings({
|
|
1579
|
+
projectId: config.projectId,
|
|
1580
|
+
projectName: config.projectName,
|
|
1581
|
+
settings: config.projectSettings,
|
|
1582
|
+
});
|
|
1583
|
+
|
|
1584
|
+
success(`Successfully pushed ${chalk.bold("all")} project settings.`);
|
|
1585
|
+
} catch (e) {
|
|
1586
|
+
throw e;
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1590
|
+
const pushSite = async ({
|
|
1591
|
+
siteId,
|
|
1592
|
+
async: asyncDeploy,
|
|
1593
|
+
code,
|
|
1594
|
+
withVariables,
|
|
1595
|
+
}: PushSiteOptions = {}): Promise<void> => {
|
|
1596
|
+
process.chdir(localConfig.configDirectoryPath);
|
|
1597
|
+
|
|
1598
|
+
const siteIds: string[] = [];
|
|
1599
|
+
|
|
1600
|
+
if (siteId) {
|
|
1601
|
+
siteIds.push(siteId);
|
|
1602
|
+
} else if (cliConfig.all) {
|
|
1603
|
+
checkDeployConditions(localConfig);
|
|
1604
|
+
const sites = localConfig.getSites();
|
|
1605
|
+
siteIds.push(
|
|
1606
|
+
...sites.map((site: any) => {
|
|
1607
|
+
return site.$id;
|
|
1608
|
+
}),
|
|
1609
|
+
);
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
if (siteIds.length <= 0) {
|
|
1613
|
+
const answers = await inquirer.prompt(questionsPushSites);
|
|
1614
|
+
if (answers.sites) {
|
|
1615
|
+
siteIds.push(...answers.sites);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
if (siteIds.length === 0) {
|
|
1620
|
+
log("No sites found.");
|
|
1621
|
+
hint(
|
|
1622
|
+
"Use 'appwrite pull sites' to synchronize existing one, or use 'appwrite init site' to create a new one.",
|
|
1623
|
+
);
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
let sites = siteIds.map((id: string) => {
|
|
1628
|
+
const sites = localConfig.getSites();
|
|
1629
|
+
const site = sites.find((s: any) => s.$id === id);
|
|
1630
|
+
|
|
1631
|
+
if (!site) {
|
|
1632
|
+
throw new Error("Site '" + id + "' not found.");
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
return site;
|
|
1636
|
+
});
|
|
1637
|
+
|
|
1638
|
+
log("Validating sites ...");
|
|
1639
|
+
// Validation is done BEFORE pushing so the deployment process can be run in async with progress update
|
|
1640
|
+
for (let site of sites) {
|
|
1641
|
+
if (!site.buildCommand) {
|
|
1642
|
+
log(`Site ${site.name} is missing build command.`);
|
|
1643
|
+
const answers = await inquirer.prompt(questionsGetEntrypoint);
|
|
1644
|
+
site.buildCommand = answers.entrypoint;
|
|
1645
|
+
localConfig.addSite(site);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
if (
|
|
1650
|
+
!(await approveChanges(
|
|
1651
|
+
sites,
|
|
1652
|
+
async (args: any) => {
|
|
1653
|
+
const sitesService = await getSitesService();
|
|
1654
|
+
return await sitesService.get({ siteId: args.siteId });
|
|
1655
|
+
},
|
|
1656
|
+
KeysSite,
|
|
1657
|
+
"siteId",
|
|
1658
|
+
"sites",
|
|
1659
|
+
["vars"],
|
|
1660
|
+
))
|
|
1661
|
+
) {
|
|
1662
|
+
return;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
log("Pushing sites ...");
|
|
1666
|
+
|
|
1667
|
+
const pushInstance = await createPushInstance();
|
|
1668
|
+
const result = await pushInstance.pushSites(sites, {
|
|
1669
|
+
async: asyncDeploy,
|
|
1670
|
+
code,
|
|
1671
|
+
withVariables,
|
|
1672
|
+
});
|
|
1673
|
+
|
|
1674
|
+
const {
|
|
1675
|
+
successfullyPushed,
|
|
1676
|
+
successfullyDeployed,
|
|
1677
|
+
failedDeployments,
|
|
1678
|
+
errors,
|
|
1679
|
+
} = result;
|
|
1680
|
+
|
|
1681
|
+
failedDeployments.forEach((failed) => {
|
|
1682
|
+
const { name, deployment, $id } = failed;
|
|
1683
|
+
const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/project-${localConfig.getProject().projectId}/sites/site-${$id}/deployments/deployment-${deployment}`;
|
|
1684
|
+
|
|
1685
|
+
error(
|
|
1686
|
+
`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`,
|
|
1687
|
+
);
|
|
1688
|
+
});
|
|
1689
|
+
|
|
1690
|
+
if (!asyncDeploy) {
|
|
1691
|
+
if (successfullyPushed === 0) {
|
|
1692
|
+
error("No sites were pushed.");
|
|
1693
|
+
} else if (successfullyDeployed !== successfullyPushed) {
|
|
1694
|
+
warn(
|
|
1695
|
+
`Successfully pushed ${successfullyDeployed} of ${successfullyPushed} sites`,
|
|
1696
|
+
);
|
|
1697
|
+
} else {
|
|
1698
|
+
success(`Successfully pushed ${successfullyPushed} sites.`);
|
|
1699
|
+
}
|
|
1700
|
+
} else {
|
|
1701
|
+
success(`Successfully pushed ${successfullyPushed} sites.`);
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
if (cliConfig.verbose) {
|
|
1705
|
+
errors.forEach((e) => {
|
|
1706
|
+
console.error(e);
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
|
|
1711
|
+
const pushFunction = async ({
|
|
1712
|
+
functionId,
|
|
1713
|
+
async: asyncDeploy,
|
|
1714
|
+
code,
|
|
1715
|
+
withVariables,
|
|
1716
|
+
}: PushFunctionOptions = {}): Promise<void> => {
|
|
1717
|
+
process.chdir(localConfig.configDirectoryPath);
|
|
1718
|
+
|
|
1719
|
+
const functionIds: string[] = [];
|
|
1720
|
+
|
|
1721
|
+
if (functionId) {
|
|
1722
|
+
functionIds.push(functionId);
|
|
1723
|
+
} else if (cliConfig.all) {
|
|
1724
|
+
checkDeployConditions(localConfig);
|
|
1725
|
+
const functions = localConfig.getFunctions();
|
|
1726
|
+
functionIds.push(
|
|
1727
|
+
...functions.map((func: any) => {
|
|
1728
|
+
return func.$id;
|
|
1729
|
+
}),
|
|
1730
|
+
);
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
if (functionIds.length <= 0) {
|
|
1734
|
+
const answers = await inquirer.prompt(questionsPushFunctions);
|
|
1735
|
+
if (answers.functions) {
|
|
1736
|
+
functionIds.push(...answers.functions);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
if (functionIds.length === 0) {
|
|
1741
|
+
log("No functions found.");
|
|
1742
|
+
hint(
|
|
1743
|
+
"Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.",
|
|
1744
|
+
);
|
|
1745
|
+
return;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
let functions = functionIds.map((id: string) => {
|
|
1749
|
+
const functions = localConfig.getFunctions();
|
|
1750
|
+
const func = functions.find((f: any) => f.$id === id);
|
|
1751
|
+
|
|
1752
|
+
if (!func) {
|
|
1753
|
+
throw new Error("Function '" + id + "' not found.");
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
return func;
|
|
1757
|
+
});
|
|
1758
|
+
|
|
1759
|
+
log("Validating functions ...");
|
|
1760
|
+
for (let func of functions) {
|
|
1761
|
+
if (!func.entrypoint) {
|
|
1762
|
+
log(`Function ${func.name} is missing an entrypoint.`);
|
|
1763
|
+
const answers = await inquirer.prompt(questionsGetEntrypoint);
|
|
1764
|
+
func.entrypoint = answers.entrypoint;
|
|
1765
|
+
localConfig.addFunction(func);
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
if (
|
|
1770
|
+
!(await approveChanges(
|
|
1771
|
+
functions,
|
|
1772
|
+
async (args: any) => {
|
|
1773
|
+
const functionsService = await getFunctionsService();
|
|
1774
|
+
return await functionsService.get({ functionId: args.functionId });
|
|
1775
|
+
},
|
|
1776
|
+
KeysFunction,
|
|
1777
|
+
"functionId",
|
|
1778
|
+
"functions",
|
|
1779
|
+
["vars"],
|
|
1780
|
+
))
|
|
1781
|
+
) {
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
log("Pushing functions ...");
|
|
1786
|
+
|
|
1787
|
+
const pushInstance = await createPushInstance();
|
|
1788
|
+
const result = await pushInstance.pushFunctions(functions, {
|
|
1789
|
+
async: asyncDeploy,
|
|
1790
|
+
code,
|
|
1791
|
+
withVariables,
|
|
1792
|
+
});
|
|
1793
|
+
|
|
1794
|
+
const {
|
|
1795
|
+
successfullyPushed,
|
|
1796
|
+
successfullyDeployed,
|
|
1797
|
+
failedDeployments,
|
|
1798
|
+
errors,
|
|
1799
|
+
} = result;
|
|
1800
|
+
|
|
1801
|
+
failedDeployments.forEach((failed) => {
|
|
1802
|
+
const { name, deployment, $id } = failed;
|
|
1803
|
+
const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/project-${localConfig.getProject().projectId}/functions/function-${$id}/deployment-${deployment}`;
|
|
1804
|
+
|
|
1805
|
+
error(
|
|
1806
|
+
`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`,
|
|
1807
|
+
);
|
|
1808
|
+
});
|
|
1809
|
+
|
|
1810
|
+
if (!asyncDeploy) {
|
|
1811
|
+
if (successfullyPushed === 0) {
|
|
1812
|
+
error("No functions were pushed.");
|
|
1813
|
+
} else if (successfullyDeployed !== successfullyPushed) {
|
|
1814
|
+
warn(
|
|
1815
|
+
`Successfully pushed ${successfullyDeployed} of ${successfullyPushed} functions`,
|
|
1816
|
+
);
|
|
1817
|
+
} else {
|
|
1818
|
+
success(`Successfully pushed ${successfullyPushed} functions.`);
|
|
1819
|
+
}
|
|
1820
|
+
} else {
|
|
1821
|
+
success(`Successfully pushed ${successfullyPushed} functions.`);
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
if (cliConfig.verbose) {
|
|
1825
|
+
errors.forEach((e) => {
|
|
1826
|
+
console.error(e);
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
|
|
1831
|
+
const pushTable = async ({
|
|
1832
|
+
attempts,
|
|
1833
|
+
}: PushTableOptions = {}): Promise<void> => {
|
|
1834
|
+
const tables: any[] = [];
|
|
1835
|
+
|
|
1836
|
+
const { resyncNeeded } = await checkAndApplyTablesDBChanges();
|
|
1837
|
+
if (resyncNeeded) {
|
|
1838
|
+
log("Resyncing configuration due to tables deletions ...");
|
|
1839
|
+
|
|
1840
|
+
const remoteTablesDBs = (
|
|
1841
|
+
await paginate(
|
|
1842
|
+
async (args: any) => {
|
|
1843
|
+
const tablesService = await getTablesDBService();
|
|
1844
|
+
return await tablesService.list(args.queries || []);
|
|
1845
|
+
},
|
|
1846
|
+
{},
|
|
1847
|
+
100,
|
|
1848
|
+
"databases",
|
|
1849
|
+
)
|
|
1850
|
+
).databases;
|
|
1851
|
+
const localTablesDBs = localConfig.getTablesDBs();
|
|
1852
|
+
|
|
1853
|
+
const remoteDatabaseIds = new Set(remoteTablesDBs.map((db: any) => db.$id));
|
|
1854
|
+
const localTables = localConfig.getTables();
|
|
1855
|
+
const validTables = localTables.filter((table: any) =>
|
|
1856
|
+
remoteDatabaseIds.has(table.databaseId),
|
|
1857
|
+
);
|
|
1858
|
+
|
|
1859
|
+
localConfig.set("tables", validTables);
|
|
1860
|
+
|
|
1861
|
+
const validTablesDBs = localTablesDBs.filter((db: any) =>
|
|
1862
|
+
remoteDatabaseIds.has(db.$id),
|
|
1863
|
+
);
|
|
1864
|
+
localConfig.set("tables", validTablesDBs);
|
|
1865
|
+
|
|
1866
|
+
success("Configuration resynced successfully.");
|
|
1867
|
+
console.log();
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
log("Checking for deleted tables ...");
|
|
1871
|
+
const localTablesDBs = localConfig.getTablesDBs();
|
|
1872
|
+
const localTables = localConfig.getTables();
|
|
1873
|
+
const tablesToDelete: any[] = [];
|
|
1874
|
+
|
|
1875
|
+
for (const db of localTablesDBs) {
|
|
1876
|
+
try {
|
|
1877
|
+
const { tables: remoteTables } = await paginate(
|
|
1878
|
+
async (args: any) => {
|
|
1879
|
+
const tablesService = await getTablesDBService();
|
|
1880
|
+
return await tablesService.listTables(
|
|
1881
|
+
args.databaseId,
|
|
1882
|
+
args.queries || [],
|
|
1883
|
+
);
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
databaseId: db.$id,
|
|
1887
|
+
},
|
|
1888
|
+
100,
|
|
1889
|
+
"tables",
|
|
1890
|
+
);
|
|
1891
|
+
|
|
1892
|
+
for (const remoteTable of remoteTables) {
|
|
1893
|
+
const localTable = localTables.find(
|
|
1894
|
+
(t: any) => t.$id === remoteTable.$id && t.databaseId === db.$id,
|
|
1895
|
+
);
|
|
1896
|
+
if (!localTable) {
|
|
1897
|
+
tablesToDelete.push({
|
|
1898
|
+
...remoteTable,
|
|
1899
|
+
databaseId: db.$id,
|
|
1900
|
+
databaseName: db.name,
|
|
1901
|
+
});
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
} catch (e) {
|
|
1905
|
+
// Skip if database doesn't exist or other errors
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
if (tablesToDelete.length > 0) {
|
|
1910
|
+
log("Found tables that exist remotely but not locally:");
|
|
1911
|
+
const deletionChanges = tablesToDelete.map((table: any) => ({
|
|
1912
|
+
id: table.$id,
|
|
1913
|
+
action: chalk.red("deleting"),
|
|
1914
|
+
key: "Table",
|
|
1915
|
+
database: table.databaseName,
|
|
1916
|
+
remote: table.name,
|
|
1917
|
+
local: "(deleted locally)",
|
|
1918
|
+
}));
|
|
1919
|
+
drawTable(deletionChanges);
|
|
1920
|
+
|
|
1921
|
+
if ((await getConfirmation()) === true) {
|
|
1922
|
+
for (const table of tablesToDelete) {
|
|
1923
|
+
try {
|
|
1924
|
+
log(
|
|
1925
|
+
`Deleting table ${table.name} ( ${table.$id} ) from database ${table.databaseName} ...`,
|
|
1926
|
+
);
|
|
1927
|
+
const tablesService = await getTablesDBService();
|
|
1928
|
+
await tablesService.deleteTable(table.databaseId, table.$id);
|
|
1929
|
+
success(`Deleted ${table.name} ( ${table.$id} )`);
|
|
1930
|
+
} catch (e: any) {
|
|
1931
|
+
error(
|
|
1932
|
+
`Failed to delete table ${table.name} ( ${table.$id} ): ${e.message}`,
|
|
1933
|
+
);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
if (cliConfig.all) {
|
|
1940
|
+
checkDeployConditions(localConfig);
|
|
1941
|
+
tables.push(...localConfig.getTables());
|
|
1942
|
+
} else {
|
|
1943
|
+
const answers = await inquirer.prompt(questionsPushTables);
|
|
1944
|
+
if (answers.tables) {
|
|
1945
|
+
const configTables = new Map();
|
|
1946
|
+
localConfig.getTables().forEach((c: any) => {
|
|
1947
|
+
configTables.set(`${c["databaseId"]}|${c["$id"]}`, c);
|
|
1948
|
+
});
|
|
1949
|
+
answers.tables.forEach((a: any) => {
|
|
1950
|
+
const table = configTables.get(a);
|
|
1951
|
+
tables.push(table);
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
if (tables.length === 0) {
|
|
1957
|
+
log("No tables found.");
|
|
1958
|
+
hint(
|
|
1959
|
+
"Use 'appwrite pull tables' to synchronize existing one, or use 'appwrite init table' to create a new one.",
|
|
1960
|
+
);
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
if (
|
|
1965
|
+
!(await approveChanges(
|
|
1966
|
+
tables,
|
|
1967
|
+
async (args: any) => {
|
|
1968
|
+
const tablesService = await getTablesDBService();
|
|
1969
|
+
return await tablesService.getTable(args.databaseId, args.tableId);
|
|
1970
|
+
},
|
|
1971
|
+
KeysTable,
|
|
1972
|
+
"tableId",
|
|
1973
|
+
"tables",
|
|
1974
|
+
["columns", "indexes"],
|
|
1975
|
+
"databaseId",
|
|
1976
|
+
"databaseId",
|
|
1977
|
+
))
|
|
1978
|
+
) {
|
|
1979
|
+
return;
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
log("Pushing tables ...");
|
|
1983
|
+
|
|
1984
|
+
const pushInstance = await createPushInstance();
|
|
1985
|
+
const result = await pushInstance.pushTables(tables, attempts);
|
|
1986
|
+
|
|
1987
|
+
const { successfullyPushed, errors } = result;
|
|
1988
|
+
|
|
1989
|
+
if (successfullyPushed === 0) {
|
|
1990
|
+
error("No tables were pushed.");
|
|
1991
|
+
} else {
|
|
1992
|
+
success(`Successfully pushed ${successfullyPushed} tables.`);
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
if (cliConfig.verbose) {
|
|
1996
|
+
errors.forEach((e) => console.error(e));
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
|
|
2000
|
+
const pushCollection = async ({}: PushTableOptions = {}): Promise<void> => {
|
|
2001
|
+
warn(
|
|
2002
|
+
"appwrite push collection has been deprecated. Please consider using 'appwrite push tables' instead",
|
|
2003
|
+
);
|
|
2004
|
+
const collections: any[] = [];
|
|
2005
|
+
|
|
2006
|
+
if (cliConfig.all) {
|
|
2007
|
+
checkDeployConditions(localConfig);
|
|
2008
|
+
collections.push(...localConfig.getCollections());
|
|
2009
|
+
} else {
|
|
2010
|
+
const answers = await inquirer.prompt(questionsPushCollections);
|
|
2011
|
+
if (answers.collections) {
|
|
2012
|
+
const configCollections = new Map();
|
|
2013
|
+
localConfig.getCollections().forEach((c: any) => {
|
|
2014
|
+
configCollections.set(`${c["databaseId"]}|${c["$id"]}`, c);
|
|
2015
|
+
});
|
|
2016
|
+
answers.collections.forEach((a: any) => {
|
|
2017
|
+
const collection = configCollections.get(a);
|
|
2018
|
+
collections.push(collection);
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
if (collections.length === 0) {
|
|
2024
|
+
log("No collections found.");
|
|
2025
|
+
hint(
|
|
2026
|
+
"Use 'appwrite pull collections' to synchronize existing one, or use 'appwrite init collection' to create a new one.",
|
|
2027
|
+
);
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
// Add database names to collections for the class method
|
|
2032
|
+
collections.forEach((collection: any) => {
|
|
2033
|
+
const localDatabase = localConfig.getDatabase(collection.databaseId);
|
|
2034
|
+
collection.databaseName = localDatabase.name ?? collection.databaseId;
|
|
2035
|
+
});
|
|
2036
|
+
|
|
2037
|
+
if (
|
|
2038
|
+
!(await approveChanges(
|
|
2039
|
+
collections,
|
|
2040
|
+
async (args: any) => {
|
|
2041
|
+
const databasesService = await getDatabasesService();
|
|
2042
|
+
return await databasesService.getCollection(
|
|
2043
|
+
args.databaseId,
|
|
2044
|
+
args.collectionId,
|
|
2045
|
+
);
|
|
2046
|
+
},
|
|
2047
|
+
KeysCollection,
|
|
2048
|
+
"collectionId",
|
|
2049
|
+
"collections",
|
|
2050
|
+
["attributes", "indexes"],
|
|
2051
|
+
"databaseId",
|
|
2052
|
+
"databaseId",
|
|
2053
|
+
))
|
|
2054
|
+
) {
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
log("Pushing collections ...");
|
|
2059
|
+
|
|
2060
|
+
const pushInstance = await createPushInstance();
|
|
2061
|
+
const result = await pushInstance.pushCollections(collections);
|
|
2062
|
+
|
|
2063
|
+
const { successfullyPushed, errors } = result;
|
|
2064
|
+
|
|
2065
|
+
if (successfullyPushed === 0) {
|
|
2066
|
+
error("No collections were pushed.");
|
|
2067
|
+
} else {
|
|
2068
|
+
success(`Successfully pushed ${successfullyPushed} collections.`);
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
if (cliConfig.verbose) {
|
|
2072
|
+
errors.forEach((e) => console.error(e));
|
|
2073
|
+
}
|
|
2074
|
+
};
|
|
2075
|
+
|
|
2076
|
+
const pushBucket = async (): Promise<void> => {
|
|
2077
|
+
let bucketIds: string[] = [];
|
|
2078
|
+
const configBuckets = localConfig.getBuckets();
|
|
2079
|
+
|
|
2080
|
+
if (cliConfig.all) {
|
|
2081
|
+
checkDeployConditions(localConfig);
|
|
2082
|
+
bucketIds.push(...configBuckets.map((b: any) => b.$id));
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
if (bucketIds.length === 0) {
|
|
2086
|
+
const answers = await inquirer.prompt(questionsPushBuckets);
|
|
2087
|
+
if (answers.buckets) {
|
|
2088
|
+
bucketIds.push(...answers.buckets);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
if (bucketIds.length === 0) {
|
|
2093
|
+
log("No buckets found.");
|
|
2094
|
+
hint(
|
|
2095
|
+
"Use 'appwrite pull buckets' to synchronize existing one, or use 'appwrite init bucket' to create a new one.",
|
|
2096
|
+
);
|
|
2097
|
+
return;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
let buckets: any[] = [];
|
|
2101
|
+
|
|
2102
|
+
for (const bucketId of bucketIds) {
|
|
2103
|
+
const idBuckets = configBuckets.filter((b: any) => b.$id === bucketId);
|
|
2104
|
+
buckets.push(...idBuckets);
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
if (
|
|
2108
|
+
!(await approveChanges(
|
|
2109
|
+
buckets,
|
|
2110
|
+
async (args: any) => {
|
|
2111
|
+
const storageService = await getStorageService();
|
|
2112
|
+
return await storageService.getBucket(args.bucketId);
|
|
2113
|
+
},
|
|
2114
|
+
KeysStorage,
|
|
2115
|
+
"bucketId",
|
|
2116
|
+
"buckets",
|
|
2117
|
+
))
|
|
2118
|
+
) {
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
log("Pushing buckets ...");
|
|
2123
|
+
|
|
2124
|
+
const pushInstance = await createPushInstance();
|
|
2125
|
+
const result = await pushInstance.pushBuckets(buckets);
|
|
2126
|
+
|
|
2127
|
+
const { successfullyPushed, errors } = result;
|
|
2128
|
+
|
|
2129
|
+
if (successfullyPushed === 0) {
|
|
2130
|
+
error("No buckets were pushed.");
|
|
2131
|
+
} else {
|
|
2132
|
+
success(`Successfully pushed ${successfullyPushed} buckets.`);
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
if (cliConfig.verbose) {
|
|
2136
|
+
errors.forEach((e) => console.error(e));
|
|
2137
|
+
}
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2140
|
+
const pushTeam = async (): Promise<void> => {
|
|
2141
|
+
let teamIds: string[] = [];
|
|
2142
|
+
const configTeams = localConfig.getTeams();
|
|
2143
|
+
|
|
2144
|
+
if (cliConfig.all) {
|
|
2145
|
+
checkDeployConditions(localConfig);
|
|
2146
|
+
teamIds.push(...configTeams.map((t: any) => t.$id));
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
if (teamIds.length === 0) {
|
|
2150
|
+
const answers = await inquirer.prompt(questionsPushTeams);
|
|
2151
|
+
if (answers.teams) {
|
|
2152
|
+
teamIds.push(...answers.teams);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
if (teamIds.length === 0) {
|
|
2157
|
+
log("No teams found.");
|
|
2158
|
+
hint(
|
|
2159
|
+
"Use 'appwrite pull teams' to synchronize existing one, or use 'appwrite init team' to create a new one.",
|
|
2160
|
+
);
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
let teams: any[] = [];
|
|
2165
|
+
|
|
2166
|
+
for (const teamId of teamIds) {
|
|
2167
|
+
const idTeams = configTeams.filter((t: any) => t.$id === teamId);
|
|
2168
|
+
teams.push(...idTeams);
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
if (
|
|
2172
|
+
!(await approveChanges(
|
|
2173
|
+
teams,
|
|
2174
|
+
async (args: any) => {
|
|
2175
|
+
const teamsService = await getTeamsService();
|
|
2176
|
+
return await teamsService.get(args.teamId);
|
|
2177
|
+
},
|
|
2178
|
+
KeysTeams,
|
|
2179
|
+
"teamId",
|
|
2180
|
+
"teams",
|
|
2181
|
+
))
|
|
2182
|
+
) {
|
|
2183
|
+
return;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
log("Pushing teams ...");
|
|
2187
|
+
|
|
2188
|
+
const pushInstance = await createPushInstance();
|
|
2189
|
+
const result = await pushInstance.pushTeams(teams);
|
|
2190
|
+
|
|
2191
|
+
const { successfullyPushed, errors } = result;
|
|
2192
|
+
|
|
2193
|
+
if (successfullyPushed === 0) {
|
|
2194
|
+
error("No teams were pushed.");
|
|
2195
|
+
} else {
|
|
2196
|
+
success(`Successfully pushed ${successfullyPushed} teams.`);
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
if (cliConfig.verbose) {
|
|
2200
|
+
errors.forEach((e) => console.error(e));
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
|
|
2204
|
+
const pushMessagingTopic = async (): Promise<void> => {
|
|
2205
|
+
let topicsIds: string[] = [];
|
|
2206
|
+
const configTopics = localConfig.getMessagingTopics();
|
|
2207
|
+
|
|
2208
|
+
if (cliConfig.all) {
|
|
2209
|
+
checkDeployConditions(localConfig);
|
|
2210
|
+
topicsIds.push(...configTopics.map((b: any) => b.$id));
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
if (topicsIds.length === 0) {
|
|
2214
|
+
const answers = await inquirer.prompt(questionsPushMessagingTopics);
|
|
2215
|
+
if (answers.topics) {
|
|
2216
|
+
topicsIds.push(...answers.topics);
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
if (topicsIds.length === 0) {
|
|
2221
|
+
log("No topics found.");
|
|
2222
|
+
hint(
|
|
2223
|
+
"Use 'appwrite pull topics' to synchronize existing one, or use 'appwrite init topic' to create a new one.",
|
|
2224
|
+
);
|
|
2225
|
+
return;
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
let topics: any[] = [];
|
|
2229
|
+
|
|
2230
|
+
for (const topicId of topicsIds) {
|
|
2231
|
+
const idTopic = configTopics.filter((b: any) => b.$id === topicId);
|
|
2232
|
+
topics.push(...idTopic);
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
if (
|
|
2236
|
+
!(await approveChanges(
|
|
2237
|
+
topics,
|
|
2238
|
+
async (args: any) => {
|
|
2239
|
+
const messagingService = await getMessagingService();
|
|
2240
|
+
return await messagingService.getTopic(args.topicId);
|
|
2241
|
+
},
|
|
2242
|
+
KeysTopics,
|
|
2243
|
+
"topicId",
|
|
2244
|
+
"topics",
|
|
2245
|
+
))
|
|
2246
|
+
) {
|
|
2247
|
+
return;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
log("Pushing topics ...");
|
|
2251
|
+
|
|
2252
|
+
const pushInstance = await createPushInstance();
|
|
2253
|
+
const result = await pushInstance.pushMessagingTopics(topics);
|
|
2254
|
+
|
|
2255
|
+
const { successfullyPushed, errors } = result;
|
|
2256
|
+
|
|
2257
|
+
if (successfullyPushed === 0) {
|
|
2258
|
+
error("No topics were pushed.");
|
|
2259
|
+
} else {
|
|
2260
|
+
success(`Successfully pushed ${successfullyPushed} topics.`);
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
if (cliConfig.verbose) {
|
|
2264
|
+
errors.forEach((e) => console.error(e));
|
|
2265
|
+
}
|
|
2266
|
+
};
|
|
2267
|
+
|
|
2268
|
+
export const push = new Command("push")
|
|
2269
|
+
.description(commandDescriptions["push"])
|
|
2270
|
+
.action(actionRunner(() => pushResources({ skipDeprecated: true })));
|
|
2271
|
+
|
|
2272
|
+
push
|
|
2273
|
+
.command("all")
|
|
2274
|
+
.description("Push all resource.")
|
|
2275
|
+
.action(
|
|
2276
|
+
actionRunner(() => {
|
|
2277
|
+
cliConfig.all = true;
|
|
2278
|
+
return pushResources({ skipDeprecated: true });
|
|
2279
|
+
}),
|
|
2280
|
+
);
|
|
2281
|
+
|
|
2282
|
+
push
|
|
2283
|
+
.command("settings")
|
|
2284
|
+
.description("Push project name, services and auth settings")
|
|
2285
|
+
.action(actionRunner(pushSettings));
|
|
2286
|
+
|
|
2287
|
+
push
|
|
2288
|
+
.command("function")
|
|
2289
|
+
.alias("functions")
|
|
2290
|
+
.description("Push functions in the current directory.")
|
|
2291
|
+
.option(`-f, --function-id <function-id>`, `ID of function to run`)
|
|
2292
|
+
.option(`-A, --async`, `Don't wait for functions deployments status`)
|
|
2293
|
+
.option("--no-code", "Don't push the function's code")
|
|
2294
|
+
.option("--with-variables", `Push function variables.`)
|
|
2295
|
+
.action(actionRunner(pushFunction));
|
|
2296
|
+
|
|
2297
|
+
push
|
|
2298
|
+
.command("site")
|
|
2299
|
+
.alias("sites")
|
|
2300
|
+
.description("Push sites in the current directory.")
|
|
2301
|
+
.option(`-f, --site-id <site-id>`, `ID of site to run`)
|
|
2302
|
+
.option(`-A, --async`, `Don't wait for sites deployments status`)
|
|
2303
|
+
.option("--no-code", "Don't push the site's code")
|
|
2304
|
+
.option("--with-variables", `Push site variables.`)
|
|
2305
|
+
.action(actionRunner(pushSite));
|
|
2306
|
+
|
|
2307
|
+
push
|
|
2308
|
+
.command("collection")
|
|
2309
|
+
.alias("collections")
|
|
2310
|
+
.description(
|
|
2311
|
+
"Push collections in the current project. (deprecated, please use 'push tables' instead)",
|
|
2312
|
+
)
|
|
2313
|
+
.option(
|
|
2314
|
+
`-a, --attempts <numberOfAttempts>`,
|
|
2315
|
+
`Max number of attempts before timing out. default: 30.`,
|
|
2316
|
+
)
|
|
2317
|
+
.action(actionRunner(pushCollection));
|
|
2318
|
+
|
|
2319
|
+
push
|
|
2320
|
+
.command("table")
|
|
2321
|
+
.alias("tables")
|
|
2322
|
+
.description("Push tables in the current project.")
|
|
2323
|
+
.option(
|
|
2324
|
+
`-a, --attempts <numberOfAttempts>`,
|
|
2325
|
+
`Max number of attempts before timing out. default: 30.`,
|
|
2326
|
+
)
|
|
2327
|
+
.action(actionRunner(pushTable));
|
|
2328
|
+
|
|
2329
|
+
push
|
|
2330
|
+
.command("bucket")
|
|
2331
|
+
.alias("buckets")
|
|
2332
|
+
.description("Push buckets in the current project.")
|
|
2333
|
+
.action(actionRunner(pushBucket));
|
|
2334
|
+
|
|
2335
|
+
push
|
|
2336
|
+
.command("team")
|
|
2337
|
+
.alias("teams")
|
|
2338
|
+
.description("Push teams in the current project.")
|
|
2339
|
+
.action(actionRunner(pushTeam));
|
|
2340
|
+
|
|
2341
|
+
push
|
|
2342
|
+
.command("topic")
|
|
2343
|
+
.alias("topics")
|
|
2344
|
+
.description("Push messaging topics in the current project.")
|
|
2345
|
+
.action(actionRunner(pushMessagingTopic));
|
|
2346
|
+
|
|
2347
|
+
export const deploy = new Command("deploy")
|
|
2348
|
+
.description("Removed. Use appwrite push instead")
|
|
2349
|
+
.action(
|
|
2350
|
+
actionRunner(async () => {
|
|
2351
|
+
warn(
|
|
2352
|
+
"appwrite deploy has been removed. Please use 'appwrite push' instead",
|
|
2353
|
+
);
|
|
2354
|
+
}),
|
|
2355
|
+
);
|