@comet/upgrade 1.17.0 → 1.19.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,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.updateDependencyVersion = void 0;
|
|
13
|
+
const promises_1 = require("fs/promises");
|
|
14
|
+
const format_code_util_1 = require("./format-code.util");
|
|
15
|
+
function updateDependencyVersion(packageJsonPath, packageName, newVersion) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const fileContent = (yield (0, promises_1.readFile)(packageJsonPath)).toString();
|
|
18
|
+
const packageJson = JSON.parse(fileContent);
|
|
19
|
+
if (packageJson.dependencies && packageJson.dependencies[packageName]) {
|
|
20
|
+
packageJson.dependencies[packageName] = newVersion;
|
|
21
|
+
}
|
|
22
|
+
const updatedContent = JSON.stringify(packageJson, null, 4);
|
|
23
|
+
yield (0, promises_1.writeFile)(packageJsonPath, yield (0, format_code_util_1.formatCode)(updatedContent, packageJsonPath));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.updateDependencyVersion = updateDependencyVersion;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const fs_1 = __importDefault(require("fs"));
|
|
39
|
+
const crypto = __importStar(require("node:crypto"));
|
|
40
|
+
const ts_morph_1 = require("ts-morph");
|
|
41
|
+
function addSitePreviewSecret() {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
updateApiFiles1();
|
|
44
|
+
updateApiFiles2();
|
|
45
|
+
updateApiFiles3();
|
|
46
|
+
updateDotEnvFile();
|
|
47
|
+
updateValuesTplFile();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.default = addSitePreviewSecret;
|
|
51
|
+
function updateApiFiles1() {
|
|
52
|
+
console.log("Add sitePreviewSecret to api/src/config/environment-variables.ts ...");
|
|
53
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./api/tsconfig.json" });
|
|
54
|
+
const sourceFile = project.getSourceFile("api/src/config/environment-variables.ts");
|
|
55
|
+
if (!sourceFile) {
|
|
56
|
+
console.error(" Could not file file, make sure to add SITE_PREVIEW_SECRET");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const cls = sourceFile.getClass("EnvironmentVariables");
|
|
60
|
+
if (!cls) {
|
|
61
|
+
console.error(" Could not class EnvironmentVariables, make sure to add SITE_PREVIEW_SECRET");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
cls.addMember("\n@IsString()\n@MinLength(16)\nSITE_PREVIEW_SECRET: string;");
|
|
65
|
+
sourceFile.saveSync();
|
|
66
|
+
console.log(" finished");
|
|
67
|
+
}
|
|
68
|
+
function updateApiFiles2() {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
console.log("Add sitePreviewSecret to api/src/config/config.ts ...");
|
|
72
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./api/tsconfig.json" });
|
|
73
|
+
const sourceFile = project.getSourceFile("api/src/config/config.ts");
|
|
74
|
+
if (!sourceFile) {
|
|
75
|
+
console.error(" Could not file file, make sure to add sitePreviewSecret: envVars.SITE_PREVIEW_SECRET");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
(_b = (_a = sourceFile
|
|
79
|
+
.getFunction("createConfig")) === null || _a === void 0 ? void 0 : _a.getBody()) === null || _b === void 0 ? void 0 : _b.getDescendantsOfKind(ts_morph_1.SyntaxKind.ReturnStatement)[0].getChildrenOfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression)[0].addProperty("sitePreviewSecret: envVars.SITE_PREVIEW_SECRET,");
|
|
80
|
+
sourceFile.saveSync();
|
|
81
|
+
console.log(" finished");
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function updateApiFiles3() {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
console.log("Add sitePreviewSecret to api/src/app.module.ts ...");
|
|
88
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./api/tsconfig.json" });
|
|
89
|
+
const sourceFile = project.getSourceFile("api/src/app.module.ts");
|
|
90
|
+
if (!sourceFile) {
|
|
91
|
+
console.error(" Could not file file, make sure to add sitePreviewSecret to PageTreeModule");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
(_b = (_a = sourceFile
|
|
95
|
+
.getClassOrThrow("AppModule")
|
|
96
|
+
.getMethodOrThrow("forRoot")
|
|
97
|
+
.getBody()) === null || _a === void 0 ? void 0 : _a.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression).find((call) => call.getText().includes("PageTreeModule.forRoot"))) === null || _b === void 0 ? void 0 : _b.getChildrenOfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression)[0].addProperty("sitePreviewSecret: config.sitePreviewSecret,");
|
|
98
|
+
sourceFile.saveSync();
|
|
99
|
+
console.log(" finished");
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function updateDotEnvFile() {
|
|
103
|
+
console.log("Update .env");
|
|
104
|
+
if (!fs_1.default.existsSync(".env")) {
|
|
105
|
+
console.error(" could not find file, please make sure to add SITE_PREVIEW_SECRET manually");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
fs_1.default.appendFile(".env", `\nSITE_PREVIEW_SECRET=${crypto.randomBytes(8).toString("hex")}\n`, (err) => {
|
|
109
|
+
console.error(` ${err}`);
|
|
110
|
+
});
|
|
111
|
+
console.log(" finished");
|
|
112
|
+
}
|
|
113
|
+
function updateValuesTplFile() {
|
|
114
|
+
const valuesFileName = "deployment/helm/values.tpl.yaml";
|
|
115
|
+
console.log(`Update ${valuesFileName}`);
|
|
116
|
+
if (!fs_1.default.existsSync(valuesFileName)) {
|
|
117
|
+
console.error(" could not find file, please make sure to add SITE_PREVIEW_SECRET to api and remove authproxy-preview.");
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const file = fs_1.default.readFileSync(valuesFileName, "utf8");
|
|
121
|
+
const lines = file.split(/\n/);
|
|
122
|
+
let currentSection = "";
|
|
123
|
+
let sitePreviewLine = 0;
|
|
124
|
+
let beginAuthproxyPreviewLine = 0;
|
|
125
|
+
let endAuthproxyPreviewLine = 0;
|
|
126
|
+
lines.forEach((line, index) => {
|
|
127
|
+
const match = line.match(/(\s*)(.*):/);
|
|
128
|
+
if (match) {
|
|
129
|
+
if (match[1].length / 2 === 0)
|
|
130
|
+
currentSection = match[2];
|
|
131
|
+
if (currentSection === "api" && match[2] === "secrets") {
|
|
132
|
+
sitePreviewLine = index;
|
|
133
|
+
}
|
|
134
|
+
if (currentSection === "authproxy-preview" && !beginAuthproxyPreviewLine) {
|
|
135
|
+
beginAuthproxyPreviewLine = index;
|
|
136
|
+
}
|
|
137
|
+
if (currentSection !== "authproxy-preview" && beginAuthproxyPreviewLine > 0 && !endAuthproxyPreviewLine) {
|
|
138
|
+
endAuthproxyPreviewLine = index;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
if (sitePreviewLine) {
|
|
143
|
+
lines.splice(sitePreviewLine, 0, ' SITE_PREVIEW_SECRET: "{{ op://$OP_PREFIX-$OP_ENVIRONMENT/site-preview-secret-$APP_ENV/password }}"');
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
console.error(" Could not find api.secrets, please make sure to add SITE_PREVIEW_SECRET manually.");
|
|
147
|
+
}
|
|
148
|
+
if (beginAuthproxyPreviewLine && endAuthproxyPreviewLine) {
|
|
149
|
+
lines.splice(beginAuthproxyPreviewLine, endAuthproxyPreviewLine - beginAuthproxyPreviewLine);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
console.error(" Could not find authproxy-preview. Please make sure to remove it from deployment manually.");
|
|
153
|
+
}
|
|
154
|
+
const content = lines.join("\n").replace(/oauth2-proxy-preview/g, "site");
|
|
155
|
+
fs_1.default.writeFileSync(valuesFileName, content);
|
|
156
|
+
console.log(" finished.");
|
|
157
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const execute_command_util_1 = require("../util/execute-command.util");
|
|
14
|
+
const update_dependency_version_util_1 = require("../util/update-dependency-version.util");
|
|
15
|
+
const adminPackageJsonPath = "admin/package.json";
|
|
16
|
+
function updateMuiVersion() {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
if (!(0, fs_1.existsSync)(adminPackageJsonPath)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
yield (0, update_dependency_version_util_1.updateDependencyVersion)(adminPackageJsonPath, "@mui/material", "^6.0.0");
|
|
22
|
+
yield (0, update_dependency_version_util_1.updateDependencyVersion)(adminPackageJsonPath, "@mui/system", "^6.0.0");
|
|
23
|
+
yield (0, update_dependency_version_util_1.updateDependencyVersion)(adminPackageJsonPath, "@mui/utils", "^6.0.0");
|
|
24
|
+
yield (0, update_dependency_version_util_1.updateDependencyVersion)(adminPackageJsonPath, "@mui/icons-material", "^6.0.0");
|
|
25
|
+
yield (0, update_dependency_version_util_1.updateDependencyVersion)(adminPackageJsonPath, "@mui/lab", "^6.0.0-beta.10");
|
|
26
|
+
yield (0, execute_command_util_1.executeCommand)("npm", ["install", "--prefix", "admin", "--no-audit", "--loglevel", "error"]);
|
|
27
|
+
yield (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/list-item-button-prop", "admin/src"]);
|
|
28
|
+
yield (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/styled", "admin/src"]);
|
|
29
|
+
yield (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/sx-prop", "admin/src"]);
|
|
30
|
+
yield (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/theme-v6", "admin/src/theme.ts"]);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.default = updateMuiVersion;
|