1.0.2 • Published 3 years ago
@chrisguest75/09_shell_mandlebrot v1.0.2
README
Demonstrates how to package a typescript tool to npm to be run as npx
How to run
npm install
# run once
npm run start
How to develop
npm run start:dev
Publish
After writing some code you can publish it.
# make sure you update the package version in package.json before updating
npm version patch
# publish it
npm publish --access public
Run as npx
Run the published package
# run and print out palette
npx @chrisguest75/09_shell_mandlebrot
How to recreate
Create folder
mkdir xx_project_name
Create
Setup typescript for a basic nodejs project
npm init --scope=@chrisguest75 -y
npm install typescript @types/node ts-node nodemon rimraf --save-dev
# get typescript version
./node_modules/typescript/bin/tsc --version
# create tsconfig.json
npx tsc --init --rootDir src --outDir build \
--esModuleInterop --resolveJsonModule --lib es6 \
--module commonjs --allowJs true --noImplicitAny true
Add a nodemonConfig to package.json
"nodemonConfig": {
"watch": ["src", "nodemon.json", "tsconfig.json", "package.json"],
"ext": "ts",
"ignore": [],
"exec": "ts-node ./src/index.ts"
}
#run
Copy the template ./src folder to the new project
```bash
cp ./src ../xx_project_name
Copy over the package.json scripts
"scripts": {
"build": "rimraf ./build && tsc",
"lint": "eslint . --ext .ts",
"start:dev": "nodemon",
"test": "echo \"Error: no test specified\" && exit 1"
},
#add the nodemon.json and run
npm run start:dev
Resources
https://itnext.io/step-by-step-building-and-publishing-an-npm-typescript-package-44fe7164964c
https://cameronnokes.com/blog/the-30-second-guide-to-publishing-a-typescript-package-to-npm/
zn+1 = zn2 + c