@innei/pretty-logger-core 0.3.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/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './consola.instance'
2
+ export * from './consola/reporters'
3
+ export * from './consola'
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@innei/pretty-logger-core",
3
+ "version": "0.3.0",
4
+ "main": "dist/index.js",
5
+ "module": "dist/index.mjs",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "require": "./dist/index.js",
10
+ "import": "./dist/index.mjs"
11
+ }
12
+ },
13
+ "dependencies": {
14
+ "cron": "3.1.6",
15
+ "defu": "^6.1.3",
16
+ "picocolors": "^1.0.0",
17
+ "std-env": "^3.5.0",
18
+ "string-width": "npm:@innei/string-width@7.1.1-fork.0"
19
+ },
20
+ "scripts": {
21
+ "build": "tsup"
22
+ }
23
+ }
package/tool.util.ts ADDED
@@ -0,0 +1,29 @@
1
+ import path from 'path'
2
+
3
+ export const getShortTime = (date: Date) => {
4
+ return Intl.DateTimeFormat('en-US', {
5
+ timeStyle: 'medium',
6
+ hour12: false,
7
+ }).format(date)
8
+ }
9
+
10
+ export const getShortDate = (date: Date) => {
11
+ return Intl.DateTimeFormat('en-US', {
12
+ dateStyle: 'short',
13
+ })
14
+ .format(date)
15
+ .replace(/\//g, '-')
16
+ }
17
+ /** 2-12-22, 21:31:42 */
18
+ export const getShortDateTime = (date: Date) => {
19
+ return Intl.DateTimeFormat('en-US', {
20
+ dateStyle: 'short',
21
+ timeStyle: 'medium',
22
+ hour12: false,
23
+ })
24
+ .format(date)
25
+ .replace(/\//g, '-')
26
+ }
27
+
28
+ export const getLogFilePath = (logDir: string, formatString: string) =>
29
+ path.resolve(logDir, formatString.replace(/%d/g, getShortDate(new Date())))
package/tsup.config.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from 'tsup'
2
+
3
+ export default defineConfig({
4
+ clean: true,
5
+ target: 'es2020',
6
+ entry: ['index.ts'],
7
+ dts: true,
8
+ format: ['cjs', 'esm'],
9
+ })