Skip to content

Commit

Permalink
refactor: deps and formatting
Browse files Browse the repository at this point in the history
This commit removes xo linting, updates dependencies, and refactor tests
to no longer require `ts-node`.
  • Loading branch information
mvllow committed Sep 2, 2023
1 parent 587cb7d commit 3984d3c
Show file tree
Hide file tree
Showing 14 changed files with 325 additions and 351 deletions.
37 changes: 8 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"scripts": {
"build": "del-cli dist && tsc && npm test",
"test": "del-cli test/mock/dist && xo && ava",
"release": "np",
"test": "del-cli test/mock/dist && ava",
"release": "npx np@latest",
"version": "npm run build"
},
"files": [
Expand All @@ -31,35 +31,14 @@
"dependencies": {
"@rose-pine/palette": "4.0.1",
"chokidar": "^3.5.3",
"meow": "^11.0.0"
"meow": "^12.1.1"
},
"devDependencies": {
"@mvllow/tsconfig": "^0.2.2",
"@types/node": "^18.15.11",
"ava": "^5.2.0",
"del-cli": "^5.0.0",
"np": "^7.7.0",
"prettier": "^2.8.7",
"ts-node": "^10.9.1",
"typescript": "^5.0.2",
"xo": "^0.53.1"
},
"prettier": {
"bracketSpacing": false,
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"useTabs": true
},
"xo": {
"prettier": true
},
"ava": {
"extensions": {
"ts": "module"
},
"nodeArguments": [
"--loader=ts-node/esm"
]
"@types/node": "^20.5.8",
"ava": "^5.3.1",
"del-cli": "^5.1.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
}
}
140 changes: 63 additions & 77 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,109 +37,95 @@ $ npx @rose-pine/build --help
$ npx @rose-pine/build -t ./template.yml -o ./
```

## Formats

**hex**\
`#ebbcba`

**hex-ns**\
`ebbcba`

**rgb**\
`235, 188, 186`

**rgb-ns**\
`235 188 186`

**rgb-array**\
`[235, 188, 186]`

**rgb-function**\
`rgb(235, 188, 186)`

**hsl**\
`2, 55%, 83%`

**hsl-ns**\
`2 55% 83%`

**hsl-array**\
`[2, 55%, 83%]`

**hsl-function**\
`hsl(2, 55%, 83%)`
## Color formats

| Name | Example |
| ------------ | -------------------- |
| hex | `#ebbcba` |
| hex-ns | `ebbcba` |
| rgb | `235, 188, 186` |
| rgb-ns | `235 188 186` |
| rgb-array | `[235, 188, 186]` |
| rgb-function | `rgb(235, 188, 186)` |
| hsl | `2, 55%, 83%` |
| hsl-ns | `2 55% 83%` |
| hsl-array | `[2, 55%, 83%]` |
| hsl-function | `hsl(2, 55%, 83%)` |

## Variables

> By default, variables are prefixed with `$`
All values from [@rose-pine/palette](https://github.com/rose-pine/palette) are available as well as the following:
All values from [@rose-pine/palette](https://github.com/rose-pine/palette) are available as well as the following.

**id**\
`rose-pine | rose-pine-moon | rose-pine-dawn`
### Metadata

**name**\
`Rosé Pine | Rosé Pine Moon | Rosé Pine Dawn`
```jsonc
// template.json
{
"id": "$id",
"name": "$name",
"description": "$description",
"type": "$type",
}

**description**\
`All natural pine, faux fur and a bit of soho vibes for the classy minimalist`
// rose-pine.json
{
"id": "rose-pine",
"name": "Rosé Pine",
"description": "All natural pine, faux fur and a bit of soho vibes for the classy minimalist",
"type": "dark",
}

**type**\
`dark | dark | light`
// rose-pine-moon.json
{
"id": "rose-pine-moon",
"name": "Rosé Pine Moon",
"description": "All natural pine, faux fur and a bit of soho vibes for the classy minimalist",
"type": "dark",
}

**highlight{Low,Med,High}Alpha**\
Highlight color with transparency, e.g. `#d4ccff36` or `rgba(212, 204, 255, 0.21)`
// rose-pine-dawn.json
{
"id": "rose-pine-dawn",
"name": "Rosé Pine Dawn",
"description": "All natural pine, faux fur and a bit of soho vibes for the classy minimalist",
"type": "light",
}
```

## Custom values per variant

> Use different values for each variant. Format as `$(main|moon|dawn)`.
> Use different values for each variant, formatted as `$(main|moon|dawn)`
### Named colors

**template**

```jsonc
{
"accent": "$($rose|$iris|$pine)"
}
```

**output**
// template.json
{ "accent": "$($rose|$iris|$pine)" }

```jsonc
{
// rose-pine.json
"accent": "#ebbcba"
// rose-pine.json
{ "accent": "#ebbcba" }

// rose-pine-moon.json
"accent": "#c4a7e7"
// rose-pine-moon.json
{ "accent": "#c4a7e7" }

// rose-pine-dawn.json
"accent": "#286983"
}
// rose-pine-dawn.json
{ "accent": "#286983" }
```

### Strings

**template**

```jsonc
{
"order": "$(Caffè|Cappuccino|Marocchino)"
}
```
// template.json
{ "order": "$(Caffè|Cappuccino|Marocchino)" }

**output**
// rose-pine.json
{ "order": "Caffè" }

```jsonc
{
// rose-pine.json
"order": "Caffè"
// rose-pine-moon.json
{ "order": "Cappuccino" }

// rose-pine-moon.json
"order": "Cappuccino"

// rose-pine-dawn.json
"order": "Marocchino"
}
// rose-pine-dawn.json
{ "order": "Marocchino" }
```
34 changes: 17 additions & 17 deletions source/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import meow from 'meow'
import build from './index.js'
import meow from "meow";
import build from "./index.js";

const cli = meow(
`
Expand All @@ -25,32 +25,32 @@ const cli = meow(
importMeta: import.meta,
flags: {
template: {
alias: 't',
type: 'string',
shortFlag: "t",
type: "string",
},
output: {
alias: 'o',
type: 'string',
shortFlag: "o",
type: "string",
},
prefix: {
alias: 'p',
type: 'string',
shortFlag: "p",
type: "string",
},
format: {
alias: 'f',
type: 'string',
shortFlag: "f",
type: "string",
},
stripSpaces: {
alias: 's',
type: 'boolean',
shortFlag: "s",
type: "boolean",
},
watch: {
alias: 'w',
type: 'boolean',
shortFlag: "w",
type: "boolean",
},
},
}
)
},
);

// @ts-expect-error We need to account for format
await build(cli.flags)
await build(cli.flags);
60 changes: 30 additions & 30 deletions source/config.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import process from 'node:process'
import process from "node:process";

export type CustomValues = Record<
string,
{
main?: string
moon?: string
dawn?: string
main?: string;
moon?: string;
dawn?: string;
}
>
>;

export type Config = {
__skipReadmeVersion: boolean
template: string
output: string
prefix: string
__skipReadmeVersion: boolean;
template: string;
output: string;
prefix: string;
format:
| 'hex'
| 'hex-ns'
| 'rgb'
| 'rgb-ns'
| 'rgb-array'
| 'rgb-function'
| 'hsl'
| 'hsl-ns'
| 'hsl-array'
| 'hsl-function'
stripSpaces: boolean
watch: boolean
}
| "hex"
| "hex-ns"
| "rgb"
| "rgb-ns"
| "rgb-array"
| "rgb-function"
| "hsl"
| "hsl-ns"
| "hsl-array"
| "hsl-function";
stripSpaces: boolean;
watch: boolean;
};

export type UserOptions = Partial<Config>
export type UserOptions = Partial<Config>;

export const resolveConfig = (flags?: UserOptions) => {
const defaultConfig: Config = {
__skipReadmeVersion: false,
template: process.cwd() + '/source/template.json',
output: process.cwd() + '/dist',
prefix: '$',
format: 'hex',
template: process.cwd() + "/source/template.json",
output: process.cwd() + "/dist",
prefix: "$",
format: "hex",
stripSpaces: false,
watch: false,
}
};

return Object.assign(defaultConfig, flags)
}
return Object.assign(defaultConfig, flags);
};
26 changes: 13 additions & 13 deletions source/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import {resolveConfig, type UserOptions} from './config.js'
import {watch} from './watch.js'
import {getPackageVersion} from './utils/get-package-version.js'
import {generateVariants} from './utils/generate-variants.js'
import {updateReadmeVersion} from './utils/update-readme-version.js'
import { resolveConfig, type UserOptions } from "./config.js";
import { watch } from "./watch.js";
import { getPackageVersion } from "./utils/get-package-version.js";
import { generateVariants } from "./utils/generate-variants.js";
import { updateReadmeVersion } from "./utils/update-readme-version.js";

export const build = async (flags?: UserOptions) => {
const config = resolveConfig(flags)
const config = resolveConfig(flags);

generateVariants(config)
generateVariants(config);

if (!config.__skipReadmeVersion) {
const version = getPackageVersion()
updateReadmeVersion(version, flags)
const version = getPackageVersion();
updateReadmeVersion(version, flags);
}

if (config.watch) {
console.log('👀 Waiting for changes...\n')
await watch(config)
console.log("👀 Waiting for changes...\n");
await watch(config);
}
}
};

export default build
export default build;
Loading

0 comments on commit 3984d3c

Please sign in to comment.