From 7b774e96728c2b6ae3ec73368206fe1d190b8f05 Mon Sep 17 00:00:00 2001 From: Karl Weinmeister Date: Sat, 18 Feb 2023 09:07:14 -0600 Subject: [PATCH 1/7] Upgrade got to v12 --- .eslintrc.json | 6 +++++- eventarc/audit-storage/package.json | 2 +- eventarc/audit-storage/test/system.test.js | 6 +++--- eventarc/generic/package.json | 2 +- eventarc/generic/test/system.test.js | 2 +- eventarc/pubsub/package.json | 2 +- eventarc/pubsub/test/system.test.js | 2 +- run/hello-broken/package.json | 2 +- run/hello-broken/test/system.test.js | 2 +- run/helloworld/package.json | 2 +- run/helloworld/test/system.test.js | 4 ++-- run/idp-sql/package.json | 2 +- run/idp-sql/test/system.test.js | 2 +- run/image-processing/package.json | 2 +- run/image-processing/test/system.test.js | 2 +- run/logging-manual/metadata.js | 4 ++-- run/logging-manual/package.json | 2 +- run/logging-manual/test/system.test.js | 4 ++-- run/markdown-preview/editor/package.json | 2 +- run/markdown-preview/editor/render.js | 2 +- run/markdown-preview/editor/test/system.test.js | 2 +- run/markdown-preview/renderer/package.json | 2 +- run/markdown-preview/renderer/test/system.test.js | 2 +- run/pubsub/package.json | 2 +- run/pubsub/test/system.test.js | 2 +- run/system-package/package.json | 2 +- run/system-package/test/system.test.js | 2 +- run/websockets/package.json | 2 +- run/websockets/test/system.test.js | 2 +- 29 files changed, 38 insertions(+), 34 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 73acfd71ca8..2d34d64d777 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,8 +3,12 @@ "env": { "mocha": true }, + "parserOptions": { + "sourceType": "module" + }, "rules": { "node/no-missing-require": ["off"], - "node/no-unpublished-require": ["off"] + "node/no-unpublished-require": ["off"], + "node/no-unsupported-features/es-syntax": ["off"] } } \ No newline at end of file diff --git a/eventarc/audit-storage/package.json b/eventarc/audit-storage/package.json index c9629bcf033..59146b73fb7 100644 --- a/eventarc/audit-storage/package.json +++ b/eventarc/audit-storage/package.json @@ -24,7 +24,7 @@ "express": "^4.16.4" }, "devDependencies": { - "got": "^11.5.0", + "got": "^12.0.0", "mocha": "^10.0.0", "sinon": "^15.0.0", "supertest": "^6.0.0" diff --git a/eventarc/audit-storage/test/system.test.js b/eventarc/audit-storage/test/system.test.js index 9ba94a66b62..7fc8931ae69 100644 --- a/eventarc/audit-storage/test/system.test.js +++ b/eventarc/audit-storage/test/system.test.js @@ -13,9 +13,9 @@ // limitations under the License. const assert = require('assert'); -const got = require('got'); +import got from 'got'; -const request = (method, route, base_url) => { +function request(method, route, base_url) { const {ID_TOKEN} = process.env; if (!ID_TOKEN) { throw Error('"ID_TOKEN" environment variable is required.'); @@ -28,7 +28,7 @@ const request = (method, route, base_url) => { method: method || 'get', throwHttpErrors: false, }); -}; +} describe('End-to-End Tests', () => { const {BASE_URL} = process.env; diff --git a/eventarc/generic/package.json b/eventarc/generic/package.json index ded0be6c200..c7919666516 100644 --- a/eventarc/generic/package.json +++ b/eventarc/generic/package.json @@ -21,7 +21,7 @@ "express": "^4.16.4" }, "devDependencies": { - "got": "^11.5.0", + "got": "^12.0.0", "mocha": "^10.0.0", "sinon": "^15.0.0", "supertest": "^6.0.0", diff --git a/eventarc/generic/test/system.test.js b/eventarc/generic/test/system.test.js index 159f30037a1..62b8d4267a1 100644 --- a/eventarc/generic/test/system.test.js +++ b/eventarc/generic/test/system.test.js @@ -13,7 +13,7 @@ // limitations under the License. const assert = require('assert'); -const got = require('got'); +import got from 'got'; const request = (method, route, base_url) => { const {ID_TOKEN} = process.env; diff --git a/eventarc/pubsub/package.json b/eventarc/pubsub/package.json index 0bb76d3165a..4e86a95c906 100644 --- a/eventarc/pubsub/package.json +++ b/eventarc/pubsub/package.json @@ -25,7 +25,7 @@ "express": "^4.16.4" }, "devDependencies": { - "got": "^11.5.0", + "got": "^12.0.0", "mocha": "^10.0.0", "sinon": "^15.0.0", "supertest": "^6.0.0", diff --git a/eventarc/pubsub/test/system.test.js b/eventarc/pubsub/test/system.test.js index 159f30037a1..62b8d4267a1 100644 --- a/eventarc/pubsub/test/system.test.js +++ b/eventarc/pubsub/test/system.test.js @@ -13,7 +13,7 @@ // limitations under the License. const assert = require('assert'); -const got = require('got'); +import got from 'got'; const request = (method, route, base_url) => { const {ID_TOKEN} = process.env; diff --git a/run/hello-broken/package.json b/run/hello-broken/package.json index d639034de31..3a384e216db 100644 --- a/run/hello-broken/package.json +++ b/run/hello-broken/package.json @@ -19,7 +19,7 @@ }, "devDependencies": { "google-auth-library": "^8.0.0", - "got": "^11.0.0", + "got": "^12.0.0", "mocha": "^10.0.0" } } diff --git a/run/hello-broken/test/system.test.js b/run/hello-broken/test/system.test.js index 639c8dc07e5..1c6d9f5c77d 100644 --- a/run/hello-broken/test/system.test.js +++ b/run/hello-broken/test/system.test.js @@ -13,7 +13,7 @@ // limitations under the License. const assert = require('assert'); -const request = require('got'); +import request from 'got'; const {execSync} = require('child_process'); const {GoogleAuth} = require('google-auth-library'); const auth = new GoogleAuth(); diff --git a/run/helloworld/package.json b/run/helloworld/package.json index 50ae6e0245a..7acba43266d 100644 --- a/run/helloworld/package.json +++ b/run/helloworld/package.json @@ -19,7 +19,7 @@ }, "devDependencies": { "google-auth-library": "^8.0.0", - "got": "^11.0.0", + "got": "^12.0.0", "mocha": "^10.0.0", "supertest": "^6.0.0" } diff --git a/run/helloworld/test/system.test.js b/run/helloworld/test/system.test.js index d37258d9350..c41d251cfe5 100644 --- a/run/helloworld/test/system.test.js +++ b/run/helloworld/test/system.test.js @@ -14,7 +14,7 @@ const assert = require('assert'); const {execSync} = require('child_process'); -const request = require('got'); +import got from 'got'; const {GoogleAuth} = require('google-auth-library'); const auth = new GoogleAuth(); @@ -23,7 +23,7 @@ const get = (route, base_url) => { throw Error('"ID_TOKEN" environment variable is required.'); } - return request(new URL(route, base_url.trim()), { + return got(new URL(route, base_url.trim()), { headers: { Authorization: `${ID_TOKEN.trim()}`, }, diff --git a/run/idp-sql/package.json b/run/idp-sql/package.json index d35eefa03ec..88d313eb1c7 100644 --- a/run/idp-sql/package.json +++ b/run/idp-sql/package.json @@ -28,7 +28,7 @@ "winston": "3.8.2" }, "devDependencies": { - "got": "^11.7.0", + "got": "^12.0.0", "mocha": "^10.0.0", "short-uuid": "^4.1.0", "sinon": "^15.0.0", diff --git a/run/idp-sql/test/system.test.js b/run/idp-sql/test/system.test.js index 343718467c0..c5ebeb9c14a 100644 --- a/run/idp-sql/test/system.test.js +++ b/run/idp-sql/test/system.test.js @@ -15,7 +15,7 @@ 'use strict'; const assert = require('assert'); -const got = require('got'); +import got from 'got'; const admin = require('firebase-admin'); const {spawnSync, execSync} = require('child_process'); diff --git a/run/image-processing/package.json b/run/image-processing/package.json index 3881b2ead3c..00ddb23aefb 100644 --- a/run/image-processing/package.json +++ b/run/image-processing/package.json @@ -26,7 +26,7 @@ }, "devDependencies": { "google-auth-library": "^8.0.0", - "got": "^11.5.0", + "got": "^12.0.0", "mocha": "^10.0.0", "supertest": "^6.0.0" } diff --git a/run/image-processing/test/system.test.js b/run/image-processing/test/system.test.js index 65722bb83a2..f18fb773ba3 100644 --- a/run/image-processing/test/system.test.js +++ b/run/image-processing/test/system.test.js @@ -14,7 +14,7 @@ const assert = require('assert'); const {execSync} = require('child_process'); -const got = require('got'); +import got from 'got'; const {GoogleAuth} = require('google-auth-library'); const auth = new GoogleAuth(); diff --git a/run/logging-manual/metadata.js b/run/logging-manual/metadata.js index 720654c3a78..e7c853f758f 100644 --- a/run/logging-manual/metadata.js +++ b/run/logging-manual/metadata.js @@ -1,4 +1,4 @@ -const request = require('got'); +import got from 'got'; // Load the project ID from GCP metadata server. // You can also use https://www.npmjs.com/package/gcp-metadata. @@ -8,6 +8,6 @@ exports.getProjectId = async () => { const options = { headers: {'Metadata-Flavor': 'Google'}, }; - const response = await request(METADATA_PROJECT_ID_URL, options); + const response = await got(METADATA_PROJECT_ID_URL, options); return response.body; }; diff --git a/run/logging-manual/package.json b/run/logging-manual/package.json index 39f08e92b1c..be6744f1620 100644 --- a/run/logging-manual/package.json +++ b/run/logging-manual/package.json @@ -16,7 +16,7 @@ "license": "Apache-2.0", "dependencies": { "express": "^4.17.1", - "got": "^11.0.0" + "got": "^12.0.0" }, "devDependencies": { "@google-cloud/logging": "^10.0.0", diff --git a/run/logging-manual/test/system.test.js b/run/logging-manual/test/system.test.js index 9f1a8d36ebb..4560a1f5cdf 100644 --- a/run/logging-manual/test/system.test.js +++ b/run/logging-manual/test/system.test.js @@ -13,7 +13,7 @@ // limitations under the License. const assert = require('assert'); -const request = require('got'); +import got from 'got'; const {Logging} = require('@google-cloud/logging'); const {execSync} = require('child_process'); const {GoogleAuth} = require('google-auth-library'); @@ -141,7 +141,7 @@ describe('Logging', () => { } console.log(`Sending test requests to ${BASE_URL}`); - await request(BASE_URL.trim(), { + await got(BASE_URL.trim(), { headers: { Authorization: `${ID_TOKEN.trim()}`, }, diff --git a/run/markdown-preview/editor/package.json b/run/markdown-preview/editor/package.json index fba10854098..336faa2c00c 100644 --- a/run/markdown-preview/editor/package.json +++ b/run/markdown-preview/editor/package.json @@ -21,7 +21,7 @@ "dependencies": { "express": "^4.17.1", "google-auth-library": "^8.0.0", - "got": "^11.8.0", + "got": "^12.0.0", "handlebars": "^4.7.6" }, "devDependencies": { diff --git a/run/markdown-preview/editor/render.js b/run/markdown-preview/editor/render.js index 9a35f6c3b5b..49e0105d4af 100644 --- a/run/markdown-preview/editor/render.js +++ b/run/markdown-preview/editor/render.js @@ -15,7 +15,7 @@ // [START cloudrun_secure_request] // [START run_secure_request] const {GoogleAuth} = require('google-auth-library'); -const got = require('got'); +import got from 'got'; const auth = new GoogleAuth(); let client, serviceUrl; diff --git a/run/markdown-preview/editor/test/system.test.js b/run/markdown-preview/editor/test/system.test.js index da5f55e622d..e82ad5e0637 100644 --- a/run/markdown-preview/editor/test/system.test.js +++ b/run/markdown-preview/editor/test/system.test.js @@ -13,7 +13,7 @@ // limitations under the License. const assert = require('assert'); -const got = require('got'); +import got from 'got'; const {execSync} = require('child_process'); const {GoogleAuth} = require('google-auth-library'); const auth = new GoogleAuth(); diff --git a/run/markdown-preview/renderer/package.json b/run/markdown-preview/renderer/package.json index 301a74c3ad2..d0ff257c8f1 100644 --- a/run/markdown-preview/renderer/package.json +++ b/run/markdown-preview/renderer/package.json @@ -23,7 +23,7 @@ }, "devDependencies": { "google-auth-library": "^8.0.0", - "got": "^11.5.0", + "got": "^12.0.0", "mocha": "^10.0.0", "sinon": "^15.0.0", "supertest": "^6.0.0" diff --git a/run/markdown-preview/renderer/test/system.test.js b/run/markdown-preview/renderer/test/system.test.js index f1ac45557cd..fd4b98d25bd 100644 --- a/run/markdown-preview/renderer/test/system.test.js +++ b/run/markdown-preview/renderer/test/system.test.js @@ -13,7 +13,7 @@ // limitations under the License. const assert = require('assert'); -const got = require('got'); +import got from 'got'; const {execSync} = require('child_process'); const {GoogleAuth} = require('google-auth-library'); const auth = new GoogleAuth(); diff --git a/run/pubsub/package.json b/run/pubsub/package.json index 6cd8833dd9e..224cbdc52cc 100644 --- a/run/pubsub/package.json +++ b/run/pubsub/package.json @@ -23,7 +23,7 @@ }, "devDependencies": { "google-auth-library": "^8.0.0", - "got": "^11.5.0", + "got": "^12.0.0", "mocha": "^10.0.0", "sinon": "^15.0.0", "supertest": "^6.0.0", diff --git a/run/pubsub/test/system.test.js b/run/pubsub/test/system.test.js index 86dffceaee5..d4129ff9062 100644 --- a/run/pubsub/test/system.test.js +++ b/run/pubsub/test/system.test.js @@ -13,7 +13,7 @@ // limitations under the License. const assert = require('assert'); -const got = require('got'); +import got from 'got'; const {GoogleAuth} = require('google-auth-library'); const auth = new GoogleAuth(); const {execSync} = require('child_process'); diff --git a/run/system-package/package.json b/run/system-package/package.json index d15e391b800..404e5c13b64 100644 --- a/run/system-package/package.json +++ b/run/system-package/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "google-auth-library": "^8.0.0", - "got": "^11.5.0", + "got": "^12.0.0", "mocha": "^10.0.0", "supertest": "^6.0.0" } diff --git a/run/system-package/test/system.test.js b/run/system-package/test/system.test.js index 2797e16dfa3..0e59089c0f8 100644 --- a/run/system-package/test/system.test.js +++ b/run/system-package/test/system.test.js @@ -13,7 +13,7 @@ // limitations under the License. const assert = require('assert'); -const got = require('got'); +import got from 'got'; const {execSync} = require('child_process'); const {GoogleAuth} = require('google-auth-library'); const auth = new GoogleAuth(); diff --git a/run/websockets/package.json b/run/websockets/package.json index 5b979484b39..40f26aeacf8 100644 --- a/run/websockets/package.json +++ b/run/websockets/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "google-auth-library": "^8.0.2", - "got": "^11.8.3", + "got": "^12.0.0", "puppeteer": "^15.1.0" } } diff --git a/run/websockets/test/system.test.js b/run/websockets/test/system.test.js index 642da06785f..01b0b514ea9 100644 --- a/run/websockets/test/system.test.js +++ b/run/websockets/test/system.test.js @@ -13,7 +13,7 @@ // limitations under the License. const assert = require('assert'); -const got = require('got'); +import got from 'got'; const {execSync} = require('child_process'); const {GoogleAuth} = require('google-auth-library'); const puppeteer = require('puppeteer'); From 785a590cb5c870ae07ba9af7f376983f44c4e49a Mon Sep 17 00:00:00 2001 From: Karl Weinmeister Date: Sat, 18 Feb 2023 09:13:48 -0600 Subject: [PATCH 2/7] update hello-broken --- run/hello-broken/test/system.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/hello-broken/test/system.test.js b/run/hello-broken/test/system.test.js index 1c6d9f5c77d..a3820c4149c 100644 --- a/run/hello-broken/test/system.test.js +++ b/run/hello-broken/test/system.test.js @@ -13,13 +13,13 @@ // limitations under the License. const assert = require('assert'); -import request from 'got'; +import got from 'got'; const {execSync} = require('child_process'); const {GoogleAuth} = require('google-auth-library'); const auth = new GoogleAuth(); const get = (route, base_url, id_token, retry = 3) => { - return request(new URL(route, base_url.trim()), { + return got(new URL(route, base_url.trim()), { headers: { Authorization: `${id_token.trim()}`, }, From 6bd41b94e092698ff2339bd8e0186512fa399c95 Mon Sep 17 00:00:00 2001 From: Karl Weinmeister Date: Sat, 18 Feb 2023 09:17:05 -0600 Subject: [PATCH 3/7] add import rules and license header --- .eslintrc.json | 2 ++ run/logging-manual/metadata.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.eslintrc.json b/.eslintrc.json index 2d34d64d777..facfa37b6c7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,7 +8,9 @@ }, "rules": { "node/no-missing-require": ["off"], + "node/no-missing-import": ["off"], "node/no-unpublished-require": ["off"], + "node/no-unpublished-import": ["off"], "node/no-unsupported-features/es-syntax": ["off"] } } \ No newline at end of file diff --git a/run/logging-manual/metadata.js b/run/logging-manual/metadata.js index e7c853f758f..1d6ef3a3b34 100644 --- a/run/logging-manual/metadata.js +++ b/run/logging-manual/metadata.js @@ -1,3 +1,17 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + import got from 'got'; // Load the project ID from GCP metadata server. From cc6596c9ba1a644cf781915e3efb359265daea1c Mon Sep 17 00:00:00 2001 From: Karl Weinmeister Date: Sat, 18 Feb 2023 09:35:01 -0600 Subject: [PATCH 4/7] update eventarc and run --- .eslintrc.json | 2 +- eventarc/audit-storage/package.json | 3 +++ eventarc/audit-storage/test/app.test.js | 8 ++++---- eventarc/audit-storage/test/system.test.js | 2 +- eventarc/generic/package.json | 3 +++ eventarc/generic/test/app.test.js | 6 +++--- eventarc/generic/test/system.test.js | 2 +- eventarc/pubsub/package.json | 3 +++ eventarc/pubsub/test/app.test.js | 6 +++--- run/hello-broken/package.json | 1 + run/hello-broken/test/system.test.js | 6 +++--- run/system-package/package.json | 1 + run/system-package/test/app.test.js | 4 ++-- run/system-package/test/system.test.js | 6 +++--- 14 files changed, 32 insertions(+), 21 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index facfa37b6c7..42e40724b07 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -13,4 +13,4 @@ "node/no-unpublished-import": ["off"], "node/no-unsupported-features/es-syntax": ["off"] } -} \ No newline at end of file +} diff --git a/eventarc/audit-storage/package.json b/eventarc/audit-storage/package.json index 59146b73fb7..8eff3d1e571 100644 --- a/eventarc/audit-storage/package.json +++ b/eventarc/audit-storage/package.json @@ -10,6 +10,7 @@ "type": "git", "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, + "type": "module", "engines": { "node": ">= 12.0.0" }, @@ -24,6 +25,8 @@ "express": "^4.16.4" }, "devDependencies": { + "@types/sinon": "^10.0.13", + "@types/supertest": "^2.0.12", "got": "^12.0.0", "mocha": "^10.0.0", "sinon": "^15.0.0", diff --git a/eventarc/audit-storage/test/app.test.js b/eventarc/audit-storage/test/app.test.js index 3138250af17..be59e4f43d4 100644 --- a/eventarc/audit-storage/test/app.test.js +++ b/eventarc/audit-storage/test/app.test.js @@ -18,10 +18,10 @@ 'use strict'; -const assert = require('assert'); -const path = require('path'); -const supertest = require('supertest'); -const sinon = require('sinon'); +import assert from 'assert'; +import path from 'path'; +import supertest from 'supertest'; +import sinon from 'sinon'; let request; diff --git a/eventarc/audit-storage/test/system.test.js b/eventarc/audit-storage/test/system.test.js index 7fc8931ae69..2d027291e4a 100644 --- a/eventarc/audit-storage/test/system.test.js +++ b/eventarc/audit-storage/test/system.test.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -const assert = require('assert'); +import assert from 'assert'; import got from 'got'; function request(method, route, base_url) { diff --git a/eventarc/generic/package.json b/eventarc/generic/package.json index c7919666516..31880e08f7e 100644 --- a/eventarc/generic/package.json +++ b/eventarc/generic/package.json @@ -2,6 +2,7 @@ "name": "cloud-eventarc-generic", "version": "1.0.0", "private": true, + "type": "module", "main": "index.js", "author": "Google LLC", "license": "Apache-2.0", @@ -21,6 +22,8 @@ "express": "^4.16.4" }, "devDependencies": { + "@types/sinon": "^10.0.13", + "@types/supertest": "^2.0.12", "got": "^12.0.0", "mocha": "^10.0.0", "sinon": "^15.0.0", diff --git a/eventarc/generic/test/app.test.js b/eventarc/generic/test/app.test.js index 34b490930ea..1eac9b23e4e 100644 --- a/eventarc/generic/test/app.test.js +++ b/eventarc/generic/test/app.test.js @@ -18,9 +18,9 @@ 'use strict'; -const assert = require('assert'); -const path = require('path'); -const supertest = require('supertest'); +import assert from 'assert'; +import path from 'path'; +import supertest from 'supertest'; let request; diff --git a/eventarc/generic/test/system.test.js b/eventarc/generic/test/system.test.js index 62b8d4267a1..f8db39e0cbc 100644 --- a/eventarc/generic/test/system.test.js +++ b/eventarc/generic/test/system.test.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -const assert = require('assert'); +import assert from 'assert'; import got from 'got'; const request = (method, route, base_url) => { diff --git a/eventarc/pubsub/package.json b/eventarc/pubsub/package.json index 4e86a95c906..447cef4da6e 100644 --- a/eventarc/pubsub/package.json +++ b/eventarc/pubsub/package.json @@ -2,6 +2,7 @@ "name": "cloud-eventarc-pubsub", "version": "1.0.0", "private": true, + "type": "module", "description": "Simple Events for Cloud Run – Pub/Sub sample", "main": "index.js", "author": "Google LLC", @@ -25,6 +26,8 @@ "express": "^4.16.4" }, "devDependencies": { + "@types/sinon": "^10.0.13", + "@types/supertest": "^2.0.12", "got": "^12.0.0", "mocha": "^10.0.0", "sinon": "^15.0.0", diff --git a/eventarc/pubsub/test/app.test.js b/eventarc/pubsub/test/app.test.js index 7cbd73d174e..ea9fd545478 100644 --- a/eventarc/pubsub/test/app.test.js +++ b/eventarc/pubsub/test/app.test.js @@ -18,9 +18,9 @@ 'use strict'; -const assert = require('assert'); -const path = require('path'); -const supertest = require('supertest'); +import assert from 'assert'; +import path from 'path'; +import supertest from 'supertest'; let request; diff --git a/run/hello-broken/package.json b/run/hello-broken/package.json index 3a384e216db..2fbdabf5a0d 100644 --- a/run/hello-broken/package.json +++ b/run/hello-broken/package.json @@ -3,6 +3,7 @@ "description": "Broken Cloud Run service for troubleshooting practice", "version": "1.0.0", "private": true, + "type": "module", "main": "index.js", "scripts": { "start": "node index.js", diff --git a/run/hello-broken/test/system.test.js b/run/hello-broken/test/system.test.js index a3820c4149c..bb75c775372 100644 --- a/run/hello-broken/test/system.test.js +++ b/run/hello-broken/test/system.test.js @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -const assert = require('assert'); +import assert from 'assert'; import got from 'got'; -const {execSync} = require('child_process'); -const {GoogleAuth} = require('google-auth-library'); +import {execSync} from 'child_process'; +import {GoogleAuth} from 'google-auth-library'; const auth = new GoogleAuth(); const get = (route, base_url, id_token, retry = 3) => { diff --git a/run/system-package/package.json b/run/system-package/package.json index 404e5c13b64..a5d943d36f8 100644 --- a/run/system-package/package.json +++ b/run/system-package/package.json @@ -4,6 +4,7 @@ "description": "Demonstrates a Cloud Run service which provides a CLI tool over HTTP.", "main": "index.js", "private": true, + "type": "module", "scripts": { "start": "node index.js", "test": "mocha test/app.test.js --check-leaks", diff --git a/run/system-package/test/app.test.js b/run/system-package/test/app.test.js index affcaefb882..4e462b8be40 100644 --- a/run/system-package/test/app.test.js +++ b/run/system-package/test/app.test.js @@ -14,8 +14,8 @@ 'use strict'; -const path = require('path'); -const supertest = require('supertest'); +import path from 'path'; +import supertest from 'supertest'; describe('Unit Tests', () => { const app = require(path.join(__dirname, '..', 'app')); diff --git a/run/system-package/test/system.test.js b/run/system-package/test/system.test.js index 0e59089c0f8..50b91e6d810 100644 --- a/run/system-package/test/system.test.js +++ b/run/system-package/test/system.test.js @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -const assert = require('assert'); +import assert from 'assert'; import got from 'got'; -const {execSync} = require('child_process'); -const {GoogleAuth} = require('google-auth-library'); +import {execSync} from 'child_process'; +import {GoogleAuth} from 'google-auth-library'; const auth = new GoogleAuth(); const request = (method, route, base_url, id_token) => { From 499745bb8c3761838118f26c2c888c9b5c72688e Mon Sep 17 00:00:00 2001 From: Karl Weinmeister Date: Sat, 18 Feb 2023 09:57:27 -0600 Subject: [PATCH 5/7] more updates --- eventarc/audit-storage/package.json | 2 +- eventarc/audit-storage/test/app.test.js | 5 +++-- eventarc/generic/package.json | 2 +- eventarc/generic/test/app.test.js | 5 +++-- eventarc/pubsub/package.json | 2 +- eventarc/pubsub/test/app.test.js | 6 +++--- eventarc/pubsub/test/system.test.js | 2 +- run/pubsub/package.json | 3 ++- run/pubsub/test/app.test.js | 13 +++++++------ run/pubsub/test/system.test.js | 6 +++--- run/system-package/package.json | 2 +- run/system-package/test/app.test.js | 3 ++- run/websockets/package.json | 1 + run/websockets/test/system.test.js | 8 ++++---- 14 files changed, 33 insertions(+), 27 deletions(-) diff --git a/eventarc/audit-storage/package.json b/eventarc/audit-storage/package.json index 8eff3d1e571..bd0289611b3 100644 --- a/eventarc/audit-storage/package.json +++ b/eventarc/audit-storage/package.json @@ -12,7 +12,7 @@ }, "type": "module", "engines": { - "node": ">= 12.0.0" + "node": ">= 12.2.0" }, "scripts": { "start": "node index.js", diff --git a/eventarc/audit-storage/test/app.test.js b/eventarc/audit-storage/test/app.test.js index be59e4f43d4..9b4c188a06f 100644 --- a/eventarc/audit-storage/test/app.test.js +++ b/eventarc/audit-storage/test/app.test.js @@ -1,4 +1,4 @@ -// Copyright 2020, Google LLC. +// Copyright 2020 Google LLC // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -22,12 +22,13 @@ import assert from 'assert'; import path from 'path'; import supertest from 'supertest'; import sinon from 'sinon'; +import {createRequire} from 'module'; let request; describe('Unit Tests', () => { before(() => { - const app = require(path.join(__dirname, '..', 'app')); + const app = createRequire(path.join(__dirname, '..', 'app')); request = supertest(app); }); diff --git a/eventarc/generic/package.json b/eventarc/generic/package.json index 31880e08f7e..634a251bdd5 100644 --- a/eventarc/generic/package.json +++ b/eventarc/generic/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">= 12.0.0" + "node": ">= 12.2.0" }, "scripts": { "start": "node index.js", diff --git a/eventarc/generic/test/app.test.js b/eventarc/generic/test/app.test.js index 1eac9b23e4e..735d0fdbcf2 100644 --- a/eventarc/generic/test/app.test.js +++ b/eventarc/generic/test/app.test.js @@ -1,4 +1,4 @@ -// Copyright 2019, Google LLC. +// Copyright 2019 Google LLC // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -21,12 +21,13 @@ import assert from 'assert'; import path from 'path'; import supertest from 'supertest'; +import {createRequire} from 'module'; let request; describe('Unit Tests', () => { before(() => { - const app = require(path.join(__dirname, '..', 'app')); + const app = createRequire(path.join(__dirname, '..', 'app')); request = supertest(app); }); diff --git a/eventarc/pubsub/package.json b/eventarc/pubsub/package.json index 447cef4da6e..fe9cb104ebb 100644 --- a/eventarc/pubsub/package.json +++ b/eventarc/pubsub/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">= 12.0.0" + "node": ">= 12.2.0" }, "scripts": { "start": "node index.js", diff --git a/eventarc/pubsub/test/app.test.js b/eventarc/pubsub/test/app.test.js index ea9fd545478..a0f52410f2b 100644 --- a/eventarc/pubsub/test/app.test.js +++ b/eventarc/pubsub/test/app.test.js @@ -1,4 +1,4 @@ -// Copyright 2019, Google LLC. +// Copyright 2019 Google LLC // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -21,12 +21,12 @@ import assert from 'assert'; import path from 'path'; import supertest from 'supertest'; - +import {createRequire} from 'module'; let request; describe('Unit Tests', () => { before(() => { - const app = require(path.join(__dirname, '..', 'app')); + const app = createRequire(path.join(__dirname, '..', 'app')); request = supertest(app); }); diff --git a/eventarc/pubsub/test/system.test.js b/eventarc/pubsub/test/system.test.js index 62b8d4267a1..f8db39e0cbc 100644 --- a/eventarc/pubsub/test/system.test.js +++ b/eventarc/pubsub/test/system.test.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -const assert = require('assert'); +import assert from 'assert'; import got from 'got'; const request = (method, route, base_url) => { diff --git a/run/pubsub/package.json b/run/pubsub/package.json index 224cbdc52cc..4b07a8fae97 100644 --- a/run/pubsub/package.json +++ b/run/pubsub/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">= 12.0.0" + "node": ">= 12.2.0" }, "scripts": { "start": "node index.js", @@ -22,6 +22,7 @@ "express": "^4.16.4" }, "devDependencies": { + "@types/uuid": "9.0.0", "google-auth-library": "^8.0.0", "got": "^12.0.0", "mocha": "^10.0.0", diff --git a/run/pubsub/test/app.test.js b/run/pubsub/test/app.test.js index db1b2a34cca..c8166489c54 100644 --- a/run/pubsub/test/app.test.js +++ b/run/pubsub/test/app.test.js @@ -18,17 +18,18 @@ 'use strict'; -const assert = require('assert'); -const path = require('path'); -const supertest = require('supertest'); -const uuid = require('uuid'); -const sinon = require('sinon'); +import assert from 'assert'; +import path from 'path'; +import supertest from 'supertest'; +import uuid from 'uuid'; +import sinon from 'sinon'; +import {createRequire} from 'module'; let request; describe('Unit Tests', () => { before(() => { - const app = require(path.join(__dirname, '..', 'app')); + const app = createRequire(path.join(__dirname, '..', 'app')); request = supertest(app); }); diff --git a/run/pubsub/test/system.test.js b/run/pubsub/test/system.test.js index d4129ff9062..f70e86c5d7e 100644 --- a/run/pubsub/test/system.test.js +++ b/run/pubsub/test/system.test.js @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -const assert = require('assert'); +import assert from 'assert'; import got from 'got'; -const {GoogleAuth} = require('google-auth-library'); +import GoogleAuth from 'google-auth-library'; const auth = new GoogleAuth(); -const {execSync} = require('child_process'); +import {execSync} from 'child_process'; let BASE_URL, ID_TOKEN; describe('End-to-End Tests', () => { diff --git a/run/system-package/package.json b/run/system-package/package.json index a5d943d36f8..426ce2ed1c4 100644 --- a/run/system-package/package.json +++ b/run/system-package/package.json @@ -11,7 +11,7 @@ "system-test": "mocha test/system.test.js --timeout=360000 --exit" }, "engines": { - "node": ">= 12.0.0" + "node": ">= 12.2.0" }, "dependencies": { "express": "^4.17.1" diff --git a/run/system-package/test/app.test.js b/run/system-package/test/app.test.js index 4e462b8be40..24bd296623b 100644 --- a/run/system-package/test/app.test.js +++ b/run/system-package/test/app.test.js @@ -16,9 +16,10 @@ import path from 'path'; import supertest from 'supertest'; +import {createRequire} from 'module'; describe('Unit Tests', () => { - const app = require(path.join(__dirname, '..', 'app')); + const app = createRequire(path.join(__dirname, '..', 'app')); const request = supertest(app); describe('should fail', () => { diff --git a/run/websockets/package.json b/run/websockets/package.json index 40f26aeacf8..6d5330abc03 100644 --- a/run/websockets/package.json +++ b/run/websockets/package.json @@ -3,6 +3,7 @@ "description": "Node.js websockets sample for Cloud Run", "version": "0.0.1", "private": true, + "type": "module", "license": "Apache Version 2.0", "author": "Google LLC", "scripts": { diff --git a/run/websockets/test/system.test.js b/run/websockets/test/system.test.js index 01b0b514ea9..6e1cdc2a297 100644 --- a/run/websockets/test/system.test.js +++ b/run/websockets/test/system.test.js @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -const assert = require('assert'); +import assert from 'assert'; import got from 'got'; -const {execSync} = require('child_process'); -const {GoogleAuth} = require('google-auth-library'); -const puppeteer = require('puppeteer'); +import {execSync} from 'child_process'; +import {GoogleAuth} from 'google-auth-library'; +import puppeteer from 'puppeteer'; const auth = new GoogleAuth(); describe('End-to-End Tests', () => { From 2ab61c14c0dce59b2a0ecbf8f001ee3e58d6d356 Mon Sep 17 00:00:00 2001 From: Karl Weinmeister Date: Sat, 18 Feb 2023 10:19:30 -0600 Subject: [PATCH 6/7] updates to some samples --- .eslintrc.json | 3 ++- eventarc/audit-storage/test/app.test.js | 5 +++++ run/helloworld/package.json | 3 ++- run/helloworld/test/index.test.js | 14 ++++++++++---- run/idp-sql/package.json | 3 ++- run/idp-sql/test/app.test.js | 17 ++++++++++++----- run/idp-sql/test/system.test.js | 6 +++--- run/image-processing/package.json | 2 +- run/image-processing/test/app.test.js | 12 +++++++++--- run/image-processing/test/system.test.js | 6 +++--- 10 files changed, 49 insertions(+), 22 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 42e40724b07..1ec3087f50c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,7 +4,8 @@ "mocha": true }, "parserOptions": { - "sourceType": "module" + "sourceType": "module", + "ecmaVersion": 2020 }, "rules": { "node/no-missing-require": ["off"], diff --git a/eventarc/audit-storage/test/app.test.js b/eventarc/audit-storage/test/app.test.js index 9b4c188a06f..fd28b5c1354 100644 --- a/eventarc/audit-storage/test/app.test.js +++ b/eventarc/audit-storage/test/app.test.js @@ -24,6 +24,11 @@ import supertest from 'supertest'; import sinon from 'sinon'; import {createRequire} from 'module'; +import {fileURLToPath} from 'url'; +import {dirname} from 'path'; +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + let request; describe('Unit Tests', () => { diff --git a/run/helloworld/package.json b/run/helloworld/package.json index 7acba43266d..a7bd2bb771b 100644 --- a/run/helloworld/package.json +++ b/run/helloworld/package.json @@ -3,6 +3,7 @@ "description": "Simple hello world sample in Node", "version": "1.0.0", "private": true, + "type": "module", "main": "index.js", "scripts": { "start": "node index.js", @@ -10,7 +11,7 @@ "system-test": "NAME=Cloud mocha test/system.test.js --timeout=180000" }, "engines": { - "node": ">= 12.0.0" + "node": ">= 12.2.0" }, "author": "Google LLC", "license": "Apache-2.0", diff --git a/run/helloworld/test/index.test.js b/run/helloworld/test/index.test.js index 7e73b128889..884408b592c 100644 --- a/run/helloworld/test/index.test.js +++ b/run/helloworld/test/index.test.js @@ -12,14 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -const assert = require('assert'); -const path = require('path'); -const supertest = require('supertest'); +import assert from 'assert'; +import path from 'path'; +import supertest from 'supertest'; +import {createRequire} from 'module'; +import {fileURLToPath} from 'url'; +import {dirname} from 'path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); let request; describe('Unit Tests', () => { before(() => { - const app = require(path.join(__dirname, '..', 'index')); + const app = createRequire(path.join(__dirname, '..', 'index')); request = supertest(app); }); diff --git a/run/idp-sql/package.json b/run/idp-sql/package.json index 88d313eb1c7..8331837e9a6 100644 --- a/run/idp-sql/package.json +++ b/run/idp-sql/package.json @@ -3,6 +3,7 @@ "description": "Identity Platform and Cloud SQL integrations sample for Cloud Run.", "version": "0.0.1", "private": true, + "type": "module", "license": "Apache-2.0", "author": "Google LLC", "repository": { @@ -10,7 +11,7 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=12.0.0" + "node": ">=12.2.0" }, "scripts": { "start": "node index.js", diff --git a/run/idp-sql/test/app.test.js b/run/idp-sql/test/app.test.js index 3d4f9898408..ccd326194a2 100644 --- a/run/idp-sql/test/app.test.js +++ b/run/idp-sql/test/app.test.js @@ -14,16 +14,23 @@ 'use strict'; -const path = require('path'); -const assert = require('assert'); -const supertest = require('supertest'); -const {buildRenderedHtml} = require('../handlebars'); +import path from 'path'; +import assert from 'assert'; +import supertest from 'supertest'; +import {createRequire} from 'module'; +import {fileURLToPath} from 'url'; +import {dirname} from 'path'; +import {buildRenderedHtml} from '../handlebars'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); let request; + describe('Unit Tests', () => { before(async () => { - const app = require(path.join(__dirname, '..', 'app')); + const app = createRequire(path.join(__dirname, '..', 'app')); request = supertest(app); }); diff --git a/run/idp-sql/test/system.test.js b/run/idp-sql/test/system.test.js index c5ebeb9c14a..11dabb9583e 100644 --- a/run/idp-sql/test/system.test.js +++ b/run/idp-sql/test/system.test.js @@ -14,10 +14,10 @@ 'use strict'; -const assert = require('assert'); +import assert from 'assert'; import got from 'got'; -const admin = require('firebase-admin'); -const {spawnSync, execSync} = require('child_process'); +import admin from 'firebase-admin'; +import {spawnSync, execSync} from 'child_process'; admin.initializeApp(); diff --git a/run/image-processing/package.json b/run/image-processing/package.json index 00ddb23aefb..fbd21ee1db9 100644 --- a/run/image-processing/package.json +++ b/run/image-processing/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">= 12.0.0" + "node": ">= 12.2.0" }, "scripts": { "start": "node index.js", diff --git a/run/image-processing/test/app.test.js b/run/image-processing/test/app.test.js index 0e9b12da374..e08dc25b906 100644 --- a/run/image-processing/test/app.test.js +++ b/run/image-processing/test/app.test.js @@ -1,11 +1,17 @@ -const path = require('path'); -const supertest = require('supertest'); +import path from 'path'; +import supertest from 'supertest'; +import {createRequire} from 'module'; +import {fileURLToPath} from 'url'; +import {dirname} from 'path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); let request; describe('Unit Tests', () => { before(() => { - const app = require(path.join(__dirname, '..', 'app')); + const app = createRequire(path.join(__dirname, '..', 'app')); request = supertest(app); }); diff --git a/run/image-processing/test/system.test.js b/run/image-processing/test/system.test.js index f18fb773ba3..c4e39ca78af 100644 --- a/run/image-processing/test/system.test.js +++ b/run/image-processing/test/system.test.js @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -const assert = require('assert'); -const {execSync} = require('child_process'); +import assert from 'assert'; +import {execSync} from 'child_process'; import got from 'got'; -const {GoogleAuth} = require('google-auth-library'); +import {GoogleAuth} from 'google-auth-library'; const auth = new GoogleAuth(); let BASE_URL, ID_TOKEN; From 2f970686d3923bf8ecef9af85175d2e81801ec77 Mon Sep 17 00:00:00 2001 From: Karl Weinmeister Date: Sat, 18 Feb 2023 10:34:43 -0600 Subject: [PATCH 7/7] more updates --- eventarc/generic/test/app.test.js | 5 +++++ eventarc/pubsub/test/app.test.js | 6 ++++++ run/idp-sql/test/app.test.js | 1 - run/image-processing/test/app.test.js | 14 ++++++++++++++ run/logging-manual/package.json | 4 ++++ run/logging-manual/test/system.test.js | 11 ++++++----- run/pubsub/test/app.test.js | 2 +- 7 files changed, 36 insertions(+), 7 deletions(-) diff --git a/eventarc/generic/test/app.test.js b/eventarc/generic/test/app.test.js index 735d0fdbcf2..07451fcae1e 100644 --- a/eventarc/generic/test/app.test.js +++ b/eventarc/generic/test/app.test.js @@ -22,6 +22,11 @@ import assert from 'assert'; import path from 'path'; import supertest from 'supertest'; import {createRequire} from 'module'; +import {fileURLToPath} from 'url'; +import {dirname} from 'path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); let request; diff --git a/eventarc/pubsub/test/app.test.js b/eventarc/pubsub/test/app.test.js index a0f52410f2b..fbfd7acc036 100644 --- a/eventarc/pubsub/test/app.test.js +++ b/eventarc/pubsub/test/app.test.js @@ -22,6 +22,12 @@ import assert from 'assert'; import path from 'path'; import supertest from 'supertest'; import {createRequire} from 'module'; +import {fileURLToPath} from 'url'; +import {dirname} from 'path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + let request; describe('Unit Tests', () => { diff --git a/run/idp-sql/test/app.test.js b/run/idp-sql/test/app.test.js index ccd326194a2..6fa53e9067b 100644 --- a/run/idp-sql/test/app.test.js +++ b/run/idp-sql/test/app.test.js @@ -27,7 +27,6 @@ const __dirname = dirname(__filename); let request; - describe('Unit Tests', () => { before(async () => { const app = createRequire(path.join(__dirname, '..', 'app')); diff --git a/run/image-processing/test/app.test.js b/run/image-processing/test/app.test.js index e08dc25b906..a6c214a7ee9 100644 --- a/run/image-processing/test/app.test.js +++ b/run/image-processing/test/app.test.js @@ -1,3 +1,17 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + import path from 'path'; import supertest from 'supertest'; import {createRequire} from 'module'; diff --git a/run/logging-manual/package.json b/run/logging-manual/package.json index be6744f1620..b8291d37e9e 100644 --- a/run/logging-manual/package.json +++ b/run/logging-manual/package.json @@ -3,10 +3,14 @@ "description": "Demonstrates logging on Cloud Run", "main": "index.js", "private": true, + "type": "module", "repository": { "type": "git", "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, + "engines": { + "node": ">=12.2.0" + }, "scripts": { "start": "node index.js", "test": "echo \"Error: no test specified\" && exit 0", diff --git a/run/logging-manual/test/system.test.js b/run/logging-manual/test/system.test.js index 4560a1f5cdf..f40854b0e8c 100644 --- a/run/logging-manual/test/system.test.js +++ b/run/logging-manual/test/system.test.js @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -const assert = require('assert'); +import assert from 'assert'; import got from 'got'; -const {Logging} = require('@google-cloud/logging'); -const {execSync} = require('child_process'); -const {GoogleAuth} = require('google-auth-library'); +import {Logging} from '@google-cloud/logging'; +import {execSync} from 'child_process'; +import {createRequire} from 'module'; +import {GoogleAuth} from 'google-auth-library'; const auth = new GoogleAuth(); const {promisify} = require('util'); @@ -24,7 +25,7 @@ const setTimeoutPromise = promisify(setTimeout); // Support concurrency by setting the service name to something unique. // The service name must be the same used to deploy to Cloud Run. -const service_name = process.env.SERVICE_NAME || require('../package').name; +const service_name = process.env.SERVICE_NAME || createRequire('../package').name; const logging = new Logging({ projectId: process.env.GOOGLE_CLOUD_PROJECT, diff --git a/run/pubsub/test/app.test.js b/run/pubsub/test/app.test.js index c8166489c54..ef25398ade4 100644 --- a/run/pubsub/test/app.test.js +++ b/run/pubsub/test/app.test.js @@ -1,4 +1,4 @@ -// Copyright 2019, Google LLC. +// Copyright 2019 Google LLC // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at