From ddb1901507c5baa10a3a98f3c79b1184aa13bd36 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" Date: Mon, 19 Nov 2018 23:52:20 +0000 Subject: [PATCH 1/6] chore(deps): update dependency @types/node to ~10.12.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 48fda90a..61e2bdd8 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@types/mocha": "^5.0.0", "@types/ncp": "^2.0.1", "@types/nock": "^9.1.0", - "@types/node": "~10.10.0", + "@types/node": "~10.12.0", "@types/once": "^1.4.0", "@types/p-limit": "^2.0.0", "@types/pify": "^3.0.2", From 39a9d500bafd05054107040ab5c1f67cd83e970f Mon Sep 17 00:00:00 2001 From: Dominic Kramer Date: Mon, 19 Nov 2018 16:22:07 -0800 Subject: [PATCH 2/6] chore: address type changes --- src/agent/state/legacy-state.ts | 17 +++++++++++++++-- src/agent/util/utils.ts | 2 +- src/agent/v8/legacy-debugapi.ts | 10 ++++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/agent/state/legacy-state.ts b/src/agent/state/legacy-state.ts index bd64f867..29302bf1 100644 --- a/src/agent/state/legacy-state.ts +++ b/src/agent/state/legacy-state.ts @@ -67,6 +67,17 @@ export function evaluate(expression: string, frame: v8.FrameMirror): } } +interface ScopeType { + Global: {}; + Script: {}; + Closure: {}; + Local: {} +} + +interface LegacyVm { + runInDebugContext: (context: String) => ScopeType; +} + class StateResolver { private state: v8.ExecutionState; private expressions: string[]; @@ -77,7 +88,7 @@ class StateResolver { private messageTable: stackdriver.Variable[]; private resolvedVariableTable: stackdriver.Variable[]; private rawVariableTable: Array; - private scopeType: {Global: {}, Script: {}, Closure: {}, Local: {}}; + private scopeType: ScopeType; /** * @param {!Object} execState * @param {Array} expressions @@ -126,7 +137,9 @@ class StateResolver { return null; }); - this.scopeType = vm.runInDebugContext('ScopeType'); + // This constructor is only used in situations where the legacy vm + // interface is used that has the `runInDebugContext` method. + this.scopeType = (vm as {} as LegacyVm).runInDebugContext('ScopeType'); } diff --git a/src/agent/util/utils.ts b/src/agent/util/utils.ts index a5f1e140..bf95a967 100644 --- a/src/agent/util/utils.ts +++ b/src/agent/util/utils.ts @@ -179,7 +179,7 @@ export function setErrorStatusAndCallback( fn: (err: Error|null) => void, breakpoint: stackdriver.Breakpoint, refersTo: stackdriver.Reference, message: string): void { const error = new Error(message); - return setImmediate(() => { + setImmediate(() => { if (breakpoint && !breakpoint.status) { breakpoint.status = new StatusMessage(refersTo, message, true); } diff --git a/src/agent/v8/legacy-debugapi.ts b/src/agent/v8/legacy-debugapi.ts index d5819f53..b5fbd3be 100644 --- a/src/agent/v8/legacy-debugapi.ts +++ b/src/agent/v8/legacy-debugapi.ts @@ -43,6 +43,10 @@ export class V8BreakpointData { public compile: null|((src: string) => string)) {} } +interface LegacyVm { + runInDebugContext: (context: string) => v8.Debug; +} + export class V8DebugApi implements debugapi.DebugApi { breakpoints: {[id: string]: V8BreakpointData} = {}; sourcemapper: SourceMapper; @@ -63,7 +67,9 @@ export class V8DebugApi implements debugapi.DebugApi { logger: consoleLogLevel.Logger, config: ResolvedDebugAgentConfig, jsFiles: ScanStats, sourcemapper: SourceMapper) { this.sourcemapper = sourcemapper; - this.v8 = vm.runInDebugContext('Debug'); + // This constructor is only used in situations where the legacy vm + // interface is used that has the `runInDebugContext` method. + this.v8 = (vm as {} as LegacyVm).runInDebugContext('Debug'); this.config = config; this.fileStats = jsFiles; this.v8Version = /(\d+\.\d+\.\d+)\.\d+/.exec(process.versions.v8); @@ -158,7 +164,7 @@ export class V8DebugApi implements debugapi.DebugApi { this.logger.info('deactivating v8 breakpoint listener'); this.v8.setListener(null); } - return setImmediate(() => { + setImmediate(() => { cb(null); }); } From 8523c4922340b9a55bc0123c9fd7bf967c697157 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 19 Nov 2018 18:15:46 -0800 Subject: [PATCH 3/6] refactor: remove a few unused dependencies (#584) --- package.json | 17 ++--------------- src/agent/debuglet.ts | 3 +-- src/agent/io/sourcemapper.ts | 4 ++-- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 48fda90a..5f343cb5 100644 --- a/package.json +++ b/package.json @@ -26,46 +26,33 @@ "@types/console-log-level": "^1.4.0", "@types/estree": "0.0.39", "@types/extend": "^3.0.0", - "@types/glob": "^7.0.0", "@types/lodash": "^4.14.69", "@types/mkdirp": "^0.5.1", "@types/mocha": "^5.0.0", "@types/ncp": "^2.0.1", "@types/nock": "^9.1.0", "@types/node": "~10.10.0", - "@types/once": "^1.4.0", "@types/p-limit": "^2.0.0", "@types/pify": "^3.0.2", "@types/proxyquire": "^1.3.28", "@types/request": "^2.47.1", - "@types/rimraf": "^2.0.2", "@types/semver": "^5.3.32", - "@types/tmp": "0.0.33", "changelog-maker": "^2.2.2", - "closure-npc": "*", "codecov": "^3.0.4", - "coveralls": "^3.0.0", "cross-env": "^5.2.0", - "glob": "^7.1.2", "gts": "^0.9.0", "intelli-espower-loader": "^1.0.1", - "istanbul": "^0.4.1", "js-green-licenses": "^0.5.0", "mkdirp": "^0.5.1", "mocha": "^5.0.0", "ncp": "^2.0.0", "nock": "^10.0.0", "nyc": "^13.1.0", - "once": "^1.4.0", - "pify": "^4.0.0", "post-install-check": "0.0.1", "proxyquire": "^2.0.0", "request": "^2.88.0", "require-inject": "^1.4.3", - "rimraf": "^2.6.2", "source-map-support": "^0.5.6", - "tmp": "0.0.33", - "tslint": "^5.4.3", "typescript": "~3.1.0" }, "dependencies": { @@ -78,11 +65,11 @@ "gcp-metadata": "^0.9.0", "lodash": "^4.12.0", "p-limit": "^2.0.0", + "pify": "^4.0.1", "semver": "^5.5.0", "source-map": "^0.6.1", "split": "^1.0.0", - "teeny-request": "^3.6.0", - "util.promisify": "^1.0.0" + "teeny-request": "^3.6.0" }, "scripts": { "changelog": "npm run compile && ./bin/run-changelog.sh", diff --git a/src/agent/debuglet.ts b/src/agent/debuglet.ts index f125deec..5aa70fc9 100644 --- a/src/agent/debuglet.ts +++ b/src/agent/debuglet.ts @@ -23,6 +23,7 @@ import * as fs from 'fs'; import * as metadata from 'gcp-metadata'; import * as _ from 'lodash'; import * as path from 'path'; +import * as promisify from 'pify'; import * as util from 'util'; import {Debug, PackageInfo} from '../client/stackdriver/debug'; @@ -39,8 +40,6 @@ import * as utils from './util/utils'; import * as debugapi from './v8/debugapi'; import {DebugApi} from './v8/debugapi'; -const promisify = require('util.promisify'); - const readFilep = promisify(fs.readFile); const ALLOW_EXPRESSIONS_MESSAGE = 'Expressions and conditions are not allowed' + diff --git a/src/agent/io/sourcemapper.ts b/src/agent/io/sourcemapper.ts index 1a8975dc..7200394f 100644 --- a/src/agent/io/sourcemapper.ts +++ b/src/agent/io/sourcemapper.ts @@ -17,12 +17,12 @@ import * as fs from 'fs'; import * as _ from 'lodash'; import * as path from 'path'; +import * as promisify from 'pify'; import * as sourceMap from 'source-map'; import {findScriptsFuzzy} from '../util/utils'; -const promisify = require('util.promisify'); -const pLimit = require('p-limit'); +import pLimit = require('p-limit'); const CONCURRENCY = 10; const readFilep = promisify(fs.readFile); From b613059f49fabf6da753da5d67182c0103d14909 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" Date: Mon, 19 Nov 2018 23:52:20 +0000 Subject: [PATCH 4/6] chore(deps): update dependency @types/node to ~10.12.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5f343cb5..3be000ff 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@types/mocha": "^5.0.0", "@types/ncp": "^2.0.1", "@types/nock": "^9.1.0", - "@types/node": "~10.10.0", + "@types/node": "~10.12.0", "@types/p-limit": "^2.0.0", "@types/pify": "^3.0.2", "@types/proxyquire": "^1.3.28", From bcd7afc84648c61a8f0d48c92f4b4332ea4c93d4 Mon Sep 17 00:00:00 2001 From: Dominic Kramer Date: Mon, 19 Nov 2018 16:22:07 -0800 Subject: [PATCH 5/6] chore: address type changes --- src/agent/state/legacy-state.ts | 17 +++++++++++++++-- src/agent/util/utils.ts | 2 +- src/agent/v8/legacy-debugapi.ts | 10 ++++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/agent/state/legacy-state.ts b/src/agent/state/legacy-state.ts index bd64f867..29302bf1 100644 --- a/src/agent/state/legacy-state.ts +++ b/src/agent/state/legacy-state.ts @@ -67,6 +67,17 @@ export function evaluate(expression: string, frame: v8.FrameMirror): } } +interface ScopeType { + Global: {}; + Script: {}; + Closure: {}; + Local: {} +} + +interface LegacyVm { + runInDebugContext: (context: String) => ScopeType; +} + class StateResolver { private state: v8.ExecutionState; private expressions: string[]; @@ -77,7 +88,7 @@ class StateResolver { private messageTable: stackdriver.Variable[]; private resolvedVariableTable: stackdriver.Variable[]; private rawVariableTable: Array; - private scopeType: {Global: {}, Script: {}, Closure: {}, Local: {}}; + private scopeType: ScopeType; /** * @param {!Object} execState * @param {Array} expressions @@ -126,7 +137,9 @@ class StateResolver { return null; }); - this.scopeType = vm.runInDebugContext('ScopeType'); + // This constructor is only used in situations where the legacy vm + // interface is used that has the `runInDebugContext` method. + this.scopeType = (vm as {} as LegacyVm).runInDebugContext('ScopeType'); } diff --git a/src/agent/util/utils.ts b/src/agent/util/utils.ts index a5f1e140..bf95a967 100644 --- a/src/agent/util/utils.ts +++ b/src/agent/util/utils.ts @@ -179,7 +179,7 @@ export function setErrorStatusAndCallback( fn: (err: Error|null) => void, breakpoint: stackdriver.Breakpoint, refersTo: stackdriver.Reference, message: string): void { const error = new Error(message); - return setImmediate(() => { + setImmediate(() => { if (breakpoint && !breakpoint.status) { breakpoint.status = new StatusMessage(refersTo, message, true); } diff --git a/src/agent/v8/legacy-debugapi.ts b/src/agent/v8/legacy-debugapi.ts index d5819f53..b5fbd3be 100644 --- a/src/agent/v8/legacy-debugapi.ts +++ b/src/agent/v8/legacy-debugapi.ts @@ -43,6 +43,10 @@ export class V8BreakpointData { public compile: null|((src: string) => string)) {} } +interface LegacyVm { + runInDebugContext: (context: string) => v8.Debug; +} + export class V8DebugApi implements debugapi.DebugApi { breakpoints: {[id: string]: V8BreakpointData} = {}; sourcemapper: SourceMapper; @@ -63,7 +67,9 @@ export class V8DebugApi implements debugapi.DebugApi { logger: consoleLogLevel.Logger, config: ResolvedDebugAgentConfig, jsFiles: ScanStats, sourcemapper: SourceMapper) { this.sourcemapper = sourcemapper; - this.v8 = vm.runInDebugContext('Debug'); + // This constructor is only used in situations where the legacy vm + // interface is used that has the `runInDebugContext` method. + this.v8 = (vm as {} as LegacyVm).runInDebugContext('Debug'); this.config = config; this.fileStats = jsFiles; this.v8Version = /(\d+\.\d+\.\d+)\.\d+/.exec(process.versions.v8); @@ -158,7 +164,7 @@ export class V8DebugApi implements debugapi.DebugApi { this.logger.info('deactivating v8 breakpoint listener'); this.v8.setListener(null); } - return setImmediate(() => { + setImmediate(() => { cb(null); }); } From 1082a2647e181f48e4f710a44df14452284e130e Mon Sep 17 00:00:00 2001 From: Dominic Kramer Date: Tue, 20 Nov 2018 10:48:10 -0800 Subject: [PATCH 6/6] chore: run `gts fix` --- src/agent/state/legacy-state.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agent/state/legacy-state.ts b/src/agent/state/legacy-state.ts index 29302bf1..0099560e 100644 --- a/src/agent/state/legacy-state.ts +++ b/src/agent/state/legacy-state.ts @@ -71,11 +71,11 @@ interface ScopeType { Global: {}; Script: {}; Closure: {}; - Local: {} + Local: {}; } interface LegacyVm { - runInDebugContext: (context: String) => ScopeType; + runInDebugContext: (context: string) => ScopeType; } class StateResolver {