zixulu 1.76.0 → 1.76.1

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 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);
@@ -4805,10 +4819,21 @@ async function updateDockerCompose() {
4805
4819
  const data = yaml_0.parse(content);
4806
4820
  const images = Object.values(data.services).map((service)=>service.image);
4807
4821
  consola_0.start("开始更新镜像");
4808
- for (const image of images)await spawnAsync(`docker pull ${image}`, {
4809
- shell: true,
4810
- stdio: "inherit"
4811
- });
4822
+ for (const image of images){
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
+ }
4812
4837
  consola_0.success("更新镜像完成");
4813
4838
  await spawnAsync("docker compose down", {
4814
4839
  shell: true,
@@ -5209,16 +5234,6 @@ async function gdm() {
5209
5234
  await writeFile(".gdm/gdm.mjs", gdm_script);
5210
5235
  await verdaccio();
5211
5236
  }
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
5237
  async function removeOpenWith(name, { file, folder, background }) {
5223
5238
  if (!file && !folder && !background) throw new Error("至少选择一个");
5224
5239
  let reg = `\ufeffWindows Registry Editor Version 5.00
@@ -5420,7 +5435,7 @@ program.command("replace-commit-message").alias("rcm").description("替换所有
5420
5435
  program.command("gdm").description("同步 geshu-docker-management").action(gdm);
5421
5436
  program.command("add-open-with").alias("aow").description("添加打开文件的脚本").argument("path", "程序路径").option("--no-file", "是否不添加文件关联").option("--no-folder", "是否不添加文件夹关联").option("--no-background", "是否不添加文件夹空白处关联").action(addOpenWith);
5422
5437
  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("[sha256]", "镜像 sha256").action((image, sha256)=>pullDockerImage({
5438
+ program.command("pull-docker-image").alias("pd").description("拉取 docker 镜像").argument("image", "镜像名称").argument("sha256", "镜像 sha256").action((image, sha256)=>pullDockerImage({
5424
5439
  image,
5425
5440
  sha256
5426
5441
  }));