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

aocity

v1.0.5

Published

[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![jsdocs][jsdocs-src]][jsdocs-href]

Downloads

28

Readme

🌆🎄 aocity

npm version npm downloads jsdocs

aocity is a elegant CLI for Advent of Code.

  • Scaffolds a minimal setup for AoC with the folder structure: <root>/<year>/<day>
  • Downloads your input file and saves it locally
  • Template support for other languages
  • Supports both JavaScript and TypeScript, powered by ESBuild
  • Provides an elegant run() function and utlities

🚧 This project is under heavy development.

Usage

Setup:

[pnpm|npm|yarn|bun] init
[pnpm|npm|yarn|bun] install aocity

Then run pnpm aoc init (you may have to checkout for other package managers, or just add aoc as a package.json script.)

This will scaffold a year folder for your current year by default.

At this point, you'll have to add your Advent of Code browser session key, this requires a few more steps.

  1. Open adventofcode.com and log in.
  2. Open your Chrome or Firefox Devtools (F12).
  3. Go to Application tab.
  4. On the sidebar, under Storage section, expand Cookies and click on https://adventofcode.com.
  5. Now you're seeing 3 cookies, one of them must be named session. Copy it's value.
  6. Save this in a .env file with the name AOC_SESSION in the root. You could also save this into your shell's rc, as this session lasts a very long time.

Now, to start a day, run: pnpm aoc start <day>.

This will scaffold your day folder, downloads your input and instructions and saves them locally, generates a minimal TypeScript file and starts the development server.

Utils

run()

Runs your solutions with utils and pretty formatting. It will also measure your performance with node:perf_hooks.

It has two props, part1 and part2. Both are structurally the same.

You can destructure context to use utlities like readInput, sum, product, asc, desc, by.

readInput()

This is just a fancy abstraction for reading your input file as we execute built files directly in a worker thread from dist.

It takes a single parameter, lines or groups and returns a list.

  • lines splits your input by newlines. (\n)
  • groups splits your input by groups. (\n\n)

input

This is the raw input file, nothing else.

sum() and product()

Adds/Multiplies two numbers.

asc and desc

This are compareFns for Array.sort().

  • asc sorts your list by ascending order.
  • desc sorts your list by decending order.

Templates

You can make custom templates for different languages, by placing them in the templates/ folder at the root.

For example, a Rust template could look like this:

.
├── 2023
└── templates
    └── rust
        ├── .aocity.json
        ├── Cargo.toml
        └── src
            └── main.rs

Your .aocity.json's contents are important:

{
  "runner": "cargo run"
}

This gets removed in the end and the runner script is added to your year's runner.

Now, you can start with pnpm aoc start -d 1 -t rust, where -t/--template is the name of your template folder.

The next time, it will remember and will run your runner command on file changes.

License

Copyright (c) 2023 taskylizard. MIT Licensed.