Skip to content

Commit

Permalink
Chimp 3.0 (#728)
Browse files Browse the repository at this point in the history
* fix: allow for arguments in type resolvers specs

* code simplification WIP

* test: testing end to end on CI. make sure freshly generated specs pass type check

* test: ignore scaffold and template tests

* docs: updated docs

* feat: code rewrite, typescript, oclif, API simplification, bug fixes
BREAKING CHANGE: take a look at the new chimp CLI - no gql: in commands anymore, and simplified package.json scripts setup

Co-authored-by: lucetius <lucetius@lucetius.pl>

Co-authored-by: lucetius <lucetius@lucetius.pl>
  • Loading branch information
lgandecki and lucetius authored Jan 29, 2021
1 parent 3f5afa2 commit d774cc8
Show file tree
Hide file tree
Showing 91 changed files with 7,787 additions and 14,593 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintcache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"/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"]
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/lib
/scaffold
/test-module
/documentation
24 changes: 13 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"plugins": [
'jest',
'prettier'
],
"extends": ["airbnb-base", 'prettier'],
"rules": {
"prettier/prettier": "error",
"no-console": "off",
"global-require": "off",
"no-plusplus": "off"
}
"plugins": ["jest", "prettier"],
"extends": ["oclif", "oclif-typescript", "prettier"],
"rules": {
"prettier/prettier": "error",
"no-console": "off",
"global-require": "off",
"no-plusplus": "off",
"unicorn/no-process-exit": "off",
"no-process-exit": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"unicorn/filename-case": "off",
"unicorn/no-abusive-eslint-disable": "off"
}
}
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: '12'
- run: npm ci
- run: npm test
- run: yarn
- run: yarn test
- run: yarn end-to-end-test
- name: Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
74 changes: 8 additions & 66 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,67 +1,9 @@
# output files of test
example/output
example/output2

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# webstorm settings
*-debug.log
*-error.log
/.nyc_output
/dist
/lib
/package-lock.json
/tmp
node_modules
.idea

.DS_STORE
125 changes: 108 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,119 @@
#
![Chimp by Xolv.io](./images/chimp.png?raw=true)
#
chimp
=====

## Your Quality Faster Companion
Your development companion for doing quality, faster.

Please go to http://chimpjs.com for documentation
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/chimp.svg)](https://npmjs.org/package/chimp)
[![CircleCI](https://circleci.com/gh/xolvio/chimp2/tree/master.svg?style=shield)](https://circleci.com/gh/xolvio/chimp2/tree/master)
[![Codecov](https://codecov.io/gh/xolvio/chimp2/branch/master/graph/badge.svg)](https://codecov.io/gh/xolvio/chimp2)
[![Downloads/week](https://img.shields.io/npm/dw/chimp.svg)](https://npmjs.org/package/chimp)
[![License](https://img.shields.io/npm/l/chimp.svg)](https://github.com/xolvio/chimp2/blob/master/package.json)

### IMPORTANT ANNOUNCEMENT - July 22nd, 2018
<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->
# Usage
<!-- usage -->
```sh-session
$ npm install -g chimp
$ chimp COMMAND
running command...
$ chimp (-v|--version|version)
chimp/0.0.0-development darwin-x64 node-v12.16.2
$ chimp --help [COMMAND]
USAGE
$ chimp COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`chimp create [NAME]`](#chimp-create-name)
* [`chimp generate`](#chimp-generate)
* [`chimp help [COMMAND]`](#chimp-help-command)
* [`chimp init`](#chimp-init)

The Chimp that you know and love is now being split into two separate projects, both of which are intended to help you deliver higher quality faster.
## `chimp create [NAME]`

The first is [*Chimpy*](https://github.com/TheBrainFamily/chimpy). This project will continue evolving and supporting the current thinking behind Chimp 1.x.
describe the command here

The second is [*Chimp 2.0*](https://github.com/xolvio/chimp). This project will be built from scratch based on the learnings made while using Chimp 1.x in the field.
```
USAGE
$ chimp create [NAME]
For more details about this decision, [please see the full announcement here.](https://medium.com/@sam_hatoum/the-future-of-chimp-js-e911f8e9aaa6)
ARGUMENTS
NAME name of the new app, also used as the directory
#### Chimp 2.0
Chimp 2.0 is likely to be a [Yeoman](http://yeoman.io/) for quality. The intention is to have Chimp be your companion that you can call on to help you create high quality code that is optimized for changes
OPTIONS
-a, --appPrefix=appPrefix [default: ~app] prefix that points to the sourcecode of your app
-g, --generatedPrefix=generatedPrefix [default: ~generated] prefix that points to the generated by chimp helper code
-h, --help show CLI help
#### Quality Faster
Please checkout the new [Quality Faster](https://www.qualityfaster.com) guide where you can learn how to build quality in to your application across the full stack.
EXAMPLES
$ chimp create my-new-app
$ chimp create my-new-app -a ~src -g ~chimp-helpers
```

Anyone that purchased The Meteor Testing Manual will get this guide for free. [See here for the announcement](https://www.qualityfaster.com/landing/meteor-testing.html).
_See code: [src/commands/create.ts](https://github.com/xolvio/chimp/blob/v0.0.0-development/src/commands/create.ts)_

#### Community
**Slack:** Please join our Slack [xolv.io/community](http://community.xolv.io) #chimp channel, where you can chat, find help and help others. (it might take a minute for the free Now.sh serverless function to start up!)
## `chimp generate`

generate GraphQL code

```
USAGE
$ chimp generate
OPTIONS
-a, --appPrefix=appPrefix [default: ~app] prefix that points to the sourcecode of your app
-g, --generatedPrefix=generatedPrefix [default: ~generated] prefix that points to the generated by chimp helper code
-h, --help show CLI help
-p, --modulesPath=modulesPath path to the graphQL modules, only use if you are migrating an existing Apollo
App and you want to use chimp only for a part of it
EXAMPLES
$ chimp generate
$ chimp generate -a ~src -g ~chimp-helpers
```

_See code: [src/commands/generate.ts](https://github.com/xolvio/chimp/blob/v0.0.0-development/src/commands/generate.ts)_

## `chimp help [COMMAND]`

display help for chimp

```
USAGE
$ chimp help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.1/src/commands/help.ts)_

## `chimp init`

init Chimp

```
USAGE
$ chimp init
OPTIONS
-h, --help show CLI help
-p, --modulesPath=modulesPath [default: ./src/modules] path to the GraphQL modules.
EXAMPLES
$ chimp init
$ chimp init -p ./src/chimp-modules
```

_See code: [src/commands/init.ts](https://github.com/xolvio/chimp/blob/v0.0.0-development/src/commands/init.ts)_
<!-- commandsstop -->
5 changes: 5 additions & 0 deletions bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

require('@oclif/command').run()
.then(require('@oclif/command/flush'))
.catch(require('@oclif/errors/handle'))
3 changes: 3 additions & 0 deletions bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
2 changes: 2 additions & 0 deletions documentation/docs/Examples/Federation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: Federation
title: Overview of a more realistic Example
---

Note: This repo was not updated to the chimp 3.0 yet.

In this section we will look at a setup that's typical to our clients.


Expand Down
4 changes: 1 addition & 3 deletions documentation/docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ This is the folder structure you will see:

```
├── README.md
├── codegen.js
├── fix-generated.js
├── jest.config.js
├── jest.setup.js
├── nodemon.run.json
Expand Down Expand Up @@ -91,7 +89,7 @@ extend type Query {
Let's run the generation now:

```bash
npm run graphql:generateAll
npm run chimp
```

That command will create Mutations/Queries/Type resolvers, tests for them, types and perform all the necessary connection between the main schema, contexts, etc.
Expand Down
6 changes: 3 additions & 3 deletions documentation/docs/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ id: structure
title: Structure Explained
---

A fresh project will consist of a following structure:
A fresh project will consist of a following structure (* are optional):

```
├── README.md
├── codegen.js
├── fix-generated.js
├── codegen.js *
├── fix-generated.js *
├── jest.config.js
├── jest.setup.js
├── nodemon.run.json
Expand Down
50 changes: 0 additions & 50 deletions example/sampleTypeDef.graphql

This file was deleted.

Loading

0 comments on commit d774cc8

Please sign in to comment.