Skip to content

Commit

Permalink
fix: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
nethriis committed May 7, 2024
1 parent 2f23dfb commit 01857b9
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 26 deletions.
30 changes: 21 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
{
"name": "harmony-framework",
"private": true,
"repository": {
"type": "git",
"url": "git+https://github.com/harmony-ts/harmony.git"
},
"name": "harmony",
"version": "0.0.1",
"description": "⚡ Next-gen Discord Bot Framework",
"repository": "harmony-ts/harmony",
"license": "MIT",
"type": "module",
"exports": {
".": {
"types": "./types.d.ts",
"import": "./dist/index.mjs"
},
"./package.json": "./package.json"
},
"main": "./dist/index.mjs",
"types": "./types.d.ts",
"files": [
"dist",
"*.d.ts"
],
"scripts": {
"prepack": "unbuild",
"start": "node ./bin/index.mjs",
"lint": "prettier --write ."
},
"types": "./dist/index.d.ts",
"resolutions": {
"harmony": "link:."
},
"dependencies": {
"c12": "^1.10.0",
"defu": "^6.1.4",
Expand All @@ -32,6 +45,5 @@
"packageManager": "[email protected]",
"engines": {
"node": "^16.0.0 || >=18.0.0"
},
"version": ""
}
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

8 changes: 4 additions & 4 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { filename } from 'pathe/utils'
import type {
CommandExecute,
CommandOptions,
Harmony,
HarmonyCommand,
HarmonyCommandInput
} from '../types'
import { Harmony } from './harmony'
} from './types'

export const resolveHarmonyCommand = (
cmd: HarmonyCommandInput,
Expand All @@ -20,8 +20,8 @@ export const resolveHarmonyCommand = (
const _cmdPath = _jiti.resolve(cmd)
const command = _jiti(_cmdPath) as HarmonyCommand<boolean>
const options: CommandOptions = {
name: filename(_cmdPath).split('.')[0],
category: filename(dirname(_cmdPath)),
name: command.options.name || filename(_cmdPath).split('.')[0],
category: command.options.category || filename(dirname(_cmdPath)),
slash: command.options.slash || filename(_cmdPath).endsWith('.slash'),
...command.options
}
Expand Down
6 changes: 3 additions & 3 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import type {
DefineEventWithOptions,
EventCallback,
EventOptions,
Harmony,
HarmonyEvent,
HarmonyEventInput
} from '../types'
import { Harmony } from './harmony'
} from './types'

export const resolveHarmonyEvent = (
evt: HarmonyEventInput,
Expand All @@ -21,7 +21,7 @@ export const resolveHarmonyEvent = (
const _evtPath = _jiti.resolve(evt)
const event = _jiti(_evtPath) as HarmonyEvent
const options: EventOptions = {
name: filename(_evtPath).split('.')[0],
name: event.options.name || filename(_evtPath).split('.')[0],
once: event.options.once || filename(_evtPath).endsWith('.once')
}

Expand Down
8 changes: 2 additions & 6 deletions src/harmony.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { HarmonyConfig, HarmonyOptions } from '../types'
import { loadOptions } from './config'
import type { LoadConfigOptions } from 'c12'
import { loadOptions } from './options'
import { scanCommands, scanEvents } from './scan'
import { resolveHarmonyCommand } from './commands'
import { resolveHarmonyEvent } from './events'

export interface Harmony {
options: HarmonyOptions
}
import type { Harmony, HarmonyConfig, HarmonyOptions } from './types'

export const createHarmony = async (
config: HarmonyConfig = {},
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './commands'
export * from './events'
export * from './config'
export * from './options'
export * from './harmony'
export * from './scan'
2 changes: 1 addition & 1 deletion src/config.ts → src/options.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LoadConfigOptions, loadConfig } from 'c12'
import { resolve } from 'pathe'
import type { HarmonyConfig } from '../types'
import type { HarmonyConfig } from './types'

const HarmonyDefaults: HarmonyConfig = {
scanDirs: [],
Expand Down
2 changes: 1 addition & 1 deletion src/scan.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { globby } from 'globby'
import { join, relative } from 'pathe'
import { Harmony } from './harmony'
import { Harmony } from './types'

const GLOB_SCAN_PATTERN = '**/*.{js,ts}'

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"resolveJsonModule": true,
"types": ["node", "./types"]
},
"include": ["src", "types"]
"include": ["src"]
}

0 comments on commit 01857b9

Please sign in to comment.