@comet/upgrade 1.70.0 → 1.72.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,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ts_morph_1 = require("ts-morph");
|
|
4
|
+
async function updateS3Config() {
|
|
5
|
+
console.log(`🚀 Update s3 config to new structure.`);
|
|
6
|
+
const filePath = "api/src/config/config.ts";
|
|
7
|
+
const project = new ts_morph_1.Project();
|
|
8
|
+
const sourceFile = project.addSourceFileAtPath(filePath);
|
|
9
|
+
// Find the createConfig function
|
|
10
|
+
const createConfigFn = sourceFile.getFunctionOrThrow("createConfig");
|
|
11
|
+
const returnStmt = createConfigFn.getBodyOrThrow().getDescendantsOfKind(ts_morph_1.SyntaxKind.ReturnStatement)[0];
|
|
12
|
+
const returnObj = returnStmt.getExpressionIfKindOrThrow(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
13
|
+
// Navigate to blob.storage.s3
|
|
14
|
+
let s3Prop;
|
|
15
|
+
try {
|
|
16
|
+
const blobProp = returnObj.getPropertyOrThrow("blob").getFirstDescendantByKindOrThrow(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
17
|
+
const storageProp = blobProp.getPropertyOrThrow("storage").getFirstDescendantByKindOrThrow(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
18
|
+
s3Prop = storageProp.getPropertyOrThrow("s3").getFirstDescendantByKindOrThrow(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.log("☑️ No S3 configuration found in the specified file. Skipping update.");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
// Get accessKeyId and secretAccessKey
|
|
25
|
+
const accessKeyIdProp = s3Prop.getProperty("accessKeyId");
|
|
26
|
+
const secretAccessKeyProp = s3Prop.getProperty("secretAccessKey");
|
|
27
|
+
if (accessKeyIdProp && secretAccessKeyProp) {
|
|
28
|
+
s3Prop.addPropertyAssignment({
|
|
29
|
+
name: "credentials",
|
|
30
|
+
initializer: `{
|
|
31
|
+
${accessKeyIdProp.getText()},
|
|
32
|
+
${secretAccessKeyProp.getText()}
|
|
33
|
+
}`,
|
|
34
|
+
});
|
|
35
|
+
accessKeyIdProp.remove();
|
|
36
|
+
secretAccessKeyProp.remove();
|
|
37
|
+
await sourceFile.save();
|
|
38
|
+
console.log(`✅ Structure changed.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.default = updateS3Config;
|
|
@@ -0,0 +1,88 @@
|
|
|
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 ts_morph_1 = require("ts-morph");
|
|
6
|
+
const package_json_util_1 = require("../util/package-json.util");
|
|
7
|
+
exports.stage = "before-install";
|
|
8
|
+
/**
|
|
9
|
+
* Prepares the admin to use the MUI DatePicker in a grid by:
|
|
10
|
+
* 1. Installing dependencies:
|
|
11
|
+
* - @mui/x-date-pickers
|
|
12
|
+
* - date-fns
|
|
13
|
+
* 2. Setting up LocalizationProvider:
|
|
14
|
+
* - Adds required imports
|
|
15
|
+
* - Wraps app with LocalizationProvider (above MuiThemeProvider)
|
|
16
|
+
* - Configures enUS locale with internationalization note
|
|
17
|
+
*/
|
|
18
|
+
async function UseMuiDatePickerInGrid() {
|
|
19
|
+
if (!(0, node_fs_1.existsSync)("admin/package.json")) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const packageJson = new package_json_util_1.PackageJson("admin/package.json");
|
|
23
|
+
packageJson.addDependency("@mui/x-date-pickers", "^7.29.4");
|
|
24
|
+
packageJson.addDependency("date-fns", "^4.1.0");
|
|
25
|
+
packageJson.save();
|
|
26
|
+
// Set up LocalizationProvider
|
|
27
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./admin/tsconfig.json" });
|
|
28
|
+
const appFile = project.getSourceFile("admin/src/App.tsx");
|
|
29
|
+
if (!appFile) {
|
|
30
|
+
console.error("🛑 App.tsx not found in admin/src. Skipping LocalizationProvider setup.");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Check if LocalizationProvider is already in use
|
|
34
|
+
const hasLocalizationProvider = appFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.JsxElement).some((element) => {
|
|
35
|
+
const openingTag = element.getOpeningElement().getTagNameNode().getText();
|
|
36
|
+
return openingTag === "LocalizationProvider";
|
|
37
|
+
});
|
|
38
|
+
if (hasLocalizationProvider) {
|
|
39
|
+
console.log("☑️ LocalizationProvider is already set up in App.tsx - skipping further steps in this codemod.");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// Add imports if they don't exist
|
|
43
|
+
if (!appFile.getImportDeclaration((imp) => imp.getModuleSpecifierValue() === "@mui/x-date-pickers")) {
|
|
44
|
+
console.log("✅ Adding LocalizationProvider import to App.tsx");
|
|
45
|
+
appFile.addImportDeclaration({
|
|
46
|
+
moduleSpecifier: "@mui/x-date-pickers",
|
|
47
|
+
namedImports: [{ name: "LocalizationProvider" }],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (!appFile.getImportDeclaration((imp) => imp.getModuleSpecifierValue() === "@mui/x-date-pickers/AdapterDateFns")) {
|
|
51
|
+
console.log("✅ Adding AdapterDateFns import to App.tsx");
|
|
52
|
+
appFile.addImportDeclaration({
|
|
53
|
+
moduleSpecifier: "@mui/x-date-pickers/AdapterDateFns",
|
|
54
|
+
namedImports: [{ name: "AdapterDateFns" }],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// Add date-fns locale import
|
|
58
|
+
if (!appFile.getImportDeclaration((imp) => imp.getModuleSpecifierValue() === "date-fns/locale")) {
|
|
59
|
+
console.log("✅ Adding date-fns locale import to App.tsx");
|
|
60
|
+
appFile.addImportDeclaration({
|
|
61
|
+
moduleSpecifier: "date-fns/locale",
|
|
62
|
+
namedImports: [{ name: "enUS" }],
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// Find MuiThemeProvider and wrap its content with LocalizationProvider
|
|
66
|
+
const muiThemeProvider = appFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.JsxElement).find((element) => {
|
|
67
|
+
const openingTag = element.getOpeningElement().getTagNameNode().getText();
|
|
68
|
+
return openingTag === "MuiThemeProvider" || openingTag === "ThemeProvider";
|
|
69
|
+
});
|
|
70
|
+
if (muiThemeProvider) {
|
|
71
|
+
console.log("✅ Adding LocalizationProvider wrapper above MuiThemeProvider");
|
|
72
|
+
muiThemeProvider.replaceWithText(`<LocalizationProvider
|
|
73
|
+
dateAdapter={AdapterDateFns}
|
|
74
|
+
/*
|
|
75
|
+
* TODO: If the application uses internationalization or another language than enUS,
|
|
76
|
+
* the locale must be adapted to the correct one from date-fns/locale
|
|
77
|
+
*/
|
|
78
|
+
adapterLocale={enUS}
|
|
79
|
+
>
|
|
80
|
+
${muiThemeProvider.getText()}
|
|
81
|
+
</LocalizationProvider>`);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
console.error("🛑 Could not find MuiThemeProvider in App.tsx");
|
|
85
|
+
}
|
|
86
|
+
await appFile.save();
|
|
87
|
+
}
|
|
88
|
+
exports.default = UseMuiDatePickerInGrid;
|