From aa89f4884ab8a068902447d5f00e7df009dfb50b Mon Sep 17 00:00:00 2001 From: ruidajo Date: Sat, 24 Feb 2024 21:33:32 -0500 Subject: [PATCH] Improving index, install and print. --- src/ExoRepo/ExoRepo.class.st | 48 +++++++++++++++++------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/src/ExoRepo/ExoRepo.class.st b/src/ExoRepo/ExoRepo.class.st index da4153b..4233762 100644 --- a/src/ExoRepo/ExoRepo.class.st +++ b/src/ExoRepo/ExoRepo.class.st @@ -10,41 +10,35 @@ Class { { #category : #accessing } ExoRepo class >> index [ "I list a set of external recommended repositories from the Grafoscopio community, in installation order." - | reposIndex repositoryAddresses| - repositoryAddresses := - #('https://code.sustrato.red/Offray/MiniDocs' - 'https://code.sustrato.red/Offray/Fossil' - 'https://code.sustrato.red/Offray/Shortener' - 'https://code.sustrato.red/Offray/TiddlyWikiPharo' - 'https://code.sustrato.red/mutabiT/EchartsPharo' - 'https://code.sustrato.red/Offray/VideoWeb' - 'https://code.sustrato.red/Offray/Socialmetrica'). + | reposIndex repositoryAddresses users | + users := #('Offray' 'mutabiT' 'ruidajo' ). reposIndex := OrderedCollection new. - repositoryAddresses do: [:adress | reposIndex add: (ExoRepo new repository: adress) ]. - ^ reposIndex + repositoryAddresses := users do: [:user | + reposIndex add: + ((STONJSON fromString:('https://code.sustrato.red/api/v1/users/', user, '/repos') asZnUrl retrieveContents) collect: [:repo | + (repo at: 'name') -> (repo at: 'html_url')])]. + ^ (reposIndex flatCollect: [:i | i]) asDictionary ] { #category : #accessing } ExoRepo class >> install: shortNameString [ - | repo | - repo := self index - detect: [:current | current repositoryName = shortNameString ] - ifNone: [ - ^ 'ERROR!: - - No repository named "', shortNameString, '". - Please run - - ExoRepo index - + | repo exoRepo | + [repo := self index at: shortNameString] + onErrorDo: [:err | UIManager default inform: 'No repository named: ', shortNameString, '. + Please run ExoRepo index to list know repositories or load your own repository with: ExoRepo new repository: {repositoryAddres}; load. - replacing "{repositoryAddres}" with a Git public repository' ]. - ^ repo load + replacing {repositoryAddres} with a Git public repository'.^ {self new. err}]. + exoRepo := self new repository: repo. + (IceRepositoryCreator new + location: exoRepo local; + remote: (IceGitRemote url: repo); + createRepository) register. + ^ exoRepo load ] { #category : #accessing } @@ -59,7 +53,7 @@ ExoRepo >> load [ self local exists ifFalse: [ (IceRepositoryCreator new location: self local; - remote: (IceGitRemote url: self repository greaseString , '.git'); + remote: (IceGitRemote url: self repository greaseString ", '.git'"); createRepository) register ]. localRepo := 'gitlocal://' , self local fullName. count := 1. @@ -88,7 +82,9 @@ ExoRepo >> local [ { #category : #accessing } ExoRepo >> printOn: aStream [ super initialize. - aStream nextPutAll: self repositoryName, ' | ', self repository asString + self repository ifNotNil: [ + aStream nextPutAll: self repositoryName, ' | ', self repository asString] + ifNil: [ aStream nextPutAll: 'ExoRepo without repository' ]. ] { #category : #accessing }