logo-soup 0.2.2 → 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,4 +1,4 @@
|
|
|
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-
|
|
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";
|
|
@@ -7,22 +7,20 @@ import { defineCommand, runMain } from "citty";
|
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
9
|
var name = "logo-soup";
|
|
10
|
-
var version = "0.2.
|
|
10
|
+
var version = "0.2.3";
|
|
11
11
|
var description = "Normalize logo dimensions for visual balance";
|
|
12
12
|
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/log.ts
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
error(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
};
|
|
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
|
+
}
|
|
26
24
|
|
|
27
25
|
//#endregion
|
|
28
26
|
//#region src/cli.ts
|
|
@@ -66,11 +64,11 @@ const command = defineCommand({
|
|
|
66
64
|
const dirPath = path.resolve(args.dir);
|
|
67
65
|
try {
|
|
68
66
|
if (!(await fsp.stat(dirPath)).isDirectory()) {
|
|
69
|
-
|
|
67
|
+
error(`Not a directory: ${dirPath}`);
|
|
70
68
|
process.exit(1);
|
|
71
69
|
}
|
|
72
70
|
} catch {
|
|
73
|
-
|
|
71
|
+
error(`Directory not found: ${dirPath}`);
|
|
74
72
|
process.exit(1);
|
|
75
73
|
}
|
|
76
74
|
const baseSize = parseNumericArg(args["base-size"], "base-size", BASE_SIZE);
|
|
@@ -88,7 +86,7 @@ const command = defineCommand({
|
|
|
88
86
|
results[file] = dimensions;
|
|
89
87
|
entries.push([file, dimensions]);
|
|
90
88
|
}
|
|
91
|
-
|
|
89
|
+
info(`${ansis.bold(name)} ${ansis.dim(`v${version}`)}`);
|
|
92
90
|
console.log();
|
|
93
91
|
const maxEntryLength = Math.max(...entries.map(([entry]) => entry.length));
|
|
94
92
|
const total = entries.length;
|
|
@@ -103,14 +101,14 @@ const command = defineCommand({
|
|
|
103
101
|
await fsp.writeFile(outputPath, `${JSON.stringify(results, void 0, 2)}\n`);
|
|
104
102
|
const relativeOutput = path.relative(process.cwd(), outputPath);
|
|
105
103
|
console.log();
|
|
106
|
-
|
|
104
|
+
success(`Wrote ${ansis.bold(String(total))} entries to ${ansis.cyan(relativeOutput)}`);
|
|
107
105
|
}
|
|
108
106
|
});
|
|
109
107
|
function parseNumericArg(value, name, fallback) {
|
|
110
108
|
if (value == null) return fallback;
|
|
111
109
|
const parsedNumber = Number(value);
|
|
112
110
|
if (Number.isNaN(parsedNumber)) {
|
|
113
|
-
|
|
111
|
+
error(`Invalid value for --${name}: "${value}" (expected a number)`);
|
|
114
112
|
process.exit(1);
|
|
115
113
|
}
|
|
116
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-
|
|
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
|
|
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