From eb9c0427d6f2e7411dd71a1d374cd4957c5c9e66 Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Fri, 10 Apr 2020 18:57:29 -0700 Subject: [PATCH] feat!: drop node8, remove eslint, update gax, fix generated protos, run the generator (#423) --- ...analyze-streaming-annotation-to-storage.js | 2 +- ...analyze-streaming-automl-classification.js | 2 +- .../analyze-streaming-labels.js | 2 +- .../analyze-streaming-object.js | 4 +- .../analyze-streaming-safe-search.js | 2 +- .../analyze-streaming-shot-change.js | 4 +- video-intelligence/analyze.js | 70 ++++++++++--------- ...ze-streaming-annotation-to-storage.test.js | 2 +- ...ze-streaming-automl-classification.test.js | 4 +- .../analyze-streaming-labels.test.js | 2 +- .../analyze-streaming-object.test.js | 2 +- .../analyze-streaming-safe-search.test.js | 2 +- .../analyze-streaming-shot-change.test.js | 2 +- .../analyze_face_detection.test.js | 2 +- .../analyze_face_detection_gcs.test.js | 2 +- .../analyze_person_detection.test.js | 2 +- .../analyze_person_detection_gcs.test.js | 2 +- .../system-test/detect_logo.test.js | 2 +- .../system-test/detect_logo_gcs.test.js | 2 +- 19 files changed, 57 insertions(+), 55 deletions(-) diff --git a/video-intelligence/analyze-streaming-annotation-to-storage.js b/video-intelligence/analyze-streaming-annotation-to-storage.js index 9f04ae38b4..c5b1bff7f7 100644 --- a/video-intelligence/analyze-streaming-annotation-to-storage.js +++ b/video-intelligence/analyze-streaming-annotation-to-storage.js @@ -52,7 +52,7 @@ async function main(path = 'YOUR_LOCAL_FILE', outputUri = 'PATH_TO_OUTPUT') { }; chunks.push(request); }) - .on('close', function() { + .on('close', () => { // configRequest should be the first in the stream of requests stream.write(configRequest); for (let i = 0; i < chunks.length; i++) { diff --git a/video-intelligence/analyze-streaming-automl-classification.js b/video-intelligence/analyze-streaming-automl-classification.js index fe661d2cb8..0e9ada7c04 100644 --- a/video-intelligence/analyze-streaming-automl-classification.js +++ b/video-intelligence/analyze-streaming-automl-classification.js @@ -62,7 +62,7 @@ async function main( }; chunks.push(request); }) - .on('close', function() { + .on('close', () => { // configRequest should be the first in the stream of requests stream.write(configRequest); for (let i = 0; i < chunks.length; i++) { diff --git a/video-intelligence/analyze-streaming-labels.js b/video-intelligence/analyze-streaming-labels.js index 12a8ed983f..111bfd4d15 100644 --- a/video-intelligence/analyze-streaming-labels.js +++ b/video-intelligence/analyze-streaming-labels.js @@ -46,7 +46,7 @@ async function main(path = 'YOUR_LOCAL_FILE') { }; chunks.push(request); }) - .on('close', function() { + .on('close', () => { // configRequest should be the first in the stream of requests stream.write(configRequest); for (let i = 0; i < chunks.length; i++) { diff --git a/video-intelligence/analyze-streaming-object.js b/video-intelligence/analyze-streaming-object.js index 042f70c327..c219e98b9c 100644 --- a/video-intelligence/analyze-streaming-object.js +++ b/video-intelligence/analyze-streaming-object.js @@ -46,7 +46,7 @@ async function main(path = 'YOUR_LOCAL_FILE') { }; chunks.push(request); }) - .on('close', function() { + .on('close', () => { // configRequest should be the first in the stream of requests stream.write(configRequest); for (let i = 0; i < chunks.length; i++) { @@ -70,7 +70,7 @@ async function main(path = 'YOUR_LOCAL_FILE') { ); //Every annotation has only one frame. const box = object.frames[0].normalizedBoundingBox; - console.log(`Bounding box position:`); + console.log('Bounding box position:'); console.log(` left :${box.left}`); console.log(` top :${box.top}`); console.log(` right :${box.right}`); diff --git a/video-intelligence/analyze-streaming-safe-search.js b/video-intelligence/analyze-streaming-safe-search.js index d9f3ad97b5..cd52bb1cc5 100644 --- a/video-intelligence/analyze-streaming-safe-search.js +++ b/video-intelligence/analyze-streaming-safe-search.js @@ -47,7 +47,7 @@ async function main(path = 'YOUR_LOCAL_FILE') { }; chunks.push(request); }) - .on('close', function() { + .on('close', () => { // configRequest should be the first in the stream of requests stream.write(configRequest); for (let i = 0; i < chunks.length; i++) { diff --git a/video-intelligence/analyze-streaming-shot-change.js b/video-intelligence/analyze-streaming-shot-change.js index c97dff48b1..fa8626e0b1 100644 --- a/video-intelligence/analyze-streaming-shot-change.js +++ b/video-intelligence/analyze-streaming-shot-change.js @@ -46,7 +46,7 @@ async function main(path = 'YOUR_LOCAL_FILE') { }; chunks.push(request); }) - .on('close', function() { + .on('close', () => { // configRequest should be the first in the stream of requests stream.write(configRequest); for (let i = 0; i < chunks.length; i++) { @@ -61,7 +61,7 @@ async function main(path = 'YOUR_LOCAL_FILE') { const shotChanges = annotations.shotAnnotations; console.log(JSON.stringify(shotChanges)); if (shotChanges.length === 1) { - console.log(`The entire video is one shot.`); + console.log('The entire video is one shot.'); } shotChanges.forEach(shot => { console.log( diff --git a/video-intelligence/analyze.js b/video-intelligence/analyze.js index 1d62dbc949..7f9885c6a7 100644 --- a/video-intelligence/analyze.js +++ b/video-intelligence/analyze.js @@ -163,7 +163,7 @@ async function analyzeShots(gcsUri) { console.log('Shot changes:'); if (shotChanges.length === 1) { - console.log(`The entire video is one shot.`); + console.log('The entire video is one shot.'); } else { shotChanges.forEach((shot, shotIdx) => { console.log(`Scene ${shotIdx} occurs from:`); @@ -344,7 +344,7 @@ async function analyzeTextGCS(gcsUri) { `Time offset for the frame: ${timeOffset.seconds || 0}` + `.${(timeOffset.nanos / 1e6).toFixed(0)}s` ); - console.log(`Rotated Bounding Box Vertices:`); + console.log('Rotated Bounding Box Vertices:'); frame.rotatedBoundingBox.vertices.forEach(vertex => { console.log(`Vertex.x:${vertex.x}, Vertex.y:${vertex.y}`); }); @@ -399,7 +399,7 @@ async function analyzeObjectTrackingGCS(gcsUri) { `Time offset for the first frame: ${timeOffset.seconds || 0}` + `.${(timeOffset.nanos / 1e6).toFixed(0)}s` ); - console.log(`Bounding box position:`); + console.log('Bounding box position:'); console.log(` left :${box.left}`); console.log(` top :${box.top}`); console.log(` right :${box.right}`); @@ -468,7 +468,7 @@ async function analyzeText(path) { `Time offset for the frame: ${timeOffset.seconds || 0}` + `.${(timeOffset.nanos / 1e6).toFixed(0)}s` ); - console.log(`Rotated Bounding Box Vertices:`); + console.log('Rotated Bounding Box Vertices:'); frame.rotatedBoundingBox.vertices.forEach(vertex => { console.log(`Vertex.x:${vertex.x}, Vertex.y:${vertex.y}`); }); @@ -526,7 +526,7 @@ async function analyzeObjectTracking(path) { `Time offset for the first frame: ${timeOffset.seconds || 0}` + `.${(timeOffset.nanos / 1e6).toFixed(0)}s` ); - console.log(`Bounding box position:`); + console.log('Bounding box position:'); console.log(` left :${box.left}`); console.log(` top :${box.top}`); console.log(` right :${box.right}`); @@ -536,77 +536,79 @@ async function analyzeObjectTracking(path) { } async function main() { - require(`yargs`) + require('yargs') .demand(1) .command( - `shots `, - `Analyzes shot angles in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.`, + 'shots ', + 'Analyzes shot angles in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.', {}, opts => analyzeShots(opts.gcsUri) ) .command( - `labels-gcs `, - `Labels objects in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.`, + 'labels-gcs ', + 'Labels objects in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.', {}, opts => analyzeLabelsGCS(opts.gcsUri) ) .command( - `labels-file `, - `Labels objects in a video stored locally using the Cloud Video Intelligence API.`, + 'labels-file ', + 'Labels objects in a video stored locally using the Cloud Video Intelligence API.', {}, opts => analyzeLabelsLocal(opts.filePath) ) .command( - `safe-search `, - `Detects explicit content in a video stored in Google Cloud Storage.`, + 'safe-search ', + 'Detects explicit content in a video stored in Google Cloud Storage.', {}, opts => analyzeSafeSearch(opts.gcsUri) ) .command( - `transcription `, - `Extract the video transcription using the Cloud Video Intelligence API.`, + 'transcription ', + 'Extract the video transcription using the Cloud Video Intelligence API.', {}, opts => analyzeVideoTranscription(opts.gcsUri) ) .command( - `video-text-gcs `, - `Analyzes text in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.`, + 'video-text-gcs ', + 'Analyzes text in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.', {}, opts => analyzeTextGCS(opts.gcsUri) ) .command( - `track-objects-gcs `, - `Analyzes objects in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.`, + 'track-objects-gcs ', + 'Analyzes objects in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.', {}, opts => analyzeObjectTrackingGCS(opts.gcsUri) ) .command( - `video-text `, - `Analyzes text in a video stored in a local file using the Cloud Video Intelligence API.`, + 'video-text ', + 'Analyzes text in a video stored in a local file using the Cloud Video Intelligence API.', {}, opts => analyzeText(opts.path) ) .command( - `track-objects `, - `Analyzes objects in a video stored in a local file using the Cloud Video Intelligence API.`, + 'track-objects ', + 'Analyzes objects in a video stored in a local file using the Cloud Video Intelligence API.', {}, opts => analyzeObjectTracking(opts.path) ) - .example(`node $0 shots gs://cloud-samples-data/video/googlework_short.mp4`) - .example(`node $0 labels-gcs gs://cloud-samples-data/video/cat.mp4`) - .example(`node $0 labels-file googlework_short.mp4`) - .example(`node $0 safe-search gs://cloud-samples-data/video/googlework_short.mp4`) - .example(`node $0 transcription gs://cloud-samples-data/video/cat.mp4`) - .example(`node $0 video-text ./resources/googlework_short.mp4`) + .example('node $0 shots gs://cloud-samples-data/video/googlework_short.mp4') + .example('node $0 labels-gcs gs://cloud-samples-data/video/cat.mp4') + .example('node $0 labels-file googlework_short.mp4') .example( - `node $0 video-text-gcs gs://nodejs-docs-samples/video/googlework_short.mp4` + 'node $0 safe-search gs://cloud-samples-data/video/googlework_short.mp4' ) - .example(`node $0 track-objects ./resources/googlework_short.mp4`) - .example(`node $0 track-objects-gcs gs://nodejs-docs-samples/video/cat.mp4`) + .example('node $0 transcription gs://cloud-samples-data/video/cat.mp4') + .example('node $0 video-text ./resources/googlework_short.mp4') + .example( + 'node $0 video-text-gcs gs://nodejs-docs-samples/video/googlework_short.mp4' + ) + .example('node $0 track-objects ./resources/googlework_short.mp4') + .example('node $0 track-objects-gcs gs://nodejs-docs-samples/video/cat.mp4') .wrap(120) .recommendCommands() .epilogue( - `For more information, see https://cloud.google.com/video-intelligence/docs` + 'For more information, see https://cloud.google.com/video-intelligence/docs' ) .help() .strict().argv; diff --git a/video-intelligence/system-test/analyze-streaming-annotation-to-storage.test.js b/video-intelligence/system-test/analyze-streaming-annotation-to-storage.test.js index b94c317272..cf128e96af 100644 --- a/video-intelligence/system-test/analyze-streaming-annotation-to-storage.test.js +++ b/video-intelligence/system-test/analyze-streaming-annotation-to-storage.test.js @@ -19,7 +19,7 @@ const {assert} = require('chai'); const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node analyze-streaming-annotation-to-storage.js`; +const cmd = 'node analyze-streaming-annotation-to-storage.js'; const project = process.env.GCLOUD_PROJECT; const file = 'resources/googlework_short.mp4'; const outputUri = 'gs://' + project + '/VIDEO_STREAMING_OUTPUT'; diff --git a/video-intelligence/system-test/analyze-streaming-automl-classification.test.js b/video-intelligence/system-test/analyze-streaming-automl-classification.test.js index a17f7230cd..18ccd6b752 100644 --- a/video-intelligence/system-test/analyze-streaming-automl-classification.test.js +++ b/video-intelligence/system-test/analyze-streaming-automl-classification.test.js @@ -20,8 +20,8 @@ const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node analyze-streaming-automl-classification.js`; -const modelId = `VCN3094808572840640512`; +const cmd = 'node analyze-streaming-automl-classification.js'; +const modelId = 'VCN3094808572840640512'; const project = process.env.GCLOUD_PROJECT; const file = 'resources/googlework_short.mp4'; diff --git a/video-intelligence/system-test/analyze-streaming-labels.test.js b/video-intelligence/system-test/analyze-streaming-labels.test.js index 5365e1c4ff..b174bc8f8f 100644 --- a/video-intelligence/system-test/analyze-streaming-labels.test.js +++ b/video-intelligence/system-test/analyze-streaming-labels.test.js @@ -20,7 +20,7 @@ const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node analyze-streaming-labels.js`; +const cmd = 'node analyze-streaming-labels.js'; const file = 'resources/googlework_short.mp4'; describe('streaming label', () => { diff --git a/video-intelligence/system-test/analyze-streaming-object.test.js b/video-intelligence/system-test/analyze-streaming-object.test.js index e115d07282..d78c340671 100644 --- a/video-intelligence/system-test/analyze-streaming-object.test.js +++ b/video-intelligence/system-test/analyze-streaming-object.test.js @@ -20,7 +20,7 @@ const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node analyze-streaming-object.js`; +const cmd = 'node analyze-streaming-object.js'; const file = 'resources/googlework_short.mp4'; describe('streaming object', () => { diff --git a/video-intelligence/system-test/analyze-streaming-safe-search.test.js b/video-intelligence/system-test/analyze-streaming-safe-search.test.js index a193fd2925..d1fd894a1c 100644 --- a/video-intelligence/system-test/analyze-streaming-safe-search.test.js +++ b/video-intelligence/system-test/analyze-streaming-safe-search.test.js @@ -19,7 +19,7 @@ const {assert} = require('chai'); const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node analyze-streaming-safe-search.js`; +const cmd = 'node analyze-streaming-safe-search.js'; const file = 'resources/googlework_short.mp4'; describe('streaming safe search', () => { diff --git a/video-intelligence/system-test/analyze-streaming-shot-change.test.js b/video-intelligence/system-test/analyze-streaming-shot-change.test.js index 99d6b34e19..1b81a9e95f 100644 --- a/video-intelligence/system-test/analyze-streaming-shot-change.test.js +++ b/video-intelligence/system-test/analyze-streaming-shot-change.test.js @@ -20,7 +20,7 @@ const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node analyze-streaming-shot-change.js`; +const cmd = 'node analyze-streaming-shot-change.js'; const file = 'resources/googlework_short.mp4'; describe('streaming shot change', () => { diff --git a/video-intelligence/system-test/analyze_face_detection.test.js b/video-intelligence/system-test/analyze_face_detection.test.js index 88505c42a9..257562bdc5 100644 --- a/video-intelligence/system-test/analyze_face_detection.test.js +++ b/video-intelligence/system-test/analyze_face_detection.test.js @@ -20,7 +20,7 @@ const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node analyze_face_detection.js`; +const cmd = 'node analyze_face_detection.js'; const file = 'resources/googlework_short.mp4'; describe('analyzing faces in video', () => { diff --git a/video-intelligence/system-test/analyze_face_detection_gcs.test.js b/video-intelligence/system-test/analyze_face_detection_gcs.test.js index 7e928509b8..e5ef77b045 100644 --- a/video-intelligence/system-test/analyze_face_detection_gcs.test.js +++ b/video-intelligence/system-test/analyze_face_detection_gcs.test.js @@ -20,7 +20,7 @@ const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node analyze_face_detection_gcs.js`; +const cmd = 'node analyze_face_detection_gcs.js'; const gcsUri = 'gs://cloud-samples-data/video/googlework_short.mp4'; describe('analyzing faces in video', () => { diff --git a/video-intelligence/system-test/analyze_person_detection.test.js b/video-intelligence/system-test/analyze_person_detection.test.js index 6573049a6e..ebfce8eaad 100644 --- a/video-intelligence/system-test/analyze_person_detection.test.js +++ b/video-intelligence/system-test/analyze_person_detection.test.js @@ -20,7 +20,7 @@ const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node analyze_person_detection.js`; +const cmd = 'node analyze_person_detection.js'; const file = 'resources/googlework_short.mp4'; describe('analyzing people in video', () => { diff --git a/video-intelligence/system-test/analyze_person_detection_gcs.test.js b/video-intelligence/system-test/analyze_person_detection_gcs.test.js index 68c8d1acac..195154caf7 100644 --- a/video-intelligence/system-test/analyze_person_detection_gcs.test.js +++ b/video-intelligence/system-test/analyze_person_detection_gcs.test.js @@ -20,7 +20,7 @@ const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node analyze_person_detection_gcs.js`; +const cmd = 'node analyze_person_detection_gcs.js'; const gcsUri = 'gs://cloud-samples-data/video/googlework_short.mp4'; describe('analyzing people in video', () => { diff --git a/video-intelligence/system-test/detect_logo.test.js b/video-intelligence/system-test/detect_logo.test.js index 14660fb02c..c19d52fe74 100644 --- a/video-intelligence/system-test/detect_logo.test.js +++ b/video-intelligence/system-test/detect_logo.test.js @@ -20,7 +20,7 @@ const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node detect_logo.js`; +const cmd = 'node detect_logo.js'; const file = 'resources/googlework_short.mp4'; describe('analyzing logos in video', () => { diff --git a/video-intelligence/system-test/detect_logo_gcs.test.js b/video-intelligence/system-test/detect_logo_gcs.test.js index 1591eccd77..bf3fe9d8c9 100644 --- a/video-intelligence/system-test/detect_logo_gcs.test.js +++ b/video-intelligence/system-test/detect_logo_gcs.test.js @@ -20,7 +20,7 @@ const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -const cmd = `node detect_logo_gcs.js`; +const cmd = 'node detect_logo_gcs.js'; const file = 'gs://cloud-samples-data/video/googlework_short.mp4'; describe('analyzing logos in video on gcs', () => {