@colaido/shared-library
v1.0.12
Published
A shared library of TypeScript interfaces, enums, and types
Downloads
1
Readme
Colaido Shared Library
A shared library of TypeScript interfaces, enums, and types.
Guide to upgrade the library automatically
Skip the guide if you are doing manually upgrade.
First: make your development changes:
- See Development guide .
Second: Install jq + tsc globally to your environment:
- Mac
brew install jq
or Ubuntu/Debiansudo apt-get install jq
Third: run the magic script
3../release.sh
Latest: check and validate
- The script successfully did the job ? Validate npm registry
- The script Failed ? Github Action failures for details
The script does the following:
- Check for necessary commands: The script checks if jq, tsc, npm, git, and gh are installed.
- Build the project: The script runs tsc to compile the TypeScript project.
- Read the current version: The script reads the current version from package.json.
- Increment the patch version: The script increments the patch version by 1.
- Update package.json: The script updates package.json with the new version.
- Install npm dependencies: The script runs npm install & generates a new package-lock.json.
- Commit changes: The script stages and commits the changes to Git.
- Push the commit: The script pushes the commit to the remote repository.
- Create a new tag: The script creates a new Git tag with the new version.
- Push the tag: The script pushes the tag to the remote repository.
- Create a GitHub release: The script uses the GitHub CLI to create a release with the new tag, title, and notes
- **Github Action run (.github/workflows/publish.yml) - which does publish the release to npm registry ()
Table of Contents
- Overview
- Installation
- Usage
- Development
- GitHub Actions Workflow
- Setting Up GitHub Secrets
- Contributing
- License
Overview
This library provides shared TypeScript interfaces, enums, and types for use across multiple projects.
Installation
Install the package via npm:
npm install @colaido/shared-library
Usage
Import and use the types in your project:
import { User, UserRole, UserID } from '@colaido/shared-library';
const user: User = {
id: "123",
name: "John Doe",
email: "[email protected]"
};
const role: UserRole = UserRole.Admin;
const userId: UserID = "123";
Development
Pulling Latest Changes
Before making new changes, ensure you have the latest code from the repository:
Pull the latest changes:
git pull origin main
Making Changes
Clone the repository if you haven't already:
git clone https://github.com/maximcoding/colaido-shared-library.git cd colaido-shared-library
Install dependencies:
npm install
Make your changes in the
src
directory. For example, you can add or update interfaces, enums, or types.** ⚠️ ⚠️ ⚠️ Should export your interface ⚠️ ⚠️ ⚠️ inside the
src/index.ts
for example:export * from './interfaces/user-profile.interface';
Build the project to ensure there are no errors:
npm run build
Committing and Pushing Changes
Stage your changes:
git add .
Commit your changes:
git commit -m "Describe your changes"
Push your changes:
git push origin main
Manually Release + Publish
Skip if you are using github actions inside CLI GUIDE
- Go to github web , inside repo => 'create a new tag' as the version from package.json
- Go to github web, inside repo => 'draft new release' from your commit + your tag
- Push to npm registry as public repository
bash npm publish
Releasing a New Tag (CLI GUIDE)
Publishing to the npm registry is handled automatically by GitHub Actions when you push a new tag to the repository. Follow these steps to create and push a new version:
Update the version number in
package.json
according to semantic versioning. ️Generate new package-lock.json and validate package-lock.json had been updated ⚠️ ⚠️ ⚠️
npm install
Commit the version bump:
git add . git commit -m "Bump version to x.x.x" git push origin main
Create a new git tag:
git tag -a v1.0.0 -m "Release version 1.0.0" # Replace with the new version
Push the tag to GitHub:
git push origin v1.0.1
Push the tag to GitHub:
gh release create v1.0.0 --title "Version 1.0.0" --notes "This release includes the following changes..."
Setting Up GitHub Secrets
To securely manage your npm token, you need to add it to your GitHub repository's secrets:
Generate an npm Token:
- Go to your npm account settings at npmjs.com.
- Generate a new token with
Publish
permissions.
Add npm Token to GitHub Secrets:
- Go to your GitHub repository.
- Navigate to
Settings
>Secrets and variables
>Actions
>New repository secret
. - Add a new secret with the name
NPM_TOKEN
and paste the npm token as the value.
Contributing
Feel free to open issues or submit pull requests for any changes or improvements. When contributing, please follow the existing code style and ensure that your changes don't break the build.
License
This project is licensed under the ISC License.