New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’
Socket
Sign inDemoInstall
Socket

serverless-fragments

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-fragments - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

dist/src/ReusableServerlessTemplate.d.ts

4

dist/src/FragmentsProcessor.d.ts

@@ -45,3 +45,3 @@ export declare type Token = {

*/
static replaceTFile(dir: string, value: string, startIndex: number, endIndex: number, indentation: string): string;
static replaceTFile(dir: string, value: string, startIndex: number, endIndex: number, indentation: string, params: Map<string, string>): string;
static extractTFile(value: string, startIndex: number, endIndex: number): TFile;

@@ -58,3 +58,3 @@ static canReplace(value: string, startIndex: number, endIndex: number, params: Map<string, string>): boolean;

static toMap(params?: string): Map<string, string>;
private static mapToString;
static mapToString(params: Map<string, string>): string;
}

@@ -61,0 +61,0 @@ /**

@@ -37,3 +37,3 @@ "use strict";

const lastTFileStartToken = lastStartTokens.pop();
value = this.replaceTFile(dir, value, lastTFileStartToken.index, currentToken.index, lastTFileStartToken.indentation);
value = this.replaceTFile(dir, value, lastTFileStartToken.index, currentToken.index, lastTFileStartToken.indentation, params);
currentToken = lastTFileStartToken;

@@ -74,6 +74,7 @@ }

*/
static replaceTFile(dir, value, startIndex, endIndex, indentation) {
static replaceTFile(dir, value, startIndex, endIndex, indentation, params) {
const tFile = this.extractTFile(value, startIndex, endIndex);
const absoluteFilePath = path_1.join(dir, tFile.filePath);
console.log(`Loading ${path_1.basename(path_1.dirname(absoluteFilePath))}/${path_1.basename(absoluteFilePath)}(${this.mapToString(tFile.params)}), indented ${indentation.length}x' ', `);
const mergedParams = new Map([...params, ...tFile.params]);
console.log(`Loading ${path_1.basename(path_1.dirname(absoluteFilePath))}/${path_1.basename(absoluteFilePath)}(${this.mapToString(mergedParams)}), indented ${indentation.length}x' ', `);
let fileContent = fs_1.readFileSync(absoluteFilePath, 'utf8');

@@ -87,3 +88,3 @@ //convert json files content to yaml which allows us to e.g. keep configuration as JSON to be easily readable from js code as well

.join('\n');
return value.replace(tFile.placeholder, this.resolveTokensRecursive(dir, fileContent, tFile.params));
return value.replace(tFile.placeholder, this.resolveTokensRecursive(dir, fileContent, mergedParams));
}

@@ -206,3 +207,14 @@ static extractTFile(value, startIndex, endIndex) {

*/
exports.load = function (filePath, params, debug = false) {
exports.load = function (filePath, params = new Map(), debug = false) {
let paramName;
for (const arg of process.argv) {
if (arg.startsWith('--')) {
paramName = arg.substring(2);
}
else if (paramName) {
params.set(paramName, arg);
paramName = undefined;
}
}
console.log(`Processing ${filePath}, params (${FragmentsProcessor.mapToString(params)})`);
const resolvedTemplate = FragmentsProcessor.resolveTokensRecursive(path_1.dirname(filePath), fs_1.readFileSync(filePath, 'utf8'), params);

@@ -209,0 +221,0 @@ if (debug) {

{
"name": "serverless-fragments",
"version": "2.0.0",
"version": "2.1.0",
"main": "dist/src/index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -19,5 +19,3 @@ # Serverless fragments

A scope of the parameters passed to template#load function, as well as _tfile_ parameters, is the parent file only.
There are not propagated to nested templates to avoid bugs related to missing nested template parameters, which are
wrongly resolved by parent parameters.
Parameters including process arguments passed to serverless are passed recursively to child fragments loaded by tfile.

@@ -176,2 +174,3 @@ ## Placeholders

* process default variable values
* support multiline tfile declaration
* support multiline tfile declaration
* _2.1.0_ pass parameters to fragments recursively
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