|
2 | 2 | // Licensed under the GNU Affero General Public License (AGPL).
|
3 | 3 | // See License.AGPL.txt in the project root for license information.
|
4 | 4 |
|
5 |
| -// Update JetBrains Platform Version |
| 5 | +// Update JetBrains Plugins (gateway / backend) Platform Version |
| 6 | +// |
| 7 | +// ``` |
| 8 | +// bun run index-jb-platform-update.ts --task=<id> |
| 9 | +// ``` |
6 | 10 |
|
7 |
| -import path from "path"; |
8 |
| -import { parseArgs } from "util"; |
9 |
| -import { pathToProjectRoot } from "./lib/common"; |
10 |
| -import { jbUpdatePlatformVersion } from "./lib/jb-update-platform-version"; |
| 11 | +import { getTaskFromArgs } from "./lib/jb-helper/jb-gradle-task-config"; |
| 12 | +import { |
| 13 | + parseGradleProperties, |
| 14 | + renderPropertiesTemplate, |
| 15 | + parseGradlePropertiesFromTaskConfig, |
| 16 | +} from "./lib/jb-helper/jb-helper"; |
| 17 | +import { fetchProductReleases } from "./lib/jb-helper/jb-releases"; |
11 | 18 |
|
12 |
| -const targetInfo = [ |
13 |
| - { |
14 |
| - id: 1, |
15 |
| - taskName: "Latest Backend Plugin", |
16 |
| - productCode: "IIU", |
17 |
| - productType: "eap,rc,release", |
18 |
| - xmlName: "IntelliJ IDEA", |
19 |
| - xmlChannels: ["IC-IU-EAP-licensing-RELEASE", "IC-IU-EAP-licensing-EAP", "IC-IU-RELEASE-licensing-RELEASE"], |
20 |
| - useXml: true, |
21 |
| - gradlePropertiesPath: path.resolve( |
22 |
| - pathToProjectRoot, |
23 |
| - "components/ide/jetbrains/backend-plugin/gradle-latest.properties", |
24 |
| - ), |
25 |
| - gradlePropertiesTemplate: `# Code generated by gha-update-image/index-jb-platform-update.ts. DO NOT EDIT. |
26 |
| -# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html |
27 |
| -# for insight into build numbers and IntelliJ Platform versions. |
28 |
| -# revert pluginSinceBuild if it's unnecessary |
29 |
| -pluginSinceBuild={{pluginSinceBuild}} |
30 |
| -pluginUntilBuild={{pluginUntilBuild}} |
31 |
| -# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl |
32 |
| -# See https://jb.gg/intellij-platform-builds-list for available build versions. |
33 |
| -pluginVerifierIdeVersions={{pluginVerifierIdeVersions}} |
34 |
| -# Version from "com.jetbrains.intellij.idea" which can be found at https://www.jetbrains.com/intellij-repository/snapshots |
35 |
| -platformVersion={{platformVersion}} |
36 |
| -`, |
37 |
| - }, |
38 |
| - { |
39 |
| - id: 2, |
40 |
| - taskName: "Latest Frontend Plugin", |
41 |
| - productCode: "GW", |
42 |
| - productType: "eap,rc,release", |
43 |
| - xmlName: "Gateway", |
44 |
| - xmlChannels: ["GW-EAP-licensing-EAP", "GW-RELEASE-licensing-RELEASE", "GW-EAP-licensing-RELEASE"], |
45 |
| - useXml: true, |
46 |
| - useHumanreadableVersion: true, |
47 |
| - gradlePropertiesPath: path.resolve( |
48 |
| - pathToProjectRoot, |
49 |
| - "components/ide/jetbrains/gateway-plugin/gradle-latest.properties", |
50 |
| - ), |
51 |
| - gradlePropertiesTemplate: `# Code generated by gha-update-image/index-jb-platform-update.ts. DO NOT EDIT. |
52 |
| -# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html |
53 |
| -# for insight into build numbers and IntelliJ Platform versions. |
54 |
| -# revert pluginSinceBuild if it's unnecessary |
55 |
| -pluginSinceBuild={{pluginSinceBuild}} |
56 |
| -pluginUntilBuild={{pluginUntilBuild}} |
57 |
| -# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl |
58 |
| -# See https://jb.gg/intellij-platform-builds-list for available build versions. |
59 |
| -pluginVerifierIdeVersions={{pluginVerifierIdeVersions}} |
60 |
| -# Version from "com.jetbrains.gateway" which can be found at https://www.jetbrains.com/intellij-repository/snapshots |
61 |
| -platformVersion={{platformVersion}} |
62 |
| -`, |
63 |
| - }, |
64 |
| - { |
65 |
| - id: 3, |
66 |
| - taskName: "Stable Frontend Plugin", |
67 |
| - productCode: "GW", |
68 |
| - productType: "release", |
69 |
| - xmlName: "Gateway", |
70 |
| - xmlChannels: ["GW-RELEASE-licensing-RELEASE"], |
71 |
| - useXml: true, |
72 |
| - useHumanreadableVersion: true, |
73 |
| - gradlePropertiesPath: path.resolve( |
74 |
| - pathToProjectRoot, |
75 |
| - "components/ide/jetbrains/gateway-plugin/gradle-stable.properties", |
76 |
| - ), |
77 |
| - gradlePropertiesTemplate: `# Code generated by gha-update-image/index-jb-platform-update.ts. DO NOT EDIT. |
78 |
| -# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html |
79 |
| -# for insight into build numbers and IntelliJ Platform versions. |
80 |
| -# revert pluginSinceBuild if it's unnecessary |
81 |
| -pluginSinceBuild={{pluginSinceBuild}} |
82 |
| -pluginUntilBuild={{pluginUntilBuild}} |
83 |
| -# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl |
84 |
| -# See https://jb.gg/intellij-platform-builds-list for available build versions. |
85 |
| -pluginVerifierIdeVersions={{pluginVerifierIdeVersions}} |
86 |
| -# Version from "com.jetbrains.gateway" which can be found at https://www.jetbrains.com/updates/updates.xml |
87 |
| -platformVersion={{platformVersion}} |
88 |
| -`, |
89 |
| - }, |
90 |
| -]; |
| 19 | +const task = getTaskFromArgs(false); |
91 | 20 |
|
92 |
| -const { values } = parseArgs({ |
93 |
| - args: Bun.argv, |
94 |
| - options: { |
95 |
| - task: { |
96 |
| - type: "string", |
97 |
| - }, |
98 |
| - }, |
99 |
| - strict: true, |
100 |
| - allowPositionals: true, |
101 |
| -}); |
| 21 | +console.log("Updating", task.taskName); |
102 | 22 |
|
103 |
| -const taskID = Number.parseInt(values.task ?? "NaN"); |
| 23 | +const releases = await fetchProductReleases(task); |
| 24 | +const newProps = parseGradlePropertiesFromTaskConfig(task, releases[0]); |
| 25 | +console.log("New properties info:", newProps); |
| 26 | +const oldProps = parseGradleProperties(await Bun.file(task.gradlePropertiesPath).text()); |
| 27 | +console.log("Old properties info:", oldProps); |
104 | 28 |
|
105 |
| -const target = targetInfo.find((e) => e.id === taskID); |
106 |
| -if (!target) { |
107 |
| - throw new Error( |
108 |
| - `Invalid task id: ${taskID}, update cmd with \`--task="<name>"\`, available tasks: \n\t- ${targetInfo |
109 |
| - .map((e) => `(${e.id}) ${e.taskName}`) |
110 |
| - .join("\n\t- ")}`, |
111 |
| - ); |
| 29 | +if (newProps.platformVersion === oldProps.platformVersion) { |
| 30 | + console.warn("PlatformVersion are the same, no need to update platform version"); |
| 31 | + process.exit(0); |
112 | 32 | }
|
113 |
| -console.log("Updating", target.taskName); |
114 |
| -jbUpdatePlatformVersion(target); |
| 33 | + |
| 34 | +const newGradleContent = renderPropertiesTemplate("gha-update-image/index-jb-platform-update.ts", task, newProps); |
| 35 | + |
| 36 | +await Bun.write(task.gradlePropertiesPath, newGradleContent); |
| 37 | + |
| 38 | +console.log("Updated platform version to:", newProps.platformVersion); |
0 commit comments