Skip to content

Commit

Permalink
Readme, test workflow, versionManager fix | 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
WarstekHUN committed Aug 15, 2023
1 parent a31fa1f commit 089c1e7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
matrix:
os:
- ubuntu-latest
node: [18.x]
node: [16.x, 17.x, 18.x]

steps:
- uses: actions/checkout@v3
Expand Down
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,10 @@ import { Num } from 'typescript-npm-package-template';
console.log(new Num(5).add(new Num(6)).val() === 11)
```

## Publishing your package
### Manual publishing only to NPM

Log in:

```bash
npm adduser
```
## CI Testing
Every commit and pull request is tested automatically on Node 16.x, 17.x and 18.x. You can set which node versions the tests should run on here: **.github/workflows/test.yml:30**.

And publish:

```bash
npm publish
```
## Publishing your package

### Using a Github Release (CI):
- Publish your package to NPM and Github Packages at the same time!
Expand Down Expand Up @@ -124,17 +114,32 @@ Follow [npm's official](https://docs.npmjs.com/creating-and-viewing-access-token
<div id="SecretSetting"></div>

On the page of your newly created or existing GitHub repo, click **Settings** -> **Secrets** -> **New repository secret**, the Name should be `NPM_TOKEN` and the Value should be your npm token.

### Publishing to Github Packages
The default configuration of this example package **assumes you publish package with an unscoped name to npm**. GitHub Packages must be named with a scope name such as "@warstekhun/typescript-npm-package-template".

Change `scope: '@warstekhun'` to your own scope in **.github/workflows/publish.yml**.

If you want to publish your package with a scoped name, change the name property in **package.json** and the scope from *@warstekhun* to yours at **.github/workflows/publish.yml:49**.

(You might have noticed `secret.GITHUB_TOKEN` in **.github/workflows/publish.yml**. You don't need to set up a secret named `GITHUB_TOKEN` actually, it is [automatically created](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#about-the-github_token-secret))


### Manual publishing only to NPM

If you publish your package to npm only, and don't want to publish to GitHub Packages, then delete the lines from `- name: Setup .npmrc file to publish to GitHub Packages` to the end of the file in **.github/workflows/publish.yml**.

(You might have noticed `secret.GITHUB_TOKEN` in **.github/workflows/publish.yml**. You don't need to set up a secret named `GITHUB_TOKEN` actually, it is [automatically created](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#about-the-github_token-secret))
Log in:

```bash
npm adduser
```

And publish:

```bash
npm publish
```

## References
- [Creating and publishing unscoped public packages - npm docs](https://docs.npmjs.com/creating-and-publishing-unscoped-public-packages)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package",
"name": "@warstekhun/typescript-npm-package-template",
"version": "1.1.0",
"version": "1.1.1",
"description": "Typescript NPM package template that is ready for NPM and Github Packages publish.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand All @@ -21,7 +21,7 @@
"test:cov-build": "jest --coverage --no-cache --runInBand && jest-coverage-badges-ts --output \"./.coverage-badges\"",
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
"format:fix": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"release": "npm run package && node tools/versionManager.js"
"release": "rimraf ./*.tgz -g && npm run package && node tools/versionManager.js"
},
"files": [
"dist"
Expand Down
5 changes: 0 additions & 5 deletions tools/versionManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const prompt = require("prompt");
const { exec, ChildProcess } = require("child_process");
const colors = require("@colors/colors");
const rimraf = require("rimraf");

prompt.start({
colors: true,
Expand All @@ -25,10 +24,6 @@ async function waitForProcess(args) {
console.log(colors.bold("\n------------------------\nWelcome to the Version Manager!"));
console.log("Every new version you create will be automatically commited, pushed, and then released to Github Packages and NPM.");

rimraf.moveRemove("./*.tgz", {
glob: true
})

const version = (await prompt.get({
pattern: /^((major|minor|patch|premajor|preminor|prepatch|prerelease|from-git)|\d+.\d+.\d+)$/,
message: "Should be: major|minor|patch|premajor|preminor|prepatch|prerelease|from-git will increase version number by npm standards. Custom input is possible. Example: x.x.x",
Expand Down

0 comments on commit 089c1e7

Please sign in to comment.