From 8f6db5ed9469eb3a09a92a9860f9a237f34e01eb Mon Sep 17 00:00:00 2001 From: Xiaozhen Liu Date: Wed, 23 Oct 2019 11:06:52 -0700 Subject: [PATCH] chore: change generated filename to snake_case (#67) * change filename to snake_case * change import filename --- templates/typescript_gapic/src/$version/$service_client.ts.njk | 2 +- templates/typescript_gapic/src/$version/index.ts.njk | 2 +- typescript/src/templater.ts | 3 ++- typescript/test/testdata/keymanager/src/v1/index.ts.baseline | 2 +- ...t.ts.baseline => key_management_service_client.ts.baseline} | 2 +- ...line => key_management_service_client_config.json.baseline} | 0 ...aseline => key_management_service_proto_list.json.baseline} | 0 ...ts.baseline => gapic-key_management_service-v1.ts.baseline} | 0 8 files changed, 6 insertions(+), 5 deletions(-) rename typescript/test/testdata/keymanager/src/v1/{keymanagementservice_client.ts.baseline => key_management_service_client.ts.baseline} (99%) rename typescript/test/testdata/keymanager/src/v1/{keymanagementservice_client_config.json.baseline => key_management_service_client_config.json.baseline} (100%) rename typescript/test/testdata/keymanager/src/v1/{keymanagementservice_proto_list.json.baseline => key_management_service_proto_list.json.baseline} (100%) rename typescript/test/testdata/keymanager/test/{gapic-keymanagementservice-v1.ts.baseline => gapic-key_management_service-v1.ts.baseline} (100%) diff --git a/templates/typescript_gapic/src/$version/$service_client.ts.njk b/templates/typescript_gapic/src/$version/$service_client.ts.njk index 00b9f9a5b..fcbab6b74 100644 --- a/templates/typescript_gapic/src/$version/$service_client.ts.njk +++ b/templates/typescript_gapic/src/$version/$service_client.ts.njk @@ -4,7 +4,7 @@ import * as path from 'path'; import * as packageJson from '../../package.json'; import * as protosTypes from '../../protos/protos'; -import * as gapicConfig from './{{ service.name.toLowerCase() }}_client_config.json'; +import * as gapicConfig from './{{ service.name.toSnakeCase() }}_client_config.json'; const version = packageJson.version; diff --git a/templates/typescript_gapic/src/$version/index.ts.njk b/templates/typescript_gapic/src/$version/index.ts.njk index 8adf96c89..90e9e7cd1 100644 --- a/templates/typescript_gapic/src/$version/index.ts.njk +++ b/templates/typescript_gapic/src/$version/index.ts.njk @@ -1,4 +1,4 @@ {% import "./license.njk" as license %}{{license.license()}} {% for service in api.services -%} -export {{ '{' + service.name.toPascalCase() + 'Client}' }} from './{{ service.name.toLowerCase() }}_client'; +export {{ '{' + service.name.toPascalCase() + 'Client}' }} from './{{ service.name.toSnakeCase() }}_client'; {%- endfor %} diff --git a/typescript/src/templater.ts b/typescript/src/templater.ts index d70afeb7b..a6d56944e 100644 --- a/typescript/src/templater.ts +++ b/typescript/src/templater.ts @@ -6,6 +6,7 @@ import * as util from 'util'; import * as plugin from '../../pbjs-genfiles/plugin'; import { API } from './schema/api'; +import { commonPrefix } from './util'; const commonParameters: { [name: string]: string } = { copyrightYear: new Date().getFullYear().toString(), @@ -68,7 +69,7 @@ function processOneTemplate( for (const service of api.services) { result.push( renderFile( - outputFilename.replace(/\$service/, service.name!.toLowerCase()), + outputFilename.replace(/\$service/, service.name!.toSnakeCase()), relativeTemplateName, { api, commonParameters, service } ) diff --git a/typescript/test/testdata/keymanager/src/v1/index.ts.baseline b/typescript/test/testdata/keymanager/src/v1/index.ts.baseline index 456626a8d..b5abfc61f 100644 --- a/typescript/test/testdata/keymanager/src/v1/index.ts.baseline +++ b/typescript/test/testdata/keymanager/src/v1/index.ts.baseline @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {KeyManagementServiceClient} from './keymanagementservice_client'; +export {KeyManagementServiceClient} from './key_management_service_client'; diff --git a/typescript/test/testdata/keymanager/src/v1/keymanagementservice_client.ts.baseline b/typescript/test/testdata/keymanager/src/v1/key_management_service_client.ts.baseline similarity index 99% rename from typescript/test/testdata/keymanager/src/v1/keymanagementservice_client.ts.baseline rename to typescript/test/testdata/keymanager/src/v1/key_management_service_client.ts.baseline index 288e38524..cc04cf22e 100644 --- a/typescript/test/testdata/keymanager/src/v1/keymanagementservice_client.ts.baseline +++ b/typescript/test/testdata/keymanager/src/v1/key_management_service_client.ts.baseline @@ -21,7 +21,7 @@ import * as path from 'path'; import * as packageJson from '../../package.json'; import * as protosTypes from '../../protos/protos'; -import * as gapicConfig from './keymanagementservice_client_config.json'; +import * as gapicConfig from './key_management_service_client_config.json'; const version = packageJson.version; diff --git a/typescript/test/testdata/keymanager/src/v1/keymanagementservice_client_config.json.baseline b/typescript/test/testdata/keymanager/src/v1/key_management_service_client_config.json.baseline similarity index 100% rename from typescript/test/testdata/keymanager/src/v1/keymanagementservice_client_config.json.baseline rename to typescript/test/testdata/keymanager/src/v1/key_management_service_client_config.json.baseline diff --git a/typescript/test/testdata/keymanager/src/v1/keymanagementservice_proto_list.json.baseline b/typescript/test/testdata/keymanager/src/v1/key_management_service_proto_list.json.baseline similarity index 100% rename from typescript/test/testdata/keymanager/src/v1/keymanagementservice_proto_list.json.baseline rename to typescript/test/testdata/keymanager/src/v1/key_management_service_proto_list.json.baseline diff --git a/typescript/test/testdata/keymanager/test/gapic-keymanagementservice-v1.ts.baseline b/typescript/test/testdata/keymanager/test/gapic-key_management_service-v1.ts.baseline similarity index 100% rename from typescript/test/testdata/keymanager/test/gapic-keymanagementservice-v1.ts.baseline rename to typescript/test/testdata/keymanager/test/gapic-key_management_service-v1.ts.baseline