-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
254 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# zhi-lib-log | ||
|
||
a simple logger for Node and Browser | ||
|
||
## Usage | ||
|
||
```ts | ||
import LogFactory from "@siyuan-community/zhi-log" | ||
|
||
const env = new Env(import.meta.env) | ||
const logger = LogFactory.defaultLogger(env) | ||
logger.debug("debug msg") | ||
logger.info("info msg") | ||
logger.error("error msg") | ||
``` | ||
|
||
## Deps | ||
|
||
``` | ||
├── @siyuan-community/zhi-device | ||
├── @siyuan-community/zhi-env | ||
├── loglevel | ||
├── callsites | ||
├── loglevel-plugin-prefix | ||
├── ansi-colors | ||
├── kleur | ||
``` | ||
|
||
## Dev | ||
|
||
```bash | ||
nx dev zhi-lib-log | ||
``` | ||
|
||
## Build | ||
|
||
```bash | ||
nx build zhi-lib-log | ||
``` | ||
|
||
## Test | ||
|
||
Execute the unit tests via [vitest](https://vitest.dev) | ||
|
||
```bash | ||
nx test zhi-lib-log | ||
``` | ||
|
||
## Publish | ||
|
||
``` | ||
nx publish zhi-lib-log --ver=0.0.1 --tag=latest | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "@siyuan-community/zhi-log", | ||
"version": "1.10.0", | ||
"type": "module", | ||
"description": "a simple logger for Node and Browser", | ||
"main": "./index.js", | ||
"typings": "./index.d.ts", | ||
"repository": "terwer/zhi", | ||
"homepage": "https://github.com/terwer/zhi/tree/main/packages/zhi-lib-log", | ||
"author": "terwer", | ||
"license": "GPL", | ||
"keywords": [ | ||
"zhi", | ||
"log", | ||
"zhi-log" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "zhi-lib-log", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/zhi-lib-log/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/vite:build", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/packages/zhi-lib-log" | ||
} | ||
}, | ||
"publish": { | ||
"command": "node tools/scripts/publish.mjs zhi-lib-log {args.ver} {args.tag}", | ||
"dependsOn": ["build"] | ||
}, | ||
"test": { | ||
"executor": "@nx/vite:test", | ||
"outputs": ["coverage/packages/zhi-lib-log"], | ||
"options": { | ||
"passWithNoTests": true, | ||
"reportsDirectory": "../../coverage/packages/zhi-lib-log" | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["packages/zhi-lib-log/**/*.ts"] | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./lib/zhi-lib-log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { zhiLibLog } from "./zhi-lib-log" | ||
|
||
describe("zhiLibLog", () => { | ||
it("should work", () => { | ||
expect(zhiLibLog()).toEqual("zhi-lib-log") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function zhiLibLog(): string { | ||
return "zhi-lib-log" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"types": ["vitest"] | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] | ||
}, | ||
"include": [ | ||
"vite.config.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.test.tsx", | ||
"src/**/*.spec.tsx", | ||
"src/**/*.test.js", | ||
"src/**/*.spec.js", | ||
"src/**/*.test.jsx", | ||
"src/**/*.spec.jsx", | ||
"src/**/*.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/// <reference types="vitest" /> | ||
import { defineConfig } from "vite" | ||
|
||
import viteTsConfigPaths from "vite-tsconfig-paths" | ||
import dts from "vite-plugin-dts" | ||
import { join } from "path" | ||
import noBundlePlugin from "vite-plugin-no-bundle" | ||
import { viteStaticCopy } from "vite-plugin-static-copy" | ||
|
||
const isTest = process.env["npm_command"] === "test" | ||
console.log("isTest=>", isTest) | ||
|
||
export default defineConfig({ | ||
cacheDir: "../../node_modules/.vite/zhi-lib-log", | ||
|
||
plugins: [ | ||
dts({ | ||
entryRoot: "src", | ||
tsConfigFilePath: join(__dirname, "tsconfig.lib.json"), | ||
skipDiagnostics: true, | ||
}), | ||
|
||
!isTest && | ||
viteTsConfigPaths({ | ||
root: "../../", | ||
}), | ||
|
||
!isTest && noBundlePlugin(), | ||
|
||
viteStaticCopy({ | ||
targets: [ | ||
{ | ||
src: "README.md", | ||
dest: ".", | ||
}, | ||
], | ||
}), | ||
], | ||
|
||
// Configuration for building your library. | ||
// See: https://vitejs.dev/guide/build.html#library-mode | ||
build: { | ||
lib: { | ||
// Could also be a dictionary or array of multiple entry points. | ||
entry: "src/index.ts", | ||
name: "zhi-lib-log", | ||
fileName: "index", | ||
// Change this to the formats you want to support. | ||
// Don't forgot to update your package.json as well. | ||
formats: ["es"], | ||
}, | ||
rollupOptions: { | ||
// External packages that should not be bundled into your library. | ||
external: [], | ||
}, | ||
}, | ||
|
||
test: { | ||
globals: true, | ||
cache: { | ||
dir: "../../node_modules/.vitest", | ||
}, | ||
environment: "jsdom", | ||
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters