spindb 0.37.2 → 0.38.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/dist/cli/bin.js +9 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/attach.js +102 -0
- package/dist/cli/commands/attach.js.map +1 -0
- package/dist/cli/commands/backup.js +197 -0
- package/dist/cli/commands/backup.js.map +1 -0
- package/dist/cli/commands/backups.js +190 -0
- package/dist/cli/commands/backups.js.map +1 -0
- package/dist/cli/commands/clone.js +119 -0
- package/dist/cli/commands/clone.js.map +1 -0
- package/dist/cli/commands/config.js +276 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/connect.js +559 -0
- package/dist/cli/commands/connect.js.map +1 -0
- package/dist/cli/commands/create.js +952 -0
- package/dist/cli/commands/create.js.map +1 -0
- package/dist/cli/commands/databases.js +485 -0
- package/dist/cli/commands/databases.js.map +1 -0
- package/dist/cli/commands/delete.js +106 -0
- package/dist/cli/commands/delete.js.map +1 -0
- package/dist/cli/commands/deps.js +238 -0
- package/dist/cli/commands/deps.js.map +1 -0
- package/dist/cli/commands/detach.js +81 -0
- package/dist/cli/commands/detach.js.map +1 -0
- package/dist/cli/commands/doctor.js +567 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/duckdb.js +207 -0
- package/dist/cli/commands/duckdb.js.map +1 -0
- package/dist/cli/commands/edit.js +524 -0
- package/dist/cli/commands/edit.js.map +1 -0
- package/dist/cli/commands/engines.js +1414 -0
- package/dist/cli/commands/engines.js.map +1 -0
- package/dist/cli/commands/export.js +383 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/info.js +270 -0
- package/dist/cli/commands/info.js.map +1 -0
- package/dist/cli/commands/list.js +215 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/logs.js +81 -0
- package/dist/cli/commands/logs.js.map +1 -0
- package/dist/cli/commands/menu/backup-handlers.js +1202 -0
- package/dist/cli/commands/menu/backup-handlers.js.map +1 -0
- package/dist/cli/commands/menu/container-handlers.js +1788 -0
- package/dist/cli/commands/menu/container-handlers.js.map +1 -0
- package/dist/cli/commands/menu/engine-handlers.js +235 -0
- package/dist/cli/commands/menu/engine-handlers.js.map +1 -0
- package/dist/cli/commands/menu/index.js +266 -0
- package/dist/cli/commands/menu/index.js.map +1 -0
- package/dist/cli/commands/menu/settings-handlers.js +320 -0
- package/dist/cli/commands/menu/settings-handlers.js.map +1 -0
- package/dist/cli/commands/menu/shared.js +13 -0
- package/dist/cli/commands/menu/shared.js.map +1 -0
- package/dist/cli/commands/menu/shell-handlers.js +1573 -0
- package/dist/cli/commands/menu/shell-handlers.js.map +1 -0
- package/dist/cli/commands/menu/sql-handlers.js +185 -0
- package/dist/cli/commands/menu/sql-handlers.js.map +1 -0
- package/dist/cli/commands/menu/update-handlers.js +322 -0
- package/dist/cli/commands/menu/update-handlers.js.map +1 -0
- package/dist/cli/commands/menu/validators.js +9 -0
- package/dist/cli/commands/menu/validators.js.map +1 -0
- package/dist/cli/commands/ports.js +166 -0
- package/dist/cli/commands/ports.js.map +1 -0
- package/dist/cli/commands/pull.js +166 -0
- package/dist/cli/commands/pull.js.map +1 -0
- package/dist/cli/commands/query.js +180 -0
- package/dist/cli/commands/query.js.map +1 -0
- package/dist/cli/commands/restore.js +428 -0
- package/dist/cli/commands/restore.js.map +1 -0
- package/dist/cli/commands/run.js +115 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/self-update.js +99 -0
- package/dist/cli/commands/self-update.js.map +1 -0
- package/dist/cli/commands/sqlite.js +207 -0
- package/dist/cli/commands/sqlite.js.map +1 -0
- package/dist/cli/commands/start.js +196 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/stop.js +182 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/commands/url.js +88 -0
- package/dist/cli/commands/url.js.map +1 -0
- package/dist/cli/commands/users.js +189 -0
- package/dist/cli/commands/users.js.map +1 -0
- package/dist/cli/commands/version.js +52 -0
- package/dist/cli/commands/version.js.map +1 -0
- package/dist/cli/commands/which.js +258 -0
- package/dist/cli/commands/which.js.map +1 -0
- package/dist/cli/constants.js +212 -0
- package/dist/cli/constants.js.map +1 -0
- package/dist/cli/helpers.js +1120 -0
- package/dist/cli/helpers.js.map +1 -0
- package/dist/cli/index.js +146 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/ui/prompts.js +1002 -0
- package/dist/cli/ui/prompts.js.map +1 -0
- package/dist/cli/ui/spinner.js +74 -0
- package/dist/cli/ui/spinner.js.map +1 -0
- package/dist/cli/ui/theme.js +99 -0
- package/dist/cli/ui/theme.js.map +1 -0
- package/dist/cli/utils/file-follower.js +79 -0
- package/dist/cli/utils/file-follower.js.map +1 -0
- package/dist/config/backup-formats.js +363 -0
- package/dist/config/backup-formats.js.map +1 -0
- package/dist/config/defaults.js +25 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/engine-defaults.js +303 -0
- package/dist/config/engine-defaults.js.map +1 -0
- package/dist/config/engines-registry.js +103 -0
- package/dist/config/engines-registry.js.map +1 -0
- package/dist/config/os-dependencies.js +767 -0
- package/dist/config/os-dependencies.js.map +1 -0
- package/dist/config/paths.js +156 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/version.js +3 -0
- package/dist/config/version.js.map +1 -0
- package/dist/core/backup-restore.js +219 -0
- package/dist/core/backup-restore.js.map +1 -0
- package/dist/core/base-binary-manager.js +403 -0
- package/dist/core/base-binary-manager.js.map +1 -0
- package/dist/core/base-document-binary-manager.js +364 -0
- package/dist/core/base-document-binary-manager.js.map +1 -0
- package/dist/core/base-embedded-binary-manager.js +364 -0
- package/dist/core/base-embedded-binary-manager.js.map +1 -0
- package/dist/core/base-server-binary-manager.js +368 -0
- package/dist/core/base-server-binary-manager.js.map +1 -0
- package/dist/core/config-manager.js +495 -0
- package/dist/core/config-manager.js.map +1 -0
- package/dist/core/container-manager.js +609 -0
- package/dist/core/container-manager.js.map +1 -0
- package/dist/core/credential-generator.js +67 -0
- package/dist/core/credential-generator.js.map +1 -0
- package/dist/core/credential-manager.js +211 -0
- package/dist/core/credential-manager.js.map +1 -0
- package/dist/core/dblab-utils.js +105 -0
- package/dist/core/dblab-utils.js.map +1 -0
- package/dist/core/dependency-manager.js +359 -0
- package/dist/core/dependency-manager.js.map +1 -0
- package/dist/core/docker-exporter.js +1077 -0
- package/dist/core/docker-exporter.js.map +1 -0
- package/dist/core/error-handler.js +295 -0
- package/dist/core/error-handler.js.map +1 -0
- package/dist/core/fs-error-utils.js +74 -0
- package/dist/core/fs-error-utils.js.map +1 -0
- package/dist/core/homebrew-version-manager.js +280 -0
- package/dist/core/homebrew-version-manager.js.map +1 -0
- package/dist/core/hostdb-client.js +252 -0
- package/dist/core/hostdb-client.js.map +1 -0
- package/dist/core/hostdb-metadata.js +243 -0
- package/dist/core/hostdb-metadata.js.map +1 -0
- package/dist/core/hostdb-releases-factory.js +161 -0
- package/dist/core/hostdb-releases-factory.js.map +1 -0
- package/dist/core/library-env.js +88 -0
- package/dist/core/library-env.js.map +1 -0
- package/dist/core/pgweb-utils.js +53 -0
- package/dist/core/pgweb-utils.js.map +1 -0
- package/dist/core/platform-service.js +632 -0
- package/dist/core/platform-service.js.map +1 -0
- package/dist/core/port-manager.js +136 -0
- package/dist/core/port-manager.js.map +1 -0
- package/dist/core/process-manager.js +445 -0
- package/dist/core/process-manager.js.map +1 -0
- package/dist/core/pull-manager.js +418 -0
- package/dist/core/pull-manager.js.map +1 -0
- package/dist/core/query-parser.js +449 -0
- package/dist/core/query-parser.js.map +1 -0
- package/dist/core/spawn-utils.js +90 -0
- package/dist/core/spawn-utils.js.map +1 -0
- package/dist/core/start-with-retry.js +90 -0
- package/dist/core/start-with-retry.js.map +1 -0
- package/dist/core/test-cleanup.js +85 -0
- package/dist/core/test-cleanup.js.map +1 -0
- package/dist/core/tls-generator.js +84 -0
- package/dist/core/tls-generator.js.map +1 -0
- package/dist/core/transaction-manager.js +139 -0
- package/dist/core/transaction-manager.js.map +1 -0
- package/dist/core/update-manager.js +241 -0
- package/dist/core/update-manager.js.map +1 -0
- package/dist/core/version-migration.js +260 -0
- package/dist/core/version-migration.js.map +1 -0
- package/dist/core/version-utils.js +91 -0
- package/dist/core/version-utils.js.map +1 -0
- package/dist/engines/base-engine.js +179 -0
- package/dist/engines/base-engine.js.map +1 -0
- package/dist/engines/clickhouse/backup.js +289 -0
- package/dist/engines/clickhouse/backup.js.map +1 -0
- package/dist/engines/clickhouse/binary-manager.js +145 -0
- package/dist/engines/clickhouse/binary-manager.js.map +1 -0
- package/dist/engines/clickhouse/binary-urls.js +100 -0
- package/dist/engines/clickhouse/binary-urls.js.map +1 -0
- package/dist/engines/clickhouse/cli-utils.js +143 -0
- package/dist/engines/clickhouse/cli-utils.js.map +1 -0
- package/dist/engines/clickhouse/hostdb-releases.js +24 -0
- package/dist/engines/clickhouse/hostdb-releases.js.map +1 -0
- package/dist/engines/clickhouse/index.js +1077 -0
- package/dist/engines/clickhouse/index.js.map +1 -0
- package/dist/engines/clickhouse/restore.js +335 -0
- package/dist/engines/clickhouse/restore.js.map +1 -0
- package/dist/engines/clickhouse/version-maps.js +83 -0
- package/dist/engines/clickhouse/version-maps.js.map +1 -0
- package/dist/engines/clickhouse/version-validator.js +133 -0
- package/dist/engines/clickhouse/version-validator.js.map +1 -0
- package/dist/engines/cockroachdb/backup.js +261 -0
- package/dist/engines/cockroachdb/backup.js.map +1 -0
- package/dist/engines/cockroachdb/binary-manager.js +33 -0
- package/dist/engines/cockroachdb/binary-manager.js.map +1 -0
- package/dist/engines/cockroachdb/binary-urls.js +33 -0
- package/dist/engines/cockroachdb/binary-urls.js.map +1 -0
- package/dist/engines/cockroachdb/cli-utils.js +338 -0
- package/dist/engines/cockroachdb/cli-utils.js.map +1 -0
- package/dist/engines/cockroachdb/hostdb-releases.js +21 -0
- package/dist/engines/cockroachdb/hostdb-releases.js.map +1 -0
- package/dist/engines/cockroachdb/index.js +1016 -0
- package/dist/engines/cockroachdb/index.js.map +1 -0
- package/dist/engines/cockroachdb/restore.js +323 -0
- package/dist/engines/cockroachdb/restore.js.map +1 -0
- package/dist/engines/cockroachdb/version-maps.js +37 -0
- package/dist/engines/cockroachdb/version-maps.js.map +1 -0
- package/dist/engines/couchdb/api-client.js +64 -0
- package/dist/engines/couchdb/api-client.js.map +1 -0
- package/dist/engines/couchdb/backup.js +90 -0
- package/dist/engines/couchdb/backup.js.map +1 -0
- package/dist/engines/couchdb/binary-manager.js +62 -0
- package/dist/engines/couchdb/binary-manager.js.map +1 -0
- package/dist/engines/couchdb/binary-urls.js +92 -0
- package/dist/engines/couchdb/binary-urls.js.map +1 -0
- package/dist/engines/couchdb/hostdb-releases.js +21 -0
- package/dist/engines/couchdb/hostdb-releases.js.map +1 -0
- package/dist/engines/couchdb/index.js +1043 -0
- package/dist/engines/couchdb/index.js.map +1 -0
- package/dist/engines/couchdb/restore.js +198 -0
- package/dist/engines/couchdb/restore.js.map +1 -0
- package/dist/engines/couchdb/version-maps.js +67 -0
- package/dist/engines/couchdb/version-maps.js.map +1 -0
- package/dist/engines/couchdb/version-validator.js +88 -0
- package/dist/engines/couchdb/version-validator.js.map +1 -0
- package/dist/engines/duckdb/binary-manager.js +33 -0
- package/dist/engines/duckdb/binary-manager.js.map +1 -0
- package/{engines/duckdb/binary-urls.ts → dist/engines/duckdb/binary-urls.js} +11 -16
- package/dist/engines/duckdb/binary-urls.js.map +1 -0
- package/dist/engines/duckdb/hostdb-releases.js +21 -0
- package/dist/engines/duckdb/hostdb-releases.js.map +1 -0
- package/dist/engines/duckdb/index.js +594 -0
- package/dist/engines/duckdb/index.js.map +1 -0
- package/dist/engines/duckdb/registry.js +265 -0
- package/dist/engines/duckdb/registry.js.map +1 -0
- package/dist/engines/duckdb/scanner.js +12 -0
- package/dist/engines/duckdb/scanner.js.map +1 -0
- package/dist/engines/duckdb/version-maps.js +67 -0
- package/dist/engines/duckdb/version-maps.js.map +1 -0
- package/dist/engines/duckdb/version-validator.js +62 -0
- package/dist/engines/duckdb/version-validator.js.map +1 -0
- package/dist/engines/ferretdb/backup.js +170 -0
- package/dist/engines/ferretdb/backup.js.map +1 -0
- package/dist/engines/ferretdb/binary-manager.js +765 -0
- package/dist/engines/ferretdb/binary-manager.js.map +1 -0
- package/dist/engines/ferretdb/binary-urls.js +135 -0
- package/dist/engines/ferretdb/binary-urls.js.map +1 -0
- package/dist/engines/ferretdb/index.js +1517 -0
- package/dist/engines/ferretdb/index.js.map +1 -0
- package/dist/engines/ferretdb/restore.js +310 -0
- package/dist/engines/ferretdb/restore.js.map +1 -0
- package/{engines/ferretdb/version-maps.ts → dist/engines/ferretdb/version-maps.js} +62 -79
- package/dist/engines/ferretdb/version-maps.js.map +1 -0
- package/dist/engines/file-based-utils.js +184 -0
- package/dist/engines/file-based-utils.js.map +1 -0
- package/dist/engines/index.js +124 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/engines/influxdb/api-client.js +54 -0
- package/dist/engines/influxdb/api-client.js.map +1 -0
- package/dist/engines/influxdb/backup.js +119 -0
- package/dist/engines/influxdb/backup.js.map +1 -0
- package/dist/engines/influxdb/binary-manager.js +87 -0
- package/dist/engines/influxdb/binary-manager.js.map +1 -0
- package/dist/engines/influxdb/binary-urls.js +56 -0
- package/dist/engines/influxdb/binary-urls.js.map +1 -0
- package/dist/engines/influxdb/hostdb-releases.js +21 -0
- package/dist/engines/influxdb/hostdb-releases.js.map +1 -0
- package/dist/engines/influxdb/index.js +962 -0
- package/dist/engines/influxdb/index.js.map +1 -0
- package/dist/engines/influxdb/restore.js +329 -0
- package/dist/engines/influxdb/restore.js.map +1 -0
- package/dist/engines/influxdb/version-maps.js +64 -0
- package/dist/engines/influxdb/version-maps.js.map +1 -0
- package/dist/engines/influxdb/version-validator.js +109 -0
- package/dist/engines/influxdb/version-validator.js.map +1 -0
- package/dist/engines/mariadb/backup.js +178 -0
- package/dist/engines/mariadb/backup.js.map +1 -0
- package/dist/engines/mariadb/binary-manager.js +33 -0
- package/dist/engines/mariadb/binary-manager.js.map +1 -0
- package/{engines/mariadb/binary-urls.ts → dist/engines/mariadb/binary-urls.js} +38 -55
- package/dist/engines/mariadb/binary-urls.js.map +1 -0
- package/dist/engines/mariadb/hostdb-releases.js +21 -0
- package/dist/engines/mariadb/hostdb-releases.js.map +1 -0
- package/dist/engines/mariadb/index.js +1011 -0
- package/dist/engines/mariadb/index.js.map +1 -0
- package/dist/engines/mariadb/restore.js +322 -0
- package/dist/engines/mariadb/restore.js.map +1 -0
- package/dist/engines/mariadb/version-maps.js +63 -0
- package/dist/engines/mariadb/version-maps.js.map +1 -0
- package/dist/engines/mariadb/version-validator.js +143 -0
- package/dist/engines/mariadb/version-validator.js.map +1 -0
- package/dist/engines/meilisearch/api-client.js +50 -0
- package/dist/engines/meilisearch/api-client.js.map +1 -0
- package/dist/engines/meilisearch/backup.js +167 -0
- package/dist/engines/meilisearch/backup.js.map +1 -0
- package/dist/engines/meilisearch/binary-manager.js +31 -0
- package/dist/engines/meilisearch/binary-manager.js.map +1 -0
- package/dist/engines/meilisearch/binary-urls.js +56 -0
- package/dist/engines/meilisearch/binary-urls.js.map +1 -0
- package/dist/engines/meilisearch/hostdb-releases.js +21 -0
- package/dist/engines/meilisearch/hostdb-releases.js.map +1 -0
- package/dist/engines/meilisearch/index.js +992 -0
- package/dist/engines/meilisearch/index.js.map +1 -0
- package/dist/engines/meilisearch/restore.js +167 -0
- package/dist/engines/meilisearch/restore.js.map +1 -0
- package/dist/engines/meilisearch/version-maps.js +67 -0
- package/dist/engines/meilisearch/version-maps.js.map +1 -0
- package/dist/engines/meilisearch/version-validator.js +109 -0
- package/dist/engines/meilisearch/version-validator.js.map +1 -0
- package/dist/engines/mongodb/backup.js +109 -0
- package/dist/engines/mongodb/backup.js.map +1 -0
- package/dist/engines/mongodb/binary-manager.js +36 -0
- package/dist/engines/mongodb/binary-manager.js.map +1 -0
- package/dist/engines/mongodb/binary-urls.js +46 -0
- package/dist/engines/mongodb/binary-urls.js.map +1 -0
- package/dist/engines/mongodb/cli-utils.js +131 -0
- package/dist/engines/mongodb/cli-utils.js.map +1 -0
- package/dist/engines/mongodb/hostdb-releases.js +77 -0
- package/dist/engines/mongodb/hostdb-releases.js.map +1 -0
- package/dist/engines/mongodb/index.js +873 -0
- package/dist/engines/mongodb/index.js.map +1 -0
- package/dist/engines/mongodb/restore.js +276 -0
- package/dist/engines/mongodb/restore.js.map +1 -0
- package/dist/engines/mongodb/version-maps.js +79 -0
- package/dist/engines/mongodb/version-maps.js.map +1 -0
- package/dist/engines/mongodb/version-validator.js +133 -0
- package/dist/engines/mongodb/version-validator.js.map +1 -0
- package/dist/engines/mysql/backup.js +210 -0
- package/dist/engines/mysql/backup.js.map +1 -0
- package/dist/engines/mysql/binary-detection.js +325 -0
- package/dist/engines/mysql/binary-detection.js.map +1 -0
- package/dist/engines/mysql/binary-manager.js +30 -0
- package/dist/engines/mysql/binary-manager.js.map +1 -0
- package/dist/engines/mysql/binary-urls.js +87 -0
- package/dist/engines/mysql/binary-urls.js.map +1 -0
- package/{engines/mysql/hostdb-releases.ts → dist/engines/mysql/hostdb-releases.js} +20 -23
- package/dist/engines/mysql/hostdb-releases.js.map +1 -0
- package/dist/engines/mysql/index.js +1066 -0
- package/dist/engines/mysql/index.js.map +1 -0
- package/dist/engines/mysql/restore.js +361 -0
- package/dist/engines/mysql/restore.js.map +1 -0
- package/dist/engines/mysql/version-maps.js +79 -0
- package/dist/engines/mysql/version-maps.js.map +1 -0
- package/dist/engines/mysql/version-validator.js +266 -0
- package/dist/engines/mysql/version-validator.js.map +1 -0
- package/dist/engines/postgresql/backup.js +118 -0
- package/dist/engines/postgresql/backup.js.map +1 -0
- package/dist/engines/postgresql/binary-manager.js +85 -0
- package/dist/engines/postgresql/binary-manager.js.map +1 -0
- package/dist/engines/postgresql/binary-urls.js +80 -0
- package/dist/engines/postgresql/binary-urls.js.map +1 -0
- package/dist/engines/postgresql/hostdb-releases.js +21 -0
- package/dist/engines/postgresql/hostdb-releases.js.map +1 -0
- package/dist/engines/postgresql/index.js +852 -0
- package/dist/engines/postgresql/index.js.map +1 -0
- package/dist/engines/postgresql/remote-version.js +109 -0
- package/dist/engines/postgresql/remote-version.js.map +1 -0
- package/dist/engines/postgresql/restore.js +254 -0
- package/dist/engines/postgresql/restore.js.map +1 -0
- package/dist/engines/postgresql/version-maps.js +73 -0
- package/dist/engines/postgresql/version-maps.js.map +1 -0
- package/dist/engines/postgresql/version-validator.js +286 -0
- package/dist/engines/postgresql/version-validator.js.map +1 -0
- package/dist/engines/qdrant/api-client.js +50 -0
- package/dist/engines/qdrant/api-client.js.map +1 -0
- package/dist/engines/qdrant/backup.js +115 -0
- package/dist/engines/qdrant/backup.js.map +1 -0
- package/dist/engines/qdrant/binary-manager.js +31 -0
- package/dist/engines/qdrant/binary-manager.js.map +1 -0
- package/dist/engines/qdrant/binary-urls.js +92 -0
- package/dist/engines/qdrant/binary-urls.js.map +1 -0
- package/dist/engines/qdrant/cli-utils.js +39 -0
- package/dist/engines/qdrant/cli-utils.js.map +1 -0
- package/dist/engines/qdrant/hostdb-releases.js +21 -0
- package/dist/engines/qdrant/hostdb-releases.js.map +1 -0
- package/dist/engines/qdrant/index.js +1002 -0
- package/dist/engines/qdrant/index.js.map +1 -0
- package/dist/engines/qdrant/restore.js +154 -0
- package/dist/engines/qdrant/restore.js.map +1 -0
- package/dist/engines/qdrant/version-maps.js +67 -0
- package/dist/engines/qdrant/version-maps.js.map +1 -0
- package/dist/engines/qdrant/version-validator.js +109 -0
- package/dist/engines/qdrant/version-validator.js.map +1 -0
- package/dist/engines/questdb/backup.js +191 -0
- package/dist/engines/questdb/backup.js.map +1 -0
- package/dist/engines/questdb/binary-manager.js +247 -0
- package/dist/engines/questdb/binary-manager.js.map +1 -0
- package/dist/engines/questdb/binary-urls.js +27 -0
- package/dist/engines/questdb/binary-urls.js.map +1 -0
- package/dist/engines/questdb/hostdb-releases.js +21 -0
- package/dist/engines/questdb/hostdb-releases.js.map +1 -0
- package/dist/engines/questdb/index.js +814 -0
- package/dist/engines/questdb/index.js.map +1 -0
- package/dist/engines/questdb/restore.js +202 -0
- package/dist/engines/questdb/restore.js.map +1 -0
- package/dist/engines/questdb/version-maps.js +33 -0
- package/dist/engines/questdb/version-maps.js.map +1 -0
- package/dist/engines/questdb/version-validator.js +99 -0
- package/dist/engines/questdb/version-validator.js.map +1 -0
- package/dist/engines/redis/backup.js +292 -0
- package/dist/engines/redis/backup.js.map +1 -0
- package/dist/engines/redis/binary-manager.js +32 -0
- package/dist/engines/redis/binary-manager.js.map +1 -0
- package/dist/engines/redis/binary-urls.js +96 -0
- package/dist/engines/redis/binary-urls.js.map +1 -0
- package/dist/engines/redis/cli-utils.js +38 -0
- package/dist/engines/redis/cli-utils.js.map +1 -0
- package/dist/engines/redis/hostdb-releases.js +21 -0
- package/dist/engines/redis/hostdb-releases.js.map +1 -0
- package/dist/engines/redis/index.js +1263 -0
- package/dist/engines/redis/index.js.map +1 -0
- package/dist/engines/redis/restore.js +338 -0
- package/dist/engines/redis/restore.js.map +1 -0
- package/dist/engines/redis/version-maps.js +70 -0
- package/dist/engines/redis/version-maps.js.map +1 -0
- package/dist/engines/redis/version-validator.js +109 -0
- package/dist/engines/redis/version-validator.js.map +1 -0
- package/dist/engines/sqlite/binary-manager.js +39 -0
- package/dist/engines/sqlite/binary-manager.js.map +1 -0
- package/{engines/sqlite/binary-urls.ts → dist/engines/sqlite/binary-urls.js} +11 -16
- package/dist/engines/sqlite/binary-urls.js.map +1 -0
- package/dist/engines/sqlite/hostdb-releases.js +21 -0
- package/dist/engines/sqlite/hostdb-releases.js.map +1 -0
- package/dist/engines/sqlite/index.js +493 -0
- package/dist/engines/sqlite/index.js.map +1 -0
- package/dist/engines/sqlite/registry.js +163 -0
- package/dist/engines/sqlite/registry.js.map +1 -0
- package/dist/engines/sqlite/scanner.js +12 -0
- package/dist/engines/sqlite/scanner.js.map +1 -0
- package/dist/engines/sqlite/version-maps.js +57 -0
- package/dist/engines/sqlite/version-maps.js.map +1 -0
- package/dist/engines/surrealdb/backup.js +97 -0
- package/dist/engines/surrealdb/backup.js.map +1 -0
- package/dist/engines/surrealdb/binary-manager.js +33 -0
- package/dist/engines/surrealdb/binary-manager.js.map +1 -0
- package/dist/engines/surrealdb/binary-urls.js +33 -0
- package/dist/engines/surrealdb/binary-urls.js.map +1 -0
- package/dist/engines/surrealdb/cli-utils.js +147 -0
- package/dist/engines/surrealdb/cli-utils.js.map +1 -0
- package/dist/engines/surrealdb/hostdb-releases.js +21 -0
- package/dist/engines/surrealdb/hostdb-releases.js.map +1 -0
- package/dist/engines/surrealdb/index.js +1022 -0
- package/dist/engines/surrealdb/index.js.map +1 -0
- package/dist/engines/surrealdb/restore.js +224 -0
- package/dist/engines/surrealdb/restore.js.map +1 -0
- package/dist/engines/surrealdb/version-maps.js +36 -0
- package/dist/engines/surrealdb/version-maps.js.map +1 -0
- package/dist/engines/tigerbeetle/backup.js +36 -0
- package/dist/engines/tigerbeetle/backup.js.map +1 -0
- package/dist/engines/tigerbeetle/binary-manager.js +72 -0
- package/dist/engines/tigerbeetle/binary-manager.js.map +1 -0
- package/dist/engines/tigerbeetle/binary-urls.js +49 -0
- package/dist/engines/tigerbeetle/binary-urls.js.map +1 -0
- package/dist/engines/tigerbeetle/hostdb-releases.js +21 -0
- package/dist/engines/tigerbeetle/hostdb-releases.js.map +1 -0
- package/dist/engines/tigerbeetle/index.js +559 -0
- package/dist/engines/tigerbeetle/index.js.map +1 -0
- package/dist/engines/tigerbeetle/restore.js +91 -0
- package/dist/engines/tigerbeetle/restore.js.map +1 -0
- package/{engines/tigerbeetle/version-maps.ts → dist/engines/tigerbeetle/version-maps.js} +22 -31
- package/dist/engines/tigerbeetle/version-maps.js.map +1 -0
- package/dist/engines/tigerbeetle/version-validator.js +108 -0
- package/dist/engines/tigerbeetle/version-validator.js.map +1 -0
- package/dist/engines/typedb/backup.js +129 -0
- package/dist/engines/typedb/backup.js.map +1 -0
- package/dist/engines/typedb/binary-manager.js +151 -0
- package/dist/engines/typedb/binary-manager.js.map +1 -0
- package/dist/engines/typedb/binary-urls.js +33 -0
- package/dist/engines/typedb/binary-urls.js.map +1 -0
- package/dist/engines/typedb/cli-utils.js +163 -0
- package/dist/engines/typedb/cli-utils.js.map +1 -0
- package/dist/engines/typedb/hostdb-releases.js +21 -0
- package/dist/engines/typedb/hostdb-releases.js.map +1 -0
- package/dist/engines/typedb/index.js +1003 -0
- package/dist/engines/typedb/index.js.map +1 -0
- package/dist/engines/typedb/restore.js +279 -0
- package/dist/engines/typedb/restore.js.map +1 -0
- package/dist/engines/typedb/version-maps.js +40 -0
- package/dist/engines/typedb/version-maps.js.map +1 -0
- package/dist/engines/typedb/version-validator.js +103 -0
- package/dist/engines/typedb/version-validator.js.map +1 -0
- package/dist/engines/valkey/backup.js +292 -0
- package/dist/engines/valkey/backup.js.map +1 -0
- package/dist/engines/valkey/binary-manager.js +33 -0
- package/dist/engines/valkey/binary-manager.js.map +1 -0
- package/dist/engines/valkey/binary-urls.js +98 -0
- package/dist/engines/valkey/binary-urls.js.map +1 -0
- package/dist/engines/valkey/cli-utils.js +38 -0
- package/dist/engines/valkey/cli-utils.js.map +1 -0
- package/dist/engines/valkey/hostdb-releases.js +21 -0
- package/dist/engines/valkey/hostdb-releases.js.map +1 -0
- package/dist/engines/valkey/index.js +1257 -0
- package/dist/engines/valkey/index.js.map +1 -0
- package/dist/engines/valkey/restore.js +340 -0
- package/dist/engines/valkey/restore.js.map +1 -0
- package/dist/engines/valkey/version-maps.js +70 -0
- package/dist/engines/valkey/version-maps.js.map +1 -0
- package/dist/engines/valkey/version-validator.js +112 -0
- package/dist/engines/valkey/version-validator.js.map +1 -0
- package/dist/engines/weaviate/api-client.js +50 -0
- package/dist/engines/weaviate/api-client.js.map +1 -0
- package/dist/engines/weaviate/backup.js +95 -0
- package/dist/engines/weaviate/backup.js.map +1 -0
- package/dist/engines/weaviate/binary-manager.js +58 -0
- package/dist/engines/weaviate/binary-manager.js.map +1 -0
- package/dist/engines/weaviate/binary-urls.js +92 -0
- package/dist/engines/weaviate/binary-urls.js.map +1 -0
- package/dist/engines/weaviate/cli-utils.js +39 -0
- package/dist/engines/weaviate/cli-utils.js.map +1 -0
- package/dist/engines/weaviate/hostdb-releases.js +21 -0
- package/dist/engines/weaviate/hostdb-releases.js.map +1 -0
- package/dist/engines/weaviate/index.js +871 -0
- package/dist/engines/weaviate/index.js.map +1 -0
- package/dist/engines/weaviate/restore.js +185 -0
- package/dist/engines/weaviate/restore.js.map +1 -0
- package/dist/engines/weaviate/version-maps.js +67 -0
- package/dist/engines/weaviate/version-maps.js.map +1 -0
- package/dist/engines/weaviate/version-validator.js +109 -0
- package/dist/engines/weaviate/version-validator.js.map +1 -0
- package/dist/types/index.js +102 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +12 -9
- package/bin/cli.js +0 -68
- package/cli/bin.ts +0 -10
- package/cli/commands/attach.ts +0 -139
- package/cli/commands/backup.ts +0 -290
- package/cli/commands/backups.ts +0 -247
- package/cli/commands/clone.ts +0 -159
- package/cli/commands/config.ts +0 -367
- package/cli/commands/connect.ts +0 -684
- package/cli/commands/create.ts +0 -1201
- package/cli/commands/databases.ts +0 -630
- package/cli/commands/delete.ts +0 -133
- package/cli/commands/deps.ts +0 -342
- package/cli/commands/detach.ts +0 -107
- package/cli/commands/doctor.ts +0 -689
- package/cli/commands/duckdb.ts +0 -273
- package/cli/commands/edit.ts +0 -683
- package/cli/commands/engines.ts +0 -1914
- package/cli/commands/export.ts +0 -544
- package/cli/commands/info.ts +0 -340
- package/cli/commands/list.ts +0 -284
- package/cli/commands/logs.ts +0 -102
- package/cli/commands/menu/backup-handlers.ts +0 -1571
- package/cli/commands/menu/container-handlers.ts +0 -2288
- package/cli/commands/menu/engine-handlers.ts +0 -355
- package/cli/commands/menu/index.ts +0 -342
- package/cli/commands/menu/settings-handlers.ts +0 -365
- package/cli/commands/menu/shared.ts +0 -23
- package/cli/commands/menu/shell-handlers.ts +0 -1811
- package/cli/commands/menu/sql-handlers.ts +0 -231
- package/cli/commands/menu/update-handlers.ts +0 -378
- package/cli/commands/menu/validators.ts +0 -8
- package/cli/commands/ports.ts +0 -211
- package/cli/commands/pull.ts +0 -223
- package/cli/commands/query.ts +0 -241
- package/cli/commands/restore.ts +0 -587
- package/cli/commands/run.ts +0 -178
- package/cli/commands/self-update.ts +0 -121
- package/cli/commands/sqlite.ts +0 -273
- package/cli/commands/start.ts +0 -218
- package/cli/commands/stop.ts +0 -241
- package/cli/commands/url.ts +0 -104
- package/cli/commands/users.ts +0 -264
- package/cli/commands/version.ts +0 -55
- package/cli/commands/which.ts +0 -290
- package/cli/constants.ts +0 -233
- package/cli/helpers.ts +0 -1593
- package/cli/index.ts +0 -162
- package/cli/ui/prompts.ts +0 -1525
- package/cli/ui/spinner.ts +0 -88
- package/cli/ui/theme.ts +0 -128
- package/cli/utils/file-follower.ts +0 -93
- package/config/backup-formats.ts +0 -446
- package/config/defaults.ts +0 -56
- package/config/engine-defaults.ts +0 -336
- package/config/engines-registry.ts +0 -150
- package/config/engines.schema.json +0 -135
- package/config/os-dependencies.ts +0 -888
- package/config/paths.ts +0 -200
- package/core/backup-restore.ts +0 -330
- package/core/base-binary-manager.ts +0 -562
- package/core/base-document-binary-manager.ts +0 -523
- package/core/base-embedded-binary-manager.ts +0 -547
- package/core/base-server-binary-manager.ts +0 -523
- package/core/config-manager.ts +0 -652
- package/core/container-manager.ts +0 -787
- package/core/credential-generator.ts +0 -93
- package/core/credential-manager.ts +0 -259
- package/core/dblab-utils.ts +0 -113
- package/core/dependency-manager.ts +0 -512
- package/core/docker-exporter.ts +0 -1345
- package/core/error-handler.ts +0 -419
- package/core/fs-error-utils.ts +0 -82
- package/core/homebrew-version-manager.ts +0 -352
- package/core/hostdb-client.ts +0 -344
- package/core/hostdb-metadata.ts +0 -350
- package/core/hostdb-releases-factory.ts +0 -237
- package/core/library-env.ts +0 -118
- package/core/pgweb-utils.ts +0 -62
- package/core/platform-service.ts +0 -829
- package/core/port-manager.ts +0 -165
- package/core/process-manager.ts +0 -576
- package/core/pull-manager.ts +0 -511
- package/core/query-parser.ts +0 -514
- package/core/spawn-utils.ts +0 -122
- package/core/start-with-retry.ts +0 -130
- package/core/test-cleanup.ts +0 -108
- package/core/tls-generator.ts +0 -116
- package/core/transaction-manager.ts +0 -158
- package/core/update-manager.ts +0 -308
- package/core/version-migration.ts +0 -346
- package/core/version-utils.ts +0 -104
- package/engines/base-engine.ts +0 -340
- package/engines/clickhouse/README.md +0 -231
- package/engines/clickhouse/backup.ts +0 -398
- package/engines/clickhouse/binary-manager.ts +0 -201
- package/engines/clickhouse/binary-urls.ts +0 -125
- package/engines/clickhouse/cli-utils.ts +0 -176
- package/engines/clickhouse/hostdb-releases.ts +0 -30
- package/engines/clickhouse/index.ts +0 -1345
- package/engines/clickhouse/restore.ts +0 -466
- package/engines/clickhouse/version-maps.ts +0 -95
- package/engines/clickhouse/version-validator.ts +0 -154
- package/engines/cockroachdb/README.md +0 -170
- package/engines/cockroachdb/backup.ts +0 -376
- package/engines/cockroachdb/binary-manager.ts +0 -45
- package/engines/cockroachdb/binary-urls.ts +0 -40
- package/engines/cockroachdb/cli-utils.ts +0 -384
- package/engines/cockroachdb/hostdb-releases.ts +0 -26
- package/engines/cockroachdb/index.ts +0 -1276
- package/engines/cockroachdb/restore.ts +0 -455
- package/engines/cockroachdb/version-maps.ts +0 -42
- package/engines/couchdb/README.md +0 -257
- package/engines/couchdb/api-client.ts +0 -81
- package/engines/couchdb/backup.ts +0 -137
- package/engines/couchdb/binary-manager.ts +0 -86
- package/engines/couchdb/binary-urls.ts +0 -115
- package/engines/couchdb/hostdb-releases.ts +0 -23
- package/engines/couchdb/index.ts +0 -1429
- package/engines/couchdb/restore.ts +0 -290
- package/engines/couchdb/version-maps.ts +0 -78
- package/engines/couchdb/version-validator.ts +0 -111
- package/engines/duckdb/README.md +0 -154
- package/engines/duckdb/binary-manager.ts +0 -45
- package/engines/duckdb/hostdb-releases.ts +0 -23
- package/engines/duckdb/index.ts +0 -749
- package/engines/duckdb/registry.ts +0 -303
- package/engines/duckdb/scanner.ts +0 -22
- package/engines/duckdb/version-maps.ts +0 -78
- package/engines/duckdb/version-validator.ts +0 -78
- package/engines/ferretdb/README.md +0 -262
- package/engines/ferretdb/backup.ts +0 -173
- package/engines/ferretdb/binary-manager.ts +0 -1095
- package/engines/ferretdb/binary-urls.ts +0 -183
- package/engines/ferretdb/index.ts +0 -1907
- package/engines/ferretdb/restore.ts +0 -357
- package/engines/file-based-utils.ts +0 -262
- package/engines/index.ts +0 -131
- package/engines/influxdb/README.md +0 -180
- package/engines/influxdb/api-client.ts +0 -64
- package/engines/influxdb/backup.ts +0 -160
- package/engines/influxdb/binary-manager.ts +0 -110
- package/engines/influxdb/binary-urls.ts +0 -69
- package/engines/influxdb/hostdb-releases.ts +0 -23
- package/engines/influxdb/index.ts +0 -1272
- package/engines/influxdb/restore.ts +0 -417
- package/engines/influxdb/version-maps.ts +0 -75
- package/engines/influxdb/version-validator.ts +0 -128
- package/engines/mariadb/README.md +0 -141
- package/engines/mariadb/backup.ts +0 -233
- package/engines/mariadb/binary-manager.ts +0 -45
- package/engines/mariadb/hostdb-releases.ts +0 -23
- package/engines/mariadb/index.ts +0 -1300
- package/engines/mariadb/restore.ts +0 -447
- package/engines/mariadb/version-maps.ts +0 -72
- package/engines/mariadb/version-validator.ts +0 -181
- package/engines/meilisearch/README.md +0 -255
- package/engines/meilisearch/api-client.ts +0 -61
- package/engines/meilisearch/backup.ts +0 -233
- package/engines/meilisearch/binary-manager.ts +0 -43
- package/engines/meilisearch/binary-urls.ts +0 -69
- package/engines/meilisearch/hostdb-releases.ts +0 -26
- package/engines/meilisearch/index.ts +0 -1292
- package/engines/meilisearch/restore.ts +0 -219
- package/engines/meilisearch/version-maps.ts +0 -78
- package/engines/meilisearch/version-validator.ts +0 -128
- package/engines/mongodb/README.md +0 -162
- package/engines/mongodb/backup.ts +0 -127
- package/engines/mongodb/binary-manager.ts +0 -48
- package/engines/mongodb/binary-urls.ts +0 -63
- package/engines/mongodb/cli-utils.ts +0 -171
- package/engines/mongodb/hostdb-releases.ts +0 -91
- package/engines/mongodb/index.ts +0 -1118
- package/engines/mongodb/restore.ts +0 -361
- package/engines/mongodb/version-maps.ts +0 -91
- package/engines/mongodb/version-validator.ts +0 -160
- package/engines/mysql/README.md +0 -142
- package/engines/mysql/backup.ts +0 -270
- package/engines/mysql/binary-detection.ts +0 -408
- package/engines/mysql/binary-manager.ts +0 -42
- package/engines/mysql/binary-urls.ts +0 -104
- package/engines/mysql/index.ts +0 -1361
- package/engines/mysql/restore.ts +0 -500
- package/engines/mysql/version-maps.ts +0 -91
- package/engines/mysql/version-validator.ts +0 -369
- package/engines/postgresql/README.md +0 -158
- package/engines/postgresql/backup.ts +0 -151
- package/engines/postgresql/binary-manager.ts +0 -114
- package/engines/postgresql/binary-urls.ts +0 -99
- package/engines/postgresql/hostdb-releases.ts +0 -26
- package/engines/postgresql/index.ts +0 -1143
- package/engines/postgresql/remote-version.ts +0 -161
- package/engines/postgresql/restore.ts +0 -342
- package/engines/postgresql/version-maps.ts +0 -83
- package/engines/postgresql/version-validator.ts +0 -413
- package/engines/qdrant/README.md +0 -222
- package/engines/qdrant/api-client.ts +0 -61
- package/engines/qdrant/backup.ts +0 -165
- package/engines/qdrant/binary-manager.ts +0 -43
- package/engines/qdrant/binary-urls.ts +0 -115
- package/engines/qdrant/cli-utils.ts +0 -43
- package/engines/qdrant/hostdb-releases.ts +0 -23
- package/engines/qdrant/index.ts +0 -1312
- package/engines/qdrant/restore.ts +0 -203
- package/engines/qdrant/version-maps.ts +0 -78
- package/engines/qdrant/version-validator.ts +0 -128
- package/engines/questdb/README.md +0 -334
- package/engines/questdb/backup.ts +0 -220
- package/engines/questdb/binary-manager.ts +0 -310
- package/engines/questdb/binary-urls.ts +0 -34
- package/engines/questdb/hostdb-releases.ts +0 -23
- package/engines/questdb/index.ts +0 -1023
- package/engines/questdb/restore.ts +0 -260
- package/engines/questdb/version-maps.ts +0 -37
- package/engines/questdb/version-validator.ts +0 -121
- package/engines/redis/README.md +0 -173
- package/engines/redis/backup.ts +0 -389
- package/engines/redis/binary-manager.ts +0 -44
- package/engines/redis/binary-urls.ts +0 -117
- package/engines/redis/cli-utils.ts +0 -42
- package/engines/redis/hostdb-releases.ts +0 -23
- package/engines/redis/index.ts +0 -1583
- package/engines/redis/restore.ts +0 -443
- package/engines/redis/version-maps.ts +0 -81
- package/engines/redis/version-validator.ts +0 -131
- package/engines/sqlite/README.md +0 -162
- package/engines/sqlite/binary-manager.ts +0 -52
- package/engines/sqlite/hostdb-releases.ts +0 -23
- package/engines/sqlite/index.ts +0 -641
- package/engines/sqlite/registry.ts +0 -198
- package/engines/sqlite/scanner.ts +0 -22
- package/engines/sqlite/version-maps.ts +0 -64
- package/engines/surrealdb/README.md +0 -218
- package/engines/surrealdb/backup.ts +0 -131
- package/engines/surrealdb/binary-manager.ts +0 -45
- package/engines/surrealdb/binary-urls.ts +0 -40
- package/engines/surrealdb/cli-utils.ts +0 -173
- package/engines/surrealdb/hostdb-releases.ts +0 -23
- package/engines/surrealdb/index.ts +0 -1246
- package/engines/surrealdb/restore.ts +0 -302
- package/engines/surrealdb/version-maps.ts +0 -41
- package/engines/tigerbeetle/README.md +0 -61
- package/engines/tigerbeetle/backup.ts +0 -49
- package/engines/tigerbeetle/binary-manager.ts +0 -95
- package/engines/tigerbeetle/binary-urls.ts +0 -62
- package/engines/tigerbeetle/hostdb-releases.ts +0 -26
- package/engines/tigerbeetle/index.ts +0 -746
- package/engines/tigerbeetle/restore.ts +0 -130
- package/engines/tigerbeetle/version-validator.ts +0 -126
- package/engines/typedb/backup.ts +0 -167
- package/engines/typedb/binary-manager.ts +0 -200
- package/engines/typedb/binary-urls.ts +0 -40
- package/engines/typedb/cli-utils.ts +0 -210
- package/engines/typedb/hostdb-releases.ts +0 -23
- package/engines/typedb/index.ts +0 -1275
- package/engines/typedb/restore.ts +0 -377
- package/engines/typedb/version-maps.ts +0 -48
- package/engines/typedb/version-validator.ts +0 -127
- package/engines/valkey/README.md +0 -219
- package/engines/valkey/backup.ts +0 -389
- package/engines/valkey/binary-manager.ts +0 -45
- package/engines/valkey/binary-urls.ts +0 -122
- package/engines/valkey/cli-utils.ts +0 -42
- package/engines/valkey/hostdb-releases.ts +0 -23
- package/engines/valkey/index.ts +0 -1585
- package/engines/valkey/restore.ts +0 -446
- package/engines/valkey/version-maps.ts +0 -81
- package/engines/valkey/version-validator.ts +0 -131
- package/engines/weaviate/README.md +0 -302
- package/engines/weaviate/api-client.ts +0 -61
- package/engines/weaviate/backup.ts +0 -145
- package/engines/weaviate/binary-manager.ts +0 -80
- package/engines/weaviate/binary-urls.ts +0 -115
- package/engines/weaviate/cli-utils.ts +0 -43
- package/engines/weaviate/hostdb-releases.ts +0 -23
- package/engines/weaviate/index.ts +0 -1139
- package/engines/weaviate/restore.ts +0 -235
- package/engines/weaviate/version-maps.ts +0 -78
- package/engines/weaviate/version-validator.ts +0 -128
- package/types/index.ts +0 -624
- /package/{config → dist/config}/engines.json +0 -0
package/cli/commands/create.ts
DELETED
|
@@ -1,1201 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander'
|
|
2
|
-
import { existsSync } from 'fs'
|
|
3
|
-
import { rm } from 'fs/promises'
|
|
4
|
-
import chalk from 'chalk'
|
|
5
|
-
import { containerManager } from '../../core/container-manager'
|
|
6
|
-
import { portManager } from '../../core/port-manager'
|
|
7
|
-
import { getEngine } from '../../engines'
|
|
8
|
-
import { getEngineDefaults } from '../../config/defaults'
|
|
9
|
-
import {
|
|
10
|
-
promptCreateOptions,
|
|
11
|
-
promptInstallDependencies,
|
|
12
|
-
promptContainerName,
|
|
13
|
-
promptConfirm,
|
|
14
|
-
} from '../ui/prompts'
|
|
15
|
-
import { createSpinner } from '../ui/spinner'
|
|
16
|
-
import { header, connectionBox } from '../ui/theme'
|
|
17
|
-
import { tmpdir } from 'os'
|
|
18
|
-
import { join } from 'path'
|
|
19
|
-
import { getMissingDependencies } from '../../core/dependency-manager'
|
|
20
|
-
import { platformService } from '../../core/platform-service'
|
|
21
|
-
import { startWithRetry } from '../../core/start-with-retry'
|
|
22
|
-
import { TransactionManager } from '../../core/transaction-manager'
|
|
23
|
-
import { isValidDatabaseName, exitWithError } from '../../core/error-handler'
|
|
24
|
-
import { resolve } from 'path'
|
|
25
|
-
import { Engine, Platform, ALL_ENGINES } from '../../types'
|
|
26
|
-
import {
|
|
27
|
-
FERRETDB_VERSION_MAP,
|
|
28
|
-
isV1 as isFerretDBv1,
|
|
29
|
-
} from '../../engines/ferretdb/version-maps'
|
|
30
|
-
import type { BaseEngine } from '../../engines/base-engine'
|
|
31
|
-
import { getEngineMetadata } from '../helpers'
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Simplified SQLite container creation flow
|
|
35
|
-
* SQLite is file-based, so no port, start/stop, or server management needed
|
|
36
|
-
*/
|
|
37
|
-
async function createSqliteContainer(
|
|
38
|
-
containerName: string,
|
|
39
|
-
dbEngine: BaseEngine,
|
|
40
|
-
version: string,
|
|
41
|
-
options: {
|
|
42
|
-
path?: string
|
|
43
|
-
from?: string | null
|
|
44
|
-
connect?: boolean
|
|
45
|
-
force?: boolean
|
|
46
|
-
json?: boolean
|
|
47
|
-
},
|
|
48
|
-
): Promise<void> {
|
|
49
|
-
const {
|
|
50
|
-
path: filePath,
|
|
51
|
-
from: restoreLocation,
|
|
52
|
-
connect,
|
|
53
|
-
force,
|
|
54
|
-
json,
|
|
55
|
-
} = options
|
|
56
|
-
|
|
57
|
-
// Check dependencies
|
|
58
|
-
const depsSpinner = json ? null : createSpinner('Checking required tools...')
|
|
59
|
-
depsSpinner?.start()
|
|
60
|
-
|
|
61
|
-
const missingDeps = await getMissingDependencies('sqlite')
|
|
62
|
-
if (missingDeps.length > 0) {
|
|
63
|
-
if (json) {
|
|
64
|
-
return exitWithError({
|
|
65
|
-
message: `Missing tools: ${missingDeps.map((d) => d.name).join(', ')}`,
|
|
66
|
-
json: true,
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
depsSpinner?.warn(
|
|
70
|
-
`Missing tools: ${missingDeps.map((d) => d.name).join(', ')}`,
|
|
71
|
-
)
|
|
72
|
-
const installed = await promptInstallDependencies(
|
|
73
|
-
missingDeps[0].binary,
|
|
74
|
-
'sqlite',
|
|
75
|
-
)
|
|
76
|
-
if (!installed) {
|
|
77
|
-
return exitWithError({ message: 'Required tools not installed' })
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
depsSpinner?.succeed('Required tools available')
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Check if container already exists
|
|
84
|
-
if (await containerManager.exists(containerName)) {
|
|
85
|
-
if (force) {
|
|
86
|
-
// Delete existing container with force
|
|
87
|
-
if (!json) {
|
|
88
|
-
console.log(
|
|
89
|
-
chalk.yellow(` Removing existing container "${containerName}"...`),
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
await containerManager.delete(containerName, { force: true })
|
|
93
|
-
} else if (json) {
|
|
94
|
-
return exitWithError({
|
|
95
|
-
message: `Container "${containerName}" already exists. Use --force to overwrite.`,
|
|
96
|
-
json: true,
|
|
97
|
-
})
|
|
98
|
-
} else {
|
|
99
|
-
while (await containerManager.exists(containerName)) {
|
|
100
|
-
console.log(
|
|
101
|
-
chalk.yellow(` Container "${containerName}" already exists.`),
|
|
102
|
-
)
|
|
103
|
-
containerName = await promptContainerName()
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Determine file path
|
|
109
|
-
const defaultPath = `./${containerName}.sqlite`
|
|
110
|
-
const absolutePath = resolve(filePath || defaultPath)
|
|
111
|
-
|
|
112
|
-
// Check if file already exists
|
|
113
|
-
if (existsSync(absolutePath)) {
|
|
114
|
-
return exitWithError({
|
|
115
|
-
message: `File already exists: ${absolutePath}`,
|
|
116
|
-
json,
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const createSpinnerInstance = json
|
|
121
|
-
? null
|
|
122
|
-
: createSpinner('Creating SQLite database...')
|
|
123
|
-
createSpinnerInstance?.start()
|
|
124
|
-
|
|
125
|
-
try {
|
|
126
|
-
// Initialize the SQLite database file and register in registry
|
|
127
|
-
await dbEngine.initDataDir(containerName, version, { path: absolutePath })
|
|
128
|
-
createSpinnerInstance?.succeed('SQLite database created')
|
|
129
|
-
} catch (error) {
|
|
130
|
-
createSpinnerInstance?.fail('Failed to create SQLite database')
|
|
131
|
-
throw error
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Handle --from restore
|
|
135
|
-
if (restoreLocation) {
|
|
136
|
-
const config = await containerManager.getConfig(containerName)
|
|
137
|
-
if (config) {
|
|
138
|
-
const format = await dbEngine.detectBackupFormat(restoreLocation)
|
|
139
|
-
const restoreSpinner = json
|
|
140
|
-
? null
|
|
141
|
-
: createSpinner(`Restoring from ${format.description}...`)
|
|
142
|
-
restoreSpinner?.start()
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
await dbEngine.restore(config, restoreLocation)
|
|
146
|
-
restoreSpinner?.succeed('Backup restored successfully')
|
|
147
|
-
} catch (error) {
|
|
148
|
-
restoreSpinner?.fail('Failed to restore backup')
|
|
149
|
-
// Clean up the created container on restore failure
|
|
150
|
-
try {
|
|
151
|
-
await containerManager.delete(containerName, { force: true })
|
|
152
|
-
} catch {
|
|
153
|
-
// Ignore cleanup errors - still throw the original restore error
|
|
154
|
-
}
|
|
155
|
-
throw error
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const connectionString = `sqlite:///${absolutePath}`
|
|
161
|
-
|
|
162
|
-
// Display success
|
|
163
|
-
if (json) {
|
|
164
|
-
const metadata = await getEngineMetadata('sqlite')
|
|
165
|
-
console.log(
|
|
166
|
-
JSON.stringify({
|
|
167
|
-
success: true,
|
|
168
|
-
name: containerName,
|
|
169
|
-
engine: 'sqlite',
|
|
170
|
-
version,
|
|
171
|
-
path: absolutePath,
|
|
172
|
-
database: containerName,
|
|
173
|
-
connectionString,
|
|
174
|
-
restored: !!restoreLocation,
|
|
175
|
-
...metadata,
|
|
176
|
-
}),
|
|
177
|
-
)
|
|
178
|
-
} else {
|
|
179
|
-
console.log()
|
|
180
|
-
console.log(chalk.green(' ✓ SQLite database ready'))
|
|
181
|
-
console.log()
|
|
182
|
-
console.log(chalk.gray(' File path:'))
|
|
183
|
-
console.log(chalk.cyan(` ${absolutePath}`))
|
|
184
|
-
console.log()
|
|
185
|
-
console.log(chalk.gray(' Connection string:'))
|
|
186
|
-
console.log(chalk.cyan(` ${connectionString}`))
|
|
187
|
-
console.log()
|
|
188
|
-
|
|
189
|
-
if (connect) {
|
|
190
|
-
const config = await containerManager.getConfig(containerName)
|
|
191
|
-
if (config) {
|
|
192
|
-
console.log(chalk.gray(' Opening shell...'))
|
|
193
|
-
console.log()
|
|
194
|
-
await dbEngine.connect(config)
|
|
195
|
-
}
|
|
196
|
-
} else {
|
|
197
|
-
console.log(chalk.gray(' Connect with:'))
|
|
198
|
-
console.log(chalk.cyan(` spindb connect ${containerName}`))
|
|
199
|
-
console.log()
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Simplified DuckDB container creation flow
|
|
206
|
-
* DuckDB is file-based, so no port, start/stop, or server management needed
|
|
207
|
-
*/
|
|
208
|
-
async function createDuckDBContainer(
|
|
209
|
-
containerName: string,
|
|
210
|
-
dbEngine: BaseEngine,
|
|
211
|
-
version: string,
|
|
212
|
-
options: {
|
|
213
|
-
path?: string
|
|
214
|
-
from?: string | null
|
|
215
|
-
connect?: boolean
|
|
216
|
-
force?: boolean
|
|
217
|
-
json?: boolean
|
|
218
|
-
},
|
|
219
|
-
): Promise<void> {
|
|
220
|
-
const {
|
|
221
|
-
path: filePath,
|
|
222
|
-
from: restoreLocation,
|
|
223
|
-
connect,
|
|
224
|
-
force,
|
|
225
|
-
json,
|
|
226
|
-
} = options
|
|
227
|
-
|
|
228
|
-
// Check dependencies
|
|
229
|
-
const depsSpinner = json ? null : createSpinner('Checking required tools...')
|
|
230
|
-
depsSpinner?.start()
|
|
231
|
-
|
|
232
|
-
const missingDeps = await getMissingDependencies('duckdb')
|
|
233
|
-
if (missingDeps.length > 0) {
|
|
234
|
-
if (json) {
|
|
235
|
-
return exitWithError({
|
|
236
|
-
message: `Missing tools: ${missingDeps.map((d) => d.name).join(', ')}`,
|
|
237
|
-
json: true,
|
|
238
|
-
})
|
|
239
|
-
}
|
|
240
|
-
depsSpinner?.warn(
|
|
241
|
-
`Missing tools: ${missingDeps.map((d) => d.name).join(', ')}`,
|
|
242
|
-
)
|
|
243
|
-
const installed = await promptInstallDependencies(
|
|
244
|
-
missingDeps[0].binary,
|
|
245
|
-
'duckdb',
|
|
246
|
-
)
|
|
247
|
-
if (!installed) {
|
|
248
|
-
return exitWithError({ message: 'Required tools not installed' })
|
|
249
|
-
}
|
|
250
|
-
} else {
|
|
251
|
-
depsSpinner?.succeed('Required tools available')
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Check if container already exists
|
|
255
|
-
if (await containerManager.exists(containerName)) {
|
|
256
|
-
if (force) {
|
|
257
|
-
// Delete existing container with force
|
|
258
|
-
if (!json) {
|
|
259
|
-
console.log(
|
|
260
|
-
chalk.yellow(` Removing existing container "${containerName}"...`),
|
|
261
|
-
)
|
|
262
|
-
}
|
|
263
|
-
await containerManager.delete(containerName, { force: true })
|
|
264
|
-
} else if (json) {
|
|
265
|
-
return exitWithError({
|
|
266
|
-
message: `Container "${containerName}" already exists. Use --force to overwrite.`,
|
|
267
|
-
json: true,
|
|
268
|
-
})
|
|
269
|
-
} else {
|
|
270
|
-
while (await containerManager.exists(containerName)) {
|
|
271
|
-
console.log(
|
|
272
|
-
chalk.yellow(` Container "${containerName}" already exists.`),
|
|
273
|
-
)
|
|
274
|
-
containerName = await promptContainerName()
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Determine file path
|
|
280
|
-
const defaultPath = `./${containerName}.duckdb`
|
|
281
|
-
const absolutePath = resolve(filePath || defaultPath)
|
|
282
|
-
|
|
283
|
-
// Check if file already exists
|
|
284
|
-
if (existsSync(absolutePath)) {
|
|
285
|
-
return exitWithError({
|
|
286
|
-
message: `File already exists: ${absolutePath}`,
|
|
287
|
-
json,
|
|
288
|
-
})
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const createSpinnerInstance = json
|
|
292
|
-
? null
|
|
293
|
-
: createSpinner('Creating DuckDB database...')
|
|
294
|
-
createSpinnerInstance?.start()
|
|
295
|
-
|
|
296
|
-
try {
|
|
297
|
-
// Initialize the DuckDB database file and register in registry
|
|
298
|
-
await dbEngine.initDataDir(containerName, version, { path: absolutePath })
|
|
299
|
-
createSpinnerInstance?.succeed('DuckDB database created')
|
|
300
|
-
} catch (error) {
|
|
301
|
-
createSpinnerInstance?.fail('Failed to create DuckDB database')
|
|
302
|
-
throw error
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// Handle --from restore
|
|
306
|
-
if (restoreLocation) {
|
|
307
|
-
const config = await containerManager.getConfig(containerName)
|
|
308
|
-
if (config) {
|
|
309
|
-
const format = await dbEngine.detectBackupFormat(restoreLocation)
|
|
310
|
-
const restoreSpinner = json
|
|
311
|
-
? null
|
|
312
|
-
: createSpinner(`Restoring from ${format.description}...`)
|
|
313
|
-
restoreSpinner?.start()
|
|
314
|
-
|
|
315
|
-
try {
|
|
316
|
-
await dbEngine.restore(config, restoreLocation)
|
|
317
|
-
restoreSpinner?.succeed('Backup restored successfully')
|
|
318
|
-
} catch (error) {
|
|
319
|
-
restoreSpinner?.fail('Failed to restore backup')
|
|
320
|
-
// Clean up the created container on restore failure
|
|
321
|
-
try {
|
|
322
|
-
await containerManager.delete(containerName, { force: true })
|
|
323
|
-
} catch {
|
|
324
|
-
// Ignore cleanup errors - still throw the original restore error
|
|
325
|
-
}
|
|
326
|
-
throw error
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
const connectionString = `duckdb:///${absolutePath}`
|
|
332
|
-
|
|
333
|
-
// Display success
|
|
334
|
-
if (json) {
|
|
335
|
-
const metadata = await getEngineMetadata('duckdb')
|
|
336
|
-
console.log(
|
|
337
|
-
JSON.stringify({
|
|
338
|
-
success: true,
|
|
339
|
-
name: containerName,
|
|
340
|
-
engine: 'duckdb',
|
|
341
|
-
version,
|
|
342
|
-
path: absolutePath,
|
|
343
|
-
database: containerName,
|
|
344
|
-
connectionString,
|
|
345
|
-
restored: !!restoreLocation,
|
|
346
|
-
...metadata,
|
|
347
|
-
}),
|
|
348
|
-
)
|
|
349
|
-
} else {
|
|
350
|
-
console.log()
|
|
351
|
-
console.log(chalk.green(' ✓ DuckDB database ready'))
|
|
352
|
-
console.log()
|
|
353
|
-
console.log(chalk.gray(' File path:'))
|
|
354
|
-
console.log(chalk.cyan(` ${absolutePath}`))
|
|
355
|
-
console.log()
|
|
356
|
-
console.log(chalk.gray(' Connection string:'))
|
|
357
|
-
console.log(chalk.cyan(` ${connectionString}`))
|
|
358
|
-
console.log()
|
|
359
|
-
|
|
360
|
-
if (connect) {
|
|
361
|
-
const config = await containerManager.getConfig(containerName)
|
|
362
|
-
if (config) {
|
|
363
|
-
console.log(chalk.gray(' Opening shell...'))
|
|
364
|
-
console.log()
|
|
365
|
-
await dbEngine.connect(config)
|
|
366
|
-
}
|
|
367
|
-
} else {
|
|
368
|
-
console.log(chalk.gray(' Connect with:'))
|
|
369
|
-
console.log(chalk.cyan(` spindb connect ${containerName}`))
|
|
370
|
-
console.log()
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
export function detectLocationType(location: string): {
|
|
376
|
-
type: 'connection' | 'file' | 'not_found'
|
|
377
|
-
inferredEngine?: Engine
|
|
378
|
-
} {
|
|
379
|
-
if (
|
|
380
|
-
location.startsWith('postgresql://') ||
|
|
381
|
-
location.startsWith('postgres://')
|
|
382
|
-
) {
|
|
383
|
-
return { type: 'connection', inferredEngine: Engine.PostgreSQL }
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
if (location.startsWith('mysql://')) {
|
|
387
|
-
return { type: 'connection', inferredEngine: Engine.MySQL }
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
if (location.startsWith('sqlite://')) {
|
|
391
|
-
return { type: 'connection', inferredEngine: Engine.SQLite }
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (location.startsWith('duckdb://')) {
|
|
395
|
-
return { type: 'connection', inferredEngine: Engine.DuckDB }
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (location.startsWith('redis://') || location.startsWith('rediss://')) {
|
|
399
|
-
return { type: 'connection', inferredEngine: Engine.Redis }
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (location.startsWith('valkey://') || location.startsWith('valkeys://')) {
|
|
403
|
-
return { type: 'connection', inferredEngine: Engine.Valkey }
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
if (location.startsWith('meilisearch://')) {
|
|
407
|
-
return { type: 'connection', inferredEngine: Engine.Meilisearch }
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
if (location.startsWith('influxdb://')) {
|
|
411
|
-
return { type: 'connection', inferredEngine: Engine.InfluxDB }
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
if (existsSync(location)) {
|
|
415
|
-
// Check if it's a SQLite file (case-insensitive)
|
|
416
|
-
const lowerLocation = location.toLowerCase()
|
|
417
|
-
if (
|
|
418
|
-
lowerLocation.endsWith('.sqlite') ||
|
|
419
|
-
lowerLocation.endsWith('.sqlite3')
|
|
420
|
-
) {
|
|
421
|
-
return { type: 'file', inferredEngine: Engine.SQLite }
|
|
422
|
-
}
|
|
423
|
-
// Check if it's a DuckDB file (case-insensitive)
|
|
424
|
-
// Note: We don't infer DuckDB from '.db' extension because it's commonly used by SQLite
|
|
425
|
-
if (lowerLocation.endsWith('.duckdb') || lowerLocation.endsWith('.ddb')) {
|
|
426
|
-
return { type: 'file', inferredEngine: Engine.DuckDB }
|
|
427
|
-
}
|
|
428
|
-
return { type: 'file' }
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return { type: 'not_found' }
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
export const createCommand = new Command('create')
|
|
435
|
-
.description('Create a new database container')
|
|
436
|
-
.argument('[name]', 'Container name')
|
|
437
|
-
.option(
|
|
438
|
-
'-e, --engine <engine>',
|
|
439
|
-
`Database engine (${ALL_ENGINES.join(', ')})`,
|
|
440
|
-
)
|
|
441
|
-
.option('--db-version <version>', 'Database version (e.g., 17, 8.0)')
|
|
442
|
-
.option('-d, --database <database>', 'Database name')
|
|
443
|
-
.option('-p, --port <port>', 'Port number')
|
|
444
|
-
.option(
|
|
445
|
-
'--path <path>',
|
|
446
|
-
'Path for SQLite/DuckDB database file (default: ./<name>.sqlite or ./<name>.duckdb)',
|
|
447
|
-
)
|
|
448
|
-
.option(
|
|
449
|
-
'--max-connections <number>',
|
|
450
|
-
'Maximum number of database connections (default: 200)',
|
|
451
|
-
)
|
|
452
|
-
.option(
|
|
453
|
-
'-f, --force',
|
|
454
|
-
'Overwrite existing container without prompting (deletes existing data)',
|
|
455
|
-
)
|
|
456
|
-
.option('--start', 'Start the container after creation (skip prompt)')
|
|
457
|
-
.option('--no-start', 'Do not start the container after creation')
|
|
458
|
-
.option('--connect', 'Open a shell connection after creation')
|
|
459
|
-
.option(
|
|
460
|
-
'--from <location>',
|
|
461
|
-
'Restore from a dump file or connection string after creation',
|
|
462
|
-
)
|
|
463
|
-
.option('-j, --json', 'Output result as JSON')
|
|
464
|
-
.action(
|
|
465
|
-
async (
|
|
466
|
-
name: string | undefined,
|
|
467
|
-
options: {
|
|
468
|
-
engine?: string
|
|
469
|
-
dbVersion?: string
|
|
470
|
-
database?: string
|
|
471
|
-
port?: string
|
|
472
|
-
path?: string
|
|
473
|
-
maxConnections?: string
|
|
474
|
-
force?: boolean
|
|
475
|
-
start?: boolean
|
|
476
|
-
connect?: boolean
|
|
477
|
-
from?: string
|
|
478
|
-
json?: boolean
|
|
479
|
-
},
|
|
480
|
-
) => {
|
|
481
|
-
let tempDumpPath: string | null = null
|
|
482
|
-
|
|
483
|
-
try {
|
|
484
|
-
let containerName = name
|
|
485
|
-
let engine: Engine = (options.engine as Engine) || Engine.PostgreSQL
|
|
486
|
-
let version = options.dbVersion
|
|
487
|
-
let database = options.database
|
|
488
|
-
|
|
489
|
-
let restoreLocation: string | null = null
|
|
490
|
-
let restoreType: 'connection' | 'file' | null = null
|
|
491
|
-
|
|
492
|
-
if (options.from) {
|
|
493
|
-
const locationInfo = detectLocationType(options.from)
|
|
494
|
-
|
|
495
|
-
if (locationInfo.type === 'not_found') {
|
|
496
|
-
return exitWithError({
|
|
497
|
-
message: `Location not found: ${options.from}. Provide a valid file path or connection string (postgresql://, mysql://, redis://, sqlite://, duckdb://)`,
|
|
498
|
-
json: options.json,
|
|
499
|
-
})
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
restoreLocation = options.from
|
|
503
|
-
restoreType = locationInfo.type
|
|
504
|
-
|
|
505
|
-
if (!options.engine && locationInfo.inferredEngine) {
|
|
506
|
-
engine = locationInfo.inferredEngine
|
|
507
|
-
if (!options.json) {
|
|
508
|
-
console.log(
|
|
509
|
-
chalk.gray(
|
|
510
|
-
` Inferred engine "${engine}" from connection string`,
|
|
511
|
-
),
|
|
512
|
-
)
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
if (options.start === false) {
|
|
517
|
-
return exitWithError({
|
|
518
|
-
message:
|
|
519
|
-
'Cannot use --no-start with --from (restore requires running container)',
|
|
520
|
-
json: options.json,
|
|
521
|
-
})
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
const engineDefaults = getEngineDefaults(engine)
|
|
526
|
-
|
|
527
|
-
if (!version) {
|
|
528
|
-
version = engineDefaults.defaultVersion
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
if (!containerName) {
|
|
532
|
-
// JSON mode requires container name argument
|
|
533
|
-
if (options.json) {
|
|
534
|
-
return exitWithError({
|
|
535
|
-
message: 'Container name is required',
|
|
536
|
-
json: true,
|
|
537
|
-
})
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
const answers = await promptCreateOptions()
|
|
541
|
-
containerName = answers.name
|
|
542
|
-
engine = answers.engine as Engine
|
|
543
|
-
version = answers.version
|
|
544
|
-
database = answers.database
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// FerretDB: force v1 on Windows (v2 requires postgresql-documentdb, not available on Windows)
|
|
548
|
-
// Runs after both CLI and interactive paths have resolved engine + version
|
|
549
|
-
if (
|
|
550
|
-
engine === Engine.FerretDB &&
|
|
551
|
-
!isFerretDBv1(version) &&
|
|
552
|
-
platformService.getPlatformInfo().platform === Platform.Win32
|
|
553
|
-
) {
|
|
554
|
-
version = FERRETDB_VERSION_MAP['1']
|
|
555
|
-
if (!options.json) {
|
|
556
|
-
console.log(
|
|
557
|
-
chalk.yellow(
|
|
558
|
-
` FerretDB v2 is not supported on Windows — using v1 (${version})`,
|
|
559
|
-
),
|
|
560
|
-
)
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
// Redis/Valkey use numbered databases (0-15), default to "0"
|
|
565
|
-
// Other engines default to container name (with hyphens replaced by underscores for SQL compatibility)
|
|
566
|
-
if (engine === Engine.Redis || engine === Engine.Valkey) {
|
|
567
|
-
database = database ?? '0'
|
|
568
|
-
// Validate Redis/Valkey database is a pure integer string 0-15
|
|
569
|
-
// Reject decimals ("1.5"), scientific notation ("1e2"), and trailing garbage ("5abc")
|
|
570
|
-
if (!/^[0-9]+$/.test(database)) {
|
|
571
|
-
return exitWithError({
|
|
572
|
-
message:
|
|
573
|
-
'Redis/Valkey database must be an integer between 0 and 15',
|
|
574
|
-
json: options.json,
|
|
575
|
-
})
|
|
576
|
-
}
|
|
577
|
-
const dbIndex = parseInt(database, 10)
|
|
578
|
-
if (dbIndex < 0 || dbIndex > 15) {
|
|
579
|
-
return exitWithError({
|
|
580
|
-
message:
|
|
581
|
-
'Redis/Valkey database must be an integer between 0 and 15',
|
|
582
|
-
json: options.json,
|
|
583
|
-
})
|
|
584
|
-
}
|
|
585
|
-
} else {
|
|
586
|
-
database = database ?? containerName.replace(/-/g, '_')
|
|
587
|
-
// Validate database name to prevent SQL injection
|
|
588
|
-
if (!isValidDatabaseName(database)) {
|
|
589
|
-
return exitWithError({
|
|
590
|
-
message:
|
|
591
|
-
'Database name must start with a letter and contain only letters, numbers, and underscores',
|
|
592
|
-
json: options.json,
|
|
593
|
-
})
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
if (!options.json) {
|
|
598
|
-
console.log(header('Creating Database Container'))
|
|
599
|
-
console.log()
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
const dbEngine = getEngine(engine)
|
|
603
|
-
const isPostgreSQL = engine === Engine.PostgreSQL
|
|
604
|
-
|
|
605
|
-
// SQLite has a simplified flow (no port, no start/stop)
|
|
606
|
-
if (engine === Engine.SQLite) {
|
|
607
|
-
await createSqliteContainer(containerName, dbEngine, version, {
|
|
608
|
-
path: options.path,
|
|
609
|
-
from: restoreLocation,
|
|
610
|
-
connect: options.connect,
|
|
611
|
-
force: options.force,
|
|
612
|
-
json: options.json,
|
|
613
|
-
})
|
|
614
|
-
return
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
// DuckDB has a simplified flow (no port, no start/stop)
|
|
618
|
-
if (engine === Engine.DuckDB) {
|
|
619
|
-
await createDuckDBContainer(containerName, dbEngine, version, {
|
|
620
|
-
path: options.path,
|
|
621
|
-
from: restoreLocation,
|
|
622
|
-
connect: options.connect,
|
|
623
|
-
force: options.force,
|
|
624
|
-
json: options.json,
|
|
625
|
-
})
|
|
626
|
-
return
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
// For server databases, validate --connect with --no-start
|
|
630
|
-
if (options.connect && options.start === false) {
|
|
631
|
-
return exitWithError({
|
|
632
|
-
message:
|
|
633
|
-
'Cannot use --no-start with --connect (connection requires running container)',
|
|
634
|
-
json: options.json,
|
|
635
|
-
})
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
// In JSON mode, require explicit --start or --no-start flag to avoid interactive prompts
|
|
639
|
-
if (
|
|
640
|
-
options.json &&
|
|
641
|
-
options.start === undefined &&
|
|
642
|
-
!restoreLocation &&
|
|
643
|
-
!options.connect
|
|
644
|
-
) {
|
|
645
|
-
return exitWithError({
|
|
646
|
-
message:
|
|
647
|
-
'In JSON mode, you must specify --start or --no-start for server databases',
|
|
648
|
-
json: true,
|
|
649
|
-
})
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// Validate --max-connections if provided
|
|
653
|
-
if (options.maxConnections) {
|
|
654
|
-
const parsed = parseInt(options.maxConnections, 10)
|
|
655
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
656
|
-
return exitWithError({
|
|
657
|
-
message:
|
|
658
|
-
'Invalid --max-connections value: must be a positive integer',
|
|
659
|
-
json: options.json,
|
|
660
|
-
})
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
const portSpinner = options.json
|
|
665
|
-
? null
|
|
666
|
-
: createSpinner('Finding available port...')
|
|
667
|
-
portSpinner?.start()
|
|
668
|
-
|
|
669
|
-
let port: number
|
|
670
|
-
if (options.port) {
|
|
671
|
-
port = parseInt(options.port, 10)
|
|
672
|
-
const available = await portManager.isPortAvailable(port)
|
|
673
|
-
if (!available) {
|
|
674
|
-
portSpinner?.fail(`Port ${port} is already in use`)
|
|
675
|
-
return exitWithError({
|
|
676
|
-
message: `Port ${port} is already in use`,
|
|
677
|
-
json: options.json,
|
|
678
|
-
})
|
|
679
|
-
}
|
|
680
|
-
portSpinner?.succeed(`Using port ${port}`)
|
|
681
|
-
} else {
|
|
682
|
-
const { port: foundPort, isDefault } =
|
|
683
|
-
await portManager.findAvailablePort({
|
|
684
|
-
preferredPort: engineDefaults.defaultPort,
|
|
685
|
-
portRange: engineDefaults.portRange,
|
|
686
|
-
})
|
|
687
|
-
port = foundPort
|
|
688
|
-
if (isDefault) {
|
|
689
|
-
portSpinner?.succeed(`Using default port ${port}`)
|
|
690
|
-
} else {
|
|
691
|
-
portSpinner?.warn(
|
|
692
|
-
`Default port ${engineDefaults.defaultPort} is in use, using port ${port}`,
|
|
693
|
-
)
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
// For PostgreSQL, ensure binaries FIRST - they include client tools (psql, pg_dump, etc.)
|
|
698
|
-
// ensureBinaries also registers tool paths in config cache so getMissingDependencies can find them
|
|
699
|
-
if (isPostgreSQL) {
|
|
700
|
-
const binarySpinner = options.json
|
|
701
|
-
? null
|
|
702
|
-
: createSpinner(
|
|
703
|
-
`Checking ${dbEngine.displayName} ${version} binaries...`,
|
|
704
|
-
)
|
|
705
|
-
binarySpinner?.start()
|
|
706
|
-
|
|
707
|
-
// Always call ensureBinaries - it handles cached binaries gracefully
|
|
708
|
-
// and registers client tool paths in config (needed for dependency checks)
|
|
709
|
-
await dbEngine.ensureBinaries(version, ({ stage, message }) => {
|
|
710
|
-
if (binarySpinner) {
|
|
711
|
-
if (stage === 'cached') {
|
|
712
|
-
binarySpinner.text = `${dbEngine.displayName} ${version} binaries ready (cached)`
|
|
713
|
-
} else {
|
|
714
|
-
binarySpinner.text = message
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
})
|
|
718
|
-
binarySpinner?.succeed(
|
|
719
|
-
`${dbEngine.displayName} ${version} binaries ready`,
|
|
720
|
-
)
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
// Check dependencies (all engines need this)
|
|
724
|
-
// For PostgreSQL, this runs AFTER binary download so client tools are available
|
|
725
|
-
const depsSpinner = options.json
|
|
726
|
-
? null
|
|
727
|
-
: createSpinner('Checking required tools...')
|
|
728
|
-
depsSpinner?.start()
|
|
729
|
-
|
|
730
|
-
let missingDeps = await getMissingDependencies(engine)
|
|
731
|
-
if (missingDeps.length > 0) {
|
|
732
|
-
// In JSON mode, error out instead of prompting
|
|
733
|
-
if (options.json) {
|
|
734
|
-
return exitWithError({
|
|
735
|
-
message: `Missing tools: ${missingDeps.map((d) => d.name).join(', ')}`,
|
|
736
|
-
json: true,
|
|
737
|
-
})
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
depsSpinner?.warn(
|
|
741
|
-
`Missing tools: ${missingDeps.map((d) => d.name).join(', ')}`,
|
|
742
|
-
)
|
|
743
|
-
|
|
744
|
-
const installed = await promptInstallDependencies(
|
|
745
|
-
missingDeps[0].binary,
|
|
746
|
-
engine,
|
|
747
|
-
)
|
|
748
|
-
|
|
749
|
-
if (!installed) {
|
|
750
|
-
return exitWithError({ message: 'Required tools not installed' })
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
missingDeps = await getMissingDependencies(engine)
|
|
754
|
-
if (missingDeps.length > 0) {
|
|
755
|
-
return exitWithError({
|
|
756
|
-
message: `Still missing tools: ${missingDeps.map((d) => d.name).join(', ')}`,
|
|
757
|
-
})
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
console.log(chalk.green(' ✓ All required tools are now available'))
|
|
761
|
-
console.log()
|
|
762
|
-
} else {
|
|
763
|
-
depsSpinner?.succeed('Required tools available')
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
// For non-PostgreSQL engines, validate version and get binary path
|
|
767
|
-
// Store the binary path for version consistency
|
|
768
|
-
let binaryPath: string | undefined
|
|
769
|
-
if (!isPostgreSQL) {
|
|
770
|
-
const binarySpinner = options.json
|
|
771
|
-
? null
|
|
772
|
-
: createSpinner(
|
|
773
|
-
`Checking ${dbEngine.displayName} ${version} binaries...`,
|
|
774
|
-
)
|
|
775
|
-
binarySpinner?.start()
|
|
776
|
-
|
|
777
|
-
try {
|
|
778
|
-
// ensureBinaries validates the version and returns the binary path
|
|
779
|
-
binaryPath = await dbEngine.ensureBinaries(
|
|
780
|
-
version,
|
|
781
|
-
({ message }) => {
|
|
782
|
-
if (binarySpinner) {
|
|
783
|
-
binarySpinner.text = message
|
|
784
|
-
}
|
|
785
|
-
},
|
|
786
|
-
)
|
|
787
|
-
binarySpinner?.succeed(
|
|
788
|
-
`${dbEngine.displayName} ${version} binaries ready`,
|
|
789
|
-
)
|
|
790
|
-
} catch (error) {
|
|
791
|
-
binarySpinner?.fail(
|
|
792
|
-
`${dbEngine.displayName} ${version} not available`,
|
|
793
|
-
)
|
|
794
|
-
if (options.json) {
|
|
795
|
-
return exitWithError({
|
|
796
|
-
message: `${dbEngine.displayName} ${version} not available`,
|
|
797
|
-
json: true,
|
|
798
|
-
})
|
|
799
|
-
}
|
|
800
|
-
throw error
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
if (await containerManager.exists(containerName)) {
|
|
805
|
-
if (options.force) {
|
|
806
|
-
// Stop the container if it's running, then delete it
|
|
807
|
-
const existingConfig =
|
|
808
|
-
await containerManager.getConfig(containerName)
|
|
809
|
-
if (existingConfig?.status === 'running') {
|
|
810
|
-
if (!options.json) {
|
|
811
|
-
console.log(
|
|
812
|
-
chalk.yellow(
|
|
813
|
-
` Stopping existing container "${containerName}"...`,
|
|
814
|
-
),
|
|
815
|
-
)
|
|
816
|
-
}
|
|
817
|
-
try {
|
|
818
|
-
await dbEngine.stop(existingConfig)
|
|
819
|
-
} catch {
|
|
820
|
-
// Ignore stop errors - container may already be stopped
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
if (!options.json) {
|
|
824
|
-
console.log(
|
|
825
|
-
chalk.yellow(
|
|
826
|
-
` Removing existing container "${containerName}"...`,
|
|
827
|
-
),
|
|
828
|
-
)
|
|
829
|
-
}
|
|
830
|
-
await containerManager.delete(containerName, { force: true })
|
|
831
|
-
} else if (options.json) {
|
|
832
|
-
return exitWithError({
|
|
833
|
-
message: `Container "${containerName}" already exists. Use --force to overwrite.`,
|
|
834
|
-
json: true,
|
|
835
|
-
})
|
|
836
|
-
} else {
|
|
837
|
-
while (await containerManager.exists(containerName)) {
|
|
838
|
-
console.log(
|
|
839
|
-
chalk.yellow(` Container "${containerName}" already exists.`),
|
|
840
|
-
)
|
|
841
|
-
containerName = await promptContainerName()
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
const tx = new TransactionManager()
|
|
847
|
-
|
|
848
|
-
const createSpinnerInstance = createSpinner('Creating container...')
|
|
849
|
-
createSpinnerInstance.start()
|
|
850
|
-
|
|
851
|
-
try {
|
|
852
|
-
await containerManager.create(containerName, {
|
|
853
|
-
engine: dbEngine.name as Engine,
|
|
854
|
-
version,
|
|
855
|
-
port,
|
|
856
|
-
database,
|
|
857
|
-
binaryPath,
|
|
858
|
-
})
|
|
859
|
-
|
|
860
|
-
tx.addRollback({
|
|
861
|
-
description: `Delete container "${containerName}"`,
|
|
862
|
-
execute: async () => {
|
|
863
|
-
await containerManager.delete(containerName, { force: true })
|
|
864
|
-
},
|
|
865
|
-
})
|
|
866
|
-
|
|
867
|
-
createSpinnerInstance.succeed('Container created')
|
|
868
|
-
} catch (error) {
|
|
869
|
-
createSpinnerInstance.fail('Failed to create container')
|
|
870
|
-
throw error
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
const initSpinner = createSpinner('Initializing database cluster...')
|
|
874
|
-
initSpinner.start()
|
|
875
|
-
|
|
876
|
-
try {
|
|
877
|
-
await dbEngine.initDataDir(containerName, version, {
|
|
878
|
-
port,
|
|
879
|
-
superuser: engineDefaults.superuser,
|
|
880
|
-
maxConnections: options.maxConnections
|
|
881
|
-
? parseInt(options.maxConnections, 10)
|
|
882
|
-
: undefined,
|
|
883
|
-
})
|
|
884
|
-
initSpinner.succeed('Database cluster initialized')
|
|
885
|
-
} catch (error) {
|
|
886
|
-
initSpinner.fail('Failed to initialize database cluster')
|
|
887
|
-
await tx.rollback()
|
|
888
|
-
throw error
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
// --from requires start, --start forces start, --no-start skips, otherwise ask user
|
|
892
|
-
// --connect implies --start for server databases
|
|
893
|
-
let shouldStart = false
|
|
894
|
-
if (restoreLocation || options.connect) {
|
|
895
|
-
shouldStart = true
|
|
896
|
-
} else if (options.start === true) {
|
|
897
|
-
shouldStart = true
|
|
898
|
-
} else if (options.start === false) {
|
|
899
|
-
shouldStart = false
|
|
900
|
-
} else {
|
|
901
|
-
// In non-interactive mode (no TTY), default to not starting
|
|
902
|
-
// This allows scripts/CI to run without --no-start flag
|
|
903
|
-
if (!process.stdin.isTTY) {
|
|
904
|
-
shouldStart = false
|
|
905
|
-
} else {
|
|
906
|
-
console.log()
|
|
907
|
-
shouldStart = await promptConfirm(
|
|
908
|
-
`Start ${containerName} now?`,
|
|
909
|
-
true,
|
|
910
|
-
)
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
const config = await containerManager.getConfig(containerName)
|
|
915
|
-
|
|
916
|
-
if (shouldStart && config) {
|
|
917
|
-
const startSpinner = createSpinner(
|
|
918
|
-
`Starting ${dbEngine.displayName}...`,
|
|
919
|
-
)
|
|
920
|
-
startSpinner.start()
|
|
921
|
-
|
|
922
|
-
try {
|
|
923
|
-
const result = await startWithRetry({
|
|
924
|
-
engine: dbEngine,
|
|
925
|
-
config,
|
|
926
|
-
onPortChange: (oldPort, newPort) => {
|
|
927
|
-
startSpinner.text = `Port ${oldPort} was in use, retrying with port ${newPort}...`
|
|
928
|
-
port = newPort
|
|
929
|
-
},
|
|
930
|
-
})
|
|
931
|
-
|
|
932
|
-
if (!result.success) {
|
|
933
|
-
startSpinner.fail(`Failed to start ${dbEngine.displayName}`)
|
|
934
|
-
await tx.rollback()
|
|
935
|
-
if (result.error) {
|
|
936
|
-
throw result.error
|
|
937
|
-
}
|
|
938
|
-
throw new Error('Failed to start container')
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
tx.addRollback({
|
|
942
|
-
description: `Stop container "${containerName}"`,
|
|
943
|
-
execute: async () => {
|
|
944
|
-
try {
|
|
945
|
-
await dbEngine.stop(config)
|
|
946
|
-
} catch {
|
|
947
|
-
// Ignore stop errors during rollback
|
|
948
|
-
}
|
|
949
|
-
},
|
|
950
|
-
})
|
|
951
|
-
|
|
952
|
-
await containerManager.updateConfig(containerName, {
|
|
953
|
-
status: 'running',
|
|
954
|
-
})
|
|
955
|
-
|
|
956
|
-
if (result.retriesUsed > 0) {
|
|
957
|
-
startSpinner.warn(
|
|
958
|
-
`${dbEngine.displayName} started on port ${result.finalPort} (original port was in use)`,
|
|
959
|
-
)
|
|
960
|
-
} else {
|
|
961
|
-
startSpinner.succeed(`${dbEngine.displayName} started`)
|
|
962
|
-
}
|
|
963
|
-
} catch (error) {
|
|
964
|
-
if (!startSpinner.isSpinning) {
|
|
965
|
-
// Error was already handled above
|
|
966
|
-
} else {
|
|
967
|
-
startSpinner.fail(`Failed to start ${dbEngine.displayName}`)
|
|
968
|
-
}
|
|
969
|
-
await tx.rollback()
|
|
970
|
-
throw error
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
const defaultDb = engineDefaults.superuser
|
|
974
|
-
if (database !== defaultDb) {
|
|
975
|
-
const dbSpinner = createSpinner(
|
|
976
|
-
`Creating database "${database}"...`,
|
|
977
|
-
)
|
|
978
|
-
dbSpinner.start()
|
|
979
|
-
|
|
980
|
-
try {
|
|
981
|
-
await dbEngine.createDatabase(config, database)
|
|
982
|
-
dbSpinner.succeed(`Database "${database}" created`)
|
|
983
|
-
} catch (error) {
|
|
984
|
-
dbSpinner.fail(`Failed to create database "${database}"`)
|
|
985
|
-
await tx.rollback()
|
|
986
|
-
throw error
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
if (restoreLocation && restoreType && config && shouldStart) {
|
|
992
|
-
let backupPath = ''
|
|
993
|
-
|
|
994
|
-
if (restoreType === 'connection') {
|
|
995
|
-
const timestamp = Date.now()
|
|
996
|
-
tempDumpPath = join(tmpdir(), `spindb-dump-${timestamp}.dump`)
|
|
997
|
-
|
|
998
|
-
let dumpSuccess = false
|
|
999
|
-
let attempts = 0
|
|
1000
|
-
const maxAttempts = 2
|
|
1001
|
-
|
|
1002
|
-
while (!dumpSuccess && attempts < maxAttempts) {
|
|
1003
|
-
attempts++
|
|
1004
|
-
const dumpSpinner = createSpinner(
|
|
1005
|
-
'Creating dump from remote database...',
|
|
1006
|
-
)
|
|
1007
|
-
dumpSpinner.start()
|
|
1008
|
-
|
|
1009
|
-
try {
|
|
1010
|
-
const dumpResult = await dbEngine.dumpFromConnectionString(
|
|
1011
|
-
restoreLocation,
|
|
1012
|
-
tempDumpPath,
|
|
1013
|
-
)
|
|
1014
|
-
dumpSpinner.succeed('Dump created from remote database')
|
|
1015
|
-
if (dumpResult.warnings?.length) {
|
|
1016
|
-
for (const warning of dumpResult.warnings) {
|
|
1017
|
-
console.log(chalk.yellow(` ${warning}`))
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
backupPath = tempDumpPath
|
|
1021
|
-
dumpSuccess = true
|
|
1022
|
-
} catch (error) {
|
|
1023
|
-
const e = error as Error
|
|
1024
|
-
dumpSpinner.fail('Failed to create dump')
|
|
1025
|
-
|
|
1026
|
-
if (
|
|
1027
|
-
e.message.includes('pg_dump not found') ||
|
|
1028
|
-
e.message.includes('ENOENT')
|
|
1029
|
-
) {
|
|
1030
|
-
// In JSON mode, don't prompt - just exit with error
|
|
1031
|
-
if (options.json) {
|
|
1032
|
-
return exitWithError({
|
|
1033
|
-
message: 'pg_dump not installed',
|
|
1034
|
-
json: true,
|
|
1035
|
-
})
|
|
1036
|
-
}
|
|
1037
|
-
const installed = await promptInstallDependencies('pg_dump')
|
|
1038
|
-
if (!installed) {
|
|
1039
|
-
return exitWithError({
|
|
1040
|
-
message: 'pg_dump not installed',
|
|
1041
|
-
json: options.json,
|
|
1042
|
-
})
|
|
1043
|
-
}
|
|
1044
|
-
continue
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
return exitWithError({
|
|
1048
|
-
message: `pg_dump error: ${e.message}`,
|
|
1049
|
-
json: options.json,
|
|
1050
|
-
})
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
if (!dumpSuccess) {
|
|
1055
|
-
return exitWithError({
|
|
1056
|
-
message: 'Failed to create dump after retries',
|
|
1057
|
-
json: options.json,
|
|
1058
|
-
})
|
|
1059
|
-
}
|
|
1060
|
-
} else {
|
|
1061
|
-
backupPath = restoreLocation
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
const detectSpinner = createSpinner('Detecting backup format...')
|
|
1065
|
-
detectSpinner.start()
|
|
1066
|
-
|
|
1067
|
-
const format = await dbEngine.detectBackupFormat(backupPath)
|
|
1068
|
-
detectSpinner.succeed(`Detected: ${format.description}`)
|
|
1069
|
-
|
|
1070
|
-
const restoreSpinner = createSpinner('Restoring backup...')
|
|
1071
|
-
restoreSpinner.start()
|
|
1072
|
-
|
|
1073
|
-
const result = await dbEngine.restore(config, backupPath, {
|
|
1074
|
-
database,
|
|
1075
|
-
createDatabase: false,
|
|
1076
|
-
})
|
|
1077
|
-
|
|
1078
|
-
if (result.code === 0) {
|
|
1079
|
-
restoreSpinner.succeed('Backup restored successfully')
|
|
1080
|
-
} else {
|
|
1081
|
-
restoreSpinner.warn('Restore completed with warnings')
|
|
1082
|
-
if (result.stderr) {
|
|
1083
|
-
console.log(chalk.yellow('\n Warnings:'))
|
|
1084
|
-
const lines = result.stderr.split('\n').slice(0, 5)
|
|
1085
|
-
lines.forEach((line) => {
|
|
1086
|
-
if (line.trim()) {
|
|
1087
|
-
console.log(chalk.gray(` ${line}`))
|
|
1088
|
-
}
|
|
1089
|
-
})
|
|
1090
|
-
if (result.stderr.split('\n').length > 5) {
|
|
1091
|
-
console.log(chalk.gray(' ...'))
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
tx.commit()
|
|
1098
|
-
|
|
1099
|
-
const finalConfig = await containerManager.getConfig(containerName)
|
|
1100
|
-
if (finalConfig) {
|
|
1101
|
-
const connectionString = dbEngine.getConnectionString(finalConfig)
|
|
1102
|
-
|
|
1103
|
-
if (options.json) {
|
|
1104
|
-
const metadata = await getEngineMetadata(finalConfig.engine)
|
|
1105
|
-
console.log(
|
|
1106
|
-
JSON.stringify({
|
|
1107
|
-
success: true,
|
|
1108
|
-
name: containerName,
|
|
1109
|
-
engine: finalConfig.engine,
|
|
1110
|
-
version: finalConfig.version,
|
|
1111
|
-
port: finalConfig.port,
|
|
1112
|
-
database,
|
|
1113
|
-
connectionString,
|
|
1114
|
-
status: finalConfig.status,
|
|
1115
|
-
restored: !!restoreLocation,
|
|
1116
|
-
...metadata,
|
|
1117
|
-
}),
|
|
1118
|
-
)
|
|
1119
|
-
} else {
|
|
1120
|
-
console.log()
|
|
1121
|
-
console.log(
|
|
1122
|
-
connectionBox(containerName, connectionString, finalConfig.port),
|
|
1123
|
-
)
|
|
1124
|
-
console.log()
|
|
1125
|
-
|
|
1126
|
-
if (options.connect && shouldStart) {
|
|
1127
|
-
// --connect flag: open shell directly
|
|
1128
|
-
const copied =
|
|
1129
|
-
await platformService.copyToClipboard(connectionString)
|
|
1130
|
-
if (copied) {
|
|
1131
|
-
console.log(
|
|
1132
|
-
chalk.gray(' Connection string copied to clipboard'),
|
|
1133
|
-
)
|
|
1134
|
-
}
|
|
1135
|
-
console.log(chalk.gray(' Opening shell...'))
|
|
1136
|
-
console.log()
|
|
1137
|
-
await dbEngine.connect(finalConfig, database)
|
|
1138
|
-
} else if (shouldStart) {
|
|
1139
|
-
console.log(chalk.gray(' Connect with:'))
|
|
1140
|
-
console.log(chalk.cyan(` spindb connect ${containerName}`))
|
|
1141
|
-
|
|
1142
|
-
const copied =
|
|
1143
|
-
await platformService.copyToClipboard(connectionString)
|
|
1144
|
-
if (copied) {
|
|
1145
|
-
console.log(
|
|
1146
|
-
chalk.gray(' Connection string copied to clipboard'),
|
|
1147
|
-
)
|
|
1148
|
-
}
|
|
1149
|
-
console.log()
|
|
1150
|
-
} else {
|
|
1151
|
-
console.log(chalk.gray(' Start the container:'))
|
|
1152
|
-
console.log(chalk.cyan(` spindb start ${containerName}`))
|
|
1153
|
-
console.log()
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
} catch (error) {
|
|
1158
|
-
const e = error as Error
|
|
1159
|
-
|
|
1160
|
-
const missingToolPatterns = [
|
|
1161
|
-
'pg_restore not found',
|
|
1162
|
-
'psql not found',
|
|
1163
|
-
'pg_dump not found',
|
|
1164
|
-
'mysql not found',
|
|
1165
|
-
'mysqldump not found',
|
|
1166
|
-
'mysqld not found',
|
|
1167
|
-
]
|
|
1168
|
-
|
|
1169
|
-
const matchingPattern = missingToolPatterns.find((p) =>
|
|
1170
|
-
e.message.includes(p),
|
|
1171
|
-
)
|
|
1172
|
-
|
|
1173
|
-
if (matchingPattern) {
|
|
1174
|
-
if (options.json) {
|
|
1175
|
-
return exitWithError({ message: e.message, json: true })
|
|
1176
|
-
}
|
|
1177
|
-
const missingTool = matchingPattern.replace(' not found', '')
|
|
1178
|
-
const installed = await promptInstallDependencies(missingTool)
|
|
1179
|
-
if (installed) {
|
|
1180
|
-
console.log(
|
|
1181
|
-
chalk.yellow(' Please re-run your command to continue.'),
|
|
1182
|
-
)
|
|
1183
|
-
}
|
|
1184
|
-
return exitWithError({
|
|
1185
|
-
message: 'Missing required tools',
|
|
1186
|
-
json: options.json,
|
|
1187
|
-
})
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
return exitWithError({ message: e.message, json: options.json })
|
|
1191
|
-
} finally {
|
|
1192
|
-
if (tempDumpPath) {
|
|
1193
|
-
try {
|
|
1194
|
-
await rm(tempDumpPath, { force: true })
|
|
1195
|
-
} catch {
|
|
1196
|
-
// Ignore cleanup errors
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
},
|
|
1201
|
-
)
|