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

@runnable/octobear

v6.0.0

Published

_Docker Compose File parser for Runnable API Client_

Downloads

52

Readme

OctoBear

Docker Compose File parser for Runnable API Client

http://1.bp.blogspot.com/-aEL7JOFG33A/UxyzFBJ0RXI/AAAAAAAADus/4jmeE4FR3_g/s1600/5455426064_fca9750514_o.jpg

Usage

This module provides two functions:

parse

const octobear = require('@runnable/octobear')

octobear.parse({
  dockerComposeFileString: String, // String for `docker-compose.yml`
  dockerComposeFilePath: String, // Path to the Compose file
  repositoryName: String, // Name or repository. Used for naming the instances (Doesn't have to  correlate 1-to-1)
  ownerUsername: String, // User's github username. Used for pre-instance creation hostname generation
  userContentDomain: String // Runnable API user content domain. Used for pre-instance creation hostname generation
})
.then(results => )

The response correspond to the following schema:

{
  results: [{
    metadata: {
      name: String, // Name specified for service in `docker-compose.yml`
    },
    extends: {
      service: 'String', // name to the service to extend
      file: 'String' // path to the compose file where original service is registered
    },
    code: { // optional
      repo: 'String', // repo full name
      commitish: 'String' // Optional. Commit or branch
    }),
    build: {
      dockerFilePath: String, // Optional. Path for Dockerfile used to build instance,
      dockerBuildContext: String, // Optional. Path for Docker build context
    },
    files: { // Optional
      '/Dockerfile': {
      body: String // Body for Dockerfile to be used. Only specified if there is  no `buildDockerfilePath`			}
    },
    instance: {
      name: String, // Instance name. Different from name specified in `docker-compose.yml`,
      containerStartCommand: String, // Optional. Command provided to start instance
      ports: Array<Number>, // Array of number for ports
      env: Array<String> // Array of strings for env variables. Includes hostname substitution
    } 
  }],
  envFiles: [String] // Array of all ENV files that should be loaded,
  mains: {
    builds: { // includes all built main
      {serviceName}: result {value in results for this}
    },
    externals: {
      {serviceName}: results {value in results for this}
    }
  }
}

populateENVsFromFiles

const octobear = require('@runnable/octobear')

const composeFileAsString = '...'
octobear.findExtendedFiles(composeFileAsString)
.then((filesPathes) => {
  const composeFiles = fethcAllComposeFiles(filesPathes)
  return octobear.parseAndMergeMultiple({...}, composeFiles, envFiles)
  .then(({ results: services, envFiles }) =>  {
    const envFiles = getAllTheseFilesAsHashTable(res.envFiles) // An object with filesnames as keys and strings as values
    return populateENVsFromFiles(services, envFiles)
  })
})

Tests

In order to run tests locally you also need to pull submodules. The easiest way to do that is cloning repo with --recursive flag:

  git clone --recursive [email protected]:Runnable/octobear.git

To update them, use

git submodule update --init --recursive

Also, in order to run tests locally you'll need populate the environment variables in configs/.env. We suggest adding them to configs/.env.test.

There are three types of tests:

  1. Unit: Used to test individual functions
  2. Functional: Used to test the complete flow of a function. This should not use any external services.
  3. Integration: Used to test results of parsing against the Runnable API

Adding Submmodules

  1. Go into test/repos/${NAME}
  2. Run git init
  3. Run git add -A
  4. Run git commit -m ""
  5. Create repo in github
  6. Push changes to github
  7. rm -rf test/repos/${NAME} (It's in github, don't worry)
  8. git submodule add [email protected]:RunnableTest/${NAME}.git test/repos/${NAME}
  9. Run git status and make sure repo was added to .gitmodules and was added
  10. Add + Commit + Push octobear repo