ExoRepo/src/ExoRepo/ExoRepo.class.st

120 lines
3.0 KiB
Smalltalk

Class {
#name : #ExoRepo,
#superclass : #Object,
#instVars : [
'repository'
],
#category : #ExoRepo
}
{ #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/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 := OrderedCollection new.
repositoryAddresses do: [:adress | reposIndex add: (ExoRepo new repository: adress) ].
^ reposIndex
]
{ #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
to list know repositories or load your own repository with:
ExoRepo new
repository: {repositoryAddres};
load.
replacing "{repositoryAddres}" with a Git public repository' ].
^ repo load
]
{ #category : #accessing }
ExoRepo >> load [
"I load the configuration of this package using a external Gitea repository."
"While more Git independient providers are implemented in Monticello, I will
use Iceberg to download the repository and load it from a local directory"
| localRepo repoName count |
repoName := self repositoryName.
self local exists
ifFalse: [ (IceRepositoryCreator new
location: self local;
remote: (IceGitRemote url: self repository greaseString , '.git');
createRepository) register ].
localRepo := 'gitlocal://' , self local fullName.
count := 1.
[ true ]
whileTrue: [ [ ^ Metacello new
repository: localRepo;
baseline: repoName;
onConflictUseLoaded;
onWarningLog;
load ]
on: IceGenericError
do: [ :ex |
Notification
signal: (String with: Character cr) , ex description , (String with: Character cr)
, 'RETRYING ' , count greaseString.
(Delay forSeconds: 2) wait.
ex retry ].
count := count + 1 ]
]
{ #category : #accessing }
ExoRepo >> local [
^ FileLocator localDirectory / 'iceberg' / (self provider) / self repositoryName
]
{ #category : #accessing }
ExoRepo >> printOn: aStream [
super initialize.
aStream nextPutAll: self repositoryName, ' | ', self repository asString
]
{ #category : #accessing }
ExoRepo >> provider [
self repository ifNil: [ ^ nil ].
^ self repository segments first
]
{ #category : #accessing }
ExoRepo >> repository [
^ repository.
]
{ #category : #accessing }
ExoRepo >> repository: aString [
repository := aString asZnUrl
]
{ #category : #accessing }
ExoRepo >> repositoryName [
self repository ifNil: [ ^ self ].
^ self repository segments second
]
{ #category : #accessing }
ExoRepo >> wiki [
^ (self local / 'wiki') ensureCreateDirectory.
]