@comet/upgrade 1.113.0 → 1.115.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/lib/v8/admin/before-install/update-graphql-admin.js +15 -0
- package/lib/v8/site/after-install/remove-graphql-client-from-site-preview-handlers.js +40 -31
- package/lib/v8/site/before-install/update-graphql-site.js +15 -0
- package/package.json +1 -1
- package/lib/v8/remove-graphql-fetch-from-site-preview-route.js +0 -56
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stage = void 0;
|
|
4
|
+
exports.default = updateGraphqlAdmin;
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const package_json_util_1 = require("../../../util/package-json.util");
|
|
7
|
+
exports.stage = "before-install";
|
|
8
|
+
async function updateGraphqlAdmin() {
|
|
9
|
+
if (!(0, fs_1.existsSync)("admin/package.json")) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const packageJson = new package_json_util_1.PackageJson("admin/package.json");
|
|
13
|
+
packageJson.updateDependency("graphql", "^16.10.0");
|
|
14
|
+
packageJson.save();
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = removeGraphQLClientFromSitePreviewHandlers;
|
|
4
|
-
const
|
|
4
|
+
const glob_1 = require("glob");
|
|
5
5
|
const ts_morph_1 = require("ts-morph");
|
|
6
6
|
/**
|
|
7
7
|
* Removes the GraphQL client/fetch from the site preview handlers
|
|
@@ -11,39 +11,48 @@ const ts_morph_1 = require("ts-morph");
|
|
|
11
11
|
*/
|
|
12
12
|
async function removeGraphQLClientFromSitePreviewHandlers() {
|
|
13
13
|
const project = new ts_morph_1.Project({ tsConfigFilePath: "./site/tsconfig.json" });
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const sourceFile = project.getSourceFile(
|
|
14
|
+
const files = glob_1.glob.sync(["site/src/**/*.ts"]);
|
|
15
|
+
for (const filePath of files) {
|
|
16
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
17
17
|
if (!sourceFile) {
|
|
18
|
-
throw new Error(
|
|
18
|
+
throw new Error(`Can't get source file for ${filePath}`);
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
const importsSitePreviewRoute = Boolean(sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue().includes("@comet/cms-site") &&
|
|
21
|
+
declaration
|
|
22
|
+
.getNamedImports()
|
|
23
|
+
.map((imp) => imp.getText())
|
|
24
|
+
.includes("sitePreviewRoute")));
|
|
25
|
+
if (importsSitePreviewRoute) {
|
|
26
|
+
sourceFile.forEachDescendant((node) => {
|
|
27
|
+
if (node.isKind(ts_morph_1.SyntaxKind.CallExpression)) {
|
|
28
|
+
const callExpr = node;
|
|
29
|
+
const expression = callExpr.getExpression();
|
|
30
|
+
if (expression.getText() === "sitePreviewRoute") {
|
|
31
|
+
if (callExpr.getArguments().length > 1) {
|
|
32
|
+
callExpr.removeArgument(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
26
37
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (callExpression) {
|
|
45
|
-
callExpression.removeArgument(2);
|
|
38
|
+
const legacyPagesRouterSitePreviewApiHandler = Boolean(sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue().includes("@comet/cms-site") &&
|
|
39
|
+
declaration
|
|
40
|
+
.getNamedImports()
|
|
41
|
+
.map((imp) => imp.getText())
|
|
42
|
+
.includes("legacyPagesRouterSitePreviewApiHandler")));
|
|
43
|
+
if (legacyPagesRouterSitePreviewApiHandler) {
|
|
44
|
+
sourceFile.forEachDescendant((node) => {
|
|
45
|
+
if (node.isKind(ts_morph_1.SyntaxKind.CallExpression)) {
|
|
46
|
+
const callExpr = node;
|
|
47
|
+
const expression = callExpr.getExpression();
|
|
48
|
+
if (expression.getText() === "legacyPagesRouterSitePreviewApiHandler") {
|
|
49
|
+
if (callExpr.getArguments().length > 2) {
|
|
50
|
+
callExpr.removeArgument(2);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
46
55
|
}
|
|
47
|
-
|
|
56
|
+
sourceFile.saveSync();
|
|
48
57
|
}
|
|
49
58
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stage = void 0;
|
|
4
|
+
exports.default = updateGraphqlSite;
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const package_json_util_1 = require("../../../util/package-json.util");
|
|
7
|
+
exports.stage = "before-install";
|
|
8
|
+
async function updateGraphqlSite() {
|
|
9
|
+
if (!(0, fs_1.existsSync)("site/package.json")) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const packageJson = new package_json_util_1.PackageJson("site/package.json");
|
|
13
|
+
packageJson.updateDependency("graphql", "^16.10.0");
|
|
14
|
+
packageJson.save();
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = removeGraphQLFetchFromSitePreviewRoute;
|
|
4
|
-
const glob_1 = require("glob");
|
|
5
|
-
const ts_morph_1 = require("ts-morph");
|
|
6
|
-
/**
|
|
7
|
-
* Remove the second argument from sitePreviewRoute(request, createGraphQLFetch());
|
|
8
|
-
* Remove the third argument from legacyPagesRouterSitePreviewApiHandler(req, res, createGraphQLClient());
|
|
9
|
-
*/
|
|
10
|
-
async function removeGraphQLFetchFromSitePreviewRoute() {
|
|
11
|
-
const project = new ts_morph_1.Project({ tsConfigFilePath: "./site/tsconfig.json" });
|
|
12
|
-
const files = glob_1.glob.sync(["site/src/**/*.ts"]);
|
|
13
|
-
for (const filePath of files) {
|
|
14
|
-
const sourceFile = project.getSourceFile(filePath);
|
|
15
|
-
if (!sourceFile) {
|
|
16
|
-
throw new Error(`Can't get source file for ${filePath}`);
|
|
17
|
-
}
|
|
18
|
-
const importsSitePreviewRoute = Boolean(sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue().includes("@comet/cms-site") &&
|
|
19
|
-
declaration
|
|
20
|
-
.getNamedImports()
|
|
21
|
-
.map((imp) => imp.getText())
|
|
22
|
-
.includes("sitePreviewRoute")));
|
|
23
|
-
if (importsSitePreviewRoute) {
|
|
24
|
-
sourceFile.forEachDescendant((node) => {
|
|
25
|
-
if (node.isKind(ts_morph_1.SyntaxKind.CallExpression)) {
|
|
26
|
-
const callExpr = node;
|
|
27
|
-
const expression = callExpr.getExpression();
|
|
28
|
-
if (expression.getText() === "sitePreviewRoute") {
|
|
29
|
-
if (callExpr.getArguments().length > 1) {
|
|
30
|
-
callExpr.removeArgument(1);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
const legacyPagesRouterSitePreviewApiHandler = Boolean(sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue().includes("@comet/cms-site") &&
|
|
37
|
-
declaration
|
|
38
|
-
.getNamedImports()
|
|
39
|
-
.map((imp) => imp.getText())
|
|
40
|
-
.includes("legacyPagesRouterSitePreviewApiHandler")));
|
|
41
|
-
if (legacyPagesRouterSitePreviewApiHandler) {
|
|
42
|
-
sourceFile.forEachDescendant((node) => {
|
|
43
|
-
if (node.isKind(ts_morph_1.SyntaxKind.CallExpression)) {
|
|
44
|
-
const callExpr = node;
|
|
45
|
-
const expression = callExpr.getExpression();
|
|
46
|
-
if (expression.getText() === "legacyPagesRouterSitePreviewApiHandler") {
|
|
47
|
-
if (callExpr.getArguments().length > 2) {
|
|
48
|
-
callExpr.removeArgument(2);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
sourceFile.saveSync();
|
|
55
|
-
}
|
|
56
|
-
}
|