Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions Delphi/Project/ExercismCLIInstaller.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
357 changes: 339 additions & 18 deletions Delphi/Project/ExercismCLIInstaller.dproj

Large diffs are not rendered by default.

35 changes: 16 additions & 19 deletions Delphi/Project/Source/uClientDownloadFrm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -6284,6 +6266,22 @@ object frmDownload: TfrmDownload
FFFF}
Stretch = True
end
object urlDocs: TLinkLabel
Left = 404
Top = 32
Width = 150
Height = 22
Caption = '<a href="https://exercism.io/cli/">https://exercism.io/cli/</a>'
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
Expand Down Expand Up @@ -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
Expand Down
35 changes: 19 additions & 16 deletions Delphi/Project/Source/uClientDownloadFrm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -192,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;
Expand Down Expand Up @@ -319,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;
Expand Down Expand Up @@ -359,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');
Expand All @@ -387,6 +381,15 @@ 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);
begin
var Browser := TBrowseUrl.Create(self);
Browser.URL := Link;
Browser.Execute;
Browser.DisposeOf;
end;

procedure TfrmDownload.tmrDownloadTimer(Sender: TObject);
var
lIs32BitWindows: boolean;
Expand Down
34 changes: 17 additions & 17 deletions Delphi/Project/Source/uConfigApiFrm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -233,6 +216,23 @@ object frmConfigAPI: TfrmConfigAPI
TabOrder = 6
OnClick = btnBrowseClick
end
object LinkLabel1: TLinkLabel
Left = 200
Top = 182
Width = 183
Height = 20
Caption =
'<a href="https://exercism.io/my/settings">https://exercism.io/my' +
'/settings</a>'
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
Expand Down
41 changes: 22 additions & 19 deletions Delphi/Project/Source/uConfigApiFrm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,7 +15,6 @@ TfrmConfigAPI = class(TForm)
btnFinish: TButton;
Label3: TLabel;
fldAPI: TEdit;
OvcURL1: TOvcURL;
Label4: TLabel;
btnConfigure: TButton;
DosCommand1: TDosCommand;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -63,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;
Expand All @@ -81,28 +82,23 @@ 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');
lBatFile.SaveToFile(TPath.Combine(InstallInfo.Path,'config.bat'));
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;
Expand All @@ -115,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;

Expand All @@ -128,4 +122,13 @@ procedure TfrmConfigAPI.FormCreate(Sender: TObject);
SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
end;

procedure TfrmConfigAPI.LinkLabel1LinkClick(Sender: TObject; const Link: string;
LinkType: TSysLinkType);
begin
var Browser := TBrowseUrl.Create(self);
Browser.URL := Link;
Browser.Execute;
Browser.DisposeOf;
end;

end.
Loading