Skip to content

Fix build scripts #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
## Contributing


Thanks for taking an insterest in contributing to the PowerShell package for
Sublime Text 3!

Expand All @@ -11,6 +10,32 @@ Development happens on the **dev** branch. Please send your PRs against that
branch only.


### Building Development Versions

To build development versions, first you need a configuration file in
`$env:USERPROFILE\sublime-package-dev.json`.

This file must contain the following information:

{
"pathToSublimeText": "...\sublime_text.exe",
"pathToSublimeTextData": "...\
}


#### Using Sublime Text

1. Press <kbd>Ctrl+Shift+B</kbd> to open the build systems menu.
2. Select 'PowerShell: Build Dev Version'


#### Using the Command Line

From the project's root:

.\bin\BuildFolder.ps1 -verbose


#### Running Tests

If you are adding functionality or making substantial changes to existing
Expand All @@ -20,12 +45,3 @@ Currently, we have very few tests and they aren't easy to run... :-(

If you feel lazy about writing tests, this is the right time to contribute --
we'll turn a blind eye more often now than later on! ;-)


### Building Versions

The easiest way to 'build' a version now consists in copying the project's
root folder's content to your *Data/Packages/PowerShell* directory.

We have build scripts under *.\bin*, but they aren't realiable. We hope to fix
that soon.
4 changes: 2 additions & 2 deletions PowerShell.sublime-project
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

"build_systems": [
{
"name": "Run",
"shell_cmd": "powershell.exe -noninteractive -file $project_path/bin/Build-Folder.ps1"
"name": "PowerShell: Build Dev Version",
"shell_cmd": "powershell.exe -noninteractive -file $project_path/bin/BuildFolder.ps1"
}
]
}
54 changes: 0 additions & 54 deletions bin/Build-Folder.ps1

This file was deleted.

32 changes: 0 additions & 32 deletions bin/Build.ps1

This file was deleted.

54 changes: 54 additions & 0 deletions bin/BuildFolder.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<#
.SYNOPSIS
Builds a version of the Sublime Text PowerShell package and deploys it
locally to Data/Packages/PowerShell.

.DESCRIPTION
Builds a version of the Sublime Text PowerShell package and deploys it
locally to Data/Packages/PowerShell.

Requires a configuration file in ~\.sublime-package-dev.json.

This file must contain the following keys:

{
"pathToSublimeText": ...\sublime_text.exe,
"pathToSublimeTextData": ...
}
#>
[CmdletBinding()]
param([switch]$Release)

. $PSScriptRoot\Config.ps1

$pathToInstalledPackages = join-path (GetConfigValue pathToSublimeTextData) 'Installed Packages'
test-path $pathToInstalledPackages -erroraction stop > $null
$pathToPackages = join-path (GetConfigValue pathToSublimeTextData) 'Packages'
test-path $pathToPackages -erroraction stop > $null
$pathToPowerShellPackage = join-path $pathToPackages 'PowerShell'

# Deploy package locally.
push-location $PSScriptRoot\..
if (test-path $pathToPowerShellPackage) {
write-verbose "Deleting old files..."
remove-item $pathToPowerShellPackage\* -recurse
}
else {
write-verbose "Creating target directory..."
new-item -itemtype directory $pathToPowerShellPackage
}
write-verbose "Copying files..."
copy-item * -recurse -exclude 'dist' $pathToPowerShellPackage
pop-location

# Restart editor.
write-verbose "Restarting editor..."
get-process sublime_text -erroraction silentlycontinue | stop-process -erroraction silentlycontinue
start-sleep -milliseconds 250

$editor = GetConfigValue pathToSublimeText
if(!(test-path $editor -erroraction stop)){
write-error "Could not locate editor executable in '$editor'."
exit 1
}
& $editor
10 changes: 0 additions & 10 deletions bin/CleanUp.ps1

This file was deleted.

40 changes: 11 additions & 29 deletions bin/Config.ps1
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
# Helpers to read files in this format:
#
# global-win editor path/to/some/bin
# project-foo deploy-url http://some/url/here
# ...
# Helpers to read files in json.

function GetConfig {
$path = "~/.sublime-package-dev"
$script:pathToConfig = "~/.sublime-package-dev.json"

if(!(test-path $path)){
write-error "Could not find personal configuration in $path."
exit 1
}
get-content $path
}
function GetConfigData {
if(!(test-path $pathToConfig)){
write-error "Could not find configuration file '$pathToConfig'."
exit 1
}

$script:configData = GetConfig
return (get-content $pathToConfig) -join "`n" | convertfrom-json
}

function GetConfigValue {
param($section, $key)
$section = $section.ToLower()
$key = $key.ToLower()
foreach($item in $configData){
if(!$item.Trim()){
continue
}
$s, $k, $v = $item.ToLower() -split ' ',3
if(($s -eq $section) -and ($k -eq $key)){
if(!$v){
throw "No value found for '${section}:$key'."
}
return $v
}
}
param($key)
return (GetConfigData).$key
}
20 changes: 0 additions & 20 deletions bin/MakeRelease.ps1

This file was deleted.

46 changes: 0 additions & 46 deletions bin/Publish.ps1

This file was deleted.