Skip to content

Commit

Permalink
Make all dependencies explicit (#439)
Browse files Browse the repository at this point in the history
* Fix deps

* Explicit dependencies

* Update package.json
  • Loading branch information
ardatan authored Jan 27, 2020
1 parent ac3b489 commit 5071524
Show file tree
Hide file tree
Showing 40 changed files with 487 additions and 376 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"node": ">=10"
},
"lint-staged": {
"packages/**/*.{ts,tsx}": [
"packages/**/src/**/*.{ts,tsx}": [
"tslint --fix",
"git add"
],
Expand All @@ -36,6 +36,7 @@
"lerna": "3.20.2",
"lint-staged": "10.0.2",
"prettier": "1.19.1",
"typescript": "3.7.5",
"tslint": "5.20.1"
},
"workspaces": [
Expand Down
1 change: 1 addition & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"author": "Dotan Simha <dotansimha@gmail.com>",
"license": "MIT",
"scripts": {
"lint": "tslint src/**/*.ts",
"clean": "rimraf dist",
"prebuild": "yarn clean",
"build": "bob",
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/debug-log.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export function debugLog(...args: any[]): void {
if (process && process.env && process.env.DEBUG && !process.env.GQL_TOOLKIT_NODEBUG) {
// tslint:disable-next-line: no-console
console.log(...args);
}
}
13 changes: 10 additions & 3 deletions packages/common/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export function chainFunctions(funcs: any[]) {

export function isEqual<T>(a: T, b: T): boolean {
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) return false;
if (a.length !== b.length) {
return false;
}

for (var index = 0; index < a.length; index++) {
if (a[index] !== b[index]) {
Expand Down Expand Up @@ -64,6 +66,7 @@ export async function resolveBuiltinModule<Module>(moduleName: string, option?:
return await import(moduleName);
}
} catch (e) {
// tslint:disable-next-line: no-console
console.warn(`
${option || moduleName} module couldn't be found for built-in ${moduleName}.
Please provide a working module in your loader options!
Expand All @@ -74,8 +77,12 @@ export async function resolveBuiltinModule<Module>(moduleName: string, option?:
}

export function compareStrings<A, B>(a: A, b: B) {
if (a.toString() < b.toString()) return -1;
if (a.toString() > b.toString()) return 1;
if (a.toString() < b.toString()) {
return -1;
}
if (a.toString() > b.toString()) {
return 1;
}
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/common/tests/print-schema-with-directives.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ describe('printSchemaWithDirectives', () => {
expect(output).toContain('Test Query Comment');
expect(output).toContain('Test Field Comment');

})
});
});
3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"author": "Dotan Simha <dotansimha@gmail.com>",
"license": "MIT",
"scripts": {
"lint": "tslint src/**/*.ts",
"clean": "rimraf dist",
"prebuild": "yarn clean",
"build": "bob",
Expand All @@ -28,6 +29,7 @@
"devDependencies": {
"@ardatan/bob": "0.2.7",
"@types/is-glob": "4.0.1",
"@types/lodash": "4.14.149",
"@types/jest": "24.9.1",
"@types/valid-url": "1.0.2",
"graphql": "14.5.8",
Expand All @@ -46,6 +48,7 @@
"globby": "11.0.0",
"import-from": "^3.0.0",
"is-glob": "4.0.1",
"lodash": "4.17.15",
"resolve-from": "5.0.0",
"tslib": "1.10.0",
"unixify": "1.0.0",
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/load-typedefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@ async function getCustomLoaderByPath(path: string, cwd: string): Promise<any> {
function stringToHash(str: string) {
let hash = 0;

if (str.length == 0) return hash;
// tslint:disable-next-line: triple-equals
if (str.length == 0) {
return hash;
}

let char;
for (let i = 0; i < str.length; i++) {
char = str.charCodeAt(i);
// tslint:disable-next-line: no-bitwise
hash = (hash << 5) - hash + char;
// tslint:disable-next-line: no-bitwise
hash = hash & hash;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('documentsFromGlob', () => {
} catch (e) {
expect(e).toBeDefined();
}
})
});

it('Should ignore schema definitions', async () => {
const glob = join(__dirname, './test-files/', '*.graphql');
Expand All @@ -92,9 +92,9 @@ describe('documentsFromGlob', () => {
it('Should ignore files that is added to ignore glob (using options.ignore)', async () => {
const glob = join(__dirname, './test-files/', '*.graphql');
const ignoreGlob = join(__dirname, './test-files/', '*.query.graphql');
const result = await loadDocuments([glob], {
ignore: ignoreGlob,
loaders: [new GraphQLFileLoader()]
const result = await loadDocuments([glob], {
ignore: ignoreGlob,
loaders: [new GraphQLFileLoader()]
});
expect(result.length).toBe(1);
});
Expand All @@ -103,7 +103,7 @@ describe('documentsFromGlob', () => {
const glob = join(__dirname, './test-files/', '*.graphql');
const ignoreGlob = `!(${join(__dirname, './test-files/', '*.query.graphql')})`;
const result = await loadDocuments([glob, ignoreGlob], {
loaders: [new GraphQLFileLoader()]
loaders: [new GraphQLFileLoader()]
});
expect(result.length).toBe(1);
});
Expand All @@ -112,7 +112,7 @@ describe('documentsFromGlob', () => {
const glob = join(__dirname, './test-with-brackets/', '**/*.ts');
const result = await loadDocuments(glob, {
loaders: [new CodeFileLoader()],
})
});
expect(result.length).toBe(1);
});
});
14 changes: 7 additions & 7 deletions packages/core/tests/loaders/documents/import-documents.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { loadDocuments } from "@graphql-toolkit/core"
import { join } from "path"
import { GraphQLFileLoader } from "@graphql-toolkit/graphql-file-loader"
import { parse, print } from "graphql";
import { loadDocuments } from '@graphql-toolkit/core';
import { join } from 'path';
import { GraphQLFileLoader } from '@graphql-toolkit/graphql-file-loader';
import { parse, print } from 'graphql';
import '../../../../testing/to-be-similar-gql-doc';

describe('import in documents', () => {
Expand All @@ -28,7 +28,7 @@ describe('import in documents', () => {
baz
}
`);
})
});
it('should get documents with specific imports properly', async () => {
const [{ document }] = await loadDocuments(join(__dirname, './import-test/specific/a.graphql'), {
loaders: [new GraphQLFileLoader()]
Expand All @@ -50,5 +50,5 @@ describe('import in documents', () => {
baz
}
`);
})
})
});
});
Loading

0 comments on commit 5071524

Please sign in to comment.