Skip to content

Commit c3ac2d6

Browse files
authored
Merge pull request #33 from angular-experts-io/feature/stats
Feature/stats
2 parents 96127f0 + c5a62d7 commit c3ac2d6

31 files changed

+885
-139
lines changed

CHANGELOG.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
## [5.0.1](https://github.com/angular-experts-io/ng-parsel/compare/v5.0.0...v5.0.1) (2024-08-06)
22

3-
43
### Bug Fixes
54

6-
* 🐛 adjust document image and realese new logo ([e33d352](https://github.com/angular-experts-io/ng-parsel/commit/e33d352762d0ccae921dbf9cd627e130d373d57a))
5+
- 🐛 adjust document image and realese new logo ([e33d352](https://github.com/angular-experts-io/ng-parsel/commit/e33d352762d0ccae921dbf9cd627e130d373d57a))
76

87
# [5.0.0](https://github.com/angular-experts-io/ng-parsel/compare/v4.3.1...v5.0.0) (2024-08-06)
98

10-
119
### Features
1210

13-
* 🎸 new logo and v5 release ([01b409c](https://github.com/angular-experts-io/ng-parsel/commit/01b409cc428d6e1e95c309fc5d9407fd5b8a1340))
14-
11+
- 🎸 new logo and v5 release ([01b409c](https://github.com/angular-experts-io/ng-parsel/commit/01b409cc428d6e1e95c309fc5d9407fd5b8a1340))
1512

1613
### BREAKING CHANGES
1714

18-
* 🧨 fix typo / NgParselValidtor becomes NgParselValidator
15+
- 🧨 fix typo / NgParselValidtor becomes NgParselValidator
1916

2017
## [4.3.1](https://github.com/angular-experts-io/ng-parsel/compare/v4.3.0...v4.3.1) (2024-08-06)
2118

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121
- [Getting started](#getting-started)
2222
- [Install](#install)
2323
- [Init configuration](#init-configuration)
24-
- [Parse codebase](#parse-codebase)
24+
- [Commands](#commands)
25+
- [Parse](#parse)
2526
- [Parse script](#parse-script)
2627
- [NPX](#npx)
27-
- [Configuration](#configuration)
28+
- [Configuration](#configuration)
29+
- [Stats](#stats)
30+
- [Stats script](#stats-script)
31+
- [NPX](#npx-1)
2832
- [Types](#types)
2933
- [Type detection](#type-detection)
3034
- [Outputs](#outputs)
@@ -60,7 +64,9 @@ Running this command will create a `.parselrc.json` configuration file in the ro
6064
configuration and adjust if needed. The configuration properties and their meaning are explained in
6165
the [configuration section](#configuration).
6266

63-
### Parse codebase
67+
## Commands
68+
69+
### Parse
6470

6571
To parse the code base you can either create a parse script in your `package.json`which calls `ng-parsel` or you can use
6672
npx.
@@ -87,7 +93,7 @@ To parse your code base with npx you can run the follwoing command inisde a term
8793
npx @angular-experts/ng-parsel parse
8894
```
8995

90-
## Configuration
96+
#### Configuration
9197

9298
ng-parsel offers the following configurations.
9399

@@ -105,6 +111,23 @@ ng-parsel offers the following configurations.
105111
| parseSpecs | true | If set to true ng-parsel will parse testing files (all files ending with `.spec.ts`) and include them in the output. |
106112
| singleFile | true | If set to to `true` the output will be written to a `ng-parsel.json` file in the output directory. If set to false, ng-parsel will generate multiple output files, one for each `componentType`. (Find out more on component types in the [next section](#component-type)) |
107113

114+
### Stats
115+
116+
The stats command is a command that gives you a quick overview of your Angular application. It shows you how many components, services, pipes, directives, modules, harnesses and specs you have in your application. Furthermore, it shows you interesting insights, like how many are standanlone and how many are part of a module.
117+
To run the stats command you can either create a stats script in your `package.json`which calls `ng-parsel` or you can use `npx`;
118+
119+
#### Stats script
120+
121+
```json
122+
"stats": "@angular-experts/ng-parsel stats"
123+
```
124+
125+
#### NPX
126+
127+
```bash
128+
npx @angular-experts/ng-parsel stats
129+
```
130+
108131
## Types
109132

110133
Currently ng-parsel classifies each file into one of the following `NgParselOutputType`.

package-lock.json

Lines changed: 43 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"start:version": "node --loader ts-node/esm src/bin/ng-parsel.bin.ts --version",
1212
"start:help": "node --loader ts-node/esm src/bin/ng-parsel.bin.ts --help",
1313
"start:parse": "node --loader ts-node/esm src/bin/ng-parsel.bin.ts parse --src './test-spa'",
14+
"start:stats": "node --loader ts-node/esm src/bin/ng-parsel.bin.ts stats --src './test-spa'",
1415
"build": "tsc && npm run copy:readme",
1516
"copy:readme": "copyfiles ./README.md ./dist",
1617
"lint": "eslint src/**/*.ts",
@@ -43,7 +44,8 @@
4344
"chalk": "^5.1.2",
4445
"commander": "^9.4.1",
4546
"cosmiconfig": "^8.0.0",
46-
"ora": "^5.4.1"
47+
"ora": "^5.4.1",
48+
"table": "^6.8.2"
4749
},
4850
"devDependencies": {
4951
"@commitlint/cli": "^17.3.0",

src/bin/ng-parsel.bin.ts

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,20 @@ import { readFileSync } from 'fs';
44
import { fileURLToPath } from 'url';
55
import { Command } from 'commander';
66
import { dirname, resolve } from 'path';
7-
import { cosmiconfigSync } from 'cosmiconfig';
87

9-
import { mergeOptionalConfigWithDefaults } from '../config/config.helper.js';
108
import { CONFIG_DEFAULT_VALUES } from '../config/config.model.js';
119
import { writeJson } from '../utils/write.util.js';
12-
import { parse } from '../parser/parser.js';
1310
import { printWelcomeMessage } from '../utils/welcome.util.js';
11+
import { parseCommand } from '../commands/parse.js';
12+
import { statsCommand } from '../commands/stats.js';
1413

1514
const program = new Command();
16-
const explorer = cosmiconfigSync('ng-parsel');
1715

1816
program.version(
1917
/*
20-
This is very complicated and could be done way simpler by using import assertion.
21-
But import assertions are not supported by Node 14.
22-
*/
18+
This is very complicated and could be done way simpler by using import assertion.
19+
But import assertions are not supported by Node 14.
20+
*/
2321
JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json')).toString() as any)
2422
.version
2523
);
@@ -36,27 +34,8 @@ program
3634
.option('--specs', 'Parse Specs', true)
3735
.option('-o, --out <string>', 'Output directory for generated files')
3836
.option('--singleFile', 'Output in a single file')
39-
.action((_srcGlob, options) => {
40-
printWelcomeMessage();
41-
42-
const configObject = explorer.search();
43-
44-
if (configObject) {
45-
console.log(
46-
chalk.cyan(
47-
`ng-parsel: configuration found under ${configObject.filepath}.
48-
Configuraton from config file will be used.`
49-
)
50-
);
51-
parse(mergeOptionalConfigWithDefaults(configObject.config));
52-
} else {
53-
console.log(chalk.cyan(`ng-parsel: no configuration found. CLI arguments will be used.`));
54-
options.src = './test-spa';
55-
56-
parse(mergeOptionalConfigWithDefaults(options));
57-
}
58-
59-
console.log(chalk.magenta('===================================='));
37+
.action((_srcGlob, cliArgs) => {
38+
parseCommand(cliArgs);
6039
});
6140

6241
program.command('init').action(() => {
@@ -70,4 +49,11 @@ program.command('init').action(() => {
7049
console.log(chalk.magenta('===================================='));
7150
});
7251

52+
program
53+
.command('stats')
54+
.option('-s, --src', 'Glob pattern to search for files')
55+
.action((_srcGlob, cliArgs) => {
56+
statsCommand(cliArgs);
57+
});
58+
7359
program.parse();

0 commit comments

Comments
 (0)