You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

refs

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refs

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

0.9.8
latest
Source
npmnpm
Version published
Weekly downloads
897
3.94%
Maintainers
0
Weekly downloads
 
Created
Source

[!WARNING]
This package now has a new home: https://www.npmjs.com/package/refmerge [https://github.com/doublenot/refmerge]

Build Status Coverage Status

refs

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

Install:

$ npm install -g refs

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:

'use strict';

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

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

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

Or cli:

$ refs -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'

Keywords

json

FAQs

Package last updated on 14 Mar 2025

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