-
Notifications
You must be signed in to change notification settings - Fork 260
chore: update readme playwright dependency version #1760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package com.microsoft.playwright.tools; | ||
|
|
||
| import java.io.FileWriter; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
| import java.util.NoSuchElementException; | ||
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
|
||
| public class UpdatePlaywrightVersion { | ||
| private static final Pattern VERSION_PATTERN = Pattern.compile( | ||
| "<groupId>com.microsoft.playwright</groupId>\\s*<artifactId>parent-pom</artifactId>\\s*<version>(\\d+\\.\\d+\\.\\d+)(?:-SNAPSHOT)?</version>" | ||
| ); | ||
| private static final Pattern MAVEN_PATTERN = Pattern.compile( | ||
| "(<dependency>\\s*<groupId>com.microsoft.playwright</groupId>\\s*<artifactId>playwright</artifactId>\\s*)<version>\\d+\\.\\d+\\.\\d+</version>(\\s*</dependency>)" | ||
| ); | ||
| private static final Pattern GRADLE_PATTERN = Pattern.compile( | ||
| "(implementation group: 'com.microsoft.playwright', name: 'playwright', version: )'\\d+\\.\\d+\\.\\d+'" | ||
| ); | ||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| Path pomPath = Paths.get("pom.xml"); | ||
| String pomContent = Files.readString(pomPath, UTF_8); | ||
|
|
||
| Matcher versionMatcher = VERSION_PATTERN.matcher(pomContent); | ||
| if (!versionMatcher.find()) { | ||
| throw new NoSuchElementException("Project version was not found"); | ||
| } | ||
| String version = versionMatcher.group(1); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Version in pom.xml usually refers to the next development version, which hasn't been published yet. Let's set it to major.(minor-1).0 similar to what we did in #1748. Also would be nice to unify this two places, sot that the versions are patched at the same place with the same deps version.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we can move it to JS like its done in https://github.com/microsoft/playwright-java/pull/1748/files - then the actual PR should be much smaller. |
||
|
|
||
| Path readmePath = Paths.get("README.md"); | ||
| String readme = Files.readString(readmePath, UTF_8); | ||
|
|
||
| String updatedReadme = updateDependencies(readme, version); | ||
|
|
||
| try (FileWriter writer = new FileWriter(readmePath.toFile(), UTF_8)) { | ||
| writer.write(updatedReadme); | ||
| } | ||
| } | ||
|
|
||
| private static String updateDependencies(String readme, String version) { | ||
| readme = MAVEN_PATTERN.matcher(readme) | ||
| .replaceAll("$1<version>" + version + "</version>$2"); | ||
|
|
||
| readme = GRADLE_PATTERN.matcher(readme) | ||
| .replaceAll("$1'" + version + "'"); | ||
|
|
||
| return readme; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it much multiline by default (without MULTILINE flag) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
