Skip to content

Commit

Permalink
💥 feat!: overwrite in ts config too
Browse files Browse the repository at this point in the history
  • Loading branch information
Rettend committed Jan 24, 2024
1 parent cda5b7a commit c731b37
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

## Backlog

- [ ] 2 more options: (any combination of these should work)
- [ ] 1 more options (any combination of options should work)
- [ ] `conventional (boolean) [true]` - only allow conventional commits, this package should work without conventional commits as well
- [ ] `overwrite (boolean) [false]` - overwrite the default emojis with the ones specified in the config (import the default emojis, import other presets)

## v2

- [x] Add e2e tests with github actions (for all operating systems)
- [x] Upgrade to unbuild `3.0.0` (currently errors), fix `masquerading as CJS` error [(see here)](https://arethetypeswrong.github.io/?p=eemoji)
- [x] Upgrade to unbuild `2.0.0` (currently errors), fix `masquerading as CJS` error [(see here)](https://arethetypeswrong.github.io/?p=eemoji) (fixed it but we ESM only now because i dont know what to do with the bin/eemoji.mjs entry file)
- [x] Upgrade antfu/eslint-config to `2.0.0` and make it work
- [x] `strict (boolean) [false]` - do not allow any commits without emojis
- [x] add `-v` alias for `--version`
- [x] make the consola start and success logs sane in the cleanup command
- [x] investigate speed, prepare script for init
- [x] move bin scripts to `scripts` folder and also build them from typescript
- [x] Generate the readme emoji table from `emojis.jsonc` (jsonc for description)
- [ ] overwrite the default emojis in ts config too (import the default emojis, import other presets)
- [ ] try astro and create a small website explaining which emoji to use and when, + stuff
1 change: 0 additions & 1 deletion build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default defineBuildConfig({
clean: true,
declaration: true,
rollup: {
emitCJS: true,
esbuild: {
minify: true,
},
Expand Down
7 changes: 3 additions & 4 deletions eemoji.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Config, defineConfig } from 'eemoji'
import { defineDefaultConfig } from 'eemoji'

export default defineConfig({
export default defineDefaultConfig({
emojis: {
add: {
'.': '➕',
Expand All @@ -18,5 +18,4 @@ export default defineConfig({
update: '👍',
},
},
} satisfies Partial<Config>,
)
})
14 changes: 4 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "eemoji",
"type": "module",
"version": "1.1.5",
"packageManager": "pnpm@8.10.0",
"packageManager": "pnpm@8.14.3",
"description": "(๑•̀ㅂ•́)و✧ Add emojis to git commits",
"author": "Rettend",
"license": "MIT",
Expand All @@ -16,15 +16,9 @@
"commit",
"emoji"
],
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"bin": {
"eemoji": "./bin/eemoji.mjs",
"eemoji-hook": "./bin/hook.sh"
Expand Down
15 changes: 12 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'node:path'
import process from 'node:process'
import { fileURLToPath } from 'node:url'
import { dirname } from 'node:path'
import { merge } from 'lodash-es'
import { merge, mergeWith } from 'lodash-es'
import { name } from '../package.json'
import emojis from './emojis.json'

Expand Down Expand Up @@ -42,9 +42,9 @@ export class ConfigObject {
emojis,
} satisfies Config

defaultTsConfig = `import { defineConfig } from 'eemoji'
defaultTsConfig = `import { defineDefaultConfig } from 'eemoji'
export default defineConfig({
export default defineDefaultConfig({
format: '{emoji} {type}: {subject}', // this is the default format (you can remove it or change it)
emojis: {}, // this gets merged with the default emojis (use it to override emojis or add new ones)
})
Expand Down Expand Up @@ -98,5 +98,14 @@ export default defineConfig({
export function defineConfig(config: Partial<Config>): Config {
const defaultConfig = new ConfigObject().defaultConfig

return mergeWith({}, defaultConfig, config, (_objValue, srcValue, key) => {
if (key === 'emojis')
return srcValue
})
}

export function defineDefaultConfig(config: Partial<Config>): Config {
const defaultConfig = new ConfigObject().defaultConfig

return merge({}, defaultConfig, config)
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { runMain as _runMain } from 'citty'
import { main } from './main'

export { defineConfig, type Config } from './config'
export { defineConfig, defineDefaultConfig, type Config } from './config'

export const runMain = () => _runMain(main)

0 comments on commit c731b37

Please sign in to comment.