1.0.5 • Published 3 years ago

@wns-test/wns-test-ms v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

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

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 the build directory
{
    ...
    "scripts": {
        "clean": "del .build/*",
        "build": "npm run clean && tsc"
    },
    ...
}
  • make sure to gitignore build/

  • fill main, types and files in package.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 git@github.com:**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
1.0.2

3 years ago

1.0.1

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago