release-please 12.6.0 → 13.0.0-candidate.0

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/build/src/bin/release-please.d.ts +51 -13
  2. package/build/src/bin/release-please.js +409 -157
  3. package/build/src/bootstrapper.d.ts +12 -0
  4. package/build/src/bootstrapper.js +60 -0
  5. package/build/src/commit.d.ts +26 -0
  6. package/build/src/{util/to-conventional-changelog-format.js → commit.js} +97 -2
  7. package/build/src/errors/index.d.ts +0 -5
  8. package/build/src/errors/index.js +1 -10
  9. package/build/src/factory.d.ts +25 -37
  10. package/build/src/factory.js +159 -151
  11. package/build/src/github.d.ts +151 -884
  12. package/build/src/github.js +584 -1014
  13. package/build/src/manifest.d.ts +177 -48
  14. package/build/src/manifest.js +583 -487
  15. package/build/src/plugin.d.ts +20 -0
  16. package/build/src/{plugins/plugin.js → plugin.js} +10 -9
  17. package/build/src/plugins/cargo-workspace.d.ts +48 -18
  18. package/build/src/plugins/cargo-workspace.js +247 -328
  19. package/build/src/plugins/merge.d.ts +11 -0
  20. package/build/src/plugins/merge.js +83 -0
  21. package/build/src/plugins/node-workspace.d.ts +35 -17
  22. package/build/src/plugins/node-workspace.js +234 -271
  23. package/build/src/plugins/workspace.d.ts +102 -0
  24. package/build/src/plugins/workspace.js +170 -0
  25. package/build/src/pull-request.d.ts +10 -0
  26. package/build/src/{updaters/java/readme.js → pull-request.js} +2 -7
  27. package/build/src/release-notes.d.ts +29 -0
  28. package/build/src/release-notes.js +71 -0
  29. package/build/src/release-pull-request.d.ts +13 -0
  30. package/build/src/{updaters/java/pom-xml.js → release-pull-request.js} +2 -7
  31. package/build/src/release.d.ts +6 -0
  32. package/build/src/release.js +16 -0
  33. package/build/src/repository.d.ts +5 -0
  34. package/build/src/repository.js +16 -0
  35. package/build/src/strategies/dart.d.ts +8 -0
  36. package/build/src/strategies/dart.js +63 -0
  37. package/build/src/strategies/elixir.d.ts +5 -0
  38. package/build/src/{releasers → strategies}/elixir.js +18 -14
  39. package/build/src/strategies/go-yoshi.d.ts +13 -0
  40. package/build/src/strategies/go-yoshi.js +106 -0
  41. package/build/src/strategies/go.d.ts +5 -0
  42. package/build/src/{releasers → strategies}/go.js +11 -12
  43. package/build/src/strategies/helm.d.ts +8 -0
  44. package/build/src/strategies/helm.js +63 -0
  45. package/build/src/strategies/java-yoshi.d.ts +24 -0
  46. package/build/src/strategies/java-yoshi.js +203 -0
  47. package/build/src/strategies/krm-blueprint.d.ts +7 -0
  48. package/build/src/{releasers → strategies}/krm-blueprint.js +26 -22
  49. package/build/src/strategies/node.d.ts +9 -0
  50. package/build/src/strategies/node.js +82 -0
  51. package/build/src/strategies/ocaml.d.ts +5 -0
  52. package/build/src/{releasers → strategies}/ocaml.js +34 -28
  53. package/build/src/strategies/php-yoshi.d.ts +9 -0
  54. package/build/src/strategies/php-yoshi.js +214 -0
  55. package/build/src/strategies/php.d.ts +6 -0
  56. package/build/src/{releasers → strategies}/php.js +24 -23
  57. package/build/src/strategies/python.d.ts +8 -0
  58. package/build/src/strategies/python.js +117 -0
  59. package/build/src/strategies/ruby-yoshi.d.ts +17 -0
  60. package/build/src/strategies/ruby-yoshi.js +116 -0
  61. package/build/src/strategies/ruby.d.ts +13 -0
  62. package/build/src/{releasers → strategies}/ruby.js +26 -27
  63. package/build/src/strategies/rust.d.ts +20 -0
  64. package/build/src/strategies/rust.js +120 -0
  65. package/build/src/strategies/simple.d.ts +5 -0
  66. package/build/src/{releasers → strategies}/simple.js +18 -14
  67. package/build/src/strategies/terraform-module.d.ts +7 -0
  68. package/build/src/{releasers → strategies}/terraform-module.js +29 -23
  69. package/build/src/strategy.d.ts +99 -0
  70. package/build/src/strategy.js +237 -0
  71. package/build/src/update.d.ts +23 -0
  72. package/build/src/{updaters/update.js → update.js} +1 -1
  73. package/build/src/updaters/changelog.d.ts +7 -10
  74. package/build/src/updaters/changelog.js +3 -9
  75. package/build/src/updaters/changelog.js.map +1 -1
  76. package/build/src/updaters/composite.d.ts +19 -0
  77. package/build/src/updaters/composite.js +42 -0
  78. package/build/src/updaters/dart/pubspec-yaml.d.ts +12 -0
  79. package/build/src/updaters/{pubspec-yaml.js → dart/pubspec-yaml.js} +13 -12
  80. package/build/src/updaters/default.d.ts +21 -0
  81. package/build/src/updaters/{version-txt.js → default.js} +16 -10
  82. package/build/src/updaters/dotnet/csproj.d.ts +12 -0
  83. package/build/src/updaters/{java/google-utils.js → dotnet/csproj.js} +16 -13
  84. package/build/src/updaters/elixir/elixir-mix-exs.d.ts +12 -0
  85. package/build/src/updaters/{elixir-mix-exs.js → elixir/elixir-mix-exs.js} +12 -10
  86. package/build/src/updaters/helm/chart-yaml.d.ts +10 -11
  87. package/build/src/updaters/helm/chart-yaml.js +12 -10
  88. package/build/src/updaters/java/java-update.d.ts +14 -0
  89. package/build/src/updaters/java/{java_update.js → java-update.js} +22 -22
  90. package/build/src/updaters/java/versions-manifest.d.ts +12 -2
  91. package/build/src/updaters/java/versions-manifest.js +20 -4
  92. package/build/src/updaters/krm/krm-blueprint-version.d.ts +10 -11
  93. package/build/src/updaters/krm/krm-blueprint-version.js +13 -12
  94. package/build/src/updaters/node/package-json.d.ts +12 -0
  95. package/build/src/updaters/{package-json.js → node/package-json.js} +14 -16
  96. package/build/src/updaters/node/package-lock-json.d.ts +8 -0
  97. package/build/src/updaters/node/package-lock-json.js +36 -0
  98. package/build/src/updaters/node/samples-package-json.d.ts +23 -0
  99. package/build/src/updaters/{samples-package-json.js → node/samples-package-json.js} +19 -8
  100. package/build/src/updaters/ocaml/dune-project.d.ts +10 -11
  101. package/build/src/updaters/ocaml/dune-project.js +11 -9
  102. package/build/src/updaters/ocaml/esy-json.d.ts +10 -11
  103. package/build/src/updaters/ocaml/esy-json.js +12 -10
  104. package/build/src/updaters/ocaml/opam.d.ts +10 -11
  105. package/build/src/updaters/ocaml/opam.js +11 -9
  106. package/build/src/updaters/php/php-client-version.d.ts +12 -0
  107. package/build/src/updaters/{php-client-version.js → php/php-client-version.js} +10 -9
  108. package/build/src/updaters/php/php-manifest.d.ts +13 -0
  109. package/build/src/updaters/{php-manifest.js → php/php-manifest.js} +17 -15
  110. package/build/src/updaters/php/root-composer-update-packages.d.ts +12 -0
  111. package/build/src/updaters/{root-composer-update-packages.js → php/root-composer-update-packages.js} +17 -16
  112. package/build/src/updaters/python/pyproject-toml.d.ts +10 -11
  113. package/build/src/updaters/python/pyproject-toml.js +13 -11
  114. package/build/src/updaters/python/python-file-with-version.d.ts +7 -11
  115. package/build/src/updaters/python/python-file-with-version.js +7 -8
  116. package/build/src/updaters/python/setup-cfg.d.ts +10 -11
  117. package/build/src/updaters/python/setup-cfg.js +10 -8
  118. package/build/src/updaters/python/setup-py.d.ts +10 -11
  119. package/build/src/updaters/python/setup-py.js +10 -8
  120. package/build/src/updaters/raw-content.d.ts +19 -0
  121. package/build/src/{plugins/index.js → updaters/raw-content.js} +23 -12
  122. package/build/src/updaters/release-please-config.d.ts +8 -0
  123. package/build/src/updaters/release-please-config.js +41 -0
  124. package/build/src/updaters/release-please-manifest.d.ts +2 -11
  125. package/build/src/updaters/release-please-manifest.js +11 -14
  126. package/build/src/updaters/ruby/version-rb.d.ts +12 -0
  127. package/build/src/updaters/{version-rb.js → ruby/version-rb.js} +10 -8
  128. package/build/src/updaters/rust/cargo-lock.d.ts +7 -11
  129. package/build/src/updaters/rust/cargo-lock.js +14 -16
  130. package/build/src/updaters/rust/cargo-toml.d.ts +7 -11
  131. package/build/src/updaters/rust/cargo-toml.js +19 -21
  132. package/build/src/updaters/terraform/module-version.d.ts +10 -11
  133. package/build/src/updaters/terraform/module-version.js +11 -9
  134. package/build/src/updaters/terraform/readme.d.ts +10 -11
  135. package/build/src/updaters/terraform/readme.js +11 -10
  136. package/build/src/updaters/terraform/readme.js.map +1 -1
  137. package/build/src/util/branch-name.d.ts +5 -4
  138. package/build/src/util/branch-name.js +13 -10
  139. package/build/src/{commit-split.d.ts → util/commit-split.d.ts} +2 -4
  140. package/build/src/{commit-split.js → util/commit-split.js} +4 -2
  141. package/build/src/util/indent-commit.d.ts +1 -1
  142. package/build/src/util/logger.d.ts +5 -2
  143. package/build/src/util/logger.js +9 -4
  144. package/build/src/util/pull-request-body.d.ts +20 -0
  145. package/build/src/util/pull-request-body.js +129 -0
  146. package/build/src/util/pull-request-title.d.ts +8 -6
  147. package/build/src/util/pull-request-title.js +20 -6
  148. package/build/src/util/tag-name.d.ts +9 -0
  149. package/build/src/util/tag-name.js +41 -0
  150. package/build/src/{updaters → util}/toml-edit.d.ts +0 -0
  151. package/build/src/{updaters → util}/toml-edit.js +0 -0
  152. package/build/src/version.d.ts +11 -0
  153. package/build/src/version.js +45 -0
  154. package/build/src/versioning-strategies/always-bump-patch.d.ts +7 -0
  155. package/build/src/{updaters/package-lock-json.js → versioning-strategies/always-bump-patch.js} +8 -11
  156. package/build/src/versioning-strategies/default.d.ts +15 -0
  157. package/build/src/versioning-strategies/default.js +67 -0
  158. package/build/src/versioning-strategies/dependency-manifest.d.ts +7 -0
  159. package/build/src/versioning-strategies/dependency-manifest.js +90 -0
  160. package/build/src/versioning-strategies/java-add-snapshot.d.ts +9 -0
  161. package/build/src/versioning-strategies/java-add-snapshot.js +53 -0
  162. package/build/src/versioning-strategies/java-snapshot.d.ts +9 -0
  163. package/build/src/versioning-strategies/java-snapshot.js +67 -0
  164. package/build/src/versioning-strategies/service-pack.d.ts +7 -0
  165. package/build/src/versioning-strategies/service-pack.js +40 -0
  166. package/build/src/versioning-strategy.d.ts +28 -0
  167. package/build/src/versioning-strategy.js +55 -0
  168. package/package.json +8 -7
  169. package/build/src/constants.d.ts +0 -7
  170. package/build/src/constants.js +0 -24
  171. package/build/src/conventional-commits.d.ts +0 -53
  172. package/build/src/conventional-commits.js +0 -167
  173. package/build/src/github-release.d.ts +0 -34
  174. package/build/src/github-release.js +0 -92
  175. package/build/src/graphql-to-commits.d.ts +0 -60
  176. package/build/src/graphql-to-commits.js +0 -112
  177. package/build/src/index.d.ts +0 -95
  178. package/build/src/index.js +0 -32
  179. package/build/src/plugins/index.d.ts +0 -5
  180. package/build/src/plugins/plugin.d.ts +0 -21
  181. package/build/src/release-pr.d.ts +0 -101
  182. package/build/src/release-pr.js +0 -461
  183. package/build/src/releasers/dart.d.ts +0 -9
  184. package/build/src/releasers/dart.js +0 -65
  185. package/build/src/releasers/elixir.d.ts +0 -5
  186. package/build/src/releasers/go-yoshi.d.ts +0 -10
  187. package/build/src/releasers/go-yoshi.js +0 -162
  188. package/build/src/releasers/go.d.ts +0 -6
  189. package/build/src/releasers/helm.d.ts +0 -9
  190. package/build/src/releasers/helm.js +0 -66
  191. package/build/src/releasers/index.d.ts +0 -7
  192. package/build/src/releasers/index.js +0 -76
  193. package/build/src/releasers/java/bump_type.d.ts +0 -4
  194. package/build/src/releasers/java/bump_type.js +0 -38
  195. package/build/src/releasers/java/stability.d.ts +0 -5
  196. package/build/src/releasers/java/stability.js +0 -37
  197. package/build/src/releasers/java/version.d.ts +0 -13
  198. package/build/src/releasers/java/version.js +0 -112
  199. package/build/src/releasers/java-backport.d.ts +0 -9
  200. package/build/src/releasers/java-backport.js +0 -43
  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,226 +15,476 @@
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', {
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
+ draft: argv.draft,
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(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
+ bumpMinorPreMajor: argv.bumpMinorPreMajor,
401
+ bumpPatchForMinorPreMajor: argv.bumpPatchForMinorPreMajor,
402
+ changelogPath: argv.changelogPath,
403
+ changelogSections: argv.changelogSections,
404
+ releaseAs: argv.releaseAs,
405
+ versioning: argv.versioningStrategy,
406
+ extraFiles: argv.extraFiles,
407
+ versionFile: argv.versionFile,
408
+ });
409
+ console.log(pullRequest);
410
+ },
411
+ };
412
+ async function buildGitHub(argv) {
413
+ const [owner, repo] = parseGithubRepoUrl(argv.repoUrl);
414
+ const github = await github_1.GitHub.create({
415
+ owner,
416
+ repo,
417
+ token: argv.token,
149
418
  });
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
- if (argv.graphqlUrl)
179
- argv.graphqlUrl = coerce_option_1.coerceOption(argv.graphqlUrl);
180
- })
419
+ return github;
420
+ }
421
+ exports.parser = yargs
422
+ .command(createReleasePullRequestCommand)
423
+ .command(createReleaseCommand)
424
+ .command(createManifestPullRequestCommand)
425
+ .command(createManifestReleaseCommand)
426
+ .command(bootstrapCommand)
181
427
  .option('debug', {
182
428
  describe: 'print verbose errors (use only for local debugging).',
183
429
  default: false,
184
430
  type: 'boolean',
185
431
  })
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',
432
+ .option('trace', {
433
+ describe: 'print extra verbose errors (use only for local debugging).',
205
434
  default: false,
435
+ type: 'boolean',
206
436
  })
207
- .option('repo-url', {
208
- describe: 'GitHub URL to generate release for',
209
- demand: true,
437
+ .middleware(argv => {
438
+ if (argv.trace) {
439
+ logger_1.setLogger(new logger_1.CheckpointLogger(true, true));
440
+ }
441
+ else if (argv.debug) {
442
+ logger_1.setLogger(new logger_1.CheckpointLogger(true));
443
+ }
210
444
  })
211
445
  .demandCommand(1)
212
446
  .strict(true)
213
447
  .scriptName('release-please');
448
+ function extractManifestOptions(argv) {
449
+ const manifestOptions = {};
450
+ if ('fork' in argv && argv.fork !== undefined) {
451
+ manifestOptions.fork = argv.fork;
452
+ }
453
+ if (argv.label) {
454
+ manifestOptions.labels = argv.label.split(',');
455
+ }
456
+ if ('releaseLabel' in argv && argv.releaseLabel) {
457
+ manifestOptions.releaseLabels = argv.releaseLabel.split(',');
458
+ }
459
+ if ('signoff' in argv && argv.signoff) {
460
+ manifestOptions.signoff = argv.signoff;
461
+ }
462
+ if ('draft' in argv && argv.draft !== undefined) {
463
+ manifestOptions.draft = argv.draft;
464
+ }
465
+ return manifestOptions;
466
+ }
214
467
  // The errors returned by octokit currently contain the
215
468
  // request object, this contains information we don't want to
216
469
  // leak. For this reason, we capture exceptions and print
217
470
  // a less verbose error message (run with --debug to output
218
471
  // the request object, don't do this in CI/CD).
219
472
  exports.handleError = (err) => {
220
- var _a;
473
+ var _a, _b;
221
474
  let status = '';
222
475
  if (exports.handleError.yargsArgs === undefined) {
223
476
  throw new Error('Set handleError.yargsArgs with a yargs.Arguments instance.');
224
477
  }
225
- if (!exports.handleError.logger) {
226
- exports.handleError.logger = console;
227
- }
228
478
  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] : '';
479
+ const errorLogger = (_a = exports.handleError.logger) !== null && _a !== void 0 ? _a : logger_1.logger;
480
+ const command = ((_b = ya === null || ya === void 0 ? void 0 : ya._) === null || _b === void 0 ? void 0 : _b.length) ? ya._[0] : '';
231
481
  if (err.status) {
232
482
  status = '' + err.status;
233
483
  }
234
- logger.error(chalk.red(`command ${command} failed${status ? ` with status ${status}` : ''}`));
484
+ errorLogger.error(`command ${command} failed${status ? ` with status ${status}` : ''}`);
235
485
  if (ya === null || ya === void 0 ? void 0 : ya.debug) {
236
- logger.error('---------');
237
- logger.error(err.stack);
486
+ logger_1.logger.error('---------');
487
+ logger_1.logger.error(err.stack);
238
488
  }
239
489
  process.exitCode = 1;
240
490
  };
@@ -242,13 +492,15 @@ exports.handleError = (err) => {
242
492
  // for the parser to be easily tested:
243
493
  let argv;
244
494
  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
- });
495
+ (async () => {
496
+ argv = await exports.parser.parseAsync();
497
+ exports.handleError.yargsArgs = argv;
498
+ process.on('unhandledRejection', err => {
499
+ exports.handleError(err);
500
+ });
501
+ process.on('uncaughtException', err => {
502
+ exports.handleError(err);
503
+ });
504
+ })();
253
505
  }
254
506
  //# 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
+ }