release-please 15.3.1 → 15.5.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,21 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ## [15.5.0](https://github.com/googleapis/release-please/compare/v15.4.0...v15.5.0) (2023-01-27)
8
+
9
+
10
+ ### Features
11
+
12
+ * Add generic TOML updater ([#1833](https://github.com/googleapis/release-please/issues/1833)) ([2768a4c](https://github.com/googleapis/release-please/commit/2768a4cfe131ac8493447a8c7512c623c200df34))
13
+ * Add toml generic updater option to extra-files schema ([#1835](https://github.com/googleapis/release-please/issues/1835)) ([9240f71](https://github.com/googleapis/release-please/commit/9240f71c21f077b240d2ce186456fb23b50dfd89))
14
+
15
+ ## [15.4.0](https://github.com/googleapis/release-please/compare/v15.3.1...v15.4.0) (2023-01-26)
16
+
17
+
18
+ ### Features
19
+
20
+ * **changelog.json:** Include referenced issues/prs ([#1830](https://github.com/googleapis/release-please/issues/1830)) ([bacbbb5](https://github.com/googleapis/release-please/commit/bacbbb52ad802d42af1ffb40e8c616cc6c6601a6))
21
+
7
22
  ## [15.3.1](https://github.com/googleapis/release-please/compare/v15.3.0...v15.3.1) (2023-01-26)
8
23
 
9
24
 
@@ -30,7 +30,13 @@ type ExtraPomFile = {
30
30
  path: string;
31
31
  glob?: boolean;
32
32
  };
33
- export type ExtraFile = string | ExtraJsonFile | ExtraYamlFile | ExtraXmlFile | ExtraPomFile;
33
+ type ExtraTomlFile = {
34
+ type: 'toml';
35
+ path: string;
36
+ jsonpath: string;
37
+ glob?: boolean;
38
+ };
39
+ export type ExtraFile = string | ExtraJsonFile | ExtraYamlFile | ExtraXmlFile | ExtraPomFile | ExtraTomlFile;
34
40
  /**
35
41
  * These are configurations provided to each strategy per-path.
36
42
  */
@@ -29,6 +29,7 @@ const generic_json_1 = require("../updaters/generic-json");
29
29
  const generic_xml_1 = require("../updaters/generic-xml");
30
30
  const pom_xml_1 = require("../updaters/java/pom-xml");
31
31
  const generic_yaml_1 = require("../updaters/generic-yaml");
32
+ const generic_toml_1 = require("../updaters/generic-toml");
32
33
  const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md';
33
34
  /**
34
35
  * A strategy is responsible for determining which files are
@@ -222,6 +223,13 @@ class BaseStrategy {
222
223
  updater: new generic_yaml_1.GenericYaml(extraFile.jsonpath, version),
223
224
  });
224
225
  break;
226
+ case 'toml':
227
+ extraFileUpdates.push({
228
+ path: this.addPath(path),
229
+ createIfMissing: false,
230
+ updater: new generic_toml_1.GenericToml(extraFile.jsonpath, version),
231
+ });
232
+ break;
225
233
  case 'xml':
226
234
  extraFileUpdates.push({
227
235
  path: this.addPath(path),
@@ -50,6 +50,7 @@ class ChangelogJson extends default_1.DefaultUpdater {
50
50
  type: commit.type,
51
51
  sha: commit.sha,
52
52
  message: message,
53
+ issues: commit.references.map(ref => ref.issue),
53
54
  };
54
55
  if (commit.scope)
55
56
  change.scope = commit.scope;
@@ -0,0 +1,21 @@
1
+ import { Updater } from '../update';
2
+ import { Version } from '../version';
3
+ import { Logger } from '../util/logger';
4
+ /**
5
+ * Updates TOML document according to given JSONPath.
6
+ *
7
+ * Note that used parser does reformat the document and removes all comments,
8
+ * and converts everything to pure TOML.
9
+ * If you want to retain formatting, use generic updater with comment hints.
10
+ */
11
+ export declare class GenericToml implements Updater {
12
+ readonly jsonpath: string;
13
+ readonly version: Version;
14
+ constructor(jsonpath: string, version: Version);
15
+ /**
16
+ * Given initial file contents, return updated contents.
17
+ * @param {string} content The initial content
18
+ * @returns {string} The updated content
19
+ */
20
+ updateContent(content: string, logger?: Logger): string;
21
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ // Copyright 2023 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.GenericToml = void 0;
17
+ const jp = require("jsonpath");
18
+ const toml_edit_1 = require("../util/toml-edit");
19
+ const logger_1 = require("../util/logger");
20
+ /**
21
+ * Updates TOML document according to given JSONPath.
22
+ *
23
+ * Note that used parser does reformat the document and removes all comments,
24
+ * and converts everything to pure TOML.
25
+ * If you want to retain formatting, use generic updater with comment hints.
26
+ */
27
+ class GenericToml {
28
+ constructor(jsonpath, version) {
29
+ this.jsonpath = jsonpath;
30
+ this.version = version;
31
+ }
32
+ /**
33
+ * Given initial file contents, return updated contents.
34
+ * @param {string} content The initial content
35
+ * @returns {string} The updated content
36
+ */
37
+ updateContent(content, logger = logger_1.logger) {
38
+ let data;
39
+ try {
40
+ data = (0, toml_edit_1.parseWith)(content);
41
+ }
42
+ catch (e) {
43
+ logger.warn('Invalid toml, cannot be parsed', e);
44
+ return content;
45
+ }
46
+ const paths = jp.paths(data, this.jsonpath);
47
+ if (!paths || paths.length === 0) {
48
+ logger.warn(`No entries modified in ${this.jsonpath}`);
49
+ return content;
50
+ }
51
+ let processed = content;
52
+ paths.forEach(path => {
53
+ if (path[0] === '$')
54
+ path = path.slice(1);
55
+ processed = (0, toml_edit_1.replaceTomlValue)(processed, path, this.version.toString());
56
+ });
57
+ return processed;
58
+ }
59
+ }
60
+ exports.GenericToml = GenericToml;
61
+ //# sourceMappingURL=generic-toml.js.map
@@ -1,3 +1,11 @@
1
+ import { JsonMap } from '@iarna/toml';
2
+ import * as TOMLParser from '@iarna/toml/lib/toml-parser';
3
+ /**
4
+ * Parses input as TOML with the given parser
5
+ * @param input A string
6
+ * @param parserType The TOML parser to use (might be custom)
7
+ */
8
+ export declare function parseWith(input: string, parserType?: typeof TOMLParser): JsonMap;
1
9
  /**
2
10
  * Given TOML input and a path to a value, attempt to replace
3
11
  * that value without modifying the formatting.
@@ -5,4 +13,4 @@
5
13
  * @param path Path to a value to replace. When replacing 'deps.tokio.version', pass ['deps', 'tokio', 'version']. The value must already exist.
6
14
  * @param newValue The value to replace the value at `path` with. Is passed through `JSON.stringify()` when replacing: strings will end up being double-quoted strings, properly escaped. Numbers will be numbers.
7
15
  */
8
- export declare function replaceTomlValue(input: string, path: string[], newValue: string): string;
16
+ export declare function replaceTomlValue(input: string, path: (string | number)[], newValue: string): string;
@@ -13,7 +13,7 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.replaceTomlValue = void 0;
16
+ exports.replaceTomlValue = exports.parseWith = void 0;
17
17
  const TOMLParser = require("@iarna/toml/lib/toml-parser");
18
18
  const taggedValueMarker = Symbol('__TAGGED_VALUE');
19
19
  /**
@@ -60,11 +60,12 @@ class TaggedTOMLParser extends TOMLParser {
60
60
  * @param input A string
61
61
  * @param parserType The TOML parser to use (might be custom)
62
62
  */
63
- function parseWith(input, parserType) {
63
+ function parseWith(input, parserType = TaggedTOMLParser) {
64
64
  const parser = new parserType();
65
65
  parser.parse(input);
66
66
  return parser.finish();
67
67
  }
68
+ exports.parseWith = parseWith;
68
69
  function isTaggedValue(x) {
69
70
  if (!x) {
70
71
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "15.3.1",
3
+ "version": "15.5.0",
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",
@@ -117,12 +117,12 @@
117
117
  "type": "string"
118
118
  },
119
119
  {
120
- "description": "An extra JSON on YAML file with a targeted update via jsonpath.",
120
+ "description": "An extra JSON, YAML, or TOML file with a targeted update via jsonpath.",
121
121
  "type": "object",
122
122
  "properties": {
123
123
  "type": {
124
124
  "description": "The file format type.",
125
- "enum": ["json", "yaml"]
125
+ "enum": ["json", "toml", "yaml"]
126
126
  },
127
127
  "path": {
128
128
  "description": "The path to the file.",