Skip to content

Commit

Permalink
move tsconfig to root
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian He committed Dec 15, 2020
1 parent e8ca6e9 commit 9b4a4ed
Show file tree
Hide file tree
Showing 43 changed files with 5,007 additions and 605 deletions.
1 change: 1 addition & 0 deletions packages/cli/.editorconfig → .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Expand Down
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/build/**
/api_docs/**
**/node_modules/**
**/test/**/*
**/*.spec.*
/scripts/*
packages/**/dist/**
packages/**/lib/**
78 changes: 78 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
https://github.com/typescript-eslint/tslint-to-eslint-config
It represents the closest reasonable ESLint configuration to this
project's original TSLint configuration.
We recommend eventually switching this configuration to extend from
the recommended rulesets in typescript-eslint.
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
Happy linting! 💖
*/
module.exports = {
env: {
es6: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'import'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
rules: {
// rules turned off in upstream project (also required when recommended-requiring-type-checking is extended)
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
// Support recommended-requiring-type-checking (specific to this project) set them as warning
'@typescript-eslint/unbound-method': 'warn',
'@typescript-eslint/no-floating-promises': 'warn',
// Making affected recommended types as warning for now
'@typescript-eslint/explicit-module-boundary-types': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-var-requires': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'no-public',
},
],
'@typescript-eslint/no-namespace': ['error', {"allowDeclarations": true }],
// "@typescript-eslint/member-ordering": "error",
// "@typescript-eslint/naming-convention": "error",
// "@typescript-eslint/no-param-reassign": "error",
'@typescript-eslint/promise-function-async': 'error',
// "arrow-body-style": "error",
complexity: 'error',
curly: ['error', 'multi-line'],
'default-case': 'error',
eqeqeq: ['error', 'always'],
'import/no-extraneous-dependencies': 'off',
'import/order': 'error',
'no-console': 'error',
'no-duplicate-imports': 'error',
// "no-magic-numbers": "error",
'no-return-await': 'error',
'no-undef-init': 'error',
'prefer-template': 'error',
'use-isnan': 'error',
},
};
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/CHANGELOG.md
**/node_modules/**
**/.*/**
**/coverage/**
**/dist/**
*.d.ts
**/.DS_Store
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 120,
"trailingComma": "es5",
"tabWidth": 2,
"singleQuote": true,
"bracketSpacing": false
}
8 changes: 4 additions & 4 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
spec: '@yarnpkg/plugin-interactive-tools'
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
spec: '@yarnpkg/plugin-version'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
spec: '@yarnpkg/plugin-workspace-tools'
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
spec: '@yarnpkg/plugin-typescript'

yarnPath: .yarn/releases/yarn-berry.js
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# SubQl
# SubQl
24 changes: 23 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,27 @@
"private": true,
"workspaces": [
"packages/*"
]
],
"devDependencies": {
"@types/node": "^12.19.7",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"eslint": "^7.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0",
"jest": "^26.6.3",
"prettier": "^2.1.2",
"pretty-quick": "^3.1.0",
"ts-loader": "^8.0.8",
"ts-node": "^9.0.0",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.0.5"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged --pattern 'packages/**/src/**/*' && npx eslint . --ext .ts"
}
}
}
1 change: 0 additions & 1 deletion packages/cli/.eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions packages/cli/.eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions packages/cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/tmp
/yarn.lock
node_modules
.data
20 changes: 14 additions & 6 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@subql/cli
===============
# @subql/cli

cli for polkagraph

Expand All @@ -9,11 +8,15 @@ cli for polkagraph
[![License](https://img.shields.io/npm/l/@subql/cli.svg)](https://github.com/packages/cli/blob/master/package.json)

<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)

- [Usage](#usage)
- [Commands](#commands)
<!-- tocstop -->

# Usage

<!-- usage -->

```sh-session
$ npm install -g @subql/cli
$ subql COMMAND
Expand All @@ -25,11 +28,15 @@ USAGE
$ subql COMMAND
...
```

<!-- usagestop -->

# Commands

<!-- commands -->
* [`subql hello [FILE]`](#subql-hello-file)
* [`subql help [COMMAND]`](#subql-help-command)

- [`subql hello [FILE]`](#subql-hello-file)
- [`subql help [COMMAND]`](#subql-help-command)

## `subql hello [FILE]`

Expand Down Expand Up @@ -67,4 +74,5 @@ OPTIONS
```

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

<!-- commandsstop -->
1 change: 0 additions & 1 deletion packages/cli/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ services:
- .data/postgres:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgres

4 changes: 2 additions & 2 deletions packages/cli/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const s = new Source(fs.readFileSync('./schema.graphql').toString());
const base = buildSchema(new Source(fs.readFileSync('./base.graphql').toString()));

const doc = parse(s);
const sc = extendSchema(base, doc)
const sc = extendSchema(base, doc);

visit(doc, {
enter(node, key, parent, path, ancestors) {
Expand All @@ -18,4 +18,4 @@ visit(doc, {
leave(node, key, parent, path, ancestors) {
console.log(`leave ${node.kind}`);
},
})
});
9 changes: 3 additions & 6 deletions packages/cli/main2.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
const { loadDocuments, loadSchema } = require('@graphql-tools/load');
const { GraphQLFileLoader } = require('@graphql-tools/graphql-file-loader');
const {loadDocuments, loadSchema} = require('@graphql-tools/load');
const {GraphQLFileLoader} = require('@graphql-tools/graphql-file-loader');

async function main() {
const document = await loadDocuments('schema.graphql', {
loaders: [
new GraphQLFileLoader()
]
loaders: [new GraphQLFileLoader()],
});
}

main();

7 changes: 1 addition & 6 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
"@oclif/dev-cli": "^1.22.2",
"@types/node": "^10.17.35",
"@types/pg-format": "^1",
"eslint": "^5.16.0",
"eslint-config-oclif": "^3.1.0",
"eslint-config-oclif-typescript": "^0.1.0",
"globby": "^10.0.2",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
"globby": "^10.0.2"
},
"engines": {
"node": ">=8.0.0"
Expand Down
10 changes: 1 addition & 9 deletions packages/cli/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@

type Extrinsic @entity {

id: ID!

NumExtrinsic: Int!


}


type testEntity @entity {

id: ID!

NumExtrinsic: Int!

NumEvent: Int


}
}
16 changes: 8 additions & 8 deletions packages/cli/src/commands/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Command, flags} from '@oclif/command'
import {generateSchema} from '../controller/codegen-controller'
import {Command, flags} from '@oclif/command';
import {generateSchema} from '../controller/codegen-controller';

export default class Codegen extends Command {
static description = 'Generate schemas for graph node'
static description = 'Generate schemas for graph node';

static flags = {
// can pass either --force or -f
Expand All @@ -18,12 +18,12 @@ export default class Codegen extends Command {
}),
*/
}
};

async run() {
this.log('*********************************')
this.log('Start codegen from schema.graphql')
this.log('*********************************')
await generateSchema()
this.log('*********************************');
this.log('Start codegen from schema.graphql');
this.log('*********************************');
await generateSchema();
}
}
18 changes: 9 additions & 9 deletions packages/cli/src/commands/hello.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import {Command, flags} from '@oclif/command'
import {Command, flags} from '@oclif/command';

export default class Hello extends Command {
static description = 'describe the command here'
static description = 'describe the command here';

static examples = [
`$ cli hello
hello world from ./src/hello.ts!
`,
]
];

static flags = {
help: flags.help({char: 'h'}),
// flag with a value (-n, --name=VALUE)
name: flags.string({char: 'n', description: 'name to print'}),
// flag with no value (-f, --force)
force: flags.boolean({char: 'f'}),
}
};

static args = [{name: 'file'}]
static args = [{name: 'file'}];

async run() {
const {args, flags} = this.parse(Hello)
const {args, flags} = this.parse(Hello);

const name = flags.name ?? 'world'
this.log(`hello ${name} from ./src/commands/hello.ts`)
const name = flags.name ?? 'world';
this.log(`hello ${name} from ./src/commands/hello.ts`);
if (args.file && flags.force) {
this.log(`you input --force and --file: ${args.file}`)
this.log(`you input --force and --file: ${args.file}`);
}
}
}
Loading

0 comments on commit 9b4a4ed

Please sign in to comment.