@comet/upgrade 1.51.0 → 1.52.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,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stage = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const package_json_util_1 = require("../util/package-json.util");
|
|
6
|
+
const adminEslintConfig = `import eslintConfigReact from "@comet/eslint-config/react.js";
|
|
7
|
+
|
|
8
|
+
/** @type {import('eslint')} */
|
|
9
|
+
const config = [
|
|
10
|
+
{
|
|
11
|
+
ignores: ["schema.json", "src/fragmentTypes.json", "dist/**", "src/**/*.generated.ts"],
|
|
12
|
+
},
|
|
13
|
+
...eslintConfigReact,
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
export default config;`;
|
|
17
|
+
const apiEslintConfig = `import eslintConfigNestJs from "@comet/eslint-config/nestjs.js";
|
|
18
|
+
|
|
19
|
+
/** @type {import('eslint')} */
|
|
20
|
+
const config = [
|
|
21
|
+
{
|
|
22
|
+
ignores: ["src/db/migrations/**", "dist/**", "src/**/*.generated.ts"],
|
|
23
|
+
},
|
|
24
|
+
...eslintConfigNestJs,
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export default config;`;
|
|
28
|
+
const siteEslintConfig = `import eslintConfigNextJs from "@comet/eslint-config/nextjs.js";
|
|
29
|
+
|
|
30
|
+
/** @type {import('eslint')} */
|
|
31
|
+
const config = [
|
|
32
|
+
{
|
|
33
|
+
ignores: ["**/**/*.generated.ts", "dist/**", "lang/**", "lang-compiled/**", "lang-extracted/**", ".next/**", "public/**"],
|
|
34
|
+
},
|
|
35
|
+
...eslintConfigNextJs,
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
export default config;`;
|
|
39
|
+
exports.stage = "before-install";
|
|
40
|
+
/**
|
|
41
|
+
* This Updates script is doing following:
|
|
42
|
+
*
|
|
43
|
+
* - updates eslint to version 9.
|
|
44
|
+
* - creates new eslint.config.mjs file with default configuration
|
|
45
|
+
* - copies content from .eslint.json to new eslint.config.mjs as a comment
|
|
46
|
+
* - deletes old .eslint.json file
|
|
47
|
+
*/
|
|
48
|
+
async function updateEslint() {
|
|
49
|
+
if ((0, fs_1.existsSync)("admin/package.json")) {
|
|
50
|
+
updateDevDependenciesInPackageJsons({ packageJsonPath: "admin/package.json" });
|
|
51
|
+
createNewFlatConfigurationFile({
|
|
52
|
+
workingDirectory: "admin/",
|
|
53
|
+
fileContent: adminEslintConfig,
|
|
54
|
+
});
|
|
55
|
+
deleteOldEslintRc({ workingDirectory: "admin/" });
|
|
56
|
+
}
|
|
57
|
+
if ((0, fs_1.existsSync)("api/package.json")) {
|
|
58
|
+
updateDevDependenciesInPackageJsons({ packageJsonPath: "api/package.json" });
|
|
59
|
+
createNewFlatConfigurationFile({
|
|
60
|
+
workingDirectory: "api/",
|
|
61
|
+
fileContent: apiEslintConfig,
|
|
62
|
+
});
|
|
63
|
+
deleteOldEslintRc({ workingDirectory: "api/" });
|
|
64
|
+
}
|
|
65
|
+
if ((0, fs_1.existsSync)("site/package.json")) {
|
|
66
|
+
updateDevDependenciesInPackageJsons({ packageJsonPath: "site/package.json" });
|
|
67
|
+
createNewFlatConfigurationFile({
|
|
68
|
+
workingDirectory: "site/",
|
|
69
|
+
fileContent: siteEslintConfig,
|
|
70
|
+
});
|
|
71
|
+
deleteOldEslintRc({ workingDirectory: "site/" });
|
|
72
|
+
// remove .eslintrc.cli.js
|
|
73
|
+
if ((0, fs_1.existsSync)("site/.eslintrc.cli.js")) {
|
|
74
|
+
(0, fs_1.rmSync)("site/.eslintrc.cli.js");
|
|
75
|
+
const packageJson = new package_json_util_1.PackageJson("site/package.json");
|
|
76
|
+
packageJson.removeScript("lint:eslint");
|
|
77
|
+
packageJson.addScript("lint:eslint", "eslint --max-warnings 0 src/ **/*.json --no-warn-ignored");
|
|
78
|
+
packageJson.save();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.default = updateEslint;
|
|
83
|
+
const updateDevDependenciesInPackageJsons = ({ packageJsonPath }) => {
|
|
84
|
+
console.log(`🚀 Update eslint to v9.18.0 in ${packageJsonPath}`);
|
|
85
|
+
const packageJson = new package_json_util_1.PackageJson(packageJsonPath);
|
|
86
|
+
packageJson.updateDependency("eslint", "^9.18.0");
|
|
87
|
+
packageJson.save();
|
|
88
|
+
};
|
|
89
|
+
const createNewFlatConfigurationFile = ({ workingDirectory, fileContent }) => {
|
|
90
|
+
console.log(`🚀 Create new eslint.config.mjs flat configuration .file ${workingDirectory}`);
|
|
91
|
+
const eslintConfig = (0, fs_1.readFileSync)(`${workingDirectory}.eslintrc.json`, "utf-8");
|
|
92
|
+
const commentedEslintConfig = eslintConfig
|
|
93
|
+
.split("\n")
|
|
94
|
+
.map((line) => `// ${line}`)
|
|
95
|
+
.join("\n");
|
|
96
|
+
const oldEslintConfigTodo = `// TODO: integrate custom rules from project into new eslint.config.mjs file
|
|
97
|
+
//
|
|
98
|
+
// Content from .eslintrc.json:
|
|
99
|
+
//
|
|
100
|
+
${commentedEslintConfig}
|
|
101
|
+
`;
|
|
102
|
+
(0, fs_1.writeFileSync)(`${workingDirectory}eslint.config.mjs`, oldEslintConfigTodo + fileContent);
|
|
103
|
+
};
|
|
104
|
+
const deleteOldEslintRc = ({ workingDirectory }) => {
|
|
105
|
+
console.log(`🚀 Delete old .eslintrc.json configuration file ${workingDirectory}`);
|
|
106
|
+
(0, fs_1.rmSync)(`${workingDirectory}.eslintrc.json`);
|
|
107
|
+
};
|