Skip to content

Commit

Permalink
Updated configlet metadata update, tests update, change in referencin…
Browse files Browse the repository at this point in the history
…g root directory of configlet
  • Loading branch information
Bajger committed Jun 13, 2024
1 parent 4c78c5a commit 81d92a5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
58 changes: 44 additions & 14 deletions dev/src/ExercismDev/ExercismGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ ExercismGenerator >> basePathReference [
{ #category : #helper }
ExercismGenerator >> checkOrUpdateConfiglet [

(self configletRootReference / 'bin' / 'configlet') asFileReference isFile
(self configletRootReference / 'configlet') isFile
ifTrue: [ ^ self ].
self traceCr: 'Could not find configlet. Fetching configlet...'.
self fetchConfiglet
Expand All @@ -137,10 +137,10 @@ ExercismGenerator >> codeExporter: anObject [
ExercismGenerator >> configletRootReference [

|configletPath|
"use default root of from git repository. If not present, use parent of exercises dir."
"use default bin directory where configlet is locatated (out from git repository). If not present, use parent of exercises dir."
configletPath := self class exercismRepositoryPath.
configletPath ifNil: [ ^ self basePathReference ].
^ configletPath asFileReference
configletPath ifNil: [ ^ self basePathReference / 'bin' ].
^ configletPath asFileReference / 'bin'
]

{ #category : #helper }
Expand Down Expand Up @@ -198,7 +198,7 @@ ExercismGenerator >> fetchConfiglet [
|result |
result := self osSubProcess new
workingDirectory: self configletRootReference fullName;
command: 'bin/fetch-configlet';
command: 'fetch-configlet';
arguments: #();
redirectStdout;
runAndWait.
Expand All @@ -210,15 +210,16 @@ ExercismGenerator >> fetchConfiglet [

{ #category : #generation }
ExercismGenerator >> generate [

"this will regenerate all active exercises"

"generate source files for active exercises"
self generateSourceFilesForActiveExercises.

"generate configuration config.json file"
ExercismConfigGenerator generateTo: self basePathReference.

"run configlet generation"
self runConfigletCommand.
self runConfigletCommandsForActiveExercices.
]

{ #category : #helper }
Expand Down Expand Up @@ -260,8 +261,9 @@ ExercismGenerator >> generateForExercise: slugName [
"generate configuration config.json file"
ExercismConfigGenerator generateTo: self basePathReference.
"run configlet generation"
self runConfigletCommand
"run configlet commands for given exercise"
self runTestSpecificationsUpdateForExercise: slugName.
self runDocsAndMetadataUpdateForExercise: slugName.
]
{ #category : #helper }
Expand Down Expand Up @@ -375,16 +377,44 @@ ExercismGenerator >> prepareExerciseDirectory: exerciseDirReference [
]
{ #category : #generation }
ExercismGenerator >> runConfigletCommand [
|result |
ExercismGenerator >> runConfigletCommandsForActiveExercices [
self exercismExercise allExercises
select: [ :ex | ex isActive ]
thenDo: [ :ex |
self runTestSpecificationsUpdateForExercise: ex name.
self runDocsAndMetadataUpdateForExercise: ex name.
]
]
{ #category : #generation }
ExercismGenerator >> runDocsAndMetadataUpdateForExercise: slugName [
| result |
result := self osSubProcess new
command: 'configlet generate';
arguments: (Array with: self basePathReference pathString surroundedBySingleQuotes);
command: 'configlet';
workingDirectory: self configletRootReference fullName;
arguments: {'sync'. '--docs'. '--filepaths'. '--metadata'. '-uy'. '-e'. slugName.} asArray;
redirectStdout;
runAndWait.
result isSuccess ifFalse: [
self error: ('Failed running "configlet sync --docs --filepaths --metadata -uy -e {1}" with result: {2}' format: { slugName. result lastError printString.})]
]
{ #category : #generation }
ExercismGenerator >> runTestSpecificationsUpdateForExercise: slugName [
| result |
result := self osSubProcess new
command: 'configlet';
workingDirectory: self configletRootReference fullName;
arguments: {'sync'. '-u'. '--tests'. 'include'. '-e'. slugName.} asArray;
redirectStdout;
runAndWait.
result isSuccess ifFalse: [
self error: 'failure running "configlet generate" - ' , result lastError printString ]
self error: ('Failed running "configlet sync -u --tests include -e {1}" with result: {2}' format: { slugName. result lastError printString.})]
]
{ #category : #helper }
Expand Down
2 changes: 1 addition & 1 deletion dev/src/ExercismTests/ExercismGeneratorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ ExercismGeneratorTest >> testCheckOrUpdateConfiglet [
DiskStore
currentFileSystem: memFileSystem
during: [
(instance configletRootReference / 'bin' / 'configlet') ensureCreateFile.
(instance configletRootReference / 'configlet') ensureCreateFile.
"when configlet is present (fake file above) - it should not proceed to fetching"
self shouldnt: [instance checkOrUpdateConfiglet]
raise: Error
Expand Down

0 comments on commit 81d92a5

Please sign in to comment.