@contember/cli 2.0.0-alpha.9 → 2.0.0-beta.2
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/contember-docker.sh +0 -0
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/deploy/DeployCommand.cjs +5 -5
- package/dist/development/src/commands/deploy/DeployCommand.cjs.map +1 -1
- package/dist/development/src/commands/deploy/DeployCommand.js +5 -5
- package/dist/development/src/commands/deploy/DeployCommand.js.map +1 -1
- package/dist/development/src/commands/migrations/MigrationAmendCommand.cjs +15 -3
- package/dist/development/src/commands/migrations/MigrationAmendCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationAmendCommand.js +15 -3
- package/dist/development/src/commands/migrations/MigrationAmendCommand.js.map +1 -1
- package/dist/development/src/commands/migrations/MigrationBlankCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationBlankCommand.js.map +1 -1
- package/dist/development/src/commands/migrations/MigrationDescribeCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationDescribeCommand.js.map +1 -1
- package/dist/development/src/commands/migrations/MigrationDiffCommand.cjs +1 -1
- package/dist/development/src/commands/migrations/MigrationDiffCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationDiffCommand.js +1 -1
- package/dist/development/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
- package/dist/development/src/commands/migrations/MigrationExecuteCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationExecuteCommand.js.map +1 -1
- package/dist/development/src/commands/migrations/MigrationRebaseCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationRebaseCommand.js.map +1 -1
- package/dist/development/src/commands/migrations/MigrationStatusCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
- package/dist/development/src/commands/misc/VersionCommand.cjs.map +1 -1
- package/dist/development/src/commands/misc/VersionCommand.js.map +1 -1
- package/dist/development/src/commands/project/ProjectGenerateDocumentationCommand.cjs.map +1 -1
- package/dist/development/src/commands/project/ProjectGenerateDocumentationCommand.js.map +1 -1
- package/dist/development/src/commands/project/ProjectPrintSchemaCommand.cjs +13 -2
- package/dist/development/src/commands/project/ProjectPrintSchemaCommand.cjs.map +1 -1
- package/dist/development/src/commands/project/ProjectPrintSchemaCommand.js +14 -3
- package/dist/development/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
- package/dist/development/src/commands/project/ProjectValidateCommand.cjs.map +1 -1
- package/dist/development/src/commands/project/ProjectValidateCommand.js.map +1 -1
- package/dist/development/src/commands/transfer/ExportCommand.cjs +2 -0
- package/dist/development/src/commands/transfer/ExportCommand.cjs.map +1 -1
- package/dist/development/src/commands/transfer/ExportCommand.js +2 -0
- package/dist/development/src/commands/transfer/ExportCommand.js.map +1 -1
- package/dist/development/src/commands/transfer/ImportCommand.cjs.map +1 -1
- package/dist/development/src/commands/transfer/ImportCommand.js.map +1 -1
- package/dist/development/src/commands/transfer/TransferCommand.cjs +2 -0
- package/dist/development/src/commands/transfer/TransferCommand.cjs.map +1 -1
- package/dist/development/src/commands/transfer/TransferCommand.js +2 -0
- package/dist/development/src/commands/transfer/TransferCommand.js.map +1 -1
- package/dist/development/src/commands/transfer/utils.cjs.map +1 -1
- package/dist/development/src/commands/transfer/utils.js.map +1 -1
- package/dist/development/src/commands/workspace/WorkspaceUpdateApiCommand.cjs.map +1 -1
- package/dist/development/src/commands/workspace/WorkspaceUpdateApiCommand.js.map +1 -1
- package/dist/development/src/consts.cjs +3 -1
- package/dist/development/src/consts.cjs.map +1 -1
- package/dist/development/src/consts.js +4 -2
- package/dist/development/src/consts.js.map +1 -1
- package/dist/development/src/dic.cjs +3 -1
- package/dist/development/src/dic.cjs.map +1 -1
- package/dist/development/src/dic.js +3 -1
- package/dist/development/src/dic.js.map +1 -1
- package/dist/development/src/lib/SystemClientProvider.cjs.map +1 -1
- package/dist/development/src/lib/SystemClientProvider.js.map +1 -1
- package/dist/development/src/lib/TenantClientProvider.cjs.map +1 -1
- package/dist/development/src/lib/TenantClientProvider.js.map +1 -1
- package/dist/development/src/lib/VersionChecker.cjs.map +1 -1
- package/dist/development/src/lib/VersionChecker.js.map +1 -1
- package/dist/development/src/lib/admin/AdminClient.cjs +1 -1
- package/dist/development/src/lib/admin/AdminClient.cjs.map +1 -1
- package/dist/development/src/lib/admin/AdminClient.js +1 -1
- package/dist/development/src/lib/admin/AdminClient.js.map +1 -1
- package/dist/development/src/lib/admin/AdminDeployer.cjs.map +1 -1
- package/dist/development/src/lib/admin/AdminDeployer.js.map +1 -1
- package/dist/development/src/lib/dsn.cjs.map +1 -1
- package/dist/development/src/lib/dsn.js.map +1 -1
- package/dist/development/src/lib/env.cjs +4 -1
- package/dist/development/src/lib/env.cjs.map +1 -1
- package/dist/development/src/lib/env.js +4 -1
- package/dist/development/src/lib/env.js.map +1 -1
- package/dist/development/src/lib/fs/DockerComposeManager.cjs.map +1 -1
- package/dist/development/src/lib/fs/DockerComposeManager.js.map +1 -1
- package/dist/development/src/lib/fs/FileSystem.cjs.map +1 -1
- package/dist/development/src/lib/fs/FileSystem.js.map +1 -1
- package/dist/development/src/lib/fs/YamlHandler.cjs.map +1 -1
- package/dist/development/src/lib/fs/YamlHandler.js.map +1 -1
- package/dist/development/src/lib/js/EsBuildBuilder.cjs +24 -19
- package/dist/development/src/lib/js/EsBuildBuilder.cjs.map +1 -1
- package/dist/development/src/lib/js/EsBuildBuilder.js +1 -1
- package/dist/development/src/lib/js/EsBuildBuilder.js.map +1 -1
- package/dist/development/src/lib/js/EvalExecutor.cjs +2 -2
- package/dist/development/src/lib/js/EvalExecutor.cjs.map +1 -1
- package/dist/development/src/lib/js/EvalExecutor.js +2 -2
- package/dist/development/src/lib/js/EvalExecutor.js.map +1 -1
- package/dist/development/src/lib/js/JsCodeRunner.cjs.map +1 -1
- package/dist/development/src/lib/js/JsCodeRunner.js.map +1 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.cjs +1 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.js +1 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.js.map +1 -1
- package/dist/development/src/lib/migrations/MigrationPrinter.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationPrinter.js.map +1 -1
- package/dist/development/src/lib/migrations/MigrationRebaseFacade.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationRebaseFacade.js.map +1 -1
- package/dist/development/src/lib/migrations/MigrationsStatusFacade.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationsStatusFacade.js.map +1 -1
- package/dist/development/src/lib/migrations/MigrationsValidator.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationsValidator.js.map +1 -1
- package/dist/development/src/lib/migrations/migrations.cjs.map +1 -1
- package/dist/development/src/lib/migrations/migrations.js.map +1 -1
- package/dist/development/src/lib/project/RemoteProject.cjs.map +1 -1
- package/dist/development/src/lib/project/RemoteProject.js.map +1 -1
- package/dist/development/src/lib/project/RemoteProjectProvider.cjs.map +1 -1
- package/dist/development/src/lib/project/RemoteProjectProvider.js.map +1 -1
- package/dist/development/src/lib/project/RemoteProjectResolver.cjs +9 -2
- package/dist/development/src/lib/project/RemoteProjectResolver.cjs.map +1 -1
- package/dist/development/src/lib/project/RemoteProjectResolver.js +9 -2
- package/dist/development/src/lib/project/RemoteProjectResolver.js.map +1 -1
- package/dist/development/src/lib/project/docs/components/EntityInfo.cjs.map +1 -1
- package/dist/development/src/lib/project/docs/components/EntityInfo.js.map +1 -1
- package/dist/development/src/lib/project/docs/components/FieldLink.cjs.map +1 -1
- package/dist/development/src/lib/project/docs/components/FieldLink.js.map +1 -1
- package/dist/development/src/lib/project/docs/components/FieldPermissions.cjs.map +1 -1
- package/dist/development/src/lib/project/docs/components/FieldPermissions.js.map +1 -1
- package/dist/development/src/lib/project/docs/components/FieldType.cjs.map +1 -1
- package/dist/development/src/lib/project/docs/components/FieldType.js.map +1 -1
- package/dist/development/src/lib/project/docs/components/OnDelete.cjs.map +1 -1
- package/dist/development/src/lib/project/docs/components/OnDelete.js.map +1 -1
- package/dist/development/src/lib/project/docs/components/ProjectInfo.cjs.map +1 -1
- package/dist/development/src/lib/project/docs/components/ProjectInfo.js.map +1 -1
- package/dist/development/src/lib/project/docs/components/SinglePermission.cjs.map +1 -1
- package/dist/development/src/lib/project/docs/components/SinglePermission.js.map +1 -1
- package/dist/development/src/lib/project/docs/projectDescribe.cjs +3 -5
- package/dist/development/src/lib/project/docs/projectDescribe.cjs.map +1 -1
- package/dist/development/src/lib/project/docs/projectDescribe.js +3 -4
- package/dist/development/src/lib/project/docs/projectDescribe.js.map +1 -1
- package/dist/development/src/lib/schema/SchemaLoader.cjs.map +1 -1
- package/dist/development/src/lib/schema/SchemaLoader.js.map +1 -1
- package/dist/development/src/lib/schema/SchemaValidationHelper.cjs.map +1 -1
- package/dist/development/src/lib/schema/SchemaValidationPrinter.cjs.map +1 -1
- package/dist/development/src/lib/schema/SchemaValidationPrinter.js.map +1 -1
- package/dist/development/src/lib/schema/collectReferences.cjs.map +1 -1
- package/dist/development/src/lib/schema/collectReferences.js.map +1 -1
- package/dist/development/src/lib/stream.cjs.map +1 -1
- package/dist/development/src/lib/stream.js.map +1 -1
- package/dist/development/src/lib/tenant/TenantClient.cjs +4 -8
- package/dist/development/src/lib/tenant/TenantClient.cjs.map +1 -1
- package/dist/development/src/lib/tenant/TenantClient.js +3 -7
- package/dist/development/src/lib/tenant/TenantClient.js.map +1 -1
- package/dist/development/src/lib/transfer/DataTransferClient.cjs +2 -2
- package/dist/development/src/lib/transfer/DataTransferClient.cjs.map +1 -1
- package/dist/development/src/lib/transfer/DataTransferClient.js +2 -2
- package/dist/development/src/lib/transfer/DataTransferClient.js.map +1 -1
- package/dist/development/src/lib/transfer/stdio.cjs.map +1 -1
- package/dist/development/src/lib/transfer/stdio.js.map +1 -1
- package/dist/development/src/lib/workspace/WorkspaceResolver.cjs.map +1 -1
- package/dist/development/src/lib/workspace/WorkspaceResolver.js.map +1 -1
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +0 -0
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/deploy/DeployCommand.cjs +5 -5
- package/dist/production/src/commands/deploy/DeployCommand.cjs.map +1 -1
- package/dist/production/src/commands/deploy/DeployCommand.js +5 -5
- package/dist/production/src/commands/deploy/DeployCommand.js.map +1 -1
- package/dist/production/src/commands/migrations/MigrationAmendCommand.cjs +15 -3
- package/dist/production/src/commands/migrations/MigrationAmendCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationAmendCommand.js +15 -3
- package/dist/production/src/commands/migrations/MigrationAmendCommand.js.map +1 -1
- package/dist/production/src/commands/migrations/MigrationBlankCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationBlankCommand.js.map +1 -1
- package/dist/production/src/commands/migrations/MigrationDescribeCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationDescribeCommand.js.map +1 -1
- package/dist/production/src/commands/migrations/MigrationDiffCommand.cjs +1 -1
- package/dist/production/src/commands/migrations/MigrationDiffCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationDiffCommand.js +1 -1
- package/dist/production/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
- package/dist/production/src/commands/migrations/MigrationExecuteCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationExecuteCommand.js.map +1 -1
- package/dist/production/src/commands/migrations/MigrationRebaseCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationRebaseCommand.js.map +1 -1
- package/dist/production/src/commands/migrations/MigrationStatusCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
- package/dist/production/src/commands/misc/VersionCommand.cjs.map +1 -1
- package/dist/production/src/commands/misc/VersionCommand.js.map +1 -1
- package/dist/production/src/commands/project/ProjectGenerateDocumentationCommand.cjs.map +1 -1
- package/dist/production/src/commands/project/ProjectGenerateDocumentationCommand.js.map +1 -1
- package/dist/production/src/commands/project/ProjectPrintSchemaCommand.cjs +13 -2
- package/dist/production/src/commands/project/ProjectPrintSchemaCommand.cjs.map +1 -1
- package/dist/production/src/commands/project/ProjectPrintSchemaCommand.js +14 -3
- package/dist/production/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
- package/dist/production/src/commands/project/ProjectValidateCommand.cjs.map +1 -1
- package/dist/production/src/commands/project/ProjectValidateCommand.js.map +1 -1
- package/dist/production/src/commands/transfer/ExportCommand.cjs +2 -0
- package/dist/production/src/commands/transfer/ExportCommand.cjs.map +1 -1
- package/dist/production/src/commands/transfer/ExportCommand.js +2 -0
- package/dist/production/src/commands/transfer/ExportCommand.js.map +1 -1
- package/dist/production/src/commands/transfer/ImportCommand.cjs.map +1 -1
- package/dist/production/src/commands/transfer/ImportCommand.js.map +1 -1
- package/dist/production/src/commands/transfer/TransferCommand.cjs +2 -0
- package/dist/production/src/commands/transfer/TransferCommand.cjs.map +1 -1
- package/dist/production/src/commands/transfer/TransferCommand.js +2 -0
- package/dist/production/src/commands/transfer/TransferCommand.js.map +1 -1
- package/dist/production/src/commands/transfer/utils.cjs.map +1 -1
- package/dist/production/src/commands/transfer/utils.js.map +1 -1
- package/dist/production/src/commands/workspace/WorkspaceUpdateApiCommand.cjs.map +1 -1
- package/dist/production/src/commands/workspace/WorkspaceUpdateApiCommand.js.map +1 -1
- package/dist/production/src/consts.cjs +3 -1
- package/dist/production/src/consts.cjs.map +1 -1
- package/dist/production/src/consts.js +4 -2
- package/dist/production/src/consts.js.map +1 -1
- package/dist/production/src/dic.cjs +3 -1
- package/dist/production/src/dic.cjs.map +1 -1
- package/dist/production/src/dic.js +3 -1
- package/dist/production/src/dic.js.map +1 -1
- package/dist/production/src/lib/SystemClientProvider.cjs.map +1 -1
- package/dist/production/src/lib/SystemClientProvider.js.map +1 -1
- package/dist/production/src/lib/TenantClientProvider.cjs.map +1 -1
- package/dist/production/src/lib/TenantClientProvider.js.map +1 -1
- package/dist/production/src/lib/VersionChecker.cjs.map +1 -1
- package/dist/production/src/lib/VersionChecker.js.map +1 -1
- package/dist/production/src/lib/admin/AdminClient.cjs +1 -1
- package/dist/production/src/lib/admin/AdminClient.cjs.map +1 -1
- package/dist/production/src/lib/admin/AdminClient.js +1 -1
- package/dist/production/src/lib/admin/AdminClient.js.map +1 -1
- package/dist/production/src/lib/admin/AdminDeployer.cjs.map +1 -1
- package/dist/production/src/lib/admin/AdminDeployer.js.map +1 -1
- package/dist/production/src/lib/dsn.cjs.map +1 -1
- package/dist/production/src/lib/dsn.js.map +1 -1
- package/dist/production/src/lib/env.cjs +4 -1
- package/dist/production/src/lib/env.cjs.map +1 -1
- package/dist/production/src/lib/env.js +4 -1
- package/dist/production/src/lib/env.js.map +1 -1
- package/dist/production/src/lib/fs/DockerComposeManager.cjs.map +1 -1
- package/dist/production/src/lib/fs/DockerComposeManager.js.map +1 -1
- package/dist/production/src/lib/fs/FileSystem.cjs.map +1 -1
- package/dist/production/src/lib/fs/FileSystem.js.map +1 -1
- package/dist/production/src/lib/fs/YamlHandler.cjs.map +1 -1
- package/dist/production/src/lib/fs/YamlHandler.js.map +1 -1
- package/dist/production/src/lib/js/EsBuildBuilder.cjs +24 -19
- package/dist/production/src/lib/js/EsBuildBuilder.cjs.map +1 -1
- package/dist/production/src/lib/js/EsBuildBuilder.js +1 -1
- package/dist/production/src/lib/js/EsBuildBuilder.js.map +1 -1
- package/dist/production/src/lib/js/EvalExecutor.cjs +2 -2
- package/dist/production/src/lib/js/EvalExecutor.cjs.map +1 -1
- package/dist/production/src/lib/js/EvalExecutor.js +2 -2
- package/dist/production/src/lib/js/EvalExecutor.js.map +1 -1
- package/dist/production/src/lib/js/JsCodeRunner.cjs.map +1 -1
- package/dist/production/src/lib/js/JsCodeRunner.js.map +1 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.cjs +1 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.js +1 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.js.map +1 -1
- package/dist/production/src/lib/migrations/MigrationPrinter.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationPrinter.js.map +1 -1
- package/dist/production/src/lib/migrations/MigrationRebaseFacade.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationRebaseFacade.js.map +1 -1
- package/dist/production/src/lib/migrations/MigrationsStatusFacade.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationsStatusFacade.js.map +1 -1
- package/dist/production/src/lib/migrations/MigrationsValidator.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationsValidator.js.map +1 -1
- package/dist/production/src/lib/migrations/migrations.cjs.map +1 -1
- package/dist/production/src/lib/migrations/migrations.js.map +1 -1
- package/dist/production/src/lib/project/RemoteProject.cjs.map +1 -1
- package/dist/production/src/lib/project/RemoteProject.js.map +1 -1
- package/dist/production/src/lib/project/RemoteProjectProvider.cjs.map +1 -1
- package/dist/production/src/lib/project/RemoteProjectProvider.js.map +1 -1
- package/dist/production/src/lib/project/RemoteProjectResolver.cjs +9 -2
- package/dist/production/src/lib/project/RemoteProjectResolver.cjs.map +1 -1
- package/dist/production/src/lib/project/RemoteProjectResolver.js +9 -2
- package/dist/production/src/lib/project/RemoteProjectResolver.js.map +1 -1
- package/dist/production/src/lib/project/docs/components/EntityInfo.cjs.map +1 -1
- package/dist/production/src/lib/project/docs/components/EntityInfo.js.map +1 -1
- package/dist/production/src/lib/project/docs/components/FieldPermissions.cjs.map +1 -1
- package/dist/production/src/lib/project/docs/components/FieldPermissions.js.map +1 -1
- package/dist/production/src/lib/project/docs/components/FieldType.cjs.map +1 -1
- package/dist/production/src/lib/project/docs/components/FieldType.js.map +1 -1
- package/dist/production/src/lib/project/docs/components/OnDelete.cjs.map +1 -1
- package/dist/production/src/lib/project/docs/components/OnDelete.js.map +1 -1
- package/dist/production/src/lib/project/docs/components/ProjectInfo.cjs.map +1 -1
- package/dist/production/src/lib/project/docs/components/ProjectInfo.js.map +1 -1
- package/dist/production/src/lib/project/docs/components/SinglePermission.cjs.map +1 -1
- package/dist/production/src/lib/project/docs/components/SinglePermission.js.map +1 -1
- package/dist/production/src/lib/project/docs/projectDescribe.cjs +2 -4
- package/dist/production/src/lib/project/docs/projectDescribe.cjs.map +1 -1
- package/dist/production/src/lib/project/docs/projectDescribe.js +2 -3
- package/dist/production/src/lib/project/docs/projectDescribe.js.map +1 -1
- package/dist/production/src/lib/schema/SchemaLoader.cjs.map +1 -1
- package/dist/production/src/lib/schema/SchemaLoader.js.map +1 -1
- package/dist/production/src/lib/schema/SchemaValidationHelper.cjs.map +1 -1
- package/dist/production/src/lib/schema/SchemaValidationPrinter.cjs.map +1 -1
- package/dist/production/src/lib/schema/SchemaValidationPrinter.js.map +1 -1
- package/dist/production/src/lib/schema/collectReferences.cjs.map +1 -1
- package/dist/production/src/lib/schema/collectReferences.js.map +1 -1
- package/dist/production/src/lib/stream.cjs.map +1 -1
- package/dist/production/src/lib/stream.js.map +1 -1
- package/dist/production/src/lib/tenant/TenantClient.cjs +4 -8
- package/dist/production/src/lib/tenant/TenantClient.cjs.map +1 -1
- package/dist/production/src/lib/tenant/TenantClient.js +3 -7
- package/dist/production/src/lib/tenant/TenantClient.js.map +1 -1
- package/dist/production/src/lib/transfer/DataTransferClient.cjs +2 -2
- package/dist/production/src/lib/transfer/DataTransferClient.cjs.map +1 -1
- package/dist/production/src/lib/transfer/DataTransferClient.js +2 -2
- package/dist/production/src/lib/transfer/DataTransferClient.js.map +1 -1
- package/dist/production/src/lib/transfer/stdio.cjs.map +1 -1
- package/dist/production/src/lib/transfer/stdio.js.map +1 -1
- package/dist/production/src/lib/workspace/WorkspaceResolver.cjs.map +1 -1
- package/dist/production/src/lib/workspace/WorkspaceResolver.js.map +1 -1
- package/dist/types/commands/deploy/DeployCommand.d.ts.map +1 -1
- package/dist/types/commands/migrations/MigrationAmendCommand.d.ts +1 -0
- package/dist/types/commands/migrations/MigrationAmendCommand.d.ts.map +1 -1
- package/dist/types/commands/project/ProjectPrintSchemaCommand.d.ts +4 -0
- package/dist/types/commands/project/ProjectPrintSchemaCommand.d.ts.map +1 -1
- package/dist/types/commands/transfer/ExportCommand.d.ts +1 -0
- package/dist/types/commands/transfer/ExportCommand.d.ts.map +1 -1
- package/dist/types/commands/transfer/TransferCommand.d.ts +1 -0
- package/dist/types/commands/transfer/TransferCommand.d.ts.map +1 -1
- package/dist/types/consts.d.ts.map +1 -1
- package/dist/types/dic.d.ts.map +1 -1
- package/dist/types/lib/env.d.ts +3 -0
- package/dist/types/lib/env.d.ts.map +1 -1
- package/dist/types/lib/js/EsBuildBuilder.d.ts.map +1 -1
- package/dist/types/lib/migrations/MigrationExecutionFacade.d.ts +2 -2
- package/dist/types/lib/migrations/MigrationExecutionFacade.d.ts.map +1 -1
- package/dist/types/lib/migrations/MigrationPrinter.d.ts.map +1 -1
- package/dist/types/lib/project/RemoteProjectResolver.d.ts +1 -1
- package/dist/types/lib/project/RemoteProjectResolver.d.ts.map +1 -1
- package/dist/types/lib/project/docs/projectDescribe.d.ts.map +1 -1
- package/dist/types/lib/tenant/TenantClient.d.ts +2 -2
- package/dist/types/lib/tenant/TenantClient.d.ts.map +1 -1
- package/dist/types/lib/transfer/DataTransferClient.d.ts +2 -1
- package/dist/types/lib/transfer/DataTransferClient.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +34 -31
- package/src/commands/deploy/DeployCommand.ts +6 -5
- package/src/commands/migrations/MigrationAmendCommand.ts +16 -3
- package/src/commands/migrations/MigrationDiffCommand.ts +1 -1
- package/src/commands/project/ProjectPrintSchemaCommand.ts +19 -3
- package/src/commands/transfer/ExportCommand.ts +3 -0
- package/src/commands/transfer/TransferCommand.ts +3 -0
- package/src/consts.ts +4 -2
- package/src/dic.ts +3 -1
- package/src/lib/admin/AdminClient.ts +1 -1
- package/src/lib/env.ts +6 -0
- package/src/lib/js/EsBuildBuilder.ts +1 -1
- package/src/lib/js/EvalExecutor.ts +2 -2
- package/src/lib/migrations/MigrationExecutionFacade.ts +3 -3
- package/src/lib/migrations/MigrationPrinter.ts +3 -0
- package/src/lib/project/RemoteProjectResolver.ts +10 -2
- package/src/lib/project/docs/projectDescribe.tsx +2 -3
- package/src/lib/tenant/TenantClient.ts +5 -9
- package/src/lib/transfer/DataTransferClient.ts +3 -2
- package/src/tsconfig.json +1 -0
- package/tsconfig.settings.json +0 -1
- package/Dockerfile +0 -20
- package/build.sh +0 -11
- package/esbuild.cjs +0 -27
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GraphQlClient } from "@contember/graphql-client";
|
|
2
2
|
const createTenantApiUrl = (url) => {
|
|
3
3
|
if (url.endsWith("/")) {
|
|
4
4
|
url = url.substring(0, url.length - 1);
|
|
@@ -13,11 +13,7 @@ class TenantClient {
|
|
|
13
13
|
this.apiClient = apiClient;
|
|
14
14
|
}
|
|
15
15
|
static create(url, apiToken) {
|
|
16
|
-
const graphqlClient = new
|
|
17
|
-
headers: {
|
|
18
|
-
Authorization: `Bearer ${apiToken}`
|
|
19
|
-
}
|
|
20
|
-
});
|
|
16
|
+
const graphqlClient = new GraphQlClient({ url: createTenantApiUrl(url), apiToken });
|
|
21
17
|
return new TenantClient(graphqlClient);
|
|
22
18
|
}
|
|
23
19
|
async createProject(slug, ignoreExisting = false) {
|
|
@@ -29,7 +25,7 @@ class TenantClient {
|
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
27
|
}`;
|
|
32
|
-
const result = await this.apiClient.
|
|
28
|
+
const result = await this.apiClient.execute(query, { variables: { slug } });
|
|
33
29
|
if (!result.createProject.ok) {
|
|
34
30
|
if (ignoreExisting && result.createProject.error.code === "ALREADY_EXISTS") {
|
|
35
31
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TenantClient.js","sources":["../../../../../../packages/cli/src/lib/tenant/TenantClient.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"TenantClient.js","sources":["../../../../../../packages/cli/src/lib/tenant/TenantClient.ts"],"sourcesContent":["import { GraphQlClient } from '@contember/graphql-client'\n\nexport const createTenantApiUrl = (url: string) => {\n\tif (url.endsWith('/')) {\n\t\turl = url.substring(0, url.length - 1)\n\t}\n\tif (url.endsWith('/tenant')) {\n\t\treturn url\n\t}\n\treturn url + '/tenant'\n}\n\n\nexport class TenantClient {\n\tconstructor(private readonly apiClient: GraphQlClient) {}\n\n\tpublic static create(url: string, apiToken: string): TenantClient {\n\t\tconst graphqlClient = new GraphQlClient({ url: createTenantApiUrl(url), apiToken })\n\t\treturn new TenantClient(graphqlClient)\n\t}\n\n\tpublic async createProject(slug: string, ignoreExisting = false): Promise<void> {\n\t\tconst query = `mutation($slug: String!) {\n createProject(projectSlug: $slug) {\n ok\n error {\n code\n }\n }\n}`\n\t\tconst result = await this.apiClient.execute<{\n\t\t\tcreateProject: { ok: boolean; error: { code: string } }\n\t\t}>(query, { variables: { slug } })\n\t\tif (!result.createProject.ok) {\n\t\t\tif (ignoreExisting && result.createProject.error.code === 'ALREADY_EXISTS') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthrow result.createProject.error.code\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAEa,MAAA,qBAAqB,CAAC,QAAgB;AAC9C,MAAA,IAAI,SAAS,GAAG,GAAG;AACtB,UAAM,IAAI,UAAU,GAAG,IAAI,SAAS,CAAC;AAAA,EAAA;AAElC,MAAA,IAAI,SAAS,SAAS,GAAG;AACrB,WAAA;AAAA,EAAA;AAER,SAAO,MAAM;AACd;AAGO,MAAM,aAAa;AAAA,EACzB,YAA6B,WAA0B;AAA1B,SAAA,YAAA;AAAA,EAAA;AAAA,EAE7B,OAAc,OAAO,KAAa,UAAgC;AAC3D,UAAA,gBAAgB,IAAI,cAAc,EAAE,KAAK,mBAAmB,GAAG,GAAG,UAAU;AAC3E,WAAA,IAAI,aAAa,aAAa;AAAA,EAAA;AAAA,EAGtC,MAAa,cAAc,MAAc,iBAAiB,OAAsB;AAC/E,UAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQR,UAAA,SAAS,MAAM,KAAK,UAAU,QAEjC,OAAO,EAAE,WAAW,EAAE,KAAK,GAAG;AAC7B,QAAA,CAAC,OAAO,cAAc,IAAI;AAC7B,UAAI,kBAAkB,OAAO,cAAc,MAAM,SAAS,kBAAkB;AAC3E;AAAA,MAAA;AAEK,YAAA,OAAO,cAAc,MAAM;AAAA,IAAA;AAAA,EAClC;AAEF;"}
|
|
@@ -53,7 +53,7 @@ class DataTransferClient {
|
|
|
53
53
|
body: gzip ? inputStream.pipe(node_zlib.createGzip()) : inputStream
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
|
-
__publicField(this, "dataExport", async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem }) => {
|
|
56
|
+
__publicField(this, "dataExport", async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }) => {
|
|
57
57
|
return await this.executeRequest({
|
|
58
58
|
url: `${baseUrl}/export`,
|
|
59
59
|
token,
|
|
@@ -62,7 +62,7 @@ class DataTransferClient {
|
|
|
62
62
|
"Content-type": "application/json"
|
|
63
63
|
},
|
|
64
64
|
body: JSON.stringify({
|
|
65
|
-
projects: [{ slug: project, system: includeSystem }]
|
|
65
|
+
projects: [{ slug: project, system: includeSystem, excludeTables }]
|
|
66
66
|
})
|
|
67
67
|
});
|
|
68
68
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTransferClient.cjs","sources":["../../../../../../packages/cli/src/lib/transfer/DataTransferClient.ts"],"sourcesContent":["import http from 'node:http'\nimport https from 'node:https'\nimport { LineTransform, readStream } from '../stream'\nimport { Readable, Stream } from 'node:stream'\nimport { createGzip } from 'node:zlib'\nimport { RemoteProject } from '../project/RemoteProject'\n\nexport class DataTransferClient {\n\n\tdataImport = async ({ printProgress, stream, project, gzip }: {\n\t\tstream: Readable\n\t\tproject: RemoteProject\n\t\tprintProgress: (message: string) => void\n\t\tgzip: boolean\n\t}) => {\n\t\tlet table = ''\n\t\tlet rowCount = 0\n\t\tlet rowTotal = 0\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tconst inputStream = stream.pipe(new LineTransform(line => {\n\t\t\ttransferred += line.length + 1\n\t\t\tif (line === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst data = JSON.parse(line)\n\t\t\tswitch (data[0]) {\n\t\t\t\tcase 'importSystemSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'importContentSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'insertBegin':\n\t\t\t\t\ttable = data[1].table\n\t\t\t\t\trowCount = 0\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertRow':\n\t\t\t\t\trowCount++\n\t\t\t\t\trowTotal++\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertEnd':\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t\tif ((rowCount % 1000) === 0 || data[0] !== 'insertRow') {\n\t\t\t\tconst mbs = Math.floor(transferred / 1024 / 1024).toString()\n\t\t\t\tconst durationS = Math.floor((Date.now() - start) / 1000)\n\t\t\t\tprintProgress(`transferred ${mbs} MiB; inserted ${rowCount} ${table} rows, ${rowTotal} total; ${durationS} seconds`)\n\t\t\t}\n\t\t\treturn line\n\t\t}))\n\n\t\treturn await this.executeRequest({\n\t\t\turl: `${project.endpoint}/import`,\n\t\t\ttoken: project.token,\n\t\t\theaders: {\n\t\t\t\t'Content-type': 'application/x-ndjson',\n\t\t\t\t...(gzip ? { 'Content-Encoding': 'gzip' } : {}),\n\t\t\t},\n\t\t\tbody: gzip ? inputStream.pipe(createGzip()) : inputStream,\n\t\t})\n\t}\n\n\n\tdataExport = async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem }: {\n\t\tproject: RemoteProject\n\t\tincludeSystem: boolean\n\t\tgzip: boolean\n\t}) => {\n\t\treturn await this.executeRequest({\n\t\t\turl: `${baseUrl}/export`,\n\t\t\ttoken,\n\t\t\theaders: {\n\t\t\t\t'Accept-Encoding': gzip ? 'gzip' : 'identity',\n\t\t\t\t'Content-type': 'application/json',\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tprojects: [{ slug: project, system: includeSystem }],\n\t\t\t}),\n\t\t})\n\t}\n\n\n\tprivate executeRequest = async ({ url, token, headers, body }: {\n\t\turl: string\n\t\ttoken: string\n\t\theaders: Record<string, string>\n\t\tbody: any\n\t}) => {\n\t\treturn await new Promise<http.IncomingMessage>((resolve, reject) => {\n\t\t\tconst req = (url.startsWith('https://') ? https : http).request(url, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\t...headers,\n\t\t\t\t},\n\t\t\t}, async res => {\n\t\t\t\tif (res.statusCode !== 200) {\n\t\t\t\t\tconst responseBody = (await readStream(res)).toString()\n\t\t\t\t\treject(new Error(`Invalid response: ${res.statusMessage}\\n${responseBody}`))\n\t\t\t\t} else {\n\t\t\t\t\tresolve(res)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tif (body instanceof Stream) {\n\t\t\t\tbody.pipe(req)\n\t\t\t} else {\n\t\t\t\treq.write(body)\n\t\t\t\treq.end()\n\t\t\t}\n\t\t})\n\t}\n}\n"],"names":["stream","LineTransform","createGzip","readStream","Stream"],"mappings":";;;;;;;;;;AAOO,MAAM,mBAAmB;AAAA,EAAzB,cAAA;AAEN,kBAAA,MAAA,cAAa,OAAO,EAAE,eAAA,QAAeA,UAAQ,SAAS,WAKhD;AACL,UAAI,QAAQ;AACZ,UAAI,WAAW;AACf,UAAI,WAAW;AACf,UAAI,cAAc;AACd,UAAA,QAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"DataTransferClient.cjs","sources":["../../../../../../packages/cli/src/lib/transfer/DataTransferClient.ts"],"sourcesContent":["import http from 'node:http'\nimport https from 'node:https'\nimport { LineTransform, readStream } from '../stream'\nimport { Readable, Stream } from 'node:stream'\nimport { createGzip } from 'node:zlib'\nimport { RemoteProject } from '../project/RemoteProject'\n\nexport class DataTransferClient {\n\n\tdataImport = async ({ printProgress, stream, project, gzip }: {\n\t\tstream: Readable\n\t\tproject: RemoteProject\n\t\tprintProgress: (message: string) => void\n\t\tgzip: boolean\n\t}) => {\n\t\tlet table = ''\n\t\tlet rowCount = 0\n\t\tlet rowTotal = 0\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tconst inputStream = stream.pipe(new LineTransform(line => {\n\t\t\ttransferred += line.length + 1\n\t\t\tif (line === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst data = JSON.parse(line)\n\t\t\tswitch (data[0]) {\n\t\t\t\tcase 'importSystemSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'importContentSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'insertBegin':\n\t\t\t\t\ttable = data[1].table\n\t\t\t\t\trowCount = 0\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertRow':\n\t\t\t\t\trowCount++\n\t\t\t\t\trowTotal++\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertEnd':\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t\tif ((rowCount % 1000) === 0 || data[0] !== 'insertRow') {\n\t\t\t\tconst mbs = Math.floor(transferred / 1024 / 1024).toString()\n\t\t\t\tconst durationS = Math.floor((Date.now() - start) / 1000)\n\t\t\t\tprintProgress(`transferred ${mbs} MiB; inserted ${rowCount} ${table} rows, ${rowTotal} total; ${durationS} seconds`)\n\t\t\t}\n\t\t\treturn line\n\t\t}))\n\n\t\treturn await this.executeRequest({\n\t\t\turl: `${project.endpoint}/import`,\n\t\t\ttoken: project.token,\n\t\t\theaders: {\n\t\t\t\t'Content-type': 'application/x-ndjson',\n\t\t\t\t...(gzip ? { 'Content-Encoding': 'gzip' } : {}),\n\t\t\t},\n\t\t\tbody: gzip ? inputStream.pipe(createGzip()) : inputStream,\n\t\t})\n\t}\n\n\n\tdataExport = async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }: {\n\t\tproject: RemoteProject\n\t\texcludeTables?: string[]\n\t\tincludeSystem: boolean\n\t\tgzip: boolean\n\t}) => {\n\t\treturn await this.executeRequest({\n\t\t\turl: `${baseUrl}/export`,\n\t\t\ttoken,\n\t\t\theaders: {\n\t\t\t\t'Accept-Encoding': gzip ? 'gzip' : 'identity',\n\t\t\t\t'Content-type': 'application/json',\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tprojects: [{ slug: project, system: includeSystem, excludeTables }],\n\t\t\t}),\n\t\t})\n\t}\n\n\n\tprivate executeRequest = async ({ url, token, headers, body }: {\n\t\turl: string\n\t\ttoken: string\n\t\theaders: Record<string, string>\n\t\tbody: any\n\t}) => {\n\t\treturn await new Promise<http.IncomingMessage>((resolve, reject) => {\n\t\t\tconst req = (url.startsWith('https://') ? https : http).request(url, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\t...headers,\n\t\t\t\t},\n\t\t\t}, async res => {\n\t\t\t\tif (res.statusCode !== 200) {\n\t\t\t\t\tconst responseBody = (await readStream(res)).toString()\n\t\t\t\t\treject(new Error(`Invalid response: ${res.statusMessage}\\n${responseBody}`))\n\t\t\t\t} else {\n\t\t\t\t\tresolve(res)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tif (body instanceof Stream) {\n\t\t\t\tbody.pip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A;AAED,YAAI,gBAAgBC,YAAAA,QAAQ;AAC3B,eAAK,KAAK,GAAG;AAAA,QAAA,OACP;AACN,cAAI,MAAM,IAAI;AACd,cAAI,IAAI;AAAA,QAAA;AAAA,MACT,CACA;AAAA,IAAA,CACF;AAAA,EAAA;AACD;;"}
|
|
@@ -51,7 +51,7 @@ class DataTransferClient {
|
|
|
51
51
|
body: gzip ? inputStream.pipe(createGzip()) : inputStream
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
|
-
__publicField(this, "dataExport", async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem }) => {
|
|
54
|
+
__publicField(this, "dataExport", async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }) => {
|
|
55
55
|
return await this.executeRequest({
|
|
56
56
|
url: `${baseUrl}/export`,
|
|
57
57
|
token,
|
|
@@ -60,7 +60,7 @@ class DataTransferClient {
|
|
|
60
60
|
"Content-type": "application/json"
|
|
61
61
|
},
|
|
62
62
|
body: JSON.stringify({
|
|
63
|
-
projects: [{ slug: project, system: includeSystem }]
|
|
63
|
+
projects: [{ slug: project, system: includeSystem, excludeTables }]
|
|
64
64
|
})
|
|
65
65
|
});
|
|
66
66
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTransferClient.js","sources":["../../../../../../packages/cli/src/lib/transfer/DataTransferClient.ts"],"sourcesContent":["import http from 'node:http'\nimport https from 'node:https'\nimport { LineTransform, readStream } from '../stream'\nimport { Readable, Stream } from 'node:stream'\nimport { createGzip } from 'node:zlib'\nimport { RemoteProject } from '../project/RemoteProject'\n\nexport class DataTransferClient {\n\n\tdataImport = async ({ printProgress, stream, project, gzip }: {\n\t\tstream: Readable\n\t\tproject: RemoteProject\n\t\tprintProgress: (message: string) => void\n\t\tgzip: boolean\n\t}) => {\n\t\tlet table = ''\n\t\tlet rowCount = 0\n\t\tlet rowTotal = 0\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tconst inputStream = stream.pipe(new LineTransform(line => {\n\t\t\ttransferred += line.length + 1\n\t\t\tif (line === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst data = JSON.parse(line)\n\t\t\tswitch (data[0]) {\n\t\t\t\tcase 'importSystemSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'importContentSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'insertBegin':\n\t\t\t\t\ttable = data[1].table\n\t\t\t\t\trowCount = 0\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertRow':\n\t\t\t\t\trowCount++\n\t\t\t\t\trowTotal++\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertEnd':\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t\tif ((rowCount % 1000) === 0 || data[0] !== 'insertRow') {\n\t\t\t\tconst mbs = Math.floor(transferred / 1024 / 1024).toString()\n\t\t\t\tconst durationS = Math.floor((Date.now() - start) / 1000)\n\t\t\t\tprintProgress(`transferred ${mbs} MiB; inserted ${rowCount} ${table} rows, ${rowTotal} total; ${durationS} seconds`)\n\t\t\t}\n\t\t\treturn line\n\t\t}))\n\n\t\treturn await this.executeRequest({\n\t\t\turl: `${project.endpoint}/import`,\n\t\t\ttoken: project.token,\n\t\t\theaders: {\n\t\t\t\t'Content-type': 'application/x-ndjson',\n\t\t\t\t...(gzip ? { 'Content-Encoding': 'gzip' } : {}),\n\t\t\t},\n\t\t\tbody: gzip ? inputStream.pipe(createGzip()) : inputStream,\n\t\t})\n\t}\n\n\n\tdataExport = async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem }: {\n\t\tproject: RemoteProject\n\t\tincludeSystem: boolean\n\t\tgzip: boolean\n\t}) => {\n\t\treturn await this.executeRequest({\n\t\t\turl: `${baseUrl}/export`,\n\t\t\ttoken,\n\t\t\theaders: {\n\t\t\t\t'Accept-Encoding': gzip ? 'gzip' : 'identity',\n\t\t\t\t'Content-type': 'application/json',\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tprojects: [{ slug: project, system: includeSystem }],\n\t\t\t}),\n\t\t})\n\t}\n\n\n\tprivate executeRequest = async ({ url, token, headers, body }: {\n\t\turl: string\n\t\ttoken: string\n\t\theaders: Record<string, string>\n\t\tbody: any\n\t}) => {\n\t\treturn await new Promise<http.IncomingMessage>((resolve, reject) => {\n\t\t\tconst req = (url.startsWith('https://') ? https : http).request(url, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\t...headers,\n\t\t\t\t},\n\t\t\t}, async res => {\n\t\t\t\tif (res.statusCode !== 200) {\n\t\t\t\t\tconst responseBody = (await readStream(res)).toString()\n\t\t\t\t\treject(new Error(`Invalid response: ${res.statusMessage}\\n${responseBody}`))\n\t\t\t\t} else {\n\t\t\t\t\tresolve(res)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tif (body instanceof Stream) {\n\t\t\t\tbody.pipe(req)\n\t\t\t} else {\n\t\t\t\treq.write(body)\n\t\t\t\treq.end()\n\t\t\t}\n\t\t})\n\t}\n}\n"],"names":["http"],"mappings":";;;;;;;;AAOO,MAAM,mBAAmB;AAAA,EAAzB,cAAA;AAEN,kBAAA,MAAA,cAAa,OAAO,EAAE,eAAe,QAAQ,SAAS,WAKhD;AACL,UAAI,QAAQ;AACZ,UAAI,WAAW;AACf,UAAI,WAAW;AACf,UAAI,cAAc;AACd,UAAA,QAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"DataTransferClient.js","sources":["../../../../../../packages/cli/src/lib/transfer/DataTransferClient.ts"],"sourcesContent":["import http from 'node:http'\nimport https from 'node:https'\nimport { LineTransform, readStream } from '../stream'\nimport { Readable, Stream } from 'node:stream'\nimport { createGzip } from 'node:zlib'\nimport { RemoteProject } from '../project/RemoteProject'\n\nexport class DataTransferClient {\n\n\tdataImport = async ({ printProgress, stream, project, gzip }: {\n\t\tstream: Readable\n\t\tproject: RemoteProject\n\t\tprintProgress: (message: string) => void\n\t\tgzip: boolean\n\t}) => {\n\t\tlet table = ''\n\t\tlet rowCount = 0\n\t\tlet rowTotal = 0\n\t\tlet transferred = 0\n\t\tlet start = Date.now()\n\t\tconst inputStream = stream.pipe(new LineTransform(line => {\n\t\t\ttransferred += line.length + 1\n\t\t\tif (line === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\tconst data = JSON.parse(line)\n\t\t\tswitch (data[0]) {\n\t\t\t\tcase 'importSystemSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'importContentSchemaBegin':\n\t\t\t\t\treturn JSON.stringify([data[0], { ...data[1], project: project.name }])\n\t\t\t\tcase 'insertBegin':\n\t\t\t\t\ttable = data[1].table\n\t\t\t\t\trowCount = 0\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertRow':\n\t\t\t\t\trowCount++\n\t\t\t\t\trowTotal++\n\t\t\t\t\tbreak\n\t\t\t\tcase 'insertEnd':\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t\tif ((rowCount % 1000) === 0 || data[0] !== 'insertRow') {\n\t\t\t\tconst mbs = Math.floor(transferred / 1024 / 1024).toString()\n\t\t\t\tconst durationS = Math.floor((Date.now() - start) / 1000)\n\t\t\t\tprintProgress(`transferred ${mbs} MiB; inserted ${rowCount} ${table} rows, ${rowTotal} total; ${durationS} seconds`)\n\t\t\t}\n\t\t\treturn line\n\t\t}))\n\n\t\treturn await this.executeRequest({\n\t\t\turl: `${project.endpoint}/import`,\n\t\t\ttoken: project.token,\n\t\t\theaders: {\n\t\t\t\t'Content-type': 'application/x-ndjson',\n\t\t\t\t...(gzip ? { 'Content-Encoding': 'gzip' } : {}),\n\t\t\t},\n\t\t\tbody: gzip ? inputStream.pipe(createGzip()) : inputStream,\n\t\t})\n\t}\n\n\n\tdataExport = async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }: {\n\t\tproject: RemoteProject\n\t\texcludeTables?: string[]\n\t\tincludeSystem: boolean\n\t\tgzip: boolean\n\t}) => {\n\t\treturn await this.executeRequest({\n\t\t\turl: `${baseUrl}/export`,\n\t\t\ttoken,\n\t\t\theaders: {\n\t\t\t\t'Accept-Encoding': gzip ? 'gzip' : 'identity',\n\t\t\t\t'Content-type': 'application/json',\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tprojects: [{ slug: project, system: includeSystem, excludeTables }],\n\t\t\t}),\n\t\t})\n\t}\n\n\n\tprivate executeRequest = async ({ url, token, headers, body }: {\n\t\turl: string\n\t\ttoken: string\n\t\theaders: Record<string, string>\n\t\tbody: any\n\t}) => {\n\t\treturn await new Promise<http.IncomingMessage>((resolve, reject) => {\n\t\t\tconst req = (url.startsWith('https://') ? https : http).request(url, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\t...headers,\n\t\t\t\t},\n\t\t\t}, async res => {\n\t\t\t\tif (res.statusCode !== 200) {\n\t\t\t\t\tconst responseBody = (await readStream(res)).toString()\n\t\t\t\t\treject(new Error(`Invalid response: ${res.statusMessage}\\n${responseBody}`))\n\t\t\t\t} else {\n\t\t\t\t\tresolve(res)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tif (body instanceof Stream) {\n\t\t\t\tbody.pipe(req)\n\t\t\t} else {\n\t\t\t\treq.write(body)\n\t\t\t\treq.end()\n\t\t\t}\n\t\t})\n\t}\n}\n"],"names":["http"],"mappings":";;;;;;;;AAOO,MAAM,mBAAmB;AAAA,EAAzB,cAAA;AAEN,kBAAA,MAAA,cAAa,OAAO,EAAE,eAAe,QAAQ,SAAS,WAKhD;AACL,UAAI,QAAQ;AACZ,UAAI,WAAW;AACf,UAAI,WAAW;AACf,UAAI,cAAc;AACd,UAAA,QAAQ,KAAK,IAAI;AACrB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,GAAG,MAAM,eAAe,oBAK3F;AACE,aAAA,MAAM,KAAK,eAAe;AAAA,QAChC,KAAK,GAAG,OAAO;AAAA,QACf;AAAA,QACA,SAAS;AAAA,UACR,mBAAmB,OAAO,SAAS;AAAA,UACnC,gBAAgB;AAAA,QACjB;AAAA,QACA,MAAM,KAAK,UAAU;AAAA,UACpB,UAAU,CAAC,EAAE,MAAM,SAAS,QAAQ,eAAe,cAAe,CAAA;AAAA,QAClE,CAAA;AAAA,MAAA,CACD;AAAA,IAAA,CACF;AAGA,kBAAA,MAAQ,kBAAiB,OAAO,EAAE,KAAK,OAAO,SAAS,WAKjD;AACL,aAAO,MAAM,IAAI,QAA8B,CAAC,SAAS,WAAW;AAC7D,cAAA,OAAO,IAAI,WAAW,UAAU,IAAI,QAAQA,eAAM,QAAQ,KAAK;AAAA,UACpE,QAAQ;AAAA,UACR,SAAS;AAAA,YACR,eAAe,UAAU,KAAK;AAAA,YAC9B,GAAG;AAAA,UAAA;AAAA,QAEL,GAAG,OAAM,QAAO;AACX,cAAA,IAAI,eAAe,KAAK;AAC3B,kBAAM,gBAAgB,MAAM,WAAW,GAAG,GAAG,SAAS;AACtD,mBAAO,IAAI,MAAM,qBAAqB,IAAI,aAAa;AAAA,EAAK,YAAY,EAAE,CAAC;AAAA,UAAA,OACrE;AACN,oBAAQ,GAAG;AAAA,UAAA;AAAA,QACZ,CACA;AAED,YAAI,gBAAgB,QAAQ;AAC3B,eAAK,KAAK,GAAG;AAAA,QAAA,OACP;AACN,cAAI,MAAM,IAAI;AACd,cAAI,IAAI;AAAA,QAAA;AAAA,MACT,CACA;AAAA,IAAA,CACF;AAAA,EAAA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.cjs","sources":["../../../../../../packages/cli/src/lib/transfer/stdio.ts"],"sourcesContent":["export const printProgressLine = (message: string) => {\n\tif (!process.stdout.clearLine) {\n\t\treturn\n\t}\n\tprocess.stdout.clearLine(0)\n\tprocess.stdout.cursorTo(0)\n\tprocess.stdout.write(message)\n}\n\n"],"names":[],"mappings":";;AAAa,MAAA,oBAAoB,CAAC,YAAoB;AACjD,MAAA,CAAC,QAAQ,OAAO,WAAW;AAC9B;AAAA,
|
|
1
|
+
{"version":3,"file":"stdio.cjs","sources":["../../../../../../packages/cli/src/lib/transfer/stdio.ts"],"sourcesContent":["export const printProgressLine = (message: string) => {\n\tif (!process.stdout.clearLine) {\n\t\treturn\n\t}\n\tprocess.stdout.clearLine(0)\n\tprocess.stdout.cursorTo(0)\n\tprocess.stdout.write(message)\n}\n\n"],"names":[],"mappings":";;AAAa,MAAA,oBAAoB,CAAC,YAAoB;AACjD,MAAA,CAAC,QAAQ,OAAO,WAAW;AAC9B;AAAA,EAAA;AAEO,UAAA,OAAO,UAAU,CAAC;AAClB,UAAA,OAAO,SAAS,CAAC;AACjB,UAAA,OAAO,MAAM,OAAO;AAC7B;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.js","sources":["../../../../../../packages/cli/src/lib/transfer/stdio.ts"],"sourcesContent":["export const printProgressLine = (message: string) => {\n\tif (!process.stdout.clearLine) {\n\t\treturn\n\t}\n\tprocess.stdout.clearLine(0)\n\tprocess.stdout.cursorTo(0)\n\tprocess.stdout.write(message)\n}\n\n"],"names":[],"mappings":"AAAa,MAAA,oBAAoB,CAAC,YAAoB;AACjD,MAAA,CAAC,QAAQ,OAAO,WAAW;AAC9B;AAAA,
|
|
1
|
+
{"version":3,"file":"stdio.js","sources":["../../../../../../packages/cli/src/lib/transfer/stdio.ts"],"sourcesContent":["export const printProgressLine = (message: string) => {\n\tif (!process.stdout.clearLine) {\n\t\treturn\n\t}\n\tprocess.stdout.clearLine(0)\n\tprocess.stdout.cursorTo(0)\n\tprocess.stdout.write(message)\n}\n\n"],"names":[],"mappings":"AAAa,MAAA,oBAAoB,CAAC,YAAoB;AACjD,MAAA,CAAC,QAAQ,OAAO,WAAW;AAC9B;AAAA,EAAA;AAEO,UAAA,OAAO,UAAU,CAAC;AAClB,UAAA,OAAO,SAAS,CAAC;AACjB,UAAA,OAAO,MAAM,OAAO;AAC7B;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceResolver.cjs","sources":["../../../../../../packages/cli/src/lib/workspace/WorkspaceResolver.ts"],"sourcesContent":["import { Workspace } from './Workspace'\nimport { join } from 'node:path'\nimport { YamlHandler } from '../fs/YamlHandler'\n\nexport interface LocalProjectConfig {\n\tapiDir?: string\n\tmigrationsDir?: string\n\tadminDir?: string | false\n\tadminDistDir?: string\n}\n\nexport class WorkspaceResolver {\n\tconstructor(\n\t\tprivate readonly yamlHandler: YamlHandler,\n\t) {\n\t}\n\n\tresolve = async (baseDir: string): Promise<Workspace> => {\n\t\tconst config = await this.readConfig(baseDir)\n\t\tconst apiDir = config.apiDir ?? join(baseDir, 'api')\n\t\tconst migrationsDir = config.migrationsDir ?? join(apiDir, 'migrations')\n\t\tconst adminDir = config.adminDir === false ? undefined : (config.adminDir ?? join(baseDir, 'admin'))\n\t\tconst adminDistDir = adminDir === undefined ? undefined : (config.adminDistDir ?? join(adminDir, 'dist'))\n\n\t\treturn {\n\t\t\tbaseDir,\n\t\t\tapiDir,\n\t\t\tmigrationsDir,\n\t\t\tadminDir,\n\t\t\tadminDistDir,\n\t\t}\n\t}\n\n\tprivate async readConfig(baseDir: string): Promise<LocalProjectConfig> {\n\t\tconst configPath = join(baseDir, 'contember.yaml')\n\t\ttry {\n\t\t\treturn await this.yamlHandler.readYaml(configPath)\n\t\t} catch (e: any) {\n\t\t\tif (e.code === 'ENOENT') {\n\t\t\t\treturn {}\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":["join"],"mappings":";;;;;;AAWO,MAAM,kBAAkB;AAAA,EAC9B,YACkB,aAChB;AADgB,SAAA,cAAA;AAIlB,kBAAA,MAAA,WAAU,OAAO,YAAwC;AACxD,YAAM,SAAS,MAAM,KAAK,WAAW,OAAO;AAC5C,YAAM,SAAS,OAAO,UAAUA,UAAAA,KAAK,SAAS,KAAK;AACnD,YAAM,gBAAgB,OAAO,iBAAiBA,UAAAA,KAAK,QAAQ,YAAY;AACjE,YAAA,WAAW,OAAO,aAAa,QAAQ,SAAa,OAAO,YAAYA,
|
|
1
|
+
{"version":3,"file":"WorkspaceResolver.cjs","sources":["../../../../../../packages/cli/src/lib/workspace/WorkspaceResolver.ts"],"sourcesContent":["import { Workspace } from './Workspace'\nimport { join } from 'node:path'\nimport { YamlHandler } from '../fs/YamlHandler'\n\nexport interface LocalProjectConfig {\n\tapiDir?: string\n\tmigrationsDir?: string\n\tadminDir?: string | false\n\tadminDistDir?: string\n}\n\nexport class WorkspaceResolver {\n\tconstructor(\n\t\tprivate readonly yamlHandler: YamlHandler,\n\t) {\n\t}\n\n\tresolve = async (baseDir: string): Promise<Workspace> => {\n\t\tconst config = await this.readConfig(baseDir)\n\t\tconst apiDir = config.apiDir ?? join(baseDir, 'api')\n\t\tconst migrationsDir = config.migrationsDir ?? join(apiDir, 'migrations')\n\t\tconst adminDir = config.adminDir === false ? undefined : (config.adminDir ?? join(baseDir, 'admin'))\n\t\tconst adminDistDir = adminDir === undefined ? undefined : (config.adminDistDir ?? join(adminDir, 'dist'))\n\n\t\treturn {\n\t\t\tbaseDir,\n\t\t\tapiDir,\n\t\t\tmigrationsDir,\n\t\t\tadminDir,\n\t\t\tadminDistDir,\n\t\t}\n\t}\n\n\tprivate async readConfig(baseDir: string): Promise<LocalProjectConfig> {\n\t\tconst configPath = join(baseDir, 'contember.yaml')\n\t\ttry {\n\t\t\treturn await this.yamlHandler.readYaml(configPath)\n\t\t} catch (e: any) {\n\t\t\tif (e.code === 'ENOENT') {\n\t\t\t\treturn {}\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":["join"],"mappings":";;;;;;AAWO,MAAM,kBAAkB;AAAA,EAC9B,YACkB,aAChB;AADgB,SAAA,cAAA;AAIlB,kBAAA,MAAA,WAAU,OAAO,YAAwC;AACxD,YAAM,SAAS,MAAM,KAAK,WAAW,OAAO;AAC5C,YAAM,SAAS,OAAO,UAAUA,UAAAA,KAAK,SAAS,KAAK;AACnD,YAAM,gBAAgB,OAAO,iBAAiBA,UAAAA,KAAK,QAAQ,YAAY;AACjE,YAAA,WAAW,OAAO,aAAa,QAAQ,SAAa,OAAO,YAAYA,eAAK,SAAS,OAAO;AAC5F,YAAA,eAAe,aAAa,SAAY,SAAa,OAAO,gBAAgBA,UAAAA,KAAK,UAAU,MAAM;AAEhG,aAAA;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IAAA,CACD;AAAA,EAAA;AAAA,EAEA,MAAc,WAAW,SAA8C;AAChE,UAAA,aAAaA,UAAAA,KAAK,SAAS,gBAAgB;AAC7C,QAAA;AACH,aAAO,MAAM,KAAK,YAAY,SAAS,UAAU;AAAA,aACzC,GAAQ;AACZ,UAAA,EAAE,SAAS,UAAU;AACxB,eAAO,CAAC;AAAA,MAAA;AAEH,YAAA;AAAA,IAAA;AAAA,EACP;AAEF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceResolver.js","sources":["../../../../../../packages/cli/src/lib/workspace/WorkspaceResolver.ts"],"sourcesContent":["import { Workspace } from './Workspace'\nimport { join } from 'node:path'\nimport { YamlHandler } from '../fs/YamlHandler'\n\nexport interface LocalProjectConfig {\n\tapiDir?: string\n\tmigrationsDir?: string\n\tadminDir?: string | false\n\tadminDistDir?: string\n}\n\nexport class WorkspaceResolver {\n\tconstructor(\n\t\tprivate readonly yamlHandler: YamlHandler,\n\t) {\n\t}\n\n\tresolve = async (baseDir: string): Promise<Workspace> => {\n\t\tconst config = await this.readConfig(baseDir)\n\t\tconst apiDir = config.apiDir ?? join(baseDir, 'api')\n\t\tconst migrationsDir = config.migrationsDir ?? join(apiDir, 'migrations')\n\t\tconst adminDir = config.adminDir === false ? undefined : (config.adminDir ?? join(baseDir, 'admin'))\n\t\tconst adminDistDir = adminDir === undefined ? undefined : (config.adminDistDir ?? join(adminDir, 'dist'))\n\n\t\treturn {\n\t\t\tbaseDir,\n\t\t\tapiDir,\n\t\t\tmigrationsDir,\n\t\t\tadminDir,\n\t\t\tadminDistDir,\n\t\t}\n\t}\n\n\tprivate async readConfig(baseDir: string): Promise<LocalProjectConfig> {\n\t\tconst configPath = join(baseDir, 'contember.yaml')\n\t\ttry {\n\t\t\treturn await this.yamlHandler.readYaml(configPath)\n\t\t} catch (e: any) {\n\t\t\tif (e.code === 'ENOENT') {\n\t\t\t\treturn {}\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAWO,MAAM,kBAAkB;AAAA,EAC9B,YACkB,aAChB;AADgB,SAAA,cAAA;AAIlB,kBAAA,MAAA,WAAU,OAAO,YAAwC;AACxD,YAAM,SAAS,MAAM,KAAK,WAAW,OAAO;AAC5C,YAAM,SAAS,OAAO,UAAU,KAAK,SAAS,KAAK;AACnD,YAAM,gBAAgB,OAAO,iBAAiB,KAAK,QAAQ,YAAY;AACjE,YAAA,WAAW,OAAO,aAAa,QAAQ,SAAa,OAAO,YAAY,KAAK,SAAS,OAAO;AAC5F,YAAA,eAAe,aAAa,SAAY,SAAa,OAAO,gBAAgB,KAAK,UAAU,MAAM;AAEhG,aAAA;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,
|
|
1
|
+
{"version":3,"file":"WorkspaceResolver.js","sources":["../../../../../../packages/cli/src/lib/workspace/WorkspaceResolver.ts"],"sourcesContent":["import { Workspace } from './Workspace'\nimport { join } from 'node:path'\nimport { YamlHandler } from '../fs/YamlHandler'\n\nexport interface LocalProjectConfig {\n\tapiDir?: string\n\tmigrationsDir?: string\n\tadminDir?: string | false\n\tadminDistDir?: string\n}\n\nexport class WorkspaceResolver {\n\tconstructor(\n\t\tprivate readonly yamlHandler: YamlHandler,\n\t) {\n\t}\n\n\tresolve = async (baseDir: string): Promise<Workspace> => {\n\t\tconst config = await this.readConfig(baseDir)\n\t\tconst apiDir = config.apiDir ?? join(baseDir, 'api')\n\t\tconst migrationsDir = config.migrationsDir ?? join(apiDir, 'migrations')\n\t\tconst adminDir = config.adminDir === false ? undefined : (config.adminDir ?? join(baseDir, 'admin'))\n\t\tconst adminDistDir = adminDir === undefined ? undefined : (config.adminDistDir ?? join(adminDir, 'dist'))\n\n\t\treturn {\n\t\t\tbaseDir,\n\t\t\tapiDir,\n\t\t\tmigrationsDir,\n\t\t\tadminDir,\n\t\t\tadminDistDir,\n\t\t}\n\t}\n\n\tprivate async readConfig(baseDir: string): Promise<LocalProjectConfig> {\n\t\tconst configPath = join(baseDir, 'contember.yaml')\n\t\ttry {\n\t\t\treturn await this.yamlHandler.readYaml(configPath)\n\t\t} catch (e: any) {\n\t\t\tif (e.code === 'ENOENT') {\n\t\t\t\treturn {}\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAWO,MAAM,kBAAkB;AAAA,EAC9B,YACkB,aAChB;AADgB,SAAA,cAAA;AAIlB,kBAAA,MAAA,WAAU,OAAO,YAAwC;AACxD,YAAM,SAAS,MAAM,KAAK,WAAW,OAAO;AAC5C,YAAM,SAAS,OAAO,UAAU,KAAK,SAAS,KAAK;AACnD,YAAM,gBAAgB,OAAO,iBAAiB,KAAK,QAAQ,YAAY;AACjE,YAAA,WAAW,OAAO,aAAa,QAAQ,SAAa,OAAO,YAAY,KAAK,SAAS,OAAO;AAC5F,YAAA,eAAe,aAAa,SAAY,SAAa,OAAO,gBAAgB,KAAK,UAAU,MAAM;AAEhG,aAAA;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IAAA,CACD;AAAA,EAAA;AAAA,EAEA,MAAc,WAAW,SAA8C;AAChE,UAAA,aAAa,KAAK,SAAS,gBAAgB;AAC7C,QAAA;AACH,aAAO,MAAM,KAAK,YAAY,SAAS,UAAU;AAAA,aACzC,GAAQ;AACZ,UAAA,EAAE,SAAS,UAAU;AACxB,eAAO,CAAC;AAAA,MAAA;AAEH,YAAA;AAAA,IAAA;AAAA,EACP;AAEF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.cjs","sources":["../../../packages/cli/src/run.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { join, resolve } from 'node:path'\nimport { packageRoot } from './consts'\nimport { createContainer } from './dic'\nimport { readCliEnv } from './lib/env'\nimport { WorkspaceResolver } from './lib/workspace/WorkspaceResolver'\nimport { YamlHandler } from './lib/fs/YamlHandler'\nimport { FileSystem } from './lib/fs/FileSystem';\n\n(async () => {\n\t// eslint-disable-next-line @typescript-eslint/no-var-requires\n\tconst version = require(join(packageRoot, 'package.json')).version\n\tconst nodeVersion = process.version.match(/^v?(\\d+)\\..+$/)\n\tif (nodeVersion && Number(nodeVersion[1]) < 18) {\n\t\tthrow `Node >= 18 is required`\n\t}\n\tconst env = readCliEnv()\n\tconst dir = env.dir ? resolve(env.dir) : process.cwd()\n\tconst workspaceResolver = new WorkspaceResolver(new YamlHandler(new FileSystem()))\n\tconst workspace = await workspaceResolver.resolve(dir)\n\tconst dic = createContainer({\n\t\tversion,\n\t\tworkspace,\n\t\tenv: env,\n\t\truntime: process.title === 'bun' ? 'bun' : 'node',\n\t})\n\n\n\tawait dic.application.run(process.argv.slice(2))\n})().catch(e => {\n\tconsole.log(e)\n\tprocess.exit(1)\n})\n"],"names":["join","packageRoot","env","readCliEnv","resolve","WorkspaceResolver","YamlHandler","FileSystem","dic","createContainer"],"mappings":";;;;;;;;;CASC,YAAY;AAEZ,QAAM,UAAU,QAAQA,
|
|
1
|
+
{"version":3,"file":"run.cjs","sources":["../../../packages/cli/src/run.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { join, resolve } from 'node:path'\nimport { packageRoot } from './consts'\nimport { createContainer } from './dic'\nimport { readCliEnv } from './lib/env'\nimport { WorkspaceResolver } from './lib/workspace/WorkspaceResolver'\nimport { YamlHandler } from './lib/fs/YamlHandler'\nimport { FileSystem } from './lib/fs/FileSystem';\n\n(async () => {\n\t// eslint-disable-next-line @typescript-eslint/no-var-requires\n\tconst version = require(join(packageRoot, 'package.json')).version\n\tconst nodeVersion = process.version.match(/^v?(\\d+)\\..+$/)\n\tif (nodeVersion && Number(nodeVersion[1]) < 18) {\n\t\tthrow `Node >= 18 is required`\n\t}\n\tconst env = readCliEnv()\n\tconst dir = env.dir ? resolve(env.dir) : process.cwd()\n\tconst workspaceResolver = new WorkspaceResolver(new YamlHandler(new FileSystem()))\n\tconst workspace = await workspaceResolver.resolve(dir)\n\tconst dic = createContainer({\n\t\tversion,\n\t\tworkspace,\n\t\tenv: env,\n\t\truntime: process.title === 'bun' ? 'bun' : 'node',\n\t})\n\n\n\tawait dic.application.run(process.argv.slice(2))\n})().catch(e => {\n\tconsole.log(e)\n\tprocess.exit(1)\n})\n"],"names":["join","packageRoot","env","readCliEnv","resolve","WorkspaceResolver","YamlHandler","FileSystem","dic","createContainer"],"mappings":";;;;;;;;;CASC,YAAY;AAEZ,QAAM,UAAU,QAAQA,UAAAA,KAAKC,OAAAA,aAAa,cAAc,CAAC,EAAE;AAC3D,QAAM,cAAc,QAAQ,QAAQ,MAAM,eAAe;AACzD,MAAI,eAAe,OAAO,YAAY,CAAC,CAAC,IAAI,IAAI;AACzC,UAAA;AAAA,EAAA;AAEP,QAAMC,QAAMC,IAAAA,WAAW;AACjB,QAAA,MAAMD,MAAI,MAAME,UAAAA,QAAQF,MAAI,GAAG,IAAI,QAAQ,IAAI;AAC/C,QAAA,oBAAoB,IAAIG,kBAAkB,kBAAA,IAAIC,YAAAA,YAAY,IAAIC,WAAA,WAAA,CAAY,CAAC;AACjF,QAAM,YAAY,MAAM,kBAAkB,QAAQ,GAAG;AACrD,QAAMC,QAAMC,IAAAA,gBAAgB;AAAA,IAC3B;AAAA,IACA;AAAA,IAAA,KACAP;AAAAA,IACA,SAAS,QAAQ,UAAU,QAAQ,QAAQ;AAAA,EAAA,CAC3C;AAGD,QAAMM,MAAI,YAAY,IAAI,QAAQ,KAAK,MAAM,CAAC,CAAC;AAChD,KAAK,MAAM,CAAK,MAAA;AACf,UAAQ,IAAI,CAAC;AACb,UAAQ,KAAK,CAAC;AACf,CAAC;"}
|
package/dist/production/run.js
CHANGED
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sources":["../../../packages/cli/src/run.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { join, resolve } from 'node:path'\nimport { packageRoot } from './consts'\nimport { createContainer } from './dic'\nimport { readCliEnv } from './lib/env'\nimport { WorkspaceResolver } from './lib/workspace/WorkspaceResolver'\nimport { YamlHandler } from './lib/fs/YamlHandler'\nimport { FileSystem } from './lib/fs/FileSystem';\n\n(async () => {\n\t// eslint-disable-next-line @typescript-eslint/no-var-requires\n\tconst version = require(join(packageRoot, 'package.json')).version\n\tconst nodeVersion = process.version.match(/^v?(\\d+)\\..+$/)\n\tif (nodeVersion && Number(nodeVersion[1]) < 18) {\n\t\tthrow `Node >= 18 is required`\n\t}\n\tconst env = readCliEnv()\n\tconst dir = env.dir ? resolve(env.dir) : process.cwd()\n\tconst workspaceResolver = new WorkspaceResolver(new YamlHandler(new FileSystem()))\n\tconst workspace = await workspaceResolver.resolve(dir)\n\tconst dic = createContainer({\n\t\tversion,\n\t\tworkspace,\n\t\tenv: env,\n\t\truntime: process.title === 'bun' ? 'bun' : 'node',\n\t})\n\n\n\tawait dic.application.run(process.argv.slice(2))\n})().catch(e => {\n\tconsole.log(e)\n\tprocess.exit(1)\n})\n"],"names":[],"mappings":";;;;;;;;CASC,YAAY;AAEZ,QAAM,UAAU,QAAQ,KAAK,aAAa,cAAc,CAAC,EAAE;AAC3D,QAAM,cAAc,QAAQ,QAAQ,MAAM,eAAe;AACzD,MAAI,eAAe,OAAO,YAAY,CAAC,CAAC,IAAI,IAAI;AACzC,UAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"run.js","sources":["../../../packages/cli/src/run.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { join, resolve } from 'node:path'\nimport { packageRoot } from './consts'\nimport { createContainer } from './dic'\nimport { readCliEnv } from './lib/env'\nimport { WorkspaceResolver } from './lib/workspace/WorkspaceResolver'\nimport { YamlHandler } from './lib/fs/YamlHandler'\nimport { FileSystem } from './lib/fs/FileSystem';\n\n(async () => {\n\t// eslint-disable-next-line @typescript-eslint/no-var-requires\n\tconst version = require(join(packageRoot, 'package.json')).version\n\tconst nodeVersion = process.version.match(/^v?(\\d+)\\..+$/)\n\tif (nodeVersion && Number(nodeVersion[1]) < 18) {\n\t\tthrow `Node >= 18 is required`\n\t}\n\tconst env = readCliEnv()\n\tconst dir = env.dir ? resolve(env.dir) : process.cwd()\n\tconst workspaceResolver = new WorkspaceResolver(new YamlHandler(new FileSystem()))\n\tconst workspace = await workspaceResolver.resolve(dir)\n\tconst dic = createContainer({\n\t\tversion,\n\t\tworkspace,\n\t\tenv: env,\n\t\truntime: process.title === 'bun' ? 'bun' : 'node',\n\t})\n\n\n\tawait dic.application.run(process.argv.slice(2))\n})().catch(e => {\n\tconsole.log(e)\n\tprocess.exit(1)\n})\n"],"names":[],"mappings":";;;;;;;;CASC,YAAY;AAEZ,QAAM,UAAU,QAAQ,KAAK,aAAa,cAAc,CAAC,EAAE;AAC3D,QAAM,cAAc,QAAQ,QAAQ,MAAM,eAAe;AACzD,MAAI,eAAe,OAAO,YAAY,CAAC,CAAC,IAAI,IAAI;AACzC,UAAA;AAAA,EAAA;AAEP,QAAM,MAAM,WAAW;AACjB,QAAA,MAAM,IAAI,MAAM,QAAQ,IAAI,GAAG,IAAI,QAAQ,IAAI;AAC/C,QAAA,oBAAoB,IAAI,kBAAkB,IAAI,YAAY,IAAI,WAAA,CAAY,CAAC;AACjF,QAAM,YAAY,MAAM,kBAAkB,QAAQ,GAAG;AACrD,QAAM,MAAM,gBAAgB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,QAAQ,UAAU,QAAQ,QAAQ;AAAA,EAAA,CAC3C;AAGD,QAAM,IAAI,YAAY,IAAI,QAAQ,KAAK,MAAM,CAAC,CAAC;AAChD,KAAK,MAAM,CAAK,MAAA;AACf,UAAQ,IAAI,CAAC;AACb,UAAQ,KAAK,CAAC;AACf,CAAC;"}
|
|
@@ -24,21 +24,21 @@ class DeployCommand extends cliCommon.Command {
|
|
|
24
24
|
}
|
|
25
25
|
async execute(input) {
|
|
26
26
|
const dsn = input.getArgument("dsn");
|
|
27
|
-
const
|
|
27
|
+
const adminEndpoint = input.getOption("admin");
|
|
28
|
+
const remoteProject = this.remoteProjectResolver.resolve(dsn, adminEndpoint);
|
|
28
29
|
if (!remoteProject) {
|
|
29
30
|
throw `Project not defined. Please provide DSN or environment variables CONTEMBER_*`;
|
|
30
31
|
}
|
|
31
32
|
this.remoteProjectProvider.setRemoteProject(remoteProject);
|
|
32
|
-
let adminEndpoint = input.getOption("admin");
|
|
33
33
|
const deployMigration = input.getOption("no-migrations") !== true;
|
|
34
34
|
const yes = input.getOption("yes") === true;
|
|
35
35
|
const projectAdminDistDir = this.workspace.adminDistDir;
|
|
36
|
-
const deployAdmin = input.getOption("no-admin") !== true && !!adminEndpoint && !!projectAdminDistDir;
|
|
36
|
+
const deployAdmin = input.getOption("no-admin") !== true && !!remoteProject.adminEndpoint && !!projectAdminDistDir;
|
|
37
37
|
console.log("");
|
|
38
38
|
console.log("Contember project deployment configuration:");
|
|
39
39
|
console.log(`Target project name: ${remoteProject.name}`);
|
|
40
40
|
console.log(`API URL: ${remoteProject.endpoint}`);
|
|
41
|
-
console.log(`Admin URL: ${adminEndpoint ?? "none"}`);
|
|
41
|
+
console.log(`Admin URL: ${remoteProject.adminEndpoint ?? "none"}`);
|
|
42
42
|
console.log(`Deploy token: ${maskToken.maskToken(remoteProject.token)}`);
|
|
43
43
|
console.log("");
|
|
44
44
|
if (deployAdmin && !await this.fs.pathExists(`${projectAdminDistDir}/index.html`)) {
|
|
@@ -79,7 +79,7 @@ class DeployCommand extends cliCommon.Command {
|
|
|
79
79
|
console.log("");
|
|
80
80
|
console.log("Deployment successful");
|
|
81
81
|
console.log(`API URL: ${remoteProject.endpoint}`);
|
|
82
|
-
console.log(`Admin URL: ${adminEndpoint ?? "none"}`);
|
|
82
|
+
console.log(`Admin URL: ${remoteProject.adminEndpoint ?? "none"}`);
|
|
83
83
|
return 0;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeployCommand.cjs","sources":["../../../../../../packages/cli/src/commands/deploy/DeployCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport prompts from 'prompts'\nimport { maskToken } from '../../lib/maskToken'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\nimport { AdminDeployer } from '../../lib/admin/AdminDeployer'\nimport { FileSystem } from '../../lib/fs/FileSystem'\nimport { RemoteProject } from '../../lib/project/RemoteProject'\nimport { Workspace } from '../../lib/workspace/Workspace'\nimport { RemoteProjectProvider } from '../../lib/project/RemoteProjectProvider'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\n\ntype Args = {\n\tdsn: string\n}\n\ntype Options = {\n\tadmin?: string\n\t['no-admin']?: boolean\n\t['no-migrations']?: boolean\n\troot?: boolean\n\tyes?: boolean\n}\n\nexport class DeployCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly adminDeployer: AdminDeployer,\n\t\tprivate readonly migrationExecutionFacade: MigrationExecutionFacade,\n\t\tprivate readonly fs: FileSystem,\n\t\tprivate readonly remoteProjectProvider: RemoteProjectProvider,\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t\tprivate readonly workspace: Workspace,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Deploy Contember project')\n\t\tconfiguration.argument('dsn')\n\n\t\tconfiguration.option('admin').valueRequired()\n\t\tconfiguration.option('root').valueNone()\n\t\tconfiguration.option('no-admin').valueNone()\n\t\tconfiguration.option('no-migrations').valueNone()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\n\t\tconst dsn = input.getArgument('dsn')\n\t\tconst remoteProject = this.remoteProjectResolver.resolve(dsn)\n\t\tif (!remoteProject) {\n\t\t\tthrow `Project not defined. Please provide DSN or environment variables CONTEMBER_*`\n\t\t}\n\t\tthis.remoteProjectProvider.setRemoteProject(remoteProject)\n\n\t\
|
|
1
|
+
{"version":3,"file":"DeployCommand.cjs","sources":["../../../../../../packages/cli/src/commands/deploy/DeployCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport prompts from 'prompts'\nimport { maskToken } from '../../lib/maskToken'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\nimport { AdminDeployer } from '../../lib/admin/AdminDeployer'\nimport { FileSystem } from '../../lib/fs/FileSystem'\nimport { RemoteProject } from '../../lib/project/RemoteProject'\nimport { Workspace } from '../../lib/workspace/Workspace'\nimport { RemoteProjectProvider } from '../../lib/project/RemoteProjectProvider'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\n\ntype Args = {\n\tdsn: string\n}\n\ntype Options = {\n\tadmin?: string\n\t['no-admin']?: boolean\n\t['no-migrations']?: boolean\n\troot?: boolean\n\tyes?: boolean\n}\n\nexport class DeployCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly adminDeployer: AdminDeployer,\n\t\tprivate readonly migrationExecutionFacade: MigrationExecutionFacade,\n\t\tprivate readonly fs: FileSystem,\n\t\tprivate readonly remoteProjectProvider: RemoteProjectProvider,\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t\tprivate readonly workspace: Workspace,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Deploy Contember project')\n\t\tconfiguration.argument('dsn')\n\n\t\tconfiguration.option('admin').valueRequired()\n\t\tconfiguration.option('root').valueNone()\n\t\tconfiguration.option('no-admin').valueNone()\n\t\tconfiguration.option('no-migrations').valueNone()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\n\t\tconst dsn = input.getArgument('dsn')\n\t\tconst adminEndpoint = input.getOption('admin')\n\t\tconst remoteProject = this.remoteProjectResolver.resolve(dsn, adminEndpoint)\n\t\tif (!remoteProject) {\n\t\t\tthrow `Project not defined. Please provide DSN or environment variables CONTEMBER_*`\n\t\t}\n\t\tthis.remoteProjectProvider.setRemoteProject(remoteProject)\n\n\t\tconst deployMigration = input.getOption('no-migrations') !== true\n\t\tconst yes = input.getOption('yes') === true\n\t\tconst projectAdminDistDir = this.workspace.adminDistDir\n\n\t\tconst deployAdmin = input.getOption('no-admin') !== true && !!remoteProject.adminEndpoint && !!projectAdminDistDir\n\n\n\t\tconsole.log('')\n\t\tconsole.log('Contember project deployment configuration:')\n\t\tconsole.log(`Target project name: ${remoteProject.name}`)\n\t\tconsole.log(`API URL: ${remoteProject.endpoint}`)\n\t\tconsole.log(`Admin URL: ${remoteProject.adminEndpoint ?? 'none'}`)\n\t\tconsole.log(`Deploy token: ${maskToken(remoteProject.token)}`)\n\t\tconsole.log('')\n\n\n\t\tif (deployAdmin && !(await this.fs.pathExists(`${projectAdminDistDir}/index.html`))) {\n\t\t\tthrow `Missing ${projectAdminDistDir}/index.html. Please build admin before deploying.`\n\t\t}\n\n\t\tif (deployMigration) {\n\t\t\tconst result = await this.migrationExecutionFacade.execute({\n\t\t\t\tforce: false,\n\t\t\t\trequireConfirmation: !yes,\n\t\t\t\tadditionalMessage: deployAdmin ? 'Admin will be deployed.' : 'Admin will NOT be deployed.',\n\t\t\t})\n\t\t\tif (!result) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (deployAdmin) {\n\t\t\tif (!deployMigration && !yes) {\n\t\t\t\tif (!process.stdin.isTTY) {\n\t\t\t\t\tthrow 'TTY not available. Pass --yes option to confirm execution.'\n\t\t\t\t}\n\t\t\t\tconsole.log('Admin will be deployed.')\n\t\t\t\tconsole.log('(to skip this dialog, you can pass --yes option)')\n\t\t\t\tconsole.log('')\n\t\t\t\tconst { ok } = await prompts({\n\t\t\t\t\ttype: 'confirm',\n\t\t\t\t\tname: 'ok',\n\t\t\t\t\tmessage: `Do you want to continue?`,\n\t\t\t\t})\n\t\t\t\tif (!ok) {\n\t\t\t\t\treturn 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait this.adminDeployer.deploy({\n\t\t\t\tdir: projectAdminDistDir,\n\t\t\t\troot: input.getOption('root') === true,\n\t\t\t})\n\t\t}\n\n\t\tconsole.log('')\n\t\tconsole.log('Deployment successful')\n\t\tconsole.log(`API URL: ${remoteProject.endpoint}`)\n\t\tconsole.log(`Admin URL: ${remoteProject.adminEndpoint ?? 'none'}`)\n\n\t\treturn 0\n\t}\n}\n"],"names":["Command","maskToken"],"mappings":";;;;;AAuBO,MAAM,sBAAsBA,UAAAA,QAAuB;AAAA,EACzD,YACkB,eACA,0BACA,IACA,uBACA,uBACA,WAChB;AACK,UAAA;AAPW,SAAA,gBAAA;AACA,SAAA,2BAAA;AACA,SAAA,KAAA;AACA,SAAA,wBAAA;AACA,SAAA,wBAAA;AACA,SAAA,YAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,0BAA0B;AACpD,kBAAc,SAAS,KAAK;AAEd,kBAAA,OAAO,OAAO,EAAE,cAAc;AAC9B,kBAAA,OAAO,MAAM,EAAE,UA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AAI,aAAa;AACZ,UAAA,CAAC,mBAAmB,CAAC,KAAK;AACzB,YAAA,CAAC,QAAQ,MAAM,OAAO;AACnB,gBAAA;AAAA,QAAA;AAEP,gBAAQ,IAAI,yBAAyB;AACrC,gBAAQ,IAAI,kDAAkD;AAC9D,gBAAQ,IAAI,EAAE;AACd,cAAM,EAAE,OAAO,MAAM,QAAQ;AAAA,UAC5B,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,QAAA,CACT;AACD,YAAI,CAAC,IAAI;AACD,iBAAA;AAAA,QAAA;AAAA,MACR;AAEK,YAAA,KAAK,cAAc,OAAO;AAAA,QAC/B,KAAK;AAAA,QACL,MAAM,MAAM,UAAU,MAAM,MAAM;AAAA,MAAA,CAClC;AAAA,IAAA;AAGF,YAAQ,IAAI,EAAE;AACd,YAAQ,IAAI,uBAAuB;AACnC,YAAQ,IAAI,YAAY,cAAc,QAAQ,EAAE;AAChD,YAAQ,IAAI,cAAc,cAAc,iBAAiB,MAAM,EAAE;AAE1D,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -22,21 +22,21 @@ class DeployCommand extends Command {
|
|
|
22
22
|
}
|
|
23
23
|
async execute(input) {
|
|
24
24
|
const dsn = input.getArgument("dsn");
|
|
25
|
-
const
|
|
25
|
+
const adminEndpoint = input.getOption("admin");
|
|
26
|
+
const remoteProject = this.remoteProjectResolver.resolve(dsn, adminEndpoint);
|
|
26
27
|
if (!remoteProject) {
|
|
27
28
|
throw `Project not defined. Please provide DSN or environment variables CONTEMBER_*`;
|
|
28
29
|
}
|
|
29
30
|
this.remoteProjectProvider.setRemoteProject(remoteProject);
|
|
30
|
-
let adminEndpoint = input.getOption("admin");
|
|
31
31
|
const deployMigration = input.getOption("no-migrations") !== true;
|
|
32
32
|
const yes = input.getOption("yes") === true;
|
|
33
33
|
const projectAdminDistDir = this.workspace.adminDistDir;
|
|
34
|
-
const deployAdmin = input.getOption("no-admin") !== true && !!adminEndpoint && !!projectAdminDistDir;
|
|
34
|
+
const deployAdmin = input.getOption("no-admin") !== true && !!remoteProject.adminEndpoint && !!projectAdminDistDir;
|
|
35
35
|
console.log("");
|
|
36
36
|
console.log("Contember project deployment configuration:");
|
|
37
37
|
console.log(`Target project name: ${remoteProject.name}`);
|
|
38
38
|
console.log(`API URL: ${remoteProject.endpoint}`);
|
|
39
|
-
console.log(`Admin URL: ${adminEndpoint ?? "none"}`);
|
|
39
|
+
console.log(`Admin URL: ${remoteProject.adminEndpoint ?? "none"}`);
|
|
40
40
|
console.log(`Deploy token: ${maskToken(remoteProject.token)}`);
|
|
41
41
|
console.log("");
|
|
42
42
|
if (deployAdmin && !await this.fs.pathExists(`${projectAdminDistDir}/index.html`)) {
|
|
@@ -77,7 +77,7 @@ class DeployCommand extends Command {
|
|
|
77
77
|
console.log("");
|
|
78
78
|
console.log("Deployment successful");
|
|
79
79
|
console.log(`API URL: ${remoteProject.endpoint}`);
|
|
80
|
-
console.log(`Admin URL: ${adminEndpoint ?? "none"}`);
|
|
80
|
+
console.log(`Admin URL: ${remoteProject.adminEndpoint ?? "none"}`);
|
|
81
81
|
return 0;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeployCommand.js","sources":["../../../../../../packages/cli/src/commands/deploy/DeployCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport prompts from 'prompts'\nimport { maskToken } from '../../lib/maskToken'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\nimport { AdminDeployer } from '../../lib/admin/AdminDeployer'\nimport { FileSystem } from '../../lib/fs/FileSystem'\nimport { RemoteProject } from '../../lib/project/RemoteProject'\nimport { Workspace } from '../../lib/workspace/Workspace'\nimport { RemoteProjectProvider } from '../../lib/project/RemoteProjectProvider'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\n\ntype Args = {\n\tdsn: string\n}\n\ntype Options = {\n\tadmin?: string\n\t['no-admin']?: boolean\n\t['no-migrations']?: boolean\n\troot?: boolean\n\tyes?: boolean\n}\n\nexport class DeployCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly adminDeployer: AdminDeployer,\n\t\tprivate readonly migrationExecutionFacade: MigrationExecutionFacade,\n\t\tprivate readonly fs: FileSystem,\n\t\tprivate readonly remoteProjectProvider: RemoteProjectProvider,\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t\tprivate readonly workspace: Workspace,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Deploy Contember project')\n\t\tconfiguration.argument('dsn')\n\n\t\tconfiguration.option('admin').valueRequired()\n\t\tconfiguration.option('root').valueNone()\n\t\tconfiguration.option('no-admin').valueNone()\n\t\tconfiguration.option('no-migrations').valueNone()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\n\t\tconst dsn = input.getArgument('dsn')\n\t\tconst remoteProject = this.remoteProjectResolver.resolve(dsn)\n\t\tif (!remoteProject) {\n\t\t\tthrow `Project not defined. Please provide DSN or environment variables CONTEMBER_*`\n\t\t}\n\t\tthis.remoteProjectProvider.setRemoteProject(remoteProject)\n\n\t\
|
|
1
|
+
{"version":3,"file":"DeployCommand.js","sources":["../../../../../../packages/cli/src/commands/deploy/DeployCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport prompts from 'prompts'\nimport { maskToken } from '../../lib/maskToken'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\nimport { AdminDeployer } from '../../lib/admin/AdminDeployer'\nimport { FileSystem } from '../../lib/fs/FileSystem'\nimport { RemoteProject } from '../../lib/project/RemoteProject'\nimport { Workspace } from '../../lib/workspace/Workspace'\nimport { RemoteProjectProvider } from '../../lib/project/RemoteProjectProvider'\nimport { RemoteProjectResolver } from '../../lib/project/RemoteProjectResolver'\n\ntype Args = {\n\tdsn: string\n}\n\ntype Options = {\n\tadmin?: string\n\t['no-admin']?: boolean\n\t['no-migrations']?: boolean\n\troot?: boolean\n\tyes?: boolean\n}\n\nexport class DeployCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly adminDeployer: AdminDeployer,\n\t\tprivate readonly migrationExecutionFacade: MigrationExecutionFacade,\n\t\tprivate readonly fs: FileSystem,\n\t\tprivate readonly remoteProjectProvider: RemoteProjectProvider,\n\t\tprivate readonly remoteProjectResolver: RemoteProjectResolver,\n\t\tprivate readonly workspace: Workspace,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Deploy Contember project')\n\t\tconfiguration.argument('dsn')\n\n\t\tconfiguration.option('admin').valueRequired()\n\t\tconfiguration.option('root').valueNone()\n\t\tconfiguration.option('no-admin').valueNone()\n\t\tconfiguration.option('no-migrations').valueNone()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void | number> {\n\n\t\tconst dsn = input.getArgument('dsn')\n\t\tconst adminEndpoint = input.getOption('admin')\n\t\tconst remoteProject = this.remoteProjectResolver.resolve(dsn, adminEndpoint)\n\t\tif (!remoteProject) {\n\t\t\tthrow `Project not defined. Please provide DSN or environment variables CONTEMBER_*`\n\t\t}\n\t\tthis.remoteProjectProvider.setRemoteProject(remoteProject)\n\n\t\tconst deployMigration = input.getOption('no-migrations') !== true\n\t\tconst yes = input.getOption('yes') === true\n\t\tconst projectAdminDistDir = this.workspace.adminDistDir\n\n\t\tconst deployAdmin = input.getOption('no-admin') !== true && !!remoteProject.adminEndpoint && !!projectAdminDistDir\n\n\n\t\tconsole.log('')\n\t\tconsole.log('Contember project deployment configuration:')\n\t\tconsole.log(`Target project name: ${remoteProject.name}`)\n\t\tconsole.log(`API URL: ${remoteProject.endpoint}`)\n\t\tconsole.log(`Admin URL: ${remoteProject.adminEndpoint ?? 'none'}`)\n\t\tconsole.log(`Deploy token: ${maskToken(remoteProject.token)}`)\n\t\tconsole.log('')\n\n\n\t\tif (deployAdmin && !(await this.fs.pathExists(`${projectAdminDistDir}/index.html`))) {\n\t\t\tthrow `Missing ${projectAdminDistDir}/index.html. Please build admin before deploying.`\n\t\t}\n\n\t\tif (deployMigration) {\n\t\t\tconst result = await this.migrationExecutionFacade.execute({\n\t\t\t\tforce: false,\n\t\t\t\trequireConfirmation: !yes,\n\t\t\t\tadditionalMessage: deployAdmin ? 'Admin will be deployed.' : 'Admin will NOT be deployed.',\n\t\t\t})\n\t\t\tif (!result) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (deployAdmin) {\n\t\t\tif (!deployMigration && !yes) {\n\t\t\t\tif (!process.stdin.isTTY) {\n\t\t\t\t\tthrow 'TTY not available. Pass --yes option to confirm execution.'\n\t\t\t\t}\n\t\t\t\tconsole.log('Admin will be deployed.')\n\t\t\t\tconsole.log('(to skip this dialog, you can pass --yes option)')\n\t\t\t\tconsole.log('')\n\t\t\t\tconst { ok } = await prompts({\n\t\t\t\t\ttype: 'confirm',\n\t\t\t\t\tname: 'ok',\n\t\t\t\t\tmessage: `Do you want to continue?`,\n\t\t\t\t})\n\t\t\t\tif (!ok) {\n\t\t\t\t\treturn 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait this.adminDeployer.deploy({\n\t\t\t\tdir: projectAdminDistDir,\n\t\t\t\troot: input.getOption('root') === true,\n\t\t\t})\n\t\t}\n\n\t\tconsole.log('')\n\t\tconsole.log('Deployment successful')\n\t\tconsole.log(`API URL: ${remoteProject.endpoint}`)\n\t\tconsole.log(`Admin URL: ${remoteProject.adminEndpoint ?? 'none'}`)\n\n\t\treturn 0\n\t}\n}\n"],"names":[],"mappings":";;;AAuBO,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I,EAAE;AAGV,QAAA,eAAe,CAAE,MAAM,KAAK,GAAG,WAAW,GAAG,mBAAmB,aAAa,GAAI;AACpF,YAAM,WAAW,mBAAmB;AAAA,IAAA;AAGrC,QAAI,iBAAiB;AACpB,YAAM,SAAS,MAAM,KAAK,yBAAyB,QAAQ;AAAA,QAC1D,OAAO;AAAA,QACP,qBAAqB,CAAC;AAAA,QACtB,mBAAmB,cAAc,4BAA4B;AAAA,MAAA,CAC7D;AACD,UAAI,CAAC,QAAQ;AACZ;AAAA,MAAA;AAAA,IACD;AAGD,QAAI,aAAa;AACZ,UAAA,CAAC,mBAAmB,CAAC,KAAK;AACzB,YAAA,CAAC,QAAQ,MAAM,OAAO;AACnB,gBAAA;AAAA,QAAA;AAEP,gBAAQ,IAAI,yBAAyB;AACrC,gBAAQ,IAAI,kDAAkD;AAC9D,gBAAQ,IAAI,EAAE;AACd,cAAM,EAAE,OAAO,MAAM,QAAQ;AAAA,UAC5B,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,QAAA,CACT;AACD,YAAI,CAAC,IAAI;AACD,iBAAA;AAAA,QAAA;AAAA,MACR;AAEK,YAAA,KAAK,cAAc,OAAO;AAAA,QAC/B,KAAK;AAAA,QACL,MAAM,MAAM,UAAU,MAAM,MAAM;AAAA,MAAA,CAClC;AAAA,IAAA;AAGF,YAAQ,IAAI,EAAE;AACd,YAAQ,IAAI,uBAAuB;AACnC,YAAQ,IAAI,YAAY,cAAc,QAAQ,EAAE;AAChD,YAAQ,IAAI,cAAc,cAAc,iBAAiB,MAAM,EAAE;AAE1D,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -79,7 +79,7 @@ class MigrationAmendCommand extends cliCommon.Command {
|
|
|
79
79
|
const systemClient = this.systemApiClientProvider.get();
|
|
80
80
|
await systemClient.migrate([intermediateResult.migration], force);
|
|
81
81
|
await systemClient.migrationDelete(intermediateResult.migration.version);
|
|
82
|
-
if (!newMigrationResult) {
|
|
82
|
+
if (!newMigrationResult && await this.shouldRemove()) {
|
|
83
83
|
await this.migrationCreator.removeMigration(amendMigration.name);
|
|
84
84
|
await systemClient.migrationDelete(amendMigration.version);
|
|
85
85
|
console.log("Latest migration was removed");
|
|
@@ -88,8 +88,8 @@ class MigrationAmendCommand extends cliCommon.Command {
|
|
|
88
88
|
const newMigration = {
|
|
89
89
|
name: amendMigration.name,
|
|
90
90
|
version: amendMigration.version,
|
|
91
|
-
formatVersion: newMigrationResult
|
|
92
|
-
modifications: newMigrationResult
|
|
91
|
+
formatVersion: newMigrationResult?.migration.formatVersion ?? amendMigration.formatVersion,
|
|
92
|
+
modifications: newMigrationResult?.migration.modifications ?? []
|
|
93
93
|
};
|
|
94
94
|
await this.migrationCreator.saveMigration(newMigration);
|
|
95
95
|
await systemClient.migrationModify(amendMigration.version, newMigration);
|
|
@@ -118,6 +118,18 @@ class MigrationAmendCommand extends cliCommon.Command {
|
|
|
118
118
|
});
|
|
119
119
|
return action === "yes";
|
|
120
120
|
}
|
|
121
|
+
async shouldRemove() {
|
|
122
|
+
const { action } = await prompts({
|
|
123
|
+
type: "select",
|
|
124
|
+
name: "action",
|
|
125
|
+
message: "The amendment results in a no-op migration because the changes introduced by the latest migration were reverted.\nYou can choose to remove the latest migration or to modify it so it is empty.",
|
|
126
|
+
choices: [
|
|
127
|
+
{ value: "remove", title: "Remove latest migration" },
|
|
128
|
+
{ value: "keep", title: "Keep latest migration and make it empty" }
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
return action === "remove";
|
|
132
|
+
}
|
|
121
133
|
}
|
|
122
134
|
exports.MigrationAmendCommand = MigrationAmendCommand;
|
|
123
135
|
//# sourceMappingURL=MigrationAmendCommand.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationAmendCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationAmendCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException, SchemaMigrator } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { emptySchema } from '@contember/schema-utils'\nimport { MigrationCreator, MigrationsResolver, SchemaVersionBuilder, SystemClient } from '@contember/migrations-client'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationsValidator } from '../../lib/migrations/MigrationsValidator'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\tyes?: true\n\tforce: boolean\n}\n\nexport class MigrationAmendCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly systemApiClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationsValidator: MigrationsValidator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Amends latest migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('force').description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migration')\n\t\tconst amendMigration = migrationName\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\t\tif (!amendMigration) {\n\t\t\tthrow 'No migration to amend'\n\t\t}\n\t\tconst force = input.getOption('force')\n\t\tconst status = await this.migrationsStatusFacade.resolveMigrationsStatus({ force })\n\t\tif (status.migrationsToExecute.length > 0) {\n\t\t\tthrow `Some migrations are not executed. Unable to amend.`\n\t\t}\n\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst intermediateResult = await this.migrationCreator.prepareMigration(initialSchema, schema, '')\n\t\t\tif (intermediateResult === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tif (amendMigration.formatVersion !== intermediateResult.migration.formatVersion) {\n\t\t\t\tthrow 'Incompatible migration format version'\n\t\t\t}\n\t\t\tconst prevSchema = await this.schemaVersionBuilder.buildSchemaAdvanced(\n\t\t\t\temptySchema,\n\t\t\t\tversion => version < amendMigration.version,\n\t\t\t)\n\t\t\tconst newSchema = await this.schemaMigrator.applyModifications(\n\t\t\t\tprevSchema,\n\t\t\t\t[...amendMigration.modifications, ...intermediateResult.migration.modifications],\n\t\t\t\tamendMigration.formatVersion,\n\t\t\t)\n\t\t\tconst newMigrationResult = await this.migrationCreator.prepareMigration(prevSchema, newSchema, '')\n\t\t\tconst followingMigrations = (await this.migrationsResolver.getSchemaMigrations()).filter(\n\t\t\t\tit => it.version > amendMigration.version,\n\t\t\t)\n\n\t\t\tconst valid = await this.migrationsValidator.validate(\n\t\t\t\tprevSchema,\n\t\t\t\t[...(newMigrationResult ? [newMigrationResult.migration] : []), ...followingMigrations],\n\t\t\t)\n\t\t\tif (!valid) {\n\t\t\t\tthrow `Cannot amend migration`\n\t\t\t}\n\n\t\t\tthis.migrationPrinter.printMigrationDescription(\n\t\t\t\tintermediateResult.initialSchema,\n\t\t\t\tintermediateResult.migration,\n\t\t\t\t{ noSql: true },\n\t\t\t)\n\t\t\tconsole.log(`Amending ${amendMigration.name}`)\n\t\t\tif (!(await this.shouldContinue(input))) {\n\t\t\t\tconsole.log('Aborting')\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tconst systemClient = this.systemApiClientProvider.get()\n\t\t\tawait systemClient.migrate([intermediateResult.migration], force)\n\t\t\tawait systemClient.migrationDelete(intermediateResult.migration.version)\n\n\t\t\tif (!newMigrationResult) {\n\t\t\t\tawait this.migrationCreator.removeMigration(amendMigration.name)\n\t\t\t\tawait systemClient.migrationDelete(amendMigration.version)\n\t\t\t\tconsole.log('Latest migration was removed')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tconst newMigration = {\n\t\t\t\tname: amendMigration.name,\n\t\t\t\tversion: amendMigration.version,\n\t\t\t\tformatVersion: newMigrationResult
|
|
1
|
+
{"version":3,"file":"MigrationAmendCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationAmendCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException, SchemaMigrator } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { emptySchema } from '@contember/schema-utils'\nimport { MigrationCreator, MigrationsResolver, SchemaVersionBuilder, SystemClient } from '@contember/migrations-client'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationsValidator } from '../../lib/migrations/MigrationsValidator'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\tyes?: true\n\tforce: boolean\n}\n\nexport class MigrationAmendCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly systemApiClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationsValidator: MigrationsValidator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Amends latest migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('force').description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migration')\n\t\tconst amendMigration = migrationName\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\t\tif (!amendMigration) {\n\t\t\tthrow 'No migration to amend'\n\t\t}\n\t\tconst force = input.getOption('force')\n\t\tconst status = await this.migrationsStatusFacade.resolveMigrationsStatus({ force })\n\t\tif (status.migrationsToExecute.length > 0) {\n\t\t\tthrow `Some migrations are not executed. Unable to amend.`\n\t\t}\n\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst intermediateResult = await this.migrationCreator.prepareMigration(initialSchema, schema, '')\n\t\t\tif (intermediateResult === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tif (amendMigration.formatVersion !== intermediateResult.migration.formatVersion) {\n\t\t\t\tthrow 'Incompatible migration format version'\n\t\t\t}\n\t\t\tconst prevSchema = await this.schemaVersionBuilder.buildSchemaAdvanced(\n\t\t\t\temptySchema,\n\t\t\t\tversion => version < amendMigration.version,\n\t\t\t)\n\t\t\tconst newSchema = await this.schemaMigrator.applyModifications(\n\t\t\t\tprevSchema,\n\t\t\t\t[...amendMigration.modifications, ...intermediateResult.migration.modifications],\n\t\t\t\tamendMigration.formatVersion,\n\t\t\t)\n\t\t\tconst newMigrationResult = await this.migrationCreator.prepareMigration(prevSchema, newSchema, '')\n\t\t\tconst followingMigrations = (await this.migrationsResolver.getSchemaMigrations()).filter(\n\t\t\t\tit => it.version > amendMigration.version,\n\t\t\t)\n\n\t\t\tconst valid = await this.migrationsValidator.validate(\n\t\t\t\tprevSchema,\n\t\t\t\t[...(newMigrationResult ? [newMigrationResult.migration] : []), ...followingMigrations],\n\t\t\t)\n\t\t\tif (!valid) {\n\t\t\t\tthrow `Cannot amend migration`\n\t\t\t}\n\n\t\t\tthis.migrationPrinter.printMigrationDescription(\n\t\t\t\tintermediateResult.initialSchema,\n\t\t\t\tintermediateResult.migration,\n\t\t\t\t{ noSql: true },\n\t\t\t)\n\t\t\tconsole.log(`Amending ${amendMigration.name}`)\n\t\t\tif (!(await this.shouldContinue(input))) {\n\t\t\t\tconsole.log('Aborting')\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tconst systemClient = this.systemApiClientProvider.get()\n\t\t\tawait systemClient.migrate([intermediateResult.migration], force)\n\t\t\tawait systemClient.migrationDelete(intermediateResult.migration.version)\n\n\t\t\tif (!newMigrationResult && await this.shouldRemove()) {\n\t\t\t\tawait this.migrationCreator.removeMigration(amendMigration.name)\n\t\t\t\tawait systemClient.migrationDelete(amendMigration.version)\n\t\t\t\tconsole.log('Latest migration was removed')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tconst newMigration = {\n\t\t\t\tname: amendMigration.name,\n\t\t\t\tversion: amendMigration.version,\n\t\t\t\tformatVersion: newMigrationResult?.migration.formatVersion ?? amendMigration.formatVersion,\n\t\t\t\tmodifications: newMigrationResult?.migration.modifications ?? [],\n\t\t\t}\n\t\t\tawait this.migrationCreator.saveMigration(newMigration)\n\t\t\tawait systemClient.migrationModify(amendMigration.version, newMigration)\n\n\t\t\treturn 0\n\t\t} catch (e) {\n\t\t\tif (e instanceof InvalidSchemaException) {\n\t\t\t\tprintValidationErrors(e.validationErrors, e.message)\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n\n\tprivate async shouldContinue(input: Input<{}, { yes?: true }>): Promise<boolean> {\n\t\tconst yes = input.getOption('yes')\n\t\tif (yes) {\n\t\t\treturn true\n\t\t}\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage: 'Do you want to continue?',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'yes', title: 'Yes' },\n\t\t\t\t{ value: 'no', title: 'Abort' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'yes'\n\t}\n\n\tprivate async shouldRemove(): Promise<boolean> {\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage: 'The amendment results in a no-op migration because the changes introduced by the latest migration were reverted.\\nYou can choose to remove the latest migration or to modify it so it is empty.',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'remove', title: 'Remove latest migration' },\n\t\t\t\t{ value: 'keep', title: 'Keep latest migration and make it empty' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'remove'\n\t}\n}\n"],"names":["Command","emptySchema","InvalidSchemaException","printValidationErrors"],"mappings":";;;;;;;AAqBO,MAAM,8BAA8BA,UAAAA,QAAuB;AAAA,EACjE,YACkB,oBACA,yBACA,wBACA,cACA,sBACA,kBACA,qBACA,kBACA,gBAChB;AACK,UAAA;AAVW,SAAA,qBAAA;AACA,SAAA,0BAAA;AACA,SAAA,yBAAA;AACA,SAAA,eAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AACA,SAAA,sBAAA;AACA,SAAA,mBAAA;AACA,SAAA,iBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,yBAAy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A,EACP;AAAA,EAGD,MAAc,eAAe,OAAoD;AAC1E,UAAA,MAAM,MAAM,UAAU,KAAK;AACjC,QAAI,KAAK;AACD,aAAA;AAAA,IAAA;AAER,UAAM,EAAE,WAAW,MAAM,QAAQ;AAAA,MAChC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,QACR,EAAE,OAAO,OAAO,OAAO,MAAM;AAAA,QAC7B,EAAE,OAAO,MAAM,OAAO,QAAQ;AAAA,MAAA;AAAA,IAC/B,CACA;AACD,WAAO,WAAW;AAAA,EAAA;AAAA,EAGnB,MAAc,eAAiC;AAC9C,UAAM,EAAE,WAAW,MAAM,QAAQ;AAAA,MAChC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,QACR,EAAE,OAAO,UAAU,OAAO,0BAA0B;AAAA,QACpD,EAAE,OAAO,QAAQ,OAAO,0CAA0C;AAAA,MAAA;AAAA,IACnE,CACA;AACD,WAAO,WAAW;AAAA,EAAA;AAEpB;;"}
|
|
@@ -77,7 +77,7 @@ class MigrationAmendCommand extends Command {
|
|
|
77
77
|
const systemClient = this.systemApiClientProvider.get();
|
|
78
78
|
await systemClient.migrate([intermediateResult.migration], force);
|
|
79
79
|
await systemClient.migrationDelete(intermediateResult.migration.version);
|
|
80
|
-
if (!newMigrationResult) {
|
|
80
|
+
if (!newMigrationResult && await this.shouldRemove()) {
|
|
81
81
|
await this.migrationCreator.removeMigration(amendMigration.name);
|
|
82
82
|
await systemClient.migrationDelete(amendMigration.version);
|
|
83
83
|
console.log("Latest migration was removed");
|
|
@@ -86,8 +86,8 @@ class MigrationAmendCommand extends Command {
|
|
|
86
86
|
const newMigration = {
|
|
87
87
|
name: amendMigration.name,
|
|
88
88
|
version: amendMigration.version,
|
|
89
|
-
formatVersion: newMigrationResult
|
|
90
|
-
modifications: newMigrationResult
|
|
89
|
+
formatVersion: newMigrationResult?.migration.formatVersion ?? amendMigration.formatVersion,
|
|
90
|
+
modifications: newMigrationResult?.migration.modifications ?? []
|
|
91
91
|
};
|
|
92
92
|
await this.migrationCreator.saveMigration(newMigration);
|
|
93
93
|
await systemClient.migrationModify(amendMigration.version, newMigration);
|
|
@@ -116,6 +116,18 @@ class MigrationAmendCommand extends Command {
|
|
|
116
116
|
});
|
|
117
117
|
return action === "yes";
|
|
118
118
|
}
|
|
119
|
+
async shouldRemove() {
|
|
120
|
+
const { action } = await prompts({
|
|
121
|
+
type: "select",
|
|
122
|
+
name: "action",
|
|
123
|
+
message: "The amendment results in a no-op migration because the changes introduced by the latest migration were reverted.\nYou can choose to remove the latest migration or to modify it so it is empty.",
|
|
124
|
+
choices: [
|
|
125
|
+
{ value: "remove", title: "Remove latest migration" },
|
|
126
|
+
{ value: "keep", title: "Keep latest migration and make it empty" }
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
return action === "remove";
|
|
130
|
+
}
|
|
119
131
|
}
|
|
120
132
|
export {
|
|
121
133
|
MigrationAmendCommand
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationAmendCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationAmendCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException, SchemaMigrator } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { emptySchema } from '@contember/schema-utils'\nimport { MigrationCreator, MigrationsResolver, SchemaVersionBuilder, SystemClient } from '@contember/migrations-client'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationsValidator } from '../../lib/migrations/MigrationsValidator'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\tyes?: true\n\tforce: boolean\n}\n\nexport class MigrationAmendCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly systemApiClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationsValidator: MigrationsValidator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Amends latest migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('force').description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migration')\n\t\tconst amendMigration = migrationName\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\t\tif (!amendMigration) {\n\t\t\tthrow 'No migration to amend'\n\t\t}\n\t\tconst force = input.getOption('force')\n\t\tconst status = await this.migrationsStatusFacade.resolveMigrationsStatus({ force })\n\t\tif (status.migrationsToExecute.length > 0) {\n\t\t\tthrow `Some migrations are not executed. Unable to amend.`\n\t\t}\n\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst intermediateResult = await this.migrationCreator.prepareMigration(initialSchema, schema, '')\n\t\t\tif (intermediateResult === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tif (amendMigration.formatVersion !== intermediateResult.migration.formatVersion) {\n\t\t\t\tthrow 'Incompatible migration format version'\n\t\t\t}\n\t\t\tconst prevSchema = await this.schemaVersionBuilder.buildSchemaAdvanced(\n\t\t\t\temptySchema,\n\t\t\t\tversion => version < amendMigration.version,\n\t\t\t)\n\t\t\tconst newSchema = await this.schemaMigrator.applyModifications(\n\t\t\t\tprevSchema,\n\t\t\t\t[...amendMigration.modifications, ...intermediateResult.migration.modifications],\n\t\t\t\tamendMigration.formatVersion,\n\t\t\t)\n\t\t\tconst newMigrationResult = await this.migrationCreator.prepareMigration(prevSchema, newSchema, '')\n\t\t\tconst followingMigrations = (await this.migrationsResolver.getSchemaMigrations()).filter(\n\t\t\t\tit => it.version > amendMigration.version,\n\t\t\t)\n\n\t\t\tconst valid = await this.migrationsValidator.validate(\n\t\t\t\tprevSchema,\n\t\t\t\t[...(newMigrationResult ? [newMigrationResult.migration] : []), ...followingMigrations],\n\t\t\t)\n\t\t\tif (!valid) {\n\t\t\t\tthrow `Cannot amend migration`\n\t\t\t}\n\n\t\t\tthis.migrationPrinter.printMigrationDescription(\n\t\t\t\tintermediateResult.initialSchema,\n\t\t\t\tintermediateResult.migration,\n\t\t\t\t{ noSql: true },\n\t\t\t)\n\t\t\tconsole.log(`Amending ${amendMigration.name}`)\n\t\t\tif (!(await this.shouldContinue(input))) {\n\t\t\t\tconsole.log('Aborting')\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tconst systemClient = this.systemApiClientProvider.get()\n\t\t\tawait systemClient.migrate([intermediateResult.migration], force)\n\t\t\tawait systemClient.migrationDelete(intermediateResult.migration.version)\n\n\t\t\tif (!newMigrationResult) {\n\t\t\t\tawait this.migrationCreator.removeMigration(amendMigration.name)\n\t\t\t\tawait systemClient.migrationDelete(amendMigration.version)\n\t\t\t\tconsole.log('Latest migration was removed')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tconst newMigration = {\n\t\t\t\tname: amendMigration.name,\n\t\t\t\tversion: amendMigration.version,\n\t\t\t\tformatVersion: newMigrationResult
|
|
1
|
+
{"version":3,"file":"MigrationAmendCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationAmendCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException, SchemaMigrator } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { emptySchema } from '@contember/schema-utils'\nimport { MigrationCreator, MigrationsResolver, SchemaVersionBuilder, SystemClient } from '@contember/migrations-client'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationsValidator } from '../../lib/migrations/MigrationsValidator'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\tyes?: true\n\tforce: boolean\n}\n\nexport class MigrationAmendCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly systemApiClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationsValidator: MigrationsValidator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Amends latest migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('force').description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migration')\n\t\tconst amendMigration = migrationName\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\t\tif (!amendMigration) {\n\t\t\tthrow 'No migration to amend'\n\t\t}\n\t\tconst force = input.getOption('force')\n\t\tconst status = await this.migrationsStatusFacade.resolveMigrationsStatus({ force })\n\t\tif (status.migrationsToExecute.length > 0) {\n\t\t\tthrow `Some migrations are not executed. Unable to amend.`\n\t\t}\n\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst intermediateResult = await this.migrationCreator.prepareMigration(initialSchema, schema, '')\n\t\t\tif (intermediateResult === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tif (amendMigration.formatVersion !== intermediateResult.migration.formatVersion) {\n\t\t\t\tthrow 'Incompatible migration format version'\n\t\t\t}\n\t\t\tconst prevSchema = await this.schemaVersionBuilder.buildSchemaAdvanced(\n\t\t\t\temptySchema,\n\t\t\t\tversion => version < amendMigration.version,\n\t\t\t)\n\t\t\tconst newSchema = await this.schemaMigrator.applyModifications(\n\t\t\t\tprevSchema,\n\t\t\t\t[...amendMigration.modifications, ...intermediateResult.migration.modifications],\n\t\t\t\tamendMigration.formatVersion,\n\t\t\t)\n\t\t\tconst newMigrationResult = await this.migrationCreator.prepareMigration(prevSchema, newSchema, '')\n\t\t\tconst followingMigrations = (await this.migrationsResolver.getSchemaMigrations()).filter(\n\t\t\t\tit => it.version > amendMigration.version,\n\t\t\t)\n\n\t\t\tconst valid = await this.migrationsValidator.validate(\n\t\t\t\tprevSchema,\n\t\t\t\t[...(newMigrationResult ? [newMigrationResult.migration] : []), ...followingMigrations],\n\t\t\t)\n\t\t\tif (!valid) {\n\t\t\t\tthrow `Cannot amend migration`\n\t\t\t}\n\n\t\t\tthis.migrationPrinter.printMigrationDescription(\n\t\t\t\tintermediateResult.initialSchema,\n\t\t\t\tintermediateResult.migration,\n\t\t\t\t{ noSql: true },\n\t\t\t)\n\t\t\tconsole.log(`Amending ${amendMigration.name}`)\n\t\t\tif (!(await this.shouldContinue(input))) {\n\t\t\t\tconsole.log('Aborting')\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tconst systemClient = this.systemApiClientProvider.get()\n\t\t\tawait systemClient.migrate([intermediateResult.migration], force)\n\t\t\tawait systemClient.migrationDelete(intermediateResult.migration.version)\n\n\t\t\tif (!newMigrationResult && await this.shouldRemove()) {\n\t\t\t\tawait this.migrationCreator.removeMigration(amendMigration.name)\n\t\t\t\tawait systemClient.migrationDelete(amendMigration.version)\n\t\t\t\tconsole.log('Latest migration was removed')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tconst newMigration = {\n\t\t\t\tname: amendMigration.name,\n\t\t\t\tversion: amendMigration.version,\n\t\t\t\tformatVersion: newMigrationResult?.migration.formatVersion ?? amendMigration.formatVersion,\n\t\t\t\tmodifications: newMigrationResult?.migration.modifications ?? [],\n\t\t\t}\n\t\t\tawait this.migrationCreator.saveMigration(newMigration)\n\t\t\tawait systemClient.migrationModify(amendMigration.version, newMigration)\n\n\t\t\treturn 0\n\t\t} catch (e) {\n\t\t\tif (e instanceof InvalidSchemaException) {\n\t\t\t\tprintValidationErrors(e.validationErrors, e.message)\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n\n\tprivate async shouldContinue(input: Input<{}, { yes?: true }>): Promise<boolean> {\n\t\tconst yes = input.getOption('yes')\n\t\tif (yes) {\n\t\t\treturn true\n\t\t}\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage: 'Do you want to continue?',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'yes', title: 'Yes' },\n\t\t\t\t{ value: 'no', title: 'Abort' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'yes'\n\t}\n\n\tprivate async shouldRemove(): Promise<boolean> {\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage: 'The amendment results in a no-op migration because the changes introduced by the latest migration were reverted.\\nYou can choose to remove the latest migration or to modify it so it is empty.',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'remove', title: 'Remove latest migration' },\n\t\t\t\t{ value: 'keep', title: 'Keep latest migration and make it empty' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'remove'\n\t}\n}\n"],"names":[],"mappings":";;;;;AAqBO,MAAM,8BAA8B,QAAuB;AAAA,EACjE,YACkB,oBACA,yBACA,wBACA,cACA,sBACA,kBACA,qBACA,kBACA,gBAChB;AACK,UAAA;AAVW,SAAA,qBAAA;AACA,SAAA,0BAAA;AACA,SAAA,yBAAA;AACA,SAAA,eAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AACA,SAAA,sBAAA;AACA,SAAA,mBAAA;AACA,SAAA,iBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,yBAAyB;AACrC,kBAAA,SAAS,WAAW,EAAE,SAAS;AAC7C,kBAAc,OAAO,OAAO,EAAE,YAAY,2DAA2D;AACrG,kBACE,OAAO,KAAK,EACZ,UAAU,EACV,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAG7C,MAAgB,QAAQ,OAA8C;AAC/D,UAAA,gBAAgB,MAAM,YAAY,WAAW;AAC7C,UAAA,iBAAiB,gBACpB,MAAM,KAAK,mBAAmB,6BAA6B,aAAa,IACxE,MAAM,KAAK,mBAAmB,0BAA0B;AAC3D,QAAI,CAAC,gBAAgB;AACd,YAAA;AAAA,IAAA;AAED,UAAA,QAAQ,MAAM,UAAU,OAAO;AACrC,UAAM,SAAS,MAAM,KAAK,uBAAuB,wBAAwB,EAAE,OAA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S;AAAA,QACR,EAAE,OAAO,UAAU,OAAO,0BAA0B;AAAA,QACpD,EAAE,OAAO,QAAQ,OAAO,0CAA0C;AAAA,MAAA;AAAA,IACnE,CACA;AACD,WAAO,WAAW;AAAA,EAAA;AAEpB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationBlankCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationBlankCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationCreator } from '@contember/migrations-client'\n\ntype Args = {\n\tmigrationName: string\n\tformat?: string\n}\n\ntype Options = {\n}\n\nexport class MigrationBlankCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates new blank migration file')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.argument('format').optional().validator(it => !it || ['js', 'ts', 'json'].includes(it))\n\t\t\t.description('Migration file format (js, ts, json), default is ts.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tconst migrationFormat = input.getArgument('format') || 'ts'\n\t\tconst filename = await this.migrationCreator.createEmptyMigrationFile(migrationName, migrationFormat)\n\t\tconsole.log(`${filename} created`)\n\t\treturn 0\n\t}\n}\n\n"],"names":["Command"],"mappings":";;;AAWO,MAAM,8BAA8BA,UAAAA,QAAuB;AAAA,EACjE,YACkB,kBAChB;AACK;AAFW,SAAA,mBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"MigrationBlankCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationBlankCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationCreator } from '@contember/migrations-client'\n\ntype Args = {\n\tmigrationName: string\n\tformat?: string\n}\n\ntype Options = {\n}\n\nexport class MigrationBlankCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates new blank migration file')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.argument('format').optional().validator(it => !it || ['js', 'ts', 'json'].includes(it))\n\t\t\t.description('Migration file format (js, ts, json), default is ts.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tconst migrationFormat = input.getArgument('format') || 'ts'\n\t\tconst filename = await this.migrationCreator.createEmptyMigrationFile(migrationName, migrationFormat)\n\t\tconsole.log(`${filename} created`)\n\t\treturn 0\n\t}\n}\n\n"],"names":["Command"],"mappings":";;;AAWO,MAAM,8BAA8BA,UAAAA,QAAuB;AAAA,EACjE,YACkB,kBAChB;AACK,UAAA;AAFW,SAAA,mBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kCAAkC;AAC5D,kBAAc,SAAS,eAAe;AACtC,kBAAc,SAAS,QAAQ,EAAE,WAAW,UAAU,QAAM,CAAC,MAAM,CAAC,MAAM,MAAM,MAAM,EAAE,SAAS,EAAE,CAAC,EAClG,YAAY,sDAAsD;AAAA,EAAA;AAAA,EAGrE,MAAgB,QAAQ,OAA8C;AAC/D,UAAA,gBAAgB,MAAM,YAAY,eAAe;AACvD,UAAM,kBAAkB,MAAM,YAAY,QAAQ,KAAK;AACvD,UAAM,WAAW,MAAM,KAAK,iBAAiB,yBAAyB,eAAe,eAAe;AAC5F,YAAA,IAAI,GAAG,QAAQ,UAAU;AAC1B,WAAA;AAAA,EAAA;AAET;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationBlankCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationBlankCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationCreator } from '@contember/migrations-client'\n\ntype Args = {\n\tmigrationName: string\n\tformat?: string\n}\n\ntype Options = {\n}\n\nexport class MigrationBlankCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates new blank migration file')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.argument('format').optional().validator(it => !it || ['js', 'ts', 'json'].includes(it))\n\t\t\t.description('Migration file format (js, ts, json), default is ts.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tconst migrationFormat = input.getArgument('format') || 'ts'\n\t\tconst filename = await this.migrationCreator.createEmptyMigrationFile(migrationName, migrationFormat)\n\t\tconsole.log(`${filename} created`)\n\t\treturn 0\n\t}\n}\n\n"],"names":[],"mappings":";AAWO,MAAM,8BAA8B,QAAuB;AAAA,EACjE,YACkB,kBAChB;AACK;AAFW,SAAA,mBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"MigrationBlankCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationBlankCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationCreator } from '@contember/migrations-client'\n\ntype Args = {\n\tmigrationName: string\n\tformat?: string\n}\n\ntype Options = {\n}\n\nexport class MigrationBlankCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates new blank migration file')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.argument('format').optional().validator(it => !it || ['js', 'ts', 'json'].includes(it))\n\t\t\t.description('Migration file format (js, ts, json), default is ts.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tconst migrationFormat = input.getArgument('format') || 'ts'\n\t\tconst filename = await this.migrationCreator.createEmptyMigrationFile(migrationName, migrationFormat)\n\t\tconsole.log(`${filename} created`)\n\t\treturn 0\n\t}\n}\n\n"],"names":[],"mappings":";AAWO,MAAM,8BAA8B,QAAuB;AAAA,EACjE,YACkB,kBAChB;AACK,UAAA;AAFW,SAAA,mBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kCAAkC;AAC5D,kBAAc,SAAS,eAAe;AACtC,kBAAc,SAAS,QAAQ,EAAE,WAAW,UAAU,QAAM,CAAC,MAAM,CAAC,MAAM,MAAM,MAAM,EAAE,SAAS,EAAE,CAAC,EAClG,YAAY,sDAAsD;AAAA,EAAA;AAAA,EAGrE,MAAgB,QAAQ,OAA8C;AAC/D,UAAA,gBAAgB,MAAM,YAAY,eAAe;AACvD,UAAM,kBAAkB,MAAM,YAAY,QAAQ,KAAK;AACvD,UAAM,WAAW,MAAM,KAAK,iBAAiB,yBAAyB,eAAe,eAAe;AAC5F,YAAA,IAAI,GAAG,QAAQ,UAAU;AAC1B,WAAA;AAAA,EAAA;AAET;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationDescribeCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationDescribeCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { MigrationsResolver, SchemaVersionBuilder } from '@contember/migrations-client'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\t['sql-only']: boolean\n\t['no-sql']: boolean\n}\n\n\nexport class MigrationDescribeCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Describes a migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('sql-only').valueNone()\n\t\tconfiguration.option('no-sql').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationArg = input.getArgument('migration')\n\t\tconst sqlOnly = input.getOption('sql-only')\n\t\tconst noSql = input.getOption('no-sql')\n\n\t\tconst migration = migrationArg\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationArg)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\n\t\tif (!migration) {\n\t\t\tthrow 'Undefined migration'\n\t\t}\n\t\tconst schema = await this.schemaVersionBuilder.buildSchemaUntil(migration.version)\n\t\tthis.migrationPrinter.printMigrationDescription(schema, migration, { sqlOnly, noSql })\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAcO,MAAM,iCAAiCA,UAAAA,QAAuB;AAAA,EACpE,YACkB,kBACA,sBACA,oBAChB;AACK;AAJW,SAAA,mBAAA;AACA,SAAA,uBAAA;AACA,SAAA,qBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"MigrationDescribeCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationDescribeCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { MigrationsResolver, SchemaVersionBuilder } from '@contember/migrations-client'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\t['sql-only']: boolean\n\t['no-sql']: boolean\n}\n\n\nexport class MigrationDescribeCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Describes a migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('sql-only').valueNone()\n\t\tconfiguration.option('no-sql').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationArg = input.getArgument('migration')\n\t\tconst sqlOnly = input.getOption('sql-only')\n\t\tconst noSql = input.getOption('no-sql')\n\n\t\tconst migration = migrationArg\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationArg)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\n\t\tif (!migration) {\n\t\t\tthrow 'Undefined migration'\n\t\t}\n\t\tconst schema = await this.schemaVersionBuilder.buildSchemaUntil(migration.version)\n\t\tthis.migrationPrinter.printMigrationDescription(schema, migration, { sqlOnly, noSql })\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAcO,MAAM,iCAAiCA,UAAAA,QAAuB;AAAA,EACpE,YACkB,kBACA,sBACA,oBAChB;AACK,UAAA;AAJW,SAAA,mBAAA;AACA,SAAA,uBAAA;AACA,SAAA,qBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uBAAuB;AACnC,kBAAA,SAAS,WAAW,EAAE,SAAS;AAC/B,kBAAA,OAAO,UAAU,EAAE,UAAU;AAC7B,kBAAA,OAAO,QAAQ,EAAE,UAAU;AAAA,EAAA;AAAA,EAG1C,MAAgB,QAAQ,OAA4C;AAC7D,UAAA,eAAe,MAAM,YAAY,WAAW;AAC5C,UAAA,UAAU,MAAM,UAAU,UAAU;AACpC,UAAA,QAAQ,MAAM,UAAU,QAAQ;AAEhC,UAAA,YAAY,eACf,MAAM,KAAK,mBAAmB,6BAA6B,YAAY,IACvE,MAAM,KAAK,mBAAmB,0BAA0B;AAE3D,QAAI,CAAC,WAAW;AACT,YAAA;AAAA,IAAA;AAEP,UAAM,SAAS,MAAM,KAAK,qBAAqB,iBAAiB,UAAU,OAAO;AACjF,SAAK,iBAAiB,0BAA0B,QAAQ,WAAW,EAAE,SAAS,OAAO;AAAA,EAAA;AAEvF;;"}
|