@design-edito/cli 0.0.59 → 0.0.62

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.
@@ -1,2 +1,3 @@
1
1
  cli
2
- make-template
2
+ make-template
3
+ tree
@@ -1 +1 @@
1
- 0.0.59
1
+ 0.0.62
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design-edito/cli",
3
- "version": "0.0.59",
3
+ "version": "0.0.62",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
@@ -13,10 +13,11 @@
13
13
  "module": "index.js",
14
14
  "bin": {
15
15
  "cli": "./cli/index.js",
16
- "make-template": "./make-template/index.js"
16
+ "make-template": "./make-template/index.js",
17
+ "tree": "./tree/index.js"
17
18
  },
18
19
  "dependencies": {
19
- "@design-edito/tools": "^0.0.27",
20
+ "@design-edito/tools": "^0.0.29",
20
21
  "commander": "^12.0.0",
21
22
  "prompts": "^2.4.2"
22
23
  },
package/tree/index.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{program as b}from"commander";import w from"@design-edito/tools/utils/node/list-subpaths/index.js";import p from"@design-edito/tools/utils/node/is-in-directory/index.js";var h=process.cwd();b.name("@design-edito/tree").description("List subpaths from the current working directory").argument("[depth]","Depth (optional)").option("-f, --files [bool]","Include files",i,!0).option("-H, --hidden [bool]","Include hidden files",i,!0).option("-d, --directories [bool]","Include directories",i,!0).option("-s, --symlinks [bool]","Include symlinks",i,!0).option("-F, --follow [bool]","Follow symlinks",i,!1).option("-u, --unique [bool]","Ensures followed symlinks contents don't create duplicates",i,!1).option("-e, --exclude [pattern]","List of patterns to exclude from the result").option("-i, --include [pattern]","List of patterns to include to the result").action(async(n,e)=>{let r=n!==void 0?parseInt(n):void 0;if(Number.isNaN(r??0))return console.error("Depth should be a number"),process.exit(1);let s=(await w(h,{maxDepth:r,files:e.files,hidden:e.hidden,directories:e.directories,symlinks:e.symlinks,followSimlinks:e.follow,dedupeSimlinksContents:e.unique,exclude:m(e.exclude),include:m(e.include),returnRelative:!0})).reduce((u,o)=>{let a=y(o),c={value:o,level:a,children:[]};u.filter(t=>t.level===a-1&&p(o,t.value)).forEach(t=>t.children.push(c));let f=u.filter(t=>t.level===a+1&&p(t.value,o));return c.children.push(...f),[...u,c]},[]);console.log(h),g(s)});b.parse(process.argv);function i(n){let e=`${n}`.trim().toLowerCase();if(e==="true")return!0;if(e==="false")return!1}function m(n){if(typeof n!="string")return;let e=/^\/(.+)\/([a-z]*)$/,r=n.match(e);if(r===null)return;let[,l,s]=r;return new RegExp(l,s)}function y(n){return n.split("/").length-1}function g(n,e=0,r=[]){n.filter(l=>l.level===e).forEach((l,s,u)=>{let o=s===u.length-1,a=o?"\u2514\u2500\u2500":"\u251C\u2500\u2500",{value:c,level:d,children:f}=l,t=c.split("/").slice(d).join("/"),v=new Array(d).fill(null).map((D,k)=>r[k]===!0?" ":"\u2502 ").join("");console.log(`${v}${a} ${t}`),g(f,d+1,[...r,o])})}