Skip to content

Commit

Permalink
feat!: drop node8 support, support for async iterators (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-fenster committed Apr 2, 2020
1 parent e4d9506 commit 2834e93
Show file tree
Hide file tree
Showing 49 changed files with 10,243 additions and 4,628 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts"
}
15 changes: 0 additions & 15 deletions .eslintrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [8, 10, 12, 13]
node: [10, 12, 13]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand Down
8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

17 changes: 17 additions & 0 deletions .prettierrc.js
@@ -0,0 +1,17 @@
// 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
//
// 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.

module.exports = {
...require('gts/.prettierrc.json')
}
10 changes: 6 additions & 4 deletions package.json
Expand Up @@ -51,7 +51,7 @@
"dot-prop": "^5.0.0",
"escape-string-regexp": "^2.0.0",
"extend": "^3.0.2",
"google-gax": "^1.14.2",
"google-gax": "^2.0.1",
"is": "^3.0.1",
"is-utf8": "^0.2.1",
"lodash.snakecase": "^4.1.1",
Expand All @@ -63,6 +63,7 @@
"through2": "^3.0.0"
},
"devDependencies": {
"@grpc/grpc-js": "^0.7.5",
"@types/escape-string-regexp": "^1.0.0",
"@types/extend": "^3.0.1",
"@types/is": "0.0.21",
Expand All @@ -82,7 +83,8 @@
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.2",
"gts": "^1.1.2",
"google-auth-library": "^6.0.0",
"gts": "2.0.0-alpha.9",
"jsdoc": "^3.6.3",
"jsdoc-fresh": "^1.0.2",
"jsdoc-region-tag": "^1.0.4",
Expand All @@ -97,9 +99,9 @@
"power-assert": "^1.6.1",
"prettier": "^1.19.1",
"proxyquire": "^2.0.0",
"sinon": "^9.0.0",
"sinon": "^9.0.1",
"ts-loader": "^6.2.1",
"typescript": "^3.7.0",
"typescript": "^3.8.3",
"uuid": "^7.0.0",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11"
Expand Down
54 changes: 27 additions & 27 deletions samples/instances.js
Expand Up @@ -21,14 +21,14 @@ async function runInstanceOperations(instanceID, clusterID) {
const bigtable = Bigtable();
const instance = bigtable.instance(instanceID);

console.log(`Check Instance Exists`);
console.log('Check Instance Exists');
// [START bigtable_check_instance_exists]
const [instanceExists] = await instance.exists();
// [END bigtable_check_instance_exists]

// Create instance if does not exists
if (!instanceExists) {
console.log(`Creating a PRODUCTION Instance`);
console.log('Creating a PRODUCTION Instance');
// [START bigtable_create_prod_instance]
// Creates a Production Instance with the ID "ssd-instance"
// with cluster id "ssd-cluster", 3 nodes and location us-central1-f
Expand All @@ -55,7 +55,7 @@ async function runInstanceOperations(instanceID, clusterID) {
}

console.log(); //for just a new-line
console.log(`Listing Instances:`);
console.log('Listing Instances:');
// [START bigtable_list_instances]
const [instances] = await bigtable.getInstances();
instances.forEach(instance => {
Expand All @@ -64,15 +64,15 @@ async function runInstanceOperations(instanceID, clusterID) {
// [END bigtable_list_instances]

console.log(); //for just a new-line
console.log(`Get Instance`);
console.log('Get Instance');
// [START bigtable_get_instance]
const [instances2] = await bigtable.instance(instanceID).get();
console.log(`Instance ID: ${instances2.id}`);
console.log(`Instance Meta: ${JSON.stringify(instances2.metadata)}`);
// [END bigtable_get_instance]

console.log(); //for just a new-line
console.log(`Listing Clusters...`);
console.log('Listing Clusters...');
// [START bigtable_get_clusters]
const instance3 = bigtable.instance(instanceID);
const [clusters] = await instance3.getClusters();
Expand All @@ -90,7 +90,7 @@ async function createDevInstance(instanceID, clusterID) {

// [START bigtable_create_dev_instance]
console.log(); //for just a new-line
console.log(`Creating a DEVELOPMENT Instance`);
console.log('Creating a DEVELOPMENT Instance');
// Set options to create an Instance
const options = {
clusters: [
Expand Down Expand Up @@ -118,7 +118,7 @@ async function deleteInstance(instanceID) {

console.log(); //for just a new-line
// [START bigtable_delete_instance]
console.log(`Deleting Instance`);
console.log('Deleting Instance');
await instance.delete();
console.log(`Instance deleted: ${instance.id}`);
// [END bigtable_delete_instance]
Expand All @@ -130,7 +130,7 @@ async function addCluster(instanceID, clusterID) {
const instance = bigtable.instance(instanceID);
const [instanceExists] = await instance.exists();
if (!instanceExists) {
console.log(`Instance does not exists`);
console.log('Instance does not exists');
} else {
console.log(); //for just a new-line
console.log(`Adding Cluster to Instance ${instance.id}`);
Expand All @@ -155,58 +155,58 @@ async function deleteCluster(instanceID, clusterID) {

// [START bigtable_delete_cluster]
console.log(); //for just a new-line
console.log(`Deleting Cluster`);
console.log('Deleting Cluster');
await cluster.delete();
console.log(`Cluster deleted: ${cluster.id}`);
// [END bigtable_delete_cluster]
}

require(`yargs`)
require('yargs')
.demand(1)
.command(
`run`,
`Creates an Instance(type: PRODUCTION) and run basic instance-operations`,
'run',
'Creates an Instance(type: PRODUCTION) and run basic instance-operations',
{},
argv => runInstanceOperations(argv.instance, argv.cluster)
)
.example(
`node $0 run --instance [instanceID] --cluster [clusterID]`,
`Run instance operations`
'node $0 run --instance [instanceID] --cluster [clusterID]',
'Run instance operations'
)
.command(`dev-instance`, `Create Development Instance`, {}, argv =>
.command('dev-instance', 'Create Development Instance', {}, argv =>
createDevInstance(argv.instance, argv.cluster)
)
.example(
`node $0 dev-instance --instance [instanceID]`,
`Create Development Instance`
'node $0 dev-instance --instance [instanceID]',
'Create Development Instance'
)
.command(`del-instance`, `Delete the Instance`, {}, argv =>
.command('del-instance', 'Delete the Instance', {}, argv =>
deleteInstance(argv.instance)
)
.example(
`node $0 del-instance --instance [instanceID]`,
`Delete the Instance.`
'node $0 del-instance --instance [instanceID]',
'Delete the Instance.'
)
.command(`add-cluster`, `Add Cluster`, {}, argv =>
.command('add-cluster', 'Add Cluster', {}, argv =>
addCluster(argv.instance, argv.cluster)
)
.example(
`node $0 add-cluster --instance [instanceID] --cluster [clusterID]`,
`Add Cluster`
'node $0 add-cluster --instance [instanceID] --cluster [clusterID]',
'Add Cluster'
)
.command(`del-cluster`, `Delete the Cluster`, {}, argv =>
.command('del-cluster', 'Delete the Cluster', {}, argv =>
deleteCluster(argv.instance, argv.cluster)
)
.example(
`node $0 del-cluster --instance [instanceID] --cluster [clusterID]`,
`Delete the Cluster`
'node $0 del-cluster --instance [instanceID] --cluster [clusterID]',
'Delete the Cluster'
)
.wrap(120)
.nargs('instance', 1)
.nargs('cluster', 1)
.describe('instance', 'Cloud Bigtable Instance ID')
.describe('cluster', 'Cloud Bigtable Cluster ID')
.recommendCommands()
.epilogue(`For more information, see https://cloud.google.com/bigtable/docs`)
.epilogue('For more information, see https://cloud.google.com/bigtable/docs')
.help()
.strict().argv;
18 changes: 9 additions & 9 deletions samples/tableadmin.js
Expand Up @@ -29,7 +29,7 @@ async function runTableOperations(instanceID, tableID) {
console.log(`Table does not exist. Creating table ${tableID}`);
await table.create();
} else {
console.log(`Table exists.`);
console.log('Table exists.');
}

console.log();
Expand Down Expand Up @@ -228,22 +228,22 @@ async function deleteTable(instanceID, tableID) {
require('yargs')
.demand(1)
.command(
`run`,
`Create a table (if does not exist) and run basic table operations.`,
'run',
'Create a table (if does not exist) and run basic table operations.',
{},
argv => runTableOperations(argv.instance, argv.table)
)
.example(
`node $0 run --instance [instanceID] --table [tableID]`,
`Create a table (if does not exist) and run basic table operations.`
'node $0 run --instance [instanceID] --table [tableID]',
'Create a table (if does not exist) and run basic table operations.'
)
.wrap(120)
.command(`delete`, `Delete table.`, {}, argv =>
.command('delete', 'Delete table.', {}, argv =>
deleteTable(argv.instance, argv.table)
)
.example(
`node $0 delete --instance [instanceID] --table [tableID]`,
`Delete a table.`
'node $0 delete --instance [instanceID] --table [tableID]',
'Delete a table.'
)
.wrap(120)
.nargs('instance', 1)
Expand All @@ -252,6 +252,6 @@ require('yargs')
.describe('table', 'Cloud Bigtable Table ID')
.demandOption(['instance', 'table'])
.recommendCommands()
.epilogue(`For more information, see https://cloud.google.com/bigtable/docs`)
.epilogue('For more information, see https://cloud.google.com/bigtable/docs')
.help()
.strict().argv;
6 changes: 3 additions & 3 deletions samples/test/app-profile.js
Expand Up @@ -14,14 +14,14 @@

'use strict';

const uuid = require(`uuid`);
const uuid = require('uuid');
const {describe, it, before, after} = require('mocha');
const Bigtable = require(`@google-cloud/bigtable`);
const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();

const INSTANCE_ID = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules
const CLUSTER_ID = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules
const APP_PROFILE_ID = `my-app-profile`;
const APP_PROFILE_ID = 'my-app-profile';

const appProfileSnippets = require('./app-profile.js');

Expand Down
4 changes: 2 additions & 2 deletions samples/test/cluster.js
Expand Up @@ -14,9 +14,9 @@

'use strict';

const uuid = require(`uuid`);
const uuid = require('uuid');
const {describe, it, before, after} = require('mocha');
const Bigtable = require(`@google-cloud/bigtable`);
const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();

const INSTANCE_ID = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules
Expand Down
4 changes: 2 additions & 2 deletions samples/test/family.js
Expand Up @@ -14,9 +14,9 @@

'use strict';

const uuid = require(`uuid`);
const uuid = require('uuid');
const {describe, it, before, after} = require('mocha');
const Bigtable = require(`@google-cloud/bigtable`);
const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();

const INSTANCE_ID = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules
Expand Down
6 changes: 3 additions & 3 deletions samples/test/filters.js
Expand Up @@ -14,7 +14,7 @@

'use strict';

const uuid = require(`uuid`);
const uuid = require('uuid');
const snapshot = require('snap-shot-it');
const {assert} = require('chai');
const {describe, it, before, after} = require('mocha');
Expand All @@ -23,7 +23,7 @@ const {Bigtable} = require('@google-cloud/bigtable');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const INSTANCE_ID = `nodejs-bigtable-samples-keepme`;
const INSTANCE_ID = 'nodejs-bigtable-samples-keepme';
const TABLE_ID = `mobile-time-series-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules

describe('filters', async () => {
Expand Down Expand Up @@ -284,7 +284,7 @@ describe('filters', async () => {
const stdout = execSync(
`node filterSnippets ${INSTANCE_ID} ${TABLE_ID} filterBlockAll`
);
const result = ``;
const result = '';
assert.equal(stdout, result);
});

Expand Down
4 changes: 2 additions & 2 deletions samples/test/instance.js
Expand Up @@ -14,9 +14,9 @@

'use strict';

const uuid = require(`uuid`);
const uuid = require('uuid');
const {describe, it, after} = require('mocha');
const Bigtable = require(`@google-cloud/bigtable`);
const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();

const INSTANCE_ID = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules
Expand Down
4 changes: 2 additions & 2 deletions samples/test/reads.js
Expand Up @@ -14,15 +14,15 @@

'use strict';

const uuid = require(`uuid`);
const uuid = require('uuid');
const snapshot = require('snap-shot-it');
const {describe, it, before, after} = require('mocha');
const cp = require('child_process');
const {Bigtable} = require('@google-cloud/bigtable');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const INSTANCE_ID = `nodejs-bigtable-samples-keepme`;
const INSTANCE_ID = 'nodejs-bigtable-samples-keepme';
const TABLE_ID = `mobile-time-series-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules

describe('reads', async () => {
Expand Down

0 comments on commit 2834e93

Please sign in to comment.