Skip to content

Commit

Permalink
Merge pull request #33 from angular-experts-io/feature/stats
Browse files Browse the repository at this point in the history
Feature/stats
  • Loading branch information
nivekcode authored Aug 20, 2024
2 parents 96127f0 + c5a62d7 commit c3ac2d6
Show file tree
Hide file tree
Showing 31 changed files with 885 additions and 139 deletions.
9 changes: 3 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
## [5.0.1](https://github.com/angular-experts-io/ng-parsel/compare/v5.0.0...v5.0.1) (2024-08-06)


### Bug Fixes

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

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


### Features

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

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

### BREAKING CHANGES

* 🧨 fix typo / NgParselValidtor becomes NgParselValidator
- 🧨 fix typo / NgParselValidtor becomes NgParselValidator

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

Expand Down
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
- [Getting started](#getting-started)
- [Install](#install)
- [Init configuration](#init-configuration)
- [Parse codebase](#parse-codebase)
- [Commands](#commands)
- [Parse](#parse)
- [Parse script](#parse-script)
- [NPX](#npx)
- [Configuration](#configuration)
- [Configuration](#configuration)
- [Stats](#stats)
- [Stats script](#stats-script)
- [NPX](#npx-1)
- [Types](#types)
- [Type detection](#type-detection)
- [Outputs](#outputs)
Expand Down Expand Up @@ -60,7 +64,9 @@ Running this command will create a `.parselrc.json` configuration file in the ro
configuration and adjust if needed. The configuration properties and their meaning are explained in
the [configuration section](#configuration).

### Parse codebase
## Commands

### Parse

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

## Configuration
#### Configuration

ng-parsel offers the following configurations.

Expand All @@ -105,6 +111,23 @@ ng-parsel offers the following configurations.
| parseSpecs | true | If set to true ng-parsel will parse testing files (all files ending with `.spec.ts`) and include them in the output. |
| 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)) |

### Stats

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.
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`;

#### Stats script

```json
"stats": "@angular-experts/ng-parsel stats"
```

#### NPX

```bash
npx @angular-experts/ng-parsel stats
```

## Types

Currently ng-parsel classifies each file into one of the following `NgParselOutputType`.
Expand Down
59 changes: 43 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"start:version": "node --loader ts-node/esm src/bin/ng-parsel.bin.ts --version",
"start:help": "node --loader ts-node/esm src/bin/ng-parsel.bin.ts --help",
"start:parse": "node --loader ts-node/esm src/bin/ng-parsel.bin.ts parse --src './test-spa'",
"start:stats": "node --loader ts-node/esm src/bin/ng-parsel.bin.ts stats --src './test-spa'",
"build": "tsc && npm run copy:readme",
"copy:readme": "copyfiles ./README.md ./dist",
"lint": "eslint src/**/*.ts",
Expand Down Expand Up @@ -43,7 +44,8 @@
"chalk": "^5.1.2",
"commander": "^9.4.1",
"cosmiconfig": "^8.0.0",
"ora": "^5.4.1"
"ora": "^5.4.1",
"table": "^6.8.2"
},
"devDependencies": {
"@commitlint/cli": "^17.3.0",
Expand Down
42 changes: 14 additions & 28 deletions src/bin/ng-parsel.bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@ import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { Command } from 'commander';
import { dirname, resolve } from 'path';
import { cosmiconfigSync } from 'cosmiconfig';

import { mergeOptionalConfigWithDefaults } from '../config/config.helper.js';
import { CONFIG_DEFAULT_VALUES } from '../config/config.model.js';
import { writeJson } from '../utils/write.util.js';
import { parse } from '../parser/parser.js';
import { printWelcomeMessage } from '../utils/welcome.util.js';
import { parseCommand } from '../commands/parse.js';
import { statsCommand } from '../commands/stats.js';

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

program.version(
/*
This is very complicated and could be done way simpler by using import assertion.
But import assertions are not supported by Node 14.
*/
This is very complicated and could be done way simpler by using import assertion.
But import assertions are not supported by Node 14.
*/
JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json')).toString() as any)
.version
);
Expand All @@ -36,27 +34,8 @@ program
.option('--specs', 'Parse Specs', true)
.option('-o, --out <string>', 'Output directory for generated files')
.option('--singleFile', 'Output in a single file')
.action((_srcGlob, options) => {
printWelcomeMessage();

const configObject = explorer.search();

if (configObject) {
console.log(
chalk.cyan(
`ng-parsel: configuration found under ${configObject.filepath}.
Configuraton from config file will be used.`
)
);
parse(mergeOptionalConfigWithDefaults(configObject.config));
} else {
console.log(chalk.cyan(`ng-parsel: no configuration found. CLI arguments will be used.`));
options.src = './test-spa';

parse(mergeOptionalConfigWithDefaults(options));
}

console.log(chalk.magenta('===================================='));
.action((_srcGlob, cliArgs) => {
parseCommand(cliArgs);
});

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

program
.command('stats')
.option('-s, --src', 'Glob pattern to search for files')
.action((_srcGlob, cliArgs) => {
statsCommand(cliArgs);
});

program.parse();
Loading

0 comments on commit c3ac2d6

Please sign in to comment.