dev-toolkit-cli 1.0.0 → 1.0.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.
@@ -2,9 +2,8 @@ import { CommanderError } from "commander";
2
2
  import fs from "fs/promises";
3
3
  import mime from "mime";
4
4
  import path from "path";
5
- import sharp from "sharp";
6
5
  import { addFilenamePrefix, getAvailablePathname, getDirectory, getFilename, getFolderFiles, normalizeFilename, removeFilenamePrefix, replaceFilenameExtension, } from "../lib/utils/index.js";
7
- import { check_dependencies, ffmpeg_video_compress } from "../lib/bash.js";
6
+ import { check_dependencies, ffmpeg_image_to_webp, ffmpeg_video_compress, } from "../lib/bash.js";
8
7
  export const FileType = ["image", "video"];
9
8
  const unsupportedFormats = {
10
9
  image: ["image/webp", "image/gif", "image/svg+xml"],
@@ -52,9 +51,10 @@ export async function file(pathname, { verbose, type, resolution, force, horizon
52
51
  console.log("\nCompression successfully finished 🚀");
53
52
  }
54
53
  async function compressImage(filePath) {
55
- await sharp(filePath)
56
- .webp()
57
- .toFile(replaceFilenameExtension(filePath, "webp"));
54
+ // await sharp(filePath)
55
+ // .webp()
56
+ // .toFile(replaceFilenameExtension(filePath, "webp"));
57
+ await ffmpeg_image_to_webp(filePath, replaceFilenameExtension(filePath, "webp"));
58
58
  await fs.rm(filePath);
59
59
  }
60
60
  async function compressVideo(filePath, resolution, force) {
package/bin/lib/bash.js CHANGED
@@ -31,3 +31,6 @@ export async function ffmpeg_video_compress(input, output, resolution = "480p",
31
31
  ? `ffmpeg -i "${input}" -s ${w}x${h} -acodec copy -y "${output}"`
32
32
  : `ffmpeg -i "${input}" -filter:v scale=-1:${h} -acodec copy -y "${output}"`);
33
33
  }
34
+ export async function ffmpeg_image_to_webp(input, output) {
35
+ return execAsync(`ffmpeg -i "${input}" -c:v libwebp "${output}"`);
36
+ }
package/bin/main.js CHANGED
@@ -1,4 +1,4 @@
1
- // #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  import { Command, CommanderError } from "commander";
3
3
  // import { ZodError } from "zod";
4
4
  import { FileType } from "./actions/action-compress.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dev-toolkit-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "repository": "https://github.com/daviinacio/dev-toolkit",
5
5
  "author": "Davi Inácio <aazz6850@gmail.com>",
6
6
  "license": "MIT",
@@ -23,7 +23,6 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "commander": "^13.1.0",
26
- "mime": "^4.0.6",
27
- "sharp": "^0.33.5"
26
+ "mime": "^4.0.6"
28
27
  }
29
28
  }
@@ -2,7 +2,6 @@ import { CommanderError } from "commander";
2
2
  import fs from "fs/promises";
3
3
  import mime from "mime";
4
4
  import path from "path";
5
- import sharp from "sharp";
6
5
 
7
6
  import { Resolution } from "../lib/constants.js";
8
7
  import {
@@ -15,7 +14,11 @@ import {
15
14
  removeFilenamePrefix,
16
15
  replaceFilenameExtension,
17
16
  } from "../lib/utils/index.js";
18
- import { check_dependencies, ffmpeg_video_compress } from "../lib/bash.js";
17
+ import {
18
+ check_dependencies,
19
+ ffmpeg_image_to_webp,
20
+ ffmpeg_video_compress,
21
+ } from "../lib/bash.js";
19
22
 
20
23
  export const FileType = ["image", "video"] as const;
21
24
  type FileType = (typeof FileType)[number];
@@ -88,9 +91,13 @@ export async function file(
88
91
  }
89
92
 
90
93
  async function compressImage(filePath: string) {
91
- await sharp(filePath)
92
- .webp()
93
- .toFile(replaceFilenameExtension(filePath, "webp"));
94
+ // await sharp(filePath)
95
+ // .webp()
96
+ // .toFile(replaceFilenameExtension(filePath, "webp"));
97
+ await ffmpeg_image_to_webp(
98
+ filePath,
99
+ replaceFilenameExtension(filePath, "webp")
100
+ );
94
101
  await fs.rm(filePath);
95
102
  }
96
103
 
package/src/lib/bash.ts CHANGED
@@ -48,3 +48,7 @@ export async function ffmpeg_video_compress(
48
48
  : `ffmpeg -i "${input}" -filter:v scale=-1:${h} -acodec copy -y "${output}"`
49
49
  );
50
50
  }
51
+
52
+ export async function ffmpeg_image_to_webp(input: string, output: string) {
53
+ return execAsync(`ffmpeg -i "${input}" -c:v libwebp "${output}"`);
54
+ }
package/src/main.ts CHANGED
@@ -1,4 +1,4 @@
1
- // #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import { Command, CommanderError } from "commander";
4
4
  // import { ZodError } from "zod";