{"id":13683390,"url":"https://github.com/imjuni/create-ts-index","last_synced_at":"2025-04-06T01:08:49.547Z","repository":{"id":26867472,"uuid":"110700938","full_name":"imjuni/create-ts-index","owner":"imjuni","description":"Automatic create index file for TypeScript","archived":false,"fork":false,"pushed_at":"2023-03-14T18:17:27.000Z","size":1541,"stargazers_count":110,"open_issues_count":6,"forks_count":19,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-30T00:37:04.200Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imjuni.png","metadata":{"files":{"readme":"README.ko.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-14T14:30:44.000Z","updated_at":"2024-08-05T18:46:59.000Z","dependencies_parsed_at":"2024-08-02T13:23:58.745Z","dependency_job_id":"b9fa700d-cf4a-40b9-9145-57987a9c1ee6","html_url":"https://github.com/imjuni/create-ts-index","commit_stats":{"total_commits":75,"total_committers":7,"mean_commits":"10.714285714285714","dds":0.2533333333333333,"last_synced_commit":"aa0b2433fdfaae02e5f52fb2152af6e27d8e6fae"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fcreate-ts-index","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fcreate-ts-index/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fcreate-ts-index/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fcreate-ts-index/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imjuni","download_url":"https://codeload.github.com/imjuni/create-ts-index/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419860,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:02:09.580Z","updated_at":"2025-04-06T01:08:49.503Z","avatar_url":"https://github.com/imjuni.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"create-ts-index\n----\n[![Download Status](https://img.shields.io/npm/dw/create-ts-index.svg)](https://npmcharts.com/compare/create-ts-index?minimal=true) [![Github Star](https://img.shields.io/github/stars/imjuni/create-ts-index.svg?style=popout)](https://github.com/imjuni/create-ts-index) [![Github Issues](https://img.shields.io/github/issues-raw/imjuni/create-ts-index.svg)](https://github.com/imjuni/create-ts-index/issues) [![NPM version](https://img.shields.io/npm/v/create-ts-index.svg)](https://www.npmjs.com/package/create-ts-index) [![License](https://img.shields.io/npm/l/create-ts-index.svg)](https://github.com/imjuni/create-ts-index/blob/master/LICENSE) [![cti](https://circleci.com/gh/imjuni/create-ts-index.svg?style=shield)](https://app.circleci.com/pipelines/github/imjuni/create-ts-index?branch=master)\n\n# 설치\n```\nnpm install create-ts-index --save-dev\n```\n\n# 소개\nTypeScript 프로젝트를 개발할 때 export를 위한 index.ts 파일을 생성합니다. index.ts 파일을 export 용도로만 사용하거나 라이브러리 프로젝트를 개발할 때 유용합니다. 예를들면 [blueprint.js](http://blueprintjs.com/)와 같은 라이브러리 프로젝트를 개발한다면 컴포넌트를 다른 프로젝트에서 사용할 수 있도록 모든 파일을 export 해야 합니다. 이런 경우 create-ts-index를 아주 유용하게 사용할 수 있습니다. 라이브러리 프로젝트가 아니라도, create-ts-index를 사용해서 export 용 index.ts 파일을 사용한다면 import 구문을 간단하게 만들 수 있고 협업할 때 import 형식에 대한 고민을 줄일 수 있어서 유용합니다.\n\n예를들어, 아래와 같은 디렉터리가 있다고 가정합시다.\n\n```\n  src/\n    app.ts\n    component/\n      Nav.ts\n      Button.ts\n```\n\ncreate-ts-index create sub-command는 아래와 같이 export index.ts 파일을 생성합니다.\n\n```\n  src/\n    app.ts\n    \u003e index.ts\n      // created from 'create-ts-index'\n      export * from './component';\n      export * from './app';\n    component/\n      Nav.ts\n      Button.ts\n      \u003e index.ts\n        // created from 'create-ts-index'\n        export * from './Nav';\n        export * from './Button';\n```\n\n만약 create-ts-index entrypoint sub-command를 사용하면 아래와 같이 동작합니다.\n\n```\n  src/\n    app.ts\n    component/\n      Nav.ts\n      Button.ts\n  \u003e entrypoint.ts\n    // created from 'create-ts-index'\n    export * from './src/app.ts'\n    export * from './src/component/Nav.ts'\n    export * from './src/component/Button.ts'\n```\n\nindex.ts 파일을 webpack entrypoint로 사용할 수 있습니다.\n\n# 옵션\n## 라이브러리로 사용할 경우\n* `fileFirst: boolean` 생성되는 export 파일내용에서 파일이름을 먼저 export 할지 디렉터리 이름을 먼저 export 할지 결정합니다. 기본 값은 `false` 입니다.\n* `addNewline: boolean` 파일 마지막에 줄바꿈 문자를 추가할지 말지를 결정합니다. 기본 값은 `true` 입니다.\n* `useSemicolon: boolean` 줄 마지막에 `;` 문자를 추가할지 말지를 결정합니다. 기본 값은 `true` 입니다.\n* `useTimestamp: boolean` 파일 처음에 주석을 작성할 때 시간(YYYY-MM-DD HH:mm 형식)을 추가할지 말지를 결정합니다. 기본 값은 `false` 입니다.\n* `includeCWD: boolean` 작업디렉터리로 전달된 cwd에 대해서 index.ts 파일을 생성할 것인지에 대해서 결정합니다. 기본 값은 `true` 입니다.\n* `excludes: string[]` 제외할 디렉터리를 전달합니다. 기본 값은 `['@types', 'typings', '__test__', '__tests__']` 입니다.\n* `fileExcludePatterns: string[]` 제외할 파일이름 패턴을 전달합니다. 기본 값은 `[]` 입니다. 전달된 패턴은 indexOf 함수를 사용하여 파일이름에서 검색되며 indexOf 함수 결과가 0 이상인 경우 제외됩니다.\n* `targetExts: string[]` export 구문을 생성할 때 사용할 확장자명을 전달합니다. 기본 값은 `['ts', 'tsx']` 입니다. 확장자명을 전달할 때는 예와같이 점 문자를 제외하고 전달해야합니다.\n* `globOptions: glob.IOptions` [node-glob](https://github.com/isaacs/node-glob) 옵션 값을 전달할 수 있습니다. 자세한 내용은 링크문서를 참고하세요.\n* `quote` export 구문에서 사용할 따옴표 문자를 전달합니다. 기본 값은 홑따옴표 입니다.\n* `verbose` 실행할 때 더 많은 로그 메시지를 출력합니다.\n* `withoutComment` index.ts 파일 또는 entrypoint.ts 파일 맨 윗줄에 추가되는 주석을 제거합니다.\n* `withoutBackupFile` index.ts 파일 또는 entrypoint.ts 파일을 생성할 때 이미 파일이 있는 경우 백업 파일을 생성하는 기능을 사용하지 않습니다.\n* `output` index.ts 파일 또는 entrypoint.ts 파일 이름의 이름을 변경합니다.\n\n## CLI(command-line interface)로 사용할 경우\n* `-f --filefirst` 생성되는 export 파일내용에서 파일이름을 먼저 export 할지 디렉터리 이름을 먼저 export 할지 결정합니다. 옵션을 생략하면 `false`, 전달하면 `true` 이며, 기본 값은 false 입니다.\n* `-n --addnewline` 파일 마지막에 줄바꿈 문자를 추가할지 말지를 결정합니다. 옵션을 생략하면 `true`, 전달하면 `false` 입니다.\n* `-s --usesemicolon` 줄 마지막에 `;` 문자를 추가할지 말지를 결정합니다. 옵션을 생략하면 `true`, 전달하면 `false` 입니다.\n* `-t --usetimestamp` 파일 처음에 주석을 작성할 때 시간(YYYY-MM-DD HH:mm 형식)을 추가할지 말지를 결정합니다. 옵션을 생략하면 `false` 전달하면 `true` 입니다.\n* `-c --includecwd` 작업디렉터리로 전달된 cwd에 대해서 index.ts 파일을 생성할 것인지에 대해서 결정합니다. 옵션을 생략하면 `true` 전달하면 `false` 입니다.\n* `-e --excludes [comma separated exclude directories]` 제외할 디렉터리를 전달합니다. 기본 값은 `['@types', 'typings', '__test__', '__tests__']` 입니다. 사용자 설정 값을 전달하려고 하는 경우 아래 예제와 같이 쉼표로 구분해서 전달하세요.\n* `-i --fileexcludes [comma separated extname]` 제외할 파일이름 패턴을 전달합니다.기본 값은 `[]` 입니다. 사용자 설정 값을 전달하려고 하는 경우 쉼표로 구분해서 전달하세요.\n* `-x --targetexts [comma separated extname]` export 구문을 생성할 때 사용할 확장자명을 전달합니다. 기본 값은 `['ts', 'tsx']` 입니다. 확장자명을 전달할 때는 예와같이 점 문자를 제외하고 전달해야합니다. 또한 사용자 설정 값을 전달하려고 하는 경우 아래 예제와 같이 쉼표로 구분해서 전달하세요.\n* `-v --verbose` 로그 메시지를 더 상세하게 출력합니다. 1.5.0 버전부터 로그 메시지 출력을 간소화 하였습니다. 하여 기존과 같이 상세한 로그를 보고자 하는 경우 이 옵션을 추가해야 합니다.\n* `-q --quote` 따옴표를 결정한다. 쌍따옴표와 홑따옴표를 전달할 수 있고 전달한 문자를 사용해서 따옴표를 출력한다.\n* `-w --withoutcomment` index.ts 파일 또는 entrypoint.ts 파일 맨 윗줄에 추가되는 주석을 제거합니다.\n* `-b --withoutbackup` index.ts 파일 또는 entrypoint.ts 파일을 생성할 때 이미 파일이 있는 경우 백업 파일을 생성하는 기능을 사용하지 않습니다.\n* `-o --output` index.ts 파일 또는 entrypoint.ts 파일 이름의 이름을 변경합니다.\n\n# 사용법\n## 라이브러리로 사용하는 경우\n### TypeScritIndexWriter 사용\n```\nconst tsiw = new TypeScritIndexWriter();\nconst option = TypeScritIndexWriter.getDefaultOption('./src');\n\n(async () =\u003e {\n  await tsiw.create(option);\n\n  // or\n\n  await tsiw.createEntrypoint(option);\n})();\n```\n\n### CommandModule 사용\n```\n(async () =\u003e {\n  const option = CreateTsIndexOption.getOption({});\n  const createCommand = new CreateCommandModule();\n  await createCommand.do(process.cwd(), option);\n});\n```\n\n## CLI로 사용하기\nGit-style sub-command를 사용합니다.\n\n* create\n  * index.ts 파일을 재귀적으로 생성합니다.\n* entrypoint\n  * entrypoint.ts 파일을 생성합니다.\n* init\n  * `.ctirc` 파일을 생성합니다.\n* clean\n  * entrypoint.ts 파일과 index.ts 파일을 모두 삭제합니다. 복원할 수 없으니 주의하세요.\n\n```\n# 기본 사용법\n## create 명령어\ncti ./src\ncti create ./src\n\n## entrypoint 명령어\ncti entrypoint ./src\n\n# 줄바꿈 문자 포함하지 않기\ncti create -n ./src\n## or\ncti entrypoint -n ./src\n\n# 제외할 디렉터리를 직접 전달하는 방법\ncti create -n -e @types typings __test__ __tests__ pages ./src\n## or\ncti entrypoint -n -e @types typings __test__ __tests__ pages ./src\n\n# entrypoint.ts 와 index.ts 파일 삭제하기\ncti clean ./src\n\n# 하위 디렉터리를 포함해서 실행하기\nfor f in *; do cti create ./$f; done\n\n# 여러 디렉터리를 전달하기\ncti create ./src/server ./src/client ./src/module\n```\n\n## CLI 에 .ctirc 설정파일 적용하기\ncreate-ts-index cli는 1.7.0버전에서 .ctirc 설정파일을 지원합니다. 설정파일 이름은 오직 `.ctirc` 만 가능합니다. `.ctirc`는 여러 개를 만들어서 적용할 수 있습니다. create-ts-index는 제일 먼저 인자로 주어진 디렉터리에서 `.ctirc` 파일을 찾습니다. 다음은 cti 스크립트가 실행된 디렉터리에서 `.ctirc` 파일을 찾습니다. 그리고 스크립트 디렉터리, 인자 디렉터리 순으로 설정을 차례대로 적용하고 스크립트를 실행합니다. 단, cti 스크립트 인자로 주어진 설정은 우선적으로 적용됩니다. `.ctirc` 파일은 [json5](https://json5.org) 형식으로 기술되며 주석을 쓰거나 키 값을 쌍따옴표를 쓰지 않고 기술할 수 있습니다. 자세한 스펙은 링크를 참고하세요.\n\n아래 예제는 `.ctirc` 파일을 어떻게 찾고, 적용하는지를 보여줍니다.\n```\n# execute on /Users/cti/github/create-ts-index\nsh\u003e cti create ./example/type01\n\n# search configuration file on \"/Users/cti/github/create-ts-index\"\n# search configuration file on \"/Users/cti/github/create-ts-index/example/type01\"\n# apply configuration by \"/Users/cti/github/create-ts-index\"\n# apply configuration by \"/Users/cti/github/create-ts-index/example/type01\"\n# every configuration is overwrited \n```\n\n### .ctirc 파일 생성하기 \ncli를 사용해서 `.ctirc` 파일을 생성할 수 있습니다.\n\n```bash\n# 현재 디렉터리에 생성\n\u003e cti init\n\n# 여러 디렉터리에 생성\n\u003e cti init ./example/type03 ./example/type02\n```\n\n# Language\n* [English](https://github.com/imjuni/create-ts-index/blob/master/README.md)\n* [Korean](https://github.com/imjuni/create-ts-index/blob/master/README.ko.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjuni%2Fcreate-ts-index","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimjuni%2Fcreate-ts-index","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjuni%2Fcreate-ts-index/lists"}