release-please 17.6.1 → 17.8.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.
@@ -38,6 +38,7 @@ const elixir_1 = require("./strategies/elixir");
38
38
  const expo_1 = require("./strategies/expo");
39
39
  const go_1 = require("./strategies/go");
40
40
  const go_yoshi_1 = require("./strategies/go-yoshi");
41
+ const go_librarian_1 = require("./strategies/go-librarian");
41
42
  const helm_1 = require("./strategies/helm");
42
43
  const java_1 = require("./strategies/java");
43
44
  const java_yoshi_1 = require("./strategies/java-yoshi");
@@ -45,10 +46,12 @@ const java_yoshi_mono_repo_1 = require("./strategies/java-yoshi-mono-repo");
45
46
  const krm_blueprint_1 = require("./strategies/krm-blueprint");
46
47
  const maven_1 = require("./strategies/maven");
47
48
  const node_1 = require("./strategies/node");
49
+ const node_librarian_1 = require("./strategies/node-librarian");
48
50
  const ocaml_1 = require("./strategies/ocaml");
49
51
  const php_1 = require("./strategies/php");
50
52
  const php_yoshi_1 = require("./strategies/php-yoshi");
51
53
  const python_1 = require("./strategies/python");
54
+ const python_librarian_1 = require("./strategies/python-librarian");
52
55
  const r_1 = require("./strategies/r");
53
56
  const ruby_1 = require("./strategies/ruby");
54
57
  const ruby_yoshi_1 = require("./strategies/ruby-yoshi");
@@ -66,6 +69,7 @@ const releasers = {
66
69
  'dotnet-yoshi': options => new dotnet_yoshi_1.DotnetYoshi(options),
67
70
  go: options => new go_1.Go(options),
68
71
  'go-yoshi': options => new go_yoshi_1.GoYoshi(options),
72
+ 'go-librarian': options => new go_librarian_1.GoLibrarian(options),
69
73
  java: options => new java_1.Java(options),
70
74
  maven: options => new maven_1.Maven(options),
71
75
  'java-yoshi': options => new java_yoshi_1.JavaYoshi(options),
@@ -87,11 +91,13 @@ const releasers = {
87
91
  }),
88
92
  'krm-blueprint': options => new krm_blueprint_1.KRMBlueprint(options),
89
93
  node: options => new node_1.Node(options),
94
+ 'node-librarian': options => new node_librarian_1.NodeLibrarian(options),
90
95
  expo: options => new expo_1.Expo(options),
91
96
  ocaml: options => new ocaml_1.OCaml(options),
92
97
  php: options => new php_1.PHP(options),
93
98
  'php-yoshi': options => new php_yoshi_1.PHPYoshi(options),
94
99
  python: options => new python_1.Python(options),
100
+ 'python-librarian': options => new python_librarian_1.PythonLibrarian(options),
95
101
  r: options => new r_1.R(options),
96
102
  ruby: options => new ruby_1.Ruby(options),
97
103
  'ruby-yoshi': options => new ruby_yoshi_1.RubyYoshi(options),
@@ -14,4 +14,4 @@ export { Logger, setLogger } from './util/logger';
14
14
  export { GitHub } from './github';
15
15
  export declare const configSchema: any;
16
16
  export declare const manifestSchema: any;
17
- export declare const VERSION = "17.6.1";
17
+ export declare const VERSION = "17.8.0";
@@ -36,6 +36,6 @@ Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () {
36
36
  exports.configSchema = require('../../schemas/config.json');
37
37
  exports.manifestSchema = require('../../schemas/manifest.json');
38
38
  // x-release-please-start-version
39
- exports.VERSION = '17.6.1';
39
+ exports.VERSION = '17.8.0';
40
40
  // x-release-please-end
41
41
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
2
+ import { Update } from '../update';
3
+ import { Version } from '../version';
4
+ export declare class GoLibrarian extends BaseStrategy {
5
+ readonly versionFile: string;
6
+ constructor(options: BaseStrategyOptions);
7
+ protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
8
+ protected initialReleaseVersion(): Version;
9
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ // Copyright 2026 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.GoLibrarian = void 0;
17
+ const base_1 = require("./base");
18
+ const changelog_1 = require("../updaters/changelog");
19
+ const librarian_yaml_1 = require("../updaters/librarian-yaml");
20
+ const version_1 = require("../version");
21
+ const version_go_1 = require("../updaters/go/version-go");
22
+ class GoLibrarian extends base_1.BaseStrategy {
23
+ constructor(options) {
24
+ var _a, _b;
25
+ options.changelogPath = (_a = options.changelogPath) !== null && _a !== void 0 ? _a : 'CHANGES.md';
26
+ super(options);
27
+ this.versionFile = (_b = options.versionFile) !== null && _b !== void 0 ? _b : 'internal/version.go';
28
+ }
29
+ async buildUpdates(options) {
30
+ const updates = [];
31
+ const version = options.newVersion;
32
+ if (!this.skipChangelog) {
33
+ updates.push({
34
+ path: this.addPath(this.changelogPath),
35
+ createIfMissing: true,
36
+ updater: new changelog_1.Changelog({
37
+ version,
38
+ changelogEntry: options.changelogEntry,
39
+ }),
40
+ });
41
+ }
42
+ if (this.versionFile) {
43
+ updates.push({
44
+ path: this.addPath(this.versionFile),
45
+ createIfMissing: false,
46
+ updater: new version_go_1.VersionGo({
47
+ version,
48
+ }),
49
+ });
50
+ }
51
+ updates.push({
52
+ path: 'librarian.yaml',
53
+ createIfMissing: false,
54
+ updater: new librarian_yaml_1.LibrarianYamlUpdater({
55
+ version,
56
+ packagePath: this.path,
57
+ component: this.component,
58
+ }),
59
+ });
60
+ return updates;
61
+ }
62
+ initialReleaseVersion() {
63
+ if (this.initialVersion) {
64
+ return version_1.Version.parse(this.initialVersion);
65
+ }
66
+ return version_1.Version.parse('1.0.0');
67
+ }
68
+ }
69
+ exports.GoLibrarian = GoLibrarian;
70
+ //# sourceMappingURL=go-librarian.js.map
@@ -23,7 +23,7 @@ const composite_1 = require("../updaters/composite");
23
23
  const errors_1 = require("../errors");
24
24
  const java_1 = require("./java");
25
25
  const java_update_1 = require("../updaters/java/java-update");
26
- const librarian_yaml_1 = require("../updaters/java/librarian-yaml");
26
+ const librarian_yaml_1 = require("../updaters/librarian-yaml");
27
27
  const filter_commits_1 = require("../util/filter-commits");
28
28
  class JavaYoshiMonoRepo extends java_1.Java {
29
29
  /**
@@ -0,0 +1,10 @@
1
+ import { BaseStrategy, BuildUpdatesOptions } from './base';
2
+ import { Update } from '../update';
3
+ import { GitHubFileContents } from '@google-automations/git-file-utils';
4
+ export declare class NodeLibrarian extends BaseStrategy {
5
+ private pkgJsonContents?;
6
+ protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
7
+ getDefaultPackageName(): Promise<string | undefined>;
8
+ protected normalizeComponent(component: string | undefined): string;
9
+ protected getPkgJsonContents(): Promise<GitHubFileContents>;
10
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ // Copyright 2026 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.NodeLibrarian = void 0;
17
+ const base_1 = require("./base");
18
+ const changelog_json_1 = require("../updaters/changelog-json");
19
+ const package_lock_json_1 = require("../updaters/node/package-lock-json");
20
+ const samples_package_json_1 = require("../updaters/node/samples-package-json");
21
+ const changelog_1 = require("../updaters/changelog");
22
+ const package_json_1 = require("../updaters/node/package-json");
23
+ const librarian_yaml_1 = require("../updaters/librarian-yaml");
24
+ const errors_1 = require("../errors");
25
+ const filter_commits_1 = require("../util/filter-commits");
26
+ class NodeLibrarian extends base_1.BaseStrategy {
27
+ async buildUpdates(options) {
28
+ var _a;
29
+ const updates = [];
30
+ const version = options.newVersion;
31
+ const versionsMap = options.versionsMap;
32
+ const packageName = (_a = (await this.getPackageName())) !== null && _a !== void 0 ? _a : '';
33
+ const lockFiles = ['package-lock.json', 'npm-shrinkwrap.json'];
34
+ lockFiles.forEach(lockFile => {
35
+ updates.push({
36
+ path: this.addPath(lockFile),
37
+ createIfMissing: false,
38
+ updater: new package_lock_json_1.PackageLockJson({
39
+ version,
40
+ versionsMap,
41
+ }),
42
+ });
43
+ });
44
+ updates.push({
45
+ path: this.addPath('samples/package.json'),
46
+ createIfMissing: false,
47
+ updater: new samples_package_json_1.SamplesPackageJson({
48
+ version,
49
+ packageName,
50
+ }),
51
+ });
52
+ !this.skipChangelog &&
53
+ updates.push({
54
+ path: this.addPath(this.changelogPath),
55
+ createIfMissing: true,
56
+ updater: new changelog_1.Changelog({
57
+ version,
58
+ changelogEntry: options.changelogEntry,
59
+ }),
60
+ });
61
+ updates.push({
62
+ path: this.addPath('package.json'),
63
+ createIfMissing: false,
64
+ cachedFileContents: this.pkgJsonContents,
65
+ updater: new package_json_1.PackageJson({
66
+ version,
67
+ }),
68
+ });
69
+ // If a machine readable changelog.json exists update it:
70
+ if (options.commits && packageName && !this.skipChangelog) {
71
+ const commits = (0, filter_commits_1.filterCommits)(options.commits, this.changelogSections);
72
+ updates.push({
73
+ path: 'changelog.json',
74
+ createIfMissing: false,
75
+ updater: new changelog_json_1.ChangelogJson({
76
+ artifactName: packageName,
77
+ version,
78
+ commits,
79
+ language: 'JAVASCRIPT',
80
+ }),
81
+ });
82
+ }
83
+ // Update librarian.yaml if this package exists within it.
84
+ updates.push({
85
+ path: 'librarian.yaml',
86
+ createIfMissing: false,
87
+ updater: new librarian_yaml_1.LibrarianYamlUpdater({
88
+ version,
89
+ packagePath: this.path,
90
+ }),
91
+ });
92
+ return updates;
93
+ }
94
+ async getDefaultPackageName() {
95
+ const pkgJsonContents = await this.getPkgJsonContents();
96
+ const pkg = JSON.parse(pkgJsonContents.parsedContent);
97
+ return pkg.name;
98
+ }
99
+ normalizeComponent(component) {
100
+ if (!component) {
101
+ return '';
102
+ }
103
+ return component.match(/^@[\w-]+\//) ? component.split('/')[1] : component;
104
+ }
105
+ async getPkgJsonContents() {
106
+ if (!this.pkgJsonContents) {
107
+ try {
108
+ this.pkgJsonContents = await this.github.getFileContentsOnBranch(this.addPath('package.json'), this.targetBranch);
109
+ }
110
+ catch (e) {
111
+ if (e instanceof errors_1.FileNotFoundError) {
112
+ throw new errors_1.MissingRequiredFileError(this.addPath('package.json'), 'node', `${this.repository.owner}/${this.repository.repo}`);
113
+ }
114
+ throw e;
115
+ }
116
+ }
117
+ return this.pkgJsonContents;
118
+ }
119
+ }
120
+ exports.NodeLibrarian = NodeLibrarian;
121
+ //# sourceMappingURL=node-librarian.js.map
@@ -0,0 +1,6 @@
1
+ import { Python } from './python';
2
+ import { BuildUpdatesOptions } from './base';
3
+ import { Update } from '../update';
4
+ export declare class PythonLibrarian extends Python {
5
+ protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
6
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ // Copyright 2026 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.PythonLibrarian = void 0;
17
+ const python_1 = require("./python");
18
+ const librarian_yaml_1 = require("../updaters/librarian-yaml");
19
+ class PythonLibrarian extends python_1.Python {
20
+ async buildUpdates(options) {
21
+ const updates = await super.buildUpdates(options);
22
+ // Update librarian.yaml if this package exists within it.
23
+ updates.push({
24
+ path: 'librarian.yaml',
25
+ createIfMissing: false,
26
+ updater: new librarian_yaml_1.LibrarianYamlUpdater({
27
+ version: options.newVersion,
28
+ packagePath: this.path,
29
+ }),
30
+ });
31
+ return updates;
32
+ }
33
+ }
34
+ exports.PythonLibrarian = PythonLibrarian;
35
+ //# sourceMappingURL=python-librarian.js.map
@@ -17,7 +17,7 @@ exports.VersionGo = void 0;
17
17
  const default_1 = require("../default");
18
18
  class VersionGo extends default_1.DefaultUpdater {
19
19
  updateContent(content) {
20
- return content.replace(/const Version = "[0-9]+\.[0-9]+\.[0-9](-\w+)?"/, `const Version = "${this.version.toString()}"`);
20
+ return content.replace(/const Version = "[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?"/, `const Version = "${this.version.toString()}"`);
21
21
  }
22
22
  }
23
23
  exports.VersionGo = VersionGo;
@@ -0,0 +1,38 @@
1
+ import { DefaultUpdater, UpdateOptions } from './default';
2
+ import { Logger } from '../util/logger';
3
+ export interface JavaModule {
4
+ artifact_id: string;
5
+ [key: string]: any;
6
+ }
7
+ export interface LibrarianLibrary {
8
+ name: string;
9
+ version: string;
10
+ output?: string;
11
+ java?: JavaModule;
12
+ [key: string]: any;
13
+ }
14
+ export interface LibrarianYamlSchema {
15
+ libraries: LibrarianLibrary[];
16
+ [key: string]: any;
17
+ }
18
+ export interface LibrarianUpdateOptions extends UpdateOptions {
19
+ packagePath?: string;
20
+ component?: string;
21
+ }
22
+ /**
23
+ * Updates a librarian.yaml file.
24
+ */
25
+ export declare class LibrarianYamlUpdater extends DefaultUpdater {
26
+ private readonly packagePath?;
27
+ private readonly component?;
28
+ private readonly specialArtifacts;
29
+ constructor(options: LibrarianUpdateOptions);
30
+ /**
31
+ * Given initial file contents, return updated contents.
32
+ * @param {string} content The initial content
33
+ * @returns {string} The updated content
34
+ */
35
+ updateContent(content: string, _logger?: Logger): string;
36
+ private deriveOutputDirectory;
37
+ private findArtifactID;
38
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ // Copyright 2026 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.LibrarianYamlUpdater = void 0;
17
+ const default_1 = require("./default");
18
+ const yaml = require("yaml");
19
+ const logger_1 = require("../util/logger");
20
+ /**
21
+ * Updates a librarian.yaml file.
22
+ */
23
+ class LibrarianYamlUpdater extends default_1.DefaultUpdater {
24
+ constructor(options) {
25
+ super(options);
26
+ this.specialArtifacts = new Map([
27
+ ['google-cloud-java', 'google-cloud-java'],
28
+ ]);
29
+ this.packagePath = options.packagePath;
30
+ this.component = options.component;
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
+ const doc = yaml.parseDocument(content);
39
+ if (!doc || doc.errors.length > 0) {
40
+ throw new Error(`Invalid yaml, cannot be parsed: ${doc.errors
41
+ .map(e => e.message)
42
+ .join(', ')}`);
43
+ }
44
+ const libraries = doc.get('libraries');
45
+ if (!libraries || !yaml.isSeq(libraries)) {
46
+ return content;
47
+ }
48
+ let modified = false;
49
+ for (const library of libraries.items) {
50
+ if (!yaml.isMap(library))
51
+ continue;
52
+ const libraryJSON = library.toJSON();
53
+ let newVersion = undefined;
54
+ if (this.versionsMap) {
55
+ // Multi-version (Java style)
56
+ const artifactID = this.findArtifactID(libraryJSON);
57
+ if (this.versionsMap.has(artifactID)) {
58
+ newVersion = this.versionsMap.get(artifactID);
59
+ }
60
+ }
61
+ else {
62
+ // Single version (Go, Python, Node style)
63
+ const isGoMatch = (this.packagePath && libraryJSON.name === this.packagePath) ||
64
+ (this.component && libraryJSON.name === this.component);
65
+ const isPythonNodeMatch = this.packagePath &&
66
+ this.deriveOutputDirectory(libraryJSON) === this.packagePath;
67
+ if (isGoMatch || isPythonNodeMatch) {
68
+ newVersion = this.version;
69
+ }
70
+ }
71
+ if (newVersion) {
72
+ const newVersionStr = newVersion.toString();
73
+ if (library.get('version') !== newVersionStr) {
74
+ library.set('version', newVersionStr);
75
+ modified = true;
76
+ }
77
+ if (this.versionsMap) {
78
+ const isSnapshot = newVersion.preRelease === 'SNAPSHOT';
79
+ if (!isSnapshot) {
80
+ let java = library.get('java');
81
+ if (!yaml.isMap(java)) {
82
+ const javaNode = doc.createNode({});
83
+ library.set('java', javaNode);
84
+ java = javaNode;
85
+ modified = true;
86
+ }
87
+ if (yaml.isMap(java)) {
88
+ if (java.get('released_version') !== newVersionStr) {
89
+ java.set('released_version', newVersionStr);
90
+ modified = true;
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ if (modified) {
98
+ return doc.toString({ lineWidth: 0 });
99
+ }
100
+ return content;
101
+ }
102
+ deriveOutputDirectory(library) {
103
+ if (library.output) {
104
+ return library.output;
105
+ }
106
+ return `packages/${library.name}`;
107
+ }
108
+ findArtifactID(library) {
109
+ const artifact = this.specialArtifacts.get(library.name);
110
+ if (artifact) {
111
+ return artifact;
112
+ }
113
+ if (library.java && library.java.artifact_id) {
114
+ return library.java.artifact_id;
115
+ }
116
+ return `google-cloud-${library.name}`;
117
+ }
118
+ }
119
+ exports.LibrarianYamlUpdater = LibrarianYamlUpdater;
120
+ //# sourceMappingURL=librarian-yaml.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "17.6.1",
3
+ "version": "17.8.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",
@@ -102,7 +102,7 @@
102
102
  "node": ">=20.0.0"
103
103
  },
104
104
  "overrides": {
105
- "tmp": "0.2.5",
105
+ "tmp": "0.2.6",
106
106
  "serialize-javascript": "^7.0.5"
107
107
  }
108
108
  }
@@ -1,29 +0,0 @@
1
- import { DefaultUpdater } from '../default';
2
- import { Logger } from '../../util/logger';
3
- export interface JavaModule {
4
- distribution_name_override: string;
5
- [key: string]: any;
6
- }
7
- export interface LibrarianLibrary {
8
- name: string;
9
- version: string;
10
- java: JavaModule;
11
- [key: string]: any;
12
- }
13
- export interface LibrarianYamlSchema {
14
- libraries: LibrarianLibrary[];
15
- [key: string]: any;
16
- }
17
- /**
18
- * Updates a librarian.yaml file.
19
- */
20
- export declare class LibrarianYamlUpdater extends DefaultUpdater {
21
- specialArtifacts: ReadonlyMap<string, string>;
22
- /**
23
- * Given initial file contents, return updated contents.
24
- * @param {string} content The initial content
25
- * @returns {string} The updated content
26
- */
27
- updateContent(content: string, logger?: Logger): string;
28
- findArtifactID(library: LibrarianLibrary): string;
29
- }
@@ -1,81 +0,0 @@
1
- "use strict";
2
- // Copyright 2026 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.LibrarianYamlUpdater = void 0;
17
- const default_1 = require("../default");
18
- const yaml = require("yaml");
19
- const logger_1 = require("../../util/logger");
20
- /**
21
- * Updates a librarian.yaml file.
22
- */
23
- class LibrarianYamlUpdater extends default_1.DefaultUpdater {
24
- constructor() {
25
- super(...arguments);
26
- this.specialArtifacts = new Map([
27
- ['google-cloud-java', 'google-cloud-java'],
28
- ]);
29
- }
30
- /**
31
- * Given initial file contents, return updated contents.
32
- * @param {string} content The initial content
33
- * @returns {string} The updated content
34
- */
35
- updateContent(content, logger = logger_1.logger) {
36
- if (!this.versionsMap) {
37
- logger.warn('missing versions map');
38
- return content;
39
- }
40
- // Use yaml package to make sure librarian.yaml is not reformatted because
41
- // we use different tool to format librarian.yaml.
42
- const doc = yaml.parseDocument(content);
43
- if (!doc || doc.errors.length > 0) {
44
- logger.warn('Invalid yaml, cannot be parsed');
45
- return content;
46
- }
47
- const libraries = doc.get('libraries');
48
- if (!libraries || !yaml.isSeq(libraries)) {
49
- return content;
50
- }
51
- let modified = false;
52
- for (const library of libraries.items) {
53
- if (!yaml.isMap(library))
54
- continue;
55
- const artifactID = this.findArtifactID(library.toJSON());
56
- if (this.versionsMap.has(artifactID)) {
57
- const newVersion = this.versionsMap.get(artifactID);
58
- if (newVersion && library.get('version') !== newVersion.toString()) {
59
- library.set('version', newVersion.toString());
60
- modified = true;
61
- }
62
- }
63
- }
64
- if (modified) {
65
- return doc.toString({ lineWidth: 0 });
66
- }
67
- return content;
68
- }
69
- findArtifactID(library) {
70
- const artifact = this.specialArtifacts.get(library.name);
71
- if (artifact) {
72
- return artifact;
73
- }
74
- if (library.java && library.java.distribution_name_override) {
75
- return library.java.distribution_name_override.split(':')[1];
76
- }
77
- return `google-cloud-${library.name}`;
78
- }
79
- }
80
- exports.LibrarianYamlUpdater = LibrarianYamlUpdater;
81
- //# sourceMappingURL=librarian-yaml.js.map