From 0b799c24b0030770ce8723eca482822e2b099075 Mon Sep 17 00:00:00 2001 From: Rizky Date: Thu, 25 Jan 2024 16:20:57 +0700 Subject: [PATCH] wip fix --- dockerzip | Bin 101735 -> 101735 bytes pkgs/docker-prep.ts | 80 +++++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/dockerzip b/dockerzip index 1a89c0ea5faed0c2784b589a6671b22d6d26bb76..045adcab89c7b55f4ebd7ddcdf9177f653ec05a3 100644 GIT binary patch delta 1855 zcmZ`(OH5Ni6zvh(Qi_N|)J1Fg2qb_YA_*9bVFiei8YQ42A7ei$gb1YtN`cZ+KBX=Q zi%F_o5Ot+4R1!97aBDO%7#Btt7)?lwJ3b2&qtn;vn`sMOG`aVld(OFcX5MB59lNw5Zi7w~Akwwn(KDI)s)sl*bmkH7vJmiR2a+%A)b}R~J($M6EQ$)t4HT zr7W@52g4FkHcCXf@u++iqak_2$bM;7Wr4zm)p=2vFRWe-tI>X|AmpuWm)x;Gr9!8; z+iS5`v|iIFQbf0;+Ju5Q72-0XLNG%^m}hz%HfmQA2zd7wptZ8J#NA37hJJYg5&E>q*?h`#?vUj{ z93`}`ggo`(2ygz}4{J;^V;aT0!mLXZ(Mlo7^+PH87iWtBw7g%|&uu!G71fWSG(-_83?*uQ!&qzz@t+;TG*D}X&iq~$Ap_bQH z#>Bn@ZmEy4bhuH$kx$$x<LhfqEXPCUJ%% zshLb}{&_^f?kW0AWm1Vo z?M`#)Z)ZMiUa_PGDhTbox4dGi{-ZCimWR&pG$b%-dX2Z7!*_ z#-^0ibVcN6U(o85;iBiJFsX1s2m9iN^2kD$hULPRNN!=iG#Wp9c_EcT)Jj8KeX&7V z!V+t}Ff0;fgG7`Yk29IJtw!Cg=A>7b|~uk){SuM@l&KO;RkBg-(?YpxjMD!s=Ak;`5`4EFNa(&bQ?L0(U6(+LcE@?%=|Abl8` zeuoUC!%sg9w`OpOJCG*&HIqcyJ)1=NWmcx7x2bk6$=Ub0B$~Eh63u#0q^X=2X { - const result: Record = {}; +const g = global as any; +if (!g.dockerPrepared) { + g.dockerPrepared = true; + const dir = { + path(...allpath: any[]) { + return path.join(process.cwd(), ...allpath); + }, + read(dirPath: string, baseDir?: string[]): Record { + const result: Record = {}; - const contents = fs.readdirSync(dirPath); + const contents = fs.readdirSync(dirPath); - for (const item of contents) { - const itemPath = path.join(dirPath, item); - const stats = fs.statSync(itemPath); + for (const item of contents) { + const itemPath = path.join(dirPath, item); + const stats = fs.statSync(itemPath); - if (stats.isFile()) { - // const content = fs.readFileSync(itemPath, "utf-8"); - result[[...(baseDir || []), item].join("/")] = ""; - } else if (stats.isDirectory()) { - if (item !== "node_modules" && item !== ".git") { - const subdirResult = dir.read(itemPath, [...(baseDir || []), item]); - Object.assign(result, subdirResult); + if (stats.isFile()) { + // const content = fs.readFileSync(itemPath, "utf-8"); + result[[...(baseDir || []), item].join("/")] = ""; + } else if (stats.isDirectory()) { + if (item !== "node_modules" && item !== ".git") { + const subdirResult = dir.read(itemPath, [...(baseDir || []), item]); + Object.assign(result, subdirResult); + } } } - } - return result; - }, -}; + return result; + }, + }; -if (!(await existsAsync(dir.path("_tmp_docker")))) { - for (const file of Object.keys(dir.read(dir.path``))) { - if (file.endsWith("package.json")) { - await dirAsync(dir.path("_tmp_docker", path.dirname(file))); - await copyAsync(dir.path(file), dir.path("_tmp_docker", file), { - overwrite: true, - }); + if (!(await existsAsync(dir.path("_tmp_docker")))) { + for (const file of Object.keys(dir.read(dir.path``))) { + if (file.endsWith("package.json")) { + await dirAsync(dir.path("_tmp_docker", path.dirname(file))); + await copyAsync(dir.path(file), dir.path("_tmp_docker", file), { + overwrite: true, + }); + } } + await copyAsync( + dir.path("bun.lockb"), + dir.path("_tmp_docker", "bun.lockb") + ); + + await $({ cwd: dir.path("_tmp_docker") })`zip -r ../docker .`; + await $`mv docker.zip dockerzip`; + await removeAsync(dir.path("_tmp_docker")); } - await copyAsync(dir.path("bun.lockb"), dir.path("_tmp_docker", "bun.lockb")); - - await $({ cwd: dir.path("_tmp_docker") })`zip -r ../docker .`; - await $`mv docker.zip dockerzip`; - await removeAsync(dir.path("_tmp_docker")); }