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

cf-compose-model

v0.1.9

Published

[![Codefresh build status]( https://g.codefresh.io/api/badges/build?repoOwner=codefresh-io&repoName=cf-compose-model&branch=master&pipelineName=cf-compose-model&accountName=codefresh-inc&type=cf-2)]( https://g.codefresh.io/repositories/codefresh-io/cf-com

Downloads

642

Readme

Codefresh Compose Model

Codefresh build status

Codefresh introducing CF-Compose-Model, our model for all compositions. Using our compose model you can:

  • Verify that your composition is valid on Codefresh.io

  • Convert Composition from one type to another

Example

More examples can be found here:

  • node example.js to run the basic examples we provided

'use strict';

const Promise      = require('bluebird');
const path         = require('path');
const CM           = require('cf-compose-model');
const ComposeModel = CM.ComposeModel;

    const path = './lib/model/tests/ComposeV1/ex1.yaml';

    console.log(`\n#############################\nExample load yaml from location ${locapathtion}\n#############################`);

    let location = path.resolve(__dirname, path);
    return ComposeModel.load(location)
        .then(compose => {
            return compose.getWarnings();
        })
        .then((warnings) => {
            console.log('\n===\nWarnings\n===');
            return Promise.map(warnings, (warning) => {
                console.log(warning.format());
            });

        })
        .then(() => {
            return cm.translate().toYaml();
        })
        .then((translated) => {
            console.log('\n===\nOutput\n===');
            console.log(translated);
        });

Installation

  • run npm install cf-compose-mode --save OR
  • clone this repo and npm isntall, yarn also supported

Api reference

Test

  • npm run unit_test
  • npm run e2e_test using the flow.yaml

Road-map:

  • [X] Support Compose V1
  • [X] Support Compose V2
  • [X] Support Compose V3
  • [ ] CLI tool - started!
  • [ ] ES5 module

Documantation

Become familiar with ComposeModel structure

ComposeModel holds inside 3 basic objects - each one of the objects holds in instances of CFNode class:

  • services
  • networks
  • volumes

More objects that ComposeModel holds:

  • originalYaml - the yaml file ComposeModel parsed. Optional
  • parser - the original parser class that used to parse the yaml. Optional
  • defaultTranslator - the translator that will be used if no other translator will be passed in translate method. The defaultTranslator exist only if the ComposeModel parsed some yaml and a translator exist for it.
  • policy - set of instructions that tell ComposeModel what are to possible warnings may each CFNode and CFLeaf have. The default value is the policy of the shared plan.

Methods of ComposeModel:

  • static:
    • parse(yaml) - Parse an yaml, search for a parser for the yaml file, parse it and return ComposeModel instance. Throw an error `parser not found' if there is no parser.
    • load(path) - Loads the yaml and parse it the same way the parse does.
  • public:
    • getAllServices() - return an object with all the services
    • getAllNetworks() - return an object with all the networks
    • getAllVolumes() - return an object with all the volumes
    • setPolicy(policy) - set the policy. Policies can be found in lib/model/policies.
    • addService(service) - add new service to the model
    • addNetwork(network) - add new network to the model
    • addVolume(volume) - add new volume to the model
    • translate(translator) - translate the model to yaml file, if translator not supplied the model will try to use the default translator if exist.
    • getWarnings() - return an array with all the warnings related to the model and the policy
    • fixWarnings(onlyAutoFix) - fix all the warnings on the model related to the policy. If onlyAutoFix flag is set then only warnings with this flag will be fixed.