@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
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from "crypto";
|
|
2
|
-
import { CommandExecutor } from "../cli/common";
|
|
3
|
-
import { containerRegistryRepoPath, isLocalOrRemoteEnv } from "./k8s-constants";
|
|
4
|
-
import { getImageData } from "./config";
|
|
5
|
-
import { getMonorepoSecretObject } from "./k8s-secrets-manager";
|
|
6
|
-
import chalk from "chalk";
|
|
7
|
-
function verifyCloudrunImage(image) {
|
|
8
|
-
const imageData = getImageData(image);
|
|
9
|
-
if (!imageData["cloudrun"]) {
|
|
10
|
-
console.error(`Image ${image} is not a cloudrun image. Add "cloudrun: true" in images.yaml`);
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function getEnvValuesToForward(env, forwardEnv) {
|
|
15
|
-
if (!forwardEnv.length)
|
|
16
|
-
return {};
|
|
17
|
-
let envValues = {};
|
|
18
|
-
const missingValues = new Set();
|
|
19
|
-
for (const key of forwardEnv) {
|
|
20
|
-
const value = process.env[key];
|
|
21
|
-
if (value) {
|
|
22
|
-
envValues[key] = value;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
missingValues.add(key);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (missingValues.size > 0 && isLocalOrRemoteEnv(env) === "remote") {
|
|
29
|
-
const secretsFromCluster = getMonorepoSecretObject(env, Array.from(missingValues));
|
|
30
|
-
for (const key of Object.keys(secretsFromCluster)) {
|
|
31
|
-
envValues[key] = secretsFromCluster[key];
|
|
32
|
-
missingValues.delete(key);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (missingValues.size > 0) {
|
|
36
|
-
console.error(`Some forwardEnv variables are missing: ${Array.from(missingValues).join(", ")}`);
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
return envValues;
|
|
40
|
-
}
|
|
41
|
-
export async function buildDev(image) {
|
|
42
|
-
verifyCloudrunImage(image);
|
|
43
|
-
const env = "development";
|
|
44
|
-
const sha = randomBytes(12).toString("hex");
|
|
45
|
-
const buildDir = new CommandExecutor(`devops prep-build ${image}`, {
|
|
46
|
-
env,
|
|
47
|
-
quiet: true
|
|
48
|
-
}).exec().trim();
|
|
49
|
-
const tag = containerRegistryRepoPath(image, env, sha);
|
|
50
|
-
console.warn(`Building ${tag} from ${buildDir}`);
|
|
51
|
-
await new CommandExecutor(`docker build --platform linux/amd64 -t ${tag} ${buildDir} --build-arg MONOREPO_ENV=${env}`, { env }).spawn({ pipeStdoutTo: "stderr" });
|
|
52
|
-
console.warn(`Pushing ${tag}`);
|
|
53
|
-
await new CommandExecutor(`docker push ${tag}`, { env }).spawn({ pipeStdoutTo: "stderr" });
|
|
54
|
-
console.warn(`\n✅ Built and pushed ${tag}\n`);
|
|
55
|
-
console.warn('Run "devops cloudrun deploy" next. For example:');
|
|
56
|
-
console.warn(chalk.blue(`./devops cloudrun deploy ${image} ${sha} --env ${env} --allow-unauthenticated --region us-east1 --forward-env ENV1,ENV2 -- --service-account RUNTIME_SA`));
|
|
57
|
-
console.warn(chalk.yellow(`\n\nRUNTIME_SA is the name of the service account used to run the Cloud Run service.`));
|
|
58
|
-
console.warn(chalk.yellow(`Find it with "gcloud iam service-accounts list"\n`));
|
|
59
|
-
console.log(sha);
|
|
60
|
-
}
|
|
61
|
-
export async function deploy({ image, env, sha, region, forwardEnv = [], allowUnauthenticated = false, cpu = "0.25", memory = "256Mi", minInstances = 0, maxInstances = 1, timeout = "60s", extraArgs = "", }) {
|
|
62
|
-
verifyCloudrunImage(image);
|
|
63
|
-
const repoPath = containerRegistryRepoPath(image, env, sha);
|
|
64
|
-
const envValues = getEnvValuesToForward(env, forwardEnv);
|
|
65
|
-
const envValuesCsv = Object.entries(envValues).map(([key, value]) => `${key}="${value}"`).join(",");
|
|
66
|
-
const serviceName = `${image}-${env}`;
|
|
67
|
-
const cmd = `
|
|
68
|
-
gcloud run deploy ${serviceName}
|
|
69
|
-
--image ${repoPath}
|
|
70
|
-
${Object.keys(envValues).length > 0 ? `--set-env-vars ${envValuesCsv}` : ""}
|
|
71
|
-
${allowUnauthenticated ? "--allow-unauthenticated" : ""}
|
|
72
|
-
--region ${region}
|
|
73
|
-
--cpu ${cpu}
|
|
74
|
-
--memory ${memory}
|
|
75
|
-
--min-instances ${minInstances}
|
|
76
|
-
--max-instances ${maxInstances}
|
|
77
|
-
--timeout ${timeout}
|
|
78
|
-
${extraArgs}
|
|
79
|
-
`.trim().replace(/\s+/g, " ");
|
|
80
|
-
await new CommandExecutor(cmd, { env }).spawn();
|
|
81
|
-
}
|
package/dist/libs/config.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type ConstFileSchema, type SingleImageSchema, type SingleTemplateSchema } from "../types";
|
|
2
|
-
export declare const getConst: <T extends keyof ConstFileSchema>(key: T, opts?: {
|
|
3
|
-
ignoreIfInvalid?: boolean;
|
|
4
|
-
}) => ConstFileSchema[T] | undefined;
|
|
5
|
-
export declare const getImageData: (imageName: string) => SingleImageSchema, getImageNames: () => string[], getTemplateData: (templateName: string) => SingleTemplateSchema;
|
|
6
|
-
export declare function getImageType(image: string): "cloudrun" | "k8s";
|
|
7
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/libs/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoC,KAAK,eAAe,EAAwB,KAAK,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAM3J,eAAO,MAAQ,QAAQ,GAgCH,CAAC,SAAS,MAAM,eAAe,OAAO,CAAC,SAAQ;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,KAAQ,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,AAhCxF,CAAC;AAC/C,eAAO,MAAQ,YAAY,cAuEQ,MAAM,KAAG,iBAAiB,EAvEhC,aAAa,kBAAE,eAAe,iBA6FlB,MAAM,KAAG,oBAAoB,AA7Fa,CAAC;AAEpF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,sBAGzC"}
|
package/dist/libs/config.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
import yaml from "yaml";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { getWorkspace } from "./discovery";
|
|
5
|
-
import { constFileSchema, imageFileSchema } from "../types";
|
|
6
|
-
const constantsFilePath = path.join(process.cwd(), ".devops/config/constants.yaml");
|
|
7
|
-
const imagesFilePath = path.join(process.cwd(), ".devops/config/images.yaml");
|
|
8
|
-
// We want these to be lazy loaded so that calling devops in a context that does not need the config files won't fail
|
|
9
|
-
export const { getConst } = processConstFile();
|
|
10
|
-
export const { getImageData, getImageNames, getTemplateData } = processImagesFile();
|
|
11
|
-
export function getImageType(image) {
|
|
12
|
-
const imageData = getImageData(image);
|
|
13
|
-
return imageData["cloudrun"] ? "cloudrun" : "k8s";
|
|
14
|
-
}
|
|
15
|
-
// Process config/constants.yaml
|
|
16
|
-
function processConstFile() {
|
|
17
|
-
let constants;
|
|
18
|
-
function constFileData() {
|
|
19
|
-
if (constants)
|
|
20
|
-
return constants;
|
|
21
|
-
try {
|
|
22
|
-
const constantsYaml = readFileSync(constantsFilePath, "utf8");
|
|
23
|
-
constants = yaml.parse(constantsYaml);
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
// This is only a warning - the file may not exist, which is fine if getConst is called with ignoreIfInvalid
|
|
27
|
-
console.warn("Warning: cannot read .devops/config/constants.yaml");
|
|
28
|
-
return { valid: false };
|
|
29
|
-
}
|
|
30
|
-
const parseRes = constFileSchema.safeParse(constants);
|
|
31
|
-
if (parseRes.error) {
|
|
32
|
-
// This is an error - if the file exists, it must be valid
|
|
33
|
-
console.error(`Error parsing config/constants.yaml: ${parseRes.error.toString()}`);
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
constants = { valid: true, data: parseRes.data };
|
|
37
|
-
return constants;
|
|
38
|
-
}
|
|
39
|
-
function getConst(key, opts = {}) {
|
|
40
|
-
const { valid, data } = constFileData();
|
|
41
|
-
if (!valid && !opts.ignoreIfInvalid) {
|
|
42
|
-
console.error(".devops/config/constants.yaml is invalid");
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
const value = data?.[key];
|
|
46
|
-
if (!value && !opts.ignoreIfInvalid) {
|
|
47
|
-
console.error(`Missing constant in .devops/config/constants.yaml: ${key}`);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
return value;
|
|
51
|
-
}
|
|
52
|
-
return { getConst };
|
|
53
|
-
}
|
|
54
|
-
// Process config/images.yaml
|
|
55
|
-
function processImagesFile() {
|
|
56
|
-
let images;
|
|
57
|
-
function imagesFileData() {
|
|
58
|
-
if (images)
|
|
59
|
-
return images;
|
|
60
|
-
try {
|
|
61
|
-
const imagesYaml = readFileSync(imagesFilePath, "utf8");
|
|
62
|
-
images = yaml.parse(imagesYaml);
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
console.error("Error reading .devops/config/images.yaml");
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
68
|
-
const parseRes = imageFileSchema.safeParse(images);
|
|
69
|
-
if (parseRes.error) {
|
|
70
|
-
console.error(`Error parsing config/images.yaml: ${parseRes.error.toString()}`);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
return images;
|
|
74
|
-
}
|
|
75
|
-
function getImageData(imageName) {
|
|
76
|
-
const imageData = imagesFileData()['images'][imageName];
|
|
77
|
-
if (!imageData) {
|
|
78
|
-
console.error(`Image ${imageName} not found in .devops/config/images.yaml`);
|
|
79
|
-
process.exit(1);
|
|
80
|
-
}
|
|
81
|
-
imageData.applications.forEach((project) => {
|
|
82
|
-
const data = getWorkspace(project);
|
|
83
|
-
if (!data) {
|
|
84
|
-
console.error(`Project ${project} not found for image ${imageName} in .devops/config/images.yaml`);
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
return imageData;
|
|
89
|
-
}
|
|
90
|
-
function getTemplateData(templateName) {
|
|
91
|
-
const templateData = imagesFileData()['templates'][templateName];
|
|
92
|
-
if (!templateData) {
|
|
93
|
-
console.error(`Template ${templateName} not found in .devops/config/images.yaml`);
|
|
94
|
-
process.exit(1);
|
|
95
|
-
}
|
|
96
|
-
return templateData;
|
|
97
|
-
}
|
|
98
|
-
function getImageNames() {
|
|
99
|
-
return Object.keys(imagesFileData()["images"]);
|
|
100
|
-
}
|
|
101
|
-
return { getImageData, getImageNames, getTemplateData };
|
|
102
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function prune(
|
|
2
|
-
/** To keep the image-related constants simple, this accepts the full URL including the prefix registry.digitalocean.com */
|
|
3
|
-
registryFullName: string,
|
|
4
|
-
/** The name of the repository inside the registry */
|
|
5
|
-
repoName: string, image: string): void;
|
|
6
|
-
//# sourceMappingURL=container-reg.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"container-reg.d.ts","sourceRoot":"","sources":["../../../src/libs/digital-ocean/container-reg.ts"],"names":[],"mappings":"AA0DA,wBAAgB,KAAK;AACnB,2HAA2H;AAC3H,gBAAgB,EAAE,MAAM;AACxB,qDAAqD;AACrD,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,QAyBd"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { CommandExecutor } from "../../cli/common";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { getConst, getImageData } from "../config";
|
|
4
|
-
const repoTagMetadataSchema = z.object({
|
|
5
|
-
// What we rely on
|
|
6
|
-
tag: z.string().optional(),
|
|
7
|
-
updated_at: z.string(),
|
|
8
|
-
manifest_digest: z.string(),
|
|
9
|
-
// Other fields that existed in the output
|
|
10
|
-
// registry_name: z.string().optional(),
|
|
11
|
-
// repository: z.string().optional(),
|
|
12
|
-
// compressed_size_bytes: z.number().optional(),
|
|
13
|
-
// size_bytes: z.number().optional(),
|
|
14
|
-
});
|
|
15
|
-
const repoTagMetadataSchemaOutput = z.array(repoTagMetadataSchema);
|
|
16
|
-
/** The metadata is returned in descending order (most recent first) */
|
|
17
|
-
function getRepoTagMetadata(repoName) {
|
|
18
|
-
// Get the metadata for the tags in the repository
|
|
19
|
-
const cmd = `doctl registry repository list-tags ${repoName} -o json`;
|
|
20
|
-
const res = new CommandExecutor(cmd, { quiet: true }).exec();
|
|
21
|
-
if (!res)
|
|
22
|
-
return [];
|
|
23
|
-
try {
|
|
24
|
-
const parsed = JSON.parse(res);
|
|
25
|
-
const parseRes = repoTagMetadataSchemaOutput.safeParse(parsed);
|
|
26
|
-
if (parseRes.error) {
|
|
27
|
-
console.error(`Error schema-parsing output from "${cmd}": ${parseRes.error.toString()}`);
|
|
28
|
-
console.error(">>> Command output");
|
|
29
|
-
console.error(res);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
return parseRes.data
|
|
33
|
-
.filter((data) => data.tag)
|
|
34
|
-
.sort((a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime());
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
console.error(`Error JSON-parsing output from "${cmd}": ${res}`);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function deleteRepoTag(repoName, tag) {
|
|
42
|
-
const cmd = `doctl registry repository delete-tag ${repoName} ${tag} --force`;
|
|
43
|
-
new CommandExecutor(cmd).exec();
|
|
44
|
-
}
|
|
45
|
-
function stargGarbageCollection(registryName) {
|
|
46
|
-
const cmd = `doctl registry garbage-collection start --include-untagged-manifests ${registryName} --force`;
|
|
47
|
-
new CommandExecutor(cmd).exec();
|
|
48
|
-
}
|
|
49
|
-
export function prune(
|
|
50
|
-
/** To keep the image-related constants simple, this accepts the full URL including the prefix registry.digitalocean.com */
|
|
51
|
-
registryFullName,
|
|
52
|
-
/** The name of the repository inside the registry */
|
|
53
|
-
repoName, image) {
|
|
54
|
-
const infra = getConst("infra");
|
|
55
|
-
if (infra !== "digitalocean") {
|
|
56
|
-
console.warn("Pruning is only supported for the DigitalOcean container registry");
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const imageData = getImageData(image);
|
|
60
|
-
if (imageData["cloudrun"]) {
|
|
61
|
-
console.warn("Pruning is skipped for cloudrun images");
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const tags = getRepoTagMetadata(repoName);
|
|
65
|
-
const versionsToKeep = Number(getConst("image-versions-to-keep"));
|
|
66
|
-
if (!tags.length || tags.length <= versionsToKeep)
|
|
67
|
-
return;
|
|
68
|
-
const tagsToDelete = tags.slice(versionsToKeep);
|
|
69
|
-
tagsToDelete.forEach((tag) => {
|
|
70
|
-
deleteRepoTag(repoName, tag.tag);
|
|
71
|
-
});
|
|
72
|
-
const registryName = registryFullName.split("/").slice(-1)[0];
|
|
73
|
-
stargGarbageCollection(registryName);
|
|
74
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { PackageData } from "../../types";
|
|
2
|
-
export declare class WorkspaceDependencies {
|
|
3
|
-
getAllProjects: () => Record<string, PackageData>;
|
|
4
|
-
dependencies: Record<string, DependencyNode>;
|
|
5
|
-
loaded: boolean;
|
|
6
|
-
workspaces: Record<string, PackageData>;
|
|
7
|
-
constructor(getAllProjects: () => Record<string, PackageData>);
|
|
8
|
-
_getOrCreate(name: string): DependencyNode;
|
|
9
|
-
_buildTree(): void;
|
|
10
|
-
getDependents(workspaceName: string): string[];
|
|
11
|
-
}
|
|
12
|
-
declare class DependencyNode {
|
|
13
|
-
name: string;
|
|
14
|
-
dependsOn: Set<string>;
|
|
15
|
-
constructor(name: string);
|
|
16
|
-
flattenDependents(allDependencies: Record<string, DependencyNode>, visited?: Set<string>): string[];
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,qBAAa,qBAAqB;IAKb,cAAc,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;IAJpE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAM;IAClD,MAAM,UAAS;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAM;gBAE1B,cAAc,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;IAEpE,YAAY,CAAC,IAAI,EAAE,MAAM;IASzB,UAAU;IAcV,aAAa,CAAC,aAAa,EAAE,MAAM;CAWpC;AAED,cAAM,cAAc;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;gBAEX,IAAI,EAAE,MAAM;IAKxB,iBAAiB,CACf,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAC/C,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;CAexB"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
export class WorkspaceDependencies {
|
|
3
|
-
getAllProjects;
|
|
4
|
-
dependencies = {};
|
|
5
|
-
loaded = false;
|
|
6
|
-
workspaces = {};
|
|
7
|
-
constructor(getAllProjects) {
|
|
8
|
-
this.getAllProjects = getAllProjects;
|
|
9
|
-
}
|
|
10
|
-
_getOrCreate(name) {
|
|
11
|
-
let node = this.dependencies[name];
|
|
12
|
-
if (!node) {
|
|
13
|
-
node = new DependencyNode(name);
|
|
14
|
-
this.dependencies[name] = node;
|
|
15
|
-
}
|
|
16
|
-
return node;
|
|
17
|
-
}
|
|
18
|
-
_buildTree() {
|
|
19
|
-
this.workspaces = this.getAllProjects();
|
|
20
|
-
this.loaded = true;
|
|
21
|
-
for (const workspace of Object.keys(this.workspaces)) {
|
|
22
|
-
const node = this._getOrCreate(workspace);
|
|
23
|
-
const data = this.workspaces[workspace];
|
|
24
|
-
for (const dep of data.dependencyNames ?? []) {
|
|
25
|
-
if (this.workspaces[dep]) {
|
|
26
|
-
node.dependsOn.add(dep);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
getDependents(workspaceName) {
|
|
32
|
-
if (!this.loaded) {
|
|
33
|
-
this._buildTree();
|
|
34
|
-
}
|
|
35
|
-
const node = this.dependencies[workspaceName];
|
|
36
|
-
if (!node) {
|
|
37
|
-
console.error(chalk.red(`\nWorkspace ${workspaceName} not found\n`));
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
return node.flattenDependents(this.dependencies);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
class DependencyNode {
|
|
44
|
-
name;
|
|
45
|
-
dependsOn;
|
|
46
|
-
constructor(name) {
|
|
47
|
-
this.name = name;
|
|
48
|
-
this.dependsOn = new Set();
|
|
49
|
-
}
|
|
50
|
-
flattenDependents(allDependencies, visited) {
|
|
51
|
-
visited ??= new Set();
|
|
52
|
-
visited.add(this.name);
|
|
53
|
-
const notVisitedDependents = [];
|
|
54
|
-
for (const dep of this.dependsOn) {
|
|
55
|
-
if (!visited.has(dep)) {
|
|
56
|
-
const node = allDependencies[dep];
|
|
57
|
-
notVisitedDependents.push(...node.flattenDependents(allDependencies, visited));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return [this.name, ...notVisitedDependents];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.spec.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/dependencies.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { WorkspaceDependencies } from './dependencies';
|
|
3
|
-
describe('createDependencyResolver', () => {
|
|
4
|
-
const projects = {
|
|
5
|
-
'@local/a': { language: "node", rootPath: 'applications/a', name: '@local/a', dependencyNames: ['@local/b', '@local/d', 'external1'] },
|
|
6
|
-
'@local/b': { language: "node", rootPath: 'applications/b', name: '@local/b', dependencyNames: ['@local/c', 'external2'] },
|
|
7
|
-
'@local/c': { language: "node", rootPath: 'applications/c', name: '@local/c', dependencyNames: ['external3'] },
|
|
8
|
-
'@local/d': { language: "node", rootPath: 'applications/d', name: '@local/d', dependencyNames: [] },
|
|
9
|
-
'@local/e': { language: "node", rootPath: 'applications/e', name: '@local/e', dependencyNames: ['@local/f'] },
|
|
10
|
-
'@local/f': { language: "node", rootPath: 'applications/f', name: '@local/f', dependencyNames: ['@local/e'] }
|
|
11
|
-
};
|
|
12
|
-
it('should return dependents of a given project', () => {
|
|
13
|
-
const resolver = new WorkspaceDependencies(() => projects);
|
|
14
|
-
expect(resolver.getDependents('@local/a')).toEqual(['@local/a', '@local/b', '@local/c', '@local/d']);
|
|
15
|
-
expect(resolver.getDependents('@local/b')).toEqual(['@local/b', '@local/c']);
|
|
16
|
-
expect(resolver.getDependents('@local/c')).toEqual(['@local/c']);
|
|
17
|
-
expect(resolver.getDependents('@local/d')).toEqual(['@local/d']);
|
|
18
|
-
expect(resolver.getDependents('@local/e')).toEqual(['@local/e', '@local/f']);
|
|
19
|
-
expect(resolver.getDependents('@local/f')).toEqual(['@local/f', '@local/e']);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { PackageData } from "../../types";
|
|
2
|
-
/** The dependent workspaces are specified in config/images.yaml */
|
|
3
|
-
export declare function getImageDescendentData(imageName: string): PackageData[];
|
|
4
|
-
export declare function getWorkspaceImages(workspaceName: string): string[];
|
|
5
|
-
//# sourceMappingURL=images.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/images.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA0B/C,mEAAmE;AACnE,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,iBAIvD;AAqBD,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,YAGvD"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { getWorkspace, workspaceDirectoryForLanguage } from ".";
|
|
2
|
-
import { getImageData, getImageNames } from "../config";
|
|
3
|
-
import { WorkspaceDependencies } from "./dependencies";
|
|
4
|
-
// = From images to workspaces
|
|
5
|
-
const _imageDescendents = {};
|
|
6
|
-
let _imageDescendentsLoaded = false;
|
|
7
|
-
function imageDescendents() {
|
|
8
|
-
if (!_imageDescendentsLoaded) {
|
|
9
|
-
for (const imageName of getImageNames()) {
|
|
10
|
-
const descendents = new Set();
|
|
11
|
-
const imageData = getImageData(imageName);
|
|
12
|
-
const workspaces = workspaceDirectoryForLanguage(imageData.language);
|
|
13
|
-
const dependencyResolver = new WorkspaceDependencies(() => workspaces);
|
|
14
|
-
imageData.applications.forEach((workspace) => {
|
|
15
|
-
dependencyResolver.getDependents(workspace).forEach((name) => descendents.add(name));
|
|
16
|
-
});
|
|
17
|
-
_imageDescendents[imageName] = Array.from(descendents).map(name => workspaces[name]);
|
|
18
|
-
}
|
|
19
|
-
_imageDescendentsLoaded = true;
|
|
20
|
-
}
|
|
21
|
-
return _imageDescendents;
|
|
22
|
-
}
|
|
23
|
-
/** The dependent workspaces are specified in config/images.yaml */
|
|
24
|
-
export function getImageDescendentData(imageName) {
|
|
25
|
-
return (imageDescendents()[imageName] ?? []);
|
|
26
|
-
}
|
|
27
|
-
// = From workspace to images
|
|
28
|
-
const _workspaceImages = {};
|
|
29
|
-
let _workspaceImagesLoaded = false;
|
|
30
|
-
function workspaceImages() {
|
|
31
|
-
if (!_workspaceImagesLoaded) {
|
|
32
|
-
for (const [imageName, descendents] of Object.entries(imageDescendents())) {
|
|
33
|
-
for (const packageData of descendents) {
|
|
34
|
-
_workspaceImages[packageData.name] ??= [];
|
|
35
|
-
_workspaceImages[packageData.name].push(imageName);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
_workspaceImagesLoaded = true;
|
|
39
|
-
}
|
|
40
|
-
return _workspaceImages;
|
|
41
|
-
}
|
|
42
|
-
export function getWorkspaceImages(workspaceName) {
|
|
43
|
-
const _verifyPresence = getWorkspace(workspaceName);
|
|
44
|
-
return workspaceImages()[workspaceName] ?? [];
|
|
45
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { SupportedLanguages, WorkspaceIndex } from "../../types";
|
|
2
|
-
export declare function workspaces(): WorkspaceIndex;
|
|
3
|
-
export declare function workspaceDirectoryForLanguage(language: SupportedLanguages): Record<string, import("../..").PackageData>;
|
|
4
|
-
export declare function getWorkspace(workspaceName: string): import("../..").WorkspaceIndexEntry;
|
|
5
|
-
export declare function globEnvYamlFiles(): string[];
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOtE,wBAAgB,UAAU,mBA8BzB;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,kBAAkB,+CASzE;AAED,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,uCAQjD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAQ3C"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { nodeWorkspaces } from "./process-package-json";
|
|
5
|
-
import { pythonWorkspaces } from "./process-pyproject-toml";
|
|
6
|
-
const rootPath = process.env.MONOREPO_ROOT || process.cwd();
|
|
7
|
-
const _workspaces = {};
|
|
8
|
-
let _workspacesLoaded = false;
|
|
9
|
-
export function workspaces() {
|
|
10
|
-
if (_workspacesLoaded)
|
|
11
|
-
return _workspaces;
|
|
12
|
-
const nodeWorkspacesData = nodeWorkspaces();
|
|
13
|
-
const pythonWorkspacesData = pythonWorkspaces();
|
|
14
|
-
Object.values(nodeWorkspacesData).forEach((data) => {
|
|
15
|
-
_workspaces[data.name] = {
|
|
16
|
-
rootPath: data.rootPath,
|
|
17
|
-
packageDataEntries: [data],
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
Object.values(pythonWorkspacesData).forEach((data) => {
|
|
21
|
-
const existing = _workspaces[data.name];
|
|
22
|
-
if (existing) {
|
|
23
|
-
if (existing.rootPath !== data.rootPath) {
|
|
24
|
-
// prettier-ignore
|
|
25
|
-
console.error(chalk.red(`\nWorkspace ${data.name} has conflicting root paths:\n\t${existing.rootPath}\n\t${data.rootPath}\n`));
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
_workspaces[data.name] = {
|
|
31
|
-
rootPath: data.rootPath,
|
|
32
|
-
packageDataEntries: [],
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
_workspaces[data.name].packageDataEntries.push(data);
|
|
36
|
-
});
|
|
37
|
-
_workspacesLoaded = true;
|
|
38
|
-
return _workspaces;
|
|
39
|
-
}
|
|
40
|
-
export function workspaceDirectoryForLanguage(language) {
|
|
41
|
-
switch (language) {
|
|
42
|
-
case "node":
|
|
43
|
-
return nodeWorkspaces();
|
|
44
|
-
case "python":
|
|
45
|
-
return pythonWorkspaces();
|
|
46
|
-
default:
|
|
47
|
-
throw new Error(`Unsupported language: ${language}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export function getWorkspace(workspaceName) {
|
|
51
|
-
const workspace = workspaces()[workspaceName];
|
|
52
|
-
if (!workspace) {
|
|
53
|
-
console.error(chalk.red(`\nWorkspace ${workspaceName} not found\n`));
|
|
54
|
-
// The gha relies on the 13 exit code for "not found"
|
|
55
|
-
process.exit(13);
|
|
56
|
-
}
|
|
57
|
-
return workspace;
|
|
58
|
-
}
|
|
59
|
-
export function globEnvYamlFiles() {
|
|
60
|
-
const allWorkspaces = workspaces();
|
|
61
|
-
const workspacePaths = [
|
|
62
|
-
...new Set(Object.values(allWorkspaces).map((w) => w.rootPath)),
|
|
63
|
-
];
|
|
64
|
-
return workspacePaths
|
|
65
|
-
.map((wsPath) => path.join(rootPath, wsPath, "env.yaml"))
|
|
66
|
-
.filter((p) => fs.existsSync(p));
|
|
67
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ZodSchema } from "zod";
|
|
2
|
-
import type { PackageData, SupportedLanguages } from "../../types";
|
|
3
|
-
export declare const IGNORED_PATHS: string[];
|
|
4
|
-
type PackageDataProcessorConfig<T> = {
|
|
5
|
-
language: SupportedLanguages;
|
|
6
|
-
pathList: string[];
|
|
7
|
-
zodSchema: ZodSchema<T>;
|
|
8
|
-
fileParser: (fileStringData: string) => unknown;
|
|
9
|
-
nameExtractor: (data: T) => string;
|
|
10
|
-
};
|
|
11
|
-
export declare class PackageDataProcessor<T> {
|
|
12
|
-
workspaceNames: Set<string>;
|
|
13
|
-
loadedFiles: Record<string, {
|
|
14
|
-
name: string;
|
|
15
|
-
data: T;
|
|
16
|
-
}>;
|
|
17
|
-
language: SupportedLanguages;
|
|
18
|
-
nameExtractor: (data: T) => string;
|
|
19
|
-
constructor(config: PackageDataProcessorConfig<T>);
|
|
20
|
-
_runFirstPass(pathList: string[], zodSchema: ZodSchema<T>, fileParser: (fileStringData: string) => unknown): void;
|
|
21
|
-
filterDependencies(dependencyNames: string[]): string[];
|
|
22
|
-
convert(iterator: (data: T) => Omit<PackageData, 'rootPath' | 'language' | 'name'>): PackageData[];
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=process-common.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-common.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/process-common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAInE,eAAO,MAAM,aAAa,UAA6B,CAAC;AAExD,KAAK,0BAA0B,CAAC,CAAC,IAAI;IACnC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC;IAChD,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;CACpC,CAAA;AAED,qBAAa,oBAAoB,CAAC,CAAC;IACjC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IACxC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAM;IAC5D,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;gBAEvB,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAMjD,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO;IAiB1G,kBAAkB,CAAC,eAAe,EAAE,MAAM,EAAE;IAI5C,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC,GAAG,WAAW,EAAE;CAMnG"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
export const IGNORED_PATHS = ["node_modules/", "venv/"];
|
|
4
|
-
export class PackageDataProcessor {
|
|
5
|
-
workspaceNames = new Set();
|
|
6
|
-
loadedFiles = {};
|
|
7
|
-
language;
|
|
8
|
-
nameExtractor;
|
|
9
|
-
constructor(config) {
|
|
10
|
-
this.language = config.language;
|
|
11
|
-
this.nameExtractor = config.nameExtractor;
|
|
12
|
-
this._runFirstPass(config.pathList, config.zodSchema, config.fileParser);
|
|
13
|
-
}
|
|
14
|
-
_runFirstPass(pathList, zodSchema, fileParser) {
|
|
15
|
-
pathList.forEach((packageFilePath) => {
|
|
16
|
-
if (IGNORED_PATHS.find(path => packageFilePath.includes(path)))
|
|
17
|
-
return;
|
|
18
|
-
const unsafeData = fileParser(fs.readFileSync(packageFilePath, "utf8"));
|
|
19
|
-
const parsedRes = zodSchema.safeParse(unsafeData);
|
|
20
|
-
if (parsedRes.error) {
|
|
21
|
-
console.error(`Error parsing ${packageFilePath}: ${parsedRes.error}`);
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
const rootDir = path.relative(process.cwd(), path.dirname(packageFilePath));
|
|
25
|
-
const name = this.nameExtractor(parsedRes.data);
|
|
26
|
-
this.workspaceNames.add(name);
|
|
27
|
-
this.loadedFiles[rootDir] = { name, data: parsedRes.data };
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
// Should be used by the iterator sent to convert in order to filter out dependencies that are not workspaces
|
|
31
|
-
filterDependencies(dependencyNames) {
|
|
32
|
-
return dependencyNames.filter((name) => this.workspaceNames.has(name));
|
|
33
|
-
}
|
|
34
|
-
convert(iterator) {
|
|
35
|
-
return Object.entries(this.loadedFiles).map(([rootPath, { name, data }]) => {
|
|
36
|
-
const res = iterator(data);
|
|
37
|
-
return { rootPath, language: this.language, name, ...res };
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-package-json.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/process-package-json.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAYtE,wBAAgB,cAAc,gCAqC7B"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import { globSync } from "glob";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { packageFileNodeSchema } from "../../types";
|
|
6
|
-
import { PackageDataProcessor } from "./process-common";
|
|
7
|
-
const rootPath = process.env.MONOREPO_ROOT || process.cwd();
|
|
8
|
-
const rootPkgJsonPath = path.join(rootPath, "package.json");
|
|
9
|
-
const rootPkgJson = JSON.parse(fs.readFileSync(rootPkgJsonPath, "utf8"));
|
|
10
|
-
const _workspaces = {};
|
|
11
|
-
let _workspacesLoaded = false;
|
|
12
|
-
export function nodeWorkspaces() {
|
|
13
|
-
if (!_workspacesLoaded) {
|
|
14
|
-
const allPackageJsons = (rootPkgJson.workspaces ?? []).flatMap((workspaceGlob) => globSync(path.join(rootPath, workspaceGlob, "package.json")));
|
|
15
|
-
const processor = new PackageDataProcessor({
|
|
16
|
-
language: "node",
|
|
17
|
-
pathList: allPackageJsons,
|
|
18
|
-
zodSchema: packageFileNodeSchema,
|
|
19
|
-
fileParser: JSON.parse,
|
|
20
|
-
nameExtractor: (data) => data.name,
|
|
21
|
-
});
|
|
22
|
-
processor
|
|
23
|
-
.convert((data) => {
|
|
24
|
-
const { dependencies, ...rest } = data;
|
|
25
|
-
const dependencyNames = Object.keys(dependencies ?? []);
|
|
26
|
-
return {
|
|
27
|
-
...rest,
|
|
28
|
-
dependencyNames: processor.filterDependencies(dependencyNames),
|
|
29
|
-
};
|
|
30
|
-
})
|
|
31
|
-
.forEach((pkgData) => {
|
|
32
|
-
_workspaces[pkgData.name] = pkgData;
|
|
33
|
-
});
|
|
34
|
-
console.warn(chalk.yellow(
|
|
35
|
-
// prettier-ignore
|
|
36
|
-
`Node workspace discovery initialized. Workspaces found: ${Object.keys(_workspaces).join(", ")}`));
|
|
37
|
-
_workspacesLoaded = true;
|
|
38
|
-
}
|
|
39
|
-
return _workspaces;
|
|
40
|
-
}
|