Skip to content

Commit 36a1450

Browse files
mayank-patelclaude
andcommitted
feat!: TypeScript rewrite with dual-format build, automated releases, lint, and demo
BREAKING CHANGE: package now ships compiled dist/ instead of raw source. Consumers importing from the package root directly must update to use the published dist/ output. - Move source to src/index.tsx, tests to __tests__/ - Add tsup build (CJS + ESM + .d.ts), dual exports map in package.json - Add semantic-release with beta prerelease channel support - Add ESLint (typescript-eslint, react, react-hooks) + Prettier + Husky pre-commit - Add CI, Release, and Deploy Demo GitHub Actions workflows - Add Vite + react-native-web demo deployed to gh-pages - Update README and add CONTRIBUTING.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 93d6e67 commit 36a1450

29 files changed

Lines changed: 21569 additions & 344 deletions

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, beta]
6+
pull_request:
7+
branches: [master, beta]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: '20'
17+
cache: 'npm'
18+
- run: npm ci
19+
- run: npm run lint
20+
- run: npm run format:check
21+
- run: npm run type-check
22+
- run: npm test
23+
- run: npm run build

.github/workflows/deploy-demo.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Deploy Demo
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: '20'
17+
cache: 'npm'
18+
cache-dependency-path: demo/package-lock.json
19+
- name: Install demo dependencies
20+
working-directory: demo
21+
run: npm ci
22+
- name: Build demo
23+
working-directory: demo
24+
run: npm run build
25+
- name: Deploy to gh-pages
26+
uses: peaceiris/actions-gh-pages@v4
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
publish_dir: ./demo/dist

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: [CI]
6+
branches: [master]
7+
types: [completed]
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13+
permissions:
14+
contents: write
15+
issues: write
16+
pull-requests: write
17+
id-token: write
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
persist-credentials: false
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: '20'
26+
cache: 'npm'
27+
- run: npm ci
28+
- run: npm run build
29+
- name: Release
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
33+
run: npx semantic-release

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
node_modules
2-
.idea
2+
.idea
3+
index.test.d.ts
4+
dist
5+
demo/dist
6+
demo/node_modules

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist
2+
node_modules
3+
demo/dist
4+
demo/node_modules
5+
CHANGELOG.md

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 100,
5+
"bracketSpacing": false,
6+
"semi": true
7+
}

.travis.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Contributing
2+
3+
## Conventional Commits
4+
5+
This project uses [Conventional Commits](https://www.conventionalcommits.org/) to automate versioning and changelog generation via `semantic-release`.
6+
7+
Every commit message must follow this format:
8+
9+
```
10+
<type>(<optional scope>): <description>
11+
```
12+
13+
### Commit types and their effect on versioning
14+
15+
| Type | Description | Release |
16+
| ---------- | ------------------------------ | ------------------ |
17+
| `feat` | A new feature | Minor version bump |
18+
| `fix` | A bug fix | Patch version bump |
19+
| `perf` | A performance improvement | Patch version bump |
20+
| `chore` | Maintenance / tooling | No release |
21+
| `docs` | Documentation only | No release |
22+
| `refactor` | Code change, no feature or fix | No release |
23+
| `style` | Formatting, whitespace | No release |
24+
| `test` | Adding or updating tests | No release |
25+
| `ci` | CI/CD changes | No release |
26+
| `build` | Build system changes | No release |
27+
28+
### Breaking changes
29+
30+
A breaking change triggers a **major version bump** regardless of the commit type. Indicate it in one of two ways:
31+
32+
**Option 1 — `!` suffix on the type:**
33+
34+
```
35+
feat!: remove deprecated myRef prop
36+
```
37+
38+
**Option 2 — `BREAKING CHANGE` footer:**
39+
40+
```
41+
feat: remove deprecated myRef prop
42+
43+
BREAKING CHANGE: The `myRef` prop has been removed. Use the standard `ref` prop instead.
44+
```
45+
46+
### More examples
47+
48+
```
49+
feat: add support for placeholder color prop
50+
fix: label stays in dirty position after clear()
51+
chore: upgrade tsup to v9
52+
docs: update README installation steps
53+
```
54+
55+
## Development workflow
56+
57+
```bash
58+
# Install dependencies
59+
npm install
60+
61+
# Run tests
62+
npm test
63+
64+
# Type-check
65+
npm run type-check
66+
67+
# Build the library
68+
npm run build
69+
70+
# Start the demo dev server (http://localhost:5173)
71+
npm run demo
72+
```
73+
74+
## Submitting changes
75+
76+
1. Fork the repository and create a branch from `master`.
77+
2. Make your changes, following the Conventional Commits format for every commit.
78+
3. Ensure `npm test`, `npm run type-check`, and `npm run build` all pass locally.
79+
4. Open a pull request against `master`. The CI workflow will run automatically.
80+
81+
## Setting up NPM_TOKEN for automated publishing
82+
83+
Automated npm publishing is handled by `semantic-release` via the `release.yml` workflow. It requires a `NPM_TOKEN` secret in the GitHub repository settings.
84+
85+
**Steps to configure:**
86+
87+
1. Log in to [npmjs.com](https://www.npmjs.com) and go to **Access Tokens** in your account settings.
88+
2. Click **Generate New Token** and choose **Granular Access Token** (or Classic → **Automation** type).
89+
3. Grant the token **read and write** access to the `react-native-floating-labels` package.
90+
4. Copy the generated token.
91+
5. In the GitHub repository, go to **Settings → Secrets and variables → Actions**.
92+
6. Click **New repository secret**, name it `NPM_TOKEN`, and paste the token value.
93+
94+
The `GITHUB_TOKEN` secret is automatically provided by GitHub Actions and requires no manual setup.
95+
96+
## Releasing
97+
98+
Releases are fully automated. When a PR is merged to `master`:
99+
100+
1. The `CI` workflow runs tests, type-check, and build.
101+
2. On success, the `Release` workflow runs `semantic-release`.
102+
3. `semantic-release` analyzes commits since the last release, determines the next version, publishes to npm, creates a GitHub release, and commits an updated `CHANGELOG.md` back to `master`.
103+
104+
You do **not** need to manually bump versions or tag releases.

0 commit comments

Comments
 (0)