release-please 12.4.0 → 13.0.0-candidate.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +4 -0
  3. package/build/src/bin/release-please.d.ts +56 -11
  4. package/build/src/bin/release-please.js +413 -150
  5. package/build/src/bootstrapper.d.ts +12 -0
  6. package/build/src/bootstrapper.js +60 -0
  7. package/build/src/commit.d.ts +26 -0
  8. package/build/src/{util/to-conventional-changelog-format.js → commit.js} +97 -2
  9. package/build/src/errors/index.d.ts +0 -5
  10. package/build/src/errors/index.js +1 -10
  11. package/build/src/factory.d.ts +25 -37
  12. package/build/src/factory.js +159 -150
  13. package/build/src/github.d.ts +154 -884
  14. package/build/src/github.js +608 -1036
  15. package/build/src/manifest.d.ts +182 -48
  16. package/build/src/manifest.js +590 -487
  17. package/build/src/plugin.d.ts +20 -0
  18. package/build/src/{plugins/plugin.js → plugin.js} +10 -9
  19. package/build/src/plugins/cargo-workspace.d.ts +48 -18
  20. package/build/src/plugins/cargo-workspace.js +247 -328
  21. package/build/src/plugins/merge.d.ts +11 -0
  22. package/build/src/plugins/merge.js +83 -0
  23. package/build/src/plugins/node-workspace.d.ts +35 -17
  24. package/build/src/plugins/node-workspace.js +234 -271
  25. package/build/src/plugins/workspace.d.ts +102 -0
  26. package/build/src/plugins/workspace.js +170 -0
  27. package/build/src/pull-request.d.ts +10 -0
  28. package/build/src/{updaters/java/readme.js → pull-request.js} +2 -7
  29. package/build/src/release-notes.d.ts +29 -0
  30. package/build/src/release-notes.js +71 -0
  31. package/build/src/release-pull-request.d.ts +13 -0
  32. package/build/src/{updaters/java/pom-xml.js → release-pull-request.js} +2 -7
  33. package/build/src/release.d.ts +6 -0
  34. package/build/src/release.js +16 -0
  35. package/build/src/repository.d.ts +5 -0
  36. package/build/src/repository.js +16 -0
  37. package/build/src/strategies/dart.d.ts +8 -0
  38. package/build/src/strategies/dart.js +63 -0
  39. package/build/src/strategies/elixir.d.ts +5 -0
  40. package/build/src/{releasers → strategies}/elixir.js +18 -14
  41. package/build/src/strategies/go-yoshi.d.ts +13 -0
  42. package/build/src/strategies/go-yoshi.js +106 -0
  43. package/build/src/strategies/go.d.ts +5 -0
  44. package/build/src/{releasers → strategies}/go.js +11 -12
  45. package/build/src/strategies/helm.d.ts +8 -0
  46. package/build/src/strategies/helm.js +63 -0
  47. package/build/src/strategies/java-yoshi.d.ts +24 -0
  48. package/build/src/strategies/java-yoshi.js +203 -0
  49. package/build/src/strategies/krm-blueprint.d.ts +7 -0
  50. package/build/src/{releasers → strategies}/krm-blueprint.js +26 -22
  51. package/build/src/strategies/node.d.ts +9 -0
  52. package/build/src/strategies/node.js +82 -0
  53. package/build/src/strategies/ocaml.d.ts +5 -0
  54. package/build/src/{releasers → strategies}/ocaml.js +34 -28
  55. package/build/src/strategies/php-yoshi.d.ts +9 -0
  56. package/build/src/strategies/php-yoshi.js +214 -0
  57. package/build/src/strategies/php.d.ts +6 -0
  58. package/build/src/{releasers → strategies}/php.js +24 -23
  59. package/build/src/strategies/python.d.ts +8 -0
  60. package/build/src/strategies/python.js +117 -0
  61. package/build/src/strategies/ruby-yoshi.d.ts +17 -0
  62. package/build/src/strategies/ruby-yoshi.js +116 -0
  63. package/build/src/strategies/ruby.d.ts +13 -0
  64. package/build/src/{releasers → strategies}/ruby.js +26 -27
  65. package/build/src/strategies/rust.d.ts +20 -0
  66. package/build/src/strategies/rust.js +120 -0
  67. package/build/src/strategies/simple.d.ts +5 -0
  68. package/build/src/{releasers → strategies}/simple.js +18 -14
  69. package/build/src/strategies/terraform-module.d.ts +7 -0
  70. package/build/src/{releasers → strategies}/terraform-module.js +29 -23
  71. package/build/src/strategy.d.ts +99 -0
  72. package/build/src/strategy.js +237 -0
  73. package/build/src/update.d.ts +23 -0
  74. package/build/src/{updaters/update.js → update.js} +1 -1
  75. package/build/src/updaters/changelog.d.ts +7 -10
  76. package/build/src/updaters/changelog.js +3 -9
  77. package/build/src/updaters/changelog.js.map +1 -1
  78. package/build/src/updaters/composite.d.ts +19 -0
  79. package/build/src/updaters/composite.js +42 -0
  80. package/build/src/updaters/dart/pubspec-yaml.d.ts +12 -0
  81. package/build/src/updaters/{pubspec-yaml.js → dart/pubspec-yaml.js} +13 -12
  82. package/build/src/updaters/default.d.ts +21 -0
  83. package/build/src/updaters/{version-txt.js → default.js} +16 -10
  84. package/build/src/updaters/dotnet/csproj.d.ts +12 -0
  85. package/build/src/updaters/{java/google-utils.js → dotnet/csproj.js} +16 -13
  86. package/build/src/updaters/elixir/elixir-mix-exs.d.ts +12 -0
  87. package/build/src/updaters/{elixir-mix-exs.js → elixir/elixir-mix-exs.js} +12 -10
  88. package/build/src/updaters/helm/chart-yaml.d.ts +10 -11
  89. package/build/src/updaters/helm/chart-yaml.js +12 -10
  90. package/build/src/updaters/java/java-update.d.ts +14 -0
  91. package/build/src/updaters/java/{java_update.js → java-update.js} +22 -22
  92. package/build/src/updaters/java/versions-manifest.d.ts +12 -2
  93. package/build/src/updaters/java/versions-manifest.js +20 -4
  94. package/build/src/updaters/krm/krm-blueprint-version.d.ts +10 -11
  95. package/build/src/updaters/krm/krm-blueprint-version.js +13 -12
  96. package/build/src/updaters/node/package-json.d.ts +12 -0
  97. package/build/src/updaters/{package-json.js → node/package-json.js} +14 -16
  98. package/build/src/updaters/node/package-lock-json.d.ts +8 -0
  99. package/build/src/updaters/node/package-lock-json.js +36 -0
  100. package/build/src/updaters/node/samples-package-json.d.ts +23 -0
  101. package/build/src/updaters/{samples-package-json.js → node/samples-package-json.js} +19 -8
  102. package/build/src/updaters/ocaml/dune-project.d.ts +10 -11
  103. package/build/src/updaters/ocaml/dune-project.js +11 -9
  104. package/build/src/updaters/ocaml/esy-json.d.ts +10 -11
  105. package/build/src/updaters/ocaml/esy-json.js +12 -10
  106. package/build/src/updaters/ocaml/opam.d.ts +10 -11
  107. package/build/src/updaters/ocaml/opam.js +11 -9
  108. package/build/src/updaters/php/php-client-version.d.ts +12 -0
  109. package/build/src/updaters/{php-client-version.js → php/php-client-version.js} +10 -9
  110. package/build/src/updaters/php/php-manifest.d.ts +13 -0
  111. package/build/src/updaters/{php-manifest.js → php/php-manifest.js} +17 -15
  112. package/build/src/updaters/php/root-composer-update-packages.d.ts +12 -0
  113. package/build/src/updaters/{root-composer-update-packages.js → php/root-composer-update-packages.js} +17 -16
  114. package/build/src/updaters/python/pyproject-toml.d.ts +10 -11
  115. package/build/src/updaters/python/pyproject-toml.js +13 -11
  116. package/build/src/updaters/python/python-file-with-version.d.ts +7 -11
  117. package/build/src/updaters/python/python-file-with-version.js +7 -8
  118. package/build/src/updaters/python/setup-cfg.d.ts +10 -11
  119. package/build/src/updaters/python/setup-cfg.js +10 -8
  120. package/build/src/updaters/python/setup-py.d.ts +10 -11
  121. package/build/src/updaters/python/setup-py.js +10 -8
  122. package/build/src/updaters/raw-content.d.ts +19 -0
  123. package/build/src/{plugins/index.js → updaters/raw-content.js} +23 -12
  124. package/build/src/updaters/release-please-config.d.ts +8 -0
  125. package/build/src/updaters/release-please-config.js +41 -0
  126. package/build/src/updaters/release-please-manifest.d.ts +2 -11
  127. package/build/src/updaters/release-please-manifest.js +11 -14
  128. package/build/src/updaters/ruby/version-rb.d.ts +12 -0
  129. package/build/src/updaters/{version-rb.js → ruby/version-rb.js} +10 -8
  130. package/build/src/updaters/rust/cargo-lock.d.ts +7 -11
  131. package/build/src/updaters/rust/cargo-lock.js +14 -16
  132. package/build/src/updaters/rust/cargo-toml.d.ts +7 -11
  133. package/build/src/updaters/rust/cargo-toml.js +19 -21
  134. package/build/src/updaters/terraform/module-version.d.ts +10 -11
  135. package/build/src/updaters/terraform/module-version.js +11 -9
  136. package/build/src/updaters/terraform/readme.d.ts +10 -11
  137. package/build/src/updaters/terraform/readme.js +11 -10
  138. package/build/src/updaters/terraform/readme.js.map +1 -1
  139. package/build/src/util/branch-name.d.ts +5 -4
  140. package/build/src/util/branch-name.js +13 -10
  141. package/build/src/{commit-split.d.ts → util/commit-split.d.ts} +2 -4
  142. package/build/src/{commit-split.js → util/commit-split.js} +4 -2
  143. package/build/src/util/indent-commit.d.ts +1 -1
  144. package/build/src/util/logger.d.ts +5 -2
  145. package/build/src/util/logger.js +9 -4
  146. package/build/src/util/pull-request-body.d.ts +20 -0
  147. package/build/src/util/pull-request-body.js +129 -0
  148. package/build/src/util/pull-request-title.d.ts +8 -6
  149. package/build/src/util/pull-request-title.js +20 -6
  150. package/build/src/util/tag-name.d.ts +9 -0
  151. package/build/src/util/tag-name.js +41 -0
  152. package/build/src/{updaters → util}/toml-edit.d.ts +0 -0
  153. package/build/src/{updaters → util}/toml-edit.js +0 -0
  154. package/build/src/version.d.ts +11 -0
  155. package/build/src/version.js +45 -0
  156. package/build/src/versioning-strategies/always-bump-patch.d.ts +7 -0
  157. package/build/src/{updaters/package-lock-json.js → versioning-strategies/always-bump-patch.js} +8 -11
  158. package/build/src/versioning-strategies/default.d.ts +15 -0
  159. package/build/src/versioning-strategies/default.js +67 -0
  160. package/build/src/versioning-strategies/dependency-manifest.d.ts +7 -0
  161. package/build/src/versioning-strategies/dependency-manifest.js +90 -0
  162. package/build/src/versioning-strategies/java-add-snapshot.d.ts +9 -0
  163. package/build/src/versioning-strategies/java-add-snapshot.js +53 -0
  164. package/build/src/versioning-strategies/java-snapshot.d.ts +9 -0
  165. package/build/src/versioning-strategies/java-snapshot.js +67 -0
  166. package/build/src/versioning-strategies/service-pack.d.ts +7 -0
  167. package/build/src/versioning-strategies/service-pack.js +40 -0
  168. package/build/src/versioning-strategy.d.ts +28 -0
  169. package/build/src/versioning-strategy.js +55 -0
  170. package/package.json +9 -8
  171. package/build/src/constants.d.ts +0 -6
  172. package/build/src/constants.js +0 -23
  173. package/build/src/conventional-commits.d.ts +0 -53
  174. package/build/src/conventional-commits.js +0 -167
  175. package/build/src/github-release.d.ts +0 -34
  176. package/build/src/github-release.js +0 -92
  177. package/build/src/graphql-to-commits.d.ts +0 -60
  178. package/build/src/graphql-to-commits.js +0 -112
  179. package/build/src/index.d.ts +0 -94
  180. package/build/src/index.js +0 -32
  181. package/build/src/plugins/index.d.ts +0 -5
  182. package/build/src/plugins/plugin.d.ts +0 -21
  183. package/build/src/release-pr.d.ts +0 -101
  184. package/build/src/release-pr.js +0 -461
  185. package/build/src/releasers/dart.d.ts +0 -9
  186. package/build/src/releasers/dart.js +0 -65
  187. package/build/src/releasers/elixir.d.ts +0 -5
  188. package/build/src/releasers/go-yoshi.d.ts +0 -10
  189. package/build/src/releasers/go-yoshi.js +0 -162
  190. package/build/src/releasers/go.d.ts +0 -6
  191. package/build/src/releasers/helm.d.ts +0 -9
  192. package/build/src/releasers/helm.js +0 -66
  193. package/build/src/releasers/index.d.ts +0 -7
  194. package/build/src/releasers/index.js +0 -74
  195. package/build/src/releasers/java/bump_type.d.ts +0 -4
  196. package/build/src/releasers/java/bump_type.js +0 -38
  197. package/build/src/releasers/java/stability.d.ts +0 -5
  198. package/build/src/releasers/java/stability.js +0 -37
  199. package/build/src/releasers/java/version.d.ts +0 -13
  200. package/build/src/releasers/java/version.js +0 -112
  201. package/build/src/releasers/java-bom.d.ts +0 -16
  202. package/build/src/releasers/java-bom.js +0 -83
  203. package/build/src/releasers/java-lts.d.ts +0 -9
  204. package/build/src/releasers/java-lts.js +0 -47
  205. package/build/src/releasers/java-yoshi.d.ts +0 -28
  206. package/build/src/releasers/java-yoshi.js +0 -304
  207. package/build/src/releasers/krm-blueprint.d.ts +0 -6
  208. package/build/src/releasers/node.d.ts +0 -10
  209. package/build/src/releasers/node.js +0 -84
  210. package/build/src/releasers/ocaml.d.ts +0 -5
  211. package/build/src/releasers/php-yoshi.d.ts +0 -5
  212. package/build/src/releasers/php-yoshi.js +0 -191
  213. package/build/src/releasers/php.d.ts +0 -7
  214. package/build/src/releasers/python.d.ts +0 -11
  215. package/build/src/releasers/python.js +0 -127
  216. package/build/src/releasers/ruby-yoshi.d.ts +0 -5
  217. package/build/src/releasers/ruby-yoshi.js +0 -142
  218. package/build/src/releasers/ruby.d.ts +0 -11
  219. package/build/src/releasers/rust.d.ts +0 -30
  220. package/build/src/releasers/rust.js +0 -163
  221. package/build/src/releasers/simple.d.ts +0 -5
  222. package/build/src/releasers/terraform-module.d.ts +0 -6
  223. package/build/src/updaters/elixir-mix-exs.d.ts +0 -13
  224. package/build/src/updaters/java/google-utils.d.ts +0 -13
  225. package/build/src/updaters/java/java_update.d.ts +0 -13
  226. package/build/src/updaters/java/pom-xml.d.ts +0 -3
  227. package/build/src/updaters/java/readme.d.ts +0 -3
  228. package/build/src/updaters/java/readme.js.map +0 -1
  229. package/build/src/updaters/package-json.d.ts +0 -16
  230. package/build/src/updaters/package-lock-json.d.ts +0 -7
  231. package/build/src/updaters/php-client-version.d.ts +0 -13
  232. package/build/src/updaters/php-manifest.d.ts +0 -13
  233. package/build/src/updaters/pubspec-yaml.d.ts +0 -13
  234. package/build/src/updaters/root-composer-update-package.d.ts +0 -13
  235. package/build/src/updaters/root-composer-update-package.js +0 -45
  236. package/build/src/updaters/root-composer-update-packages.d.ts +0 -13
  237. package/build/src/updaters/samples-package-json.d.ts +0 -13
  238. package/build/src/updaters/update.d.ts +0 -20
  239. package/build/src/updaters/version-rb.d.ts +0 -13
  240. package/build/src/updaters/version-txt.d.ts +0 -12
  241. package/build/src/updaters/version.d.ts +0 -13
  242. package/build/src/updaters/version.js +0 -31
  243. package/build/src/util/checkpoint.d.ts +0 -6
  244. package/build/src/util/checkpoint.js +0 -33
  245. package/build/src/util/release-notes.d.ts +0 -7
  246. package/build/src/util/release-notes.js +0 -34
  247. package/build/src/util/to-conventional-changelog-format.d.ts +0 -2
@@ -15,219 +15,480 @@
15
15
  // limitations under the License.
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.handleError = exports.parser = void 0;
18
- const chalk = require("chalk");
19
18
  const coerce_option_1 = require("../util/coerce-option");
20
- const factory_1 = require("../factory");
21
- const releasers_1 = require("../releasers");
22
19
  const yargs = require("yargs");
23
- const constants_1 = require("../constants");
24
- function releaserCommon(ya) {
20
+ const github_1 = require("../github");
21
+ const manifest_1 = require("../manifest");
22
+ const logger_1 = require("../util/logger");
23
+ const factory_1 = require("../factory");
24
+ const bootstrapper_1 = require("../bootstrapper");
25
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
26
+ const parseGithubRepoUrl = require('parse-github-repo-url');
27
+ function gitHubOptions(yargs) {
28
+ return yargs
29
+ .option('token', { describe: 'GitHub token with repo write permissions' })
30
+ .option('api-url', {
31
+ describe: 'URL to use when making API requests',
32
+ default: github_1.GH_API_URL,
33
+ type: 'string',
34
+ })
35
+ .option('graphql-url', {
36
+ describe: 'URL to use when making GraphQL requests',
37
+ default: github_1.GH_GRAPHQL_URL,
38
+ type: 'string',
39
+ })
40
+ .option('default-branch', {
41
+ describe: 'The branch to open release PRs against and tag releases on',
42
+ type: 'string',
43
+ deprecated: 'use --target-branch instead',
44
+ })
45
+ .option('target-branch', {
46
+ describe: 'The branch to open release PRs against and tag releases on',
47
+ type: 'string',
48
+ })
49
+ .option('repo-url', {
50
+ describe: 'GitHub URL to generate release for',
51
+ demand: true,
52
+ })
53
+ .option('dry-run', {
54
+ describe: 'Prepare but do not take action',
55
+ type: 'boolean',
56
+ default: false,
57
+ })
58
+ .middleware(_argv => {
59
+ const argv = _argv;
60
+ // allow secrets to be loaded from file path
61
+ // rather than being passed directly to the bin.
62
+ if (argv.token)
63
+ argv.token = coerce_option_1.coerceOption(argv.token);
64
+ if (argv.apiUrl)
65
+ argv.apiUrl = coerce_option_1.coerceOption(argv.apiUrl);
66
+ if (argv.graphqlUrl)
67
+ argv.graphqlUrl = coerce_option_1.coerceOption(argv.graphqlUrl);
68
+ });
69
+ }
70
+ function releaseOptions(yargs) {
71
+ return yargs
72
+ .option('draft', {
73
+ describe: 'mark release as a draft. no tag is created but tag_name and ' +
74
+ 'target_commitish are associated with the release for future ' +
75
+ 'tag creation upon "un-drafting" the release.',
76
+ type: 'boolean',
77
+ default: false,
78
+ })
79
+ .option('label', {
80
+ default: 'autorelease: pending',
81
+ describe: 'comma-separated list of labels to remove to from release PR',
82
+ })
83
+ .option('release-label', {
84
+ describe: 'set a pull request label other than "autorelease: tagged"',
85
+ default: 'autorelease: tagged',
86
+ type: 'string',
87
+ });
88
+ }
89
+ function pullRequestOptions(yargs) {
25
90
  // common to ReleasePR and GitHubRelease
26
- ya.option('label', {
91
+ return yargs
92
+ .option('label', {
27
93
  default: 'autorelease: pending',
28
- describe: 'label to remove from release PR',
94
+ describe: 'comma-separated list of labels to add to from release PR',
95
+ })
96
+ .option('fork', {
97
+ describe: 'should the PR be created from a fork',
98
+ type: 'boolean',
99
+ default: false,
100
+ })
101
+ .option('draft-pull-request', {
102
+ describe: 'mark pull request as a draft',
103
+ type: 'boolean',
104
+ default: false,
105
+ })
106
+ .option('signoff', {
107
+ describe: 'Add Signed-off-by line at the end of the commit log message using the user and email provided. (format "Name <email@example.com>").',
108
+ type: 'string',
29
109
  });
30
- ya.option('release-as', {
110
+ }
111
+ function pullRequestStrategyOptions(yargs) {
112
+ return yargs
113
+ .option('release-as', {
31
114
  describe: 'override the semantically determined release version',
32
115
  type: 'string',
33
- });
34
- ya.option('bump-minor-pre-major', {
116
+ })
117
+ .option('bump-minor-pre-major', {
35
118
  describe: 'should we bump the semver minor prior to the first major release',
36
119
  default: false,
37
120
  type: 'boolean',
38
- });
39
- ya.option('bump-patch-for-minor-pre-major', {
121
+ })
122
+ .option('bump-patch-for-minor-pre-major', {
40
123
  describe: 'should we bump the semver patch instead of the minor for non-breaking' +
41
124
  ' changes prior to the first major release',
42
125
  default: false,
43
126
  type: 'boolean',
44
- });
45
- ya.option('path', {
46
- describe: 'release from path other than root directory',
47
- type: 'string',
48
- });
49
- ya.option('package-name', {
50
- describe: 'name of package release is being minted for',
51
- });
52
- ya.option('monorepo-tags', {
127
+ })
128
+ .option('monorepo-tags', {
53
129
  describe: 'include library name in tags and release branches',
54
130
  type: 'boolean',
55
131
  default: false,
56
- });
57
- ya.option('version-file', {
132
+ })
133
+ .option('extra-files', {
134
+ describe: 'extra files for the strategy to consider',
135
+ type: 'string',
136
+ coerce(arg) {
137
+ if (arg) {
138
+ return arg.split(',');
139
+ }
140
+ return arg;
141
+ },
142
+ })
143
+ .option('version-file', {
58
144
  describe: 'path to version file to update, e.g., version.rb',
59
- });
60
- ya.option('last-package-version', {
61
- describe: 'last version # that package was released as',
62
- });
63
- ya.option('snapshot', {
145
+ type: 'string',
146
+ })
147
+ .option('snapshot', {
64
148
  describe: 'is it a snapshot (or pre-release) being generated?',
65
149
  type: 'boolean',
66
150
  default: false,
67
- });
68
- ya.option('pull-request-title-pattern', {
151
+ })
152
+ .option('versioning-strategy', {
153
+ describe: 'strategy used for bumping versions',
154
+ choices: factory_1.getVersioningStrategyTypes(),
155
+ default: 'default',
156
+ })
157
+ .option('pull-request-title-pattern', {
69
158
  describe: 'Title pattern to make release PR',
70
159
  type: 'string',
71
- });
72
- ya.option('signoff', {
73
- describe: 'Add Signed-off-by line at the end of the commit log message using the user and email provided. (format "Name <email@example.com>").',
74
- type: 'string',
75
- });
76
- ya.option('changelog-path', {
160
+ })
161
+ .option('changelog-path', {
77
162
  default: 'CHANGELOG.md',
78
163
  describe: 'where can the CHANGELOG be found in the project?',
79
- });
80
- ya.option('latest-tag-version', {
164
+ type: 'string',
165
+ })
166
+ .option('last-package-version', {
167
+ describe: 'last version # that package was released as',
168
+ type: 'string',
169
+ deprecated: 'use --latest-tag-version instead',
170
+ })
171
+ .option('latest-tag-version', {
81
172
  describe: 'Override the detected latest tag version',
82
173
  type: 'string',
83
- });
84
- ya.option('latest-tag-sha', {
174
+ })
175
+ .option('latest-tag-sha', {
85
176
  describe: 'Override the detected latest tag SHA',
86
177
  type: 'string',
87
- });
88
- ya.option('latest-tag-name', {
178
+ })
179
+ .option('latest-tag-name', {
89
180
  describe: 'Override the detected latest tag name',
90
181
  type: 'string',
182
+ })
183
+ .middleware(_argv => {
184
+ const argv = _argv;
185
+ if (argv.defaultBranch) {
186
+ logger_1.logger.warn('--default-branch is deprecated. Please use --target-branch instead.');
187
+ argv.targetBranch = argv.targetBranch || argv.defaultBranch;
188
+ }
189
+ if (argv.lastPackageVersion) {
190
+ logger_1.logger.warn('--latest-package-version is deprecated. Please use --latest-tag-version instead.');
191
+ argv.latestTagVersion =
192
+ argv.latestTagVersion || argv.lastPackageVersion;
193
+ }
91
194
  });
92
195
  }
93
- function releaseType(ya, defaultType) {
94
- const relTypeOptions = {
196
+ function manifestConfigOptions(yargs, defaultType) {
197
+ return yargs
198
+ .option('path', {
199
+ describe: 'release from path other than root directory',
200
+ type: 'string',
201
+ })
202
+ .option('component', {
203
+ describe: 'name of component release is being minted for',
204
+ type: 'string',
205
+ })
206
+ .option('package-name', {
207
+ describe: 'name of package release is being minted for',
208
+ type: 'string',
209
+ })
210
+ .option('release-type', {
95
211
  describe: 'what type of repo is a release being created for?',
96
- choices: releasers_1.getReleaserTypes(),
97
- };
98
- if (defaultType) {
99
- relTypeOptions.default = defaultType;
100
- }
101
- ya.option('release-type', relTypeOptions);
212
+ choices: factory_1.getReleaserTypes(),
213
+ default: defaultType,
214
+ });
102
215
  }
103
- function manifestOptions(ya) {
104
- ya.option('config-file', {
216
+ function manifestOptions(yargs) {
217
+ return yargs
218
+ .option('config-file', {
105
219
  default: 'release-please-config.json',
106
220
  describe: 'where can the config file be found in the project?',
107
- });
108
- ya.option('manifest-file', {
221
+ })
222
+ .option('manifest-file', {
109
223
  default: '.release-please-manifest.json',
110
224
  describe: 'where can the manifest file be found in the project?',
111
225
  });
112
226
  }
113
- exports.parser = yargs
114
- .command('manifest-pr', 'create a release-PR using a manifest file', (yargs) => {
115
- manifestOptions(yargs);
116
- }, (argv) => {
117
- factory_1.factory.runCommand('manifest-pr', argv).catch(exports.handleError);
118
- })
119
- .command('manifest-release', 'create releases/tags from last release-PR using a manifest file', (yargs) => {
120
- manifestOptions(yargs);
121
- }, (argv) => {
122
- factory_1.factory.runCommand('manifest-release', argv).catch(exports.handleError);
123
- })
124
- .command('release-pr', 'create or update a PR representing the next release',
125
- // options unique to ReleasePR
126
- (yargs) => {
127
- releaseType(yargs, 'node');
128
- releaserCommon(yargs);
129
- }, (argv) => {
130
- factory_1.factory.runCommand('release-pr', argv).catch(exports.handleError);
131
- })
132
- .command('latest-tag', 'find the sha of the latest release',
133
- // options unique to ReleasePR
134
- (yargs) => {
135
- releaseType(yargs, 'node');
136
- releaserCommon(yargs);
137
- }, (argv) => {
138
- factory_1.factory
139
- .runCommand('latest-tag', argv)
140
- .catch(exports.handleError)
141
- .then(latestTag => {
142
- if (latestTag) {
143
- console.log(latestTag);
227
+ const createReleasePullRequestCommand = {
228
+ command: 'release-pr',
229
+ describe: 'create or update a PR representing the next release',
230
+ builder(yargs) {
231
+ return manifestOptions(manifestConfigOptions(pullRequestOptions(pullRequestStrategyOptions(gitHubOptions(yargs)))));
232
+ },
233
+ async handler(argv) {
234
+ const github = await buildGitHub(argv);
235
+ const targetBranch = argv.targetBranch || github.repository.defaultBranch;
236
+ let manifest;
237
+ if (argv.releaseType) {
238
+ manifest = await manifest_1.Manifest.fromConfig(github, targetBranch, {
239
+ releaseType: argv.releaseType,
240
+ component: argv.component,
241
+ packageName: argv.packageName,
242
+ draftPullRequest: argv.draftPullRequest,
243
+ bumpMinorPreMajor: argv.bumpMinorPreMajor,
244
+ bumpPatchForMinorPreMajor: argv.bumpPatchForMinorPreMajor,
245
+ changelogPath: argv.changelogPath,
246
+ changelogSections: argv.changelogSections,
247
+ releaseAs: argv.releaseAs,
248
+ versioning: argv.versioningStrategy,
249
+ extraFiles: argv.extraFiles,
250
+ versionFile: argv.versionFile,
251
+ }, extractManifestOptions(argv), argv.path);
144
252
  }
145
253
  else {
146
- console.log('No latest tag found.');
147
- process.exitCode = 1;
254
+ const manifestOptions = extractManifestOptions(argv);
255
+ manifest = await manifest_1.Manifest.fromManifest(github, targetBranch, argv.configFile, argv.manifestFile, manifestOptions);
148
256
  }
257
+ if (argv.dryRun) {
258
+ const pullRequests = await manifest.buildPullRequests();
259
+ console.log(`Would open ${pullRequests.length} pull requests`);
260
+ console.log('fork:', manifest.fork);
261
+ for (const pullRequest of pullRequests) {
262
+ console.log('title:', pullRequest.title.toString());
263
+ console.log('branch:', pullRequest.headRefName);
264
+ console.log('draft:', pullRequest.draft);
265
+ console.log('body:', pullRequest.body.toString());
266
+ console.log('updates:', pullRequest.updates.length);
267
+ for (const update of pullRequest.updates) {
268
+ console.log(` ${update.path}: `,
269
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
270
+ update.updater.constructor);
271
+ }
272
+ }
273
+ }
274
+ else {
275
+ const pullRequestNumbers = await manifest.createPullRequests();
276
+ console.log(pullRequestNumbers);
277
+ }
278
+ },
279
+ };
280
+ const createReleaseCommand = {
281
+ command: 'github-release',
282
+ describe: 'create a GitHub release from a release PR',
283
+ builder(yargs) {
284
+ return releaseOptions(manifestOptions(manifestConfigOptions(gitHubOptions(yargs))));
285
+ },
286
+ async handler(argv) {
287
+ const github = await buildGitHub(argv);
288
+ const targetBranch = argv.targetBranch ||
289
+ argv.defaultBranch ||
290
+ github.repository.defaultBranch;
291
+ let manifest;
292
+ if (argv.releaseType) {
293
+ manifest = await manifest_1.Manifest.fromConfig(github, targetBranch, {
294
+ releaseType: argv.releaseType,
295
+ component: argv.component,
296
+ packageName: argv.packageName,
297
+ draft: argv.draft,
298
+ }, extractManifestOptions(argv), argv.path);
299
+ }
300
+ else {
301
+ const manifestOptions = extractManifestOptions(argv);
302
+ manifest = await manifest_1.Manifest.fromManifest(github, targetBranch, argv.configFile, argv.manifestFile, manifestOptions);
303
+ }
304
+ if (argv.dryRun) {
305
+ const releases = await manifest.buildReleases();
306
+ logger_1.logger.info(releases);
307
+ }
308
+ else {
309
+ const releaseNumbers = await manifest.createReleases();
310
+ console.log(releaseNumbers);
311
+ }
312
+ },
313
+ };
314
+ const createManifestPullRequestCommand = {
315
+ command: 'manifest-pr',
316
+ describe: 'create a release-PR using a manifest file',
317
+ deprecated: 'use release-pr instead.',
318
+ builder(yargs) {
319
+ return manifestOptions(pullRequestOptions(gitHubOptions(yargs)));
320
+ },
321
+ async handler(argv) {
322
+ logger_1.logger.warn('manifest-pr is deprecated. Please use release-pr instead.');
323
+ const github = await buildGitHub(argv);
324
+ const targetBranch = argv.targetBranch ||
325
+ argv.defaultBranch ||
326
+ github.repository.defaultBranch;
327
+ const manifestOptions = extractManifestOptions(argv);
328
+ const manifest = await manifest_1.Manifest.fromManifest(github, targetBranch, argv.configFile, argv.manifestFile, manifestOptions);
329
+ if (argv.dryRun) {
330
+ const pullRequests = await manifest.buildPullRequests();
331
+ console.log(`Would open ${pullRequests.length} pull requests`);
332
+ console.log('fork:', manifest.fork);
333
+ for (const pullRequest of pullRequests) {
334
+ console.log('title:', pullRequest.title.toString());
335
+ console.log('branch:', pullRequest.headRefName);
336
+ console.log('draft:', pullRequest.draft);
337
+ console.log('body:', pullRequest.body.toString());
338
+ console.log('updates:', pullRequest.updates.length);
339
+ for (const update of pullRequest.updates) {
340
+ console.log(` ${update.path}: `,
341
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
342
+ update.updater.constructor);
343
+ }
344
+ }
345
+ }
346
+ else {
347
+ const pullRequestNumbers = await manifest.createPullRequests();
348
+ console.log(pullRequestNumbers);
349
+ }
350
+ },
351
+ };
352
+ const createManifestReleaseCommand = {
353
+ command: 'manifest-release',
354
+ describe: 'create releases/tags from last release-PR using a manifest file',
355
+ deprecated: 'use github-release instead',
356
+ builder(yargs) {
357
+ return manifestOptions(releaseOptions(gitHubOptions(yargs)));
358
+ },
359
+ async handler(argv) {
360
+ logger_1.logger.warn('manifest-release is deprecated. Please use github-release instead.');
361
+ const github = await buildGitHub(argv);
362
+ const targetBranch = argv.targetBranch ||
363
+ argv.defaultBranch ||
364
+ github.repository.defaultBranch;
365
+ const manifestOptions = extractManifestOptions(argv);
366
+ const manifest = await manifest_1.Manifest.fromManifest(github, targetBranch, argv.configFile, argv.manifestFile, manifestOptions);
367
+ if (argv.dryRun) {
368
+ const releases = await manifest.buildReleases();
369
+ logger_1.logger.info(releases);
370
+ }
371
+ else {
372
+ const releaseNumbers = await manifest.createReleases();
373
+ console.log(releaseNumbers);
374
+ }
375
+ },
376
+ };
377
+ const bootstrapCommand = {
378
+ command: 'bootstrap',
379
+ describe: 'configure release manifest',
380
+ builder(yargs) {
381
+ return manifestOptions(releaseOptions(pullRequestStrategyOptions(gitHubOptions(yargs))))
382
+ .option('initial-version', {
383
+ description: 'current version',
384
+ })
385
+ .coerce('path', arg => {
386
+ return arg || manifest_1.ROOT_PROJECT_PATH;
387
+ });
388
+ },
389
+ async handler(argv) {
390
+ const github = await buildGitHub(argv);
391
+ const targetBranch = argv.targetBranch ||
392
+ argv.defaultBranch ||
393
+ github.repository.defaultBranch;
394
+ const bootstrapper = new bootstrapper_1.Bootstrapper(github, targetBranch, argv.manifestFile, argv.configFile, argv.initialVersion);
395
+ const pullRequest = await bootstrapper.bootstrap(argv.path, {
396
+ releaseType: argv.releaseType,
397
+ component: argv.component,
398
+ packageName: argv.packageName,
399
+ draft: argv.draft,
400
+ draftPullRequest: argv.draftPullRequest,
401
+ bumpMinorPreMajor: argv.bumpMinorPreMajor,
402
+ bumpPatchForMinorPreMajor: argv.bumpPatchForMinorPreMajor,
403
+ changelogPath: argv.changelogPath,
404
+ changelogSections: argv.changelogSections,
405
+ releaseAs: argv.releaseAs,
406
+ versioning: argv.versioningStrategy,
407
+ extraFiles: argv.extraFiles,
408
+ versionFile: argv.versionFile,
409
+ });
410
+ console.log(pullRequest);
411
+ },
412
+ };
413
+ async function buildGitHub(argv) {
414
+ const [owner, repo] = parseGithubRepoUrl(argv.repoUrl);
415
+ const github = await github_1.GitHub.create({
416
+ owner,
417
+ repo,
418
+ token: argv.token,
149
419
  });
150
- })
151
- .command('github-release', 'create a GitHub release from a release PR',
152
- // options unique to GitHubRelease
153
- (yargs) => {
154
- releaseType(yargs);
155
- releaserCommon(yargs);
156
- yargs.option('draft', {
157
- describe: 'mark release as a draft. no tag is created but tag_name and ' +
158
- 'target_commitish are associated with the release for future ' +
159
- 'tag creation upon "un-drafting" the release.',
160
- type: 'boolean',
161
- default: false,
162
- });
163
- yargs.option('release-label', {
164
- describe: 'set a pull request label other than "autorelease: tagged"',
165
- type: 'string',
166
- });
167
- }, (argv) => {
168
- factory_1.factory.runCommand('github-release', argv).catch(exports.handleError);
169
- })
170
- .middleware(_argv => {
171
- const argv = _argv;
172
- // allow secrets to be loaded from file path
173
- // rather than being passed directly to the bin.
174
- if (argv.token)
175
- argv.token = coerce_option_1.coerceOption(argv.token);
176
- if (argv.apiUrl)
177
- argv.apiUrl = coerce_option_1.coerceOption(argv.apiUrl);
178
- })
420
+ return github;
421
+ }
422
+ exports.parser = yargs
423
+ .command(createReleasePullRequestCommand)
424
+ .command(createReleaseCommand)
425
+ .command(createManifestPullRequestCommand)
426
+ .command(createManifestReleaseCommand)
427
+ .command(bootstrapCommand)
179
428
  .option('debug', {
180
429
  describe: 'print verbose errors (use only for local debugging).',
181
430
  default: false,
182
431
  type: 'boolean',
183
432
  })
184
- // See base GitHub options (e.g. GitHubFactoryOptions)
185
- .option('token', { describe: 'GitHub token with repo write permissions' })
186
- .option('api-url', {
187
- describe: 'URL to use when making API requests',
188
- default: constants_1.GH_API_URL,
189
- type: 'string',
190
- })
191
- .option('default-branch', {
192
- describe: 'The branch to open release PRs against and tag releases on',
193
- type: 'string',
194
- })
195
- .option('fork', {
196
- describe: 'should the PR be created from a fork',
197
- type: 'boolean',
433
+ .option('trace', {
434
+ describe: 'print extra verbose errors (use only for local debugging).',
198
435
  default: false,
436
+ type: 'boolean',
199
437
  })
200
- .option('repo-url', {
201
- describe: 'GitHub URL to generate release for',
202
- demand: true,
438
+ .middleware(argv => {
439
+ if (argv.trace) {
440
+ logger_1.setLogger(new logger_1.CheckpointLogger(true, true));
441
+ }
442
+ else if (argv.debug) {
443
+ logger_1.setLogger(new logger_1.CheckpointLogger(true));
444
+ }
203
445
  })
204
446
  .demandCommand(1)
205
447
  .strict(true)
206
448
  .scriptName('release-please');
449
+ function extractManifestOptions(argv) {
450
+ const manifestOptions = {};
451
+ if ('fork' in argv && argv.fork !== undefined) {
452
+ manifestOptions.fork = argv.fork;
453
+ }
454
+ if (argv.label) {
455
+ manifestOptions.labels = argv.label.split(',');
456
+ }
457
+ if ('releaseLabel' in argv && argv.releaseLabel) {
458
+ manifestOptions.releaseLabels = argv.releaseLabel.split(',');
459
+ }
460
+ if ('signoff' in argv && argv.signoff) {
461
+ manifestOptions.signoff = argv.signoff;
462
+ }
463
+ if ('draft' in argv && argv.draft !== undefined) {
464
+ manifestOptions.draft = argv.draft;
465
+ }
466
+ if ('draftPullRequest' in argv && argv.draftPullRequest !== undefined) {
467
+ manifestOptions.draftPullRequest = argv.draftPullRequest;
468
+ }
469
+ return manifestOptions;
470
+ }
207
471
  // The errors returned by octokit currently contain the
208
472
  // request object, this contains information we don't want to
209
473
  // leak. For this reason, we capture exceptions and print
210
474
  // a less verbose error message (run with --debug to output
211
475
  // the request object, don't do this in CI/CD).
212
476
  exports.handleError = (err) => {
213
- var _a;
477
+ var _a, _b;
214
478
  let status = '';
215
479
  if (exports.handleError.yargsArgs === undefined) {
216
480
  throw new Error('Set handleError.yargsArgs with a yargs.Arguments instance.');
217
481
  }
218
- if (!exports.handleError.logger) {
219
- exports.handleError.logger = console;
220
- }
221
482
  const ya = exports.handleError.yargsArgs;
222
- const logger = exports.handleError.logger;
223
- const command = ((_a = ya === null || ya === void 0 ? void 0 : ya._) === null || _a === void 0 ? void 0 : _a.length) ? ya._[0] : '';
483
+ const errorLogger = (_a = exports.handleError.logger) !== null && _a !== void 0 ? _a : logger_1.logger;
484
+ const command = ((_b = ya === null || ya === void 0 ? void 0 : ya._) === null || _b === void 0 ? void 0 : _b.length) ? ya._[0] : '';
224
485
  if (err.status) {
225
486
  status = '' + err.status;
226
487
  }
227
- logger.error(chalk.red(`command ${command} failed${status ? ` with status ${status}` : ''}`));
488
+ errorLogger.error(`command ${command} failed${status ? ` with status ${status}` : ''}`);
228
489
  if (ya === null || ya === void 0 ? void 0 : ya.debug) {
229
- logger.error('---------');
230
- logger.error(err.stack);
490
+ logger_1.logger.error('---------');
491
+ logger_1.logger.error(err.stack);
231
492
  }
232
493
  process.exitCode = 1;
233
494
  };
@@ -235,13 +496,15 @@ exports.handleError = (err) => {
235
496
  // for the parser to be easily tested:
236
497
  let argv;
237
498
  if (require.main === module) {
238
- argv = exports.parser.parse();
239
- exports.handleError.yargsArgs = argv;
240
- process.on('unhandledRejection', err => {
241
- exports.handleError(err);
242
- });
243
- process.on('uncaughtException', err => {
244
- exports.handleError(err);
245
- });
499
+ (async () => {
500
+ argv = await exports.parser.parseAsync();
501
+ exports.handleError.yargsArgs = argv;
502
+ process.on('unhandledRejection', err => {
503
+ exports.handleError(err);
504
+ });
505
+ process.on('uncaughtException', err => {
506
+ exports.handleError(err);
507
+ });
508
+ })();
246
509
  }
247
510
  //# sourceMappingURL=release-please.js.map
@@ -0,0 +1,12 @@
1
+ import { GitHub } from './github';
2
+ import { ReleaserConfig } from './manifest';
3
+ import { PullRequest } from './pull-request';
4
+ export declare class Bootstrapper {
5
+ private github;
6
+ private targetBranch;
7
+ private manifestFile;
8
+ private configFile;
9
+ private initialVersion;
10
+ constructor(github: GitHub, targetBranch: string, manifestFile?: string, configFile?: string, initialVersionString?: string);
11
+ bootstrap(path: string, config: ReleaserConfig): Promise<PullRequest>;
12
+ }