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

@betafcc/herocoders

v2.0.1

Published

Downloads

1

Readme

Herocoders

Usage

npx @betafcc/herocoders

result

Explanation

In truth, for a simple task like this, I'd do a single deno script file:

#!/usr/bin/env -S deno run -A

// -- data extraction
const HOST = 'https://herocoders.atlassian.net/rest/api/3'

const [components, search] = await Promise.all([
  fetch(`${HOST}/project/SP/components`).then(r => r.json()),
  fetch(`${HOST}/search?jql=project=SP`).then(r => r.json()),
])

// -- data normalization
const table = search.issues.flatMap(issue =>
  // linearize by component
  issue.fields.components.map(component => ({
    issue,
    component,
    project: issue.fields.project,
  }))
)

// -- data analysis
// id of components without lead
const woLead = new Set(components.filter(c => !c.lead).map(c => c.id))

const result = table
  .filter(row => row.project.key === 'SP' && woLead.has(row.component.id))
  // looks scary but it's a standard `groupby` in reducer form
  .reduce((acc, next) => {
    const cid = next.component.id
    if (!(cid in acc)) acc[cid] = 0
    acc[cid] += 1
    return acc
  }, {})

// -- formatted output
console.table(
  Object.entries(result).map(([k, v]) => ({
    component: components.find(c => c.id === k).name,
    issues: v,
  }))
)
// ┌───────┬───────────────────┬────────┐
// │ (idx) │ component         │ issues │
// ├───────┼───────────────────┼────────┤
// │     0 │ "Synchronization" │      2 │
// │     1 │ "Backend"         │      1 │
// │     2 │ "Templates"       │      5 │
// └───────┴───────────────────┴────────┘

As overengineering a simple task is anti-yagni, and a mark of a Java programmer bad engineer.

But to show off some 'production-level' good practices, I will do a complete boilerplate, with the features:

  • formatting
  • linting
  • testing
  • github hooks for ci
  • github hooks for npm publish on merge main

Boilerplate

For quick 'production-level' code, I tend to use tsdx, so I don't worry about building for 1000 of environments correctly and I just need to tweak a bit the default configuration

npx tsdx create herocoders-node

Plus a personal script for making release easier, by automating git tagging, package.json version updating, and avoid triggering redundant github actions

I also tend to do exploration-development by using either node notebooks or a scratch folder, to be run on watch with the npm script:

npm run ts-node-dev ./scratch/jam.ts

And lastly, extension recommendations so people don't get crazy with inconsistent workflow per developer, while still having the freedom to use their own preferences

Dev-Workflow

Each developer can clone this repository and develop a feature under a feature branch:

git clone [email protected]:betafcc/herocoders
cd herocoders
git checkout -b feat/ds-123/my-ticket-feature

When it's done, the code can be pushed to origin and create PR, that will trigger github hooks to run some steps to allow the PR to be merged to main

When a PR is merged to main, other github hooks will run to publish the package to npm directly from the repository