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

occupant-website-auto-gen

v1.1.2

Published

Auto-Gen is available as a Node.js function or command line interface. The input to these is a set of font file paths, which will produce a set of objects that describe metadata about the fonts. Designed to be plugged into the Occupant Website generation

Downloads

11

Readme

Occupant Website Auto-Gen

Auto-Gen is available as a Node.js function or command line interface. The input to these is a set of font file paths, which will produce a set of objects that describe metadata about the fonts. Designed to be plugged into the Occupant Website generation process, giving a programmatic interface into aspects of their fonts to be featured on their website.

Installation

npm install occupant-website-auto-gen

Usage

Node.js

const autoGen = require('occupant-website-auto-gen')
const { glob } = require('glob')

;(async () => {
  const cwd = '/path/to/fonts'
  const fontPaths = await glob('**/*.woff2', { cwd })
  const { docs, stats } = await autoGen({ fontPaths, cwd })
})()

The function signature is autoGen({ fontPaths, cwd, includeOptionalFeatures=false }).

fontPaths is an array of font file paths where the directory name is the font series, and all file paths within this directory are in the shape {name}-{width?,VF?}-{weight?}{italic?}. For example:

  • a variable font would be FontName-VF.woff2
  • a font series without widths would be FontName-Weight.woff2 for the roman and FontName-WeightItalic.woff2 for the italic.
  • a font series with widths would be FontName-Width-Weight.woff2 for the roman and FontName-Width-WeightItalic.woff2 for the italic.

cwd is the path where these fontPaths are all relative to.

The return value is { docs, stats }. docs is an array of metadata files. These are the primary output of the function. stats is an object that includes information around what the function saw across all font files processed. This includes useful debugging information like if there was a font weight encountered that was not accounted for in the sorting process done within font-name-parts

CLI

npx auto-gen {cwd} --help will give the command line interface usage information. It can also be read in the source

Development

To actively develop this repo you will need a Node.js environment. nvm is recommended for this, as it gives affordances for switching between versions of Node.js within your terminal. The current version that is being used for development is captured in the .nvmrc file. At the time or writing this is v20.4.0.

# Run these from within this repository
# Activate the correct verseion of Node.js
$ nvm use
# Install dependencies
$ npm install

There are many ways to test the output of this repository, but since it is destined for use with the Occupant Website, it can be best to use it directly. npm link allows one to use a local version of a module, we can use this to link our local module for use within the Occupant Website.

# Starting at the root of this package
# Give our npm a reference to our local package
$ npm link
# change directories to the Occupant Website,
$ cd ../_OccupantWebsite
# or from within another terminal window that
# has access to the same `npm` we can link
# our local package
$ npm link occupant-website-auto-gen

We can now run auto-gen commands that will use our local package.

# From _OccupantWebsite
# Run an auto-gen build looking at a single font series to increase our
# iteration cycle time
$ npx auto-gen src/fonts --match=Allium/*.woff2 --output=src/_data/fonts
# Alternatively we can run an entire build which lives behind this npm command
$ npm run build:auto-gen
# The above command is the same as the following
$ npx auto-gen src/fonts --match=**/*.woff2 --output=src/_data/fonts