reset completely
Signed-off-by: pengzhile <pengzhile@gmail.com>
This commit is contained in:
		
							parent
							
								
									f7b3d92ce5
								
							
						
					
					
						commit
						d1c6256b0d
					
				|  | @ -4,7 +4,7 @@ plugins { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| group 'io.zhile.research.intellij' | group 'io.zhile.research.intellij' | ||||||
| version '1.0.3' | version '1.0.4' | ||||||
| 
 | 
 | ||||||
| repositories { | repositories { | ||||||
|     mavenCentral() |     mavenCentral() | ||||||
|  | @ -25,6 +25,8 @@ intellij { | ||||||
| 
 | 
 | ||||||
| patchPluginXml { | patchPluginXml { | ||||||
|     changeNotes """ |     changeNotes """ | ||||||
|  |     release v1.0.4 | ||||||
|  |       1. reset completely | ||||||
|     release v1.0.3 |     release v1.0.3 | ||||||
|       1. bug fix |       1. bug fix | ||||||
|     release v1.0.2 |     release v1.0.2 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| #!/bin/bash | #!/bin/bash | ||||||
| # reset jetbrains ide evals | # reset jetbrains ide evals v1.0.4 | ||||||
| 
 | 
 | ||||||
| OS_NAME=$(uname -s) | OS_NAME=$(uname -s) | ||||||
| JB_PRODUCTS="IntelliJIdea CLion PhpStorm GoLand PyCharm WebStorm Rider DataGrip RubyMine AppCode" | JB_PRODUCTS="IntelliJIdea CLion PhpStorm GoLand PyCharm WebStorm Rider DataGrip RubyMine AppCode" | ||||||
|  | @ -9,7 +9,9 @@ if [ "$OS_NAME" == "Darwin" ]; then | ||||||
| 
 | 
 | ||||||
|   for PRD in $JB_PRODUCTS; do |   for PRD in $JB_PRODUCTS; do | ||||||
|     rm -rf ~/Library/Preferences/"${PRD}"*/eval |     rm -rf ~/Library/Preferences/"${PRD}"*/eval | ||||||
|  |     sed -i '' '/name="evlsprt.*"/d' ~/Library/Preferences/"${PRD}"*/options/other.xml >/dev/null 2>&1 | ||||||
|     rm -rf ~/Library/Application\ Support/JetBrains/"${PRD}"*/eval |     rm -rf ~/Library/Application\ Support/JetBrains/"${PRD}"*/eval | ||||||
|  |     sed -i '' '/name="evlsprt.*"/d' ~/Library/Application\ Support/JetBrains/"${PRD}"*/options/other.xml >/dev/null 2>&1 | ||||||
|   done |   done | ||||||
| 
 | 
 | ||||||
|   plutil -remove "/.JetBrains\.UserIdOnMachine" ~/Library/Preferences/com.apple.java.util.prefs.plist >/dev/null |   plutil -remove "/.JetBrains\.UserIdOnMachine" ~/Library/Preferences/com.apple.java.util.prefs.plist >/dev/null | ||||||
|  | @ -20,7 +22,9 @@ elif [ "$OS_NAME" == "Linux" ]; then | ||||||
| 
 | 
 | ||||||
|   for PRD in $JB_PRODUCTS; do |   for PRD in $JB_PRODUCTS; do | ||||||
|     rm -rf ~/."${PRD}"*/config/eval |     rm -rf ~/."${PRD}"*/config/eval | ||||||
|  |     sed -i '/name="evlsprt.*"/d' ~/."${PRD}"*/config/options/other.xml >/dev/null 2>&1 | ||||||
|     rm -rf ~/.config/JetBrains/"${PRD}"*/eval |     rm -rf ~/.config/JetBrains/"${PRD}"*/eval | ||||||
|  |     sed -i '/name="evlsprt.*"/d' ~/.config/JetBrains/"${PRD}"*/options/other.xml >/dev/null 2>&1 | ||||||
|   done |   done | ||||||
| 
 | 
 | ||||||
|   sed -i '/key="JetBrains\.UserIdOnMachine"/d' ~/.java/.userPrefs/prefs.xml |   sed -i '/key="JetBrains\.UserIdOnMachine"/d' ~/.java/.userPrefs/prefs.xml | ||||||
|  |  | ||||||
|  | @ -1,3 +1,4 @@ | ||||||
|  | ' reset jetbrains ide evals v1.0.4 | ||||||
| Set oShell = CreateObject("WScript.Shell") | Set oShell = CreateObject("WScript.Shell") | ||||||
| Set oFS = CreateObject("Scripting.FileSystemObject") | Set oFS = CreateObject("Scripting.FileSystemObject") | ||||||
| sHomeFolder = oShell.ExpandEnvironmentStrings("%USERPROFILE%") | sHomeFolder = oShell.ExpandEnvironmentStrings("%USERPROFILE%") | ||||||
|  | @ -9,26 +10,43 @@ re.IgnoreCase = True | ||||||
| re.Pattern    = "\.?(IntelliJIdea|GoLand|CLion|PyCharm|DataGrip|RubyMine|AppCode|PhpStorm|WebStorm|Rider).*" | re.Pattern    = "\.?(IntelliJIdea|GoLand|CLion|PyCharm|DataGrip|RubyMine|AppCode|PhpStorm|WebStorm|Rider).*" | ||||||
| 
 | 
 | ||||||
| Sub removeEval(ByVal file, ByVal sEvalPath) | Sub removeEval(ByVal file, ByVal sEvalPath) | ||||||
| 	bMatch = re.Test(file.Name) |     bMatch = re.Test(file.Name) | ||||||
|     If Not bMatch Then |     If Not bMatch Then | ||||||
| 		Exit Sub |         Exit Sub | ||||||
| 	End If |     End If | ||||||
| 
 | 
 | ||||||
| 	If oFS.FolderExists(sEvalPath) Then |     If oFS.FolderExists(sEvalPath) Then | ||||||
| 		oFS.DeleteFolder sEvalPath, True  |         oFS.DeleteFolder sEvalPath, True | ||||||
| 	End If |     End If | ||||||
|  | 
 | ||||||
|  |     content = "" | ||||||
|  |     otherFile = oFS.GetParentFolderName(sEvalPath) + "\options\other.xml" | ||||||
|  |     If oFS.FileExists(otherFile) Then | ||||||
|  |         Set txtStream = oFS.OpenTextFile(otherFile, 1, False) | ||||||
|  |         Do While Not txtStream.AtEndOfStream | ||||||
|  |             line = txtStream.ReadLine | ||||||
|  |             If InStr(line, "name=""evlsprt") = 0 Then | ||||||
|  |                 content = content + line + vbLf | ||||||
|  |             End If | ||||||
|  |         Loop | ||||||
|  |         txtStream.Close | ||||||
|  | 
 | ||||||
|  |         Set txtStream = oFS.OpenTextFile(otherFile, 2, False) | ||||||
|  |         txtStream.Write content | ||||||
|  |         txtStream.Close | ||||||
|  |     End If | ||||||
| End Sub | End Sub | ||||||
| 
 | 
 | ||||||
| If oFS.FolderExists(sHomeFolder) Then | If oFS.FolderExists(sHomeFolder) Then | ||||||
| 	For Each oFile In oFS.GetFolder(sHomeFolder).SubFolders |     For Each oFile In oFS.GetFolder(sHomeFolder).SubFolders | ||||||
|     	removeEval oFile, sHomeFolder + "\" + oFile.Name + "\config\eval" |         removeEval oFile, sHomeFolder + "\" + oFile.Name + "\config\eval" | ||||||
| 	Next |     Next | ||||||
| End If | End If | ||||||
| 
 | 
 | ||||||
| If oFS.FolderExists(sJBDataFolder) Then | If oFS.FolderExists(sJBDataFolder) Then | ||||||
| 	For Each oFile In oFS.GetFolder(sJBDataFolder).SubFolders |     For Each oFile In oFS.GetFolder(sJBDataFolder).SubFolders | ||||||
| 	    removeEval oFile, sJBDataFolder + "\" + oFile.Name + "\eval" |         removeEval oFile, sJBDataFolder + "\" + oFile.Name + "\eval" | ||||||
| 	Next |     Next | ||||||
| End If | End If | ||||||
| 
 | 
 | ||||||
| On Error Resume Next | On Error Resume Next | ||||||
|  |  | ||||||
|  | @ -16,12 +16,16 @@ import io.zhile.research.intellij.helper.NotificationHelper; | ||||||
| import org.jetbrains.annotations.NotNull; | import org.jetbrains.annotations.NotNull; | ||||||
| 
 | 
 | ||||||
| import java.io.File; | import java.io.File; | ||||||
|  | import java.io.IOException; | ||||||
|  | import java.nio.file.Files; | ||||||
| import java.nio.file.Paths; | import java.nio.file.Paths; | ||||||
| import java.util.prefs.BackingStoreException; | import java.util.Scanner; | ||||||
| import java.util.prefs.Preferences; | import java.util.prefs.Preferences; | ||||||
| 
 | 
 | ||||||
| public class ResetAction extends AnAction { | public class ResetAction extends AnAction { | ||||||
|     private static final String OLD_MACHINE_ID_KEY = "JetBrains.UserIdOnMachine"; |     private static final String OLD_MACHINE_ID_KEY = "JetBrains.UserIdOnMachine"; | ||||||
|  |     private static final String NEW_MACHINE_ID_KEY = "user_id_on_machine"; | ||||||
|  |     private static final String DEVICE_ID_KEY = "device_id"; | ||||||
|     private static final String DEFAULT_COMPANY_NAME = "jetbrains"; |     private static final String DEFAULT_COMPANY_NAME = "jetbrains"; | ||||||
| 
 | 
 | ||||||
|     public ResetAction() { |     public ResetAction() { | ||||||
|  | @ -39,18 +43,35 @@ public class ResetAction extends AnAction { | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         File optionsFile = getOptionsFile(); | ||||||
|  |         if (optionsFile.exists()) { | ||||||
|  |             try (Scanner scanner = new Scanner(optionsFile)) { | ||||||
|  |                 StringBuilder sbContent = new StringBuilder(); | ||||||
|  |                 while (scanner.hasNextLine()) { | ||||||
|  |                     String line = scanner.nextLine(); | ||||||
|  |                     if (!line.contains("name=\"evlsprt")) { | ||||||
|  |                         sbContent.append(line).append("\n"); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  |                 Files.write(Paths.get(optionsFile.toURI()), sbContent.toString().getBytes()); | ||||||
|  |             } catch (IOException e) { | ||||||
|  |                 NotificationHelper.showError(project, e.getMessage()); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance(); |         ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance(); | ||||||
| 
 | 
 | ||||||
|         String companyName = appInfo.getShortCompanyName(); |         String companyName = appInfo.getShortCompanyName(); | ||||||
|         String node = StringUtil.isEmptyOrSpaces(companyName) ? DEFAULT_COMPANY_NAME : companyName.toLowerCase(); |         String node = StringUtil.isEmptyOrSpaces(companyName) ? DEFAULT_COMPANY_NAME : companyName.toLowerCase(); | ||||||
| 
 | 
 | ||||||
|         try { |         Preferences prefsRoot = Preferences.userRoot(); | ||||||
|             Preferences.userRoot().remove(OLD_MACHINE_ID_KEY); |         Preferences prefs = prefsRoot.node(node); | ||||||
|             Preferences.userRoot().node(node).removeNode(); | 
 | ||||||
|         } catch (BackingStoreException e) { |         prefsRoot.remove(OLD_MACHINE_ID_KEY); | ||||||
|             NotificationHelper.showError(project, e.getMessage()); |         prefs.remove(NEW_MACHINE_ID_KEY); | ||||||
|             return; |         prefs.remove(DEVICE_ID_KEY); | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         Preferences.userRoot().node(Constants.PLUGIN_NAME).put(Constants.PRODUCT_NAME + Constants.PRODUCT_HASH, Long.toString(System.currentTimeMillis())); |         Preferences.userRoot().node(Constants.PLUGIN_NAME).put(Constants.PRODUCT_NAME + Constants.PRODUCT_HASH, Long.toString(System.currentTimeMillis())); | ||||||
| 
 | 
 | ||||||
|  | @ -91,4 +112,10 @@ public class ResetAction extends AnAction { | ||||||
| 
 | 
 | ||||||
|         return new File(configPath, "eval"); |         return new File(configPath, "eval"); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     protected File getOptionsFile() { | ||||||
|  |         String configPath = PathManager.getConfigPath(); | ||||||
|  | 
 | ||||||
|  |         return new File(new File(configPath, "options"), "other.xml"); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 pengzhile
						pengzhile