@comet/upgrade 1.46.0 → 1.48.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/v7/replace-exception-interceptor-with-exception-filter.js +35 -9
- package/lib/v8/clipboard-helpers.js +68 -0
- package/lib/v8/merge-blocks-admin-into-cms-admin.js +56 -0
- package/lib/v8/remove-blocks-packages.js +9 -4
- package/lib/v8/replace-nestjs-console-with-nest-commander.js +20 -0
- package/lib/v8/update-nest-dependencies.js +0 -1
- package/package.json +1 -1
|
@@ -1,19 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const format_code_util_1 = require("../util/format-code.util");
|
|
3
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
4
|
/**
|
|
6
5
|
* Replaces the old ExceptionInterceptor with the new ExceptionFilter
|
|
7
6
|
*/
|
|
8
7
|
async function replaceExceptionInterceptorWithExceptionFilter() {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
if (!
|
|
12
|
-
console.log("ExceptionInterceptor not found in main.ts. Make sure that you use the new ExceptionFilter.");
|
|
8
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./api/tsconfig.json" });
|
|
9
|
+
const sourceFile = project.getSourceFile("api/src/main.ts");
|
|
10
|
+
if (!sourceFile) {
|
|
13
11
|
return;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const cmsApiImport = sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue() === "@comet/cms-api");
|
|
14
|
+
if (!cmsApiImport) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const exceptionInterceptorImport = cmsApiImport.getNamedImports().find((namedImport) => namedImport.getName() === "ExceptionInterceptor");
|
|
18
|
+
if (!exceptionInterceptorImport) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const bootstrap = sourceFile.getFirstDescendantByKind(ts_morph_1.SyntaxKind.FunctionDeclaration);
|
|
22
|
+
if (!bootstrap) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const useGlobalInterceptors = sourceFile
|
|
26
|
+
.getDescendantsOfKind(ts_morph_1.SyntaxKind.ExpressionStatement)
|
|
27
|
+
.find((node) => node.getText().includes("useGlobalInterceptors"));
|
|
28
|
+
if (!useGlobalInterceptors) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
bootstrap.insertStatements(useGlobalInterceptors.getChildIndex() + 1, "app.useGlobalFilters(new ExceptionFilter(config.debug));");
|
|
32
|
+
const exceptionInterceptor = useGlobalInterceptors
|
|
33
|
+
.getDescendantsOfKind(ts_morph_1.SyntaxKind.NewExpression)
|
|
34
|
+
.find((node) => node.getText().includes("ExceptionInterceptor"));
|
|
35
|
+
if (exceptionInterceptor) {
|
|
36
|
+
useGlobalInterceptors.getFirstDescendantByKindOrThrow(ts_morph_1.SyntaxKind.CallExpression).removeArgument(exceptionInterceptor);
|
|
37
|
+
if (useGlobalInterceptors.getDescendantsOfKind(ts_morph_1.SyntaxKind.NewExpression).length === 0) {
|
|
38
|
+
useGlobalInterceptors.remove();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exceptionInterceptorImport.remove();
|
|
42
|
+
cmsApiImport.addNamedImport("ExceptionFilter");
|
|
43
|
+
await sourceFile.save();
|
|
18
44
|
}
|
|
19
45
|
exports.default = replaceExceptionInterceptorWithExceptionFilter;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const glob_1 = require("glob");
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
/**
|
|
6
|
+
* readClipboard -> readClipboardText
|
|
7
|
+
* writeClipboard -> writeClipboardText
|
|
8
|
+
*/
|
|
9
|
+
async function updateClipboardHelpers() {
|
|
10
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./admin/tsconfig.json" });
|
|
11
|
+
const files = glob_1.glob.sync(["admin/src/**/*.ts", "admin/src/**/*.tsx"]);
|
|
12
|
+
for (const filePath of files) {
|
|
13
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
14
|
+
if (!sourceFile) {
|
|
15
|
+
throw new Error(`Can't get source file for ${filePath}`);
|
|
16
|
+
}
|
|
17
|
+
const blocksAdminImport = sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue().includes("@comet/blocks-admin"));
|
|
18
|
+
if (!blocksAdminImport) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const cometAdminImport = sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue() === "@comet/admin");
|
|
22
|
+
const readClipboardImport = blocksAdminImport.getNamedImports().find((namedImport) => namedImport.getText() === "readClipboard");
|
|
23
|
+
if (readClipboardImport) {
|
|
24
|
+
// Remove old import
|
|
25
|
+
readClipboardImport.remove();
|
|
26
|
+
// Add new import
|
|
27
|
+
if (cometAdminImport) {
|
|
28
|
+
cometAdminImport.addNamedImports(["readClipboardText"]);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
sourceFile.addImportDeclaration({
|
|
32
|
+
namedImports: ["readClipboardText"],
|
|
33
|
+
moduleSpecifier: "@comet/admin",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Update usages
|
|
37
|
+
sourceFile
|
|
38
|
+
.getDescendantsOfKind(ts_morph_1.SyntaxKind.Identifier)
|
|
39
|
+
.filter((node) => node.getText() === "readClipboard")
|
|
40
|
+
.forEach((node) => node.replaceWithText("readClipboardText"));
|
|
41
|
+
}
|
|
42
|
+
const writeClipboardImport = blocksAdminImport.getNamedImports().find((namedImport) => namedImport.getText() === "writeClipboard");
|
|
43
|
+
if (writeClipboardImport) {
|
|
44
|
+
// Remove old import
|
|
45
|
+
writeClipboardImport.remove();
|
|
46
|
+
// Add new import
|
|
47
|
+
if (cometAdminImport) {
|
|
48
|
+
cometAdminImport.addNamedImports(["writeClipboardText"]);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
sourceFile.addImportDeclaration({
|
|
52
|
+
namedImports: ["writeClipboardText"],
|
|
53
|
+
moduleSpecifier: "@comet/admin",
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// Update usages
|
|
57
|
+
sourceFile
|
|
58
|
+
.getDescendantsOfKind(ts_morph_1.SyntaxKind.Identifier)
|
|
59
|
+
.filter((node) => node.getText() === "writeClipboard")
|
|
60
|
+
.forEach((node) => node.replaceWithText("writeClipboardText"));
|
|
61
|
+
}
|
|
62
|
+
if (blocksAdminImport.getNamedImports().length === 0) {
|
|
63
|
+
blocksAdminImport.remove();
|
|
64
|
+
}
|
|
65
|
+
await sourceFile.save();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.default = updateClipboardHelpers;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const promises_1 = require("fs/promises");
|
|
4
|
+
const glob_1 = require("glob");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
const renamedExports = {
|
|
7
|
+
createCompositeSetting: "createCompositeBlockField",
|
|
8
|
+
createCompositeSettings: "createCompositeBlockFields",
|
|
9
|
+
IPreviewContext: "BlockPreviewContext",
|
|
10
|
+
PreviewStateInterface: "BlockPreviewStateInterface",
|
|
11
|
+
AdminComponentPart: "BlockAdminComponentPart",
|
|
12
|
+
AdminComponentButton: "BlockAdminComponentButton",
|
|
13
|
+
AdminComponentNestedButton: "BlockAdminComponentNestedButton",
|
|
14
|
+
AdminComponentPaper: "BlockAdminComponentPaper",
|
|
15
|
+
useAdminComponentPaper: "useBlockAdminComponentPaper",
|
|
16
|
+
AdminComponentRoot: "BlockAdminComponentRoot",
|
|
17
|
+
AdminComponentSection: "BlockAdminComponentSection",
|
|
18
|
+
AdminComponentSectionGroup: "BlockAdminComponentSectionGroup",
|
|
19
|
+
AdminTabLabel: "BlockAdminTabLabel",
|
|
20
|
+
AdminTabsProps: "BlockAdminTabsProps",
|
|
21
|
+
AdminTabs: "BlockAdminTabs",
|
|
22
|
+
};
|
|
23
|
+
async function mergeBlocksAdminIntoCmsAdmin() {
|
|
24
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./admin/tsconfig.json" });
|
|
25
|
+
const files = glob_1.glob.sync(["admin/src/**/*.ts", "admin/src/**/*.tsx"]);
|
|
26
|
+
for (const filePath of files) {
|
|
27
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
28
|
+
if (!sourceFile) {
|
|
29
|
+
throw new Error(`Can't get source file for ${filePath}`);
|
|
30
|
+
}
|
|
31
|
+
const blocksAdminImport = sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue().includes("@comet/blocks-admin"));
|
|
32
|
+
if (!blocksAdminImport) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const blocksAdminImports = blocksAdminImport.getNamedImports().map((namedImport) => namedImport.getText());
|
|
36
|
+
const importsToRename = Object.entries(renamedExports).filter(([oldExport]) => blocksAdminImports.includes(oldExport));
|
|
37
|
+
blocksAdminImport.remove();
|
|
38
|
+
const cmsAdminImport = sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue().includes("@comet/cms-admin"));
|
|
39
|
+
if (cmsAdminImport) {
|
|
40
|
+
cmsAdminImport.addNamedImports(blocksAdminImports);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
sourceFile.addImportDeclaration({
|
|
44
|
+
namedImports: blocksAdminImports,
|
|
45
|
+
moduleSpecifier: "@comet/cms-admin",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
await sourceFile.save();
|
|
49
|
+
let fileContent = (await (0, promises_1.readFile)(filePath)).toString();
|
|
50
|
+
for (const [oldExport, newExport] of importsToRename) {
|
|
51
|
+
fileContent = fileContent.replaceAll(oldExport, newExport);
|
|
52
|
+
}
|
|
53
|
+
await (0, promises_1.writeFile)(filePath, fileContent);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.default = mergeBlocksAdminIntoCmsAdmin;
|
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stage = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
|
-
const
|
|
5
|
+
const package_json_util_1 = require("../util/package-json.util");
|
|
6
6
|
exports.stage = "before-install";
|
|
7
7
|
async function removeBlocksPackages() {
|
|
8
8
|
if ((0, fs_1.existsSync)("api/package.json")) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const packageJson = new package_json_util_1.PackageJson("api/package.json");
|
|
10
|
+
packageJson.removeDependency("@comet/blocks-api");
|
|
11
|
+
packageJson.save();
|
|
12
|
+
}
|
|
13
|
+
if ((0, fs_1.existsSync)("admin/package.json")) {
|
|
14
|
+
const packageJson = new package_json_util_1.PackageJson("admin/package.json");
|
|
15
|
+
packageJson.removeDependency("@comet/blocks-admin");
|
|
16
|
+
packageJson.save();
|
|
12
17
|
}
|
|
13
18
|
}
|
|
14
19
|
exports.default = removeBlocksPackages;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stage = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const package_json_util_1 = require("../util/package-json.util");
|
|
6
|
+
exports.stage = "before-install";
|
|
7
|
+
/**
|
|
8
|
+
* Replace the nestjs-console package with nest-commander
|
|
9
|
+
*/
|
|
10
|
+
async function ReplaceNestJsConsoleWithNestCommander() {
|
|
11
|
+
if (!(0, node_fs_1.existsSync)("api/package.json")) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const packageJson = new package_json_util_1.PackageJson("api/package.json");
|
|
15
|
+
packageJson.removeDependency("nestjs-console");
|
|
16
|
+
packageJson.addDependency("nest-commander", "^3.16.0");
|
|
17
|
+
packageJson.addDependency("@types/inquirer", "^8.1.3", true);
|
|
18
|
+
packageJson.save();
|
|
19
|
+
}
|
|
20
|
+
exports.default = ReplaceNestJsConsoleWithNestCommander;
|
|
@@ -18,7 +18,6 @@ async function updateNestDependencies() {
|
|
|
18
18
|
packageJson.updateDependency("@nestjs/graphql", "^12.0.0");
|
|
19
19
|
packageJson.updateDependency("@nestjs/platform-express", "^10.0.0");
|
|
20
20
|
packageJson.updateDependency("graphql", "^16.6.0");
|
|
21
|
-
packageJson.updateDependency("nestjs-console", "^9.0.0");
|
|
22
21
|
packageJson.updateDependency("@golevelup/nestjs-discovery", "^4.0.0");
|
|
23
22
|
packageJson.updateDependency("@nestjs/cli", "^10.0.0");
|
|
24
23
|
packageJson.updateDependency("@nestjs/schematics", "^10.0.0");
|