@vaharoni/devops 1.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/dist/app-support/crypto/index.d.ts +15 -0
- package/dist/app-support/crypto/index.d.ts.map +1 -0
- package/dist/app-support/crypto/index.js +30 -0
- package/dist/app-support/crypto/internal-token.d.ts +20 -0
- package/dist/app-support/crypto/internal-token.d.ts.map +1 -0
- package/dist/app-support/crypto/internal-token.js +42 -0
- package/dist/app-support/crypto/internal-token.spec.d.ts +2 -0
- package/dist/app-support/crypto/internal-token.spec.d.ts.map +1 -0
- package/dist/app-support/crypto/internal-token.spec.js +45 -0
- package/dist/app-support/crypto/secret.d.ts +3 -0
- package/dist/app-support/crypto/secret.d.ts.map +1 -0
- package/dist/app-support/crypto/secret.js +12 -0
- package/dist/app-support/crypto/secret.spec.d.ts +2 -0
- package/dist/app-support/crypto/secret.spec.d.ts.map +1 -0
- package/dist/app-support/crypto/secret.spec.js +15 -0
- package/dist/app-support/discovery/dev-discovery-loader.d.ts +2 -0
- package/dist/app-support/discovery/dev-discovery-loader.d.ts.map +1 -0
- package/dist/app-support/discovery/dev-discovery-loader.js +30 -0
- package/dist/app-support/discovery/service-endpoint.d.ts +2 -0
- package/dist/app-support/discovery/service-endpoint.d.ts.map +1 -0
- package/dist/app-support/discovery/service-endpoint.js +10 -0
- package/dist/cli/affected.d.ts +11 -0
- package/dist/cli/affected.d.ts.map +1 -0
- package/dist/cli/affected.js +103 -0
- package/dist/cli/common.d.ts +89 -0
- package/dist/cli/common.d.ts.map +1 -0
- package/dist/cli/common.js +236 -0
- package/dist/cli/common.spec.d.ts +2 -0
- package/dist/cli/common.spec.d.ts.map +1 -0
- package/dist/cli/common.spec.js +64 -0
- package/dist/cli/console.d.ts +11 -0
- package/dist/cli/console.d.ts.map +1 -0
- package/dist/cli/console.js +35 -0
- package/dist/cli/constant.d.ts +11 -0
- package/dist/cli/constant.d.ts.map +1 -0
- package/dist/cli/constant.js +22 -0
- package/dist/cli/db.d.ts +11 -0
- package/dist/cli/db.d.ts.map +1 -0
- package/dist/cli/db.js +119 -0
- package/dist/cli/dml.d.ts +11 -0
- package/dist/cli/dml.d.ts.map +1 -0
- package/dist/cli/dml.js +116 -0
- package/dist/cli/env.d.ts +11 -0
- package/dist/cli/env.d.ts.map +1 -0
- package/dist/cli/env.js +67 -0
- package/dist/cli/exec.d.ts +11 -0
- package/dist/cli/exec.d.ts.map +1 -0
- package/dist/cli/exec.js +50 -0
- package/dist/cli/image.d.ts +11 -0
- package/dist/cli/image.d.ts.map +1 -0
- package/dist/cli/image.js +140 -0
- package/dist/cli/init.d.ts +11 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +66 -0
- package/dist/cli/internal-curl.d.ts +11 -0
- package/dist/cli/internal-curl.d.ts.map +1 -0
- package/dist/cli/internal-curl.js +43 -0
- package/dist/cli/job.d.ts +11 -0
- package/dist/cli/job.d.ts.map +1 -0
- package/dist/cli/job.js +67 -0
- package/dist/cli/jwt.d.ts +11 -0
- package/dist/cli/jwt.d.ts.map +1 -0
- package/dist/cli/jwt.js +27 -0
- package/dist/cli/namespace.d.ts +11 -0
- package/dist/cli/namespace.d.ts.map +1 -0
- package/dist/cli/namespace.js +70 -0
- package/dist/cli/prep-build.d.ts +11 -0
- package/dist/cli/prep-build.d.ts.map +1 -0
- package/dist/cli/prep-build.js +82 -0
- package/dist/cli/prisma.d.ts +11 -0
- package/dist/cli/prisma.d.ts.map +1 -0
- package/dist/cli/prisma.js +25 -0
- package/dist/cli/redis.d.ts +11 -0
- package/dist/cli/redis.d.ts.map +1 -0
- package/dist/cli/redis.js +76 -0
- package/dist/cli/registry.d.ts +11 -0
- package/dist/cli/registry.d.ts.map +1 -0
- package/dist/cli/registry.js +58 -0
- package/dist/cli/run-many.d.ts +11 -0
- package/dist/cli/run-many.d.ts.map +1 -0
- package/dist/cli/run-many.js +50 -0
- package/dist/cli/run.d.ts +11 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +37 -0
- package/dist/cli/template.d.ts +11 -0
- package/dist/cli/template.d.ts.map +1 -0
- package/dist/cli/template.js +123 -0
- package/dist/cli/test.d.ts +11 -0
- package/dist/cli/test.d.ts.map +1 -0
- package/dist/cli/test.js +28 -0
- package/dist/devops.d.ts +3 -0
- package/dist/devops.d.ts.map +1 -0
- package/dist/devops.js +103 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/libs/affected-entities.d.ts +15 -0
- package/dist/libs/affected-entities.d.ts.map +1 -0
- package/dist/libs/affected-entities.js +52 -0
- package/dist/libs/config.d.ts +6 -0
- package/dist/libs/config.d.ts.map +1 -0
- package/dist/libs/config.js +98 -0
- package/dist/libs/dependencies.d.ts +19 -0
- package/dist/libs/dependencies.d.ts.map +1 -0
- package/dist/libs/dependencies.js +62 -0
- package/dist/libs/dependencies.spec.d.ts +2 -0
- package/dist/libs/dependencies.spec.d.ts.map +1 -0
- package/dist/libs/dependencies.spec.js +21 -0
- package/dist/libs/digital-ocean/container-reg.d.ts +6 -0
- package/dist/libs/digital-ocean/container-reg.d.ts.map +1 -0
- package/dist/libs/digital-ocean/container-reg.js +69 -0
- package/dist/libs/discovery/dependencies.d.ts +19 -0
- package/dist/libs/discovery/dependencies.d.ts.map +1 -0
- package/dist/libs/discovery/dependencies.js +62 -0
- package/dist/libs/discovery/dependencies.spec.d.ts +2 -0
- package/dist/libs/discovery/dependencies.spec.d.ts.map +1 -0
- package/dist/libs/discovery/dependencies.spec.js +21 -0
- package/dist/libs/discovery/images.d.ts +5 -0
- package/dist/libs/discovery/images.d.ts.map +1 -0
- package/dist/libs/discovery/images.js +45 -0
- package/dist/libs/discovery/index.d.ts +5 -0
- package/dist/libs/discovery/index.d.ts.map +1 -0
- package/dist/libs/discovery/index.js +55 -0
- package/dist/libs/discovery/package-json-processor.d.ts +3 -0
- package/dist/libs/discovery/package-json-processor.d.ts.map +1 -0
- package/dist/libs/discovery/package-json-processor.js +34 -0
- package/dist/libs/discovery/process-common.d.ts +25 -0
- package/dist/libs/discovery/process-common.d.ts.map +1 -0
- package/dist/libs/discovery/process-common.js +40 -0
- package/dist/libs/discovery/process-package-json.d.ts +3 -0
- package/dist/libs/discovery/process-package-json.d.ts.map +1 -0
- package/dist/libs/discovery/process-package-json.js +34 -0
- package/dist/libs/discovery/process-pyproject-toml.d.ts +3 -0
- package/dist/libs/discovery/process-pyproject-toml.d.ts.map +1 -0
- package/dist/libs/discovery/process-pyproject-toml.js +36 -0
- package/dist/libs/discovery/pyproject-toml-processor.d.ts +3 -0
- package/dist/libs/discovery/pyproject-toml-processor.d.ts.map +1 -0
- package/dist/libs/discovery/pyproject-toml-processor.js +39 -0
- package/dist/libs/git-helpers.d.ts +8 -0
- package/dist/libs/git-helpers.d.ts.map +1 -0
- package/dist/libs/git-helpers.js +20 -0
- package/dist/libs/hetzner/reg-secret.d.ts +3 -0
- package/dist/libs/hetzner/reg-secret.d.ts.map +1 -0
- package/dist/libs/hetzner/reg-secret.js +39 -0
- package/dist/libs/k8s-constants.d.ts +12 -0
- package/dist/libs/k8s-constants.d.ts.map +1 -0
- package/dist/libs/k8s-constants.js +66 -0
- package/dist/libs/k8s-db.d.ts +18 -0
- package/dist/libs/k8s-db.d.ts.map +1 -0
- package/dist/libs/k8s-db.js +73 -0
- package/dist/libs/k8s-generate.d.ts +17 -0
- package/dist/libs/k8s-generate.d.ts.map +1 -0
- package/dist/libs/k8s-generate.js +179 -0
- package/dist/libs/k8s-helpers.d.ts +11 -0
- package/dist/libs/k8s-helpers.d.ts.map +1 -0
- package/dist/libs/k8s-helpers.js +42 -0
- package/dist/libs/k8s-image-config.d.ts +8 -0
- package/dist/libs/k8s-image-config.d.ts.map +1 -0
- package/dist/libs/k8s-image-config.js +113 -0
- package/dist/libs/k8s-job-waiter.d.ts +8 -0
- package/dist/libs/k8s-job-waiter.d.ts.map +1 -0
- package/dist/libs/k8s-job-waiter.js +84 -0
- package/dist/libs/k8s-namespace.d.ts +7 -0
- package/dist/libs/k8s-namespace.d.ts.map +1 -0
- package/dist/libs/k8s-namespace.js +27 -0
- package/dist/libs/k8s-redis.d.ts +6 -0
- package/dist/libs/k8s-redis.d.ts.map +1 -0
- package/dist/libs/k8s-redis.js +31 -0
- package/dist/libs/k8s-secrets-manager.d.ts +5 -0
- package/dist/libs/k8s-secrets-manager.d.ts.map +1 -0
- package/dist/libs/k8s-secrets-manager.js +61 -0
- package/dist/libs/validate-env.d.ts +56 -0
- package/dist/libs/validate-env.d.ts.map +1 -0
- package/dist/libs/validate-env.js +214 -0
- package/dist/libs/validate-env.spec.d.ts +2 -0
- package/dist/libs/validate-env.spec.d.ts.map +1 -0
- package/dist/libs/validate-env.spec.js +168 -0
- package/dist/libs/workspace-discovery.d.ts +2 -0
- package/dist/libs/workspace-discovery.d.ts.map +1 -0
- package/dist/libs/workspace-discovery.js +75 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +1 -0
- package/dist/types/index.d.ts +925 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +79 -0
- package/package.json +55 -0
- package/src/app-support/crypto/index.ts +31 -0
- package/src/app-support/crypto/internal-token.spec.ts +53 -0
- package/src/app-support/crypto/internal-token.ts +82 -0
- package/src/app-support/crypto/secret.spec.ts +18 -0
- package/src/app-support/crypto/secret.ts +13 -0
- package/src/app-support/discovery/dev-discovery-loader.ts +35 -0
- package/src/app-support/discovery/service-endpoint.ts +12 -0
- package/src/cli/affected.ts +116 -0
- package/src/cli/common.spec.ts +78 -0
- package/src/cli/common.ts +323 -0
- package/src/cli/console.ts +46 -0
- package/src/cli/constant.ts +25 -0
- package/src/cli/db.ts +133 -0
- package/src/cli/dml.ts +126 -0
- package/src/cli/env.ts +87 -0
- package/src/cli/exec.sh +21 -0
- package/src/cli/exec.ts +57 -0
- package/src/cli/image.ts +197 -0
- package/src/cli/init.ts +75 -0
- package/src/cli/internal-curl.ts +48 -0
- package/src/cli/job.ts +80 -0
- package/src/cli/jwt.ts +32 -0
- package/src/cli/namespace.ts +78 -0
- package/src/cli/prep-build.ts +96 -0
- package/src/cli/prisma.ts +33 -0
- package/src/cli/redis.ts +83 -0
- package/src/cli/registry.ts +76 -0
- package/src/cli/run-many.ts +61 -0
- package/src/cli/run.ts +46 -0
- package/src/cli/template.ts +169 -0
- package/src/cli/test.ts +30 -0
- package/src/devops.ts +119 -0
- package/src/index.ts +3 -0
- package/src/libs/affected-entities.ts +71 -0
- package/src/libs/config.ts +117 -0
- package/src/libs/digital-ocean/container-reg.ts +81 -0
- package/src/libs/discovery/dependencies.spec.ts +25 -0
- package/src/libs/discovery/dependencies.ts +73 -0
- package/src/libs/discovery/images.ts +57 -0
- package/src/libs/discovery/index.ts +60 -0
- package/src/libs/discovery/process-common.ts +55 -0
- package/src/libs/discovery/process-package-json.ts +47 -0
- package/src/libs/discovery/process-pyproject-toml.ts +43 -0
- package/src/libs/git-helpers.ts +32 -0
- package/src/libs/hetzner/reg-secret.ts +54 -0
- package/src/libs/k8s-constants.ts +83 -0
- package/src/libs/k8s-db.ts +83 -0
- package/src/libs/k8s-generate.ts +211 -0
- package/src/libs/k8s-helpers.ts +59 -0
- package/src/libs/k8s-image-config.ts +165 -0
- package/src/libs/k8s-job-waiter.ts +124 -0
- package/src/libs/k8s-namespace.ts +41 -0
- package/src/libs/k8s-redis.ts +31 -0
- package/src/libs/k8s-secrets-manager.ts +79 -0
- package/src/libs/validate-env.spec.ts +223 -0
- package/src/libs/validate-env.ts +266 -0
- package/src/target-templates/.devops/config/constants.yaml +17 -0
- package/src/target-templates/.devops/config/images.yaml +88 -0
- package/src/target-templates/.devops/docker-images/common/docker-common.sh +23 -0
- package/src/target-templates/.devops/docker-images/node-services/node-exec.sh +8 -0
- package/src/target-templates/.devops/docker-images/node-services/node-run.sh +8 -0
- package/src/target-templates/.devops/docker-images/node-services.Dockerfile +34 -0
- package/src/target-templates/.devops/docker-images/python-services/python-exec.sh +8 -0
- package/src/target-templates/.devops/docker-images/python-services/python-run.sh +8 -0
- package/src/target-templates/.devops/docker-images/python-services.Dockerfile +29 -0
- package/src/target-templates/.devops/env.example.yaml +23 -0
- package/src/target-templates/.devops/infra/hetzner/abandoned/harbor-values.yaml +30 -0
- package/src/target-templates/.devops/infra/hetzner/abandoned/hcloud-config.yaml +134 -0
- package/src/target-templates/.devops/infra/hetzner/cert-manager.yaml +25 -0
- package/src/target-templates/.devops/infra/hetzner/harbor-cert.yaml +13 -0
- package/src/target-templates/.devops/infra/hetzner/harbor-values.yaml +76 -0
- package/src/target-templates/.devops/infra/hetzner/hcloud-config.yaml +113 -0
- package/src/target-templates/.devops/infra/hetzner/ingress-nginx-annotations.yaml +49 -0
- package/src/target-templates/.devops/infra/hetzner/ingress-nginx-configmap.yaml +8 -0
- package/src/target-templates/.devops/infra/hetzner/retain-storage-class.yaml +8 -0
- package/src/target-templates/.devops/infra/monitoring-ingress.yaml +62 -0
- package/src/target-templates/.devops/infra/stackgres-ui-ingress.yaml +35 -0
- package/src/target-templates/.devops/infra/test.yaml +60 -0
- package/src/target-templates/.devops/manifests/_index.yaml +21 -0
- package/src/target-templates/.devops/manifests/cron-jobs.yaml.hb +55 -0
- package/src/target-templates/.devops/manifests/db-migrate-job.yaml.hb +42 -0
- package/src/target-templates/.devops/manifests/deployment-debug.yaml.hb +44 -0
- package/src/target-templates/.devops/manifests/deployment-process.yaml.hb +47 -0
- package/src/target-templates/.devops/manifests/deployment-web.yaml.hb +53 -0
- package/src/target-templates/.devops/manifests/ingress.yaml.hb +21 -0
- package/src/target-templates/.devops/manifests/prefect.yaml.hb +62 -0
- package/src/target-templates/.devops/manifests/service.yaml.hb +15 -0
- package/src/target-templates/.devops/milvus/production/milvus-values.yaml +2 -0
- package/src/target-templates/.devops/milvus/staging/milvus-values.yaml +2 -0
- package/src/target-templates/.devops/postgres/DailyOperatorRestart.yaml +54 -0
- package/src/target-templates/.devops/postgres/production/cluster/PodDisruptionBudget.yaml +27 -0
- package/src/target-templates/.devops/postgres/production/cluster/SGCluster.yaml +47 -0
- package/src/target-templates/.devops/postgres/production/cluster/StackGres-alerts.yaml +191 -0
- package/src/target-templates/.devops/postgres/production/configurations/06-SGDistributedLogs.yaml +11 -0
- package/src/target-templates/.devops/postgres/production/configurations/07-SGObjectStorage.yaml +18 -0
- package/src/target-templates/.devops/postgres/production/configurations/08-SGScript.yaml +12 -0
- package/src/target-templates/.devops/postgres/staging/cluster/SGCluster.yaml +42 -0
- package/src/target-templates/.devops/postgres/staging/configurations/07-SGObjectStorage.yaml +18 -0
- package/src/target-templates/.devops/postgres/staging/configurations/08-SGScript.yaml +12 -0
- package/src/target-templates/.devops/prefect/production/prefect-values.yaml +14 -0
- package/src/target-templates/.devops/prefect/staging/prefect-values.yaml +14 -0
- package/src/target-templates/.devops/redis/production/redis-values.yaml +20 -0
- package/src/target-templates/.devops/redis/staging/redis-values.yaml +8 -0
- package/src/target-templates/.envrc +5 -0
- package/src/target-templates/.github/actions/build-image@v1/action.yaml +86 -0
- package/src/target-templates/.github/actions/connect-to-digital-ocean@v1/action.yaml +29 -0
- package/src/target-templates/.github/actions/connect-to-hetzner@v1/action.yaml +31 -0
- package/src/target-templates/.github/actions/connect-to-infra@v1/action.yaml +46 -0
- package/src/target-templates/.github/actions/db-migrate@v1/action.yaml +23 -0
- package/src/target-templates/.github/actions/deploy-image@v1/action.yaml +33 -0
- package/src/target-templates/.github/actions/setup-prereq@v1/action.yaml +29 -0
- package/src/target-templates/.github/workflows/k8s-build.yaml +84 -0
- package/src/target-templates/applications/example-data-pipeline/pyproject.toml +14 -0
- package/src/target-templates/applications/example-data-pipeline/src/example_data_pipeline/main.py +38 -0
- package/src/target-templates/applications/example-node/index.ts +30 -0
- package/src/target-templates/applications/example-node/package.json +26 -0
- package/src/target-templates/applications/example-node/tsconfig.json +3 -0
- package/src/target-templates/applications/example-python/pyproject.toml +20 -0
- package/src/target-templates/applications/example-python/src/example_python/__init__.py +0 -0
- package/src/target-templates/applications/example-python/src/example_python/main.py +13 -0
- package/src/target-templates/applications/example-python/src/example_python/scripts.py +17 -0
- package/src/target-templates/applications/example-python/tests/__init__.py +0 -0
- package/src/target-templates/applications/jobs/README.md +68 -0
- package/src/target-templates/applications/jobs/index.ts +1 -0
- package/src/target-templates/applications/jobs/package.json +30 -0
- package/src/target-templates/applications/jobs/tsconfig.json +3 -0
- package/src/target-templates/config/.env.development +1 -0
- package/src/target-templates/config/.env.global +4 -0
- package/src/target-templates/config/.env.test +1 -0
- package/src/target-templates/db/db/__init__.py +0 -0
- package/src/target-templates/db/db/db_client_test.py +46 -0
- package/src/target-templates/db/db-client-test.ts +140 -0
- package/src/target-templates/db/db-client.ts +19 -0
- package/src/target-templates/db/env.yaml +4 -0
- package/src/target-templates/db/package.json +17 -0
- package/src/target-templates/db/prisma/schema.prisma +24 -0
- package/src/target-templates/db/prisma-setup-vitest.ts +27 -0
- package/src/target-templates/db/pyproject.toml +14 -0
- package/src/target-templates/db/tsconfig.json +3 -0
- package/src/target-templates/devops +3 -0
- package/src/target-templates/devopspy +3 -0
- package/src/target-templates/dml/package.json +7 -0
- package/src/target-templates/dml/tsconfig.json +3 -0
- package/src/target-templates/libs/example-node-lib/bun.lock +27 -0
- package/src/target-templates/libs/example-node-lib/index.ts +3 -0
- package/src/target-templates/libs/example-node-lib/package.json +12 -0
- package/src/target-templates/libs/example-node-lib/tsconfig.json +3 -0
- package/src/target-templates/libs/example-python-lib/pyproject.toml +11 -0
- package/src/target-templates/libs/example-python-lib/src/example_python_lib/__init__.py +2 -0
- package/src/target-templates/pyproject.toml +19 -0
- package/src/target-templates/tmp/.gitkeep +0 -0
- package/src/target-templates/tsconfig.json +27 -0
- package/src/test.ts +0 -0
- package/src/types/index.ts +173 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
import fs from "fs-extra";
|
2
|
+
import os from "os";
|
3
|
+
import path from "path";
|
4
|
+
import { CLICommandParser, printUsageAndExit } from "./common";
|
5
|
+
import { getImageData, getTemplateData } from "../libs/config";
|
6
|
+
import { getMonorepoSecret } from "../libs/k8s-secrets-manager";
|
7
|
+
import { getImageDescendentData } from "../libs/discovery/images";
|
8
|
+
const oneLiner = "Copies all dependencies of an image to a temporary folder in preparation for a Docker build";
|
9
|
+
const keyExamples = `
|
10
|
+
$ devops prep-build main-node
|
11
|
+
`.trim();
|
12
|
+
const usage = `
|
13
|
+
${oneLiner}
|
14
|
+
|
15
|
+
USAGE
|
16
|
+
devops prep-build <image>
|
17
|
+
|
18
|
+
EXAMPLES
|
19
|
+
${keyExamples}
|
20
|
+
`;
|
21
|
+
async function run(cmdObj) {
|
22
|
+
if (cmdObj.help || cmdObj.args.length === 0)
|
23
|
+
printUsageAndExit(usage);
|
24
|
+
const [image] = cmdObj.args;
|
25
|
+
const imageData = getImageData(image);
|
26
|
+
const imageTemplate = imageData["image-template"];
|
27
|
+
const dockerFile = `${imageTemplate}.Dockerfile`;
|
28
|
+
const dockerFilePath = path.join(".devops/docker-images", dockerFile);
|
29
|
+
const dockerImagePayloadPath = path.join(".devops/docker-images", imageTemplate);
|
30
|
+
const dockerCommonPayloadPath = path.join(".devops/docker-images", "common");
|
31
|
+
const imageTemplateData = getTemplateData(imageTemplate);
|
32
|
+
const copyCommon = imageTemplateData["copy-common"] ?? false;
|
33
|
+
const imageExtraContent = imageTemplateData["extra-content"] ?? [];
|
34
|
+
if (!fs.existsSync(dockerFilePath)) {
|
35
|
+
console.error(`The dockerfile ${dockerFilePath} does not exist`);
|
36
|
+
process.exit(1);
|
37
|
+
}
|
38
|
+
imageExtraContent.forEach((file) => {
|
39
|
+
if (!fs.existsSync(file)) {
|
40
|
+
console.error(`The file ${file} is specified in the extra-content section of ${image} but does not exist`);
|
41
|
+
process.exit(1);
|
42
|
+
}
|
43
|
+
});
|
44
|
+
const destFolder = `${os.tmpdir()}/image-${image}-${Date.now()}`;
|
45
|
+
// Avoid clutter stdout, as the caller will want to capture the final output to cd into it
|
46
|
+
console.warn(`Creating build in ${destFolder}`);
|
47
|
+
fs.mkdirSync(destFolder);
|
48
|
+
// Copy Dockerfile
|
49
|
+
console.warn(`COPYING Dockerfile`);
|
50
|
+
fs.copySync(dockerFilePath, path.join(destFolder, "Dockerfile"));
|
51
|
+
if (copyCommon) {
|
52
|
+
console.warn(`COPYING Docker common`);
|
53
|
+
fs.copySync(dockerCommonPayloadPath, destFolder);
|
54
|
+
}
|
55
|
+
console.warn(`COPYING Docker image payload`);
|
56
|
+
fs.copySync(dockerImagePayloadPath, destFolder);
|
57
|
+
console.warn(`COPYING .devops/config`);
|
58
|
+
fs.mkdirSync(path.join(destFolder, ".devops"));
|
59
|
+
fs.copySync(".devops/config", path.join(destFolder, ".devops/config"));
|
60
|
+
// Create config directory. It should be deleted by the docker image so that it can be mounted as a volume when the pod is run
|
61
|
+
console.warn(`CREATING config for the build process`);
|
62
|
+
fs.mkdirSync(path.join(destFolder, "config"));
|
63
|
+
const envFileData = getMonorepoSecret(cmdObj.env);
|
64
|
+
fs.writeFileSync(path.join(destFolder, `config/.env.global`), envFileData);
|
65
|
+
// Copy all dependencies
|
66
|
+
getImageDescendentData(image).forEach((project) => {
|
67
|
+
console.warn(`COPYING ${project.rootPath}`);
|
68
|
+
if (project.rootPath === ".devops")
|
69
|
+
return;
|
70
|
+
fs.copySync(project.rootPath, path.join(destFolder, project.rootPath));
|
71
|
+
});
|
72
|
+
// Copy image-extra content
|
73
|
+
console.warn(`COPYING files from image-extra-content`);
|
74
|
+
imageExtraContent.forEach((file) => {
|
75
|
+
fs.copySync(file, path.join(destFolder, file));
|
76
|
+
console.warn(` ${file}`);
|
77
|
+
});
|
78
|
+
console.log(destFolder);
|
79
|
+
}
|
80
|
+
export default {
|
81
|
+
"prep-build": { oneLiner, keyExamples, run },
|
82
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { CLICommandParser } from "./common";
|
2
|
+
declare function run(cmdObj: CLICommandParser): Promise<void>;
|
3
|
+
declare const _default: {
|
4
|
+
prisma: {
|
5
|
+
oneLiner: string;
|
6
|
+
keyExamples: string;
|
7
|
+
run: typeof run;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export default _default;
|
11
|
+
//# sourceMappingURL=prisma.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/cli/prisma.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,UAAU,CAAC;AAuB/D,iBAAe,GAAG,CAAC,MAAM,EAAE,gBAAgB,iBAK1C;;;;;;;;AAED,wBAEE"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { CLICommandParser, printUsageAndExit } from "./common";
|
2
|
+
import url from "url";
|
3
|
+
import path from "path";
|
4
|
+
const __file__ = url.fileURLToPath(import.meta.url);
|
5
|
+
const __src__ = path.join(path.dirname(__file__), "../..", "src");
|
6
|
+
const execShPath = path.join(__src__, "cli/exec.sh");
|
7
|
+
const oneLiner = "Runs prisma commands in the db project after injecting the environment variables";
|
8
|
+
const keyExamples = `$ devops prisma migrate dev`;
|
9
|
+
const usage = `
|
10
|
+
${oneLiner}
|
11
|
+
|
12
|
+
GENERAL USAGE
|
13
|
+
devops prisma <command>
|
14
|
+
|
15
|
+
<command> can be any command you normally set prisma for.
|
16
|
+
|
17
|
+
EXAMPLES
|
18
|
+
${keyExamples}
|
19
|
+
`;
|
20
|
+
async function run(cmdObj) {
|
21
|
+
cmdObj.executorFromEnv(`${execShPath} db prisma ${cmdObj.args.join(" ")}`, { checkEnvYaml: false }).spawn();
|
22
|
+
}
|
23
|
+
export default {
|
24
|
+
prisma: { oneLiner, keyExamples, run },
|
25
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { CLICommandParser } from "./common";
|
2
|
+
declare function run(cmdObj: CLICommandParser): void;
|
3
|
+
declare const _default: {
|
4
|
+
redis: {
|
5
|
+
oneLiner: string;
|
6
|
+
keyExamples: string;
|
7
|
+
run: typeof run;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export default _default;
|
11
|
+
//# sourceMappingURL=redis.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/cli/redis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,UAAU,CAAC;AA2D7E,iBAAS,GAAG,CAAC,MAAM,EAAE,gBAAgB,QAiBpC;;;;;;;;AAED,wBAEE"}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import chalk from "chalk";
|
2
|
+
import { establishRedisTunnel, getRedisList, getRedisPassword } from "../libs/k8s-redis";
|
3
|
+
import { CLICommandParser, printUsageAndExit, StrongParams } from "./common";
|
4
|
+
const oneLiner = "Utilities to help accessing production and staging redis";
|
5
|
+
const keyExamples = `
|
6
|
+
$ devops redis list
|
7
|
+
$ devops redis password redis-staging
|
8
|
+
$ devops redis tunnel redis-staging
|
9
|
+
`.trim();
|
10
|
+
const usage = `
|
11
|
+
${oneLiner}
|
12
|
+
|
13
|
+
COMMANDS
|
14
|
+
list Lists the available redis installations
|
15
|
+
password <namespace> Shows the password for the Redis instance
|
16
|
+
tunnel <namespace> [-p <port>] Sets up a tunnel to the remote Redis instance so you can access the DB from your local machine on port 9379 by default
|
17
|
+
|
18
|
+
NOTES
|
19
|
+
This command assumes the namespace and the helm release name are the same.
|
20
|
+
The --env flag should not be used with these commands, as the Redis namespaces follow different conventions than the monorepo env.
|
21
|
+
|
22
|
+
EXAMPLES
|
23
|
+
${keyExamples}
|
24
|
+
`;
|
25
|
+
const handlers = {
|
26
|
+
list: () => {
|
27
|
+
const res = getRedisList();
|
28
|
+
console.log(res);
|
29
|
+
},
|
30
|
+
password: (opts) => {
|
31
|
+
const namespace = opts.required("namespace");
|
32
|
+
const res = getRedisPassword(namespace);
|
33
|
+
if (!res) {
|
34
|
+
console.error("Failed to get the secret");
|
35
|
+
process.exit(1);
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
console.log();
|
39
|
+
console.log(res.password);
|
40
|
+
console.log();
|
41
|
+
}
|
42
|
+
},
|
43
|
+
tunnel: (opts) => {
|
44
|
+
const namespace = opts.required("namespace");
|
45
|
+
const port = opts.optional("port") ?? '9379';
|
46
|
+
const res = getRedisPassword(namespace);
|
47
|
+
console.log(chalk.blue('\nAfter the tunnel is established, connect to Redis by running:\n\t') +
|
48
|
+
chalk.green.bold(`redis-cli -p ${port} --askpass`));
|
49
|
+
if (res) {
|
50
|
+
console.log(chalk.blue('\tPassword: ') + chalk.green.bold(res.password));
|
51
|
+
console.log();
|
52
|
+
}
|
53
|
+
establishRedisTunnel(namespace, port);
|
54
|
+
},
|
55
|
+
};
|
56
|
+
function run(cmdObj) {
|
57
|
+
if (cmdObj.help || cmdObj.args.length < 1)
|
58
|
+
printUsageAndExit(usage);
|
59
|
+
const parsed = cmdObj.parseOptions({ params: ["-p"] });
|
60
|
+
const [command, namespace] = parsed.args;
|
61
|
+
const port = parsed.options["-p"];
|
62
|
+
// @ts-expect-error left as an exercise for the reader
|
63
|
+
const handler = handlers[command];
|
64
|
+
if (!handler) {
|
65
|
+
console.error(`Unknown command: ${command}`);
|
66
|
+
printUsageAndExit(usage);
|
67
|
+
}
|
68
|
+
const params = new StrongParams(usage, {
|
69
|
+
namespace,
|
70
|
+
port,
|
71
|
+
});
|
72
|
+
handler(params);
|
73
|
+
}
|
74
|
+
export default {
|
75
|
+
redis: { oneLiner, keyExamples, run },
|
76
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { CLICommandParser } from "./common";
|
2
|
+
declare function run(cmdObj: CLICommandParser): void;
|
3
|
+
declare const _default: {
|
4
|
+
registry: {
|
5
|
+
oneLiner: string;
|
6
|
+
keyExamples: string;
|
7
|
+
run: typeof run;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export default _default;
|
11
|
+
//# sourceMappingURL=registry.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/cli/registry.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,UAAU,CAAC;AAoD7E,iBAAS,GAAG,CAAC,MAAM,EAAE,gBAAgB,QAYpC;;;;;;;;AAED,wBAEE"}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { getConst, getImageData } from "../libs/config";
|
2
|
+
import { prune } from "../libs/digital-ocean/container-reg";
|
3
|
+
import { containerRegistryPath, containerRegistryRepoName, containerRegistryRepoPath, } from "../libs/k8s-constants";
|
4
|
+
import { CLICommandParser, StrongParams, printUsageAndExit } from "./common";
|
5
|
+
const oneLiner = "Manage container repositories";
|
6
|
+
const keyExamples = `
|
7
|
+
$ devops registry server-url
|
8
|
+
$ devops registry reg-url
|
9
|
+
$ devops registry repo-url my-image sha
|
10
|
+
$ devops registry prune my-image
|
11
|
+
`.trim();
|
12
|
+
const usage = `
|
13
|
+
${oneLiner}
|
14
|
+
|
15
|
+
USAGE
|
16
|
+
Get base URLs
|
17
|
+
devops registry server-url
|
18
|
+
devops registry reg-url
|
19
|
+
|
20
|
+
Gets the URL of an image in the container registry:
|
21
|
+
devops registry repo-url <image> <sha> --env <env>
|
22
|
+
|
23
|
+
Prunes the repository of old images to enforce the "image-versions-to-keep" constant in config/constants.yaml:
|
24
|
+
devops registry prune <image> --env <env>
|
25
|
+
|
26
|
+
This is only relevant when the "infra" constant is set to "digitalocean".
|
27
|
+
|
28
|
+
EXAMPLES
|
29
|
+
${keyExamples}
|
30
|
+
`;
|
31
|
+
const handlers = {
|
32
|
+
"server-url": () => console.log(getConst("registry-base-url")),
|
33
|
+
"reg-url": () => console.log(containerRegistryPath()),
|
34
|
+
"repo-url": (opts) => {
|
35
|
+
console.log(containerRegistryRepoPath(opts.required("image"), opts.required("env"), opts.required("sha")));
|
36
|
+
},
|
37
|
+
prune: (opts) => {
|
38
|
+
const regName = containerRegistryPath();
|
39
|
+
const repoName = containerRegistryRepoName(opts.required("image"), opts.required("env"));
|
40
|
+
prune(regName, repoName);
|
41
|
+
},
|
42
|
+
};
|
43
|
+
function run(cmdObj) {
|
44
|
+
if (cmdObj.help || cmdObj.args.length < 1)
|
45
|
+
printUsageAndExit(usage);
|
46
|
+
const [command, image, sha] = cmdObj.args;
|
47
|
+
// @ts-expect-error left as an exercise for the reader
|
48
|
+
const handler = handlers[command];
|
49
|
+
if (!handler) {
|
50
|
+
console.error(`Unknown command: ${command}`);
|
51
|
+
printUsageAndExit(usage);
|
52
|
+
}
|
53
|
+
const params = new StrongParams(usage, { image, env: cmdObj.env, sha });
|
54
|
+
handler(params);
|
55
|
+
}
|
56
|
+
export default {
|
57
|
+
registry: { oneLiner, keyExamples, run },
|
58
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { CLICommandParser } from "./common";
|
2
|
+
declare function run(cmdObj: CLICommandParser): Promise<void>;
|
3
|
+
declare const _default: {
|
4
|
+
"run-many": {
|
5
|
+
oneLiner: string;
|
6
|
+
keyExamples: string;
|
7
|
+
run: typeof run;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export default _default;
|
11
|
+
//# sourceMappingURL=run-many.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"run-many.d.ts","sourceRoot":"","sources":["../../src/cli/run-many.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,UAAU,CAAC;AAyB/D,iBAAe,GAAG,CAAC,MAAM,EAAE,gBAAgB,iBA8B1C;;;;;;;;AAED,wBAEE"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { workspaceDirectoryForLanguage } from "../libs/discovery";
|
2
|
+
import { CLICommandParser, printUsageAndExit } from "./common";
|
3
|
+
import concurrently, {} from "concurrently";
|
4
|
+
const oneLiner = "Runs a script concurrently in all projects that define it in their package.json";
|
5
|
+
const keyExamples = `
|
6
|
+
$ devops run-many build
|
7
|
+
`.trim();
|
8
|
+
const usage = `
|
9
|
+
${oneLiner}
|
10
|
+
|
11
|
+
USAGE
|
12
|
+
devops run-many <script-name> [--kill-others-on-fail]
|
13
|
+
|
14
|
+
NOTE
|
15
|
+
Only works for node projects. Use 'devopspy' for python projects.
|
16
|
+
|
17
|
+
EXAMPLES
|
18
|
+
${keyExamples}
|
19
|
+
`;
|
20
|
+
async function run(cmdObj) {
|
21
|
+
if (cmdObj.help || cmdObj.args.length === 0)
|
22
|
+
printUsageAndExit(usage);
|
23
|
+
const parsed = cmdObj.parseOptions({ booleans: ["--kill-others-on-fail"] });
|
24
|
+
const [script] = parsed.args;
|
25
|
+
const remaining = parsed.args.slice(1).join(" ");
|
26
|
+
const commands = [];
|
27
|
+
Object.values(workspaceDirectoryForLanguage('node')).forEach(async (packageData) => {
|
28
|
+
if (packageData.scripts?.[script]) {
|
29
|
+
commands.push({
|
30
|
+
name: packageData.name,
|
31
|
+
command: `devops --env ${cmdObj.env} run ${packageData.name}:${script} ${remaining}`,
|
32
|
+
});
|
33
|
+
}
|
34
|
+
});
|
35
|
+
if (!commands.length) {
|
36
|
+
console.error(`No workspaces define the script: ${script}`);
|
37
|
+
process.exit(0);
|
38
|
+
}
|
39
|
+
// prettier-ignore
|
40
|
+
const options = parsed.options["--kill-others-on-fail"] ? { killOthers: "failure" } : {};
|
41
|
+
concurrently(commands, options)
|
42
|
+
.result.then(() => { })
|
43
|
+
.catch((error) => {
|
44
|
+
console.error("One of the commands failed");
|
45
|
+
process.exit(1);
|
46
|
+
});
|
47
|
+
}
|
48
|
+
export default {
|
49
|
+
"run-many": { oneLiner, keyExamples, run },
|
50
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { CLICommandParser } from "./common";
|
2
|
+
declare function run(cmdObj: CLICommandParser): Promise<void>;
|
3
|
+
declare const _default: {
|
4
|
+
run: {
|
5
|
+
oneLiner: string;
|
6
|
+
keyExamples: string;
|
7
|
+
run: typeof run;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export default _default;
|
11
|
+
//# sourceMappingURL=run.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,UAAU,CAAC;AA2B/D,iBAAe,GAAG,CAAC,MAAM,EAAE,gBAAgB,iBAc1C;;;;;;;;AAED,wBAEE"}
|
package/dist/cli/run.js
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
import { CLICommandParser, printUsageAndExit } from "./common";
|
2
|
+
import url from "url";
|
3
|
+
import path from "path";
|
4
|
+
import { getWorkspace } from "../libs/discovery";
|
5
|
+
const __file__ = url.fileURLToPath(import.meta.url);
|
6
|
+
const __src__ = path.join(path.dirname(__file__), "../..", "src");
|
7
|
+
const execShPath = path.join(__src__, "cli/exec.sh");
|
8
|
+
const oneLiner = "Runs a script defined in package.json after injecting env variables";
|
9
|
+
const keyExamples = `$ devops run project:test`;
|
10
|
+
const usage = `
|
11
|
+
${oneLiner}
|
12
|
+
|
13
|
+
GENERAL USAGE
|
14
|
+
devops run <project-name>:<script-name> [--] [options for script]
|
15
|
+
|
16
|
+
NOTES
|
17
|
+
- Only works for node projects. Use 'devopspy' for python projects.
|
18
|
+
- Does not allow interactive mode. If you need interactivity, use devops exec instead.
|
19
|
+
|
20
|
+
EXAMPLES
|
21
|
+
${keyExamples}
|
22
|
+
`;
|
23
|
+
async function run(cmdObj) {
|
24
|
+
if (cmdObj.help || cmdObj.args.length === 0)
|
25
|
+
printUsageAndExit(usage);
|
26
|
+
const [workspace, script] = cmdObj.args[0].split(":");
|
27
|
+
if (!workspace || !script)
|
28
|
+
printUsageAndExit(usage);
|
29
|
+
const rootPath = getWorkspace(workspace).rootPath;
|
30
|
+
const remaining = cmdObj.args.slice(1).join(" ");
|
31
|
+
cmdObj
|
32
|
+
.executorFromEnv(`${execShPath} ${rootPath} bun run ${script} ${remaining}`, { checkEnvYaml: true })
|
33
|
+
.spawn();
|
34
|
+
}
|
35
|
+
export default {
|
36
|
+
run: { oneLiner, keyExamples, run },
|
37
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { CLICommandParser } from "../../src/cli/common";
|
2
|
+
declare function run(cmdObj: CLICommandParser): void;
|
3
|
+
declare const _default: {
|
4
|
+
template: {
|
5
|
+
oneLiner: string;
|
6
|
+
keyExamples: string;
|
7
|
+
run: typeof run;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export default _default;
|
11
|
+
//# sourceMappingURL=template.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/cli/template.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,sBAAsB,CAAC;AA4IzF,iBAAS,GAAG,CAAC,MAAM,EAAE,gBAAgB,QAsBpC;;;;;;;;AAED,wBAEE"}
|
@@ -0,0 +1,123 @@
|
|
1
|
+
import {} from "../libs/k8s-image-config";
|
2
|
+
import { CLICommandParser, printUsageAndExit, StrongParams } from "../../src/cli/common";
|
3
|
+
import { generateDbMigrateJob, generateDebugDeployment, generateWorkspaceDeployment, ImageContextGenerator } from "../libs/k8s-generate";
|
4
|
+
import chalk from "chalk";
|
5
|
+
import { getWorkspace } from "../libs/discovery";
|
6
|
+
import { getWorkspaceImages } from "../libs/discovery/images";
|
7
|
+
import { getImageData, getImageNames } from "../libs/config";
|
8
|
+
const SUPPORTED_CONTEXT_TYPES = ['deployment', 'db-migrate', 'debug'];
|
9
|
+
const oneLiner = "Utilities to help validate manifest templates rendering.";
|
10
|
+
const keyExamples = `
|
11
|
+
$ devops template context deployment www
|
12
|
+
$ devops template context debug
|
13
|
+
$ devops template context db-migrate
|
14
|
+
$ devops template gen deployment www
|
15
|
+
$ devops template gen debug main-node
|
16
|
+
$ devops template gen db-migrate
|
17
|
+
`.trim();
|
18
|
+
const usage = `
|
19
|
+
${oneLiner}
|
20
|
+
|
21
|
+
IMPORTANT
|
22
|
+
This command generates examples only. It's intended to help design new templates by showing what context variables are available
|
23
|
+
and how they get rendered using handlebar replacement. They should not be used to apply changes to the cluster.
|
24
|
+
|
25
|
+
SHOW CONTEXT OBJECT
|
26
|
+
devops template context deployment <workspace>
|
27
|
+
devops template context db-migrate-job|debug
|
28
|
+
|
29
|
+
Prints out a context object with dummy values for the specified template type.
|
30
|
+
For deployment, the workspace name is required.
|
31
|
+
|
32
|
+
GENERATE TEMPLATES
|
33
|
+
devops template gen deployment <workspace>
|
34
|
+
devops template gen debug <image>
|
35
|
+
devops template gen db-migrate-job
|
36
|
+
|
37
|
+
For deployment, generates an example manifest of a workspace, including override files present under the 'manifests' folder.
|
38
|
+
|
39
|
+
EXAMPLES
|
40
|
+
${keyExamples}
|
41
|
+
`;
|
42
|
+
const handlers = {
|
43
|
+
context: {
|
44
|
+
'deployment': (opts) => {
|
45
|
+
const workspace = opts.required('workspaceOrImage');
|
46
|
+
const workspaceData = getWorkspace(workspace);
|
47
|
+
const packageDataWithDeployment = workspaceData.packageDataEntries.find((entry) => entry.deployment);
|
48
|
+
if (!packageDataWithDeployment) {
|
49
|
+
console.error(`No deployment found for workspace ${workspace}`);
|
50
|
+
process.exit(1);
|
51
|
+
}
|
52
|
+
const randomImage = getWorkspaceImages(workspace)[0];
|
53
|
+
console.warn(chalk.green("\nThis is a sample context object used to render a manifest template of type deployment:\n"));
|
54
|
+
console.log(JSON.stringify(new ImageContextGenerator(opts.required('env'), randomImage, 'dummy-sha').getDeployment(packageDataWithDeployment), null, 2));
|
55
|
+
},
|
56
|
+
'db-migrate': (opts) => {
|
57
|
+
const randomImage = getWorkspaceImages('db').filter(image => getImageData(image)['can-db-migrate'])[0];
|
58
|
+
if (!randomImage) {
|
59
|
+
console.error("No image found with can-db-migrate=true in the db workspace.");
|
60
|
+
process.exit(1);
|
61
|
+
}
|
62
|
+
console.warn(chalk.green("\nThis is a sample context object used to render a manifest template of type db-migrate:\n"));
|
63
|
+
console.log(JSON.stringify(new ImageContextGenerator(opts.required('env'), randomImage, 'dummy-sha').getDbMigrate(), null, 2));
|
64
|
+
},
|
65
|
+
'debug': (opts) => {
|
66
|
+
const randomImage = getImageNames()[0];
|
67
|
+
console.warn(chalk.green("\nThis is a sample context object used to render a manifest template of type debug:\n"));
|
68
|
+
console.log(JSON.stringify(new ImageContextGenerator(opts.required('env'), randomImage, 'dummy-sha').getDebug(), null, 2));
|
69
|
+
},
|
70
|
+
},
|
71
|
+
gen: {
|
72
|
+
'deployment': (opts) => {
|
73
|
+
const workspace = opts.required('workspaceOrImage');
|
74
|
+
const workspaceData = getWorkspace(workspace);
|
75
|
+
const packageDataWithDeployment = workspaceData.packageDataEntries.find((entry) => entry.deployment);
|
76
|
+
if (!packageDataWithDeployment) {
|
77
|
+
console.error(`No deployment found for workspace ${workspace}`);
|
78
|
+
process.exit(1);
|
79
|
+
}
|
80
|
+
const randomImage = getWorkspaceImages(workspace)[0];
|
81
|
+
console.warn(chalk.green(`\nThis is a sample of generated manifests for the ${workspace} workspace:\n`));
|
82
|
+
console.log(generateWorkspaceDeployment(packageDataWithDeployment, opts.required('env'), randomImage, 'dummy-sha'));
|
83
|
+
},
|
84
|
+
'db-migrate': (opts) => {
|
85
|
+
const randomImage = getWorkspaceImages('db').filter(image => getImageData(image)['can-db-migrate'])[0];
|
86
|
+
if (!randomImage) {
|
87
|
+
console.error("No image found with can-db-migrate=true in the db workspace.");
|
88
|
+
process.exit(1);
|
89
|
+
}
|
90
|
+
console.warn(chalk.green("\nThis is a sample of generated manifests for the db-migrate job:\n"));
|
91
|
+
console.log(generateDbMigrateJob(opts.required('env'), randomImage, 'dummy-sha'));
|
92
|
+
},
|
93
|
+
'debug': (opts) => {
|
94
|
+
const image = opts.required('workspaceOrImage');
|
95
|
+
console.warn(chalk.green(`\nThis is a sample of generated manifests for the debug image ${image}:\n`));
|
96
|
+
console.log(generateDebugDeployment(opts.required('env'), image, 'dummy-sha'));
|
97
|
+
},
|
98
|
+
},
|
99
|
+
};
|
100
|
+
function run(cmdObj) {
|
101
|
+
if (cmdObj.help || cmdObj.args.length < 1)
|
102
|
+
printUsageAndExit(usage);
|
103
|
+
const [command, contextType, param] = cmdObj.args;
|
104
|
+
const commandHandler = handlers[command];
|
105
|
+
if (!commandHandler) {
|
106
|
+
console.error(`Unknown command: ${command}`);
|
107
|
+
printUsageAndExit(usage);
|
108
|
+
}
|
109
|
+
if (!SUPPORTED_CONTEXT_TYPES.includes(contextType)) {
|
110
|
+
console.error(`Unknown context type: ${contextType}. Supported types: ${SUPPORTED_CONTEXT_TYPES.join(', ')}`);
|
111
|
+
process.exit(1);
|
112
|
+
}
|
113
|
+
const handler = commandHandler[contextType];
|
114
|
+
const params = new StrongParams(usage, {
|
115
|
+
env: cmdObj.env === 'development' ? 'staging' : cmdObj.env,
|
116
|
+
contextType,
|
117
|
+
workspaceOrImage: param
|
118
|
+
});
|
119
|
+
handler(params);
|
120
|
+
}
|
121
|
+
export default {
|
122
|
+
template: { oneLiner, keyExamples, run },
|
123
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { CLICommandParser } from "./common";
|
2
|
+
declare function run(cmdObj: CLICommandParser): void;
|
3
|
+
declare const _default: {
|
4
|
+
test: {
|
5
|
+
oneLiner: string;
|
6
|
+
keyExamples: string;
|
7
|
+
run: typeof run;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export default _default;
|
11
|
+
//# sourceMappingURL=test.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/cli/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsC,MAAM,UAAU,CAAC;AAehF,iBAAS,GAAG,CAAC,MAAM,EAAE,gBAAgB,QAUpC;;;;;;;;AAED,wBAEE"}
|
package/dist/cli/test.js
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
import { CLICommandParser, CommandExecutor, printUsageAndExit } from "./common";
|
2
|
+
const oneLiner = "Runs tests in all projects or one specific project";
|
3
|
+
const keyExamples = `
|
4
|
+
$ devops test
|
5
|
+
$ devops test project
|
6
|
+
`;
|
7
|
+
const usage = `
|
8
|
+
${oneLiner}
|
9
|
+
|
10
|
+
USAGE
|
11
|
+
${keyExamples}
|
12
|
+
`;
|
13
|
+
function run(cmdObj) {
|
14
|
+
const options = cmdObj.parseOptions({ params: ["--in"] });
|
15
|
+
if (cmdObj.help || options.args.length > 1)
|
16
|
+
printUsageAndExit(usage);
|
17
|
+
const workspace = options.args[0];
|
18
|
+
const env = cmdObj.envForced ? cmdObj.env : "test";
|
19
|
+
if (workspace) {
|
20
|
+
new CommandExecutor(`devops run ${workspace}:test --env ${env}`).spawn();
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
new CommandExecutor(`devops run-many test --env ${env}`).spawn();
|
24
|
+
}
|
25
|
+
}
|
26
|
+
export default {
|
27
|
+
test: { oneLiner, keyExamples, run },
|
28
|
+
};
|
package/dist/devops.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"devops.d.ts","sourceRoot":"","sources":["../src/devops.ts"],"names":[],"mappings":""}
|