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

import-map-storage-helper

v1.1.0

Published

Import-map-storage-helper is a CLI tool to assist you managing the storage of your Micro-frontend assets. If you use [single-spa](https://single-spa.js.org/) coupled with a CI to manage your micro-frontend project, you may generate many assets on your sto

Downloads

8

Readme

import-map-storage-helper

Import-map-storage-helper is a CLI tool to assist you managing the storage of your Micro-frontend assets. If you use single-spa coupled with a CI to manage your micro-frontend project, you may generate many assets on your storage provider. The first goal of the tool is to clean unused assets based on configurable rules to free space (and optimize cost). Import-map-storage-helper use the import-map-deployer APIs to list used assets. This first version only support Google Cloud Storage and contributions are welcome to add more storage providers.

Installation

Install from npm registry

npm install --global import-map-storage-helper

Usage

im-storage-helper help

the main command is clean :

  ____  _                               _   _      _
 / ___|| |_ ___  _ __ __ _  __ _  ___  | | | | ___| |_ __   ___ _ __
 \___ \| __/ _ \| '__/ _` |/ _` |/ _ \ | |_| |/ _ \ | '_ \ / _ \ '__|
  ___) | || (_) | | | (_| | (_| |  __/ |  _  |  __/ | |_) |  __/ |
 |____/ \__\___/|_|  \__,_|\__, |\___| |_| |_|\___|_| .__/ \___|_|
                           |___/                    |_|

Usage: im-storage-helper clean [options]

clean storage following the rules provided

Options:
  -d, --dry-run              Do not delete file, only print Action
  -c, --config <configfile>  configuration file path (relative to the current directory)
  -h, --help                 display help for command

Configuration

The default configuration file is a config.json file in the current directory. The --config option let specify a configuration file path.

The configuration file must be as followed :

{
  "storage": {
    "type": "gcs",
    "bucket": "my-assets",
    "pathPrefix": "my-prefix/",
    "assetBaseUrl": "https://assets.domain.com/"
  },
  "importMapDeployer": {
    "url": "http://localhost:5000"
  },
  "defaultAction": "keep",
  "rules": [
    {
      "name": "my-rule",
      "action": "keep",
      "versionSelector": "regex",
      "olderThan": {
        "amount": 2,
        "unit": "month"
      }
    },
    {
      "name": "my-rule2",
      "action": "delete",
      "olderThan": {
        "amount": 3,
        "unit": "month"
      }
    },
    {
      "name": "my-rule3",
      "action": "delete",
      "versionSelector": ".*-to-delete$"
    }
  ]
}

storage

Note that you must have the GOOGLE_APPLICATION_CREDENTIALS environment variable set for authentication.

  • type: Storage type (Google Cloud Storage = gcs). Only gcs available.
  • bucket: Google Storage bucket name
  • pathPrefix (Optional): the base path of assets in the bucket. It must end with a /.

The bucket may be organized like :

pathPrefix
    |- application1
    |   |- version1
    |   |   |- files
    |   |- version2
    |   |   |- files
    |- application2
    |   |- version1
    |   |   |- files
    |   |- version2
    |   |   |- files
  • assetBaseUrl: This the begining of the public URL assets. It must end with a /. Assets must accessed by ${assetUrl}${pathPrefix}application1/version1/... This URL must be the one used in the import-map.

import-map-deployer

Note that you must have the IMD_USERNAME and IMD_PASSWORD environment variables set for authentication.

defaultAction

This is the action performed when no rule match for application version. It can be one of keep or delete.

rules

Rules are the cleanning logic. They describe which application version must be kept and which must be deleted.

A rule has the following properties :

  • name: The rule name

  • action: The action to perform. (keep or delete)

  • versionSelector (optional): A javascript string pattern Regexp to select a version the rule can be applied

  • olderThan (optional): An object that represent a Duration. This let apply the rule only on version orlder than the given duration

    • amount: The amount of time
    • unit: The unit of the amount given. This must be one of available unit.

rules samples

delete old development version

Assuming that the development version look like 2.4.0-dev.3 and match "^\\d*.\\d*.\\d*-dev.\\d*". To delete development versions more than 3 weeks old use the following configuration :

{
  [...]
  "defaultAction": "keep",
  "rules": [
    {
      "name": "dev-3weeks-old",
      "action": "delete",
      "versionSelector": "^\\d*.\\d*.\\d*-dev.\\d*",
      "olderThan": {
        "amount": 3,
        "unit": "week"
      }
    }
  ]
}