wip fix
This commit is contained in:
parent
994ba5e608
commit
0b799c24b0
|
|
@ -1,53 +1,55 @@
|
||||||
import { $ } from "execa";
|
import { $ } from "execa";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import {
|
import { copyAsync, dirAsync, existsAsync, removeAsync } from "fs-jetpack";
|
||||||
copyAsync,
|
|
||||||
dirAsync,
|
|
||||||
existsAsync,
|
|
||||||
removeAsync
|
|
||||||
} from "fs-jetpack";
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
const dir = {
|
const g = global as any;
|
||||||
path(...allpath: any[]) {
|
if (!g.dockerPrepared) {
|
||||||
return path.join(process.cwd(), ...allpath);
|
g.dockerPrepared = true;
|
||||||
},
|
const dir = {
|
||||||
read(dirPath: string, baseDir?: string[]): Record<string, string> {
|
path(...allpath: any[]) {
|
||||||
const result: Record<string, string> = {};
|
return path.join(process.cwd(), ...allpath);
|
||||||
|
},
|
||||||
|
read(dirPath: string, baseDir?: string[]): Record<string, string> {
|
||||||
|
const result: Record<string, string> = {};
|
||||||
|
|
||||||
const contents = fs.readdirSync(dirPath);
|
const contents = fs.readdirSync(dirPath);
|
||||||
|
|
||||||
for (const item of contents) {
|
for (const item of contents) {
|
||||||
const itemPath = path.join(dirPath, item);
|
const itemPath = path.join(dirPath, item);
|
||||||
const stats = fs.statSync(itemPath);
|
const stats = fs.statSync(itemPath);
|
||||||
|
|
||||||
if (stats.isFile()) {
|
if (stats.isFile()) {
|
||||||
// const content = fs.readFileSync(itemPath, "utf-8");
|
// const content = fs.readFileSync(itemPath, "utf-8");
|
||||||
result[[...(baseDir || []), item].join("/")] = "";
|
result[[...(baseDir || []), item].join("/")] = "";
|
||||||
} else if (stats.isDirectory()) {
|
} else if (stats.isDirectory()) {
|
||||||
if (item !== "node_modules" && item !== ".git") {
|
if (item !== "node_modules" && item !== ".git") {
|
||||||
const subdirResult = dir.read(itemPath, [...(baseDir || []), item]);
|
const subdirResult = dir.read(itemPath, [...(baseDir || []), item]);
|
||||||
Object.assign(result, subdirResult);
|
Object.assign(result, subdirResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!(await existsAsync(dir.path("_tmp_docker")))) {
|
if (!(await existsAsync(dir.path("_tmp_docker")))) {
|
||||||
for (const file of Object.keys(dir.read(dir.path``))) {
|
for (const file of Object.keys(dir.read(dir.path``))) {
|
||||||
if (file.endsWith("package.json")) {
|
if (file.endsWith("package.json")) {
|
||||||
await dirAsync(dir.path("_tmp_docker", path.dirname(file)));
|
await dirAsync(dir.path("_tmp_docker", path.dirname(file)));
|
||||||
await copyAsync(dir.path(file), dir.path("_tmp_docker", file), {
|
await copyAsync(dir.path(file), dir.path("_tmp_docker", file), {
|
||||||
overwrite: true,
|
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"));
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue