@comet/upgrade 1.32.0 → 1.33.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.
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ts_morph_1 = require("ts-morph");
4
+ /**
5
+ * From
6
+ *
7
+ * if (error instanceof ValidationError) {
8
+ * return new ValidationError("Invalid request.");
9
+ * }
10
+ *
11
+ * to
12
+ *
13
+ * if (error.extensions?.code === "GRAPHQL_VALIDATION_FAILED") {
14
+ * return new ValidationError("Invalid request.");
15
+ * }
16
+ */
17
+ async function updateGraphQLFormatError() {
18
+ const project = new ts_morph_1.Project({ tsConfigFilePath: "./api/tsconfig.json" });
19
+ const sourceFile = project.getSourceFile("api/src/app.module.ts");
20
+ if (!sourceFile) {
21
+ throw new Error("app.module.ts not found");
22
+ }
23
+ // Change the import
24
+ sourceFile.getImportDeclaration((importDeclaration) => importDeclaration.getModuleSpecifierValue() === "apollo-server-express")?.remove();
25
+ sourceFile.addImportDeclaration({ namedImports: ["ValidationError"], moduleSpecifier: "@nestjs/apollo" });
26
+ // Update the if statement
27
+ sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.BinaryExpression).forEach((node) => {
28
+ if (node.getText() === "error instanceof ValidationError") {
29
+ node.replaceWithText(`error.extensions?.code === "GRAPHQL_VALIDATION_FAILED"`);
30
+ }
31
+ });
32
+ await sourceFile.save();
33
+ }
34
+ exports.default = updateGraphQLFormatError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comet/upgrade",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "description": "Upgrade scripts for Comet DXP",
5
5
  "homepage": "https://github.com/vivid-planet/comet-upgrade#readme",
6
6
  "bugs": {