From f6963033f0ea4595706a9c2d18b4462f28caa5bc Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Wed, 12 Dec 2018 22:47:43 -0500 Subject: [PATCH 1/8] updated for Delphi 10.3 These are updates made automatically by the Delphi IDE. --- Delphi/Project/ExercismCLIInstaller.dproj | 61 +++++++++++++++++++++-- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/Delphi/Project/ExercismCLIInstaller.dproj b/Delphi/Project/ExercismCLIInstaller.dproj index 667d427..54b8d92 100644 --- a/Delphi/Project/ExercismCLIInstaller.dproj +++ b/Delphi/Project/ExercismCLIInstaller.dproj @@ -7,7 +7,7 @@ 1153 Application VCL - 18.4 + 18.5 Win32 @@ -97,7 +97,6 @@ true - true true Win32\Release CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.5.3.2;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.5;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) @@ -107,6 +106,7 @@ 2 true true + PerMonitor DEBUG;$(DCC_Define) @@ -118,11 +118,11 @@ true - true true CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) Win32\Debug Win32\Debug + PerMonitor @@ -187,7 +187,6 @@ 1 - Contents\MacOS 0 @@ -197,6 +196,12 @@ 1 + + + res\xml + 1 + + library\lib\armeabi-v7a @@ -233,6 +238,12 @@ 1 + + + res\values-v21 + 1 + + res\drawable @@ -311,6 +322,11 @@ 1 .framework + + Contents\MacOS + 1 + .framework + 0 @@ -333,6 +349,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .dll;.bpl @@ -356,6 +377,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .bpl @@ -378,6 +404,10 @@ Contents\Resources\StartUp\ 0 + + Contents\Resources\StartUp\ + 0 + 0 @@ -514,23 +544,41 @@ 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + ..\ 1 + + ..\ + 1 + Contents 1 + + Contents + 1 + Contents\Resources 1 + + Contents\Resources + 1 + @@ -553,6 +601,10 @@ Contents\MacOS 1 + + Contents\MacOS + 1 + 0 @@ -592,6 +644,7 @@ + From e4cb32de3472ebbb7be05a648e494d38b0d7ce27 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Wed, 12 Dec 2018 22:49:03 -0500 Subject: [PATCH 2/8] replace ovclabel with linklabel --- Delphi/Project/Source/uClientDownloadFrm.dfm | 35 +++++++++--------- Delphi/Project/Source/uConfigApiFrm.dfm | 34 +++++++++--------- Delphi/Project/Source/uInstallLocationFrm.dfm | 36 ++++++++----------- 3 files changed, 47 insertions(+), 58 deletions(-) diff --git a/Delphi/Project/Source/uClientDownloadFrm.dfm b/Delphi/Project/Source/uClientDownloadFrm.dfm index 763a0cf..f8910c5 100644 --- a/Delphi/Project/Source/uClientDownloadFrm.dfm +++ b/Delphi/Project/Source/uClientDownloadFrm.dfm @@ -111,24 +111,6 @@ object frmDownload: TfrmDownload ParentFont = False Transparent = True end - object urlDocs: TOvcURL - Left = 404 - Top = 32 - Width = 125 - Height = 18 - Hint = 'http://cli.exercism.io' - Caption = 'CLI Documentation' - URL = 'http://cli.exercism.io' - UseVisitedColor = True - Font.Charset = DEFAULT_CHARSET - Font.Color = clWhite - Font.Height = -15 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - Transparent = True - Visible = False - end object imgV2Logo: TImage Left = 5 Top = 7 @@ -6284,6 +6266,22 @@ object frmDownload: TfrmDownload FFFF} Stretch = True end + object urlDocs: TLinkLabel + Left = 404 + Top = 32 + Width = 150 + Height = 22 + Caption = 'https://exercism.io/cli/' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -15 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 0 + Visible = False + OnLinkClick = urlDocsLinkClick + end end object btnCancel: TButton Left = 421 @@ -6344,7 +6342,6 @@ object frmDownload: TfrmDownload AcceptCharset = 'UTF-8, *;q=0.8' BaseURL = 'https://api.github.com/repos/exercism/cli/releases/latest' Params = <> - HandleRedirects = True RaiseExceptionOn500 = False Left = 52 Top = 124 diff --git a/Delphi/Project/Source/uConfigApiFrm.dfm b/Delphi/Project/Source/uConfigApiFrm.dfm index 5202232..06588ad 100644 --- a/Delphi/Project/Source/uConfigApiFrm.dfm +++ b/Delphi/Project/Source/uConfigApiFrm.dfm @@ -33,23 +33,6 @@ object frmConfigAPI: TfrmConfigAPI ParentFont = False WordWrap = True end - object OvcURL1: TOvcURL - Left = 200 - Top = 182 - Width = 216 - Height = 16 - Hint = 'http://exercism.io/account/key' - Caption = 'I don'#39't have or don'#39't know my API key' - URL = 'http://exercism.io/account/key' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -13 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - ParentShowHint = False - ShowHint = True - end object Label4: TLabel Left = 11 Top = 127 @@ -233,6 +216,23 @@ object frmConfigAPI: TfrmConfigAPI TabOrder = 6 OnClick = btnBrowseClick end + object LinkLabel1: TLinkLabel + Left = 200 + Top = 182 + Width = 183 + Height = 20 + Caption = + 'https://exercism.io/my' + + '/settings' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 7 + OnLinkClick = LinkLabel1LinkClick + end object DosCommand1: TDosCommand InputToOutput = True MaxTimeAfterBeginning = 0 diff --git a/Delphi/Project/Source/uInstallLocationFrm.dfm b/Delphi/Project/Source/uInstallLocationFrm.dfm index bae30c9..dc721d3 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.dfm +++ b/Delphi/Project/Source/uInstallLocationFrm.dfm @@ -48,28 +48,6 @@ object frmInstallLocation: TfrmInstallLocation Caption = 'By clicking &Next you accept the' Transparent = True end - object OvcURL4: TOvcURL - Left = 311 - Top = 193 - Width = 91 - Height = 13 - Hint = - 'https://github.com/exercism/windows-installer/blob/master/LICENS' + - 'E' - Caption = 'License Agreement' - URL = - 'https://github.com/exercism/windows-installer/blob/master/LICENS' + - 'E' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [fsUnderline] - ParentFont = False - ParentShowHint = False - ShowHint = True - Transparent = True - end object Panel1: TPanel Left = 0 Top = 0 @@ -6366,4 +6344,18 @@ object frmInstallLocation: TfrmInstallLocation TabOrder = 4 OnClick = btnBrowseClick end + object LinkLabel1: TLinkLabel + Left = 311 + Top = 193 + Width = 95 + Height = 13 + Hint = + 'https://github.com/exercism/windows-installer/blob/master/LICENS' + + 'E' + Caption = + 'License Agreement' + TabOrder = 5 + OnLinkClick = LinkLabel1LinkClick + end end From 409f3444fb63dce66f1b1a3f7498e462677cf10d Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Wed, 12 Dec 2018 22:54:06 -0500 Subject: [PATCH 3/8] add LinkClick event handler When label is clicked will cause default browser to be spawned opened to Link url. --- Delphi/Project/Source/uClientDownloadFrm.pas | 19 +++++++++++++++--- Delphi/Project/Source/uConfigApiFrm.pas | 20 ++++++++++++++++--- Delphi/Project/Source/uInstallLocationFrm.pas | 19 +++++++++++++++--- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/Delphi/Project/Source/uClientDownloadFrm.pas b/Delphi/Project/Source/uClientDownloadFrm.pas index 3585bd2..0d83579 100644 --- a/Delphi/Project/Source/uClientDownloadFrm.pas +++ b/Delphi/Project/Source/uClientDownloadFrm.pas @@ -11,7 +11,7 @@ interface FireDAC.DApt.Intf, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client, REST.Response.Adapter, REST.Client, Data.Bind.Components, Data.Bind.ObjectScope, System.Types, System.Net.HttpClient, System.UITypes, - Vcl.Imaging.pngimage, ovcurl; + Vcl.Imaging.pngimage, REST.Types; type Tos = class @@ -55,11 +55,11 @@ TfrmDownload = class(TForm) btnStopDownload: TButton; Label4: TLabel; btnFinish: TButton; - urlDocs: TOvcURL; Root: TRESTResponseDataSetAdapter; tableRoot: TFDMemTable; Image1: TImage; imgV2Logo: TImage; + urlDocs: TLinkLabel; procedure btnCancelClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure tmrDownloadTimer(Sender: TObject); @@ -68,6 +68,8 @@ TfrmDownload = class(TForm) procedure tmrInstallTimer(Sender: TObject); procedure btnStopDownloadClick(Sender: TObject); procedure btnFinishClick(Sender: TObject); + procedure urlDocsLinkClick(Sender: TObject; const Link: string; + LinkType: TSysLinkType); private { Private declarations } InstallInfo : TInstallInfo; @@ -99,7 +101,7 @@ TfrmDownload = class(TForm) function NewAssets(aFDMemTable: TFDMemTable): IAssetsURL; implementation -uses System.IOUtils, System.Zip, uUpdatePath; +uses System.IOUtils, System.Zip, uUpdatePath, Vcl.ExtActns; {$R *.dfm} type TAssetsURL = class(TInterfacedObject, IAssetsURL) @@ -387,6 +389,17 @@ procedure TfrmDownload.Update_PATH(var aStatus: TResultStatus); mStatus.Lines.Add(format('Folder "%s" NOT added to Path.',[InstallInfo.Path])); end; +procedure TfrmDownload.urlDocsLinkClick(Sender: TObject; const Link: string; + LinkType: TSysLinkType); +var + Browser: TBrowseUrl; +begin + Browser := TBrowseUrl.Create(self); + Browser.URL := Link; + Browser.Execute; + Browser.DisposeOf; +end; + procedure TfrmDownload.tmrDownloadTimer(Sender: TObject); var lIs32BitWindows: boolean; diff --git a/Delphi/Project/Source/uConfigApiFrm.pas b/Delphi/Project/Source/uConfigApiFrm.pas index ee1e82e..9bfc470 100644 --- a/Delphi/Project/Source/uConfigApiFrm.pas +++ b/Delphi/Project/Source/uConfigApiFrm.pas @@ -4,7 +4,7 @@ interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, - Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, ovcurl, + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, uTypes, Vcl.Imaging.pngimage, DosCommand; type @@ -15,7 +15,6 @@ TfrmConfigAPI = class(TForm) btnFinish: TButton; Label3: TLabel; fldAPI: TEdit; - OvcURL1: TOvcURL; Label4: TLabel; btnConfigure: TButton; DosCommand1: TDosCommand; @@ -25,12 +24,15 @@ TfrmConfigAPI = class(TForm) Label5: TLabel; Label6: TLabel; Image1: TImage; + LinkLabel1: TLinkLabel; procedure btnFinishClick(Sender: TObject); procedure fldChanging(Sender: TObject); procedure FormCreate(Sender: TObject); procedure btnConfigureClick(Sender: TObject); procedure DosCommand1Terminated(Sender: TObject); procedure btnBrowseClick(Sender: TObject); + procedure LinkLabel1LinkClick(Sender: TObject; const Link: string; + LinkType: TSysLinkType); private { Private declarations } InstallInfo: TInstallInfo; @@ -44,7 +46,8 @@ TfrmConfigAPI = class(TForm) implementation uses System.IOUtils, - Vcl.FileCtrl; + Vcl.FileCtrl, + Vcl.ExtActns; {$R *.dfm} function ShowConfigAPIForm(const aInstallInfo: TInstallInfo): TResultStatus; @@ -128,4 +131,15 @@ procedure TfrmConfigAPI.FormCreate(Sender: TObject); SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_APPWINDOW); end; +procedure TfrmConfigAPI.LinkLabel1LinkClick(Sender: TObject; const Link: string; + LinkType: TSysLinkType); +var + Browser: TBrowseUrl; +begin + Browser := TBrowseUrl.Create(self); + Browser.URL := Link; + Browser.Execute; + Browser.DisposeOf; +end; + end. diff --git a/Delphi/Project/Source/uInstallLocationFrm.pas b/Delphi/Project/Source/uInstallLocationFrm.pas index dcd6a6a..9f49f52 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.pas +++ b/Delphi/Project/Source/uInstallLocationFrm.pas @@ -6,7 +6,7 @@ interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, uTypes, Vcl.StdCtrls, Vcl.ExtCtrls, - Vcl.Imaging.pngimage, System.UITypes, ovcurl; + Vcl.Imaging.pngimage, System.UITypes; type TfrmInstallLocation = class(TForm) @@ -20,13 +20,15 @@ TfrmInstallLocation = class(TForm) btnBrowse: TButton; Label4: TLabel; Label5: TLabel; - OvcURL4: TOvcURL; Image1: TImage; imgV2Logo: TImage; + LinkLabel1: TLinkLabel; procedure btnCancelClick(Sender: TObject); procedure btnNextClick(Sender: TObject); procedure btnBrowseClick(Sender: TObject); procedure FormCreate(Sender: TObject); + procedure LinkLabel1LinkClick(Sender: TObject; const Link: string; + LinkType: TSysLinkType); private { Private declarations } public @@ -38,7 +40,7 @@ TfrmInstallLocation = class(TForm) implementation uses - Vcl.FileCtrl; + Vcl.FileCtrl, Vcl.ExtActns; {$R *.dfm} var @@ -116,4 +118,15 @@ procedure TfrmInstallLocation.FormCreate(Sender: TObject); SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_APPWINDOW); end; +procedure TfrmInstallLocation.LinkLabel1LinkClick(Sender: TObject; + const Link: string; LinkType: TSysLinkType); +var + Browser: TBrowseUrl; +begin + Browser := TBrowseUrl.Create(self); + Browser.URL := Link; + Browser.Execute; + Browser.DisposeOf; +end; + end. From 0c14971451caa174928406c90e3ea152793f01ce Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Wed, 12 Dec 2018 23:00:42 -0500 Subject: [PATCH 4/8] use inline var declaration of TBrowseUrl --- Delphi/Project/Source/uClientDownloadFrm.pas | 4 +--- Delphi/Project/Source/uConfigApiFrm.pas | 4 +--- Delphi/Project/Source/uInstallLocationFrm.pas | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Delphi/Project/Source/uClientDownloadFrm.pas b/Delphi/Project/Source/uClientDownloadFrm.pas index 0d83579..ec13c15 100644 --- a/Delphi/Project/Source/uClientDownloadFrm.pas +++ b/Delphi/Project/Source/uClientDownloadFrm.pas @@ -391,10 +391,8 @@ procedure TfrmDownload.Update_PATH(var aStatus: TResultStatus); procedure TfrmDownload.urlDocsLinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType); -var - Browser: TBrowseUrl; begin - Browser := TBrowseUrl.Create(self); + var Browser := TBrowseUrl.Create(self); Browser.URL := Link; Browser.Execute; Browser.DisposeOf; diff --git a/Delphi/Project/Source/uConfigApiFrm.pas b/Delphi/Project/Source/uConfigApiFrm.pas index 9bfc470..357f1c3 100644 --- a/Delphi/Project/Source/uConfigApiFrm.pas +++ b/Delphi/Project/Source/uConfigApiFrm.pas @@ -133,10 +133,8 @@ procedure TfrmConfigAPI.FormCreate(Sender: TObject); procedure TfrmConfigAPI.LinkLabel1LinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType); -var - Browser: TBrowseUrl; begin - Browser := TBrowseUrl.Create(self); + var Browser := TBrowseUrl.Create(self); Browser.URL := Link; Browser.Execute; Browser.DisposeOf; diff --git a/Delphi/Project/Source/uInstallLocationFrm.pas b/Delphi/Project/Source/uInstallLocationFrm.pas index 9f49f52..4a2edb8 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.pas +++ b/Delphi/Project/Source/uInstallLocationFrm.pas @@ -120,10 +120,8 @@ procedure TfrmInstallLocation.FormCreate(Sender: TObject); procedure TfrmInstallLocation.LinkLabel1LinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType); -var - Browser: TBrowseUrl; begin - Browser := TBrowseUrl.Create(self); + var Browser := TBrowseUrl.Create(self); Browser.URL := Link; Browser.Execute; Browser.DisposeOf; From 9372ec98cf603fb11e77ad7d5e91c594d11ac96b Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Wed, 12 Dec 2018 23:47:48 -0500 Subject: [PATCH 5/8] refactored to use inline var declarations --- Delphi/Project/ExercismCLIInstaller.dpr | 12 +++----- Delphi/Project/Source/uClientDownloadFrm.pas | 18 ++++-------- Delphi/Project/Source/uConfigApiFrm.pas | 23 +++++---------- Delphi/Project/Source/uInstallLocationFrm.pas | 15 +++------- Delphi/Project/Source/uUpdatePath.pas | 29 ++++++------------- 5 files changed, 29 insertions(+), 68 deletions(-) diff --git a/Delphi/Project/ExercismCLIInstaller.dpr b/Delphi/Project/ExercismCLIInstaller.dpr index aad2c3c..804ae6f 100644 --- a/Delphi/Project/ExercismCLIInstaller.dpr +++ b/Delphi/Project/ExercismCLIInstaller.dpr @@ -11,19 +11,15 @@ uses {$R *.res} -var LoopStatus, - ResultStatus: TResultStatus; - i: integer; - InstallInfo: TInstallInfo; - begin + var InstallInfo: TInstallInfo; fillchar(InstallInfo, sizeof(TInstallInfo), #0); Application.Initialize; Application.MainFormOnTaskbar := True; - i := 0; - LoopStatus := rsContinue; - ResultStatus := rsCancel; + var i := 0; + var LoopStatus := rsContinue; repeat + var ResultStatus := rsCancel; case i of 0: ResultStatus := ShowInstallLocationForm(InstallInfo); 1: ResultStatus := ShowClientDownloadForm(InstallInfo); diff --git a/Delphi/Project/Source/uClientDownloadFrm.pas b/Delphi/Project/Source/uClientDownloadFrm.pas index ec13c15..1270ed8 100644 --- a/Delphi/Project/Source/uClientDownloadFrm.pas +++ b/Delphi/Project/Source/uClientDownloadFrm.pas @@ -194,10 +194,8 @@ procedure TfrmDownload.btnStopDownloadClick(Sender: TObject); end; procedure TfrmDownload.FormCreate(Sender: TObject); -var - TLSProts: THTTPSecureProtocols; begin - TLSProts := [THTTPSecureProtocol.TLS12]; + var TLSProts: THTTPSecureProtocols := [THTTPSecureProtocol.TLS12]; RESTClient1.SecureProtocols := TLSProts; FClient := THTTPClient.Create; FClient.SecureProtocols := TLSProts; @@ -321,18 +319,14 @@ function TfrmDownload.FetchDownloadURL(const aIs32BitWindows: Boolean; var aStat end; procedure TfrmDownload.Download_CLI_ZIP(aDownloadURL: IDownloadURL; var aStatus: TResultStatus); -var - lFilename: string; - URL: string; - LSize: Int64; begin aStatus := rsCancel; - LFileName := TPath.Combine(InstallInfo.Path, 'exercism.zip'); + var lFileName := TPath.Combine(InstallInfo.Path, 'exercism.zip'); try FAsyncResponse := nil; - URL := aDownloadURL.Url; + var URL := aDownloadURL.Url; - LSize := aDownloadURL.DownloadSize; + var LSize := aDownloadURL.DownloadSize; ProgressBarDownload.Max := LSize; ProgressBarDownload.Min := 0; @@ -361,13 +355,11 @@ procedure TfrmDownload.Download_CLI_ZIP(aDownloadURL: IDownloadURL; var aStatus: end; procedure TfrmDownload.Unzip_CLI(var aStatus: TResultStatus); -var - lFilename: string; begin aStatus := rsCancel; mStatus.Lines.Add(format('Unzipping CLI to %s',[InstallInfo.Path])); + var lFilename := TPath.Combine(InstallInfo.Path,'exercism.zip'); try - lFilename := TPath.Combine(InstallInfo.Path,'exercism.zip'); TZipFile.ExtractZipFile(lFilename, TPath.Combine(InstallInfo.Path,'')); aStatus := rsNext; mStatus.Lines.Add('CLI Extraction Successful'); diff --git a/Delphi/Project/Source/uConfigApiFrm.pas b/Delphi/Project/Source/uConfigApiFrm.pas index 357f1c3..f180905 100644 --- a/Delphi/Project/Source/uConfigApiFrm.pas +++ b/Delphi/Project/Source/uConfigApiFrm.pas @@ -66,14 +66,12 @@ function ShowConfigAPIForm(const aInstallInfo: TInstallInfo): TResultStatus; procedure TfrmConfigAPI.btnFinishClick(Sender: TObject); begin - close; + close; end; procedure TfrmConfigAPI.btnBrowseClick(Sender: TObject); -var - folder: string; begin - folder := fldSolutionLocation.Text; + var folder: string := fldSolutionLocation.Text; if Vcl.FileCtrl.SelectDirectory('Select Solution Location', '', folder, [sdNewUI, sdNewFolder], Self) then begin fldSolutionLocation.Text := folder; @@ -84,14 +82,11 @@ procedure TfrmConfigAPI.btnBrowseClick(Sender: TObject); procedure TfrmConfigAPI.btnConfigureClick(Sender: TObject); procedure MakeBat; - var - lBatFile: TStringlist; - lCommandLine: string; begin - lBatFile := TStringlist.Create; + var lBatFile := TStringlist.Create; lBatFile.Add('@echo off'); lBatFile.Add(format('cd "%s"',[InstallInfo.Path])); - lCommandLine := format('%s %s --key=%s --dir="%s"', + var lCommandLine := format('%s %s --key=%s --dir="%s"', ['exercism.exe', 'configure', fldAPI.Text, fldSolutionLocation.Text]); lBatFile.Add(lCommandLine); lBatFile.Add('exit'); @@ -99,13 +94,11 @@ procedure TfrmConfigAPI.btnConfigureClick(Sender: TObject); lBatFile.DisposeOf; end; -var - lCommandLine: string; begin MakeBat; btnConfigure.Enabled := false; DosCommand1.CurrentDir := InstallInfo.Path; - lCommandLine := TPath.Combine(InstallInfo.Path,'config.bat'); + var lCommandLine := TPath.Combine(InstallInfo.Path,'config.bat'); DosCommand1.CommandLine := lCommandLine; DosCommand1.Execute; end; @@ -118,11 +111,9 @@ procedure TfrmConfigAPI.DosCommand1Terminated(Sender: TObject); end; procedure TfrmConfigAPI.fldChanging(Sender: TObject); -var - lAPI, lLocation: string; begin - lAPI := fldAPI.Text; - lLocation := fldSolutionLocation.Text; + var lAPI: string := fldAPI.Text; + var lLocation: string := fldSolutionLocation.Text; btnConfigure.Enabled := not (lAPI.IsEmpty or lLocation.IsEmpty);; end; diff --git a/Delphi/Project/Source/uInstallLocationFrm.pas b/Delphi/Project/Source/uInstallLocationFrm.pas index 4a2edb8..b440708 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.pas +++ b/Delphi/Project/Source/uInstallLocationFrm.pas @@ -43,13 +43,10 @@ implementation Vcl.FileCtrl, Vcl.ExtActns; {$R *.dfm} -var - thisForm: TfrmInstallLocation; - function ShowInstallLocationForm(var aInstallInfo: TInstallInfo): TResultStatus; begin result := rsCancel; - thisForm := TfrmInstallLocation.Create(nil); + var thisForm := TfrmInstallLocation.Create(nil); try thisForm.ShowModal; if thisForm.NextClicked then @@ -63,10 +60,8 @@ function ShowInstallLocationForm(var aInstallInfo: TInstallInfo): TResultStatus; end; procedure TfrmInstallLocation.btnBrowseClick(Sender: TObject); -var - folder: string; begin - folder := fldLocation.Text; + var folder: string := fldLocation.Text; if vcl.FileCtrl.SelectDirectory('Select Install Location', '', Folder, [sdNewUI, sdNewFolder], Self) then begin fldLocation.Text := folder; @@ -79,13 +74,11 @@ procedure TfrmInstallLocation.btnCancelClick(Sender: TObject); end; procedure TfrmInstallLocation.btnNextClick(Sender: TObject); -var lOKNext: boolean; - lDlgResult: word; begin - lOKNext := true; + var lOKNext := true; if not System.SysUtils.DirectoryExists(fldLocation.Text) then begin - lDlgResult := MessageDlg(format('Directory "%s" does not exist.'+#13#10+ + var lDlgResult := MessageDlg(format('Directory "%s" does not exist.'+#13#10+ 'Shall I create it for you?', [fldLocation.Text]),mtError, [mbYes, mbNo],0); if lDlgResult = mrYes then diff --git a/Delphi/Project/Source/uUpdatePath.pas b/Delphi/Project/Source/uUpdatePath.pas index d96d0d2..05c6107 100644 --- a/Delphi/Project/Source/uUpdatePath.pas +++ b/Delphi/Project/Source/uUpdatePath.pas @@ -15,19 +15,15 @@ implementation {$endif} class function TUpdatePath.AddToPath(aDir: string): Boolean; -var - reg: TRegistry; - openResult: Boolean; - lPath: string; begin result := false; - reg := TRegistry.Create; + var reg := TRegistry.Create; try reg.RootKey := HKEY_CURRENT_USER; - openResult := reg.OpenKeyReadOnly('Environment'); + var openResult := reg.OpenKeyReadOnly('Environment'); if openResult then begin - lPath:= reg.ReadString('Path'); + var lPath:= reg.ReadString('Path'); if lPath.ToLower.Contains(aDir.ToLower) then result := true else @@ -77,27 +73,20 @@ class procedure TUpdatePath.BroadcastChange; end; class function TUpdatePath.RemoveFromPath(aDir: string): Boolean; -var - reg: TRegistry; - openResult: Boolean; - lPath: string; - lSplitPath: TArray; - lNewPath: string; - lDir: string; begin result := false; - reg := TRegistry.Create; + var reg := TRegistry.Create; try reg.RootKey := {HKEY_LOCAL_MACHINE{} HKEY_CURRENT_USER{}; - openResult := reg.OpenKeyReadOnly('Environment'); + var openResult := reg.OpenKeyReadOnly('Environment'); if openResult then begin - lPath:= reg.ReadString('Path'); + var lPath:= reg.ReadString('Path'); if lPath.ToLower.Contains(aDir.ToLower) then begin - lSplitPath := lPath.Split([';']); - lNewPath := ''; - for lDir in lSplitPath do + var lSplitPath: TArray := lPath.Split([';']); + var lNewPath := ''; + for var lDir in lSplitPath do begin if lDir.ToLower <> aDir.ToLower then if lNewPath.IsEmpty then From b591d6ebab68ffb94ca896f0395bafcab35c054e Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Thu, 14 Feb 2019 22:32:05 -0500 Subject: [PATCH 6/8] bump version Confirmed that code builds with new Delphi version, 10.3.1 --- Delphi/Project/ExercismCLIInstaller.dproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Delphi/Project/ExercismCLIInstaller.dproj b/Delphi/Project/ExercismCLIInstaller.dproj index 54b8d92..6f92b39 100644 --- a/Delphi/Project/ExercismCLIInstaller.dproj +++ b/Delphi/Project/ExercismCLIInstaller.dproj @@ -7,7 +7,7 @@ 1153 Application VCL - 18.5 + 18.6 Win32 @@ -99,11 +99,11 @@ true true Win32\Release - CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.5.3.2;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.5;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.5.3.3;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.5;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) Win32\Release 5 3 - 2 + 3 true true PerMonitor From a97afa8ce4f687f3890dac785a1ea23f248a4170 Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Mon, 4 Nov 2019 00:19:42 -0500 Subject: [PATCH 7/8] Bump Version for 10.3.2 --- Delphi/Project/ExercismCLIInstaller.dproj | 288 +++++++++++++++++++++- 1 file changed, 275 insertions(+), 13 deletions(-) diff --git a/Delphi/Project/ExercismCLIInstaller.dproj b/Delphi/Project/ExercismCLIInstaller.dproj index 6f92b39..9f0f5d9 100644 --- a/Delphi/Project/ExercismCLIInstaller.dproj +++ b/Delphi/Project/ExercismCLIInstaller.dproj @@ -4,10 +4,10 @@ ExercismCLIInstaller.dpr True Release - 1153 + 1025 Application VCL - 18.6 + 18.7 Win32 @@ -18,11 +18,6 @@ Base true - - true - Base - true - true Base @@ -82,10 +77,6 @@ Win32\ Win32\ - - $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png - $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png - RELEASE;$(DCC_Define) 0 @@ -166,9 +157,7 @@ True - True True - False @@ -244,6 +233,12 @@ 1 + + + res\values + 1 + + res\drawable @@ -280,6 +275,36 @@ 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + res\drawable-small @@ -304,6 +329,12 @@ 1 + + + res\values + 1 + + 1 @@ -423,6 +454,17 @@ 1 + + + 1 + + + 1 + + + 1 + + 1 @@ -434,6 +476,39 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + 1 @@ -445,6 +520,61 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + 1 @@ -456,6 +586,116 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + 1 @@ -489,6 +729,28 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + 1 From c134a19fc9177638751458a7355f4da55195195b Mon Sep 17 00:00:00 2001 From: Ryan Potts Date: Sun, 1 Mar 2020 21:29:06 -0500 Subject: [PATCH 8/8] WIP: Find previous installed CLI Will detect all occurrences of exercism.exe that might exist in PATH. At this point only deals with the first found. The first found location can optionally become the install location, which will overwrite the old CLI with the latest. More needs to be done to deal with multiple finds of the CLI and if it was installed previously via Chocolatey. --- Delphi/Project/ExercismCLIInstaller.dproj | 10 +- Delphi/Project/Source/uInstallLocationFrm.dfm | 77 +++++++++++- Delphi/Project/Source/uInstallLocationFrm.pas | 115 +++++++++++++++++- 3 files changed, 195 insertions(+), 7 deletions(-) diff --git a/Delphi/Project/ExercismCLIInstaller.dproj b/Delphi/Project/ExercismCLIInstaller.dproj index 9f0f5d9..66a8212 100644 --- a/Delphi/Project/ExercismCLIInstaller.dproj +++ b/Delphi/Project/ExercismCLIInstaller.dproj @@ -90,11 +90,11 @@ true true Win32\Release - CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.5.3.3;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.5;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.5.3.4;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.5;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName) Win32\Release 5 3 - 3 + 4 true true PerMonitor @@ -167,6 +167,12 @@ true + + + ExercismCLIInstaller.exe + true + + 1 diff --git a/Delphi/Project/Source/uInstallLocationFrm.dfm b/Delphi/Project/Source/uInstallLocationFrm.dfm index dc721d3..0eae5c4 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.dfm +++ b/Delphi/Project/Source/uInstallLocationFrm.dfm @@ -15,7 +15,9 @@ object frmInstallLocation: TfrmInstallLocation Font.Style = [] OldCreateOrder = False Position = poScreenCenter + OnActivate = FormActivate OnCreate = FormCreate + OnDestroy = FormDestroy PixelsPerInch = 96 TextHeight = 13 object Label3: TLabel @@ -48,6 +50,79 @@ object frmInstallLocation: TfrmInstallLocation Caption = 'By clicking &Next you accept the' Transparent = True end + object pnlPreexistingCLI: TPanel + Left = 8 + Top = 88 + Width = 624 + Height = 169 + ParentBackground = False + ShowCaption = False + TabOrder = 6 + Visible = False + object Label6: TLabel + Left = 23 + Top = 12 + Width = 578 + Height = 36 + AutoSize = False + Caption = + 'A copy of the Exercism CLI has been found already installed on t' + + 'his system. Only one copy of the CLI should be installed and al' + + 'l other copies removed.' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -15 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + WordWrap = True + end + object Label7: TLabel + Left = 81 + Top = 64 + Width = 462 + Height = 18 + Caption = + 'Would you like to install the CLI where the previous version was' + + ' found?' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -15 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + end + object btnYes: TButton + Left = 220 + Top = 92 + Width = 75 + Height = 25 + Caption = 'Yes' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -15 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 0 + OnClick = btnYesClick + end + object btnNo: TButton + Left = 328 + Top = 92 + Width = 75 + Height = 25 + Caption = 'No' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -15 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 1 + OnClick = btnNoClick + end + end object Panel1: TPanel Left = 0 Top = 0 @@ -6348,7 +6423,7 @@ object frmInstallLocation: TfrmInstallLocation Left = 311 Top = 193 Width = 95 - Height = 13 + Height = 17 Hint = 'https://github.com/exercism/windows-installer/blob/master/LICENS' + 'E' diff --git a/Delphi/Project/Source/uInstallLocationFrm.pas b/Delphi/Project/Source/uInstallLocationFrm.pas index b440708..0fc822f 100644 --- a/Delphi/Project/Source/uInstallLocationFrm.pas +++ b/Delphi/Project/Source/uInstallLocationFrm.pas @@ -1,14 +1,14 @@ unit uInstallLocationFrm; -{_define SimTLSCheckFailure} -{$define SkipTLSCheck} interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, uTypes, Vcl.StdCtrls, Vcl.ExtCtrls, - Vcl.Imaging.pngimage, System.UITypes; + Vcl.Imaging.pngimage, System.Generics.Collections, System.UITypes, Vcl.Buttons; type + TCLIPresent = class; + TfrmInstallLocation = class(TForm) Panel1: TPanel; Label1: TLabel; @@ -23,24 +23,53 @@ TfrmInstallLocation = class(TForm) Image1: TImage; imgV2Logo: TImage; LinkLabel1: TLinkLabel; + pnlPreexistingCLI: TPanel; + Label6: TLabel; + Label7: TLabel; + btnYes: TButton; + btnNo: TButton; procedure btnCancelClick(Sender: TObject); procedure btnNextClick(Sender: TObject); procedure btnBrowseClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure LinkLabel1LinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType); + procedure FormDestroy(Sender: TObject); + procedure FormActivate(Sender: TObject); + procedure btnYesClick(Sender: TObject); + procedure btnNoClick(Sender: TObject); private { Private declarations } + OldCLIPresent: TCLIPresent; public { Public declarations } NextClicked: boolean; end; + TCLIPresent = class + strict private + const + CliFilename = 'exercism.exe'; + var + FInstallTo: string; + FListOfFinds: TList; + FIsPresent: Boolean; + FNumberFound: Integer; + function GetPath: string; + public + constructor Create; + destructor Destroy; override; + procedure FindPreexistingCLI; + property InstallTo: string read FInstallTo; + property IsPresent: Boolean read FIsPresent; + property NumberFound: Integer read FNumberFound; + end; + function ShowInstallLocationForm(var aInstallInfo: TInstallInfo): TResultStatus; implementation uses - Vcl.FileCtrl, Vcl.ExtActns; + StrUtils, Vcl.FileCtrl, Vcl.ExtActns, Registry; {$R *.dfm} function ShowInstallLocationForm(var aInstallInfo: TInstallInfo): TResultStatus; @@ -105,12 +134,36 @@ procedure TfrmInstallLocation.btnNextClick(Sender: TObject); end; end; +procedure TfrmInstallLocation.btnNoClick(Sender: TObject); +begin + pnlPreexistingCLI.Visible := false; + MessageDlg('Please remove all copies of the CLI before attempting to install the latest version.', mtInformation, [mbOk], 0); + btnCancel.Click; +end; + +procedure TfrmInstallLocation.FormActivate(Sender: TObject); +begin + OldCLIPresent.FindPreexistingCLI; + if OldCLIPresent.IsPresent then + begin + pnlPreexistingCLI.BringToFront; + pnlPreexistingCLI.Visible := true; + btnNext.Enabled := false; + end; +end; + procedure TfrmInstallLocation.FormCreate(Sender: TObject); begin NextClicked := false; + OldCLIPresent := TCLIPresent.Create; SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_APPWINDOW); end; +procedure TfrmInstallLocation.FormDestroy(Sender: TObject); +begin + OldCLIPresent.DisposeOf; +end; + procedure TfrmInstallLocation.LinkLabel1LinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType); begin @@ -120,4 +173,58 @@ procedure TfrmInstallLocation.LinkLabel1LinkClick(Sender: TObject; Browser.DisposeOf; end; +procedure TfrmInstallLocation.btnYesClick(Sender: TObject); +begin + pnlPreexistingCLI.Visible := false; + fldLocation.Text := OldCLIPresent.InstallTo; + btnNext.Enabled := True; +end; + +{ TCLIPresent } + +constructor TCLIPresent.Create; +begin + inherited; + FListOfFinds := TList.Create; +end; + +destructor TCLIPresent.Destroy; +begin + FListOfFinds.DisposeOf; + inherited; +end; + +procedure TCLIPresent.FindPreexistingCLI; +begin + var PathArray := GetPath.Split([';']); + for var aPath in PathArray do + begin + var fixedPath := aPath; + if not fixedPath.EndsWith('\') then + fixedPath := fixedPath + '\'; + var LFileToFind := fixedPath + CliFilename; + if FileExists(LFileToFind) then + FListOfFinds.Add(aPath); + end; + FNumberFound := FListOfFinds.Count; + FIsPresent := FNumberFound > 0; + FInstallTo := ifthen(FIsPresent, FListOfFinds[0]); +end; + +function TCLIPresent.GetPath: string; +begin + var reg := TRegistry.Create; + try + reg.RootKey := HKEY_CURRENT_USER; + var openResult := reg.OpenKeyReadOnly('Environment'); + if openResult then + Result := reg.ReadString('Path') + else + Result := ''; + finally + reg.CloseKey; + reg.Free; + end; +end; + end.