From 5f9ebd28448983679a6df4fd6c8e580fb0271a77 Mon Sep 17 00:00:00 2001 From: Google GitHub Actions Bot <72759630+google-github-actions-bot@users.noreply.github.com> Date: Tue, 11 Apr 2023 11:54:29 -0400 Subject: [PATCH] chore: build dist (#758) Build dist PR --- dist/index.js | 154 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 125 insertions(+), 29 deletions(-) diff --git a/dist/index.js b/dist/index.js index d0de39b..60b4a33 100644 --- a/dist/index.js +++ b/dist/index.js @@ -69,9 +69,8 @@ async function runManifest (command) { fork } ) - // Create or update release PRs: - outputPRs(await manifest.createPullRequests()) if (command !== 'manifest-pr') { + outputReleases(await manifest.createReleases()) manifest = await Manifest.fromManifest( github, github.repository.defaultBranch, @@ -82,8 +81,9 @@ async function runManifest (command) { fork } ) - outputReleases(await manifest.createReleases()) } + // Create or update release PRs: + outputPRs(await manifest.createPullRequests()) } async function main () { @@ -85694,7 +85694,10 @@ class GitHubChangelogNotes { this.github = github; } async buildNotes(_commits, options) { - return await this.github.generateReleaseNotes(options.currentTag, options.targetBranch, options.previousTag); + const body = await this.github.generateReleaseNotes(options.currentTag, options.targetBranch, options.previousTag); + const date = new Date().toLocaleDateString('en-CA'); + const header = `## ${options.version} (${date})`; + return `${header}\n\n${body}`; } } exports.GitHubChangelogNotes = GitHubChangelogNotes; @@ -87764,6 +87767,7 @@ const release_please_manifest_1 = __nccwpck_require__(9817); const errors_1 = __nccwpck_require__(93637); const pull_request_overflow_handler_1 = __nccwpck_require__(93937); const signoff_commit_message_1 = __nccwpck_require__(2686); +const commit_exclude_1 = __nccwpck_require__(14702); exports.DEFAULT_RELEASE_PLEASE_CONFIG = 'release-please-config.json'; exports.DEFAULT_RELEASE_PLEASE_MANIFEST = '.release-please-manifest.json'; exports.ROOT_PROJECT_PATH = '.'; @@ -88036,10 +88040,12 @@ class Manifest { }); const splitCommits = cs.split(commits); // limit paths to ones since the last release - const commitsPerPath = {}; + let commitsPerPath = {}; for (const path in this.repositoryConfig) { commitsPerPath[path] = commitsAfterSha(path === exports.ROOT_PROJECT_PATH ? commits : splitCommits[path], releaseShasByPath[path]); } + const commitExclude = new commit_exclude_1.CommitExclude(this.repositoryConfig); + commitsPerPath = commitExclude.excludeCommits(commitsPerPath); // backfill latest release tags from manifest for (const path in this.repositoryConfig) { const latestRelease = releasesByPath[path]; @@ -88511,6 +88517,7 @@ function extractReleaserConfig(config) { extraLabels: (_c = config['extra-label']) === null || _c === void 0 ? void 0 : _c.split(','), skipSnapshot: config['skip-snapshot'], initialVersion: config['initial-version'], + excludePaths: config['exclude-paths'], }; } /** @@ -88719,7 +88726,7 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, config, return candidateTagVersion.sort((a, b) => b.compare(a))[0]; } function mergeReleaserConfig(defaultConfig, pathConfig) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2; return { releaseType: (_b = (_a = pathConfig.releaseType) !== null && _a !== void 0 ? _a : defaultConfig.releaseType) !== null && _b !== void 0 ? _b : 'node', bumpMinorPreMajor: (_c = pathConfig.bumpMinorPreMajor) !== null && _c !== void 0 ? _c : defaultConfig.bumpMinorPreMajor, @@ -88746,6 +88753,7 @@ function mergeReleaserConfig(defaultConfig, pathConfig) { skipSnapshot: (_z = pathConfig.skipSnapshot) !== null && _z !== void 0 ? _z : defaultConfig.skipSnapshot, initialVersion: (_0 = pathConfig.initialVersion) !== null && _0 !== void 0 ? _0 : defaultConfig.initialVersion, extraLabels: (_1 = pathConfig.extraLabels) !== null && _1 !== void 0 ? _1 : defaultConfig.extraLabels, + excludePaths: (_2 = pathConfig.excludePaths) !== null && _2 !== void 0 ? _2 : defaultConfig.excludePaths, }; } /** @@ -93779,7 +93787,11 @@ class BaseXml { const document = new dom.DOMParser().parseFromString(content); const updated = this.updateDocument(document); if (updated) { - return new dom.XMLSerializer().serializeToString(document); + const newContent = new dom.XMLSerializer().serializeToString(document); + if (content.endsWith('\n') && !newContent.endsWith('\n')) { + return `${newContent}\n`; + } + return newContent; } else { return content; @@ -95744,7 +95756,7 @@ class SetupCfg extends default_1.DefaultUpdater { * @returns {string} The updated content */ updateContent(content) { - return content.replace(/(version ?= ?)[0-9]+\.[0-9]+\.[0-9](?:-\w+)?/, `$1${this.version}`); + return content.replace(/(version ?= ?)[0-9]+\.[0-9]+\.[0-9]+(?:-\w+)?/, `$1${this.version}`); } } exports.SetupCfg = SetupCfg; @@ -96568,6 +96580,62 @@ class ComponentBranchName extends BranchName { /***/ }), +/***/ 14702: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.CommitExclude = void 0; +const manifest_1 = __nccwpck_require__(31999); +const commit_utils_1 = __nccwpck_require__(16828); +class CommitExclude { + constructor(config) { + this.excludePaths = {}; + Object.entries(config).forEach(([path, releaseConfig]) => { + if (releaseConfig.excludePaths) { + this.excludePaths[path] = (0, commit_utils_1.normalizePaths)(releaseConfig.excludePaths); + } + }); + } + excludeCommits(commitsPerPath) { + const filteredCommitsPerPath = {}; + Object.entries(commitsPerPath).forEach(([path, commits]) => { + if (this.excludePaths[path]) { + commits = commits.filter(commit => this.shouldInclude(commit, this.excludePaths[path], path)); + } + filteredCommitsPerPath[path] = commits; + }); + return filteredCommitsPerPath; + } + shouldInclude(commit, excludePaths, packagePath) { + return (!commit.files || + !commit.files + .filter(file => this.isRelevant(file, packagePath)) + .every(file => excludePaths.some(path => this.isRelevant(file, path)))); + } + isRelevant(file, path) { + return path === manifest_1.ROOT_PROJECT_PATH || file.indexOf(`${path}/`) === 0; + } +} +exports.CommitExclude = CommitExclude; +//# sourceMappingURL=commit-exclude.js.map + +/***/ }), + /***/ 6941: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -96589,6 +96657,7 @@ class ComponentBranchName extends BranchName { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.CommitSplit = void 0; const manifest_1 = __nccwpck_require__(31999); +const commit_utils_1 = __nccwpck_require__(16828); /** * Helper class for splitting commits by component path. If `packagePaths` * is configured, then only consider the provided paths. If `includeEmpty` @@ -96600,28 +96669,14 @@ class CommitSplit { opts = opts || {}; this.includeEmpty = !!opts.includeEmpty; if (opts.packagePaths) { - const paths = []; - for (let newPath of opts.packagePaths) { + const paths = (0, commit_utils_1.normalizePaths)(opts.packagePaths); + this.packagePaths = paths + .filter(path => { // The special "." path, representing the root of the module, should be // ignored by commit-split as it is assigned all commits in manifest.ts - if (newPath === manifest_1.ROOT_PROJECT_PATH) { - continue; - } - // normalize so that all paths have leading and trailing slashes for - // non-overlap validation. - // NOTE: GitHub API always returns paths using the `/` separator, - // regardless of what platform the client code is running on - newPath = newPath.replace(/\/$/, ''); - newPath = newPath.replace(/^\//, ''); - newPath = newPath.replace(/$/, '/'); - newPath = newPath.replace(/^/, '/'); - // store them with leading and trailing slashes removed. - newPath = newPath.replace(/\/$/, ''); - newPath = newPath.replace(/^\//, ''); - paths.push(newPath); - } - // sort by longest paths first - this.packagePaths = paths.sort((a, b) => b.length - a.length); + return path !== manifest_1.ROOT_PROJECT_PATH; + }) + .sort((a, b) => b.length - a.length); // sort by longest paths first } } /** @@ -96688,6 +96743,47 @@ exports.CommitSplit = CommitSplit; /***/ }), +/***/ 16828: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.normalizePaths = void 0; +const normalizePaths = (paths) => { + return paths.map(path => { + // normalize so that all paths have leading and trailing slashes for + // non-overlap validation. + // NOTE: GitHub API always returns paths using the `/` separator, + // regardless of what platform the client code is running on + let newPath = path.replace(/\/$/, ''); + newPath = newPath.replace(/^\//, ''); + newPath = newPath.replace(/$/, '/'); + newPath = newPath.replace(/^/, '/'); + // store them with leading and trailing slashes removed. + newPath = newPath.replace(/\/$/, ''); + newPath = newPath.replace(/^\//, ''); + return newPath; + }); +}; +exports.normalizePaths = normalizePaths; +//# sourceMappingURL=commit-utils.js.map + +/***/ }), + /***/ 26498: /***/ ((__unused_webpack_module, exports) => { @@ -119575,7 +119671,7 @@ module.exports = {}; /***/ ((module) => { "use strict"; -module.exports = {"i8":"15.9.2"}; +module.exports = {"i8":"15.10.2"}; /***/ }),