release-please 12.6.0 → 13.0.0-candidate.3

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