117 lines
3.2 KiB
Smalltalk
117 lines
3.2 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 users |
|
|
users := #('Offray' 'mutabiT' 'ruidajo' ).
|
|
reposIndex := OrderedCollection new.
|
|
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 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'.^ {self new. err}].
|
|
exoRepo := self new repository: repo.
|
|
(IceRepositoryCreator new
|
|
location: exoRepo local;
|
|
remote: (IceGitRemote url: repo);
|
|
createRepository) register.
|
|
^ exoRepo 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.
|
|
self repository ifNotNil: [
|
|
aStream nextPutAll: self repositoryName, ' | ', self repository asString]
|
|
ifNil: [ aStream nextPutAll: 'ExoRepo without repository' ].
|
|
]
|
|
|
|
{ #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.
|
|
|
|
]
|