generated from StyleShit/create-typescript-package
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 040dbf8
Showing
16 changed files
with
6,272 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: 'npm' | ||
directory: '/' | ||
groups: | ||
dependencies: | ||
dependency-type: 'production' | ||
dev-dependencies: | ||
dependency-type: 'development' | ||
schedule: | ||
interval: 'daily' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
ci: | ||
name: Lint, Test and Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
cache: 'npm' | ||
node-version: 20.x | ||
|
||
- name: Install Deps | ||
run: npm ci | ||
|
||
- name: Run Lint | ||
run: npm run lint | ||
|
||
- name: Run Format | ||
run: npm run format:check | ||
|
||
- name: Run Test | ||
run: npm run test:coverage | ||
|
||
- name: Cache build | ||
id: cache-build | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-build | ||
with: | ||
path: ./dist | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Run Build | ||
run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
if: startsWith(github.repository, 'StyleShit/') | ||
|
||
permissions: | ||
contents: write # to create release (changesets/action) | ||
issues: write # to post issue comments (changesets/action) | ||
pull-requests: write # to create pull request (changesets/action) | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
cache: 'npm' | ||
node-version: 20.x | ||
|
||
- run: npm ci | ||
|
||
- name: Cache build | ||
id: cache-build | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-build | ||
with: | ||
path: ./dist | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Create release PR or publish | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
publish: npm run release | ||
commit: 'chore(release): publish' | ||
title: 'Release package' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
coverage | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
!.vscode/settings.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/.changeset/** | ||
!/.changeset/config.json | ||
/CHANGELOG.md | ||
/dist/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"useTabs": true, | ||
"tabWidth": 4, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"overrides": [ | ||
{ | ||
"files": "*.md", | ||
"options": { | ||
"useTabs": false, | ||
"tabWidth": 2 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"eslint.experimental.useFlatConfig": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Create TypeScript Package | ||
|
||
A template project for developing & publishing TypeScript packages. | ||
|
||
## Configuration | ||
|
||
1. Replace the package name, description, author, license, etc. in the [package.json](./package.json) with your package's details | ||
|
||
2. Update this [README.md](./README.md) file to contain your package's documentation | ||
|
||
3. Update the [release.yml](.github/workflows/release.yml) workflow to check for your username when publishing (this is used to prevent the workflow from running in forks): | ||
|
||
```yaml | ||
if: startsWith(github.repository, '{your-username}/') | ||
``` | ||
4. Configure `GITHUB_TOKEN` to have the permissions to create Pull Requests: | ||
|
||
1. Go to https://github.com/{owner}/{repo}/settings/actions | ||
2. Check "Allow GitHub Actions to create and approve pull requests" under "Workflow permissions" | ||
|
||
5. Add `NPM_TOKEN` to your Repository secrets: | ||
|
||
1. Go to NPM's [Access Tokens](https://www.npmjs.com/settings/styleshit/tokens) page | ||
2. Click "Generate New Token" -> "Classic Token" and follow the instructions (make sure to choose "Automation" for the token type) | ||
3. Go to https://github.com/{owner}/{repo}/settings/secrets/actions, and add the generated token as a secret named `NPM_TOKEN` | ||
|
||
## Structure | ||
|
||
- `src/` - TypeScript source files | ||
- `**/__tests__/` - Test files | ||
- `dist/` - Compiled JavaScript files | ||
|
||
## Tools | ||
|
||
This template uses [tsup](https://tsup.egoist.dev/) for transpiling & bundling, | ||
[Vitest](https://vitest.dev/) for testing, | ||
[ESLint](https://eslint.org/) & [TypeScript ESLint](https://typescript-eslint.io/) (with the strictest configuration) for linting, | ||
[Prettier](https://prettier.io/) for formatting, | ||
and [Changesets](https://github.com/changesets/changesets) for versioning & publishing. | ||
|
||
## Development Flow | ||
|
||
1. Add your code & tests to the `src/` directory | ||
|
||
2. Use `npm run test` to run the tests | ||
|
||
3. Use `npm run lint` to lint the code | ||
|
||
4. Use `npm run format` to format the code | ||
|
||
5. Use `npm run build` to build the package | ||
|
||
6. Run `npx changeset` each time you want to add a commit to the changelog (see [Using Changesets](https://github.com/changesets/changesets/blob/main/docs/intro-to-using-changesets.md#using-changesets) for more info) | ||
|
||
7. Commit & push your changes | ||
|
||
8. The CI will automatically open a PR with the changes, or add the changes to an existing PR | ||
|
||
9. Review & merge the PR when you're ready to publish the package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import globals from 'globals'; | ||
import eslint from '@eslint/js'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
export default tseslint.config( | ||
eslint.configs.recommended, | ||
...tseslint.configs.strictTypeChecked, | ||
{ | ||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
...globals.node, | ||
}, | ||
parserOptions: { | ||
project: true, | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
}, | ||
{ | ||
ignores: [ | ||
'**/coverage/**', | ||
'**/dist/**', | ||
'**/node_modules/**', | ||
'**/__snapshots__/**', | ||
], | ||
}, | ||
); |
Oops, something went wrong.