npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@robotical/learning-site-tools

v1.0.6

Published

This packages contains tools shared between Sanity and Learning site.

Downloads

3

Readme

Step 1

echo "node_modules
/lib" >> .gitignore 

Step 2

npm install --save-dev typescript

Step 3

echo '
{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "declaration": true,
        "outDir": "./lib",
        "strict": true
    },
    "include": ["src"],
    "exclude": ["node_modules", "**/__tests__/*"]
}' >> tsconfig.json

Step 4

mkdir src

Step 5

echo "export const Greeter = (name: string) =>'Hello ' + name;" >> src/index.ts

Step 6

Add a build command in the scripts of packages.json like so: "build" : "tsc"

Step 7

Add "files": ["lib/**/*"] in the first level of packages.json

Formatting and linting

Step 1

npm install --save-dev prettier tslint tslint-config-prettier

Step 2

echo '
{
   "extends": ["tslint:recommended", "tslint-config-prettier"]
}' >> tslint.json

Step 3

echo '
{
  "printWidth": 120,
  "trailingComma": "all",
  "singleQuote": true
}
' >> .prettierrc

Step 4

Add the lint- and format scripts to package.json like so:

    "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
    "lint": "tslint -p tsconfig.json",

Testing

Step 1

npm install --save-dev jest ts-jest @types/jest

Step 2

echo '
{
  "transform": {
    "^.+.(t|j)sx?$": "ts-jest"
  },
  "testRegex": "(/__tests__/(.*test)).(jsx?|tsx?)$",
  "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
}
' >> jestconfig.json

Step 3

add "test": "jest --config jestconfig.json" in the scripts of packages.json

Step 4

mkdir src/__tests__

Step 5

echo '
import { Greeter } from "../index";
test("My Greeter", () => {
  expect(Greeter("Carl")).toBe("Hello Carl");
});
' >> src/__tests__/Greeter.test.ts

Step 6

Replase the scripts in packages.json with these:

    "format": "prettier --write 'src/**/*.ts'",
    "lint": "tslint -p tsconfig.json",
    "build": "tsc",
    "prepare" : "npm run build",
    "prepublishOnly" : "npm test && npm run lint",
    "preversion" : "npm run lint",
    "version" : "npm run format && git add -A src",
    "postversion" : "git push && git push --tags",
    "test": "jest --config jestconfig.json"

Step 7

Add in the first level of packages.json these:

    "main": "lib/index.js",
    "types": "lib/index.d.ts",

Publishing

Info -- you can skip

prepare will run both BEFORE the package is packed and published, and on local npm install. Perfect for running building the code in package.json: "prepare" : "npm run build"

prepublishOnly will run BEFORE prepare and ONLY on npm publish. Here we will run our test and lint to make sure we don’t publish bad code: in package.json: "prepublishOnly" : "npm test && npm run lint"

preversion will run before bumping a new package version. To be extra sure that we’re not bumping a version with bad code, why not run lint here as well? 😃 in package.json: "preversion" : "npm run lint"

version will run after a new version has been bumped. If your package has a git repository, like in our case, a commit and a new version-tag will be made every time you bump a new version. This command will run BEFORE the commit is made. One idea is to run the formatter here and so no ugly code will pass into the new version: in package.json: "version" : "npm run format && git add -A src"

postversion will run after the commit has been made. A perfect place for pushing the commit as well as the tag. in package.json: "postversion" : "git push && git push --tags"

Step 1

npm run prepare && npm run prepublishOnly && npm run preversion

Step 2

Bump version

Step 3

npm run version && npm run postversion && npm publish

Publishing all commands

npm run prepare && npm run prepublishOnly && npm run preversion && npm run version && npm run postversion && npm publish -access public