t0n 0.20260804.0 → 0.20260913.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/cli.ts +5 -2
- package/src/id.ts +1 -0
- package/src/string.ts +1 -1
- package/src/timestamp.ts +1 -1
- package/src/toint.ts +6 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "t0n",
|
|
3
3
|
"description": "Collection of elegant typescript resources for web artisans",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20260913.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
7
7
|
"files": ["src"],
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"chokidar": "^3.5.2",
|
|
21
21
|
"citty": "^0.2.2",
|
|
22
22
|
"consola": "^3.4.2",
|
|
23
|
-
"hono": "^4.
|
|
23
|
+
"hono": "^4.13.7",
|
|
24
24
|
"pathe": "^2.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"bun-types": "^1.
|
|
27
|
+
"bun-types": "^1.4.0",
|
|
28
28
|
"tsx": "^4.19.4",
|
|
29
29
|
"typescript": "^5.9.3"
|
|
30
30
|
},
|
package/src/cli.ts
CHANGED
|
@@ -112,15 +112,17 @@ export const killProcess = async (proc: Bun.Subprocess | null) => {
|
|
|
112
112
|
|
|
113
113
|
import { isColorSupported, dim } from './color'
|
|
114
114
|
import { defineCommand, runMain, renderUsage } from 'citty'
|
|
115
|
-
import type { ArgsDef, CommandDef } from 'citty'
|
|
115
|
+
import type { ArgsDef, CommandContext, CommandDef } from 'citty'
|
|
116
116
|
import { createConsola } from 'consola'
|
|
117
117
|
|
|
118
118
|
export { defineCommand as command }
|
|
119
|
-
export function cli({ name, description, version, commands }: {
|
|
119
|
+
export function cli({ name, description, version, commands, setup, cleanup }: {
|
|
120
120
|
name: string,
|
|
121
121
|
description?: string,
|
|
122
122
|
version: string,
|
|
123
123
|
commands: Record<string, string>,
|
|
124
|
+
setup?: ((context: CommandContext) => any | Promise<any>),
|
|
125
|
+
cleanup?: ((context: CommandContext) => any | Promise<any>)
|
|
124
126
|
}) {
|
|
125
127
|
const _cli = description || name.toUpperCase()
|
|
126
128
|
const v = [_cli, isColorSupported ? dim('v'+version) : version].join(' ')
|
|
@@ -150,5 +152,6 @@ export function cli({ name, description, version, commands }: {
|
|
|
150
152
|
description: _cli,
|
|
151
153
|
},
|
|
152
154
|
subCommands: Object.fromEntries(Object.entries(commands).map(([key, path]) => [key, () => import(path).then(r => r.default)])),
|
|
155
|
+
setup, cleanup,
|
|
153
156
|
}), { rawArgs: length ? undefined : ['-h'], showUsage })
|
|
154
157
|
}
|
package/src/id.ts
CHANGED
package/src/string.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const normalize = (text: string, sep: string) =>
|
|
2
2
|
text.replace(/([a-z])([A-Z])/g, `$1${sep}$2`)
|
|
3
|
-
.replace(/[\s
|
|
3
|
+
.replace(/[\s\.\-_\/\\]+/g, sep)
|
|
4
4
|
.toLowerCase()
|
|
5
5
|
.replace(new RegExp(`[^\\w${sep}]+`, 'g'), '')
|
|
6
6
|
.replace(new RegExp(`${sep}{2,}`, 'g'), sep)
|
package/src/timestamp.ts
CHANGED
package/src/toint.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export function toInt(
|
|
2
|
-
if (typeof
|
|
3
|
-
return
|
|
1
|
+
export function toInt(val: any[] | string | number): number {
|
|
2
|
+
if (typeof val === 'number')
|
|
3
|
+
return Math.abs(val)
|
|
4
|
+
// if (typeof data === 'number' && Number.isInteger(data))
|
|
5
|
+
// return data
|
|
4
6
|
|
|
5
|
-
const jsonString = JSON.stringify(
|
|
7
|
+
const jsonString = JSON.stringify(val)
|
|
6
8
|
// Simplified implementation without MD5 (less accurate than the original)
|
|
7
9
|
// TODO: add o md5 and stable-hash
|
|
8
10
|
const numericString = jsonString.replace(/\D/g, '')
|