Skip to content

Commit

Permalink
Merge pull request #346 from cofacts/typescript
Browse files Browse the repository at this point in the history
Add Typescript
  • Loading branch information
MrOrz committed Apr 27, 2023
2 parents 277c844 + dc7a89f commit 76f4c6e
Show file tree
Hide file tree
Showing 15 changed files with 14,411 additions and 2,557 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
!webpack.config.js
!i18n/*
!.env
!static
!static
!typegen
!tsconfig.json
13 changes: 12 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
'prettier',
],
env: { node: true, es6: true, jest: true },
plugins: ['prettier'],
plugins: ['prettier', 'import'],
rules: {
'prettier/prettier': [
'error',
Expand All @@ -19,8 +19,19 @@ module.exports = {
'no-console': 'off', // just use console :P
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts'],
},
'import/resolver': {
'babel-module': {},
typescript: {},
},
},
overrides: [
{
files: ['**/*.ts'],
extends: ['plugin:@typescript-eslint/recommended'],
plugins: ['@typescript-eslint'],
},
],
};
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
${{ runner.OS }}-
- run: npm ci
- run: npm run lint
- run: npm run typecheck
- run: npm run i18n:validate
- run: npm run test --ignore-scripts -- --coverage
- name: Update coveralls
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ To use Dialogflow,

[Create](https://support.google.com/analytics/answer/2709829) a custom (user scope) dimemsion for `Message Source`, and a custom (hit scope) metrix for `Group Members Count`. Both of them default index is 1. If the indexes GA created are not 1, find `cd1` and `cm1` in the code and change them to `cd$theIndexGACreated` and `cm$theIndexGACreated` respectively.

### Typescript

Use `npm run typecheck` to check types; use `npm run typegen` to generate type from GraphQL schema.

---

## Production Deployment
Expand Down
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
},
},
],
'@babel/preset-typescript',
],
plugins: [
['ttag', { resolve: { translations: `i18n/${locale}.po` } }],
Expand Down
22 changes: 22 additions & 0 deletions codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: './src/graphql/cofacts-api.graphql',
documents: ['src/**/*.ts', 'src/**/*.graphql'],
generates: {
'./typegen/': {
preset: 'client',
plugins: [],
presetConfig: {
fragmentMasking: false,
},
config: {
enumsAsTypes: true,
immutableTypes: true,
skipTypename: true,
avoidOptionals: true,
},
},
},
};
export default config;
1 change: 1 addition & 0 deletions ecosystem.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
// Don't reload server for LIFF changes
ignore_watch: ['src/liff'],
interpreter: './node_modules/.bin/babel-node',
interpreter_args: '--extensions .ts,.js',
},
],
};
Loading

0 comments on commit 76f4c6e

Please sign in to comment.