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