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

read-cortex-json

v3.6.1

Published

The thing cortex uses to read cortex.json files or fallback to read cortex configurations from package.json

Downloads

43

Readme

read-cortex-json NPM version Build Status Dependency Status

The thing cortex uses to read cortex.json files or fallback to read cortex configurations from package.json.

Cortex supports both cortex.json and the 'cortex' field of package.json. But with read-cortex-json, you don't have to care about all this, and you should ALWAYS use this module to read and save cortex.json.

Install

npm install read-cortex-json --save

Usage

var cortexJson = require('read-cortex-json');

cortexJson.read(cwd, callback)

  • cwd path current working directory
  • callback function(err, json)
  • err Error
  • json Object

Reads and returns the information of a cortex package.

cortexJson.read('/path/to/your/repo', function(err, json){
  if (err) {
    console.error('There was an error', e);
    return;
  }
  
  console.log('The package data is:', json);
});

cortexJson.extra(cwd, callback)

This method is different from cortexJson.read() that it will validate some stuff and flavors the object with some default values which cortex registry needs.

cortexJson.clean(cwd, json, callback)

Cleans and validate the json.

This method will check the json object first. If it is an old object, cortexJson.clean will santitize it.

After cortexJson.clean() and cortexJson.enhanced(), there are always

  • main, if no main entry found, it will be false
  • css, if no csses found, it will be []
  • entries, if no entries found, it will be [].
  • cortex.main will be require.resolve()d. That is, if there is a index.js, but cortex.main is 'index', and after enhanced(), cortex.main will be 'index.js'.
  • cortex.css and cortex.entries will always be an globbed array(even an empty array) after enhanced()
  • If a path, either from main, css, or entries, is explicitly defined but not found, an error will throw.
  • If a package has neither main, css, nor entries, an 'CORTEX_NO_ENTRY' error will throw.

in the json data.

cortexJson.enhance(cwd, callback)

It is a cortexJson.extra() then cortexJson.clean()

cortexJson.save(cwd, json, callback)

  • callback function(err)

Save the json to the file.

cortexJson.package_root(cwd, callback)

  • callback function(root)

Traverses up from the cwd and gets the first directory that contains a package file of cortex.

Sometimes user might run cortex commands inside the subtle directories of the current repo, and we must make sure cortex commands always run at the root directory.

cortexJson.cached_document(name, cache_root, callback)

  • name String package name
  • cache_root path cache directory of the current profile
  • callback function(err, document)
  • document json

Gets the cached document.