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

organic-dna-repo-loader

v2.1.1

Published

Utility module for loading repo dna accordingly to stem skeleton 2.1 structure.

Downloads

15

Readme

organic-dna-repo-loader

Utility module for loading repo dna accordingly to stem skeleton v2.1 & v3.x.x structure.

Features:

  • [x] loading of repo's root /dna folder
  • [x] recognizing and loading repo's cells having dna folder in them
    • [x] automatically (slower)
    • [x] manually listed
  • [x] mounting cell's dna index as its root dna branch
  • [x] resolves refrences once all DNA folders are loaded into memory
  • [x] based on [email protected]
  • [x] defers DNA loading to existing implementation under cells/node_modules/lib/load-root-dna as per stem skeleton 2.1 concept.
  • [x] defers DNA loading to existing implementation under cells/packages/lib/load-root-dna as per stem skeleton 3.0.0 concept.

usage

install

$ npm i organic-dna-repo-loader

api

loadDNA({root, mod, skipExistingLoaderUsage: false}):Promise

Loads <root>/dna and any cell dna found with glob pattern <root>/cells/**/dna into memory by apply mode on the loaded DNA chunks before resolving.

  • root : String, a full path to folder containing dna and cells folders
  • mode : String, optional mode or combination of modes to instruct DNA folding, see organic-dna-cellmodes for more info.
  • skipExistingLoaderUsage : Boolean, defualts to false. If set to true will not use existing loader found at <repo>/cells/node_modules/lib/load-root-dna.js

example manual

//       /sample-repo-with-cell-paths
//       | - cells/cell1/dna/index.yaml
//       | - dna/branch.json
//       | - dna/common.yaml
# cells/cell1/dna/index.yaml
cellInfo: v1
cellPaths: # Array of path relative paths to cells
 - 'cells/cell1' 
// usage 

const loadDNA = require('organic-dna-repo-loader')
const dna = await loadDNA(process.cwd() + '/sample-repo')

expect(dna).toDeepEqual({
  branch: {
    property: "value"
  },
  cells: {
    cell1: {
      build: {
        myProperty: "value"
      }
    }
  },
  common: {
    property: "value"
  }
})

example automatic

:warning: this method doesn't scale well with increased amount of cells to search for, so it is useful up to 20 cells.

//       /sample-repo
//       | - cells/cell1/dna/index.yaml
//       | - dna/branch.json
//       | - dna/common.yaml

const loadDNA = require('organic-dna-repo-loader')
const dna = await loadDNA(process.cwd() + '/sample-repo')

expect(dna).toDeepEqual({
  branch: {
    property: "value"
  },
  cells: {
    cell1: {
      build: {
        myProperty: "value"
      }
    }
  },
  common: {
    property: "value"
  }
})

existing dna loader

The implementation is designed to check for existence of <repo>/cells/node_modules/lib/load-root-dna.js and if it is present to require that instead of the original logic.

It is expected that this existing dna loader module exports the following

module.exports = async function (mode) {
  return DNA
}

ie, it should accept mode, load the respective repo DNA and return it as Promise.

Usually the existing dna loader can be implemented using organic-dna-repo-loader as its first step like so:

const loadDNA = require('organic-dna-repo-loader')
module.exports = async function (mode) {
  let repoDNA = loadDNA({
    root: __dirname, // or any other way to indicate repo's root folder
    mode,
    skipExistingLoaderUsage: true
  })
  // augment repoDNA ...
  return repoDNA
}