An open API service indexing awesome lists of open source software.

https://github.com/luisreinoso/ng-filename-parser

Angular file name convention parser
https://github.com/luisreinoso/ng-filename-parser

angular parser typescript

Last synced: about 2 months ago
JSON representation

Angular file name convention parser

Awesome Lists containing this project

README

          

# ng filename parser

Angular file name convention parser

```
src/ project source code
|- app/
| |- user/ user module
| |- components/ dummy components
| | |- menu/
| | | |- menu.component.html
| | | |- menu.component.scss
| | | |- menu.component.spec.ts
| | | |- menu.component.ts
| | | |- menu.stories.ts
| |- pages/ smart components
| | |- dashboard/
| | | |- dashboard.page.html
| | | |- dashboard.page.scss
| | | |- dashboard.page.spec.ts
| | | |- dashboard.page.stories.ts also support dashboard.stories.ts
| | | |- dashboard.page.ts
| +- ...
```

### Installation

```bash
npm install --save ng-filename-parser
```

### Usage

Import required helper function.

```typescript
import {
getNgFilenameTokens,
getStyleFile,
getHtmlFile,
getSpecFile,
getTypescriptFile,
getStorybookFile,
} from 'ng-filename-parser'
```

#### getNgFilenameTokens

Pass as argument the angular project filename to tokenizer to `getNgFilenameTokens`

```typescript
const filename = '/home/angular/project/src/app/app.component.ts'
const tokens = getNgFilenameTokens(filename)
```

This will return:

```
{
component: 'app',
type: ['component']
}
```

#### getFiles functions

Based on filename tokens user could request filename of styles/ts/stories/spec files.

- `getStyleFile`
- `getHtmlFile`
- `getSpecFile`
- `getTypescriptFile`
- `getStorybookFile`

Checkout testing files for more information.

### Release

- run `npm run release`

### License

Luis Reinoso 2021 [MIT License](LICENSE)