|
| 1 | +Class { |
| 2 | + #name : 'TSLibrariesYAML', |
| 3 | + #superclass : 'TSLibraries', |
| 4 | + #category : 'TreeSitter-Libraries', |
| 5 | + #package : 'TreeSitter-Libraries' |
| 6 | +} |
| 7 | + |
| 8 | +{ #category : 'as yet unclassified' } |
| 9 | +TSLibrariesYAML >> cloneTreeSitterYAML [ |
| 10 | + |
| 11 | + | clonePath cloneCommand status lastReleasedVersion| |
| 12 | + "Construct clone path" |
| 13 | + clonePath := self originalLibrariesDirectory , '/tree-sitter-yaml'. |
| 14 | + |
| 15 | + "before cloning get the latest release" |
| 16 | + "lastReleasedVersion := self class gitBranchToUse ifNil: [ self latestReleaseTagForOwner: 'ikatyang' repo: 'tree-sitter-yaml' ]." |
| 17 | + |
| 18 | + "Execute clone command" |
| 19 | + cloneCommand := 'git clone https://github.com/ikatyang/tree-sitter-yaml.git ' |
| 20 | + , clonePath. |
| 21 | + "cloneCommand := 'git clone --branch ', lastReleasedVersion ,' --depth 1 https://github.com/ikatyang/tree-sitter-yaml.git ' |
| 22 | + , clonePath." |
| 23 | + |
| 24 | + self logInTranscript: |
| 25 | + 'Start cloning Tree-Sitter-YAML in' , clonePath. |
| 26 | + |
| 27 | + "Run the command" |
| 28 | + status := LibC uniqueInstance system: cloneCommand. |
| 29 | + |
| 30 | + "Verify success" |
| 31 | + status = 0 |
| 32 | + ifTrue: [ |
| 33 | + self logInTranscript: |
| 34 | + 'Tree Sitter YAML successfully cloned to: ' , clonePath ] |
| 35 | + ifFalse: [ |
| 36 | + self logInTranscript: |
| 37 | + 'Tree Sitter YAML clone failed with exit code: ' |
| 38 | + , status asString ] |
| 39 | +] |
| 40 | + |
| 41 | +{ #category : 'as yet unclassified' } |
| 42 | +TSLibrariesYAML >> ensureYAMLLibraryExists [ |
| 43 | + |
| 44 | + self yamlLibraryExists ifFalse: [ |
| 45 | + self yamlLibraryExistsInDocuments ifFalse: [ |
| 46 | + self |
| 47 | + cloneTreeSitterYAML ; |
| 48 | + generateTreeSitterYAMLLibraries ]. |
| 49 | + self moveYAMLLibraryToPharoVM ] |
| 50 | +] |
| 51 | + |
| 52 | +{ #category : 'as yet unclassified' } |
| 53 | +TSLibrariesYAML >> generateTreeSitterYAMLLibraries [ |
| 54 | + |
| 55 | + | command status cmdLines | |
| 56 | + cmdLines := TSLibrariesCommandLinesYAML new. |
| 57 | + self isMacOS |
| 58 | + ifTrue: [ command := cmdLines cmdMacTreeSitterYAML ] |
| 59 | + ifFalse: [ |
| 60 | + self isWindows |
| 61 | + ifTrue: [ command := cmdLines cmdWindowsTreeSitterYAML ] |
| 62 | + ifFalse: [ command := cmdLines cmdLinuxTreeSitterYAML ] ]. |
| 63 | + |
| 64 | + self logInTranscript: 'Start generating Tree Sitter YAML library'. |
| 65 | + |
| 66 | + "Run the command" |
| 67 | + status := LibC uniqueInstance system: command. |
| 68 | + |
| 69 | + self logInTranscript: |
| 70 | + 'Tree Sitter YAML library generation command is finished'. |
| 71 | + |
| 72 | + "Verify success" |
| 73 | + status = 0 |
| 74 | + ifTrue: [ |
| 75 | + self logInTranscript: |
| 76 | + 'Tree Sitter YAML library generated successfully' ] |
| 77 | + ifFalse: [ |
| 78 | + Error signal: |
| 79 | + 'Tree Sitter YAML library was not generated successfully' ]. |
| 80 | + |
| 81 | + status := 0. |
| 82 | + |
| 83 | + ^ status |
| 84 | +] |
| 85 | + |
| 86 | +{ #category : 'as yet unclassified' } |
| 87 | +TSLibrariesYAML >> moveYAMLLibraryToPharoVM [ |
| 88 | + |
| 89 | + self moveLibrary: self yamlLibraryName from: '/tree-sitter-YAML/' |
| 90 | +] |
| 91 | + |
| 92 | +{ #category : 'as yet unclassified' } |
| 93 | +TSLibrariesYAML >> yamlLibraryExists [ |
| 94 | + |
| 95 | + ^ (self vmLibrariesDirectory / self yamlLibraryName) |
| 96 | + asFileReference exists |
| 97 | +] |
| 98 | + |
| 99 | +{ #category : 'as yet unclassified' } |
| 100 | +TSLibrariesYAML >> yamlLibraryExistsInDocuments [ |
| 101 | + |
| 102 | + ^ (self originalLibrariesDirectory asFileReference / self yamlLibraryName) |
| 103 | + asFileReference exists |
| 104 | +] |
| 105 | + |
| 106 | +{ #category : 'as yet unclassified' } |
| 107 | +TSLibrariesYAML >> yamlLibraryName [ |
| 108 | + |
| 109 | + ^ self libraryName: 'libtree-sitter-yaml'. |
| 110 | +] |
0 commit comments