https://github.com/noviel/typescript-library-monorepo-template
TypeScript Library Monorepo Template
https://github.com/noviel/typescript-library-monorepo-template
github-actions github-packages lerna library monorepo template tsdx typescript yarn-workspaces
Last synced: 4 months ago
JSON representation
TypeScript Library Monorepo Template
- Host: GitHub
- URL: https://github.com/noviel/typescript-library-monorepo-template
- Owner: Noviel
- License: mit
- Created: 2020-08-04T20:09:12.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-21T08:05:51.000Z (over 2 years ago)
- Last Synced: 2025-03-30T00:25:55.461Z (6 months ago)
- Topics: github-actions, github-packages, lerna, library, monorepo, template, tsdx, typescript, yarn-workspaces
- Language: TypeScript
- Homepage:
- Size: 967 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Typescript Library Monorepo Template
## Features
- Full TypeScript support, linting, formatting, ESM and CommonJS bundles and many other developer's goodies with [tsdx](https://github.com/formium/tsdx).
- Linting on precommit with `husky` and `lint-staged`.
- Multiple packages management with Lerna.
- Scoped private NPM packages with GitHub Packages.
- Basic extendable CI process with GitHub Actions.
- Ability to add CLI packages.## Setup
### GitHub Packages
To use Github Packages registry you must [provide](https://github.com/settings/tokens/new) `Personal access token` with `read:packages` and `write:packages` scopes.
It can be stored in `.npmrc` file in the root directory:
```
//npm.pkg.github.com/:_authToken=GITHUB_REGISTRY_ACCESS_TOKEN
@OWNER:registry=https://npm.pkg.github.com
always-auth=true
````OWNER` is the name of the user or organization account that owns the repository.
#### Multiple packages
[GitHub docs on multiple packages at the same repository](https://docs.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages#publishing-multiple-packages-to-the-same-repository)
In `package.json` of every package:
```json
"repository" : {
"type" : "git",
"url": "ssh://git@github.com/OWNER/REPOSITORY.git",
"directory": "packages/name"
},
````OWNER` is the name of the user or organization account that owns the repository.
`REPOSITORY` is the name of the repositroy containing the package.### GitHub Actions
Personal access token with packages scopes must be provided to GitHub Actions as `NPM_TOKEN` (or you can rename it in `.github/workflows/main.yml):
To add a token to the repository: `Settings` -> `Secrets` -> `New secret`.
## Workflows
### Add new package
1. Use `template-demo-core` package `as a reference (package must include`package.json`,`tsconfig.json`and`src/index.ts`).
2. Run `yarn lerna bootstrap`.### Add CLI package
Use `template-demo-cli` package as a reference.
### Publish
```sh
yarn lerna publish
```Publish every changed package to registry. It will build packages before publish.
### Add dependency to a package
```sh
yarn lerna add --scope=@
```### Build packages
```sh
yarn build
```