Skip to content

Commit

Permalink
chore(release): v0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kettei-sproutty committed Aug 17, 2024
1 parent a4dfe4a commit 39d818c
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 30 deletions.
32 changes: 32 additions & 0 deletions examples/basic.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import colsys from '../src/main.mjs';

console.log(
colsys.bold("bold"),
colsys.dim("dim"),
colsys.italic("italic"),
colsys.underline("underline"),
colsys.inverse("inverse"),
colsys.strikethrough("strikethrough"),
colsys.black("black")
);

console.log(
colsys.red("red"),
colsys.green("green"),
colsys.yellow("yellow"),
colsys.blue("blue"),
colsys.magenta("magenta"),
colsys.cyan("cyan"),
colsys.white("white"),
colsys.gray("gray"),
);

console.log(
colsys.bgRed("bgRed"),
colsys.bgGreen("bgGreen"),
colsys.bgYellow("bgYellow"),
colsys.bgBlue("bgBlue"),
colsys.bgMagenta("bgMagenta"),
colsys.bgCyan("bgCyan"),
colsys.bgWhite("bgWhite")
);
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "colsys",
"version": "0.1.3",
"contributors": [
"Luca di Gianventura <lutaok>",
"Alessio Marchi <kettei-sproutty>"
],
"version": "0.1.5",
"main": "src/main.mjs",
"contributors": [
"Luca di Gianventura <lutaok>",
"Alessio Marchi <kettei-sproutty>"
],
"description": "A light and zero-dependecy terminal string styling library",
"license": "(MIT OR Apache-2.0)",
"keywords": [
Expand Down Expand Up @@ -41,15 +42,22 @@
"types": "./src/main.d.ts"
}
},
"scripts": {
"scripts": {
"bench": "node benchmarks/simple.mjs",
"release": "node release.mjs",
"format": "biome format --write",
"test": "vitest"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@types/node": "^22.4.0",
"ansi-colors": "^4.1.3",
"benchmark": "^2.1.4",
"chalk": "^5.3.0",
"colorette": "^2.0.20",
"colors": "^1.4.0",
"kleur": "^4.1.5",
"picocolors": "^1.0.1",
"vitest": "^2.0.5"
},
"engines": {
Expand Down
64 changes: 62 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ fs.writeFileSync("package.json", JSON.stringify(packageJSON, undefined, "\t"));

const execPromise = promisify(exec);

await execPromise("pnpm pack");
const { stdout } = await execPromise("pnpm publish --no-git-checks")

console.log(stdout);
Expand Down
13 changes: 8 additions & 5 deletions src/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ const util = require("node:util");

const handler = {
get(target, property) {
const properties = target?.()?.properties || [];
properties.push(property);
return new Proxy(() => ({ properties }), handler);
let properties = [];
if (target && typeof target === 'function' && target()) {
properties = target().properties || [];
}
properties.push(property)
return new Proxy(() => ({ properties }), handler);
},

apply(target, _thisArg, args) {
const properties = target?.()?.properties;
const properties = target().properties;
return util.styleText(properties, args.join(" "));
},
};

const nodeSyles = new Proxy(() => {}, handler);
const nodeSyles = new Proxy(function() {}, handler);

module.exports = nodeSyles;
9 changes: 4 additions & 5 deletions src/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ type OmitArray<T> = T extends (infer U)[] ? U : T;

type Params = OmitArray<Parameters<typeof styleText>[0]>;

type NodeStylesProxy = {
[key in Params]: NodeStylesProxy & ((...args: any[]) => string);
type ColsysProxy = {
[key in Params]: ColsysProxy & ((...args: any[]) => string);
};

/**
Expand All @@ -19,7 +19,6 @@ type NodeStylesProxy = {
* colsys.red.bold("red+bold");
* ```
*/
declare const nodeStyles: NodeStylesProxy;
declare const colsys: ColsysProxy;


export default nodeStyles;
export default colsys;
24 changes: 13 additions & 11 deletions src/main.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { styleText } from "node:util";

let properties = [];

const handler = {
get(target, property) {
const properties = target?.()?.properties || [];
properties.push(property);
return new Proxy(() => ({ properties }), handler);
},
get(_target, property, receiver) {
properties.push(property);
return receiver;
},

apply(target, _thisArg, args) {
const properties = target?.()?.properties;
return styleText(properties, args.join(" "));
},
apply(_target, _thisArg, args) {
const style = styleText(properties, args.join(" "));

Check failure on line 12 in src/main.mjs

View workflow job for this annotation

GitHub Actions / test

tests/chalk.test.js > advanced chalk compatibility > it can parse RGB

TypeError: The argument 'format' must be one of: 'reset', 'bold', 'dim', 'italic', 'underline', 'blink', 'inverse', 'hidden', 'strikethrough', 'doubleunderline', 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'bgBlack', 'bgRed', 'bgGreen', 'bgYellow', 'bgBlue', 'bgMagenta', 'bgCyan', 'bgWhite', 'framed', 'overlined', 'gray', 'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright', 'whiteBright', 'bgGray', 'bgRedBright', 'bgGreenBright', 'bgYellowBright', 'bgBlueBright', 'bgMagentaBright', 'bgCyanBright', 'bgWhiteBright'. Received 'rgb' ❯ Object.apply src/main.mjs:12:19 ❯ tests/chalk.test.js:64:5 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_INVALID_ARG_VALUE' }

Check failure on line 12 in src/main.mjs

View workflow job for this annotation

GitHub Actions / test

tests/chalk.test.js > advanced chalk compatibility > it can parse HEX

TypeError: The argument 'format' must be one of: 'reset', 'bold', 'dim', 'italic', 'underline', 'blink', 'inverse', 'hidden', 'strikethrough', 'doubleunderline', 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'bgBlack', 'bgRed', 'bgGreen', 'bgYellow', 'bgBlue', 'bgMagenta', 'bgCyan', 'bgWhite', 'framed', 'overlined', 'gray', 'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright', 'whiteBright', 'bgGray', 'bgRedBright', 'bgGreenBright', 'bgYellowBright', 'bgBlueBright', 'bgMagentaBright', 'bgCyanBright', 'bgWhiteBright'. Received 'rgb' ❯ Object.apply src/main.mjs:12:19 ❯ tests/chalk.test.js:72:25 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_INVALID_ARG_VALUE' }
properties = [];
return style
}
};

const nodeSyles = new Proxy(() => {}, handler);
const colsys = new Proxy(() => {}, handler);

export default nodeSyles;
export default colsys;

0 comments on commit 39d818c

Please sign in to comment.