forked from react-native-community/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate
tools
to TypeScript (react-native-community#296)
* Migrate tools package to Typescript * Prebuild ts * Improve yarn build-clean * Remove unnecessary statements * Fix linting * Fix eslint * Update packages/tools/src/isPackagerRunning.ts Co-Authored-By: Michał Pierzchała <[email protected]> * adjust package.json * add vscode helper settings * remove dead node-fetch references
- Loading branch information
Showing
24 changed files
with
367 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"redhat.vscode-yaml", | ||
"flowtype.flow-for-vscode", | ||
"esbenp.prettier-vscode" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"editor.rulers": [80], | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/node_modules": true, | ||
"**/build": true | ||
}, | ||
"editor.formatOnSave": true, | ||
"flow.useNPMPackagedFlow": true, | ||
"javascript.validate.enable": false, | ||
"prettier.eslintIntegration": true, | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
{ | ||
"language": "typescript", | ||
"autoFix": true | ||
}, | ||
{ | ||
"language": "typescriptreact", | ||
"autoFix": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/tools/src/getDefaultUserTerminal.js → packages/tools/src/getDefaultUserTerminal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const getDefaultUserTerminal = (): ?string => | ||
const getDefaultUserTerminal = (): string | undefined => | ||
process.env.REACT_TERMINAL || process.env.TERM_PROGRAM; | ||
|
||
export default getDefaultUserTerminal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
/** | ||
* @flow | ||
*/ | ||
import chalk from 'chalk'; | ||
|
||
const SEPARATOR = ', '; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "build" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const chalk = require('chalk'); | ||
const execa = require('execa'); | ||
const {getPackages, adjustToTerminalWidth, OK} = require('./helpers'); | ||
|
||
const packages = getPackages(); | ||
|
||
const packagesWithTs = packages.filter(p => | ||
fs.existsSync(path.resolve(p, 'tsconfig.json')), | ||
); | ||
|
||
const args = [ | ||
path.resolve( | ||
require.resolve('typescript/package.json'), | ||
'..', | ||
require('typescript/package.json').bin.tsc, | ||
), | ||
'-b', | ||
...packagesWithTs, | ||
...process.argv.slice(2), | ||
]; | ||
|
||
console.log(chalk.inverse('Building TypeScript definition files')); | ||
process.stdout.write(adjustToTerminalWidth('Building\n')); | ||
|
||
try { | ||
execa.sync('node', args, {stdio: 'inherit'}); | ||
process.stdout.write(`${OK}\n`); | ||
} catch (e) { | ||
process.stdout.write('\n'); | ||
console.error( | ||
chalk.inverse.red('Unable to build TypeScript definition files'), | ||
); | ||
console.error(e.stack); | ||
process.exitCode = 1; | ||
} |
Oops, something went wrong.