diff --git a/src/strategies/php-yoshi.ts b/src/strategies/php-yoshi.ts index 8e19374fb..9567db77c 100644 --- a/src/strategies/php-yoshi.ts +++ b/src/strategies/php-yoshi.ts @@ -16,7 +16,6 @@ import {BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions} from './base'; import {Update} from '../update'; import {Changelog} from '../updaters/changelog'; import {RootComposerUpdatePackages} from '../updaters/php/root-composer-update-packages'; -import {PHPManifest} from '../updaters/php/php-manifest'; import {PHPClientVersion} from '../updaters/php/php-client-version'; import {VersionsMap, Version} from '../version'; import {Commit, parseConventionalCommits} from '../commit'; @@ -242,8 +241,7 @@ export class PHPYoshi extends BaseStrategy { }), }); - // update the aggregate package information in the root - // composer.json and manifest.json. + // update the aggregate package information in the root composer.json updates.push({ path: this.addPath('composer.json'), createIfMissing: false, @@ -253,33 +251,6 @@ export class PHPYoshi extends BaseStrategy { }), }); - updates.push({ - path: this.addPath('docs/manifest.json'), - createIfMissing: false, - updater: new PHPManifest({ - version, - versionsMap, - }), - }); - - updates.push({ - path: this.addPath('src/Version.php'), - createIfMissing: false, - updater: new PHPClientVersion({ - version, - versionsMap, - }), - }); - - updates.push({ - path: this.addPath('src/ServiceBuilder.php'), - createIfMissing: false, - updater: new PHPClientVersion({ - version, - versionsMap, - }), - }); - return updates; } } diff --git a/src/updaters/php/php-manifest.ts b/src/updaters/php/php-manifest.ts deleted file mode 100644 index 737087c48..000000000 --- a/src/updaters/php/php-manifest.ts +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2019 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. - -import {logger as defaultLogger, Logger} from '../../util/logger'; -import {jsonStringify} from '../../util/json-stringify'; -import {DefaultUpdater} from '../default'; - -interface ManifestModule { - name: string; - versions: string[]; -} - -/** - * Updates a manifest.json file. - * @see https://github.com/googleapis/google-cloud-php/blob/master/docs/manifest.json - */ -export class PHPManifest extends DefaultUpdater { - /** - * Given initial file contents, return updated contents. - * @param {string} content The initial content - * @returns {string} The updated content - */ - updateContent(content: string, logger: Logger = defaultLogger): string { - if (!this.versionsMap || this.versionsMap.size === 0) { - logger.info('no updates necessary'); - return content; - } - const parsed = JSON.parse(content); - parsed.modules.forEach((module: ManifestModule) => { - if (!this.versionsMap) return; - for (const [key, version] of this.versionsMap) { - if (module.name === key) { - logger.info(`adding ${key}@${version} to manifest`); - module.versions.unshift(`v${version}`); - } - } - - // the mono-repo's own API version should be added to the - // google/cloud key: - if (module.name === 'google/cloud') { - module.versions.unshift(`v${this.version}`); - } - }); - - return jsonStringify(parsed, content); - } -} diff --git a/test/strategies/php-yoshi.ts b/test/strategies/php-yoshi.ts index 58a5ff500..47f972658 100644 --- a/test/strategies/php-yoshi.ts +++ b/test/strategies/php-yoshi.ts @@ -23,7 +23,6 @@ import {TagName} from '../../src/util/tag-name'; import {Version} from '../../src/version'; import {Changelog} from '../../src/updaters/changelog'; import {RootComposerUpdatePackages} from '../../src/updaters/php/root-composer-update-packages'; -import {PHPManifest} from '../../src/updaters/php/php-manifest'; import {PHPClientVersion} from '../../src/updaters/php/php-client-version'; import {DefaultUpdater} from '../../src/updaters/default'; import snapshot = require('snap-shot-it'); @@ -152,9 +151,6 @@ describe('PHPYoshi', () => { const updates = release!.updates; assertHasUpdate(updates, 'CHANGELOG.md', Changelog); assertHasUpdate(updates, 'composer.json', RootComposerUpdatePackages); - assertHasUpdate(updates, 'docs/manifest.json', PHPManifest); - assertHasUpdate(updates, 'src/Version.php', PHPClientVersion); - assertHasUpdate(updates, 'src/ServiceBuilder.php', PHPClientVersion); }); it('finds touched components', async () => { const strategy = new PHPYoshi({ diff --git a/test/updaters/fixtures/php/manifest.json b/test/updaters/fixtures/php/manifest.json deleted file mode 100644 index 9524b7f98..000000000 --- a/test/updaters/fixtures/php/manifest.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "lang": "php", - "friendlyLang": "PHP", - "libraryTitle": "Google Cloud Client Library", - "moduleName": "google-cloud-php", - "markdown": "php", - "defaultModule": "google-cloud", - "modules": [ - { - "id": "google-cloud", - "name": "google/cloud", - "defaultService": "servicebuilder", - "versions": [ - "v0.7.1", - "v0.7.0", - "v0.6.0", - "v0.5.1", - "v0.5.0", - "v0.4.1", - "v0.4.0", - "v0.3.0", - "master" - ] - }, - { - "id": "access-context-manager", - "name": "google/access-context-manager", - "defaultService": "accesscontextmanager/readme", - "versions": [ - "v0.1.1", - "v0.1.0", - "master" - ] - }, - { - "id": "analytics-admin", - "name": "google/analytics-admin", - "defaultService": "analyticsadmin/readme", - "versions": [ - "v0.4.1", - "v0.4.0", - "v0.3.0", - "v0.2.0", - "v0.1.0", - "master" - ] - } - ], - "content": "json", - "home": "home.html", - "package": { - "title": "Packagist", - "href": "https://packagist.org/packages/google/cloud" - } -} \ No newline at end of file diff --git a/test/updaters/php-manifest.ts b/test/updaters/php-manifest.ts deleted file mode 100644 index f66e9ffb5..000000000 --- a/test/updaters/php-manifest.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2021 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. - -import {readFileSync} from 'fs'; -import {resolve} from 'path'; -import * as snapshot from 'snap-shot-it'; -import {describe, it} from 'mocha'; -import {PHPManifest} from '../../src/updaters/php/php-manifest'; -import {Version} from '../../src/version'; - -const fixturesPath = './test/updaters/fixtures/php'; - -describe('PHPManifest', () => { - describe('updateContent', () => { - it('update version in docs manifest', async () => { - const versions = new Map(); - versions.set('google/access-context-manager', Version.parse('0.2.0')); - const oldContent = readFileSync( - resolve(fixturesPath, './manifest.json'), - 'utf8' - ).replace(/\r\n/g, '\n'); - const composer = new PHPManifest({ - version: Version.parse('0.8.0'), - versionsMap: versions, - }); - const newContent = composer.updateContent(oldContent); - snapshot(newContent); - }); - }); -});