JSPM

  • Created
  • Published
  • Downloads 145342
  • Score
    100M100P100Q169464F
  • License MIT

Build info utility

Package Exports

  • @netlify/build-info

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@netlify/build-info) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Node

Build Info

Build information detection utility.

The purpose of this lib is to, given a project and a configuration, return a set of useful data for our build system. Currently it's used to detect:

But it's possible to extend it in the future to extract other bits of information, such as the heuristics present in the build-image.

Example (Node.js)

const { getBuildInfo } = require('./src/main')

(async () => {
  console.log(await getBuildInfo({ projectDir: 'path/to/site', rootDir: '/project/root/dir' }))
  // {
  //   jsWorkspaces: {
  //     isRoot: false,
  //     packages: [
  //       'path/to/site',
  //       'path/to/component/library'
  //       'path/to/utility/library'
  //     ]
  //   },
  //   frameworks: [
  //     {
  //        name: 'gatsby',
  //        category: 'static_site_generator',
  //        dev: {
  //          commands: ['gatsby develop'],
  //          port: 8000
  //        },
  //        build: {
  //          commands: ['gatsby build'],
  //          directory: 'public'
  //        },
  //        env: { GATSBY_LOGGER: 'yurnalist' },
  //        plugins: []
  //      }
  //    ]
  // }

  console.log(await getBuildInfo({ projectDir: '/project/root/dir' }))
  // {
  //   jsWorkspaces: {
  //     isRoot: true,
  //     packages: [
  //       'path/to/site',
  //       'path/to/component/library'
  //       'path/to/utility/library'
  //     ]
  //   },
  //   frameworks: []
  // }
})();

Example (CLI)

$ build-info /project/root/dir
{
  jsWorkspaces: {
    isRoot: true,
    packages: [
      'path/to/site',
      'path/to/component/library'
      'path/to/utility/library'
    ]
  },
  frameworks: []
}

$ build-info path/to/site --rootDir /project/root/dir
{
  jsWorkspaces: {
    isRoot: false,
    packages: [
      'path/to/site',
      'path/to/component/library'
      'path/to/utility/library'
    ]
  },
  frameworks: [
    {
       name: 'gatsby',
       category: 'static_site_generator',
       dev: {
         commands: ['gatsby develop'],
         port: 8000
       },
       build: {
         commands: ['gatsby build'],
         directory: 'public'
       },
       env: { GATSBY_LOGGER: 'yurnalist' },
       plugins: []
     }
  ]
}

Contributors

Please see CONTRIBUTING.md for instructions on how to set up and work on this repository. Thanks for contributing!