Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Duda committed May 8, 2024
1 parent 7b345fe commit 1b778ab
Showing 1 changed file with 44 additions and 20 deletions.
64 changes: 44 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[![npm version](https://badge.fury.io/js/scope-tags.svg)](https://www.npmjs.com/package/scope-tags)
![Auto test and deploy](https://github.com/matiduda/scope-tags/actions/workflows/test-and-deploy-to-npm.yml/badge.svg)

### Architecture diagram

![Alt text](img/architecture.png)

### Scope Tags

Expand All @@ -15,6 +12,10 @@ Command line tool for doing [change impact analysis](https://en.wikipedia.org/wi

Currently in internal beta tests

### Architecture diagram

![Alt text](img/architecture.png)

### How to install

From the repository you want to test the package run
Expand All @@ -23,9 +24,39 @@ From the repository you want to test the package run
npm i scope-tags -D
```

### How to run

From the repository you want to test the package run

```
npx scope
```
You can list available commands using
```
npx scope --help
```

### Configuration

- Option `--report-for-commit-list` is used to update Jira issues, and requires additional metadata in this format:
Scope tags support some option configurable by the user. This enables you to modify the script behaviour and set some global data which is used by the report generator. Available options are:

- `projects: Object[]` - Array with project details in following format:

| Parameter name | Type | Description |
|-----------------------|----------|-------------------------------------------------------------------------------------------------- |
| name | string | Name of the project |
| location | string | Path to the project `tsconfig.json` file |
| useExternalImportMap? | string | Path to import map file which can be used to find references to other types than `.ts` or `.tsx` - see **Externral Import Map** below |
| supportedFiles? | string[] | Array of files supported by the external import map |

- `gitCommitCountLimit: number` - It is the maximum number of commits to search for when doing rev walk on git push hook - used just on the user side while running commands `--verify-unpushed-commits` or `--skip`. It this number is reached you'll get a warning and ignoring it may result in some files being ommited from tag verification.
- `updateIssueURL?: string` - URL used for the POST endpoint with generated report for JIRA issues
- `ignoredExtensions: string[]` - List of file extensions ignored by the script
- `viewIssueURL?: string` - URL used to link from generated HTML logs to Jira issues
- `logsURL?: string` - Location of the generated HTML logs while running `--report-for-commit-list`. Used to link to logs directly from generated reports - makes it easier to see all changes which were made to that build. It is optional, if not present the link won't be added to reports. The URL should contain build tag (`"buildTag"` specified in build metadata file) somewhere.

- Option `--report-for-commit-list buildData.json ./logs.html` is used to do a bunch of stuff - generate reports, logs, and update Jira issues.
It requires additional metadata file `buildData.json` in the following format:

```
{
Expand All @@ -44,7 +75,9 @@ npm i scope-tags -D
}
```

## config.json
`./logs.html` is the destination path of generated HTML logs.

## Eternal import map

- Option `projects.externalImportMap` requires additional metadata in this format:

Expand All @@ -58,11 +91,8 @@ npm i scope-tags -D
}
]
```
> To use multiple files use a file name with `{x}` specifying current import map chunk.
- Option `gitCommitCountLimit` is a maximum number of commits to search for when doing rev walk on git push hook - used just on the user side while running commands `--verify-unpushed-commits` or `--skip`. It this number is reached you'll get a warning and ignoring it may result in some files being ommited from tag verification.

- Option `logsURL` is used to link to logs directly from generated reports - makes it easier to see all changes which were made to that build. It is optional, if not present the link won't be added to reports. The URL should contain build tag (`"buildTag"` specified in build metadata file) somewhere.
> To use multiple files use a file name with `{x}` specifying current import map chunk.
### Local development

Expand All @@ -73,19 +103,18 @@ npm i scope-tags -D
5. Use the local version of the script using `scope` (without the `npx prefix`) (if it doesn't work - restart the terminal)
6. `npx scope` runs version installed in the current repository (as a dependency), `scope` runs locally builded version

To run tests manually use `npm run test`.
> To run test suite use `npm run test`
### Publishing

For unit testing there is a [separate mock repository](https://github.com/matiduda/scope-tags-mock-repo-for-testing-only), which should be keeped up-to-date

Publishing is made automatically by pushing a commit to the main branch, see [github action](https://github.com/matiduda/scope-tags/actions/workflows/test-and-deploy-to-npm.yml)
<!-- To make things easier for developing... -->

The mock repo can be updated automatically by running `./pushTestRepo.sh`

### Features to do

- [-] Use [spinner](https://www.npmjs.com/package/ora) while waiting for async operations (opening repo, ast analysis) - probably not needed because wait time is short
- [-] If eslint available, compare changed files before and after linting. Then, ommit files which only have these changes from scope report - won't be needed because of git option to discard whitespaces and empty lines
- [ ] Add keyboard shortcut hints when selecting tags and files -> https://github.com/enquirer/enquirer#select-choices
- [ ] Add groups on select prompt:
- [ ] Group files based on common path (files from same directory sould be grouped)
Expand All @@ -94,10 +123,5 @@ Publishing is made automatically by pushing a commit to the main branch, see [gi
- [ ] Unit tests for common actions:
- [ ] Testing if files are correstly updated in database depending on changes in git
- [ ] On loading `tags.json` assert that all parents exist in database, if not then these modules won't be displayed
- [ ] Add [automatic publish to npm](https://github.com/marketplace/actions/automated-releases-for-npm-packages) as github action (if tests passed)

### To be discussed

- [ ] Testing approach - how each functionality should be tested?
- [ ] What actions can be performed on files?
- Adding
- [ ] Add unit tests for even the basic stuff - reading and parsing JSON files, synchronization between the database and repository, etc.
- [ ] Ass unit tests for the basic actions which can be performed on files - adding, deleting, modifying, renaming. After initial database entry the script should automatically handle all cases.

0 comments on commit 1b778ab

Please sign in to comment.