-
Notifications
You must be signed in to change notification settings - Fork 694
fix(generator): support explicit directory option and use in packagejson/README templates #8897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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) }}", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| "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) }}", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Suggested change
|
||||||
| "author": "Google LLC", | ||||||
| "main": "build/src/index.js", | ||||||
| "files": [ | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) }} | ||
|
Comment on lines
+110
to
+112
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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) }}", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| "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) }}", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Suggested change
|
||||||
| "author": "Google LLC", | ||||||
| "main": "./build/cjs/src/index.cjs", | ||||||
| "types": "./build/cjs/src/index.d.ts", | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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)') | ||||||||||
|
Comment on lines
+83
to
+84
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
|
||||||||||
| .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; | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||
| 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}"`); | ||||||||||
| } | ||||||||||
|
Comment on lines
+221
to
+223
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||
| if (mainServiceName) { | ||||||||||
| protocCommand.push( | ||||||||||
| `--typescript_gapic_opt="main-service=${mainServiceName}"`, | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| // 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']; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| private readMainServiceName() { | ||
|
|
@@ -326,6 +328,7 @@ export class Generator { | |
| grpcServiceConfig: this.grpcServiceConfig, | ||
| bundleConfigs: this.bundleConfigs, | ||
| publishName: this.publishName, | ||
| directory: this.directory, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| mainServiceName: this.mainServiceName, | ||
| serviceYaml: this.serviceYaml, | ||
| rest: this.rest, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| // 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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| this.loggingName = | ||
| this.publishName.match(/[^/]+\/(.*)/)?.[1] ?? this.publishName; | ||
| this.handwrittenLayer = options.handwrittenLayer ?? false; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ export interface Options { | |
| grpcServiceConfig: protos.grpc.service_config.ServiceConfig; | ||
| bundleConfigs?: BundleConfig[]; | ||
| publishName?: string; | ||
| directory?: string; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| mainServiceName?: string; | ||
| serviceYaml?: ServiceYaml; | ||
| rest?: boolean; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
api.packageDirinstead ofapi.directoryto match the renamed property.