@dx-pkg/logger 1.1.1 → 2.0.3
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/dist/examples/index.js +1 -0
- package/dist/src/index.d.ts +33 -0
- package/dist/src/index.js +8 -0
- package/package.json +21 -46
- package/.prettier +0 -21
- package/CHANGELOG.md +0 -49
- package/examples/index.ts +0 -1
- package/project.json +0 -85
- package/scripts/clean-dts-comments.js +0 -17
- package/src/console-logger.ts +0 -68
- package/src/index.ts +0 -2
- package/src/types.ts +0 -18
- package/tsconfig.build.json +0 -10
- package/tsconfig.dev.json +0 -9
- package/tsconfig.json +0 -25
- package/tsdown.config.build.ts +0 -35
- package/tsdown.config.dev.ts +0 -36
- package/tsup.config.build.ts +0 -27
- package/tsup.config.dev.ts +0 -29
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log(`Hello World!`);export{};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
export interface Logger {
|
|
3
|
+
info(message: string, ...args: unknown[]): void;
|
|
4
|
+
warn(message: string, ...args: unknown[]): void;
|
|
5
|
+
error(message: string, ...args: unknown[]): void;
|
|
6
|
+
debug(message: string, ...args: unknown[]): void;
|
|
7
|
+
success(message: string, ...args: unknown[]): void;
|
|
8
|
+
box(message: string, ...args: unknown[]): void;
|
|
9
|
+
heading(message: string): void;
|
|
10
|
+
}
|
|
11
|
+
export interface CliLogger extends Logger {
|
|
12
|
+
header(message: string): void;
|
|
13
|
+
gray(message: string): void;
|
|
14
|
+
yellow(message: string): void;
|
|
15
|
+
logEmptyLine(): void;
|
|
16
|
+
logSeparator(): void;
|
|
17
|
+
logSummary(successCount: number, failCount: number, totalCount: number): void;
|
|
18
|
+
}
|
|
19
|
+
export declare class ConsoleLogger implements CliLogger {
|
|
20
|
+
info(message: string, ...args: unknown[]): void;
|
|
21
|
+
warn(message: string, ...args: unknown[]): void;
|
|
22
|
+
error(message: string, ...args: unknown[]): void;
|
|
23
|
+
debug(message: string, ...args: unknown[]): void;
|
|
24
|
+
success(message: string, ...args: unknown[]): void;
|
|
25
|
+
box(message: string, ...args: unknown[]): void;
|
|
26
|
+
heading(message: string): void;
|
|
27
|
+
header(message: string): void;
|
|
28
|
+
gray(message: string): void;
|
|
29
|
+
yellow(message: string): void;
|
|
30
|
+
logEmptyLine(): void;
|
|
31
|
+
logSeparator(): void;
|
|
32
|
+
logSummary(successCount: number, failCount: number, totalCount: number): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import e from"node:process";import t from"node:os";import n from"node:tty";function r(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function i(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
2
|
+
`:`
|
|
3
|
+
`)+n,i=r+1,r=e.indexOf(`
|
|
4
|
+
`,i)}while(r!==-1);return a+=e.slice(i),a}const a=(e=0)=>t=>`\u{1B}[${t+e}m`,o=(e=0)=>t=>`\u{1B}[${38+e};5;${t}m`,s=(e=0)=>(t,n,r)=>`\u{1B}[${38+e};2;${t};${n};${r}m`,c=e=>`\u{1B}[58;5;${e<90?e-30:e-90+8}m`,l={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:[`4:2`,24],underlineCurly:[`4:3`,24],underlineDotted:[`4:4`,24],underlineDashed:[`4:5`,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:[`58;5;0`,59],underlineRed:[`58;5;1`,59],underlineGreen:[`58;5;2`,59],underlineYellow:[`58;5;3`,59],underlineBlue:[`58;5;4`,59],underlineMagenta:[`58;5;5`,59],underlineCyan:[`58;5;6`,59],underlineWhite:[`58;5;7`,59],underlineBlackBright:[`58;5;8`,59],underlineGray:[`58;5;8`,59],underlineGrey:[`58;5;8`,59],underlineRedBright:[`58;5;9`,59],underlineGreenBright:[`58;5;10`,59],underlineYellowBright:[`58;5;11`,59],underlineBlueBright:[`58;5;12`,59],underlineMagentaBright:[`58;5;13`,59],underlineCyanBright:[`58;5;14`,59],underlineWhiteBright:[`58;5;15`,59]}};Object.keys(l.modifier);const u=Object.keys(l.color),d=Object.keys(l.bgColor);Object.keys(l.underlineColor),[...u,...d];function f(){let e=/* @__PURE__ */ new Map;for(let[t,n]of Object.entries(l)){for(let[t,r]of Object.entries(n))l[t]={open:`\u{1B}[${r[0]}m`,close:`\u{1B}[${r[1]}m`},n[t]=l[t],e.set(Number.parseInt(r[0],10),r[1]);Object.defineProperty(l,t,{value:n,enumerable:!1})}return Object.defineProperty(l,"codes",{value:e,enumerable:!1}),l.color.close=`\x1B[39m`,l.bgColor.close=`\x1B[49m`,l.underlineColor.close=`\x1B[59m`,l.color.ansi=a(),l.color.ansi256=o(),l.color.ansi16m=s(),l.bgColor.ansi=a(10),l.bgColor.ansi256=o(10),l.bgColor.ansi16m=s(10),l.underlineColor.ansi=c,l.underlineColor.ansi256=o(20),l.underlineColor.ansi16m=s(20),Object.defineProperties(l,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[\da-f]{6}|[\da-f]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>l.rgbToAnsi256(...l.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>l.ansi256ToAnsi(l.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>l.ansi256ToAnsi(l.hexToAnsi256(e)),enumerable:!1}}),l}const p=f();function m(t,n=globalThis.Deno?globalThis.Deno.args:e.argv){let r=t.startsWith(`-`)?``:t.length===1?`-`:`--`,i=n.indexOf(r+t),a=n.indexOf(`--`);return i!==-1&&(a===-1||i<a)}const{env:h}=e;let g;m(`no-color`)||m(`no-colors`)||m(`color=false`)||m(`color=never`)?g=0:(m(`color`)||m(`colors`)||m(`color=true`)||m(`color=always`))&&(g=1);function _(){return/^\d+$/.test(h.FORCE_COLOR)}function v(){if(`FORCE_COLOR`in h){if(h.FORCE_COLOR===`false`)return 0;if(h.FORCE_COLOR===`true`||h.FORCE_COLOR.length===0)return 1;if(_())return Math.min(Number.parseInt(h.FORCE_COLOR,10),3)}}function y(e){return e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function b(n,{streamIsTTY:r,sniffFlags:i=!0}={}){let a=v();a!==void 0&&(g=a);let o=i?g:a;if(o===0)return 0;if(i){if(m(`color=16m`)||m(`color=full`)||m(`color=truecolor`))return 3;if(m(`color=256`))return 2}if(o!==void 0&&_())return o;if(`TF_BUILD`in h&&`AGENT_NAME`in h)return 1;if(n&&!r&&o===void 0)return 0;let s=o||0;if(h.TERM===`dumb`)return s;if(e.platform===`win32`){let e=t.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in h)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in h)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in h)||h.CI_NAME===`codeship`?1:s;if(`TEAMCITY_VERSION`in h)return+!!/^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(h.TEAMCITY_VERSION);if(h.COLORTERM===`truecolor`||h.TERM===`xterm-kitty`||h.TERM===`xterm-ghostty`||h.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in h){let e=Number.parseInt((h.TERM_PROGRAM_VERSION||``).split(`.`,1)[0],10);switch(h.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(?:color)?$/i.test(h.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(h.TERM)||`COLORTERM`in h?1:s}function x(e,t={}){return y(b(e,{streamIsTTY:e&&e.isTTY,...t}))}const{stdout:S,stderr:C}={stdout:x({isTTY:n.isatty(1)}),stderr:x({isTTY:n.isatty(2)})},w=Symbol(`GENERATOR`),T=Symbol(`STYLER`),E=Symbol(`IS_EMPTY`),D=Symbol(`LEVEL`),O=Object.create(null),k=e=>{if(!Number.isSafeInteger(e)||e<0||e>3)throw Error("The `level` should be an integer from 0 to 3")},A={enumerable:!0,get(){return this[D]},set(e){k(e),this[D]=e}},j=(e,t={})=>{t.level!==void 0&&k(t.level);let n=S?S.level:0;e[D]=t.level===void 0?n:t.level},M=e=>{let t=(...e)=>e.join(` `);return j(t,e),Object.setPrototypeOf(t,N.prototype),t};function N(e){return M(e)}Object.setPrototypeOf(N.prototype,Function.prototype);for(let[e,t]of Object.entries(p))O[e]={get(){let n=L(this,I(t.open,t.close,this[T]),this[E]);return Object.defineProperty(this,e,{value:n}),n}};O.visible={get(){let e=L(this,this[T],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const P=(e,t)=>{let n=p[t];if(e===`rgb`){let e=(e,t,r)=>n.ansi(p.rgbToAnsi(e,t,r));return[e,e,(e,t,r)=>n.ansi256(p.rgbToAnsi256(e,t,r)),n.ansi16m]}if(e===`hex`){let e=e=>n.ansi(p.hexToAnsi(e));return[e,e,e=>n.ansi256(p.hexToAnsi256(e)),e=>n.ansi16m(...p.hexToRgb(e))]}let r=e=>n.ansi(p.ansi256ToAnsi(e));return[r,r,n.ansi256,n.ansi256]};for(let e of[`rgb`,`hex`,`ansi256`]){let t=e[0].toUpperCase()+e.slice(1);for(let[n,r]of[[e,`color`],[`bg`+t,`bgColor`],[`underline`+t,`underlineColor`]]){let{close:t}=p[r],i=P(e,r);O[n]={get(){let e=function(e,n,r){let a=i[this.level](e,n,r);return L(this,I(a,t,this[T]),this[E])};return Object.defineProperty(this,n,{value:e}),e}}}}const F=Object.defineProperties(()=>{},{...O,level:{enumerable:!0,get(){return this[w].level},set(e){this[w].level=e}}}),I=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},L=(e,t,n)=>{let r=(...e)=>e.length===1?R(r,``+e[0]):e.length===2?R(r,e[0]+` `+e[1]):R(r,e.join(` `));return Object.setPrototypeOf(r,F),r[w]=e[w]??e,r[T]=t,r[E]=n,r},R=(e,t)=>{if(e[w][D]<=0||!t)return e[E]?``:t;let n=e[T];if(n===void 0)return t;let{openAll:a,closeAll:o}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=r(t,n.close,n.open),n=n.parent;let s=t.indexOf(`
|
|
5
|
+
`);return s!==-1&&(t=i(t,o,a,s)),a+t+o};Object.defineProperties(N.prototype,{...O,level:A});const z=N();N({level:C?C.level:0});var B=class{info(e,...t){console.log(z.blue(e),...t)}warn(e,...t){console.warn(z.yellow(e),...t)}error(e,...t){console.error(z.red(e),...t)}debug(e,...t){console.debug(z.gray(e),...t)}success(e,...t){console.log(z.green(e),...t)}box(e,...t){let n=(t.length>0?`${e} ${t.join(` `)}`:e).split(`
|
|
6
|
+
`),r=Math.max(...n.map(e=>e.length)),i=`─`.repeat(r+2),a=`╭${i}╮`,o=`╰${i}╯`,s=n.map(e=>`│ ${e.padEnd(r)} │`).join(`
|
|
7
|
+
`);console.log(z.cyan([a,s,o].join(`
|
|
8
|
+
`)))}heading(e){this.header(e)}header(e){this.logSeparator(),console.log(z.bold.magenta(`● ${e}`)),this.logSeparator()}gray(e){console.log(z.gray(e))}yellow(e){console.log(z.yellow(e))}logEmptyLine(){console.log(``)}logSeparator(){console.log(z.blue(`═`.repeat(50)))}logSummary(e,t,n){this.logSeparator(),console.log(z.blue(`\n📊 Summary: ${e} succeeded, ${t} failed out of ${n} total\n`))}};export{B as ConsoleLogger};
|
package/package.json
CHANGED
|
@@ -1,67 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dx-pkg/logger",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"private": false,
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
7
|
"author": "Dong Tran",
|
|
8
|
-
"type": "
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"!dist/tsconfig.tsbuildinfo"
|
|
12
|
+
],
|
|
13
|
+
"main": "./dist/src/index.js",
|
|
14
|
+
"types": "./dist/src/index.d.ts",
|
|
12
15
|
"exports": {
|
|
13
16
|
".": {
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"default": "./src/index.js"
|
|
17
|
-
},
|
|
18
|
-
"import": {
|
|
19
|
-
"types": "./src/index.d.mts",
|
|
20
|
-
"default": "./src/index.mjs"
|
|
21
|
-
}
|
|
17
|
+
"types": "./dist/src/index.d.ts",
|
|
18
|
+
"default": "./dist/src/index.js"
|
|
22
19
|
},
|
|
23
20
|
"./examples": {
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"default": "./examples/index.js"
|
|
27
|
-
},
|
|
28
|
-
"import": {
|
|
29
|
-
"types": "./examples/index.d.mts",
|
|
30
|
-
"default": "./examples/index.mjs"
|
|
31
|
-
}
|
|
21
|
+
"types": "./dist/examples/index.d.ts",
|
|
22
|
+
"default": "./dist/examples/index.js"
|
|
32
23
|
}
|
|
33
24
|
},
|
|
34
25
|
"scripts": {
|
|
35
26
|
"build": "npm run build:tsdown",
|
|
36
27
|
"dev": "npm run dev:tsdown",
|
|
37
|
-
"build:tsdown": "tsdown --config tsdown.config.build.
|
|
38
|
-
"dev:tsdown": "tsdown --config tsdown.config.dev.
|
|
39
|
-
"build:tsup": "tsup --config tsup.config.build.ts",
|
|
40
|
-
"dev:tsup": "tsup --config tsup.config.dev.ts",
|
|
41
|
-
"build:tsc": "tsc -p tsconfig.json",
|
|
42
|
-
"dev:tsc": "tsc -p tsconfig.json --watch",
|
|
28
|
+
"build:tsdown": "tsdown --config tsdown.config.build.mts --config-loader native && node scripts/clean-dts-comments.js",
|
|
29
|
+
"dev:tsdown": "tsdown --config tsdown.config.dev.mts --config-loader native && node scripts/clean-dts-comments.js",
|
|
43
30
|
"example:build": "npm run build && npm run example",
|
|
44
|
-
"example
|
|
45
|
-
"example": "node ../../dist/packages/logger/examples/index.js",
|
|
31
|
+
"example": "node ./dist/examples/index.js",
|
|
46
32
|
"test": "jest",
|
|
47
|
-
"
|
|
48
|
-
"lint:fix": "eslint . --fix",
|
|
49
|
-
"format": "prettier --check '**/*.{ts,json,md}' --ignore-unknown",
|
|
50
|
-
"format:fix": "prettier --write '**/*.{ts,json,md}' --ignore-unknown",
|
|
51
|
-
"prettier": "prettier",
|
|
52
|
-
"bin": "node ../../dist/packages/logger/src/commands/index.js",
|
|
53
|
-
"build:artifact": "npm run copy:artifact && npm run link:artifact",
|
|
54
|
-
"copy:artifact": "dx-tools sync -s . -d ../../dist/packages/logger --filter 'package.json, .npmignore, .npmrc, *.md' --cwd . --verbose",
|
|
55
|
-
"link:artifact": "mksymlink -s ./node_modules -t ../../dist/packages/logger/node_modules -f"
|
|
33
|
+
"bin": "node ./dist/src/commands/index.js"
|
|
56
34
|
},
|
|
57
35
|
"devDependencies": {
|
|
58
36
|
"@types/jest": "^30.0.0",
|
|
59
|
-
"@types/node": "^
|
|
60
|
-
"
|
|
61
|
-
"prettier": "^3.8.1",
|
|
37
|
+
"@types/node": "^26.6.2",
|
|
38
|
+
"chalk": "^6.0.0",
|
|
62
39
|
"ts-jest": "^29.4.5",
|
|
63
|
-
"
|
|
64
|
-
"tsdown": "^0.21.2",
|
|
65
|
-
"tsup": "^8.5.1"
|
|
40
|
+
"tsdown": "^0.23.0"
|
|
66
41
|
}
|
|
67
|
-
}
|
|
42
|
+
}
|
package/.prettier
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"semi": false,
|
|
3
|
-
"trailingComma": "es5",
|
|
4
|
-
"singleQuote": true,
|
|
5
|
-
"printWidth": 180,
|
|
6
|
-
"tabWidth": 4,
|
|
7
|
-
"useTabs": false,
|
|
8
|
-
"arrowParens": "always",
|
|
9
|
-
"endOfLine": "lf",
|
|
10
|
-
"overrides": [
|
|
11
|
-
{
|
|
12
|
-
"files": [
|
|
13
|
-
"*.yml",
|
|
14
|
-
"*.yaml"
|
|
15
|
-
],
|
|
16
|
-
"options": {
|
|
17
|
-
"tabWidth": 2
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# @dx-pkg/logger
|
|
2
|
-
|
|
3
|
-
## 1.1.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- e6bb5f3: separate interfaces and update dependencies
|
|
8
|
-
|
|
9
|
-
## 1.0.9
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- 94bfb61: setup tsdown and tsup builder and config
|
|
14
|
-
|
|
15
|
-
## 1.0.8
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- 1778d73: Change API for logging a specific color
|
|
20
|
-
|
|
21
|
-
## 1.0.7
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- 4a47297: Init changeset
|
|
26
|
-
|
|
27
|
-
## 1.0.6
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- 31ad92f: add README.md
|
|
32
|
-
|
|
33
|
-
## 1.0.5
|
|
34
|
-
|
|
35
|
-
### Patch Changes
|
|
36
|
-
|
|
37
|
-
- 31ad92f: add README.md
|
|
38
|
-
|
|
39
|
-
## 1.0.4
|
|
40
|
-
|
|
41
|
-
### Patch Changes
|
|
42
|
-
|
|
43
|
-
- 31ad92f: add README.md
|
|
44
|
-
|
|
45
|
-
## 1.1.0
|
|
46
|
-
|
|
47
|
-
### Minor Changes
|
|
48
|
-
|
|
49
|
-
- 27396e9: test changeset
|
package/examples/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('Hello World!')
|
package/project.json
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dx-pkg/logger",
|
|
3
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"sourceRoot": "packages/logger/src",
|
|
5
|
-
"projectType": "application",
|
|
6
|
-
"tags": [],
|
|
7
|
-
"targets": {
|
|
8
|
-
"build": {
|
|
9
|
-
"executor": "nx:run-commands",
|
|
10
|
-
"options": {
|
|
11
|
-
"commands": [
|
|
12
|
-
"cd {projectRoot} && npm run build",
|
|
13
|
-
"cd {projectRoot} && npm run copy:artifact"
|
|
14
|
-
],
|
|
15
|
-
"cwd": "{workspaceRoot}",
|
|
16
|
-
"parallel": false
|
|
17
|
-
},
|
|
18
|
-
"outputs": ["{workspaceRoot}/dist/{projectRoot}"],
|
|
19
|
-
"dependsOn": ["^build"]
|
|
20
|
-
},
|
|
21
|
-
"build:artifact": {
|
|
22
|
-
"executor": "nx:run-commands",
|
|
23
|
-
"options": {
|
|
24
|
-
"command": "cd {projectRoot} && npm run build:artifact",
|
|
25
|
-
"cwd": "{workspaceRoot}"
|
|
26
|
-
},
|
|
27
|
-
"cache": false,
|
|
28
|
-
"dependsOn": ["build"]
|
|
29
|
-
},
|
|
30
|
-
"dev": {
|
|
31
|
-
"executor": "nx:run-commands",
|
|
32
|
-
"options": {
|
|
33
|
-
"commands": [
|
|
34
|
-
"cd {projectRoot} && npm run copy:artifact",
|
|
35
|
-
"cd {projectRoot} && npm run dev"
|
|
36
|
-
],
|
|
37
|
-
"cwd": "{workspaceRoot}",
|
|
38
|
-
"parallel": true
|
|
39
|
-
},
|
|
40
|
-
"outputs": ["{workspaceRoot}/dist/{projectRoot}"],
|
|
41
|
-
"dependsOn": ["^build"]
|
|
42
|
-
},
|
|
43
|
-
"start": {
|
|
44
|
-
"executor": "nx:run-commands",
|
|
45
|
-
"dependsOn": ["build"],
|
|
46
|
-
"options": {
|
|
47
|
-
"command": "node --env-file=.env dist/{projectRoot}/src/command.js",
|
|
48
|
-
"cwd": "{workspaceRoot}"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"test": {
|
|
52
|
-
"executor": "@nx/jest:jest",
|
|
53
|
-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
54
|
-
"options": {
|
|
55
|
-
"jestConfig": "{projectRoot}/jest.config.js",
|
|
56
|
-
"passWithNoTests": true
|
|
57
|
-
},
|
|
58
|
-
"configurations": {
|
|
59
|
-
"ci": {
|
|
60
|
-
"ci": true,
|
|
61
|
-
"coverage": true
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
"lint": {
|
|
66
|
-
"executor": "@nx/eslint:lint",
|
|
67
|
-
"outputs": ["{options.outputFile}"],
|
|
68
|
-
"options": {
|
|
69
|
-
"lintFilePatterns": ["{projectRoot}/**/*.ts"]
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
"format": {
|
|
73
|
-
"executor": "nx:run-commands",
|
|
74
|
-
"options": {
|
|
75
|
-
"command": "prettier --write '{projectRoot}/**/*.{ts,json,md}' --ignore-unknown"
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
"format:check": {
|
|
79
|
-
"executor": "nx:run-commands",
|
|
80
|
-
"options": {
|
|
81
|
-
"command": "prettier --check '{projectRoot}/**/*.{ts,json,md}' --ignore-unknown"
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const dir = path.resolve(__dirname, '../../../dist/packages/logger/src'); // hoặc nơi xuất .d.ts
|
|
5
|
-
|
|
6
|
-
fs.readdirSync(dir)
|
|
7
|
-
.filter(file => file.endsWith('.d.ts') || file.endsWith('.d.mts'))
|
|
8
|
-
.forEach(file => {
|
|
9
|
-
console.log('✔ Clean comments', file)
|
|
10
|
-
const fp = path.join(dir, file);
|
|
11
|
-
let content = fs.readFileSync(fp, 'utf-8');
|
|
12
|
-
// Xóa //#region và //#endregion
|
|
13
|
-
content = content.replace(/^\/\/#(?:region|endregion).*$/gm, '');
|
|
14
|
-
// Xóa dòng trống thừa nếu muốn
|
|
15
|
-
content = content.replace(/\n\s*\n/g, '\n');
|
|
16
|
-
fs.writeFileSync(fp, content);
|
|
17
|
-
});
|
package/src/console-logger.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { CliLogger } from "./types";
|
|
3
|
-
|
|
4
|
-
export class ConsoleLogger implements CliLogger {
|
|
5
|
-
info(message: string, ...args: unknown[]): void {
|
|
6
|
-
console.log(chalk.blue(message), ...args);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
warn(message: string, ...args: unknown[]): void {
|
|
10
|
-
console.warn(chalk.yellow(message), ...args);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
error(message: string, ...args: unknown[]): void {
|
|
14
|
-
console.error(chalk.red(message), ...args);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
debug(message: string, ...args: unknown[]): void {
|
|
18
|
-
console.debug(chalk.gray(message), ...args);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
success(message: string, ...args: unknown[]): void {
|
|
22
|
-
console.log(chalk.green(message), ...args);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
box(message: string, ...args: unknown[]): void {
|
|
26
|
-
const text = args.length > 0 ? `${message} ${args.join(' ')}` : message;
|
|
27
|
-
const lines = text.split('\n');
|
|
28
|
-
const maxLen = Math.max(...lines.map(l => l.length));
|
|
29
|
-
const horizontal = '─'.repeat(maxLen + 2);
|
|
30
|
-
const top = `╭${horizontal}╮`;
|
|
31
|
-
const bottom = `╰${horizontal}╯`;
|
|
32
|
-
const body = lines.map(l => `│ ${l.padEnd(maxLen)} │`).join('\n');
|
|
33
|
-
console.log(chalk.cyan([top, body, bottom].join('\n')));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
heading(message: string): void {
|
|
37
|
-
this.header(message)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
header(message: string): void {
|
|
41
|
-
this.logSeparator();
|
|
42
|
-
console.log(chalk.bold.magenta(`● ${message}`));
|
|
43
|
-
this.logSeparator();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
gray(message: string): void {
|
|
47
|
-
console.log(chalk.gray(message));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
yellow(message: string): void {
|
|
51
|
-
console.log(chalk.yellow(message));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
logEmptyLine(): void {
|
|
55
|
-
console.log('');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
logSeparator(): void {
|
|
59
|
-
console.log(chalk.blue('═'.repeat(50)));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
logSummary(successCount: number, failCount: number, totalCount: number): void {
|
|
63
|
-
this.logSeparator();
|
|
64
|
-
console.log(
|
|
65
|
-
chalk.blue(`\n📊 Summary: ${successCount} succeeded, ${failCount} failed out of ${totalCount} total\n`)
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
package/src/index.ts
DELETED
package/src/types.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface Logger {
|
|
2
|
-
info(message: string, ...args: unknown[]): void;
|
|
3
|
-
warn(message: string, ...args: unknown[]): void;
|
|
4
|
-
error(message: string, ...args: unknown[]): void;
|
|
5
|
-
debug(message: string, ...args: unknown[]): void;
|
|
6
|
-
success(message: string, ...args: unknown[]): void;
|
|
7
|
-
box(message: string, ...args: unknown[]): void;
|
|
8
|
-
heading(message: string): void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface CliLogger extends Logger {
|
|
12
|
-
header(message: string): void;
|
|
13
|
-
gray(message: string): void;
|
|
14
|
-
yellow(message: string): void;
|
|
15
|
-
logEmptyLine(): void;
|
|
16
|
-
logSeparator(): void;
|
|
17
|
-
logSummary(successCount: number, failCount: number, totalCount: number): void;
|
|
18
|
-
}
|
package/tsconfig.build.json
DELETED
package/tsconfig.dev.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"strict": true,
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"skipLibCheck": true,
|
|
6
|
-
"forceConsistentCasingInFileNames": true,
|
|
7
|
-
"sourceMap": true,
|
|
8
|
-
"outDir": "../../dist/packages/logger",
|
|
9
|
-
"rootDir": ".",
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"declarationMap": true,
|
|
12
|
-
"composite": true,
|
|
13
|
-
"tsBuildInfoFile": "../../dist/packages/logger/tsconfig.tsbuildinfo",
|
|
14
|
-
"types": ["node", "jest"],
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"module": "node16",
|
|
17
|
-
"moduleResolution": "node16",
|
|
18
|
-
"target": "es2020",
|
|
19
|
-
"allowJs": true,
|
|
20
|
-
"noImplicitAny": false
|
|
21
|
-
},
|
|
22
|
-
"include": ["./src/**/*", "./examples/**/*", "./src/__mocks__/**/*"],
|
|
23
|
-
"exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.test.ts", "**/__mocks__/**"],
|
|
24
|
-
"references": []
|
|
25
|
-
}
|
package/tsdown.config.build.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsdown';
|
|
2
|
-
import type { OutExtensionContext } from 'tsdown';
|
|
3
|
-
|
|
4
|
-
const outExtensions = ({ format }: OutExtensionContext) => ({
|
|
5
|
-
js: format === 'cjs' ? '.js' : '.mjs',
|
|
6
|
-
dts: format === 'cjs' ? '.d.ts' : '.d.mts',
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export default defineConfig([
|
|
10
|
-
{
|
|
11
|
-
entry: { index: 'src/index.ts' },
|
|
12
|
-
format: ['cjs', 'esm'],
|
|
13
|
-
dts: true,
|
|
14
|
-
clean: true,
|
|
15
|
-
minify: true,
|
|
16
|
-
sourcemap: false,
|
|
17
|
-
outDir: '../../dist/packages/logger/src',
|
|
18
|
-
tsconfig: 'tsconfig.build.json',
|
|
19
|
-
outExtensions,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
entry: { index: 'examples/index.ts' },
|
|
23
|
-
format: ['cjs', 'esm'],
|
|
24
|
-
dts: false,
|
|
25
|
-
clean: true,
|
|
26
|
-
minify: true,
|
|
27
|
-
sourcemap: false,
|
|
28
|
-
outDir: '../../dist/packages/logger/examples',
|
|
29
|
-
tsconfig: 'tsconfig.build.json',
|
|
30
|
-
outExtensions,
|
|
31
|
-
loader: {
|
|
32
|
-
'.scss': 'copy',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
]);
|
package/tsdown.config.dev.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { defineConfig, type OutExtensionContext } from 'tsdown';
|
|
2
|
-
|
|
3
|
-
const outExtensions = ({ format }: OutExtensionContext) => ({
|
|
4
|
-
js: format === 'cjs' ? '.js' : '.mjs',
|
|
5
|
-
dts: format === 'cjs' ? '.d.ts' : '.d.mts',
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export default defineConfig([
|
|
9
|
-
{
|
|
10
|
-
entry: { index: 'src/index.ts' },
|
|
11
|
-
format: ['cjs', 'esm'],
|
|
12
|
-
dts: true,
|
|
13
|
-
clean: false,
|
|
14
|
-
watch: true,
|
|
15
|
-
minify: false,
|
|
16
|
-
sourcemap: true,
|
|
17
|
-
outDir: '../../dist/packages/logger/src',
|
|
18
|
-
tsconfig: 'tsconfig.dev.json',
|
|
19
|
-
outExtensions,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
entry: { index: 'examples/index.ts' },
|
|
23
|
-
format: ['cjs', 'esm'],
|
|
24
|
-
dts: false,
|
|
25
|
-
clean: false,
|
|
26
|
-
watch: true,
|
|
27
|
-
sourcemap: true,
|
|
28
|
-
minify: false,
|
|
29
|
-
outDir: '../../dist/packages/logger/examples',
|
|
30
|
-
tsconfig: 'tsconfig.dev.json',
|
|
31
|
-
outExtensions,
|
|
32
|
-
loader: {
|
|
33
|
-
'.scss': 'copy',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
]);
|
package/tsup.config.build.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup';
|
|
2
|
-
|
|
3
|
-
export default defineConfig([
|
|
4
|
-
{
|
|
5
|
-
entry: { index: 'src/index.ts' },
|
|
6
|
-
format: ['cjs', 'esm'],
|
|
7
|
-
dts: true,
|
|
8
|
-
clean: true,
|
|
9
|
-
minify: true,
|
|
10
|
-
sourcemap: false,
|
|
11
|
-
outDir: '../../dist/packages/logger/src',
|
|
12
|
-
tsconfig: 'tsconfig.build.json',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
entry: { index: 'examples/index.ts' },
|
|
16
|
-
format: ['cjs', 'esm'],
|
|
17
|
-
dts: false,
|
|
18
|
-
clean: false,
|
|
19
|
-
minify: true,
|
|
20
|
-
sourcemap: false,
|
|
21
|
-
outDir: '../../dist/packages/logger/examples',
|
|
22
|
-
tsconfig: 'tsconfig.build.json',
|
|
23
|
-
loader: {
|
|
24
|
-
'.scss': 'copy',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
]);
|
package/tsup.config.dev.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup';
|
|
2
|
-
|
|
3
|
-
export default defineConfig([
|
|
4
|
-
{
|
|
5
|
-
entry: { index: 'src/index.ts' },
|
|
6
|
-
format: ['cjs', 'esm'],
|
|
7
|
-
dts: true,
|
|
8
|
-
clean: false,
|
|
9
|
-
watch: true,
|
|
10
|
-
minify: false,
|
|
11
|
-
sourcemap: true,
|
|
12
|
-
outDir: '../../dist/packages/logger/src',
|
|
13
|
-
tsconfig: 'tsconfig.dev.json',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
entry: { index: 'examples/index.ts' },
|
|
17
|
-
format: ['cjs', 'esm'],
|
|
18
|
-
dts: false,
|
|
19
|
-
clean: false,
|
|
20
|
-
watch: true,
|
|
21
|
-
minify: false,
|
|
22
|
-
sourcemap: true,
|
|
23
|
-
outDir: '../../dist/packages/logger/examples',
|
|
24
|
-
tsconfig: 'tsconfig.dev.json',
|
|
25
|
-
loader: {
|
|
26
|
-
'.scss': 'copy',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
]);
|