@khatastroffik/treefolder 1.2.0 → 1.2.1
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/README.md +1 -0
- package/dist/index.js +41 -1
- package/package.json +25 -5
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ This is the recommanded and easiest approach.
|
|
|
38
38
|
1. [Auto "root folder"](#auto-root-folder)
|
|
39
39
|
1. [Auto "ignore paths"](#auto-ignore-paths)
|
|
40
40
|
1. [Sort leaves "folders first"](#sort-leaves-folders-first)
|
|
41
|
+
1. [List output](#list-output)
|
|
41
42
|
1. [Styled output](#styled-output)
|
|
42
43
|
1. [Version information](#version-information)
|
|
43
44
|
1. [Verbose output](#verbose-output)
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,42 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var E=Object.create;var $=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var _=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of O(t))!K.call(e,r)&&r!==n&&$(e,r,{get:()=>t[r],enumerable:!(l=M(t,r))||l.enumerable});return e};var u=(e,t,n)=>(n=e!=null?E(S(e)):{},_(t||!e||!e.__esModule?$(n,"default",{value:e,enumerable:!0}):n,e));var h=u(require("node:path"));var s=class{static folderCount=1;static fileCount=0;static ignoredCount=0;static commandLineArgs={}};var b=require("node:process"),f=require("node:util");var p="1.2.0";function a(e){return(0,f.styleText)(typeof e=="number"?"yellow":"blueBright",`${e}`)}async function R(){let e=await fetch("https://registry.npmjs.org/@khatastroffik/treefolder");return await new Promise(l=>setTimeout(l,100)),(await e.json())["dist-tags"].latest}async function P(){if(o.version){let e=`
|
|
3
|
+
\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510
|
|
4
|
+
| |
|
|
5
|
+
\u256D\u2501\u2533\u2501\u256D\u2501\u256D\u2501\u256E\u256E
|
|
6
|
+
\u2503\u2508\u2508\u2508\u2523\u2584\u254B\u2584\u252B
|
|
7
|
+
\u2503\u2508\u2503\u2508\u2570\u2501\u2570\u2501\u2501\u2501\u2501\u2501\u2501\u256E "K11K"
|
|
8
|
+
\u2570\u2533\u256F\u2508\u2508\u2508\u2508\u2508\u2508\u2508\u2508 \u25E2\u2588\u25E3 a very pragmatic dog
|
|
9
|
+
\u2503\u2508\u2508\u2508\u2508\u2508\u2508\u2508\u2508\u2508\u2508\u2588\u2588\u2588\u2588
|
|
10
|
+
\u2503\u2508\u2508\u2508\u2508\u2508\u2508\u2508\u2508\u2508\u2508\u25E5\u2588\u25E4
|
|
11
|
+
\u2503\u2508\u2508\u2508\u2508\u256D\u2501\u2533\u2501\u2501\u2501\u2501\u256F
|
|
12
|
+
\u2523\u2501\u2501\u2501\u2501\u2501\u2501\u252B
|
|
13
|
+
| |
|
|
14
|
+
\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 made by khatastroffik \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
|
|
15
|
+
`,t,n=await R();return n&&n!==p&&(t=(0,f.styleText)("yellow",`
|
|
16
|
+
\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510
|
|
17
|
+
| A new version of Treefolder is available: |
|
|
18
|
+
| current: ${p} -> latest: ${n} |
|
|
19
|
+
| |
|
|
20
|
+
| Install the latest version with: |
|
|
21
|
+
| "npm update -g @khatastroffik/treefolder@latest" |
|
|
22
|
+
\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
|
|
23
|
+
`)),console.info(a(`
|
|
24
|
+
Treefolder aka "tfold"
|
|
25
|
+
Version ${p}
|
|
26
|
+
|
|
27
|
+
https://npmjs.com/@khatastroffik/treefolder
|
|
28
|
+
${t??e}`)),(0,b.exit)(0)}}async function j(){o.verbose&&(console.info(a(`
|
|
29
|
+
Command line arguments:`)),console.info(s.commandLineArgs),console.info(a(`
|
|
30
|
+
Treefolder configuration:`)),console.info(o,`
|
|
31
|
+
`),console.info(a(`Scanned ${a(s.folderCount)} folders and ${a(s.fileCount)} files.`)),console.info(a(`Filtered out ${a(s.ignoredCount)} items (folders or files).`)))}var W={style:{type:"string",default:"none",short:"s"},verbose:{type:"boolean",default:!1},unsorted:{type:"boolean",default:!1,short:"u"},version:{type:"boolean",default:!1,short:"v"},list:{type:"boolean",default:!1,short:"l"}};function C(){try{return(0,f.parseArgs)({options:W,allowPositionals:!0,strict:!0})}catch(e){let t=e;return console.error(`[${(0,f.styleText)("red",t.name)}]: ${t.message}`),(0,b.exit)(1)}}var i=" ",x=(r=>(r.none="none",r.wireframe="wireframe",r.black="black",r.colored="colored",r))(x||{}),I={none:{closed:"",open:"",file:""},wireframe:{closed:"\u{1F5C0} ",open:"\u{1F5C1} ",file:"\u{1F5CB}"},black:{closed:"\u{1F5BF} ",open:"\u{1F5BF} ",file:"\u{1F5CE}"},colored:{closed:"\u{1F4C1} ",open:"\u{1F4C2} ",file:"\u{1F4C4}"}},o={style:"none",symbols:I.none,root:".",ignores:["node_modules","dist","build",".git",".husky\\_","logs",".angular","coverage"],verbose:!1,unsorted:!1,formatAsList:!1,version:!1};async function T(){let{values:e,positionals:t}=C();o.version=e.version,o.formatAsList=e.list,o.style=x[e.style]??o.style,o.symbols=I[o.style],o.root=h.default.resolve(t.length>0?t[0]:o.root),o.ignores=o.ignores.map(n=>h.default.join(o.root,n)),o.unsorted=!!e.unsorted,o.verbose=!!e.verbose,s.commandLineArgs={...e,root:t[0]??"n/a"}}var L=u(require("node:fs")),c=u(require("node:path")),g=u(require("node:util"));var q=g.default.promisify(L.default.readdir),k,w;function G(e){return`${e.indent+e.folderPrefix+e.foldersymbol+c.default.basename(e.folderName)}
|
|
32
|
+
`}function J(e){return`${e.indent+e.contentItemPrefix+e.entityPrefix+e.contentItem.name}
|
|
33
|
+
`}function Q(e){let t=e.folderName+c.default.sep;return o.style==="colored"&&(t=(0,g.styleText)("blueBright",t)),`${t}
|
|
34
|
+
`}function U(e){return`${c.default.join(e.contentItem.parentPath,e.contentItem.name)}
|
|
35
|
+
`}function X(e,t){return e.isDirectory()?t.isFile()?-1:e.name.localeCompare(t.name):t.isDirectory()?1:e.name.localeCompare(t.name)}function Y(e,t){let n=o.ignores.includes(c.default.join(e,t));return n&&s.ignoredCount++,n}async function Z(e){let t=(await q(e,{withFileTypes:!0})).filter(n=>!Y(e,n.name));return o.unsorted?t:t.sort(X)}async function A(e,t,n,l){let r=await Z(e),V=r.length<1?o.symbols.closed:o.symbols.open,N=n?"":(l?"\u2514\u2500":"\u251C\u2500")+(o.symbols.open?"":i),y=k({indent:t,folderPrefix:N,foldersymbol:V,folderName:e}),v=n?"":l?`${i}${i}${i}`:`\u2502${i}${i}`,F=r.length-1;for(let m=0;m<r.length;m++){let d=r[m];if(d.isDirectory()&&(y+=await A(c.default.join(e,d.name),t+v,!1,m===F)),d.isFile()){s.fileCount++;let B=m===F?`\u2514\u2500${o.symbols.file}${i}`:`\u251C\u2500${o.symbols.file}${i}`;y+=w({indent:t,contentItemPrefix:v,entityPrefix:B,contentItem:d})}}return s.folderCount++,y}async function D(){k=G,w=J,o.formatAsList&&(k=Q,w=U);let e=await A(o.root,"",!0,!0);console.info(e)}async function H(){await T(),await P(),await D(),await j()}H();
|
|
36
|
+
/*!
|
|
37
|
+
* @khatastroffik/treefolder
|
|
38
|
+
*
|
|
39
|
+
* License: MIT
|
|
40
|
+
* Copyright (c) 2026, Loïs Bégué
|
|
41
|
+
*
|
|
42
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khatastroffik/treefolder",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"devEngines": {
|
|
5
5
|
"packageManager": [
|
|
6
6
|
{
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@eslint/markdown": "^7.5.1",
|
|
56
56
|
"@types/jest": "^30.0.0",
|
|
57
57
|
"@types/node": "^25.0.3",
|
|
58
|
+
"esbuild": "^0.27.2",
|
|
58
59
|
"eslint": "^9.39.2",
|
|
59
60
|
"eslint-plugin-format": "^1.1.0",
|
|
60
61
|
"eslint-plugin-jest": "^29.12.1",
|
|
@@ -63,7 +64,6 @@
|
|
|
63
64
|
"jest": "^30.2.0",
|
|
64
65
|
"lint-staged": "^16.2.7",
|
|
65
66
|
"rimraf": "^6.1.2",
|
|
66
|
-
"terser": "^5.46.0",
|
|
67
67
|
"ts-jest": "^29.4.6",
|
|
68
68
|
"tsx": "^4.21.0",
|
|
69
69
|
"typescript": "^5.9.3",
|
|
@@ -72,15 +72,35 @@
|
|
|
72
72
|
"lint-staged": {
|
|
73
73
|
"*.ts": "pnpm lintix"
|
|
74
74
|
},
|
|
75
|
+
"commit-and-tag-version": {
|
|
76
|
+
"types": [
|
|
77
|
+
{
|
|
78
|
+
"type": "refactor",
|
|
79
|
+
"section": "Refactors",
|
|
80
|
+
"hidden": false
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"type": "docs",
|
|
84
|
+
"section": "Documentation",
|
|
85
|
+
"hidden": false
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"type": "build",
|
|
89
|
+
"section": "Build System / Dependencies",
|
|
90
|
+
"hidden": false
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
},
|
|
75
94
|
"scripts": {
|
|
76
95
|
"test": "jest --passWithNoTests",
|
|
77
96
|
"lint": "eslint .",
|
|
78
97
|
"lintix": "eslint . --fix",
|
|
79
98
|
"clean": "rimraf ./dist",
|
|
80
|
-
"dev": "tsx watch src/index.ts",
|
|
99
|
+
"dev": "tsx watch --include \"src/**/*\" src/index.ts",
|
|
81
100
|
"typecheck": "tsc --noEmit",
|
|
82
|
-
"build": "pnpm clean &&
|
|
83
|
-
"
|
|
101
|
+
"build": "pnpm clean && esbuild --bundle --minify --platform=node --outdir=dist ./src/index.ts",
|
|
102
|
+
"buildwatch": "pnpm build --watch --watch-delay=500",
|
|
103
|
+
"build2prod": "pnpm build --tree-shaking=true --analyze",
|
|
84
104
|
"start": "node .",
|
|
85
105
|
"pushtags": "git push --follow-tags origin main",
|
|
86
106
|
"try-commit": "git hook run pre-commit",
|