zixulu 1.75.2 → 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 +34 -4
- package/dist/index.js.map +1 -1
- package/dist/src/utils/pullDockerImage.d.ts +5 -0
- package/dist/src/utils/updateDockerCompose.d.ts +31 -0
- package/package.json +13 -13
- package/src/index.ts +9 -0
- package/src/utils/addPrettier.ts +1 -0
- package/src/utils/pullDockerImage.ts +21 -0
- package/src/utils/updateDockerCompose.ts +46 -4
package/dist/index.js
CHANGED
|
@@ -1414,6 +1414,7 @@ const config = {
|
|
|
1414
1414
|
plugins: ["@1adybug/prettier"],
|
|
1415
1415
|
controlStatementBraces: "add",
|
|
1416
1416
|
multiLineBraces: "add",
|
|
1417
|
+
nodeProtocol: true,
|
|
1417
1418
|
}
|
|
1418
1419
|
|
|
1419
1420
|
export default config
|
|
@@ -4796,6 +4797,20 @@ async function test() {
|
|
|
4796
4797
|
console.log(isSudo);
|
|
4797
4798
|
console.log(process.argv);
|
|
4798
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
|
+
}
|
|
4799
4814
|
async function updateDockerCompose() {
|
|
4800
4815
|
const dir = await readdir(".");
|
|
4801
4816
|
const file = dir.find((item)=>"docker-compose.yml" === item || "docker-compose.yaml" === item);
|
|
@@ -4804,10 +4819,21 @@ async function updateDockerCompose() {
|
|
|
4804
4819
|
const data = yaml_0.parse(content);
|
|
4805
4820
|
const images = Object.values(data.services).map((service)=>service.image);
|
|
4806
4821
|
consola_0.start("开始更新镜像");
|
|
4807
|
-
for (const image of images)
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
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
|
+
}
|
|
4811
4837
|
consola_0.success("更新镜像完成");
|
|
4812
4838
|
await spawnAsync("docker compose down", {
|
|
4813
4839
|
shell: true,
|
|
@@ -5409,6 +5435,10 @@ program.command("replace-commit-message").alias("rcm").description("替换所有
|
|
|
5409
5435
|
program.command("gdm").description("同步 geshu-docker-management").action(gdm);
|
|
5410
5436
|
program.command("add-open-with").alias("aow").description("添加打开文件的脚本").argument("path", "程序路径").option("--no-file", "是否不添加文件关联").option("--no-folder", "是否不添加文件夹关联").option("--no-background", "是否不添加文件夹空白处关联").action(addOpenWith);
|
|
5411
5437
|
program.command("remove-open-with").alias("row").description("删除打开文件的脚本").argument("name", "脚本名称").option("--no-file", "是否不删除文件关联").option("--no-folder", "是否不删除文件夹关联").option("--no-background", "是否不删除文件夹空白处关联").action(removeOpenWith);
|
|
5438
|
+
program.command("pull-docker-image").alias("pd").description("拉取 docker 镜像").argument("image", "镜像名称").argument("sha256", "镜像 sha256").action((image, sha256)=>pullDockerImage({
|
|
5439
|
+
image,
|
|
5440
|
+
sha256
|
|
5441
|
+
}));
|
|
5412
5442
|
program.parse();
|
|
5413
5443
|
|
|
5414
5444
|
//# sourceMappingURL=index.js.map
|