Skip to content

Commit 732a908

Browse files
authored
Merge pull request ekino#31 from tienduy-nguyen/OAC-0004-ts
feat(typescript): convert js to ts
2 parents ce703ae + 840741e commit 732a908

25 files changed

+623
-637
lines changed

.eslintrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parserOptions:
2-
ecmaVersion: 9
2+
ecmaVersion: 11
33
sourceType: script
44
env:
55
node: true

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ jspm_packages
5050
!.yarn/plugins
5151
!.yarn/sdks
5252
!.yarn/versions
53-
.pnp.*
53+
.pnp.*
54+
.vscode

.npmignore

-33
This file was deleted.

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ NODE_MODULES ?= "./node_modules"
55
NODE_MODULES_BIN ?= "${NODE_MODULES}/.bin"
66

77
FROM_VERSION ?= $(shell yarn run -s version)
8+
EXAMPLE_FILES := $(shell find "examples" -name "*.js")
89

910
############## HELP ##############
1011

@@ -55,3 +56,10 @@ release: ##@release generates a new release
5556
@git commit -m "chore(v${RELEASE_VERSION}): bump version to ${RELEASE_VERSION}"
5657
@git tag -a "v${RELEASE_VERSION}" -m "version ${RELEASE_VERSION}"
5758
@git push origin v${RELEASE_VERSION}
59+
60+
examples: ##@examples run examples files
61+
@echo "${YELLOW}start to run all examples files"
62+
@if [ ! -d "lib" ]; then yarn build; fi;\
63+
for file in $(EXAMPLE_FILES); do echo "\n\nRun $${file}"; node $${file}; done;\
64+
65+
.PHONY: examples

examples/example1.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const logger = require('../index')
1+
const logger = require('../lib/index')
22

33
logger.setNamespaces('root:*')
44
logger.setLevel('debug')
55

6-
const log = logger('root:testing')
6+
const log = logger.createLogger('root:testing')
77
log.debug('sample message', {
88
foo: 'bar',
99
})

examples/example2.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const logger = require('../index')
1+
const logger = require('../lib/index')
22

33
logger.setNamespaces('root:*')
44
logger.setLevel('debug')
55

6-
const log = logger('root:testing')
6+
const log = logger.createLogger('root:testing')
77
log.debug('ctxId', 'log with predefined context ID', {
88
foo: 'bar',
99
})

examples/example3.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const logger = require('../index')
1+
const logger = require('../lib/index')
22

33
logger.setNamespaces('namespace:*')
44
logger.setLevel('debug')
55
//logger.setOutput(logger.outputs.json)
66

7-
const log = logger('namespace:subNamespace')
8-
log.debug('ctxId', 'Will be logged',{someData: 'someValue', someData2: 'someValue'})
7+
const log = logger.createLogger('namespace:subNamespace')
8+
log.debug('ctxId', 'Will be logged', { someData: 'someValue', someData2: 'someValue' })

examples/example_context.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const logger = require('../index')
1+
const logger = require('../lib/index')
22

33
logger.setOutput(logger.outputs.pretty)
44
logger.setNamespaces('*')
55
logger.setLevel('info')
66
logger.setGlobalContext({ version: '2.0.0', env: 'dev' })
77

8-
const log = logger('namespace')
8+
const log = logger.createLogger('namespace')
99

1010
log.warn('message', { someData: 'someValue' })

examples/example_data.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const logger = require('../index')
1+
const logger = require('../lib/index')
22

33
logger.setOutput(logger.outputs.pretty)
44
logger.setNamespaces('namespace:*')
55
logger.setLevel('info')
66

7-
const log = logger('namespace:subNamespace')
7+
const log = logger.createLogger('namespace:subNamespace')
88

9-
log.warn('message', { someData: 'someValue' })
9+
log.warn('message', { someData: 'someValue' })

examples/example_pretty.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const logger = require('../index')
1+
const logger = require('../lib/index')
22

33
logger.setNamespaces('namespace:*')
44
logger.setLevel('debug')
55
logger.setOutput(logger.outputs.pretty)
66

7-
const log = logger('namespace:subNamespace')
8-
log.debug('ctxId', 'Will be logged',{someData: 'someValue', someData2: 'someValue'})
7+
const log = logger.createLogger('namespace:subNamespace')
8+
log.debug('ctxId', 'Will be logged', { someData: 'someValue', someData2: 'someValue' })

index.d.ts

-53
This file was deleted.

0 commit comments

Comments
 (0)