feat: added some better logging
This commit is contained in:
parent
41c9e40cef
commit
223fc6c2d0
6 changed files with 58 additions and 4 deletions
13
README.md
Normal file
13
README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Priduck Theme CLI
|
||||
|
||||
_A CLI for generating a tri-color theme based on a single hue and an even rotation around the color wheel._
|
||||
|
||||
Priduck (name is nonscense) is a color theme originally designed for [Fedran](https://fedran.com) where the base color is a hue (in degrees, 0-360) with with nine colors based on an even distribution around the wheel with nine-levels of brightness ranging from a near-black to a near-white.
|
||||
|
||||
## Debugging
|
||||
|
||||
The CLI uses [debug](https://github.com/debug-js/debug) for logging and (relatively) minor output. The CLI will produce no output unless the `DEBUG` environment variable is set, such as:
|
||||
|
||||
```shell
|
||||
export DEBUG="*"
|
||||
```
|
26
package-lock.json
generated
26
package-lock.json
generated
|
@ -1,16 +1,17 @@
|
|||
{
|
||||
"name": "@priduck-color-theme/base",
|
||||
"name": "@priduck-color-theme/priduck-cli",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@priduck-color-theme/base",
|
||||
"name": "@priduck-color-theme/priduck-cli",
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@priduck-color-theme/cli": "^0.0.1",
|
||||
"colorjs.io": "^0.5.0",
|
||||
"debug": "^4.3.4",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -85,6 +86,22 @@
|
|||
"resolved": "https://registry.npmjs.org/colorjs.io/-/colorjs.io-0.5.0.tgz",
|
||||
"integrity": "sha512-qekjTiBLM3F/sXKks/ih5aWaHIGu+Ftel0yKEvmpbKvmxpNOhojKgha5uiWEUOqEpRjC1Tq3nJRT7WgdBOxIGg=="
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
|
@ -129,6 +146,11 @@
|
|||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
"dependencies": {
|
||||
"@priduck-color-theme/cli": "^0.0.1",
|
||||
"colorjs.io": "^0.5.0",
|
||||
"debug": "^4.3.4",
|
||||
"yargs": "^17.7.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import * as colors from "../../colors.mjs";
|
||||
import { write } from "../../output.mjs";
|
||||
import debug from "debug";
|
||||
|
||||
/** @type {object} */
|
||||
const log = debug("css").extend("variables");
|
||||
|
||||
export const command = "variables [path.css]";
|
||||
export const desc = "Generate a CSS file that uses variables to generate";
|
||||
|
@ -16,6 +20,8 @@ export async function handler(argv) {
|
|||
// Start with the basic CSS header.
|
||||
let lines = [":root {"];
|
||||
|
||||
log("generating CSS using variables");
|
||||
|
||||
// We have ten colors, with 0 being the base hue and the others being evenly
|
||||
// rotated around the color wheel.
|
||||
for (const color of colors.colorList) {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import * as colors from "../colors.mjs";
|
||||
import { write } from "../output.mjs";
|
||||
import debug from "debug";
|
||||
|
||||
/** @type {object} */
|
||||
const log = debug("palette");
|
||||
|
||||
export const command = "palette [path.gpl]";
|
||||
export const desc = "Generate a GNU Imp/Inkscape palette";
|
||||
|
@ -43,6 +47,10 @@ export async function handler(argv) {
|
|||
// Start with the header.
|
||||
let lines = ["GIMP Palette", `Name: ${argv.name}`, "Columns: 30", ""];
|
||||
|
||||
log("generating GPL palette named", argv.name);
|
||||
log("using base hue", argv.hue, "as color 0");
|
||||
log("using secondary", argv.secondary, "tertiary", argv.tertiary);
|
||||
|
||||
// Loop through the three primary colors, then the brightness for each one.
|
||||
const colorList = [0, argv.secondary, argv.tertiary];
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { mkdirp } from "mkdirp";
|
||||
import path from "path";
|
||||
import fs from "node:fs/promises";
|
||||
import debug from "debug";
|
||||
|
||||
/** @type {object} */
|
||||
const log = debug("output");
|
||||
|
||||
/**
|
||||
* Writes the output to either the console if there is no output or it is
|
||||
|
@ -24,12 +28,12 @@ export async function write(argv, input) {
|
|||
const file = argv.output;
|
||||
const dir = path.dirname(file);
|
||||
|
||||
console.log("writing", file);
|
||||
log("writing", file);
|
||||
|
||||
await mkdirp(dir);
|
||||
|
||||
// Now, write out the file.
|
||||
await fs.writeFile(file, Buffer.from(text));
|
||||
|
||||
console.log("wrote", file);
|
||||
log("wrote", file);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue