Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use api.packageDir instead of api.directory to match the renamed property.

[homepage_samples]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.packageDir or ('packages/' + api.naming.namePath) }}/samples
[homepage_changelog]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.packageDir or ('packages/' + api.naming.namePath) }}/CHANGELOG.md
[homepage]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.packageDir or ('packages/' + api.naming.namePath) }}

Original file line number Diff line number Diff line change
Expand Up @@ -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) }}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use api.packageDir instead of api.directory to match the renamed property.

Suggested change
"directory": "{{ api.directory or ('packages/' + api.naming.namePath) }}",
"directory": "{{ api.packageDir 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) }}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use api.packageDir instead of api.directory to match the renamed property.

Suggested change
"homepage": "https://github.com/googleapis/google-cloud-node/tree/main/{{ api.directory or ('packages/' + api.naming.namePath) }}",
"homepage": "https://github.com/googleapis/google-cloud-node/tree/main/{{ api.packageDir or ('packages/' + api.naming.namePath) }}",

"author": "Google LLC",
"main": "build/src/index.js",
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use api.packageDir instead of api.directory to match the renamed property.

[homepage_samples]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.packageDir or ('packages/' + api.naming.namePath) }}/samples
[homepage_changelog]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.packageDir or ('packages/' + api.naming.namePath) }}/CHANGELOG.md
[homepage]: https://github.com/googleapis/google-cloud-node/blob/main/{{ api.packageDir or ('packages/' + api.naming.namePath) }}

Original file line number Diff line number Diff line change
Expand Up @@ -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) }}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use api.packageDir instead of api.directory to match the renamed property.

Suggested change
"directory": "{{ api.directory or ('packages/' + api.naming.namePath) }}",
"directory": "{{ api.packageDir 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) }}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use api.packageDir instead of api.directory to match the renamed property.

Suggested change
"homepage": "https://github.com/googleapis/google-cloud-node/tree/main/{{ api.directory or ('packages/' + api.naming.namePath) }}",
"homepage": "https://github.com/googleapis/google-cloud-node/tree/main/{{ api.packageDir or ('packages/' + api.naming.namePath) }}",

"author": "Google LLC",
"main": "./build/cjs/src/index.cjs",
"types": "./build/cjs/src/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using --directory as a CLI option name is highly generic and can easily be confused with the output directory where the generated code is written. To avoid confusion and maintain consistency with --package-name, it is recommended to name this option --package-dir.

Suggested change
.alias('directory', 'package_dir')
.describe('directory', 'Monorepo directory of the package (e.g. packages/google-cloud-workflows)')
.alias('package-dir', 'package_dir')
.describe('package-dir', 'Monorepo directory of the package (e.g. packages/google-cloud-workflows)')

.alias('main-service', 'main_service')
.describe(
'main_service',
Expand Down Expand Up @@ -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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Retrieve the option as packageDir to match the renamed --package-dir CLI option.

Suggested change
const directory = argv.directory as string | undefined;
const packageDir = argv.packageDir as string | undefined;

const mainServiceName = argv.mainService as string | undefined;
const template = argv.template as string | undefined;
const gapicValidatorOut = argv.gapicValidatorOut as string | undefined;
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pass the option as package-dir to the protoc plugin to match the renamed option.

Suggested change
if (directory) {
protocCommand.push(`--typescript_gapic_opt="directory=${directory}"`);
}
if (packageDir) {
protocCommand.push(`--typescript_gapic_opt="package-dir=${packageDir}"`);
}

if (mainServiceName) {
protocCommand.push(
`--typescript_gapic_opt="main-service=${mainServiceName}"`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Rename the property to packageDir to be more descriptive and consistent with the renamed option.

  packageDir?: 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;
Expand Down Expand Up @@ -186,6 +187,7 @@ export class Generator {

private readPublishPackageName() {
this.publishName = this.paramMap['package-name'];
this.directory = this.paramMap['directory'];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Read the renamed package-dir option from paramMap.

    this.packageDir = this.paramMap['package-dir'];

}

private readMainServiceName() {
Expand Down Expand Up @@ -326,6 +328,7 @@ export class Generator {
grpcServiceConfig: this.grpcServiceConfig,
bundleConfigs: this.bundleConfigs,
publishName: this.publishName,
directory: this.directory,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pass packageDir instead of directory to the naming options.

      packageDir: this.packageDir,

mainServiceName: this.mainServiceName,
serviceYaml: this.serviceYaml,
rest: this.rest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Rename the property to packageDir to match the updated naming options.

Suggested change
directory?: string;
packageDir?: 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.
Expand Down Expand Up @@ -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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Assign packageDir from options.

Suggested change
this.directory = options.directory;
this.packageDir = options.packageDir;

this.loggingName =
this.publishName.match(/[^/]+\/(.*)/)?.[1] ?? this.publishName;
this.handwrittenLayer = options.handwrittenLayer ?? false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface Options {
grpcServiceConfig: protos.grpc.service_config.ServiceConfig;
bundleConfigs?: BundleConfig[];
publishName?: string;
directory?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Rename the directory option to packageDir in the Options interface.

Suggested change
directory?: string;
packageDir?: string;

mainServiceName?: string;
serviceYaml?: ServiceYaml;
rest?: boolean;
Expand Down
Loading