forked from revel/revel
/
package.go
51 lines (39 loc) · 1.07 KB
/
package.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"github.com/robfig/revel"
"io/ioutil"
"os"
"path"
)
var cmdPackage = &Command{
UsageLine: "package [import path]",
Short: "package a Revel application (e.g. for deployment)",
Long: `
Package the Revel web application named by the given import path.
This allows it to be deployed and run on a machine that lacks a Go installation.
For example:
revel package github.com/robfig/revel/samples/chat
`,
}
func init() {
cmdPackage.Run = packageApp
}
func packageApp(args []string) {
if len(args) == 0 {
fmt.Fprint(os.Stderr, cmdPackage.Long)
return
}
appImportPath := args[0]
revel.Init("", appImportPath, "")
// Remove the archive if it already exists.
destFile := path.Base(revel.BasePath) + ".tar.gz"
os.Remove(destFile)
// Collect stuff in a temp directory.
tmpDir, err := ioutil.TempDir("", path.Base(revel.BasePath))
panicOnError(err, "Failed to get temp dir")
buildApp([]string{args[0], tmpDir})
// Create the zip file.
archiveName := mustTarGzDir(destFile, tmpDir)
fmt.Println("Your archive is ready:", archiveName)
}