From 9b6fddd60f3f4a7193952aae17359f07e352928d Mon Sep 17 00:00:00 2001 From: Dan Erickson Date: Thu, 18 Apr 2019 11:54:12 -0600 Subject: [PATCH] Adds support for java properties file format --- README.md | 19 +++++++++++++++---- package.json | 1 + src/file.ts | 2 ++ test/file.spec.ts | 1 + yarn.lock | 5 +++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3f68759..ebcd916 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![CircleCI](https://img.shields.io/circleci/project/github/sbstjn/serverless-stack-output.svg)](https://circleci.com/gh/sbstjn/serverless-stack-output) [![Coveralls](https://img.shields.io/coveralls/sbstjn/serverless-stack-output.svg)](https://coveralls.io/github/sbstjn/serverless-stack-output) -A [serverless](https://serverless.com) plugin to store output from your AWS CloudFormation Stack in JSON/YAML/TOML files, or to pass the output to a JavaScript function for further processing. +A [serverless](https://serverless.com) plugin to store output from your AWS CloudFormation Stack in JSON/YAML/TOML/PROPERTIES files, or to pass the output to a JavaScript function for further processing. ## Usage @@ -28,7 +28,7 @@ plugins: custom: output: handler: scripts/output.handler # Same syntax as you already know - file: .build/stack.toml # toml, yaml, yml, and json format is available + file: .build/stack.toml # toml, yaml, yml, json, and properties format is available ``` ### Handler @@ -45,7 +45,7 @@ module.exports = { handler } ### File Formats -Just name your file with a `.json`, `.toml`, `.yaml`, or `.yml` extension, and the plugin will take care of formatting your output. Please make sure the location where you want to save the file exists! +Just name your file with a `.json`, `.toml`, `.yaml`, `.yml`, or `.properties` extension, and the plugin will take care of formatting your output. Please make sure the location where you want to save the file exists! ## License @@ -161,4 +161,15 @@ ServerlessDeploymentBucketName: sls-stack-output-example-serverlessdeploymentbuc "ServiceEndpoint": "https://APIGatewayID.execute-api.us-east-1.amazonaws.com/dev", "ServerlessDeploymentBucketName": "sls-stack-output-example-serverlessdeploymentbuck-BucketID" } -``` \ No newline at end of file +``` + +#### PROPERTIES + +```properties +ExampleUserSecret = YourUserSecretKey +ExampleUserKey = YourUserAccessKey +ExampleLambdaFunctionQualifiedArn = arn:aws:lambda:us-east-1:AccountID:function:sls-stack-output-example-dev-example:9 +ExampleStaticValue = example-static-value +ServiceEndpoint = https://APIGatewayID.execute-api.us-east-1.amazonaws.com/dev +ServerlessDeploymentBucketName = sls-stack-output-example-serverlessdeploymentbuck-BucketID +``` diff --git a/package.json b/package.json index abe53e7..aeae147 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "output" ], "dependencies": { + "properties": "^1.2.1", "tomlify-j0.4": "^2.0.0", "yamljs": "^0.3.0" }, diff --git a/src/file.ts b/src/file.ts index 5ea6295..3c795b0 100644 --- a/src/file.ts +++ b/src/file.ts @@ -16,6 +16,8 @@ export default class StackOutputFile { case 'YAML': case 'YML': return require('yamljs').stringify(data) + case 'PROPERTIES': + return require('properties').stringify(data) default: throw new Error('No formatter found for `' + ext + '` extension') } diff --git a/test/file.spec.ts b/test/file.spec.ts index eca7bfe..e3bb8be 100644 --- a/test/file.spec.ts +++ b/test/file.spec.ts @@ -18,6 +18,7 @@ describe('File', () => { {file: 'test.yml', valid: true, type: 'yaml', data: `foo: bar\n`}, {file: 'test.json', valid: true, type: 'json', data: `{\n "foo": "bar"\n}`}, {file: 'test.toml', valid: true, type: 'toml', data: 'foo = "bar"'}, + {file: 'test.properties', valid: true, type: 'properties', data: 'foo = bar'}, {file: 'test.zip', valid: false} ], (data) => { diff --git a/yarn.lock b/yarn.lock index 97a6158..d522996 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1821,6 +1821,11 @@ private@^0.1.6: version "0.1.7" resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" +properties@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/properties/-/properties-1.2.1.tgz#0ee97a7fc020b1a2a55b8659eda4aa8d869094bd" + integrity sha1-Dul6f8AgsaKlW4ZZ7aSqjYaQlL0= + prr@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a"