Skip to content

Commit b35ddd5

Browse files
Complete code migration (#18)
1 parent c3dceb8 commit b35ddd5

File tree

6 files changed

+85
-37
lines changed

6 files changed

+85
-37
lines changed

error-reporting/.eslintrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
rules:
3+
no-console: off

error-reporting/package.json

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,29 @@
44
"private": true,
55
"license": "Apache-2.0",
66
"author": "Google Inc.",
7-
"repository": {
8-
"type": "git",
9-
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
10-
},
7+
"repository": "googleapis/nodejs-error-reporting",
118
"engines": {
129
"node": ">=4.3.2"
1310
},
1411
"scripts": {
15-
"lint": "samples lint",
16-
"pretest": "npm run lint",
12+
"ava": "ava -T 20s --verbose test/*.test.js system-test/*.test.js",
13+
"cover": "nyc --reporter=lcov --cache ava -T 20s --verbose test/*.test.js system-test/*.test.js && nyc report",
1714
"error-test": "samples test app --msg \"Something broke!\" --url \"http://localhost:33332/error\" --port 33332 -- snippets.js express",
1815
"exception-test": "samples test app --code 500 --msg SyntaxError --url \"http://localhost:33333/exception\" --port 33333 -- snippets.js express",
1916
"system-test": "ava -T 1m --verbose system-test/*.test.js",
2017
"all-test": "npm run system-test && npm run error-test && npm run exception-test",
21-
"test": "samples test run --cmd npm -- run all-test"
18+
"test": "repo-tools test run --cmd npm -- run cover"
2219
},
2320
"dependencies": {
2421
"@google-cloud/error-reporting": "0.2.1",
2522
"express": "4.15.4",
2623
"yargs": "8.0.2"
2724
},
2825
"devDependencies": {
29-
"@google-cloud/nodejs-repo-tools": "1.4.17",
30-
"ava": "0.21.0",
26+
"@google-cloud/nodejs-repo-tools": "2.1.0",
27+
"ava": "0.23.0",
28+
"nyc": "11.2.1",
3129
"proxyquire": "1.8.0",
3230
"sinon": "3.2.0"
33-
},
34-
"cloud-repo-tools": {
35-
"requiresKeyFile": true,
36-
"requiresProjectId": true,
37-
"product": "error_reporting",
38-
"samples": [
39-
{
40-
"id": "snippets",
41-
"name": "Examples",
42-
"file": "snippets.js",
43-
"docs_link": "https://cloud.google.com/error-reporting/docs",
44-
"usage": "node snippets.js --help"
45-
}
46-
]
4731
}
4832
}

error-reporting/quickstart.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright 2017, Google, Inc.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
'use strict';
17+
18+
// eslint-disable-next-line no-unused-vars
19+
function quickstart() {
20+
// [START error_reporting_quickstart]
21+
// Imports the Google Cloud client library
22+
const ErrorReporting = require('@google-cloud/error-reporting');
23+
24+
// Instantiates a client
25+
const errors = ErrorReporting();
26+
27+
// Reports a simple error
28+
errors.report('Something broke!');
29+
// [END error_reporting_quickstart]
30+
}

error-reporting/snippets.js

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
'use strict';
1717

18-
function setupImplicit () {
18+
function setupImplicit() {
1919
// [START error_reporting_setup_implicit]
2020
// Imports the Google Cloud client library
2121
const ErrorReporting = require('@google-cloud/error-reporting');
@@ -28,23 +28,23 @@ function setupImplicit () {
2828
// [END error_reporting_setup_implicit]
2929
}
3030

31-
function setupExplicit () {
31+
function setupExplicit() {
3232
// [START error_reporting_setup_explicit]
3333
// Imports the Google Cloud client library
3434
const ErrorReporting = require('@google-cloud/error-reporting');
3535

3636
// Instantiates a client
3737
const errors = ErrorReporting({
3838
projectId: 'your-project-id',
39-
keyFilename: '/path/to/key.json'
39+
keyFilename: '/path/to/key.json',
4040
});
4141

4242
// Reports a simple error
4343
errors.report('Something broke!');
4444
// [END error_reporting_setup_explicit]
4545
}
4646

47-
function manual () {
47+
function manual() {
4848
// [START error_reporting_manual]
4949
// Imports the Google Cloud client library
5050
const ErrorReporting = require('@google-cloud/error-reporting');
@@ -76,7 +76,7 @@ function manual () {
7676
// [END error_reporting_manual]
7777
}
7878

79-
function express () {
79+
function express() {
8080
// [START error_reporting_express]
8181
const express = require('express');
8282

@@ -112,17 +112,43 @@ function express () {
112112
// The command-line program
113113
const cli = require(`yargs`)
114114
.demand(1)
115-
.command('setup-implicit', 'Reports a simple error using implicit credentials.', {}, setupImplicit)
116-
.command('setup-explicit', 'Reports a simple error using explicit credentials.', {}, setupExplicit)
115+
.command(
116+
'setup-implicit',
117+
'Reports a simple error using implicit credentials.',
118+
{},
119+
setupImplicit
120+
)
121+
.command(
122+
'setup-explicit',
123+
'Reports a simple error using explicit credentials.',
124+
{},
125+
setupExplicit
126+
)
117127
.command('manual', 'Manually reports errors.', {}, manual)
118-
.command('express', 'Starts and Express service with integrated error reporting.', {}, express)
119-
.example('node $0 setup-implicit', 'Reports a simple error using implicit credentials.')
120-
.example('node $0 setup-explicit', 'Reports a simple error using explicit credentials.')
128+
.command(
129+
'express',
130+
'Starts and Express service with integrated error reporting.',
131+
{},
132+
express
133+
)
134+
.example(
135+
'node $0 setup-implicit',
136+
'Reports a simple error using implicit credentials.'
137+
)
138+
.example(
139+
'node $0 setup-explicit',
140+
'Reports a simple error using explicit credentials.'
141+
)
121142
.example('node $0 manual', 'Manually report some errors.')
122-
.example('node $0 express', 'Starts and Express service with integrated error reporting.')
143+
.example(
144+
'node $0 express',
145+
'Starts and Express service with integrated error reporting.'
146+
)
123147
.wrap(120)
124148
.recommendCommands()
125-
.epilogue(`For more information, see https://cloud.google.com/error-reporting/docs`)
149+
.epilogue(
150+
`For more information, see https://cloud.google.com/error-reporting/docs`
151+
)
126152
.help()
127153
.strict();
128154

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
rules:
3+
node/no-unpublished-require: off
4+
node/no-unsupported-features: off
5+
no-empty: off

error-reporting/system-test/snippets.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ const cmd = `node snippets.js`;
2424

2525
test.before(tools.checkCredentials);
2626

27-
test.serial(`should setup using implicit credentials`, async (t) => {
27+
test.serial(`should setup using implicit credentials`, async t => {
2828
t.plan(0);
2929
// There's no output, the command should just succeed
3030
await tools.runAsync(`${cmd} setup-implicit`, cwd);
3131
});
3232

33-
test.serial(`should report errors manually`, async (t) => {
33+
test.serial(`should report errors manually`, async t => {
3434
const output = await tools.runAsync(`${cmd} manual`, cwd);
3535
t.is(output.includes('Done reporting error event!'), true);
3636
t.is(output.includes('Done reporting Error object!'), true);

0 commit comments

Comments
 (0)