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

frontman

v0.0.1

Published

Manage yaml frontmatter using cson from the command line

Downloads

2

Readme

frontman Build Status NPM version

Manage yaml front-matter from the command line --- like a boss

Description

Frontman is supplied one or more filenames and an option template filename. Each file can be of any supported type (plain text, text with a yaml front matter block, yaml files, json files, or cson files). Frontman will combine meta data and/or content from the template file with meta data and/or content in the base file, writing the results to stdio. Meta data in the template file will join or replace meta data from the first file. If the template file is a cson file the base file meta data is available to the template using the @document object and the content is available as @document.__content.

Warning... this is a work in progress. The usage is changing rapidly. I'm still discovering new ways to use this. Feedback is welcome.

Install

npm install -g frontman

Features and command line usage

  1. Add front matter to an existing file using a template. Any meta data (or content if present) in the template file will be added to replace meta data in the base file. Other meta data in the base file will remain untouched. If the base file or the template file are cson files the code is while reading.

    frontman {filename} -t {template}

  2. Replace front matter in an existing file using a template. Like #1 any meta data (or content if present) in the template file will be added to replace meta data in the base file. However, in this case if a meta data key is not explicitly references in the template it is removed.

    frontman {filename} -t {template} -r

  3. Process template and convert to json (or cson or yml). Same as #1 except output json formatted meta data.

    frontman {filename} -t {template} -j

  4. Convert an existing file or creating a new file based on a template. This is useful for converting a file to a front-matter file (or json, cson, or yaml file) or creating a new file based on a template. If the source is a cson file the code is processed. Other file types are simply converted to a file containing a front-matter block.

    frontman {filename}

  5. Remove front matter. Since no template file is supplied and the replace flag is set the resulting output will be the content from the source file without front matter.

    frontman {filename} -r

Templates

Templates are text files containing front-matter meta data and/or content that will be merged with or replace the existing front-matter and/or content in the input. If the -r flag is specified the front-matter from the template will replace all front-matter in the base file. Without the -r flag data in the front-matter is added to existing values in the input file. If the template (or input file) is a cson file (as determined by the file extension) the code in the cson file is executed. If the template file is a cson file the base file variables are available to the template using @document object and the content is available as @document.__content. See the examples below.

Examples

  1. Adding or replacing front matter (this is a valid json file; a cson or yml file will also work):

    {
      "title": "title",
      "date": "12-12-12"
    }
  2. Modifying front matter (this is a cson file, only cson files can reference the base file):

    {
      name: @document.name
      description: @document.name
      value: @document.value*10
      date: new Date()
      length: @document.__content.length
    }
  1. Templating a new file (this is a cson file, only cson files can call functions such as Date()):

    {
      title: "Title Here"
      description: ""
      date: new Date()
      tags: [ 'post' ]
      layout: 'post'
      __content: "Your content here"
    }

Try out a live example now

License

Copyright (c) 2013 Jayson Harshbarger Gittip donate button Paypal donate button

MIT License

Acknowledgments

Built using generator-commader and autocmdr.