Skip to content

Commit

Permalink
TEC-1867 Change URLs to point to BL repo (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
patryk-w-bl authored Jan 21, 2025
1 parent fd8e7de commit 7bdb605
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 72 deletions.
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
# ts-migrate

*ts-migrate* is a tool for helping migrate code to TypeScript.
_ts-migrate_ is a tool for helping migrate code to TypeScript.
It takes a JavaScript, or a partial TypeScript, project in and gives a compiling TypeScript project out.

*ts-migrate* is intended to accelerate the TypeScript migration process. The resulting code will pass the build, but a followup is required to improve type safety. There will be lots of `// @ts-expect-error`, and `any` that will need to be fixed over time. In general, it is a lot nicer than starting from scratch.
_ts-migrate_ is intended to accelerate the TypeScript migration process. The resulting code will pass the build, but a followup is required to improve type safety. There will be lots of `// @ts-expect-error`, and `any` that will need to be fixed over time. In general, it is a lot nicer than starting from scratch.

*ts-migrate* is designed as a set of plugins so that it can be pretty customizable for different use-cases. Potentially, more plugins can be added for addressing things like improvements of type quality or libraries-related things (like prop-types in React).
_ts-migrate_ is designed as a set of plugins so that it can be pretty customizable for different use-cases. Potentially, more plugins can be added for addressing things like improvements of type quality or libraries-related things (like prop-types in React).

Plugins are combined into migration configs. We currently have two main migration configs:

* for the main JavaScript → TypeScript migration
* for the reignore script
- for the main JavaScript → TypeScript migration
- for the reignore script

These configs can be moved out of the default script, and people can add custom configs with a different set of plugins for their needs.

You can find instructions on how to install and run ts-migrate in the [main package](./packages/ts-migrate/). If you find any [issues](https://github.com/airbnb/ts-migrate/issues) or have ideas for improvements, we welcome your [contributions](https://github.com/airbnb/ts-migrate/blob/master/CONTRIBUTING.md)!
You can find instructions on how to install and run ts-migrate in the [main package](./packages/ts-migrate/). If you find any [issues](https://github.com/brightlocal/ts-migrate/issues) or have ideas for improvements, we welcome your [contributions](https://github.com/brightlocal/ts-migrate/blob/master/CONTRIBUTING.md)!

Check out the [blog post](https://medium.com/airbnb-engineering/ts-migrate-a-tool-for-migrating-to-typescript-at-scale-cd23bfeb5cc) about ts-migrate!


# Published Packages

| Folder | Version | Package |
| ------ | ------- | ------- |
| [packages/ts-migrate](./packages/ts-migrate/) | [![npm version](https://badge.fury.io/js/ts-migrate.svg)](https://badge.fury.io/js/ts-migrate) | [ts-migrate](https://www.npmjs.com/package/ts-migrate) |
| Folder | Version | Package |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| [packages/ts-migrate](./packages/ts-migrate/) | [![npm version](https://badge.fury.io/js/ts-migrate.svg)](https://badge.fury.io/js/ts-migrate) | [ts-migrate](https://www.npmjs.com/package/ts-migrate) |
| [packages/ts-migrate-plugins](./packages/ts-migrate-plugins/) | [![npm version](https://badge.fury.io/js/ts-migrate-plugins.svg)](https://badge.fury.io/js/ts-migrate-plugins) | [ts-migrate-plugins](https://www.npmjs.com/package/ts-migrate-plugins) |
| [packages/ts-migrate-server](./packages/ts-migrate-server/) | [![npm version](https://badge.fury.io/js/ts-migrate-server.svg)](https://badge.fury.io/js/ts-migrate-server) | [ts-migrate-server](https://www.npmjs.com/package/ts-migrate-server) |
| [packages/ts-migrate-server](./packages/ts-migrate-server/) | [![npm version](https://badge.fury.io/js/ts-migrate-server.svg)](https://badge.fury.io/js/ts-migrate-server) | [ts-migrate-server](https://www.npmjs.com/package/ts-migrate-server) |

# Unpublished Packages

| Folder | Description |
| ------ | -----------|
| Folder | Description |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| [packages/ts-migrate-example](./packages/ts-migrate-example/) | basic example of usage of the ts-migrate-server with a writing a custom simple plugin |


# Authors

<table>
Expand Down Expand Up @@ -67,7 +65,6 @@ Check out the [blog post](https://medium.com/airbnb-engineering/ts-migrate-a-too
</tbody>
</table>


# License

MIT, see [LICENSE](https://github.com/airbnb/ts-migrate/blob/master/LICENCE) for details.
MIT, see [LICENSE](https://github.com/brightlocal/ts-migrate/blob/master/LICENCE) for details.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.1.39",
"version": "0.1.40",
"npmClient": "yarn",
"useWorkspaces": true,
"stream": true
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/airbnb/ts-migrate.git",
"url": "https://github.com/brightlocal/ts-migrate.git",
"directory": "packages/ts-migrate-server"
},
"bugs": {
"url": "https://github.com/airbnb/ts-migrate/issues"
"url": "https://github.com/brightlocal/ts-migrate/issues"
},
"private": true,
"description": "ts-migrate monorepo",
Expand Down
16 changes: 8 additions & 8 deletions packages/ts-migrate-example/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# ts-migrate-example

`ts-migrate-example` is a basic example of usage of the [@brightlocaldev/ts-migrate-server](https://github.com/airbnb/ts-migrate/tree/master/packages/@brightlocaldev/ts-migrate-server) with writing a custom plugin.
`ts-migrate-example` is a basic example of usage of the [@brightlocaldev/ts-migrate-server](https://github.com/brightlocal/ts-migrate/tree/master/packages/@brightlocaldev/ts-migrate-server) with writing a custom plugin.

### We have examples of the three categories of plugins:

- [example-plugin-jscodeshift](https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-example/src/example-plugin-jscodeshift.ts) simply reverses the names of all identifiers.
- [example-plugin-jscodeshift](https://github.com/brightlocal/ts-migrate/blob/master/packages/ts-migrate-example/src/example-plugin-jscodeshift.ts) simply reverses the names of all identifiers.

- [example-plugin-text](https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-example/src/example-plugin-text.ts) will add a `console.log` before each return statement.
- [example-plugin-text](https://github.com/brightlocal/ts-migrate/blob/master/packages/ts-migrate-example/src/example-plugin-text.ts) will add a `console.log` before each return statement.

- [example-plugin-ts](https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-example/src/example-plugin-ts.ts) is a simple TypeScript AST-based plugin, which shows how we can add simple types to the JavaScript code with the usage of [TypeScript compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API).
- [example-plugin-ts](https://github.com/brightlocal/ts-migrate/blob/master/packages/ts-migrate-example/src/example-plugin-ts.ts) is a simple TypeScript AST-based plugin, which shows how we can add simple types to the JavaScript code with the usage of [TypeScript compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API).

We're using the following input:

Expand All @@ -18,7 +18,7 @@ function mult(first, second) {
}
```

and with a [config of 3 simple plugins](https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-example/src/index.ts#L18), produce the output:
and with a [config of 3 simple plugins](https://github.com/brightlocal/ts-migrate/blob/master/packages/ts-migrate-example/src/index.ts#L18), produce the output:

```typescript
function tlum(tsrif: number, dnoces: number): number {
Expand All @@ -27,12 +27,12 @@ function tlum(tsrif: number, dnoces: number): number {
}
```

You can read about codemods [here](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) and browse [ts-migrate repository](https://github.com/airbnb/ts-migrate) for additional examples and tests.
You can read about codemods [here](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) and browse [ts-migrate repository](https://github.com/brightlocal/ts-migrate) for additional examples and tests.

# I have an issue, what should I do?

Please file the issue [here](https://github.com/airbnb/ts-migrate/issues/new).
Please file the issue [here](https://github.com/brightlocal/ts-migrate/issues/new).

# Contributing

See the [Contributors Guide](https://github.com/airbnb/ts-migrate/blob/master/CONTRIBUTING.md).
See the [Contributors Guide](https://github.com/brightlocal/ts-migrate/blob/master/CONTRIBUTING.md).
6 changes: 3 additions & 3 deletions packages/ts-migrate-example/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@brightlocaldev/ts-migrate-example",
"version": "0.1.39",
"version": "0.1.40",
"private": "true",
"description": "Basic example of usage of the ts-migrate-server with writing a custom plugin",
"license": "MIT",
"scripts": {
"example": "ts-node -T -O '{ \"esModuleInterop\": true }' --skip-project src/index.ts"
},
"dependencies": {
"@brightlocaldev/ts-migrate-plugins": "^0.1.38",
"@brightlocaldev/ts-migrate-server": "^0.1.38",
"@brightlocaldev/ts-migrate-plugins": "^0.1.40",
"@brightlocaldev/ts-migrate-server": "^0.1.40",
"jscodeshift": "^0.12.0",
"ts-node": "^8.3.0",
"typescript": "4.7.2"
Expand Down
10 changes: 5 additions & 5 deletions packages/ts-migrate-plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@brightlocaldev/ts-migrate-plugins",
"version": "0.1.38",
"version": "0.1.40",
"description": "Set of codemods, which are doing transformation of js/jsx to ts/tsx",
"main": "build/src/index.js",
"directories": {
Expand All @@ -21,11 +21,11 @@
],
"repository": {
"type": "git",
"url": "https://github.com/airbnb/ts-migrate.git",
"url": "https://github.com/brightlocal/ts-migrate.git",
"directory": "packages/ts-migrate-plugins"
},
"bugs": {
"url": "https://github.com/airbnb/ts-migrate/issues"
"url": "https://github.com/brightlocal/ts-migrate/issues"
},
"scripts": {
"test": "jest --config jest-config.json",
Expand Down Expand Up @@ -56,10 +56,10 @@
"url": "https://github.com/lencioni"
}
],
"homepage": "https://github.com/airbnb/ts-migrate#readme",
"homepage": "https://github.com/brightlocal/ts-migrate#readme",
"license": "MIT",
"dependencies": {
"@brightlocaldev/ts-migrate-server": "^0.1.38",
"@brightlocaldev/ts-migrate-server": "^0.1.40",
"eslint": "^7.14.0",
"jscodeshift": "^0.13.0",
"json-schema": "^0.4.0",
Expand Down
23 changes: 11 additions & 12 deletions packages/ts-migrate-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@

# Install

Install *ts-migrate-server* using [npm](https://www.npmjs.com):
Install _ts-migrate-server_ using [npm](https://www.npmjs.com):

`npm install --save-dev ts-migrate-server`

Or [yarn](https://yarnpkg.com):

`yarn add --dev ts-migrate-server`


# Usage

```typescript
import path from 'path';
import { migrate, MigrateConfig } from 'ts-migrate-server';
import path from "path";
import { migrate, MigrateConfig } from "ts-migrate-server";

// get input files folder
const inputDir = path.resolve(__dirname, 'input');
const inputDir = path.resolve(__dirname, "input");

// create new migration config. You can add your plugins there
const config = new MigrateConfig();
Expand All @@ -34,20 +33,20 @@ process.exit(exitCode);

# FAQ

> How can I use *ts-migrate-server*?
> How can I use _ts-migrate-server_?
You can take a look at [basic usage example](https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-example/src/index.ts#L2).
Another resource would be [source code](https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate/cli.ts) of the *ts-migrate* cli.
You can take a look at [basic usage example](https://github.com/brightlocal/ts-migrate/blob/master/packages/ts-migrate-example/src/index.ts#L2).
Another resource would be [source code](https://github.com/brightlocal/ts-migrate/blob/master/packages/ts-migrate/cli.ts) of the _ts-migrate_ cli.

> Why not just use codemods?
You actually can use [codemods](https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-plugins/src/plugins/declare-missing-class-properties.ts) in your plugins!
*ts-migrate-server* provides a more standardized API around TypeScript compiler usage and allows us to use the benefits of the TypeScript APIs without complicated setup.
You actually can use [codemods](https://github.com/brightlocal/ts-migrate/blob/master/packages/ts-migrate-plugins/src/plugins/declare-missing-class-properties.ts) in your plugins!
_ts-migrate-server_ provides a more standardized API around TypeScript compiler usage and allows us to use the benefits of the TypeScript APIs without complicated setup.

> I have an issue with a specific plugin, what should I do?
Please file an [issue here](https://github.com/airbnb/ts-migrate/issues/new).
Please file an [issue here](https://github.com/brightlocal/ts-migrate/issues/new).

# Contributing

See the [Contributors Guide](https://github.com/airbnb/ts-migrate/blob/master/CONTRIBUTING.md).
See the [Contributors Guide](https://github.com/brightlocal/ts-migrate/blob/master/CONTRIBUTING.md).
8 changes: 4 additions & 4 deletions packages/ts-migrate-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@brightlocaldev/ts-migrate-server",
"version": "0.1.38",
"version": "0.1.40",
"description": "A package that contains the main migration runner and spawns a TSServer process",
"main": "build/src/index.js",
"directories": {
Expand All @@ -21,11 +21,11 @@
],
"repository": {
"type": "git",
"url": "https://github.com/airbnb/ts-migrate.git",
"url": "https://github.com/brightlocal/ts-migrate.git",
"directory": "packages/ts-migrate-server"
},
"bugs": {
"url": "https://github.com/airbnb/ts-migrate/issues"
"url": "https://github.com/brightlocal/ts-migrate/issues"
},
"scripts": {
"test": "jest --config jest-config.json",
Expand Down Expand Up @@ -56,7 +56,7 @@
"url": "https://github.com/lencioni"
}
],
"homepage": "https://github.com/airbnb/ts-migrate#readme",
"homepage": "https://github.com/brightlocal/ts-migrate#readme",
"license": "MIT",
"dependencies": {
"@ts-morph/bootstrap": "^0.16.0",
Expand Down
24 changes: 9 additions & 15 deletions packages/ts-migrate/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# ts-migrate

*ts-migrate is a tool for migrating frontend application to TypeScript.*
_ts-migrate is a tool for migrating frontend application to TypeScript._
Run `npx ts-migrate <folder>` to convert your frontend application to TypeScript.

*ts-migrate* is designed around Airbnb projects. Use at your own risk.

_ts-migrate_ is designed around Airbnb projects. Use at your own risk.

# Install

Install [*ts-migrate*](https://www.npmjs.com/package/ts-migrate) using [npm](https://www.npmjs.com):
Install [_ts-migrate_](https://www.npmjs.com/package/ts-migrate) using [npm](https://www.npmjs.com):

`npm install --save-dev ts-migrate`

Expand All @@ -23,7 +22,8 @@ Migrate an entire project like this:
```sh
npx -p ts-migrate -c "ts-migrate-full <folder>"
```
The `ts-migrate-full` command will perform a `git add` and `git commit` after each major step (_[details here]( https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate/bin/ts-migrate-full.sh )_).

The `ts-migrate-full` command will perform a `git add` and `git commit` after each major step (_[details here](https://github.com/brightlocal/ts-migrate/blob/master/packages/ts-migrate/bin/ts-migrate-full.sh)_).

Please note that it may take a long time to do a full migration.
You can also migrate individual parts of a project by specifying a subset of sources:
Expand Down Expand Up @@ -73,8 +73,8 @@ Examples:

If you are in a situation where you made some big project-wide changes, update of the common library like TypeScript, React or Redux or improve types for the large codebase. As a result of these operations, you might get quite a few TypeScript compilation errors. There are two ways to proceed:

1) Fix all the errors (ideal, but time-consuming).
2) Make the project compilable and fix errors gradually.
1. Fix all the errors (ideal, but time-consuming).
2. Make the project compilable and fix errors gradually.

For the second option we created a re-ignore script, which will fully automate this step. It will add `any` or `@ts-expect-error` (`@ts-ignores`) comments for all problematic places and will make your project compilable.

Expand Down Expand Up @@ -106,33 +106,27 @@ npx ts-migrate-full /path/to/your/project \
Unfortunately, no, it is only so smart. It does figure out types from propTypes, but it will fall back to `any` (`$TSFixMe`) for things it can't figure it out.


> I ran ts-migrate on my code and see lots of `@ts-expect-error` (`@ts-ignores`) and `any`. Is that expected?
The ts-migrate codemods are only so smart. So, follow up is required to refine the types and remove the `any` (`$TSFixMe`) and `@ts-expect-error` (`@ts-ignores`). The hope is that it's a nicer starting point than from scratch and that it helps accelerate the TypeScript migration process.


> Um... ts-migrate broke my code! D:
Please file the [issue here](https://github.com/airbnb/ts-migrate/issues/new).

Please file the [issue here](https://github.com/brightlocal/ts-migrate/issues/new).

> What is `$TSFixMe`?
It's just an alias to `any`: `type $TSFixMe = any;`. We use it at Airbnb for simplifying the migration experience.
We also have the same alias for functions: `type $TSFixMeFunction = (...args: any[]) => any;`.


> How did you use ts-migrate?
It was used a lot at Airbnb codebase! With the help of the ts-migrate we were able to migrate the main part of the entire codebase to the TypeScript. We were able to provide much better starting points in the migration for the huge applications (50k+ lines of codes) and they were migrated in one day!


> Is ts-migrate framework-oriented?
By itself, ts-migrate is not related to any framework. We created a set of plugins, which are related to the React (link to react). So, default configuration(link) contains plugins, which are expecting a react codebase as an input. We didn't test it on any other frameworks or libraries, use at your own risk!


# Contributing

See the [Contributors Guide](https://github.com/airbnb/ts-migrate/blob/master/CONTRIBUTING.md).
See the [Contributors Guide](https://github.com/brightlocal/ts-migrate/blob/master/CONTRIBUTING.md).
12 changes: 6 additions & 6 deletions packages/ts-migrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@brightlocaldev/ts-migrate",
"version": "0.1.39",
"version": "0.1.40",
"description": "A tool for migrating frontend application from JavaScript to TypeScript",
"directories": {
"test": "tests"
Expand All @@ -24,11 +24,11 @@
],
"repository": {
"type": "git",
"url": "https://github.com/airbnb/ts-migrate.git",
"url": "https://github.com/brightlocal/ts-migrate.git",
"directory": "packages/ts-migrate"
},
"bugs": {
"url": "https://github.com/airbnb/ts-migrate/issues"
"url": "https://github.com/brightlocal/ts-migrate/issues"
},
"scripts": {
"test": "jest --config jest-config.json",
Expand Down Expand Up @@ -59,11 +59,11 @@
"url": "https://github.com/lencioni"
}
],
"homepage": "https://github.com/airbnb/ts-migrate#readme",
"homepage": "https://github.com/brightlocal/ts-migrate#readme",
"license": "MIT",
"dependencies": {
"@brightlocaldev/ts-migrate-plugins": "^0.1.38",
"@brightlocaldev/ts-migrate-server": "^0.1.38",
"@brightlocaldev/ts-migrate-plugins": "^0.1.40",
"@brightlocaldev/ts-migrate-server": "^0.1.40",
"create-jest-runner": "^0.5.3",
"json5": "^2.1.1",
"json5-writer": "^0.1.8",
Expand Down

0 comments on commit 7bdb605

Please sign in to comment.