From 0c5c2c88ffc83650f33ed3dfb39da30b6a80eb30 Mon Sep 17 00:00:00 2001 From: Batuhan Wilhelm Date: Thu, 18 Jan 2024 18:02:33 +0300 Subject: [PATCH] feat: add download dockerfile step --- src/saofile.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/saofile.ts b/src/saofile.ts index 89380a67..e9bde6e2 100644 --- a/src/saofile.ts +++ b/src/saofile.ts @@ -15,6 +15,7 @@ import { formatFiles } from "@Helper/prettier"; import chalk from "chalk"; import { exec } from "child_process"; import { prompt } from "enquirer"; +import fs from "fs"; import fetch from "node-fetch"; import path from "path"; import { promisify } from "util"; @@ -382,7 +383,27 @@ const saoConfig: GeneratorConfig = { tips.preInstall(); }, async completed(saoInstance) { - const { debug, apiMode } = saoInstance.opts.extras; + const { debug, apiMode, projectType } = saoInstance.opts.extras; + + /** + * Download Dockerfile + */ + if (projectType.startsWith("refine")) { + const folder = projectType.split("-")[1]; + + fetch( + `https://raw.githubusercontent.com/refinedev/dockerfiles/main/dockerfiles/${folder}/Dockerfile`, + ).then((r) => { + r.blob().then((b) => + b.text().then((t) => { + fs.writeFileSync( + path.join(saoInstance.outDir, "Dockerfile"), + t, + ); + }), + ); + }); + } /** * Format generated project