diff --git a/lib/internal/graph/graphQL.ts b/lib/internal/graph/graphQL.ts index 4d4c440b1..f2e3db5b3 100644 --- a/lib/internal/graph/graphQL.ts +++ b/lib/internal/graph/graphQL.ts @@ -299,14 +299,14 @@ function inlineFragments(q: string, name: string, moduleDir: string, fragmentDir const content = fs.readFileSync(p.join(fragmentDir, f)).toString(); const graphql = gql(content); return { - name: (graphql.definitions[0]).name.value, - kind: (graphql.definitions[0]).kind, + name: (graphql.definitions[0] as any).name?.value, + kind: graphql.definitions[0].kind, body: content.slice(content.indexOf("{") + 1, content.lastIndexOf("}") - 1), }; }).filter(f => f.kind === "FragmentDefinition"); FragmentExpression.lastIndex = 0; - let result; + let result: RegExpExecArray; // tslint:disable-next-line:no-conditional-assignment while (result = FragmentExpression.exec(q)) { @@ -329,7 +329,6 @@ function locateAndLoadGraphql( ): string { let path = options.path; - const name = options.name; // Read subscription from file if given if (options.path) { if (!path.endsWith(".graphql")) { @@ -346,7 +345,7 @@ function locateAndLoadGraphql( const queries = fs.readdirSync(queryDir).filter(f => f.endsWith(".graphql")).filter(f => { const content = fs.readFileSync(p.join(queryDir, f)).toString(); const graphql = gql(content); - return (graphql.definitions[0]).name.value === options.name; + return (graphql.definitions[0] as any).name?.value === options.name; }); if (queries.length === 1) { path = p.join(queryDir, queries[0]); diff --git a/lib/internal/transport/express/ExpressServer.ts b/lib/internal/transport/express/ExpressServer.ts index fbc144f88..db1f4bac0 100644 --- a/lib/internal/transport/express/ExpressServer.ts +++ b/lib/internal/transport/express/ExpressServer.ts @@ -1,4 +1,4 @@ -import * as GitHubApi from "@octokit/rest"; +import { Octokit } from "@octokit/rest"; import * as bodyParser from "body-parser"; import * as express from "express"; import * as passport from "passport"; @@ -112,19 +112,19 @@ export class ExpressServer { this.exp.options(`${this.apiBase}/log/events`, cors()); this.exp.get(`${this.apiBase}/log/events`, cors(), this.adminRoute, this.authenticate, (req, res) => { - res.json(globals.eventStore().events(req.query.from)); + res.json(globals.eventStore().events(req.query.from as unknown as number)); }); this.exp.options(`${this.apiBase}/log/commands`, cors()); this.exp.get(`${this.apiBase}/log/commands`, cors(), this.adminRoute, this.authenticate, (req, res) => { - res.json(globals.eventStore().commands(req.query.from)); + res.json(globals.eventStore().commands(req.query.from as unknown as number)); }); this.exp.options(`${this.apiBase}/log/messages`, cors()); this.exp.get(`${this.apiBase}/log/messages`, cors(), this.adminRoute, this.authenticate, (req, res) => { - res.json(globals.eventStore().messages(req.query.from)); + res.json(globals.eventStore().messages(req.query.from as unknown as number)); }); this.exp.options(`${this.apiBase}/series/events`, cors()); @@ -242,7 +242,7 @@ export class ExpressServer { passReqToCallback: true, } as bearer.IStrategyOptions, (req, token, done) => { - const api = new GitHubApi(); + const api = new Octokit(); api.authenticate({ type: "token", token }); api.users.getAuthenticated({}) .then(user => { diff --git a/lib/internal/util/memory.ts b/lib/internal/util/memory.ts index 1ff25ee9d..da73e94e5 100644 --- a/lib/internal/util/memory.ts +++ b/lib/internal/util/memory.ts @@ -26,7 +26,7 @@ export function initMemoryMonitoring(dataDirectory: string = `${appRoot.path}/he * Create a head dump that can be downloaded and used to profile head usage. * @returns {string} */ -export function mtrace(): string { +export function mtrace(): void { try { logger.debug("Memory statistics '%j'", memoryUsage()); const mtrace = require("mtrace"); @@ -39,7 +39,7 @@ export function mtrace(): string { } broadcast({ type: "atomist:gc" }); broadcast({ type: "atomist:mtrace" }); - return name; + return; } catch (err) { logger.error("Failed to initialise mtrace. Required 'mtrace' module is missing or can't be" + " loaded. Please install with 'npm install --save mtrace'"); diff --git a/lib/project/fileGlobs.ts b/lib/project/fileGlobs.ts index 27b280159..4a76e5348 100644 --- a/lib/project/fileGlobs.ts +++ b/lib/project/fileGlobs.ts @@ -5,14 +5,12 @@ export const AllFiles = "**/**"; /** * Negative glob to exclude .git directory - * @type {string} */ export const ExcludeGit = "!.git/**"; /** * Negative glob to exclude node_modules directory. We nearly always want to exclude * this when handling node projects, for performance reasons. - * @type {string} */ export const ExcludeNodeModules = "!**/node_modules/**"; @@ -21,12 +19,10 @@ export const ExcludeTarget = "!target/**"; /** * Default exclusions (git and node modules). * Must be combined with a positive glob. - * @type {[string , string]} */ export const DefaultExcludes = [ExcludeGit, ExcludeNodeModules, ExcludeTarget]; /** * Include all files except with default exclusions (git and node modules) - * @type {[string , string , string]} */ export const DefaultFiles = [AllFiles].concat(DefaultExcludes); diff --git a/test/project/support/AbstractProject.test.ts b/test/project/support/AbstractProject.test.ts index e4f81195b..f8854ac5f 100644 --- a/test/project/support/AbstractProject.test.ts +++ b/test/project/support/AbstractProject.test.ts @@ -1,27 +1,12 @@ import * as assert from "assert"; import { GitHubRepoRef } from "../../../lib/operations/common/GitHubRepoRef"; -import { - AllFiles, - DefaultExcludes, - DefaultFiles, -} from "../../../lib/project/fileGlobs"; import { GitCommandGitProject } from "../../../lib/project/git/GitCommandGitProject"; -import { globMatchesWithin } from "../../../lib/project/support/AbstractProject"; import { spawnPromise } from "../../../lib/util/child_process"; describe("AbstractProject", () => { describe("globMatchesWithin", () => { - before(() => { - DefaultFiles.splice(1, DefaultFiles.length); - }); - - after(() => { - DefaultFiles.splice(0, DefaultFiles.length); - DefaultFiles.push(AllFiles, ...DefaultExcludes); - }); - it("should match ts pattern in nested folder", async () => { const patterns = [ "*.{d.ts,js,ts}{,.map}", @@ -32,7 +17,7 @@ describe("AbstractProject", () => { const p = await GitCommandGitProject.cloned(undefined, GitHubRepoRef.from({ owner: "atomist", - repo: "sdm-pack-build", + repo: "yaml-updater", } as any)); await spawnPromise("npm", ["ci"], { cwd: p.baseDir }); @@ -42,7 +27,7 @@ describe("AbstractProject", () => { assert(matches.length > 1); assert(!matches.some(m => m.path.startsWith("node_modules"))); - }).timeout(60000); + }).timeout(20000); });