JSPM

refmerge

0.9.7
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q23852F
  • License MIT

Compile and merge YAML, JSON or INI config files together through file path references

Package Exports

  • refmerge
  • refmerge/index.js

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 (refmerge) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status Coverage Status

refmerge

Compile and merge YAML, JSON or INI config files together through file path references

Install:

$ npm install -g refmerge

Example: YAML

Template(s):

AWSTemplateFormatVersion: '2010-09-09'

Resources:
  - $ref: ./resources/role-policies.yaml
RolePolicies:
  $ref: ./resources/role-policy-iam-custom-role.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:

'use strict';

const path = require('path');
const refmerge = require('refmerge');

const templateDir = `${__dirname}/../templates`;
const buildDir = `${__dirname}/../build`;
const inputTemplate = path.resolve(`${templateDir}/template.yaml`);
const outputFile = path.resolve(`${buildDir}/output-template.yaml`);

try {
  refmerge(inputTemplate, outputFile)
    .then((results) => {
      console.log(`\n  File written: ${results.outputFile}`);
    });
} catch (e) {
  console.error(e.message);
  console.error(e.stack);
}

Or cli:

$ refmerge -o ./build/output.yaml ./templates/main.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'