logo-soup 0.1.0 → 0.2.0
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/README.md +1 -1
- package/dist/cli.mjs +24 -11
- package/dist/index.mjs +1 -1
- package/dist/{normalize-BN3StFfP.mjs → normalize-DbCIuSqg.mjs} +1 -4
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
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-DbCIuSqg.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
5
|
import { defineCommand, runMain } from "citty";
|
|
6
6
|
import { consola } from "consola";
|
|
7
|
+
import { colors } from "consola/utils";
|
|
7
8
|
|
|
8
9
|
//#region package.json
|
|
9
10
|
var name = "logo-soup";
|
|
10
|
-
var version = "0.
|
|
11
|
+
var version = "0.2.0";
|
|
11
12
|
var description = "Normalize logo dimensions for visual balance";
|
|
12
13
|
|
|
13
14
|
//#endregion
|
|
@@ -62,10 +63,9 @@ const command = defineCommand({
|
|
|
62
63
|
const baseSize = parseNumericArg(args["base-size"], "base-size", BASE_SIZE);
|
|
63
64
|
const scaleFactor = parseNumericArg(args["scale-factor"], "scale-factor", SCALE_FACTOR);
|
|
64
65
|
const densityFactor = parseNumericArg(args["density-factor"], "density-factor", DENSITY_FACTOR);
|
|
65
|
-
const
|
|
66
|
-
consola.start(`Analyzing logos in ${dirPath}`);
|
|
67
|
-
const metricsMap = await analyzeDirectory(dirPath, { extensions });
|
|
66
|
+
const metricsMap = await analyzeDirectory(dirPath, { extensions: args.extensions ? args.extensions.split(",").map((ext) => ext.trim().toLowerCase()) : DEFAULT_EXTENSIONS });
|
|
68
67
|
const results = {};
|
|
68
|
+
const entries = [];
|
|
69
69
|
for (const [file, metrics] of metricsMap) {
|
|
70
70
|
const dimensions = normalize(metrics, {
|
|
71
71
|
baseSize,
|
|
@@ -73,22 +73,35 @@ const command = defineCommand({
|
|
|
73
73
|
densityFactor
|
|
74
74
|
});
|
|
75
75
|
results[file] = dimensions;
|
|
76
|
-
|
|
76
|
+
entries.push([file, dimensions]);
|
|
77
|
+
}
|
|
78
|
+
console.log();
|
|
79
|
+
console.log(`${colors.cyan("●")} ${colors.bold(name)} ${colors.dim(`v${version}`)}`);
|
|
80
|
+
console.log();
|
|
81
|
+
const maxEntryLength = Math.max(...entries.map(([entry]) => entry.length));
|
|
82
|
+
const total = entries.length;
|
|
83
|
+
for (const [i, [file, dimensions]] of entries.entries()) {
|
|
84
|
+
const branch = i === total - 1 ? "└─" : "├─";
|
|
85
|
+
const dimStr = `${dimensions.width}${colors.dim("×")}${dimensions.height}`;
|
|
86
|
+
const padding = " ".repeat(maxEntryLength - file.length + 2);
|
|
87
|
+
console.log(` ${colors.dim(branch)} ${colors.cyan(file)}${padding}${dimStr}`);
|
|
77
88
|
}
|
|
78
89
|
const outputPath = path.resolve(args.output);
|
|
79
90
|
await fsp.mkdir(path.dirname(outputPath), { recursive: true });
|
|
80
91
|
await fsp.writeFile(outputPath, `${JSON.stringify(results, null, 2)}\n`);
|
|
81
|
-
|
|
92
|
+
const relativeOutput = path.relative(process.cwd(), outputPath);
|
|
93
|
+
console.log();
|
|
94
|
+
consola.success(`Wrote ${colors.bold(String(total))} entries to ${colors.cyan(relativeOutput)}`);
|
|
82
95
|
}
|
|
83
96
|
});
|
|
84
97
|
function parseNumericArg(value, name, fallback) {
|
|
85
|
-
if (value
|
|
86
|
-
const
|
|
87
|
-
if (Number.isNaN(
|
|
98
|
+
if (value == null) return fallback;
|
|
99
|
+
const parsedNumber = Number(value);
|
|
100
|
+
if (Number.isNaN(parsedNumber)) {
|
|
88
101
|
consola.error(`Invalid value for --${name}: "${value}" (expected a number)`);
|
|
89
102
|
process.exit(1);
|
|
90
103
|
}
|
|
91
|
-
return
|
|
104
|
+
return parsedNumber;
|
|
92
105
|
}
|
|
93
106
|
runMain(command);
|
|
94
107
|
|
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-DbCIuSqg.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 };
|
|
@@ -38,10 +38,7 @@ async function analyze(filePath, options = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
async function analyzeDirectory(dirPath, options = {}) {
|
|
40
40
|
const { extensions = DEFAULT_EXTENSIONS, ...analyzeOptions } = options;
|
|
41
|
-
const files = (await fsp.readdir(dirPath)).filter((
|
|
42
|
-
const ext = path.extname(fileName).slice(1).toLowerCase();
|
|
43
|
-
return extensions.includes(ext);
|
|
44
|
-
});
|
|
41
|
+
const files = (await fsp.readdir(dirPath)).filter((entry) => extensions.includes(path.extname(entry).slice(1).toLowerCase()));
|
|
45
42
|
const results = /* @__PURE__ */ new Map();
|
|
46
43
|
for (const file of files) {
|
|
47
44
|
const absolutePath = path.resolve(dirPath, file);
|
package/package.json
CHANGED