logo-soup 0.2.1 → 0.2.3

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/cli.mjs CHANGED
@@ -1,16 +1,27 @@
1
- import { c as DENSITY_FACTOR, d as SCALE_FACTOR, i as BASE_SIZE, o as DEFAULT_EXTENSIONS, r as analyzeDirectory, t as normalize } from "./normalize-B5apzI38.mjs";
1
+ import { c as DENSITY_FACTOR, d as SCALE_FACTOR, i as BASE_SIZE, o as DEFAULT_EXTENSIONS, r as analyzeDirectory, t as normalize } from "./normalize-DuSYnT9A.mjs";
2
2
  import * as fsp from "node:fs/promises";
3
3
  import * as path from "node:path";
4
4
  import process from "node:process";
5
+ import * as ansis from "ansis";
5
6
  import { defineCommand, runMain } from "citty";
6
- import { consola } from "consola";
7
- import { colors } from "consola/utils";
8
7
 
9
8
  //#region package.json
10
9
  var name = "logo-soup";
11
- var version = "0.2.1";
10
+ var version = "0.2.3";
12
11
  var description = "Normalize logo dimensions for visual balance";
13
12
 
13
+ //#endregion
14
+ //#region src/log.ts
15
+ function success(message) {
16
+ console.log(`${ansis.green("✔")} ${message}`);
17
+ }
18
+ function error(message) {
19
+ console.error(`${ansis.red("✖")} ${message}`);
20
+ }
21
+ function info(message) {
22
+ console.log(`${ansis.cyan("●")} ${message}`);
23
+ }
24
+
14
25
  //#endregion
15
26
  //#region src/cli.ts
16
27
  const command = defineCommand({
@@ -53,11 +64,11 @@ const command = defineCommand({
53
64
  const dirPath = path.resolve(args.dir);
54
65
  try {
55
66
  if (!(await fsp.stat(dirPath)).isDirectory()) {
56
- consola.error(`Not a directory: ${dirPath}`);
67
+ error(`Not a directory: ${dirPath}`);
57
68
  process.exit(1);
58
69
  }
59
70
  } catch {
60
- consola.error(`Directory not found: ${dirPath}`);
71
+ error(`Directory not found: ${dirPath}`);
61
72
  process.exit(1);
62
73
  }
63
74
  const baseSize = parseNumericArg(args["base-size"], "base-size", BASE_SIZE);
@@ -75,30 +86,29 @@ const command = defineCommand({
75
86
  results[file] = dimensions;
76
87
  entries.push([file, dimensions]);
77
88
  }
78
- console.log();
79
- console.log(`${colors.cyan("●")} ${colors.bold(name)} ${colors.dim(`v${version}`)}`);
89
+ info(`${ansis.bold(name)} ${ansis.dim(`v${version}`)}`);
80
90
  console.log();
81
91
  const maxEntryLength = Math.max(...entries.map(([entry]) => entry.length));
82
92
  const total = entries.length;
83
93
  for (const [i, [file, dimensions]] of entries.entries()) {
84
94
  const branch = i === total - 1 ? "└─" : "├─";
85
- const dimStr = `${dimensions.width}${colors.dim("×")}${dimensions.height}`;
95
+ const dimStr = `${dimensions.width}${ansis.dim("×")}${dimensions.height}`;
86
96
  const padding = " ".repeat(maxEntryLength - file.length + 2);
87
- console.log(` ${colors.dim(branch)} ${colors.cyan(file)}${padding}${dimStr}`);
97
+ console.log(` ${ansis.dim(branch)} ${ansis.cyan(file)}${padding}${dimStr}`);
88
98
  }
89
99
  const outputPath = path.resolve(args.output);
90
100
  await fsp.mkdir(path.dirname(outputPath), { recursive: true });
91
- await fsp.writeFile(outputPath, `${JSON.stringify(results, null, 2)}\n`);
101
+ await fsp.writeFile(outputPath, `${JSON.stringify(results, void 0, 2)}\n`);
92
102
  const relativeOutput = path.relative(process.cwd(), outputPath);
93
103
  console.log();
94
- consola.success(`Wrote ${colors.bold(String(total))} entries to ${colors.cyan(relativeOutput)}`);
104
+ success(`Wrote ${ansis.bold(String(total))} entries to ${ansis.cyan(relativeOutput)}`);
95
105
  }
96
106
  });
97
107
  function parseNumericArg(value, name, fallback) {
98
108
  if (value == null) return fallback;
99
109
  const parsedNumber = Number(value);
100
110
  if (Number.isNaN(parsedNumber)) {
101
- consola.error(`Invalid value for --${name}: "${value}" (expected a number)`);
111
+ error(`Invalid value for --${name}: "${value}" (expected a number)`);
102
112
  process.exit(1);
103
113
  }
104
114
  return parsedNumber;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { a as CONTRAST_THRESHOLD, c as DENSITY_FACTOR, d as SCALE_FACTOR, i as BASE_SIZE, l as REFERENCE_DENSITY, n as analyze, o as DEFAULT_EXTENSIONS, r as analyzeDirectory, s as DENSITY_DAMPENING, t as normalize, u as SAMPLE_MAX_SIZE } from "./normalize-B5apzI38.mjs";
1
+ import { a as CONTRAST_THRESHOLD, c as DENSITY_FACTOR, d as SCALE_FACTOR, i as BASE_SIZE, l as REFERENCE_DENSITY, n as analyze, o as DEFAULT_EXTENSIONS, r as analyzeDirectory, s as DENSITY_DAMPENING, t as normalize, u as SAMPLE_MAX_SIZE } from "./normalize-DuSYnT9A.mjs";
2
2
 
3
3
  export { BASE_SIZE, CONTRAST_THRESHOLD, DEFAULT_EXTENSIONS, DENSITY_DAMPENING, DENSITY_FACTOR, REFERENCE_DENSITY, SAMPLE_MAX_SIZE, SCALE_FACTOR, analyze, analyzeDirectory, normalize };
@@ -39,14 +39,12 @@ async function analyze(filePath, options = {}) {
39
39
  async function analyzeDirectory(dirPath, options = {}) {
40
40
  const { extensions = DEFAULT_EXTENSIONS, ...analyzeOptions } = options;
41
41
  const files = (await fsp.readdir(dirPath)).filter((entry) => extensions.includes(path.extname(entry).slice(1).toLowerCase()));
42
+ const fileMetrics = await Promise.allSettled(files.map(async (file) => ({
43
+ file,
44
+ metrics: await analyze(path.resolve(dirPath, file), analyzeOptions)
45
+ })));
42
46
  const results = /* @__PURE__ */ new Map();
43
- for (const file of files) {
44
- const absolutePath = path.resolve(dirPath, file);
45
- try {
46
- const metrics = await analyze(absolutePath, analyzeOptions);
47
- if (metrics) results.set(file, metrics);
48
- } catch {}
49
- }
47
+ for (const result of fileMetrics) if (result.status === "fulfilled" && result.value.metrics) results.set(result.value.file, result.value.metrics);
50
48
  return results;
51
49
  }
52
50
  async function extractPixels(filePath, sampleMaxSize) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "logo-soup",
3
3
  "type": "module",
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "packageManager": "pnpm@10.30.0",
6
6
  "description": "Normalize logo dimensions for visual balance",
7
7
  "author": "Johann Schopplich <hello@johannschopplich.com>",
@@ -40,6 +40,7 @@
40
40
  "dist"
41
41
  ],
42
42
  "scripts": {
43
+ "dev": "node src/cli.ts",
43
44
  "build": "tsdown",
44
45
  "lint": "eslint .",
45
46
  "lint:fix": "eslint . --fix",
@@ -48,8 +49,8 @@
48
49
  "release": "bumpp"
49
50
  },
50
51
  "dependencies": {
52
+ "ansis": "^4.2.0",
51
53
  "citty": "^0.2.1",
52
- "consola": "^3.4.2",
53
54
  "sharp": "^0.34.5"
54
55
  },
55
56
  "devDependencies": {