Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 8de9032

Browse files
DominicKramerJustinBeckwith
authored andcommitted
chore(deps): upgrade to gts 1.0.0 (#681)
1 parent d36462e commit 8de9032

47 files changed

Lines changed: 4757 additions & 3485 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"changelog-maker": "^2.2.2",
4242
"codecov": "^3.0.4",
4343
"cross-env": "^5.2.0",
44-
"gts": "^0.9.0",
44+
"gts": "^1.0.0",
4545
"intelli-espower-loader": "^1.0.1",
4646
"js-green-licenses": "^0.5.0",
4747
"mkdirp": "^0.5.1",

src/agent/config.ts

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,19 @@
1616

1717
import {GoogleAuthOptions} from '@google-cloud/common';
1818

19-
export type DebugAgentConfig = GoogleAuthOptions&{
20-
[K in keyof ResolvedDebugAgentConfig]?: Partial<ResolvedDebugAgentConfig[K]>
21-
};
19+
export type DebugAgentConfig = GoogleAuthOptions &
20+
{
21+
[K in keyof ResolvedDebugAgentConfig]?: Partial<ResolvedDebugAgentConfig[K]>
22+
};
2223

23-
export type LogLevel = 'error'|'trace'|'debug'|'info'|'warn'|'fatal'|undefined;
24+
export type LogLevel =
25+
| 'error'
26+
| 'trace'
27+
| 'debug'
28+
| 'info'
29+
| 'warn'
30+
| 'fatal'
31+
| undefined;
2432
export interface Logger {
2533
error(...args: Array<{}>): void;
2634
trace(...args: Array<{}>): void;
@@ -41,14 +49,16 @@ export interface RepoId {
4149
}
4250

4351
export interface AliasContext {
44-
kind: 'ANY'|'FIXED'|'MOVABLE'|'OTHER';
52+
kind: 'ANY' | 'FIXED' | 'MOVABLE' | 'OTHER';
4553
name: string;
4654
}
4755

4856
export interface CloudRepoSourceContext {
4957
cloudRepo: {
50-
repoId: RepoId; revisionId: string;
51-
aliasName?: string; aliasContext: AliasContext;
58+
repoId: RepoId;
59+
revisionId: string;
60+
aliasName?: string;
61+
aliasContext: AliasContext;
5262
};
5363
}
5464

@@ -58,12 +68,13 @@ export interface CloudWorkspaceId {
5868
}
5969

6070
export interface CloudWorkspaceSourceContext {
61-
cloudWorkspace: {workspaceId: CloudWorkspaceId; snapshotId: string;};
71+
cloudWorkspace: {workspaceId: CloudWorkspaceId; snapshotId: string};
6272
}
6373

6474
export interface GerritSourceContext {
6575
gerrit: {
66-
hostUri: string; gerritProject: string;
76+
hostUri: string;
77+
gerritProject: string;
6778
// one of:
6879
revisionId?: string;
6980
aliasName?: string;
@@ -72,7 +83,7 @@ export interface GerritSourceContext {
7283
}
7384

7485
export interface GitSourceContext {
75-
git: {url: string; revisionId: string;};
86+
git: {url: string; revisionId: string};
7687
}
7788

7889
export interface ResolvedDebugAgentConfig extends GoogleAuthOptions {
@@ -150,8 +161,11 @@ export interface ResolvedDebugAgentConfig extends GoogleAuthOptions {
150161
* @link
151162
* https://cloud.google.com/debugger/api/reference/rest/v2/Debuggee#SourceContext
152163
*/
153-
sourceContext?: CloudRepoSourceContext|CloudWorkspaceSourceContext|
154-
GerritSourceContext|GitSourceContext;
164+
sourceContext?:
165+
| CloudRepoSourceContext
166+
| CloudWorkspaceSourceContext
167+
| GerritSourceContext
168+
| GitSourceContext;
155169

156170
/**
157171
* The path within your repository to the directory
@@ -211,9 +225,11 @@ export interface ResolvedDebugAgentConfig extends GoogleAuthOptions {
211225
* for example, the debug agent would know to set the breakpoint in
212226
* the `/x/y/src/index.js` file.
213227
*/
214-
pathResolver?:
215-
(scriptPath: string, knownFiles: string[],
216-
resolved: string[]) => string[] | undefined;
228+
pathResolver?: (
229+
scriptPath: string,
230+
knownFiles: string[],
231+
resolved: string[]
232+
) => string[] | undefined;
217233

218234
/**
219235
* agent log level 0-disabled, 1-error, 2-warn, 3-info, 4-debug
@@ -303,7 +319,8 @@ export interface ResolvedDebugAgentConfig extends GoogleAuthOptions {
303319
* These configuration options are for internal experimentation only.
304320
*/
305321
internal: {
306-
registerDelayOnFetcherErrorSec: number; maxRegistrationRetryDelay: number;
322+
registerDelayOnFetcherErrorSec: number;
323+
maxRegistrationRetryDelay: number;
307324
};
308325

309326
/**
@@ -336,31 +353,34 @@ export const defaultConfig: ResolvedDebugAgentConfig = {
336353

337354
// FIXME(ofrobots): today we prioritize GAE_MODULE_NAME/GAE_MODULE_VERSION
338355
// over the user specified config. We should reverse that.
339-
serviceContext:
340-
{service: undefined, version: undefined, minorVersion_: undefined},
356+
serviceContext: {
357+
service: undefined,
358+
version: undefined,
359+
minorVersion_: undefined,
360+
},
341361

342362
appPathRelativeToRepository: undefined,
343363
pathResolver: undefined,
344364
logLevel: 1,
345365
breakpointUpdateIntervalSec: 10,
346-
breakpointExpirationSec: 60 * 60 * 24, // 24 hours
366+
breakpointExpirationSec: 60 * 60 * 24, // 24 hours
347367

348368
capture: {
349369
includeNodeModules: false,
350370
maxFrames: 20,
351371
maxExpandFrames: 5,
352372
maxProperties: 10,
353373
maxDataSize: 20000,
354-
maxStringLength: 100
374+
maxStringLength: 100,
355375
},
356376

357377
log: {maxLogsPerSecond: 50, logDelaySeconds: 1, logFunction: console.log},
358378

359379
internal: {
360-
registerDelayOnFetcherErrorSec: 300, // 5 minutes.
361-
maxRegistrationRetryDelay: 40
380+
registerDelayOnFetcherErrorSec: 300, // 5 minutes.
381+
maxRegistrationRetryDelay: 40,
362382
},
363383

364384
forceNewAgent_: false,
365-
testMode_: false
385+
testMode_: false,
366386
};

src/agent/controller.ts

Lines changed: 66 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import {ServiceObject} from '@google-cloud/common';
2222
import * as assert from 'assert';
2323
import * as qs from 'querystring';
24-
import * as request from 'request'; // Only for type declarations.
24+
import * as request from 'request'; // Only for type declarations.
2525

2626
import {URL} from 'url';
2727

@@ -33,7 +33,7 @@ import * as stackdriver from '../types/stackdriver';
3333
const API = 'https://clouddebugger.googleapis.com/v2/controller';
3434

3535
export class Controller extends ServiceObject {
36-
private nextWaitToken: string|null;
36+
private nextWaitToken: string | null;
3737

3838
apiUrl: string;
3939

@@ -60,21 +60,28 @@ export class Controller extends ServiceObject {
6060
* @param {!function(?Error,Object=)} callback
6161
* @private
6262
*/
63-
register(debuggee: Debuggee, callback: (err: Error|null, result?: {
64-
debuggee: Debuggee
65-
}) => void): void {
63+
register(
64+
debuggee: Debuggee,
65+
callback: (
66+
err: Error | null,
67+
result?: {
68+
debuggee: Debuggee;
69+
}
70+
) => void
71+
): void {
6672
const options = {
6773
uri: this.apiUrl + '/debuggees/register',
6874
method: 'POST',
6975
json: true,
70-
body: {debuggee}
76+
body: {debuggee},
7177
};
7278
this.request(options, (err, body: {debuggee: Debuggee}, response) => {
7379
if (err) {
7480
callback(err);
7581
} else if (response!.statusCode !== 200) {
76-
callback(new Error(
77-
'unable to register, statusCode ' + response!.statusCode));
82+
callback(
83+
new Error('unable to register, statusCode ' + response!.statusCode)
84+
);
7885
} else if (!body.debuggee) {
7986
callback(new Error('invalid response body from server'));
8087
} else {
@@ -84,49 +91,59 @@ export class Controller extends ServiceObject {
8491
});
8592
}
8693

87-
8894
/**
8995
* Fetch the list of breakpoints from the server. Assumes we have registered.
9096
* @param {!function(?Error,Object=,Object=)} callback accepting (err, response,
9197
* body)
9298
*/
9399
listBreakpoints(
94-
debuggee: Debuggee,
95-
callback:
96-
(err: Error|null, response?: request.Response,
97-
body?: stackdriver.ListBreakpointsResponse) => void): void {
100+
debuggee: Debuggee,
101+
callback: (
102+
err: Error | null,
103+
response?: request.Response,
104+
body?: stackdriver.ListBreakpointsResponse
105+
) => void
106+
): void {
98107
const that = this;
99108
assert(debuggee.id, 'should have a registered debuggee');
100109
const query: stackdriver.ListBreakpointsQuery = {successOnTimeout: true};
101110
if (that.nextWaitToken) {
102111
query.waitToken = that.nextWaitToken;
103112
}
104113

105-
const uri = this.apiUrl + '/debuggees/' + encodeURIComponent(debuggee.id) +
106-
'/breakpoints?' + qs.stringify(query);
114+
const uri =
115+
this.apiUrl +
116+
'/debuggees/' +
117+
encodeURIComponent(debuggee.id) +
118+
'/breakpoints?' +
119+
qs.stringify(query);
107120
that.request(
108-
{uri, json: true},
109-
(err, body: stackdriver.ListBreakpointsResponse, response) => {
110-
if (!response) {
111-
callback(
112-
err || new Error('unknown error - request response missing'));
113-
return;
114-
} else if (response.statusCode === 404) {
115-
// The v2 API returns 404 (google.rpc.Code.NOT_FOUND) when the agent
116-
// registration expires. We should re-register.
117-
callback(null, response);
118-
return;
119-
} else if (response.statusCode !== 200) {
120-
callback(new Error(
121-
'unable to list breakpoints, status code ' +
122-
response.statusCode));
123-
return;
124-
} else {
125-
body = body || {};
126-
that.nextWaitToken = body.nextWaitToken;
127-
callback(null, response, body);
128-
}
129-
});
121+
{uri, json: true},
122+
(err, body: stackdriver.ListBreakpointsResponse, response) => {
123+
if (!response) {
124+
callback(
125+
err || new Error('unknown error - request response missing')
126+
);
127+
return;
128+
} else if (response.statusCode === 404) {
129+
// The v2 API returns 404 (google.rpc.Code.NOT_FOUND) when the agent
130+
// registration expires. We should re-register.
131+
callback(null, response);
132+
return;
133+
} else if (response.statusCode !== 200) {
134+
callback(
135+
new Error(
136+
'unable to list breakpoints, status code ' + response.statusCode
137+
)
138+
);
139+
return;
140+
} else {
141+
body = body || {};
142+
that.nextWaitToken = body.nextWaitToken;
143+
callback(null, response, body);
144+
}
145+
}
146+
);
130147
}
131148

132149
/**
@@ -136,19 +153,25 @@ export class Controller extends ServiceObject {
136153
* @param {!Function} callback accepting (err, body)
137154
*/
138155
updateBreakpoint(
139-
debuggee: Debuggee, breakpoint: stackdriver.Breakpoint,
140-
callback: (err?: Error, body?: {}) => void): void {
156+
debuggee: Debuggee,
157+
breakpoint: stackdriver.Breakpoint,
158+
callback: (err?: Error, body?: {}) => void
159+
): void {
141160
assert(debuggee.id, 'should have a registered debuggee');
142161

143162
breakpoint.action = 'CAPTURE';
144163
breakpoint.isFinalState = true;
145164
const options = {
146-
uri: this.apiUrl + '/debuggees/' + encodeURIComponent(debuggee.id) +
147-
// TODO: Address the case where `breakpoint.id` is `undefined`.
148-
'/breakpoints/' + encodeURIComponent(breakpoint.id as string),
165+
uri:
166+
this.apiUrl +
167+
'/debuggees/' +
168+
encodeURIComponent(debuggee.id) +
169+
// TODO: Address the case where `breakpoint.id` is `undefined`.
170+
'/breakpoints/' +
171+
encodeURIComponent(breakpoint.id as string),
149172
json: true,
150173
method: 'PUT',
151-
body: {debuggeeId: debuggee.id, breakpoint}
174+
body: {debuggeeId: debuggee.id, breakpoint},
152175
};
153176

154177
// We need to have a try/catch here because a JSON.stringify will be done

0 commit comments

Comments
 (0)