zixulu 1.76.0 → 1.76.2
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/dist/index.js +31 -17
- package/dist/index.js.map +1 -1
- package/dist/src/utils/pullDockerImage.d.ts +1 -1
- package/dist/src/utils/updateDockerCompose.d.ts +31 -0
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/utils/pullDockerImage.ts +9 -6
- package/src/utils/updateDockerCompose.ts +47 -8
package/dist/index.js
CHANGED
|
@@ -4797,6 +4797,20 @@ async function test() {
|
|
|
4797
4797
|
console.log(isSudo);
|
|
4798
4798
|
console.log(process.argv);
|
|
4799
4799
|
}
|
|
4800
|
+
async function pullDockerImage({ image, sha256 }) {
|
|
4801
|
+
const match = image.match(/^(.+):(.+)$/);
|
|
4802
|
+
image = match ? match[1] : image;
|
|
4803
|
+
const tag = match ? match[2] : "latest";
|
|
4804
|
+
sha256 = sha256?.replace(/^@?sha256:/, "");
|
|
4805
|
+
await spawnAsync(`docker pull ${image}@sha256:${sha256}`, {
|
|
4806
|
+
shell: true,
|
|
4807
|
+
stdio: "inherit"
|
|
4808
|
+
});
|
|
4809
|
+
await spawnAsync(`docker tag ${image}@sha256:${sha256} ${image}:${tag}`, {
|
|
4810
|
+
shell: true,
|
|
4811
|
+
stdio: "inherit"
|
|
4812
|
+
});
|
|
4813
|
+
}
|
|
4800
4814
|
async function updateDockerCompose() {
|
|
4801
4815
|
const dir = await readdir(".");
|
|
4802
4816
|
const file = dir.find((item)=>"docker-compose.yml" === item || "docker-compose.yaml" === item);
|
|
@@ -4804,12 +4818,22 @@ async function updateDockerCompose() {
|
|
|
4804
4818
|
const content = await readFile(file, "utf-8");
|
|
4805
4819
|
const data = yaml_0.parse(content);
|
|
4806
4820
|
const images = Object.values(data.services).map((service)=>service.image);
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4821
|
+
for (const image of images){
|
|
4822
|
+
consola_0.start(`开始更新镜像 ${image}`);
|
|
4823
|
+
const match = image.match(/^(.+):(.+)$/);
|
|
4824
|
+
const name = match ? match[1] : image;
|
|
4825
|
+
const tag = match ? match[2] : "latest";
|
|
4826
|
+
const response = await node_fetch(`https://hub.docker.com/v2/repositories/${name}/tags/${tag}`, {
|
|
4827
|
+
agent: agent
|
|
4828
|
+
});
|
|
4829
|
+
const data = await response.json();
|
|
4830
|
+
const sha256 = data.digest;
|
|
4831
|
+
await pullDockerImage({
|
|
4832
|
+
image,
|
|
4833
|
+
sha256
|
|
4834
|
+
});
|
|
4835
|
+
consola_0.info(`更新镜像 ${image} 完成`);
|
|
4836
|
+
}
|
|
4813
4837
|
await spawnAsync("docker compose down", {
|
|
4814
4838
|
shell: true,
|
|
4815
4839
|
stdio: "inherit"
|
|
@@ -5209,16 +5233,6 @@ async function gdm() {
|
|
|
5209
5233
|
await writeFile(".gdm/gdm.mjs", gdm_script);
|
|
5210
5234
|
await verdaccio();
|
|
5211
5235
|
}
|
|
5212
|
-
async function pullDockerImage({ image, sha256 }) {
|
|
5213
|
-
const match = image.match(/^(.+):(.+)$/);
|
|
5214
|
-
image = match ? match[1] : image;
|
|
5215
|
-
const tag = match ? match[2] : "latest";
|
|
5216
|
-
sha256 = sha256?.replace(/^@?sha256:/, "");
|
|
5217
|
-
if (sha256) {
|
|
5218
|
-
await spawnAsync(`docker pull ${image}@sha256:${sha256}`);
|
|
5219
|
-
await spawnAsync(`docker tag ${image}@sha256:${sha256} ${image}:${tag}`);
|
|
5220
|
-
} else await spawnAsync(`docker pull ${image}:${tag}`);
|
|
5221
|
-
}
|
|
5222
5236
|
async function removeOpenWith(name, { file, folder, background }) {
|
|
5223
5237
|
if (!file && !folder && !background) throw new Error("至少选择一个");
|
|
5224
5238
|
let reg = `\ufeffWindows Registry Editor Version 5.00
|
|
@@ -5420,7 +5434,7 @@ program.command("replace-commit-message").alias("rcm").description("替换所有
|
|
|
5420
5434
|
program.command("gdm").description("同步 geshu-docker-management").action(gdm);
|
|
5421
5435
|
program.command("add-open-with").alias("aow").description("添加打开文件的脚本").argument("path", "程序路径").option("--no-file", "是否不添加文件关联").option("--no-folder", "是否不添加文件夹关联").option("--no-background", "是否不添加文件夹空白处关联").action(addOpenWith);
|
|
5422
5436
|
program.command("remove-open-with").alias("row").description("删除打开文件的脚本").argument("name", "脚本名称").option("--no-file", "是否不删除文件关联").option("--no-folder", "是否不删除文件夹关联").option("--no-background", "是否不删除文件夹空白处关联").action(removeOpenWith);
|
|
5423
|
-
program.command("pull-docker-image").alias("pd").description("拉取 docker 镜像").argument("image", "镜像名称").argument("
|
|
5437
|
+
program.command("pull-docker-image").alias("pd").description("拉取 docker 镜像").argument("image", "镜像名称").argument("sha256", "镜像 sha256").action((image, sha256)=>pullDockerImage({
|
|
5424
5438
|
image,
|
|
5425
5439
|
sha256
|
|
5426
5440
|
}));
|