From 7f7a3f98150ad33aa2af312ce7e48f0f2067a39e Mon Sep 17 00:00:00 2001 From: "S. Amir Najafi" Date: Wed, 31 Aug 2022 11:10:48 +0430 Subject: [PATCH 1/7] docs: log level in logger --- packages/core/logger/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/logger/README.md b/packages/core/logger/README.md index 9cfd6d5fc..d72799847 100644 --- a/packages/core/logger/README.md +++ b/packages/core/logger/README.md @@ -16,7 +16,7 @@ function sayHello(name: string) { ### Debug Mode -Many of the methods in the logger are no-ops when the debug mode is off. +Many of the methods in the logger are no-ops when the debug mode is off in browser. Please remember to **reload** the window after changing the debug mode. - Debugging all scopes @@ -37,6 +37,8 @@ Please remember to **reload** the window after changing the debug mode. window.localStorage?.setItem('ALWATR_DEBUG', '*alwatr*'); ``` +> Make sure the [log level](https://developer.chrome.com/docs/devtools/console/log/#browser) in set correctly. + ## API ### `createLogger(scope: string, color: string, force = boolean)` From d559958d45ee8e142ed67c72f652bebe0dd15a05 Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Mon, 19 Sep 2022 14:02:35 +0430 Subject: [PATCH 2/7] Update packages/core/logger/README.md Co-authored-by: Younes Adltalab --- packages/core/logger/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/logger/README.md b/packages/core/logger/README.md index d72799847..5d12f7a94 100644 --- a/packages/core/logger/README.md +++ b/packages/core/logger/README.md @@ -16,7 +16,7 @@ function sayHello(name: string) { ### Debug Mode -Many of the methods in the logger are no-ops when the debug mode is off in browser. +Many of the methods in the logger are no-ops when the debug mode is off in the browser. Please remember to **reload** the window after changing the debug mode. - Debugging all scopes From 881ea7f8e88dc0d526b6fa813d727de8a0d36e87 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Mon, 19 Sep 2022 17:21:02 +0430 Subject: [PATCH 3/7] style: eslint operator-linebreak --- .eslintrc.json | 1 + packages/core/logger/src/logger.ts | 32 ++++++++++---------- packages/core/nano-server/src/nano-server.ts | 8 ++--- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5b8328752..ae5d73e2b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -37,6 +37,7 @@ "space-infix-ops": "error", "new-cap": ["error", {"capIsNewExceptionPattern": "Mixin$"}], "brace-style": ["error", "stroustrup", {"allowSingleLine": true}], + "operator-linebreak": ["error", "after", {"overrides": {"?": "before", ":": "before"}}], "@typescript-eslint/explicit-function-return-type": "error", "import/order": [ "error", diff --git a/packages/core/logger/src/logger.ts b/packages/core/logger/src/logger.ts index 6f32b0da9..2e68160b2 100644 --- a/packages/core/logger/src/logger.ts +++ b/packages/core/logger/src/logger.ts @@ -18,8 +18,8 @@ alwatrRegisteredList.push({ * Color list storage for logger. */ let colorIndex = 0; -const colorList = isBrowser ? - [ +const colorList = isBrowser + ? [ '#35b997', '#f05561', '#ee224a', @@ -35,8 +35,8 @@ const colorList = isBrowser ? '#1da2dc', '#f05123', '#ee2524', - ] : - ['0;36', '0;35', '0;34', '0;33', '0;32']; // red and white omitted + ] + : ['0;36', '0;35', '0;34', '0;33', '0;32']; // red and white omitted const getNextColor = (): string => { const color = colorList[colorIndex]; @@ -47,9 +47,9 @@ const getNextColor = (): string => { return color; }; -const debugString = isBrowser ? - globalThis.localStorage?.getItem('ALWATR_DEBUG')?.trim() : - globalThis.process?.env?.ALWATR_DEBUG?.trim(); +const debugString = isBrowser + ? globalThis.localStorage?.getItem('ALWATR_DEBUG')?.trim() + : globalThis.process?.env?.ALWATR_DEBUG?.trim(); const getDebugState = (scope: string): boolean => { if (debugString == null && isBrowser === false && globalThis.process.env.NODE_ENV !== 'production') { @@ -128,13 +128,13 @@ export const createLogger = ( color, scope, - accident: isBrowser ? - console.warn.bind(console, '%c%s%c.%s "%s" => Accident: "%s" (%s)!', styleScope, scope, style.reset) : - console.warn.bind(console, `${styleScope}⚠️ %s\x1b[33m.%s "%s" =>${style.reset}`, scope), + accident: isBrowser + ? console.warn.bind(console, '%c%s%c.%s "%s" => Accident: "%s" (%s)!', styleScope, scope, style.reset) + : console.warn.bind(console, `${styleScope}⚠️ %s\x1b[33m.%s "%s" =>${style.reset}`, scope), - error: isBrowser ? - console.error.bind(console, '%c%s%c.%s "%s" =>', styleScope, scope, style.reset) : - console.error.bind(console, `${styleScope}❌ %s\x1b[31m.%s "%s" =>\x1b[0;2m`, scope), + error: isBrowser + ? console.error.bind(console, '%c%s%c.%s "%s" =>', styleScope, scope, style.reset) + : console.error.bind(console, `${styleScope}❌ %s\x1b[31m.%s "%s" =>\x1b[0;2m`, scope), }; if (!debug) { @@ -161,9 +161,9 @@ export const createLogger = ( logMethodFull: console.debug.bind(console, keySection + '.%s(%o); // %o', styleScope, scope, style.reset), - incident: isBrowser ? - console.trace.bind(console, '%c%s%c.%s() => Incident: "%s" (%s)!', styleScope, scope, style.reset) : - console.log.bind(console, `${styleScope}🔸 %s${style.reset}.%s() => Incident: "%s" (%s)!\x1b[0;2m`, scope), + incident: isBrowser + ? console.trace.bind(console, '%c%s%c.%s() => Incident: "%s" (%s)!', styleScope, scope, style.reset) + : console.log.bind(console, `${styleScope}🔸 %s${style.reset}.%s() => Incident: "%s" (%s)!\x1b[0;2m`, scope), logOther: console.debug.bind(console, keySection, styleScope, scope, style.reset), }; diff --git a/packages/core/nano-server/src/nano-server.ts b/packages/core/nano-server/src/nano-server.ts index c5930e4fb..51755660c 100644 --- a/packages/core/nano-server/src/nano-server.ts +++ b/packages/core/nano-server/src/nano-server.ts @@ -282,13 +282,13 @@ export class AlwatrConnection { catch { this._logger.accident('responseData', 'data_stringify_failed', 'JSON.stringify(data) failed!'); return this.reply( - content.ok === false ? - { + content.ok === false + ? { ok: false, statusCode: content.statusCode, errorCode: content.errorCode, - } : - { + } + : { ok: false, statusCode: 500, errorCode: 'data_stringify_failed', From d257193ee8b6692c52a0eee988d7bd4c2244ecfe Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Fri, 23 Sep 2022 12:11:03 +0330 Subject: [PATCH 4/7] lint: use eslintignore --- .eslintignore | 4 ++++ packages/core/signal/src/signal.ts | 2 ++ packages/core/storage/src/storage.ts | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..9ac25a8f4 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +# Build +*.js +*.map +*.d.ts diff --git a/packages/core/signal/src/signal.ts b/packages/core/signal/src/signal.ts index 06e1b8bb4..a40ee35c4 100644 --- a/packages/core/signal/src/signal.ts +++ b/packages/core/signal/src/signal.ts @@ -133,6 +133,7 @@ export class SignalInterface { ): ListenerInterface { this._logger.logMethodArgs('setProvider', {options}); const listener = _setSignalProvider(this._signal, this._requestSignal, signalProvider, options); + // eslint-disable-next-line @typescript-eslint/no-use-before-define return new ListenerInterface(this._requestSignal, listener); } @@ -235,6 +236,7 @@ export class SignalInterface { ): ListenerInterface { this._logger.logMethodArgs('addListener', {options}); const listener = _addSignalListener(this._signal, listenerCallback, options); + // eslint-disable-next-line @typescript-eslint/no-use-before-define return new ListenerInterface(this._signal, listener); } } diff --git a/packages/core/storage/src/storage.ts b/packages/core/storage/src/storage.ts index a0766fec5..f317c7de0 100644 --- a/packages/core/storage/src/storage.ts +++ b/packages/core/storage/src/storage.ts @@ -5,7 +5,7 @@ import exitHook from 'exit-hook'; import {readJsonFile, writeJsonFile} from './util.js'; -import type {DocumentObject, DocumentListStorage, AlwatrStorageConfig} from './type'; +import type {DocumentObject, DocumentListStorage, AlwatrStorageConfig} from './type.js'; export {DocumentObject, DocumentListStorage, AlwatrStorageConfig as Config}; From 6e596cef83af943301cd108e066f7d08e61c2c7f Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Fri, 23 Sep 2022 12:21:43 +0330 Subject: [PATCH 5/7] fix(issue_template): add all packages --- .github/ISSUE_TEMPLATE/2-feature-request.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/2-feature-request.yaml b/.github/ISSUE_TEMPLATE/2-feature-request.yaml index 6892cb794..8f4ee60cc 100644 --- a/.github/ISSUE_TEMPLATE/2-feature-request.yaml +++ b/.github/ISSUE_TEMPLATE/2-feature-request.yaml @@ -1,5 +1,5 @@ name: 'Feature Request' -description: Suggest a feature for Angular Framework +description: Suggest a feature for Alwatr packages body: - type: dropdown @@ -12,6 +12,12 @@ body: - logger - router - signal + - token + - nano-server + - element + - i18n + - math + - font - Don't known / other multiple: true validations: From d7ac8fb47bfabea7048741ff1ecc669f94dfd6d1 Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Fri, 23 Sep 2022 12:21:53 +0330 Subject: [PATCH 6/7] feat: add config.yml --- .github/ISSUE_TEMPLATE/config.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..b86618e07 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Telegram group of Alwatr developers + url: 'https://t.me/AlwatrWG' + about: Communication with developers From 30e06a0636eea901de7b472315c22db377b78444 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Fri, 23 Sep 2022 20:36:34 +0330 Subject: [PATCH 7/7] chore(signal): remove eslint-disable-next-line --- packages/core/signal/src/signal.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/core/signal/src/signal.ts b/packages/core/signal/src/signal.ts index a40ee35c4..06e1b8bb4 100644 --- a/packages/core/signal/src/signal.ts +++ b/packages/core/signal/src/signal.ts @@ -133,7 +133,6 @@ export class SignalInterface { ): ListenerInterface { this._logger.logMethodArgs('setProvider', {options}); const listener = _setSignalProvider(this._signal, this._requestSignal, signalProvider, options); - // eslint-disable-next-line @typescript-eslint/no-use-before-define return new ListenerInterface(this._requestSignal, listener); } @@ -236,7 +235,6 @@ export class SignalInterface { ): ListenerInterface { this._logger.logMethodArgs('addListener', {options}); const listener = _addSignalListener(this._signal, listenerCallback, options); - // eslint-disable-next-line @typescript-eslint/no-use-before-define return new ListenerInterface(this._signal, listener); } }