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
- Host: GitHub
- URL: https://github.com/luisreinoso/ng-filename-parser
- Owner: LuisReinoso
- License: mit
- Created: 2021-01-02T12:22:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-21T09:05:37.000Z (over 3 years ago)
- Last Synced: 2025-03-19T21:30:41.431Z (over 1 year ago)
- Topics: angular, parser, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/ng-filename-parser
- Size: 292 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: code-of-conduct.md
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)