@design-edito/cli 0.0.62 → 0.0.63

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 +1 @@
1
- 0.0.62
1
+ 0.0.63
package/cli/index.js CHANGED
@@ -2,3 +2,4 @@
2
2
  import m from"node:process";import{promises as l}from"node:fs";import f from"node:url";import r from"node:path";import{spawn as g}from"node:child_process";import{program as t}from"commander";var h=f.fileURLToPath(import.meta.url),a=r.dirname(h);t.name("@design-edito/cli").description("The home of @design-edito/cli's project");t.command("list").description("list all the available commands").action(j);t.command("version").description("print current version of the package").action(v);var w=await c();w.forEach(n=>{t.command(n,{hidden:!0}).allowUnknownOption(!0).action(async(...i)=>{let[o,e,s,...d]=m.argv;if(s===void 0)return t.help();if(!(await c()).includes(s))return t.help();let p=r.join(a,"../",s,"index.js");g(p,d,{stdio:"inherit"}).on("error",u=>console.error(`Failed to start subprogram '${s}':`,u))})});t.parse(m.argv);async function c(){let n=r.join(a,"assets/list.txt");return(await l.readFile(n,{encoding:"utf-8"})).split(`
3
3
  `).map(o=>o.trim())}async function j(){let i=(await c()).map(o=>{let e=Object.assign(new Array(24).fill(" "),o.split("")).join("");return o==="cli"?`${e} # npx @design-edito/cli help`:`${e} # npx @design-edito/cli ${o} help`}).join(`
4
4
  `);console.log(i)}async function v(){let n=r.join(a,"assets/version.txt"),i=await l.readFile(n,{encoding:"utf-8"});console.log(i)}
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cli/index.ts"],
4
+ "sourcesContent": ["import process from 'node:process'\nimport { promises as fs } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\nprogram\n .name('@design-edito/cli')\n .description('The home of @design-edito/cli\\'s project')\n \nprogram\n .command('list')\n .description('list all the available commands')\n .action(printCommands)\n\nprogram\n .command('version')\n .description('print current version of the package')\n .action(printVersion)\n\nconst subCommands = await listCommands()\nsubCommands.forEach(subCommand => {\n program\n .command(subCommand, { hidden: true })\n .allowUnknownOption(true)\n .action(async (...args) => {\n const [_nodePath, _thisPath, targetCommand, ...forwardedArgs] = process.argv\n if (targetCommand === undefined) return program.help()\n const commandsList = await listCommands()\n if (!commandsList.includes(targetCommand)) return program.help()\n const subprogramPath = path.join(__dirname, '../', targetCommand, 'index.js')\n const subprocess = spawn(subprogramPath, forwardedArgs, { stdio: 'inherit' })\n subprocess.on('error', err => console.error(`Failed to start subprogram '${targetCommand}':`, err))\n })\n})\n\nprogram.parse(process.argv)\n\nasync function listCommands () {\n const listFilePath = path.join(__dirname, 'assets/list.txt')\n const list = await fs.readFile(listFilePath, { encoding: 'utf-8' })\n return list.split('\\n').map(e => e.trim())\n}\n\nasync function printCommands () {\n const list = await listCommands()\n const output = list\n .map(c => {\n const twentyFourCharName = Object.assign(\n new Array(24).fill(' ') as string[],\n c.split('') as string[]\n ).join('')\n if (c === 'cli') return `${twentyFourCharName} # npx @design-edito/cli help`\n return `${twentyFourCharName} # npx @design-edito/cli ${c} help`\n })\n .join('\\n')\n console.log(output)\n return;\n}\n\nasync function printVersion () {\n const versionFilePath = path.join(__dirname, 'assets/version.txt')\n const version = await fs.readFile(versionFilePath, { encoding: 'utf-8' })\n console.log(version)\n return;\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,MAAU,UAC/B,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,OAAS,WAAAC,MAAe,YAExB,IAAMC,EAAaJ,EAAI,cAAc,YAAY,GAAG,EAC9CK,EAAYJ,EAAK,QAAQG,CAAU,EAEzCD,EACG,KAAK,mBAAmB,EACxB,YAAY,yCAA0C,EAEzDA,EACG,QAAQ,MAAM,EACd,YAAY,iCAAiC,EAC7C,OAAOG,C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AMgB,EAAkBtB,EAAK,KAAKI,EAAW,oBAAoB,EAC3DmB,EAAU,MAAMzB,EAAG,SAASwB,EAAiB,CAAE,SAAU,OAAQ,CAAC,EACxE,QAAQ,IAAIC,CAAO,CAErB",
6
+ "names": ["process", "fs", "url", "path", "spawn", "program", "__filename", "__dirname", "printCommands", "printVersion", "subCommands", "listCommands", "subCommand", "args", "_nodePath", "_thisPath", "targetCommand", "forwardedArgs", "subprogramPath", "err", "listFilePath", "e", "output", "c", "twentyFourCharName", "versionFilePath", "version"]
7
+ }
@@ -6,15 +6,15 @@
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build:scripts": "npx tsc -p scripts/tsconfig.json",
9
+ "build:public": "cp -r public/* dist",
9
10
  "build:src": "npm run build:scripts && node .scripts/build/index.js",
10
11
  "build:src:preact": "PREACT=true npm run build:src",
12
+ "watch:public": "npx chokidar-cli 'public/**/*' -c 'npm run build:public'",
11
13
  "watch:src": "WATCH=true npm run build:src",
12
14
  "watch:src:preact": "PREACT=true npm run watch:src",
13
15
  "make:dist": "mkdir -p dist",
14
- "make:pages": "mkdir -p pages",
15
16
  "serve:dist": "npm run make:dist && npx http-server dist --port ${PORT} --cors -c-1",
16
- "serve:pages": "npm run make:pages && npx http-server pages --port ${PORT} --cors -c-1",
17
- "start": "npx concurrently -n 'watch:src,serve:dist ,serve:pages' 'npm run watch:src' 'PORT=${PORT_DIST:-3001} npm run serve:dist' 'PORT=${PORT_DIST:-3000} npm run serve:pages'",
17
+ "start": "npx concurrently -n 'watch:src ,watch:public,serve:dist ' 'npm run watch:src' 'npm run watch:public' 'PORT=${PORT_DIST:-3000} npm run serve:dist'",
18
18
  "start:preact": "PREACT=true npm start"
19
19
  },
20
20
  "author": "",
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import n from"node:process";import{promises as a,existsSync as d}from"node:fs";import j from"node:url";import t from"node:path";import{spawn as w}from"node:child_process";import{program as i}from"commander";import y from"prompts";import P from"@design-edito/tools/utils/node/read-write-file/index.js";var k=j.fileURLToPath(import.meta.url),u=t.dirname(k),c=n.cwd();i.name("@design-edito/make-template").description("Generate in cwd a project template");i.command("html").description("make simple html project structure").action(x);i.command("react").description("make react + typescript project structure").action(S);i.parse(n.argv);async function x(){let e=t.join(u,"assets/html");if(!d(e))return console.error(`Could not find the template to copy at ${e}`),n.exit(1);let o=t.join(c,"html-template");await a.cp(e,o,{recursive:!0})}async function S(){let e=t.join(u,"assets/react");if(!d(e))return console.error(`Could not find the template to copy at ${e}`),n.exit(1);let o=t.join(c,"react-template");await a.cp(e,o,{recursive:!0});let{projectName:p}=await y({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),g=t.join(o,"package.json");await P(g,r=>{let s=typeof r=="string"?r:r.toString(),f=JSON.parse(s);delete f.name;let h={name:p,...f};return`${JSON.stringify(h,null,2)}
3
3
  `},{encoding:"utf-8"});let l=w(`cd ${o} && npm i`,{stdio:"inherit",shell:!0});await new Promise((r,s)=>{l.on("exit",()=>r(!0)),l.on("error",()=>s(!1))});let m=t.join(c,p);await a.rename(o,m),await a.rename(t.join(m,"gitignore"),t.join(m,".gitignore"))}
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/make-template/index.ts"],
4
+ "sourcesContent": ["import process from 'node:process'\nimport { promises as fs, existsSync } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\nimport prompts from 'prompts'\nimport readWriteFile from '@design-edito/tools/utils/node/read-write-file/index.js'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\nconst CWD = process.cwd()\n\nprogram\n .name('@design-edito/make-template')\n .description('Generate in cwd a project template')\n \nprogram\n .command('html')\n .description('make simple html project structure')\n .action(makeHtml)\n\nprogram\n .command('react')\n .description('make react + typescript project structure')\n .action(makeReact)\n\nprogram.parse(process.argv)\n\nasync function makeHtml () {\n const htmlTemplatePath = path.join(__dirname, 'assets/html')\n if (!existsSync(htmlTemplatePath)) {\n console.error(`Could not find the template to copy at ${htmlTemplatePath}`)\n return process.exit(1)\n }\n const targetPath = path.join(CWD, 'html-template')\n await fs.cp(htmlTemplatePath, targetPath, { recursive: true })\n}\n\nasync function makeReact () {\n const htmlTemplatePath = path.join(__dirname, 'assets/react')\n if (!existsSync(htmlTemplatePath)) {\n console.error(`Could not find the template to copy at ${htmlTemplatePath}`)\n return process.exit(1)\n }\n const defaultTargetPath = path.join(CWD, 'react-template')\n \n // Copy\n await fs.cp(htmlTemplatePath, defaultTargetPath, { recursive: true })\n const { projectName } = await prompts({\n name: 'projectName',\n message: 'Project name ? (for package.json name field)',\n type: 'text'\n })\n \n // Custom name\n const packageJsonPath = path.join(defaultTargetPath, 'package.json')\n await readWriteFile(packageJsonPath, rawContent => {\n const content = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const contentObj = JSON.parse(content) as Record<string, string>\n delete contentObj.name\n const newContentObj = {\n name: projectName,\n ...contentObj\n }\n return `${JSON.stringify(newContentObj, null, 2)}\\n`\n }, { encoding: 'utf-8' })\n \n // Install deps\n const npmISubprocess = spawn(`cd ${defaultTargetPath} && npm i`, { stdio: 'inherit', shell: true })\n await new Promise((resolve, reject) => {\n npmISubprocess.on('exit', () => resolve(true))\n npmISubprocess.on('error', () => reject(false))\n })\n\n // Rename project\n const targetPath = path.join(CWD, projectName)\n await fs.rename(defaultTargetPath, targetPath)\n\n // Rename gitignore\n await fs.rename(\n path.join(targetPath, 'gitignore'),\n path.join(targetPath, '.gitignore')\n )\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,EAAI,cAAAC,MAAkB,UAC3C,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,OAAS,WAAAC,MAAe,YACxB,OAAOC,MAAa,UACpB,OAAOC,MAAmB,0DAE1B,IAAMC,EA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G,KAAK,UAAUC,EAAe,KAAM,CAAC,CAAC;AAAA,CAClD,EAAG,CAAE,SAAU,OAAQ,CAAC,EAGxB,IAAMC,EAAiBlB,EAAM,MAAMW,CAAiB,YAAa,CAAE,MAAO,UAAW,MAAO,EAAK,CAAC,EAClG,MAAM,IAAI,QAAQ,CAACQ,EAASC,IAAW,CACrCF,EAAe,GAAG,OAAQ,IAAMC,EAAQ,EAAI,CAAC,EAC7CD,EAAe,GAAG,QAAS,IAAME,EAAO,EAAK,CAAC,CAChD,CAAC,EAGD,IAAMV,EAAaX,EAAK,KAAKO,EAAKM,CAAW,EAC7C,MAAMhB,EAAG,OAAOe,EAAmBD,CAAU,EAG7C,MAAMd,EAAG,OACPG,EAAK,KAAKW,EAAY,WAAW,EACjCX,EAAK,KAAKW,EAAY,YAAY,CACpC,CACF",
6
+ "names": ["process", "fs", "existsSync", "url", "path", "spawn", "program", "prompts", "readWriteFile", "__filename", "__dirname", "CWD", "makeHtml", "makeReact", "htmlTemplatePath", "targetPath", "defaultTargetPath", "projectName", "packageJsonPath", "rawContent", "content", "contentObj", "newContentObj", "npmISubprocess", "resolve", "reject"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design-edito/cli",
3
- "version": "0.0.62",
3
+ "version": "0.0.63",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
@@ -22,7 +22,6 @@
22
22
  "prompts": "^2.4.2"
23
23
  },
24
24
  "devDependencies": {
25
- "@commander-js/extra-typings": "^12.0.1",
26
25
  "@types/node": "^20.11.30",
27
26
  "@types/prompts": "^2.4.9",
28
27
  "@types/semver": "^7.5.8",
package/tree/index.js CHANGED
@@ -1,2 +1,3 @@
1
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])})}
2
+ import{program as b}from"commander";import w from"@design-edito/tools/utils/node/list-subpaths/index.js";import f 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, defaults to 0)").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]","Regexp patterns to exclude from the result").option("-i, --include [pattern]","Regexp patterns to include in the result").action(async(n,e)=>{let r=n!==void 0?parseInt(n):0;if(Number.isNaN(r))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,l)=>{let a=y(l),c={value:l,level:a,children:[]};u.filter(t=>t.level===a-1&&f(l,t.value)).forEach(t=>t.children.push(c));let p=u.filter(t=>t.level===a+1&&f(t.value,l));return c.children.push(...p),[...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[,o,s]=r;return new RegExp(o,s)}function y(n){return n.split("/").length-1}function g(n,e=0,r=[]){n.filter(o=>o.level===e).forEach((o,s,u)=>{let l=s===u.length-1,a=l?"\u2514\u2500\u2500":"\u251C\u2500\u2500",{value:c,level:d,children:p}=o,t=c.split("/").slice(d).join("/"),v=new Array(d).fill(null).map((x,k)=>r[k]===!0?" ":"\u2502 ").join("");console.log(`${v}${a} ${t}`),g(p,d+1,[...r,l])})}
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tree/index.ts"],
4
+ "sourcesContent": ["import { program } from 'commander'\nimport listSubpaths from '@design-edito/tools/utils/node/list-subpaths/index.js'\nimport isInDirectory from '@design-edito/tools/utils/node/is-in-directory/index.js'\n\nconst CWD = process.cwd()\n\ntype SubpathData = {\n value: string\n level: number\n children: SubpathData[]\n}\n\nprogram\n .name('@design-edito/tree')\n .description('List subpaths from the current working directory')\n .argument('[depth]', 'Depth (optional, defaults to 0)')\n .option('-f, --files [bool]', 'Include files', parseBoolean, true)\n .option('-H, --hidden [bool]', 'Include hidden files', parseBoolean, true)\n .option('-d, --directories [bool]', 'Include directories', parseBoolean, true)\n .option('-s, --symlinks [bool]', 'Include symlinks', parseBoolean, true)\n .option('-F, --follow [bool]', 'Follow symlinks', parseBoolean, false)\n .option('-u, --unique [bool]', 'Ensures followed symlinks contents don\\'t create duplicates', parseBoolean, false)\n .option('-e, --exclude [pattern]', 'Regexp patterns to exclude from the result')\n .option('-i, --include [pattern]', 'Regexp patterns to include in the result')\n .action(async (_depth, options) => {\n const depth = _depth !== undefined ? parseInt(_depth) : 0\n if (Number.isNaN(depth)) {\n console.error('Depth should be a number')\n return process.exit(1)\n }\n const subpaths = await listSubpaths(CWD, {\n maxDepth: depth,\n files: options.files,\n hidden: options.hidden,\n directories: options.directories,\n symlinks: options.symlinks,\n followSimlinks: options.follow,\n dedupeSimlinksContents: options.unique,\n exclude: makeRegexp(options.exclude),\n include: makeRegexp(options.include),\n returnRelative: true\n })\n const subpathsData = subpaths.reduce<SubpathData[]>((reduced, subpath) => {\n const level = getLevel(subpath)\n const thisSubpathData = {\n value: subpath,\n level,\n children: [] as SubpathData[]\n }\n // Parents\n const parents = reduced.filter(subpathData => subpathData.level === level - 1 && isInDirectory(subpath, subpathData.value))\n parents.forEach(parent => parent.children.push(thisSubpathData))\n // Children\n const children = reduced.filter(subpathData => subpathData.level === level + 1 && isInDirectory(subpathData.value, subpath))\n thisSubpathData.children.push(...children)\n return [...reduced, thisSubpathData]\n }, [])\n console.log(CWD)\n printSubpathData(subpathsData)\n })\n\nprogram.parse(process.argv)\n\nfunction parseBoolean (val: unknown) {\n const strVal = `${val}`.trim().toLowerCase()\n if (strVal === 'true') return true\n if (strVal === 'false') return false\n return undefined\n}\n\nfunction makeRegexp (strRegexp: unknown) {\n if (typeof strRegexp !== 'string') return undefined\n const validRegexpRegexp = /^\\/(.+)\\/([a-z]*)$/\n const inputMatches = strRegexp.match(validRegexpRegexp)\n if (inputMatches === null) return undefined\n const [, pattern, flags] = inputMatches\n return new RegExp(pattern!, flags!)\n}\n\nfunction getLevel (path: string) {\n const chunks = path.split('/')\n return chunks.length - 1\n}\n\nfunction printSubpathData (\n subpathsData: SubpathData[],\n level: number = 0,\n parentsAreLastMap: boolean[] = []) {\n subpathsData\n .filter(subpathData => subpathData.level === level)\n .forEach((subpathsData, pos, filtered) => {\n const isLast = pos === filtered.length - 1\n const indentChar = isLast ? '\u2514\u2500\u2500' : '\u251C\u2500\u2500'\n const { value, level, children } = subpathsData\n const toPrint = value.split('/').slice(level).join('/')\n const indentChars = new Array(level).fill(null).map((e, pos) => {\n if (parentsAreLastMap[pos] === true) return ' '\n else return '\u2502 '\n }).join('')\n console.log(`${indentChars}${indentChar} ${toPrint}`)\n printSubpathData(children, level + 1, [...parentsAreLastMap, isLast])\n })\n}\n"],
5
+ "mappings": "AAAA,OAAS,WAAAA,MAAe,YACxB,OAAOC,MAAkB,wDACzB,OAAOC,MAAmB,0DAE1B,IAAMC,EAAM,QAAQ,IAAI,EAQxBH,EACG,KAAK,oBAAoB,EACzB,YAAY,kDAAkD,EAC9D,SAAS,UAAW,iCAAiC,EACrD,OAAO,qBAAsB,gBAAiBI,EAAc,EAAI,EAChE,OAAO,sBAAuB,uBAAwBA,EAAc,EAAI,EACxE,OAAO,2BAA4B,sBAAuBA,EAAc,EAAI,EAC5E,OAAO,wBAAyB,mBAAoBA,EAAc,EAAI,EACtE,OAAO,sBAAuB,kBAAmBA,EAAc,EAAK,EACpE,OAAO,sBAAuB,6DAA+DA,EAAc,EAAK,EAChH,OAAO,0BAA2B,4CAA4C,EAC9E,OAAO,0BAA2B,0CAA0C,EAC5E,OAAO,MAAOC,EAAQC,I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MC,CAAiB,EACtD,GAAIC,IAAiB,KAAM,OAC3B,GAAM,CAAC,CAAEC,EAASC,CAAK,EAAIF,EAC3B,OAAO,IAAI,OAAOC,EAAUC,CAAM,CACpC,CAEA,SAASZ,EAAUa,EAAc,CAE/B,OADeA,EAAK,MAAM,GAAG,EACf,OAAS,CACzB,CAEA,SAASR,EACPV,EACAI,EAAgB,EAChBe,EAA+B,CAAC,EAAG,CACnCnB,EACG,OAAOO,GAAeA,EAAY,QAAUH,CAAK,EACjD,QAAQ,CAACJ,EAAcoB,EAAKC,IAAa,CACxC,IAAMC,EAASF,IAAQC,EAAS,OAAS,EACnCE,EAAaD,EAAS,qBAAQ,qBAC9B,CAAE,MAAAE,EAAO,MAAApB,EAAO,SAAAK,CAAS,EAAIT,EAC7ByB,EAAUD,EAAM,MAAM,GAAG,EAAE,MAAMpB,CAAK,EAAE,KAAK,GAAG,EAChDsB,EAAc,IAAI,MAAMtB,CAAK,EAAE,KAAK,IAAI,EAAE,IAAI,CAACuB,EAAGP,IAClDD,EAAkBC,CAAG,IAAM,GAAa,OAChC,WACb,EAAE,KAAK,EAAE,EACV,QAAQ,IAAI,GAAGM,CAAW,GAAGH,CAAU,IAAIE,CAAO,EAAE,EACpDf,EAAiBD,EAAUL,EAAQ,EAAG,CAAC,GAAGe,EAAmBG,CAAM,CAAC,CACtE,CAAC,CACL",
6
+ "names": ["program", "listSubpaths", "isInDirectory", "CWD", "parseBoolean", "_depth", "options", "depth", "subpathsData", "makeRegexp", "reduced", "subpath", "level", "getLevel", "thisSubpathData", "subpathData", "parent", "children", "printSubpathData", "val", "strVal", "strRegexp", "validRegexpRegexp", "inputMatches", "pattern", "flags", "path", "parentsAreLastMap", "pos", "filtered", "isLast", "indentChar", "value", "toPrint", "indentChars", "e"]
7
+ }