Publishing Configurations to Pharo Meta Repositories

Each Pharo version has a dedicated meta repository for publishing Metacello Configurations so that they can be one-click installed through the Pharo catalog.

While Configurations can be manually copied to a meta repo using the Monticello browser, this script (for a workspace) automates the process, copying the most recent Configuration to one or more Pharo meta repos:

username := password := nil.
recentPharoVersions := 2 to: 7.
publish := [:stHubGroupAndRepo :configNameOrNil :pharoVersions :stHubExtraGroupsAndRepos | | ui configName version |
	ui := UIManager default.
	(username :=
		ui
			request: 'Username'
			initialAnswer: (username ifNil: ['']))
			ifNil: [self error: 'Username required'].
	(password :=
		ui
			request: 'Password'
			initialAnswer: (password ifNil: ['']))
			ifNil: [''].

	configName := configNameOrNil ifNil: [stHubGroupAndRepo copyAfter: $/].
	Gofer it
		url: 'http://www.smalltalkhub.com/mc/', stHubGroupAndRepo, '/main';
		configurationOf: configName;
		load.
	
	version := (MCPackage named: 'ConfigurationOf', configName) workingCopy versionInfo name.
	(pharoVersions collect: [:each | | str |
		(str := each asString) size > 1
			ifTrue: [str]
			ifFalse: [str, '0']])
		reject: [:each | each = '61' or: [each beginsWith: '1']]
		thenDo: [:each |
			each = '20'
				ifTrue: [
					Gofer it
						url: 'http://ss3.gemstone.com/ss/MetaRepoForPharo20';
						version: version;
						push]
				ifFalse: [
					Gofer it
						url: 'http://www.smalltalkhub.com/mc/Pharo/MetaRepoForPharo', each, '/main'
							username: username
							password: password;
						version: version;
						push]].

	stHubExtraGroupsAndRepos
		ifNotNil: [
			stHubExtraGroupsAndRepos do: [:each |
				Gofer it
					url: 'http://www.smalltalkhub.com/mc/', each, '/main'
						username: username
						password: password;
					version: version;
					push]]].

After highlighting and evaluating the above, it can be used like this:

publish
	value: 'PharoExtras/XMLParser'
	value: 'XMLParser'
	value: recentPharoVersions
	value: nil.

When evaluated (in the same workspace), the latest ConfigurationOfXMLParser will be copied to the meta repos for Pharo versions 2-7.

This snippet does the same for the XMLParserHTML project, but it also publishes the Configuration to the PharoExtras/XMLParser repo:

publish
	value: 'PharoExtras/XMLParserHTML'
	value: 'XMLParserHTML'
	value: recentPharoVersions
	value: #('PharoExtras/XMLParser').
Advertisements