Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ctix

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ctix - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

2

dist/ctix.js
#!/usr/bin/env node
/*! For license information please see ctix.js.LICENSE.txt */
(()=>{"use strict";var e={181:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Counter=void 0,t.Counter=class{constructor(e){this.count=0,this.verbose=e}get log(){return this.count+=1,this.count}get debug(){return this.count+=this.verbose?1:0,this.count}}},900:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=void 0;class r{constructor(){this._log=console.log,this._debug=()=>{},this._error=console.error}log(...e){this._log(...e)}debug(...e){this._debug(...e)}error(...e){this._error(...e)}switch(e){e?(this._log=console.log,this._debug=console.debug,this._error=console.error):(this._log=console.log,this._debug=()=>{},this._error=console.error)}}t.Logger=r;const o=new r;t.default=o},930:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clean=t.getCleanFilenames=void 0;const o=r(655),n=r(138),i=o.__importDefault(r(974)),a=o.__importStar(r(431)),l=o.__importStar(r(686)),s=o.__importStar(r(972)),c=o.__importStar(r(147)),p=r(352),u=o.__importStar(r(17)),f=r(734),d=(0,i.default)("ctix:clean-tool");t.getCleanFilenames=({cliOption:e,includeBackupFrom:t})=>async()=>{var r,o;try{const i=(0,n.defaultOption)(),c=null!==(r=null==e?void 0:e.resolvedProjectFilePath)&&void 0!==r?r:i.project,m=null!==(o=null==e?void 0:e.resolvedProjectDirPath)&&void 0!==o?o:i.project,g=null==t||t;if((0,p.isFalse)(await(0,f.exists)(c)))return a.left(new Error(`invalid tsconfig.json path: ${c}`));const h=await l.pipe((0,n.getCTIXOptions)({projectPath:c}),s.chain((t=>(0,n.getMergedConfig)({projectPath:c,cliOption:null!=e?e:i,optionObjects:t}))))();if(a.isLeft(h))return a.left(h.left);const y=(0,f.settify)(h.right.filter((e=>e.dir.indexOf("node_modules")<0)).map((e=>u.join(e.dir,"**",e.option.exportFilename)))),v=(0,f.settify)(h.right.map((e=>u.join(e.dir,"**",`${e.option.exportFilename}.bak`)))),w=await(0,f.fastGlobWrap)(g?y.concat(v).map((e=>(0,f.replaceSepToPosix)(e))):y.map((e=>(0,f.replaceSepToPosix)(e))),{dot:!0,cwd:m,ignore:[(0,f.replaceSepToPosix)(u.join(c,"**","node_modules","**"))]}),x=w.filter((e=>e.startsWith(m)));return d("resolved: ",c,y,w,x),a.right(x)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised from getCleanFilenames");return d("Error raised: ",t.message),d("Error raised: ",t.stack),a.left(t)}},t.clean=async function({filenames:e}){try{const t=(await Promise.all(e.map((e=>async function(e){try{return await c.promises.unlink(e),a.right(!0)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised from unlink");return d("Error raised: ",t.message),d("Error raised: ",t.stack),a.left(t)}}(e))))).map((e=>a.isLeft(e)?e.left.message:"")).filter((e=>""!==e));return t.length>0?a.left(new Error(`invalid filename and path: ${t.join("\n")}`)):a.right(!0)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised from clean");return d("Error raised: ",t.message),d("Error raised: ",t.stack),a.left(t)}}},138:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getConfigFiles=t.getMergedConfig=t.getCTIXOptions=t.getNonEmptyOption=t.readOptionFile=t.defaultOption=t.getExportFilename=void 0;const o=r(655),n=r(734),i=o.__importDefault(r(974)),a=o.__importDefault(r(330)),l=o.__importStar(r(431)),s=o.__importStar(r(686)),c=o.__importStar(r(147)),p=o.__importDefault(r(959)),u=r(352),f=o.__importDefault(r(17)),d=o.__importDefault(r(900)),m=r(734),g=(0,i.default)("ctix:config-test-case");function h(e){var t,r,o,n,i;const a=null!==(t=null==e?void 0:e.project)&&void 0!==t?t:f.default.join(process.cwd(),"tsconfig.json"),l=null!==(r=null==e?void 0:e.exportFilename)&&void 0!==r?r:"index.ts",s=null!==(o=null==e?void 0:e.excludePath)&&void 0!==o&&o;return{addNewline:!0,useSemicolon:!0,useTimestamp:!1,useComment:!0,exportFilename:l,quote:"'",verbose:!1,useBackupFile:!0,outputDir:a,useRootDir:null!==(n=null==e?void 0:e.useRootDir)&&void 0!==n&&n,excludePath:s,useUpperFirst:null===(i=null==e?void 0:e.useUpperFirst)||void 0===i||i,project:a}}async function y(e,t){var r;try{const t=await c.promises.readFile(e),r=p.default.parse(t.toString());return["project","addNewline","useSemicolon","useTimestamp","useComment","quote","verbose","useBackupFile","exportFilename","useRootDir"].reduce(((e,t)=>{const o=e;return(0,u.isNotEmpty)(r[t])&&(o[t]=r[t]),o}),{})}catch(o){const n=o instanceof Error?o:new Error("unknown error raised");return d.default.error(`Error caused from ${e}`),d.default.error(null!==(r=n.message)&&void 0!==r?r:""),g("---------------------------------------------------------------------------"),g("Error caused from readOptionFile"),g(n.message),g(n.stack),g("---------------------------------------------------------------------------"),h({project:t})}}function v(e,t){var r,o,n,i,a,l,s,c,p,u,f,d,m;const g="string"==typeof t?h({project:t}):t;return{project:null!==(r=null==e?void 0:e.project)&&void 0!==r?r:g.project,addNewline:null!==(o=null==e?void 0:e.addNewline)&&void 0!==o?o:g.addNewline,useSemicolon:null!==(n=null==e?void 0:e.useSemicolon)&&void 0!==n?n:g.useSemicolon,useTimestamp:null!==(i=null==e?void 0:e.useTimestamp)&&void 0!==i?i:g.useTimestamp,useComment:null!==(a=null==e?void 0:e.useComment)&&void 0!==a?a:g.useComment,quote:null!==(l=null==e?void 0:e.quote)&&void 0!==l?l:g.quote,verbose:null!==(s=null==e?void 0:e.verbose)&&void 0!==s?s:g.verbose,useBackupFile:null!==(c=null==e?void 0:e.useBackupFile)&&void 0!==c?c:g.useBackupFile,exportFilename:null!==(p=null==e?void 0:e.exportFilename)&&void 0!==p?p:g.exportFilename,outputDir:null!==(u=null==e?void 0:e.outputDir)&&void 0!==u?u:g.outputDir,useRootDir:null!==(f=null==e?void 0:e.useRootDir)&&void 0!==f?f:g.useRootDir,excludePath:null!==(d=null==e?void 0:e.excludePath)&&void 0!==d?d:g.excludePath,useUpperFirst:null!==(m=null==e?void 0:e.useUpperFirst)&&void 0!==m?m:g.useUpperFirst}}t.getExportFilename=e=>s.pipe(e,(e=>(0,u.isEmpty)(e)?"index.ts":e),(e=>""===e?"index.ts":e)),t.defaultOption=h,t.readOptionFile=y,t.getNonEmptyOption=v,t.getCTIXOptions=e=>async()=>{try{const t=f.default.resolve(e.projectPath),r=f.default.dirname(t),o=await(0,n.fastGlobWrap)(`${r}/**/*`,{onlyDirectories:!0,ignore:[(0,n.replaceSepToPosix)(f.default.join(r,"**","node_modules","**"))]}),i=await Promise.all([r,...o].map((e=>(async()=>{const o=f.default.join(e,".ctirc"),i=await(0,n.exists)(o),a=(0,m.fpGetDirDepth)(r,e);g("Working configuration file: ",a,o,i);try{return{dir:f.default.resolve(e),exists:i,depth:a,option:i?await y(o,t):void 0}}catch(t){const n=t instanceof Error?t:new Error("unknown error raised");return g(o,i),g(n.message),{dir:e,depth:(0,m.fpGetDirDepth)(r,e),exists:i,option:void 0}}})())));return l.right([...i].sort(((e,t)=>{const r=e.depth-t.depth;return 0===r?e.dir.localeCompare(t.dir):r})))}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return l.left(t)}},t.getMergedConfig=({projectPath:e,cliOption:r,optionObjects:o})=>async()=>{var n;try{if(o.length>1){const i=h({project:e}),s=(0,a.default)(v(o[0].option,i),v(r,i)),c=o[o.length-1],p={...o[0],option:{...s,project:s.project,excludePath:s.excludePath,useRootDir:s.useRootDir,useUpperFirst:s.useUpperFirst,exportFilename:(0,t.getExportFilename)(s.exportFilename)}},u=new Map(o.map((e=>[e.dir,e]))),f={...p,option:(0,a.default)(h({project:e}),{...null!==(n=p.option)&&void 0!==n?n:i})},d=new Map;d.set(f.dir,f),(0,m.fpTimes)(c.depth,!1).forEach((e=>{g(`directory depth "${e}" processed`),Array.from(u.values()).filter((t=>t.depth===e)).forEach((e=>{var t,r,o,n,l;const c=u.get(e.dir),p=null!==(o=null===(r=d.get((0,m.getParentPath)(null!==(t=null==c?void 0:c.dir)&&void 0!==t?t:"")))||void 0===r?void 0:r.option)&&void 0!==o?o:h();if(void 0!==c&&void 0!==p){const e={...c,option:(0,a.default)(p,null!==(n=c.option)&&void 0!==n?n:h({exportFilename:p.exportFilename,useRootDir:p.useRootDir,project:p.project,useUpperFirst:s.useUpperFirst,excludePath:p.excludePath}))};d.set(e.dir,e),g("exportFilename-1: ",p.exportFilename,(null!==(l=c.option)&&void 0!==l?l:i).exportFilename,e.option.exportFilename)}else{const t={...e,option:v(null==c?void 0:c.option,i)};d.set(e.dir,t),g("exportFilename-2: ",t.option.exportFilename)}}))}));const y=[f,...Array.from(d.values())];return l.right(y)}return l.right([...o].map((e=>({...e,option:h()}))))}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return l.left(t)}},t.getConfigFiles=async function(e){try{const t=f.default.dirname(f.default.resolve(e.projectPath)),r=f.default.join(t,"**",".ctirc"),o=(await(0,n.fastGlobWrap)(r,{dot:!0})).sort(((e,t)=>e.localeCompare(t)));return g("finded: ",e,r,o),l.right({projectPath:e.projectPath,optionFiles:o})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return l.left(t)}}},981:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getIgnoredContents=t.getIgnoreFileContents=t.getIgnoreFiles=void 0;const o=r(655),n=o.__importDefault(r(974)),i=o.__importStar(r(431)),a=o.__importDefault(r(147)),l=o.__importDefault(r(837)),s=o.__importDefault(r(17)),c=r(734),p=(0,n.default)("ctix:ignore-tool");t.getIgnoreFiles=e=>async()=>{try{const t=s.default.resolve(e),r=s.default.join(t,"**",".ctiignore"),o=s.default.join(t,"**",".npmignore"),n=await(0,c.fastGlobWrap)([r,o],{dot:!0});return p("resolved: ",t,r),i.right({cwd:e,filenames:n})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return i.left(t)}},t.getIgnoreFileContents=e=>async()=>{try{const t=(await Promise.all(e.filenames.map((e=>(async()=>({filename:e,buffer:await a.default.promises.readFile(e)}))())))).map((e=>({filename:e.filename,buffer:e.buffer.toString()}))).map((e=>({filename:e.filename,directory:s.default.dirname(e.filename),content:(0,l.default)(e.buffer)})));return i.right({cwd:e.cwd,ignores:t})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return i.left(t)}},t.getIgnoredContents=e=>async()=>{try{const t=e.ignores.map((e=>e.content.map((t=>s.default.join(e.directory,t))))).flatMap((e=>e)),r=t.map((e=>(0,c.replaceSepToPosix)(e))),o=await(0,c.fastGlobWrap)(r,{dot:!0});return p("target ignore file: ",t),p("glob processed ignore file: ",o),i.right({cwd:e.cwd,ignores:o})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return i.left(t)}}},734:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getParentPath=t.fpGetDirDepth=t.fpReplaceCwd=t.fpRemoveFirstPathSep=t.fpRemoveDrivePath=t.fpRemoveLastPathSep=t.fpTimes=t.fpAddDotPath=t.fpRefineStartSlash=t.fpRefinePathSep=t.fpRemoveExt=t.fpRemoveExtWithTSX=t.fastGlobWrap=t.winify=t.replaceSepToPosix=t.settify=t.getDirname=t.exists=void 0;const o=r(655),n=o.__importDefault(r(479)),i=o.__importStar(r(431)),a=r(686),l=o.__importStar(r(147)),s=r(352),c=o.__importStar(r(17));async function p(e){try{const t=await l.promises.access(e);return(0,s.isEmpty)(t)}catch(e){return!1}}function u(e){if("/"!==c.sep){const t=c.posix.join(...e.split(c.sep));return e.startsWith(c.sep)?`${c.posix.sep}${t}`:t}return e}t.exists=p,t.getDirname=async function(e,t){try{if((await l.promises.lstat(e)).isDirectory())return null!=t&&t?e:c.resolve(e);const r=c.dirname(e);if((0,s.isFalse)(await p(r)))throw new Error(`Cannot found dirname: ${r}`);return null!=t&&t?r:c.resolve(r)}catch(t){throw t instanceof Error?t:new Error(`unknown error from dirname: ${e}`)}},t.settify=function(e){return Array.from(new Set(e))},t.replaceSepToPosix=u,t.winify=function(e){return e.replace(/\//g,c.sep)},t.fastGlobWrap=async function(e,t){const r=(Array.isArray(e)?e:[e]).map((e=>u(e)));return(await(0,n.default)(r,t)).map((e=>e.replace(/\//g,c.sep)))},t.fpRemoveExtWithTSX=e=>(0,a.pipe)(e,(e=>e.replace(/\.d\.ts$/,"")),(e=>e.replace(/\.tsx$/,"")),(e=>e.replace(/\.ts$/,""))),t.fpRemoveExt=e=>(0,a.pipe)(e,(e=>e.replace(/\.d\.ts$/,"")),(e=>"/index.tsx"!==e&&"index.tsx"!==e?e.replace(/\.tsx$/,""):e),(e=>e.replace(/\.ts$/,""))),t.fpRefinePathSep=e=>(0,a.pipe)(e,(e=>"/"!==c.sep?i.left(e):i.right(e)),i.fold((e=>e.replace(new RegExp(c.sep.replace("\\","\\\\"),"g"),"/")),(e=>e))),t.fpRefineStartSlash=e=>(0,a.pipe)(e,(e=>e.startsWith("/")?i.left(e):i.right(e)),i.fold((e=>e.substring(1,e.length)),(e=>e))),t.fpAddDotPath=e=>(0,a.pipe)(e,(e=>e.startsWith(".")?i.left(e):i.right(e)),i.fold((e=>e),(e=>`./${e}`))),t.fpTimes=(e,t=!0)=>(0,a.pipe)(e,(e=>new Array(e).fill(0)),(e=>e.map(((e,r)=>r+(t?0:1))))),t.fpRemoveLastPathSep=e=>(0,a.pipe)(e,(e=>e.endsWith(c.sep)?i.left(e):i.right(e)),i.fold((e=>e.substring(0,e.length-1>0?e.length-1:e.length)),(e=>e))),t.fpRemoveDrivePath=e=>(0,a.pipe)(e,(e=>e.replace(/^([A-Za-z]:)(.+)/,"$2"))),t.fpRemoveFirstPathSep=e=>(0,a.pipe)(e,(e=>e.startsWith(c.sep)?i.left(e):i.right(e)),i.fold((e=>e.substring(e.length-1>0?1:0,e.length)),(e=>e))),t.fpReplaceCwd=(e,r)=>(0,a.pipe)(e,(e=>(0,t.fpRemoveLastPathSep)(e)),(e=>e===(0,t.fpRemoveLastPathSep)(r)?i.left(e):i.right(e)),i.fold((()=>""),(0,a.flow)((e=>e.endsWith(c.sep)?i.left(e):i.right(e)),i.fold((e=>e),(e=>`${e}${c.sep}`)),(e=>r.replace(e,"")),(e=>(0,t.fpRemoveDrivePath)(e))))),t.fpGetDirDepth=(e,r)=>(0,a.pipe)(e,(e=>(0,t.fpReplaceCwd)(e,r)),(e=>e.split(c.sep)),(e=>e.filter((e=>""!==e))),(e=>e.length)),t.getParentPath=e=>(0,a.pipe)(e,(e=>e.split(c.sep)),(e=>e.slice(0,e.length-1)),(e=>e.join(c.sep)),(e=>c.resolve(e)))},395:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getTypeScriptExportStatement=t.getTypeScriptSource=t.getTypeScriptConfig=void 0;const o=r(655),n=o.__importDefault(r(974)),i=o.__importStar(r(431)),a=o.__importStar(r(686)),l=r(352),s=o.__importDefault(r(17)),c=o.__importDefault(r(7)),p=r(734),u=r(887),f=(0,n.default)("ctix:tsfiles"),d=({cliPath:e,tsconfigResolved:t,tsconfigInCliPath:r})=>async()=>await(0,p.exists)(t)?i.right(t):await(0,p.exists)(r)?i.right(s.default.join(e,t)):i.left(new Error(`Cannot found ${t} in ${process.cwd()} or ${e}`));t.getTypeScriptConfig=({tsconfigPath:e})=>async()=>{try{const t=process.cwd(),r=s.default.join(t,"tsconfig.json"),o=(0,l.isNotEmpty)(e)?s.default.resolve(e):s.default.resolve(r),n=await a.flow((()=>({cliPath:t,tsconfigInCliPath:r,tsconfigResolved:o})),d)()();if(i.isLeft(n))return i.left(new Error(`Cannot found ${o} in ${t} or ${t}`));const p={fileExists:c.default.sys.fileExists,readFile:c.default.sys.readFile,readDirectory:c.default.sys.readDirectory,useCaseSensitiveFileNames:!0},u=c.default.readConfigFile(n.right,c.default.sys.readFile),m=c.default.parseJsonConfigFileContent(u.config,p,s.default.dirname(n.right));return f("tsconfig filenames: ",m.fileNames),i.right(m)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return i.left(t)}},t.getTypeScriptSource=({tsconfig:e,ignores:t})=>async()=>{try{const r=new Map(t.map((e=>s.default.resolve(e))).map((e=>[e,!0]))),o=e.fileNames.map((e=>s.default.resolve(e))).filter((e=>{var t;return(0,l.isFalse)(null!==(t=r.get(e))&&void 0!==t&&t)}));f("typescript configed files: ",e.fileNames),f("typescript process ignored files: ",o);const n=c.default.createProgram(o,e.options);return(0,l.isEmpty)(n)?i.left(new Error("invalid source file")):i.right({program:n,filenames:o})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return i.left(t)}},t.getTypeScriptExportStatement=async function({program:e,filenames:t}){try{const r=new Map(t.map((e=>[(0,p.replaceSepToPosix)(e),!0]))),o=await Promise.all(e.getSourceFiles().filter((e=>{var t;return null!==(t=r.get(e.fileName))&&void 0!==t&&t})).map((e=>e.statements.map((t=>(0,u.delintNode)({filename:e.fileName,source:t}))))).flatMap((e=>e))),n=o.map((e=>e.export.map((t=>({filename:e.filename,exported:t}))))).flatMap((e=>e)).map((e=>e.filename)).filter((e=>(0,l.isNotEmpty)(e))).map((e=>(0,p.winify)(e))),a=new Set(n),s=Array.from(a).sort(((e,t)=>e.localeCompare(t))),c=o.map((e=>e.default.map((t=>({filename:e.filename,defaulted:t}))))).flatMap((e=>e)).map((e=>e.filename)).map((e=>(0,p.winify)(e))),d=new Set(c),m=Array.from(d).sort(((e,t)=>e.localeCompare(t)));return f("file-1: ",e.getSourceFiles().map((e=>e.fileName)).filter((e=>e.indexOf("node_modules")<0))),f("file-2: ",t),f("export file: ",n," default file: ",c),i.right({program:e,exportFilenames:s,defaultExportFilenames:m})}catch(e){return i.left(e)}}},887:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.delintNode=t.hasExportModifiers=void 0;const o=r(655),n=o.__importDefault(r(974)),i=o.__importStar(r(397)),a=r(281),l=r(352),s=o.__importDefault(r(7)),c=(0,n.default)("ctixd:ignore-tool");t.hasExportModifiers=e=>(0,a.pipe)(e,(e=>e.modifiers),(e=>(0,l.isEmpty)(e)?i.left("none"):i.right(e)),i.fold((e=>e),(e=>{var t,r;const o=null!==(t=e.some((e=>e.kind===s.default.SyntaxKind.ExportKeyword)))&&void 0!==t&&t,n=null!==(r=null==e?void 0:e.some((e=>e.kind===s.default.SyntaxKind.DefaultKeyword)))&&void 0!==r&&r;return o&&n?"default":o&&(0,l.isFalse)(n)?"exported":"none"}))),t.delintNode=async function({source:e,filename:r}){const o=[],n=[];c("delintNode: ",r);let i="";const a=e=>{switch(e.kind){case s.default.SyntaxKind.VariableStatement:case s.default.SyntaxKind.InterfaceDeclaration:case s.default.SyntaxKind.TypeAliasDeclaration:case s.default.SyntaxKind.FunctionDeclaration:case s.default.SyntaxKind.ClassDeclaration:case s.default.SyntaxKind.EnumDeclaration:i=(0,t.hasExportModifiers)(e),"default"===i&&n.push(e),"exported"===i&&o.push(e);break;case s.default.SyntaxKind.ExportAssignment:n.push(e)}s.default.forEachChild(e,a)};return a(e),{filename:r,export:o,default:n}}},453:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.write=t.getSingleFileWriteContents=t.getWriteContents=t.getModuleDir=void 0;const o=r(655),n=r(734),i=r(110),a=o.__importDefault(r(635)),l=o.__importDefault(r(974)),s=o.__importStar(r(431)),c=o.__importStar(r(686)),p=o.__importStar(r(972)),u=o.__importStar(r(147)),f=r(352),d=o.__importStar(r(17)),m=r(309),g=r(138),h=(0,l.default)("ctix:write");async function y({filename:e,replacer:t,configMap:r}){var o;const i=d.dirname(e);h("createExportContents: ",i);try{const a=r.get(i),l=null!==(o=null==a?void 0:a.option.quote)&&void 0!==o?o:"'",s=t({dirname:i,filename:e}),p=`export * from ${l}${c.flow(n.fpRefinePathSep,n.fpRemoveExt,n.fpRefineStartSlash,n.fpAddDotPath)(s)}${l}`;return{dirname:await(0,n.getDirname)(e),content:p}}catch(t){const r=t instanceof Error?t:new Error("unknown error raised");return h(r.message),h(r.stack),{dirname:d.dirname(e),content:void 0}}}async function v({filename:e,replacer:t,configMap:r}){var o;const a=d.dirname(e);try{const s=r.get(a),p=null!==(o=null==s?void 0:s.option.quote)&&void 0!==o?o:"'",u=t({dirname:a,filename:e}),g=c.flow(n.fpRefinePathSep,n.fpRemoveExt,n.fpRefineStartSlash,n.fpAddDotPath)(u),h=(null==s?void 0:s.option.excludePath)?c.flow((e=>d.basename(e)),n.fpRemoveExtWithTSX)(u):c.flow(n.fpRefinePathSep,n.fpRemoveExtWithTSX)(u),y=`export { default as ${(null==(l=null==s?void 0:s.option)||(0,f.isFalse)(l.excludePath)||(0,f.isFalse)(l.useUpperFirst)?i.camelCase:e=>/^[A-Z]\w+/.test(e)?(0,m.upperCaseFirst)((0,i.camelCase)(e)):(0,i.camelCase)(e))(h)} } from ${p}${g}${p}`;return{dirname:await(0,n.getDirname)(e),content:y}}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return h(t.message),h(t.stack),{dirname:a,content:void 0}}var l}function w({project:e,configMap:t,filenames:r}){const o=r.map((t=>{const r=d.dirname(t);return{depth:r.replace(e,"").split(d.sep).length-1,dirname:r,filename:t}})).sort(((e,t)=>{const r=t.depth-e.depth;return 0===r?t.filename.localeCompare(e.filename):r})),[i]=o,a=i.depth;h("dirs: ",a,o);const l=(0,n.fpTimes)(a).map((e=>{const r=o.filter((t=>t.depth===e));return h("current depth: ",e),r.map((r=>{var i,a;const l=o.filter((t=>t.dirname.indexOf(r.dirname)>=0&&t.dirname!==r.dirname&&t.depth-e==1)),s=t.get(r.dirname),p=null!==(i=null==s?void 0:s.option)&&void 0!==i?i:(0,g.defaultOption)(),u=null!==(a=null==s?void 0:s.option.quote)&&void 0!==a?a:"'",f=(0,n.settify)(l.map((e=>d.dirname(e.filename))));if("index.ts"===p.exportFilename||"index.d.ts"===p.exportFilename){const e=f.map((e=>{const t=c.flow(n.fpRefinePathSep,n.fpRemoveExt,n.fpRefineStartSlash)(e.replace(r.dirname,""));return`export * from ${u}./${t}${u}`}));return{dirname:r.dirname,content:e}}const m=f.map((e=>{const t=c.flow(n.fpRefinePathSep,n.fpRemoveExt,n.fpRefineStartSlash)(d.join(e.replace(r.dirname,""),p.exportFilename));return`export * from ${u}./${t}${u}`}));return{dirname:r.dirname,content:m}}))})).flatMap((e=>e)),s=new Map(l.map((e=>[e.dirname,e.content]))),p=Array.from(s.entries()).map((([e,t])=>({dirname:e,content:t}))).filter((e=>Array.isArray(e.content)&&e.content.length>0));return h("module directory: ",p),p.map((e=>e.content.map((t=>({dirname:e.dirname,content:t}))))).flatMap((e=>e))}t.getModuleDir=w,t.getWriteContents=async function(e){try{const t=new Map(e.optionObjects.map((e=>[e.dir,e]))),[r]=e.optionObjects,o=d.resolve(d.dirname(r.option.project));h("exportFilenames: ",e.exportFilenames),h("defaultExportFilenames: ",e.defaultExportFilenames);const n=e=>d.relative(e.dirname,e.filename),i=(await Promise.all(e.exportFilenames.map((e=>y({filename:e,configMap:t,replacer:n}))))).filter((e=>(0,f.isNotEmpty)(e.content))),a=(await Promise.all(e.defaultExportFilenames.map((e=>v({filename:e,configMap:t,replacer:n}))))).filter((e=>(0,f.isNotEmpty)(e.content))),l=w({project:o,configMap:t,filenames:e.exportFilenames.concat(e.defaultExportFilenames)}),c=i.concat(a).concat(l).reduce(((e,t)=>{const r=e;return(0,f.isEmpty)(e[t.dirname])&&(r[t.dirname]=[]),(0,f.isNotEmpty)(t.content)&&(r[t.dirname]=[...r[t.dirname],t.content]),r}),{}),p=Object.entries(c).map((([e,t])=>({pathname:e,content:t}))).sort(((e,t)=>e.pathname.localeCompare(t.pathname)));return s.right(p)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return s.left(t)}},t.getSingleFileWriteContents=async function(e){try{const t=new Map(e.optionObjects.map((e=>[e.dir,e])));h("exportFilenames: ",e.exportFilenames),h("defaultExportFilenames: ",e.defaultExportFilenames);const r=await(async(e,t)=>{if((0,f.isFalse)(t.useRootDir))return d.resolve(await(0,n.getDirname)(t.outputDir));const r=(e=>{if(void 0!==e.rootDir&&null!==e.rootDir)return d.resolve(e.rootDir);if(void 0!==e.rootDirs&&null!==e.rootDirs){const[t]=e.rootDirs;return d.resolve(t)}})(e.getCompilerOptions());if(null!=r){const e=await(0,n.getDirname)(t.outputDir);return d.relative(r,e).startsWith("..")?r:d.resolve(e)}return d.resolve(await(0,n.getDirname)(t.outputDir))})(e.program,e.rootOptions),o=e=>d.relative(r,e.filename),i=(await Promise.all(e.exportFilenames.map((e=>y({filename:e,configMap:t,replacer:o}))))).filter((e=>(0,f.isNotEmpty)(e.content))),a=(await Promise.all(e.defaultExportFilenames.map((e=>v({filename:e,configMap:t,replacer:o}))))).filter((e=>(0,f.isNotEmpty)(e.content))),l=i.concat(a).reduce(((e,t)=>{const o=e;return(0,f.isEmpty)(o[r])&&(o[r]=[]),(0,f.isNotEmpty)(t.content)&&(o[r]=[...o[r],t.content]),o}),{}),c=Object.entries(l).map((([e,t])=>({pathname:e,content:t})));return s.right(c)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return s.left(t)}},t.write=async function(e){try{const t=new Map(e.optionObjects.map((e=>[e.dir,e]))),r=async e=>{var r;h("current: ",e.pathname);const o=null!==(r=t.get(e.pathname))&&void 0!==r?r:{dir:e.pathname,depth:0,exists:!1,option:(0,g.defaultOption)()},i=o.option.exportFilename,l=d.resolve(e.pathname,i),m=d.resolve(e.pathname,`${i}.bak`);if((0,f.isTrue)(o.option.useBackupFile)&&await(0,n.exists)(l)){const e=await c.pipe(p.taskify(u.readFile)(l),p.chain((e=>p.taskify(u.writeFile)(m,e))))();if(s.isLeft(e))return h("error caused from backup write, ..."),h(e.left.message),h(e.left.stack),s.left(e.left)}const y=(0,a.default)(),v=c.pipe(o.option.useComment?"// created from ctix":"",(e=>o.option.useComment&&o.option.useTimestamp?`${e} ${y.format("YYYY-MM-DD HH:mm:ss")}`:e),(e=>""!==e?`${e}\n\n`:e)),w=Buffer.from(`${v}${e.content.map((e=>o.option.useSemicolon?`${e};`:e)).join("\n")}${o.option.addNewline?"\n":""}`,"utf8"),x=await p.taskify(u.writeFile)(l,w)();return s.isLeft(x)?(h(`error caused from ${i} write, ...`),h(x.left.message),h(x.left.stack),s.left(x.left)):s.right(1)},o=(await Promise.all(e.contents.map((e=>r(e))))).map((e=>s.isRight(e)?1:0)).reduce(((e,t)=>e+t));return h("successfully writed index: ",o),s.right(o)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return s.left(t)}}},655:(e,t,r)=>{r.r(t),r.d(t,{__extends:()=>n,__assign:()=>i,__rest:()=>a,__decorate:()=>l,__param:()=>s,__metadata:()=>c,__awaiter:()=>p,__generator:()=>u,__createBinding:()=>f,__exportStar:()=>d,__values:()=>m,__read:()=>g,__spread:()=>h,__spreadArrays:()=>y,__spreadArray:()=>v,__await:()=>w,__asyncGenerator:()=>x,__asyncDelegator:()=>b,__asyncValues:()=>_,__makeTemplateObject:()=>S,__importStar:()=>E,__importDefault:()=>j,__classPrivateFieldGet:()=>F,__classPrivateFieldSet:()=>D});var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},o(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return i=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};function a(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}function l(e,t,r,o){var n,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var l=e.length-1;l>=0;l--)(n=e[l])&&(a=(i<3?n(a):i>3?n(t,r,a):n(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function s(e,t){return function(r,o){t(r,o,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,r,o){return new(r||(r=Promise))((function(n,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))}function u(e,t){var r,o,n,i,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,o&&(n=2&i[0]?o.return:i[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;switch(o=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){a.label=i[1];break}if(6===i[0]&&a.label<n[1]){a.label=n[1],n=i;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(i);break}n[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{r=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}var f=Object.create?function(e,t,r,o){void 0===o&&(o=r),Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]};function d(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||f(t,e,r)}function m(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return a}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function y(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var o=Array(e),n=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,l=i.length;a<l;a++,n++)o[n]=i[a];return o}function v(e,t,r){if(r||2===arguments.length)for(var o,n=0,i=t.length;n<i;n++)!o&&n in t||(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}function w(e){return this instanceof w?(this.v=e,this):new w(e)}function x(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,n=r.apply(e,t||[]),i=[];return o={},a("next"),a("throw"),a("return"),o[Symbol.asyncIterator]=function(){return this},o;function a(e){n[e]&&(o[e]=function(t){return new Promise((function(r,o){i.push([e,t,r,o])>1||l(e,t)}))})}function l(e,t){try{(r=n[e](t)).value instanceof w?Promise.resolve(r.value.v).then(s,c):p(i[0][2],r)}catch(e){p(i[0][3],e)}var r}function s(e){l("next",e)}function c(e){l("throw",e)}function p(e,t){e(t),i.shift(),i.length&&l(i[0][0],i[0][1])}}function b(e){var t,r;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,n){t[o]=e[o]?function(t){return(r=!r)?{value:w(e[o](t)),done:"return"===o}:n?n(t):t}:n}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=m(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(r){t[r]=e[r]&&function(t){return new Promise((function(o,n){!function(e,t,r,o){Promise.resolve(o).then((function(t){e({value:t,done:r})}),t)}(o,n,(t=e[r](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var P=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function E(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&f(t,e,r);return P(t,e),t}function j(e){return e&&e.__esModule?e:{default:e}}function F(e,t,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(e):o?o.value:t.get(e)}function D(e,t,r,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,r):n?n.value=r:t.set(e,r),r}},351:e=>{e.exports=require("@oclif/core")},22:e=>{e.exports=require("chalk")},110:e=>{e.exports=require("change-case")},635:e=>{e.exports=require("dayjs")},974:e=>{e.exports=require("debug")},330:e=>{e.exports=require("deepmerge")},479:e=>{e.exports=require("fast-glob")},819:e=>{e.exports=require("fp-ts/Apply")},431:e=>{e.exports=require("fp-ts/Either")},972:e=>{e.exports=require("fp-ts/TaskEither")},686:e=>{e.exports=require("fp-ts/function")},397:e=>{e.exports=require("fp-ts/lib/Either")},281:e=>{e.exports=require("fp-ts/lib/pipeable")},959:e=>{e.exports=require("json5")},352:e=>{e.exports=require("my-easy-fp")},837:e=>{e.exports=require("parse-gitignore")},261:e=>{e.exports=require("source-map-support")},7:e=>{e.exports=require("typescript")},309:e=>{e.exports=require("upper-case-first")},392:e=>{e.exports=require("yargs")},147:e=>{e.exports=require("fs")},17:e=>{e.exports=require("path")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{var e=o;Object.defineProperty(e,"__esModule",{value:!0});const t=r(655),n=r(930),i=r(181),a=r(138),l=r(981),s=t.__importDefault(r(900)),c=r(734),p=r(395),u=r(453),f=t.__importDefault(r(22)),d=r(351),m=t.__importDefault(r(974)),g=t.__importStar(r(819)),h=t.__importStar(r(431)),y=t.__importStar(r(686)),v=t.__importStar(r(972)),w=t.__importStar(r(147)),x=t.__importStar(r(17)),b=t.__importDefault(r(261)),_=t.__importDefault(r(392)),S=(0,m.default)("ctix:cli-tool");function P(e){return e.option("addNewline",{alias:"n",describe:"add newline on EOF",type:"boolean"}).option("useSemicolon",{alias:"s",describe:"add semicolon on every export statement",type:"boolean"}).option("useTimestamp",{alias:"m",describe:"timestamp write on ctix comment right-side, only works in useComment option set true",type:"boolean"}).option("useComment",{alias:"c",describe:"add ctix comment at first line of creted index.ts file, that remark created from ctix",type:"boolean"}).option("quote",{alias:"q",describe:"change quote character at export syntax",type:"string"}).option("excludePath",{alias:"x",describe:"exclude path in default export variable(or function)",type:"boolean",default:!1}).option("useUpperFirst",{describe:"Default export variable, class, function name keep first capital character.",type:"boolean",default:!0}).option("useBackupFile",{alias:"b",describe:"created backup file if exists index.ts file already in directory",type:"boolean"}),e}async function E(e,t){if(void 0===e&&void 0===t)throw new Error(`invalid project path, don't exist: "${e}" or "${null!=t?t:""}"`);const r=null!=t?t:"";if(await(0,c.exists)(r))return x.resolve(r);const o=x.join(r,"tsconfig.json");if(await(0,c.exists)(o))return x.resolve(o);if(void 0===e)throw new Error(`invalid project path, don't exist: "${e}" or "${null!=t?t:""}"`);if(await(0,c.exists)(e))return x.resolve(e);const n=x.join(e,"tsconfig.json");if(await(0,c.exists)(n))return x.resolve(n);throw new Error(`invalid project path, don't exist: ${e} or ${null!=t?t:""}`)}b.default.install(),(0,_.default)(process.argv.slice(2)).command({command:"$0 [tsconfigPath]",aliases:"create [tsconfigPath]",builder:e=>P(e),handler:async e=>{var t,r,o,n;s.default.switch(null!==(t=e.verbose)&&void 0!==t&&t);const m=new i.Counter(null!==(r=e.verbose)&&void 0!==r&&r);try{const t=await E(e.tsconfigPath,e.project),r=x.resolve(t),i=await(0,c.getDirname)(r,!0);process.chdir(i),d.CliUx.ux.action.start(f.default`{yellow ctix} ${null!==(o=e.exportFilename)&&void 0!==o?o:"index.ts"} file create mode:`,"initializing",{stdout:!0});const w={...(0,a.getNonEmptyOption)(e,t),resolvedProjectDirPath:i,resolvedProjectFilePath:r};s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} project directory: ${t}`),s.default.log(f.default`{yellow ctix - ${m.log}:} read ignore file, tsconfig file, cti config {green complete}`),d.CliUx.ux.action.status="processing ...";const b=await g.sequenceT(v.ApplicativeSeq)(y.pipe((0,l.getIgnoreFiles)(i),v.chain(l.getIgnoreFileContents),v.chain(l.getIgnoredContents)),(0,p.getTypeScriptConfig)({tsconfigPath:r}),y.pipe((0,a.getCTIXOptions)({projectPath:r}),v.chain((e=>(0,a.getMergedConfig)({projectPath:r,optionObjects:e,cliOption:w})))))();if(h.isLeft(b))throw b.left;const[_,S,P]=b.right;s.default.log(f.default`{yellow ctix - ${m.log}:} typescript source file parsing {green compile} `),d.CliUx.ux.action.status="processing ...",s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} ignore content - ${_.ignores.length}`),s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} typescript file - ${S.fileNames.length}`),s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} config file - ${P.length}`);const j=await y.pipe(v.right({tsconfig:S,ignores:_.ignores}),v.chain(p.getTypeScriptSource),v.chain((e=>()=>(0,p.getTypeScriptExportStatement)({program:e.program,filenames:e.filenames}))))();if(h.isLeft(j))throw j.left;s.default.log(f.default`{yellow ctix - ${m.log}:} ${null!==(n=e.exportFilename)&&void 0!==n?n:"index.ts"} write on project directory {green compile}`);const F=await(0,u.getWriteContents)({...j.right,optionObjects:P});if(h.isLeft(F))throw F.left;await(0,u.write)({contents:F.right,optionObjects:P})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");s.default.error(f.default`{red error} message below, `),s.default.error(t.message)}finally{d.CliUx.ux.action.stop("complete")}}}).command({command:"single [tsconfigPath]",aliases:["entrypoint [tsconfigPath]"],builder:e=>{const t=P(e);return t.option("useRootDir",{alias:"r",describe:"output file under rootDir in tsconfig.json",type:"boolean"}).option("output",{alias:"o",describe:"Output directory",type:"string"}),t},handler:async e=>{var t,r,o,n;s.default.switch(null!==(t=e.verbose)&&void 0!==t&&t);const m=new i.Counter(null!==(r=e.verbose)&&void 0!==r&&r);try{const t=await E(e.tsconfigPath,e.project),r=x.resolve(t),i=await(0,c.getDirname)(r,!0);process.chdir(i),d.CliUx.ux.action.start(f.default`{yellow ctix} single ${null!==(o=e.exportFilename)&&void 0!==o?o:"index.ts"} file create mode:`,"initializing",{stdout:!0});const w={...(0,a.getNonEmptyOption)(e,t),resolvedProjectDirPath:i,resolvedProjectFilePath:r};s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} project directory: ${t}`),s.default.log(f.default`{yellow ctix - ${m.log}:} read ignore file, tsconfig file, cti config {green complete}`),d.CliUx.ux.action.status="processing ...";const b=await g.sequenceT(v.ApplicativeSeq)(y.pipe((0,l.getIgnoreFiles)(i),v.chain(l.getIgnoreFileContents),v.chain(l.getIgnoredContents)),(0,p.getTypeScriptConfig)({tsconfigPath:t}),y.pipe((0,a.getCTIXOptions)({projectPath:r}),v.chain((e=>(0,a.getMergedConfig)({projectPath:r,optionObjects:e,cliOption:w})))))();if(h.isLeft(b))throw b.left;const[_,S,P]=b.right;s.default.log(f.default`{yellow ctix - ${m.log}:} typescript source file parsing {green compile} `),d.CliUx.ux.action.status="processing ...",s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} ignore content - ${_.ignores.length}`),s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} typescript file - ${S.fileNames.length}`),s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} config file - ${P.length}`);const j=await y.pipe(v.right({tsconfig:S,ignores:_.ignores}),v.chain(p.getTypeScriptSource),v.chain((e=>()=>(0,p.getTypeScriptExportStatement)({program:e.program,filenames:e.filenames}))))();if(h.isLeft(j))throw j.left;s.default.log(f.default`{yellow ctix - ${m.log}:} ${null!==(n=e.exportFilename)&&void 0!==n?n:"index.ts"} write on project directory {green compile}`);const F=await(0,u.getSingleFileWriteContents)({...j.right,optionObjects:P,rootOptions:w});if(h.isLeft(F))throw F.left;await(0,u.write)({contents:F.right,optionObjects:P})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");s.default.error(f.default`{red error} message below, `),s.default.error(t.message)}finally{d.CliUx.ux.action.stop("complete")}}}).command({command:"clean [tsconfigPath]",builder:e=>(e.option("includeBackup",{alias:"b",describe:"clean with backup file",default:!1,type:"boolean"}),e),handler:async e=>{var t,r,o;const l=new i.Counter(null!==(t=e.verbose)&&void 0!==t&&t);s.default.switch(null!==(r=e.verbose)&&void 0!==r&&r);try{const t=await E(e.tsconfigPath,e.project),r=x.resolve(t),i=await(0,c.getDirname)(r,!0);process.chdir(i),S("path.resolve in ctix.ts: ",x.resolve(t)),d.CliUx.ux.action.start(f.default`{yellow ctix} ${null!==(o=e.exportFilename)&&void 0!==o?o:"index.ts"} file clean mode:`,"initializing",{stdout:!0});const p={...(0,a.getNonEmptyOption)(e,t),resolvedProjectDirPath:i,resolvedProjectFilePath:r};S("clean option: ",p);const u=await y.pipe((0,n.getCleanFilenames)({cliOption:p,includeBackupFrom:e.includeBackup}),v.chain((e=>()=>(s.default.log(f.default`{yellow ctix - ${l.log}:} clean file find {green complete}`),s.default.debug(f.default`{yellow ctix - ${l.debug}:} {blueBright [info]} clean file - ${e.length}`),(0,n.clean)({filenames:e})))))();if(h.isLeft(u))throw u.left;s.default.log(f.default`{yellow ctix - ${l.log}:} clean action {green complete}`)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");s.default.error(f.default`{red error} message below, `),s.default.error(t.message)}finally{d.CliUx.ux.action.stop("complete")}}}).command({command:"init [tsconfigPath]",builder:e=>e,handler:async e=>{var t,r;const o=new i.Counter(null!==(t=e.verbose)&&void 0!==t&&t);s.default.switch(null!==(r=e.verbose)&&void 0!==r&&r);try{const t=await E(e.tsconfigPath,e.project);d.CliUx.ux.action.start(f.default`{yellow ctix} generate .ctirc:`,"initializing",{stdout:!0}),s.default.log(f.default`{yellow ctix - ${o.log}:} default option generation {green compile} `),d.CliUx.ux.action.status="processing ...";const r={...(0,a.defaultOption)()};delete r.project,delete r.verbose;const n=x.dirname(t);await w.promises.writeFile(x.join(n,".ctirc"),JSON.stringify(r)),s.default.log(f.default`{yellow ctix - ${o.log}:} .ctirc file write {green compile} `),d.CliUx.ux.action.status="processing ..."}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");s.default.error(f.default`{red error} message below, `),s.default.error(t.message)}finally{d.CliUx.ux.action.stop("complete")}}}).option("project",{alias:"p",describe:'tsconfig.json path: you must pass path with filename, like this "./tsconfig.json"',type:"string"}).option("exportFilename",{alias:"f",describe:'Export filename, if you not pass this field that use "index.ts" or "index.d.ts"',type:"string"}).option("verbose",{alias:"v",describe:"display more detailed log",type:"boolean"}).help().argv})();var n=exports;for(var i in o)n[i]=o[i];o.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
(()=>{"use strict";var e={181:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Counter=void 0,t.Counter=class{constructor(e){this.count=0,this.verbose=e}get log(){return this.count+=1,this.count}get debug(){return this.count+=this.verbose?1:0,this.count}}},900:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=void 0;class r{constructor(){this._log=console.log,this._debug=()=>{},this._error=console.error}log(...e){this._log(...e)}debug(...e){this._debug(...e)}error(...e){this._error(...e)}switch(e){e?(this._log=console.log,this._debug=console.debug,this._error=console.error):(this._log=console.log,this._debug=()=>{},this._error=console.error)}}t.Logger=r;const o=new r;t.default=o},930:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clean=t.getCleanFilenames=void 0;const o=r(655),n=r(138),i=o.__importDefault(r(974)),a=o.__importStar(r(431)),l=o.__importStar(r(686)),s=o.__importStar(r(972)),c=o.__importStar(r(147)),p=r(352),u=o.__importStar(r(17)),f=r(734),d=(0,i.default)("ctix:clean-tool");t.getCleanFilenames=({cliOption:e,includeBackupFrom:t})=>async()=>{var r,o;try{const i=(0,n.defaultOption)(),c=null!==(r=null==e?void 0:e.resolvedProjectFilePath)&&void 0!==r?r:i.project,m=null!==(o=null==e?void 0:e.resolvedProjectDirPath)&&void 0!==o?o:i.project,g=null==t||t;if((0,p.isFalse)(await(0,f.exists)(c)))return a.left(new Error(`invalid tsconfig.json path: ${c}`));const h=await l.pipe((0,n.getCTIXOptions)({projectPath:c}),s.chain((t=>(0,n.getMergedConfig)({projectPath:c,cliOption:null!=e?e:i,optionObjects:t}))))();if(a.isLeft(h))return a.left(h.left);const y=(0,f.settify)(h.right.filter((e=>e.dir.indexOf("node_modules")<0)).map((e=>u.join(e.dir,"**",e.option.exportFilename)))),v=(0,f.settify)(h.right.map((e=>u.join(e.dir,"**",`${e.option.exportFilename}.bak`)))),w=await(0,f.fastGlobWrap)(g?y.concat(v).map((e=>(0,f.replaceSepToPosix)(e))):y.map((e=>(0,f.replaceSepToPosix)(e))),{dot:!0,cwd:m,ignore:[(0,f.replaceSepToPosix)(u.join(c,"**","node_modules","**"))]}),x=w.filter((e=>e.startsWith(m)));return d("resolved: ",c,y,w,x),a.right(x)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised from getCleanFilenames");return d("Error raised: ",t.message),d("Error raised: ",t.stack),a.left(t)}},t.clean=async function({filenames:e}){try{const t=(await Promise.all(e.map((e=>async function(e){try{return await c.promises.unlink(e),a.right(!0)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised from unlink");return d("Error raised: ",t.message),d("Error raised: ",t.stack),a.left(t)}}(e))))).map((e=>a.isLeft(e)?e.left.message:"")).filter((e=>""!==e));return t.length>0?a.left(new Error(`invalid filename and path: ${t.join("\n")}`)):a.right(!0)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised from clean");return d("Error raised: ",t.message),d("Error raised: ",t.stack),a.left(t)}}},138:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getConfigFiles=t.getMergedConfig=t.getCTIXOptions=t.getNonEmptyOption=t.readOptionFile=t.defaultOption=t.getExportFilename=void 0;const o=r(655),n=r(734),i=o.__importDefault(r(974)),a=o.__importDefault(r(330)),l=o.__importStar(r(431)),s=o.__importStar(r(686)),c=o.__importStar(r(147)),p=o.__importDefault(r(959)),u=r(352),f=o.__importDefault(r(17)),d=o.__importDefault(r(900)),m=r(734),g=(0,i.default)("ctix:config-test-case");function h(e){var t,r,o,n,i;const a=null!==(t=null==e?void 0:e.project)&&void 0!==t?t:f.default.join(process.cwd(),"tsconfig.json"),l=null!==(r=null==e?void 0:e.exportFilename)&&void 0!==r?r:"index.ts",s=null!==(o=null==e?void 0:e.excludePath)&&void 0!==o&&o;return{addNewline:!0,useSemicolon:!0,useTimestamp:!1,useComment:!0,exportFilename:l,quote:"'",verbose:!1,useBackupFile:!0,output:a,useRootDir:null!==(n=null==e?void 0:e.useRootDir)&&void 0!==n&&n,excludePath:s,useUpperFirst:null===(i=null==e?void 0:e.useUpperFirst)||void 0===i||i,project:a}}async function y(e,t){var r;try{const t=await c.promises.readFile(e),r=p.default.parse(t.toString());return["project","addNewline","useSemicolon","useTimestamp","useComment","quote","verbose","useBackupFile","exportFilename","useRootDir"].reduce(((e,t)=>{const o=e;return(0,u.isNotEmpty)(r[t])&&(o[t]=r[t]),o}),{})}catch(o){const n=o instanceof Error?o:new Error("unknown error raised");return d.default.error(`Error caused from ${e}`),d.default.error(null!==(r=n.message)&&void 0!==r?r:""),g("---------------------------------------------------------------------------"),g("Error caused from readOptionFile"),g(n.message),g(n.stack),g("---------------------------------------------------------------------------"),h({project:t})}}function v(e,t){var r,o,n,i,a,l,s,c,p,u,f,d,m;const g="string"==typeof t?h({project:t}):t;return{project:null!==(r=null==e?void 0:e.project)&&void 0!==r?r:g.project,addNewline:null!==(o=null==e?void 0:e.addNewline)&&void 0!==o?o:g.addNewline,useSemicolon:null!==(n=null==e?void 0:e.useSemicolon)&&void 0!==n?n:g.useSemicolon,useTimestamp:null!==(i=null==e?void 0:e.useTimestamp)&&void 0!==i?i:g.useTimestamp,useComment:null!==(a=null==e?void 0:e.useComment)&&void 0!==a?a:g.useComment,quote:null!==(l=null==e?void 0:e.quote)&&void 0!==l?l:g.quote,verbose:null!==(s=null==e?void 0:e.verbose)&&void 0!==s?s:g.verbose,useBackupFile:null!==(c=null==e?void 0:e.useBackupFile)&&void 0!==c?c:g.useBackupFile,exportFilename:null!==(p=null==e?void 0:e.exportFilename)&&void 0!==p?p:g.exportFilename,output:null!==(u=null==e?void 0:e.output)&&void 0!==u?u:g.output,useRootDir:null!==(f=null==e?void 0:e.useRootDir)&&void 0!==f?f:g.useRootDir,excludePath:null!==(d=null==e?void 0:e.excludePath)&&void 0!==d?d:g.excludePath,useUpperFirst:null!==(m=null==e?void 0:e.useUpperFirst)&&void 0!==m?m:g.useUpperFirst}}t.getExportFilename=e=>s.pipe(e,(e=>(0,u.isEmpty)(e)?"index.ts":e),(e=>""===e?"index.ts":e)),t.defaultOption=h,t.readOptionFile=y,t.getNonEmptyOption=v,t.getCTIXOptions=e=>async()=>{try{const t=f.default.resolve(e.projectPath),r=f.default.dirname(t),o=await(0,n.fastGlobWrap)(`${r}/**/*`,{onlyDirectories:!0,ignore:[(0,n.replaceSepToPosix)(f.default.join(r,"**","node_modules","**"))]}),i=await Promise.all([r,...o].map((e=>(async()=>{const o=f.default.join(e,".ctirc"),i=await(0,n.exists)(o),a=(0,m.fpGetDirDepth)(r,e);g("Working configuration file: ",a,o,i);try{return{dir:f.default.resolve(e),exists:i,depth:a,option:i?await y(o,t):void 0}}catch(t){const n=t instanceof Error?t:new Error("unknown error raised");return g(o,i),g(n.message),{dir:e,depth:(0,m.fpGetDirDepth)(r,e),exists:i,option:void 0}}})())));return l.right([...i].sort(((e,t)=>{const r=e.depth-t.depth;return 0===r?e.dir.localeCompare(t.dir):r})))}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return l.left(t)}},t.getMergedConfig=({projectPath:e,cliOption:r,optionObjects:o})=>async()=>{var n;try{if(o.length>1){const i=h({project:e}),s=(0,a.default)(v(o[0].option,i),v(r,i)),c=o[o.length-1],p={...o[0],option:{...s,project:s.project,excludePath:s.excludePath,useRootDir:s.useRootDir,useUpperFirst:s.useUpperFirst,exportFilename:(0,t.getExportFilename)(s.exportFilename)}},u=new Map(o.map((e=>[e.dir,e]))),f={...p,option:(0,a.default)(h({project:e}),{...null!==(n=p.option)&&void 0!==n?n:i})},d=new Map;d.set(f.dir,f),(0,m.fpTimes)(c.depth,!1).forEach((e=>{g(`directory depth "${e}" processed`),Array.from(u.values()).filter((t=>t.depth===e)).forEach((e=>{var t,r,o,n,l;const c=u.get(e.dir),p=null!==(o=null===(r=d.get((0,m.getParentPath)(null!==(t=null==c?void 0:c.dir)&&void 0!==t?t:"")))||void 0===r?void 0:r.option)&&void 0!==o?o:h();if(void 0!==c&&void 0!==p){const e={...c,option:(0,a.default)(p,null!==(n=c.option)&&void 0!==n?n:h({exportFilename:p.exportFilename,useRootDir:p.useRootDir,project:p.project,useUpperFirst:s.useUpperFirst,excludePath:p.excludePath}))};d.set(e.dir,e),g("exportFilename-1: ",p.exportFilename,(null!==(l=c.option)&&void 0!==l?l:i).exportFilename,e.option.exportFilename)}else{const t={...e,option:v(null==c?void 0:c.option,i)};d.set(e.dir,t),g("exportFilename-2: ",t.option.exportFilename)}}))}));const y=[f,...Array.from(d.values())];return l.right(y)}return l.right([...o].map((e=>({...e,option:h()}))))}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return l.left(t)}},t.getConfigFiles=async function(e){try{const t=f.default.dirname(f.default.resolve(e.projectPath)),r=f.default.join(t,"**",".ctirc"),o=(await(0,n.fastGlobWrap)(r,{dot:!0})).sort(((e,t)=>e.localeCompare(t)));return g("finded: ",e,r,o),l.right({projectPath:e.projectPath,optionFiles:o})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return l.left(t)}}},981:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getIgnoredContents=t.getIgnoreFileContents=t.getIgnoreFiles=void 0;const o=r(655),n=o.__importDefault(r(974)),i=o.__importStar(r(431)),a=o.__importDefault(r(147)),l=o.__importDefault(r(837)),s=o.__importDefault(r(17)),c=r(734),p=(0,n.default)("ctix:ignore-tool");t.getIgnoreFiles=e=>async()=>{try{const t=s.default.resolve(e),r=s.default.join(t,"**",".ctiignore"),o=s.default.join(t,"**",".npmignore"),n=await(0,c.fastGlobWrap)([r,o],{dot:!0});return p("resolved: ",t,r),i.right({cwd:e,filenames:n})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return i.left(t)}},t.getIgnoreFileContents=e=>async()=>{try{const t=(await Promise.all(e.filenames.map((e=>(async()=>({filename:e,buffer:await a.default.promises.readFile(e)}))())))).map((e=>({filename:e.filename,buffer:e.buffer.toString()}))).map((e=>({filename:e.filename,directory:s.default.dirname(e.filename),content:(0,l.default)(e.buffer)})));return i.right({cwd:e.cwd,ignores:t})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return i.left(t)}},t.getIgnoredContents=e=>async()=>{try{const t=e.ignores.map((e=>e.content.map((t=>s.default.join(e.directory,t))))).flatMap((e=>e)),r=t.map((e=>(0,c.replaceSepToPosix)(e))),o=await(0,c.fastGlobWrap)(r,{dot:!0});return p("target ignore file: ",t),p("glob processed ignore file: ",o),i.right({cwd:e.cwd,ignores:o})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return i.left(t)}}},734:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getParentPath=t.fpGetDirDepth=t.fpReplaceCwd=t.fpRemoveFirstPathSep=t.fpRemoveDrivePath=t.fpRemoveLastPathSep=t.fpTimes=t.fpAddDotPath=t.fpRefineStartSlash=t.fpRefinePathSep=t.fpRemoveExt=t.fpRemoveExtWithTSX=t.fastGlobWrap=t.winify=t.replaceSepToPosix=t.settify=t.getDirname=t.exists=void 0;const o=r(655),n=o.__importDefault(r(479)),i=o.__importStar(r(431)),a=r(686),l=o.__importStar(r(147)),s=r(352),c=o.__importStar(r(17));async function p(e){try{const t=await l.promises.access(e);return(0,s.isEmpty)(t)}catch(e){return!1}}function u(e){if("/"!==c.sep){const t=c.posix.join(...e.split(c.sep));return e.startsWith(c.sep)?`${c.posix.sep}${t}`:t}return e}t.exists=p,t.getDirname=async function(e,t){try{if((await l.promises.lstat(e)).isDirectory())return null!=t&&t?e:c.resolve(e);const r=c.dirname(e);if((0,s.isFalse)(await p(r)))throw new Error(`Cannot found dirname: ${r}`);return null!=t&&t?r:c.resolve(r)}catch(t){throw t instanceof Error?t:new Error(`unknown error from dirname: ${e}`)}},t.settify=function(e){return Array.from(new Set(e))},t.replaceSepToPosix=u,t.winify=function(e){return e.replace(/\//g,c.sep)},t.fastGlobWrap=async function(e,t){const r=(Array.isArray(e)?e:[e]).map((e=>u(e)));return(await(0,n.default)(r,t)).map((e=>e.replace(/\//g,c.sep)))},t.fpRemoveExtWithTSX=e=>(0,a.pipe)(e,(e=>e.replace(/\.d\.ts$/,"")),(e=>e.replace(/\.tsx$/,"")),(e=>e.replace(/\.ts$/,""))),t.fpRemoveExt=e=>(0,a.pipe)(e,(e=>e.replace(/\.d\.ts$/,"")),(e=>"/index.tsx"!==e&&"index.tsx"!==e?e.replace(/\.tsx$/,""):e),(e=>e.replace(/\.ts$/,""))),t.fpRefinePathSep=e=>(0,a.pipe)(e,(e=>"/"!==c.sep?i.left(e):i.right(e)),i.fold((e=>e.replace(new RegExp(c.sep.replace("\\","\\\\"),"g"),"/")),(e=>e))),t.fpRefineStartSlash=e=>(0,a.pipe)(e,(e=>e.startsWith("/")?i.left(e):i.right(e)),i.fold((e=>e.substring(1,e.length)),(e=>e))),t.fpAddDotPath=e=>(0,a.pipe)(e,(e=>e.startsWith(".")?i.left(e):i.right(e)),i.fold((e=>e),(e=>`./${e}`))),t.fpTimes=(e,t=!0)=>(0,a.pipe)(e,(e=>new Array(e).fill(0)),(e=>e.map(((e,r)=>r+(t?0:1))))),t.fpRemoveLastPathSep=e=>(0,a.pipe)(e,(e=>e.endsWith(c.sep)?i.left(e):i.right(e)),i.fold((e=>e.substring(0,e.length-1>0?e.length-1:e.length)),(e=>e))),t.fpRemoveDrivePath=e=>(0,a.pipe)(e,(e=>e.replace(/^([A-Za-z]:)(.+)/,"$2"))),t.fpRemoveFirstPathSep=e=>(0,a.pipe)(e,(e=>e.startsWith(c.sep)?i.left(e):i.right(e)),i.fold((e=>e.substring(e.length-1>0?1:0,e.length)),(e=>e))),t.fpReplaceCwd=(e,r)=>(0,a.pipe)(e,(e=>(0,t.fpRemoveLastPathSep)(e)),(e=>e===(0,t.fpRemoveLastPathSep)(r)?i.left(e):i.right(e)),i.fold((()=>""),(0,a.flow)((e=>e.endsWith(c.sep)?i.left(e):i.right(e)),i.fold((e=>e),(e=>`${e}${c.sep}`)),(e=>r.replace(e,"")),(e=>(0,t.fpRemoveDrivePath)(e))))),t.fpGetDirDepth=(e,r)=>(0,a.pipe)(e,(e=>(0,t.fpReplaceCwd)(e,r)),(e=>e.split(c.sep)),(e=>e.filter((e=>""!==e))),(e=>e.length)),t.getParentPath=e=>(0,a.pipe)(e,(e=>e.split(c.sep)),(e=>e.slice(0,e.length-1)),(e=>e.join(c.sep)),(e=>c.resolve(e)))},395:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getTypeScriptExportStatement=t.getTypeScriptSource=t.getTypeScriptConfig=void 0;const o=r(655),n=o.__importDefault(r(974)),i=o.__importStar(r(431)),a=o.__importStar(r(686)),l=r(352),s=o.__importDefault(r(17)),c=o.__importDefault(r(7)),p=r(734),u=r(887),f=(0,n.default)("ctix:tsfiles"),d=({cliPath:e,tsconfigResolved:t,tsconfigInCliPath:r})=>async()=>await(0,p.exists)(t)?i.right(t):await(0,p.exists)(r)?i.right(s.default.join(e,t)):i.left(new Error(`Cannot found ${t} in ${process.cwd()} or ${e}`));t.getTypeScriptConfig=({tsconfigPath:e})=>async()=>{try{const t=process.cwd(),r=s.default.join(t,"tsconfig.json"),o=(0,l.isNotEmpty)(e)?s.default.resolve(e):s.default.resolve(r),n=await a.flow((()=>({cliPath:t,tsconfigInCliPath:r,tsconfigResolved:o})),d)()();if(i.isLeft(n))return i.left(new Error(`Cannot found ${o} in ${t} or ${t}`));const p={fileExists:c.default.sys.fileExists,readFile:c.default.sys.readFile,readDirectory:c.default.sys.readDirectory,useCaseSensitiveFileNames:!0},u=c.default.readConfigFile(n.right,c.default.sys.readFile),m=c.default.parseJsonConfigFileContent(u.config,p,s.default.dirname(n.right));return f("tsconfig filenames: ",m.fileNames),i.right(m)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return i.left(t)}},t.getTypeScriptSource=({tsconfig:e,ignores:t})=>async()=>{try{const r=new Map(t.map((e=>s.default.resolve(e))).map((e=>[e,!0]))),o=e.fileNames.map((e=>s.default.resolve(e))).filter((e=>{var t;return(0,l.isFalse)(null!==(t=r.get(e))&&void 0!==t&&t)}));f("typescript configed files: ",e.fileNames),f("typescript process ignored files: ",o);const n=c.default.createProgram(o,e.options);return(0,l.isEmpty)(n)?i.left(new Error("invalid source file")):i.right({program:n,filenames:o})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return i.left(t)}},t.getTypeScriptExportStatement=async function({program:e,filenames:t}){try{const r=new Map(t.map((e=>[(0,p.replaceSepToPosix)(e),!0]))),o=await Promise.all(e.getSourceFiles().filter((e=>{var t;return null!==(t=r.get(e.fileName))&&void 0!==t&&t})).map((e=>e.statements.map((t=>(0,u.delintNode)({filename:e.fileName,source:t}))))).flatMap((e=>e))),n=o.map((e=>e.export.map((t=>({filename:e.filename,exported:t}))))).flatMap((e=>e)).map((e=>e.filename)).filter((e=>(0,l.isNotEmpty)(e))).map((e=>(0,p.winify)(e))),a=new Set(n),s=Array.from(a).sort(((e,t)=>e.localeCompare(t))),c=o.map((e=>e.default.map((t=>({filename:e.filename,defaulted:t}))))).flatMap((e=>e)).map((e=>e.filename)).map((e=>(0,p.winify)(e))),d=new Set(c),m=Array.from(d).sort(((e,t)=>e.localeCompare(t)));return f("file-1: ",e.getSourceFiles().map((e=>e.fileName)).filter((e=>e.indexOf("node_modules")<0))),f("file-2: ",t),f("export file: ",n," default file: ",c),i.right({program:e,exportFilenames:s,defaultExportFilenames:m})}catch(e){return i.left(e)}}},887:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.delintNode=t.hasExportModifiers=void 0;const o=r(655),n=o.__importDefault(r(974)),i=o.__importStar(r(397)),a=r(281),l=r(352),s=o.__importDefault(r(7)),c=(0,n.default)("ctixd:ignore-tool");t.hasExportModifiers=e=>(0,a.pipe)(e,(e=>e.modifiers),(e=>(0,l.isEmpty)(e)?i.left("none"):i.right(e)),i.fold((e=>e),(e=>{var t,r;const o=null!==(t=e.some((e=>e.kind===s.default.SyntaxKind.ExportKeyword)))&&void 0!==t&&t,n=null!==(r=null==e?void 0:e.some((e=>e.kind===s.default.SyntaxKind.DefaultKeyword)))&&void 0!==r&&r;return o&&n?"default":o&&(0,l.isFalse)(n)?"exported":"none"}))),t.delintNode=async function({source:e,filename:r}){const o=[],n=[];c("delintNode: ",r);let i="";const a=e=>{switch(e.kind){case s.default.SyntaxKind.VariableStatement:case s.default.SyntaxKind.InterfaceDeclaration:case s.default.SyntaxKind.TypeAliasDeclaration:case s.default.SyntaxKind.FunctionDeclaration:case s.default.SyntaxKind.ClassDeclaration:case s.default.SyntaxKind.EnumDeclaration:i=(0,t.hasExportModifiers)(e),"default"===i&&n.push(e),"exported"===i&&o.push(e);break;case s.default.SyntaxKind.ExportAssignment:n.push(e)}s.default.forEachChild(e,a)};return a(e),{filename:r,export:o,default:n}}},453:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.write=t.getSingleFileWriteContents=t.getWriteContents=t.getModuleDir=void 0;const o=r(655),n=r(734),i=r(110),a=o.__importDefault(r(635)),l=o.__importDefault(r(974)),s=o.__importStar(r(431)),c=o.__importStar(r(686)),p=o.__importStar(r(972)),u=o.__importStar(r(147)),f=r(352),d=o.__importStar(r(17)),m=r(309),g=r(138),h=(0,l.default)("ctix:write");async function y({filename:e,replacer:t,configMap:r}){var o;const i=d.dirname(e);h("createExportContents: ",i);try{const a=r.get(i),l=null!==(o=null==a?void 0:a.option.quote)&&void 0!==o?o:"'",s=t({dirname:i,filename:e}),p=`export * from ${l}${c.flow(n.fpRefinePathSep,n.fpRemoveExt,n.fpRefineStartSlash,n.fpAddDotPath)(s)}${l}`;return{dirname:await(0,n.getDirname)(e),content:p}}catch(t){const r=t instanceof Error?t:new Error("unknown error raised");return h(r.message),h(r.stack),{dirname:d.dirname(e),content:void 0}}}async function v({filename:e,replacer:t,configMap:r}){var o;const a=d.dirname(e);try{const s=r.get(a),p=null!==(o=null==s?void 0:s.option.quote)&&void 0!==o?o:"'",u=t({dirname:a,filename:e}),g=c.flow(n.fpRefinePathSep,n.fpRemoveExt,n.fpRefineStartSlash,n.fpAddDotPath)(u),h=(null==s?void 0:s.option.excludePath)?c.flow((e=>d.basename(e)),n.fpRemoveExtWithTSX)(u):c.flow(n.fpRefinePathSep,n.fpRemoveExtWithTSX)(u),y=`export { default as ${(null==(l=null==s?void 0:s.option)||(0,f.isFalse)(l.excludePath)||(0,f.isFalse)(l.useUpperFirst)?i.camelCase:e=>/^[A-Z]\w+/.test(e)?(0,m.upperCaseFirst)((0,i.camelCase)(e)):(0,i.camelCase)(e))(h)} } from ${p}${g}${p}`;return{dirname:await(0,n.getDirname)(e),content:y}}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return h(t.message),h(t.stack),{dirname:a,content:void 0}}var l}function w({project:e,configMap:t,filenames:r}){const o=r.map((t=>{const r=d.dirname(t);return{depth:r.replace(e,"").split(d.sep).length-1,dirname:r,filename:t}})).sort(((e,t)=>{const r=t.depth-e.depth;return 0===r?t.filename.localeCompare(e.filename):r})),[i]=o,a=i.depth;h("dirs: ",a,o);const l=(0,n.fpTimes)(a).map((e=>{const r=o.filter((t=>t.depth===e));return h("current depth: ",e),r.map((r=>{var i,a;const l=o.filter((t=>t.dirname.indexOf(r.dirname)>=0&&t.dirname!==r.dirname&&t.depth-e==1)),s=t.get(r.dirname),p=null!==(i=null==s?void 0:s.option)&&void 0!==i?i:(0,g.defaultOption)(),u=null!==(a=null==s?void 0:s.option.quote)&&void 0!==a?a:"'",f=(0,n.settify)(l.map((e=>d.dirname(e.filename))));if("index.ts"===p.exportFilename||"index.d.ts"===p.exportFilename){const e=f.map((e=>{const t=c.flow(n.fpRefinePathSep,n.fpRemoveExt,n.fpRefineStartSlash)(e.replace(r.dirname,""));return`export * from ${u}./${t}${u}`}));return{dirname:r.dirname,content:e}}const m=f.map((e=>{const t=c.flow(n.fpRefinePathSep,n.fpRemoveExt,n.fpRefineStartSlash)(d.join(e.replace(r.dirname,""),p.exportFilename));return`export * from ${u}./${t}${u}`}));return{dirname:r.dirname,content:m}}))})).flatMap((e=>e)),s=new Map(l.map((e=>[e.dirname,e.content]))),p=Array.from(s.entries()).map((([e,t])=>({dirname:e,content:t}))).filter((e=>Array.isArray(e.content)&&e.content.length>0));return h("module directory: ",p),p.map((e=>e.content.map((t=>({dirname:e.dirname,content:t}))))).flatMap((e=>e))}t.getModuleDir=w,t.getWriteContents=async function(e){try{const t=new Map(e.optionObjects.map((e=>[e.dir,e]))),[r]=e.optionObjects,o=d.resolve(d.dirname(r.option.project));h("exportFilenames: ",e.exportFilenames),h("defaultExportFilenames: ",e.defaultExportFilenames);const n=e=>d.relative(e.dirname,e.filename),i=(await Promise.all(e.exportFilenames.map((e=>y({filename:e,configMap:t,replacer:n}))))).filter((e=>(0,f.isNotEmpty)(e.content))),a=(await Promise.all(e.defaultExportFilenames.map((e=>v({filename:e,configMap:t,replacer:n}))))).filter((e=>(0,f.isNotEmpty)(e.content))),l=w({project:o,configMap:t,filenames:e.exportFilenames.concat(e.defaultExportFilenames)}),c=i.concat(a).concat(l).reduce(((e,t)=>{const r=e;return(0,f.isEmpty)(e[t.dirname])&&(r[t.dirname]=[]),(0,f.isNotEmpty)(t.content)&&(r[t.dirname]=[...r[t.dirname],t.content]),r}),{}),p=Object.entries(c).map((([e,t])=>({pathname:e,content:t}))).sort(((e,t)=>e.pathname.localeCompare(t.pathname)));return s.right(p)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return s.left(t)}},t.getSingleFileWriteContents=async function(e){try{const t=new Map(e.optionObjects.map((e=>[e.dir,e])));h("exportFilenames: ",e.exportFilenames),h("defaultExportFilenames: ",e.defaultExportFilenames);const r=await(async(e,t)=>{if((0,f.isFalse)(t.useRootDir))return d.resolve(await(0,n.getDirname)(t.output));const r=(e=>{if(void 0!==e.rootDir&&null!==e.rootDir)return d.resolve(e.rootDir);if(void 0!==e.rootDirs&&null!==e.rootDirs){const[t]=e.rootDirs;return d.resolve(t)}})(e.getCompilerOptions());if(null!=r){const e=await(0,n.getDirname)(t.output);return d.relative(r,e).startsWith("..")?r:d.resolve(e)}return d.resolve(await(0,n.getDirname)(t.output))})(e.program,e.rootOptions),o=e=>d.relative(r,e.filename),i=(await Promise.all(e.exportFilenames.map((e=>y({filename:e,configMap:t,replacer:o}))))).filter((e=>(0,f.isNotEmpty)(e.content))),a=(await Promise.all(e.defaultExportFilenames.map((e=>v({filename:e,configMap:t,replacer:o}))))).filter((e=>(0,f.isNotEmpty)(e.content))),l=i.concat(a).reduce(((e,t)=>{const o=e;return(0,f.isEmpty)(o[r])&&(o[r]=[]),(0,f.isNotEmpty)(t.content)&&(o[r]=[...o[r],t.content]),o}),{}),c=Object.entries(l).map((([e,t])=>({pathname:e,content:t})));return s.right(c)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return s.left(t)}},t.write=async function(e){try{const t=new Map(e.optionObjects.map((e=>[e.dir,e]))),r=async e=>{var r;h("current: ",e.pathname);const o=null!==(r=t.get(e.pathname))&&void 0!==r?r:{dir:e.pathname,depth:0,exists:!1,option:(0,g.defaultOption)()},i=o.option.exportFilename,l=d.resolve(e.pathname,i),m=d.resolve(e.pathname,`${i}.bak`);if((0,f.isTrue)(o.option.useBackupFile)&&await(0,n.exists)(l)){const e=await c.pipe(p.taskify(u.readFile)(l),p.chain((e=>p.taskify(u.writeFile)(m,e))))();if(s.isLeft(e))return h("error caused from backup write, ..."),h(e.left.message),h(e.left.stack),s.left(e.left)}const y=(0,a.default)(),v=c.pipe(o.option.useComment?"// created from ctix":"",(e=>o.option.useComment&&o.option.useTimestamp?`${e} ${y.format("YYYY-MM-DD HH:mm:ss")}`:e),(e=>""!==e?`${e}\n\n`:e)),w=Buffer.from(`${v}${e.content.map((e=>o.option.useSemicolon?`${e};`:e)).join("\n")}${o.option.addNewline?"\n":""}`,"utf8"),x=await p.taskify(u.writeFile)(l,w)();return s.isLeft(x)?(h(`error caused from ${i} write, ...`),h(x.left.message),h(x.left.stack),s.left(x.left)):s.right(1)},o=(await Promise.all(e.contents.map((e=>r(e))))).map((e=>s.isRight(e)?1:0)).reduce(((e,t)=>e+t));return h("successfully writed index: ",o),s.right(o)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");return s.left(t)}}},655:(e,t,r)=>{r.r(t),r.d(t,{__extends:()=>n,__assign:()=>i,__rest:()=>a,__decorate:()=>l,__param:()=>s,__metadata:()=>c,__awaiter:()=>p,__generator:()=>u,__createBinding:()=>f,__exportStar:()=>d,__values:()=>m,__read:()=>g,__spread:()=>h,__spreadArrays:()=>y,__spreadArray:()=>v,__await:()=>w,__asyncGenerator:()=>x,__asyncDelegator:()=>b,__asyncValues:()=>_,__makeTemplateObject:()=>S,__importStar:()=>E,__importDefault:()=>j,__classPrivateFieldGet:()=>F,__classPrivateFieldSet:()=>O});var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},o(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return i=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};function a(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}function l(e,t,r,o){var n,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var l=e.length-1;l>=0;l--)(n=e[l])&&(a=(i<3?n(a):i>3?n(t,r,a):n(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function s(e,t){return function(r,o){t(r,o,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,r,o){return new(r||(r=Promise))((function(n,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function l(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))}function u(e,t){var r,o,n,i,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,o&&(n=2&i[0]?o.return:i[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;switch(o=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){a.label=i[1];break}if(6===i[0]&&a.label<n[1]){a.label=n[1],n=i;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(i);break}n[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{r=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}var f=Object.create?function(e,t,r,o){void 0===o&&(o=r),Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]};function d(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||f(t,e,r)}function m(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return a}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function y(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var o=Array(e),n=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,l=i.length;a<l;a++,n++)o[n]=i[a];return o}function v(e,t,r){if(r||2===arguments.length)for(var o,n=0,i=t.length;n<i;n++)!o&&n in t||(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}function w(e){return this instanceof w?(this.v=e,this):new w(e)}function x(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,n=r.apply(e,t||[]),i=[];return o={},a("next"),a("throw"),a("return"),o[Symbol.asyncIterator]=function(){return this},o;function a(e){n[e]&&(o[e]=function(t){return new Promise((function(r,o){i.push([e,t,r,o])>1||l(e,t)}))})}function l(e,t){try{(r=n[e](t)).value instanceof w?Promise.resolve(r.value.v).then(s,c):p(i[0][2],r)}catch(e){p(i[0][3],e)}var r}function s(e){l("next",e)}function c(e){l("throw",e)}function p(e,t){e(t),i.shift(),i.length&&l(i[0][0],i[0][1])}}function b(e){var t,r;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,n){t[o]=e[o]?function(t){return(r=!r)?{value:w(e[o](t)),done:"return"===o}:n?n(t):t}:n}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=m(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(r){t[r]=e[r]&&function(t){return new Promise((function(o,n){!function(e,t,r,o){Promise.resolve(o).then((function(t){e({value:t,done:r})}),t)}(o,n,(t=e[r](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var P=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function E(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&f(t,e,r);return P(t,e),t}function j(e){return e&&e.__esModule?e:{default:e}}function F(e,t,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(e):o?o.value:t.get(e)}function O(e,t,r,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,r):n?n.value=r:t.set(e,r),r}},351:e=>{e.exports=require("@oclif/core")},22:e=>{e.exports=require("chalk")},110:e=>{e.exports=require("change-case")},635:e=>{e.exports=require("dayjs")},974:e=>{e.exports=require("debug")},330:e=>{e.exports=require("deepmerge")},479:e=>{e.exports=require("fast-glob")},819:e=>{e.exports=require("fp-ts/Apply")},431:e=>{e.exports=require("fp-ts/Either")},972:e=>{e.exports=require("fp-ts/TaskEither")},686:e=>{e.exports=require("fp-ts/function")},397:e=>{e.exports=require("fp-ts/lib/Either")},281:e=>{e.exports=require("fp-ts/lib/pipeable")},959:e=>{e.exports=require("json5")},352:e=>{e.exports=require("my-easy-fp")},837:e=>{e.exports=require("parse-gitignore")},261:e=>{e.exports=require("source-map-support")},7:e=>{e.exports=require("typescript")},309:e=>{e.exports=require("upper-case-first")},392:e=>{e.exports=require("yargs")},147:e=>{e.exports=require("fs")},17:e=>{e.exports=require("path")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{var e=o;Object.defineProperty(e,"__esModule",{value:!0});const t=r(655),n=r(930),i=r(181),a=r(138),l=r(981),s=t.__importDefault(r(900)),c=r(734),p=r(395),u=r(453),f=t.__importDefault(r(22)),d=r(351),m=t.__importDefault(r(974)),g=t.__importStar(r(819)),h=t.__importStar(r(431)),y=t.__importStar(r(686)),v=t.__importStar(r(972)),w=t.__importStar(r(147)),x=t.__importStar(r(17)),b=t.__importDefault(r(261)),_=t.__importDefault(r(392)),S=(0,m.default)("ctix:cli-tool");function P(e){return e.option("addNewline",{alias:"n",describe:"add newline on EOF",type:"boolean"}).option("useSemicolon",{alias:"s",describe:"add semicolon on every export statement",type:"boolean"}).option("useTimestamp",{alias:"m",describe:"timestamp write on ctix comment right-side, only works in useComment option set true",type:"boolean"}).option("useComment",{alias:"c",describe:"add ctix comment at first line of creted index.ts file, that remark created from ctix",type:"boolean"}).option("quote",{alias:"q",describe:"change quote character at export syntax",type:"string"}).option("excludePath",{alias:"x",describe:"exclude path in default export variable(or function)",type:"boolean",default:!1}).option("useUpperFirst",{describe:"Default export variable, class, function name keep first capital character.",type:"boolean",default:!0}).option("useBackupFile",{alias:"b",describe:"created backup file if exists index.ts file already in directory",type:"boolean"}),e}async function E(e,t){if(void 0===e&&void 0===t)throw new Error(`invalid project path, don't exist: "${e}" or "${null!=t?t:""}"`);const r=null!=t?t:"";if(await(0,c.exists)(r))return x.resolve(r);const o=x.join(r,"tsconfig.json");if(await(0,c.exists)(o))return x.resolve(o);if(void 0===e)throw new Error(`invalid project path, don't exist: "${e}" or "${null!=t?t:""}"`);if(await(0,c.exists)(e))return x.resolve(e);const n=x.join(e,"tsconfig.json");if(await(0,c.exists)(n))return x.resolve(n);throw new Error(`invalid project path, don't exist: ${e} or ${null!=t?t:""}`)}b.default.install(),(0,_.default)(process.argv.slice(2)).command({command:"$0 [tsconfigPath]",aliases:"create [tsconfigPath]",builder:e=>P(e),handler:async e=>{var t,r,o,n;s.default.switch(null!==(t=e.verbose)&&void 0!==t&&t);const m=new i.Counter(null!==(r=e.verbose)&&void 0!==r&&r);try{const t=await E(e.tsconfigPath,e.project),r=x.resolve(t),i=await(0,c.getDirname)(r,!0);process.chdir(i),d.CliUx.ux.action.start(f.default`{yellow ctix} ${null!==(o=e.exportFilename)&&void 0!==o?o:"index.ts"} file create mode:`,"initializing",{stdout:!0});const w={...(0,a.getNonEmptyOption)(e,t),resolvedProjectDirPath:i,resolvedProjectFilePath:r};s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} project directory: ${t}`),s.default.log(f.default`{yellow ctix - ${m.log}:} read ignore file, tsconfig file, cti config {green complete}`),d.CliUx.ux.action.status="processing ...";const b=await g.sequenceT(v.ApplicativeSeq)(y.pipe((0,l.getIgnoreFiles)(i),v.chain(l.getIgnoreFileContents),v.chain(l.getIgnoredContents)),(0,p.getTypeScriptConfig)({tsconfigPath:r}),y.pipe((0,a.getCTIXOptions)({projectPath:r}),v.chain((e=>(0,a.getMergedConfig)({projectPath:r,optionObjects:e,cliOption:w})))))();if(h.isLeft(b))throw b.left;const[_,S,P]=b.right;s.default.log(f.default`{yellow ctix - ${m.log}:} typescript source file parsing {green compile} `),d.CliUx.ux.action.status="processing ...",s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} ignore content - ${_.ignores.length}`),s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} typescript file - ${S.fileNames.length}`),s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} config file - ${P.length}`);const j=await y.pipe(v.right({tsconfig:S,ignores:_.ignores}),v.chain(p.getTypeScriptSource),v.chain((e=>()=>(0,p.getTypeScriptExportStatement)({program:e.program,filenames:e.filenames}))))();if(h.isLeft(j))throw j.left;s.default.log(f.default`{yellow ctix - ${m.log}:} ${null!==(n=e.exportFilename)&&void 0!==n?n:"index.ts"} write on project directory {green compile}`);const F=await(0,u.getWriteContents)({...j.right,optionObjects:P});if(h.isLeft(F))throw F.left;await(0,u.write)({contents:F.right,optionObjects:P})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");s.default.error(f.default`{red error} message below, `),s.default.error(t.message)}finally{d.CliUx.ux.action.stop("complete")}}}).command({command:"single [tsconfigPath]",aliases:["entrypoint [tsconfigPath]"],builder:e=>{const t=P(e);return t.option("useRootDir",{alias:"r",describe:"output file under rootDir in tsconfig.json",type:"boolean"}).option("output",{alias:"o",describe:"output directory",type:"string"}),t},handler:async e=>{var t,r,o,n;s.default.switch(null!==(t=e.verbose)&&void 0!==t&&t);const m=new i.Counter(null!==(r=e.verbose)&&void 0!==r&&r);try{const t=await E(e.tsconfigPath,e.project),r=x.resolve(t),i=await(0,c.getDirname)(r,!0);process.chdir(i),d.CliUx.ux.action.start(f.default`{yellow ctix} single ${null!==(o=e.exportFilename)&&void 0!==o?o:"index.ts"} file create mode:`,"initializing",{stdout:!0});const w={...(0,a.getNonEmptyOption)(e,t),resolvedProjectDirPath:i,resolvedProjectFilePath:r};s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} project directory: ${t}`),s.default.log(f.default`{yellow ctix - ${m.log}:} read ignore file, tsconfig file, cti config {green complete}`),d.CliUx.ux.action.status="processing ...";const b=await g.sequenceT(v.ApplicativeSeq)(y.pipe((0,l.getIgnoreFiles)(i),v.chain(l.getIgnoreFileContents),v.chain(l.getIgnoredContents)),(0,p.getTypeScriptConfig)({tsconfigPath:t}),y.pipe((0,a.getCTIXOptions)({projectPath:r}),v.chain((e=>(0,a.getMergedConfig)({projectPath:r,optionObjects:e,cliOption:w})))))();if(h.isLeft(b))throw b.left;const[_,S,P]=b.right;s.default.log(f.default`{yellow ctix - ${m.log}:} typescript source file parsing {green compile} `),d.CliUx.ux.action.status="processing ...",s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} ignore content - ${_.ignores.length}`),s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} typescript file - ${S.fileNames.length}`),s.default.debug(f.default`{yellow ctix - ${m.debug}:} {blueBright [info]} config file - ${P.length}`);const j=await y.pipe(v.right({tsconfig:S,ignores:_.ignores}),v.chain(p.getTypeScriptSource),v.chain((e=>()=>(0,p.getTypeScriptExportStatement)({program:e.program,filenames:e.filenames}))))();if(h.isLeft(j))throw j.left;s.default.log(f.default`{yellow ctix - ${m.log}:} ${null!==(n=e.exportFilename)&&void 0!==n?n:"index.ts"} write on project directory {green compile}`);const F=await(0,u.getSingleFileWriteContents)({...j.right,optionObjects:P,rootOptions:w});if(h.isLeft(F))throw F.left;await(0,u.write)({contents:F.right,optionObjects:P})}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");s.default.error(f.default`{red error} message below, `),s.default.error(t.message)}finally{d.CliUx.ux.action.stop("complete")}}}).command({command:"clean [tsconfigPath]",builder:e=>(e.option("includeBackup",{alias:"b",describe:"clean with backup file",default:!1,type:"boolean"}),e),handler:async e=>{var t,r,o;const l=new i.Counter(null!==(t=e.verbose)&&void 0!==t&&t);s.default.switch(null!==(r=e.verbose)&&void 0!==r&&r);try{const t=await E(e.tsconfigPath,e.project),r=x.resolve(t),i=await(0,c.getDirname)(r,!0);process.chdir(i),S("path.resolve in ctix.ts: ",x.resolve(t)),d.CliUx.ux.action.start(f.default`{yellow ctix} ${null!==(o=e.exportFilename)&&void 0!==o?o:"index.ts"} file clean mode:`,"initializing",{stdout:!0});const p={...(0,a.getNonEmptyOption)(e,t),resolvedProjectDirPath:i,resolvedProjectFilePath:r};S("clean option: ",p);const u=await y.pipe((0,n.getCleanFilenames)({cliOption:p,includeBackupFrom:e.includeBackup}),v.chain((e=>()=>(s.default.log(f.default`{yellow ctix - ${l.log}:} clean file find {green complete}`),s.default.debug(f.default`{yellow ctix - ${l.debug}:} {blueBright [info]} clean file - ${e.length}`),(0,n.clean)({filenames:e})))))();if(h.isLeft(u))throw u.left;s.default.log(f.default`{yellow ctix - ${l.log}:} clean action {green complete}`)}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");s.default.error(f.default`{red error} message below, `),s.default.error(t.message)}finally{d.CliUx.ux.action.stop("complete")}}}).command({command:"init [tsconfigPath]",builder:e=>e,handler:async e=>{var t,r;const o=new i.Counter(null!==(t=e.verbose)&&void 0!==t&&t);s.default.switch(null!==(r=e.verbose)&&void 0!==r&&r);try{const t=await E(e.tsconfigPath,e.project);d.CliUx.ux.action.start(f.default`{yellow ctix} generate .ctirc:`,"initializing",{stdout:!0}),s.default.log(f.default`{yellow ctix - ${o.log}:} default option generation {green compile} `),d.CliUx.ux.action.status="processing ...";const r={...(0,a.defaultOption)()};delete r.project,delete r.verbose;const n=x.dirname(t);await w.promises.writeFile(x.join(n,".ctirc"),JSON.stringify(r)),s.default.log(f.default`{yellow ctix - ${o.log}:} .ctirc file write {green compile} `),d.CliUx.ux.action.status="processing ..."}catch(e){const t=e instanceof Error?e:new Error("unknown error raised");s.default.error(f.default`{red error} message below, `),s.default.error(t.message)}finally{d.CliUx.ux.action.stop("complete")}}}).option("project",{alias:"p",describe:'tsconfig.json path: you must pass path with filename, like this "./tsconfig.json"',type:"string"}).option("exportFilename",{alias:"f",describe:'Export filename, if you not pass this field that use "index.ts" or "index.d.ts"',type:"string"}).option("verbose",{alias:"v",describe:"display more detailed log",type:"boolean"}).help().argv})();var n=exports;for(var i in o)n[i]=o[i];o.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();

@@ -11,3 +11,3 @@ export interface ICTIXOptions {

exportFilename: string;
outputDir: string;
output: string;
useRootDir: boolean;

@@ -14,0 +14,0 @@ excludePath: boolean;

{
"name": "ctix",
"version": "0.5.1",
"version": "0.5.2",
"description": "Automatic create index.ts file",

@@ -5,0 +5,0 @@ "main": "dist/cti.js",

@@ -103,3 +103,3 @@ ctix - Next generation Create TypeScript Index file

| --quote | -q | ' | create, single | change quote character at export syntax |
| --outputDir | -q | ' | create, single | change quote character at export syntax |
| --output | -o | N/A | single | output directory |
| --useBackupFile | -b | true | create, single | created backup file if exists export file(default index.ts) file already in directory |

@@ -106,0 +106,0 @@ | --useRootDir | -r | false | single | output file under rootDir in tsconfig.json. |

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc