Skip to content

Commit 90dea98

Browse files
author
Aleksandra Sikora
authored
cli-ext: add typescript support (#4820)
1 parent b9ed3df commit 90dea98

File tree

15 files changed

+542
-41
lines changed

15 files changed

+542
-41
lines changed

cli-ext/.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
presets: ["@babel/preset-env"],
3-
plugins: ["@babel/plugin-transform-async-to-generator"]
2+
"presets": ["@babel/preset-env", "@babel/preset-typescript"],
3+
"plugins": ["@babel/plugin-transform-async-to-generator"]
44
}

cli-ext/.eslintrc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"env": {
33
"node": true
44
},
5-
"extends": "airbnb-base",
6-
"plugins": ["promise"],
5+
"extends": ["airbnb-base", "plugin:@typescript-eslint/recommended"],
6+
"plugins": ["promise", "@typescript-eslint/eslint-plugin"],
7+
"parser": "@typescript-eslint/parser",
78
"rules": {
89
"no-console": "off",
910
"consistent-return": "off",
@@ -24,6 +25,10 @@
2425
"promise/no-promise-in-callback": "error",
2526
"promise/no-callback-in-promise": "error",
2627
"promise/no-return-in-finally": "error",
27-
"prefer-arrow-callback": "error"
28+
"prefer-arrow-callback": "error",
29+
"@typescript-eslint/no-var-requires": "off",
30+
"@typescript-eslint/no-explicit-any": "off",
31+
"@typescript-eslint/explicit-function-return-type": "off",
32+
"@typescript-eslint/camelcase": "off"
2833
}
2934
}

cli-ext/package-lock.json

Lines changed: 504 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli-ext/package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
"scripts": {
77
"get-shared-modules": "rm -rf src/shared && cp ../console/src/shared ./src/shared -r",
88
"pretranspile": "npm run get-shared-modules",
9-
"transpile": "rm -rf build/* && babel ./src ./tests --out-dir build",
9+
"transpile": "rm -rf build/* && babel --extensions '.ts,.js' ./src ./tests --out-dir build",
1010
"prebuild": "npm run transpile",
1111
"build": "rm -rf ./bin/* && pkg ./build/command.js --output ./bin/cli-ext-hasura -t node12-linux-x64,node12-macos-x64,node12-win-x64",
1212
"pretest": "npm run transpile && babel ./tests --out-dir _tmptests",
1313
"posttest": "rm -rf _tmptests",
1414
"test": "node ./_tmptests/index.js",
15-
"lint": "eslint 'src/**/*.js' --fix",
16-
"format": "prettier-eslint $PWD'src/**/*.{js,json}' --write && npm run lint"
15+
"lint": "eslint 'src/**/*.{js,ts}' --fix",
16+
"format": "prettier-eslint $PWD'src/**/*.{js,ts,json}' --write && npm run lint"
1717
},
1818
"lint-staged": {
1919
"**/*.js": [
@@ -42,12 +42,19 @@
4242
"@babel/core": "^7.0.0",
4343
"@babel/plugin-transform-async-to-generator": "^7.7.4",
4444
"@babel/preset-env": "^7.7.6",
45+
"@babel/preset-typescript": "^7.9.0",
46+
"@types/graphql": "^14.5.0",
47+
"@types/inflection": "^1.5.28",
48+
"@types/node-fetch": "^2.5.7",
49+
"@typescript-eslint/eslint-plugin": "^2.34.0",
50+
"@typescript-eslint/parser": "^2.34.0",
4551
"eslint": "^6.8.0",
4652
"eslint-config-airbnb-base": "^14.1.0",
4753
"eslint-plugin-import": "^2.20.2",
4854
"eslint-plugin-promise": "^4.2.1",
4955
"husky": "^4.2.5",
5056
"lint-staged": "^10.1.5",
51-
"prettier-eslint-cli": "^5.0.0"
57+
"prettier-eslint-cli": "^5.0.0",
58+
"typescript": "^3.9.2"
5259
}
53-
}
60+
}

cli-ext/src/command.js renamed to cli-ext/src/command.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { getFlagValue, OUTPUT_FILE_FLAG } = require('./utils/commandUtils');
77
const commandArgs = process.argv;
88
const outputFilePath = getFlagValue(commandArgs, OUTPUT_FILE_FLAG);
99

10-
const logOutput = (log) => {
10+
const logOutput = (log: any) => {
1111
try {
1212
fs.writeFile(outputFilePath, log, 'utf8', () => {
1313
console.log(
@@ -43,13 +43,13 @@ try {
4343
}
4444
if (cliResponse.constructor.name === 'Promise') {
4545
cliResponse
46-
.then((r) => {
46+
.then((r: { error?: string }) => {
4747
if (r.error) {
4848
throw Error(r.error);
4949
}
5050
logOutput(JSON.stringify(r));
5151
})
52-
.catch((e) => {
52+
.catch((e: Error) => {
5353
console.error(e);
5454
process.exit(1);
5555
});
File renamed without changes.

cli-ext/src/services/actions-codegen/command.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const { getInputPayload } = require('../../utils/commandUtils');
22
const handler = require('./handler');
33

44
const command = (subCommands) => {
5-
const rootInput = subCommands[0];
65
const payload = getInputPayload(subCommands);
76
return handler(payload);
87
};

cli-ext/src/services/actions-codegen/handler.js renamed to cli-ext/src/services/actions-codegen/handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { getActionsCodegen } = require('./codegen');
22

3-
const handler = async (payload) => {
3+
const handler = async (payload: unknown) => {
44
try {
55
const codegen = await getActionsCodegen(payload);
66
return { codegen };
File renamed without changes.

0 commit comments

Comments
 (0)