diff --git a/CHANGELOG.md b/CHANGELOG.md index ca9593f..fe0a8d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 5.0.2 +Task 6.0.2 +- Add aliases for renamed inputs to ease upgrade ([#11](https://github.com/qetza/replacetokens-task/issues/11)). + ## 5.0.1 Task 6.0.1 - Fix missing default variables due to case-sensitivity ([#8](https://github.com/qetza/replacetokens-task/issues/8)). @@ -17,7 +21,7 @@ Task 6.0.0 - renamed input _enableRecursion_ to _recursive_ - renamed input _rootDirectory_ to _root_ - renamed _tokenPattern_ value `rm` to `doubleunderscores` - - renamed input _writeBOM_ to _addBom_ + - renamed input _writeBOM_ to _addBOM_ - changed _writeBOM_ default value to `false` - renamed input _verbosity_ to _logLevel_ - renamed _verbosity_ value `detailed` to `debug` diff --git a/scripts/package.js b/scripts/package.js index 95a0804..ae301bb 100644 --- a/scripts/package.js +++ b/scripts/package.js @@ -140,8 +140,6 @@ cp('-Rf', path.join(__dirname, '..', 'images', 'screenshot*.png'), `${packageIma // update metadata var public = process.argv.includes('--public'); -var taskId = public ? undefined : '0664FF86-F509-4392-A33C-B2D9239B9AE5'; -var application = public ? undefined : 'replacetokens-task-dev'; versions.forEach(version => { console.log(); @@ -162,24 +160,23 @@ versions.forEach(version => { console.log(`> version: ${taskVersion}`); if (!public) { - manifest.friendlyName = `${manifest.friendlyName} (dev ${taskVersion})`; - - console.log(`> friendlyName: ${manifest.friendlyName}`); - } + manifest.id = '0664FF86-F509-4392-A33C-B2D9239B9AE5'; + console.log(`> id: ${manifest.id}`); - if (taskId) { - manifest.id = taskId; + manifest.name = `${manifest.name}-dev`; + console.log(`> name: ${manifest.name}`); - console.log(`> id: ${manifest.id}`); + manifest.friendlyName = `${manifest.friendlyName} (dev ${taskVersion})`; + console.log(`> friendlyName: ${manifest.friendlyName}`); } fs.writeFileSync(path.join(packageTaskDir, 'task.json'), JSON.stringify(manifest, null, 2)); var script = fs.readFileSync(path.join(packageTaskDir, 'index.js'), { encoding: 'utf8' }); - if (application) { - script = script.replace(/const\s+application\s*=\s*'[^']*'\s*;/, `const application = '${application}';`); + if (!public) { + script = script.replace(/const\s+application\s*=\s*'[^']*'\s*;/, `const application = 'replacetokens-task-dev';`); - console.log(`> application: ${application}`); + console.log(`> application: replacetokens-task-dev`); } script = script.replace(/const\s+version\s*=\s*'[^']*'\s*;/, `const version = '${taskVersion}';`); diff --git a/tasks/ReplaceTokensV5/tests/L0.ts b/tasks/ReplaceTokensV5/tests/L0.ts index 75a21bc..a4ab251 100644 --- a/tasks/ReplaceTokensV5/tests/L0.ts +++ b/tasks/ReplaceTokensV5/tests/L0.ts @@ -9,7 +9,7 @@ const data = path.join(__dirname, '../../tests/_data'); const tmp = path.join(__dirname, '_tmp'); describe('ReplaceTokens v5 L0 suite', function () { - this.timeout(5000); + this.timeout(10000); function runValidation(validator: () => void, tr: ttm.MockTestRunner, done: Mocha.Done) { try { diff --git a/tasks/ReplaceTokensV6/CHANGELOG.md b/tasks/ReplaceTokensV6/CHANGELOG.md index a804066..c2f26d8 100644 --- a/tasks/ReplaceTokensV6/CHANGELOG.md +++ b/tasks/ReplaceTokensV6/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 6.0.2 +- Add aliases for renamed inputs to ease upgrade ([#11](https://github.com/qetza/replacetokens-task/issues/11)). + ## 6.0.1 - Fix missing default variables due to case-sensitivity ([#8](https://github.com/qetza/replacetokens-task/issues/8)). @@ -17,7 +20,7 @@ - renamed input _enableRecursion_ to _recursive_ - renamed input _rootDirectory_ to _root_ - renamed _tokenPattern_ value `rm` to `doubleunderscores` - - renamed input _writeBOM_ to _addBom_ + - renamed input _writeBOM_ to _addBOM_ - changed _writeBOM_ default value to `false` - renamed input _verbosity_ to _logLevel_ - renamed _verbosity_ value `detailed` to `debug` diff --git a/tasks/ReplaceTokensV6/index.ts b/tasks/ReplaceTokensV6/index.ts index cfd746b..05a9656 100644 --- a/tasks/ReplaceTokensV6/index.ts +++ b/tasks/ReplaceTokensV6/index.ts @@ -32,27 +32,29 @@ async function run() { try { // read and validate inputs - const sources = tl.getDelimitedInput('sources', /\r?\n/, true); + const sources = tl.getDelimitedInput('targetFiles', /\r?\n/); + if (sources.length === 0) throw new Error('Input required: sources'); + const options: rt.Options = { - addBOM: tl.getBoolInput('addBOM'), + addBOM: tl.getBoolInput('writeBOM'), encoding: tl.getInput('encoding') || rt.Encodings.Auto, escape: { chars: tl.getInput('charsToEscape'), escapeChar: tl.getInput('escapeChar'), - type: getChoiceInput('escape', [rt.Escapes.Auto, rt.Escapes.Custom, rt.Escapes.Json, rt.Escapes.Off, rt.Escapes.Xml]) || rt.Escapes.Auto + type: getChoiceInput('escapeType', [rt.Escapes.Auto, rt.Escapes.Custom, rt.Escapes.Json, rt.Escapes.Off, rt.Escapes.Xml], 'escape') || rt.Escapes.Auto }, missing: { action: getChoiceInput('missingVarAction', [rt.MissingVariables.Action.Keep, rt.MissingVariables.Action.None, rt.MissingVariables.Action.Replace]) || rt.MissingVariables.Action.None, - default: tl.getInput('missingVarDefault') || '', + default: tl.getInput('defaultValue') || '', log: - getChoiceInput('missingVarLog', [rt.MissingVariables.Log.Error, rt.MissingVariables.Log.Off, rt.MissingVariables.Log.Warn]) || + getChoiceInput('actionOnMissing', [rt.MissingVariables.Log.Error, rt.MissingVariables.Log.Off, rt.MissingVariables.Log.Warn], 'missingVarLog') || rt.MissingVariables.Log.Warn }, - recursive: tl.getBoolInput('recursive'), - root: tl.getPathInput('root', false, true), - separator: tl.getInput('separator') || rt.Defaults.Separator, + recursive: tl.getBoolInput('enableRecursion'), + root: tl.getPathInput('rootDirectory', false, true), + separator: tl.getInput('variableSeparator') || rt.Defaults.Separator, token: { pattern: getChoiceInput('tokenPattern', [ @@ -68,9 +70,9 @@ async function run() { suffix: tl.getInput('tokenSuffix') }, transforms: { - enabled: tl.getBoolInput('transforms'), - prefix: tl.getInput('transformsPrefix') || rt.Defaults.TransformPrefix, - suffix: tl.getInput('transformsSuffix') || rt.Defaults.TransformSuffix + enabled: tl.getBoolInput('enableTransforms'), + prefix: tl.getInput('transformPrefix') || rt.Defaults.TransformPrefix, + suffix: tl.getInput('transformSuffix') || rt.Defaults.TransformSuffix } }; @@ -83,8 +85,8 @@ async function run() { await parseVariables(tl.getInput('additionalVariables'), options.root, options.separator) ); - const ifNoFilesFound = tl.getInput('ifNoFilesFound') || 'ignore'; - const logLevelStr = tl.getInput('logLevel') || 'info'; + const ifNoFilesFound = tl.getInput('actionOnNoFiles') || 'ignore'; + const logLevelStr = tl.getInput('verbosity') || 'info'; // set telemetry attributes telemetryEvent.setAttributes({ @@ -187,11 +189,12 @@ async function run() { } } -var getChoiceInput = function (name: string, choices: string[]): string { +var getChoiceInput = function (name: string, choices: string[], alias?: string): string { + alias = alias || name; const input = tl.getInput(name)?.trim(); if (!input || choices.includes(input)) return input; - throw new Error(`Unsupported value for input: ${name}\nSupport input list: '${choices.join(' | ')}'`); + throw new Error(`Unsupported value for input: ${alias}\nSupport input list: '${choices.join(' | ')}'`); }; var parseVariables = async function (input: string, root: string, separator: string): Promise<{ [key: string]: any }> { diff --git a/tasks/ReplaceTokensV6/task.json b/tasks/ReplaceTokensV6/task.json index c242826..f1fd2d9 100644 --- a/tasks/ReplaceTokensV6/task.json +++ b/tasks/ReplaceTokensV6/task.json @@ -13,7 +13,7 @@ "version": { "Major": 6, "Minor": 0, - "Patch": 1 + "Patch": 2 }, "releaseNotes": "breaking changes, see [changelog](https://github.com/qetza/replacetokens-task/blob/master/tasks/ReplaceTokensV6/CHANGELOG.md)", "instanceNameFormat": "Replace tokens", @@ -21,7 +21,8 @@ "groups": [], "inputs": [ { - "name": "root", + "name": "rootDirectory", + "aliases": ["root"], "type": "filePath", "required": false, "defaultValue": "", @@ -29,7 +30,8 @@ "helpMarkDown": "The root path to use when reading files with a relative path. Default: $(System.DefaultWorkingDirectory)" }, { - "name": "sources", + "name": "targetFiles", + "aliases": ["sources"], "type": "multiLine", "required": true, "defaultValue": "", @@ -88,7 +90,8 @@ "helpMarkDown": "The encoding to read and write all files. Default: auto" }, { - "name": "addBom", + "name": "writeBOM", + "aliases": ["addBOM"], "type": "boolean", "required": false, "defaultValue": false, @@ -105,7 +108,8 @@ "helpMarkDown": "A YAML formatted string containing additional variables or file or environment variable references." }, { - "name": "separator", + "name": "variableSeparator", + "aliases": ["separator"], "type": "string", "defaultValue": ".", "required": false, @@ -114,7 +118,8 @@ "helpMarkDown": "The separtor to use when flattening keys in variables." }, { - "name": "escape", + "name": "escapeType", + "aliases": ["escape"], "type": "pickList", "required": false, "defaultValue": "auto", @@ -132,7 +137,7 @@ "name": "escapeChar", "type": "string", "required": false, - "visibleRule": "escape == custom", + "visibleRule": "escapeType == custom", "label": "Escape character", "helpMarkDown": "The escape character to use when using 'custom' escape." }, @@ -140,12 +145,13 @@ "name": "charsToEscape", "type": "string", "required": false, - "visibleRule": "escape == custom", + "visibleRule": "escapeType == custom", "label": "Characters to escape", "helpMarkDown": "The characters to escape when using 'custom' escape." }, { - "name": "logLevel", + "name": "verbosity", + "aliases": ["logLevel"], "type": "pickList", "required": false, "defaultValue": "info", @@ -172,7 +178,8 @@ "helpMarkDown": "The behavior if variable is not found. Default: none" }, { - "name": "missingVarDefault", + "name": "defaultValue", + "aliases": ["missingVarDefault"], "type": "string", "required": false, "defaultValue": "", @@ -181,7 +188,8 @@ "helpMarkDown": "The default value to use when a key is not found. Default: empty string" }, { - "name": "missingVarLog", + "name": "actionOnMissing", + "aliases": ["missingVarLog"], "type": "pickList", "required": false, "defaultValue": "warn", @@ -195,7 +203,8 @@ "helpMarkDown": "The level to log key not found messages. Default: warn" }, { - "name": "ifNoFilesFound", + "name": "actionOnNoFiles", + "aliases": ["ifNoFilesFound"], "type": "pickList", "required": false, "defaultValue": "ignore", @@ -208,7 +217,8 @@ "helpMarkDown": "The behavior if no files are found. Default: ignore" }, { - "name": "recursive", + "name": "enableRecursion", + "aliases": ["recursive"], "type": "boolean", "required": false, "defaultValue": false, @@ -216,7 +226,8 @@ "helpMarkDown": "Enable token replacements in values recusively. Default: false" }, { - "name": "transforms", + "name": "enableTransforms", + "aliases": ["transforms"], "type": "boolean", "required": false, "defaultValue": false, @@ -224,20 +235,22 @@ "helpMarkDown": "Enable transforms on values. Default: false" }, { - "name": "transformsPrefix", + "name": "transformPrefix", + "aliases": ["transformsPrefix"], "type": "string", "required": false, "defaultValue": "(", - "visibleRule": "transforms == true", + "visibleRule": "enableTransforms == true", "label": "Transforms prefix", "helpMarkDown": "The tranforms prefix when using transforms. Default: (" }, { - "name": "transformsSuffix", + "name": "transformSuffix", + "aliases": ["transformsSuffix"], "type": "string", "required": false, "defaultValue": ")", - "visibleRule": "transforms == true", + "visibleRule": "enableTransforms == true", "label": "Transforms suffix", "helpMarkDown": "The tranforms suffix when using transforms. Default: )" }, diff --git a/tasks/ReplaceTokensV6/tests/L0.ts b/tasks/ReplaceTokensV6/tests/L0.ts index 09b6549..71212b8 100644 --- a/tasks/ReplaceTokensV6/tests/L0.ts +++ b/tasks/ReplaceTokensV6/tests/L0.ts @@ -7,7 +7,7 @@ const data = path.join(__dirname, '..', '..', 'tests', '_data'); const tmp = path.join(__dirname, '_tmp'); describe('ReplaceTokens v6 L0 suite', function () { - this.timeout(5000); + this.timeout(10000); afterEach(() => { // clean env diff --git a/tasks/ReplaceTokensV6/tests/L0_IfNoFilesFound.ts b/tasks/ReplaceTokensV6/tests/L0_IfNoFilesFound.ts index ba3a6a2..e4096ec 100644 --- a/tasks/ReplaceTokensV6/tests/L0_IfNoFilesFound.ts +++ b/tasks/ReplaceTokensV6/tests/L0_IfNoFilesFound.ts @@ -5,8 +5,8 @@ const taskPath = path.join(__dirname, '..', 'index.js'); const tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath); // inputs -tmr.setInput('sources', process.env['__sources__']); -tmr.setInput('ifNoFilesFound', process.env['__ifNoFilesFound__']); +tmr.setInput('targetFiles', process.env['__sources__']); +tmr.setInput('actionOnNoFiles', process.env['__ifNoFilesFound__']); // mocks const rt = require('@qetza/replacetokens'); diff --git a/tasks/ReplaceTokensV6/tests/L0_LogLevel.ts b/tasks/ReplaceTokensV6/tests/L0_LogLevel.ts index a94566a..35ddf81 100644 --- a/tasks/ReplaceTokensV6/tests/L0_LogLevel.ts +++ b/tasks/ReplaceTokensV6/tests/L0_LogLevel.ts @@ -5,8 +5,8 @@ const taskPath = path.join(__dirname, '..', 'index.js'); const tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath); // inputs -tmr.setInput('sources', process.env['__sources__']); -tmr.setInput('logLevel', process.env['__logLevel__']); +tmr.setInput('targetFiles', process.env['__sources__']); +tmr.setInput('verbosity', process.env['__logLevel__']); // mocks const rt = require('@qetza/replacetokens'); diff --git a/tasks/ReplaceTokensV6/tests/L0_Run.ts b/tasks/ReplaceTokensV6/tests/L0_Run.ts index 6e680f8..f16ce1e 100644 --- a/tasks/ReplaceTokensV6/tests/L0_Run.ts +++ b/tasks/ReplaceTokensV6/tests/L0_Run.ts @@ -5,28 +5,28 @@ const taskPath = path.join(__dirname, '..', 'index.js'); const tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath); // inputs -if (process.env['__sources__']) tmr.setInput('sources', process.env['__sources__']); -if (process.env['__addBOM__']) tmr.setInput('addBOM', process.env['__addBOM__']); +if (process.env['__sources__']) tmr.setInput('targetFiles', process.env['__sources__']); +if (process.env['__addBOM__']) tmr.setInput('writeBOM', process.env['__addBOM__']); if (process.env['__additionalVariables__']) tmr.setInput('additionalVariables', process.env['__additionalVariables__']); if (process.env['__charsToEscape__']) tmr.setInput('charsToEscape', process.env['__charsToEscape__']); if (process.env['__encoding__']) tmr.setInput('encoding', process.env['__encoding__']); -if (process.env['__escape__']) tmr.setInput('escape', process.env['__escape__']); +if (process.env['__escape__']) tmr.setInput('escapeType', process.env['__escape__']); if (process.env['__escapeChar__']) tmr.setInput('escapeChar', process.env['__escapeChar__']); -if (process.env['__ifNoFilesFound__']) tmr.setInput('ifNoFilesFound', process.env['__ifNoFilesFound__']); -if (process.env['__logLevel__']) tmr.setInput('logLevel', process.env['__logLevel__']); +if (process.env['__ifNoFilesFound__']) tmr.setInput('actionOnNoFiles', process.env['__ifNoFilesFound__']); +if (process.env['__logLevel__']) tmr.setInput('verbosity', process.env['__logLevel__']); if (process.env['__missingVarAction__']) tmr.setInput('missingVarAction', process.env['__missingVarAction__']); -if (process.env['__missingVarDefault__']) tmr.setInput('missingVarDefault', process.env['__missingVarDefault__']); -if (process.env['__missingVarLog__']) tmr.setInput('missingVarLog', process.env['__missingVarLog__']); -if (process.env['__recursive__']) tmr.setInput('recursive', process.env['__recursive__']); -if (process.env['__root__']) tmr.setInput('root', process.env['__root__']); -if (process.env['__separator__']) tmr.setInput('separator', process.env['__separator__']); +if (process.env['__missingVarDefault__']) tmr.setInput('defaultValue', process.env['__missingVarDefault__']); +if (process.env['__missingVarLog__']) tmr.setInput('actionOnMissing', process.env['__missingVarLog__']); +if (process.env['__recursive__']) tmr.setInput('enableRecursion', process.env['__recursive__']); +if (process.env['__root__']) tmr.setInput('rootDirectory', process.env['__root__']); +if (process.env['__separator__']) tmr.setInput('variableSeparator', process.env['__separator__']); if (process.env['__telemetryOptout__']) tmr.setInput('telemetryOptout', process.env['__telemetryOptout__']); if (process.env['__tokenPattern__']) tmr.setInput('tokenPattern', process.env['__tokenPattern__']); if (process.env['__tokenPrefix__']) tmr.setInput('tokenPrefix', process.env['__tokenPrefix__']); if (process.env['__tokenSuffix__']) tmr.setInput('tokenSuffix', process.env['__tokenSuffix__']); -if (process.env['__transforms__']) tmr.setInput('transforms', process.env['__transforms__']); -if (process.env['__transformsPrefix__']) tmr.setInput('transformsPrefix', process.env['__transformsPrefix__']); -if (process.env['__transformsSuffix__']) tmr.setInput('transformsSuffix', process.env['__transformsSuffix__']); +if (process.env['__transforms__']) tmr.setInput('enableTransforms', process.env['__transforms__']); +if (process.env['__transformsPrefix__']) tmr.setInput('transformPrefix', process.env['__transformsPrefix__']); +if (process.env['__transformsSuffix__']) tmr.setInput('transformSuffix', process.env['__transformsSuffix__']); // mocks const rtClone = Object.assign({}, require('@qetza/replacetokens')); diff --git a/vss-extension.json b/vss-extension.json index 61b1b14..b05f6a4 100644 --- a/vss-extension.json +++ b/vss-extension.json @@ -2,7 +2,7 @@ "manifestVersion": 1, "id": "replacetokens", "name": "Replace Tokens", - "version": "5.0.1", + "version": "5.0.2", "public": true, "publisher": "qetza", "targets": [