Skip to content

Commit

Permalink
refactor: drop dependency on nodejs-repo-tools (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Jun 24, 2019
1 parent c76fba9 commit ec0c3b5
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 112 deletions.
31 changes: 0 additions & 31 deletions .cloud-repo-tools.json

This file was deleted.

32 changes: 15 additions & 17 deletions README.md
Expand Up @@ -55,28 +55,26 @@ npm install @google-cloud/bigtable
### Using the client library

```javascript
// Imports the Google Cloud client library
const Bigtable = require('@google-cloud/bigtable');
// Imports the Google Cloud client library
const Bigtable = require('@google-cloud/bigtable');

async function quickstart(
INSTANCE_ID = 'my-instance', // ID of the Cloud Bigtable instance
TABLE_ID = 'my-table' // ID of the Cloud Bigtable table
) {
const bigtable = Bigtable();

// Connect to an existing instance:my-bigtable-instance
const instance = bigtable.instance(INSTANCE_ID);
async function quickstart() {
// Connect to an existing instance:my-bigtable-instance
const instance = bigtable.instance(INSTANCE_ID);

// Connect to an existing table:my-table
const table = instance.table(TABLE_ID);
// Connect to an existing table:my-table
const table = instance.table(TABLE_ID);

// Read a row from my-table using a row key
const [singleRow] = await table.row('r1').get();
// Read a row from my-table using a row key
const [singleRow] = await table.row('r1').get();

// Print the row key and data (column value, labels, timestamp)
const rowData = JSON.stringify(singleRow.data, null, 4);
console.log(`Row key: ${singleRow.id}\nData: ${rowData}`);
}
// Print the row key and data (column value, labels, timestamp)
const rowData = JSON.stringify(singleRow.data, null, 4);
console.log(`Row key: ${singleRow.id}\nData: ${rowData}`);
}
quickstart();

```

Expand All @@ -95,7 +93,7 @@ has instructions for running the samples.
| Write Batch | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeBatch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeBatch.js,samples/README.md) |
| Write Conditionally | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeConditionally.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeConditionally.js,samples/README.md) |
| Write Increment | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeIncrement.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeIncrement.js,samples/README.md) |
| Write Simple | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeSimple.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeSimple.js,samples/README.md) |
| Simple Insert | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeSimple.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeSimple.js,samples/README.md) |



Expand Down
2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -34,7 +34,6 @@
"predocs-test": "npm run docs",
"docs-test": "linkinator docs -r --skip www.googleapis.com",
"fix": "gts fix && npm run lintfix",
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json",
"lint": "eslint '**/*.js'",
"lintfix": "eslint --fix '**/*.js'",
"prepare": "npm run compile",
Expand Down Expand Up @@ -70,7 +69,6 @@
"through2": "^3.0.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"@types/escape-string-regexp": "^1.0.0",
"@types/extend": "^3.0.1",
"@types/is": "0.0.21",
Expand Down
16 changes: 9 additions & 7 deletions samples/README.md
Expand Up @@ -18,7 +18,7 @@
* [Write Batch](#write-batch)
* [Write Conditionally](#write-conditionally)
* [Write Increment](#write-increment)
* [Write Simple](#write-simple)
* [Simple Insert](#simple-insert)

## Before you begin

Expand Down Expand Up @@ -55,7 +55,7 @@ View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master
__Usage:__


`node quickstart.js`
`node quickstart.js <instanceId> <tableId>`


-----
Expand Down Expand Up @@ -89,7 +89,7 @@ View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master
__Usage:__


`node writeBatch.js`
`node writeBatch.js <instanceId>`


-----
Expand All @@ -106,7 +106,7 @@ View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master
__Usage:__


`node writeConditionally.js`
`node writeConditionally.js <instanceId>`


-----
Expand All @@ -123,15 +123,17 @@ View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master
__Usage:__


`node writeIncrement.js`
`node writeIncrement.js <instanceId>`


-----




### Write Simple
### Simple Insert

Insert a row into a table.

View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeSimple.js).

Expand All @@ -140,7 +142,7 @@ View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master
__Usage:__


`node writeSimple.js`
`node writeSimple.js <instanceId>`



Expand Down
4 changes: 1 addition & 3 deletions samples/package.json
Expand Up @@ -20,11 +20,9 @@
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"chai": "^4.2.0",
"doctoc": "^1.3.1",
"mocha": "^6.0.0"
},
"scripts": {
"doctoc": "doctoc README.md */README.md",
"test": "mocha system-test --timeout=60000"
"test": "mocha --timeout=60000"
}
}
37 changes: 22 additions & 15 deletions samples/quickstart.js
Expand Up @@ -15,30 +15,37 @@

'use strict';

// [START bigtable_quickstart]
// Imports the Google Cloud client library
const Bigtable = require('@google-cloud/bigtable');
// sample-metadata:
// title: Quickstart
// usage: node quickstart.js <instanceId> <tableId>

async function quickstart(
async function main(
INSTANCE_ID = 'my-instance', // ID of the Cloud Bigtable instance
TABLE_ID = 'my-table' // ID of the Cloud Bigtable table
) {
// [START bigtable_quickstart]
// Imports the Google Cloud client library
const Bigtable = require('@google-cloud/bigtable');

const bigtable = Bigtable();

// Connect to an existing instance:my-bigtable-instance
const instance = bigtable.instance(INSTANCE_ID);
async function quickstart() {
// Connect to an existing instance:my-bigtable-instance
const instance = bigtable.instance(INSTANCE_ID);

// Connect to an existing table:my-table
const table = instance.table(TABLE_ID);
// Connect to an existing table:my-table
const table = instance.table(TABLE_ID);

// Read a row from my-table using a row key
const [singleRow] = await table.row('r1').get();
// Read a row from my-table using a row key
const [singleRow] = await table.row('r1').get();

// Print the row key and data (column value, labels, timestamp)
const rowData = JSON.stringify(singleRow.data, null, 4);
console.log(`Row key: ${singleRow.id}\nData: ${rowData}`);
// Print the row key and data (column value, labels, timestamp)
const rowData = JSON.stringify(singleRow.data, null, 4);
console.log(`Row key: ${singleRow.id}\nData: ${rowData}`);
}
quickstart();
// [END bigtable_quickstart]
}
// [END bigtable_quickstart]

const args = process.argv.slice(2);
quickstart(...args).catch(console.error);
main(...args).catch(console.error);
2 changes: 0 additions & 2 deletions samples/tableadmin.js
Expand Up @@ -13,8 +13,6 @@
* limitations under the License.
*/

/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "apiResponse" }]*/

// Imports the Google Cloud client library
const Bigtable = require('@google-cloud/bigtable');

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -15,42 +15,36 @@

'use strict';

const path = require('path');
const assert = require('assert');
const tools = require('@google-cloud/nodejs-repo-tools');
const {assert} = require('chai');
const uuid = require('uuid');

const {execSync} = require('child_process');
const Bigtable = require('@google-cloud/bigtable');

const exec = cmd => execSync(cmd, {encoding: 'utf8'});

const bigtable = new Bigtable();
const clusterId = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules
const instanceId = `nodejs-bigtable-samples-${uuid.v4()}`.substr(0, 30); // Bigtable naming rules
const instance = bigtable.instance(instanceId);

const cwd = path.join(__dirname, '..');
const cmd = 'node instances.js';

before(async () => {
await instance.create({
clusters: [
{
id: clusterId,
location: 'us-central1-c',
nodes: 3,
},
],
describe('instances', () => {
before(async () => {
await instance.create({
clusters: [
{
id: clusterId,
location: 'us-central1-c',
nodes: 3,
},
],
});
});
});

after(async () => await instance.delete());
after(() => instance.delete());

it('should list zones', async () =>
await tools
.tryTest(async () => {
const output = await tools.runAsync(
`${cmd} run --instance ${instanceId}`,
cwd
);
assert(output.includes('Instances:'));
assert(output.includes(instanceId));
})
.start());
it('should list zones', () => {
const output = exec(`node instances.js run --instance ${instanceId}`);
assert.include(output, 'Instances:');
assert.include(output, instanceId);
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions samples/writeBatch.js
Expand Up @@ -15,6 +15,10 @@

'use strict';

// sample-metadata:
// title: Write Batch
// usage: node writeBatch.js <instanceId>

function main(instanceId = 'YOUR_INSTANCE_ID') {
// [START bigtable_writes_batch]
/**
Expand Down
4 changes: 4 additions & 0 deletions samples/writeConditionally.js
Expand Up @@ -15,6 +15,10 @@

'use strict';

// sample-metadata:
// title: Write Conditionally
// usage: node writeConditionally.js <instanceId>

function main(instanceId = 'YOUR_INSTANCE_ID') {
// [START bigtable_writes_conditional]
/**
Expand Down
4 changes: 4 additions & 0 deletions samples/writeIncrement.js
Expand Up @@ -15,6 +15,10 @@

'use strict';

// sample-metadata:
// title: Write Increment
// usage: node writeIncrement.js <instanceId>

function main(instanceId = 'YOUR_INSTANCE_ID') {
// [START bigtable_writes_increment]
/**
Expand Down
15 changes: 9 additions & 6 deletions samples/writeSimple.js
Expand Up @@ -15,18 +15,21 @@

'use strict';

// sample-metadata:
// title: Simple Insert
// description: Insert a row into a table.
// usage: node writeSimple.js <instanceId>

function main(instanceId = 'YOUR_INSTANCE_ID') {
// [START bigtable_writes_simple]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const instanceId = 'YOUR_INSTANCE_ID';

const Bigtable = require('@google-cloud/bigtable');

const bigtable = Bigtable();

async function writeSimple() {
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const instanceId = 'YOUR_INSTANCE_ID';
const instance = bigtable.instance(instanceId);
const table = instance.table('mobile-time-series');

Expand Down

0 comments on commit ec0c3b5

Please sign in to comment.