diff --git a/.eslintcache b/.eslintcache deleted file mode 100644 index 62e78b2a..00000000 --- a/.eslintcache +++ /dev/null @@ -1 +0,0 @@ -[{"/Volumes/fast/Projects/chimp/src/commands/create.ts":"1","/Volumes/fast/Projects/chimp/src/commands/generate.ts":"2","/Volumes/fast/Projects/chimp/src/commands/init.ts":"3","/Volumes/fast/Projects/chimp/src/declarations.d.ts":"4","/Volumes/fast/Projects/chimp/src/generate/generate-module.ts":"5","/Volumes/fast/Projects/chimp/src/generate/helpers/execQuietly.ts":"6","/Volumes/fast/Projects/chimp/src/generate/helpers/findProjectMainPath.ts":"7","/Volumes/fast/Projects/chimp/src/generate/helpers/ListrHelper.ts":"8","/Volumes/fast/Projects/chimp/src/generate/helpers/saveRenderedTemplate.ts":"9","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/get-module-infos.spec.ts":"10","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/get-module-infos.ts":"11","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getFederatedEntities.spec.ts":"12","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getFederatedEntities.ts":"13","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getInterfaces.spec.ts":"14","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getInterfaces.ts":"15","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getModuleNames.spec.ts":"16","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getModuleNames.ts":"17","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getScalars.spec.ts":"18","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getScalars.ts":"19","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/parse-graphql.spec.ts":"20","/Volumes/fast/Projects/chimp/src/generate/parse-graphql/parse-graphql.ts":"21","/Volumes/fast/Projects/chimp/src/generate/templates/combineSchemas.ts":"22","/Volumes/fast/Projects/chimp/src/generate/templates/printSchema.ts":"23","/Volumes/fast/Projects/chimp/src/generate/templates/schema.ts":"24","/Volumes/fast/Projects/chimp/src/index.ts":"25","/Volumes/fast/Projects/chimp/src/init/assert-git-clean-state.ts":"26","/Volumes/fast/Projects/chimp/src/init/assert-module-path-in-top-level-src.spec.ts":"27","/Volumes/fast/Projects/chimp/src/init/assert-module-path-in-top-level-src.ts":"28","/Volumes/fast/Projects/chimp/src/scripts/end-to-end-test.ts":"29"},{"size":2642,"mtime":1611748464000,"results":"30","hashOfConfig":"31"},{"size":3104,"mtime":1611925279000,"results":"32","hashOfConfig":"31"},{"size":8182,"mtime":1611925279000,"results":"33","hashOfConfig":"31"},{"size":146,"mtime":1611838695000,"results":"34","hashOfConfig":"31"},{"size":18912,"mtime":1611925279000,"results":"35","hashOfConfig":"31"},{"size":731,"mtime":1611853009000,"results":"36","hashOfConfig":"31"},{"size":243,"mtime":1611748471000,"results":"37","hashOfConfig":"31"},{"size":1315,"mtime":1611925279000,"results":"38","hashOfConfig":"31"},{"size":829,"mtime":1611748339000,"results":"39","hashOfConfig":"31"},{"size":700,"mtime":1611834248000,"results":"40","hashOfConfig":"31"},{"size":562,"mtime":1611908845000,"results":"41","hashOfConfig":"31"},{"size":511,"mtime":1611747157000,"results":"42","hashOfConfig":"31"},{"size":591,"mtime":1611748275000,"results":"43","hashOfConfig":"31"},{"size":552,"mtime":1611747163000,"results":"44","hashOfConfig":"31"},{"size":298,"mtime":1611747177000,"results":"45","hashOfConfig":"31"},{"size":862,"mtime":1611747189000,"results":"46","hashOfConfig":"31"},{"size":456,"mtime":1611747534000,"results":"47","hashOfConfig":"31"},{"size":504,"mtime":1611747211000,"results":"48","hashOfConfig":"31"},{"size":255,"mtime":1611747231000,"results":"49","hashOfConfig":"31"},{"size":2975,"mtime":1611926282000,"results":"50","hashOfConfig":"31"},{"size":1449,"mtime":1611747676000,"results":"51","hashOfConfig":"31"},{"size":1605,"mtime":1611926244000,"results":"52","hashOfConfig":"31"},{"size":101,"mtime":1611926244000,"results":"53","hashOfConfig":"31"},{"size":518,"mtime":1611926244000,"results":"54","hashOfConfig":"31"},{"size":38,"mtime":1611926244000,"results":"55","hashOfConfig":"31"},{"size":1018,"mtime":1611846723000,"results":"56","hashOfConfig":"31"},{"size":397,"mtime":1611843260000,"results":"57","hashOfConfig":"31"},{"size":521,"mtime":1611833282000,"results":"58","hashOfConfig":"31"},{"size":1987,"mtime":1611926300000,"results":"59","hashOfConfig":"31"},{"filePath":"60","messages":"61","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"vqwgs4",{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","errorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"66","messages":"67","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"68","messages":"69","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"72","messages":"73","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"74","messages":"75","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"78","messages":"79","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"80","messages":"81","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"82","messages":"83","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"84","messages":"85","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"86","messages":"87","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"88","messages":"89","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"90","messages":"91","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"92","messages":"93","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"94","messages":"95","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"96","messages":"97","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"98","messages":"99","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"100","messages":"101","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"102","messages":"103","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"104","messages":"105","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"106","messages":"107","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"108","messages":"109","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"110","messages":"111","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"112","messages":"113","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"114","messages":"115","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"116","messages":"117","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Volumes/fast/Projects/chimp/src/commands/create.ts",[],"/Volumes/fast/Projects/chimp/src/commands/generate.ts",[],"/Volumes/fast/Projects/chimp/src/commands/init.ts",["118","119","120","121"],"/Volumes/fast/Projects/chimp/src/declarations.d.ts",[],"/Volumes/fast/Projects/chimp/src/generate/generate-module.ts",[],"/Volumes/fast/Projects/chimp/src/generate/helpers/execQuietly.ts",[],"/Volumes/fast/Projects/chimp/src/generate/helpers/findProjectMainPath.ts",[],"/Volumes/fast/Projects/chimp/src/generate/helpers/ListrHelper.ts",[],"/Volumes/fast/Projects/chimp/src/generate/helpers/saveRenderedTemplate.ts",["122"],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/get-module-infos.spec.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/get-module-infos.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getFederatedEntities.spec.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getFederatedEntities.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getInterfaces.spec.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getInterfaces.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getModuleNames.spec.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getModuleNames.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getScalars.spec.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/getScalars.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/parse-graphql.spec.ts",[],"/Volumes/fast/Projects/chimp/src/generate/parse-graphql/parse-graphql.ts",[],"/Volumes/fast/Projects/chimp/src/generate/templates/combineSchemas.ts",[],"/Volumes/fast/Projects/chimp/src/generate/templates/printSchema.ts",[],"/Volumes/fast/Projects/chimp/src/generate/templates/schema.ts",[],"/Volumes/fast/Projects/chimp/src/index.ts",[],"/Volumes/fast/Projects/chimp/src/init/assert-git-clean-state.ts",[],"/Volumes/fast/Projects/chimp/src/init/assert-module-path-in-top-level-src.spec.ts",[],"/Volumes/fast/Projects/chimp/src/init/assert-module-path-in-top-level-src.ts",[],"/Volumes/fast/Projects/chimp/src/scripts/end-to-end-test.ts",[],{"ruleId":"123","severity":1,"message":"124","line":65,"column":3,"nodeType":"125","endLine":65,"endColumn":44},{"ruleId":"123","severity":1,"message":"124","line":87,"column":3,"nodeType":"125","endLine":87,"endColumn":21},{"ruleId":"123","severity":1,"message":"124","line":92,"column":3,"nodeType":"125","endLine":92,"endColumn":28},{"ruleId":"123","severity":1,"message":"124","line":121,"column":5,"nodeType":"125","endLine":121,"endColumn":191},{"ruleId":"126","severity":1,"message":"127","line":15,"column":8,"nodeType":"128","messageId":"129","endLine":15,"endColumn":37},"no-warning-comments","Unexpected 'todo' comment.","Line","max-params","Function 'saveRenderedTemplate' has too many parameters (5). Maximum allowed is 4.","FunctionDeclaration","exceed"] \ No newline at end of file diff --git a/.gitignore b/.gitignore index 154e8542..d64fbdf0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /tmp node_modules .idea +.eslintcache diff --git a/src/commands/create.ts b/src/commands/create.ts index ebdee3ee..7bba47e3 100644 --- a/src/commands/create.ts +++ b/src/commands/create.ts @@ -3,6 +3,7 @@ import * as path from 'path'; // @ts-ignore import shelljs from 'shelljs'; import { Command, flags } from '@oclif/command'; +import { getChimpVersion } from '../helpers/get-chimp-version'; function updatePrefixes(appDirectory: string, appPrefix: string, generatedPrefix: string) { if (appPrefix || generatedPrefix) { @@ -29,6 +30,8 @@ function updatePrefixes(appDirectory: string, appPrefix: string, generatedPrefix `chimp generate${gqlGenerateCustomPrefixString}`, `${appDirectory}/package.json`, ); + const currentChimpVersion = getChimpVersion(); + shelljs.sed('-i', '"chimp": "latest"', `"chimp": "${currentChimpVersion}"`, `${appDirectory}/package.json`); } } diff --git a/src/commands/init.ts b/src/commands/init.ts index 441f4730..21ec02c7 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -8,6 +8,7 @@ import { findProjectMainPath } from '../generate/helpers/findProjectMainPath'; import { ListrRenderer, newTask } from '../generate/helpers/ListrHelper'; import { assertModulePathInTopLevelSrc } from '../init/assert-module-path-in-top-level-src'; import { assertGitCleanState } from '../init/assert-git-clean-state'; +import { getChimpVersion } from '../helpers/get-chimp-version'; const DEFAULT_MODULES_PATH = './src/modules'; const debug = configDebug('commands:init'); @@ -26,7 +27,7 @@ const addProjectDependencies = async (projectMainPath: string, modulesPath: stri chimpCommand = `${chimpCommand} -p ${modulesPath}`; // } packageJsonFile.scripts.chimp = chimpCommand; - packageJsonFile.devDependencies.chimp = 'latest'; + packageJsonFile.devDependencies.chimp = getChimpVersion(); } function addDevDependenciesWithMatchingVersions(packages: string[]) { diff --git a/src/generate/parse-graphql/getScalars.spec.ts b/src/generate/parse-graphql/getScalars.spec.ts index a61b9e95..f1bec738 100644 --- a/src/generate/parse-graphql/getScalars.spec.ts +++ b/src/generate/parse-graphql/getScalars.spec.ts @@ -26,3 +26,30 @@ test('get the non extended types with apollo key annotation', () => { expect(res).toEqual(['MyOwn']); }); + +test('ignore built-in Upload scalar', () => { + const schemaString = gql` + type TodoItem @key(fields: "id") { + id: ID! + list: List + } + + extend type List { + id: ID! + todos: [TodoItem!]! + incompleteCount: Int! + } + + type InMemory { + id: ID! + } + + scalar First + scalar Upload + scalar ThirdOne + `; + + const res = getScalars(schemaString); + + expect(res).toEqual(['First', 'ThirdOne']); +}); diff --git a/src/generate/parse-graphql/getScalars.ts b/src/generate/parse-graphql/getScalars.ts index bd96a6ca..c6cb699f 100644 --- a/src/generate/parse-graphql/getScalars.ts +++ b/src/generate/parse-graphql/getScalars.ts @@ -1,10 +1,15 @@ import gql from 'graphql-tag'; -export default (graphqlString: string) => { +export default (graphqlString: string): string[] => { const graphqlAST = gql` ${graphqlString} `; - // @ts-ignore - return graphqlAST.definitions.filter((d) => d.kind === 'ScalarTypeDefinition').map((f) => f.name.value); + return ( + graphqlAST.definitions + .filter((d) => d.kind === 'ScalarTypeDefinition') + // @ts-ignore + .map((f) => f.name.value) + .filter((s) => s !== 'Upload') + ); }; diff --git a/src/helpers/get-chimp-version.ts b/src/helpers/get-chimp-version.ts new file mode 100644 index 00000000..64936399 --- /dev/null +++ b/src/helpers/get-chimp-version.ts @@ -0,0 +1,9 @@ +// @ts-ignore +import finder from 'find-package-json'; + +export const getChimpVersion = () => { + const f = finder(__dirname); + const packageJson = f.next(); + + return packageJson.value.version; +}; diff --git a/src/scripts/end-to-end-test.ts b/src/scripts/end-to-end-test.ts index 017d9f3f..8b2c76f8 100644 --- a/src/scripts/end-to-end-test.ts +++ b/src/scripts/end-to-end-test.ts @@ -27,7 +27,7 @@ quietExec('./chimp/bin/run create chimp-test-repo', { cwd: pathToRunFrom }); shelljs.cp('-R', './test-module', '../chimp-test-repo/src/modules/'); const pathToRunFromChimp = path.join(process.cwd(), '../chimp-test-repo'); console.log('GOZDECKI pathToRunFromChimp', pathToRunFromChimp); -shelljs.sed('-i', /"chimp": "latest"/, '"chimp": "../chimp"', path.join(pathToRunFromChimp, 'package.json')); +shelljs.sed('-i', /"chimp": "0.0.0-development"/, '"chimp": "../chimp"', path.join(pathToRunFromChimp, 'package.json')); quietExec('npm install', { cwd: pathToRunFromChimp }); quietExec('npm run type-check', { cwd: pathToRunFromChimp });