Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

refs-compiler

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refs-compiler

Compiler for YAML, JSON and INI files using path references

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Coverage Status Build Status

References Compiler

Compiler for YAML, JSON and INI files using path references

Install

# npm
# global
$ npm install -g refs-compiler

# dev dependency
$ npm install refs-compiler --save-dev

# Yarn
# global
$ yarn global add refs-compiler

# dev dependency
$ yarn add refs-compiler -D

Example: YAML

Template(s)
AWSTemplateFormatVersion: '2010-09-09'

Resources:
  - $ref: ./relative/path/to/file.yaml
RolePolicies:
  $ref: ./resources/role-policies.yaml
Type: 'AWS::IAM::Policy'
Properties:
  PolicyName: custom-role
  Roles:
    - custom-role
  PolicyDocument:
    Version: '2012-10-17'
    Statement:
      -
        Sid: PassRole
        Effect: Allow
        Resource:
          -
            'Fn::Join':
              - ""
              -
                - 'arn:aws:iam::'
                -
                  Ref: 'AWS::AccountId'
                - ':role/*'
        Action:
          - 'iam:PassRole'

Code

// CommonJS
const path = require('path');
const { default: compiler } = require('refs-compiler');
// ES6
import path from 'path';
import compiler from 'refs-compiler';

const inputTemplate = path.resolve('/path/to/template.yaml');
const outputFile = path.resolve(`/path/to/output.yaml`);

try {
  compiler(inputTemplate, outputFile)
      .then(results => {
          console.log(`file created in ${results.outputFile}`);
      })
      .catch(error => {
          console.log(`An error occurred while writing the file: ${error.message}`);
          console.log(error.stack);
      });
} catch (e) {
  console.error(e.message);
  console.error(e.stack);
}

CLI

$ refs-compiler -o ./build/output.yaml ./templates/template.yaml

Output

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  - RolePolicies:
      Type: 'AWS::IAM::Policy'
      Properties:
        PolicyName: custom-role
        Roles:
          - custom-role
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Sid: PassRole
              Effect: Allow
              Resource:
                - 'Fn::Join':
                    - ''
                    - - 'arn:aws:iam::'
                      - Ref: 'AWS::AccountId'
                      - ':role/*'
              Action:
                - 'iam:PassRole'

Acknowledgement

The base code was borrowed from doublenot/refs and then refactored / rewritten to support NodeJS 8+ using native Promises + async/await

Keywords

FAQs

Package last updated on 29 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc