release-please 13.0.0-candidate.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.
@@ -37,8 +37,13 @@ interface ManifestConfigArgs {
37
37
  packageName?: string;
38
38
  releaseType?: ReleaseType;
39
39
  }
40
- interface PullRequestArgs {
40
+ interface ReleaseArgs {
41
41
  draft?: boolean;
42
+ releaseLabel?: string;
43
+ label?: string;
44
+ }
45
+ interface PullRequestArgs {
46
+ draftPullRequest?: boolean;
42
47
  label?: string;
43
48
  signoff?: string;
44
49
  }
@@ -52,7 +57,7 @@ interface PullRequestStrategyArgs {
52
57
  pullRequestTitlePattern?: string;
53
58
  extraFiles?: string[];
54
59
  }
55
- interface BootstrapArgs extends GitHubArgs, ManifestArgs, ManifestConfigArgs, VersioningArgs, PullRequestArgs, PullRequestStrategyArgs {
60
+ interface BootstrapArgs extends GitHubArgs, ManifestArgs, ManifestConfigArgs, VersioningArgs, PullRequestArgs, PullRequestStrategyArgs, ReleaseArgs {
56
61
  initialVersion?: string;
57
62
  }
58
63
  export declare const parser: yargs.Argv<BootstrapArgs & {
@@ -98,7 +98,7 @@ function pullRequestOptions(yargs) {
98
98
  type: 'boolean',
99
99
  default: false,
100
100
  })
101
- .option('draft', {
101
+ .option('draft-pull-request', {
102
102
  describe: 'mark pull request as a draft',
103
103
  type: 'boolean',
104
104
  default: false,
@@ -239,7 +239,7 @@ const createReleasePullRequestCommand = {
239
239
  releaseType: argv.releaseType,
240
240
  component: argv.component,
241
241
  packageName: argv.packageName,
242
- draft: argv.draft,
242
+ draftPullRequest: argv.draftPullRequest,
243
243
  bumpMinorPreMajor: argv.bumpMinorPreMajor,
244
244
  bumpPatchForMinorPreMajor: argv.bumpPatchForMinorPreMajor,
245
245
  changelogPath: argv.changelogPath,
@@ -378,7 +378,7 @@ const bootstrapCommand = {
378
378
  command: 'bootstrap',
379
379
  describe: 'configure release manifest',
380
380
  builder(yargs) {
381
- return manifestOptions(pullRequestStrategyOptions(gitHubOptions(yargs)))
381
+ return manifestOptions(releaseOptions(pullRequestStrategyOptions(gitHubOptions(yargs))))
382
382
  .option('initial-version', {
383
383
  description: 'current version',
384
384
  })
@@ -397,6 +397,7 @@ const bootstrapCommand = {
397
397
  component: argv.component,
398
398
  packageName: argv.packageName,
399
399
  draft: argv.draft,
400
+ draftPullRequest: argv.draftPullRequest,
400
401
  bumpMinorPreMajor: argv.bumpMinorPreMajor,
401
402
  bumpPatchForMinorPreMajor: argv.bumpPatchForMinorPreMajor,
402
403
  changelogPath: argv.changelogPath,
@@ -462,6 +463,9 @@ function extractManifestOptions(argv) {
462
463
  if ('draft' in argv && argv.draft !== undefined) {
463
464
  manifestOptions.draft = argv.draft;
464
465
  }
466
+ if ('draftPullRequest' in argv && argv.draftPullRequest !== undefined) {
467
+ manifestOptions.draftPullRequest = argv.draftPullRequest;
468
+ }
465
469
  return manifestOptions;
466
470
  }
467
471
  // The errors returned by octokit currently contain the
@@ -42,6 +42,7 @@ export interface GitHubRelease {
42
42
  sha: string;
43
43
  notes?: string;
44
44
  url: string;
45
+ draft?: boolean;
45
46
  }
46
47
  export declare class GitHub {
47
48
  readonly repository: Repository;
@@ -97,6 +98,14 @@ export declare class GitHub {
97
98
  */
98
99
  mergeCommitIterator(targetBranch: string, maxResults?: number): AsyncGenerator<Commit, void, unknown>;
99
100
  private mergeCommitsGraphQL;
101
+ /**
102
+ * Get the list of file paths modified in a given commit.
103
+ *
104
+ * @param {string} sha The commit SHA
105
+ * @returns {string[]} File paths
106
+ * @throws {GitHubAPIError} on an API error
107
+ */
108
+ getCommitFiles: (sha: string) => Promise<string[]>;
100
109
  private graphqlRequest;
101
110
  /**
102
111
  * Iterate through merged pull requests with a max number of results scanned.
@@ -129,15 +138,6 @@ export declare class GitHub {
129
138
  */
130
139
  releaseIterator(maxResults?: number): AsyncGenerator<GitHubRelease, void, unknown>;
131
140
  private releaseGraphQL;
132
- /**
133
- * Return a list of tags. The list is not guaranteed to be sorted.
134
- *
135
- * @param {number} page - Page of results. Defaults to 1.
136
- * @param {number} perPage - Number of results per page. Defaults to 100.
137
- * @returns {GitHubRelease[]} - List of tags
138
- * @throws {GitHubAPIError} on an API error
139
- */
140
- private listReleases;
141
141
  /**
142
142
  * Fetch the contents of a file from the configured branch
143
143
  *
@@ -276,7 +276,9 @@ export declare class GitHub {
276
276
  * @throws {DuplicateReleaseError} if the release tag already exists
277
277
  * @throws {GitHubAPIError} on other API errors
278
278
  */
279
- createRelease: (release: Release) => Promise<GitHubRelease>;
279
+ createRelease: (release: Release, options?: {
280
+ draft?: boolean | undefined;
281
+ } | undefined) => Promise<GitHubRelease>;
280
282
  /**
281
283
  * Makes a comment on a issue/pull request.
282
284
  *
@@ -28,6 +28,23 @@ const manifest_1 = require("./manifest");
28
28
  const signoff_commit_message_1 = require("./util/signoff-commit-message");
29
29
  class GitHub {
30
30
  constructor(options) {
31
+ /**
32
+ * Get the list of file paths modified in a given commit.
33
+ *
34
+ * @param {string} sha The commit SHA
35
+ * @returns {string[]} File paths
36
+ * @throws {GitHubAPIError} on an API error
37
+ */
38
+ this.getCommitFiles = wrapAsync(async (sha) => {
39
+ logger_1.logger.debug(`Backfilling file list for commit: ${sha}`);
40
+ const resp = await this.octokit.repos.getCommit({
41
+ owner: this.repository.owner,
42
+ repo: this.repository.repo,
43
+ ref: sha,
44
+ });
45
+ const files = resp.data.files || [];
46
+ return files.map(file => file.filename).filter(filename => !!filename);
47
+ });
31
48
  this.graphqlRequest = wrapAsync(async (opts, maxRetries = 1) => {
32
49
  while (maxRetries >= 0) {
33
50
  try {
@@ -41,32 +58,6 @@ class GitHub {
41
58
  maxRetries -= 1;
42
59
  }
43
60
  });
44
- /**
45
- * Return a list of tags. The list is not guaranteed to be sorted.
46
- *
47
- * @param {number} page - Page of results. Defaults to 1.
48
- * @param {number} perPage - Number of results per page. Defaults to 100.
49
- * @returns {GitHubRelease[]} - List of tags
50
- * @throws {GitHubAPIError} on an API error
51
- */
52
- this.listReleases = wrapAsync(async (page = 1, perPage = 100) => {
53
- logger_1.logger.debug(`Fetching releases page ${page}`);
54
- const releases = await this.octokit.repos.listReleases({
55
- owner: this.repository.owner,
56
- repo: this.repository.repo,
57
- page,
58
- per_page: perPage,
59
- });
60
- return releases.data.map(release => {
61
- return {
62
- name: release.name || undefined,
63
- tagName: release.tag_name,
64
- sha: release.target_commitish,
65
- notes: release.body_text,
66
- url: release.html_url,
67
- };
68
- });
69
- });
70
61
  /**
71
62
  * Fetch the contents of a file with the Contents API
72
63
  *
@@ -306,13 +297,14 @@ class GitHub {
306
297
  * @throws {DuplicateReleaseError} if the release tag already exists
307
298
  * @throws {GitHubAPIError} on other API errors
308
299
  */
309
- this.createRelease = wrapAsync(async (release) => {
300
+ this.createRelease = wrapAsync(async (release, options = {}) => {
310
301
  const resp = await this.octokit.repos.createRelease({
311
302
  owner: this.repository.owner,
312
303
  repo: this.repository.repo,
313
304
  tag_name: release.tag.toString(),
314
305
  body: release.notes,
315
306
  sha: release.sha,
307
+ draft: !!options.draft,
316
308
  });
317
309
  return {
318
310
  name: resp.data.name || undefined,
@@ -320,6 +312,7 @@ class GitHub {
320
312
  sha: resp.data.target_commitish,
321
313
  notes: resp.data.body_text,
322
314
  url: resp.data.html_url,
315
+ draft: resp.data.draft,
323
316
  };
324
317
  }, e => {
325
318
  if (e instanceof request_error_1.RequestError) {
@@ -568,38 +561,44 @@ class GitHub {
568
561
  }
569
562
  const history = response.repository.ref.target.history;
570
563
  const commits = (history.nodes || []);
564
+ const commitData = [];
565
+ for (const graphCommit of commits) {
566
+ const commit = {
567
+ sha: graphCommit.sha,
568
+ message: graphCommit.message,
569
+ files: [],
570
+ };
571
+ const pullRequest = graphCommit.associatedPullRequests.nodes.find(pr => {
572
+ return pr.mergeCommit && pr.mergeCommit.oid === graphCommit.sha;
573
+ });
574
+ if (pullRequest) {
575
+ const files = pullRequest.files.nodes.map(node => node.path);
576
+ commit.pullRequest = {
577
+ sha: commit.sha,
578
+ number: pullRequest.number,
579
+ baseBranchName: pullRequest.baseRefName,
580
+ headBranchName: pullRequest.headRefName,
581
+ title: pullRequest.title,
582
+ body: pullRequest.body,
583
+ labels: pullRequest.labels.nodes.map(node => node.name),
584
+ files,
585
+ };
586
+ // We cannot directly fetch files on commits via graphql, only provide file
587
+ // information for commits with associated pull requests
588
+ commit.files = files;
589
+ }
590
+ else {
591
+ // In this case, there is no squashed merge commit. This could be a simple
592
+ // merge commit, a rebase merge commit, or a direct commit to the branch.
593
+ // Fallback to fetching the list of commits from the REST API. In the future
594
+ // we can perhaps lazy load these.
595
+ commit.files = await this.getCommitFiles(graphCommit.sha);
596
+ }
597
+ commitData.push(commit);
598
+ }
571
599
  return {
572
600
  pageInfo: history.pageInfo,
573
- data: commits.map(graphCommit => {
574
- const commit = {
575
- sha: graphCommit.sha,
576
- message: graphCommit.message,
577
- files: [],
578
- };
579
- const pullRequest = graphCommit.associatedPullRequests.nodes.find(pr => {
580
- return pr.mergeCommit && pr.mergeCommit.oid === graphCommit.sha;
581
- });
582
- if (pullRequest) {
583
- const files = pullRequest.files.nodes.map(node => node.path);
584
- commit.pullRequest = {
585
- sha: commit.sha,
586
- number: pullRequest.number,
587
- baseBranchName: pullRequest.baseRefName,
588
- headBranchName: pullRequest.headRefName,
589
- title: pullRequest.title,
590
- body: pullRequest.body,
591
- labels: pullRequest.labels.nodes.map(node => node.name),
592
- files,
593
- };
594
- // We cannot directly fetch files on commits via graphql, only provide file
595
- // information for commits with associated pull requests
596
- commit.files = files;
597
- }
598
- else {
599
- logger_1.logger.warn(`No merged pull request for commit: ${graphCommit.sha} - files unavailable`);
600
- }
601
- return commit;
602
- }),
601
+ data: commitData,
603
602
  };
604
603
  }
605
604
  /**
@@ -750,6 +749,7 @@ class GitHub {
750
749
  }
751
750
  url
752
751
  description
752
+ isDraft
753
753
  }
754
754
  pageInfo {
755
755
  endCursor
@@ -783,6 +783,7 @@ class GitHub {
783
783
  sha: release.tagCommit.oid,
784
784
  notes: release.description,
785
785
  url: release.url,
786
+ draft: release.isDraft,
786
787
  };
787
788
  }),
788
789
  };
@@ -18,6 +18,7 @@ export interface ReleaserConfig {
18
18
  releaseAs?: string;
19
19
  skipGithubRelease?: boolean;
20
20
  draft?: boolean;
21
+ draftPullRequest?: boolean;
21
22
  component?: string;
22
23
  packageName?: string;
23
24
  versionFile?: string;
@@ -30,6 +31,7 @@ export interface CandidateReleasePullRequest {
30
31
  }
31
32
  export interface CandidateRelease extends Release {
32
33
  pullRequest: PullRequest;
34
+ draft?: boolean;
33
35
  }
34
36
  interface ReleaserConfigJson {
35
37
  'release-type'?: ReleaseType;
@@ -39,6 +41,7 @@ interface ReleaserConfigJson {
39
41
  'release-as'?: string;
40
42
  'skip-github-release'?: boolean;
41
43
  draft?: boolean;
44
+ 'draft-pull-request'?: boolean;
42
45
  label?: string;
43
46
  'release-label'?: string;
44
47
  'version-file'?: string;
@@ -56,7 +59,7 @@ export interface ManifestOptions {
56
59
  labels?: string[];
57
60
  releaseLabels?: string[];
58
61
  draft?: boolean;
59
- releaseDraft?: boolean;
62
+ draftPullRequest?: boolean;
60
63
  }
61
64
  interface ReleaserPackageConfig extends ReleaserConfigJson {
62
65
  'package-name'?: string;
@@ -98,6 +101,8 @@ export declare class Manifest {
98
101
  private manifestPath;
99
102
  private bootstrapSha?;
100
103
  private lastReleaseSha?;
104
+ private draft?;
105
+ private draftPullRequest?;
101
106
  /**
102
107
  * Create a Manifest from explicit config in code. This assumes that the
103
108
  * repository has a single component at the root path.
@@ -74,6 +74,8 @@ class Manifest {
74
74
  this.labels = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.labels) || DEFAULT_LABELS;
75
75
  this.bootstrapSha = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.bootstrapSha;
76
76
  this.lastReleaseSha = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.lastReleaseSha;
77
+ this.draft = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.draft;
78
+ this.draftPullRequest = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.draftPullRequest;
77
79
  }
78
80
  /**
79
81
  * Create a Manifest from config files in the repository.
@@ -140,6 +142,7 @@ class Manifest {
140
142
  * @returns {ReleasePullRequest[]} The candidate pull requests to open or update.
141
143
  */
142
144
  async buildPullRequests() {
145
+ var _a;
143
146
  logger_1.logger.info('Building pull requests');
144
147
  const pathsByComponent = await this.getPathsByComponent();
145
148
  const strategiesByPath = await this.getStrategiesByPath();
@@ -258,7 +261,7 @@ class Manifest {
258
261
  }
259
262
  const strategy = strategiesByPath[path];
260
263
  const latestRelease = releasesByPath[path];
261
- const releasePullRequest = await strategy.buildReleasePullRequest(pathCommits, latestRelease, config.draft, this.labels);
264
+ const releasePullRequest = await strategy.buildReleasePullRequest(pathCommits, latestRelease, (_a = config.draftPullRequest) !== null && _a !== void 0 ? _a : this.draftPullRequest, this.labels);
262
265
  if (releasePullRequest) {
263
266
  if (releasePullRequest.version) {
264
267
  const versionsMap = new Map();
@@ -376,6 +379,7 @@ class Manifest {
376
379
  * @returns {CandidateRelease[]} List of release candidates
377
380
  */
378
381
  async buildReleases() {
382
+ var _a;
379
383
  logger_1.logger.info('Building releases');
380
384
  const strategiesByPath = await this.getStrategiesByPath();
381
385
  // Find merged release pull requests
@@ -411,6 +415,7 @@ class Manifest {
411
415
  releases.push({
412
416
  ...release,
413
417
  pullRequest,
418
+ draft: (_a = config.draft) !== null && _a !== void 0 ? _a : this.draft,
414
419
  });
415
420
  }
416
421
  }
@@ -458,7 +463,9 @@ class Manifest {
458
463
  return githubReleases;
459
464
  }
460
465
  async createRelease(release) {
461
- const githubRelease = await this.github.createRelease(release);
466
+ const githubRelease = await this.github.createRelease(release, {
467
+ draft: release.draft,
468
+ });
462
469
  // comment on pull request
463
470
  const comment = `:robot: Release is at ${githubRelease.url} :sunflower:`;
464
471
  await this.github.commentOnIssue(comment, release.pullRequest.number);
@@ -493,7 +500,6 @@ class Manifest {
493
500
  logger_1.logger.warn(`Multiple paths for ${component}: ${this._pathsByComponent[component]}, ${path}`);
494
501
  }
495
502
  this._pathsByComponent[component] = path;
496
- logger_1.logger.info(this._pathsByComponent);
497
503
  }
498
504
  }
499
505
  return this._pathsByComponent;
@@ -517,6 +523,7 @@ function extractReleaserConfig(config) {
517
523
  releaseAs: config['release-as'],
518
524
  skipGithubRelease: config['skip-github-release'],
519
525
  draft: config.draft,
526
+ draftPullRequest: config['draft-pull-request'],
520
527
  component: config['component'],
521
528
  packageName: config['package-name'],
522
529
  versionFile: config['version-file'],
@@ -26,7 +26,7 @@ class MajorVersionUpdate {
26
26
  exports.MajorVersionUpdate = MajorVersionUpdate;
27
27
  class MinorVersionUpdate {
28
28
  constructor() {
29
- this.name = 'major';
29
+ this.name = 'minor';
30
30
  }
31
31
  bump(version) {
32
32
  return new version_1.Version(version.major, version.minor + 1, 0, version.preRelease, version.build);
@@ -35,7 +35,7 @@ class MinorVersionUpdate {
35
35
  exports.MinorVersionUpdate = MinorVersionUpdate;
36
36
  class PatchVersionUpdate {
37
37
  constructor() {
38
- this.name = 'major';
38
+ this.name = 'patch';
39
39
  }
40
40
  bump(version) {
41
41
  return new version_1.Version(version.major, version.minor, version.patch + 1, version.preRelease, version.build);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.0.0-candidate.0",
3
+ "version": "13.0.0-candidate.1",
4
4
  "description": "generate release PRs based on the conventionalcommits.org spec",
5
5
  "main": "./build/src/index.js",
6
6
  "bin": "./build/src/bin/release-please.js",