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

fs-docker

v1.0.0

Published

Scan filesystem directory for Dockerfiles and create metadata output.

Downloads

34

Readme

npm version CI

FS Docker 💾

This is a library to scan for docker images in a defined directory and associate them to (nested) groups 🔥.

Table of Contents

Installation

npm install fs-docker --save

Specification

Image

An image is in most cases represented by a Dockerfile in a directory. In some cases the image is also described with some meta information by an image descriptor file (image.json). But the descriptor file can also be a replacement for the Dockerfile.

The scan result object has the following 5 base properties:

  • id The Identifier is a way to identify the image beside the name property.

  • name Like already mentioned in th description for the id property.

  • groupId The groupId is the directory name of the last group, if not otherwise specified with the id property in an image-group.json file.

  • path The path is the relative path on the host machine, with different path separators (windows: \\, linux: /) depending on the operating system.

  • virtualPath The virtualPath is a path only containing group ids and the own image id, seperated with /.

These properties can be extended by providing a image.json file in the same directory as the Dockerfile.

Group

A group has the same base properties as an image, expect of the groupId property. The only other difference is, that the descriptor file must be named image-group.json.

Usage

To demonstrate the usage of the package, the test data directory path (test/data) is used as scan path, to simplify how to replicate the code example and use it for an own use cases.

import {scanDirectory} from "fs-docker";

(async () => {
    // Provide a base directory path to scan
    const directoryPath = 'test/data';

    const scanResult = scanDirectory(directoryPath);

    console.log(scanResult);
});

Output

{
      "images": [
        {
          "id": "image",
          "name": "Cool image",
          "groupId": "group",
          "path": "group\\image",
          "virtualPath": "group/image"
        },
        {
          "id": "meta-id",
          "name": "MetaId",
          "groupId": "sub-sub-group",
          "path": "group\\undefined\\sub-sub-group\\image",
          "virtualPath": "group/sub-sub-group/meta-id"
        },
        {
          "id": "image",
          "name": "image",
          "groupId": null,
          "path": "image",
          "virtualPath": "image"
        }
      ],
      "groups": [
          {
              "name": "Group",
              "license": "MIT",
              "id": "group",
              "virtualPath": "group",
              "path": "group"
          },
          {
              "name": "SubGroup",
              "id": "sub-group",
              "virtualPath": "group/sub-group",
              "path": "group\\sub-group"
          },
          {
              "name": "SubSubGroup",
              "id": "sub-sub-group",
              "virtualPath": "group/sub-sub-group",
              "path": "group\\undefined\\sub-sub-group"
          }
      ]
    }

The above output was captured on a Windows machine. Therefore, the path values are seperated with \\ instead of a / like on a linux machine.