From 3fd874ac76d515955d4e726a024f347b361d180e Mon Sep 17 00:00:00 2001 From: Guillaume ROUCHON Date: Tue, 12 Mar 2024 13:56:24 +0100 Subject: [PATCH] make variable names case-insensitive --- CHANGELOG.md | 4 ++++ README.md | 11 ++++++----- tasks/ReplaceTokensV6/CHANGELOG.md | 3 +++ tasks/ReplaceTokensV6/README.md | 11 ++++++----- tasks/ReplaceTokensV6/package-lock.json | 12 ++++++------ tasks/ReplaceTokensV6/package.json | 2 +- tasks/ReplaceTokensV6/task.json | 2 +- tasks/ReplaceTokensV6/tests/L0.ts | 13 ++++++------- vss-extension.json | 2 +- 9 files changed, 34 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecd35e5..ca9593f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 5.0.1 +Task 6.0.1 +- Fix missing default variables due to case-sensitivity ([#8](https://github.com/qetza/replacetokens-task/issues/8)). + ## 5.0.0 Task 6.0.0 - **Breaking changes**: the task was completely rewritten to use the npm package [@qetza/replacetokens](https://www.npmjs.com/package/@qetza/replacetokens) and be more similar with the new [ReplaceTokens GitHub Actions](https://github.com/marketplace/actions/replacetokens): diff --git a/README.md b/README.md index b226c11..4fdfe63 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ The task was completely rewritten to use the npm package [@qetza/replacetokens]( # Optional. Default: false addBOM: '' - # A YAML formatted string containing additional variable values. + # A YAML formatted string containing additional variable values (keys are case-insensitive). # YAML can be: # - an object: properties will be parsed as key/value pairs # - a string starting with '@': value is parsed as multiple glob patterns separated @@ -91,11 +91,12 @@ The task was completely rewritten to use the npm package [@qetza/replacetokens]( # Example: # - '@**/*.json;**/*.yml;!**/local/*' # - '$COMPUTER_VARS' - # - - # var1: '${{ parameters.var1 }}' + # - var1: '${{ parameters.var1 }}' # - # will add all variables from '.json' and '.yml' files except under 'local' directory, - # from the environment variable 'COMPUTER_VARS' and the inline variable 'var1' + # will add all variables from: + # - '.json' and '.yml' files except under 'local' directory, + # - the environment variable 'COMPUTER_VARS' + # - the inline variable 'var1' # # Optional. additionalVariables: '' diff --git a/tasks/ReplaceTokensV6/CHANGELOG.md b/tasks/ReplaceTokensV6/CHANGELOG.md index adfb54c..a804066 100644 --- a/tasks/ReplaceTokensV6/CHANGELOG.md +++ b/tasks/ReplaceTokensV6/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 6.0.1 +- Fix missing default variables due to case-sensitivity ([#8](https://github.com/qetza/replacetokens-task/issues/8)). + ## 6.0.0 - **Breaking changes**: the task was completely rewritten to use the npm package [@qetza/replacetokens](https://www.npmjs.com/package/@qetza/replacetokens) and be more similar with the new [ReplaceTokens GitHub Actions](https://github.com/marketplace/actions/replacetokens): - support only node 16 diff --git a/tasks/ReplaceTokensV6/README.md b/tasks/ReplaceTokensV6/README.md index 5edaa6e..e7d0b13 100644 --- a/tasks/ReplaceTokensV6/README.md +++ b/tasks/ReplaceTokensV6/README.md @@ -76,7 +76,7 @@ The task was completely rewritten to use the npm package [@qetza/replacetokens]( # Optional. Default: false addBOM: '' - # A YAML formatted string containing additional variable values. + # A YAML formatted string containing additional variable values (keys are case-insensitive). # YAML can be: # - an object: properties will be parsed as key/value pairs # - a string starting with '@': value is parsed as multiple glob patterns separated @@ -91,11 +91,12 @@ The task was completely rewritten to use the npm package [@qetza/replacetokens]( # Example: # - '@**/*.json;**/*.yml;!**/local/*' # - '$COMPUTER_VARS' - # - - # var1: '${{ parameters.var1 }}' + # - var1: '${{ parameters.var1 }}' # - # will add all variables from '.json' and '.yml' files except under 'local' directory, - # from the environment variable 'COMPUTER_VARS' and the inline variable 'var1' + # will add all variables from: + # - '.json' and '.yml' files except under 'local' directory, + # - the environment variable 'COMPUTER_VARS' + # - the inline variable 'var1' # # Optional. additionalVariables: '' diff --git a/tasks/ReplaceTokensV6/package-lock.json b/tasks/ReplaceTokensV6/package-lock.json index 2311ea3..f22fe03 100644 --- a/tasks/ReplaceTokensV6/package-lock.json +++ b/tasks/ReplaceTokensV6/package-lock.json @@ -117,9 +117,9 @@ } }, "node_modules/@qetza/replacetokens": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@qetza/replacetokens/-/replacetokens-1.2.0.tgz", - "integrity": "sha512-AuwUV7HX9QDEOFpdANrjuwseSPoSs4dZx9ibucdEtJ7Wr5ao/gDl+CX2/kYNpxdyNZCFX2gv+UXYoAlsRmISvw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@qetza/replacetokens/-/replacetokens-1.3.0.tgz", + "integrity": "sha512-iegsgIQy2QLllm6UMHKlI6jHCuUPqexOvFwM4tRX6H+OucOeWou6FzghCOKr1/Khi6cUm5ejeFkNUuA0uESiyw==", "dependencies": { "fast-glob": "^3.3.2", "iconv-lite": "^0.6.3", @@ -1127,9 +1127,9 @@ "integrity": "sha512-CAOgFOKLybd02uj/GhCdEeeBjOS0yeoDeo/CA7ASBSmenpZHAKGB3iDm/rv3BQLcabb/OprDEsSQ1y0P8A7Siw==" }, "@qetza/replacetokens": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@qetza/replacetokens/-/replacetokens-1.2.0.tgz", - "integrity": "sha512-AuwUV7HX9QDEOFpdANrjuwseSPoSs4dZx9ibucdEtJ7Wr5ao/gDl+CX2/kYNpxdyNZCFX2gv+UXYoAlsRmISvw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@qetza/replacetokens/-/replacetokens-1.3.0.tgz", + "integrity": "sha512-iegsgIQy2QLllm6UMHKlI6jHCuUPqexOvFwM4tRX6H+OucOeWou6FzghCOKr1/Khi6cUm5ejeFkNUuA0uESiyw==", "requires": { "fast-glob": "^3.3.2", "iconv-lite": "^0.6.3", diff --git a/tasks/ReplaceTokensV6/package.json b/tasks/ReplaceTokensV6/package.json index 7b7c5eb..0044fa3 100644 --- a/tasks/ReplaceTokensV6/package.json +++ b/tasks/ReplaceTokensV6/package.json @@ -8,7 +8,7 @@ "@opentelemetry/api": "^1.8.0", "@opentelemetry/sdk-trace-base": "^1.22.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@qetza/replacetokens": "^1.2.0", + "@qetza/replacetokens": "^1.3.0", "axios": "^1.6.7", "azure-pipelines-task-lib": "^4.1.0", "fast-glob": "^3.3.2", diff --git a/tasks/ReplaceTokensV6/task.json b/tasks/ReplaceTokensV6/task.json index b5d5976..c242826 100644 --- a/tasks/ReplaceTokensV6/task.json +++ b/tasks/ReplaceTokensV6/task.json @@ -13,7 +13,7 @@ "version": { "Major": 6, "Minor": 0, - "Patch": 0 + "Patch": 1 }, "releaseNotes": "breaking changes, see [changelog](https://github.com/qetza/replacetokens-task/blob/master/tasks/ReplaceTokensV6/CHANGELOG.md)", "instanceNameFormat": "Replace tokens", diff --git a/tasks/ReplaceTokensV6/tests/L0.ts b/tasks/ReplaceTokensV6/tests/L0.ts index 9c08ad2..09b6549 100644 --- a/tasks/ReplaceTokensV6/tests/L0.ts +++ b/tasks/ReplaceTokensV6/tests/L0.ts @@ -198,7 +198,7 @@ describe('ReplaceTokens v6 L0 suite', function () { tr.succeeded.should.be.true; tr.stdout.should.include('sources: ["**/*.json","**/*.xml","**/*.yml"]'); - tr.stdout.should.include('variables: {"var_secret":"secret","var_yml2":"secret","var_var":"var","var_yaml2":"var"}'); + tr.stdout.should.include('variables: {"VAR_SECRET":"secret","VAR_YML2":"secret","VAR_VAR":"var","VAR_YAML2":"var"}'); tr.stdout.should.include( 'options: {"addBOM":false,"encoding":"auto","escape":{"type":"auto"},"missing":{"action":"none","default":"","log":"warn"},"recursive":false,"separator":".","token":{"pattern":"default"},"transforms":{"enabled":false,"prefix":"(","suffix":")"}}' ); @@ -327,7 +327,7 @@ describe('ReplaceTokens v6 L0 suite', function () { tr.stdout.should.include(`##vso[task.debug]loading variables from file '${path.join(data, 'vars.yml').replace(/\\/g, '/')}'`); tr.stdout.should.include(`##vso[task.debug]loading variables from file '${path.join(data, 'vars.yaml').replace(/\\/g, '/')}'`); - tr.stdout.should.include('variables: {"var_json":"file","var_yaml1":"file","var_yaml2":"file","var_yml1":"file","var_yml2":"file"}'); + tr.stdout.should.include('variables: {"VAR_JSON":"file","VAR_YAML1":"file","VAR_YAML2":"file","VAR_YML1":"file","VAR_YML2":"file"}'); }, tr); }); @@ -347,7 +347,7 @@ describe('ReplaceTokens v6 L0 suite', function () { runValidations(() => { tr.stdout.should.include("##vso[task.debug]loading variables from environment variable '__VARS__'"); - tr.stdout.should.include('variables: {"var1":"value1","var2":"value2"}'); + tr.stdout.should.include('variables: {"VAR1":"value1","VAR2":"value2"}'); }, tr); }); @@ -367,7 +367,7 @@ describe('ReplaceTokens v6 L0 suite', function () { // assert runValidations(() => { - tr.stdout.should.include('variables: {"var1":"value1","var2":"value2"}'); + tr.stdout.should.include('variables: {"VAR1":"value1","VAR2":"value2"}'); }, tr); }); @@ -388,8 +388,7 @@ describe('ReplaceTokens v6 L0 suite', function () { process.env['__additionalVariables__'] = ` - '@**/_data/vars.*;!**/*.xml' - '$__VARS__' -- - var2: inline +- var2: inline var_yml2: inline `; @@ -400,7 +399,7 @@ describe('ReplaceTokens v6 L0 suite', function () { // assert runValidations(() => { tr.stdout.should.include( - 'variables: {"var_secret":"secret","var_yml2":"inline","var_var":"var","var_yaml2":"file","var_json":"file","var_yaml1":"file","var_yml1":"file","var1":"env","var2":"inline"}' + 'variables: {"VAR_SECRET":"secret","VAR_YML2":"inline","VAR_VAR":"var","VAR_YAML2":"file","VAR_JSON":"file","VAR_YAML1":"file","VAR_YML1":"file","VAR1":"env","VAR2":"inline"}' ); }, tr); } finally { diff --git a/vss-extension.json b/vss-extension.json index 22b416e..61b1b14 100644 --- a/vss-extension.json +++ b/vss-extension.json @@ -2,7 +2,7 @@ "manifestVersion": 1, "id": "replacetokens", "name": "Replace Tokens", - "version": "5.0.0", + "version": "5.0.1", "public": true, "publisher": "qetza", "targets": [