Skip to main content

Create Command

Collect exported something(variable, function, object, class, interface etc.) information to create index.ts file in each directories. You can use the top-level directory index.ts file as an entrypoint. In this case, be careful of duplicate export.

create command option schema

NameShortDefaultTypeRequiredCommand
--config-cstringcreate
--project-pstringrequiredcreate
--startAt-ause --project valuestringcreate
--exportFilename-findex.tsstringcreate
--useSemicolon-struestringcreate
--useTimestamp-tfalsebooleancreate
--useComment-mtruebooleancreate
--quote-q'stringcreate
--keepFileExt-kfalsebooleancreate
--overwrite-wfalsebooleancreate
--ignoreFile-g.ctiignorestringcreate
--skipEmptyDir-etruebooleancreate
--noBackupfalsebooleancreate
--spinnerStreamstdoutenum(stdout, stderr)create
--progressStreamstdoutenum(stdout, stderr)create
--reasonerStreamstderrenum(stdout, stderr)create

create command option description

NameDescription
--configconfiguration file(.ctirc) path
--projecttsconfig.json path: you must pass path with filename, like this "./tsconfig.json"
--startAtstart working from startAt directory. If you do not pass startAt use project directory.
--exportFilenameExport filename, if you not pass this field that use "index.ts" or "index.d.ts"
--useSemicolonadd semicolon on line ending at every export statement
--useTimestamptimestamp write on ctix comment right-side, only works in useComment option set true
--useCommentctix comment add on first line of creted export file(default index.ts) file, that remark created from ctix
--quotechange quote character at export syntax
--keepFileExtkeep file extension on export statement path literal
--overwriteoverwrite each index.ts file
--ignoreFileignore file name. You can pass ignore, config file at ctix and use it like profile
--skipEmptyDirIf set true this option, skip empty directory
--noBackupnot create backup file even if set overwrite option enable
--spinnerStreamStream of cli spinner, you can pass stdout or stderr
--progressStreamStream of cli progress, you can pass stdout or stderr
--reasonerStreamStream of cli reasoner. Reasoner show name conflict error and already exist index.ts file error. You can pass stdout or stderr

skipEmptyDir mechanishm

If you want to include index.ts file in your vcs(eg. git) what is useful choice.

Origin tree structure

# To-Be
├─ src/
│ ├─ component/
│ │ ├─ nav/
│ │ │ ├─ Nav.tsx
│ │ ├─ small/
│ │ │ ├─ Button.tsx
│ │ │ ├─ Input.tsx
│ │ ├─ large/
│ │ │ ├─ Tree.tsx
│ │ │ ├─ Grid.tsx
│ ├─ pages/
│ │ ├─ Hero.tsx
│ │ ├─ User.tsx
├─ App.tsx

in case of skipEmptyDir value false

# To-Be
├─ src/
│ ├─ component/
│ │ ├─ nav/
│ │ │ ├─ Nav.tsx
│ │ │ ├─ index.ts # created
│ │ ├─ small/
│ │ │ ├─ Button.tsx
│ │ │ ├─ Input.tsx
│ │ │ ├─ index.ts # created
│ │ ├─ large/
│ │ │ ├─ Tree.tsx
│ │ │ ├─ Grid.tsx
│ │ │ ├─ index.ts # created
│ │ ├─ index.ts # created
│ ├─ pages/
│ │ ├─ Hero.tsx
│ │ ├─ User.tsx
│ │ ├─ index.ts # created
│ ├─ index.ts # created
├─ App.tsx
├─ index.ts # created

in case of skipEmptyDir value true

Enabling the skipEmptyDir option does not create index.ts file in empty directories

# To-Be
├─ src/
│ ├─ component/
│ │ ├─ nav/
│ │ │ ├─ Nav.tsx
│ │ │ ├─ index.ts # created
│ │ ├─ small/
│ │ │ ├─ Button.tsx
│ │ │ ├─ Input.tsx
│ │ │ ├─ index.ts # created
│ │ ├─ large/
│ │ │ ├─ Tree.tsx
│ │ │ ├─ Grid.tsx
│ │ │ ├─ index.ts # created
│ ├─ pages/
│ │ ├─ Hero.tsx
│ │ ├─ User.tsx
│ │ ├─ index.ts # created
├─ App.tsx
├─ index.ts # created

src/component/nav/index.ts

// created from 'ctix'
export * from './Nav';

src/component/small/index.ts

// created from 'ctix'
export * from './Button';
export * from './Input';

src/component/large/index.ts

// created from 'ctix'
export * from './Tree';
export * from './Grid';

startAt mechanishm

in case of startAt set lib

Passing the startAt option create index.ts file from startAt directory.

# To-Be
├─ lib/
│ ├─ component/
│ │ ├─ nav/
│ │ │ ├─ Nav.tsx
│ │ │ ├─ index.ts # created
│ │ ├─ small/
│ │ │ ├─ Button.tsx
│ │ │ ├─ Input.tsx
│ │ │ ├─ index.ts # created
│ │ ├─ large/
│ │ │ ├─ Tree.tsx
│ │ │ ├─ Grid.tsx
│ │ │ ├─ index.ts # created
│ ├─ pages/
│ │ ├─ Hero.tsx
│ │ ├─ User.tsx
│ │ ├─ index.ts # created
│ ├─ index.ts # created
├─ App.tsx