From 383ad4b9448f281a4015698cd6b9030ba39fea60 Mon Sep 17 00:00:00 2001
From: Xiaozhen Liu <xiaozhenliu@google.com>
Date: Mon, 23 Mar 2020 12:36:59 -0700
Subject: [PATCH] feat: sort package-json for generator to avoid noise in API
 conversion (#352)

* sort keys in package-json

* sort package-json in generated client
---
 baselines/bigquery-storage/package.json     |  6 +++---
 baselines/disable-packing-test/package.json |  6 +++---
 baselines/dlp/package.json                  |  6 +++---
 baselines/kms/package.json                  |  6 +++---
 baselines/logging/package.json              |  6 +++---
 baselines/monitoring/package.json           |  6 +++---
 baselines/redis/package.json                |  6 +++---
 baselines/showcase/package.json             |  6 +++---
 baselines/texttospeech/package.json         |  6 +++---
 baselines/translate/package.json            |  6 +++---
 package.json                                | 18 +++++++++---------
 templates/typescript_gapic/package.json     |  6 +++---
 12 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/baselines/bigquery-storage/package.json b/baselines/bigquery-storage/package.json
index c6bbec539..aa7790378 100644
--- a/baselines/bigquery-storage/package.json
+++ b/baselines/bigquery-storage/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-storage",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",
diff --git a/baselines/disable-packing-test/package.json b/baselines/disable-packing-test/package.json
index 31fbe3aed..8b39a68c5 100644
--- a/baselines/disable-packing-test/package.json
+++ b/baselines/disable-packing-test/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-showcase",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",
diff --git a/baselines/dlp/package.json b/baselines/dlp/package.json
index f3e76aafc..05035f965 100644
--- a/baselines/dlp/package.json
+++ b/baselines/dlp/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-dlp",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",
diff --git a/baselines/kms/package.json b/baselines/kms/package.json
index 1584f5c23..3c7d783c2 100644
--- a/baselines/kms/package.json
+++ b/baselines/kms/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-kms",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",
diff --git a/baselines/logging/package.json b/baselines/logging/package.json
index b5ddc012e..84e72432e 100644
--- a/baselines/logging/package.json
+++ b/baselines/logging/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-logging",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",
diff --git a/baselines/monitoring/package.json b/baselines/monitoring/package.json
index f6241928f..3a5a3d88d 100644
--- a/baselines/monitoring/package.json
+++ b/baselines/monitoring/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-monitoring",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",
diff --git a/baselines/redis/package.json b/baselines/redis/package.json
index 050a1371c..b0ecdb46d 100644
--- a/baselines/redis/package.json
+++ b/baselines/redis/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-redis",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",
diff --git a/baselines/showcase/package.json b/baselines/showcase/package.json
index 31fbe3aed..8b39a68c5 100644
--- a/baselines/showcase/package.json
+++ b/baselines/showcase/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-showcase",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",
diff --git a/baselines/texttospeech/package.json b/baselines/texttospeech/package.json
index 5c69f45a9..a40253f87 100644
--- a/baselines/texttospeech/package.json
+++ b/baselines/texttospeech/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-texttospeech",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",
diff --git a/baselines/translate/package.json b/baselines/translate/package.json
index fc7883dc2..a9f734696 100644
--- a/baselines/translate/package.json
+++ b/baselines/translate/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-translation",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",
diff --git a/package.json b/package.json
index 380fcc3ee..f413a6145 100644
--- a/package.json
+++ b/package.json
@@ -12,15 +12,15 @@
   },
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "bin": {
+    "gapic-generator-typescript": "build/src/start-script.js",
+    "protoc-gen-typescript_gapic": "build/src/cli.js"
+  },
   "files": [
     "build/src",
     "pbjs-genfiles",
     "templates"
   ],
-  "bin": {
-    "gapic-generator-typescript": "build/src/start-script.js",
-    "protoc-gen-typescript_gapic": "build/src/cli.js"
-  },
   "scripts": {
     "baseline": "node build/tools/update-baselines.js",
     "clean": "gts clean",
@@ -28,23 +28,23 @@
     "compile": "tsc -p .",
     "compile-protos": "pbjs -p protos -p node_modules/google-gax/protos -t static-module -o pbjs-genfiles/plugin.js google/protobuf/compiler/plugin.proto google/api/annotations.proto google/api/field_behavior.proto google/api/resource.proto google/api/client.proto google/longrunning/operations.proto service_config.proto && pbts pbjs-genfiles/plugin.js -o pbjs-genfiles/plugin.d.ts",
     "docker-test": "sh docker/test.sh",
-    "ts-test-application": "mocha build/test/test-application/test-ts --timeout 600000",
-    "js-test-application": "mocha build/test/test-application/test-js --timeout 600000",
     "fix": "gts fix",
+    "js-test-application": "mocha build/test/test-application/test-js --timeout 600000",
     "lint": "gts check",
+    "prepack": "cd templates/typescript_gapic && rm -f package.json.njk && mv package.json package.json.njk",
+    "postpack": "cd templates/typescript_gapic && mv package.json.njk package.json && ln -s package.json package.json.njk",
     "prepare": "npm run compile-protos && npm run compile",
     "pretest": "npm run compile-protos && npm run compile",
     "test": "c8 --reporter=lcov mocha build/test/unit",
-    "prepack": "cd templates/typescript_gapic && rm -f package.json.njk && mv package.json package.json.njk",
-    "postpack": "cd templates/typescript_gapic && mv package.json.njk package.json && ln -s package.json package.json.njk"
+    "ts-test-application": "mocha build/test/test-application/test-ts --timeout 600000"
   },
   "dependencies": {
     "@types/js-yaml": "^3.12.2",
     "file-system": "^2.2.2",
     "fs-extra": "^9.0.0",
     "get-stdin": "^7.0.0",
-    "js-yaml": "^3.13.1",
     "google-gax": "^1.15.1",
+    "js-yaml": "^3.13.1",
     "nunjucks": "^3.2.1",
     "object-hash": "^2.0.3",
     "protobufjs": "^6.8.9",
diff --git a/templates/typescript_gapic/package.json b/templates/typescript_gapic/package.json
index 43fb45755..c20b7b5e6 100644
--- a/templates/typescript_gapic/package.json
+++ b/templates/typescript_gapic/package.json
@@ -5,20 +5,20 @@
   "repository": "googleapis/nodejs-{{ api.naming.productName.toKebabCase() }}",
   "license": "Apache-2.0",
   "author": "Google LLC",
+  "main": "build/src/index.js",
   "files": [
     "build/src",
     "build/protos"
   ],
-  "main": "build/src/index.js",
   "scripts": {
     "clean": "gts clean",
     "compile": "tsc -p . && cp -r protos build/",
     "compile-protos": "compileProtos src",
     "docs": "jsdoc -c .jsdoc.js",
+    "predocs-test": "npm run docs",
     "docs-test": "linkinator docs",
     "fix": "gts fix",
     "lint": "gts check",
-    "predocs-test": "npm run docs",
     "prepare": "npm run compile-protos && npm run compile",
     "system-test": "c8 mocha build/system-test",
     "test": "c8 mocha build/test"
@@ -36,8 +36,8 @@
     "jsdoc-region-tag": "^1.0.4",
     "linkinator": "^2.0.4",
     "mocha": "^6.2.2",
-    "pack-n-play": "^1.0.0-2",
     "null-loader": "^3.0.0",
+    "pack-n-play": "^1.0.0-2",
     "ts-loader": "^6.2.2",
     "typescript": "~3.8.3",
     "webpack": "^4.42.0",