https://github.com/giladgd/typeorm-codebase-sync
Automatically update your codebase to add migrations, entities and subscribers to your `data-source.ts` file
https://github.com/giladgd/typeorm-codebase-sync
ast cli code codebase data-source datasource edit files sync ts typeorm typeorm-extension typeorm-migration typescript
Last synced: about 10 hours ago
JSON representation
Automatically update your codebase to add migrations, entities and subscribers to your `data-source.ts` file
- Host: GitHub
- URL: https://github.com/giladgd/typeorm-codebase-sync
- Owner: giladgd
- Created: 2022-03-28T16:03:35.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-04T19:45:59.000Z (almost 4 years ago)
- Last Synced: 2025-10-10T14:28:03.638Z (4 months ago)
- Topics: ast, cli, code, codebase, data-source, datasource, edit, files, sync, ts, typeorm, typeorm-extension, typeorm-migration, typescript
- Language: TypeScript
- Homepage:
- Size: 322 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# TypeORM Codebase Sync
Automatically update your codebase to add migrations, entities and subscribers to your `data-source.ts` file
[](https://github.com/giladgd/typeorm-codebase-sync/actions/workflows/test.yml)
[](https://www.npmjs.com/package/typeorm-codebase-sync)
[](https://codecov.io/gh/giladgd/typeorm-codebase-sync)
## Installation
1. Install dependencies
```bash
npm install --save-dev typescript
npm install --save typeorm
```
2. Install `typeorm-codebase-sync`
```bash
npm install --save-dev typeorm-codebase-sync
```
3. Add `typeorm-sync` script to `package.json`
```bash
npm set-script "typeorm-sync" "typeorm-codebase-sync addReferences --dataSource ./src/db/data-source.ts --migrations ./src/db/migrations --entities ./src/db/entities --subscribers ./src/db/subscribers"
```
4. To automatically run `typeorm-sync` after using the typeorm CLI, edit `package.json`:
```bash
npm set-script "posttypeorm" "npm run typeorm-sync"
```
> Given that your `package.json` contains a script called `typeorm`,
> after each time you run `npm run typeorm -- `, the `typeorm-sync` script will automatically run
## Documentation
### `addReferences` command
```txt
Usage: typeorm-codebase-sync addReferences --dataSource [options]
Required:
-d, --dataSource Path to a data-source.ts file [string] [required]
Files:
-m, --migrations Glob of migration files or folders containing migration files [array]
-e, --entities Glob of entity files or folders containing entity files [array]
-s, --subscribers Glob of subscriber files or folders containing subscriber files [array]
Options:
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
```