Skip to content

Commit

Permalink
Add startAt options
Browse files Browse the repository at this point in the history
## Add new options: startAt

- startAt option set start working directory
  - create, single, remove, init mode applied
- fix broken testcase

## Change logging package

- consola > pino
  - pino support cjs, esm both
- apply lint on example
- package version bumps

## Write documentation: startAt option and remove command

## deps
  - my-easy-fp: 0.14.0 > 0.15.0
  - my-node-fp: 0.7.0 > 0.8.1
  - cli-progress: 3.11.1 > 3.11.2
  - dayjs: 1.11.2 > 1.11.5
  - typescript: 4.7.4 > 4.8.2
  - ts-morph: 15.0.0 > 15.1.0
  - type-fest: 2.18.0 > 2.19.0
  • Loading branch information
imjuni committed Sep 4, 2022
1 parent 9150c06 commit 47e743e
Show file tree
Hide file tree
Showing 63 changed files with 3,124 additions and 2,804 deletions.
4 changes: 4 additions & 0 deletions .configs/vuepress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const navs: NavbarConfig = [
text: 'Create',
link: '/usage/create-command.md',
},
{
text: 'Remove',
link: '/usage/remove-command.md',
},
],
},
{
Expand Down
4 changes: 2 additions & 2 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ module.exports = {
ignorePatterns: ['__test__/*', '__tests__/*'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
project: './tsconfig.eslint.json',
},
plugins: ['@typescript-eslint', '@typescript-eslint/tslint', 'prettier', 'import'],
plugins: ['@typescript-eslint', 'prettier', 'import'],
rules: {
'@typescript-eslint/indent': 'off',
'max-len': ['error', { code: 120 }],
Expand Down
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,26 @@ It is not recommanded to use `index.ts` file to re-map paths or shorten the path

## Option

| Name | Short | Default | Command | Description |
| :--------------- | ----- | -------- | ---------------------- | ---------------------------------------------------------------------------------------------------------- |
| --config | -c | | All | configuration file(.ctirc) path |
| --project | -p | required | All | tsconfig.json path: you must pass path with filename, like this "./tsconfig.json" |
| --exportFilename | -f | index.ts | create, single, remove | Export filename, if you not pass this field that use "index.ts" or "index.d.ts" |
| --useSemicolon | -s | true | create, single | add semicolon on line ending at every export statement |
| --useTimestamp | -t | false | create, single | timestamp write on ctix comment right-side, only works in useComment option set true |
| --useComment | -m | true | create, single | ctix comment add on first line of creted export file(default index.ts) file, that remark created from ctix |
| --quote | -q | ' | create, single | change quote character at export syntax |
| --keepFileExt | -k | ' | create, single | keep file extension on export statement path literal |
| --overwrite | -w | ' | create, single | overwrite each index.ts file |
| --skipEmptyDir | -e | ' | create | empty directory skip create index.ts file |
| --output | -o | N/A | single | output directory |
| --useRootDir | -r | false | single | output file under rootDir in tsconfig.json. |
| --includeBackup | N/A | false | remove | If this option set true on remove mode what will be delete backup file. |
| Name | Short | Default | Command | Description |
| :--------------- | ----- | ----------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| --config | -c | | All | configuration file(.ctirc) path |
| --project | -p | required | All | tsconfig.json path: you must pass path with filename, like this "./tsconfig.json" |
| --spinnerStream | | stdout | All | Stream of cli spinner, you can pass stdout or stderr |
| --progressStream | | stdout | All | Stream of cli progress, you can pass stdout or stderr |
| --reasonerStream | | stderr | All | Stream of cli reasoner. Reasoner show name conflict error and already exist index.ts file error. You can pass stdout or stderr |
| --startAt | -a | = --project | All | start working from startAt directory. If you do not pass startAt use project directory. |
| --exportFilename | -f | index.ts | create, single, remove | Export filename, if you not pass this field that use "index.ts" or "index.d.ts" |
| --useSemicolon | -s | true | create, single | add semicolon on line ending at every export statement |
| --useTimestamp | -t | false | create, single | timestamp write on ctix comment right-side, only works in useComment option set true |
| --useComment | -m | true | create, single | ctix comment add on first line of creted export file(default index.ts) file, that remark created from ctix |
| --quote | -q | ' | create, single | change quote character at export syntax |
| --keepFileExt | -k | ' | create, single | keep file extension on export statement path literal |
| --overwrite | -w | ' | create, single | overwrite each index.ts file |
| --ignoreFile | -g | | create, single | ignore file name. You can pass ignore, config file at ctix and use it like profile |
| --skipEmptyDir | -e | ' | create | empty directory skip create index.ts file |
| --output | -o | N/A | single | output directory |
| --useRootDir | -r | false | single | output file under rootDir in tsconfig.json. |
| --includeBackup | -b | false | remove | If this option set true on remove mode what will be delete backup file. |

## Ignore

Expand Down
45 changes: 25 additions & 20 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ After `ctix create -p ./tsconfig.json` command.
│ │ ├─ Nav.tsx
│ │ ├─ Button.tsx
│ │ ├─ Input.tsx
│ │ ├─ index.ts # create
│ │ ├─ index.ts # created
│ ├─ pages/
│ │ ├─ Hero.tsx
│ │ ├─ User.tsx
│ │ ├─ index.ts # create
│ ├─ index.ts # create
│ │ ├─ index.ts # created
│ ├─ index.ts # created
├─ App.tsx
├─ index.ts # create
├─ index.ts # created
```

Each file is as belows:
Expand Down Expand Up @@ -133,7 +133,7 @@ After `ctix single -p ./tsconfig.json` command. single mode create one `index.ts
│ │ ├─ Hero.tsx
│ │ ├─ User.tsx
├─ App.tsx
├─ index.ts # create
├─ index.ts # created
```

Each file is as belows:
Expand Down Expand Up @@ -175,21 +175,26 @@ It is not recommanded to use `index.ts` file to re-map paths or shorten the path

## Option

| Name | Short | Default | Command | Description |
| :--------------- | ----- | -------- | ---------------------- | ---------------------------------------------------------------------------------------------------------- |
| --config | -c | | All | configuration file(.ctirc) path |
| --project | -p | required | All | tsconfig.json path: you must pass path with filename, like this "./tsconfig.json" |
| --exportFilename | -f | index.ts | create, single, remove | Export filename, if you not pass this field that use "index.ts" or "index.d.ts" |
| --useSemicolon | -s | true | create, single | add semicolon on line ending at every export statement |
| --useTimestamp | -t | false | create, single | timestamp write on ctix comment right-side, only works in useComment option set true |
| --useComment | -m | true | create, single | ctix comment add on first line of creted export file(default index.ts) file, that remark created from ctix |
| --quote | -q | ' | create, single | change quote character at export syntax |
| --keepFileExt | -k | ' | create, single | keep file extension on export statement path literal |
| --overwrite | -w | ' | create, single | overwrite each index.ts file |
| --skipEmptyDir | -e | ' | create | empty directory skip create index.ts file |
| --output | -o | N/A | single | output directory |
| --useRootDir | -r | false | single | output file under rootDir in tsconfig.json. |
| --includeBackup | N/A | false | remove | If this option set true on remove mode what will be delete backup file. |
| Name | Short | Default | Command | Description |
| :--------------- | ----- | ----------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| --config | -c | | All | configuration file(.ctirc) path |
| --project | -p | required | All | tsconfig.json path: you must pass path with filename, like this "./tsconfig.json" |
| --spinnerStream | | stdout | All | Stream of cli spinner, you can pass stdout or stderr |
| --progressStream | | stdout | All | Stream of cli progress, you can pass stdout or stderr |
| --reasonerStream | | stderr | All | Stream of cli reasoner. Reasoner show name conflict error and already exist index.ts file error. You can pass stdout or stderr |
| --startAt | -a | = --project | All | start working from startAt directory. If you do not pass startAt use project directory. |
| --exportFilename | -f | index.ts | create, single, remove | Export filename, if you not pass this field that use "index.ts" or "index.d.ts" |
| --useSemicolon | -s | true | create, single | add semicolon on line ending at every export statement |
| --useTimestamp | -t | false | create, single | timestamp write on ctix comment right-side, only works in useComment option set true |
| --useComment | -m | true | create, single | ctix comment add on first line of creted export file(default index.ts) file, that remark created from ctix |
| --quote | -q | ' | create, single | change quote character at export syntax |
| --keepFileExt | -k | ' | create, single | keep file extension on export statement path literal |
| --overwrite | -w | ' | create, single | overwrite each index.ts file |
| --ignoreFile | -g | | create, single | ignore file name. You can pass ignore, config file at ctix and use it like profile |
| --skipEmptyDir | -e | ' | create | empty directory skip create index.ts file |
| --output | -o | N/A | single | output directory |
| --useRootDir | -r | false | single | output file under rootDir in tsconfig.json. |
| --includeBackup | -b | false | remove | If this option set true on remove mode what will be delete backup file. |

## Ignore

Expand Down
69 changes: 41 additions & 28 deletions docs/usage/create-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,31 @@ Collect exported something(variable, function, object, class, interface etc.) in

## create command option schema

| Name | Short | Default | Type | Required | Command |
| :--------------- | ----- | -------- | -------------------- | -------- | ------- |
| --config | -c | | string | | create |
| --project | -p | | string | required | create |
| --exportFilename | -f | index.ts | string | required | create |
| --useSemicolon | -s | true | string | | create |
| --useTimestamp | -t | false | boolean | | create |
| --useComment | -m | true | boolean | | create |
| --quote | -q | ' | string | | create |
| --keepFileExt | -k | false | boolean | | create |
| --overwrite | -w | false | boolean | | create |
| --ignoreFile | -g | | string | | create |
| --skipEmptyDir | -e | true | boolean | | create |
| --spinnerStream | | stdout | enum(stdout, stderr) | | create |
| --progressStream | | stdout | enum(stdout, stderr) | | create |
| --reasonerStream | | stderr | enum(stdout, stderr) | | create |
| Name | Short | Default | Type | Required | Command |
| :--------------- | ----- | ------------------- | -------------------- | -------- | ------- |
| --config | -c | | string | | create |
| --project | -p | | string | required | create |
| --startAt | -a | use --project value | string | required | create |
| --exportFilename | -f | index.ts | string | required | create |
| --useSemicolon | -s | true | string | | create |
| --useTimestamp | -t | false | boolean | | create |
| --useComment | -m | true | boolean | | create |
| --quote | -q | ' | string | | create |
| --keepFileExt | -k | false | boolean | | create |
| --overwrite | -w | false | boolean | | create |
| --ignoreFile | -g | | string | | create |
| --skipEmptyDir | -e | true | boolean | | create |
| --spinnerStream | | stdout | enum(stdout, stderr) | | create |
| --progressStream | | stdout | enum(stdout, stderr) | | create |
| --reasonerStream | | stderr | enum(stdout, stderr) | | create |

## create command option description

| Name | Description |
| :--------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| --config | configuration file(.ctirc) path |
| --project | tsconfig.json path: you must pass path with filename, like this "./tsconfig.json" |
| --startAt | start working from startAt directory. If you do not pass startAt use project directory. |
| --exportFilename | Export filename, if you not pass this field that use "index.ts" or "index.d.ts" |
| --useSemicolon | add semicolon on line ending at every export statement |
| --useTimestamp | timestamp write on ctix comment right-side, only works in useComment option set true |
Expand Down Expand Up @@ -145,20 +147,31 @@ export * from './Tree';
export * from './Grid';
```

#### `src/pages/index.ts`
## startAt mechanishm

```text
// created from 'ctix'
export * from './Hero';
export * from './User';
```
### in case of startAt set `src`

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

```text
// created from 'ctix'
export * from './component/nav';
export * from './component/small';
export * from './component/large';
export * from './pages';
# 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
│ ├─ index.ts # created
├─ App.tsx
```
Loading

0 comments on commit 47e743e

Please sign in to comment.