-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3c5b6d0
Showing
4 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
spm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Makoto Tajitsu | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# SPM | ||
|
||
Salesforce Package Manager | ||
|
||
## Install | ||
|
||
Download binary file and copy it to executable path. | ||
|
||
If you want to use latest version, execute following command. | ||
|
||
```bash | ||
$ go get github.com/tzmfreedom/spm | ||
``` | ||
|
||
## Usage | ||
|
||
Install Package | ||
|
||
```bash | ||
$ spm install github.com/tzmfreedom/apex-util | ||
Enter Username: {USERNAME} | ||
Enter Password: {PASSWORD} | ||
Production/Developer?(y/n): y | ||
``` | ||
|
||
```bash | ||
$ spm install -c package.yml | ||
Enter Username: {USERNAME} | ||
Enter Password: {PASSWORD} | ||
Production/Developer?(y/n): y | ||
``` | ||
|
||
Package.yml format | ||
|
||
```yaml | ||
packages: | ||
- github.com/tzmfreedom/apex-util1 | ||
- github.com/tzmfreedom/apex-util2 | ||
- github.com/tzmfreedom/apex-util3 | ||
``` | ||
UnInstall Package | ||
```bash | ||
$ spm uninstall github.com/tzmfreedom/apex-util | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"fmt" | ||
"io" | ||
|
||
"github.com/urfave/cli" | ||
"gopkg.in/src-d/go-git.v4" | ||
) | ||
|
||
type Config struct { | ||
username string | ||
password string | ||
endpoint string | ||
api_version string | ||
} | ||
|
||
func main() { | ||
app := cli.NewApp() | ||
app.Name = "spm" | ||
app.Usage = "salesforce package manager" | ||
app.Commands = []cli.Command{ | ||
{ | ||
Name: "install", | ||
Aliases: []string{"i"}, | ||
Usage: "install salesforce package", | ||
//Flags: []cli.Flag { | ||
// cli.StringFlag{ | ||
// Name: "lang, l", | ||
// Value: "english", | ||
// Usage: "language for the greeting", | ||
// }, | ||
//}, | ||
Action: func(c *cli.Context) error { | ||
var username string | ||
var password string | ||
fmt.Print("Enter Username: ") | ||
fmt.Scanln(&username) | ||
fmt.Printf("Enter Password: ") | ||
fmt.Scanln(&password) | ||
fmt.Printf("%q %q", username, password) | ||
os.Exit(0) | ||
|
||
install("https://" + c.Args().First(), nil) | ||
return nil | ||
}, | ||
}, | ||
} | ||
|
||
app.Run(os.Args) | ||
} | ||
|
||
func install(url string, options []string) { | ||
cloneFromRemoteRepository(url, url, options) | ||
deployToSalesforce(url, Config{}) | ||
} | ||
|
||
func cloneFromRemoteRepository(directory string, url string, option []string) { | ||
r, err := git.NewFilesystemRepository(directory) | ||
err = r.Clone(&git.CloneOptions{ | ||
URL: url, | ||
}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// ... retrieving the branch being pointed by HEAD | ||
ref, _ := r.Head() | ||
|
||
// ... retrieving the commit object | ||
commit, _ := r.Commit(ref.Hash()) | ||
|
||
// ... we get all the files from the commit | ||
files, _ := commit.Files() | ||
|
||
_, err = r.Head() | ||
err = files.ForEach(func(f *git.File) error { | ||
abs := filepath.Join(directory, f.Name) | ||
dir := filepath.Dir(abs) | ||
|
||
os.MkdirAll(dir, 0777) | ||
file, err := os.Create(abs) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
defer file.Close() | ||
r, err := f.Reader() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
defer r.Close() | ||
|
||
if err := file.Chmod(f.Mode); err != nil { | ||
return err | ||
} | ||
|
||
_, err = io.Copy(file, r) | ||
return err | ||
}) | ||
} | ||
|
||
func deployToSalesforce(directory string, config Config) { | ||
|
||
} |