@vaharoni/devops 1.2.13 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-N7EX3HJH.js +139 -0
- package/dist/chunk-RZ46YYZZ.js +420 -0
- package/dist/chunk-WKP7EQNU.js +421 -0
- package/dist/devops.d.ts +0 -2
- package/dist/devops.js +3235 -91
- package/dist/index.d.ts +972 -4
- package/dist/index.js +67 -3
- package/dist/plugins.d.ts +95 -4
- package/dist/plugins.js +20 -6
- package/dist/src/target-templates/README.md +1 -0
- package/dist/src/target-templates/cluster-resource-options/README.md +2 -0
- package/dist/src/target-templates/cluster-resource-options/dns-test/dns-test.yaml +60 -0
- package/dist/src/target-templates/cluster-resource-options/milvus/production/milvus-values.yaml +2 -0
- package/dist/src/target-templates/cluster-resource-options/milvus/staging/milvus-values.yaml +2 -0
- package/dist/src/target-templates/cluster-resource-options/monitoring-ingress/monitoring-ingress.yaml +62 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/daily-operator-restart.yaml +54 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/production/cluster/PodDisruptionBudget.yaml +27 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/production/cluster/SGCluster.yaml +47 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/production/cluster/StackGres-alerts.yaml +191 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/production/configurations/06-SGDistributedLogs.yaml +11 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/production/configurations/07-SGObjectStorage.yaml +18 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/production/configurations/08-SGScript.yaml +12 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/stackgres-ui-ingress.yaml +35 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/staging/cluster/SGCluster.yaml +42 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/staging/configurations/07-SGObjectStorage.yaml +18 -0
- package/dist/src/target-templates/cluster-resource-options/postgres/staging/configurations/08-SGScript.yaml +12 -0
- package/dist/src/target-templates/cluster-resource-options/prefect/production/prefect-values.yaml +14 -0
- package/dist/src/target-templates/cluster-resource-options/prefect/staging/prefect-values.yaml +14 -0
- package/dist/src/target-templates/cluster-resource-options/redis/production/redis-values.yaml +20 -0
- package/dist/src/target-templates/cluster-resource-options/redis/staging/redis-values.yaml +8 -0
- package/dist/src/target-templates/infra-variants/README.md +2 -0
- package/dist/src/target-templates/infra-variants/digitalocean/.devops/config/constants.yaml +18 -0
- package/dist/src/target-templates/infra-variants/digitalocean/.github/workflows/k8s-build.yaml +91 -0
- package/dist/src/target-templates/infra-variants/gcloud/.devops/config/constants.yaml +15 -0
- package/dist/src/target-templates/infra-variants/gcloud/.devops/manifests/ingress.yaml.hb +22 -0
- package/dist/src/target-templates/infra-variants/gcloud/.github/workflows/k8s-build.yaml +95 -0
- package/dist/src/target-templates/infra-variants/hetzner/.devops/config/constants.yaml +18 -0
- package/dist/src/target-templates/infra-variants/hetzner/.devops/infra/hetzner/abandoned/harbor-values.yaml +30 -0
- package/dist/src/target-templates/infra-variants/hetzner/.devops/infra/hetzner/abandoned/hcloud-config.yaml +134 -0
- package/dist/src/target-templates/infra-variants/hetzner/.devops/infra/hetzner/cert-manager.yaml +25 -0
- package/dist/src/target-templates/infra-variants/hetzner/.devops/infra/hetzner/harbor-cert.yaml +13 -0
- package/dist/src/target-templates/infra-variants/hetzner/.devops/infra/hetzner/harbor-values.yaml +76 -0
- package/dist/src/target-templates/infra-variants/hetzner/.devops/infra/hetzner/hcloud-config.yaml +113 -0
- package/dist/src/target-templates/infra-variants/hetzner/.devops/infra/hetzner/ingress-nginx-annotations.yaml +49 -0
- package/dist/src/target-templates/infra-variants/hetzner/.devops/infra/hetzner/ingress-nginx-configmap.yaml +8 -0
- package/dist/src/target-templates/infra-variants/hetzner/.devops/infra/hetzner/retain-storage-class.yaml +8 -0
- package/dist/src/target-templates/infra-variants/hetzner/.github/workflows/k8s-build.yaml +93 -0
- package/dist/src/target-templates/lang-variants-common/README.md +4 -0
- package/dist/src/target-templates/lang-variants-common/python/.cursor/rules/monorepo-python.mdc +56 -0
- package/dist/src/target-templates/lang-variants-common/python/.devops/config/images.yaml +89 -0
- package/dist/src/target-templates/lang-variants-common/python/.devops/docker-images/python-services/python-exec.sh +8 -0
- package/dist/src/target-templates/lang-variants-common/python/.devops/docker-images/python-services/python-run.sh +8 -0
- package/dist/src/target-templates/lang-variants-common/python/.devops/docker-images/python-services.Dockerfile +29 -0
- package/dist/src/target-templates/lang-variants-common/python/.devops/manifests/_index.yaml +21 -0
- package/dist/src/target-templates/lang-variants-common/python/.devops/manifests/prefect.yaml.hb +63 -0
- package/dist/src/target-templates/lang-variants-common/python/applications/example-data-pipeline/pyproject.toml +14 -0
- package/dist/src/target-templates/lang-variants-common/python/applications/example-data-pipeline/src/example_data_pipeline/main.py +38 -0
- package/dist/src/target-templates/lang-variants-common/python/applications/example-python/pyproject.toml +20 -0
- package/dist/src/target-templates/lang-variants-common/python/applications/example-python/src/example_python/__init__.py +0 -0
- package/dist/src/target-templates/lang-variants-common/python/applications/example-python/src/example_python/main.py +13 -0
- package/dist/src/target-templates/lang-variants-common/python/applications/example-python/src/example_python/scripts.py +17 -0
- package/dist/src/target-templates/lang-variants-common/python/applications/example-python/tests/__init__.py +0 -0
- package/dist/src/target-templates/lang-variants-common/python/devopspy +3 -0
- package/dist/src/target-templates/lang-variants-common/python/libs/example-python-lib/pyproject.toml +11 -0
- package/dist/src/target-templates/lang-variants-common/python/libs/example-python-lib/src/example_python_lib/__init__.py +2 -0
- package/dist/src/target-templates/lang-variants-common/python/pyproject.toml +16 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.cursor/rules/monorepo-typescript.mdc +51 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/config/images.yaml +69 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/docker-images/cloudrun.Dockerfile +31 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/docker-images/common/docker-common.sh +23 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/docker-images/node-services/node-exec.sh +8 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/docker-images/node-services/node-run.sh +8 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/docker-images/node-services.Dockerfile +31 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/env.example.yaml +23 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/manifests/_index.yaml +19 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/manifests/cron-jobs.yaml.hb +56 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/manifests/db-migrate-job.yaml.hb +43 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/manifests/deployment-debug.yaml.hb +42 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/manifests/deployment-process.yaml.hb +48 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/manifests/deployment-web.yaml.hb +54 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/manifests/ingress.yaml.hb +21 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.devops/manifests/service.yaml.hb +15 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.envrc +5 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.github/actions/build-image@v1/action.yaml +81 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.github/actions/connect-to-digital-ocean@v1/action.yaml +29 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.github/actions/connect-to-gke@v1/action.yaml +43 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.github/actions/connect-to-hetzner@v1/action.yaml +31 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.github/actions/db-migrate@v1/action.yaml +23 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.github/actions/deploy-image-cloudrun@v1/action.yaml +71 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.github/actions/deploy-image-k8s@v1/action.yaml +37 -0
- package/dist/src/target-templates/lang-variants-common/typescript/.github/actions/setup-prereq@v1/action.yaml +24 -0
- package/dist/src/target-templates/lang-variants-common/typescript/applications/example-node/index.ts +30 -0
- package/dist/src/target-templates/lang-variants-common/typescript/applications/example-node/package.json +26 -0
- package/dist/src/target-templates/lang-variants-common/typescript/applications/example-node/tsconfig.json +3 -0
- package/dist/src/target-templates/lang-variants-common/typescript/applications/jobs/README.md +68 -0
- package/dist/src/target-templates/lang-variants-common/typescript/applications/jobs/index.ts +1 -0
- package/dist/src/target-templates/lang-variants-common/typescript/applications/jobs/package.json +30 -0
- package/dist/src/target-templates/lang-variants-common/typescript/applications/jobs/tsconfig.json +3 -0
- package/dist/src/target-templates/lang-variants-common/typescript/config/.env.development +1 -0
- package/dist/src/target-templates/lang-variants-common/typescript/config/.env.global +4 -0
- package/dist/src/target-templates/lang-variants-common/typescript/config/.env.test +1 -0
- package/dist/src/target-templates/lang-variants-common/typescript/devops +3 -0
- package/dist/src/target-templates/lang-variants-common/typescript/libs/example-node-lib/index.ts +3 -0
- package/dist/src/target-templates/lang-variants-common/typescript/libs/example-node-lib/package.json +12 -0
- package/dist/src/target-templates/lang-variants-common/typescript/libs/example-node-lib/tsconfig.json +3 -0
- package/dist/src/target-templates/lang-variants-common/typescript/tmp/.gitkeep +0 -0
- package/dist/src/target-templates/lang-variants-common/typescript/tsconfig.json +27 -0
- package/dist/src/target-templates/lang-variants-prisma/README.md +3 -0
- package/dist/src/target-templates/lang-variants-prisma/python/.cursor/rules/prisma-python.mdc +55 -0
- package/dist/src/target-templates/lang-variants-prisma/python/.cursor/rules/testing-python.mdc +89 -0
- package/dist/src/target-templates/lang-variants-prisma/python/db/db/__init__.py +0 -0
- package/dist/src/target-templates/lang-variants-prisma/python/db/db/db_client_test.py +46 -0
- package/dist/src/target-templates/lang-variants-prisma/python/db/pyproject.toml +14 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/.cursor/rules/prisma-typescript.mdc +54 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/.cursor/rules/testing-typescript.mdc +103 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/db/db-client-test.ts +142 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/db/db-client.ts +19 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/db/env.yaml +4 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/db/package.json +17 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/db/prisma/schema.prisma +24 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/db/prisma-setup-vitest.ts +27 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/db/tsconfig.json +3 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/dml/package.json +7 -0
- package/dist/src/target-templates/lang-variants-prisma/typescript/dml/tsconfig.json +3 -0
- package/package.json +3 -2
- package/src/cli/core/exec.ts +2 -4
- package/src/cli/core/run.ts +2 -4
- package/src/cli/extensions/prisma.ts +2 -4
- package/src/libs/init-generator.ts +2 -4
- package/src/pkg-root.ts +14 -0
- package/src/plugins.ts +2 -4
- package/dist/app-support/crypto/aes.d.ts +0 -15
- package/dist/app-support/crypto/aes.d.ts.map +0 -1
- package/dist/app-support/crypto/aes.js +0 -56
- package/dist/app-support/crypto/aes.spec.d.ts +0 -2
- package/dist/app-support/crypto/aes.spec.d.ts.map +0 -1
- package/dist/app-support/crypto/aes.spec.js +0 -58
- package/dist/app-support/crypto/index.d.ts +0 -16
- package/dist/app-support/crypto/index.d.ts.map +0 -1
- package/dist/app-support/crypto/index.js +0 -31
- package/dist/app-support/crypto/internal-token.d.ts +0 -20
- package/dist/app-support/crypto/internal-token.d.ts.map +0 -1
- package/dist/app-support/crypto/internal-token.js +0 -42
- package/dist/app-support/crypto/internal-token.spec.d.ts +0 -2
- package/dist/app-support/crypto/internal-token.spec.d.ts.map +0 -1
- package/dist/app-support/crypto/internal-token.spec.js +0 -45
- package/dist/app-support/crypto/secret.d.ts +0 -3
- package/dist/app-support/crypto/secret.d.ts.map +0 -1
- package/dist/app-support/crypto/secret.js +0 -12
- package/dist/app-support/crypto/secret.spec.d.ts +0 -2
- package/dist/app-support/crypto/secret.spec.d.ts.map +0 -1
- package/dist/app-support/crypto/secret.spec.js +0 -15
- package/dist/app-support/discovery/dev-discovery-loader.d.ts +0 -2
- package/dist/app-support/discovery/dev-discovery-loader.d.ts.map +0 -1
- package/dist/app-support/discovery/dev-discovery-loader.js +0 -30
- package/dist/app-support/discovery/service-endpoint.d.ts +0 -2
- package/dist/app-support/discovery/service-endpoint.d.ts.map +0 -1
- package/dist/app-support/discovery/service-endpoint.js +0 -10
- package/dist/cli/common.d.ts +0 -89
- package/dist/cli/common.d.ts.map +0 -1
- package/dist/cli/common.js +0 -246
- package/dist/cli/common.spec.d.ts +0 -2
- package/dist/cli/common.spec.d.ts.map +0 -1
- package/dist/cli/common.spec.js +0 -64
- package/dist/cli/core/affected.d.ts +0 -9
- package/dist/cli/core/affected.d.ts.map +0 -1
- package/dist/cli/core/affected.js +0 -101
- package/dist/cli/core/cloudrun.d.ts +0 -9
- package/dist/cli/core/cloudrun.d.ts.map +0 -1
- package/dist/cli/core/cloudrun.js +0 -119
- package/dist/cli/core/console.d.ts +0 -10
- package/dist/cli/core/console.d.ts.map +0 -1
- package/dist/cli/core/console.js +0 -50
- package/dist/cli/core/constant.d.ts +0 -9
- package/dist/cli/core/constant.d.ts.map +0 -1
- package/dist/cli/core/constant.js +0 -20
- package/dist/cli/core/env.d.ts +0 -9
- package/dist/cli/core/env.d.ts.map +0 -1
- package/dist/cli/core/env.js +0 -65
- package/dist/cli/core/exec.d.ts +0 -9
- package/dist/cli/core/exec.d.ts.map +0 -1
- package/dist/cli/core/exec.js +0 -48
- package/dist/cli/core/image.d.ts +0 -9
- package/dist/cli/core/image.d.ts.map +0 -1
- package/dist/cli/core/image.js +0 -153
- package/dist/cli/core/index.d.ts +0 -16
- package/dist/cli/core/index.d.ts.map +0 -1
- package/dist/cli/core/index.js +0 -15
- package/dist/cli/core/init.d.ts +0 -9
- package/dist/cli/core/init.d.ts.map +0 -1
- package/dist/cli/core/init.js +0 -219
- package/dist/cli/core/job.d.ts +0 -9
- package/dist/cli/core/job.d.ts.map +0 -1
- package/dist/cli/core/job.js +0 -65
- package/dist/cli/core/namespace.d.ts +0 -9
- package/dist/cli/core/namespace.d.ts.map +0 -1
- package/dist/cli/core/namespace.js +0 -67
- package/dist/cli/core/prep-build.d.ts +0 -10
- package/dist/cli/core/prep-build.d.ts.map +0 -1
- package/dist/cli/core/prep-build.js +0 -109
- package/dist/cli/core/registry.d.ts +0 -9
- package/dist/cli/core/registry.d.ts.map +0 -1
- package/dist/cli/core/registry.js +0 -66
- package/dist/cli/core/run-many.d.ts +0 -10
- package/dist/cli/core/run-many.d.ts.map +0 -1
- package/dist/cli/core/run-many.js +0 -48
- package/dist/cli/core/run.d.ts +0 -9
- package/dist/cli/core/run.d.ts.map +0 -1
- package/dist/cli/core/run.js +0 -35
- package/dist/cli/core/test.d.ts +0 -9
- package/dist/cli/core/test.d.ts.map +0 -1
- package/dist/cli/core/test.js +0 -26
- package/dist/cli/extensions/dml.d.ts +0 -9
- package/dist/cli/extensions/dml.d.ts.map +0 -1
- package/dist/cli/extensions/dml.js +0 -114
- package/dist/cli/extensions/index.d.ts +0 -9
- package/dist/cli/extensions/index.d.ts.map +0 -1
- package/dist/cli/extensions/index.js +0 -8
- package/dist/cli/extensions/internal-curl.d.ts +0 -10
- package/dist/cli/extensions/internal-curl.d.ts.map +0 -1
- package/dist/cli/extensions/internal-curl.js +0 -41
- package/dist/cli/extensions/jwt.d.ts +0 -9
- package/dist/cli/extensions/jwt.d.ts.map +0 -1
- package/dist/cli/extensions/jwt.js +0 -25
- package/dist/cli/extensions/prisma.d.ts +0 -9
- package/dist/cli/extensions/prisma.d.ts.map +0 -1
- package/dist/cli/extensions/prisma.js +0 -23
- package/dist/cli/extensions/redis-bitnami.d.ts +0 -11
- package/dist/cli/extensions/redis-bitnami.d.ts.map +0 -1
- package/dist/cli/extensions/redis-bitnami.js +0 -74
- package/dist/cli/extensions/redis-ha.d.ts +0 -11
- package/dist/cli/extensions/redis-ha.d.ts.map +0 -1
- package/dist/cli/extensions/redis-ha.js +0 -51
- package/dist/cli/extensions/stackgres.d.ts +0 -10
- package/dist/cli/extensions/stackgres.d.ts.map +0 -1
- package/dist/cli/extensions/stackgres.js +0 -117
- package/dist/cli/extensions/template.d.ts +0 -9
- package/dist/cli/extensions/template.d.ts.map +0 -1
- package/dist/cli/extensions/template.js +0 -121
- package/dist/devops.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/libs/affected-entities.d.ts +0 -15
- package/dist/libs/affected-entities.d.ts.map +0 -1
- package/dist/libs/affected-entities.js +0 -52
- package/dist/libs/cloudrun-helpers.d.ts +0 -16
- package/dist/libs/cloudrun-helpers.d.ts.map +0 -1
- package/dist/libs/cloudrun-helpers.js +0 -81
- package/dist/libs/config.d.ts +0 -7
- package/dist/libs/config.d.ts.map +0 -1
- package/dist/libs/config.js +0 -102
- package/dist/libs/digital-ocean/container-reg.d.ts +0 -6
- package/dist/libs/digital-ocean/container-reg.d.ts.map +0 -1
- package/dist/libs/digital-ocean/container-reg.js +0 -74
- package/dist/libs/discovery/dependencies.d.ts +0 -19
- package/dist/libs/discovery/dependencies.d.ts.map +0 -1
- package/dist/libs/discovery/dependencies.js +0 -62
- package/dist/libs/discovery/dependencies.spec.d.ts +0 -2
- package/dist/libs/discovery/dependencies.spec.d.ts.map +0 -1
- package/dist/libs/discovery/dependencies.spec.js +0 -21
- package/dist/libs/discovery/images.d.ts +0 -5
- package/dist/libs/discovery/images.d.ts.map +0 -1
- package/dist/libs/discovery/images.js +0 -45
- package/dist/libs/discovery/index.d.ts +0 -6
- package/dist/libs/discovery/index.d.ts.map +0 -1
- package/dist/libs/discovery/index.js +0 -67
- package/dist/libs/discovery/process-common.d.ts +0 -25
- package/dist/libs/discovery/process-common.d.ts.map +0 -1
- package/dist/libs/discovery/process-common.js +0 -40
- package/dist/libs/discovery/process-package-json.d.ts +0 -3
- package/dist/libs/discovery/process-package-json.d.ts.map +0 -1
- package/dist/libs/discovery/process-package-json.js +0 -40
- package/dist/libs/discovery/process-pyproject-toml.d.ts +0 -3
- package/dist/libs/discovery/process-pyproject-toml.d.ts.map +0 -1
- package/dist/libs/discovery/process-pyproject-toml.js +0 -49
- package/dist/libs/git-helpers.d.ts +0 -8
- package/dist/libs/git-helpers.d.ts.map +0 -1
- package/dist/libs/git-helpers.js +0 -20
- package/dist/libs/hetzner/reg-secret.d.ts +0 -3
- package/dist/libs/hetzner/reg-secret.d.ts.map +0 -1
- package/dist/libs/hetzner/reg-secret.js +0 -39
- package/dist/libs/init-generator.d.ts +0 -41
- package/dist/libs/init-generator.d.ts.map +0 -1
- package/dist/libs/init-generator.js +0 -123
- package/dist/libs/k8s-constants.d.ts +0 -13
- package/dist/libs/k8s-constants.d.ts.map +0 -1
- package/dist/libs/k8s-constants.js +0 -91
- package/dist/libs/k8s-db.d.ts +0 -18
- package/dist/libs/k8s-db.d.ts.map +0 -1
- package/dist/libs/k8s-db.js +0 -73
- package/dist/libs/k8s-generate.d.ts +0 -17
- package/dist/libs/k8s-generate.d.ts.map +0 -1
- package/dist/libs/k8s-generate.js +0 -193
- package/dist/libs/k8s-helpers.d.ts +0 -11
- package/dist/libs/k8s-helpers.d.ts.map +0 -1
- package/dist/libs/k8s-helpers.js +0 -42
- package/dist/libs/k8s-image-config.d.ts +0 -8
- package/dist/libs/k8s-image-config.d.ts.map +0 -1
- package/dist/libs/k8s-image-config.js +0 -113
- package/dist/libs/k8s-job-waiter.d.ts +0 -8
- package/dist/libs/k8s-job-waiter.d.ts.map +0 -1
- package/dist/libs/k8s-job-waiter.js +0 -84
- package/dist/libs/k8s-namespace.d.ts +0 -7
- package/dist/libs/k8s-namespace.d.ts.map +0 -1
- package/dist/libs/k8s-namespace.js +0 -27
- package/dist/libs/k8s-redis-bitnami.d.ts +0 -6
- package/dist/libs/k8s-redis-bitnami.d.ts.map +0 -1
- package/dist/libs/k8s-redis-bitnami.js +0 -31
- package/dist/libs/k8s-redis-ha.d.ts +0 -3
- package/dist/libs/k8s-redis-ha.d.ts.map +0 -1
- package/dist/libs/k8s-redis-ha.js +0 -15
- package/dist/libs/k8s-secrets-manager.d.ts +0 -6
- package/dist/libs/k8s-secrets-manager.d.ts.map +0 -1
- package/dist/libs/k8s-secrets-manager.js +0 -64
- package/dist/libs/validate-env.d.ts +0 -56
- package/dist/libs/validate-env.d.ts.map +0 -1
- package/dist/libs/validate-env.js +0 -214
- package/dist/libs/validate-env.spec.d.ts +0 -2
- package/dist/libs/validate-env.spec.d.ts.map +0 -1
- package/dist/libs/validate-env.spec.js +0 -168
- package/dist/plugins.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -939
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -82
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
globs: *.prisma,*.sql
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Prisma (Python)
|
|
7
|
+
|
|
8
|
+
Assume all existing prisma migrations are applied, hence never change existing migrations.
|
|
9
|
+
|
|
10
|
+
NEVER reset the development database without permission.
|
|
11
|
+
|
|
12
|
+
As you know, Prisma is not good at renaming, so after creating migrations automatically from schema changes always go over the migrations and make sure it captured the user intent.
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
All prisma commands should be executed via the devopspy CLI:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
./devopspy prisma <some command>
|
|
20
|
+
./devopspy prisma migrate dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To generate the Prisma client after schema changes:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
./devopspy run db:generate
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## DB Package
|
|
30
|
+
|
|
31
|
+
The prisma schema resides in `db/prisma/schema.prisma`. To use the Prisma client from any application, add `db` as a workspace dependency in your `pyproject.toml`:
|
|
32
|
+
|
|
33
|
+
```toml
|
|
34
|
+
[tool.uv.sources]
|
|
35
|
+
db = { workspace = true }
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then import as usual:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from db import prisma
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Schema Conventions
|
|
45
|
+
|
|
46
|
+
When editing Prisma schemas:
|
|
47
|
+
|
|
48
|
+
- Define new models with singular PascalCase names and map them to plural snake_case table names via `@@map`.
|
|
49
|
+
- All table columns should remain in snake_case using `@map` on each field when needed.
|
|
50
|
+
- Default primary keys should be `String @id @default(cuid())` unless there is an explicit reason to use another strategy.
|
|
51
|
+
- Add `@default(now())` + `@map("created_at")` for creation timestamps and `@default(now()) @updatedAt @map("updated_at")` for update timestamps.
|
|
52
|
+
- Always create an index (`@@index`) for every relational field to keep lookups performant.
|
|
53
|
+
- Prefer Prisma's default column type mapping; use `@db.*` annotations only when you truly need a non-default database type.
|
|
54
|
+
- Prefer lowercase values for enums we fully control (e.g., `pending`, `completed` instead of `PENDING`, `COMPLETED`).
|
|
55
|
+
- Prefer strings rather than enums for data-driven closed-lists unless the user requests otherwise.
|
package/dist/src/target-templates/lang-variants-prisma/python/.cursor/rules/testing-python.mdc
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
alwaysApply: true
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Testing
|
|
6
|
+
|
|
7
|
+
## Running Tests
|
|
8
|
+
|
|
9
|
+
**IMPORTANT**: Always use `./devopspy test` to run tests:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Run all tests
|
|
13
|
+
./devopspy test
|
|
14
|
+
|
|
15
|
+
# Run tests for a specific package
|
|
16
|
+
./devopspy test <project-name>
|
|
17
|
+
./devopspy test my-service
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This command:
|
|
21
|
+
|
|
22
|
+
- Sets `MONOREPO_ENV=test` to use the test database (separate from development)
|
|
23
|
+
- Loads the correct environment variables from `config/.env.test`
|
|
24
|
+
- Ensures test isolation
|
|
25
|
+
|
|
26
|
+
**Never run tests directly with `pytest`** - this will use the development database and might pollute it with test data.
|
|
27
|
+
|
|
28
|
+
## Prisma Transactional Testing
|
|
29
|
+
|
|
30
|
+
We use a transactional testing pattern where each test runs inside a database transaction that is automatically rolled back after the test completes. This ensures:
|
|
31
|
+
|
|
32
|
+
- Complete test isolation - tests don't affect each other
|
|
33
|
+
- No cleanup code needed - the rollback handles it
|
|
34
|
+
- Fast tests - no need to truncate tables between tests
|
|
35
|
+
|
|
36
|
+
### Setting Up Tests for a New Package
|
|
37
|
+
|
|
38
|
+
1. Create a `tests/conftest.py` in your package that imports the test fixtures:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from db.db_client_test import *
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
2. Ensure `db` is in your workspace dependencies in `pyproject.toml`:
|
|
45
|
+
|
|
46
|
+
```toml
|
|
47
|
+
[project]
|
|
48
|
+
dependencies = ["db"]
|
|
49
|
+
|
|
50
|
+
[tool.uv.sources]
|
|
51
|
+
db = { workspace = true }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Writing Tests
|
|
55
|
+
|
|
56
|
+
Tests receive a `db_connection` fixture that provides a transactional database connection:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import pytest
|
|
60
|
+
|
|
61
|
+
@pytest.mark.asyncio
|
|
62
|
+
async def test_creates_record(db_connection):
|
|
63
|
+
# This record will be rolled back after the test
|
|
64
|
+
record = await db_connection.mymodel.create(
|
|
65
|
+
data={"name": "test"}
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
assert record.id is not None
|
|
69
|
+
|
|
70
|
+
@pytest.mark.asyncio
|
|
71
|
+
async def test_can_use_same_data(db_connection):
|
|
72
|
+
# This test gets a clean slate - the previous test's data was rolled back
|
|
73
|
+
record = await db_connection.mymodel.create(
|
|
74
|
+
data={"name": "test"} # same name works!
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
assert record.id is not None
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### How It Works
|
|
81
|
+
|
|
82
|
+
The `db_connection` fixture in `db/db_client_test.py`:
|
|
83
|
+
|
|
84
|
+
- Creates a new Prisma client and connects to the database
|
|
85
|
+
- Starts a transaction and yields a `TransactionProxy` to the test
|
|
86
|
+
- Raises `RollbackTransaction` after the test completes to rollback all changes
|
|
87
|
+
- Disconnects from the database
|
|
88
|
+
|
|
89
|
+
This means each test receives an isolated transaction that is automatically rolled back.
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import pytest_asyncio
|
|
2
|
+
from prisma import Prisma
|
|
3
|
+
from contextlib import asynccontextmanager
|
|
4
|
+
|
|
5
|
+
"""Usage:
|
|
6
|
+
Add the file tests/conftest.py with the following content:
|
|
7
|
+
|
|
8
|
+
from db.db_client_test import *
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
# To open ipython at a particular point, do this:
|
|
12
|
+
#
|
|
13
|
+
# Add imports:
|
|
14
|
+
# from IPython import embed
|
|
15
|
+
# import nest_asyncio
|
|
16
|
+
#
|
|
17
|
+
# Insert this to the right position in the code:
|
|
18
|
+
# nest_asyncio.apply()
|
|
19
|
+
# embed()
|
|
20
|
+
|
|
21
|
+
class RollbackTransaction(Exception): pass
|
|
22
|
+
|
|
23
|
+
class TransactionProxy:
|
|
24
|
+
def __init__(self, transaction):
|
|
25
|
+
self._transaction = transaction
|
|
26
|
+
|
|
27
|
+
def __getattr__(self, name):
|
|
28
|
+
return getattr(self._transaction, name)
|
|
29
|
+
|
|
30
|
+
@asynccontextmanager
|
|
31
|
+
async def tx(self):
|
|
32
|
+
yield self._transaction
|
|
33
|
+
|
|
34
|
+
@pytest_asyncio.fixture(scope='function')
|
|
35
|
+
async def db_connection():
|
|
36
|
+
db = Prisma()
|
|
37
|
+
await db.connect()
|
|
38
|
+
try:
|
|
39
|
+
async with db.tx() as transaction:
|
|
40
|
+
tx = TransactionProxy(transaction)
|
|
41
|
+
yield tx
|
|
42
|
+
raise RollbackTransaction('rollback')
|
|
43
|
+
except RollbackTransaction:
|
|
44
|
+
pass
|
|
45
|
+
finally:
|
|
46
|
+
await db.disconnect()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "db"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = ""
|
|
5
|
+
authors = []
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = ["prisma (>=0.15.0,<0.16.0)"]
|
|
8
|
+
|
|
9
|
+
[tool.devops.scripts]
|
|
10
|
+
generate = "prisma generate --generator python-client"
|
|
11
|
+
|
|
12
|
+
[build-system]
|
|
13
|
+
requires = ["hatchling"]
|
|
14
|
+
build-backend = "hatchling.build"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
globs: *.prisma,*.sql
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Prisma
|
|
7
|
+
|
|
8
|
+
Assume all existing prisma migrations are applied, hence never change existing migrations.
|
|
9
|
+
|
|
10
|
+
NEVER reset the development database without permission.
|
|
11
|
+
|
|
12
|
+
As you know, Prisma is not good at renaming, so after creating migrations automatically from schema changes always go over the migrations and make sure it captured the user intent.
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
All prisma commands should be executed via the devops CLI:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
./devops prisma <some command>
|
|
20
|
+
./devops prisma migrate dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To generate the Prisma client after schema changes:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
./devops run db:generate
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## DB Package
|
|
30
|
+
|
|
31
|
+
The prisma schema resides in `db/prisma/schema.prisma`. To connect to prisma from any application, add `"db": "workspace:*"` to the dependency list of the app's `package.json`. Then import as usual:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { prisma } from "db";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
To import Prisma types corresponding to tables, import from the prisma client package:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { type SomeType } from "@prisma/client";
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Schema Conventions
|
|
44
|
+
|
|
45
|
+
When editing Prisma schemas:
|
|
46
|
+
|
|
47
|
+
- Define new models with singular PascalCase names and map them to plural snake_case table names via `@@map`.
|
|
48
|
+
- All table columns should remain in snake_case using `@map` on each field when needed.
|
|
49
|
+
- Default primary keys should be `String @id @default(cuid())` unless there is an explicit reason to use another strategy.
|
|
50
|
+
- Add `@default(now())` + `@map("created_at")` for creation timestamps and `@default(now()) @updatedAt @map("updated_at")` for update timestamps.
|
|
51
|
+
- Always create an index (`@@index`) for every relational field to keep lookups performant.
|
|
52
|
+
- Prefer Prisma's default column type mapping; use `@db.*` annotations only when you truly need a non-default database type.
|
|
53
|
+
- Prefer lowercase values for enums we fully control (e.g., `pending`, `completed` instead of `PENDING`, `COMPLETED`).
|
|
54
|
+
- Prefer strings rather than enums for data-driven closed-lists unless the user requests otherwise.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
alwaysApply: true
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Testing
|
|
6
|
+
|
|
7
|
+
## Running Tests
|
|
8
|
+
|
|
9
|
+
**IMPORTANT**: Always use `./devops test` to run tests:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Run all tests
|
|
13
|
+
./devops test
|
|
14
|
+
|
|
15
|
+
# Run tests for a specific package
|
|
16
|
+
./devops test <project-name>
|
|
17
|
+
./devops test @local/my-service
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This command:
|
|
21
|
+
|
|
22
|
+
- Sets `MONOREPO_ENV=test` to use the test database (separate from development)
|
|
23
|
+
- Loads the correct environment variables from `config/.env.test`
|
|
24
|
+
- Ensures test isolation
|
|
25
|
+
|
|
26
|
+
**Never run tests directly with `bun test` or `vitest`** - this will use the development database and might pollute it with test data if the transactional testing (see below) is not properly configured.
|
|
27
|
+
|
|
28
|
+
## Prisma Transactional Testing
|
|
29
|
+
|
|
30
|
+
We use a transactional testing pattern where each test runs inside a database transaction that is automatically rolled back after the test completes. This ensures:
|
|
31
|
+
|
|
32
|
+
- Complete test isolation - tests don't affect each other
|
|
33
|
+
- No cleanup code needed - the rollback handles it
|
|
34
|
+
- Fast tests - no need to truncate tables between tests
|
|
35
|
+
|
|
36
|
+
### Setting Up Tests for a New Package
|
|
37
|
+
|
|
38
|
+
1. Add vitest as a dev dependency and a test script to your `package.json`:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"vitest": "^3.0.9"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"test": "vitest"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
2. Create a `vitest.config.ts` in your package root:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { defineConfig } from "vitest/config";
|
|
55
|
+
|
|
56
|
+
export default defineConfig({
|
|
57
|
+
test: {
|
|
58
|
+
setupFiles: ["../../db/prisma-setup-vitest.ts"], // adjust path based on package location
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
3. Ensure `"db": "workspace:*"` is in your dependencies if you use Prisma.
|
|
64
|
+
|
|
65
|
+
### Writing Tests
|
|
66
|
+
|
|
67
|
+
Tests can create database records freely - they will be rolled back automatically:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { describe, it, expect } from "vitest";
|
|
71
|
+
import { prisma } from "db";
|
|
72
|
+
|
|
73
|
+
describe("MyFeature", () => {
|
|
74
|
+
it("creates a record", async () => {
|
|
75
|
+
// This record will be rolled back after the test
|
|
76
|
+
const record = await prisma.myModel.create({
|
|
77
|
+
data: { name: "test" },
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
expect(record.id).toBeDefined();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("can use the same data", async () => {
|
|
84
|
+
// This test gets a clean slate - the previous test's data was rolled back
|
|
85
|
+
const record = await prisma.myModel.create({
|
|
86
|
+
data: { name: "test" }, // same name works!
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
expect(record.id).toBeDefined();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### How It Works
|
|
95
|
+
|
|
96
|
+
The setup in `db/prisma-setup-vitest.ts` and `db/db-client-test.ts`:
|
|
97
|
+
|
|
98
|
+
- Creates a transactional Prisma client with `$begin()` and `$rollback()` methods
|
|
99
|
+
- Stores it in `globalThis.prismaGlobal` (same singleton used by `db/db-client.ts`)
|
|
100
|
+
- Mocks the `"db"` module so all imports get the transactional client
|
|
101
|
+
- Wraps each test in `beforeEach`/`afterEach` hooks that start and rollback transactions
|
|
102
|
+
|
|
103
|
+
This means all code importing `prisma` from `"db"` - including services being tested - uses the same transactional client.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// This code is used in db/prisma-setup-vitest.ts to run test code in the context of a rollbacked transaction.
|
|
2
|
+
// It is an improvement of:
|
|
3
|
+
// https://github.com/prisma/prisma-client-extensions/tree/main/callback-free-itx
|
|
4
|
+
//
|
|
5
|
+
// The main idea is to return a single client object that knows whether a transaction is active.
|
|
6
|
+
// If a transaction is active, it routes all calls to that transaction client.
|
|
7
|
+
// If no transaction is active, it routes all calls to the original client.
|
|
8
|
+
// To activate a transaction, use $begin().
|
|
9
|
+
//
|
|
10
|
+
// See:
|
|
11
|
+
// https://github.com/prisma/prisma/issues/12458
|
|
12
|
+
// https://github.com/prisma/prisma-client-extensions/pull/52
|
|
13
|
+
// https://www.prisma.io/docs/orm/more/help-and-troubleshooting/help-articles/nextjs-prisma-client-dev-practices
|
|
14
|
+
//
|
|
15
|
+
import { Prisma, PrismaClient } from '@prisma/client';
|
|
16
|
+
|
|
17
|
+
const ROLLBACK = { [Symbol.for('prisma.client.extension.rollback')]: true };
|
|
18
|
+
|
|
19
|
+
export const prismaClientSingleton = () => {
|
|
20
|
+
let _txClient: FlatTransactionClient | null = null;
|
|
21
|
+
const prismaClientOptions = process.env['PRISMA_DEBUG']
|
|
22
|
+
? { log: ['query' as const] }
|
|
23
|
+
: undefined;
|
|
24
|
+
|
|
25
|
+
const extendedClient = new PrismaClient(prismaClientOptions).$extends({
|
|
26
|
+
client: {
|
|
27
|
+
async $begin() {
|
|
28
|
+
const prisma = Prisma.getExtensionContext(this);
|
|
29
|
+
let setTxClient: (txClient: Prisma.TransactionClient) => void;
|
|
30
|
+
let commit: () => void;
|
|
31
|
+
let rollback: () => void;
|
|
32
|
+
|
|
33
|
+
// a promise for getting the tx inner client
|
|
34
|
+
const txClient = new Promise<Prisma.TransactionClient>((res) => {
|
|
35
|
+
setTxClient = (txClient) => res(txClient);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// a promise for controlling the transaction
|
|
39
|
+
const txPromise = new Promise((_res, _rej) => {
|
|
40
|
+
commit = () => _res(undefined);
|
|
41
|
+
rollback = () => _rej(ROLLBACK);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// opening a transaction to control externally
|
|
45
|
+
if (
|
|
46
|
+
'$transaction' in prisma &&
|
|
47
|
+
typeof prisma.$transaction === 'function'
|
|
48
|
+
) {
|
|
49
|
+
// [AA] Note the change from the github repo to actually make rollbacks work
|
|
50
|
+
const tx = prisma
|
|
51
|
+
.$transaction((txClient: unknown) => {
|
|
52
|
+
setTxClient(txClient as unknown as Prisma.TransactionClient);
|
|
53
|
+
return txPromise;
|
|
54
|
+
})
|
|
55
|
+
.catch((e: unknown) => {
|
|
56
|
+
if (e === ROLLBACK) return;
|
|
57
|
+
throw e;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// return a proxy TransactionClient with `$commit` and `$rollback` methods
|
|
61
|
+
_txClient = new Proxy(await txClient, {
|
|
62
|
+
get(target, prop) {
|
|
63
|
+
if (prop === '$commit') {
|
|
64
|
+
return () => {
|
|
65
|
+
_txClient = null;
|
|
66
|
+
commit();
|
|
67
|
+
return tx;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (prop === '$rollback') {
|
|
71
|
+
return () => {
|
|
72
|
+
_txClient = null;
|
|
73
|
+
rollback();
|
|
74
|
+
return tx;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (prop === '$transaction') {
|
|
78
|
+
return async (fn: CallableFunction) => {
|
|
79
|
+
return fn(target);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return target[prop as keyof typeof target];
|
|
83
|
+
},
|
|
84
|
+
}) as FlatTransactionClient;
|
|
85
|
+
|
|
86
|
+
return _txClient;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
throw new Error('Transactions are not supported by this client');
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/* eslint-disable */
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
const client = new Proxy(extendedClient, {
|
|
97
|
+
get(_target, prop) {
|
|
98
|
+
if (_txClient) {
|
|
99
|
+
return _txClient[prop as keyof typeof _txClient];
|
|
100
|
+
} else {
|
|
101
|
+
return extendedClient[prop as keyof typeof extendedClient];
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
/* eslint-enable */
|
|
106
|
+
|
|
107
|
+
return client as unknown as ExtendedTransactionClient | FlatTransactionClient;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Use the same global singleton key as db-client.ts (prismaGlobal)
|
|
111
|
+
// This ensures all code importing from "db" uses the same transactional client
|
|
112
|
+
declare global {
|
|
113
|
+
// eslint-disable-next-line no-var
|
|
114
|
+
var prismaGlobal:
|
|
115
|
+
| ExtendedTransactionClient
|
|
116
|
+
| FlatTransactionClient
|
|
117
|
+
| undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type ExtendedTransactionClient = Prisma.TransactionClient & {
|
|
121
|
+
$begin: () => Promise<FlatTransactionClient>;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type FlatTransactionClient = Prisma.TransactionClient & {
|
|
125
|
+
$commit: () => Promise<void>;
|
|
126
|
+
$rollback: () => Promise<void>;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const prisma: ExtendedTransactionClient | FlatTransactionClient =
|
|
130
|
+
globalThis.prismaGlobal ?? prismaClientSingleton();
|
|
131
|
+
|
|
132
|
+
globalThis.prismaGlobal = prisma;
|
|
133
|
+
|
|
134
|
+
export { prisma };
|
|
135
|
+
|
|
136
|
+
export async function startTx() {
|
|
137
|
+
await (prisma as ExtendedTransactionClient).$begin();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export async function rollbackTx() {
|
|
141
|
+
await (prisma as FlatTransactionClient).$rollback();
|
|
142
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// See https://www.prisma.io/docs/orm/more/help-and-troubleshooting/help-articles/nextjs-prisma-client-dev-practices
|
|
2
|
+
import { PrismaClient } from '@prisma/client';
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
// eslint-disable-next-line no-var
|
|
6
|
+
var prismaGlobal: PrismaClient | undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const prismaClientSingleton = () => {
|
|
10
|
+
return new PrismaClient();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const prisma = (globalThis.prismaGlobal ??
|
|
14
|
+
prismaClientSingleton()) as PrismaClient;
|
|
15
|
+
|
|
16
|
+
globalThis.prismaGlobal = prisma;
|
|
17
|
+
|
|
18
|
+
export { prisma };
|
|
19
|
+
export * from '@prisma/client';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "db",
|
|
3
|
+
"main": "db-client.ts",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"generate": "prisma generate --generator js-client",
|
|
8
|
+
"migrate-deploy": "prisma migrate deploy"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@prisma/client": "^6.5.0",
|
|
12
|
+
"prisma": "^6.5.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"vitest": "^3.0.9"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// This is your Prisma schema file,
|
|
2
|
+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
3
|
+
|
|
4
|
+
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
5
|
+
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
6
|
+
|
|
7
|
+
generator client {
|
|
8
|
+
provider = "prisma-client-js"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
generator js-client {
|
|
12
|
+
provider = "prisma-client-js"
|
|
13
|
+
previewFeatures = ["postgresqlExtensions"]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
generator python-client {
|
|
17
|
+
provider = "prisma-client-py"
|
|
18
|
+
previewFeatures = ["postgresqlExtensions"]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
datasource db {
|
|
22
|
+
provider = "postgresql"
|
|
23
|
+
url = env("DATABASE_URL")
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { afterEach, beforeEach, vi } from 'vitest';
|
|
2
|
+
import { prisma, rollbackTx, startTx } from './db-client-test';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Usage:
|
|
6
|
+
* Create a `vitest.config.ts` in the project's folder with the following content.
|
|
7
|
+
* Adjust the path to the setup file based on the nesting of the project's folder.
|
|
8
|
+
|
|
9
|
+
import { defineConfig } from 'vitest/config'
|
|
10
|
+
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
test: {
|
|
13
|
+
setupFiles: ['../../db/prisma-setup-vitest.ts']
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
vi.mock('db', () => ({ prisma }));
|
|
20
|
+
|
|
21
|
+
beforeEach(async () => {
|
|
22
|
+
await startTx();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterEach(async () => {
|
|
26
|
+
await rollbackTx();
|
|
27
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaharoni/devops",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.14",
|
|
5
5
|
"description": "Devops utility",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "
|
|
26
|
+
"build": "tsup",
|
|
27
27
|
"test": "vitest run"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@types/fs-extra": "^11.0.4",
|
|
60
60
|
"@types/handlebars": "^4.1.0",
|
|
61
61
|
"@types/lodash": "^4.17.16",
|
|
62
|
+
"tsup": "^8.5.1",
|
|
62
63
|
"vitest": "^1.6.0"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
package/src/cli/core/exec.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { CLICommandParser, CommandExecutor, printUsageAndExit } from "../common";
|
|
2
|
-
import url from "url";
|
|
3
2
|
import path from "path";
|
|
4
3
|
import { getWorkspace } from "../../libs/discovery";
|
|
4
|
+
import { pkgRoot } from "../../pkg-root";
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const __cli__ = path.join(path.dirname(__file__), "../..", "cli");
|
|
8
|
-
const execShPath = path.join(__cli__, "exec.sh");
|
|
6
|
+
const execShPath = path.join(pkgRoot, "cli/exec.sh");
|
|
9
7
|
|
|
10
8
|
const oneLiner =
|
|
11
9
|
"Executes a command after injecting env variables, either globally or in a workspace";
|
package/src/cli/core/run.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { CLICommandParser, printUsageAndExit } from "../common";
|
|
2
|
-
import url from "url";
|
|
3
2
|
import path from "path";
|
|
4
3
|
import { getWorkspace } from "../../libs/discovery";
|
|
4
|
+
import { pkgRoot } from "../../pkg-root";
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const __cli__ = path.join(path.dirname(__file__), "../..", "cli");
|
|
8
|
-
const execShPath = path.join(__cli__, "exec.sh");
|
|
6
|
+
const execShPath = path.join(pkgRoot, "cli/exec.sh");
|
|
9
7
|
|
|
10
8
|
const oneLiner =
|
|
11
9
|
"Runs a script defined in package.json after injecting env variables";
|