|
13 | 13 |
|
14 | 14 | A boilerplate repo for publishing typescript packages to npm |
15 | 15 |
|
| 16 | +## Usage |
| 17 | + |
| 18 | +Some notes on how to use this repo. Some day I'll hopefully automate the biggest part of this. |
| 19 | + |
| 20 | +### Clone the repo: |
| 21 | + |
| 22 | +```shell script |
| 23 | +npx degit https://github.com/beeman/template-typescript-package my-new-package |
| 24 | +``` |
| 25 | + |
| 26 | +### Initialize the new project |
| 27 | + |
| 28 | + |
| 29 | +```shell script |
| 30 | +cd my-new-package |
| 31 | +yarn # to install the deps |
| 32 | +git init # to initialize a new Git repo |
| 33 | +# Manually create a remote repo and follow the instructions OR: |
| 34 | +hub create # Use this amazing tool called 'hub': https://github.com/github/hub |
| 35 | +``` |
| 36 | + |
| 37 | +#### Update meta data: |
| 38 | + |
| 39 | +Update the following fields in `package.json`: |
| 40 | + |
| 41 | +- name |
| 42 | +- description |
| 43 | +- repository |
| 44 | +- keywords |
| 45 | +- author |
| 46 | +- license |
| 47 | +- bugs |
| 48 | +- homepage |
| 49 | + |
| 50 | +Make sure to don't change the `version` property, versioning this package is handled by `semantic-release`! |
| 51 | + |
| 52 | +#### Update README |
| 53 | + |
| 54 | +Basically you want to search/replace the repo and package name to match your repo/package name and add any new info. |
| 55 | + |
| 56 | +### Getting the GitHub and NPM tokens |
| 57 | + |
| 58 | +#### GitHub |
| 59 | + |
| 60 | +- Log in to GitHub. |
| 61 | +- Navigate to [https://github.com/settings/tokens](https://github.com/settings/tokens). |
| 62 | +- Click `Generate new token`. |
| 63 | +- Fill in the `note` field so you remember what the token is for. |
| 64 | +- Select the `write:packages` scope. This will also enable the `repo` and `read:packages` scopes. |
| 65 | +- Click `Generate token`. |
| 66 | +- Copy the code and store it to use in the next step. |
| 67 | + |
| 68 | +#### NPM |
| 69 | + |
| 70 | +- Log in to NPM. |
| 71 | +- Click the Tokens link from the top-right menu. |
| 72 | +- Click Create New Token |
| 73 | +- Select `Read and Publish` then click `Create Token`. |
| 74 | +- Copy the code and store it to use in the next step. |
| 75 | + |
| 76 | +### Setting the GitHub and NPM tokens |
| 77 | + |
| 78 | +- Open your new repo on GitHub. |
| 79 | +- Navigate to `Settings` then `Secrets`. |
| 80 | +- Click `Add a new secret`. |
| 81 | +- Add the `GH_TOKEN` secret with the GitHub token. |
| 82 | +- Click `Add a new secret` again. |
| 83 | +- Add the `NPM_TOKEN` secret with the NPM token. |
| 84 | + |
| 85 | +Your repo is now set up to publish packages to NPM and the GitHub Package Registry. |
| 86 | + |
| 87 | +### Write your code |
| 88 | + |
| 89 | +Write your amazing new code and make sure to update the tests! |
| 90 | + |
| 91 | +You can run `yarn lint` and `yarn test` to check if your project will pass CI. |
| 92 | + |
| 93 | +### Publish it |
| 94 | + |
| 95 | +With a `git push` you will create a new version and publish it to `npm`. |
| 96 | + |
| 97 | +```shell script |
| 98 | +git commit -m "feat: initial commit" |
| 99 | +git push origin master |
| 100 | +``` |
| 101 | + |
16 | 102 | ## Credits |
17 | 103 |
|
18 | 104 | Based on [npm-typescript-package-boilerplate](https://github.com/93v/npm-typescript-package-boilerplate) with a few changes. |
|
0 commit comments