Skip to content

Commit

Permalink
Fix compilation after package updates
Browse files Browse the repository at this point in the history
Fix compilation after various package and type updates.

Speed up test flaky test.
  • Loading branch information
David Dooling committed Feb 9, 2021
1 parent 6040997 commit 5091d1a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 33 deletions.
9 changes: 4 additions & 5 deletions lib/internal/graph/graphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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")) {
Expand All @@ -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]);
Expand Down
10 changes: 5 additions & 5 deletions lib/internal/transport/express/ExpressServer.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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 => {
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/util/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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'");
Expand Down
4 changes: 0 additions & 4 deletions lib/project/fileGlobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/**";

Expand All @@ -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);
19 changes: 2 additions & 17 deletions test/project/support/AbstractProject.test.ts
Original file line number Diff line number Diff line change
@@ -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}",
Expand All @@ -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 });
Expand All @@ -42,7 +27,7 @@ describe("AbstractProject", () => {
assert(matches.length > 1);
assert(!matches.some(m => m.path.startsWith("node_modules")));

}).timeout(60000);
}).timeout(20000);

});

Expand Down

0 comments on commit 5091d1a

Please sign in to comment.