diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/README.md.njk b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/README.md.njk index 154e9784e453..0f343ebf7ce3 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/README.md.njk +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/README.md.njk @@ -107,6 +107,6 @@ See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [billing]: https://support.google.com/cloud/answer/6293499#enable-billing [enable_api]: https://console.cloud.google.com/flows/enableapi?apiid={{ api.hostName }} [auth]: https://cloud.google.com/docs/authentication/external/set-up-adc-local -[homepage_samples]: https://github.com/googleapis/google-cloud-node/blob/main/packages/{{ api.naming.namePath }}/samples -[homepage_changelog]: https://github.com/googleapis/google-cloud-node/blob/main/packages/{{ api.naming.namePath }}/CHANGELOG.md -[homepage]: https://github.com/googleapis/google-cloud-node/blob/main/packages/{{ api.naming.namePath }} +[homepage_samples]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.directory or ('packages/' + api.naming.namePath) }}/samples +[homepage_changelog]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.directory or ('packages/' + api.naming.namePath) }}/CHANGELOG.md +[homepage]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.directory or ('packages/' + api.naming.namePath) }} diff --git a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/package.json b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/package.json index bc786ce6f907..c7bae7af4f61 100644 --- a/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/package.json +++ b/core/generator/gapic-generator-typescript/templates/cjs/typescript_gapic/package.json @@ -4,11 +4,11 @@ "description": "{{ api.naming.productName }} client for Node.js", "repository": { "type": "git", - "directory": "packages/{{ api.naming.namePath }}", + "directory": "{{ api.directory or ('packages/' + api.naming.namePath) }}", "url": "https://github.com/googleapis/google-cloud-node.git" }, "license": "Apache-2.0", - "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/packages/{{ api.naming.namePath }}", + "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/{{ api.directory or ('packages/' + api.naming.namePath) }}", "author": "Google LLC", "main": "build/src/index.js", "files": [ diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/README.md.njk b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/README.md.njk index 154e9784e453..0f343ebf7ce3 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/README.md.njk +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/README.md.njk @@ -107,6 +107,6 @@ See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [billing]: https://support.google.com/cloud/answer/6293499#enable-billing [enable_api]: https://console.cloud.google.com/flows/enableapi?apiid={{ api.hostName }} [auth]: https://cloud.google.com/docs/authentication/external/set-up-adc-local -[homepage_samples]: https://github.com/googleapis/google-cloud-node/blob/main/packages/{{ api.naming.namePath }}/samples -[homepage_changelog]: https://github.com/googleapis/google-cloud-node/blob/main/packages/{{ api.naming.namePath }}/CHANGELOG.md -[homepage]: https://github.com/googleapis/google-cloud-node/blob/main/packages/{{ api.naming.namePath }} +[homepage_samples]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.directory or ('packages/' + api.naming.namePath) }}/samples +[homepage_changelog]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.directory or ('packages/' + api.naming.namePath) }}/CHANGELOG.md +[homepage]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.directory or ('packages/' + api.naming.namePath) }} diff --git a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/package.json b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/package.json index 4be057fd0956..51da7ad5f6d0 100644 --- a/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/package.json +++ b/core/generator/gapic-generator-typescript/templates/esm/typescript_gapic/package.json @@ -4,11 +4,11 @@ "description": "{{ api.naming.productName }} client for Node.js", "repository": { "type": "git", - "directory": "packages/{{ api.naming.namePath }}", + "directory": "{{ api.directory or ('packages/' + api.naming.namePath) }}", "url": "https://github.com/googleapis/google-cloud-node.git" }, "license": "Apache-2.0", - "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/packages/{{ api.naming.namePath }}", + "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/{{ api.directory or ('packages/' + api.naming.namePath) }}", "author": "Google LLC", "main": "./build/cjs/src/index.cjs", "types": "./build/cjs/src/index.d.ts", diff --git a/core/generator/gapic-generator-typescript/typescript/src/gapic-generator-typescript.ts b/core/generator/gapic-generator-typescript/typescript/src/gapic-generator-typescript.ts index 86f94791dc57..1bc4f816d37a 100755 --- a/core/generator/gapic-generator-typescript/typescript/src/gapic-generator-typescript.ts +++ b/core/generator/gapic-generator-typescript/typescript/src/gapic-generator-typescript.ts @@ -80,6 +80,8 @@ async function main(processArgv: string[]) { .describe('service-yaml', 'Path to service yaml') .alias('package-name', 'package_name') .describe('package-name', 'Publish package name') + .alias('directory', 'package_dir') + .describe('directory', 'Monorepo directory of the package (e.g. packages/google-cloud-workflows)') .alias('main-service', 'main_service') .describe( 'main_service', @@ -146,6 +148,7 @@ async function main(processArgv: string[]) { const bundleConfig = argv.bundleConfig as string | undefined; const serviceYaml = argv.serviceYaml as string | undefined; const packageName = argv.packageName as string | undefined; + const directory = argv.directory as string | undefined; const mainServiceName = argv.mainService as string | undefined; const template = argv.template as string | undefined; const gapicValidatorOut = argv.gapicValidatorOut as string | undefined; @@ -215,6 +218,9 @@ async function main(processArgv: string[]) { if (packageName) { protocCommand.push(`--typescript_gapic_opt="package-name=${packageName}"`); } + if (directory) { + protocCommand.push(`--typescript_gapic_opt="directory=${directory}"`); + } if (mainServiceName) { protocCommand.push( `--typescript_gapic_opt="main-service=${mainServiceName}"`, diff --git a/core/generator/gapic-generator-typescript/typescript/src/generator.ts b/core/generator/gapic-generator-typescript/typescript/src/generator.ts index 84a8e818781f..d123eae16381 100644 --- a/core/generator/gapic-generator-typescript/typescript/src/generator.ts +++ b/core/generator/gapic-generator-typescript/typescript/src/generator.ts @@ -71,6 +71,7 @@ export class Generator { paramMap: OptionsMap; // This field is for users passing proper publish package name like @google-cloud/text-to-speech. publishName?: string; + directory?: string; // For historical reasons, Webpack library name matches "the main" service of the client library. // Sometimes it's hard to figure out automatically, so making this an option. mainServiceName?: string; @@ -186,6 +187,7 @@ export class Generator { private readPublishPackageName() { this.publishName = this.paramMap['package-name']; + this.directory = this.paramMap['directory']; } private readMainServiceName() { @@ -326,6 +328,7 @@ export class Generator { grpcServiceConfig: this.grpcServiceConfig, bundleConfigs: this.bundleConfigs, publishName: this.publishName, + directory: this.directory, mainServiceName: this.mainServiceName, serviceYaml: this.serviceYaml, rest: this.rest, diff --git a/core/generator/gapic-generator-typescript/typescript/src/schema/api.ts b/core/generator/gapic-generator-typescript/typescript/src/schema/api.ts index a49572f920f2..f4301c621d12 100644 --- a/core/generator/gapic-generator-typescript/typescript/src/schema/api.ts +++ b/core/generator/gapic-generator-typescript/typescript/src/schema/api.ts @@ -31,6 +31,7 @@ export class API { port?: string; // This field is for users passing proper publish package name like @google-cloud/text-to-speech. publishName: string; + directory?: string; // The short name we'll use for the package (e.g. @google-cloud/text-to-speech -> text-to-speech) loggingName: string; // For historical reasons, Webpack library name matches "the main" service of the client library. @@ -102,6 +103,7 @@ export class API { // users specify the actual package name, if not, set it to product name. this.publishName = options.publishName || this.naming.productName.toKebabCase(); + this.directory = options.directory; this.loggingName = this.publishName.match(/[^/]+\/(.*)/)?.[1] ?? this.publishName; this.handwrittenLayer = options.handwrittenLayer ?? false; diff --git a/core/generator/gapic-generator-typescript/typescript/src/schema/naming.ts b/core/generator/gapic-generator-typescript/typescript/src/schema/naming.ts index 0d95f68a732c..5df2cb134088 100644 --- a/core/generator/gapic-generator-typescript/typescript/src/schema/naming.ts +++ b/core/generator/gapic-generator-typescript/typescript/src/schema/naming.ts @@ -22,6 +22,7 @@ export interface Options { grpcServiceConfig: protos.grpc.service_config.ServiceConfig; bundleConfigs?: BundleConfig[]; publishName?: string; + directory?: string; mainServiceName?: string; serviceYaml?: ServiceYaml; rest?: boolean;