"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateBackendBuildSh = generateBackendBuildSh;
function generateBackendBuildSh({ devOps: { database }, schema: { projectType, slug }, }) {
    const useDb = !!database;
    return projectType.kind === 'workspace'
        ? buildShWorkspace({ useDb, projectDirectory: projectType.projectDirectory, slug })
        : buildShStandalone({ useDb, slug });
}
const buildShWorkspace = ({ useDb, projectDirectory, slug, }) => {
    const name = slug.replaceAll('-', '_');
    return /*sh*/ String.raw `#!/bin/bash

rm -rf out/
npm i -g turbo@^2
turbo prune @postxl/${slug} @postxl/${slug}-api --docker

cp tsconfig.json tsconfig.base.json tsconfig.build.json ./out/full/
${useDb ? `cp projects/${projectDirectory}/docker/backend/migrate.sh ./out/full/projects/${projectDirectory}/backend/` : ''}

rm -rf ./out/full/projects/${projectDirectory}/frontend/
rm -rf ./out/full/projects/${projectDirectory}/e2e/

docker build -f projects/${projectDirectory}/docker/backend/Dockerfile \
  --secret id=TURBO_TOKEN,env=TURBO_TOKEN \
  -t ${name}_backend:latest ./out 
`;
};
const buildShStandalone = ({ useDb, slug }) => {
    const name = slug.replaceAll('-', '_');
    return /*sh*/ String.raw `#!/bin/bash

rm -rf out/
npm i -g turbo@^2
turbo prune @postxl/${slug}-api --docker

cp tsconfig.json prisma.config.ts ./out/full/
cp docker/backend/start.api.sh${useDb ? ' docker/backend/migrate.sh' : ''} ./out/full/backend/
cp -r migrations ./out/full/

rm -rf ./out/full/frontend/
rm -rf ./out/full/e2e/

docker build -f docker/backend/Dockerfile \
  --secret id=TURBO_TOKEN,env=TURBO_TOKEN \
  -t ${name}_backend:latest ./out
`;
};
//# sourceMappingURL=backend-build-sh.generator.js.map