From 5a287a0716f95c5c82d4028826efd73e195c2f0b Mon Sep 17 00:00:00 2001 From: Joshua Napoli Date: Wed, 14 Dec 2022 20:24:05 -0500 Subject: [PATCH 1/6] Upgrade to @actions/core@^1.10.0 Fixes #54 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ee6a8fb..5b8cd08 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ } }, "dependencies": { - "@actions/core": "^1.9.1", + "@actions/core": "^1.10.0", "js-yaml": "^3.13.1", "lodash.get": "^4.4.2" }, diff --git a/yarn.lock b/yarn.lock index 73de142..b3a0fe9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@actions/core@^1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.9.1.tgz#97c0201b1f9856df4f7c3a375cdcdb0c2a2f750b" - integrity sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA== +"@actions/core@^1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.0.tgz#44551c3c71163949a2f06e94d9ca2157a0cfac4f" + integrity sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug== dependencies: "@actions/http-client" "^2.0.1" uuid "^8.3.2" From 83b52b283744b433301f79eefc8060e6117a02b2 Mon Sep 17 00:00:00 2001 From: Joshua Napoli Date: Wed, 14 Dec 2022 22:45:05 -0500 Subject: [PATCH 2/6] Use JMESPath queries Fixes #32 --- README.md | 27 ++++++++++++++++++++++----- env/test.yml | 3 +++ package.json | 4 ++-- src/generateEachPath.js | 8 +++++--- test/unit/main.test.js | 11 ++++++++++- test/unit/readYaml.test.js | 19 ++++++++++++++++++- yarn.lock | 10 +++++----- 7 files changed, 65 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 28aaa02..3910efb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This action reads a YAML file and outputs selected properties. -The action uses lodash.get to access properties at the provided paths. The `file` input is the only required input. All other inputs are mapped into equally named outputs with the value at the given paths. +The action uses a [JMESPath](https://jmespath.org/) query to access properties at the provided paths. The `file` is the only input required. All other inputs are mapped into equally named outputs with the value at the given paths. ## Inputs @@ -10,9 +10,9 @@ The action uses lodash.get to access properties at the provided paths. The `file **Required** The name of the file to load. -### `name: path` +### `name: query` -Give each path to look-up as a `name: path` input pair. +Give each path to look-up as a `name: query` input pair. ## Outputs @@ -29,8 +29,8 @@ provider: ``` A step definition like this: -```yml -uses: CumulusDS/get-yaml-paths-action@v0.1.0 +```yaml +uses: CumulusDS/get-yaml-paths-action@v0.2.0 with: file: file.yml bar: foo.bar @@ -38,6 +38,23 @@ with: ``` sets the `bar` output to `baz` and sets the `providerstage` output (note all lower-case) to `green`. +Object and array outputs are JSON-serialized. For example, given an input file `qux.yml`: +```yaml +qux: + - bar: hello + - bar: world +``` + +A step definition like this: +```yaml +uses: CumulusDS/get-yaml-paths-action@v0.2.0 +with: + file: qux.yml + bars: qux[].bar +``` + +Sets the `bars` output to `["hello","world"]`. + ## CloudFormation The CloudFormation YAML schema is supported. The input file can contain the CloudFormation template tags: diff --git a/env/test.yml b/env/test.yml index 3ac568f..f53fde7 100644 --- a/env/test.yml +++ b/env/test.yml @@ -2,3 +2,6 @@ foo: bar: baz provider: stage: green +qux: + - bar: hello + - bar: world diff --git a/package.json b/package.json index 5b8cd08..bc153d3 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ }, "dependencies": { "@actions/core": "^1.10.0", - "js-yaml": "^3.13.1", - "lodash.get": "^4.4.2" + "jmespath": "^0.16.0", + "js-yaml": "^3.13.1" }, "devDependencies": { "@babel/core": "^7.17.8", diff --git a/src/generateEachPath.js b/src/generateEachPath.js index 20d4402..37c4836 100644 --- a/src/generateEachPath.js +++ b/src/generateEachPath.js @@ -1,14 +1,16 @@ // @flow -import get from "lodash.get"; +// $FlowFixMe[untyped-import] +import jmespath from "jmespath"; export default function* generateEachPath( document: {}, paths: { [string]: string } ): Iterable<{ name: string, value: string }> { for (const name of Object.keys(paths)) { - const path = paths[name]; - const value = get(document, path); + const query = paths[name]; + const result = jmespath.search(document, query); + const value = typeof result === "object" ? JSON.stringify(result) : result; yield { name, value }; } } diff --git a/test/unit/main.test.js b/test/unit/main.test.js index c5b904e..e73ca71 100644 --- a/test/unit/main.test.js +++ b/test/unit/main.test.js @@ -10,10 +10,19 @@ describe("main", () => { const OLD_ENV = process.env; it("calls setOutput when successful", async () => { - process.env = { INPUT_FILE: "env/test.yml", INPUT_A: "foo.bar", INPUT_B: "provider.stage", NOT_INPUT_C: "c" }; + process.env = { + INPUT_FILE: "env/test.yml", + INPUT_A: "foo.bar", + INPUT_B: "provider.stage", + NOT_INPUT_C: "c", + INPUT_D: "qux[].bar", + INPUT_E: "foo" + }; await main(); expect(core.setOutput).toHaveBeenCalledWith("a", "baz"); expect(core.setOutput).toHaveBeenCalledWith("b", "green"); + expect(core.setOutput).toHaveBeenCalledWith("d", '["hello","world"]'); + expect(core.setOutput).toHaveBeenCalledWith("e", '{"bar":"baz"}'); }); it("calls setFailed when unsuccessful", async () => { diff --git a/test/unit/readYaml.test.js b/test/unit/readYaml.test.js index 6b98bb7..ad3adad 100644 --- a/test/unit/readYaml.test.js +++ b/test/unit/readYaml.test.js @@ -4,7 +4,24 @@ import readYaml from "../../src/readYaml"; describe("readYaml", () => { it("reads a yaml file", () => - expect(readYaml("env/test.yml")).resolves.toEqual({ foo: { bar: "baz" }, provider: { stage: "green" } })); + expect(readYaml("env/test.yml")).resolves.toMatchInlineSnapshot(` + Object { + "foo": Object { + "bar": "baz", + }, + "provider": Object { + "stage": "green", + }, + "qux": Array [ + Object { + "bar": "hello", + }, + Object { + "bar": "world", + }, + ], + } + `)); it("reads a CloudFormation yaml file", () => expect(readYaml("env/cfn.yml")).resolves.toMatchObject({ diff --git a/yarn.lock b/yarn.lock index b3a0fe9..6056725 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4988,6 +4988,11 @@ jest@^26.0.0: import-local "^3.0.2" jest-cli "^26.6.3" +jmespath@^0.16.0: + version "0.16.0" + resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.16.0.tgz#b15b0a85dfd4d930d43e69ed605943c802785076" + integrity sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw== + "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -5216,11 +5221,6 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" -lodash.get@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" - integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= - lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" From 3bc9a6659d3660a82c555e6d40f7305fbea2209a Mon Sep 17 00:00:00 2001 From: Joshua Napoli Date: Wed, 14 Dec 2022 22:46:33 -0500 Subject: [PATCH 3/6] Upgrade to @babel/core@^7.18.6 Fixes vulnerability Cxc7705965-e0f0 --- package.json | 2 +- yarn.lock | 214 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 212 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index bc153d3..0bc1c9d 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "js-yaml": "^3.13.1" }, "devDependencies": { - "@babel/core": "^7.17.8", + "@babel/core": "^7.18.6", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3", "@babel/preset-env": "^7.8.3", "@babel/preset-flow": "^7.16.7", diff --git a/yarn.lock b/yarn.lock index 6056725..deab645 100644 --- a/yarn.lock +++ b/yarn.lock @@ -38,6 +38,13 @@ dependencies: "@babel/highlight" "^7.16.7" +"@babel/code-frame@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a" + integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q== + dependencies: + "@babel/highlight" "^7.18.6" + "@babel/compat-data@^7.12.7": version "7.12.7" resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.12.7.tgz#9329b4782a7d6bbd7eef57e11addf91ee3ef1e41" @@ -48,7 +55,12 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.17.7.tgz#078d8b833fbbcc95286613be8c716cef2b519fa2" integrity sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ== -"@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.17.8", "@babel/core@^7.7.5": +"@babel/compat-data@^7.20.0": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.5.tgz#86f172690b093373a933223b4745deeb6049e733" + integrity sha512-KZXo2t10+/jxmkhNXc7pZTqRvSOIvVv/+lJwHS+B2rErwOyjuVRh60yVpb7liQ1U5t7lLJ1bz+t8tSypUZdm0g== + +"@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.7.5": version "7.17.8" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.8.tgz#3dac27c190ebc3a4381110d46c80e77efe172e1a" integrity sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ== @@ -69,6 +81,27 @@ json5 "^2.1.2" semver "^6.3.0" +"@babel/core@^7.18.6": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.5.tgz#45e2114dc6cd4ab167f81daf7820e8fa1250d113" + integrity sha512-UdOWmk4pNWTm/4DlPUl/Pt4Gz4rcEMb7CY0Y3eJl5Yz1vI8ZJGmHWaVE55LoxRjdpx0z259GE9U5STA9atUinQ== + dependencies: + "@ampproject/remapping" "^2.1.0" + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.20.5" + "@babel/helper-compilation-targets" "^7.20.0" + "@babel/helper-module-transforms" "^7.20.2" + "@babel/helpers" "^7.20.5" + "@babel/parser" "^7.20.5" + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.20.5" + "@babel/types" "^7.20.5" + convert-source-map "^1.7.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.2.1" + semver "^6.3.0" + "@babel/generator@^7.17.3", "@babel/generator@^7.17.7": version "7.17.7" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.7.tgz#8da2599beb4a86194a3b24df6c085931d9ee45ad" @@ -78,6 +111,15 @@ jsesc "^2.5.1" source-map "^0.5.0" +"@babel/generator@^7.20.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.20.5.tgz#cb25abee3178adf58d6814b68517c62bdbfdda95" + integrity sha512-jl7JY2Ykn9S0yj4DQP82sYvPU+T3g0HFcWTqDLqiuA9tGRNIj9VfbtXGAYTTkyNEnQk1jkMGOdYka8aG/lulCA== + dependencies: + "@babel/types" "^7.20.5" + "@jridgewell/gen-mapping" "^0.3.2" + jsesc "^2.5.1" + "@babel/helper-annotate-as-pure@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.10.4.tgz#5bf0d495a3f757ac3bda48b5bf3b3ba309c72ba3" @@ -103,6 +145,16 @@ browserslist "^4.17.5" semver "^6.3.0" +"@babel/helper-compilation-targets@^7.20.0": + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz#6bf5374d424e1b3922822f1d9bdaa43b1a139d0a" + integrity sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ== + dependencies: + "@babel/compat-data" "^7.20.0" + "@babel/helper-validator-option" "^7.18.6" + browserslist "^4.21.3" + semver "^6.3.0" + "@babel/helper-create-class-features-plugin@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.12.1.tgz#3c45998f431edd4a9214c5f1d3ad1448a6137f6e" @@ -138,6 +190,11 @@ dependencies: "@babel/types" "^7.16.7" +"@babel/helper-environment-visitor@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz#0c0cee9b35d2ca190478756865bb3528422f51be" + integrity sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg== + "@babel/helper-explode-assignable-expression@^7.10.4": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.12.1.tgz#8006a466695c4ad86a2a5f2fb15b5f2c31ad5633" @@ -163,6 +220,14 @@ "@babel/template" "^7.16.7" "@babel/types" "^7.16.7" +"@babel/helper-function-name@^7.19.0": + version "7.19.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz#941574ed5390682e872e52d3f38ce9d1bef4648c" + integrity sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w== + dependencies: + "@babel/template" "^7.18.10" + "@babel/types" "^7.19.0" + "@babel/helper-get-function-arity@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.4.tgz#98c1cbea0e2332f33f9a4661b8ce1505b2c19ba2" @@ -191,6 +256,13 @@ dependencies: "@babel/types" "^7.16.7" +"@babel/helper-hoist-variables@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz#d4d2c8fb4baeaa5c68b99cc8245c56554f926678" + integrity sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q== + dependencies: + "@babel/types" "^7.18.6" + "@babel/helper-member-expression-to-functions@^7.12.1": version "7.12.7" resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.12.7.tgz#aa77bd0396ec8114e5e30787efa78599d874a855" @@ -212,6 +284,13 @@ dependencies: "@babel/types" "^7.16.7" +"@babel/helper-module-imports@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz#1e3ebdbbd08aad1437b428c50204db13c5a3ca6e" + integrity sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA== + dependencies: + "@babel/types" "^7.18.6" + "@babel/helper-module-transforms@^7.12.1", "@babel/helper-module-transforms@^7.17.7": version "7.17.7" resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.17.7.tgz#3943c7f777139e7954a5355c815263741a9c1cbd" @@ -226,6 +305,20 @@ "@babel/traverse" "^7.17.3" "@babel/types" "^7.17.0" +"@babel/helper-module-transforms@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.2.tgz#ac53da669501edd37e658602a21ba14c08748712" + integrity sha512-zvBKyJXRbmK07XhMuujYoJ48B5yvvmM6+wcpv6Ivj4Yg6qO7NOZOSnvZN9CRl1zz1Z4cKf8YejmCMh8clOoOeA== + dependencies: + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-module-imports" "^7.18.6" + "@babel/helper-simple-access" "^7.20.2" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/helper-validator-identifier" "^7.19.1" + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.20.1" + "@babel/types" "^7.20.2" + "@babel/helper-optimise-call-expression@^7.10.4": version "7.12.7" resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.12.7.tgz#7f94ae5e08721a49467346aa04fd22f750033b9c" @@ -271,6 +364,13 @@ dependencies: "@babel/types" "^7.17.0" +"@babel/helper-simple-access@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz#0ab452687fe0c2cfb1e2b9e0015de07fc2d62dd9" + integrity sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA== + dependencies: + "@babel/types" "^7.20.2" + "@babel/helper-skip-transparent-expression-wrappers@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.12.1.tgz#462dc63a7e435ade8468385c63d2b84cce4b3cbf" @@ -292,6 +392,18 @@ dependencies: "@babel/types" "^7.16.7" +"@babel/helper-split-export-declaration@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz#7367949bc75b20c6d5a5d4a97bba2824ae8ef075" + integrity sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-string-parser@^7.19.4": + version "7.19.4" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63" + integrity sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw== + "@babel/helper-validator-identifier@^7.10.4": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" @@ -302,11 +414,21 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz#9c97e30d31b2b8c72a1d08984f2ca9b574d7a076" integrity sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g== +"@babel/helper-validator-identifier@^7.19.1": + version "7.19.1" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" + integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w== + "@babel/helper-validator-option@^7.12.1", "@babel/helper-validator-option@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz#b203ce62ce5fe153899b617c08957de860de4d23" integrity sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ== +"@babel/helper-validator-option@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz#bf0d2b5a509b1f336099e4ff36e1a63aa5db4db8" + integrity sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw== + "@babel/helper-wrap-function@^7.10.4": version "7.12.3" resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.12.3.tgz#3332339fc4d1fbbf1c27d7958c27d34708e990d9" @@ -326,7 +448,16 @@ "@babel/traverse" "^7.17.3" "@babel/types" "^7.17.0" -"@babel/highlight@^7.10.4", "@babel/highlight@^7.16.7": +"@babel/helpers@^7.20.5": + version "7.20.6" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.20.6.tgz#e64778046b70e04779dfbdf924e7ebb45992c763" + integrity sha512-Pf/OjgfgFRW5bApskEz5pvidpim7tEDPlFtKcNRXWmfHGn9IEI2W2flqRQXTFb7gIPTyK++N6rVHuwKut4XK6w== + dependencies: + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.20.5" + "@babel/types" "^7.20.5" + +"@babel/highlight@^7.10.4", "@babel/highlight@^7.16.7", "@babel/highlight@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf" integrity sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g== @@ -340,6 +471,11 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.8.tgz#2817fb9d885dd8132ea0f8eb615a6388cca1c240" integrity sha512-BoHhDJrJXqcg+ZL16Xv39H9n+AqJ4pcDrQBGZN+wHxIysrLZ3/ECwCBUch/1zUNhnsXULcONU3Ei5Hmkfk6kiQ== +"@babel/parser@^7.18.10", "@babel/parser@^7.20.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.5.tgz#7f3c7335fe417665d929f34ae5dceae4c04015e8" + integrity sha512-r27t/cy/m9uKLXQNWWebeCUHgnAZq0CpG1OwKRxzJMP1vpSU4bSIK2hq+/cp0bQxetkXx38n09rNu8jVkcK/zA== + "@babel/plugin-proposal-async-generator-functions@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.12.1.tgz#dc6c1170e27d8aca99ff65f4925bd06b1c90550e" @@ -946,6 +1082,15 @@ "@babel/parser" "^7.16.7" "@babel/types" "^7.16.7" +"@babel/template@^7.18.10": + version "7.18.10" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.18.10.tgz#6f9134835970d1dbf0835c0d100c9f38de0c5e71" + integrity sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/parser" "^7.18.10" + "@babel/types" "^7.18.10" + "@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.5", "@babel/traverse@^7.17.3", "@babel/traverse@^7.7.0": version "7.17.3" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.3.tgz#0ae0f15b27d9a92ba1f2263358ea7c4e7db47b57" @@ -962,6 +1107,22 @@ debug "^4.1.0" globals "^11.1.0" +"@babel/traverse@^7.20.1", "@babel/traverse@^7.20.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.5.tgz#78eb244bea8270fdda1ef9af22a5d5e5b7e57133" + integrity sha512-WM5ZNN3JITQIq9tFZaw1ojLU3WgWdtkxnhM1AegMS+PvHjkM5IXjmYEGY7yukz5XS4sJyEf2VzWjI8uAavhxBQ== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.20.5" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-function-name" "^7.19.0" + "@babel/helper-hoist-variables" "^7.18.6" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/parser" "^7.20.5" + "@babel/types" "^7.20.5" + debug "^4.1.0" + globals "^11.1.0" + "@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.5", "@babel/types@^7.12.7", "@babel/types@^7.16.7", "@babel/types@^7.17.0", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@^7.7.0": version "7.17.0" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.0.tgz#a826e368bccb6b3d84acd76acad5c0d87342390b" @@ -970,6 +1131,15 @@ "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" +"@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.19.0", "@babel/types@^7.20.2", "@babel/types@^7.20.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.5.tgz#e206ae370b5393d94dfd1d04cd687cace53efa84" + integrity sha512-c9fst/h2/dcF7H+MJKZ2T0KjEQ8hY/BNnDk/H3XY8C4Aw/eWQXWn/lWntHF9ooUBnGmEvbfGrTgLWc+um0YDUg== + dependencies: + "@babel/helper-string-parser" "^7.19.4" + "@babel/helper-validator-identifier" "^7.19.1" + to-fast-properties "^2.0.0" + "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" @@ -1271,7 +1441,7 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" -"@jridgewell/gen-mapping@^0.3.0": +"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2": version "0.3.2" resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== @@ -2282,6 +2452,16 @@ browserslist@^4.17.5: node-releases "^2.0.1" picocolors "^1.0.0" +browserslist@^4.21.3: + version "4.21.4" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.4.tgz#e7496bbc67b9e39dd0f98565feccdcb0d4ff6987" + integrity sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw== + dependencies: + caniuse-lite "^1.0.30001400" + electron-to-chromium "^1.4.251" + node-releases "^2.0.6" + update-browserslist-db "^1.0.9" + bser@2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/bser/-/bser-2.1.1.tgz#e6787da20ece9d07998533cfd9de6f5c38f4bc05" @@ -2360,6 +2540,11 @@ caniuse-lite@^1.0.30001286: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001300.tgz#11ab6c57d3eb6f964cba950401fd00a146786468" integrity sha512-cVjiJHWGcNlJi8TZVKNMnvMid3Z3TTdDHmLDzlOdIiZq138Exvo0G+G0wTdVYolxKb4AYwC+38pxodiInVtJSA== +caniuse-lite@^1.0.30001400: + version "1.0.30001439" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001439.tgz#ab7371faeb4adff4b74dad1718a6fd122e45d9cb" + integrity sha512-1MgUzEkoMO6gKfXflStpYgZDlFM7M/ck/bgfVCACO5vnAf0fXoNVHdWtqGU+MYca+4bL9Z5bpOVmR33cWW9G2A== + capture-exit@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/capture-exit/-/capture-exit-2.0.0.tgz#fb953bfaebeb781f62898239dabb426d08a509a4" @@ -2913,6 +3098,11 @@ electron-to-chromium@^1.4.17: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.49.tgz#5b6a3dc032590beef4be485a4b0b3fe7d0e3dfd7" integrity sha512-k/0t1TRfonHIp8TJKfjBu2cKj8MqYTiEpOhci+q7CVEE5xnCQnx1pTa+V8b/sdhe4S3PR4p4iceEQWhGrKQORQ== +electron-to-chromium@^1.4.251: + version "1.4.284" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz#61046d1e4cab3a25238f6bf7413795270f125592" + integrity sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA== + emittery@^0.7.1: version "0.7.2" resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.7.2.tgz#25595908e13af0f5674ab419396e2fb394cdfa82" @@ -5093,6 +5283,11 @@ json5@^2.1.2: dependencies: minimist "^1.2.5" +json5@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" + integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== + jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" @@ -5526,6 +5721,11 @@ node-releases@^2.0.1: resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.1.tgz#3d1d395f204f1f2f29a54358b9fb678765ad2fc5" integrity sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA== +node-releases@^2.0.6: + version "2.0.7" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.7.tgz#593edbc7c22860ee4d32d3933cfebdfab0c0e0e5" + integrity sha512-EJ3rzxL9pTWPjk5arA0s0dgXpnyiAbJDE6wHT62g7VsgrgQgmmZ+Ru++M1BFofncWja+Pnn3rEr3fieRySAdKQ== + node-stream-zip@^1.15.0: version "1.15.0" resolved "https://registry.yarnpkg.com/node-stream-zip/-/node-stream-zip-1.15.0.tgz#158adb88ed8004c6c49a396b50a6a5de3bca33ea" @@ -7317,6 +7517,14 @@ unset-value@^1.0.0: has-value "^0.3.1" isobject "^3.0.0" +update-browserslist-db@^1.0.9: + version "1.0.10" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz#0f54b876545726f17d00cd9a2561e6dade943ff3" + integrity sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ== + dependencies: + escalade "^3.1.1" + picocolors "^1.0.0" + uri-js@^4.2.2: version "4.4.1" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" From cb479027bca5b0fd7a3f02668ca7a7c43d2f9ab3 Mon Sep 17 00:00:00 2001 From: Joshua Napoli Date: Wed, 14 Dec 2022 23:17:17 -0500 Subject: [PATCH 4/6] Special characters must be quoted in the query Closes #21 --- README.md | 19 +++++++++++++++++++ env/test.yml | 1 + src/main.js | 1 + test/unit/main.test.js | 4 +++- test/unit/readYaml.test.js | 1 + 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3910efb..938c8cd 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,25 @@ The CloudFormation YAML schema is supported. The input file can contain the Clou - `!Split` - `!Sub` +## Possible Issues + +### Quoting Special Characters + +Keys with hyphens and other special characters should be quoted in the query. For example, given an input file like this: +```yaml +foo-bar: baz +``` + +Then use a step definition like this: +```yaml +uses: CumulusDS/get-yaml-paths-action@v0.2.0 +with: + file: file.yml + foobar: '"foo-bar"' +``` + +The query should be `"foo-bar"` to get the value of the `foo-bar` key. Without the quotes, the query would be interpreted as a numerical subtraction, which would result in an error. + # See Also [get-json-paths-action](https://github.com/gr2m/get-json-paths-action) diff --git a/env/test.yml b/env/test.yml index f53fde7..cfaace7 100644 --- a/env/test.yml +++ b/env/test.yml @@ -5,3 +5,4 @@ provider: qux: - bar: hello - bar: world +foo-bar: 7 diff --git a/src/main.js b/src/main.js index 36bac66..eadf4e6 100644 --- a/src/main.js +++ b/src/main.js @@ -15,6 +15,7 @@ export default async function main() { core.setOutput(name, value); } } catch (error) { + console.log(error); core.setFailed(error.message); process.exit(1); } diff --git a/test/unit/main.test.js b/test/unit/main.test.js index e73ca71..39d6160 100644 --- a/test/unit/main.test.js +++ b/test/unit/main.test.js @@ -16,13 +16,15 @@ describe("main", () => { INPUT_B: "provider.stage", NOT_INPUT_C: "c", INPUT_D: "qux[].bar", - INPUT_E: "foo" + INPUT_E: "foo", + INPUT_F: '"foo-bar"' }; await main(); expect(core.setOutput).toHaveBeenCalledWith("a", "baz"); expect(core.setOutput).toHaveBeenCalledWith("b", "green"); expect(core.setOutput).toHaveBeenCalledWith("d", '["hello","world"]'); expect(core.setOutput).toHaveBeenCalledWith("e", '{"bar":"baz"}'); + expect(core.setOutput).toHaveBeenCalledWith("f", 7); }); it("calls setFailed when unsuccessful", async () => { diff --git a/test/unit/readYaml.test.js b/test/unit/readYaml.test.js index ad3adad..ae8999d 100644 --- a/test/unit/readYaml.test.js +++ b/test/unit/readYaml.test.js @@ -9,6 +9,7 @@ describe("readYaml", () => { "foo": Object { "bar": "baz", }, + "foo-bar": 7, "provider": Object { "stage": "green", }, From cd3608e03915732ec0692a89aa15f40588d1f2de Mon Sep 17 00:00:00 2001 From: Joshua Napoli Date: Wed, 14 Dec 2022 23:21:53 -0500 Subject: [PATCH 5/6] Document GitHub Runner Warning Closes #7 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 938c8cd..5ae2f8a 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,15 @@ with: The query should be `"foo-bar"` to get the value of the `foo-bar` key. Without the quotes, the query would be interpreted as a numerical subtraction, which would result in an error. +### GitHub Runner Warning + +The inputs to this action cannot be statically defined or listed in the actions.yml definition. This results in a nuisance warning from the Actions Runner like this: +``` +Warning: Unexpected input(s) '...', valid inputs are ['file'] +``` + +The [actions/runner#514](https://github.com/actions/runner/issues/514) issue tracks this limitation of the Actions Runner. + # See Also [get-json-paths-action](https://github.com/gr2m/get-json-paths-action) From 769116b0d7b771f49802bf8353c3e32546e4a535 Mon Sep 17 00:00:00 2001 From: Joshua Napoli Date: Wed, 14 Dec 2022 23:25:54 -0500 Subject: [PATCH 6/6] Remove unused libdef --- flow-typed/npm/lodash.get_vx.x.x.js | 33 ----------------------------- 1 file changed, 33 deletions(-) delete mode 100644 flow-typed/npm/lodash.get_vx.x.x.js diff --git a/flow-typed/npm/lodash.get_vx.x.x.js b/flow-typed/npm/lodash.get_vx.x.x.js deleted file mode 100644 index 14a6595..0000000 --- a/flow-typed/npm/lodash.get_vx.x.x.js +++ /dev/null @@ -1,33 +0,0 @@ -// flow-typed signature: b6ac2ec7cb1fc7f35b183b5ff74fdefe -// flow-typed version: <>/lodash.get_v^4.4.2/flow_v0.112.0 - -/** - * This is an autogenerated libdef stub for: - * - * 'lodash.get' - * - * Fill this stub out by replacing all the `any` types. - * - * Once filled out, we encourage you to share your work with the - * community by sending a pull request to: - * https://github.com/flowtype/flow-typed - */ - -declare module 'lodash.get' { - declare module.exports: any; -} - -/** - * We include stubs for each file inside this npm package in case you need to - * require those files directly. Feel free to delete any files that aren't - * needed. - */ - - -// Filename aliases -declare module 'lodash.get/index' { - declare module.exports: $Exports<'lodash.get'>; -} -declare module 'lodash.get/index.js' { - declare module.exports: $Exports<'lodash.get'>; -}