diff --git a/analyze/index.ts b/analyze/index.ts index b173783..d3cea90 100755 --- a/analyze/index.ts +++ b/analyze/index.ts @@ -1,12 +1,12 @@ #!/usr/bin/env zx -import { cacheDir, configDir, loadConfig } from "../utils.ts" +import { cacheDir, chalkDebug, configDir, loadConfig } from "../utils.ts" import { AnalysisConfig, analyzeImages, defaultConfig, ImageAnalysisData, runPreAnalysis } from "./analysis.ts" import "zx/globals" const pathToConfig = `${configDir}/analyze-config.json` -console.debug(`Trying to load config from ${pathToConfig}...`) +console.debug(chalkDebug(`Trying to load config from ${pathToConfig}...`)) const config = await loadConfig(pathToConfig, defaultConfig) as AnalysisConfig @@ -14,7 +14,7 @@ if (config == undefined) { throw new Error("Couldn't initialize config!") } -console.debug(`Config: \n${JSON.stringify(config, null, 4)}`) +console.debug(chalkDebug(`Config: \n${JSON.stringify(config, null, 4)}`)) await fs.cp(`${cacheDir}/analysis.json`, `${cacheDir}/analysis.json.prev`, { force: true }, (err: Error) => { if (err) { diff --git a/apply/index.ts b/apply/index.ts index 003076d..18dfadf 100644 --- a/apply/index.ts +++ b/apply/index.ts @@ -1,7 +1,7 @@ #!/usr/bin/env zx import { ImageAnalysisData } from "../analyze/analysis.ts" -import { cacheDir, configDir, loadConfig, map, mapEaseOutQuint } from "../utils.ts" +import { cacheDir, chalkDebug, configDir, loadConfig, map, mapEaseOutQuint } from "../utils.ts" import { ApplicationConfig, defaultConfig, findMatchingImages, getOpenMeteoData } from "./application.ts" import * as SunCalc from "suncalc" import "zx/globals" @@ -9,7 +9,7 @@ import "zx/globals" const pathToConfig = `${configDir}/apply-config.json` const pathToCache = `${cacheDir}/analysis.json` -console.debug(`Trying to load application config from ${pathToConfig}...`) +console.debug(chalkDebug(`Trying to load application config from ${pathToConfig}...`)) const config = await loadConfig( pathToConfig, defaultConfig, @@ -67,12 +67,12 @@ const lightnessValue = map( console.info(`Calculated target colour oklch(${lightnessValue} ${chromaValue} ${hueValue})!`) -console.debug(`Trying to open cache file ${pathToCache}...`) +console.debug(chalkDebug(`Trying to open cache file ${pathToCache}...`)) const cacheFile = await fs.promises.readFile(`${pathToCache}`, { encoding: "utf8", }) const imagesData = JSON.parse(cacheFile) as ImageAnalysisData -console.debug(`Opened cache file ${pathToCache}!`) +console.debug(chalkDebug(`Opened cache file ${pathToCache}!`)) const targetFile = findMatchingImages(imagesData, hueValue, chromaValue, lightnessValue) diff --git a/deno.lock b/deno.lock index 6adbed6..67695d1 100644 --- a/deno.lock +++ b/deno.lock @@ -3,6 +3,8 @@ "specifiers": { "jsr:@std/assert@1": "1.0.19", "jsr:@std/internal@^1.0.12": "1.0.14", + "jsr:@std/internal@^1.0.14": "1.0.14", + "jsr:@std/path@^1.1.5": "1.1.5", "npm:suncalc@2": "2.0.0", "npm:zx@^8.8.5": "8.8.5" }, @@ -39,6 +41,7 @@ ], "packageJson": { "dependencies": [ + "npm:chalk@^5.6.2", "npm:suncalc@2", "npm:zx@^8.8.5" ] diff --git a/package-lock.json b/package-lock.json index 1bb31cc..098c25b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,10 +5,23 @@ "packages": { "": { "dependencies": { + "chalk": "^5.6.2", "suncalc": "^2.0.0", "zx": "^8.8.5" } }, + "node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/suncalc": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/suncalc/-/suncalc-2.0.0.tgz", diff --git a/package.json b/package.json index 5e2aca6..1c5ec4f 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "chalk": "^5.6.2", "suncalc": "^2.0.0", "zx": "^8.8.5" } diff --git a/test.ts b/test.ts new file mode 100644 index 0000000..e69de29