-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from deno-library/JSR
Switch to JSR deployement
- Loading branch information
Showing
21 changed files
with
903 additions
and
55 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ jobs: | |
- name: Setup Deno | ||
uses: denoland/[email protected] | ||
with: | ||
deno-version: v1.40.x | ||
deno-version: v1.43.3 | ||
|
||
- name: Node setup | ||
uses: actions/[email protected] | ||
|
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 |
---|---|---|
|
@@ -24,7 +24,8 @@ jobs: | |
uses: denoland/[email protected] | ||
# uses: denoland/setup-deno@9db7f66e8e16b5699a514448ce994936c63f0d54 | ||
with: | ||
deno-version: v1.40.x # required due to usage of Deno.stdout.isTerminal() | ||
deno-version: v1.43.3 | ||
# deno-version: v1.40.x # required due to usage of Deno.stdout.isTerminal() | ||
# deno-version: v1.x | ||
|
||
- name: Verify formatting | ||
|
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,47 @@ | ||
name: Publish to JSR | ||
|
||
on: | ||
release: | ||
types: [created] | ||
workflow_dispatch: | ||
inputs: | ||
npm_version: | ||
description: 'Version number to publish on JSR X.Y.Z' | ||
required: true | ||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- name: Setup repo | ||
uses: actions/[email protected] # use nodeJS 20 | ||
|
||
- name: Setup Deno | ||
uses: denoland/[email protected] | ||
with: | ||
deno-version: v1.43.3 | ||
|
||
- name: Node setup | ||
uses: actions/[email protected] | ||
with: | ||
node-version: 20 | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- name: Run linter | ||
run: deno lint | ||
|
||
- name: Run tests | ||
run: deno test -A | ||
|
||
- name: show deno version | ||
run: deno --version | ||
|
||
- name: Publish package ${{inputs.npm_version}} | ||
run: npx jsr publish |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# deno-logger | ||
|
||
[![NPM Version](https://img.shields.io/npm/v/@denodnt/logger.svg?style=flat)](https://www.npmjs.org/package/@denodnt/logger) | ||
[![JSR Version](https://jsr.io/badges/@deno-lib/logger)](https://jsr.io/@deno-lib/logger) | ||
|
||
Deno / NodeJS colorful logger colorful logger | ||
|
||
For Deno usage refer to [deno-logger doc](https://deno.land/x/logger) | ||
|
@@ -10,7 +12,7 @@ For Deno usage refer to [deno-logger doc](https://deno.land/x/logger) | |
### console logger | ||
|
||
```js | ||
import Logger from "https://deno.land/x/[email protected].5/logger.ts"; | ||
import Logger from "https://deno.land/x/[email protected].6/logger.ts"; | ||
|
||
const logger = new Logger(); | ||
|
||
|
@@ -22,7 +24,7 @@ logger.error("i am from consoleLogger", new Error("test")); | |
### file and console logger | ||
|
||
```js | ||
import Logger from "https://deno.land/x/[email protected].5/logger.ts"; | ||
import Logger from "https://deno.land/x/[email protected].6/logger.ts"; | ||
|
||
const logger = new Logger(); | ||
|
||
|
@@ -42,7 +44,7 @@ logger.error("i am from fileLogger", new Error("test")); | |
### file logger only | ||
|
||
```js | ||
import Logger from "https://deno.land/x/[email protected].5/logger.ts"; | ||
import Logger from "https://deno.land/x/[email protected].6/logger.ts"; | ||
|
||
const logger = new Logger(); | ||
await logger.initFileLogger("../log"); | ||
|
@@ -68,7 +70,7 @@ interface fileLoggerOptions { | |
example | ||
|
||
```js | ||
import Logger from "https://deno.land/x/[email protected].5/logger.ts"; | ||
import Logger from "https://deno.land/x/[email protected].6/logger.ts"; | ||
const logger = new Logger(); | ||
|
||
// cut by day | ||
|
@@ -97,25 +99,23 @@ await logger.initFileLogger("../log", { | |
// filename is [type].log.[n] | ||
// example info.log.1, info.log.2 ... | ||
// when reach maxBackupCount, the [type].log.[maxBackupCount-1] will be overwrite | ||
/* | ||
detail: | ||
`maxBytes` specifies the maximum size | ||
in bytes that the log file can grow to before rolling over to a new one. If the | ||
size of the new log message plus the current log file size exceeds `maxBytes` | ||
then a roll over is triggered. When a roll over occurs, before the log message | ||
is written, the log file is renamed and appended with `.1`. If a `.1` version | ||
already existed, it would have been renamed `.2` first and so on. The maximum | ||
number of log files to keep is specified by `maxBackupCount`. After the renames | ||
are complete the log message is written to the original, now blank, file. | ||
Example: Given `log.txt`, `log.txt.1`, `log.txt.2` and `log.txt.3`, a | ||
`maxBackupCount` of 3 and a new log message which would cause `log.txt` to | ||
exceed `maxBytes`, then `log.txt.2` would be renamed to `log.txt.3` (thereby | ||
discarding the original contents of `log.txt.3` since 3 is the maximum number of | ||
backups to keep), `log.txt.1` would be renamed to `log.txt.2`, `log.txt` would | ||
be renamed to `log.txt.1` and finally `log.txt` would be created from scratch | ||
where the new log message would be written. | ||
*/ | ||
// detail: | ||
// `maxBytes` specifies the maximum size | ||
// in bytes that the log file can grow to before rolling over to a new one. If the | ||
// size of the new log message plus the current log file size exceeds `maxBytes` | ||
// then a roll over is triggered. When a roll over occurs, before the log message | ||
// is written, the log file is renamed and appended with `.1`. If a `.1` version | ||
// already existed, it would have been renamed `.2` first and so on. The maximum | ||
// number of log files to keep is specified by `maxBackupCount`. After the renames | ||
// are complete the log message is written to the original, now blank, file. | ||
// | ||
// Example: Given `log.txt`, `log.txt.1`, `log.txt.2` and `log.txt.3`, a | ||
// `maxBackupCount` of 3 and a new log message which would cause `log.txt` to | ||
// exceed `maxBytes`, then `log.txt.2` would be renamed to `log.txt.3` (thereby | ||
// discarding the original contents of `log.txt.3` since 3 is the maximum number of | ||
// backups to keep), `log.txt.1` would be renamed to `log.txt.2`, `log.txt` would | ||
// be renamed to `log.txt.1` and finally `log.txt` would be created from scratch | ||
// where the new log message would be written. | ||
await logger.initFileLogger("../log", { | ||
maxBytes: 10 * 1024, | ||
maxBackupCount: 10, | ||
|
@@ -158,7 +158,7 @@ await logger.initFileLogger("../log", { | |
## disableConsole and enableConsole | ||
|
||
```js | ||
import Logger from "https://deno.land/x/[email protected].5/logger.ts"; | ||
import Logger from "https://deno.land/x/[email protected].6/logger.ts"; | ||
|
||
const logger = new Logger(); | ||
|
||
|
@@ -175,7 +175,7 @@ logger.info("console enabled, you can see me"); | |
## disableFile and enableFile | ||
|
||
```js | ||
import Logger from "https://deno.land/x/[email protected].5/logger.ts"; | ||
import Logger from "https://deno.land/x/[email protected].6/logger.ts"; | ||
|
||
const logger = new Logger(); | ||
await logger.initFileLogger("../log"); | ||
|
@@ -202,7 +202,7 @@ example: | |
3. fileLogger, consoleLogger => disable => enable => fileLogger, consoleLogger | ||
|
||
```js | ||
import Logger from "https://deno.land/x/[email protected].5/logger.ts"; | ||
import Logger from "https://deno.land/x/[email protected].6/logger.ts"; | ||
|
||
const logger = new Logger(); | ||
await logger.initFileLogger("../log"); | ||
|
@@ -228,7 +228,7 @@ To convert your Deno project to a dual-stack npm project, you should use | |
`scripts/build_npm.ts` that looks like: | ||
|
||
```ts | ||
import { build, emptyDir } from "https://deno.land/x/dnt/mod.ts"; | ||
import { build, emptyDir } from "@deno/dnt"; | ||
|
||
// grap the next version number as you want | ||
const version: Deno.args[0]; | ||
|
@@ -249,9 +249,9 @@ await build({ | |
}, | ||
// map your favorite deno logger to its npm port. | ||
mappings: { | ||
"https://deno.land/x/logger@v1.2.0/logger.ts": { | ||
"https://deno.land/x/logger@v1.1.6/logger.ts": { | ||
name: "@denodnt/logger", | ||
version: "1.2.0", | ||
version: "1.1.6", | ||
peerDependency: false, | ||
}, | ||
}, | ||
|
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 |
---|---|---|
@@ -1,10 +1,7 @@ | ||
// dnt deps can not be moved to dev_deps.ts | ||
import { | ||
build, | ||
emptyDir, | ||
type PackageJson, | ||
} from "https://deno.land/x/[email protected]/mod.ts"; | ||
import * as pc from "https://deno.land/[email protected]/fmt/colors.ts"; | ||
import { build, emptyDir } from "@deno/dnt"; | ||
import type { PackageJson } from "@deno/dnt"; | ||
import * as pc from "jsr:@std/[email protected]/colors"; | ||
|
||
export async function buildDnt() { | ||
let version = Deno.args[0]; | ||
|
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,40 @@ | ||
const readmeContentOriginal = Deno.readTextFileSync("README.md"); | ||
const jsonStr = Deno.readTextFileSync("deno.jsonc"); | ||
const jsonConf = JSON.parse(jsonStr) as { version: string }; | ||
|
||
let readmeContent = readmeContentOriginal.replaceAll( | ||
/https:\/\/deno.land\/x\/logger@v[\d.]+\/logger.ts/g, | ||
`https://deno.land/x/logger@v${jsonConf.version}/logger.ts`, | ||
).replaceAll( | ||
/version: "[\d.]+"/g, | ||
`version: "${jsonConf.version}"`, | ||
); | ||
|
||
// update current version in readme | ||
if (readmeContent !== readmeContentOriginal) { | ||
Deno.writeTextFileSync("README.md", readmeContent); | ||
} | ||
|
||
readmeContent = readmeContent.replaceAll( | ||
/https:\/\/deno.land\/x\/logger@v[\d.]+\/logger.ts/g, | ||
`jsr:@deno-lib/logger@${jsonConf.version}/logger`, | ||
); | ||
|
||
// Write the updated content back to the mod.ts file | ||
Deno.writeTextFileSync( | ||
"mod.ts", | ||
`/** | ||
* ${readmeContent} | ||
* @module | ||
*/ | ||
/** | ||
* The Logger class | ||
*/ | ||
export { default as Logger } from "./logger.ts"; | ||
/** | ||
* The Logger class default instance | ||
*/ | ||
export { default as default } from "./logger.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
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
Oops, something went wrong.