@tramvai/tools-migrate 0.5.128 → 0.5.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Tool for code migrations
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Tool for executing code migrations for the tramvai modules.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
How does it work:
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
7
|
+
- in published module folder `__migrations__` contains migrations files for the execution
|
|
8
|
+
- found migrations that were have not been executed before are running
|
|
9
|
+
- migrations can change files `package.json`, `tramvai.json` and project source code
|
|
10
|
+
- after migration run information about executed migrations is added to file `.tramvai-migrate-applied.json` to the project root
|
|
11
|
+
- all of the changed files after migrations should be added and committed to remote repository
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## How to
|
|
14
|
+
|
|
15
|
+
### Disable migrations
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
To disable migration add environment variable `SKIP_TRAMVAI_MIGRATIONS`.
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
### Add new migration
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
You can add new migration with command `yarn generate:migration`. You will need to specify package name for the migration and the migration name itself.
|
|
22
|
+
|
|
23
|
+
Also add to this package's `package.json` folder with the built migrations to the field `files` if it wasn't specified before:
|
|
20
24
|
|
|
21
25
|
```json
|
|
22
26
|
"files": [
|
|
@@ -25,19 +29,17 @@
|
|
|
25
29
|
],
|
|
26
30
|
```
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Миграция представляет собой функцию, принимающую специальное апи с помощью которого можно осуществлять изменения кода или конфигов.
|
|
32
|
+
Migration is a function that accepts special api using which it implements changes to the source code or configs.
|
|
31
33
|
|
|
32
34
|
```tsx
|
|
33
35
|
export interface Api {
|
|
34
|
-
packageJSON: PackageJSON; //
|
|
35
|
-
tramvaiJSON: TramvaiJSON; //
|
|
36
|
-
transform: (transformer: Transform, pathTransformer?: PathTransformer) => Promise<void>; //
|
|
36
|
+
packageJSON: PackageJSON; // object represented root package.json
|
|
37
|
+
tramvaiJSON: TramvaiJSON; // object represented tramvai.json
|
|
38
|
+
transform: (transformer: Transform, pathTransformer?: PathTransformer) => Promise<void>; // function that accepts transform function for `jscodeshift` and transform function for the file renames
|
|
37
39
|
}
|
|
38
40
|
```
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
Code transformations is done with [jscodeshift](https://github.com/facebook/jscodeshift)
|
|
41
43
|
|
|
42
44
|
## How to
|
|
43
45
|
|