Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 1x 7x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | "use strict" import async from 'async'; import bag from 'bagofcli'; import stringFormat from 'string-format'; import util from 'util'; import semverVersionScheme from '../version-schemes/semver.js'; import gitScmScheme from '../scm-schemes/git.js'; import jsonResourceType from '../resource-types/json.js'; import keepAChangelogResourceType from '../resource-types/keep-a-changelog.js'; import makefileResourceType from '../resource-types/makefile.js'; import textResourceType from '../resource-types/text.js'; import tomlResourceType from '../resource-types/toml.js'; import yamlResourceType from '../resource-types/yaml.js'; /** * This is the default release scheme for RTK using Git as SCM. */ class Rtk { constructor(versionSchemeName, scmSchemeName, preReleaseVersion, opts) { versionSchemeName = versionSchemeName || 'semver'; scmSchemeName = scmSchemeName || 'git'; this.versionSchemes = { semver: semverVersionScheme }; this.scmSchemes = { git: gitScmScheme }; this.resourceTypes = { json: jsonResourceType, makefile: makefileResourceType, text: textResourceType, toml: tomlResourceType, yaml: yamlResourceType }; this.resourceTypes['keep-a-changelog'] = keepAChangelogResourceType; const VersionSchemeClass = this.versionSchemes[versionSchemeName]; this.versionScheme = new VersionSchemeClass(preReleaseVersion, opts.releaseIncrementType, opts.postReleaseIncrementType); this.scmScheme = this.scmSchemes[scmSchemeName]; this.logOpts = {} if (opts.dryRun) { this.logOpts['labels'] = ['dry run']; } } pre(resources, opts, cb) { const self = this; bag.logStepHeading('Executing pre step of rtk release scheme...', self.logOpts); let tasks = []; let paths = []; resources.forEach((resource) => { function resourceTask(cb) { let releaseVersion = resource.params && resource.params.release_value ? resource.params.release_value : self.versionScheme.getReleaseVersion(); if (resource.params && resource.params.release_format) { releaseVersion = stringFormat(resource.params.release_format, { version: releaseVersion }); } const message = util.format('Setting release version %s on %s resource located at %s', releaseVersion, resource.type, resource.path); bag.logStepItemSuccess(message, self.logOpts); self.resourceTypes[resource.type].setReleaseVersion(releaseVersion, resource, opts, cb); } tasks.push(resourceTask); paths.push(resource.path); }); function scmTask(cb) { const message = util.format('Committing release version changes made to %s...', paths.join(', ')); bag.logStepItemSuccess(message, self.logOpts); if (!opts.dryRun) { self.scmScheme.saveChanges(util.format('Release version %s', self.versionScheme.getReleaseVersion()), paths, cb); } else { cb(); } } tasks.push(scmTask); async.series(tasks, cb); } release(resources, opts, cb) { const self = this; bag.logStepHeading('Executing release step of rtk release scheme...', self.logOpts); let tasks = []; function scmTask(cb) { // Use tagFormat option to format the version to be used as SCM tag const formattedVersion = stringFormat(opts.tagFormat, { version: self.versionScheme.getReleaseVersion() }); const message = util.format('Adding release version tag %s ...', formattedVersion); bag.logStepItemSuccess(message, self.logOpts); if (!opts.dryRun) { self.scmScheme.addVersion(formattedVersion, cb); } else { cb(); } } tasks.push(scmTask); async.series(tasks, cb); } post(resources, opts, cb) { const self = this; bag.logStepHeading('Executing post step of rtk release scheme...', self.logOpts); let tasks = []; let paths = []; resources.forEach((resource) => { function resourceTask(cb) { const postReleaseVersion = resource.params && resource.params.post_release_value ? resource.params.post_release_value : self.versionScheme.getPostReleaseVersion(); const message = util.format('Setting next pre-release version %s on %s resource located at %s', postReleaseVersion, resource.type, resource.path); bag.logStepItemSuccess(message, self.logOpts); self.resourceTypes[resource.type].setPostReleaseVersion(postReleaseVersion, resource, opts, cb); } tasks.push(resourceTask); paths.push(resource.path); }); function scmTask(cb) { const message = util.format('Committing next pre-release version changes made to %s...', paths.join(', ')); bag.logStepItemSuccess(message, self.logOpts); if (!opts.dryRun) { self.scmScheme.saveChanges(util.format('Bump up to next pre-release version %s', self.versionScheme.getPostReleaseVersion()), paths), cb; } else { cb(); } } tasks.push(scmTask); async.series(tasks, cb); } } export { Rtk as default }; |