forked from mobxjs/mobx
-
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.
Moved undecorate to separate package
- Loading branch information
1 parent
d523576
commit ec2f58c
Showing
11 changed files
with
2,400 additions
and
36 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
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Michel Weststrate | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 @@ | ||
# mobx-undecorate | ||
|
||
Converts MobX 5 to MobX 6 code | ||
|
||
Running this code mod: | ||
|
||
Go to the folder with your source files and run `npx mobx-undecorate`. | ||
|
||
This package converts the following MobX 4/5 API's to their MobX 6 equivalent | ||
|
||
- `@computed` | ||
- `@action` | ||
- `@observable` | ||
- `@observer` | ||
- `@inject` | ||
- `decorate | ||
|
||
### Options | ||
|
||
The following flags are accepted: | ||
|
||
- `--ignoreImports` Normally the codemod will only convert decorators if they are imported from a mobx package. This flag ignores checking for imports and converts all `@computed`, `@action`, `@observable`, `@observer` and `@inject` calls. | ||
- `--keepDecorators` doesn't rewrite decorators but keeps them as is. But still does generate the required `makeObservable` calls. Use this option if you convert to MobX 6 but will keep using decorators. | ||
- `--decoratorsAfterExport`: set this flag only if you have `decoratorsBeforeExport: false` in your Babel configuration. (Otherwise you will get an error like `SyntaxError: Decorators must be placed *before* the 'export' keyword. You can set the 'decoratorsBeforeExport' option to false`) |
2 changes: 1 addition & 1 deletion
2
codemod/undecorate.spec.ts → ...x-undecorate/__tests__/undecorate.spec.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
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,17 @@ | ||
#!/usr/bin/env node | ||
import { spawn } from "child_process" | ||
|
||
// this is pretty lame, probably better make a .cmd and .sh file... | ||
spawn( | ||
"node_modules/.bin/codeshift", | ||
[ | ||
"-t", | ||
"src/undecorate.ts", | ||
process.cwd(), | ||
...process.argv.filter(arg => arg.startsWith("--")).join(" ") | ||
], | ||
{ | ||
cwd: __dirname, | ||
stdio: "inherit" | ||
} | ||
) |
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,67 @@ | ||
{ | ||
"name": "mobx-undecorate", | ||
"version": "0.0.1", | ||
"description": "Migrate MobX 4/5 to MobX 6", | ||
"bin": "cli.js", | ||
"scripts": { | ||
"test": "../../node_modules/.bin/jest" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mobxjs/mobx.git" | ||
}, | ||
"author": "Michel Weststrate", | ||
"license": "MIT", | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/mobx" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/mobxjs/mobx/issues" | ||
}, | ||
"files": [ | ||
"cli.js", | ||
"src", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"homepage": "https://mobx.js.org/", | ||
"dependencies": { | ||
"@babel/core": "^7.9.0", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/plugin-proposal-decorators": "^7.8.3", | ||
"@babel/plugin-transform-runtime": "^7.9.0", | ||
"@babel/preset-env": "^7.9.5", | ||
"@babel/preset-typescript": "^7.9.0", | ||
"@babel/runtime": "^7.9.2", | ||
"@types/jest": "^25.2.1", | ||
"@types/jscodeshift": "^0.7.0", | ||
"@types/node": "^11.15.12", | ||
"dedent-js": "^1.0.1", | ||
"jscodeshift": "^0.7.0" | ||
}, | ||
"keywords": [ | ||
"mobx" | ||
], | ||
"jest": { | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest", | ||
"^.+\\.jsx?$": "babel-jest" | ||
}, | ||
"testRegex": "__tests__/.*\\.(t|j)sx?$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/", | ||
"/\\./" | ||
], | ||
"watchPathIgnorePatterns": [ | ||
"<rootDir>/node_modules/" | ||
] | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.