@wns-test/wns-test-ms
v1.0.5
Published
## Initialization and manual publish
Downloads
4
Readme
Publish a npm package
Initialization and manual publish
Initialize and first publish
- initialize a new npm project
npm init -y
- change the name in package.json to
@organization/project
- initialize git repository and commit
- publish your package
npm login
npm publish
- check your profile on https://www.npmjs.com/
Write a typecript package
- create
tsconfig.json
tsc --init
- install dependencies
npm install typescript del-cli --save-dev
- create
src/index.ts
with some ts code - update
tsconfig.json
{
...
"declaration": true, /* Generates corresponding '.d.ts' file. */
"outDir": "./build", /* Redirect output structure to the directory. */
...
}
- update
package.json
scripts to be sure to clean thebuild
directory
{
...
"scripts": {
"clean": "del .build/*",
"build": "npm run clean && tsc"
},
...
}
make sure to gitignore
build/
fill
main
,types
andfiles
inpackage.json
{
...
"main": "./build/index.js",
"types": "./build/index.d.ts",
"files": [
"./build/**/*"
],
...
}
Update and publish new package version (manually)
- commit your changes
- update your version number manually or run command:
npm version patch
- build and publish
npm run build
npm publish
Publish automatically with a Github action
Connect to a remote github repo (if not done yet)
git remote add origin [email protected]:**github-account**/**project-name**.git
git branch -M main
git push -u origin main
npm publish token
- create and copy a
npm
publish access token - create a repository secret NPM_TOKEN on your Github repository
Create a publish action
- copy
.github/workflows/publish.yml
in you repository - before pushing to
main
think of update the package version