feat(rpc): run generate-channels during lint (#3238)

This commit is contained in:
Dmitry Gozman 2020-07-30 15:08:21 -07:00 committed by GitHub
parent 9103ce0060
commit 6297f86cfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 5 deletions

View File

@ -18,7 +18,7 @@
"tsc-installer": "tsc -p ./src/install/tsconfig.json",
"doc": "node utils/doclint/cli.js",
"test-infra": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js && node utils/testrunner/test/test.js",
"lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && npm run test-types && npm run test-infra",
"lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && npm run generate-channels && npm run test-types && npm run test-infra",
"debug-test": "node --inspect-brk test/test.js",
"clean": "rimraf lib && rimraf types",
"prepare": "node install-from-github.js",
@ -26,6 +26,7 @@
"watch": "node utils/runWebpack.js --mode='development' --watch --silent | tsc -w -p .",
"test-types": "npm run generate-types && npx -p typescript@3.7.5 tsc -p utils/generate_types/test/tsconfig.json && npm run typecheck-tests",
"generate-types": "node utils/generate_types/",
"generate-channels": "node utils/generate_channels.js",
"typecheck-tests": "tsc -p ./test/",
"roll-browser": "node utils/roll_browser.js",
"jest": "jest",

View File

@ -2034,7 +2034,7 @@ export type RouteAbortParams = {
errorCode?: string,
};
export type RouteAbortOptions = {
errorCode?: string,
};
export type RouteAbortResult = void;
export type RouteContinueParams = {
@ -2064,7 +2064,13 @@ export type RouteFulfillParams = {
isBase64?: boolean,
};
export type RouteFulfillOptions = {
status?: number,
headers?: {
name: string,
value: string,
}[],
body?: string,
isBase64?: boolean,
};
export type RouteFulfillResult = void;

View File

@ -229,5 +229,18 @@ validator_ts.push(`
}
`);
fs.writeFileSync(path.join(__dirname, '..', 'src', 'rpc', 'channels.ts'), channels_ts.join('\n'), 'utf-8');
fs.writeFileSync(path.join(__dirname, '..', 'src', 'rpc', 'validator.ts'), validator_ts.join('\n'), 'utf-8');
let hasChanges = false;
function writeFile(filePath, content) {
const existing = fs.readFileSync(filePath, 'utf8');
if (existing === content)
return;
hasChanges = true;
const root = path.join(__dirname, '..');
console.log(`Writing //${path.relative(root, filePath)}`);
fs.writeFileSync(filePath, content, 'utf8');
}
writeFile(path.join(__dirname, '..', 'src', 'rpc', 'channels.ts'), channels_ts.join('\n'));
writeFile(path.join(__dirname, '..', 'src', 'rpc', 'validator.ts'), validator_ts.join('\n'));
process.exit(hasChanges ? 1 : 0);