ramper-v2 v0.0.1
Ramper V2
Development
Set up tools and environment
You need to have Node.js installed. Node includes npm as its default package manager.
Open the whole package folder with a good code editor, preferably Visual Studio Code. Consider installing VS Code extensions ES Lint and Prettier.
In the VS Code top menu: Terminal -> New Terminal
Install dependencies
Install dependencies with npm:
npm i
Write your code
Make necessary changes in package.json (name, version, description, keywords, author, homepage and other URLs).
Write your code in src folder, and unit test in test folder, replacing the original files there.
The VS Code shortcuts for formatting of a code file are: Shift + Alt + F (Windows); Shift + Option (Alt) + F (MacOS); Ctrl + Shift + I (Linux).
Change code linting and formatting settings in .prettierrc.js if you want.
Test
Test your code with Jest framework:
npm run test
Note: Example TypeScript Package uses husky, pinst and commitlint to automatically execute test and lint commit message before every commit.
Build
Build production (distribution) files in your dist folder:
npm run build
It generates CommonJS (in dist/cjs folder), ES Modules (in dist/esm folder), bundled and minified UMD (in dist/umd folder), as well as TypeScript declaration files (in dist/types folder).
Try it before publishing
Run:
npm link
npm link will create a symlink in the global folder, which may be {prefix}/lib/node_modules/ramper-v2 or C:\Users\\AppData\Roaming\npm\node_modules\ramper-v2.
Create an empty folder elsewhere, you don't even need to npm init
(to generate package.json). Open the folder with VS Code, open a terminal and just run:
npm link ramper-v2
This will create a symbolic link from globally-installed ramper-v2 to node_modules/ of the current folder.
You can then create a, for example, testnum.ts file with the content:
import { Num } from 'ramper-v2'
console.log(new Num(5).add(new Num(6)).val() === 11)
If you don't see any linting errors in VS Code, if you put your mouse cursor over Num
and see its type, then it's all good.
Whenever you want to uninstall the globally-installed ramper-v2 and remove the symlink in the global folder, run:
npm uninstall ramper-v2 -g
Prepare to publish
Create an npm account.
Manual publishing to npm
Log in:
npm adduser
And publish:
npm publish
This package is configured to use GitHub Actions CI/CD to automate both the npm and GitHub Packages publishing process. The following are what you have to do.
Notes
- It uses npm but you can easily switch to yarn, of course (remember to change all "npm" in
scripts
in the file package.json)- Whether you use npm as your package manager ≠ Whether you can publish to the npm registry
- Works fine in VS Code. In my configuration .eslintrc and .prettierrc cooperate perfectly
- See
scripts
in package.json for other predefined script commands - pinst is used to solve a problem of husky
- The installation of the package with npm, yarn v1 and yarn v2+ is ensured in this test