@comet/upgrade 1.25.0 → 1.27.0
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
CHANGED
|
@@ -39,17 +39,10 @@ npx @comet/upgrade v7/hide-graphql-field-suggestions.ts
|
|
|
39
39
|
cd project-you-want-to-upgrade/
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
Run the upgrade script. Replace `<path-to-comet-upgrade-repository>` with the location of the cloned comet-upgrade repository (e.g., `../comet-upgrade/`):
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Execute the local @comet/upgrade binary:
|
|
49
|
-
|
|
50
|
-
```sh
|
|
51
|
-
../comet-upgrade/bin/index.js 4 # comet-upgrade directory
|
|
52
|
-
|
|
45
|
+
<path-to-comet-upgrade-repository>/bin/index.js v4/change-something.ts
|
|
53
46
|
```
|
|
54
47
|
|
|
55
48
|
Verify the changes in your project. If something is not as expected, adapt the upgrade script accordingly and then run it again on a clean state:
|
|
@@ -57,5 +50,5 @@ npx @comet/upgrade v7/hide-graphql-field-suggestions.ts
|
|
|
57
50
|
```sh
|
|
58
51
|
git reset --hard HEAD
|
|
59
52
|
|
|
60
|
-
|
|
53
|
+
<path-to-comet-upgrade-repository>/bin/index.js v4/change-something.ts
|
|
61
54
|
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ts_morph_1 = require("ts-morph");
|
|
4
|
+
/**
|
|
5
|
+
* from
|
|
6
|
+
*
|
|
7
|
+
* createAuthResolver({
|
|
8
|
+
* currentUser: CurrentUser,
|
|
9
|
+
* }),
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* to
|
|
13
|
+
*
|
|
14
|
+
* createAuthResolver({}),
|
|
15
|
+
*/
|
|
16
|
+
async function removeCurrentUserFromAuthModule() {
|
|
17
|
+
console.log("Remove Current User From Auth Module");
|
|
18
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./api/tsconfig.json" });
|
|
19
|
+
const sourceFiles = project.getSourceFiles("api/src/**/*.ts");
|
|
20
|
+
sourceFiles.forEach((sourceFile) => {
|
|
21
|
+
const createAuthResolverCall = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression).find((callExpression) => {
|
|
22
|
+
const expression = callExpression.getExpression();
|
|
23
|
+
return expression.getText() === "createAuthResolver";
|
|
24
|
+
});
|
|
25
|
+
if (createAuthResolverCall) {
|
|
26
|
+
const argument = createAuthResolverCall.getArguments()[0];
|
|
27
|
+
if (argument && argument.getKind() === ts_morph_1.SyntaxKind.ObjectLiteralExpression) {
|
|
28
|
+
const objectLiteral = argument.asKindOrThrow(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
29
|
+
const currentUserProp = objectLiteral.getProperty("currentUser");
|
|
30
|
+
if (currentUserProp) {
|
|
31
|
+
console.log("Found createAuthResolver and removed currentUser in ", sourceFile.getFilePath());
|
|
32
|
+
currentUserProp.remove();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
sourceFile.save();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.default = removeCurrentUserFromAuthModule;
|