countcores
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Gets the number of cores of machine

Summary

  1. Write your library in index.ts
  2. npm run build : Generate types index.d.ts and library index.js via typescript tsc into dist/ folder
  3. Create a story for your library like trial1.stories.ts, importing from index.js to demo it on localhost:6006
  4. npm pub Package and publish dist/ folder

How to Use

npm install countcores
import numcores from 'countcores';
console.log(numcores)

publishing npm package

  • package.json
    • Add "main": "dist/index.js", - Published module entry point is here
    • Add "files" : ["dist","README.md"], - Only publishes files in dist and README.md to npm
    • Add "types" : "dist/index.d.ts" - Detect types entry point
  • tsconfig.json
    • Add "outDir": "./dist", - Output to dist folder
    • Add "exclude": ["dist",...] - Do not typecheck generated files
    • Add "declaration": true, - generate index.d.ts
    • Add "typeRoots": ["@types", "node_modules/@types"], - detect your own custom types folder @types
      • mkdir @types and add global.d.ts

Typedoc

  • Note: no need to install typedoc since the plugins with install the appropriate version
npm install typedoc-plugin-missing-exports
npm install --save-dev typedoc-umlclass

Add these script to package.json

  "scripts": {
    "build": "npm run clean && tsc",
    "clean": "tsc --build --clean",
    "cleandoc": "rm -r docs",
    "doc": "typedoc --entryPointStrategy resolve .",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
npm run build
npm run cleandoc
npm run doc

Storybook

  • trial.stores.ts is the story that uses our demo library.
npx storybook init
# select HTML
export NODE_OPTIONS=--openssl-legacy-provider
npm storybook start
#visit localhost:6006

Deploy docs

Choose to deploy w/ github action as static page template

Modify path: '.' ==> path: './docs'

        with:
          # Upload entire repository
          path: './docs'

Dependents (0)

Package Sidebar

Install

npm i countcores

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

33.2 kB

Total Files

7

Last publish

Collaborators

  • userjy